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