Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1494 was 1494, checked in by rgrieder, 16 years ago
  • set the svn:eol-style property to all files so, that where ever you check out, you'll get the right line endings (had to change every file with mixed endings to windows in order to set the property)
  • 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#define GAMESTATEID_INITIAL -1
49#define CLIENTID_UNKNOWN -2
50
51// WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
52
53namespace network
54{
55  /**
56  * This class implements a list for client informations
57  * @author Oliver Scheuss
58  */
59  class ClientInformation{
60  public:
61    ClientInformation();
62    ClientInformation(bool head);
63    //   ClientInformation(ClientInformation *prev, ClientInformation *next);
64    //   ClientInformation(ClientInformation *prev);
65    ~ClientInformation();
66    ClientInformation *next();
67    ClientInformation *prev();
68    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(int id){ShipID_=id;}
76   
77    // get functions
78    inline int getShipID(){return ShipID_;}
79    int getID();
80    int getGamestateID();
81    int getPartialGamestateID();
82    ENetPeer *getPeer();
83    bool getHead();
84    void setHead(bool h);
85   
86    int getFailures();
87    void addFailure();
88    void resetFailures();
89   
90    bool removeClient(int clientID);
91    bool removeClient(ENetPeer *peer);
92    //## add bool mask-function eventually
93    ClientInformation *findClient(int clientID, bool look_backwards=false);
94    //## add bool mask-function eventually
95    ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
96
97    bool setSynched(bool s);
98    bool getSynched();
99
100
101    private:
102      bool setNext(ClientInformation *next);
103      bool setPrev(ClientInformation *prev);
104    ClientInformation *insertAfter(ClientInformation *ins);
105    ClientInformation *insertBefore(ClientInformation *ins);
106   
107    ClientInformation *preve;
108    ClientInformation *nexte;
109    //actual information:
110    ENetPeer *peer_;
111    int clientID_;
112    int gamestateID_;
113    int partialGamestateID_;
114    int ShipID_;   // this is the unique objectID
115    bool synched_;
116    bool head_;
117    unsigned short failures_;
118   
119  };
120
121}
122
123#endif /* _ClientInformation_H__ */
Note: See TracBrowser for help on using the repository browser.