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: Benjamin Wuest |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | |
---|
17 | /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module |
---|
18 | For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput |
---|
19 | */ |
---|
20 | #define DEBUG_MODULE_NETWORK |
---|
21 | |
---|
22 | #include "util/loading/factory.h" |
---|
23 | #include "state.h" |
---|
24 | #include "class_list.h" |
---|
25 | |
---|
26 | #include "network_stream.h" |
---|
27 | #include "shared_network_data.h" |
---|
28 | #include "converter.h" |
---|
29 | #include "message_manager.h" |
---|
30 | |
---|
31 | #include "playable.h" |
---|
32 | #include "player.h" |
---|
33 | |
---|
34 | #include "game_world.h" |
---|
35 | |
---|
36 | #include "game_rules.h" |
---|
37 | #include "network_game_rules.h" |
---|
38 | |
---|
39 | #include "network_game_manager.h" |
---|
40 | |
---|
41 | |
---|
42 | /* using namespace std is default, this needs to be here */ |
---|
43 | using namespace std; |
---|
44 | |
---|
45 | NetworkGameManager* NetworkGameManager::singletonRef = NULL; |
---|
46 | |
---|
47 | /*! |
---|
48 | * Standard constructor |
---|
49 | */ |
---|
50 | NetworkGameManager::NetworkGameManager() |
---|
51 | : Synchronizeable() |
---|
52 | { |
---|
53 | PRINTF(0)("START\n"); |
---|
54 | |
---|
55 | /* set the class id for the base object */ |
---|
56 | this->setClassID(CL_NETWORK_GAME_MANAGER, "NetworkGameManager"); |
---|
57 | |
---|
58 | this->setSynchronized(true); |
---|
59 | } |
---|
60 | |
---|
61 | /*! |
---|
62 | * Standard destructor |
---|
63 | */ |
---|
64 | NetworkGameManager::~NetworkGameManager() |
---|
65 | { |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | /** |
---|
70 | * insert new player into game |
---|
71 | * @param userId |
---|
72 | * @return |
---|
73 | */ |
---|
74 | bool NetworkGameManager::signalNewPlayer( int userId ) |
---|
75 | { |
---|
76 | assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) ); |
---|
77 | |
---|
78 | NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); |
---|
79 | |
---|
80 | int team = rules.getTeamForNewUser(); |
---|
81 | ClassID playableClassId = rules.getPlayableClassId( team ); |
---|
82 | std::string playableModel = rules.getPlayableModelFileName( team, playableClassId ); |
---|
83 | |
---|
84 | BaseObject * bo = Factory::fabricate( playableClassId ); |
---|
85 | |
---|
86 | assert( bo->isA( CL_PLAYABLE ) ); |
---|
87 | |
---|
88 | Playable & playable = *(dynamic_cast<Playable*>(bo)); |
---|
89 | |
---|
90 | playable.loadModel( playableModel ); |
---|
91 | |
---|
92 | PlayerStats * stats = rules.getNewPlayerStats( userId ); |
---|
93 | |
---|
94 | stats->setTeamId( team ); |
---|
95 | stats->setPlayableClassId( playableClassId ); |
---|
96 | stats->setPlayableUniqueId( playable.getUniqueID() ); |
---|
97 | stats->setModelFileName( playableModel ); |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | /** |
---|
102 | * remove player from game |
---|
103 | * @param userID |
---|
104 | * @return |
---|
105 | */ |
---|
106 | bool NetworkGameManager::signalLeftPlayer(int userID) |
---|
107 | { |
---|
108 | } |
---|
109 | |
---|
110 | |
---|
111 | |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | |
---|