Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/consolecommands2/src/libraries/network/FunctionCallManager.cc @ 7864

Last change on this file since 7864 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 6.7 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "FunctionCallManager.h"
30#include "packet/FunctionCalls.h"
31
32namespace orxonox {
33
34std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::clientMap_;
35
36// Static calls
37
38void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID)
39{
40  if(clientMap_.find(clientID)==clientMap_.end())
41  {
42    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
43    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
44  }
45  FunctionCallManager::clientMap_[clientID]->addCallStatic(functionID);
46}
47void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1)
48{
49  if(clientMap_.find(clientID)==clientMap_.end())
50  {
51    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
52    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
53  }
54  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1);
55}
56void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
57{
58  if(clientMap_.find(clientID)==clientMap_.end())
59  {
60    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
61    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
62  }
63  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);
64}
65void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
66{
67  if(clientMap_.find(clientID)==clientMap_.end())
68  {
69    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
70    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
71  }
72  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
73}
74void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
75{
76  if(clientMap_.find(clientID)==clientMap_.end())
77  {
78    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
79    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
80  }
81  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
82}
83void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
84{
85  if(clientMap_.find(clientID)==clientMap_.end())
86  {
87    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
88    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
89  }
90  FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
91}
92
93
94// MemberCalls
95
96void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID)
97{
98  if(clientMap_.find(clientID)==clientMap_.end())
99  {
100    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
101    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
102  }
103  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID);
104}
105void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1)
106{
107  if(clientMap_.find(clientID)==clientMap_.end())
108  {
109    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
110    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
111  }
112  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1);
113}
114void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
115{
116  if(clientMap_.find(clientID)==clientMap_.end())
117  {
118    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
119    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
120  }
121  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);
122}
123void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
124{
125  if(clientMap_.find(clientID)==clientMap_.end())
126  {
127    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
128    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
129  }
130  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
131}
132void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
133{
134  if(clientMap_.find(clientID)==clientMap_.end())
135  {
136    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
137    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
138  }
139  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
140}
141void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
142{
143  if(clientMap_.find(clientID)==clientMap_.end())
144  {
145    FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
146    FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
147  }
148  FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
149}
150
151// Send calls
152
153void FunctionCallManager::sendCalls()
154{
155  std::map<uint32_t, packet::FunctionCalls*>::iterator it;
156  for (it = FunctionCallManager::clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); it++ )
157  {
158    assert(!FunctionCallManager::clientMap_.empty());
159    it->second->send();
160  }
161  FunctionCallManager::clientMap_.clear();
162}
163
164
165} //namespace orxonox
Note: See TracBrowser for help on using the repository browser.