Changeset 1769 for code/trunk
- Timestamp:
- Sep 11, 2008, 5:06:24 PM (16 years ago)
- Location:
- code/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/Client.cc
r1767 r1769 45 45 #include "core/ConsoleCommand.h" 46 46 #include "packet/Packet.h" 47 #include "packet/Acknowledgement.h"47 // #include "packet/Acknowledgement.h" 48 48 49 49 namespace network … … 166 166 assert(packet->process()); 167 167 } 168 int gameStateID = gamestate.processGamestates(); 169 if(gameStateID==GAMESTATEID_INITIAL) 170 if(gameStateFailure_){ 171 packet::Acknowledgement *ack = new packet::Acknowledgement((unsigned int)GAMESTATEID_INITIAL, 0); 172 if(!ack->send()) 173 COUT(3) << "could not (negatively) ack gamestate" << std::endl; 174 else 175 COUT(4) << "negatively acked a gamestate" << std::endl; 176 } 177 else 178 gameStateFailure_=true; 179 else if(gameStateID!=0){ 180 // ack gamestate and set synched 168 if(gamestate.processGamestates()) 169 { 181 170 if(!isSynched_) 182 171 isSynched_=true; 183 gameStateFailure_=false; 184 packet::Acknowledgement *ack = new packet::Acknowledgement(gameStateID, 0); 185 if(!ack->send()) 186 COUT(3) << "could not ack gamestate" << std::endl; 187 }// otherwise we had no gamestate to load 172 }else 173 COUT(3) << "gamestate has not been processed sucessfully" << std::endl; 188 174 gamestate.cleanup(); 189 175 return; -
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); -
code/trunk/src/network/GamestateClient.h
r1763 r1769 62 62 bool ack(int gamestateID, int clientID); 63 63 64 intprocessGamestates();64 bool processGamestates(); 65 65 packet::Gamestate *getGamestate(); 66 66 void cleanup(); … … 69 69 void removeObject(orxonox::ObjectListIterator<Synchronisable> &it); 70 70 void printGamestateMap(); 71 bool sendAck(unsigned int gamestateID); 71 72 bool saveShipCache(); 72 73 bool loadShipCache(); -
code/trunk/src/network/GamestateManager.cc
r1763 r1769 157 157 int curid = temp->getGamestateID(); 158 158 159 if(gamestateID == GAMESTATEID_INITIAL){159 if(gamestateID == 0){ 160 160 temp->setGamestateID(GAMESTATEID_INITIAL); 161 161 if(curid!=GAMESTATEID_INITIAL){ … … 163 163 --(gamestateUsed.find(curid)->second); 164 164 } 165 return false; 166 } 167 if(curid > gamestateID) 165 return true; 166 } 167 //if(curid > gamestateID) 168 assert(curid<gamestateID); 168 169 // the network packets got messed up 169 return true;170 //return true; 170 171 COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl; 171 172 // decrease usage of gamestate and save it -
code/trunk/src/network/packet/Acknowledgement.cc
r1763 r1769 31 31 #include "network/Host.h" 32 32 #include "network/GamestateHandler.h" 33 #include "core/CoreIncludes.h" 33 34 34 35 namespace network { … … 63 64 64 65 bool Acknowledgement::process(){ 65 bool b = GamestateHandler::ackGamestate( data_[_ACKID], clientID_);66 bool b = GamestateHandler::ackGamestate(getAckID(), clientID_); 66 67 delete this; 67 68 return b; … … 69 70 70 71 unsigned int Acknowledgement::getAckID(){ 71 return *(unsigned int *) &data_[ _ACKID ];72 return *(unsigned int *)(data_ + _ACKID); 72 73 } 73 74 -
code/trunk/src/orxonox/objects/Model.cc
r1751 r1769 52 52 RegisterObject(Model); 53 53 registerAllVariables(); 54 if(this->isExactlyA(Class(Model)))55 setObjectFrequency(1);56 54 } 57 55 … … 87 85 COUT(4) << "Loader (Model.cc): Created model" << std::endl; 88 86 } 87 if(this->isExactlyA(Class(Model))) 88 setObjectFrequency(300); //sync all 10 seconds (this only applies to asteroids and other isExactlyA(Model) 89 89 return true; 90 90 }
Note: See TracChangeset
for help on using the changeset viewer.