Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/world.cc @ 6150

Last change on this file since 6150 was 6150, checked in by bensch, 18 years ago

orxonox/trunk: cleanup of the world begin

File size: 18.2 KB
RevLine 
[4555]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
[1855]10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
[2190]13   co-programmer: Christian Meyer
[5390]14   co-programmer: Benjamin Grauer
[1853]15*/
16
[3590]17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
18
[2190]19#include "world.h"
[3608]20
[5205]21#include "shell_command.h"
[6150]22#include "resource_manager.h"
[4347]23#include "state.h"
24
[3608]25#include "p_node.h"
[2190]26#include "world_entity.h"
[2036]27#include "player.h"
[2190]28#include "camera.h"
[2816]29#include "environment.h"
[6150]30
[4245]31#include "test_entity.h"
[3608]32#include "terrain.h"
[3436]33#include "light.h"
[4726]34#include "load_param.h"
[5174]35#include "shell.h"
[3620]36
[4940]37#include "fast_factory.h"
[3812]38#include "animation_player.h"
[4176]39#include "particle_engine.h"
[4245]40#include "graphics_engine.h"
[4338]41#include "physics_engine.h"
[4396]42#include "fields.h"
[3646]43
[4488]44#include "md2Model.h"
45
[3608]46#include "glmenu_imagescreen.h"
47#include "list.h"
[4010]48#include "game_loader.h"
[2036]49
[3964]50#include "animation3d.h"
[3608]51
[4010]52#include "substring.h"
[3608]53
[4261]54#include "factory.h"
[4245]55
[5556]56#include "weapons/projectile.h"
[4405]57#include "event_handler.h"
[4504]58#include "sound_engine.h"
[4961]59#include "ogg_player.h"
[4504]60
[4747]61#include "class_list.h"
62
[4917]63#include "cd_engine.h"
[5750]64#include "npcs/npc_test1.h"
[5318]65#include "shader.h"
[4820]66
[5915]67#include "playable.h"
[5996]68#include "network_manager.h"
69#include "playable.h"
[5915]70
[5996]71
[5205]72SHELL_COMMAND(speed, World, setSpeed);
[5389]73SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);
[5429]74SHELL_COMMAND(toggleBVVisibility, World, toggleBVVisibility);
[5205]75
[1856]76using namespace std;
[1853]77
[4978]78//! This creates a Factory to fabricate a World
[5750]79CREATE_FACTORY(World, CL_WORLD);
[3620]80
[4261]81World::World(const TiXmlElement* root)
[4010]82{
83  this->constuctorInit("", -1);
[4094]84  this->path = NULL;
[4555]85
[4261]86  this->loadParams(root);
[4010]87}
88
[4555]89/**
[4838]90 *  remove the World from memory
[6150]91 *
92 *  delete everything explicitly, that isn't contained in the parenting tree!
93 *  things contained in the tree are deleted automaticaly
[4838]94 */
[2190]95World::~World ()
[1872]96{
[5206]97  delete this->shell;
[3546]98  PRINTF(3)("World::~World() - deleting current world\n");
[3677]99
[5915]100  delete this->localPlayer;
[5115]101
[5296]102  // delete all the initialized Engines.
[5447]103  FastFactory::flushAll(true);
[4735]104  delete LightManager::getInstance();
[4822]105  delete ParticleEngine::getInstance();
[5296]106  delete AnimationPlayer::getInstance();
[4978]107  delete PhysicsEngine::getInstance();
[4822]108
[4978]109  // external engines initialized by the orxonox-class get deleted
[4504]110  SoundEngine::getInstance()->flushAllBuffers();
[4830]111  SoundEngine::getInstance()->flushAllSources();
[4504]112
[6142]113  if (State::getObjectManager() == &this->objectManager)
114    State::setObjectManager(NULL);
[4978]115  // erease everything that is left.
[6074]116  delete PNode::getNullParent();
[5915]117
[6054]118  //secondary cleanup of PNodes;
119  const std::list<BaseObject*>* nodeList = ClassList::getList(CL_PARENT_NODE);
120  if (nodeList != NULL)
121    while (!nodeList->empty())
122      delete nodeList->front();
123
[5318]124  Shader::suspendShader();
[4872]125
[4978]126  // unload the resources !!
[4136]127  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
[1872]128}
[1858]129
[3526]130/**
[4978]131 * initializes the world.
132 * @param name the name of the world
133 * @param worldID the ID of this world
134 *
135 * set all stuff here that is world generic and does not use to much memory
136 * because the real init() function StoryEntity::init() will be called
137 * shortly before start of the game.
138 * since all worlds are initiated/referenced before they will be started.
139 * NO LEVEL LOADING HERE - NEVER!
[3526]140*/
[4978]141void World::constuctorInit(const char* name, int worldID)
[3526]142{
[4320]143  this->setClassID(CL_WORLD, "World");
[2636]144
[4978]145  this->setName(name);
[5211]146  this->gameTime = 0.0f;
[5205]147  this->setSpeed(1.0);
[4961]148  this->music = NULL;
[5211]149  this->shell = NULL;
[5915]150  this->localPlayer = NULL;
151  this->localCamera = NULL;
[5389]152
153  this->showPNodes = false;
[5429]154  this->showBV = false;
[3629]155}
[3526]156
[4978]157/**
158 * loads the parameters of a World from an XML-element
159 * @param root the XML-element to load from
160 */
[4261]161void World::loadParams(const TiXmlElement* root)
162{
[4600]163  PRINTF(4)("Creating a World\n");
[4261]164
[5671]165  LoadParam(root, "identifier", this, World, setStoryID)
[4261]166    .describe("Sets the StoryID of this world");
[4834]167
[5671]168  LoadParam(root, "nextid", this, World, setNextStoryID)
[4261]169    .describe("Sets the ID of the next world");
[4834]170
[5671]171  LoadParam(root, "path", this, World, setPath)
[4261]172    .describe("The Filename of this World (relative from the data-dir)");
173}
174
[3629]175/**
[4978]176 * this is executed just before load
177 *
178 * since the load function sometimes needs data, that has been initialized
179 * before the load and after the proceeding storyentity has finished
[3629]180*/
181ErrorMessage World::preLoad()
182{
[6142]183  State::setObjectManager(&this->objectManager);
[4829]184  this->cycle = 0;
185
[3620]186  /* init the world interface */
[5206]187  this->shell = new Shell();
[4010]188
[4735]189  LightManager::getInstance();
[6074]190  PNode::getNullParent();
[3993]191
[4010]192  AnimationPlayer::getInstance(); // initializes the animationPlayer
[5915]193  ParticleEngine::getInstance();
[4338]194  PhysicsEngine::getInstance();
[4010]195
[4015]196  this->localCamera = new Camera();
[4978]197  this->localCamera->setName ("World-Camera");
[4555]198
[4827]199  State::setCamera(this->localCamera, this->localCamera->getTarget());
[4347]200
[4245]201  GraphicsEngine::getInstance()->displayFPS(true);
[3526]202}
203
204
[3449]205/**
[4836]206 *  loads the World by initializing all resources, and set their default values.
[6150]207 */
[3459]208ErrorMessage World::load()
[4555]209{
[4104]210  PRINTF(3)("> Loading world: '%s'\n", getPath());
211  TiXmlElement* element;
[4010]212  GameLoader* loader = GameLoader::getInstance();
[4555]213
[4010]214  if( getPath() == NULL)
[2636]215    {
[4104]216      PRINTF(1)("World has no path specified for loading");
[4010]217      return (ErrorMessage){213,"Path not specified","World::load()"};
218    }
[4555]219
[5915]220  TiXmlDocument* XMLDoc = new TiXmlDocument( getPath());
[4010]221  // load the campaign document
[4555]222  if( !XMLDoc->LoadFile())
[4010]223  {
224    // report an error
[5915]225    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
[4010]226    delete XMLDoc;
227    return (ErrorMessage){213,"XML File parsing error","World::load()"};
228  }
[4555]229
[4010]230  // check basic validity
231  TiXmlElement* root = XMLDoc->RootElement();
232  assert( root != NULL);
[4555]233
[4010]234  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
235    {
236      // report an error
[4104]237      PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
[4010]238      delete XMLDoc;
239      return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
240    }
[4555]241
[4010]242  // load the parameters
243  // name
244  const char* string = grabParameter( root, "name");
245  if( string == NULL)
246    {
[4104]247      PRINTF(2)("World is missing a proper 'name'\n");
[5211]248      this->setName("Unknown");
[4010]249    }
250  else
251    {
[5211]252      this->setName(string);
[4010]253    }
[4978]254
[4104]255  ////////////////
256  // LOADSCREEN //
257  ////////////////
258  element = root->FirstChildElement("LoadScreen");
259  if (element == NULL)
260    {
261      PRINTF(2)("no LoadScreen specified, loading default\n");
262
263      glmis->setBackgroundImage("pictures/load_screen.jpg");
264      this->glmis->setMaximum(8);
265      this->glmis->draw();
266    }
267  else
268    {
[4261]269      this->glmis->loadParams(element);
[4104]270      this->glmis->draw();
271    }
272  this->glmis->draw();
[4726]273
274  ////////////////////////
275  // find WorldEntities //
276  ////////////////////////
277
[4104]278  element = root->FirstChildElement("WorldEntities");
[4555]279
[4010]280  if( element == NULL)
281    {
[4104]282      PRINTF(1)("World is missing 'WorldEntities'\n");
[4010]283    }
284  else
285    {
286      element = element->FirstChildElement();
287      // load Players/Objects/Whatever
[4104]288      PRINTF(4)("Loading WorldEntities\n");
[4010]289      while( element != NULL)
[4555]290        {
[5996]291          BaseObject* created = Factory::fabricate(element);
[5915]292          if( created != NULL )
293          {
294            if(created->isA(CL_WORLD_ENTITY))
295              this->spawn(dynamic_cast<WorldEntity*>(created));
[5996]296            printf("Created a %s: %s\n", created->getClassName(), created->getName());
[5915]297          }
298
[4555]299          // if we load a 'Player' we use it as localPlayer
[5915]300
301
[4555]302          //todo do this more elegant
[5915]303          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
[6150]304            this->sky = dynamic_cast<WorldEntity*>(created);
[4918]305          if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
306          {
[5915]307            terrain = dynamic_cast<Terrain*>(created);
[4918]308            CDEngine::getInstance()->setTerrain(terrain);
309          }
[4555]310          element = element->NextSiblingElement();
[4836]311          glmis->step(); //! @todo temporary
[4555]312        }
[4104]313      PRINTF(4)("Done loading WorldEntities\n");
[4010]314    }
[4555]315
[4726]316    //////////////////////////////
317    // LOADING ADDITIONAL STUFF //
318    //////////////////////////////
319
[5652]320    LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams);
[4735]321
[5915]322   LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);
323//   LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);
[4726]324
[4010]325  // free the XML data
[4015]326
[4010]327  delete XMLDoc;
[4015]328  /* GENERIC LOADING PROCESS FINISHED */
[4555]329
330
[5915]331  // Create a Player
332  this->localPlayer = new Player();
[4245]333
[5915]334  Playable* playable;
335  const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
336  if (playableList != NULL)
337  {
338    playable = dynamic_cast<Playable*>(playableList->front());
339    this->localPlayer->setControllable(playable);
340  }
[4555]341
[5915]342  // bind camera
343  playable->addChild (this->localCamera);
[4555]344
[5915]345//   //localCamera->setParent(TrackNode::getInstance());
346//  tn->addChild(this->localCamera);
[4620]347  localCamera->setClipRegion(1, 10000.0);
[5915]348  localCamera->lookAt(playable);
349//  this->localPlayer->setParentMode(PNODE_ALL);
[5355]350  if (sky != NULL)
351  {
352    this->sky->setParent(this->localCamera);
353    this->sky->setParentMode(PNODE_MOVEMENT);
354  }
[3368]355
[4504]356  SoundEngine::getInstance()->setListener(this->localCamera);
[4176]357
[4347]358
[4709]359
[4715]360  ////////////
361  // STATIC //
362  ////////////
363
364
[4721]365//   TestEntity* testEntity = new TestEntity();
366//   testEntity->setRelCoor(Vector(570, 10, -15));
367//   testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
368//   this->spawn(testEntity);
[4397]369
[4976]370  for(int i = 0; i < 100; i++)
371  {
[5750]372    WorldEntity* tmp = new NPCTest1();
[5049]373    char npcChar[10];
374    sprintf (npcChar, "NPC_%d", i);
[5256]375        tmp->setName(npcChar);
[5336]376    tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
[4976]377    this->spawn(tmp);
378  }
379
[6034]380  this->music = NULL;
381  //(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);
[5211]382  //music->playback();
[4010]383}
[3365]384
[4245]385
[4326]386/**
[4836]387 *  initializes a new World shortly before start
[4978]388 *
389 * this is the function, that will be loaded shortly before the world is
390 * started
[3459]391*/
392ErrorMessage World::init()
393{
394  this->bPause = false;
[5051]395
396  /* update the object position before game start - so there are no wrong coordinates used in the first processing */
[6074]397  PNode::getNullParent()->updateNode (0.001f);
398  PNode::getNullParent()->updateNode (0.001f);
[3459]399}
400
401
402/**
[4836]403 *  starts the World
[6150]404 */
[3459]405ErrorMessage World::start()
406{
407  this->bQuitOrxonox = false;
408  this->bQuitCurrentGame = false;
409  this->mainLoop();
410}
411
412/**
[4836]413 *  stops the world.
[3459]414
415   This happens, when the player decides to end the Level.
416*/
417ErrorMessage World::stop()
418{
[3546]419  PRINTF(3)("World::stop() - got stop signal\n");
[3459]420  this->bQuitCurrentGame = true;
421}
422
423/**
[4836]424 *  pauses the Game
[3459]425*/
426ErrorMessage World::pause()
427{
428  this->isPaused = true;
429}
430
431/**
[4836]432 *  ends the pause Phase
[3459]433*/
434ErrorMessage World::resume()
435{
436  this->isPaused = false;
437}
438
439/**
[4836]440 *  destroys the World
[3459]441*/
442ErrorMessage World::destroy()
443{
[3566]444
[3459]445}
446
447/**
[4836]448 *  shows the loading screen
[3459]449*/
450void World::displayLoadScreen ()
451{
[4555]452  PRINTF(3)("World::displayLoadScreen - start\n");
453
454  //GLMenuImageScreen*
[4099]455  this->glmis = new GLMenuImageScreen();
[3675]456  this->glmis->setMaximum(8);
[4555]457
458  PRINTF(3)("World::displayLoadScreen - end\n");
[3459]459}
460
461/**
[6150]462 * @brief removes the loadscreen, and changes over to the game
463 *
464 * @todo take out the delay
[3459]465*/
466void World::releaseLoadScreen ()
467{
[4555]468  PRINTF(3)("World::releaseLoadScreen - start\n");
[3459]469  this->glmis->setValue(this->glmis->getMaximum());
[4555]470  PRINTF(3)("World::releaseLoadScreen - end\n");
[4099]471  delete this->glmis;
[3459]472}
473
474
[3620]475/**
[4836]476 *  this returns the current game time
477 * @returns elapsed game time
[3646]478*/
479double World::getGameTime()
480{
481  return this->gameTime;
482}
483
[3225]484
[5045]485
[2190]486/**
[4836]487 *  synchronize local data with remote data
[1855]488*/
[2636]489void World::synchronize ()
[1855]490{
[2636]491  // Get remote input
492  // Update synchronizables
[5996]493/*  NetworkManager::getInstance()->synchronize();*/
[1855]494}
[2636]495
[3459]496
[2636]497/**
[4836]498 *  run all input processing
[3225]499
500   the command node is the central input event dispatcher. the node uses the even-queue from
501   sdl and has its own event-passing-queue.
[2636]502*/
[3225]503void World::handleInput ()
[2636]504{
[4407]505  EventHandler::getInstance()->process();
506
[2636]507  // remoteinput
508}
509
[6142]510void World::tick(std::list<WorldEntity*> entityList, float dt)
511{
512  std::list<WorldEntity*>::iterator entity;
513  for (entity = entityList.begin(); entity != entityList.end(); entity++)
514    (*entity)->tick(dt);
[3459]515
[6142]516}
517
[2636]518/**
[4836]519 *  advance the timeline
[3225]520
521   this calculates the time used to process one frame (with all input handling, drawing, etc)
522   the time is mesured in ms and passed to all world-entities and other classes that need
523   a heart-beat.
[2636]524*/
[3551]525void World::tick ()
[2636]526{
527  Uint32 currentFrame = SDL_GetTicks();
528  if(!this->bPause)
529    {
[3644]530      this->dt = currentFrame - this->lastFrame;
[4555]531
[4610]532      if( this->dt > 10)
[4555]533        {
534          float fps = 1000/dt;
[3790]535
[4555]536          // temporary, only for showing how fast the text-engine is
537          char tmpChar[20];
538          sprintf(tmpChar, "fps: %4.0f", fps);
539        }
[2636]540      else
[4555]541        {
542          /* the frame-rate is limited to 100 frames per second, all other things are for
543             nothing.
544          */
[5048]545          PRINTF(3)("fps = 1000 - frame rate is adjusted\n");
[4610]546          SDL_Delay(10-dt);
[4555]547          this->dt = 10;
548        }
549
[5205]550      this->dtS = (float)this->dt / 1000.0 * this->speed;
[4145]551      this->gameTime += this->dtS;
[4833]552
[6142]553/*      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
554      this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);
555      this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/
556      this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);
557      this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);
[4010]558
[3459]559      /* update tick the rest */
[4832]560      this->localCamera->tick(this->dtS);
[4558]561      // tick the engines
[4245]562      AnimationPlayer::getInstance()->tick(this->dtS);
[4979]563//      if (this->cycle > 5)
[4558]564        PhysicsEngine::getInstance()->tick(this->dtS);
[4396]565
[4558]566      ParticleEngine::getInstance()->tick(this->dtS);
[4396]567
[4831]568
[4558]569      /** actualy the Graphics Engine should tick the world not the other way around...
[4555]570         but since we like the things not too complicated we got it this way around
571         until there is need or time to do it the other way around.
[4836]572         @todo: GraphicsEngine ticks world: separation of processes and data...
[4681]573
574        bensch: in my opinion the GraphicsEngine could draw the world, but not tick it,
575         beceause graphics have nothing(or at least not much) to do with Motion.
[4245]576      */
577      GraphicsEngine::getInstance()->tick(this->dtS);
[2636]578    }
579  this->lastFrame = currentFrame;
580}
581
[3216]582
[2636]583/**
[4836]584 *  this function gives the world a consistant state
[3551]585
586   after ticking (updating the world state) this will give a constistant
587   state to the whole system.
588*/
589void World::update()
590{
[5406]591  GraphicsEngine::getInstance()->update(this->dtS);
[6074]592  PNode::getNullParent()->updateNode (this->dtS);
[4504]593
594  SoundEngine::getInstance()->update();
[4978]595  //music->update();
[3551]596}
597
598
[4917]599void World::collide()
600{
[6142]601  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),
602                                            this->objectManager.getObjectList(OM_GROUP_01_PROJ));
603  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),
604                                            this->objectManager.getObjectList(OM_COMMON));
[4917]605}
606
[3551]607/**
[4836]608 *  render the current frame
[4555]609
[3225]610   clear all buffers and draw the world
[2636]611*/
612void World::display ()
613{
614  // clear buffer
615  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
616  // set camera
617  this->localCamera->apply ();
618  // draw world
619  this->draw();
620  // draw HUD
[4837]621  /** @todo draw HUD */
[2636]622  // flip buffers
[4681]623  GraphicsEngine::swapBuffers();
[3365]624  //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
625  //SDL_Flip (screen);
[2636]626}
627
[2644]628
[3225]629/**
[4917]630 *  runs through all entities calling their draw() methods
631 */
632void World::draw ()
633{
[6142]634  GraphicsEngine* engine = GraphicsEngine::getInstance();
635  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));
636  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));
637  engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));
638  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));
639  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));
640  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
[4917]641
[6142]642//   {
643//     if( entity->isVisible() ) entity->draw();
644  //FIXME
645//     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
646//     entity = iterator->nextElement();
647//   }
648
[4917]649  ParticleEngine::getInstance()->draw();
650
[5389]651  if (unlikely(this->showPNodes))
[6074]652    PNode::getNullParent()->debugDraw(0);
[5389]653
[6142]654  engine->draw();
[4917]655  //TextEngine::getInstance()->draw();
656}
657
[2816]658
[3225]659/**
[6150]660 * \brief main loop of the world: executing all world relevant function
661 *
662 * in this loop we synchronize (if networked), handle input events, give the heart-beat to
663 * all other member-entities of the world (tick to player, enemies etc.), checking for
664 * collisions drawing everything to the screen.
665 */
666void World::mainLoop()
[2816]667{
[6150]668  this->lastFrame = SDL_GetTicks ();
669  PRINTF(3)("World::mainLoop() - Entering main loop\n");
[3529]670
[6150]671  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */
672  {
673    ++this->cycle;
674      // Network
675    this->synchronize ();
676      // Process input
677    this->handleInput ();
678    if( this->bQuitCurrentGame || this->bQuitOrxonox)
679      break;
680      // Process time
681    this->tick ();
682      // Process collision
683    this->collide ();
684      // Update the state
685    this->update ();
686      // Draw
687    this->display ();
688  }
[3365]689
[6150]690  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
[2644]691}
[2816]692
693
[6150]694
[3521]695/**
[4836]696 *  add and spawn a new entity to this world
697 * @param entity to be added
[3521]698*/
[6150]699void World::spawn(WorldEntity* entity)
[3521]700{
[6150]701//   this->entities->add (entity);
702  entity->postSpawn ();
[3521]703}
704
[4010]705void World::setPath( const char* name)
706{
[4094]707  if (this->path)
708    delete this->path;
709  if (ResourceManager::isFile(name))
710  {
711    this->path = new char[strlen(name)+1];
712    strcpy(this->path, name);
713  }
714  else
715    {
716      this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];
717      sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);
718    }
[4010]719}
720
721const char* World::getPath( void)
722{
723  return path;
724}
Note: See TracBrowser for help on using the repository browser.