Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud/src/network/GameStateManager.h @ 842

Last change on this file since 842 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

File size: 1.5 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    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  };
61
62}
63
64#endif /* _GameStateManager_H__ */
Note: See TracBrowser for help on using the repository browser.