Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 403 was 403, checked in by dumenim, 17 years ago

compressed gamestates

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 "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 struct defines a gamestate:
34 * compsize is the size of the compressed data
35 * normsize is the size of the uncompressed data
36 * data are the gamestates
37 */
38  struct GameStateCompressed{
39        int id; 
40        int compsize;
41        int normsize;
42        unsigned char *data;
43  };
44
45/**
46 * This Class implements a manager for gamestates:
47 * - creating snapshots of gamestates
48 * - writing gamestates to universe
49 * - diffing gamestates ?
50 *
51 * EN/DECODATION:
52 * a: last Gamestate a client has received
53 * b: new Gamestate
54 * x: diffed and compressed gamestate
55 * x=(a^b)
56 * b=(a^x)
57 * diff(a,diff(a,x))=x (hope this is correct)
58 * @author Oliver Scheuss
59*/
60class GameStateManager{
61public:
62  GameStateManager();
63  ~GameStateManager();
64  GameState getSnapshot(int id);
65  bool loadSnapshot(GameState state);
66  GameState encode(GameState a, GameState b);
67  GameState decode(GameState a, GameState x);
68private:
69  void removeObject(orxonox::Iterator<Synchronisable> &it);
70  GameState diff(GameState a, GameState b);
71  GameState compress(GameState a);
72  GameState decompress(GameState a);
73};
74
75}
76
77#endif
Note: See TracBrowser for help on using the repository browser.