Changeset 1008 for code/branches/network/src/network/Server.cc
- Timestamp:
- Apr 10, 2008, 12:55:35 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/Server.cc
r1007 r1008 95 95 bool Server::sendMSG(const char *msg) { 96 96 ENetPacket *packet = packet_gen.chatMessage(msg); 97 std::cout <<"adding Packets" << std::endl;97 COUT(4) <<"Server: adding Packets" << std::endl; 98 98 connection->addPacketAll(packet); 99 99 //std::cout <<"added packets" << std::endl; 100 100 if (connection->sendPackets()){ 101 std::cout << "Sucessfully" << std::endl;101 COUT(4) << "Server: Sucessfully" << std::endl; 102 102 return true; 103 103 } … … 126 126 while(!connection->queueEmpty()){ 127 127 //std::cout << "Client " << clientID << " sent: " << std::endl; 128 //clientID here is a reference to grab clientID from ClientInformation 128 129 packet = connection->getPacket(clientID); 129 elaborate(packet, clientID); 130 //if statement to catch case that packetbuffer is empty 131 if( !elaborate(packet, clientID) ) 132 COUT(4) << "Server: PacketBuffer empty" << std::endl; 130 133 } 131 134 } … … 136 139 void Server::updateGamestate() { 137 140 gamestates->update(); 141 COUT(4) << "Server: one gamestate update complete, goig to sendGameState" << std::endl; 138 142 //std::cout << "updated gamestate, sending it" << std::endl; 139 143 //if(clients->getGamestateID()!=GAMESTATEID_INITIAL) 140 sendGameState(); 144 sendGameState(); 145 COUT(4) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl; 141 146 //std::cout << "sent gamestate" << std::endl; 142 147 } … … 146 151 */ 147 152 bool Server::sendGameState() { 148 COUT(5) << " startingsendGameState" << std::endl;153 COUT(5) << "Server: starting function sendGameState" << std::endl; 149 154 ClientInformation *temp = clients; 150 155 bool added=false; 151 while(temp !=NULL){156 while(temp != NULL){ 152 157 if(temp->head){ 153 158 temp=temp->next(); 159 //think this works without continue 154 160 continue; 155 161 } 156 162 if( !(temp->getSynched()) ){ 157 COUT(5) << " not sending gamestate" << std::endl;163 COUT(5) << "Server: not sending gamestate" << std::endl; 158 164 temp=temp->next(); 165 //think this works without continue 159 166 continue; 160 167 } 161 COUT(5) << " doing gamestate gamestate preparation" << std::endl;162 int gid = temp->getGamestateID(); 163 int cid = temp->getID(); 164 COUT(5) << " server, got acked (gamestate) ID: " << gid << std::endl;168 COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl; 169 int gid = temp->getGamestateID(); //get gamestate id 170 int cid = temp->getID(); //get client id 171 COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl; 165 172 GameStateCompressed *gs = gamestates->popGameState(cid); 166 173 if(gs==NULL){ 167 COUT(2) << " could not generate gamestate" << std::endl;174 COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl; 168 175 return false; 169 176 } 170 177 //std::cout << "adding gamestate" << std::endl; 171 connection->addPacket(packet_gen.gstate(gs), cid); 178 if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) ) 179 COUT(4) << "Server: packet with client id (cid): " << cid << " not sended" << std::endl; 172 180 //std::cout << "added gamestate" << std::endl; 173 181 added=true; 174 182 temp=temp->next(); 175 183 } 176 if(added) 184 if(added) { 185 //std::cout << "send gamestates from server.cc in sendGameState" << std::endl; 177 186 return connection->sendPackets(); 178 COUT(5) << "had no gamestates to send" << std::endl; 187 } 188 COUT(5) << "Server: had no gamestates to send" << std::endl; 179 189 return false; 180 190 } 181 191 182 192 void Server::processAck( ack *data, int clientID) { 183 COUT(5) << " processing ack from client: " << clientID << "; ack-id: " << data->id << std::endl;193 COUT(5) << "Server: processing ack from client: " << clientID << "; ack-id: " << data->id << std::endl; 184 194 clients->findClient(clientID)->setGamestateID(data->a); 185 195 }
Note: See TracChangeset
for help on using the changeset viewer.