Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2006, 10:08:41 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: removed stupid included in base_object.h
this should lead to faster compile-times

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/network_game_manager.cc

    r8228 r8362  
    3939#include "network_game_manager.h"
    4040
     41#include "debug.h"
     42
    4143
    4244/* using namespace std is default, this needs to be here */
     
    5759
    5860  this->setSynchronized(true);
    59  
     61
    6062  MessageManager::getInstance()->registerMessageHandler( MSGID_DELETESYNCHRONIZEABLE, delSynchronizeableHandler, NULL );
    6163  MessageManager::getInstance()->registerMessageHandler( MSGID_PREFEREDTEAM, preferedTeamHandler, NULL );
    62  
     64
    6365  this->gameState = 0;
    6466  registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) );
     
    7577/**
    7678 * insert new player into game
    77  * @param userId 
    78  * @return 
     79 * @param userId
     80 * @return
    7981 */
    8082bool NetworkGameManager::signalNewPlayer( int userId )
     
    8385  assert( State::getGameRules() );
    8486  assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
    85  
     87
    8688  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
    87  
     89
    8890  int team = rules.getTeamForNewUser();
    8991  ClassID playableClassId = rules.getPlayableClassId( userId, team );
    9092  std::string playableModel = rules.getPlayableModelFileName( userId, team, playableClassId );
    91  
     93
    9294  BaseObject * bo = Factory::fabricate( playableClassId );
    93  
     95
    9496  assert( bo != NULL );
    9597  assert( bo->isA( CL_PLAYABLE ) );
    96  
     98
    9799  Playable & playable = *(dynamic_cast<Playable*>(bo));
    98  
     100
    99101  playable.loadModel( playableModel );
    100102  playable.setOwner( userId );
    101103  playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    102104  playable.setSynchronized( true );
    103  
     105
    104106  PlayerStats * stats = rules.getNewPlayerStats( userId );
    105  
     107
    106108  stats->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    107109  stats->setSynchronized( true );
    108110  stats->setOwner( getHostID() );
    109  
     111
    110112  stats->setTeamId( team );
    111113  stats->setPlayableClassId( playableClassId );
    112114  stats->setPlayableUniqueId( playable.getUniqueID() );
    113115  stats->setModelFileName( playableModel );
    114  
     116
    115117  return true;
    116118}
     
    119121/**
    120122 * remove player from game
    121  * @param userID 
    122  * @return 
     123 * @param userID
     124 * @return
    123125 */
    124126bool NetworkGameManager::signalLeftPlayer(int userID)
     
    130132    delete PlayerStats::getStats( userID );
    131133  }
    132  
     134
    133135  return true;
    134136}
     
    138140/**
    139141 * handler for remove synchronizeable messages
    140  * @param messageId 
    141  * @param data 
    142  * @param dataLength 
    143  * @param someData 
    144  * @param userId 
     142 * @param messageId
     143 * @param data
     144 * @param dataLength
     145 * @param someData
     146 * @param userId
    145147 * @return true on successfull handling else handler will be called again
    146148 */
     
    152154    return true;
    153155  }
    154  
     156
    155157  int uniqueId = 0;
    156158  int len = Converter::byteArrayToInt( data, &uniqueId );
    157  
     159
    158160  if ( len != dataLength )
    159161  {
     
    161163    return true;
    162164  }
    163  
     165
    164166  const std::list<BaseObject*> * list = ClassList::getList( CL_SYNCHRONIZEABLE );
    165  
     167
    166168  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    167169  {
     
    173175        return true;
    174176      }
    175      
     177
    176178      delete dynamic_cast<Synchronizeable*>(*it);
    177179      return true;
    178180    }
    179181  }
    180  
     182
    181183  return true;
    182184}
     
    189191{
    190192  byte buf[INTSIZE];
    191  
     193
    192194  assert( Converter::intToByteArray( uniqueId, buf, INTSIZE ) == INTSIZE );
    193  
     195
    194196  MessageManager::getInstance()->sendMessage( MSGID_DELETESYNCHRONIZEABLE, buf, INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
    195197}
     
    199201/**
    200202 * handler for MSGID_PREFEREDTEAM message
    201  * @param messageId 
    202  * @param data 
    203  * @param dataLength 
    204  * @param someData 
    205  * @param userId 
    206  * @return 
     203 * @param messageId
     204 * @param data
     205 * @param dataLength
     206 * @param someData
     207 * @param userId
     208 * @return
    207209 */
    208210bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
    209211{
    210212  assert( NetworkGameManager::getInstance()->isServer() );
    211  
     213
    212214  int teamId = 0;
    213215  int len = Converter::byteArrayToInt( data, &teamId );
    214  
     216
    215217  if ( len != dataLength )
    216218  {
     
    218220    return true;
    219221  }
    220  
     222
    221223  NetworkGameManager::getInstance()->setPreferedTeam( userId, teamId );
    222  
     224
    223225  return true;
    224226}
     
    228230  if ( !PlayerStats::getStats( userId ) )
    229231    return;
    230  
     232
    231233  PlayerStats & stats = *(PlayerStats::getStats( userId ));
    232  
     234
    233235  stats.setPreferedTeamId( teamId );
    234236}
     
    236238/**
    237239 * set prefered team for this host
    238  * @param teamId 
     240 * @param teamId
    239241 */
    240242void NetworkGameManager::prefereTeam( int teamId )
     
    245247  {
    246248    byte buf[INTSIZE];
    247    
     249
    248250    assert( Converter::intToByteArray( teamId, buf, INTSIZE) == INTSIZE );
    249    
     251
    250252    MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, 0, MP_HIGHBANDWIDTH );
    251253  }
Note: See TracChangeset for help on using the changeset viewer.