[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 | |
---|
[6404] | 33 | using namespace std; |
---|
[6366] | 34 | |
---|
| 35 | |
---|
[6498] | 36 | //! Register a command to print some multiplayer world infos |
---|
| 37 | SHELL_COMMAND(debug, MultiPlayerWorld, debug); |
---|
| 38 | |
---|
| 39 | |
---|
[6358] | 40 | //! This creates a Factory to fabricate a MultiPlayerWorld |
---|
[6361] | 41 | CREATE_FACTORY(MultiPlayerWorld, CL_MULTI_PLAYER_WORLD); |
---|
[6139] | 42 | |
---|
[6361] | 43 | |
---|
[6358] | 44 | MultiPlayerWorld::MultiPlayerWorld(const TiXmlElement* root) |
---|
[6989] | 45 | : GameWorld() |
---|
[6139] | 46 | { |
---|
[6402] | 47 | this->setClassID(CL_MULTI_PLAYER_WORLD, "MultiPlayerWorld"); |
---|
| 48 | |
---|
[6408] | 49 | this->dataTank = new MultiPlayerWorldData(); |
---|
| 50 | |
---|
[6139] | 51 | this->loadParams(root); |
---|
| 52 | } |
---|
| 53 | |
---|
[6361] | 54 | |
---|
[6139] | 55 | /** |
---|
[6358] | 56 | * remove the MultiPlayerWorld from memory |
---|
[6345] | 57 | * |
---|
| 58 | * delete everything explicitly, that isn't contained in the parenting tree! |
---|
| 59 | * things contained in the tree are deleted automaticaly |
---|
[6139] | 60 | */ |
---|
[6358] | 61 | MultiPlayerWorld::~MultiPlayerWorld () |
---|
[6139] | 62 | { |
---|
[6358] | 63 | PRINTF(3)("MultiPlayerWorld::~MultiPlayerWorld() - deleting current world\n"); |
---|
[7287] | 64 | if( this->dataTank) |
---|
| 65 | delete this->dataTank; |
---|
[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] | 73 | void 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 | */ |
---|
| 86 | void 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 | */ |
---|
| 95 | void MultiPlayerWorld::collisionDetection() |
---|
| 96 | { |
---|
[9008] | 97 | //CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), this->dataTank->objectManager->getObjectList(OM_PLAYERS)); |
---|
| 98 | |
---|
| 99 | PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_PLAYERS_PROJ\n\n"); |
---|
| 100 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ), |
---|
| 101 | this->dataTank->objectManager->getObjectList(OM_PLAYERS)); |
---|
| 102 | PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n"); |
---|
[8068] | 103 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), |
---|
[9008] | 104 | this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ)); |
---|
| 105 | PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n"); |
---|
[8068] | 106 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), |
---|
[9008] | 107 | this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ)); |
---|
[8894] | 108 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), |
---|
[9008] | 109 | this->dataTank->objectManager->getObjectList(OM_GROUP_00)); |
---|
[8894] | 110 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), |
---|
[9008] | 111 | this->dataTank->objectManager->getObjectList(OM_GROUP_01)); |
---|
[8894] | 112 | |
---|
[9008] | 113 | |
---|
| 114 | |
---|
| 115 | PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_00 vs OM_GROUP_01_PROJ\n\n"); |
---|
[8068] | 116 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), |
---|
| 117 | this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ)); |
---|
[9008] | 118 | PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_00 vs OM_GROUP_01\n\n"); |
---|
[8068] | 119 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), |
---|
| 120 | this->dataTank->objectManager->getObjectList(OM_GROUP_01)); |
---|
[9008] | 121 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), |
---|
| 122 | this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ)); |
---|
[8068] | 123 | |
---|
[9008] | 124 | PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_01 vs OM_GROUP_00_PROJ\n\n"); |
---|
[8068] | 125 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01), |
---|
[9008] | 126 | this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ)); |
---|
| 127 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01), |
---|
| 128 | this->dataTank->objectManager->getObjectList(OM_GROUP_00)); |
---|
| 129 | CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01), |
---|
| 130 | this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ)); |
---|
[9110] | 131 | |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | // ground collision detection: BSP Model |
---|
| 135 | CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_GROUP_00)); |
---|
| 136 | CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_GROUP_01)); |
---|
| 137 | CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_PLAYERS)); |
---|
[8068] | 138 | } |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | /** |
---|
[6498] | 142 | * some debug ouptut - shell command |
---|
| 143 | */ |
---|
| 144 | void MultiPlayerWorld::debug() |
---|
| 145 | { |
---|
| 146 | ((MultiPlayerWorldData*)this->dataTank)->debug(); |
---|
[6512] | 147 | } |
---|
[8228] | 148 | |
---|
| 149 | /** |
---|
| 150 | * cleanup |
---|
[8717] | 151 | * @return |
---|
[8228] | 152 | */ |
---|
| 153 | ErrorMessage MultiPlayerWorld::unloadData( ) |
---|
| 154 | { |
---|
[8717] | 155 | |
---|
[8228] | 156 | GameWorld::unloadData(); |
---|
[8717] | 157 | |
---|
[8228] | 158 | delete NetworkManager::getInstance(); |
---|
| 159 | delete NetworkGameManager::getInstance(); |
---|
| 160 | |
---|
[9059] | 161 | State::setOnline( false ); |
---|
[9110] | 162 | |
---|
[8717] | 163 | return ErrorMessage(); |
---|
[8228] | 164 | } |
---|