Changeset 7777 for code/branches/network5/src/libraries/network/Client.cc
- Timestamp:
- Dec 19, 2010, 2:27:06 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network5/src/libraries/network/Client.cc
r7772 r7777 64 64 */ 65 65 Client::Client(): 66 gamestate(0),67 66 isSynched_(false), 68 67 gameStateFailure_(false), … … 85 84 { 86 85 Synchronisable::setClient(true); 87 this->gamestate = new GamestateClient();88 86 if( ClientConnection::establishConnection() ) 89 87 { 90 88 Host::setActive(true); 89 GamestateManager::addPeer(NETWORK_PEER_ID_SERVER); 91 90 return true; 92 91 } … … 101 100 bool Client::closeConnection() 102 101 { 103 assert(this->gamestate);104 delete this->gamestate;105 this->gamestate = 0;106 102 Host::setActive(false); 103 GamestateManager::removePeer(NETWORK_PEER_ID_SERVER); 107 104 return ClientConnection::closeConnection(); 108 105 } … … 138 135 { 139 136 packet::Chat *m = new packet::Chat(message, Host::getPlayerID()); 140 return m->send( );137 return m->send(static_cast<Host*>(this)); 141 138 } 142 139 … … 157 154 { 158 155 COUT(4) << "popping partial gamestate: " << std::endl; 159 packet::Gamestate *gs = gamestate->getGamestate(); 156 // packet::Gamestate *gs = GamestateClient::getGamestate(); 157 GamestateManager::update(); 158 std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates(); 159 std::vector<packet::Gamestate*>::iterator it; 160 for( it = gamestates.begin(); it != gamestates.end(); ++it ) 161 { 162 (*it)->send( static_cast<Host*>(this) ); 163 } 160 164 //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now 161 if(gs){162 COUT(4) << "client tick: sending gs " << gs << std::endl;163 if( !gs->send() )164 COUT(2) << "Problem adding partial gamestate to queue" << std::endl;165 // gs gets automatically deleted by enet callback166 }167 FunctionCallManager::sendCalls( );165 // if(gs){ 166 // COUT(4) << "client tick: sending gs " << gs << std::endl; 167 // if( !gs->send() ) 168 // COUT(2) << "Problem adding partial gamestate to queue" << std::endl; 169 // // gs gets automatically deleted by enet callback 170 // } 171 FunctionCallManager::sendCalls(static_cast<Host*>(this)); 168 172 } 169 173 } … … 171 175 172 176 Connection::processQueue(); 173 if( gamestate->processGamestates())177 if(GamestateManager::processGamestates()) 174 178 { 175 179 FunctionCallManager::processBufferedFunctionCalls(); … … 177 181 isSynched_=true; 178 182 } 179 gamestate->cleanup();183 // GamestateManager::cleanup();; 180 184 // Connection::sendPackets(); 181 185 … … 198 202 Game::getInstance().popState(); 199 203 } 204 205 void Client::processPacket(packet::Packet* packet) 206 { 207 if( packet->isReliable() ) 208 { 209 if( this->getLastProcessedGamestateID(packet->getPeerID()) >= packet->getRequiredGamestateID() ) 210 packet->process(static_cast<Host*>(this)); 211 else 212 this->packetQueue_.push_back(packet); 213 } 214 else 215 packet->process(static_cast<Host*>(this)); 216 } 217 200 218 201 219
Note: See TracChangeset
for help on using the changeset viewer.