Changeset 777 for code/branches/FICN/src/network/GameStateManager.h
- Timestamp:
- Dec 31, 2007, 7:40:23 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/GameStateManager.h
r774 r777 15 15 #include <map> 16 16 17 #include "zlib.h" 18 19 #include "ClientInformation.h" 20 #include "Synchronisable.h" 21 #include "core/CoreIncludes.h" 22 #include "core/Iterator.h" 17 #include "NetworkPrereqs.h" 23 18 #include "PacketTypes.h" 24 19 25 namespace network { 20 namespace network 21 { 26 22 27 23 #define KEEP_GAMESTATES 20 28 24 29 /**30 * This Class implements a manager for gamestates:31 * - creating snapshots of gamestates32 * - writing gamestates to universe33 * - diffing gamestates ?34 *35 * EN/DECODATION:36 * a: last Gamestate a client has received37 * b: new Gamestate38 * x: diffed and compressed gamestate39 * x=(a^b)40 * b=(a^x)41 * diff(a,diff(a,x))=x (hope this is correct)42 * @author Oliver Scheuss43 */44 class GameStateManager{45 public:46 GameStateManager(ClientInformation *head);47 ~GameStateManager();48 void update();49 GameStateCompressed popGameState(int clientID);50 void ackGameState(int clientID, int gamestateID);51 int id;52 private: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 gamestate62 GameState *reference;63 ClientInformation *head_;64 };25 /** 26 * This Class implements a manager for gamestates: 27 * - creating snapshots of gamestates 28 * - writing gamestates to universe 29 * - diffing gamestates ? 30 * 31 * EN/DECODATION: 32 * a: last Gamestate a client has received 33 * b: new Gamestate 34 * x: diffed and compressed gamestate 35 * x=(a^b) 36 * b=(a^x) 37 * diff(a,diff(a,x))=x (hope this is correct) 38 * @author Oliver Scheuss 39 */ 40 class GameStateManager{ 41 public: 42 GameStateManager(ClientInformation *head); 43 ~GameStateManager(); 44 void update(); 45 GameStateCompressed popGameState(int clientID); 46 void ackGameState(int clientID, int gamestateID); 47 int id; 48 private: 49 GameState *getSnapshot(int id); 50 GameStateCompressed encode(GameState *a, GameState *b); 51 GameStateCompressed encode(GameState *a); 52 GameState diff(GameState *a, GameState *b); 53 GameStateCompressed compress_(GameState *a); 54 bool deleteUnusedGameState(int gamestateID); 55 56 std::map<int, GameState*> gameStateMap; //map gsID to gamestate* 57 std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate 58 GameState *reference; 59 ClientInformation *head_; 60 }; 65 61 66 62 }
Note: See TracChangeset
for help on using the changeset viewer.