Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9406 in orxonox.OLD for trunk/src/world_entities/spawning_point.cc


Ignore:
Timestamp:
Jul 24, 2006, 11:09:47 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/spawning_point.cc

    r9235 r9406  
    3131#include "shared_network_data.h"
    3232
     33
     34/// TODO REMOVE converter.h
     35#include "converter.h"
     36
    3337CREATE_FACTORY( SpawningPoint, CL_SPAWNING_POINT );
    3438
     
    4145
    4246  this->init();
    43  
     47
    4448  if (root != NULL)
    4549    this->loadParams(root);
     
    5054  this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
    5155  PRINTF(0)("Created SpawningPoint\n");
    52  
     56
    5357  this->teamId = -1;
    5458  this->localTimer = 0.0f;
    55  
     59
    5660  this->toList( OM_DEAD_TICK );
    57  
     61
    5862  MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL );
    59  
     63
    6064  this->setSynchronized( true );
    6165}
     
    9498  qe.entity = entity;
    9599  qe.respawnTime = this->localTimer + delay;
    96  
     100
    97101  queue.push_back( qe );
    98102}
     
    105109{
    106110  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    107  
     111
    108112  bool found = false;
    109  
     113
    110114  if ( !list )
    111115    return;
    112    
     116
    113117  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    114118  {
     
    119123    }
    120124  }
    121  
     125
    122126  if ( !found )
    123127    return;
    124128
    125   PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClassName());
     129  PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClassCName());
    126130
    127131
    128132  entity->setAbsCoor( this->getAbsCoor() );
    129133  entity->setAbsDir( this->getAbsDir() );
    130  
     134
    131135  //TODO set camera (not smooth)
    132  
     136
    133137  if ( State::getGameRules() )
    134138  {
    135139    (State::getGameRules())->registerSpawn( entity );
    136140  }
    137  
     141
    138142  entity->respawn();
    139143}
     
    157161      //spawn the player
    158162      this->spawn(it->entity);
    159      
     163
    160164      const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    161  
     165
    162166      bool found = false;
    163  
     167
    164168      if ( !list )
    165169        return;
    166    
     170
    167171      for ( std::list<BaseObject*>::const_iterator it2 = list->begin(); it2 != list->end(); it2++ )
    168172      {
     
    173177        }
    174178      }
    175  
    176       if ( found && SharedNetworkData::getInstance()->isGameServer() )
     179
     180      if ( found && SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
    177181        this->sendRespawnMessage( it->entity->getUniqueID() );
    178182
    179183      std::list<QueueEntry>::iterator delit = it;
    180184      it++;
    181      
     185
    182186      queue.erase( delit );
    183      
     187
    184188      continue;
    185189    }
    186    
     190
    187191    it++;
    188192  }
     
    203207void SpawningPoint::sendRespawnMessage( int uniqueId )
    204208{
     209#warning this byte array is not being deleted according to valginrd
    205210  byte * buf = new byte[2*INTSIZE];
    206  
     211
    207212  assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE );
    208213  assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE );
    209  
     214
    210215  MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
    211216}
     
    213218bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
    214219{
    215   if ( SharedNetworkData::getInstance()->isGameServer() )
     220  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
    216221  {
    217222    PRINTF(2)("server received spawn message!\n");
    218223    return true;
    219224  }
    220    
     225
    221226  int spUniqueId;
    222227  int uniqueId;
    223  
     228
    224229  if ( dataLength != 2*INTSIZE )
    225230  {
     
    227232    return true;
    228233  }
    229  
     234
    230235  assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE );
    231236  assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE );
    232  
     237
    233238  PRINTF(0)("SPAWNMESSAGE %d\n", uniqueId);
    234  
     239
    235240  SpawningPoint * sp = NULL;
    236241  Playable      * playable = NULL;
    237  
     242
    238243  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
    239  
     244
    240245  if ( list )
    241246  {
     
    250255    }
    251256  }
    252  
     257
    253258  if ( !sp )
    254259  {
     
    256261    return false;
    257262  }
    258  
     263
    259264  list = ClassList::getList( CL_PLAYABLE );
    260  
     265
    261266  if ( list )
    262267  {
     
    270275    }
    271276  }
    272  
     277
    273278  if ( !playable )
    274279  {
     
    276281    return false;
    277282  }
    278  
     283
    279284  sp->spawn( playable );
    280  
     285
    281286  return true;
    282287}
Note: See TracChangeset for help on using the changeset viewer.