Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 30, 2005, 1:52:26 AM (18 years ago)
Author:
bensch
Message:

orxonox/branches/newtork: merged the network branche for merging to the trunk
confilcts maily resolved in favor of trunk with some minor fixes

merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/network . -r6146:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network_merged/src/lib/network/network_game_manager.h

    r6139 r6340  
    1414
    1515
     16class TiXmlElement;
    1617
    1718/**
    1819 * protocol definition
    1920 *
    20  *  CREATE_ENTITY:      CLASS_ID, UNIQUE_ID, OWNER
    21  *  REMOVE_ENTITY:      UNIQUE_ID
     21 *  CREATE_ENTITY:       CLASS_ID, UNIQUE_ID, OWNER
     22 *  REMOVE_ENTITY:       UNIQUE_ID
    2223 *
    23  *  CREATE_ENTITY_LIST: NUMBER, [CLASS_ID, UNIQUE_ID, OWNER][0..NUMBER]
    24  *  REMOVE_ENTITY_LIST: NUMBER, [UNIQUE_ID][0..NUMBER]
     24 *  CREATE_ENTITY_LIST:  NUMBER, [CLASS_ID, UNIQUE_ID, OWNER][0..NUMBER]
     25 *  REMOVE_ENTITY_LIST:  NUMBER, [UNIQUE_ID][0..NUMBER]
    2526 *
    26  *  REQUEST_CREATE:     CLASS_ID
    27  *  REQUEST_REMOVE:     UNIQUE_ID
     27 *  REQUEST_CREATE:      CLASS_ID
     28 *  REQUEST_REMOVE:      UNIQUE_ID
    2829 *
    29  *  REQUEST_SYNC:       UNIQUE_ID
    30  *  REQUEST_SYNC_LIST: NUMBER, [UNIQUE_ID][0..NUMBER]
     30 *  //REQUEST_CREATE_LIST: NUMBER, [CLASS_ID][0..NUMBER]
     31 *  //REQUEST_CREATE_LIST: NUMBER, [UNIQUE_ID][0..NUMBER]
    3132 *
     33 *  REQUEST_ENTITY_LIST: //request the whole world :D
     34 *  REQUEST_SYNC:        UNIQUE_ID
     35 *  //REQUEST_SYNC_LIST:   NUMBER, [UNIQUE_ID][0..NUMBER]
     36 *
     37 *  YOU_ARE_ENTITY:      UNIQUE_ID
    3238 *
    3339 */
    3440
     41typedef enum NetworkGameManagerProtocol{
     42  CREATE_ENTITY = 0,
     43  REMOVE_ENTITY,
     44  CREATE_ENTITY_LIST,
     45  REMOVE_ENTITY_LIST,
     46  REQUEST_CREATE,
     47  REQUEST_REMOVE,
     48  REQUEST_SYNC,
     49  YOU_ARE_ENTITY,
     50  REQUEST_ENTITY_LIST
     51};
    3552
    36 
    37 
    38 
    39 
    40 
    41 
    42 
     53struct clientBuffer
     54{
     55  int length;
     56  int maxLength;
     57  byte * buffer;
     58};
    4359
    4460/*!
     
    4864{
    4965  public:
    50     NetworkGameManager();
    5166    ~NetworkGameManager();
    5267
    53     virtual void writeBytes(const byte* data, int length);
     68    static NetworkGameManager* NetworkGameManager::getInstance()
     69    { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
     70
     71    virtual int writeBytes(const byte* data, int length, int sender);
    5472    virtual int readBytes(byte* data, int maxLength, int * reciever);
    5573    virtual void writeDebug() const;
    5674    virtual void readDebug() const;
    5775
    58     void createEntity(int classID);
    59     void createEntityList(int* classIDList);
    60     void removeEntity(int uniqueID);
    61     void removeEntityList(int* uniqueIDList);
     76    void createEntity( ClassID classID, int owner = 0 );
     77    BaseObject* createEntity( TiXmlElement* element);
     78    void removeEntity( int uniqueID );
     79    void sendYouAre( int uniqueID, int userID );
    6280
    63     void sync(int uniqueID);
    64     void syncList(int* uniqueIDList);
     81    void sync(int uniqueID, int owner);
    6582
     83    void sendEntityList(int userID);
    6684
    6785  private:
    68     void requestCreateEntity(int classID);
    69     void executeCreateEntity(int classID);
    70     void requestCreateEntityList(int* classIDList);
    71     void executeCreateEntityList(int* classIDList);
     86    NetworkGameManager();
     87
     88    void requestCreateEntity(ClassID classID);
     89    void executeCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0);
    7290
    7391    void requestRemoveEntity(int uniqueID);
    7492    void executeRemoveEntity(int uniqueID);
    75     void requestRemoveEntityList(int* uniqueIDList);
    76     void executeRemoveEntityList(int* uniqueIDList);
    7793
     94    void executeRequestSync( int uniqueID, int user );
    7895
     96    void doCreateEntity(ClassID classID, int uniqueID, int owner);
     97    void doRemoveEntity(int uniqueID);
     98    void doRequestSync(int uniqueID, int userID);
     99    void doYouAre( int uniqueID );
    79100
    80     bool canCreateEntity(int classID);
     101    bool canCreateEntity(ClassID classID);
    81102
     103    void resizeBufferVector(int n);
    82104
     105    inline bool writeToClientBuffer( clientBuffer &cb, byte*data, int length );
     106    inline bool writeToClientBuffer( clientBuffer &cb, byte b );
     107    inline bool writeToClientBuffer( clientBuffer &cb, int i );
     108    inline bool readFromClientBuffer( clientBuffer &cb, byte*data, int length );
     109
     110    //helper functions for writeBytes
     111    inline bool handleRequestCreate( int& i, const byte* data, int length, int sender );
     112    inline bool handleRequestRemove( int& i, const byte* data, int length, int sender );
     113    inline bool handleCreateEntity( int& i, const byte* data, int length, int sender );
     114    inline bool handleRemoveEntity( int& i, const byte* data, int length, int sender );
     115    inline bool handleCreateEntityList( int& i, const byte* data, int length, int sender );
     116    inline bool handleRemoveEntityList( int& i, const byte* data, int length, int sender );
     117    inline bool handleYouAreEntity( int& i, const byte* data, int length, int sender );
     118    inline bool handleRequestSync( int& i, const byte* data, int length, int sender );
    83119
    84120  private:
    85     byte*          inBuffer;
    86     byte*          outBuffer;
     121    std::vector<clientBuffer>     outBuffer;
     122    clientBuffer                  allOutBuffer;
     123    static NetworkGameManager*    singletonRef;
     124
     125    int                           newUniqueID;
     126    bool                          hasRequestedWorld;
    87127};
    88128
Note: See TracChangeset for help on using the changeset viewer.