Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 12, 2010, 4:06:46 PM (15 years ago)
Author:
smerkli
Message:

questions resolved, ready for in-game testing.

Location:
code/branches/chat/src/orxonox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/chat/src/orxonox/ChatHistory.cc

    r6690 r6693  
    3333{
    3434#endif
    35   /* QUESTION */
    36   /* is this necessary? if yes uncomment please :P */
    37   //CreateFactory(ChatHistory);
    3835
    3936  /* constructor */
    40   #ifndef TEST
     37#ifndef TEST
    4138  ChatHistory(BaseObject* creator) : BaseObject(creator)
    42   #else
     39#else
    4340  ChatHistory::ChatHistory()
    44   #endif
     41#endif
    4542  {
    4643    /* register the object */
    47     #ifndef TEST
     44#ifndef TEST
    4845    RegisterObject(ChatHistory);
    49     #endif
     46#endif
    5047
    5148    this->hist_log_enabled = true;
     
    7673    unsigned int senderID)
    7774  {
    78     /* QUESTION */
    79     /* sanity - check for valid senderID */
     75    /* --> a) look up the actual name of the sender */
     76    std::string text;
    8077
    81     /* TODO make a correct name */
    82     std::string name = "" + senderID; /* NOTE to be changed */
     78#ifndef TEST
     79    if (senderID != CLIENTID_UNKNOWN)
     80    {
     81       std::string name = "unknown";
     82       PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
     83       if (player)
     84         name = player->getName();
    8385
    84     /* TODO */
    85     /* QUESTION */
    86     /* --> a) look up the actual name of the sender */
    87     /* --> b) add sender name and string up with a separator
    88      *    to make up the actual message
    89      */
     86         text = name + ": " + message;
     87    }
     88    else
     89      text = message;
     90#else
     91    text = message;
     92#endif
    9093
    9194    /* add the line to the history */
    92     this->chat_hist_addline( name + ": " + message );
     95    this->chat_hist_addline( text );
    9396
    9497    /* add the line to the log */
    95     this->chat_hist_logline( name + ": " + message );
     98    this->chat_hist_logline( text );
    9699  }
    97100
     
    125128  int ChatHistory::chat_hist_openlog()
    126129  {
    127     /* QUESTION */
    128130    /* TODO: find out the name of the file to log to via settings
    129131     *       and set the this->hist_logfile_path variable to it
    130132     */
    131     this->hist_logfile.open( "/tmp/setsomepath.txt",
     133#ifndef TEST
     134    this->hist_logfile.open( PathConfig::getInstance().getLogPathString() +
     135      "chatlog.log",
    132136      std::fstream::out | std::fstream::app );
     137#else
     138    this->hist_logfile.open( "/tmp/chatlog.log",
     139      std::fstream::out | std::fstream::app );
     140#endif
    133141
    134     /* QUESTION */
    135142    /* TODO check whether this works (not sure how you'd like it?) */
     143    if( !this->hist_logfile )
     144    { this->hist_log_enabled = false;
     145#ifndef TEST
     146      COUT(2) << "Warning: Could not open logfile." << std::endl;
     147#endif
     148    }
    136149
    137150    /* if it worked */
  • code/branches/chat/src/orxonox/ChatHistory.h

    r6690 r6693  
    3333
    3434/* define this if you're unit testing */
    35 #define TEST 0
     35#define TEST 1
    3636
    3737#ifndef TEST
    3838#include <core/BaseObject.h>
     39#include <core/PathConfig.h>
    3940#endif
    4041
     
    5051
    5152  /* constructor */
    52   #ifndef TEST
     53#ifndef TEST
    5354  class _OrxonoxExport ChatHistory : public BaseObject, public ChatListener
    54   #else
     55#else
    5556  class ChatHistory
    56   #endif
     57#endif
    5758  {
    5859    public:
    5960      /* constructors, destructors */
    60       #ifndef TEST
     61#ifndef TEST
    6162      ChatHistory(BaseObject* creator);
    62       #else
     63#else
    6364      ChatHistory();
    64       #endif
     65#endif
    6566      virtual ~ChatHistory();
    6667
Note: See TracChangeset for help on using the changeset viewer.