Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/ClientInformation.h @ 2151

Last change on this file since 2151 was 2087, checked in by landauf, 16 years ago

merged objecthierarchy branch back to trunk

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