Changeset 8858 for code/trunk/src/libraries/network
- Timestamp:
- Aug 23, 2011, 12:45:53 AM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 38 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore
-
old new 1 1 build 2 2 codeblocks 3 vs 3 4 dependencies
-
- Property svn:mergeinfo changed
/code/branches/output (added) merged: 8739-8740,8765,8771-8772,8774-8780,8787-8789,8794-8799,8801,8803-8812,8814,8816-8817,8820,8822,8825-8837,8840,8844,8846,8848-8850,8853-8854
- Property svn:ignore
-
code/trunk/src/libraries/network/CMakeLists.txt
r8351 r8858 19 19 20 20 SET_SOURCE_FILES(NETWORK_SRC_FILES 21 ChatListener.cc22 21 Client.cc 23 22 ClientConnection.cc … … 45 44 46 45 SET_SOURCE_FILES(NETWORK_HDR_FILES 47 ChatListener.h48 46 Client.h 49 47 ClientConnection.h … … 61 59 WANDiscovery.h 62 60 MasterServerComm.h 61 NetworkChatListener.h 63 62 NetworkFunction.h 64 63 NetworkPrecompiledHeaders.h -
code/trunk/src/libraries/network/Client.cc
r8327 r8858 44 44 45 45 #include "util/Clock.h" 46 #include "util/ Debug.h"46 #include "util/Output.h" 47 47 #include "util/ScopedSingletonManager.h" 48 48 #include "synchronisable/Synchronisable.h" … … 116 116 } 117 117 118 bool Client::processChat(const std::string& message, unsigned int playerID)119 {120 // COUT(1) << "Player " << playerID << ": " << message << std::endl;121 return true;122 }123 124 118 void Client::printRTT() 125 119 { 126 COUT(0) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;127 } 128 129 /** 130 * This function implements the method of sending a chat message to the server120 orxout(message) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl; 121 } 122 123 /** 124 * @brief Sends a chat message to the server. 131 125 * @param message message to be sent 132 * @return result(true/false) 126 * @param sourceID the ID of the sender 127 * @param targetID the ID of the receiver 133 128 */ 134 bool Client::chat(const std::string& message) 135 { 136 packet::Chat *m = new packet::Chat(message, Host::getPlayerID()); 137 return m->send(static_cast<Host*>(this)); 138 } 139 129 void Client::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 130 { 131 // send the message to the server 132 packet::Chat* packet = new packet::Chat(message, sourceID, targetID); 133 packet->send(static_cast<Host*>(this)); 134 } 135 136 /** 137 * @brief Gets called if a packet::Chat packet is received. Calls the parent function which passes the message to the listeners. 138 */ 139 void Client::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 140 { 141 // call the parent function which passes the message to the listeners 142 Host::doReceiveChat(message, sourceID, targetID); 143 } 140 144 141 145 /** … … 150 154 { 151 155 timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD; 152 // COUT(3) << '.';153 156 if ( isConnected() && isSynched_ ) 154 157 { 155 COUT(4) << "popping partial gamestate: " << std::endl;158 orxout(verbose, context::network) << "popping partial gamestate: " << endl; 156 159 // packet::Gamestate *gs = GamestateClient::getGamestate(); 157 160 if( GamestateManager::update() ) … … 166 169 //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now 167 170 // if(gs){ 168 // COUT(4) << "client tick: sending gs " << gs << std::endl;171 // orxout(verbose, context::network) << "client tick: sending gs " << gs << endl; 169 172 // if( !gs->send() ) 170 // COUT(2) << "Problem adding partial gamestate to queue" << std::endl;173 // orxout(internal_warning, context::network) << "Problem adding partial gamestate to queue" << endl; 171 174 // // gs gets automatically deleted by enet callback 172 175 // } … … 204 207 Game::getInstance().popState(); 205 208 } 206 209 207 210 void Client::processPacket(packet::Packet* packet) 208 211 { … … 217 220 packet->process(static_cast<Host*>(this)); 218 221 } 219 220 221 222 223 222 } -
code/trunk/src/libraries/network/Client.h
r7801 r8858 73 73 Client(); 74 74 ~Client(); 75 75 76 76 static Client* getInstance(){ return singletonPtr_s; } // tolua_export 77 77 … … 81 81 void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID); 82 82 virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); } 83 bool processChat(const std::string& message, unsigned int playerID); 84 virtual bool chat(const std::string& message); 85 virtual bool broadcast(const std::string& message) { return false; } 83 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 84 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 86 85 virtual void printRTT(); 87 86 -
code/trunk/src/libraries/network/ClientConnection.cc
r8327 r8858 32 32 #define WIN32_LEAN_AND_MEAN 33 33 #include <enet/enet.h> 34 #include "util/ Debug.h"34 #include "util/Output.h" 35 35 36 36 namespace orxonox … … 60 60 void ClientConnection::setServerAddress( const std::string& serverAddress ) { 61 61 if (enet_address_set_host (this->serverAddress_, serverAddress.c_str()) < 0) 62 COUT(1) << "Error: Could not resolve \"" << serverAddress << "\"." << std::endl;62 orxout(internal_error, context::network) << "Could not resolve \"" << serverAddress << "\"." << endl; 63 63 } 64 64 … … 76 76 if ( this->host_ == NULL ) 77 77 { 78 COUT(1) << "ClientConnection: host_ == NULL" << std::endl;78 orxout(internal_error, context::network) << "ClientConnection: host_ == NULL" << endl; 79 79 // error handling 80 80 return false; … … 86 86 assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL ); 87 87 if (this->host_->socket4 == ENET_SOCKET_NULL) 88 COUT(2) << "Warning: IPv4 Socket failed." << std::endl;88 orxout(internal_warning, context::network) << "IPv4 Socket failed." << endl; 89 89 else if (this->host_->socket6 == ENET_SOCKET_NULL) 90 COUT(2) << "Warning: IPv6 Socket failed." << std::endl;90 orxout(internal_warning, context::network) << "IPv6 Socket failed." << endl; 91 91 else 92 COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;92 orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl; 93 93 94 94 this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CHANNEL_COUNT, 0); 95 95 if ( this->server_==NULL ) 96 96 { 97 COUT(1) << "ClientConnection: server_ == NULL" << std::endl;97 orxout(internal_error, context::network) << "ClientConnection: server_ == NULL" << endl; 98 98 // error handling 99 99 return false; … … 113 113 } 114 114 } 115 COUT(1) << "Could not connect to server" << endl;115 orxout(user_error, context::network) << "Could not connect to server" << endl; 116 116 return false; 117 117 } … … 140 140 break; 141 141 case ENET_EVENT_TYPE_DISCONNECT: 142 COUT(4) << "received disconnect confirmation from server" << endl;142 orxout(verbose, context::network) << "received disconnect confirmation from server" << endl; 143 143 this->connectionClosed(); 144 144 return true; … … 167 167 { 168 168 this->established_=false; 169 COUT(1) << "Received disconnect Packet from Server!" << endl;169 orxout(internal_error, context::network) << "Received disconnect Packet from Server!" << endl; 170 170 // server closed the connection 171 171 this->stopCommunicationThread(); -
code/trunk/src/libraries/network/Connection.cc
r8327 r8858 144 144 while( outgoingEventsCount > 0 ) 145 145 { 146 // COUT(0) << "outgoing event" << endl;146 // orxout(verbose, context::network) << "outgoing event" << endl; 147 147 this->outgoingEventsMutex_->lock(); 148 148 outgoingEvent outEvent = this->outgoingEvents_.front(); -
code/trunk/src/libraries/network/GamestateManager.cc
r8407 r8858 52 52 #include "core/command/Executor.h" 53 53 #include "core/GameMode.h" 54 #include "util/ Debug.h"54 #include "util/Output.h" 55 55 #include "util/Clock.h" 56 56 #include "util/OrxAssert.h" … … 128 128 if( !this->sendPacket(ack)) 129 129 { 130 COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;130 orxout(internal_warning, context::network) << "could not ack gamestate: " << gamestateID << endl; 131 131 return false; 132 132 } 133 133 else 134 134 { 135 COUT(5) << "acked a gamestate: " << gamestateID << std::endl;135 orxout(verbose_more, context::network) << "acked a gamestate: " << gamestateID << endl; 136 136 return true; 137 137 } … … 182 182 if( !peerIt->second.isSynched ) 183 183 { 184 COUT(5) << "Server: not sending gamestate" << std::endl;184 orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl; 185 185 continue; 186 186 } 187 COUT(5) << "client id: " << peerIt->first << std::endl;188 COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;187 orxout(verbose_more, context::network) << "client id: " << peerIt->first << endl; 188 orxout(verbose_more, context::network) << "Server: doing gamestate gamestate preparation" << endl; 189 189 int peerID = peerIt->first; //get client id 190 190 … … 256 256 // OrxVerify(gs->compressData(), ""); 257 257 clock.capture(); 258 COUT(5) << "diff and compress time: " << clock.getDeltaTime() << endl;259 // COUT(5) << "sending gamestate with id " << gs->getID();258 orxout(verbose_more, context::network) << "diff and compress time: " << clock.getDeltaTime() << endl; 259 // orxout(verbose_more, context::network) << "sending gamestate with id " << gs->getID(); 260 260 // if(gamestate->isDiffed()) 261 // COUT(5) << " and baseid " << gs->getBaseID() << endl;261 // orxout(verbose_more, context::network) << " and baseid " << gs->getBaseID() << endl; 262 262 // else 263 // COUT(5) << endl;263 // orxout(verbose_more, context::network) << endl; 264 264 gs->setPeerID(peerID); 265 265 destgamestate = gs; … … 291 291 if( gamestateID <= curid && curid != GAMESTATEID_INITIAL ) 292 292 return true; 293 COUT(4) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << std::endl;293 orxout(verbose, context::network) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << endl; 294 294 std::map<uint32_t, packet::Gamestate*>::iterator it2; 295 295 for( it2=it->second.gamestates.begin(); it2!=it->second.gamestates.end(); ) -
code/trunk/src/libraries/network/Host.cc
r8408 r8858 32 32 #include <string> 33 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/ObjectList.h" 35 36 #include "core/command/ConsoleCommand.h" 36 #include " ChatListener.h"37 #include "NetworkChatListener.h" 37 38 38 39 namespace orxonox { … … 41 42 static const std::string __CC_printRTT_name = "printRTT"; 42 43 43 SetConsoleCommand("chat", &Host::Chat);44 44 SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT); 45 45 … … 89 89 } 90 90 91 void Host::Chat(const std::string& message) 91 /** 92 * @brief Sends a chat message through the network. 93 * @param message message to be sent 94 * @param sourceID the ID of the sender 95 * @param targetID the ID of the receiver 96 */ 97 void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 92 98 { 93 if(instances_s.size()==0) 94 { 95 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 96 it->incomingChat(message, 0); 97 // return true; 98 } 99 else 100 { 101 bool result = true; 102 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it ) 103 { 104 if( (*it)->isActive() ) 105 { 106 if( !(*it)->chat(message) ) 107 result = false; 108 } 109 } 110 // return result; 111 } 99 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it ) 100 if( (*it)->isActive() ) 101 (*it)->doSendChat(message, sourceID, targetID); 112 102 } 113 103 114 bool Host::Broadcast(const std::string& message) 104 /** 105 * @brief Gets called if a packet::Chat packet is received. Passes the message to the listeners. 106 */ 107 void Host::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 115 108 { 116 if(instances_s.size()==0) 117 { 118 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 119 it->incomingChat(message, NETWORK_PEER_ID_BROADCAST); 120 return true; 121 } 122 else 123 { 124 bool result = true; 125 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it ) 126 { 127 if( (*it)->isActive() ) 128 { 129 if( !(*it)->broadcast(message) ) 130 result = false; 131 } 132 } 133 return result; 134 } 109 for (ObjectList<NetworkChatListener>::iterator it = ObjectList<NetworkChatListener>::begin(); it != ObjectList<NetworkChatListener>::end(); ++it) 110 it->incomingChat(message, sourceID); 135 111 } 136 112 137 bool Host::incomingChat(const std::string& message, unsigned int playerID)138 {139 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)140 it->incomingChat(message, playerID);141 142 bool result = true;143 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )144 {145 if( (*it)->isActive() )146 {147 if( !(*it)->processChat(message, playerID) )148 result = false;149 }150 }151 return result;152 }153 113 154 114 bool Host::isServer() … … 156 116 for (std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it ) 157 117 { 158 if( (*it)->isServer_() ) 159 return true; 118 if( (*it)->isActive() ) 119 { 120 if( (*it)->isServer_() ) 121 return true; 122 } 160 123 } 161 124 return false; 162 125 } 163 126 164 127 Host* Host::getActiveInstance() 165 128 { … … 176 139 177 140 141 ////////////////////////////////////////////////////////////////////////// 142 // NetworkChatListener // 143 ////////////////////////////////////////////////////////////////////////// 144 145 NetworkChatListener::NetworkChatListener() 146 { 147 RegisterRootObject(NetworkChatListener); 148 } 149 178 150 }//namespace orxonox -
code/trunk/src/libraries/network/Host.h
r8403 r8858 52 52 class _NetworkExport Host: public GamestateManager 53 53 { 54 friend class packet::Chat; 55 54 56 private: 55 //TODO add these functions or adequate56 //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;57 //virtual bool sendChat(packet::Chat *chat)=0;58 57 virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID)=0; 59 virtual bool chat(const std::string& message)=0;60 virtual bool broadcast(const std::string& message)=0;61 virtual bool processChat(const std::string& message, unsigned int playerID)=0;62 58 virtual bool isServer_()=0; 63 64 65 59 66 60 protected: … … 68 62 virtual ~Host(); 69 63 void setActive( bool bActive ){ bIsActive_ = bActive; } 70 // static Host *instance_; 64 65 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0; 66 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0; 71 67 72 68 public: … … 74 70 static bool running(){ return instances_s.size(); } 75 71 static void addPacket(ENetPacket* packet, int clientID = NETWORK_PEER_ID_SERVER, uint8_t channelID = 0); 76 //static bool chat(std::string& message);77 // static bool receiveChat(packet::Chat *message, unsigned int clientID);78 72 static unsigned int getPlayerID(){ return clientID_s; } 79 73 static void setClientID(unsigned int id){ clientID_s = id; } 80 74 static bool isServer(); 81 static void Chat(const std::string& message); 82 static bool Broadcast(const std::string& message); 83 static bool incomingChat(const std::string& message, unsigned int playerID); 75 static void sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 84 76 virtual void printRTT()=0; 85 77 bool isActive(){ return bIsActive_; } -
code/trunk/src/libraries/network/LANDiscoverable.cc
r8351 r8858 33 33 #include <cstring> 34 34 35 #include "util/ Debug.h"35 #include "util/Output.h" 36 36 #include "packet/ServerInformation.h" 37 37 … … 71 71 this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 ); 72 72 if ( this->host_ == NULL ) 73 COUT(1) << "LANDiscoverable: host_ == NULL" << std::endl;73 orxout(internal_error, context::network) << "LANDiscoverable: host_ == NULL" << endl; 74 74 } 75 75 else … … 94 94 { 95 95 case ENET_EVENT_TYPE_CONNECT: 96 COUT(4) << "Received LAN discovery connect from client " << event.peer->host->receivedAddress << std::endl;96 orxout(verbose, context::network) << "Received LAN discovery connect from client " << event.peer->host->receivedAddress << endl; 97 97 break; 98 98 case ENET_EVENT_TYPE_DISCONNECT: … … 102 102 if( strcmp( LAN_DISCOVERY_MESSAGE, (char*)event.packet->data ) == 0 ) // check for a suitable orxonox client 103 103 { 104 COUT(3) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << std::endl;104 orxout(internal_info, context::network) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << endl; 105 105 packet::ServerInformation info; 106 106 info.setServerName("Orxonox Server"); -
code/trunk/src/libraries/network/LANDiscovery.cc
r8706 r8858 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Oliver Scheuss 24 24 * Co-authors: 25 25 * ... … … 44 44 this->host_ = enet_host_create(NULL, 10, 0, 0, 0 ); 45 45 if ( this->host_ == NULL ) 46 COUT(1) << "LANDiscovery: host_ == NULL" << std::endl;46 orxout(internal_error, context::network) << "LANDiscovery: host_ == NULL" << endl; 47 47 } 48 48 … … 66 66 peer = enet_host_connect(this->host_, &address, 0, 0); 67 67 if (peer == NULL) 68 COUT(1) << "Error: Could not send LAN discovery to IPv4 Broadcast." << std::endl;68 orxout(internal_error, context::network) << "Could not send LAN discovery to IPv4 Broadcast." << endl; 69 69 70 70 /* IPv6 */ … … 72 72 peer = enet_host_connect(this->host_, &address, 0, 0); 73 73 if (peer == NULL) 74 COUT(1) << "Error: Could not send LAN discovery to IPv6 Multicast." << std::endl;74 orxout(internal_error, context::network) << "Could not send LAN discovery to IPv6 Multicast." << endl; 75 75 76 76 ENetEvent event; … … 81 81 case ENET_EVENT_TYPE_CONNECT: 82 82 { 83 COUT(4) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << std::endl;83 orxout(verbose, context::network) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << endl; 84 84 ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE); 85 85 enet_peer_send(event.peer, 0, packet); … … 89 89 { 90 90 packet::ServerInformation info(&event); 91 COUT(3) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;91 orxout(internal_info, context::network) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl; 92 92 std::vector<packet::ServerInformation>::iterator it; 93 93 for( it=this->servers_.begin(); it!=this->servers_.end(); ++it ) -
code/trunk/src/libraries/network/LANDiscovery.h
r8351 r8858 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Oliver Scheuss 24 24 * Co-authors: 25 25 * ... -
code/trunk/src/libraries/network/MasterServer.cc
r8351 r8858 38 38 helper_output_debug( ENetEvent *event, char *addrconv ) 39 39 { 40 COUT(4) << "A packet of length" 40 orxout(verbose, context::master_server) 41 << "A packet of length" 41 42 << event->packet->dataLength 42 43 << " containing " … … 45 46 << addrconv 46 47 << " on channel " 47 << event->channelID << "\n";48 << event->channelID << endl; 48 49 } 49 50 … … 66 67 + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 ); 67 68 if( !tosend ) 68 { COUT(2) << "Masterserver.cc: Memory allocation failed.\n";69 { orxout(internal_warning, context::master_server) << "Masterserver.cc: Memory allocation failed." << endl; 69 70 continue; 70 71 } … … 108 109 { /* check for bad parameters */ 109 110 if( !event ) 110 { COUT(2) << "MasterServer::eventConnect: No event given.\n";111 { orxout(internal_warning, context::master_server) << "MasterServer::eventConnect: No event given." << endl; 111 112 return -1; 112 113 } … … 117 118 118 119 /* output debug info */ 119 COUT(4) << "A new client connected from "120 orxout(verbose, context::master_server) << "A new client connected from " 120 121 << addrconv 121 122 << " on port " 122 << event->peer->address.port << "\n";123 << event->peer->address.port << endl; 123 124 124 125 /* store string form of address here */ … … 134 135 { /* check for bad parameters */ 135 136 if( !event ) 136 { COUT(2) << "No event given.\n";137 { orxout(internal_warning, context::master_server) << "No event given." << endl; 137 138 return -1; 138 139 } 139 140 140 141 /* output that the disconnect happened */ 141 COUT(4) << (char*)event->peer->data << " disconnected.\n";142 orxout(verbose, context::master_server) << (char*)event->peer->data << " disconnected." << endl; 142 143 143 144 /* create string from peer data */ … … 159 160 { /* validate packet */ 160 161 if( !event || !(event->packet) || !(event->peer) ) 161 { COUT(2) << "No complete event given.\n";162 { orxout(internal_warning, context::master_server) << "No complete event given." << endl; 162 163 return -1; 163 164 } … … 182 183 183 184 /* tell people we did so */ 184 COUT(2) << "Added new server to list: " <<185 packet::ServerInformation( event ).getServerIP() << "\n";185 orxout(internal_info, context::master_server) << "Added new server to list: " << 186 packet::ServerInformation( event ).getServerIP() << endl; 186 187 } 187 188 … … 197 198 198 199 /* tell the user */ 199 COUT(2) << "Removed server " << name << " from list.\n";200 orxout(internal_info, context::master_server) << "Removed server " << name << " from list." << endl; 200 201 } 201 202 … … 230 231 if( event == NULL ) 231 232 { 232 COUT(1) << "Could not create ENetEvent structure, exiting.\n";233 orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl; 233 234 exit( EXIT_FAILURE ); 234 235 } … … 263 264 /***** INITIALIZE NETWORKING *****/ 264 265 if( enet_initialize () != 0) 265 { COUT(1) << "An error occurred while initializing ENet.\n";266 { orxout(user_error, context::master_server) << "An error occurred while initializing ENet." << endl; 266 267 exit( EXIT_FAILURE ); 267 268 } … … 285 286 /* see if creation worked */ 286 287 if( !this->server ) 287 { COUT(1) <<288 "An error occurred while trying to create an ENet server host. \n";288 { orxout(user_error, context::master_server) << 289 "An error occurred while trying to create an ENet server host." << endl; 289 290 exit( EXIT_FAILURE ); 290 291 } … … 294 295 295 296 /* tell people we're now initialized */ 296 COUT(0) << "MasterServer initialized, waiting for connections.\n";297 orxout(internal_status, context::master_server) << "MasterServer initialized, waiting for connections." << endl; 297 298 } 298 299 -
code/trunk/src/libraries/network/MasterServerComm.cc
r8351 r8858 28 28 29 29 #include "MasterServerComm.h" 30 #include "util/Debug.h" 30 #include "util/Output.h" 31 #include "WANDiscovery.h" 31 32 32 33 namespace orxonox … … 44 45 /* initialize Enet */ 45 46 if( enet_initialize () != 0 ) 46 { COUT(1) << "An error occurred while initializing ENet.\n";47 { orxout(internal_error, context::master_server) << "An error occurred while initializing ENet." << endl; 47 48 return 1; 48 49 } … … 61 62 /* see if it worked */ 62 63 if (this->client == NULL) 63 { COUT(1) << "An error occurred while trying to create an "64 << "ENet client host. \n";64 { orxout(internal_error, context::master_server) << "An error occurred while trying to create an " 65 << "ENet client host." << endl; 65 66 return 1; 66 67 } … … 85 86 86 87 if( this->peer == NULL ) 87 { COUT(2) << "ERROR:No available peers for initiating an ENet"88 << " connection. \n";88 { orxout(internal_error, context::master_server) << "No available peers for initiating an ENet" 89 << " connection." << endl; 89 90 return -1; 90 91 } … … 93 94 if (enet_host_service (this->client, &this->event, 500) > 0 && 94 95 this->event.type == ENET_EVENT_TYPE_CONNECT ) 95 COUT(3) << "Connection to master server succeeded.\n";96 orxout(internal_info, context::master_server) << "Connection to master server succeeded." << endl; 96 97 else 97 98 { 98 99 enet_peer_reset (this->peer); 99 COUT(2) << "ERROR: connection to " << address << " failed.\n";100 orxout(internal_warning, context::master_server) << "Connection to " << address << " failed." << endl; 100 101 return -1; 101 102 } … … 128 129 129 130 case ENET_EVENT_TYPE_DISCONNECT: 130 COUT(4) << "Disconnect from master server successful.\n";131 orxout(verbose, context::master_server) << "Disconnect from master server successful." << endl; 131 132 return 0; 132 133 default: break; … … 149 150 * so we can also make callbacks from objects 150 151 */ 151 int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ), 152 int delayms ) 152 int MasterServerComm::pollForReply( WANDiscovery* listener, int delayms ) 153 153 { 154 154 /* see whether anything happened */ 155 155 /* WORK MARK REMOVE THIS OUTPUT */ 156 COUT(2) << "polling masterserver...\n";156 orxout(verbose, context::master_server) << "polling masterserver..." << endl; 157 157 158 158 /* address buffer */ … … 176 176 addrconv = (char *) calloc( 50, 1 ); 177 177 if( !addrconv ) 178 { COUT(2) << "MasterServerComm.cc: Could not allocate memory!\n";178 { orxout(internal_warning, context::master_server) << "MasterServerComm.cc: Could not allocate memory!" << endl; 179 179 break; 180 180 } … … 185 185 186 186 /* DEBUG */ 187 COUT(3) << "MasterServer Debug: A packet of length "187 orxout(verbose, context::master_server) << "MasterServer Debug: A packet of length " 188 188 << this->event.packet->dataLength 189 189 << " containing " << this->event.packet->data … … 193 193 194 194 /* call the supplied callback, if any. */ 195 if( (*callback)!= NULL )196 retval = (*callback)( addrconv, &(this->event) );195 if( listener != NULL ) 196 retval = listener->rhandler( addrconv, &(this->event) ); 197 197 198 198 /* clean up */ -
code/trunk/src/libraries/network/MasterServerComm.h
r8351 r8858 93 93 * 94 94 * Poll the master server for new data and act accordingly */ 95 int pollForReply( int (*callback)( char*, ENetEvent* ), int delayms );95 int pollForReply( WANDiscovery* listener, int delayms ); 96 96 97 97 private: -
code/trunk/src/libraries/network/NetworkPrecompiledHeaders.h
r8351 r8858 52 52 #include <set> // 20 53 53 54 #include "util/ Debug.h" // 2054 #include "util/Output.h" // 20 55 55 #include <loki/TypeTraits.h> // 18 56 56 -
code/trunk/src/libraries/network/NetworkPrereqs.h
r8351 r8858 118 118 namespace orxonox 119 119 { 120 class ChatListener;121 120 class Client; 122 121 class ClientConnection; … … 130 129 class GamestateManager; 131 130 class Host; 131 class MasterServer; 132 class MasterServerComm; 133 class NetworkChatListener; 132 134 class NetworkFunctionBase; 133 135 struct NetworkFunctionPointer; … … 136 138 class NetworkMemberFunction; 137 139 class NetworkMemberFunctionBase; 140 class PeerList; 138 141 class Server; 139 142 class ServerConnection; 140 143 class TrafficControl; 144 class WANDiscoverable; 145 class WANDiscovery; 141 146 142 147 // packet -
code/trunk/src/libraries/network/PeerList.cc
r8351 r8858 28 28 29 29 #include "PeerList.h" 30 #include <network/packet/ServerInformation.h> 30 31 31 #include <cstdio> 32 #include "util/Output.h" 33 #include "network/packet/ServerInformation.h" 32 34 33 35 namespace orxonox … … 40 42 { /* error correction */ 41 43 if( toadd == NULL ) 42 { fprintf( stderr, "PeerList::addPeer: empty peer given.\n" );44 { orxout(internal_error, context::master_server) << "PeerList::addPeer: empty peer given." << endl; 43 45 return -1; 44 46 } -
code/trunk/src/libraries/network/Server.cc
r8706 r8858 47 47 48 48 #include "util/Clock.h" 49 #include "util/ Debug.h"49 #include "util/Output.h" 50 50 #include "core/ObjectList.h" 51 51 #include "core/command/Executor.h" … … 56 56 #include "packet/Gamestate.h" 57 57 #include "packet/Welcome.h" 58 #include "ChatListener.h"59 58 // #include "ClientInformation.h" 60 59 #include "FunctionCallManager.h" 61 60 #include "GamestateManager.h" 62 #include "WANDiscovery.h"63 61 64 62 namespace orxonox … … 100 98 } 101 99 102 103 /** helper that connects to the master server */104 void Server::helper_ConnectToMasterserver()105 {106 // WANDiscovery::getInstance().msc.sendRequest( MSPROTO_GAME_SERVER " "107 // MSPROTO_REGISTER_SERVER );108 }109 110 100 /** 111 101 * This function opens the server by creating the listener thread … … 114 104 { 115 105 Host::setActive(true); 116 COUT(4) << "opening server" << endl;106 orxout(verbose, context::network) << "opening server" << endl; 117 107 this->openListener(); 118 108 119 109 /* make discoverable on LAN */ 120 110 LANDiscoverable::setActivity(true); … … 122 112 /* make discoverable on WAN */ 123 113 WANDiscoverable::setActivity(true); 124 /* TODO this needs to be optional, we need a switch from the UI to125 * enable/disable this126 */127 // helper_ConnectToMasterserver();128 114 129 115 /* done */ … … 137 123 { 138 124 Host::setActive(false); 139 COUT(4) << "closing server" << endl;125 orxout(verbose, context::network) << "closing server" << endl; 140 126 this->disconnectClients(); 141 127 this->closeListener(); 142 128 143 129 /* tell master server we're closing */ 144 COUT(2) << "disconnecting." << endl;145 WANDiscoverable::setActivity(false); 146 COUT(2) << "disconnecting done" << endl;130 orxout(internal_info, context::network) << "disconnecting." << endl; 131 WANDiscoverable::setActivity(false); 132 orxout(internal_info, context::network) << "disconnecting done" << endl; 147 133 148 134 LANDiscoverable::setActivity(false); 149 135 return; 150 }151 152 bool Server::processChat(const std::string& message, unsigned int playerID)153 {154 // ClientInformation *temp = ClientInformation::getBegin();155 packet::Chat *chat;156 // while(temp){157 chat = new packet::Chat(message, playerID);158 chat->setPeerID(NETWORK_PEER_ID_BROADCAST);159 chat->send( static_cast<Host*>(this) );160 // COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;161 // temp = temp->next();162 // }163 // COUT(1) << "Player " << playerID << ": " << message << std::endl;164 return true;165 }166 167 168 /* handle incoming data */169 int rephandler( char *addr, ENetEvent *ev )170 {171 /* reply to pings */172 if( !strncmp( (char *)ev->packet->data, MSPROTO_PING_GAMESERVER,173 MSPROTO_PING_GAMESERVER_LEN ) )174 //this->msc.sendRequest( MSPROTO_ACK );175 /* NOTE implement this after pollForReply176 * reimplementation177 */178 return 0;179 180 /* done handling, return all ok code 0 */181 return 0;182 }183 184 void Server::helper_HandleMasterServerRequests()185 {186 /* poll the master server for replies and see whether something187 * has to be done or changed.188 */189 //WANDiscovery::getInstance().msc.pollForReply( rhandler, 10 );190 136 } 191 137 … … 202 148 // receive and process incoming discovery packets 203 149 LANDiscoverable::update(); 204 205 // receive and process requests from master server206 /* todo */207 //helper_HandleMasterServerRequests();208 150 209 151 if ( GamestateManager::hasPeers() ) … … 246 188 { 247 189 // for( ClientInformation* temp=ClientInformation::getBegin(); temp!=0; temp=temp->next() ) 248 // COUT(0) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl;190 // orxout(message) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl; 249 191 } 250 192 … … 268 210 return; 269 211 GamestateManager::update(); 270 // COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;271 // std::cout << "updated gamestate, sending it" << std::endl;212 // orxout(verbose_more, context::network) << "Server: one gamestate update complete, goig to sendGameState" << endl; 213 //orxout(verbose_more, context::network) << "updated gamestate, sending it" << endl; 272 214 //if(clients->getGamestateID()!=GAMESTATEID_INITIAL) 273 215 sendGameStates(); 274 216 sendObjectDeletes(); 275 // COUT(5) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;276 // std::cout << "sent gamestate" << std::endl;217 // orxout(verbose_more, context::network) << "Server: one sendGameState turn complete, repeat in next tick" << endl; 218 //orxout(verbose_more, context::network) << "sent gamestate" << endl; 277 219 } 278 220 … … 305 247 return true; //everything ok (no deletes this tick) 306 248 } 307 // COUT(3) << "sending DeleteObjects" << std::endl;249 // orxout(verbose, context::network) << "sending DeleteObjects" << endl; 308 250 // while(temp != NULL){ 309 251 // if( !(temp->getSynched()) ) 310 252 // { 311 // COUT(5) << "Server: not sending gamestate" << std::endl;253 // orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl; 312 254 // temp=temp->next(); 313 255 // continue; … … 318 260 del->setPeerID(NETWORK_PEER_ID_BROADCAST); 319 261 if ( !del->send( static_cast<Host*>(this) ) ) 320 COUT(3) << "Server: could not broadcast deleteObjects packet" << std::endl;262 orxout(internal_warning, context::network) << "Server: could not broadcast deleteObjects packet" << endl; 321 263 // temp=temp->next(); 322 264 // gs gets automatically deleted by enet callback … … 330 272 { 331 273 // static unsigned int newid=1; 332 // 333 // COUT(2) << "Server: adding client" << std::endl;274 // 275 // orxout(internal_info, context::network) << "Server: adding client" << endl; 334 276 // ClientInformation *temp = ClientInformation::insertBack(new ClientInformation); 335 277 // if(!temp) 336 278 // { 337 // COUT(2) << "Server: could not add client" << std::endl;279 // orxout(internal_warning, context::network) << "Server: could not add client" << endl; 338 280 // } 339 281 // temp->setID(newid); … … 347 289 // ++newid; 348 290 349 COUT(3) << "Server: added client id: " << peerID << std::endl;291 orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl; 350 292 createClient(peerID); 351 293 } … … 353 295 void Server::removePeer(uint32_t peerID) 354 296 { 355 COUT(4) << "removing client from list" << std::endl;297 orxout(verbose, context::network) << "removing client from list" << endl; 356 298 // ClientInformation *client = ClientInformation::findClient(&event->peer->address); 357 299 // if(!client) … … 375 317 // } 376 318 } 377 319 378 320 void Server::processPacket(packet::Packet* packet) 379 321 { … … 395 337 // if(!temp) 396 338 // { 397 // COUT(2) << "Server. could not create client with id: " << clientID << std::endl;339 // orxout(internal_error, context::network) << "Server. could not create client with id: " << clientID << endl; 398 340 // return false; 399 341 // } 400 // COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;342 // orxout(verbose, context::network) << "Con.Man: creating client id: " << temp->getID() << endl; 401 343 402 344 // synchronise class ids … … 411 353 // temp->setSynched(true); 412 354 GamestateManager::setSynched(clientID); 413 414 COUT(4) << "sending welcome" << std::endl;355 356 orxout(verbose, context::network) << "sending welcome" << endl; 415 357 packet::Welcome *w = new packet::Welcome(clientID); 416 358 w->setPeerID(clientID); … … 438 380 } 439 381 440 bool Server::chat(const std::string& message) 441 { 442 return this->sendChat(message, Host::getPlayerID()); 443 } 444 445 bool Server::broadcast(const std::string& message) 446 { 447 return this->sendChat(message, NETWORK_PEER_ID_BROADCAST); 448 } 449 450 bool Server::sendChat(const std::string& message, unsigned int clientID) 451 { 452 // ClientInformation *temp = ClientInformation::getBegin(); 453 packet::Chat *chat; 454 // while(temp) 455 { 456 chat = new packet::Chat(message, clientID); 457 chat->setPeerID(NETWORK_PEER_ID_BROADCAST); 458 chat->send( static_cast<Host*>(this) ); 459 // COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl; 460 // temp = temp->next(); 461 } 462 // COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl; 463 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 464 it->incomingChat(message, clientID); 465 466 return true; 382 /** 383 * @brief Sends a chat message to the given target ID. 384 * @param message message to be sent 385 * @param sourceID the ID of the sender 386 * @param targetID the ID of the receiver 387 */ 388 void Server::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 389 { 390 // check if the target exists. just ignore the message otherwise 391 if (!this->isValidTarget(targetID)) // TODO: remove this if an invalid clientIDs don't trigger assertions anymore 392 return; 393 394 // send the message to the target 395 packet::Chat* packet = new packet::Chat(message, sourceID, targetID); 396 packet->setPeerID(targetID); 397 packet->send( static_cast<Host*>(this) ); 398 399 // if the target is (or includes) this host as well, call the parent function which passes the message to the listeners 400 if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == Host::getPlayerID()) 401 Host::doReceiveChat(message, sourceID, targetID); 402 } 403 404 /** 405 * @brief Gets called if a packet::Chat packet is received. Forwards the packet to the target 406 * and calls the parent function if necessary. 407 */ 408 void Server::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 409 { 410 this->doSendChat(message, sourceID, targetID); 411 } 412 413 /** 414 * @brief Returns true if the target ID is in the list of clients (or if it 415 * corresponds to the broadcast or the server ID). 416 */ 417 bool Server::isValidTarget(unsigned int targetID) 418 { 419 if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == NETWORK_PEER_ID_SERVER) 420 return true; 421 422 std::vector<uint32_t>::iterator it; 423 for( it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it ) 424 if( *it == targetID ) 425 return true; 426 427 return false; 467 428 } 468 429 … … 476 437 } 477 438 assert(failures<10); 478 COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;439 orxout(verbose, context::network) << "syncClassid:\tall synchClassID packets have been sent" << endl; 479 440 } 480 441 -
code/trunk/src/libraries/network/Server.h
r8351 r8858 42 42 #include "LANDiscoverable.h" 43 43 #include "WANDiscoverable.h" 44 // #include "MasterServerComm.h"45 // #include "MasterServerProtocol.h"46 44 47 45 … … 61 59 ~Server(); 62 60 63 /* helpers */64 void helper_ConnectToMasterserver();65 void helper_HandleMasterServerRequests();66 int replyhandler( char *addr, ENetEvent *ev );67 68 61 void open(); 69 62 void close(); 70 bool processChat(const std::string& message, unsigned int playerID);71 63 void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID); 72 64 virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); } … … 89 81 bool sendGameStates(); 90 82 bool sendObjectDeletes(); 91 virtual bool chat(const std::string& message);92 virtual bool broadcast(const std::string& message);93 bool sendChat(const std::string& message, unsigned int clientID);83 bool isValidTarget(unsigned int targetID); 84 virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 85 virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID); 94 86 void syncClassid(unsigned int clientID); 95 87 -
code/trunk/src/libraries/network/ServerConnection.cc
r8358 r8858 34 34 #include <enet/enet.h> 35 35 36 #include "util/ Debug.h"36 #include "util/Output.h" 37 37 #include <util/Sleep.h> 38 38 // #include "ClientInformation.h" … … 61 61 { 62 62 if (enet_address_set_host (this->bindAddress_, bindAddress.c_str()) < 0) 63 COUT(1) << "Error: Could not resolve \"" << bindAddress << "\"." << std::endl;63 orxout(internal_error, context::network) << "Could not resolve \"" << bindAddress << "\"." << endl; 64 64 } 65 65 … … 75 75 if ( this->host_ == NULL ) 76 76 { 77 COUT(1) << "ServerConnection: host_ == NULL" << std::endl;77 orxout(internal_error, context::network) << "ServerConnection: host_ == NULL" << endl; 78 78 return false; 79 79 } … … 83 83 assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL ); 84 84 if (this->host_->socket4 == ENET_SOCKET_NULL) 85 COUT(2) << "Warning: IPv4 Socket failed." << std::endl;85 orxout(internal_warning, context::network) << "IPv4 Socket failed." << endl; 86 86 else if (this->host_->socket6 == ENET_SOCKET_NULL) 87 COUT(2) << "Warning: IPv6 Socket failed." << std::endl;87 orxout(internal_warning, context::network) << "IPv6 Socket failed." << endl; 88 88 else 89 COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;89 orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl; 90 90 91 91 // start communication thread … … 114 114 // ClientInformation *temp = ClientInformation::findClient(clientID); 115 115 // if(!temp){ 116 // COUT(3) << "C.Man: addPacket findClient failed" << std::endl;116 // orxout(internal_warning, context::network) << "C.Man: addPacket findClient failed" << endl; 117 117 // } 118 118 Connection::addPacket(packet, clientID, channelID); -
code/trunk/src/libraries/network/TrafficControl.cc
r6417 r8858 287 287 { 288 288 std::list<obj>::iterator it; 289 COUT(0) << "=========== Objectlist ===========" << endl;289 orxout(debug_output, context::network) << "=========== Objectlist ===========" << endl; 290 290 for( it=list.begin(); it!=list.end(); it++) 291 COUT(0) << "ObjectID: " << it->objID << " creatorID: " << it->objCreatorID << " Priority: " << clientListPerm_[clientID][it->objID].objValuePerm + clientListPerm_[clientID][it->objID].objValueSched << " size: " << it->objSize << endl;291 orxout(debug_output, context::network) << "ObjectID: " << it->objID << " creatorID: " << it->objCreatorID << " Priority: " << clientListPerm_[clientID][it->objID].objValuePerm + clientListPerm_[clientID][it->objID].objValueSched << " size: " << it->objSize << endl; 292 292 } 293 293 -
code/trunk/src/libraries/network/WANDiscoverable.cc
r8351 r8858 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau (original)23 * Sandro 'smerkli' Merkli 24 24 * Co-authors: 25 * Sandro 'smerkli' Merkli (adaptions to WAN) 26 * ... 25 * Oliver Scheuss (original) 27 26 * 28 27 */ … … 44 43 { 45 44 /* debugging output */ 46 COUT(4) << "Creating WANDiscoverable.\n";45 orxout(verbose, context::master_server) << "Creating WANDiscoverable." << endl; 47 46 48 47 /* register object in orxonox */ … … 91 90 if( msc.initialize() ) 92 91 { 93 COUT(2) << "Error: could not initialize master server communications!\n";92 orxout(internal_error, context::master_server) << "Could not initialize master server communications!" << endl; 94 93 return false; 95 94 } … … 98 97 if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) ) 99 98 { 100 COUT(2) << "Error: could not connect to master server at "101 << this->msaddress << std::endl;99 orxout(internal_error, context::master_server) << "Could not connect to master server at " 100 << this->msaddress << endl; 102 101 return false; 103 102 } 104 103 105 104 /* debugging output */ 106 COUT(4) << "Initialization of WANDiscoverable complete.\n";105 orxout(verbose, context::master_server) << "Initialization of WANDiscoverable complete." << endl; 107 106 108 107 -
code/trunk/src/libraries/network/WANDiscoverable.h
r8729 r8858 19 19 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 20 * 21 * Author: Fabian 'x3n' Landau (original) Co-authors: Sandro 'smerkli' Merkli 22 * (copied and adapted to WAN) 21 * Author: 22 * Sandro 'smerkli' Merkli 23 * Co-authors: 24 * Oliver Scheuss (original) 23 25 * 24 26 */ -
code/trunk/src/libraries/network/WANDiscovery.cc
r8351 r8858 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau (original)23 * Sandro 'smerkli' Merkli 24 24 * Co-authors: 25 * Sandro 'smerkli' Merkli (adaptions to WAN) 26 * ... 25 * Oliver Scheuss (original) 27 26 * 28 27 */ … … 33 32 #include <cstring> 34 33 35 #include "util/ScopedSingletonManager.h"36 34 #include "core/CoreIncludes.h" 37 35 … … 39 37 namespace orxonox 40 38 { 41 ManageScopedSingleton(WANDiscovery, ScopeID::Graphics, true);42 43 44 39 WANDiscovery::WANDiscovery() 45 40 { 46 41 /* debugging output */ 47 COUT(4) << "Creating WANDiscovery.\n";42 orxout(verbose, context::master_server) << "Creating WANDiscovery." << endl; 48 43 49 44 /* register object in orxonox */ … … 55 50 /* initialize it and see if it worked */ 56 51 if( msc.initialize() ) 57 COUT(2) << "Error: could not initialize master server communications!\n";52 orxout(internal_error, context::master_server) << "Could not initialize master server communications!" << endl; 58 53 59 54 /* connect and see if it worked */ 60 55 if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) ) 61 COUT(2) << "Error: could not connect to master server at "62 << this->msaddress << std::endl;56 orxout(internal_error, context::master_server) << "Could not connect to master server at " 57 << this->msaddress << endl; 63 58 64 59 /* debugging output */ 65 COUT(4) << "Initialization of WANDiscovery complete.\n";60 orxout(verbose, context::master_server) << "Initialization of WANDiscovery complete." << endl; 66 61 } 67 62 … … 81 76 82 77 /* callback for the network reply poller */ 83 int rhandler( char *addr, ENetEvent *ev )78 int WANDiscovery::rhandler( char *addr, ENetEvent *ev ) 84 79 { 85 80 /* error recognition */ 86 81 if( !ev || !ev->packet || !ev->packet->data ) 87 { COUT(2) << "Bad arguments received in WANDiscovery's reply handler.\n";82 { orxout(internal_warning, context::master_server) << "Bad arguments received in WANDiscovery's reply handler." << endl; 88 83 return 0; 89 84 } … … 104 99 105 100 /* add to list */ 106 WANDiscovery::getInstance().servers_.push_back( toadd );101 this->servers_.push_back( toadd ); 107 102 } 108 103 else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END, … … 133 128 { 134 129 /* poll for reply and act according to what was received */ 135 switch( this->msc.pollForReply( rhandler, 500 ) )130 switch( this->msc.pollForReply( this, 500 ) ) 136 131 { case 0: /* no event occured, decrease timeout */ 137 132 --i; break; -
code/trunk/src/libraries/network/WANDiscovery.h
r8351 r8858 19 19 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 20 * 21 * Author: Fabian 'x3n' Landau (original) Co-authors: Sandro 'smerkli' Merkli 22 * (copied and adapted to WAN) 21 * Author: 22 * Sandro 'smerkli' Merkli 23 * Co-authors: 24 * Oliver Scheuss (original) 23 25 * 24 26 */ … … 30 32 #include "packet/ServerInformation.h" 31 33 #include "core/ConfigFileManager.h" 32 #include "util/Singleton.h"33 34 #include "core/OrxonoxClass.h" 34 35 #include "core/ConfigValueIncludes.h" … … 47 48 class _NetworkExport WANDiscovery 48 49 // tolua_end 49 : public Singleton<WANDiscovery>, publicOrxonoxClass50 : public OrxonoxClass 50 51 { // tolua_export 51 friend class Singleton<WANDiscovery>;52 52 public: 53 53 /** constructor */ 54 WANDiscovery(); 54 WANDiscovery(); // tolua_export 55 55 56 56 /** destructor */ … … 81 81 std::string getServerListItemIP( unsigned int index ); // tolua_export 82 82 83 /** \return an instance of WANDiscovery84 *85 * Create and return an instance of WANDiscovery.86 */87 static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export88 89 83 /* todo: might make this private and use getter/setter methods 90 84 * at some later time. … … 98 92 /** Master server communications object */ 99 93 MasterServerComm msc; 94 95 int rhandler( char *addr, ENetEvent *ev ); 100 96 101 97 private: 102 /** Singleton pointer */103 static WANDiscovery* singletonPtr_s;104 105 98 /** master server address */ 106 99 std::string msaddress; -
code/trunk/src/libraries/network/packet/Acknowledgement.cc
r7801 r8858 29 29 #include "Acknowledgement.h" 30 30 31 #include "util/ Debug.h"31 #include "util/Output.h" 32 32 #include "network/GamestateHandler.h" 33 33 #include "network/Host.h" … … 64 64 65 65 bool Acknowledgement::process(orxonox::Host* host){ 66 COUT(5) << "processing ACK with ID: " << getAckID() << endl;66 orxout(verbose_more, context::packets) << "processing ACK with ID: " << getAckID() << endl; 67 67 bool b = host->ackGamestate(getAckID(), peerID_); 68 68 delete this; -
code/trunk/src/libraries/network/packet/Chat.cc
r7801 r8858 39 39 40 40 /* Some lengths */ 41 #define _PACKETID 0 42 const int _PLAYERID = _PACKETID + sizeof(Type::Value); 43 #define _MESSAGELENGTH _PLAYERID + sizeof(uint32_t) 44 #define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t) 41 #define _PACKETID 0 42 #define _SOURCEID _PACKETID + sizeof(Type::Value) 43 #define _TARGETID _SOURCEID + sizeof(uint32_t) 44 #define _MESSAGELENGTH _TARGETID + sizeof(uint32_t) 45 #define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t) 45 46 46 Chat::Chat( const std::string& message, unsigned int playerID )47 Chat::Chat( const std::string& message, unsigned int sourceID, unsigned int targetID ) 47 48 : Packet() 48 49 { … … 57 58 58 59 *(Type::Value *)(data_ + _PACKETID ) = Type::Chat; 59 *(unsigned int *)(data_ + _PLAYERID ) = playerID; 60 *(unsigned int *)(data_ + _SOURCEID ) = sourceID; 61 *(unsigned int *)(data_ + _TARGETID ) = targetID; 60 62 *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_; 61 63 … … 81 83 82 84 bool Chat::process(orxonox::Host* host){ 83 bool b = host->incomingChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_PLAYERID));85 host->doReceiveChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_SOURCEID), *(uint32_t *)(data_+_TARGETID)); 84 86 delete this; 85 return b;87 return true; 86 88 } 87 89 -
code/trunk/src/libraries/network/packet/Chat.h
r7801 r8858 42 42 public: 43 43 /* constructors */ 44 Chat( const std::string& message, unsigned int playerID );44 Chat( const std::string& message, unsigned int sourceID, unsigned int targetID ); 45 45 Chat( uint8_t* data, unsigned int clientID ); 46 46 -
code/trunk/src/libraries/network/packet/ClassID.cc
r7801 r8858 92 92 assert(tempsize==packetSize); 93 93 94 COUT(5) << "classid packetSize is " << packetSize << endl;94 orxout(verbose_more, context::packets) << "classid packetSize is " << packetSize << endl; 95 95 96 96 } … … 131 131 Identifier::clearNetworkIDs(); 132 132 133 COUT(4) << "=== processing classids: " << endl;133 orxout(verbose, context::packets) << "=== processing classids: " << endl; 134 134 std::pair<uint32_t, std::string> tempPair; 135 135 Identifier *id; … … 143 143 classname = temp+2*sizeof(uint32_t); 144 144 id=ClassByString( std::string((const char*)classname) ); 145 COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;145 orxout(internal_info, context::packets) << "processing classid: " << networkID << " name: " << classname << " id: " << id << endl; 146 146 if(id==NULL){ 147 COUT(0) << "Received a bad classname" << endl;147 orxout(user_error, context::packets) << "Received a bad classname" << endl; 148 148 abort(); 149 149 } -
code/trunk/src/libraries/network/packet/DeleteObjects.cc
r7801 r8858 31 31 32 32 #include <cassert> 33 #include "util/ Debug.h"33 #include "util/Output.h" 34 34 #include "network/synchronisable/Synchronisable.h" 35 35 … … 62 62 if(number==0) 63 63 return false; 64 COUT(4) << "sending DeleteObjects: ";64 orxout(verbose, context::packets) << "sending DeleteObjects: "; 65 65 unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1); 66 66 data_ = new uint8_t[size]; … … 73 73 unsigned int temp = Synchronisable::popDeletedObject(); 74 74 *reinterpret_cast<uint32_t*>(tdata) = temp; 75 COUT(4) << temp << ' ';75 orxout(verbose, context::packets) << temp << ' '; 76 76 tdata += sizeof(uint32_t); 77 77 } 78 COUT(4) << std::endl;78 orxout(verbose, context::packets) << endl; 79 79 return true; 80 80 } … … 90 90 for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++) 91 91 { 92 COUT(4) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;92 orxout(verbose, context::packets) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << endl; 93 93 Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) ); 94 94 } -
code/trunk/src/libraries/network/packet/FunctionIDs.cc
r7801 r8858 34 34 #include <string> 35 35 36 #include "util/ Debug.h"36 #include "util/Output.h" 37 37 #include "core/ObjectList.h" 38 38 #include "network/NetworkFunction.h" … … 88 88 } 89 89 90 COUT(5) << "FunctionIDs packetSize is " << packetSize << endl;90 orxout(verbose_more, context::packets) << "FunctionIDs packetSize is " << packetSize << endl; 91 91 92 92 } … … 126 126 unsigned char *functionname; 127 127 128 COUT(4) << "=== processing functionids: " << endl;128 orxout(verbose, context::packets) << "=== processing functionids: " << endl; 129 129 std::pair<uint32_t, std::string> tempPair; 130 130 // read the total number of classes … … 137 137 stringsize = *(uint32_t*)(temp+sizeof(uint32_t)); 138 138 functionname = temp+2*sizeof(uint32_t); 139 COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl;139 orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl; 140 140 NetworkFunctionBase::setNetworkID((const char*)functionname, networkID); 141 141 temp += 2*sizeof(uint32_t) + stringsize; -
code/trunk/src/libraries/network/packet/Gamestate.cc
r8394 r8858 31 31 #include <zlib.h> 32 32 33 #include "util/ Debug.h"33 #include "util/Output.h" 34 34 #include "util/OrxAssert.h" 35 35 #include "core/GameMode.h" … … 108 108 uint32_t size = calcGamestateSize(id, mode); 109 109 110 COUT(5) << "G.ST.Man: producing gamestate with id: " << id << std::endl;110 orxout(verbose_more, context::packets) << "G.ST.Man: producing gamestate with id: " << id << endl; 111 111 if(size==0) 112 112 return false; … … 114 114 if(!data_) 115 115 { 116 COUT(2) << "GameStateManager: could not allocate memory" << std::endl;116 orxout(internal_warning, context::packets) << "GameStateManager: could not allocate memory" << endl; 117 117 return false; 118 118 } … … 139 139 assert(0); // if we don't use multithreading this part shouldn't be neccessary 140 140 // start allocate additional memory 141 COUT(3) << "Gamestate: need additional memory" << std::endl;141 orxout(internal_info, context::packets) << "Gamestate: need additional memory" << endl; 142 142 ObjectList<Synchronisable>::iterator temp = it; 143 143 uint32_t addsize=tempsize; … … 167 167 //stop write gamestate header 168 168 169 COUT(5) << "Gamestate: Gamestate size: " << currentsize << std::endl;170 COUT(5) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << std::endl;169 orxout(verbose_more, context::packets) << "Gamestate: Gamestate size: " << currentsize << endl; 170 orxout(verbose_more, context::packets) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << endl; 171 171 return true; 172 172 } … … 175 175 bool Gamestate::spreadData(uint8_t mode) 176 176 { 177 COUT(5) << "processing gamestate with id " << header_.getID() << endl;177 orxout(verbose_more, context::packets) << "processing gamestate with id " << header_.getID() << endl; 178 178 assert(data_); 179 179 assert(!header_.isCompressed()); … … 195 195 else 196 196 { 197 // COUT(4) << "not creating object of classid " << objectheader.getClassID() << endl;197 // orxout(verbose, context::packets) << "not creating object of classid " << objectheader.getClassID() << endl; 198 198 mem += objectheader.getDataSize() + ( objectheader.isDiffed() ? SynchronisableHeaderLight::getSize() : SynchronisableHeader::getSize() ); 199 199 } … … 201 201 else 202 202 { 203 // COUT(4) << "updating object of classid " << objectheader.getClassID() << endl;203 // orxout(verbose, context::packets) << "updating object of classid " << objectheader.getClassID() << endl; 204 204 OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data"); 205 205 } … … 219 219 if (it->objectMode_ != 0x0) 220 220 { 221 COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;222 COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;223 COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;221 orxout(user_error, context::packets) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << endl; 222 orxout(user_error, context::packets) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << endl; 223 orxout(user_error, context::packets) << "Objects class: " << it->getIdentifier()->getName() << endl; 224 224 assert(false); 225 225 } … … 232 232 if (it->getObjectID() == *it2) 233 233 { 234 COUT(0) << "Found duplicate objectIDs on the client!" << std::endl235 << "Are you sure you don't create a Sychnronisable objcect with 'new' \236 that doesn't have objectMode = 0x0?" << std::endl;234 orxout(user_error, context::packets) << "Found duplicate objectIDs on the client!" << endl 235 << "Are you sure you don't create a Sychnronisable objcect with 'new' \ 236 that doesn't have objectMode = 0x0?" << endl; 237 237 assert(false); 238 238 } … … 293 293 switch ( retval ) 294 294 { 295 case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;296 case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; return false;297 case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; return false;298 case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; return false;295 case Z_OK: orxout(verbose_more, context::packets) << "G.St.Man: compress: successfully compressed" << endl; break; 296 case Z_MEM_ERROR: orxout(internal_error, context::packets) << "G.St.Man: compress: not enough memory available in gamestate.compress" << endl; return false; 297 case Z_BUF_ERROR: orxout(internal_warning, context::packets) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << endl; return false; 298 case Z_DATA_ERROR: orxout(internal_warning, context::packets) << "G.St.Man: compress: data corrupted in gamestate.compress" << endl; return false; 299 299 } 300 300 … … 310 310 header_.setCompSize( buffer ); 311 311 header_.setCompressed( true ); 312 COUT(4) << "gamestate compress datasize: " << header_.getDataSize() << " compsize: " << header_.getCompSize() << std::endl;312 orxout(verbose, context::packets) << "gamestate compress datasize: " << header_.getDataSize() << " compsize: " << header_.getCompSize() << endl; 313 313 return true; 314 314 } … … 319 319 assert(data_); 320 320 assert(header_.isCompressed()); 321 COUT(4) << "GameStateClient: uncompressing gamestate. id: " << header_.getID() << ", baseid: " << header_.getBaseID() << ", datasize: " << header_.getDataSize() << ", compsize: " << header_.getCompSize() << std::endl;321 orxout(verbose, context::packets) << "GameStateClient: uncompressing gamestate. id: " << header_.getID() << ", baseid: " << header_.getBaseID() << ", datasize: " << header_.getDataSize() << ", compsize: " << header_.getCompSize() << endl; 322 322 uint32_t datasize = header_.getDataSize(); 323 323 uint32_t compsize = header_.getCompSize(); … … 333 333 switch ( retval ) 334 334 { 335 case Z_OK: COUT(5) << "successfully decompressed" << std::endl; break;336 case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return false;337 case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return false;338 case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;335 case Z_OK: orxout(verbose_more, context::packets) << "successfully decompressed" << endl; break; 336 case Z_MEM_ERROR: orxout(internal_error, context::packets) << "not enough memory available" << endl; return false; 337 case Z_BUF_ERROR: orxout(internal_warning, context::packets) << "not enough memory available in the buffer" << endl; return false; 338 case Z_DATA_ERROR: orxout(internal_warning, context::packets) << "data corrupted (zlib)" << endl; return false; 339 339 } 340 340 … … 375 375 if( memcmp( origDataPtr+objectOffset, baseDataPtr+objectOffset, objectHeader.getDataSize()) == 0 ) 376 376 { 377 // COUT(4) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;377 // orxout(verbose, context::packets) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl; 378 378 origDataPtr += objectOffset + objectHeader.getDataSize(); // skip the whole object 379 379 baseDataPtr += objectOffset + objectHeader.getDataSize(); … … 431 431 inline void /*Gamestate::*/copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes ) 432 432 { 433 // COUT(4) << "docopy" << endl;433 // orxout(verbose, context::packets) << "docopy" << endl; 434 434 // Just copy over the whole Object 435 435 memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() ); … … 440 440 // SynchronisableHeader baseHeader( baseData ); 441 441 // baseData += baseHeader.getDataSize()+SynchronisableHeader::getSize(); 442 // COUT(4) << "copy " << h.getObjectID() << endl;443 // COUT(4) << "copy " << h.getObjectID() << ":";442 // orxout(verbose, context::packets) << "copy " << h.getObjectID() << endl; 443 // orxout(verbose, context::packets) << "copy " << h.getObjectID() << ":"; 444 444 sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); 445 445 // for( unsigned int i = 0; i < Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); ++i ) 446 446 // { 447 // // COUT(4) << " " << *sizes;447 // // orxout(verbose, context::packets) << " " << *sizes; 448 448 // ++sizes; 449 449 // } 450 // COUT(4) << endl;450 // orxout(verbose, context::packets) << endl; 451 451 } 452 452 … … 541 541 if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() ) 542 542 { 543 // COUT(4) << "diffing object in order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;543 // orxout(verbose, context::packets) << "diffing object in order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 544 544 diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); 545 545 diffedObject = true; … … 547 547 else 548 548 { 549 // COUT(4) << "copy object because of different data sizes (1): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;549 // orxout(verbose, context::packets) << "copy object because of different data sizes (1): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 550 550 copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); 551 551 assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd); … … 565 565 if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() ) 566 566 { 567 // COUT(4) << "diffing object out of order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;567 // orxout(verbose, context::packets) << "diffing object out of order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 568 568 diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); 569 569 diffedObject = true; … … 571 571 else 572 572 { 573 // COUT(4) << "copy object because of different data sizes (2): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;573 // orxout(verbose, context::packets) << "copy object because of different data sizes (2): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 574 574 copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); 575 575 assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd); … … 578 578 else 579 579 { 580 // COUT(4) << "copy object: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;580 // orxout(verbose, context::packets) << "copy object: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl; 581 581 assert(baseDataPtr == oldBaseDataPtr); 582 582 copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt); … … 718 718 //copy in the zeros 719 719 // std::list<obj>::iterator itt; 720 // COUT(0) << "myvector contains:";720 // orxout() << "myvector contains:"; 721 721 // for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ ) 722 // COUT(0) << " " << (*itt).objID;723 // COUT(0) << endl;722 // orxout() << " " << (*itt).objID; 723 // orxout() << endl; 724 724 for(it=dataVector_.begin(); it!=dataVector_.end();){ 725 725 SynchronisableHeader oldobjectheader(origdata); … … 771 771 nrOfVariables += it->getNrOfVariables(); 772 772 } 773 // COUT(0) << "allocating " << nrOfVariables << " ints" << endl;773 // orxout() << "allocating " << nrOfVariables << " ints" << endl; 774 774 this->sizes_.reserve(nrOfVariables); 775 775 return size; -
code/trunk/src/libraries/network/packet/Packet.cc
r8327 r8858 37 37 #include <boost/thread/mutex.hpp> 38 38 39 #include "util/ Debug.h"39 #include "util/Output.h" 40 40 #include "Acknowledgement.h" 41 41 #include "Chat.h" … … 192 192 // peerID = NETWORK_PEER_ID_SERVER; 193 193 Packet *p = 0; 194 // COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;194 // orxout(verbose_ultra, context::packets) << "packet type: " << *(Type::Value *)&data[_PACKETID] << endl; 195 195 switch( *(Type::Value *)(data + _PACKETID) ) 196 196 { 197 197 case Type::Acknowledgement: 198 // COUT(5) << "ack" << std::endl;198 // orxout(verbose_more, context::packets) << "ack" << endl; 199 199 p = new Acknowledgement( data, peerID ); 200 200 break; 201 201 case Type::Chat: 202 // COUT(5) << "chat" << std::endl;202 // orxout(verbose_more, context::packets) << "chat" << endl; 203 203 p = new Chat( data, peerID ); 204 204 break; 205 205 case Type::ClassID: 206 // COUT(5) << "classid" << std::endl;206 // orxout(verbose_more, context::packets) << "classid" << endl; 207 207 p = new ClassID( data, peerID ); 208 208 break; 209 209 case Type::Gamestate: 210 // COUT(5) << "gamestate" << std::endl;210 // orxout(verbose_more, context::packets) << "gamestate" << endl; 211 211 p = new Gamestate( data, peerID ); 212 212 break; 213 213 case Type::Welcome: 214 // COUT(5) << "welcome" << std::endl;214 // orxout(verbose_more, context::packets) << "welcome" << endl; 215 215 p = new Welcome( data, peerID ); 216 216 break; 217 217 case Type::DeleteObjects: 218 // COUT(5) << "deleteobjects" << std::endl;218 // orxout(verbose_more, context::packets) << "deleteobjects" << endl; 219 219 p = new DeleteObjects( data, peerID ); 220 220 break; 221 221 case Type::FunctionCalls: 222 // COUT(5) << "functionCalls" << std::endl;222 // orxout(verbose_more, context::packets) << "functionCalls" << endl; 223 223 p = new FunctionCalls( data, peerID ); 224 224 break; 225 225 case Type::FunctionIDs: 226 // COUT(5) << "functionIDs" << std::endl;226 // orxout(verbose_more, context::packets) << "functionIDs" << endl; 227 227 p = new FunctionIDs( data, peerID ); 228 228 break; … … 255 255 packetMap_.erase(it); 256 256 Packet::packetMapMutex_.unlock(); 257 // COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;257 // orxout(verbose_ultra, context::packets) << "PacketMap size: " << packetMap_.size() << endl; 258 258 } 259 259 -
code/trunk/src/libraries/network/packet/Welcome.cc
r8706 r8858 32 32 33 33 #include <cassert> 34 #include "util/ Debug.h"34 #include "util/Output.h" 35 35 #include "network/Host.h" 36 36 #include "network/synchronisable/Synchronisable.h" … … 78 78 assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321); 79 79 host->setClientID(clientID); 80 COUT(3) << "Welcome set clientId: " << clientID << endl;80 orxout(internal_info, context::packets) << "Welcome set clientId: " << clientID << endl; 81 81 Synchronisable::setClient(true); 82 82 delete this; -
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
r8706 r8858 130 130 // assert( !header.isDiffed() ); 131 131 132 COUT(4) << "fabricating object with id: " << header.getObjectID() << std::endl;132 orxout(verbose, context::network) << "fabricating object with id: " << header.getObjectID() << endl; 133 133 134 134 Identifier* id = ClassByID(header.getClassID()); … … 136 136 { 137 137 for(int i = 0; i<160; i++) 138 COUT(0) << "classid: " << i << " identifier: " << ClassByID(i) << endl;139 COUT(0) << "Assertion failed: id" << std::endl;140 COUT(0) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl;138 orxout(user_error, context::network) << "classid: " << i << " identifier: " << ClassByID(i) << endl; 139 orxout(user_error, context::network) << "Assertion failed: id" << endl; 140 orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl; 141 141 abort(); 142 142 } … … 168 168 bo->setLevel(creator->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself) 169 169 //assert(no->classID_ == header.getClassID()); 170 COUT(4) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << std::endl;170 orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl; 171 171 // update data and create object/entity... 172 172 bool b = no->updateData(mem, mode, true); … … 242 242 uint8_t* oldmem = mem; 243 243 if (this->classID_==0) 244 COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;244 orxout(internal_info, context::network) << "classid 0 " << this->getIdentifier()->getName() << endl; 245 245 #endif 246 246 … … 258 258 // end copy header 259 259 260 CCOUT(5) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << std::endl;261 // COUT(4) << "objectid: " << this->objectID_ << ":";260 orxout(verbose_more, context::network) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << endl; 261 // orxout(verbose, context::network) << "objectid: " << this->objectID_ << ":"; 262 262 // copy to location 263 263 for(i=syncList_.begin(); i!=syncList_.end(); ++i) 264 264 { 265 265 uint32_t varsize = (*i)->getData( mem, mode ); 266 // COUT(4) << " " << varsize;266 // orxout(verbose, context::network) << " " << varsize; 267 267 tempsize += varsize; 268 268 sizes.push_back(varsize); … … 271 271 } 272 272 assert(tempsize!=0); // if this happens an empty object (with no variables) would be transmitted 273 // COUT(4) << endl;273 // orxout(verbose, context::network) << endl; 274 274 275 275 header.setObjectID( this->objectID_ ); … … 305 305 if(syncList_.empty()) 306 306 { 307 orxout(internal_warning, context::network) << "Synchronisable::updateData syncList_ is empty" << endl; 307 308 assert(0); 308 COUT(2) << "Synchronisable::updateData syncList_ is empty" << std::endl;309 309 return false; 310 310 } … … 326 326 } 327 327 328 // COUT(5) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;328 //orxout(verbose_more, context::network) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << endl; 329 329 if( !syncHeaderLight.isDiffed() ) 330 330 { … … 344 344 { 345 345 mem += SynchronisableHeaderLight::getSize(); 346 // COUT(0) << "objectID: " << this->objectID_ << endl;346 // orxout(debug_output, context::network) << "objectID: " << this->objectID_ << endl; 347 347 while( mem < data+syncHeaderLight.getDataSize()+SynchronisableHeaderLight::getSize() ) 348 348 { 349 349 VariableID varID = *(VariableID*)mem; 350 // COUT(0) << "varID: " << varID << endl;350 // orxout(debug_output, context::network) << "varID: " << varID << endl; 351 351 assert( varID < syncList_.size() ); 352 352 mem += sizeof(VariableID); -
code/trunk/src/libraries/network/synchronisable/Synchronisable.h
r8706 r8858 232 232 it++; 233 233 } 234 COUT(1) << "Tried to unregister not registered variable" << endl;234 orxout(internal_error, context::network) << "Tried to unregister not registered variable" << endl; 235 235 assert(false); //if we reach this point something went wrong: 236 236 // the variable has not been registered before -
code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
r7266 r8858 202 202 if ( *static_cast<uint8_t*>(mem) != this->varReference_ ) 203 203 { // wrong reference number, so discard the data 204 // COUT(0) << "discharding data" << endl;204 // orxout(debug_output, context::network) << "discharding data" << endl; 205 205 mem += getSize( mode ); // SynchronisableVariableBidirectional::getSize returns size of variable + reference 206 206 return;
Note: See TracChangeset
for help on using the changeset viewer.