- Timestamp:
- May 26, 2008, 9:21:53 PM (16 years ago)
- Location:
- code/branches/network/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/Client.cc
r1425 r1431 85 85 isConnected=false; 86 86 isSynched_=false; 87 gameStateFailure_=false; 87 88 } 88 89 … … 95 96 isConnected=false; 96 97 isSynched_=false; 98 gameStateFailure_=false; 97 99 } 98 100 … … 105 107 isConnected=false; 106 108 isSynched_=false; 109 gameStateFailure_=false; 107 110 } 108 111 … … 247 250 } 248 251 int gameStateID = gamestate.processGameState(); 249 if(gameStateID!=GAMESTATEID_INITIAL){ 252 if(gameStateID==GAMESTATEID_INITIAL) 253 if(gameStateFailure_){ 254 if(!client_connection.addPacket(pck_gen.acknowledgement(GAMESTATEID_INITIAL))) 255 COUT(3) << "could not (negatively) ack gamestate" << std::endl; 256 else 257 COUT(4) << "negatively acked a gamestate" << std::endl; 258 } 259 else 260 gameStateFailure_=true; 261 else if(gameStateID!=0){ 250 262 // ack gamestate and set synched 251 263 if(!isSynched_) 252 264 isSynched_=true; 265 gameStateFailure_=false; 253 266 if(!client_connection.addPacket(pck_gen.acknowledgement(gameStateID))) 254 267 COUT(3) << "could not ack gamestate" << std::endl; 255 } 268 }// otherwise we had no gamestate to load 256 269 gamestate.cleanup(); 257 270 if(!client_connection.sendPackets()) -
code/branches/network/src/network/Client.h
r1293 r1431 110 110 int clientID_; // this is the id the server gave to us 111 111 int shipID_; 112 bool gameStateFailure_; 112 113 }; 113 114 -
code/branches/network/src/network/ClientInformation.cc
r1389 r1431 156 156 } 157 157 158 bool ClientInformation::setGame stateID(int id){158 bool ClientInformation::setGameStateID(int id){ 159 159 boost::recursive_mutex::scoped_lock lock(mutex_); 160 160 if(!this) -
code/branches/network/src/network/ClientInformation.h
r1389 r1431 69 69 void setID(int clientID); 70 70 bool setPeer(ENetPeer *peer); 71 bool setGame stateID(int id);71 bool setGameStateID(int id); 72 72 bool setPartialGamestateID(int id); 73 73 inline void setShipID(int id){ShipID_=id;} -
code/branches/network/src/network/GameStateClient.cc
r1425 r1431 117 117 int GameStateClient::processGameState(){ 118 118 if(tempGameState_==NULL) 119 return GAMESTATEID_INITIAL;119 return 0; 120 120 int id=tempGameState_->id; 121 121 bool b = saveShipCache(); … … 176 176 orxonox::Identifier* id = ID((unsigned int)sync.classID); 177 177 if(!id){ 178 COUT( 4) << "We could not identify a new object; classid: " << sync.classID<< std::endl;179 return false; 178 COUT(3) << "We could not identify a new object; classid: " << sync.classID << " objectID: " << sync.objectID << " size: " << sync.length << std::endl; 179 return false; // most probably the gamestate is corrupted 180 180 } 181 181 Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate()); … … 278 278 int of=0; // pointers offset 279 279 int dest_length=0; 280 if(old->size>=diff->size)280 /*if(old->size>=diff->size) 281 281 dest_length=old->size; 282 else 282 else*/ 283 283 dest_length=diff->size; 284 284 // unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char)); … … 295 295 of++; 296 296 } 297 } else{297 } /*else{ 298 298 while(of<dest_length){ 299 299 *(dp+of)=*(ap+of)^n; 300 300 of++; 301 301 } 302 } 302 }*/ 303 303 } 304 304 // should be finished now -
code/branches/network/src/network/GameStateManager.cc
r1425 r1431 140 140 client = it->second; 141 141 GameState *server = reference; 142 COUT(3) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << std::endl;142 COUT(3) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl; 143 143 if(client) 144 144 return encode(client, server); … … 260 260 data+=sizeof(int); 261 261 sync.classID = *(int*)data; 262 if(sync.classID == 0) // TODO: remove this 263 COUT(3) << "received a classid 0" << std::endl; 262 264 data+=sizeof(int); 263 265 sync.data = data; … … 269 271 270 272 if(!it){ 271 // the object does not exist yet273 // the objectaber ich glaub die does not exist yet 272 274 COUT(4) << "loadsnapshot: creating new object " << std::endl; 273 275 //COUT(4) << "loadSnapshot:\tclassid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl; … … 337 339 } 338 340 339 GameState *GameStateManager::diff(GameState *a , GameState *b) {340 unsigned char *ap = a ->data, *bp = b->data;341 GameState *GameStateManager::diff(GameState *alt, GameState *neu) { 342 unsigned char *ap = alt->data, *bp = neu->data; 341 343 int of=0; // pointers offset 342 344 int dest_length=0; 343 if(a->size>=b->size)344 dest_length=a ->size;345 else 346 dest_length= b->size;345 /*if(alt->size>neu->size) 346 dest_length=alt->size; 347 else*/ 348 dest_length=neu->size; 347 349 //unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char)); 348 350 unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)]; 349 while(of<a ->size && of<b->size){351 while(of<alt->size && of<neu->size){ 350 352 *(dp+of)=*(ap+of)^*(bp+of); // do the xor 351 353 ++of; 352 354 } 353 if(a ->size!=b->size){ // do we have to fill up ?355 if(alt->size!=neu->size){ // do we have to fill up ? 354 356 unsigned char n=0; 355 if(a ->size<b->size){357 if(alt->size<neu->size){ 356 358 while(of<dest_length){ 357 359 *(dp+of)=n^*(bp+of); 358 360 of++; 359 361 } 360 } else{362 } /*else{ 361 363 while(of<dest_length){ 362 364 *(dp+of)=*(ap+of)^n; 363 365 of++; 364 366 } 365 } 367 }*/ 366 368 } 367 369 368 370 GameState *r = new GameState; 369 r->id = b->id;371 r->id = neu->id; 370 372 r->size = dest_length; 371 373 r->diffed = true; 372 r->base_id = a ->id;374 r->base_id = alt->id; 373 375 r->data = dp; 374 376 r->complete = true; … … 459 461 return; 460 462 int curid = temp->getGamestateID(); 463 464 if(gamestateID == GAMESTATEID_INITIAL){ 465 temp->setGameStateID(GAMESTATEID_INITIAL); 466 --(gameStateUsed.find(curid)->second); 467 return; 468 } 461 469 if(curid > gamestateID) 462 470 // the network packets got messed up … … 469 477 --(gameStateUsed.find(curid)->second); 470 478 ++(gameStateUsed.find(gamestateID)->second); 471 temp->setGame stateID(gamestateID);479 temp->setGameStateID(gamestateID); 472 480 /* 473 481 GameState *old = clientGameState[clientID]; -
code/branches/network/src/network/GameStateManager.h
r1425 r1431 86 86 GameStateCompressed *encode(GameState *a, GameState *b); 87 87 GameStateCompressed *encode(GameState *a); 88 GameState *diff(GameState *a , GameState *b);88 GameState *diff(GameState *alt, GameState *neu); 89 89 GameStateCompressed *compress_(GameState *a); 90 90 GameState *decompress(GameStateCompressed *a); -
code/branches/network/src/network/Server.cc
r1425 r1431 263 263 264 264 void Server::processAck( ack *data, int clientID) { 265 COUT(4) << " \b\b\b\n\n\n\n\nServer: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;265 COUT(4) << "Server: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl; 266 266 gamestates->ackGameState(clientID, data->a); 267 267 delete data; -
code/branches/network/src/network/Synchronisable.cc
r1425 r1431 70 70 bool Synchronisable::create(){ 71 71 this->classID = this->getIdentifier()->getNetworkID(); 72 COUT(4) << " setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;72 COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl; 73 73 return true; 74 74 } -
code/branches/network/src/network/diffTest.cc
r1360 r1431 549 549 550 550 std::cout << "test setGamestateID" << std::endl; 551 temp->setGame stateID( 8 );551 temp->setGameStateID( 8 ); 552 552 printClientInformationBox( temp ); 553 553 … … 559 559 newInfo->setSynched( true ); 560 560 newInfo->setPeer( NULL ); 561 toool->setGame stateID( 199 );561 toool->setGameStateID( 199 ); 562 562 toool->setID( numberOfClients+1); 563 563 toool->setSynched( true ); -
code/branches/network/src/orxonox/objects/SpaceShip.cc
r1425 r1431 359 359 Projectile *p = new Projectile(this); 360 360 p->create(); 361 if(p->classID==0) 362 COUT(3) << "generated projectile with classid 0" << std::endl; // TODO: remove this output 361 363 362 364 p->setBacksync(true);
Note: See TracChangeset
for help on using the changeset viewer.