Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/GameStateManager.h @ 620

Last change on this file since 620 was 496, checked in by landauf, 17 years ago

added files from objecthierarchy, changed includes

File size: 1.6 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 NETWORK_GAMESTATEMANAGER_H
13#define NETWORK_GAMESTATEMANAGER_H
14
15#include <map>
16
17#include "zlib.h"
18
19#include "ClientInformation.h"
20#include "Synchronisable.h"
21#include "orxonox/core/CoreIncludes.h"
22#include "orxonox/core/Iterator.h"
23#include "PacketTypes.h"
24
25namespace network {
26
27#define KEEP_GAMESTATES 20
28
29/**
30 * This Class implements a manager for gamestates:
31 * - creating snapshots of gamestates
32 * - writing gamestates to universe
33 * - diffing gamestates ?
34 *
35 * EN/DECODATION:
36 * a: last Gamestate a client has received
37 * b: new Gamestate
38 * x: diffed and compressed gamestate
39 * x=(a^b)
40 * b=(a^x)
41 * diff(a,diff(a,x))=x (hope this is correct)
42 * @author Oliver Scheuss
43*/
44class GameStateManager{
45public:
46  GameStateManager(ClientInformation *head);
47  ~GameStateManager();
48  void update();
49  GameStateCompressed popGameState(int clientID);
50  void ackGameState(int clientID, int gamestateID);
51private:
52  GameState *getSnapshot(int id);
53  GameStateCompressed encode(GameState *a, GameState *b);
54  GameStateCompressed encode(GameState *a);
55  GameState diff(GameState *a, GameState *b);
56  GameStateCompressed compress_(GameState *a);
57  bool deleteUnusedGameState(int gamestateID);
58 
59  std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
60  std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
61  GameState *reference;
62  int id;
63  ClientInformation *head_;
64};
65
66}
67
68#endif
Note: See TracBrowser for help on using the repository browser.