Changeset 2990 for code/branches/netp3/src/network/Client.cc
- Timestamp:
- May 19, 2009, 9:35:10 PM (15 years ago)
- Location:
- code/branches/netp3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp3
- Property svn:mergeinfo changed
/code/branches/netp2 (added) merged: 2835-2836,2861,2937-2938,2940-2941,2943-2945,2947-2949,2951,2953,2964-2965,2974-2976
- Property svn:mergeinfo changed
-
code/branches/netp3/src/network/Client.cc
r2896 r2990 48 48 #include "core/CoreIncludes.h" 49 49 #include "packet/Packet.h" 50 #include "FunctionCallManager.h" 50 51 51 52 // #include "packet/Acknowledgement.h" … … 140 141 */ 141 142 void Client::update(const Clock& time){ 142 // COUT(3) << "."; 143 if(client_connection.isConnected() && isSynched_){ 144 COUT(4) << "popping partial gamestate: " << std::endl; 145 packet::Gamestate *gs = gamestate.getGamestate(); 146 if(gs){ 147 COUT(4) << "client tick: sending gs " << gs << std::endl; 148 if( !gs->send() ) 149 COUT(3) << "Problem adding partial gamestate to queue" << std::endl; 143 //this steers our network frequency 144 timeSinceLastUpdate_+=time; 145 if(timeSinceLastUpdate_>=NETWORK_PERIOD){ 146 timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD; 147 // COUT(3) << "."; 148 if(client_connection.isConnected() && isSynched_){ 149 COUT(4) << "popping partial gamestate: " << std::endl; 150 packet::Gamestate *gs = gamestate.getGamestate(); 151 if(gs){ 152 COUT(4) << "client tick: sending gs " << gs << std::endl; 153 if( !gs->send() ) 154 COUT(3) << "Problem adding partial gamestate to queue" << std::endl; 150 155 // gs gets automatically deleted by enet callback 156 } 157 FunctionCallManager::sendCalls(); 151 158 } 159 ENetEvent *event; 160 // stop if the packet queue is empty 161 while(!(client_connection.queueEmpty())){ 162 event = client_connection.getEvent(); 163 COUT(5) << "tick packet size " << event->packet->dataLength << std::endl; 164 packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer); 165 // note: packet commits suicide here except for the GameState. That is then deleted by a GamestateHandler 166 bool b = packet->process(); 167 assert(b); 168 } 169 if(gamestate.processGamestates()) 170 { 171 if(!isSynched_) 172 isSynched_=true; 173 } 174 gamestate.cleanup(); 152 175 } 153 ENetEvent *event; 154 // stop if the packet queue is empty 155 while(!(client_connection.queueEmpty())){ 156 event = client_connection.getEvent(); 157 COUT(5) << "tick packet size " << event->packet->dataLength << std::endl; 158 packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer); 159 // note: packet commits suicide here except for the GameState. That is then deleted by a GamestateHandler 160 bool b = packet->process(); 161 assert(b); 162 } 163 if(gamestate.processGamestates()) 164 { 165 if(!isSynched_) 166 isSynched_=true; 167 } 168 gamestate.cleanup(); 176 169 177 return; 170 178 }
Note: See TracChangeset
for help on using the changeset viewer.