Changeset 1907 for code/trunk/src/network/Client.cc
- Timestamp:
- Oct 12, 2008, 7:40:47 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/Client.cc
r1769 r1907 43 43 #include "Synchronisable.h" 44 44 #include "core/CoreIncludes.h" 45 #include "core/ConsoleCommand.h"46 45 #include "packet/Packet.h" 47 46 // #include "packet/Acknowledgement.h" … … 61 60 isSynched_=false; 62 61 gameStateFailure_=false; 63 isServer_ = false;64 62 } 65 63 … … 73 71 isSynched_=false; 74 72 gameStateFailure_=false; 75 isServer_ = false;76 73 } 77 74 … … 85 82 isSynched_=false; 86 83 gameStateFailure_=false; 87 isServer_ = false;88 84 } 89 85 … … 118 114 } 119 115 120 bool Client::processChat(packet::Chat *message, unsigned int clientID){ 121 return message->process(); 116 bool Client::processChat(std::string message, unsigned int playerID){ 117 COUT(1) << "Player " << playerID << ": " << message << std::endl; 118 return true; 122 119 } 123 124 /*bool Client::sendChat(packet::Chat *chat){ 125 chat->process(); 126 packet::Packet *p = new packet::Packet(chat); 127 return p->send(); 128 }*/ 120 121 /** 122 * This function implements the method of sending a chat message to the server 123 * @param message message to be sent 124 * @return result(true/false) 125 */ 126 bool Client::chat(std::string message){ 127 packet::Chat *m = new packet::Chat(message, Host::getPlayerID()); 128 return m->send(); 129 } 129 130 130 131 131 132 /** 132 * submits a chat message to the server 133 * @param message message to send 134 * @return true/false 135 */ 136 bool Client::sendChat( std::string message ){ 137 // generate packet and add it to queue 138 if(!isConnected) 139 return false; 140 packet::Chat chat(message, 0); 141 return chat.send(); 142 // send packets 143 } 144 145 /** 146 * Performs a GameState update 147 */ 133 * Processes incoming packets, sends a gamestate to the server and does the cleanup 134 * @param time 135 */ 148 136 void Client::tick(float time){ 149 137 // COUT(3) << "."; … … 164 152 COUT(5) << "tick packet size " << event->packet->dataLength << std::endl; 165 153 packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer); 166 assert(packet->process()); 154 bool b = packet->process(); 155 assert(b); 167 156 } 168 157 if(gamestate.processGamestates()) … … 170 159 if(!isSynched_) 171 160 isSynched_=true; 172 }else 173 COUT(3) << "gamestate has not been processed sucessfully" << std::endl; 161 } 174 162 gamestate.cleanup(); 175 163 return;
Note: See TracChangeset
for help on using the changeset viewer.