Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 11, 2006, 9:58:22 PM (20 years ago)
Author:
patrick
Message:

trunk: merged the network branche into the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/multi_player_world_data.cc

    r6434 r6498  
    5050
    5151
     52
    5253using namespace std;
    5354
     
    5859MultiPlayerWorldData::MultiPlayerWorldData()
    5960    : GameWorldData()
    60 {}
     61{
     62  this->toggle = false;
     63}
    6164
    6265
     
    157160        }
    158161      }
    159       /* clients only spawn the SpaceShip */
    160       /// FIXME it is not said to be a SpaceShip
    161       else if( !strcmp( element->Value(), "SpaceShip"))
    162       {
    163         BaseObject* created = Factory::fabricate(element);
    164         if( created != NULL )
    165           PRINTF(1)("Created a %s: %s (%8.u)\n", created->getClassName(), created->getName(), created->getLeafClassID());
    166         else
    167           PRINTF(1)("NetworkWorld: could not create this entity\n");
    168       }
    169162      element = element->NextSiblingElement();
     163
    170164
    171165      glmis->step();
     
    173167    }
    174168
    175 
    176     /* create a Player */
    177     this->localPlayer = new Player();
    178     Playable* playable;
    179     const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
    180     if (playableList != NULL)
    181     {
    182       playable = dynamic_cast<Playable*>(playableList->front());
    183       this->localPlayer->setControllable(playable);
     169    if( NetworkManager::getInstance()->isGameServer())
     170    {
     171      this->localPlayer = new Player();
     172      State::setPlayer(this->localPlayer);
     173
     174      Playable* playable;
     175      const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
     176      assert( playableList != NULL);
     177
     178      if (playableList != NULL)
     179      {
     180        playable = dynamic_cast<Playable*>(playableList->front());
     181        this->localPlayer->setControllable(playable);
     182      }
     183    }
     184    else
     185    {
     186      /* create a Player */
     187      this->localPlayer = new Player();
     188      State::setPlayer(this->localPlayer);
    184189    }
    185190
     
    221226}
    222227
     228
     229/**
     230 * some debug output
     231 */
     232void MultiPlayerWorldData::debug()
     233{
     234  PRINT(0)("==================================================\n");
     235  Playable* playable;
     236  const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
     237  assert(playableList != NULL);
     238  std::list<BaseObject*>::const_iterator entity;
     239
     240
     241
     242  for (entity = playableList->begin(); entity != playableList->end(); entity++)
     243  {
     244    Playable* p = dynamic_cast<Playable*>(*entity);
     245    PRINTF(0)("Got a playable, class: %s, name: %s, uid: %i\n", (*entity)->getClassName(), (*entity)->getName(), p->getUniqueID());
     246  }
     247
     248
     249  if( this->toggle)
     250  {
     251    playable = dynamic_cast<Playable*>(playableList->front());
     252    this->localPlayer->disconnectControllable();
     253    this->localPlayer->setControllable(playable);
     254    this->toggle = !this->toggle;
     255  }
     256  else
     257  {
     258    playable = dynamic_cast<Playable*>(playableList->back());
     259    this->localPlayer->disconnectControllable();
     260    this->localPlayer->setControllable(playable);
     261    this->toggle = !this->toggle;
     262  }
     263
     264
     265
     266  PNode* cam = State::getCameraTarget();
     267  PRINT(0)("Camera has target - class: %s, name: %s, uid: %i\n", cam->getClassName(), cam->getName(), cam->getUniqueID());
     268
     269  PRINT(0)("==================================================\n");
     270
     271}
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
Note: See TracChangeset for help on using the changeset viewer.