[1168] | 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 | |
---|
[1232] | 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> |
---|
[1318] | 46 | #include <boost/thread/recursive_mutex.hpp> |
---|
[1232] | 47 | |
---|
| 48 | #define GAMESTATEID_INITIAL -1 |
---|
[1299] | 49 | #define CLIENTID_UNKNOWN -2 |
---|
[1232] | 50 | |
---|
| 51 | namespace network |
---|
| 52 | { |
---|
| 53 | /** |
---|
| 54 | * This class implements a list for client informations |
---|
| 55 | * @author Oliver Scheuss |
---|
| 56 | */ |
---|
| 57 | class ClientInformation{ |
---|
| 58 | public: |
---|
| 59 | ClientInformation(); |
---|
| 60 | ClientInformation(bool head); |
---|
| 61 | // ClientInformation(ClientInformation *prev, ClientInformation *next); |
---|
| 62 | // ClientInformation(ClientInformation *prev); |
---|
| 63 | ~ClientInformation(); |
---|
| 64 | ClientInformation *next(); |
---|
| 65 | ClientInformation *prev(); |
---|
| 66 | ClientInformation *insertBack(ClientInformation *ins); |
---|
| 67 | |
---|
| 68 | // set functions |
---|
| 69 | void setID(int clientID); |
---|
[1299] | 70 | bool setPeer(ENetPeer *peer); |
---|
| 71 | bool setGamestateID(int id); |
---|
[1232] | 72 | inline void setShipID(int id){ShipID_=id;} |
---|
| 73 | |
---|
| 74 | // get functions |
---|
| 75 | inline int getShipID(){return ShipID_;} |
---|
| 76 | int getID(); |
---|
| 77 | int getGamestateID(); |
---|
| 78 | ENetPeer *getPeer(); |
---|
[1318] | 79 | bool getHead(); |
---|
| 80 | void setHead(bool h); |
---|
[1232] | 81 | |
---|
[1318] | 82 | int getFailures(); |
---|
| 83 | void addFailure(); |
---|
| 84 | void resetFailures(); |
---|
[1232] | 85 | |
---|
| 86 | bool removeClient(int clientID); |
---|
| 87 | bool removeClient(ENetPeer *peer); |
---|
| 88 | //## add bool mask-function eventually |
---|
| 89 | ClientInformation *findClient(int clientID, bool look_backwards=false); |
---|
| 90 | //## add bool mask-function eventually |
---|
| 91 | ClientInformation *findClient(ENetAddress *address, bool look_backwards=false); |
---|
| 92 | |
---|
[1299] | 93 | bool setSynched(bool s); |
---|
[1232] | 94 | bool getSynched(); |
---|
| 95 | |
---|
| 96 | |
---|
[1318] | 97 | private: |
---|
| 98 | bool setNext(ClientInformation *next); |
---|
| 99 | bool setPrev(ClientInformation *prev); |
---|
| 100 | ClientInformation *insertAfter(ClientInformation *ins); |
---|
| 101 | ClientInformation *insertBefore(ClientInformation *ins); |
---|
| 102 | |
---|
[1232] | 103 | ClientInformation *preve; |
---|
| 104 | ClientInformation *nexte; |
---|
| 105 | //actual information: |
---|
| 106 | ENetPeer *peer_; |
---|
| 107 | int clientID_; |
---|
| 108 | int gamestateID_; |
---|
| 109 | int ShipID_; // this is the unique objectID |
---|
| 110 | bool synched_; |
---|
[1318] | 111 | bool head_; |
---|
| 112 | unsigned short failures_; |
---|
| 113 | static boost::recursive_mutex mutex_; |
---|
| 114 | |
---|
[1232] | 115 | }; |
---|
| 116 | |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | #endif /* _ClientInformation_H__ */ |
---|