Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/GameStateManager.h @ 984

Last change on this file since 984 was 984, checked in by dumenim, 16 years ago

some bugfix in GameStateManager.cc, CMakeLists now generates networktest executable, some test functions added

File size: 1.7 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 _GameStateManager_H__
13#define _GameStateManager_H__
14
15#include <map>
16
17#include "NetworkPrereqs.h"
18#include "PacketTypes.h"
19
20namespace network
21{
22
23#define KEEP_GAMESTATES 20
24
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    //#### ADDED FOR TESTING PURPOSE ####
45    GameStateCompressed* testCompress( GameState* g );
46    GameState* testDiff( GameState* a, GameState* b );
47    //#### END TESTING PURPOSE ####
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 gamestate
62    GameState *reference;
63    ClientInformation *head_;
64  };
65
66}
67
68#endif /* _GameStateManager_H__ */
Note: See TracBrowser for help on using the repository browser.