Changeset 8588 in orxonox.OLD for branches/network/src
- Timestamp:
- Jun 19, 2006, 6:46:49 PM (18 years ago)
- Location:
- branches/network/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/message_manager.h
r8236 r8588 31 31 MSGID_DELETESYNCHRONIZEABLE, 32 32 MSGID_PREFEREDTEAM, 33 MSGID_CHANGENICKNAME 33 MSGID_CHANGENICKNAME, 34 MSGID_CHATMESSAGE 34 35 }; 35 36 -
branches/network/src/lib/network/network_game_manager.cc
r8459 r8588 280 280 281 281 282 282 bool NetworkGameManager::chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 283 { 284 assert( State::getGameRules() ); 285 assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) ); 286 287 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); 288 289 if ( dataLength < 2*INTSIZE ) 290 { 291 PRINTF(2)("got too small chatmessage from client %d\n", userId); 292 293 return true; 294 } 295 296 int messageType = 0; 297 Converter::byteArrayToInt( data, &messageType ); 298 std::string message; 299 Converter::byteArrayToString( data+INTSIZE, message, dataLength-INTSIZE ); 300 301 rules.handleChatMessage( userId, message, messageType ); 302 303 return true; 304 } 305 306 /** 307 * send chat message 308 * @param message message text 309 * @param messageType some int 310 * @param userId user to send message to -1 = ALL 311 */ 312 void NetworkGameManager::sendChatMessage( const std::string & message, int messageType, int userId ) 313 { 314 byte * buf = new byte[message.length()]+2*INTSIZE; 315 316 assert( Converter::intToByteArray( messageType, buf, INTSIZE ) == INTSIZE ); 317 assert( Converter::stringToByteArray(message, buf+INTSIZE, message.length()+INTSIZE) == message.length()+INTSIZE ); 318 319 if ( userId == -1 ) 320 MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, sizeof(buf), RT_ALL_ME, 0, MP_HIGHBANDWIDTH ); 321 else 322 MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, sizeof(buf), RT_USER, userId, MP_HIGHBANDWIDTH ); 323 324 delete [] buf; 325 } 326 327 328 -
branches/network/src/lib/network/network_game_manager.h
r8147 r8588 64 64 65 65 void tick( float ds ); 66 67 void sendChatMessage( const std::string & message, int messageType, int userId = -1 ); 66 68 67 69 private: … … 70 72 static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 71 73 static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 74 static bool chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 72 75 73 76 void setPreferedTeam( int userId, int teamId ); -
branches/network/src/util/multiplayer_team_deathmatch.cc
r8466 r8588 548 548 549 549 550 551 552 550 /** 551 * this method is called by NetworkGameManger when he recieved a chat message 552 * @param userId senders user id 553 * @param message message string 554 * @param messageType some int 555 */ 556 void MultiplayerTeamDeathmatch::handleChatMessage( int userId, const std::string & message, int messageType ) 557 { 558 std::string name = "unknown"; 559 560 if ( PlayerStats::getStats( userId ) ) 561 { 562 name = PlayerStats::getStats( userId )->getNickName(); 563 } 564 565 PRINTF(0)("CHATMESSAGE %s: %s\n", name.c_str(), message.c_str() ); 566 } 567 568 569 570 -
branches/network/src/util/multiplayer_team_deathmatch.h
r8331 r8588 57 57 58 58 virtual void process(const Event &event); 59 60 virtual void handleChatMessage( int userId, const std::string & message, int messageType ); 59 61 60 62 protected: -
branches/network/src/util/network_game_rules.h
r8147 r8588 25 25 26 26 virtual PlayerStats * getNewPlayerStats( int userId ){ return new PlayerStats( userId ); } 27 28 virtual void handleChatMessage( int userId, const std::string & message, int messageType ) = 0; 27 29 28 30
Note: See TracChangeset
for help on using the changeset viewer.