Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 30, 2005, 10:49:00 PM (18 years ago)
Author:
patrick
Message:

network: major changes in the world files

File:
1 edited

Legend:

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

    r6352 r6358  
    1717#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
    1818
    19 #include "world.h"
     19#include "game_world.h"
    2020
    2121#include "shell_command.h"
     
    7070
    7171
    72 SHELL_COMMAND(speed, World, setSpeed);
    73 SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);
    74 SHELL_COMMAND(toggleBVVisibility, World, toggleBVVisibility);
     72SHELL_COMMAND(speed, GameWorld, setSpeed);
     73SHELL_COMMAND(togglePNodeVisibility, GameWorld, togglePNodeVisibility);
     74SHELL_COMMAND(toggleBVVisibility, GameWorld, toggleBVVisibility);
    7575
    7676using namespace std;
    7777
    78 //! This creates a Factory to fabricate a World
    79 CREATE_FACTORY(World, CL_WORLD);
    80 
    81 World::World(const TiXmlElement* root)
     78//! This creates a Factory to fabricate a GameWorld
     79CREATE_FACTORY(GameWorld, CL_GAME_WORLD);
     80
     81
     82
     83GameWorld::GameWorld(const TiXmlElement* root)
    8284{
    8385  this->constuctorInit("", -1);
     
    8890
    8991/**
    90  *  remove the World from memory
     92 *  remove the GameWorld from memory
    9193 *
    9294 *  delete everything explicitly, that isn't contained in the parenting tree!
    9395 *  things contained in the tree are deleted automaticaly
    9496 */
    95 World::~World ()
     97GameWorld::~GameWorld ()
    9698{
    9799  delete this->shell;
    98   PRINTF(3)("World::~World() - deleting current world\n");
     100  PRINTF(3)("GameWorld::~GameWorld() - deleting current world\n");
    99101
    100102  delete this->localPlayer;
     
    129131
    130132/**
    131  * initializes the world.
     133 *  initializes the world.
    132134 * @param name the name of the world
    133135 * @param worldID the ID of this world
     
    139141 * NO LEVEL LOADING HERE - NEVER!
    140142*/
    141 void World::constuctorInit(const char* name, int worldID)
    142 {
    143   this->setClassID(CL_WORLD, "World");
     143void GameWorld::constuctorInit(const char* name, int worldID)
     144{
     145  this->setClassID(CL_GAME_WORLD, "GameWorld");
    144146
    145147  this->setName(name);
     
    156158
    157159/**
    158  * loads the parameters of a World from an XML-element
     160 * loads the parameters of a GameWorld from an XML-element
    159161 * @param root the XML-element to load from
    160162 */
    161 void World::loadParams(const TiXmlElement* root)
    162 {
    163   PRINTF(4)("Creating a World\n");
    164 
    165   LoadParam(root, "identifier", this, World, setStoryID)
     163void GameWorld::loadParams(const TiXmlElement* root)
     164{
     165  PRINTF(4)("Creating a GameWorld\n");
     166
     167  LoadParam(root, "identifier", this, GameWorld, setStoryID)
    166168    .describe("Sets the StoryID of this world");
    167169
    168   LoadParam(root, "nextid", this, World, setNextStoryID)
     170  LoadParam(root, "nextid", this, GameWorld, setNextStoryID)
    169171    .describe("Sets the ID of the next world");
    170172
    171   LoadParam(root, "path", this, World, setPath)
    172     .describe("The Filename of this World (relative from the data-dir)");
     173  LoadParam(root, "path", this, GameWorld, setPath)
     174    .describe("The Filename of this GameWorld (relative from the data-dir)");
    173175}
    174176
     
    179181 * before the load and after the proceeding storyentity has finished
    180182*/
    181 ErrorMessage World::preLoad()
     183ErrorMessage GameWorld::preLoad()
    182184{
    183185  State::setObjectManager(&this->objectManager);
     
    195197
    196198  this->localCamera = new Camera();
    197   this->localCamera->setName ("World-Camera");
     199  this->localCamera->setName ("GameWorld-Camera");
    198200
    199201  State::setCamera(this->localCamera, this->localCamera->getTarget());
     
    205207
    206208/**
    207  *  loads the World by initializing all resources, and set their default values.
     209 *  loads the GameWorld by initializing all resources, and set their default values.
    208210 */
    209 ErrorMessage World::load()
     211ErrorMessage GameWorld::load()
    210212{
    211213  PRINTF(3)("> Loading world: '%s'\n", getPath());
     
    215217  if( getPath() == NULL)
    216218    {
    217       PRINTF(1)("World has no path specified for loading");
    218       return (ErrorMessage){213,"Path not specified","World::load()"};
     219      PRINTF(1)("GameWorld has no path specified for loading");
     220      return (ErrorMessage){213,"Path not specified","GameWorld::load()"};
    219221    }
    220222
     
    226228    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    227229    delete XMLDoc;
    228     return (ErrorMessage){213,"XML File parsing error","World::load()"};
     230    return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"};
    229231  }
    230232
     
    238240      PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
    239241      delete XMLDoc;
    240       return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
     242      return (ErrorMessage){213,"Path not a WorldDataFile","GameWorld::load()"};
    241243    }
    242244
     
    246248  if( string == NULL)
    247249    {
    248       PRINTF(2)("World is missing a proper 'name'\n");
     250      PRINTF(2)("GameWorld is missing a proper 'name'\n");
    249251      this->setName("Unknown");
    250252    }
     
    281283  if( element == NULL)
    282284    {
    283       PRINTF(1)("World is missing 'WorldEntities'\n");
     285      PRINTF(1)("GameWorld is missing 'WorldEntities'\n");
    284286    }
    285287  else
     
    353355  SoundEngine::getInstance()->setListener(this->localCamera);
    354356
    355 
    356 
    357   ////////////
    358   // STATIC //
    359   ////////////
    360 
    361 
    362 //   TestEntity* testEntity = new TestEntity();
    363 //   testEntity->setRelCoor(Vector(570, 10, -15));
    364 //   testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    365 //   this->spawn(testEntity);
    366 
    367   for(int i = 0; i < 100; i++)
    368   {
    369     WorldEntity* tmp = new NPCTest1();
    370     char npcChar[10];
    371     sprintf (npcChar, "NPC_%d", i);
    372         tmp->setName(npcChar);
    373     tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
    374     this->spawn(tmp);
    375   }
     357  /* some static stuff*/
    376358
    377359  this->music = NULL;
     
    380362}
    381363
    382 ErrorMessage World::postLoad()
     364ErrorMessage GameWorld::postLoad()
    383365{
    384366  this->releaseLoadScreen();
     
    387369
    388370/**
    389  *  initializes a new World shortly before start
     371 *  initializes a new GameWorld shortly before start
    390372 *
    391373 * this is the function, that will be loaded shortly before the world is
    392374 * started
    393375*/
    394 ErrorMessage World::preStart()
     376ErrorMessage GameWorld::preStart()
    395377{
    396378  this->bPause = false;
     
    403385
    404386/**
    405  *  starts the World
     387 *  starts the GameWorld
    406388 */
    407 ErrorMessage World::start()
     389ErrorMessage GameWorld::start()
    408390{
    409391  this->bQuitWorld = false;
     
    416398   This happens, when the player decides to end the Level.
    417399*/
    418 ErrorMessage World::stop()
    419 {
    420   PRINTF(3)("World::stop() - got stop signal\n");
     400ErrorMessage GameWorld::stop()
     401{
     402  PRINTF(3)("GameWorld::stop() - got stop signal\n");
    421403  this->bQuitWorld= true;
    422404}
     
    425407 *  pauses the Game
    426408*/
    427 ErrorMessage World::pause()
     409ErrorMessage GameWorld::pause()
    428410{
    429411  this->isPaused = true;
     
    433415 *  ends the pause Phase
    434416*/
    435 ErrorMessage World::resume()
     417ErrorMessage GameWorld::resume()
    436418{
    437419  this->isPaused = false;
     
    439421
    440422/**
    441  *  destroys the World
    442 */
    443 ErrorMessage World::destroy()
     423 *  destroys the GameWorld
     424*/
     425ErrorMessage GameWorld::destroy()
    444426{
    445427
     
    449431 *  shows the loading screen
    450432*/
    451 void World::displayLoadScreen ()
    452 {
    453   PRINTF(3)("World::displayLoadScreen - start\n");
     433void GameWorld::displayLoadScreen ()
     434{
     435  PRINTF(3)("GameWorld::displayLoadScreen - start\n");
    454436
    455437  //GLMenuImageScreen*
     
    457439  this->glmis->setMaximum(8);
    458440
    459   PRINTF(3)("World::displayLoadScreen - end\n");
     441  PRINTF(3)("GameWorld::displayLoadScreen - end\n");
    460442}
    461443
     
    465447 * @todo take out the delay
    466448*/
    467 void World::releaseLoadScreen ()
    468 {
    469   PRINTF(3)("World::releaseLoadScreen - start\n");
     449void GameWorld::releaseLoadScreen ()
     450{
     451  PRINTF(3)("GameWorld::releaseLoadScreen - start\n");
    470452  this->glmis->setValue(this->glmis->getMaximum());
    471   PRINTF(3)("World::releaseLoadScreen - end\n");
     453  PRINTF(3)("GameWorld::releaseLoadScreen - end\n");
    472454  delete this->glmis;
    473455}
     
    478460 * @returns elapsed game time
    479461*/
    480 double World::getGameTime()
     462double GameWorld::getGameTime()
    481463{
    482464  return this->gameTime;
     
    488470 *  synchronize local data with remote data
    489471*/
    490 void World::synchronize ()
     472void GameWorld::synchronize ()
    491473{
    492474  // Get remote input
     
    502484   sdl and has its own event-passing-queue.
    503485*/
    504 void World::handleInput ()
     486void GameWorld::handleInput ()
    505487{
    506488  EventHandler::getInstance()->process();
     
    509491}
    510492
    511 void World::tick(std::list<WorldEntity*> entityList, float dt)
     493void GameWorld::tick(std::list<WorldEntity*> entityList, float dt)
    512494{
    513495  std::list<WorldEntity*>::iterator entity;
     
    524506   a heart-beat.
    525507*/
    526 void World::tick ()
     508void GameWorld::tick ()
    527509{
    528510  Uint32 currentFrame = SDL_GetTicks();
     
    588570   state to the whole system.
    589571*/
    590 void World::update()
     572void GameWorld::update()
    591573{
    592574  GraphicsEngine::getInstance()->update(this->dtS);
     
    597579
    598580
    599 void World::collide()
     581void GameWorld::collide()
    600582{
    601583  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),
     
    610592   clear all buffers and draw the world
    611593*/
    612 void World::display ()
     594void GameWorld::display ()
    613595{
    614596  // clear buffer
     
    630612 *  runs through all entities calling their draw() methods
    631613 */
    632 void World::draw ()
     614void GameWorld::draw ()
    633615{
    634616  GraphicsEngine* engine = GraphicsEngine::getInstance();
     
    674656 * collisions drawing everything to the screen.
    675657 */
    676 void World::mainLoop()
     658void GameWorld::mainLoop()
    677659{
    678660  this->lastFrame = SDL_GetTicks ();
    679   PRINTF(3)("World::mainLoop() - Entering main loop\n");
     661  PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n");
    680662
    681663  while(!this->bQuitWorld) /* @todo implement pause */
     
    698680  }
    699681
    700   PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
     682  PRINTF(3)("GameWorld::mainLoop() - Exiting the main loop\n");
    701683}
    702684
     
    707689 * @param entity to be added
    708690*/
    709 void World::spawn(WorldEntity* entity)
     691void GameWorld::spawn(WorldEntity* entity)
    710692{
    711693//   this->entities->add (entity);
     
    713695}
    714696
    715 void World::setPath( const char* name)
     697void GameWorld::setPath( const char* name)
    716698{
    717699  if (this->path)
     
    729711}
    730712
    731 const char* World::getPath( void)
     713const char* GameWorld::getPath( void)
    732714{
    733715  return path;
Note: See TracChangeset for help on using the changeset viewer.