| [1505] | 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 | #include <boost/thread/recursive_mutex.hpp> |
|---|
| 47 | |
|---|
| [2371] | 48 | |
|---|
| [1505] | 49 | // WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE |
|---|
| 50 | |
|---|
| [2171] | 51 | namespace orxonox |
|---|
| [1505] | 52 | { |
|---|
| [2087] | 53 | |
|---|
| [1505] | 54 | /** |
|---|
| 55 | * This class implements a list for client informations |
|---|
| 56 | * @author Oliver Scheuss |
|---|
| 57 | */ |
|---|
| [2087] | 58 | class _NetworkExport ClientInformation{ |
|---|
| [1505] | 59 | public: |
|---|
| 60 | ClientInformation(); |
|---|
| 61 | // ClientInformation(ClientInformation *prev, ClientInformation *next); |
|---|
| 62 | // ClientInformation(ClientInformation *prev); |
|---|
| 63 | ~ClientInformation(); |
|---|
| 64 | ClientInformation *next(); |
|---|
| 65 | ClientInformation *prev(); |
|---|
| [1735] | 66 | static ClientInformation *insertBack(ClientInformation *ins); |
|---|
| [2087] | 67 | |
|---|
| [1505] | 68 | // set functions |
|---|
| 69 | void setID(int clientID); |
|---|
| 70 | bool setPeer(ENetPeer *peer); |
|---|
| [1735] | 71 | bool setGamestateID(int id); |
|---|
| [1505] | 72 | bool setPartialGamestateID(int id); |
|---|
| [1735] | 73 | inline void setShipID(unsigned int id){ShipID_=id;} |
|---|
| [2087] | 74 | |
|---|
| [1505] | 75 | // get functions |
|---|
| [1735] | 76 | inline unsigned int getShipID(){return ShipID_;} |
|---|
| [2087] | 77 | unsigned int getID(); |
|---|
| 78 | unsigned int getGamestateID(); |
|---|
| 79 | unsigned int getPartialGamestateID(); |
|---|
| [1505] | 80 | ENetPeer *getPeer(); |
|---|
| [2087] | 81 | |
|---|
| [1505] | 82 | int getFailures(); |
|---|
| 83 | void addFailure(); |
|---|
| 84 | void resetFailures(); |
|---|
| [1534] | 85 | enet_uint32 getRTT(); |
|---|
| [2087] | 86 | double getPacketLoss(); |
|---|
| 87 | |
|---|
| 88 | static bool removeClient(unsigned int clientID); |
|---|
| [1735] | 89 | static bool removeClient(ENetPeer *peer); |
|---|
| [2087] | 90 | static ClientInformation *findClient(unsigned int clientID, bool look_backwards=false); |
|---|
| [1735] | 91 | static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false); |
|---|
| 92 | static ClientInformation *getBegin(){return head_;} |
|---|
| [1505] | 93 | |
|---|
| 94 | bool setSynched(bool s); |
|---|
| 95 | bool getSynched(); |
|---|
| 96 | |
|---|
| 97 | |
|---|
| [1735] | 98 | private: |
|---|
| 99 | static ClientInformation *head_; |
|---|
| [2087] | 100 | |
|---|
| [1735] | 101 | bool setNext(ClientInformation *next); |
|---|
| 102 | bool setPrev(ClientInformation *prev); |
|---|
| [1505] | 103 | ClientInformation *insertAfter(ClientInformation *ins); |
|---|
| 104 | ClientInformation *insertBefore(ClientInformation *ins); |
|---|
| [2087] | 105 | |
|---|
| [1505] | 106 | ClientInformation *preve; |
|---|
| 107 | ClientInformation *nexte; |
|---|
| 108 | //actual information: |
|---|
| 109 | ENetPeer *peer_; |
|---|
| [2087] | 110 | unsigned int clientID_; |
|---|
| 111 | unsigned int gamestateID_; |
|---|
| 112 | unsigned int partialGamestateID_; |
|---|
| [1735] | 113 | unsigned int ShipID_; // this is the unique objectID |
|---|
| [1505] | 114 | bool synched_; |
|---|
| 115 | unsigned short failures_; |
|---|
| [2087] | 116 | |
|---|
| [1505] | 117 | }; |
|---|
| 118 | |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | #endif /* _ClientInformation_H__ */ |
|---|