Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

trunk: merged the network branche back to trunk

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