Changeset 6693 for code/branches/chat
- Timestamp:
- Apr 12, 2010, 4:06:46 PM (15 years ago)
- Location:
- code/branches/chat/src/orxonox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/chat/src/orxonox/ChatHistory.cc
r6690 r6693 33 33 { 34 34 #endif 35 /* QUESTION */36 /* is this necessary? if yes uncomment please :P */37 //CreateFactory(ChatHistory);38 35 39 36 /* constructor */ 40 37 #ifndef TEST 41 38 ChatHistory(BaseObject* creator) : BaseObject(creator) 42 39 #else 43 40 ChatHistory::ChatHistory() 44 41 #endif 45 42 { 46 43 /* register the object */ 47 44 #ifndef TEST 48 45 RegisterObject(ChatHistory); 49 46 #endif 50 47 51 48 this->hist_log_enabled = true; … … 76 73 unsigned int senderID) 77 74 { 78 /* QUESTION*/79 /* sanity - check for valid senderID */75 /* --> a) look up the actual name of the sender */ 76 std::string text; 80 77 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(); 83 85 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 90 93 91 94 /* add the line to the history */ 92 this->chat_hist_addline( name + ": " + message);95 this->chat_hist_addline( text ); 93 96 94 97 /* add the line to the log */ 95 this->chat_hist_logline( name + ": " + message);98 this->chat_hist_logline( text ); 96 99 } 97 100 … … 125 128 int ChatHistory::chat_hist_openlog() 126 129 { 127 /* QUESTION */128 130 /* TODO: find out the name of the file to log to via settings 129 131 * and set the this->hist_logfile_path variable to it 130 132 */ 131 this->hist_logfile.open( "/tmp/setsomepath.txt", 133 #ifndef TEST 134 this->hist_logfile.open( PathConfig::getInstance().getLogPathString() + 135 "chatlog.log", 132 136 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 133 141 134 /* QUESTION */135 142 /* 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 } 136 149 137 150 /* if it worked */ -
code/branches/chat/src/orxonox/ChatHistory.h
r6690 r6693 33 33 34 34 /* define this if you're unit testing */ 35 #define TEST 035 #define TEST 1 36 36 37 37 #ifndef TEST 38 38 #include <core/BaseObject.h> 39 #include <core/PathConfig.h> 39 40 #endif 40 41 … … 50 51 51 52 /* constructor */ 52 53 #ifndef TEST 53 54 class _OrxonoxExport ChatHistory : public BaseObject, public ChatListener 54 55 #else 55 56 class ChatHistory 56 57 #endif 57 58 { 58 59 public: 59 60 /* constructors, destructors */ 60 61 #ifndef TEST 61 62 ChatHistory(BaseObject* creator); 62 63 #else 63 64 ChatHistory(); 64 65 #endif 65 66 virtual ~ChatHistory(); 66 67
Note: See TracChangeset
for help on using the changeset viewer.