Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation/src/network/ClientInformation.h @ 2736

Last change on this file since 2736 was 2371, checked in by scheusso, 16 years ago

merged network branch to presentation branch

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