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