Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/tutorialFS09/src/network/ClientInformation.h @ 10422

Last change on this file since 10422 was 2756, checked in by rgrieder, 16 years ago

Minimising problems when including windows.h because it defines macros like "min" and "max" if not explicitly specified.
There are two headers we use that include windows.h: OgreWindowEventUtilities.h and enet.h. I had to tweak a little bit there as well.

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