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