Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 400 was 385, checked in by scheusso, 17 years ago

extended GameStateManager:
added functions

  • encode (takes two gamestates and returns a diffed and compressed gamestate)
  • decode (opposite of encode)
  • compress (called by encode) — not yet implemented
  • decompress (called by decode) — not yet implemented
  • diff (called by en/decode)
File size: 1.4 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 "Synchronisable.h"
16#include "orxonox/core/IdentifierIncludes.h"
17#include "orxonox/core/Iterator.h"
18
19namespace network {
20
21/**
22 * This struct defines a gamestate:
23 * size: total size of the data in *data
24 * data: pointer to the data allocated in the memory
25 */
26  struct GameState{
27  int id;
28  int size;
29  unsigned char *data;
30};
31
32/**
33 * This Class implements a manager for gamestates:
34 * - creating snapshots of gamestates
35 * - writing gamestates to universe
36 * - diffing gamestates ?
37 *
38 * EN/DECODATION:
39 * a: last Gamestate a client has received
40 * b: new Gamestate
41 * x: diffed and compressed gamestate
42 * x=(a^b)
43 * b=(a^x)
44 * diff(a,diff(a,x))=x (hope this is correct)
45 * @author Oliver Scheuss
46*/
47class GameStateManager{
48public:
49  GameStateManager();
50  ~GameStateManager();
51  GameState getSnapshot(int id);
52  bool loadSnapshot(GameState state);
53  GameState encode(GameState a, GameState b);
54  GameState decode(GameState a, GameState x);
55private:
56  void removeObject(orxonox::Iterator<Synchronisable> &it);
57  GameState diff(GameState a, GameState b);
58  GameState compress(GameState a);
59  GameState decompress(GameState a);
60};
61
62}
63
64#endif
Note: See TracBrowser for help on using the repository browser.