Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6498 in orxonox.OLD for trunk/src/story_entities


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

trunk: merged the network branche into the trunk

Location:
trunk/src/story_entities
Files:
6 edited

Legend:

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

    r6457 r6498  
    131131  this->shell = new Shell();
    132132
     133  State::setCurrentStoryEntity(dynamic_cast<StoryEntity*>(this));
    133134  this->dataTank->init();
    134135}
  • trunk/src/story_entities/game_world.h

    r6424 r6498  
    99
    1010#include "story_entity.h"
    11 
     11#include "game_world_data.h"
    1212
    1313class TiXmlElement;
     
    5656
    5757
     58    inline void setSky(WorldEntity* sky) { this->dataTank->sky = sky; }
     59
     60
    5861  protected:
    5962    /* world - running functions */
  • trunk/src/story_entities/multi_player_world.cc

    r6424 r6498  
    2121#include "factory.h"
    2222#include "load_param.h"
     23#include "shell_command.h"
    2324
    2425#include "network_manager.h"
     
    2627
    2728using namespace std;
     29
     30
     31//! Register a command to print some multiplayer world infos
     32SHELL_COMMAND(debug, MultiPlayerWorld, debug);
    2833
    2934
     
    7984}
    8085
     86
     87/**
     88 * some debug ouptut - shell command
     89 */
     90void MultiPlayerWorld::debug()
     91{
     92  ((MultiPlayerWorldData*)this->dataTank)->debug();
     93}
  • trunk/src/story_entities/multi_player_world.h

    r6424 r6498  
    2727  void loadParams(const TiXmlElement* root);
    2828
     29  void debug();
     30
    2931  protected:
    3032    virtual void synchronize();
  • 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
  • trunk/src/story_entities/multi_player_world_data.h

    r6424 r6498  
    2424    virtual ErrorMessage init();
    2525
     26    void debug();
     27
    2628
    2729  protected:
     
    3335    virtual ErrorMessage unloadWorldEntities();
    3436    virtual ErrorMessage unloadScene();
     37
     38  private:
     39    bool toggle;
    3540};
    3641
Note: See TracChangeset for help on using the changeset viewer.