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