Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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).

File:
1 edited

Legend:

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