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 | * ... |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | // |
---|
30 | // C++ Interface: ClientInformation |
---|
31 | // |
---|
32 | // Description: |
---|
33 | // |
---|
34 | // |
---|
35 | // Author: <>, (C) 2007 |
---|
36 | // |
---|
37 | // Copyright: See COPYING file that comes with this distribution |
---|
38 | // |
---|
39 | // |
---|
40 | #ifndef _ClientInformation_H__ |
---|
41 | #define _ClientInformation_H__ |
---|
42 | |
---|
43 | #include "NetworkPrereqs.h" |
---|
44 | |
---|
45 | #include <enet/enet.h> |
---|
46 | |
---|
47 | #define GAMESTATEID_INITIAL -1 |
---|
48 | #define CLIENTID_UNKNOWN -2 |
---|
49 | |
---|
50 | namespace network |
---|
51 | { |
---|
52 | /** |
---|
53 | * This class implements a list for client informations |
---|
54 | * @author Oliver Scheuss |
---|
55 | */ |
---|
56 | class ClientInformation{ |
---|
57 | public: |
---|
58 | ClientInformation(); |
---|
59 | ClientInformation(bool head); |
---|
60 | // ClientInformation(ClientInformation *prev, ClientInformation *next); |
---|
61 | // ClientInformation(ClientInformation *prev); |
---|
62 | ~ClientInformation(); |
---|
63 | ClientInformation *next(); |
---|
64 | ClientInformation *prev(); |
---|
65 | bool setNext(ClientInformation *next); |
---|
66 | bool setPrev(ClientInformation *prev); |
---|
67 | ClientInformation *insertAfter(ClientInformation *ins); |
---|
68 | ClientInformation *insertBefore(ClientInformation *ins); |
---|
69 | ClientInformation *insertBack(ClientInformation *ins); |
---|
70 | |
---|
71 | // set functions |
---|
72 | void setID(int clientID); |
---|
73 | bool setPeer(ENetPeer *peer); |
---|
74 | bool setGamestateID(int id); |
---|
75 | inline void setShipID(int id){ShipID_=id;} |
---|
76 | |
---|
77 | // get functions |
---|
78 | inline int getShipID(){return ShipID_;} |
---|
79 | int getID(); |
---|
80 | int getGamestateID(); |
---|
81 | ENetPeer *getPeer(); |
---|
82 | |
---|
83 | |
---|
84 | bool removeClient(int clientID); |
---|
85 | bool removeClient(ENetPeer *peer); |
---|
86 | //## add bool mask-function eventually |
---|
87 | ClientInformation *findClient(int clientID, bool look_backwards=false); |
---|
88 | //## add bool mask-function eventually |
---|
89 | ClientInformation *findClient(ENetAddress *address, bool look_backwards=false); |
---|
90 | |
---|
91 | bool setSynched(bool s); |
---|
92 | bool getSynched(); |
---|
93 | |
---|
94 | bool head; |
---|
95 | unsigned short failures_; |
---|
96 | |
---|
97 | private: |
---|
98 | ClientInformation *preve; |
---|
99 | ClientInformation *nexte; |
---|
100 | //actual information: |
---|
101 | ENetPeer *peer_; |
---|
102 | int clientID_; |
---|
103 | int gamestateID_; |
---|
104 | int ShipID_; // this is the unique objectID |
---|
105 | bool synched_; |
---|
106 | }; |
---|
107 | |
---|
108 | } |
---|
109 | |
---|
110 | #endif /* _ClientInformation_H__ */ |
---|