Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/multi_player_world.cc @ 10606

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

merged network back to trunk

File size: 5.5 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
18#include "multi_player_world.h"
19#include "multi_player_world_data.h"
20
21#include "util/loading/factory.h"
22#include "util/loading/load_param.h"
23#include "shell_command.h"
24
25#include "cd_engine.h"
26
27#include "network_manager.h"
28#include "network_game_manager.h"
29
30#include "state.h"
31
32
33#include "glgui_handler.h"
34
35//! Register a command to print some multiplayer world infos
36SHELL_COMMAND(debug, MultiPlayerWorld, debug);
37
38
39//! This creates a Factory to fabricate a MultiPlayerWorld
40ObjectListDefinition(MultiPlayerWorld);
41CREATE_FACTORY(MultiPlayerWorld);
42
43MultiPlayerWorld::MultiPlayerWorld(const TiXmlElement* root)
44  : GameWorld()
45{
46  this->registerObject(this, MultiPlayerWorld::_objectList);
47
48  this->dataTank = new MultiPlayerWorldData();
49
50  this->loadParams(root);
51}
52
53
54/**
55 *  remove the MultiPlayerWorld from memory
56 *
57 *  delete everything explicitly, that isn't contained in the parenting tree!
58 *  things contained in the tree are deleted automaticaly
59 */
60MultiPlayerWorld::~MultiPlayerWorld ()
61{
62  PRINTF(3)("MultiPlayerWorld::~MultiPlayerWorld() - deleting current world\n");
63  if( this->dataTank)
64    delete this->dataTank;
65  OrxGui::GLGuiHandler::deleteInstance( );
66}
67
68
69/**
70 * loads the parameters of a MultiPlayerWorld from an XML-element
71 * @param root the XML-element to load from
72 */
73void MultiPlayerWorld::loadParams(const TiXmlElement* root)
74{
75  GameWorld::loadParams(root);
76
77  PRINTF(4)("Creating a MultiPlayerWorld\n");
78}
79
80
81/**
82 *  synchronizes the network since this is a network world
83 *
84 * this function overrides the synchrinize from the GameWorld
85 */
86void MultiPlayerWorld::synchronize()
87{
88  NetworkManager::getInstance()->synchronize(this->dtS);
89}
90
91
92/**
93 * kicks the CDEngine to detect the collisions between the object groups in the world
94 */
95void MultiPlayerWorld::collisionDetection()
96{
97  //CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_PLAYERS), this->dataTank->objectManager->getEntityList(OM_PLAYERS));
98
99  PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n");
100  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_PLAYERS),
101    this->dataTank->objectManager->getEntityList(OM_GROUP_00_PROJ));
102  PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n");
103  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_PLAYERS),
104    this->dataTank->objectManager->getEntityList(OM_GROUP_01_PROJ));
105  PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_PLAYERS_PROJ\n\n");
106  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_PLAYERS),
107    this->dataTank->objectManager->getEntityList(OM_PLAYERS_PROJ));
108
109  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_00),
110  this->dataTank->objectManager->getEntityList(OM_PLAYERS));
111  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
112  this->dataTank->objectManager->getEntityList(OM_PLAYERS));
113
114
115
116  PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_00 vs OM_GROUP_01_PROJ\n\n");
117  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_00),
118    this->dataTank->objectManager->getEntityList(OM_GROUP_01_PROJ));
119  PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_00 vs OM_GROUP_01\n\n");
120  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_00),
121    this->dataTank->objectManager->getEntityList(OM_GROUP_01));
122  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_00),
123    this->dataTank->objectManager->getEntityList(OM_PLAYERS_PROJ));
124
125  PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_01 vs OM_GROUP_00_PROJ\n\n");
126  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
127    this->dataTank->objectManager->getEntityList(OM_GROUP_00_PROJ));
128  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
129    this->dataTank->objectManager->getEntityList(OM_GROUP_00));
130  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getEntityList(OM_GROUP_01),
131    this->dataTank->objectManager->getEntityList(OM_PLAYERS_PROJ));
132
133
134
135    // ground collision detection: BSP Model
136  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getEntityList(OM_GROUP_00));
137  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getEntityList(OM_GROUP_01));
138  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getEntityList(OM_PLAYERS));
139}
140
141
142/**
143 * some debug ouptut - shell command
144 */
145void MultiPlayerWorld::debug()
146{
147  ((MultiPlayerWorldData*)this->dataTank)->debug();
148}
149
150/**
151 * cleanup
152 * @return
153 */
154ErrorMessage MultiPlayerWorld::unloadData( )
155{
156
157  GameWorld::unloadData();
158
159  delete NetworkManager::getInstance();
160  delete NetworkGameManager::getInstance();
161
162  State::setOnline( false );
163
164  return ErrorMessage();
165}
Note: See TracBrowser for help on using the repository browser.