Changeset 1769 for code/trunk/src/network/GamestateClient.cc
- Timestamp:
- Sep 11, 2008, 5:06:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/GamestateClient.cc
r1767 r1769 35 35 #include "core/Iterator.h" 36 36 #include "Synchronisable.h" 37 #include "packet/Acknowledgement.h" 37 38 38 39 … … 70 71 } 71 72 72 intGamestateClient::processGamestates(){73 bool GamestateClient::processGamestates(){ 73 74 if(tempGamestate_==NULL) 74 return 0;75 return false; 75 76 int id = GAMESTATEID_INITIAL; 76 77 bool b = saveShipCache(); 77 78 packet::Gamestate *processed = processGamestate(tempGamestate_); 78 if(!processed) 79 return GAMESTATEID_INITIAL; 79 if(!processed){ 80 if(b) 81 loadShipCache(); 82 return false; 83 } 80 84 // assert(processed); 81 85 //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs 82 tempGamestate_= 0;86 tempGamestate_=NULL; 83 87 gamestateMap_[processed->getID()]=processed; 84 88 last_diff_ = processed->getID(); … … 86 90 loadShipCache(); 87 91 id = processed->getID(); 88 cleanup();89 return id;92 sendAck(id); 93 return true; 90 94 } 91 95 … … 129 133 COUT(4) << std::endl; 130 134 135 } 136 137 bool GamestateClient::sendAck(unsigned int gamestateID){ 138 packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0); 139 if(!ack->send()){ 140 COUT(3) << "could not ack gamestate: " << gamestateID << std::endl; 141 return false; 142 } 143 else{ 144 COUT(3) << "acked a gamestate: " << gamestateID << std::endl; 145 return true; 146 } 131 147 } 132 148 … … 169 185 if(gs->isDiffed()){ 170 186 packet::Gamestate *base = gamestateMap_[gs->getBaseID()]; 171 if(!base) 187 if(!base){ 188 delete gs; 172 189 return 0; 190 } 173 191 // assert(base); //TODO: fix this 174 192 packet::Gamestate *undiffed = gs->undiff(base);
Note: See TracChangeset
for help on using the changeset viewer.