Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/ClientInformation.h @ 2351

Last change on this file since 2351 was 2351, checked in by scheusso, 15 years ago

some changes. still not working yet, but will correct theese problems after merge with network64

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