Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 23, 2011, 12:45:53 AM (13 years ago)
Author:
landauf
Message:

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

  • orxout levelname message
  • orxout_context levelname context message
  • shortcuts: log message, error message, warning message, status message, info message, debug message
Location:
code/trunk
Files:
2 deleted
38 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/CMakeLists.txt

    r8351 r8858  
    1919
    2020SET_SOURCE_FILES(NETWORK_SRC_FILES
    21   ChatListener.cc
    2221  Client.cc
    2322  ClientConnection.cc
     
    4544
    4645SET_SOURCE_FILES(NETWORK_HDR_FILES
    47   ChatListener.h
    4846  Client.h
    4947  ClientConnection.h
     
    6159  WANDiscovery.h
    6260  MasterServerComm.h
     61  NetworkChatListener.h
    6362  NetworkFunction.h
    6463  NetworkPrecompiledHeaders.h
  • code/trunk/src/libraries/network/Client.cc

    r8327 r8858  
    4444
    4545#include "util/Clock.h"
    46 #include "util/Debug.h"
     46#include "util/Output.h"
    4747#include "util/ScopedSingletonManager.h"
    4848#include "synchronisable/Synchronisable.h"
     
    116116  }
    117117
    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 
    124118  void Client::printRTT()
    125119  {
    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 server
     120    orxout(message) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;
     121  }
     122
     123  /**
     124   * @brief Sends a chat message to the server.
    131125   * @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
    133128   */
    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  }
    140144
    141145  /**
     
    150154    {
    151155      timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
    152       //     COUT(3) << '.';
    153156      if ( isConnected() && isSynched_ )
    154157      {
    155         COUT(4) << "popping partial gamestate: " << std::endl;
     158        orxout(verbose, context::network) << "popping partial gamestate: " << endl;
    156159//         packet::Gamestate *gs = GamestateClient::getGamestate();
    157160        if( GamestateManager::update() )
     
    166169        //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
    167170//         if(gs){
    168 //           COUT(4) << "client tick: sending gs " << gs << std::endl;
     171//           orxout(verbose, context::network) << "client tick: sending gs " << gs << endl;
    169172//           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;
    171174//         // gs gets automatically deleted by enet callback
    172175//         }
     
    204207    Game::getInstance().popState();
    205208  }
    206  
     209
    207210  void Client::processPacket(packet::Packet* packet)
    208211  {
     
    217220      packet->process(static_cast<Host*>(this));
    218221  }
    219 
    220 
    221 
    222 
    223222}
  • code/trunk/src/libraries/network/Client.h

    r7801 r8858  
    7373    Client();
    7474    ~Client();
    75    
     75
    7676    static Client* getInstance(){ return singletonPtr_s; } // tolua_export
    7777
     
    8181    void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID);
    8282    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);
    8685    virtual void printRTT();
    8786
  • code/trunk/src/libraries/network/ClientConnection.cc

    r8327 r8858  
    3232#define WIN32_LEAN_AND_MEAN
    3333#include <enet/enet.h>
    34 #include "util/Debug.h"
     34#include "util/Output.h"
    3535
    3636namespace orxonox
     
    6060  void ClientConnection::setServerAddress( const std::string& serverAddress ) {
    6161    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;
    6363  }
    6464
     
    7676    if ( this->host_ == NULL )
    7777    {
    78       COUT(1) << "ClientConnection: host_ == NULL" << std::endl;
     78      orxout(internal_error, context::network) << "ClientConnection: host_ == NULL" << endl;
    7979      // error handling
    8080      return false;
     
    8686    assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
    8787    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;
    8989    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;
    9191    else
    92         COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
     92        orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl;
    9393
    9494    this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CHANNEL_COUNT, 0);
    9595    if ( this->server_==NULL )
    9696    {
    97       COUT(1) << "ClientConnection: server_ == NULL" << std::endl;
     97      orxout(internal_error, context::network) << "ClientConnection: server_ == NULL" << endl;
    9898      // error handling
    9999      return false;
     
    113113      }
    114114    }
    115     COUT(1) << "Could not connect to server" << endl;
     115    orxout(user_error, context::network) << "Could not connect to server" << endl;
    116116    return false;
    117117  }
     
    140140            break;
    141141          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;
    143143            this->connectionClosed();
    144144            return true;
     
    167167  {
    168168    this->established_=false;
    169     COUT(1) << "Received disconnect Packet from Server!" << endl;
     169    orxout(internal_error, context::network) << "Received disconnect Packet from Server!" << endl;
    170170        // server closed the connection
    171171    this->stopCommunicationThread();
  • code/trunk/src/libraries/network/Connection.cc

    r8327 r8858  
    144144      while( outgoingEventsCount > 0 )
    145145      {
    146 //         COUT(0) << "outgoing event" << endl;
     146//         orxout(verbose, context::network) << "outgoing event" << endl;
    147147        this->outgoingEventsMutex_->lock();
    148148        outgoingEvent outEvent = this->outgoingEvents_.front();
  • code/trunk/src/libraries/network/GamestateManager.cc

    r8407 r8858  
    5252#include "core/command/Executor.h"
    5353#include "core/GameMode.h"
    54 #include "util/Debug.h"
     54#include "util/Output.h"
    5555#include "util/Clock.h"
    5656#include "util/OrxAssert.h"
     
    128128    if( !this->sendPacket(ack))
    129129    {
    130       COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;
     130      orxout(internal_warning, context::network) << "could not ack gamestate: " << gamestateID << endl;
    131131      return false;
    132132    }
    133133    else
    134134    {
    135       COUT(5) << "acked a gamestate: " << gamestateID << std::endl;
     135      orxout(verbose_more, context::network) << "acked a gamestate: " << gamestateID << endl;
    136136      return true;
    137137    }
     
    182182      if( !peerIt->second.isSynched )
    183183      {
    184         COUT(5) << "Server: not sending gamestate" << std::endl;
     184        orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
    185185        continue;
    186186      }
    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;
    189189      int peerID = peerIt->first; //get client id
    190190
     
    256256//     OrxVerify(gs->compressData(), "");
    257257    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();
    260260//     if(gamestate->isDiffed())
    261 //       COUT(5) << " and baseid " << gs->getBaseID() << endl;
     261//       orxout(verbose_more, context::network) << " and baseid " << gs->getBaseID() << endl;
    262262//     else
    263 //       COUT(5) << endl;
     263//       orxout(verbose_more, context::network) << endl;
    264264    gs->setPeerID(peerID);
    265265    destgamestate = gs;
     
    291291    if( gamestateID <= curid && curid != GAMESTATEID_INITIAL )
    292292        return true;
    293 COUT(4) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << std::endl;
     293orxout(verbose, context::network) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << endl;
    294294    std::map<uint32_t, packet::Gamestate*>::iterator it2;
    295295    for( it2=it->second.gamestates.begin(); it2!=it->second.gamestates.end(); )
  • code/trunk/src/libraries/network/Host.cc

    r8408 r8858  
    3232#include <string>
    3333
     34#include "core/CoreIncludes.h"
    3435#include "core/ObjectList.h"
    3536#include "core/command/ConsoleCommand.h"
    36 #include "ChatListener.h"
     37#include "NetworkChatListener.h"
    3738
    3839namespace orxonox {
     
    4142  static const std::string __CC_printRTT_name = "printRTT";
    4243
    43   SetConsoleCommand("chat", &Host::Chat);
    4444  SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT);
    4545
     
    8989  }
    9090
    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)
    9298  {
    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);
    112102  }
    113103
    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)
    115108  {
    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);
    135111  }
    136112
    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   }
    153113
    154114  bool Host::isServer()
     
    156116    for (std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it )
    157117    {
    158       if( (*it)->isServer_() )
    159         return true;
     118      if( (*it)->isActive() )
     119      {
     120        if( (*it)->isServer_() )
     121          return true;
     122      }
    160123    }
    161124    return false;
    162125  }
    163  
     126
    164127  Host* Host::getActiveInstance()
    165128  {
     
    176139
    177140
     141  //////////////////////////////////////////////////////////////////////////
     142  // NetworkChatListener                                                  //
     143  //////////////////////////////////////////////////////////////////////////
     144
     145  NetworkChatListener::NetworkChatListener()
     146  {
     147      RegisterRootObject(NetworkChatListener);
     148  }
     149
    178150}//namespace orxonox
  • code/trunk/src/libraries/network/Host.h

    r8403 r8858  
    5252class _NetworkExport Host: public GamestateManager
    5353{
     54  friend class packet::Chat;
     55
    5456  private:
    55     //TODO add these functions or adequate
    56     //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
    57     //virtual bool sendChat(packet::Chat *chat)=0;
    5857    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;
    6258    virtual bool isServer_()=0;
    63 
    64 
    6559
    6660  protected:
     
    6862    virtual ~Host();
    6963    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;
    7167
    7268  public:
     
    7470    static bool running(){ return instances_s.size(); }
    7571    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);
    7872    static unsigned int getPlayerID(){ return clientID_s; }
    7973    static void setClientID(unsigned int id){ clientID_s = id; }
    8074    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);
    8476    virtual void printRTT()=0;
    8577    bool isActive(){ return bIsActive_; }
  • code/trunk/src/libraries/network/LANDiscoverable.cc

    r8351 r8858  
    3333#include <cstring>
    3434
    35 #include "util/Debug.h"
     35#include "util/Output.h"
    3636#include "packet/ServerInformation.h"
    3737
     
    7171      this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 );
    7272      if ( this->host_ == NULL )
    73           COUT(1) << "LANDiscoverable: host_ == NULL" << std::endl;
     73          orxout(internal_error, context::network) << "LANDiscoverable: host_ == NULL" << endl;
    7474    }
    7575    else
     
    9494      {
    9595        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;
    9797            break;
    9898        case ENET_EVENT_TYPE_DISCONNECT:
     
    102102          if( strcmp( LAN_DISCOVERY_MESSAGE, (char*)event.packet->data ) == 0 )      // check for a suitable orxonox client
    103103          {
    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;
    105105            packet::ServerInformation info;
    106106            info.setServerName("Orxonox Server");
  • code/trunk/src/libraries/network/LANDiscovery.cc

    r8706 r8858  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Oliver Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    4444    this->host_ = enet_host_create(NULL, 10, 0, 0, 0 );
    4545    if ( this->host_ == NULL )
    46         COUT(1) << "LANDiscovery: host_ == NULL" << std::endl;
     46        orxout(internal_error, context::network) << "LANDiscovery: host_ == NULL" << endl;
    4747  }
    4848
     
    6666    peer = enet_host_connect(this->host_, &address, 0, 0);
    6767    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;
    6969
    7070    /* IPv6 */
     
    7272    peer = enet_host_connect(this->host_, &address, 0, 0);
    7373    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;
    7575
    7676    ENetEvent event;
     
    8181        case ENET_EVENT_TYPE_CONNECT:
    8282        {
    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;
    8484          ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE);
    8585          enet_peer_send(event.peer, 0, packet);
     
    8989          {
    9090            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;
    9292            std::vector<packet::ServerInformation>::iterator it;
    9393            for( it=this->servers_.begin(); it!=this->servers_.end(); ++it )
  • code/trunk/src/libraries/network/LANDiscovery.h

    r8351 r8858  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Oliver Scheuss
    2424 *   Co-authors:
    2525 *      ...
  • code/trunk/src/libraries/network/MasterServer.cc

    r8351 r8858  
    3838  helper_output_debug( ENetEvent *event, char *addrconv )
    3939  {
    40     COUT(4) << "A packet of length"
     40    orxout(verbose, context::master_server)
     41      << "A packet of length"
    4142      << event->packet->dataLength
    4243      << " containing "
     
    4546      << addrconv
    4647      << " on channel "
    47       << event->channelID << "\n";
     48      << event->channelID << endl;
    4849  }
    4950
     
    6667          + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 );
    6768      if( !tosend )
    68       { COUT(2) << "Masterserver.cc: Memory allocation failed.\n";
     69      { orxout(internal_warning, context::master_server) << "Masterserver.cc: Memory allocation failed." << endl;
    6970        continue;
    7071      }
     
    108109  { /* check for bad parameters */
    109110    if( !event )
    110     { COUT(2) << "MasterServer::eventConnect: No event given.\n" ;
     111    { orxout(internal_warning, context::master_server) << "MasterServer::eventConnect: No event given." << endl;
    111112      return -1;
    112113    }
     
    117118
    118119    /* output debug info */
    119     COUT(4) << "A new client connected from "
     120    orxout(verbose, context::master_server) << "A new client connected from "
    120121      << addrconv
    121122      << " on port "
    122       << event->peer->address.port << "\n";
     123      << event->peer->address.port << endl;
    123124
    124125    /* store string form of address here */
     
    134135  { /* check for bad parameters */
    135136    if( !event )
    136     { COUT(2) << "No event given.\n";
     137    { orxout(internal_warning, context::master_server) << "No event given." << endl;
    137138      return -1;
    138139    }
    139140
    140141    /* 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;
    142143
    143144    /* create string from peer data */
     
    159160  { /* validate packet */
    160161    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;
    162163      return -1;
    163164    }
     
    182183       
    183184        /* 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;
    186187      }
    187188
     
    197198
    198199        /* 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;
    200201      }
    201202
     
    230231    if( event == NULL )
    231232    {
    232       COUT(1) << "Could not create ENetEvent structure, exiting.\n";
     233      orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl;
    233234      exit( EXIT_FAILURE );
    234235    }
     
    263264    /***** INITIALIZE NETWORKING *****/
    264265    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;
    266267      exit( EXIT_FAILURE );
    267268    }
     
    285286    /* see if creation worked */
    286287    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;
    289290      exit( EXIT_FAILURE );
    290291    }
     
    294295
    295296    /* 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;
    297298  }
    298299
  • code/trunk/src/libraries/network/MasterServerComm.cc

    r8351 r8858  
    2828
    2929#include "MasterServerComm.h"
    30 #include "util/Debug.h"
     30#include "util/Output.h"
     31#include "WANDiscovery.h"
    3132
    3233namespace orxonox
     
    4445    /* initialize Enet */
    4546    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;
    4748      return 1;
    4849    }
     
    6162    /* see if it worked */
    6263    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;
    6566      return 1;
    6667    }
     
    8586
    8687    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;
    8990      return -1;
    9091    }
     
    9394    if (enet_host_service (this->client, &this->event, 500) > 0 &&
    9495        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;
    9697    else
    9798    {
    9899      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;
    100101      return -1;
    101102    }
     
    128129
    129130        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;
    131132          return 0;
    132133        default: break;
     
    149150   * so we can also make callbacks from objects
    150151   */
    151   int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ),
    152     int delayms )
     152  int MasterServerComm::pollForReply( WANDiscovery* listener, int delayms )
    153153  {
    154154    /* see whether anything happened */
    155155    /* WORK MARK REMOVE THIS OUTPUT */
    156     COUT(2) << "polling masterserver...\n";
     156    orxout(verbose, context::master_server) << "polling masterserver..." << endl;
    157157
    158158    /* address buffer */
     
    176176          addrconv = (char *) calloc( 50, 1 );
    177177          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;
    179179            break;
    180180          }
     
    185185
    186186          /* DEBUG */
    187           COUT(3) << "MasterServer Debug: A packet of length "
     187          orxout(verbose, context::master_server) << "MasterServer Debug: A packet of length "
    188188            << this->event.packet->dataLength
    189189            << " containing " << this->event.packet->data
     
    193193
    194194          /* 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) );
    197197
    198198          /* clean up */
  • code/trunk/src/libraries/network/MasterServerComm.h

    r8351 r8858  
    9393       *
    9494       * 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 );
    9696
    9797    private:
  • code/trunk/src/libraries/network/NetworkPrecompiledHeaders.h

    r8351 r8858  
    5252#include <set>      // 20
    5353
    54 #include "util/Debug.h"      // 20
     54#include "util/Output.h"      // 20
    5555#include <loki/TypeTraits.h> // 18
    5656
  • code/trunk/src/libraries/network/NetworkPrereqs.h

    r8351 r8858  
    118118namespace orxonox
    119119{
    120   class ChatListener;
    121120  class Client;
    122121  class ClientConnection;
     
    130129  class GamestateManager;
    131130  class Host;
     131  class MasterServer;
     132  class MasterServerComm;
     133  class NetworkChatListener;
    132134  class NetworkFunctionBase;
    133135  struct NetworkFunctionPointer;
     
    136138  class NetworkMemberFunction;
    137139  class NetworkMemberFunctionBase;
     140  class PeerList;
    138141  class Server;
    139142  class ServerConnection;
    140143  class TrafficControl;
     144  class WANDiscoverable;
     145  class WANDiscovery;
    141146
    142147  // packet
  • code/trunk/src/libraries/network/PeerList.cc

    r8351 r8858  
    2828
    2929#include "PeerList.h"
    30 #include <network/packet/ServerInformation.h>
     30
    3131#include <cstdio>
     32#include "util/Output.h"
     33#include "network/packet/ServerInformation.h"
    3234
    3335namespace orxonox
     
    4042  { /* error correction */
    4143    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;
    4345      return -1;
    4446    }
  • code/trunk/src/libraries/network/Server.cc

    r8706 r8858  
    4747
    4848#include "util/Clock.h"
    49 #include "util/Debug.h"
     49#include "util/Output.h"
    5050#include "core/ObjectList.h"
    5151#include "core/command/Executor.h"
     
    5656#include "packet/Gamestate.h"
    5757#include "packet/Welcome.h"
    58 #include "ChatListener.h"
    5958// #include "ClientInformation.h"
    6059#include "FunctionCallManager.h"
    6160#include "GamestateManager.h"
    62 #include "WANDiscovery.h"
    6361
    6462namespace orxonox
     
    10098  }
    10199
    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 
    110100  /**
    111101  * This function opens the server by creating the listener thread
     
    114104  {
    115105    Host::setActive(true);
    116     COUT(4) << "opening server" << endl;
     106    orxout(verbose, context::network) << "opening server" << endl;
    117107    this->openListener();
    118    
     108
    119109    /* make discoverable on LAN */
    120110    LANDiscoverable::setActivity(true);
     
    122112    /* make discoverable on WAN */
    123113    WANDiscoverable::setActivity(true);
    124     /* TODO this needs to be optional, we need a switch from the UI to
    125      * enable/disable this
    126      */
    127 //     helper_ConnectToMasterserver();
    128114
    129115    /* done */
     
    137123  {
    138124    Host::setActive(false);
    139     COUT(4) << "closing server" << endl;
     125    orxout(verbose, context::network) << "closing server" << endl;
    140126    this->disconnectClients();
    141127    this->closeListener();
    142128
    143129    /* 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;
    147133
    148134    LANDiscoverable::setActivity(false);
    149135    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 pollForReply
    176        * reimplementation
    177        */
    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 something
    187      * has to be done or changed.
    188      */
    189     //WANDiscovery::getInstance().msc.pollForReply( rhandler, 10 );
    190136  }
    191137
     
    202148    // receive and process incoming discovery packets
    203149    LANDiscoverable::update();
    204    
    205     // receive and process requests from master server
    206     /* todo */
    207     //helper_HandleMasterServerRequests();
    208150
    209151    if ( GamestateManager::hasPeers() )
     
    246188  {
    247189//     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;
    249191  }
    250192
     
    268210      return;
    269211    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;
    272214    //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
    273215    sendGameStates();
    274216    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;
    277219  }
    278220
     
    305247      return true;  //everything ok (no deletes this tick)
    306248    }
    307 //     COUT(3) << "sending DeleteObjects" << std::endl;
     249//     orxout(verbose, context::network) << "sending DeleteObjects" << endl;
    308250//     while(temp != NULL){
    309251//       if( !(temp->getSynched()) )
    310252//       {
    311 //         COUT(5) << "Server: not sending gamestate" << std::endl;
     253//         orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
    312254//         temp=temp->next();
    313255//         continue;
     
    318260    del->setPeerID(NETWORK_PEER_ID_BROADCAST);
    319261    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;
    321263//       temp=temp->next();
    322264      // gs gets automatically deleted by enet callback
     
    330272  {
    331273//     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;
    334276//     ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
    335277//     if(!temp)
    336278//     {
    337 //       COUT(2) << "Server: could not add client" << std::endl;
     279//       orxout(internal_warning, context::network) << "Server: could not add client" << endl;
    338280//     }
    339281//     temp->setID(newid);
     
    347289//     ++newid;
    348290
    349     COUT(3) << "Server: added client id: " << peerID << std::endl;
     291    orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl;
    350292    createClient(peerID);
    351293}
     
    353295  void Server::removePeer(uint32_t peerID)
    354296  {
    355     COUT(4) << "removing client from list" << std::endl;
     297    orxout(verbose, context::network) << "removing client from list" << endl;
    356298//     ClientInformation *client = ClientInformation::findClient(&event->peer->address);
    357299//     if(!client)
     
    375317//     }
    376318  }
    377  
     319
    378320  void Server::processPacket(packet::Packet* packet)
    379321  {
     
    395337//     if(!temp)
    396338//     {
    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;
    398340//       return false;
    399341//     }
    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;
    401343
    402344    // synchronise class ids
     
    411353//     temp->setSynched(true);
    412354    GamestateManager::setSynched(clientID);
    413    
    414     COUT(4) << "sending welcome" << std::endl;
     355
     356    orxout(verbose, context::network) << "sending welcome" << endl;
    415357    packet::Welcome *w = new packet::Welcome(clientID);
    416358    w->setPeerID(clientID);
     
    438380  }
    439381
    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;
    467428  }
    468429
     
    476437    }
    477438    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;
    479440  }
    480441
  • code/trunk/src/libraries/network/Server.h

    r8351 r8858  
    4242#include "LANDiscoverable.h"
    4343#include "WANDiscoverable.h"
    44 // #include "MasterServerComm.h"
    45 // #include "MasterServerProtocol.h"
    4644
    4745
     
    6159    ~Server();
    6260
    63     /* helpers */
    64     void helper_ConnectToMasterserver();
    65     void helper_HandleMasterServerRequests();
    66     int replyhandler( char *addr, ENetEvent *ev );
    67 
    6861    void open();
    6962    void close();
    70     bool processChat(const std::string& message, unsigned int playerID);
    7163    void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID);
    7264    virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
     
    8981    bool sendGameStates();
    9082    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);
    9486    void syncClassid(unsigned int clientID);
    9587
  • code/trunk/src/libraries/network/ServerConnection.cc

    r8358 r8858  
    3434#include <enet/enet.h>
    3535
    36 #include "util/Debug.h"
     36#include "util/Output.h"
    3737#include <util/Sleep.h>
    3838// #include "ClientInformation.h"
     
    6161  {
    6262    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;
    6464  }
    6565
     
    7575    if ( this->host_ == NULL )
    7676    {
    77         COUT(1) << "ServerConnection: host_ == NULL" << std::endl;
     77        orxout(internal_error, context::network) << "ServerConnection: host_ == NULL" << endl;
    7878        return false;
    7979    }
     
    8383    assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
    8484    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;
    8686    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;
    8888    else
    89         COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
     89        orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl;
    9090   
    9191    // start communication thread
     
    114114//       ClientInformation *temp = ClientInformation::findClient(clientID);
    115115//       if(!temp){
    116 //         COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
     116//         orxout(internal_warning, context::network) << "C.Man: addPacket findClient failed" << endl;
    117117//       }
    118118      Connection::addPacket(packet, clientID, channelID);
  • code/trunk/src/libraries/network/TrafficControl.cc

    r6417 r8858  
    287287  {
    288288    std::list<obj>::iterator it;
    289     COUT(0) << "=========== Objectlist ===========" << endl;
     289    orxout(debug_output, context::network) << "=========== Objectlist ===========" << endl;
    290290    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;
    292292  }
    293293
  • code/trunk/src/libraries/network/WANDiscoverable.cc

    r8351 r8858  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau (original)
     23 *      Sandro 'smerkli' Merkli
    2424 *   Co-authors:
    25  *      Sandro 'smerkli' Merkli (adaptions to WAN)
    26  *      ...
     25 *      Oliver Scheuss (original)
    2726 *
    2827 */
     
    4443  {
    4544    /* debugging output */
    46     COUT(4) << "Creating WANDiscoverable.\n";
     45    orxout(verbose, context::master_server) << "Creating WANDiscoverable." << endl;
    4746 
    4847    /* register object in orxonox */
     
    9190    if( msc.initialize() )
    9291    {
    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;
    9493      return false;
    9594    }
     
    9897    if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) )
    9998    {
    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;
    102101      return false;
    103102    }
    104103                 
    105104    /* debugging output */
    106     COUT(4) << "Initialization of WANDiscoverable complete.\n";
     105    orxout(verbose, context::master_server) << "Initialization of WANDiscoverable complete." << endl;
    107106   
    108107   
  • code/trunk/src/libraries/network/WANDiscoverable.h

    r8729 r8858  
    1919 *   Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2020 *
    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)
    2325 *
    2426 */
  • code/trunk/src/libraries/network/WANDiscovery.cc

    r8351 r8858  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau (original)
     23 *      Sandro 'smerkli' Merkli
    2424 *   Co-authors:
    25  *      Sandro 'smerkli' Merkli (adaptions to WAN)
    26  *      ...
     25 *      Oliver Scheuss (original)
    2726 *
    2827 */
     
    3332#include <cstring>
    3433
    35 #include "util/ScopedSingletonManager.h"
    3634#include "core/CoreIncludes.h"
    3735
     
    3937namespace orxonox
    4038{
    41   ManageScopedSingleton(WANDiscovery, ScopeID::Graphics, true);
    42 
    43 
    4439  WANDiscovery::WANDiscovery()
    4540  {
    4641    /* debugging output */
    47     COUT(4) << "Creating WANDiscovery.\n";
     42    orxout(verbose, context::master_server) << "Creating WANDiscovery." << endl;
    4843 
    4944    /* register object in orxonox */
     
    5550    /* initialize it and see if it worked */
    5651    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;
    5853
    5954    /* connect and see if it worked */
    6055    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;
    6358
    6459    /* debugging output */
    65     COUT(4) << "Initialization of WANDiscovery complete.\n";
     60    orxout(verbose, context::master_server) << "Initialization of WANDiscovery complete." << endl;
    6661  }
    6762
     
    8176
    8277  /* callback for the network reply poller */
    83   int rhandler( char *addr, ENetEvent *ev )
     78  int WANDiscovery::rhandler( char *addr, ENetEvent *ev )
    8479  {
    8580    /* error recognition */
    8681    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;
    8883      return 0;
    8984    }
     
    10499
    105100      /* add to list */
    106       WANDiscovery::getInstance().servers_.push_back( toadd );
     101      this->servers_.push_back( toadd );
    107102    }
    108103    else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END,
     
    133128    {
    134129      /* poll for reply and act according to what was received */
    135       switch( this->msc.pollForReply( rhandler, 500 ) )
     130      switch( this->msc.pollForReply( this, 500 ) )
    136131      { case 0: /* no event occured, decrease timeout */
    137132          --i; break;
  • code/trunk/src/libraries/network/WANDiscovery.h

    r8351 r8858  
    1919 *   Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2020 *
    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)
    2325 *
    2426 */
     
    3032#include "packet/ServerInformation.h"
    3133#include "core/ConfigFileManager.h"
    32 #include "util/Singleton.h"
    3334#include "core/OrxonoxClass.h"
    3435#include "core/ConfigValueIncludes.h"
     
    4748  class _NetworkExport WANDiscovery
    4849// tolua_end
    49     : public Singleton<WANDiscovery>, public OrxonoxClass
     50    : public OrxonoxClass
    5051  { // tolua_export
    51     friend class Singleton<WANDiscovery>;
    5252    public:
    5353      /** constructor */
    54       WANDiscovery();
     54      WANDiscovery(); // tolua_export
    5555
    5656      /** destructor */
     
    8181      std::string getServerListItemIP( unsigned int index ); // tolua_export
    8282
    83       /** \return an instance of WANDiscovery
    84        *
    85        * Create and return an instance of WANDiscovery.
    86        */
    87       static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export
    88    
    8983      /* todo: might make this private and use getter/setter methods
    9084       * at some later time.
     
    9892      /** Master server communications object */
    9993      MasterServerComm msc;
     94
     95      int rhandler( char *addr, ENetEvent *ev );
    10096     
    10197    private:
    102       /** Singleton pointer */
    103       static WANDiscovery* singletonPtr_s;
    104 
    10598      /** master server address */
    10699      std::string msaddress;
  • code/trunk/src/libraries/network/packet/Acknowledgement.cc

    r7801 r8858  
    2929#include "Acknowledgement.h"
    3030
    31 #include "util/Debug.h"
     31#include "util/Output.h"
    3232#include "network/GamestateHandler.h"
    3333#include "network/Host.h"
     
    6464
    6565bool 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;
    6767  bool b = host->ackGamestate(getAckID(), peerID_);
    6868  delete this;
  • code/trunk/src/libraries/network/packet/Chat.cc

    r7801 r8858  
    3939
    4040/* 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)
    4546
    46 Chat::Chat( const std::string& message, unsigned int playerID )
     47Chat::Chat( const std::string& message, unsigned int sourceID, unsigned int targetID )
    4748 : Packet()
    4849{
     
    5758
    5859  *(Type::Value *)(data_ + _PACKETID ) = Type::Chat;
    59   *(unsigned int *)(data_ + _PLAYERID ) = playerID;
     60  *(unsigned int *)(data_ + _SOURCEID ) = sourceID;
     61  *(unsigned int *)(data_ + _TARGETID ) = targetID;
    6062  *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
    6163
     
    8183
    8284bool 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));
    8486  delete this;
    85   return b;
     87  return true;
    8688}
    8789
  • code/trunk/src/libraries/network/packet/Chat.h

    r7801 r8858  
    4242public:
    4343  /* constructors */
    44   Chat( const std::string& message, unsigned int playerID );
     44  Chat( const std::string& message, unsigned int sourceID, unsigned int targetID );
    4545  Chat( uint8_t* data, unsigned int clientID );
    4646
  • code/trunk/src/libraries/network/packet/ClassID.cc

    r7801 r8858  
    9292  assert(tempsize==packetSize);
    9393
    94   COUT(5) << "classid packetSize is " << packetSize << endl;
     94  orxout(verbose_more, context::packets) << "classid packetSize is " << packetSize << endl;
    9595
    9696}
     
    131131  Identifier::clearNetworkIDs();
    132132
    133   COUT(4) << "=== processing classids: " << endl;
     133  orxout(verbose, context::packets) << "=== processing classids: " << endl;
    134134  std::pair<uint32_t, std::string> tempPair;
    135135  Identifier *id;
     
    143143    classname = temp+2*sizeof(uint32_t);
    144144    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;
    146146    if(id==NULL){
    147       COUT(0) << "Received a bad classname" << endl;
     147      orxout(user_error, context::packets) << "Received a bad classname" << endl;
    148148      abort();
    149149    }
  • code/trunk/src/libraries/network/packet/DeleteObjects.cc

    r7801 r8858  
    3131
    3232#include <cassert>
    33 #include "util/Debug.h"
     33#include "util/Output.h"
    3434#include "network/synchronisable/Synchronisable.h"
    3535
     
    6262  if(number==0)
    6363    return false;
    64   COUT(4) << "sending DeleteObjects: ";
     64  orxout(verbose, context::packets) << "sending DeleteObjects: ";
    6565  unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1);
    6666  data_ = new uint8_t[size];
     
    7373    unsigned int temp = Synchronisable::popDeletedObject();
    7474    *reinterpret_cast<uint32_t*>(tdata) = temp;
    75     COUT(4) << temp << ' ';
     75    orxout(verbose, context::packets) << temp << ' ';
    7676    tdata += sizeof(uint32_t);
    7777  }
    78   COUT(4) << std::endl;
     78  orxout(verbose, context::packets) << endl;
    7979  return true;
    8080}
     
    9090  for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++)
    9191  {
    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;
    9393    Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
    9494  }
  • code/trunk/src/libraries/network/packet/FunctionIDs.cc

    r7801 r8858  
    3434#include <string>
    3535
    36 #include "util/Debug.h"
     36#include "util/Output.h"
    3737#include "core/ObjectList.h"
    3838#include "network/NetworkFunction.h"
     
    8888  }
    8989
    90   COUT(5) << "FunctionIDs packetSize is " << packetSize << endl;
     90  orxout(verbose_more, context::packets) << "FunctionIDs packetSize is " << packetSize << endl;
    9191
    9292}
     
    126126  unsigned char *functionname;
    127127
    128   COUT(4) << "=== processing functionids: " << endl;
     128  orxout(verbose, context::packets) << "=== processing functionids: " << endl;
    129129  std::pair<uint32_t, std::string> tempPair;
    130130  // read the total number of classes
     
    137137    stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
    138138    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;
    140140    NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
    141141    temp += 2*sizeof(uint32_t) + stringsize;
  • code/trunk/src/libraries/network/packet/Gamestate.cc

    r8394 r8858  
    3131#include <zlib.h>
    3232
    33 #include "util/Debug.h"
     33#include "util/Output.h"
    3434#include "util/OrxAssert.h"
    3535#include "core/GameMode.h"
     
    108108  uint32_t size = calcGamestateSize(id, mode);
    109109
    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;
    111111  if(size==0)
    112112    return false;
     
    114114  if(!data_)
    115115  {
    116     COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
     116    orxout(internal_warning, context::packets) << "GameStateManager: could not allocate memory" << endl;
    117117    return false;
    118118  }
     
    139139      assert(0); // if we don't use multithreading this part shouldn't be neccessary
    140140      // start allocate additional memory
    141       COUT(3) << "Gamestate: need additional memory" << std::endl;
     141      orxout(internal_info, context::packets) << "Gamestate: need additional memory" << endl;
    142142      ObjectList<Synchronisable>::iterator temp = it;
    143143      uint32_t addsize=tempsize;
     
    167167  //stop write gamestate header
    168168
    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;
    171171  return true;
    172172}
     
    175175bool Gamestate::spreadData(uint8_t mode)
    176176{
    177   COUT(5) << "processing gamestate with id " << header_.getID() << endl;
     177  orxout(verbose_more, context::packets) << "processing gamestate with id " << header_.getID() << endl;
    178178  assert(data_);
    179179  assert(!header_.isCompressed());
     
    195195      else
    196196      {
    197 //         COUT(4) << "not creating object of classid " << objectheader.getClassID() << endl;
     197//         orxout(verbose, context::packets) << "not creating object of classid " << objectheader.getClassID() << endl;
    198198        mem += objectheader.getDataSize() + ( objectheader.isDiffed() ? SynchronisableHeaderLight::getSize() : SynchronisableHeader::getSize() );
    199199      }
     
    201201    else
    202202    {
    203 //       COUT(4) << "updating object of classid " << objectheader.getClassID() << endl;
     203//       orxout(verbose, context::packets) << "updating object of classid " << objectheader.getClassID() << endl;
    204204      OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data");
    205205    }
     
    219219        if (it->objectMode_ != 0x0)
    220220        {
    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;
    224224          assert(false);
    225225        }
     
    232232          if (it->getObjectID() == *it2)
    233233          {
    234             COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
    235                     << "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;
    237237            assert(false);
    238238          }
     
    293293  switch ( retval )
    294294  {
    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;
    299299  }
    300300
     
    310310  header_.setCompSize( buffer );
    311311  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;
    313313  return true;
    314314}
     
    319319  assert(data_);
    320320  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;
    322322  uint32_t datasize = header_.getDataSize();
    323323  uint32_t compsize = header_.getCompSize();
     
    333333  switch ( retval )
    334334  {
    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;
    339339  }
    340340
     
    375375  if( memcmp( origDataPtr+objectOffset, baseDataPtr+objectOffset, objectHeader.getDataSize()) == 0 )
    376376  {
    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;
    378378    origDataPtr += objectOffset + objectHeader.getDataSize(); // skip the whole object
    379379    baseDataPtr += objectOffset + objectHeader.getDataSize();
     
    431431inline void /*Gamestate::*/copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes )
    432432{
    433   //       COUT(4) << "docopy" << endl;
     433  //       orxout(verbose, context::packets) << "docopy" << endl;
    434434  // Just copy over the whole Object
    435435  memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() );
     
    440440//   SynchronisableHeader baseHeader( baseData );
    441441//   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() << ":";
    444444  sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables();
    445445//   for( unsigned int i = 0; i < Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); ++i )
    446446//   {
    447 //     //         COUT(4) << " " << *sizes;
     447//     //         orxout(verbose, context::packets) << " " << *sizes;
    448448//     ++sizes;
    449449//   }
    450     //       COUT(4) << endl;
     450    //       orxout(verbose, context::packets) << endl;
    451451}
    452452
     
    541541      if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() )
    542542      {
    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;
    544544        diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
    545545        diffedObject = true;
     
    547547      else
    548548      {
    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;
    550550        copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
    551551        assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd);
     
    565565        if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() )
    566566        {
    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;
    568568          diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
    569569          diffedObject = true;
     
    571571        else
    572572        {
    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;
    574574          copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
    575575          assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd);
     
    578578      else
    579579      {
    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;
    581581        assert(baseDataPtr == oldBaseDataPtr);
    582582        copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
     
    718718  //copy in the zeros
    719719//   std::list<obj>::iterator itt;
    720 //   COUT(0) << "myvector contains:";
     720//   orxout() << "myvector contains:";
    721721//   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
    722 //     COUT(0) << " " << (*itt).objID;
    723 //   COUT(0) << endl;
     722//     orxout() << " " << (*itt).objID;
     723//   orxout() << endl;
    724724  for(it=dataVector_.begin(); it!=dataVector_.end();){
    725725    SynchronisableHeader oldobjectheader(origdata);
     
    771771    nrOfVariables += it->getNrOfVariables();
    772772  }
    773 //   COUT(0) << "allocating " << nrOfVariables << " ints" << endl;
     773//   orxout() << "allocating " << nrOfVariables << " ints" << endl;
    774774  this->sizes_.reserve(nrOfVariables);
    775775  return size;
  • code/trunk/src/libraries/network/packet/Packet.cc

    r8327 r8858  
    3737#include <boost/thread/mutex.hpp>
    3838
    39 #include "util/Debug.h"
     39#include "util/Output.h"
    4040#include "Acknowledgement.h"
    4141#include "Chat.h"
     
    192192//     peerID = NETWORK_PEER_ID_SERVER;
    193193  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;
    195195  switch( *(Type::Value *)(data + _PACKETID) )
    196196  {
    197197    case Type::Acknowledgement:
    198 //       COUT(5) << "ack" << std::endl;
     198//       orxout(verbose_more, context::packets) << "ack" << endl;
    199199    p = new Acknowledgement( data, peerID );
    200200      break;
    201201    case Type::Chat:
    202 //       COUT(5) << "chat" << std::endl;
     202//       orxout(verbose_more, context::packets) << "chat" << endl;
    203203      p = new Chat( data, peerID );
    204204      break;
    205205    case Type::ClassID:
    206 //       COUT(5) << "classid" << std::endl;
     206//       orxout(verbose_more, context::packets) << "classid" << endl;
    207207      p = new ClassID( data, peerID );
    208208      break;
    209209    case Type::Gamestate:
    210 //       COUT(5) << "gamestate" << std::endl;
     210//       orxout(verbose_more, context::packets) << "gamestate" << endl;
    211211      p = new Gamestate( data, peerID );
    212212      break;
    213213    case Type::Welcome:
    214 //       COUT(5) << "welcome" << std::endl;
     214//       orxout(verbose_more, context::packets) << "welcome" << endl;
    215215      p = new Welcome( data, peerID );
    216216      break;
    217217    case Type::DeleteObjects:
    218 //       COUT(5) << "deleteobjects" << std::endl;
     218//       orxout(verbose_more, context::packets) << "deleteobjects" << endl;
    219219      p = new DeleteObjects( data, peerID );
    220220      break;
    221221    case Type::FunctionCalls:
    222 //       COUT(5) << "functionCalls" << std::endl;
     222//       orxout(verbose_more, context::packets) << "functionCalls" << endl;
    223223      p = new FunctionCalls( data, peerID );
    224224      break;
    225225    case Type::FunctionIDs:
    226 //       COUT(5) << "functionIDs" << std::endl;
     226//       orxout(verbose_more, context::packets) << "functionIDs" << endl;
    227227      p = new FunctionIDs( data, peerID );
    228228      break;
     
    255255  packetMap_.erase(it);
    256256  Packet::packetMapMutex_.unlock();
    257 //   COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;
     257//   orxout(verbose_ultra, context::packets) << "PacketMap size: " << packetMap_.size() << endl;
    258258}
    259259
  • code/trunk/src/libraries/network/packet/Welcome.cc

    r8706 r8858  
    3232
    3333#include <cassert>
    34 #include "util/Debug.h"
     34#include "util/Output.h"
    3535#include "network/Host.h"
    3636#include "network/synchronisable/Synchronisable.h"
     
    7878  assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321);
    7979  host->setClientID(clientID);
    80   COUT(3) << "Welcome set clientId: " << clientID << endl;
     80  orxout(internal_info, context::packets) << "Welcome set clientId: " << clientID << endl;
    8181  Synchronisable::setClient(true);
    8282  delete this;
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.cc

    r8706 r8858  
    130130//     assert( !header.isDiffed() );
    131131
    132     COUT(4) << "fabricating object with id: " << header.getObjectID() << std::endl;
     132    orxout(verbose, context::network) << "fabricating object with id: " << header.getObjectID() << endl;
    133133
    134134    Identifier* id = ClassByID(header.getClassID());
     
    136136    {
    137137        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;
    141141        abort();
    142142    }
     
    168168      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)
    169169    //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;
    171171          // update data and create object/entity...
    172172    bool b = no->updateData(mem, mode, true);
     
    242242    uint8_t* oldmem = mem;
    243243    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;
    245245#endif
    246246
     
    258258    // end copy header
    259259
    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_ << ":";
    262262    // copy to location
    263263    for(i=syncList_.begin(); i!=syncList_.end(); ++i)
    264264    {
    265265      uint32_t varsize = (*i)->getData( mem, mode );
    266 //       COUT(4) << " " << varsize;
     266//       orxout(verbose, context::network) << " " << varsize;
    267267      tempsize += varsize;
    268268      sizes.push_back(varsize);
     
    271271    }
    272272    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;
    274274
    275275    header.setObjectID( this->objectID_ );
     
    305305    if(syncList_.empty())
    306306    {
     307      orxout(internal_warning, context::network) << "Synchronisable::updateData syncList_ is empty" << endl;
    307308      assert(0);
    308       COUT(2) << "Synchronisable::updateData syncList_ is empty" << std::endl;
    309309      return false;
    310310    }
     
    326326    }
    327327
    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;
    329329    if( !syncHeaderLight.isDiffed() )
    330330    {
     
    344344    {
    345345      mem += SynchronisableHeaderLight::getSize();
    346 //       COUT(0) << "objectID: " << this->objectID_ << endl;
     346//       orxout(debug_output, context::network) << "objectID: " << this->objectID_ << endl;
    347347      while( mem < data+syncHeaderLight.getDataSize()+SynchronisableHeaderLight::getSize() )
    348348      {
    349349        VariableID varID = *(VariableID*)mem;
    350 //         COUT(0) << "varID: " << varID << endl;
     350//         orxout(debug_output, context::network) << "varID: " << varID << endl;
    351351        assert( varID < syncList_.size() );
    352352        mem += sizeof(VariableID);
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.h

    r8706 r8858  
    232232        it++;
    233233    }
    234     COUT(1) << "Tried to unregister not registered variable" << endl;
     234    orxout(internal_error, context::network) << "Tried to unregister not registered variable" << endl;
    235235    assert(false); //if we reach this point something went wrong:
    236236    // the variable has not been registered before
  • code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h

    r7266 r8858  
    202202        if ( *static_cast<uint8_t*>(mem) != this->varReference_ )
    203203        { // wrong reference number, so discard the data
    204 //           COUT(0) << "discharding data" << endl;
     204//           orxout(debug_output, context::network) << "discharding data" << endl;
    205205          mem += getSize( mode ); // SynchronisableVariableBidirectional::getSize returns size of variable + reference
    206206          return;
Note: See TracChangeset for help on using the changeset viewer.