Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/consolecommands2/src/libraries/network/ClientInformation.h @ 7621

Last change on this file since 7621 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

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