Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/Synchronisable.h @ 247

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

added GameStateManager class:

  • gets snapshots of the universe (gamestate) and returns them
  • processes snapshots and loads them to the universe

modified Synchronisable

  • added a function getData(usigned char *data), which puts the data to

the already given pointer (more efficient memory handling for the
GameState class)

  • added a function getSize(), which tells you the total size of the

current gamestate (so that you can allocate enough memory and give it to
getData

File size: 1.2 KB
Line 
1//
2// C++ Interface: synchronisable
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_SYNCHRONISABLE_H
13#define NETWORK_SYNCHRONISABLE_H
14
15#include <list>
16
17namespace network {
18
19 
20struct syncData{
21  int length;
22  int classID;
23  int objectID;
24  unsigned char *data;
25};
26
27typedef struct synchronisableVariable{
28  int size;
29  const void *var;
30}SYNCVAR;
31
32 
33/**
34 * This class is the base class of all the Objects in the universe that need to be synchronised over the network
35 * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list.
36 * @author Oliver Scheuss
37*/
38class Synchronisable{
39public:
40  Synchronisable();
41
42  ~Synchronisable();
43  int objectID;
44  int classID;
45   
46  void registerVar(const void *var, int size);
47  syncData getData();
48  syncData getData(unsigned char *mem);
49  int getSize();
50  bool updateData(syncData vars);
51  virtual void registerAllVariables();
52
53private:
54  std::list<SYNCVAR> syncList;
55  int datasize;
56};
57
58}
59
60#endif
Note: See TracBrowser for help on using the repository browser.