Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/story_entities/multi_player_world.cc @ 6387

Last change on this file since 6387 was 6387, checked in by patrick, 18 years ago

network: much more work on the StoryEntity functions and reimplementations of the DataTanks of each StoryEntity

File size: 6.1 KB
Line 
1/*
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.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
16
17#include "multi_player_world.h"
18
19#include "state.h"
20#include "class_list.h"
21
22#include "load_param.h"
23#include "fast_factory.h"
24#include "factory.h"
25
26
27#include "shell_command.h"
28#include "resource_manager.h"
29#include "state.h"
30
31#include "game_loader.h"
32#include "glmenu_imagescreen.h"
33
34#include "p_node.h"
35#include "world_entity.h"
36#include "player.h"
37#include "camera.h"
38#include "environment.h"
39#include "terrain.h"
40
41
42
43
44using namespace std;
45
46//! This creates a Factory to fabricate a MultiPlayerWorld
47CREATE_FACTORY(MultiPlayerWorld, CL_MULTI_PLAYER_WORLD);
48
49
50MultiPlayerWorld::MultiPlayerWorld(const TiXmlElement* root)
51  : GameWorld(root)
52{
53  this->constuctorInit("", -1);
54  this->path = NULL;
55
56  this->loadParams(root);
57}
58
59
60/**
61 *  remove the MultiPlayerWorld from memory
62 *
63 *  delete everything explicitly, that isn't contained in the parenting tree!
64 *  things contained in the tree are deleted automaticaly
65 */
66MultiPlayerWorld::~MultiPlayerWorld ()
67{
68  PRINTF(3)("MultiPlayerWorld::~MultiPlayerWorld() - deleting current world\n");
69}
70
71
72/**
73 * initializes the world.
74 * @param name the name of the world
75 * @param worldID the ID of this world
76 *
77 * set all stuff here that is world generic and does not use to much memory
78 * because the real init() function StoryEntity::init() will be called
79 * shortly before start of the game.
80 * since all worlds are initiated/referenced before they will be started.
81 * NO LEVEL LOADING HERE - NEVER!
82*/
83void MultiPlayerWorld::constuctorInit(const char* name, int worldID)
84{
85  this->setClassID(CL_MULTI_PLAYER_WORLD, "MultiPlayerWorld");
86  this->setName(name);
87
88  this->gameTime = 0.0f;
89  this->setSpeed(1.0);
90  this->music = NULL;
91  this->shell = NULL;
92
93  this->showPNodes = false;
94  this->showBV = false;
95}
96
97
98/**
99 * loads the parameters of a MultiPlayerWorld from an XML-element
100 * @param root the XML-element to load from
101 */
102void MultiPlayerWorld::loadParams(const TiXmlElement* root)
103{
104  static_cast<GameWorld*>(this)->loadParams(root);
105
106  PRINTF(4)("Creating a MultiPlayerWorld\n");
107}
108
109
110
111
112/**
113 *  loads the GameWorld by initializing all resources, and set their default values.
114 */
115ErrorMessage MultiPlayerWorld::load()
116{
117
118  ////////////////////////////
119  // Loading Spawning Point //
120  ////////////////////////////
121//   element = root->FirstChildElement("SpawningPoints");
122//   if( element == NULL)
123//   {
124//     PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n");
125//   }
126//   else
127//   {
128//     element = element->FirstChildElement();
129//       // load Players/Objects/Whatever
130//     PRINTF(4)("Loading Spawning Points\n");
131//     while( element != NULL)
132//     {
133//       BaseObject* created = Factory::fabricate(element);
134//       if( created != NULL )
135//       {
136// //        if(created->isA(CL_SPAWNING_POINT))
137// //          this->spawn(dynamic_cast<WorldEntity*>(created));
138//         printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName());
139//       }
140//
141//
142//       element = element->NextSiblingElement();
143//       glmis->step(); //! @todo temporary
144//     }
145//     PRINTF(4)("Done loading NetworkWorldEntities\n");
146//   }
147//
148//
149//   ////////////////////////
150//   // find WorldEntities //
151//   ////////////////////////
152//   element = root->FirstChildElement("WorldEntities");
153//   if( element == NULL)
154//   {
155//     PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n");
156//   }
157//   else
158//   {
159//     element = element->FirstChildElement();
160//       // load Players/Objects/Whatever
161//     PRINTF(4)("Loading NetworkWorldEntities\n");
162//     while( element != NULL)
163//     {
164//       if( NetworkManager::getInstance()->isGameServer())
165//       {
166//
167//         BaseObject* created = NetworkGameManager::getInstance()->createEntity(element);
168//         if( created != NULL )
169//         {
170// //          if(created->isA(CL_WORLD_ENTITY))
171// //            this->spawn(dynamic_cast<WorldEntity*>(created));
172//           printf("Created a %s: %s\n", created->getClassName(), created->getName());
173//         }
174//         else
175//           PRINTF(1)("NetworkWorld: could not create this entity\n");
176//
177//           // if we load a 'Player' we use it as localPlayer
178//
179//
180//           //todo do this more elegant
181//         if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
182//           sky = dynamic_cast<WorldEntity*>(created);
183//         if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
184//         {
185//           terrain = dynamic_cast<Terrain*>(created);
186//           CDEngine::getInstance()->setTerrain(terrain);
187//
188//         }
189//
190//       }
191//       else if( /* !strcmp( element->Value(), "SkyBox") || */ /* !strcmp( element->Value(), "Terrain") || */ !strcmp( element->Value(), "SpaceShip"))
192//       {
193//         BaseObject* created = Factory::fabricate(element);
194//         if( created != NULL )
195//         {
196// //          if(created->isA(CL_WORLD_ENTITY))
197// //            this->spawn(dynamic_cast<WorldEntity*>(created));
198//           printf("Created a %s: %s\n", created->getClassName(), created->getName());
199//         }
200//         else
201//           PRINTF(1)("NetworkWorld: could not create this entity\n");
202//
203//           // if we load a 'Player' we use it as localPlayer
204//
205//
206//           //todo do this more elegant
207//         if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
208//           sky = dynamic_cast<WorldEntity*>(created);
209//         if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
210//         {
211//           terrain = dynamic_cast<Terrain*>(created);
212//           CDEngine::getInstance()->setTerrain(terrain);
213//         }
214//       }
215//       element = element->NextSiblingElement();
216//       glmis->step(); //! @todo temporary
217//       PRINTF(4)("Done loading NetworkWorldEntities\n");
218//     }
219  }
220
221
222
223
Note: See TracBrowser for help on using the repository browser.