Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6069 in orxonox.OLD for branches/network/src/story_entities


Ignore:
Timestamp:
Dec 12, 2005, 5:18:36 PM (19 years ago)
Author:
patrick
Message:

network: network world changes and spawning points

Location:
branches/network/src/story_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/story_entities/network_world.cc

    r6065 r6069  
    7575
    7676
    77 SHELL_COMMAND(speed, World, setSpeed);
    78 SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);
    79 SHELL_COMMAND(toggleBVVisibility, World, toggleBVVisibility);
     77SHELL_COMMAND(speed, NetworkWorld, setSpeed);
     78SHELL_COMMAND(togglePNodeVisibility, NetworkWorld, togglePNodeVisibility);
     79SHELL_COMMAND(toggleBVVisibility, NetworkWorld, toggleBVVisibility);
    8080
    8181using namespace std;
    8282
    83 //! This creates a Factory to fabricate a World
    84 CREATE_FACTORY(World, CL_WORLD);
    85 
    86 World::World(const TiXmlElement* root)
     83//! This creates a Factory to fabricate a NetworkWorld
     84CREATE_FACTORY(NetworkWorld, CL_WORLD);
     85
     86NetworkWorld::NetworkWorld(const TiXmlElement* root)
    8787{
    8888  this->constuctorInit("", -1);
     
    9393
    9494/**
    95   *  create a new World
     95  *  create a new NetworkWorld
    9696
    9797    This creates a new empty world!
    9898*/
    99 World::World (const char* name)
     99NetworkWorld::NetworkWorld (const char* name)
    100100{
    101101  this->path = NULL;
     
    104104
    105105/**
    106  *  creates a new World...
     106 *  creates a new NetworkWorld...
    107107 * @param worldID with this ID
    108108*/
    109 World::World (int worldID)
     109NetworkWorld::NetworkWorld (int worldID)
    110110{
    111111  this->path = NULL;
     
    114114
    115115/**
    116  *  remove the World from memory
     116 *  remove the NetworkWorld from memory
    117117
    118118    delete everything explicitly, that isn't contained in the parenting tree!
    119119    things contained in the tree are deleted automaticaly
    120120 */
    121 World::~World ()
     121NetworkWorld::~NetworkWorld ()
    122122{
    123123  delete this->shell;
    124   PRINTF(3)("World::~World() - deleting current world\n");
    125 
    126 
    127   // here everything that is alocated by the World is deleted
     124  PRINTF(3)("NetworkWorld::~NetworkWorld() - deleting current world\n");
     125
     126
     127  // here everything that is alocated by the NetworkWorld is deleted
    128128  delete this->entities;
    129129  State::setWorldEntityList(NULL);
     
    165165 * NO LEVEL LOADING HERE - NEVER!
    166166*/
    167 void World::constuctorInit(const char* name, int worldID)
    168 {
    169   this->setClassID(CL_WORLD, "World");
     167void NetworkWorld::constuctorInit(const char* name, int worldID)
     168{
     169  this->setClassID(CL_WORLD, "NetworkWorld");
    170170
    171171  this->setName(name);
    172   this->debugWorldNr = worldID;
     172  this->debugNetworkWorldNr = worldID;
    173173  this->gameTime = 0.0f;
    174174  this->setSpeed(1.0);
     
    184184
    185185/**
    186  * loads the parameters of a World from an XML-element
     186 * loads the parameters of a NetworkWorld from an XML-element
    187187 * @param root the XML-element to load from
    188188 */
    189 void World::loadParams(const TiXmlElement* root)
    190 {
    191   PRINTF(4)("Creating a World\n");
    192 
    193   LoadParam(root, "identifier", this, World, setStoryID)
     189void NetworkWorld::loadParams(const TiXmlElement* root)
     190{
     191  PRINTF(4)("Creating a NetworkWorld\n");
     192
     193  LoadParam(root, "identifier", this, NetworkWorld, setStoryID)
    194194    .describe("Sets the StoryID of this world");
    195195
    196   LoadParam(root, "nextid", this, World, setNextStoryID)
     196  LoadParam(root, "nextid", this, NetworkWorld, setNextStoryID)
    197197    .describe("Sets the ID of the next world");
    198198
    199   LoadParam(root, "path", this, World, setPath)
    200     .describe("The Filename of this World (relative from the data-dir)");
     199  LoadParam(root, "path", this, NetworkWorld, setPath)
     200    .describe("The Filename of this NetworkWorld (relative from the data-dir)");
    201201}
    202202
     
    207207 * before the load and after the proceeding storyentity has finished
    208208*/
    209 ErrorMessage World::preLoad()
     209ErrorMessage NetworkWorld::preLoad()
    210210{
    211211  State::setWorldEntityList(this->entities = new tList<WorldEntity>());
     
    223223
    224224  this->localCamera = new Camera();
    225   this->localCamera->setName ("World-Camera");
     225  this->localCamera->setName ("NetworkWorld-Camera");
    226226
    227227  State::setCamera(this->localCamera, this->localCamera->getTarget());
     
    234234
    235235/**
    236  *  loads the World by initializing all resources, and set their default values.
    237 */
    238 ErrorMessage World::load()
     236 *  loads the NetworkWorld by initializing all resources, and set their default values.
     237*/
     238ErrorMessage NetworkWorld::load()
    239239{
    240240  PRINTF(3)("> Loading world: '%s'\n", getPath());
     
    244244  if( getPath() == NULL)
    245245    {
    246       PRINTF(1)("World has no path specified for loading");
    247       this->loadDebugWorld(this->getStoryID());
    248       return (ErrorMessage){213,"Path not specified","World::load()"};
     246      PRINTF(1)("NetworkWorld has no path specified for loading");
     247      this->loadDebugNetworkWorld(this->getStoryID());
     248      return (ErrorMessage){213,"Path not specified","NetworkWorld::load()"};
    249249    }
    250250
     
    256256    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    257257    delete XMLDoc;
    258     return (ErrorMessage){213,"XML File parsing error","World::load()"};
     258    return (ErrorMessage){213,"XML File parsing error","NetworkWorld::load()"};
    259259  }
    260260
     
    268268      PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
    269269      delete XMLDoc;
    270       return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
    271     }
     270      return (ErrorMessage){213,"Path not a WorldDataFile","NetworkWorld::load()"};
     271    }
     272
    272273
    273274  // load the parameters
     
    283284      this->setName(string);
    284285    }
     286
    285287
    286288  ////////////////
     
    303305  this->glmis->draw();
    304306
     307
     308
     309  ////////////////////////////
     310  // Loading Spawning Point //
     311  ////////////////////////////
     312  element = root->FirstChildElement("SpawningPoints");
     313  if( element == NULL)
     314  {
     315    PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n");
     316  }
     317  else
     318  {
     319    element = element->FirstChildElement();
     320      // load Players/Objects/Whatever
     321    PRINTF(4)("Loading Spawning Points\n");
     322    while( element != NULL)
     323    {
     324      BaseObject* created = Factory::fabricate(element);
     325      if( created != NULL )
     326      {
     327        if(created->isA(CL_WORLD_ENTITY))
     328          this->spawn(dynamic_cast<WorldEntity*>(created));
     329        printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName());
     330      }
     331
     332          // if we load a 'Player' we use it as localPlayer
     333
     334
     335          //todo do this more elegant
     336      if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
     337        sky = dynamic_cast<SkyBox*>(created);
     338      if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
     339      {
     340        terrain = dynamic_cast<Terrain*>(created);
     341        CDEngine::getInstance()->setTerrain(terrain);
     342      }
     343      element = element->NextSiblingElement();
     344      glmis->step(); //! @todo temporary
     345    }
     346    PRINTF(4)("Done loading NetworkWorldEntities\n");
     347  }
     348
     349
    305350  ////////////////////////
    306351  // find WorldEntities //
    307352  ////////////////////////
    308 
    309353  element = root->FirstChildElement("WorldEntities");
    310 
    311354  if( element == NULL)
    312355    {
    313       PRINTF(1)("World is missing 'WorldEntities'\n");
     356      PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n");
    314357    }
    315358  else
     
    317360      element = element->FirstChildElement();
    318361      // load Players/Objects/Whatever
    319       PRINTF(4)("Loading WorldEntities\n");
     362      PRINTF(4)("Loading NetworkWorldEntities\n");
    320363      while( element != NULL)
    321364        {
     
    342385          glmis->step(); //! @todo temporary
    343386        }
    344       PRINTF(4)("Done loading WorldEntities\n");
     387      PRINTF(4)("Done loading NetworkWorldEntities\n");
    345388    }
    346389
     
    424467 * creates a debug world: only for experimental stuff
    425468*/
    426 void World::loadDebugWorld(int worldID)
     469void NetworkWorld::loadDebugNetworkWorld(int worldID)
    427470{
    428471  /*monitor progress*/
     
    435478  LightManager::getInstance()->debug();
    436479
    437   switch(this->debugWorldNr)
     480  switch(this->debugNetworkWorldNr)
    438481    {
    439482      /*
     
    491534
    492535/**
    493  *  initializes a new World shortly before start
     536 *  initializes a new NetworkWorld shortly before start
    494537 *
    495538 * this is the function, that will be loaded shortly before the world is
    496539 * started
    497540*/
    498 ErrorMessage World::init()
     541ErrorMessage NetworkWorld::init()
    499542{
    500543  this->bPause = false;
     
    508551
    509552/**
    510  *  starts the World
    511 */
    512 ErrorMessage World::start()
    513 {
    514   PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);
     553 *  starts the NetworkWorld
     554*/
     555ErrorMessage NetworkWorld::start()
     556{
     557  PRINTF(3)("NetworkWorld::start() - starting current NetworkWorld: nr %i\n", this->debugNetworkWorldNr);
    515558  this->bQuitOrxonox = false;
    516559  this->bQuitCurrentGame = false;
     
    523566   This happens, when the player decides to end the Level.
    524567*/
    525 ErrorMessage World::stop()
    526 {
    527   PRINTF(3)("World::stop() - got stop signal\n");
     568ErrorMessage NetworkWorld::stop()
     569{
     570  PRINTF(3)("NetworkWorld::stop() - got stop signal\n");
    528571  this->bQuitCurrentGame = true;
    529572}
     
    532575 *  pauses the Game
    533576*/
    534 ErrorMessage World::pause()
     577ErrorMessage NetworkWorld::pause()
    535578{
    536579  this->isPaused = true;
     
    540583 *  ends the pause Phase
    541584*/
    542 ErrorMessage World::resume()
     585ErrorMessage NetworkWorld::resume()
    543586{
    544587  this->isPaused = false;
     
    546589
    547590/**
    548  *  destroys the World
    549 */
    550 ErrorMessage World::destroy()
     591 *  destroys the NetworkWorld
     592*/
     593ErrorMessage NetworkWorld::destroy()
    551594{
    552595
     
    556599 *  shows the loading screen
    557600*/
    558 void World::displayLoadScreen ()
    559 {
    560   PRINTF(3)("World::displayLoadScreen - start\n");
     601void NetworkWorld::displayLoadScreen ()
     602{
     603  PRINTF(3)("NetworkWorld::displayLoadScreen - start\n");
    561604
    562605  //GLMenuImageScreen*
     
    564607  this->glmis->setMaximum(8);
    565608
    566   PRINTF(3)("World::displayLoadScreen - end\n");
     609  PRINTF(3)("NetworkWorld::displayLoadScreen - end\n");
    567610}
    568611
     
    572615   @todo take out the delay
    573616*/
    574 void World::releaseLoadScreen ()
    575 {
    576   PRINTF(3)("World::releaseLoadScreen - start\n");
     617void NetworkWorld::releaseLoadScreen ()
     618{
     619  PRINTF(3)("NetworkWorld::releaseLoadScreen - start\n");
    577620  this->glmis->setValue(this->glmis->getMaximum());
    578   PRINTF(3)("World::releaseLoadScreen - end\n");
     621  PRINTF(3)("NetworkWorld::releaseLoadScreen - end\n");
    579622  delete this->glmis;
    580623}
     
    585628 * @returns entity list
    586629*/
    587 tList<WorldEntity>* World::getEntities()
     630tList<WorldEntity>* NetworkWorld::getEntities()
    588631{
    589632  return this->entities;
     
    595638 * @returns elapsed game time
    596639*/
    597 double World::getGameTime()
     640double NetworkWorld::getGameTime()
    598641{
    599642  return this->gameTime;
     
    605648   the current class/procedure
    606649*/
    607 void World::debug()
    608 {
    609   PRINTF(0)("Printing out the List of alive WorldEntities:\n");
     650void NetworkWorld::debug()
     651{
     652  PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");
    610653  tIterator<WorldEntity>* iterator = this->entities->getIterator();
    611654  WorldEntity* entity = iterator->firstElement();
     
    626669  collisions drawing everything to the screen.
    627670*/
    628 void World::mainLoop()
     671void NetworkWorld::mainLoop()
    629672{
    630673  this->lastFrame = SDL_GetTicks ();
    631   PRINTF(3)("World::mainLoop() - Entering main loop\n");
     674  PRINTF(3)("NetworkWorld::mainLoop() - Entering main loop\n");
    632675
    633676  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */
    634677    {
    635678      ++this->cycle;
    636       PRINTF(4)("World::mainloop() - number of entities: %i\n", this->entities->getSize());
     679      PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());
    637680      // Network
    638681      this->synchronize ();
     
    651694    }
    652695
    653   PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
     696  PRINTF(3)("NetworkWorld::mainLoop() - Exiting the main loop\n");
    654697}
    655698
     
    658701 *  synchronize local data with remote data
    659702*/
    660 void World::synchronize ()
     703void NetworkWorld::synchronize ()
    661704{
    662705  // Get remote input
     
    672715   sdl and has its own event-passing-queue.
    673716*/
    674 void World::handleInput ()
     717void NetworkWorld::handleInput ()
    675718{
    676719  EventHandler::getInstance()->process();
     
    687730   a heart-beat.
    688731*/
    689 void World::tick ()
     732void NetworkWorld::tick ()
    690733{
    691734  Uint32 currentFrame = SDL_GetTicks();
     
    755798   state to the whole system.
    756799*/
    757 void World::update()
     800void NetworkWorld::update()
    758801{
    759802  GarbageCollector::getInstance()->update();
     
    766809
    767810
    768 void World::collide()
     811void NetworkWorld::collide()
    769812{
    770813  CDEngine::getInstance()->checkCollisions();
     
    776819   clear all buffers and draw the world
    777820*/
    778 void World::display ()
     821void NetworkWorld::display ()
    779822{
    780823  // clear buffer
     
    796839 *  runs through all entities calling their draw() methods
    797840 */
    798 void World::draw ()
     841void NetworkWorld::draw ()
    799842{
    800843  /* draw entities */
     
    826869 * @param entity to be added
    827870*/
    828 void World::spawn(WorldEntity* entity)
     871void NetworkWorld::spawn(WorldEntity* entity)
    829872{
    830873  this->entities->add (entity);
     
    839882 * @param absDir In which direction should it look.
    840883*/
    841 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
     884void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
    842885{
    843886  this->entities->add (entity);
     
    857900 * @param In which relative direction should it look.
    858901*/
    859 void World::spawn(WorldEntity* entity, PNode* parentNode,
     902void NetworkWorld::spawn(WorldEntity* entity, PNode* parentNode,
    860903                  Vector* relCoor, Quaternion* relDir)
    861904{
     
    873916}
    874917
    875 void World::setPath( const char* name)
     918void NetworkWorld::setPath( const char* name)
    876919{
    877920  if (this->path)
     
    889932}
    890933
    891 const char* World::getPath( void)
     934const char* NetworkWorld::getPath( void)
    892935{
    893936  return path;
  • branches/network/src/story_entities/network_world.h

    r6065 r6069  
    1212#include "p_node.h"
    1313
    14 class World;
     14class NetworkWorld;
    1515class WorldEntity;
    1616class Camera;
     
    3030   it is the main driving factor during gameplay.
    3131*/
    32 class World : public StoryEntity {
     32class NetworkWorld : public StoryEntity {
    3333
    3434 public:
    35   World (const char* name);
    36   World (int worldID);
    37   World (const TiXmlElement* root = NULL);
    38   virtual ~World ();
     35  NetworkWorld (const char* name);
     36  NetworkWorld (int worldID);
     37  NetworkWorld (const TiXmlElement* root = NULL);
     38  virtual ~NetworkWorld ();
    3939
    4040  void loadParams(const TiXmlElement* root);
     
    5252  virtual ErrorMessage destroy ();
    5353
    54   void loadDebugWorld(int worldID);
     54  void loadDebugNetworkWorld(int worldID);
    5555
    5656  virtual void displayLoadScreen();
     
    105105    GLMenuImageScreen* glmis;           //!< The Level-Loader Display
    106106
    107     int debugWorldNr;                   //!< The Debug Nr. needed, if something goes wrong
     107    int debugNetworkWorldNr;                   //!< The Debug Nr. needed, if something goes wrong
    108108    char* path;                         //!< The file from which this world is loaded
    109109
     
    114114    Camera* localCamera;                //!< The current Camera
    115115    WorldEntity* sky;                   //!< The Environmental Heaven of orxonox @todo insert this to environment insted
    116     Terrain* terrain;                   //!< The Terrain of the World.
     116    Terrain* terrain;                   //!< The Terrain of the NetworkWorld.
    117117
    118118    GLuint objectList;                  //!< temporary: @todo this will be ereased soon
Note: See TracChangeset for help on using the changeset viewer.