- Timestamp:
- Jun 20, 2006, 5:52:34 PM (18 years ago)
- Location:
- branches/network/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/message_manager.cc
r8635 r8643 19 19 20 20 #include "network_stream.h" 21 #include "shared_network_data.h" 21 22 22 23 using namespace std; … … 339 340 msg.length = dataLength; 340 341 msg.messageId = messageId; 341 msg.number = newNumber++;342 msg.number = SharedNetworkData::getInstance()->getHostID(); 342 343 msg.priority = messagePriority; 343 344 -
branches/network/src/lib/network/network_game_manager.cc
r8623 r8643 112 112 stats->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 113 113 stats->setSynchronized( true ); 114 stats->setOwner( getHostID() );114 stats->setOwner( SharedNetworkData::getInstance()->getHostID() ); 115 115 116 116 stats->setTeamId( team ); … … 247 247 { 248 248 if ( isServer() ) 249 setPreferedTeam( getHostID(), teamId );249 setPreferedTeam( SharedNetworkData::getInstance()->getHostID(), teamId ); 250 250 else 251 251 { … … 284 284 bool NetworkGameManager::chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 285 285 { 286 PRINTF(0)("NetworkGameManager::chatMessageHandler %d %d\n", userId, SharedNetworkData::getInstance()->getHostID() ); 287 if ( NetworkGameManager::getInstance()->isServer() && userId != SharedNetworkData::getInstance()->getHostID() ) 288 { 289 MessageManager::getInstance()->sendMessage( messageId, data, dataLength, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 290 } 291 286 292 assert( State::getGameRules() ); 287 293 assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) ); … … 289 295 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); 290 296 291 if ( dataLength < 2*INTSIZE )297 if ( dataLength < 3*INTSIZE ) 292 298 { 293 299 PRINTF(2)("got too small chatmessage from client %d\n", userId); … … 298 304 int messageType = 0; 299 305 Converter::byteArrayToInt( data, &messageType ); 306 int senderUserId = 0; 307 Converter::byteArrayToInt( data+INTSIZE, &senderUserId ); 300 308 std::string message; 301 Converter::byteArrayToString( data+ INTSIZE, message, dataLength-INTSIZE );302 303 rules.handleChatMessage( userId, message, messageType );309 Converter::byteArrayToString( data+2*INTSIZE, message, dataLength-2*INTSIZE ); 310 311 rules.handleChatMessage( senderUserId, message, messageType ); 304 312 305 313 return true; … … 310 318 * @param message message text 311 319 * @param messageType some int 312 * @param userId user to send message to -1 = ALL 313 */ 314 void NetworkGameManager::sendChatMessage( const std::string & message, int messageType, int userId ) 315 { 316 byte * buf = new byte[message.length()+2*INTSIZE]; 320 */ 321 void NetworkGameManager::sendChatMessage( const std::string & message, int messageType ) 322 { 323 byte * buf = new byte[message.length()+3*INTSIZE]; 317 324 318 325 assert( Converter::intToByteArray( messageType, buf, INTSIZE ) == INTSIZE ); 319 assert( Converter::stringToByteArray(message, buf+INTSIZE, message.length()+INTSIZE) == message.length()+INTSIZE ); 320 321 if ( userId == -1 ) 322 MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+2*INTSIZE, RT_ALL_ME, 0, MP_HIGHBANDWIDTH ); 326 assert( Converter::intToByteArray( SharedNetworkData::getInstance()->getHostID(), buf+INTSIZE, INTSIZE ) == INTSIZE ); 327 assert( Converter::stringToByteArray(message, buf+2*INTSIZE, message.length()+INTSIZE) == message.length()+INTSIZE ); 328 329 if ( this->isServer() ) 330 MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_ME, 0, MP_HIGHBANDWIDTH ); 323 331 else 324 MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+2*INTSIZE, RT_USER, userId, MP_HIGHBANDWIDTH ); 332 MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 333 325 334 326 335 delete [] buf; -
branches/network/src/lib/network/network_game_manager.h
r8623 r8643 65 65 void tick( float ds ); 66 66 67 void sendChatMessage( const std::string & message, int messageType , int userId = -1);67 void sendChatMessage( const std::string & message, int messageType ); 68 68 69 69 private: -
branches/network/src/lib/network/player_stats.cc
r8623 r8643 95 95 this->setPlayableUniqueId( this->playableUniqueId ); 96 96 97 PRINTF(0)("uniqueID changed %d %d %d\n", userId, getHostID(), getUniqueID());97 PRINTF(0)("uniqueID changed %d %d %d\n", userId, SharedNetworkData::getInstance()->getHostID(), getUniqueID()); 98 98 } 99 99 … … 155 155 } 156 156 157 if ( this->playable && userId == getHostID() )157 if ( this->playable && userId == SharedNetworkData::getInstance()->getHostID() ) 158 158 { 159 159 State::getPlayer()->setPlayable( this->playable ); -
branches/network/src/lib/network/synchronizeable.cc
r8623 r8643 38 38 this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable"); 39 39 this->owner = 0; 40 this->hostID = SharedNetworkData::getInstance()->getHostID(); 41 this->setIsServer(this->hostID == 0); 40 this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0); 42 41 this->uniqueID = NET_UID_UNASSIGNED; 43 42 this->networkStream = NULL; … … 222 221 hasPermission = ( 223 222 this->isServer() && (*it)->checkPermission( PERMISSION_SERVER ) || 224 this->owner == this->hostID&& (*it)->checkPermission( PERMISSION_OWNER ) ||223 this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) || 225 224 this->isServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) || 226 225 (*it)->checkPermission( PERMISSION_ALL ) … … 345 344 (*it)->checkPermission( PERMISSION_SERVER ) && networkStream->isUserServer( userId ) || 346 345 (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId || 347 networkStream->isUserServer( userId ) && this->owner != getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||346 networkStream->isUserServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) || 348 347 (*it)->checkPermission( PERMISSION_ALL ) 349 348 ) -
branches/network/src/lib/network/synchronizeable.h
r8068 r8643 67 67 inline void setUniqueID( int id ){ uniqueID = id; } 68 68 inline int getUniqueID() const { return uniqueID; } 69 inline int getHostID() { return this->hostID; }70 69 71 70 inline int getOwner(){ return owner; } … … 89 88 int mLeafClassId; //!< store leafClassId to send via states 90 89 int owner; //!< hostId of owner ( 0 if none / server ) 91 int hostID; //!< my own host id92 90 bool bSynchronize; //!< do we need beeing synchronized? 93 91 -
branches/network/src/util/multiplayer_team_deathmatch.cc
r8635 r8643 87 87 this->notifier->show(); 88 88 this->notifier->setAbsCoor2D(5, 30); 89 this->notifier->setFadeAge( 6.0 ); 90 this->notifier->setHideAge( 8.0 ); 89 91 this->input = new OrxGui::GLGuiInputLine(); 92 this->input->setAbsCoor2D(180, 5); 90 93 this->input->connect(SIGNAL(input, enterPushed), this, SLOT(MultiplayerTeamDeathmatch, onInputEnter)); 91 94 } … … 597 600 } 598 601 599 PRINTF(0)("CHATMESSAGE %s : %s\n", name.c_str(), message.c_str() );602 PRINTF(0)("CHATMESSAGE %s (%d): %s\n", name.c_str(), userId, message.c_str() ); 600 603 notifier->pushNotifyMessage(name + ": " + message); 601 604 } -
branches/network/src/world_entities/space_ships/space_ship.cc
r8228 r8643 33 33 34 34 #include "network_game_manager.h" 35 #include "shared_network_data.h" 35 36 36 37 #include "power_ups/weapon_power_up.h" … … 326 327 Playable::tick(time); 327 328 328 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() )329 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() ) 329 330 { 330 331 if (xMouse > controlVelocityX) xMouse = controlVelocityX; -
branches/network/src/world_entities/spectator.cc
r8228 r8643 20 20 #include "key_mapper.h" 21 21 22 #include "shared_network_data.h" 22 23 23 24 CREATE_FACTORY(Spectator, CL_SPECTATOR); … … 161 162 Playable::tick( time ); 162 163 163 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() )164 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() ) 164 165 { 165 166 xMouse *= time / 10;
Note: See TracChangeset
for help on using the changeset viewer.