Changeset 1990
- Timestamp:
- Oct 21, 2008, 5:53:09 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/ClientInformation.cc
r1960 r1990 59 59 60 60 ClientInformation::~ClientInformation() { 61 if(this==head_)62 head_=next();63 61 if(prev()!=0) 64 62 prev()->setNext(this->next()); 65 63 if(next()!=0) 66 64 next()->setPrev(this->prev()); 65 if(this==head_) 66 head_=next(); 67 67 } 68 68 -
code/branches/objecthierarchy/src/network/GamestateClient.cc
r1944 r1990 43 43 struct _NetworkExport GameStateItem{ 44 44 packet::Gamestate *state; 45 int id;45 unsigned int id; 46 46 }; 47 47 … … 56 56 } 57 57 58 bool GamestateClient::ack( int gamestateID,int clientID){58 bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID){ 59 59 return true; 60 60 } 61 61 62 bool GamestateClient::add(packet::Gamestate *gs, int clientID){62 bool GamestateClient::add(packet::Gamestate *gs, unsigned int clientID){ 63 63 if(tempGamestate_!=NULL){ 64 64 //delete the obsolete gamestate … … 110 110 111 111 void GamestateClient::cleanup(){ 112 std::map< int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();112 std::map<unsigned int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin(); 113 113 while(it!=gamestateMap_.end()){ 114 114 if(it->first>=last_diff_) … … 123 123 124 124 void GamestateClient::printGamestateMap(){ 125 std::map< int, packet::Gamestate*>::iterator it;125 std::map<unsigned int, packet::Gamestate*>::iterator it; 126 126 COUT(4) << "gamestates: "; 127 127 for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){ -
code/branches/objecthierarchy/src/network/GamestateClient.h
r1916 r1990 48 48 #include "GamestateHandler.h" 49 49 50 #define GAMESTATEID_INITIAL -1 50 const unsigned int GAMESTATEID_INITIAL=-1; 51 51 52 52 namespace network … … 58 58 ~GamestateClient(); 59 59 60 bool add(packet::Gamestate *gs, int clientID);61 bool ack( int gamestateID,int clientID);60 bool add(packet::Gamestate *gs, unsigned int clientID); 61 bool ack(unsigned int gamestateID, unsigned int clientID); 62 62 63 63 bool processGamestates(); … … 70 70 bool sendAck(unsigned int gamestateID); 71 71 72 int last_diff_;73 int last_gamestate_;74 std::map< int, packet::Gamestate *> gamestateMap_;72 unsigned int last_diff_; 73 unsigned int last_gamestate_; 74 std::map<unsigned int, packet::Gamestate *> gamestateMap_; 75 75 packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue 76 76 unsigned char *shipCache_; -
code/branches/objecthierarchy/src/network/GamestateHandler.h
r1916 r1990 41 41 class _NetworkExport GamestateHandler{ 42 42 private: 43 virtual bool add(packet::Gamestate *gs, int clientID)=0;44 virtual bool ack( int gamestateID,int clientID)=0;43 virtual bool add(packet::Gamestate *gs, unsigned int clientID)=0; 44 virtual bool ack(unsigned int gamestateID, unsigned int clientID)=0; 45 45 46 46 static GamestateHandler *instance_; … … 52 52 53 53 public: 54 static bool addGamestate(packet::Gamestate *gs, int clientID){ return instance_->add(gs, clientID); }55 static bool ackGamestate( int gamestateID,int clientID){ return instance_->ack(gamestateID, clientID); }54 static bool addGamestate(packet::Gamestate *gs, unsigned int clientID){ return instance_->add(gs, clientID); } 55 static bool ackGamestate(unsigned int gamestateID, unsigned int clientID){ return instance_->ack(gamestateID, clientID); } 56 56 }; 57 57 -
code/branches/objecthierarchy/src/network/GamestateManager.cc
r1962 r1990 65 65 } 66 66 67 bool GamestateManager::add(packet::Gamestate *gs, int clientID){67 bool GamestateManager::add(packet::Gamestate *gs, unsigned int clientID){ 68 68 assert(gs); 69 std::map< int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);69 std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID); 70 70 if(it!=gamestateQueue.end()){ 71 71 // delete obsolete gamestate … … 77 77 78 78 bool GamestateManager::processGamestates(){ 79 std::map< int, packet::Gamestate*>::iterator it;79 std::map<unsigned int, packet::Gamestate*>::iterator it; 80 80 // now push only the most recent gamestates we received (ignore obsolete ones) 81 81 for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){ … … 126 126 }*/ 127 127 128 packet::Gamestate *GamestateManager::popGameState( int clientID) {128 packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) { 129 129 //why are we searching the same client's gamestate id as we searched in 130 130 //Server::sendGameState? … … 141 141 packet::Gamestate *client=NULL; 142 142 if(gID != GAMESTATEID_INITIAL){ 143 std::map<unsigned int, std::map< int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID);143 std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID); 144 144 if(clientMap!=gamestateMap_.end()){ 145 std::map< int, packet::Gamestate*>::iterator it = clientMap->second.find(gID);145 std::map<unsigned int, packet::Gamestate*>::iterator it = clientMap->second.find(gID); 146 146 if(it!=clientMap->second.end()) 147 147 client = it->second; … … 162 162 163 163 164 bool GamestateManager::ack( int gamestateID,int clientID) {164 bool GamestateManager::ack(unsigned int gamestateID, unsigned int clientID) { 165 165 ClientInformation *temp = ClientInformation::findClient(clientID); 166 166 assert(temp); … … 172 172 } 173 173 174 assert(curid <gamestateID);174 assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID); 175 175 COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl; 176 std::map< int, packet::Gamestate*>::iterator it, tempit;176 std::map<unsigned int, packet::Gamestate*>::iterator it, tempit; 177 177 for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; it++){ 178 178 delete it->second; … … 186 186 void GamestateManager::removeClient(ClientInformation* client){ 187 187 assert(client); 188 std::map<unsigned int, std::map< int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());188 std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID()); 189 189 // first delete all remained gamestates 190 std::map< int, packet::Gamestate*>::iterator it;190 std::map<unsigned int, packet::Gamestate*>::iterator it; 191 191 for(it=clientMap->second.begin(); it!=clientMap->second.end(); it++) 192 192 delete it->second; -
code/branches/objecthierarchy/src/network/GamestateManager.h
r1916 r1990 71 71 ~GamestateManager(); 72 72 73 bool add(packet::Gamestate *gs, int clientID);73 bool add(packet::Gamestate *gs, unsigned int clientID); 74 74 bool processGamestates(); 75 75 bool update(); 76 packet::Gamestate *popGameState( int clientID);76 packet::Gamestate *popGameState(unsigned int clientID); 77 77 78 78 bool getSnapshot(); 79 79 80 bool ack( int gamestateID,int clientID);80 bool ack(unsigned int gamestateID, unsigned int clientID); 81 81 void removeClient(ClientInformation *client); 82 82 private: … … 84 84 bool processGamestate(packet::Gamestate *gs); 85 85 86 std::map<unsigned int, std::map< int, packet::Gamestate*> > gamestateMap_;86 std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_; 87 87 //std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate* 88 88 //std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate 89 std::map< int, packet::Gamestate*> gamestateQueue;89 std::map<unsigned int, packet::Gamestate*> gamestateQueue; 90 90 packet::Gamestate *reference; 91 int id_;91 unsigned int id_; 92 92 }; 93 93 -
code/branches/objecthierarchy/src/network/Synchronisable.cc
r1989 r1990 230 230 * 0x2: client->server (not recommended) 231 231 * 0x3: bidirectional 232 * @return true: if ! isMyTickor if everything was successfully saved232 * @return true: if !doSync or if everything was successfully saved 233 233 */ 234 234 bool Synchronisable::getData(uint8_t*& mem, unsigned int id, int mode){ 235 235 //if this tick is we dont synchronise, then abort now 236 if(! isMyTick(id))236 if(!doSync(id)) 237 237 return true; 238 238 //std::cout << "inside getData" << std::endl; … … 363 363 */ 364 364 uint32_t Synchronisable::getSize(unsigned int id, int mode){ 365 if(! isMyTick(id))365 if(!doSync(id)) 366 366 return 0; 367 367 int tsize=sizeof(synchronisableHeader); … … 392 392 * @return true/false 393 393 */ 394 bool Synchronisable:: isMyTick(unsigned int id){394 bool Synchronisable::doSync(unsigned int id){ 395 395 return ( (objectMode_&state_)!=0 ); 396 396 } -
code/branches/objecthierarchy/src/network/Synchronisable.h
r1989 r1990 122 122 bool isMyData(uint8_t* mem); 123 123 bool doSelection(unsigned int id); 124 bool isMyTick(unsigned int id);124 bool doSync(unsigned int id); 125 125 126 126 unsigned int objectID; -
code/branches/objecthierarchy/src/network/packet/Gamestate.cc
r1907 r1990 268 268 unsigned int compsize = HEADER->compsize; 269 269 unsigned int bufsize; 270 assert(compsize<=datasize);270 // assert(compsize<=datasize); 271 271 bufsize = datasize; 272 272 assert(bufsize!=0); -
code/branches/objecthierarchy/src/orxonox/objects/Test.cc
r1960 r1990 65 65 66 66 void Test::checkV1(){ 67 COUT(1) << "V1 changed: " << v1 << std::endl;67 COUT(1) << "V1 changed: " << v1 << std::endl; 68 68 } 69 69 70 70 void Test::checkV2(){ 71 COUT(1) << "V2 changed: " << v2 << std::endl;71 COUT(1) << "V2 changed: " << v2 << std::endl; 72 72 } 73 73 74 74 void Test::checkV3(){ 75 COUT(1) << "V3 changed: " << v3 << std::endl;75 COUT(1) << "V3 changed: " << v3 << std::endl; 76 76 } 77 77 -
code/branches/objecthierarchy/src/orxonox/objects/Test.h
r1958 r1990 36 36 namespace orxonox 37 37 { 38 class _OrxonoxExport Test: public BaseObject, virtualpublic network::Synchronisable38 class _OrxonoxExport Test: public BaseObject, public network::Synchronisable 39 39 { 40 40 public: … … 60 60 } 61 61 62 #endif /* _ PlayerInfo_H__ */62 #endif /* _Test_H__ */
Note: See TracChangeset
for help on using the changeset viewer.