Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/GameStateManager.h @ 632

Last change on this file since 632 was 624, checked in by scheusso, 17 years ago

changes in gamestatehandling

File size: 1.6 KB
Line 
1//
2// C++ Interface: GameStateManager
3//
4// Description:
5//
6//
7// Author:  Oliver Scheuss, (C) 2007
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#ifndef NETWORK_GAMESTATEMANAGER_H
13#define NETWORK_GAMESTATEMANAGER_H
14
15#include <map>
16
17#include "zlib.h"
18
19#include "ClientInformation.h"
20#include "Synchronisable.h"
21#include "orxonox/core/CoreIncludes.h"
22#include "orxonox/core/Iterator.h"
23#include "PacketTypes.h"
24
25namespace network {
26
27#define KEEP_GAMESTATES 20
28
29/**
30 * This Class implements a manager for gamestates:
31 * - creating snapshots of gamestates
32 * - writing gamestates to universe
33 * - diffing gamestates ?
34 *
35 * EN/DECODATION:
36 * a: last Gamestate a client has received
37 * b: new Gamestate
38 * x: diffed and compressed gamestate
39 * x=(a^b)
40 * b=(a^x)
41 * diff(a,diff(a,x))=x (hope this is correct)
42 * @author Oliver Scheuss
43*/
44class GameStateManager{
45public:
46  GameStateManager(ClientInformation *head);
47  ~GameStateManager();
48  void update();
49  GameStateCompressed popGameState(int clientID);
50  void ackGameState(int clientID, int gamestateID);
51  int id;
52private:
53  GameState *getSnapshot(int id);
54  GameStateCompressed encode(GameState *a, GameState *b);
55  GameStateCompressed encode(GameState *a);
56  GameState diff(GameState *a, GameState *b);
57  GameStateCompressed compress_(GameState *a);
58  bool deleteUnusedGameState(int gamestateID);
59 
60  std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
61  std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
62  GameState *reference;
63  ClientInformation *head_;
64};
65
66}
67
68#endif
Note: See TracBrowser for help on using the repository browser.