Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9014 was 9008, checked in by bensch, 18 years ago

orxonox/trunk: merged the network bak to the trunk
merged with command:
svn merge -r8804:HEAD https://svn.orxonox.net/orxonox/branches/multi_player_map .

conflicts all resolved in favour of the branche

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