| 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 "factory.h" |
|---|
| 22 | #include "load_param.h" |
|---|
| 23 | |
|---|
| 24 | #include "network_manager.h" |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | using namespace std; |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | //! This creates a Factory to fabricate a MultiPlayerWorld |
|---|
| 31 | CREATE_FACTORY(MultiPlayerWorld, CL_MULTI_PLAYER_WORLD); |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | MultiPlayerWorld::MultiPlayerWorld(const TiXmlElement* root) |
|---|
| 35 | : GameWorld(root) |
|---|
| 36 | { |
|---|
| 37 | this->setClassID(CL_MULTI_PLAYER_WORLD, "MultiPlayerWorld"); |
|---|
| 38 | |
|---|
| 39 | this->dataTank = new MultiPlayerWorldData(); |
|---|
| 40 | |
|---|
| 41 | this->loadParams(root); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * remove the MultiPlayerWorld from memory |
|---|
| 47 | * |
|---|
| 48 | * delete everything explicitly, that isn't contained in the parenting tree! |
|---|
| 49 | * things contained in the tree are deleted automaticaly |
|---|
| 50 | */ |
|---|
| 51 | MultiPlayerWorld::~MultiPlayerWorld () |
|---|
| 52 | { |
|---|
| 53 | PRINTF(3)("MultiPlayerWorld::~MultiPlayerWorld() - deleting current world\n"); |
|---|
| 54 | if( this->dataTank) |
|---|
| 55 | delete this->dataTank; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | /** |
|---|
| 60 | * loads the parameters of a MultiPlayerWorld from an XML-element |
|---|
| 61 | * @param root the XML-element to load from |
|---|
| 62 | */ |
|---|
| 63 | void MultiPlayerWorld::loadParams(const TiXmlElement* root) |
|---|
| 64 | { |
|---|
| 65 | static_cast<GameWorld*>(this)->loadParams(root); |
|---|
| 66 | |
|---|
| 67 | PRINTF(4)("Creating a MultiPlayerWorld\n"); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | /** |
|---|
| 72 | * synchronizes the network since this is a network world |
|---|
| 73 | * |
|---|
| 74 | * this function overrides the synchrinize from the GameWorld |
|---|
| 75 | */ |
|---|
| 76 | void MultiPlayerWorld::synchronize() |
|---|
| 77 | { |
|---|
| 78 | NetworkManager::getInstance()->synchronize(); |
|---|
| 79 | } |
|---|
| 80 | |
|---|