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 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • 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}
Note: See TracChangeset for help on using the changeset viewer.