- Timestamp:
- Oct 14, 2008, 12:20:14 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/GamestateClient.cc
r1907 r1916 40 40 namespace network 41 41 { 42 struct GameStateItem{42 struct _NetworkExport GameStateItem{ 43 43 packet::Gamestate *state; 44 44 int id; … … 50 50 last_gamestate_=GAMESTATEID_INITIAL-1; 51 51 tempGamestate_=NULL; 52 myShip_=NULL;53 52 } 54 53 … … 75 74 return false; 76 75 int id = GAMESTATEID_INITIAL; 77 bool b = saveShipCache();78 76 packet::Gamestate *processed = processGamestate(tempGamestate_); 79 if(!processed){80 if(b)81 loadShipCache();82 return false;83 }84 77 // assert(processed); 85 78 //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs … … 87 80 gamestateMap_[processed->getID()]=processed; 88 81 last_diff_ = processed->getID(); 89 if(b)90 loadShipCache();91 82 id = processed->getID(); 92 83 sendAck(id); … … 134 125 135 126 } 136 127 137 128 bool GamestateClient::sendAck(unsigned int gamestateID){ 138 129 packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0); … … 145 136 return true; 146 137 } 147 }148 149 bool GamestateClient::saveShipCache(){150 if(myShip_==NULL){151 myShip_ = orxonox::SpaceShip::getLocalShip();152 // COUT(2) << "myShip_: " << myShip_ << " getLocalShip(): " << orxonox::SpaceShip::getLocalShip() << std::endl;153 if(!myShip_)154 return false;155 }156 if(myShip_){157 // unsigned char *data = new unsigned char[myShip_->getSize()];158 int size=myShip_->getSize(0, 0x1);159 if(size==0)160 return false;161 shipCache_ = new unsigned char [size];162 unsigned char *temp = shipCache_;163 if(!myShip_->getData(temp, 0, 0x1))164 COUT(3) << "could not save shipCache" << std::endl;165 return true;166 }else167 return false;168 }169 170 bool GamestateClient::loadShipCache(){171 myShip_=orxonox::SpaceShip::getLocalShip(); //TODO: remove this (only a hack)172 if(myShip_ && shipCache_){173 assert(myShip_->getIdentifier());174 unsigned char *temp = shipCache_;175 myShip_->updateData(temp, 0x2);176 delete shipCache_;177 return true;178 }else179 return false;180 138 } 181 139
Note: See TracChangeset
for help on using the changeset viewer.