[247] | 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 | |
---|
[413] | 15 | #include <vector> |
---|
| 16 | |
---|
| 17 | #include "zlib.h" |
---|
| 18 | |
---|
[332] | 19 | #include "Synchronisable.h" |
---|
| 20 | #include "orxonox/core/IdentifierIncludes.h" |
---|
| 21 | #include "orxonox/core/Iterator.h" |
---|
[415] | 22 | #include "PacketTypes.h" |
---|
[332] | 23 | |
---|
[247] | 24 | namespace network { |
---|
| 25 | |
---|
| 26 | |
---|
[403] | 27 | |
---|
| 28 | /** |
---|
[247] | 29 | * This Class implements a manager for gamestates: |
---|
| 30 | * - creating snapshots of gamestates |
---|
| 31 | * - writing gamestates to universe |
---|
| 32 | * - diffing gamestates ? |
---|
[385] | 33 | * |
---|
| 34 | * EN/DECODATION: |
---|
| 35 | * a: last Gamestate a client has received |
---|
| 36 | * b: new Gamestate |
---|
| 37 | * x: diffed and compressed gamestate |
---|
| 38 | * x=(a^b) |
---|
| 39 | * b=(a^x) |
---|
| 40 | * diff(a,diff(a,x))=x (hope this is correct) |
---|
[247] | 41 | * @author Oliver Scheuss |
---|
| 42 | */ |
---|
| 43 | class GameStateManager{ |
---|
| 44 | public: |
---|
| 45 | GameStateManager(); |
---|
| 46 | ~GameStateManager(); |
---|
[413] | 47 | void update(); |
---|
| 48 | GameStateCompressed popGameState(int clientID); |
---|
[422] | 49 | void ackGameState(int clientID, int gamestateID); |
---|
[425] | 50 | void removeClient(int clientID); |
---|
[247] | 51 | private: |
---|
[422] | 52 | GameState *getSnapshot(int id); |
---|
[413] | 53 | GameStateCompressed encode(GameState *a, GameState *b); |
---|
| 54 | GameState diff(GameState *a, GameState *b); |
---|
| 55 | GameStateCompressed compress_(GameState a); |
---|
[422] | 56 | bool deleteUnusedGameState(GameState *state); |
---|
[413] | 57 | |
---|
| 58 | std::vector<GameState *> clientGameState; |
---|
[422] | 59 | std::vector<GameState *> idGameState; |
---|
| 60 | GameState *reference; |
---|
[413] | 61 | int id; |
---|
[247] | 62 | }; |
---|
| 63 | |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | #endif |
---|