Changeset 6340 in orxonox.OLD for branches/network_merged/src/lib/network/network_game_manager.h
- Timestamp:
- Dec 30, 2005, 1:52:26 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network_merged/src/lib/network/network_game_manager.h
r6139 r6340 14 14 15 15 16 class TiXmlElement; 16 17 17 18 /** 18 19 * protocol definition 19 20 * 20 * CREATE_ENTITY: CLASS_ID, UNIQUE_ID, OWNER21 * REMOVE_ENTITY: UNIQUE_ID21 * CREATE_ENTITY: CLASS_ID, UNIQUE_ID, OWNER 22 * REMOVE_ENTITY: UNIQUE_ID 22 23 * 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] 25 26 * 26 * REQUEST_CREATE: CLASS_ID27 * REQUEST_REMOVE: UNIQUE_ID27 * REQUEST_CREATE: CLASS_ID 28 * REQUEST_REMOVE: UNIQUE_ID 28 29 * 29 * REQUEST_SYNC: UNIQUE_ID30 * 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] 31 32 * 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 32 38 * 33 39 */ 34 40 41 typedef 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 }; 35 52 36 37 38 39 40 41 42 53 struct clientBuffer 54 { 55 int length; 56 int maxLength; 57 byte * buffer; 58 }; 43 59 44 60 /*! … … 48 64 { 49 65 public: 50 NetworkGameManager();51 66 ~NetworkGameManager(); 52 67 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); 54 72 virtual int readBytes(byte* data, int maxLength, int * reciever); 55 73 virtual void writeDebug() const; 56 74 virtual void readDebug() const; 57 75 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 ); 62 80 63 void sync(int uniqueID); 64 void syncList(int* uniqueIDList); 81 void sync(int uniqueID, int owner); 65 82 83 void sendEntityList(int userID); 66 84 67 85 private: 68 void requestCreateEntity(int classID);69 void executeCreateEntity(int classID); 70 void requestCreateEntity List(int* classIDList);71 void executeCreateEntity List(int* classIDList);86 NetworkGameManager(); 87 88 void requestCreateEntity(ClassID classID); 89 void executeCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0); 72 90 73 91 void requestRemoveEntity(int uniqueID); 74 92 void executeRemoveEntity(int uniqueID); 75 void requestRemoveEntityList(int* uniqueIDList);76 void executeRemoveEntityList(int* uniqueIDList);77 93 94 void executeRequestSync( int uniqueID, int user ); 78 95 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 ); 79 100 80 bool canCreateEntity( intclassID);101 bool canCreateEntity(ClassID classID); 81 102 103 void resizeBufferVector(int n); 82 104 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 ); 83 119 84 120 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; 87 127 }; 88 128
Note: See TracChangeset
for help on using the changeset viewer.