Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9507 in orxonox.OLD


Ignore:
Timestamp:
Jul 27, 2006, 1:59:30 PM (18 years ago)
Author:
patrick
Message:

the player team change should now work on all clients in the network, its now a global synch variable

Location:
branches/proxy/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/message_manager.h

    r9494 r9507  
    2626
    2727
     28//!< different message ids
    2829enum MessageId
    2930{
    30   TESTMESSAGEID = 1,
    31   MSGID_DELETESYNCHRONIZEABLE,
    32   MSGID_PREFEREDTEAM,
    33   MSGID_CHANGENICKNAME,
    34   MSGID_CHATMESSAGE,
    35   MSGID_RESPAWN
     31  TESTMESSAGEID                  = 1,         //!< for testing purposes
     32  MSGID_DELETESYNCHRONIZEABLE,                //!< message for sync deletion
     33  MSGID_PREFEREDTEAM,                         //!< change prefered team
     34  MSGID_CHANGENICKNAME,                       //!< change nicknames
     35  MSGID_CHATMESSAGE,                          //!< chat message
     36  MSGID_RESPAWN,                              //!< respawn message
     37
     38  MSGID_FORWARDMESSAGE                        //!< forwarding a messag between proxy and master server
    3639};
     40
    3741
    3842typedef bool (*MessageCallback)( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
  • branches/proxy/src/lib/network/network_game_manager.cc

    r9503 r9507  
    272272void NetworkGameManager::prefereTeam( int teamId )
    273273{
    274   if ( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
    275     setPreferedTeam( SharedNetworkData::getInstance()->getHostID(), teamId );
     274  if ( SharedNetworkData::getInstance()->isMasterServer() )
     275    this->setPreferedTeam( SharedNetworkData::getInstance()->getHostID(), teamId );
    276276  else
    277277  {
     
    280280    assert( Converter::intToByteArray( teamId, buf, INTSIZE) == INTSIZE );
    281281
    282     MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, 0, MP_HIGHBANDWIDTH );
     282    // send this message to the master server
     283    MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, NET_ID_MASTER_SERVER, MP_HIGHBANDWIDTH );
    283284  }
    284285}
  • branches/proxy/src/lib/network/player_stats.cc

    r9505 r9507  
    107107    this->oldNickName = nickName;
    108108  }
    109 
    110   if ( std::find( id.begin(), id.end(), teamId_handle ) != id.end() )
    111   {
    112     PRINTF(0)("user %s joins team %i\n", this->nickName.c_str(), this->teamId);
    113     this->setPreferedTeamIdHandler( this->teamId);
    114   }
    115 
    116 }
    117 
    118 
    119 /**
    120  * handler for setting the prefered team id
    121  * @param newTeamId: the new team id
    122  */
    123 void PlayerStats::setPreferedTeamIdHandler( int newTeamId)
    124 {
    125 
    126   if( this->playable == NULL)
    127   {
    128     PRINTF(0)("could not set prefered team, since the playable is not yet set\n");
    129     return;
    130   }
    131 
    132   this->playable->setTeam(newTeamId);
    133109}
    134110
     
    189165    State::getPlayer()->setPlayable( this->playable );
    190166    // also set the team id
    191     this->playable->setTeam(this->getTeamId());
    192167  }
    193168
  • branches/proxy/src/lib/network/player_stats.h

    r9505 r9507  
    4747    inline void setTeamId( int teamId ){ this->teamId = teamId; }
    4848
    49     void setPreferedTeamIdHandler( int newTeamId);
    5049    inline int getPreferedTeamId(){ return preferedTeamId; }
    5150    inline void setPreferedTeamId( int preferedTeamId ) { this->preferedTeamId = preferedTeamId; }
  • branches/proxy/src/world_entities/playable.cc

    r9500 r9507  
    6868
    6969
     70  this->teamChangeHandler = registerVarId( new SynchronizeableInt( &this->teamId, &this->teamId, "team-id" ) );
    7071  registerVar( new SynchronizeableInt( &score, &score, "score" ) );
    7172  registerVar( new SynchronizeableBool( &bFire, &bFire, "bFire", PERMISSION_OWNER));
     
    524525  "FirstPerson"
    525526};
     527
     528
     529/**
     530 * handler for changes on registred vars
     531 * @param id id's which changed
     532 */
     533void Playable::varChangeHandler( std::list< int > & id )
     534{
     535  if ( std::find( id.begin(), id.end(), this->teamChangeHandler) != id.end() )
     536  {
     537    this->setTeam(this->teamId);
     538  }
     539
     540  WorldEntity::varChangeHandler(id);
     541}
  • branches/proxy/src/world_entities/playable.h

    r9501 r9507  
    1111#include "event.h"
    1212#include <vector>
     13#include <list>
    1314
    1415#include "world_entities/weapons/weapon_manager.h"
     
    4344
    4445  virtual void loadParams(const TiXmlElement* root);
     46  void varChangeHandler( std::list< int > & id );
    4547
    4648  // Weapon and Pickups
     
    6163  /** @return a List of Events in PEV_* sytle */
    6264  inline const std::vector<int>& getEventList() { return this->events; };
    63   virtual void setTeam(int teamID);
    6465
    6566
     
    7778  inline void setScore( int score ) { this->score = score; }
    7879  inline int  getScore() { return this->score; }
     80  inline void setTeamId( int teamId) { this->teamId = teamId;}
     81  inline int getTeamId() const { return this->teamId; }
     82  virtual void setTeam(int teamID);
     83
    7984
    8085  void setEnterRadius(float radius) { this->enterRadius = radius; };
     
    121126
    122127  int                   score;              //!< players score
     128  int                   teamChangeHandler;  //!< handler id for team changes network sync
     129  int                   teamId;             //!< id of the current team
    123130
    124131  bool                  bDead;
     
    128135  float                 enterRadius;        //!< How far one can be away from the Playable to enter it.
    129136
    130   WorldEntity* collider;
     137  WorldEntity*          collider;
    131138};
    132139
  • branches/proxy/src/world_entities/space_ships/turbine_hover.cc

    r9502 r9507  
    276276  else if (teamID == 1)
    277277    this->setBoostColor(Color::red);
     278
     279  // set the local team id, very important
     280  this->setTeamId(teamID);
    278281}
    279282
Note: See TracChangeset for help on using the changeset viewer.