Changeset 6358 in orxonox.OLD for branches/network/src/story_entities/multi_player_world.cc
- Timestamp:
- Dec 30, 2005, 10:49:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/multi_player_world.cc
r6355 r6358 11 11 ### File Specific: 12 12 main-programmer: Patrick Boenzli 13 co-programmer: Christian Meyer14 co-programmer: Benjamin Grauer15 13 */ 16 14 17 15 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD 18 16 19 #include " network_world.h"17 #include "multi_player_world.h" 20 18 21 #include "shell_command.h"22 #include "resource_manager.h"23 19 #include "state.h" 20 #include "class_list.h" 24 21 25 #include "p_node.h"26 #include "world_entity.h"27 #include "player.h"28 #include "camera.h"29 #include "environment.h"30 #include "terrain.h"31 32 #include "test_entity.h"33 #include "terrain.h"34 #include "light.h"35 22 #include "load_param.h" 36 #include "shell.h"37 38 23 #include "fast_factory.h" 39 #include "animation_player.h"40 #include "particle_engine.h"41 #include "graphics_engine.h"42 #include "physics_engine.h"43 #include "fields.h"44 45 #include "md2Model.h"46 47 #include "glmenu_imagescreen.h"48 #include "game_loader.h"49 50 #include "animation3d.h"51 52 #include "substring.h"53 54 24 #include "factory.h" 55 25 56 #include "weapons/projectile.h"57 #include "event_handler.h"58 #include "sound_engine.h"59 #include "ogg_player.h"60 61 #include "class_list.h"62 63 #include "cd_engine.h"64 #include "npcs/npc_test1.h"65 #include "shader.h"66 67 #include "playable.h"68 #include "network_manager.h"69 #include "network_game_manager.h"70 #include "playable.h"71 26 72 27 73 SHELL_COMMAND(speed, NetworkWorld, setSpeed); 74 SHELL_COMMAND(togglePNodeVisibility, NetworkWorld, togglePNodeVisibility); 75 SHELL_COMMAND(toggleBVVisibility, NetworkWorld, toggleBVVisibility); 28 29 SHELL_COMMAND(speed, MultiPlayerWorld, setSpeed); 30 SHELL_COMMAND(togglePNodeVisibility, MultiPlayerWorld, togglePNodeVisibility); 31 SHELL_COMMAND(toggleBVVisibility, MultiPlayerWorld, toggleBVVisibility); 76 32 77 33 using namespace std; 78 34 79 //! This creates a Factory to fabricate a NetworkWorld80 CREATE_FACTORY( NetworkWorld, CL_WORLD);35 //! This creates a Factory to fabricate a MultiPlayerWorld 36 CREATE_FACTORY(MultiPlayerWorld, CL_WORLD); 81 37 82 NetworkWorld::NetworkWorld(const TiXmlElement* root)38 MultiPlayerWorld::MultiPlayerWorld(const TiXmlElement* root) 83 39 { 84 40 this->constuctorInit("", -1); … … 89 45 90 46 /** 91 * remove the NetworkWorld from memory47 * remove the MultiPlayerWorld from memory 92 48 * 93 49 * delete everything explicitly, that isn't contained in the parenting tree! 94 50 * things contained in the tree are deleted automaticaly 95 51 */ 96 NetworkWorld::~NetworkWorld ()52 MultiPlayerWorld::~MultiPlayerWorld () 97 53 { 98 54 delete this->shell; 99 PRINTF(3)(" NetworkWorld::~NetworkWorld() - deleting current world\n");55 PRINTF(3)("MultiPlayerWorld::~MultiPlayerWorld() - deleting current world\n"); 100 56 101 57 delete this->localPlayer; … … 140 96 * NO LEVEL LOADING HERE - NEVER! 141 97 */ 142 void NetworkWorld::constuctorInit(const char* name, int worldID)98 void MultiPlayerWorld::constuctorInit(const char* name, int worldID) 143 99 { 144 this->setClassID(CL_WORLD, " NetworkWorld");100 this->setClassID(CL_WORLD, "MultiPlayerWorld"); 145 101 PRINTF(0)("START\n"); 146 102 … … 157 113 } 158 114 115 159 116 /** 160 * loads the parameters of a NetworkWorld from an XML-element117 * loads the parameters of a MultiPlayerWorld from an XML-element 161 118 * @param root the XML-element to load from 162 119 */ 163 void NetworkWorld::loadParams(const TiXmlElement* root)120 void MultiPlayerWorld::loadParams(const TiXmlElement* root) 164 121 { 165 PRINTF(4)("Creating a NetworkWorld\n");122 static_cast<GameWorld*>(this)->loadParams(root); 166 123 167 LoadParam(root, "identifier", this, NetworkWorld, setStoryID)168 .describe("Sets the StoryID of this world"); 124 PRINTF(4)("Creating a MultiPlayerWorld\n"); 125 } 169 126 170 LoadParam(root, "nextid", this, NetworkWorld, setNextStoryID)171 .describe("Sets the ID of the next world");172 127 173 LoadParam(root, "path", this, NetworkWorld, setPath)174 .describe("The Filename of this NetworkWorld (relative from the data-dir)");175 }176 128 177 129 /** … … 180 132 * since the load function sometimes needs data, that has been initialized 181 133 * before the load and after the proceeding storyentity has finished 182 */183 ErrorMessage NetworkWorld::preLoad()134 */ 135 ErrorMessage GameWorld::preLoad() 184 136 { 185 State::setObjectManager(&this->objectManager); 186 this->cycle = 0; 137 static_cast<GameWorld*>(this)->preLoad(); 187 138 188 /* init the world interface */ 189 this->shell = new Shell(); 190 191 LightManager::getInstance(); 192 PNode::getNullParent(); 193 194 AnimationPlayer::getInstance(); // initializes the animationPlayer 195 ParticleEngine::getInstance(); 196 PhysicsEngine::getInstance(); 197 198 this->localCamera = new Camera(); 199 this->localCamera->setName ("NetworkWorld-Camera"); 200 201 State::setCamera(this->localCamera, this->localCamera->getTarget()); 202 203 GraphicsEngine::getInstance()->displayFPS(true); 204 this->displayLoadScreen(); 139 /* the the single player specific stuff */ 205 140 } 206 141 207 142 208 143 /** 209 * loads the NetworkWorld by initializing all resources, and set their default values.144 * loads the GameWorld by initializing all resources, and set their default values. 210 145 */ 211 ErrorMessage NetworkWorld::load()146 ErrorMessage GameWorld::load() 212 147 { 213 PRINTF(3)("> Loading world: '%s'\n", getPath()); 214 TiXmlElement* element; 215 GameLoader* loader = GameLoader::getInstance(); 148 static_cast<GameWorld*>(this)->load(); 216 149 217 if( getPath() == NULL) 218 { 219 PRINTF(1)("World has no path specified for loading"); 220 return (ErrorMessage){213,"Path not specified","World::load()"}; 221 } 150 /* the the single player specific stuff here */ 222 151 223 TiXmlDocument* XMLDoc = new TiXmlDocument( getPath()); 224 // load the campaign document 225 if( !XMLDoc->LoadFile()) 152 /* some static world entities */ 153 for(int i = 0; i < 100; i++) 226 154 { 227 // report an error 228 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 229 delete XMLDoc; 230 return (ErrorMessage){213,"XML File parsing error","NetworkWorld::load()"}; 155 WorldEntity* tmp = new NPCTest1(); 156 char npcChar[10]; 157 sprintf (npcChar, "NPC_%d", i); 158 tmp->setName(npcChar); 159 tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30); 160 this->spawn(tmp); 231 161 } 232 233 // check basic validity234 TiXmlElement* root = XMLDoc->RootElement();235 assert( root != NULL);236 237 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))238 {239 // report an error240 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");241 delete XMLDoc;242 return (ErrorMessage){213,"Path not a WorldDataFile","NetworkWorld::load()"};243 }244 245 246 // load the parameters247 // name248 const char* string = grabParameter( root, "name");249 if( string == NULL)250 {251 PRINTF(2)("World is missing a proper 'name'\n");252 this->setName("Unknown");253 }254 else255 {256 this->setName(string);257 }258 259 260 ////////////////261 // LOADSCREEN //262 ////////////////263 element = root->FirstChildElement("LoadScreen");264 if (element == NULL)265 {266 PRINTF(2)("no LoadScreen specified, loading default\n");267 268 glmis->setBackgroundImage("pictures/load_screen.jpg");269 this->glmis->setMaximum(8);270 this->glmis->draw();271 }272 else273 {274 this->glmis->loadParams(element);275 this->glmis->draw();276 }277 this->glmis->draw();278 279 280 281 ////////////////////////////282 // Loading Spawning Point //283 ////////////////////////////284 element = root->FirstChildElement("SpawningPoints");285 if( element == NULL)286 {287 PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n");288 }289 else290 {291 element = element->FirstChildElement();292 // load Players/Objects/Whatever293 PRINTF(4)("Loading Spawning Points\n");294 while( element != NULL)295 {296 BaseObject* created = Factory::fabricate(element);297 if( created != NULL )298 {299 // if(created->isA(CL_SPAWNING_POINT))300 // this->spawn(dynamic_cast<WorldEntity*>(created));301 printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName());302 }303 304 305 element = element->NextSiblingElement();306 glmis->step(); //! @todo temporary307 }308 PRINTF(4)("Done loading NetworkWorldEntities\n");309 }310 311 312 ////////////////////////313 // find WorldEntities //314 ////////////////////////315 element = root->FirstChildElement("WorldEntities");316 if( element == NULL)317 {318 PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n");319 }320 else321 {322 element = element->FirstChildElement();323 // load Players/Objects/Whatever324 PRINTF(4)("Loading NetworkWorldEntities\n");325 while( element != NULL)326 {327 if( NetworkManager::getInstance()->isGameServer())328 {329 330 BaseObject* created = NetworkGameManager::getInstance()->createEntity(element);331 if( created != NULL )332 {333 // if(created->isA(CL_WORLD_ENTITY))334 // this->spawn(dynamic_cast<WorldEntity*>(created));335 printf("Created a %s: %s\n", created->getClassName(), created->getName());336 }337 else338 PRINTF(1)("NetworkWorld: could not create this entity\n");339 340 // if we load a 'Player' we use it as localPlayer341 342 343 //todo do this more elegant344 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))345 sky = dynamic_cast<WorldEntity*>(created);346 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))347 {348 terrain = dynamic_cast<Terrain*>(created);349 CDEngine::getInstance()->setTerrain(terrain);350 351 }352 353 }354 else if( /* !strcmp( element->Value(), "SkyBox") || */ /* !strcmp( element->Value(), "Terrain") || */ !strcmp( element->Value(), "SpaceShip"))355 {356 BaseObject* created = Factory::fabricate(element);357 if( created != NULL )358 {359 // if(created->isA(CL_WORLD_ENTITY))360 // this->spawn(dynamic_cast<WorldEntity*>(created));361 printf("Created a %s: %s\n", created->getClassName(), created->getName());362 }363 else364 PRINTF(1)("NetworkWorld: could not create this entity\n");365 366 // if we load a 'Player' we use it as localPlayer367 368 369 //todo do this more elegant370 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))371 sky = dynamic_cast<WorldEntity*>(created);372 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))373 {374 terrain = dynamic_cast<Terrain*>(created);375 CDEngine::getInstance()->setTerrain(terrain);376 }377 }378 element = element->NextSiblingElement();379 glmis->step(); //! @todo temporary380 PRINTF(4)("Done loading NetworkWorldEntities\n");381 }382 }383 384 385 //////////////////////////////386 // LOADING ADDITIONAL STUFF //387 //////////////////////////////388 389 LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams);390 391 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);392 // LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);393 394 // free the XML data395 396 delete XMLDoc;397 /* GENERIC LOADING PROCESS FINISHED */398 399 400 // Create a Player401 this->localPlayer = new Player();402 403 Playable* playable;404 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);405 if (playableList != NULL)406 {407 playable = dynamic_cast<Playable*>(playableList->front());408 this->localPlayer->setControllable(playable);409 }410 411 412 // //localCamera->setParent(TrackNode::getInstance());413 // tn->addChild(this->localCamera);414 localCamera->setClipRegion(1, 10000.0);415 // localCamera->lookAt(playable);416 // this->localPlayer->setParentMode(PNODE_ALL);417 if (this->sky != NULL)418 {419 this->localCamera->addChild(sky);420 }421 SoundEngine::getInstance()->setListener(this->localCamera);422 423 424 425 ////////////426 // STATIC //427 ////////////428 429 430 // TestEntity* testEntity = new TestEntity();431 // testEntity->setRelCoor(Vector(570, 10, -15));432 // testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));433 // this->spawn(testEntity);434 435 // for(int i = 0; i < 100; i++)436 // {437 // WorldEntity* tmp = NetworkGameManager::;438 // char npcChar[10];439 // sprintf (npcChar, "NPC_%d", i);440 // tmp->setName(npcChar);441 // tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);442 // this->spawn(tmp);443 // }444 445 this->music = NULL;446 //(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);447 //music->playback();448 }449 450 ErrorMessage NetworkWorld::postLoad()451 {452 /*monitor progress*/453 this->glmis->step();454 // stuff beyond this point remains to be loaded properly455 456 // LIGHT initialisation457 LightManager::getInstance()->setAmbientColor(.1,.1,.1);458 // LightManager::getInstance()->addLight();459 LightManager::getInstance()->debug();460 461 this->releaseLoadScreen();462 162 } 463 163 464 164 465 165 /** 466 * initializes a new NetworkWorld shortly before start 467 * 468 * this is the function, that will be loaded shortly before the world is 469 * started 470 */ 471 ErrorMessage NetworkWorld::preStart() 166 * post loads the GameWorld by initializing all resources, and set their default values. 167 */ 168 ErrorMessage GameWorld::postLoad() 472 169 { 473 this->bPause = false;170 static_cast<GameWorld*>(this)->postLoad(); 474 171 475 /* update the object position before game start - so there are no wrong coordinates used in the first processing */ 476 PNode::getNullParent()->updateNode (0.001f); 477 PNode::getNullParent()->updateNode (0.001f); 172 /* the single player specific stuff here */ 478 173 } 479 174 480 481 /**482 * starts the NetworkWorld483 */484 ErrorMessage NetworkWorld::start()485 {486 this->bQuitWorld = false;487 this->mainLoop();488 }489 490 /**491 * stops the world.492 493 This happens, when the player decides to end the Level.494 */495 ErrorMessage NetworkWorld::stop()496 {497 PRINTF(3)("NetworkWorld::stop() - got stop signal\n");498 this->bQuitWorld= true;499 }500 501 /**502 * pauses the Game503 */504 ErrorMessage NetworkWorld::pause()505 {506 this->isPaused = true;507 }508 509 /**510 * ends the pause Phase511 */512 ErrorMessage NetworkWorld::resume()513 {514 this->isPaused = false;515 }516 517 /**518 * destroys the NetworkWorld519 */520 ErrorMessage NetworkWorld::destroy()521 {522 523 }524 525 /**526 * shows the loading screen527 */528 void NetworkWorld::displayLoadScreen ()529 {530 PRINTF(3)("NetworkWorld::displayLoadScreen - start\n");531 532 //GLMenuImageScreen*533 this->glmis = new GLMenuImageScreen();534 this->glmis->setMaximum(8);535 536 PRINTF(3)("NetworkWorld::displayLoadScreen - end\n");537 }538 539 /**540 * @brief removes the loadscreen, and changes over to the game541 *542 * @todo take out the delay543 */544 void NetworkWorld::releaseLoadScreen ()545 {546 PRINTF(3)("NetworkWorld::releaseLoadScreen - start\n");547 this->glmis->setValue(this->glmis->getMaximum());548 PRINTF(3)("NetworkWorld::releaseLoadScreen - end\n");549 delete this->glmis;550 }551 552 553 /**554 * this returns the current game time555 * @returns elapsed game time556 */557 double NetworkWorld::getGameTime()558 {559 return this->gameTime;560 }561 562 /**563 \brief main loop of the world: executing all world relevant function564 in this loop we synchronize (if networked), handle input events, give the heart-beat to565 all other member-entities of the world (tick to player, enemies etc.), checking for566 collisions drawing everything to the screen.567 */568 void NetworkWorld::mainLoop()569 {570 this->lastFrame = SDL_GetTicks ();571 PRINTF(3)("World::mainLoop() - Entering main loop\n");572 573 while(!this->bQuitWorld) /* @todo implement pause */574 {575 ++this->cycle;576 // Network577 this->synchronize ();578 // Process input579 this->handleInput ();580 if( this->bQuitWorld)581 break;582 // Process time583 this->tick ();584 // Process collision585 this->collide ();586 // Update the state587 this->update ();588 // Draw589 this->display ();590 }591 592 PRINTF(3)("NetworkWorld::mainLoop() - Exiting the main loop\n");593 }594 595 596 /**597 * synchronize local data with remote data598 */599 void NetworkWorld::synchronize ()600 {601 // Get remote input602 // Update synchronizables603 NetworkManager::getInstance()->synchronize();604 }605 606 607 /**608 * run all input processing609 610 the command node is the central input event dispatcher. the node uses the even-queue from611 sdl and has its own event-passing-queue.612 */613 void NetworkWorld::handleInput ()614 {615 EventHandler::getInstance()->process();616 617 // remoteinput618 }619 620 void NetworkWorld::tick(std::list<WorldEntity*> entityList, float dt)621 {622 std::list<WorldEntity*>::iterator entity;623 for (entity = entityList.begin(); entity != entityList.end(); entity++)624 (*entity)->tick(dt);625 626 }627 628 /**629 * advance the timeline630 631 this calculates the time used to process one frame (with all input handling, drawing, etc)632 the time is mesured in ms and passed to all world-entities and other classes that need633 a heart-beat.634 */635 void NetworkWorld::tick ()636 {637 Uint32 currentFrame = SDL_GetTicks();638 if(!this->bPause)639 {640 this->dt = currentFrame - this->lastFrame;641 642 if( this->dt > 10)643 {644 float fps = 1000/dt;645 646 // temporary, only for showing how fast the text-engine is647 char tmpChar[20];648 sprintf(tmpChar, "fps: %4.0f", fps);649 }650 else651 {652 /* the frame-rate is limited to 100 frames per second, all other things are for653 nothing.654 */655 PRINTF(3)("fps = 1000 - frame rate is adjusted\n");656 SDL_Delay(10-dt);657 this->dt = 10;658 }659 660 this->dtS = (float)this->dt / 1000.0 * this->speed;661 this->gameTime += this->dtS;662 663 this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);664 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);665 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);666 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);667 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);668 669 /* update tick the rest */670 this->localCamera->tick(this->dtS);671 // tick the engines672 AnimationPlayer::getInstance()->tick(this->dtS);673 // if (this->cycle > 5)674 PhysicsEngine::getInstance()->tick(this->dtS);675 676 ParticleEngine::getInstance()->tick(this->dtS);677 678 679 /** actualy the Graphics Engine should tick the world not the other way around...680 but since we like the things not too complicated we got it this way around681 until there is need or time to do it the other way around.682 @todo: GraphicsEngine ticks world: separation of processes and data...683 684 bensch: in my opinion the GraphicsEngine could draw the world, but not tick it,685 beceause graphics have nothing(or at least not much) to do with Motion.686 */687 GraphicsEngine::getInstance()->tick(this->dtS);688 }689 this->lastFrame = currentFrame;690 }691 692 693 /**694 * this function gives the world a consistant state695 696 after ticking (updating the world state) this will give a constistant697 state to the whole system.698 */699 void NetworkWorld::update()700 {701 GraphicsEngine::getInstance()->update(this->dtS);702 PNode::getNullParent()->updateNode (this->dtS);703 SoundEngine::getInstance()->update();704 //music->update();705 }706 707 708 void NetworkWorld::collide()709 {710 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),711 this->objectManager.getObjectList(OM_GROUP_01_PROJ));712 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),713 this->objectManager.getObjectList(OM_COMMON));714 }715 716 /**717 * render the current frame718 719 clear all buffers and draw the world720 */721 void NetworkWorld::display ()722 {723 // clear buffer724 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);725 // set camera726 this->localCamera->apply ();727 // draw world728 this->draw();729 // draw HUD730 /** @todo draw HUD */731 // flip buffers732 GraphicsEngine::swapBuffers();733 //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();734 //SDL_Flip (screen);735 }736 737 738 /**739 * runs through all entities calling their draw() methods740 */741 void NetworkWorld::draw ()742 {743 GraphicsEngine* engine = GraphicsEngine::getInstance();744 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));745 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));746 engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));747 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));748 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));749 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));750 751 if( unlikely( this->showBV)) // to draw the bounding boxes of the objects at level 2 for debug purp752 {753 CDEngine* engine = CDEngine::getInstance();754 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));755 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON));756 engine->drawBV(State::getObjectManager()->getObjectList(OM_COMMON));757 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_00));758 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01));759 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));760 }761 762 // {763 // if( entity->isVisible() ) entity->draw();764 //FIXME765 // entity = iterator->nextElement();766 // }767 768 ParticleEngine::getInstance()->draw();769 770 if (unlikely(this->showPNodes))771 PNode::getNullParent()->debugDraw(0);772 773 engine->draw();774 //TextEngine::getInstance()->draw();775 }776 777 void NetworkWorld::setPath( const char* name)778 {779 if (this->path)780 delete this->path;781 if (ResourceManager::isFile(name))782 {783 this->path = new char[strlen(name)+1];784 strcpy(this->path, name);785 }786 else787 {788 this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];789 sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);790 }791 }792 793 const char* NetworkWorld::getPath( void)794 {795 return path;796 }
Note: See TracChangeset
for help on using the changeset viewer.