Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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