Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8829


Ignore:
Timestamp:
Aug 7, 2011, 3:11:16 PM (13 years ago)
Author:
landauf
Message:

enhanced chat system. chat related code is now separated into network-side code (located in Host, Client, Server) and client-side code (located in ChatManager).
note that there are now two chat related listeners: NetworkChatListener, which is used to send chat from the network to ChatManager, and ChatListener, which is used to send online and offline chat from ChatManager to the actual chat interfaces (ChatOverlay, ChatInputHandler, …).
the "chat" console command now supports a second argument which is the clientID of the receiver. this allows private messages (or gameplay messages directed to only one specific player).

Location:
code/branches/output/src
Files:
4 added
2 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/libraries/network/CMakeLists.txt

    r8351 r8829  
    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/branches/output/src/libraries/network/Client.cc

    r8807 r8829  
    116116  }
    117117
    118   bool Client::processChat(const std::string& message, unsigned int playerID)
    119   {
    120 //    orxout(message) << "Player " << playerID << ": " << message << endl;
    121     return true;
    122   }
    123 
    124118  void Client::printRTT()
    125119  {
     
    128122
    129123  /**
    130    * This function implements the method of sending a chat message to the server
     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  /**
     
    203207    Game::getInstance().popState();
    204208  }
    205  
     209
    206210  void Client::processPacket(packet::Packet* packet)
    207211  {
     
    216220      packet->process(static_cast<Host*>(this));
    217221  }
    218 
    219 
    220 
    221 
    222222}
  • code/branches/output/src/libraries/network/Client.h

    r7801 r8829  
    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/branches/output/src/libraries/network/Host.cc

    r8827 r8829  
    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     for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
    94       it->incomingChat(message, 0);
    95 
    96     bool result = true;
    9799    for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
    98     {
    99100      if( (*it)->isActive() )
    100       {
    101         if( !(*it)->chat(message) )
    102           result = false;
    103       }
    104     }
    105 //    return result;
     101        (*it)->doSendChat(message, sourceID, targetID);
    106102  }
    107103
    108   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)
    109108  {
    110     for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
    111       it->incomingChat(message, NETWORK_PEER_ID_BROADCAST);
    112 
    113     bool result = true;
    114     for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
    115     {
    116       if( (*it)->isActive() )
    117       {
    118         if( !(*it)->broadcast(message) )
    119           result = false;
    120       }
    121     }
    122     return result;
     109    for (ObjectList<NetworkChatListener>::iterator it = ObjectList<NetworkChatListener>::begin(); it != ObjectList<NetworkChatListener>::end(); ++it)
     110      it->incomingChat(message, sourceID);
    123111  }
    124112
    125   bool Host::incomingChat(const std::string& message, unsigned int playerID)
    126   {
    127     for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
    128       it->incomingChat(message, playerID);
    129 
    130     bool result = true;
    131     for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
    132     {
    133       if( (*it)->isActive() )
    134       {
    135         if( !(*it)->processChat(message, playerID) )
    136           result = false;
    137       }
    138     }
    139     return result;
    140   }
    141113
    142114  bool Host::isServer()
     
    167139
    168140
     141  //////////////////////////////////////////////////////////////////////////
     142  // NetworkChatListener                                                  //
     143  //////////////////////////////////////////////////////////////////////////
     144
     145  NetworkChatListener::NetworkChatListener()
     146  {
     147      RegisterRootObject(NetworkChatListener);
     148  }
     149
    169150}//namespace orxonox
  • code/branches/output/src/libraries/network/Host.h

    r8403 r8829  
    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/branches/output/src/libraries/network/NetworkPrereqs.h

    r8351 r8829  
    118118namespace orxonox
    119119{
    120   class ChatListener;
    121120  class Client;
    122121  class ClientConnection;
     
    130129  class GamestateManager;
    131130  class Host;
     131  class NetworkChatListener;
    132132  class NetworkFunctionBase;
    133133  struct NetworkFunctionPointer;
  • code/branches/output/src/libraries/network/Server.cc

    r8807 r8829  
    5656#include "packet/Gamestate.h"
    5757#include "packet/Welcome.h"
    58 #include "ChatListener.h"
    5958// #include "ClientInformation.h"
    6059#include "FunctionCallManager.h"
     
    104103  void Server::helper_ConnectToMasterserver()
    105104  {
    106 //     WANDiscovery::getInstance().msc.sendRequest( MSPROTO_GAME_SERVER " " 
     105//     WANDiscovery::getInstance().msc.sendRequest( MSPROTO_GAME_SERVER " "
    107106//       MSPROTO_REGISTER_SERVER );
    108107  }
     
    116115    orxout(verbose, context::network) << "opening server" << endl;
    117116    this->openListener();
    118    
     117
    119118    /* make discoverable on LAN */
    120119    LANDiscoverable::setActivity(true);
     
    123122    WANDiscoverable::setActivity(true);
    124123    /* TODO this needs to be optional, we need a switch from the UI to
    125      * enable/disable this 
     124     * enable/disable this
    126125     */
    127126//     helper_ConnectToMasterserver();
     
    143142    /* tell master server we're closing */
    144143    orxout(internal_info, context::network) << "disconnecting." << endl;
    145     WANDiscoverable::setActivity(false);   
     144    WANDiscoverable::setActivity(false);
    146145    orxout(internal_info, context::network) << "disconnecting done" << endl;
    147146
     
    150149  }
    151150
    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 //         orxout(internal_warning, context::network) << "could not send Chat message to client ID: " << temp->getID() << endl;
    161 //       temp = temp->next();
    162 //     }
    163 //    orxout(message) << "Player " << playerID << ": " << message << endl;
    164     return true;
    165   }
    166 
    167 
    168151  /* handle incoming data */
    169152  int rephandler( char *addr, ENetEvent *ev )
    170   { 
     153  {
    171154    /* reply to pings */
    172     if( !strncmp( (char *)ev->packet->data, MSPROTO_PING_GAMESERVER, 
     155    if( !strncmp( (char *)ev->packet->data, MSPROTO_PING_GAMESERVER,
    173156      MSPROTO_PING_GAMESERVER_LEN ) )
    174157      //this->msc.sendRequest( MSPROTO_ACK );
    175158      /* NOTE implement this after pollForReply
    176        * reimplementation 
     159       * reimplementation
    177160       */
    178161      return 0;
     
    183166
    184167  void Server::helper_HandleMasterServerRequests()
    185   { 
    186     /* poll the master server for replies and see whether something 
     168  {
     169    /* poll the master server for replies and see whether something
    187170     * has to be done or changed.
    188171     */
     
    202185    // receive and process incoming discovery packets
    203186    LANDiscoverable::update();
    204    
     187
    205188    // receive and process requests from master server
    206189    /* todo */
     
    330313  {
    331314//     static unsigned int newid=1;
    332 // 
     315//
    333316//     orxout(internal_info, context::network) << "Server: adding client" << endl;
    334317//     ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
     
    375358//     }
    376359  }
    377  
     360
    378361  void Server::processPacket(packet::Packet* packet)
    379362  {
     
    411394//     temp->setSynched(true);
    412395    GamestateManager::setSynched(clientID);
    413    
     396
    414397    orxout(verbose, context::network) << "sending welcome" << endl;
    415398    packet::Welcome *w = new packet::Welcome(clientID);
     
    438421  }
    439422
    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 //         orxout(internal_warning, context::network) << "could not send Chat message to client ID: " << temp->getID() << endl;
    460 //       temp = temp->next();
    461     }
    462 //    orxout(message) << "Player " << Host::getPlayerID() << ": " << message << endl;
    463     for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
    464       it->incomingChat(message, clientID);
    465 
    466     return true;
     423  /**
     424   * @brief Sends a chat message to the given target ID.
     425   * @param message message to be sent
     426   * @param sourceID the ID of the sender
     427   * @param targetID the ID of the receiver
     428   */
     429  void Server::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
     430  {
     431    // check if the target exists. just ignore the message otherwise
     432    if (!this->isValidTarget(targetID)) // TODO: remove this if an invalid clientIDs don't trigger assertions anymore
     433      return;
     434
     435    // send the message to the target
     436    packet::Chat* packet = new packet::Chat(message, sourceID, targetID);
     437    packet->setPeerID(targetID);
     438    packet->send( static_cast<Host*>(this) );
     439
     440    // if the target is (or includes) this host as well, call the parent function which passes the message to the listeners
     441    if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == Host::getPlayerID())
     442      Host::doReceiveChat(message, sourceID, targetID);
     443  }
     444
     445  /**
     446   * @brief Gets called if a packet::Chat packet is received. Forwards the packet to the target
     447   * and calls the parent function if necessary.
     448   */
     449  void Server::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
     450  {
     451      this->doSendChat(message, sourceID, targetID);
     452  }
     453
     454  /**
     455   * @brief Returns true if the target ID is in the list of clients (or if it
     456   * corresponds to the broadcast or the server ID).
     457   */
     458  bool Server::isValidTarget(unsigned int targetID)
     459  {
     460    if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == NETWORK_PEER_ID_SERVER)
     461      return true;
     462
     463    std::vector<uint32_t>::iterator it;
     464    for( it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it )
     465      if( *it == targetID )
     466        return true;
     467
     468    return false;
    467469  }
    468470
  • code/branches/output/src/libraries/network/Server.h

    r8351 r8829  
    6868    void open();
    6969    void close();
    70     bool processChat(const std::string& message, unsigned int playerID);
    7170    void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID);
    7271    virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
     
    8988    bool sendGameStates();
    9089    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);
     90    bool isValidTarget(unsigned int targetID);
     91    virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
     92    virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
    9493    void syncClassid(unsigned int clientID);
    9594
  • code/branches/output/src/libraries/network/packet/Chat.cc

    r7801 r8829  
    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/branches/output/src/libraries/network/packet/Chat.h

    r7801 r8829  
    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/branches/output/src/modules/gametypes/RaceCheckPoint.cc

    r8822 r8829  
    3232#include "core/CoreIncludes.h"
    3333#include "core/XMLPort.h"
    34 #include "network/Host.h"
     34#include "chat/ChatManager.h"
    3535#include "SpaceRace.h"
    3636
     
    112112                            + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1);
    113113                const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
    114                 Host::Broadcast(message);
     114                ChatManager::message(message);
    115115            }
    116116        }
  • code/branches/output/src/modules/gametypes/SpaceRace.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/Host.h"
    33 #include <util/Clock.h>
    34 #include <util/Math.h>
     32#include "chat/ChatManager.h"
     33#include "util/Clock.h"
     34#include "util/Math.h"
    3535#include "util/Convert.h"
    3636
     
    6060                        + " before the time limit. You lose!";
    6161            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    62             Host::Broadcast(message);
     62            ChatManager::message(message);
    6363        }
    6464        else
     
    7070                        + "." + multi_cast<std::string>(ms) + " seconds.";
    7171            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    72             Host::Broadcast(message);
     72            ChatManager::message(message);
    7373/*
    7474            float time = this->clock_.getSecondsPrecise();
     
    8686
    8787        std::string message("The match has started! Reach the check points as quickly as possible!");
    88         Host::Broadcast(message);
     88        ChatManager::message(message);
    8989    }
    9090
     
    9999                        + " seconds.";
    100100        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    101         Host::Broadcast(message);
     101        ChatManager::message(message);
    102102    }
    103103
  • code/branches/output/src/modules/overlays/hud/ChatOverlay.cc

    r8826 r8829  
    6767    }
    6868
    69     void ChatOverlay::incomingChat(const std::string& message, unsigned int senderID)
     69    void ChatOverlay::incomingChat(const std::string& message, const std::string& /*name*/)
    7070    {
    71         std::string text = message;
    72 
    73         if (senderID != NETWORK_PEER_ID_UNKNOWN)
    74         {
    75             PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
    76             if (player)
    77                 text = player->getName() + ": " + message;
    78         }
    79 
    80         this->messages_.push_back(multi_cast<Ogre::DisplayString>(text));
     71        this->messages_.push_back(multi_cast<Ogre::DisplayString>(message));
    8172
    8273        Timer* timer = new Timer();
  • code/branches/output/src/modules/overlays/hud/ChatOverlay.h

    r6417 r8829  
    3535#include <OgreOverlayElement.h>
    3636
    37 #include "network/ChatListener.h"
     37#include "chat/ChatListener.h"
    3838#include "overlays/OverlayText.h"
    3939
     
    4949
    5050        protected:
    51             virtual void incomingChat(const std::string& message, unsigned int senderID);
     51            virtual void incomingChat(const std::string& message, const std::string& name);
    5252
    5353            std::list<Ogre::DisplayString> messages_;
  • code/branches/output/src/orxonox/OrxonoxPrereqs.h

    r8351 r8829  
    7777    class Radar;
    7878    class Scene;
     79
     80    // chat
     81    class ChatHistory;
     82    class ChatInputHandler;
     83    class ChatListener;
     84    class ChatManager;
    7985
    8086    // collisionshapes
  • code/branches/output/src/orxonox/chat/CMakeLists.txt

    r8828 r8829  
    22  ChatHistory.cc
    33  ChatInputHandler.cc
     4  ChatManager.cc
    45)
  • code/branches/output/src/orxonox/chat/ChatHistory.cc

    r8828 r8829  
    7474
    7575  /* react to incoming chat */
    76   void ChatHistory::incomingChat(const std::string& message,
    77     unsigned int senderID)
     76  void ChatHistory::incomingChat(const std::string& message, const std::string& /*name*/)
    7877  {
    79     /* --> a) look up the actual name of the sender */
    80     std::string text = message;
    81 
    82 #ifndef CHATTEST
    83     /* get sender ID and prepend it to the message */
    84     if (senderID != NETWORK_PEER_ID_UNKNOWN)
    85     {
    86       PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
    87       if (player)
    88         text = player->getName() + ": " + message;
    89     }
    90 #endif
    91 
    9278    /* add the line to the history */
    93     this->chat_hist_addline( text );
     79    this->chat_hist_addline( message );
    9480
    9581    /* add the line to the log */
    96     this->chat_hist_logline( text );
     82    this->chat_hist_logline( message );
    9783  }
    9884
  • code/branches/output/src/orxonox/chat/ChatHistory.h

    r8828 r8829  
    3737
    3838#ifndef CHATTEST
    39 #include <OrxonoxPrereqs.h>
    40 #include <PlayerManager.h>
    41 #include <infos/PlayerInfo.h>
    42 #include <core/BaseObject.h>
    43 #include <network/ChatListener.h>
    44 #include <core/PathConfig.h>
    45 #include <util/Singleton.h>
     39#include "OrxonoxPrereqs.h"
     40
     41#include "util/Singleton.h"
     42#include "core/BaseObject.h"
     43#include "core/PathConfig.h"
     44#include "chat/ChatListener.h"
     45#include "infos/PlayerInfo.h"
     46#include "PlayerManager.h"
    4647#endif
    4748
     
    8283       * \param senderID Identification number of the sender
    8384       */
    84       virtual void incomingChat(const std::string& message,
    85         unsigned int senderID);
     85      virtual void incomingChat(const std::string& message, const std::string& name);
    8686
    8787      /** Synchronize logfile onto the hard drive
  • code/branches/output/src/orxonox/chat/ChatInputHandler.cc

    r8828 r8829  
    4444#include "core/input/InputManager.h"
    4545#include "core/input/InputState.h"
    46 #include "network/Host.h"
    47 
     46
     47#include "chat/ChatManager.h"
    4848#include "PlayerManager.h"
    4949#include "infos/PlayerInfo.h"
     
    213213
    214214  /* handle incoming chat */
    215   void ChatInputHandler::incomingChat(const std::string& message,
    216     unsigned int senderID)
    217   {
    218     /* look up the actual name of the sender */
    219     std::string text = message;
    220     std::string name = "";
    221 
    222     /* setup player name info */
    223     if (senderID != NETWORK_PEER_ID_UNKNOWN)
    224     {
    225        PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
    226        if (player)
    227        {
    228          name = player->getName();
    229          text = name + ": " + message;
    230        }
    231     }
    232 
     215  void ChatInputHandler::incomingChat(const std::string& message, const std::string& name)
     216  {
    233217    /* create item */
    234     CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( text );
     218    CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( message );
    235219
    236220    /* setup colors */
     
    320304
    321305    /* c) send the chat via some call */
    322     Host::Chat( msgtosend );
     306    ChatManager::chat( msgtosend );
    323307
    324308    /* d) stop listening to input - only if this is not fullchat */
  • code/branches/output/src/orxonox/chat/ChatInputHandler.h

    r8828 r8829  
    3030#define _ChatInputHandler_H__
    3131
    32 #include <OrxonoxPrereqs.h>
     32#include "OrxonoxPrereqs.h"
    3333
    3434#include <string>
     
    3737
    3838#include "util/Singleton.h"
    39 #include "network/ChatListener.h"
     39#include "chat/ChatListener.h"
    4040
    4141namespace orxonox // tolua_export
     
    112112       * history window of the full chat window)
    113113       */
    114       void incomingChat( const std::string& message,
    115         unsigned int senderID );
     114      void incomingChat(const std::string& message, const std::string& name);
    116115
    117116      /** \param full true means show full chat window with history,
  • code/branches/output/src/orxonox/gametypes/Asteroids.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/Host.h"
     32#include "chat/ChatManager.h"
    3333#include "worldentities/pawns/Pawn.h"
    3434
     
    7474
    7575        std::string message("The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...");
    76         Host::Broadcast(message);
     76        ChatManager::message(message);
    7777
    7878    }
     
    8383
    8484        std::string message("The match has ended.");
    85         Host::Broadcast(message);
     85        ChatManager::message(message);
    8686    }
    8787}
  • code/branches/output/src/orxonox/gametypes/Deathmatch.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/Host.h"
     32#include "chat/ChatManager.h"
    3333#include "infos/PlayerInfo.h"
    3434#include "worldentities/pawns/Pawn.h"
     
    4848
    4949        std::string message("The match has started!");
    50         Host::Broadcast(message);
     50        ChatManager::message(message);
    5151    }
    5252
     
    5656
    5757        std::string message("The match has ended.");
    58         Host::Broadcast(message);
     58        ChatManager::message(message);
    5959    }
    6060
     
    6464
    6565        const std::string& message = player->getName() + " entered the game";
    66         Host::Broadcast(message);
     66        ChatManager::message(message);
    6767    }
    6868
     
    7474        {
    7575            const std::string& message = player->getName() + " left the game";
    76             Host::Broadcast(message);
     76            ChatManager::message(message);
    7777        }
    7878
     
    8787        {
    8888            const std::string& message = player->getOldName() + " changed name to " + player->getName();
    89             Host::Broadcast(message);
     89            ChatManager::message(message);
    9090        }
    9191
     
    108108                message = victim->getPlayer()->getName() + " died";
    109109
    110             Host::Broadcast(message);
     110            ChatManager::message(message);
    111111        }
    112112
     
    121121        {
    122122            const std::string& message = player->getName() + " scores!";
    123             Host::Broadcast(message);
     123            ChatManager::message(message);
    124124        }
    125125    }
  • code/branches/output/src/orxonox/gametypes/Dynamicmatch.cc

    r8822 r8829  
    4949#include "core/CoreIncludes.h"
    5050#include "core/command/Executor.h"
    51 #include "network/Host.h"
     51#include "chat/ChatManager.h"
    5252#include "infos/PlayerInfo.h"
    5353#include "worldentities/pawns/Pawn.h"
     
    343343        Gametype::playerEntered(player);
    344344        const std::string& message = player->getName() + " entered the game";
    345         Host::Broadcast(message);
     345        ChatManager::message(message);
    346346    }
    347347
     
    358358            }
    359359            const std::string& message = player->getName() + " left the game";
    360             Host::Broadcast(message);
     360            ChatManager::message(message);
    361361            //remove player from map
    362362            playerParty_.erase (player);
     
    615615        {
    616616            const std::string& message = player->getOldName() + " changed name to " + player->getName();
    617             Host::Broadcast(message);
     617            ChatManager::message(message);
    618618        }
    619619
     
    627627        {
    628628            std::string message("Dynamicmatch started!");
    629             Host::Broadcast(message);
     629            ChatManager::message(message);
    630630        }
    631631        else if(tutorial) // Announce selectionphase
     
    643643    {
    644644        std::string message("Earn points:\n\n\n\tIf you're red: Chase the blue player!\n\n\tIf you're blue shoot at a red player or hide.\n\n\tIf you're green: You've got the licence to kill red players!");
    645         Host::Broadcast(message);
     645        ChatManager::message(message);
    646646        callInstructions_.setTimer(10, false, createExecutor(createFunctor(&Dynamicmatch::furtherInstructions, this)));
    647647    }
     
    650650    {
    651651        std::string message("After 3 Minutes the game is over.");
    652         Host::Broadcast(message);
     652        ChatManager::message(message);
    653653    }*/
    654654    void Dynamicmatch::end()
     
    657657
    658658        std::string message("Time out. Press F2 to see the points you scored.");
    659         Host::Broadcast(message);
     659        ChatManager::message(message);
    660660    }
    661661    SpawnPoint* Dynamicmatch::getBestSpawnPoint(PlayerInfo* player) const
  • code/branches/output/src/orxonox/gametypes/LastManStanding.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/Host.h"
     32#include "chat/ChatManager.h"
    3333#include "infos/PlayerInfo.h"
    3434#include "worldentities/pawns/Pawn.h"
     
    105105            this->playersAlive--;
    106106            const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
    107             Host::Broadcast(message);
     107            ChatManager::message(message);
    108108        }
    109109
  • code/branches/output/src/orxonox/gametypes/LastTeamStanding.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/NetworkPrereqs.h"
    33 #include "network/Host.h"
     32#include "chat/ChatManager.h"
    3433#include "infos/PlayerInfo.h"
    3534#include "worldentities/pawns/Pawn.h"
     
    119118                this->teamsAlive--;
    120119            const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
    121             Host::Broadcast(message);
     120            ChatManager::message(message);
    122121        }
    123122        return allow;
  • code/branches/output/src/orxonox/gametypes/UnderAttack.cc

    r8822 r8829  
    3232#include "core/CoreIncludes.h"
    3333#include "core/ConfigValueIncludes.h"
    34 #include "network/Host.h"
     34#include "chat/ChatManager.h"
    3535#include "worldentities/pawns/Destroyer.h"
    3636#include "infos/PlayerInfo.h"
     
    7070        this->end(); //end gametype
    7171        std::string message("Ship destroyed! Team 0 has won!");
    72         Host::Broadcast(message);
     72        ChatManager::message(message);
    7373        this->gameEnded_ = true;
    7474
     
    152152                this->end();
    153153                std::string message("Time is up! Team 1 has won!");
    154                 Host::Broadcast(message);
     154                ChatManager::message(message);
    155155
    156156                for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
     
    171171                const std::string& message = multi_cast<std::string>(timesequence_) + " seconds left!";
    172172/*
    173                 Host::Broadcast(message);
     173                ChatManager::message(message);
    174174*/
    175175                this->gtinfo_->sendAnnounceMessage(message);
Note: See TracChangeset for help on using the changeset viewer.