Changeset 7801 for code/trunk/src/libraries/network/Client.cc
- Timestamp:
- Dec 22, 2010, 7:24:24 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/Client.cc
r7495 r7801 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 } … … 114 111 } 115 112 116 bool Client::queuePacket(ENetPacket *packet, int clientID) 117 { 118 bool b = ClientConnection::addPacket(packet); 119 assert(b); 120 return b; 113 void Client::queuePacket(ENetPacket *packet, int clientID, uint8_t channelID) 114 { 115 ClientConnection::addPacket(packet, channelID); 121 116 } 122 117 … … 140 135 { 141 136 packet::Chat *m = new packet::Chat(message, Host::getPlayerID()); 142 return m->send( );137 return m->send(static_cast<Host*>(this)); 143 138 } 144 139 … … 159 154 { 160 155 COUT(4) << "popping partial gamestate: " << std::endl; 161 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 } 162 164 //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now 163 if(gs){164 COUT(4) << "client tick: sending gs " << gs << std::endl;165 if( !gs->send() )166 COUT(3) << "Problem adding partial gamestate to queue" << std::endl;167 // gs gets automatically deleted by enet callback168 }169 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)); 170 172 } 171 173 } 172 sendPackets(); // flush the enet queue174 // sendPackets(); // flush the enet queue 173 175 174 176 Connection::processQueue(); 175 if( gamestate->processGamestates())177 if(GamestateManager::processGamestates()) 176 178 { 177 179 FunctionCallManager::processBufferedFunctionCalls(); … … 179 181 isSynched_=true; 180 182 } 181 gamestate->cleanup();182 Connection::sendPackets();183 // GamestateManager::cleanup();; 184 // Connection::sendPackets(); 183 185 184 186 return; … … 200 202 Game::getInstance().popState(); 201 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 202 218 203 219
Note: See TracChangeset
for help on using the changeset viewer.