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