Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8643 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 20, 2006, 5:52:34 PM (18 years ago)
Author:
rennerc
Message:

chatting works now with right names

Location:
branches/network/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/message_manager.cc

    r8635 r8643  
    1919
    2020#include "network_stream.h"
     21#include "shared_network_data.h"
    2122
    2223using namespace std;
     
    339340    msg.length = dataLength;
    340341    msg.messageId = messageId;
    341     msg.number = newNumber++;
     342    msg.number = SharedNetworkData::getInstance()->getHostID();
    342343    msg.priority = messagePriority;
    343344
  • branches/network/src/lib/network/network_game_manager.cc

    r8623 r8643  
    112112  stats->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    113113  stats->setSynchronized( true );
    114   stats->setOwner( getHostID() );
     114  stats->setOwner( SharedNetworkData::getInstance()->getHostID() );
    115115 
    116116  stats->setTeamId( team );
     
    247247{
    248248  if ( isServer() )
    249     setPreferedTeam( getHostID(), teamId );
     249    setPreferedTeam( SharedNetworkData::getInstance()->getHostID(), teamId );
    250250  else
    251251  {
     
    284284bool NetworkGameManager::chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
    285285{
     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 
    286292  assert( State::getGameRules() );
    287293  assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
     
    289295  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
    290296 
    291   if ( dataLength < 2*INTSIZE )
     297  if ( dataLength < 3*INTSIZE )
    292298  {
    293299    PRINTF(2)("got too small chatmessage from client %d\n", userId);
     
    298304  int messageType = 0;
    299305  Converter::byteArrayToInt( data, &messageType );
     306  int senderUserId = 0;
     307  Converter::byteArrayToInt( data+INTSIZE, &senderUserId );
    300308  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 );
    304312
    305313  return true;
     
    310318 * @param message message text
    311319 * @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 */
     321void NetworkGameManager::sendChatMessage( const std::string & message, int messageType )
     322{
     323  byte * buf = new byte[message.length()+3*INTSIZE];
    317324
    318325  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 );
    323331  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
    325334 
    326335  delete [] buf;
  • branches/network/src/lib/network/network_game_manager.h

    r8623 r8643  
    6565    void tick( float ds );
    6666   
    67     void sendChatMessage( const std::string & message, int messageType, int userId = -1 );
     67    void sendChatMessage( const std::string & message, int messageType );
    6868
    6969  private:
  • branches/network/src/lib/network/player_stats.cc

    r8623 r8643  
    9595    this->setPlayableUniqueId( this->playableUniqueId );
    9696   
    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());
    9898  }
    9999 
     
    155155  }
    156156 
    157   if ( this->playable && userId == getHostID() )
     157  if ( this->playable && userId == SharedNetworkData::getInstance()->getHostID() )
    158158  {
    159159    State::getPlayer()->setPlayable( this->playable );
  • branches/network/src/lib/network/synchronizeable.cc

    r8623 r8643  
    3838  this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
    3939  this->owner = 0;
    40   this->hostID = SharedNetworkData::getInstance()->getHostID();
    41   this->setIsServer(this->hostID == 0);
     40  this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0);
    4241  this->uniqueID = NET_UID_UNASSIGNED;
    4342  this->networkStream = NULL;
     
    222221    hasPermission = (
    223222            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 ) ||
    225224            this->isServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) ||
    226225            (*it)->checkPermission( PERMISSION_ALL )
     
    345344        (*it)->checkPermission( PERMISSION_SERVER ) && networkStream->isUserServer( userId ) ||
    346345        (*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 ) ||
    348347        (*it)->checkPermission( PERMISSION_ALL )
    349348       )
  • branches/network/src/lib/network/synchronizeable.h

    r8068 r8643  
    6767    inline void setUniqueID( int id ){ uniqueID = id; }
    6868    inline int  getUniqueID() const { return uniqueID; }
    69     inline int getHostID() { return this->hostID; }
    7069
    7170    inline int getOwner(){ return owner; }
     
    8988    int               mLeafClassId;   //!< store leafClassId to send via states
    9089    int               owner;          //!< hostId of owner ( 0 if none / server )
    91     int               hostID;         //!< my own host id
    9290    bool              bSynchronize;   //!< do we need beeing synchronized?
    9391
  • branches/network/src/util/multiplayer_team_deathmatch.cc

    r8635 r8643  
    8787  this->notifier->show();
    8888  this->notifier->setAbsCoor2D(5, 30);
     89  this->notifier->setFadeAge( 6.0 );
     90  this->notifier->setHideAge( 8.0 );
    8991  this->input = new OrxGui::GLGuiInputLine();
     92  this->input->setAbsCoor2D(180, 5);
    9093  this->input->connect(SIGNAL(input, enterPushed), this, SLOT(MultiplayerTeamDeathmatch, onInputEnter));
    9194}
     
    597600  }
    598601 
    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() );
    600603  notifier->pushNotifyMessage(name + ": " + message);
    601604}
  • branches/network/src/world_entities/space_ships/space_ship.cc

    r8228 r8643  
    3333
    3434#include "network_game_manager.h"
     35#include "shared_network_data.h"
    3536
    3637#include "power_ups/weapon_power_up.h"
     
    326327  Playable::tick(time);
    327328
    328   if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() )
     329  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() )
    329330   {
    330331    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
  • branches/network/src/world_entities/spectator.cc

    r8228 r8643  
    2020#include "key_mapper.h"
    2121
     22#include "shared_network_data.h"
    2223
    2324CREATE_FACTORY(Spectator, CL_SPECTATOR);
     
    161162  Playable::tick( time );
    162163 
    163   if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() )
     164  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() )
    164165  {
    165166    xMouse *= time / 10;
Note: See TracChangeset for help on using the changeset viewer.