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 | |
---|
16 | #include "network_node.h" |
---|
17 | |
---|
18 | |
---|
19 | #include "debug.h" |
---|
20 | |
---|
21 | |
---|
22 | /** |
---|
23 | * constructor |
---|
24 | */ |
---|
25 | NetworkNode::NetworkNode() |
---|
26 | { |
---|
27 | this->playerNumber = 0; |
---|
28 | this->nodeType = NET_CLIENT; |
---|
29 | } |
---|
30 | |
---|
31 | |
---|
32 | /** |
---|
33 | * deconstructor |
---|
34 | */ |
---|
35 | NetworkNode::~NetworkNode() |
---|
36 | {} |
---|
37 | |
---|
38 | |
---|
39 | /** |
---|
40 | * adds a client |
---|
41 | */ |
---|
42 | void NetworkNode::addClient(PeerInfo* node) |
---|
43 | { |
---|
44 | this->clientList.push_back(node); |
---|
45 | this->playerNumber++; |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * adds a proxy server |
---|
50 | */ |
---|
51 | void NetworkNode::addProxyServer(PeerInfo* node) |
---|
52 | { |
---|
53 | this->proxyServerList.push_back(node); |
---|
54 | this->playerNumber++; |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * adds a master server |
---|
59 | */ |
---|
60 | void NetworkNode::addMasterServer(PeerInfo* node) |
---|
61 | { |
---|
62 | this->masterServerList.push_back(node); |
---|
63 | this->playerNumber++; |
---|
64 | } |
---|
65 | |
---|
66 | /** |
---|
67 | * removes a client |
---|
68 | */ |
---|
69 | void NetworkNode::removeClient(PeerInfo* node) |
---|
70 | { |
---|
71 | std::list<PeerInfo*>::iterator it = this->clientList.begin(); |
---|
72 | for(; it != this->clientList.end(); it++) |
---|
73 | { |
---|
74 | if( *it == node) |
---|
75 | { |
---|
76 | this->clientList.erase(it); |
---|
77 | this->playerNumber--; |
---|
78 | return; |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | PRINTF(2)("Could not remove client from the list, very strange..."); |
---|
83 | } |
---|
84 | |
---|
85 | /** |
---|
86 | * removes a proxy server |
---|
87 | */ |
---|
88 | void NetworkNode::removeProxyServer(PeerInfo* node) |
---|
89 | { |
---|
90 | std::list<PeerInfo*>::iterator it = this->proxyServerList.begin(); |
---|
91 | for(; it != this->proxyServerList.end(); it++) |
---|
92 | { |
---|
93 | if( *it == node) |
---|
94 | { |
---|
95 | this->proxyServerList.erase(it); |
---|
96 | this->playerNumber--; |
---|
97 | return; |
---|
98 | } |
---|
99 | } |
---|
100 | |
---|
101 | PRINTF(2)("Could not remove proxy server from the list, very strange..."); |
---|
102 | } |
---|
103 | |
---|
104 | /** |
---|
105 | * removes a master server |
---|
106 | */ |
---|
107 | void NetworkNode::removeMasterServer(PeerInfo* node) |
---|
108 | { |
---|
109 | std::list<PeerInfo*>::iterator it = this->masterServerList.begin(); |
---|
110 | for(; it != this->masterServerList.end(); it++) |
---|
111 | { |
---|
112 | if( *it == node) |
---|
113 | { |
---|
114 | this->masterServerList.erase(it); |
---|
115 | this->playerNumber--; |
---|
116 | return; |
---|
117 | } |
---|
118 | } |
---|
119 | |
---|
120 | PRINTF(2)("Could not remove client from the list, very strange..."); |
---|
121 | } |
---|