/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD #include "multi_player_world.h" #include "state.h" #include "class_list.h" #include "load_param.h" #include "fast_factory.h" #include "factory.h" #include "shell_command.h" #include "resource_manager.h" #include "state.h" #include "game_loader.h" #include "glmenu_imagescreen.h" #include "p_node.h" #include "world_entity.h" #include "player.h" #include "camera.h" #include "environment.h" #include "terrain.h" using namespace std; //! This creates a Factory to fabricate a MultiPlayerWorld CREATE_FACTORY(MultiPlayerWorld, CL_MULTI_PLAYER_WORLD); MultiPlayerWorld::MultiPlayerWorld(const TiXmlElement* root) : GameWorld(root) { this->constuctorInit("", -1); this->path = NULL; this->loadParams(root); } /** * remove the MultiPlayerWorld from memory * * delete everything explicitly, that isn't contained in the parenting tree! * things contained in the tree are deleted automaticaly */ MultiPlayerWorld::~MultiPlayerWorld () { PRINTF(3)("MultiPlayerWorld::~MultiPlayerWorld() - deleting current world\n"); } /** * initializes the world. * @param name the name of the world * @param worldID the ID of this world * * set all stuff here that is world generic and does not use to much memory * because the real init() function StoryEntity::init() will be called * shortly before start of the game. * since all worlds are initiated/referenced before they will be started. * NO LEVEL LOADING HERE - NEVER! */ void MultiPlayerWorld::constuctorInit(const char* name, int worldID) { this->setClassID(CL_MULTI_PLAYER_WORLD, "MultiPlayerWorld"); this->setName(name); this->gameTime = 0.0f; this->setSpeed(1.0); this->music = NULL; this->shell = NULL; this->showPNodes = false; this->showBV = false; } /** * loads the parameters of a MultiPlayerWorld from an XML-element * @param root the XML-element to load from */ void MultiPlayerWorld::loadParams(const TiXmlElement* root) { static_cast(this)->loadParams(root); PRINTF(4)("Creating a MultiPlayerWorld\n"); } /** * loads the GameWorld by initializing all resources, and set their default values. */ ErrorMessage MultiPlayerWorld::load() { //////////////////////////// // Loading Spawning Point // //////////////////////////// // element = root->FirstChildElement("SpawningPoints"); // if( element == NULL) // { // PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n"); // } // else // { // element = element->FirstChildElement(); // // load Players/Objects/Whatever // PRINTF(4)("Loading Spawning Points\n"); // while( element != NULL) // { // BaseObject* created = Factory::fabricate(element); // if( created != NULL ) // { // // if(created->isA(CL_SPAWNING_POINT)) // // this->spawn(dynamic_cast(created)); // printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName()); // } // // // element = element->NextSiblingElement(); // glmis->step(); //! @todo temporary // } // PRINTF(4)("Done loading NetworkWorldEntities\n"); // } // // // //////////////////////// // // find WorldEntities // // //////////////////////// // element = root->FirstChildElement("WorldEntities"); // if( element == NULL) // { // PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n"); // } // else // { // element = element->FirstChildElement(); // // load Players/Objects/Whatever // PRINTF(4)("Loading NetworkWorldEntities\n"); // while( element != NULL) // { // if( NetworkManager::getInstance()->isGameServer()) // { // // BaseObject* created = NetworkGameManager::getInstance()->createEntity(element); // if( created != NULL ) // { // // if(created->isA(CL_WORLD_ENTITY)) // // this->spawn(dynamic_cast(created)); // printf("Created a %s: %s\n", created->getClassName(), created->getName()); // } // else // PRINTF(1)("NetworkWorld: could not create this entity\n"); // // // if we load a 'Player' we use it as localPlayer // // // //todo do this more elegant // if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) // sky = dynamic_cast(created); // if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) // { // terrain = dynamic_cast(created); // CDEngine::getInstance()->setTerrain(terrain); // // } // // } // else if( /* !strcmp( element->Value(), "SkyBox") || */ /* !strcmp( element->Value(), "Terrain") || */ !strcmp( element->Value(), "SpaceShip")) // { // BaseObject* created = Factory::fabricate(element); // if( created != NULL ) // { // // if(created->isA(CL_WORLD_ENTITY)) // // this->spawn(dynamic_cast(created)); // printf("Created a %s: %s\n", created->getClassName(), created->getName()); // } // else // PRINTF(1)("NetworkWorld: could not create this entity\n"); // // // if we load a 'Player' we use it as localPlayer // // // //todo do this more elegant // if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) // sky = dynamic_cast(created); // if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) // { // terrain = dynamic_cast(created); // CDEngine::getInstance()->setTerrain(terrain); // } // } // element = element->NextSiblingElement(); // glmis->step(); //! @todo temporary // PRINTF(4)("Done loading NetworkWorldEntities\n"); // } }