Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1488 was 1360, checked in by rgrieder, 16 years ago

merged merge branch back to trunk

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#define GAMESTATEID_INITIAL -1
49#define CLIENTID_UNKNOWN -2
50
51namespace network
52{
53  /**
54  * This class implements a list for client informations
55  * @author Oliver Scheuss
56  */
57  class ClientInformation{
58  public:
59    ClientInformation();
60    ClientInformation(bool head);
61    //   ClientInformation(ClientInformation *prev, ClientInformation *next);
62    //   ClientInformation(ClientInformation *prev);
63    ~ClientInformation();
64    ClientInformation *next();
65    ClientInformation *prev();
66    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(int id){ShipID_=id;}
74   
75    // get functions
76    inline int getShipID(){return ShipID_;}
77    int getID();
78    int getGamestateID();
79    int getPartialGamestateID();
80    ENetPeer *getPeer();
81    bool getHead();
82    void setHead(bool h);
83   
84    int getFailures();
85    void addFailure();
86    void resetFailures();
87   
88    bool removeClient(int clientID);
89    bool removeClient(ENetPeer *peer);
90    //## add bool mask-function eventually
91    ClientInformation *findClient(int clientID, bool look_backwards=false);
92    //## add bool mask-function eventually
93    ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
94
95    bool setSynched(bool s);
96    bool getSynched();
97
98
99    private:
100      bool setNext(ClientInformation *next);
101      bool setPrev(ClientInformation *prev);
102    ClientInformation *insertAfter(ClientInformation *ins);
103    ClientInformation *insertBefore(ClientInformation *ins);
104   
105    ClientInformation *preve;
106    ClientInformation *nexte;
107    //actual information:
108    ENetPeer *peer_;
109    int clientID_;
110    int gamestateID_;
111    int partialGamestateID_;
112    int ShipID_;   // this is the unique objectID
113    bool synched_;
114    bool head_;
115    unsigned short failures_;
116    static boost::recursive_mutex mutex_;
117   
118  };
119
120}
121
122#endif /* _ClientInformation_H__ */
Note: See TracBrowser for help on using the repository browser.