Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 26, 2008, 12:59:48 AM (16 years ago)
Author:
scheusso
Message:

Fix in Projectiles (network fix)
different improvements in synchronisable and gamestates

File:
1 edited

Legend:

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

    r1827 r1834  
    4444#define REGISTERSTRING_WITHDIR(stringname, mode) registerVar(&stringname, stringname.length()+1, network::STRING, mode)
    4545
     46//TODO: this is only a very ugly hack ...
     47namespace orxonox{
     48class SpaceShip;
     49}
     50
    4651namespace network
    4752{
     
    7580  }SYNCVAR;
    7681
    77 
    7882  /**
    7983  * This class is the base class of all the Objects in the universe that need to be synchronised over the network
     
    8387  class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{
    8488  public:
     89    friend class packet::Gamestate;
     90    friend class GamestateClient;
     91    friend class Server;
     92    friend class orxonox::SpaceShip;
     93    virtual ~Synchronisable();
     94
    8595   
    86     virtual ~Synchronisable();
    87     unsigned int objectID;
    88     unsigned int classID;
    89 
    90     bool getData(unsigned char*& men, unsigned int id, int mode=0x0);
    91     int getSize(unsigned int id, int mode=0x0);
    92     bool updateData(unsigned char*& mem, int mode=0x0);
    93     bool isMyData(unsigned char* mem);
    94     bool doSelection(unsigned int id);
    95     void setObjectMode(int mode);
    96     void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
    97    
    98     virtual void registerAllVariables()=0;
    9996    virtual bool create();
    10097    static void setClient(bool b);
     
    106103    static unsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
    107104   
    108    
     105    inline unsigned int getObjectID(){return objectID;}
     106    inline unsigned int getClassID(){return classID;}
    109107  protected:
    110108    Synchronisable();
    111109    void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
     110    void setObjectMode(int mode);
     111    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
     112    virtual void registerAllVariables()=0;
     113   
     114   
    112115  private:
     116    bool getData(unsigned char*& men, unsigned int id, int mode=0x0);
     117    int getSize(unsigned int id, int mode=0x0);
     118    bool updateData(unsigned char*& mem, int mode=0x0);
     119    bool isMyData(unsigned char* mem);
     120    bool doSelection(unsigned int id);
    113121    bool isMyTick(unsigned int id);
     122   
     123    unsigned int objectID;
     124    unsigned int classID;
     125   
    114126    std::list<synchronisableVariable *> *syncList;
    115     int datasize;
    116127    static int state_; // detemines wheter we are server (default) or client
    117128    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
Note: See TracChangeset for help on using the changeset viewer.