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