Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

network: digging deeper to bring more sense into the framework

File size: 6.2 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  this->localPlayer = NULL;
93  this->localCamera = NULL;
94
95  this->showPNodes = false;
96  this->showBV = false;
97}
98
99
100/**
101 * loads the parameters of a MultiPlayerWorld from an XML-element
102 * @param root the XML-element to load from
103 */
104void MultiPlayerWorld::loadParams(const TiXmlElement* root)
105{
106  static_cast<GameWorld*>(this)->loadParams(root);
107
108  PRINTF(4)("Creating a MultiPlayerWorld\n");
109}
110
111
112
113
114/**
115 *  loads the GameWorld by initializing all resources, and set their default values.
116 */
117ErrorMessage MultiPlayerWorld::load()
118{
119
120  ////////////////////////////
121  // Loading Spawning Point //
122  ////////////////////////////
123//   element = root->FirstChildElement("SpawningPoints");
124//   if( element == NULL)
125//   {
126//     PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n");
127//   }
128//   else
129//   {
130//     element = element->FirstChildElement();
131//       // load Players/Objects/Whatever
132//     PRINTF(4)("Loading Spawning Points\n");
133//     while( element != NULL)
134//     {
135//       BaseObject* created = Factory::fabricate(element);
136//       if( created != NULL )
137//       {
138// //        if(created->isA(CL_SPAWNING_POINT))
139// //          this->spawn(dynamic_cast<WorldEntity*>(created));
140//         printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName());
141//       }
142//
143//
144//       element = element->NextSiblingElement();
145//       glmis->step(); //! @todo temporary
146//     }
147//     PRINTF(4)("Done loading NetworkWorldEntities\n");
148//   }
149//
150//
151//   ////////////////////////
152//   // find WorldEntities //
153//   ////////////////////////
154//   element = root->FirstChildElement("WorldEntities");
155//   if( element == NULL)
156//   {
157//     PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n");
158//   }
159//   else
160//   {
161//     element = element->FirstChildElement();
162//       // load Players/Objects/Whatever
163//     PRINTF(4)("Loading NetworkWorldEntities\n");
164//     while( element != NULL)
165//     {
166//       if( NetworkManager::getInstance()->isGameServer())
167//       {
168//
169//         BaseObject* created = NetworkGameManager::getInstance()->createEntity(element);
170//         if( created != NULL )
171//         {
172// //          if(created->isA(CL_WORLD_ENTITY))
173// //            this->spawn(dynamic_cast<WorldEntity*>(created));
174//           printf("Created a %s: %s\n", created->getClassName(), created->getName());
175//         }
176//         else
177//           PRINTF(1)("NetworkWorld: could not create this entity\n");
178//
179//           // if we load a 'Player' we use it as localPlayer
180//
181//
182//           //todo do this more elegant
183//         if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
184//           sky = dynamic_cast<WorldEntity*>(created);
185//         if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
186//         {
187//           terrain = dynamic_cast<Terrain*>(created);
188//           CDEngine::getInstance()->setTerrain(terrain);
189//
190//         }
191//
192//       }
193//       else if( /* !strcmp( element->Value(), "SkyBox") || */ /* !strcmp( element->Value(), "Terrain") || */ !strcmp( element->Value(), "SpaceShip"))
194//       {
195//         BaseObject* created = Factory::fabricate(element);
196//         if( created != NULL )
197//         {
198// //          if(created->isA(CL_WORLD_ENTITY))
199// //            this->spawn(dynamic_cast<WorldEntity*>(created));
200//           printf("Created a %s: %s\n", created->getClassName(), created->getName());
201//         }
202//         else
203//           PRINTF(1)("NetworkWorld: could not create this entity\n");
204//
205//           // if we load a 'Player' we use it as localPlayer
206//
207//
208//           //todo do this more elegant
209//         if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
210//           sky = dynamic_cast<WorldEntity*>(created);
211//         if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
212//         {
213//           terrain = dynamic_cast<Terrain*>(created);
214//           CDEngine::getInstance()->setTerrain(terrain);
215//         }
216//       }
217//       element = element->NextSiblingElement();
218//       glmis->step(); //! @todo temporary
219//       PRINTF(4)("Done loading NetworkWorldEntities\n");
220//     }
221  }
222
223
224
225
Note: See TracBrowser for help on using the repository browser.