Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2008, 5:12:31 PM (16 years ago)
Author:
scheusso
Message:

bidirectional synchronisation works now:
register variables with mode direction::serverMaster or direction::clientMaster
clientMaster: both sides may change the variable but the client is master
serverMaster: both sides may change the variable but the server is master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/Synchronisable.h

    r2112 r2132  
    6262  namespace syncmode{
    6363    enum mode{
    64       one=0,
     64      once=0,
    6565      always=1
    6666    };
     
    8181
    8282  struct _NetworkExport synchronisableVariable{
    83     unsigned int size;
    84     int mode; // this determines in which direction the variable gets synchronised
     83    size_t size;
     84    uint8_t mode; // this determines in which direction the variable gets synchronised
    8585    void *var;
    8686    variableType type;
     
    9898  public:
    9999    friend class packet::Gamestate;
    100     friend class GamestateClient;
    101     friend class Server;
     100//     friend class Server;
    102101    virtual ~Synchronisable();
    103102
     
    106105    static void setClient(bool b);
    107106
    108     static Synchronisable *fabricate(uint8_t*& mem, int mode=0x0);
     107    static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0);
    109108    static bool deleteObject(unsigned int objectID);
    110109    static Synchronisable *getSynchronisable(unsigned int objectID);
     
    116115  protected:
    117116    Synchronisable(BaseObject* creator);
    118     void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
    119     void setObjectMode(int mode);
     117    void registerVar(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
     118    void setObjectMode(uint8_t mode);
    120119    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
    121120
    122121
    123122  private:
    124     bool getData(uint8_t*& men, unsigned int id, int mode=0x0);
    125     uint32_t getSize(unsigned int id, int mode=0x0);
    126     bool updateData(uint8_t*& mem, int mode=0x0, bool forceCallback=false);
     123    bool getData(uint8_t*& men, unsigned int id, uint8_t mode=0x0);
     124    uint32_t getSize(unsigned int id, uint8_t mode=0x0);
     125    bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
    127126    bool isMyData(uint8_t* mem);
    128127    bool doSelection(unsigned int id);
    129     bool doSync(unsigned int id);
     128    bool doSync(unsigned int id, uint8_t mode=0x0);
    130129
    131130    unsigned int objectID;
     
    134133
    135134    std::list<synchronisableVariable *> *syncList;
    136     static int state_; // detemines wheter we are server (default) or client
     135    static uint8_t state_; // detemines wheter we are server (default) or client
    137136    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
    138137    unsigned int objectFrequency_;
Note: See TracChangeset for help on using the changeset viewer.