Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1087 was 1007, checked in by scheusso, 16 years ago

forgot something

File size: 1.8 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    void cleanup(); // "garbage handler"
54    GameState *getSnapshot(int id);
55    GameStateCompressed *encode(GameState *a, GameState *b);
56    GameStateCompressed *encode(GameState *a);
57    GameState *diff(GameState *a, GameState *b);
58    GameStateCompressed *compress_(GameState *a);
59    bool deleteUnusedGameState(int gamestateID);
60
61    std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
62    std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
63    GameState *reference;
64    ClientInformation *head_;
65  };
66
67}
68
69#endif /* _GameStateManager_H__ */
Note: See TracBrowser for help on using the repository browser.