Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/src/libraries/network/ClientInformation.h @ 11270

Last change on this file since 11270 was 7801, checked in by dafrick, 14 years ago

Merging presentation2 branch back to trunk.

  • Property svn:eol-style set to native
File size: 3.1 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    inline void setShipID(unsigned int id){ShipID_=id;}
69
70    // get functions
71    inline unsigned int getShipID(){return ShipID_;}
72    unsigned int getID();
73    unsigned int getGamestateID();
74    ENetPeer *getPeer();
75
76    uint32_t getRTT();
77    double getPacketLoss();
78
79    static bool removeClient(unsigned int clientID);
80    static bool removeClient(ENetPeer *peer);
81    static ClientInformation *findClient(unsigned int clientID, bool look_backwards=false);
82    static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
83    static ClientInformation *getBegin(){return head_;}
84    static bool hasClients(){ return ClientInformation::head_!=0; }
85
86    bool setSynched(bool s);
87    bool getSynched();
88
89  private:
90    static ClientInformation *head_;
91
92    bool setNext(ClientInformation *next);
93    bool setPrev(ClientInformation *prev);
94    ClientInformation *insertAfter(ClientInformation *ins);
95    ClientInformation *insertBefore(ClientInformation *ins);
96
97    ClientInformation *preve;
98    ClientInformation *nexte;
99    //actual information:
100    ENetPeer *peer_;
101    unsigned int clientID_;
102    unsigned int gamestateID_;
103    unsigned int ShipID_;   // this is the unique objectID
104    bool synched_;
105
106  };
107
108}
109
110#endif /* _ClientInformation_H__ */
Note: See TracBrowser for help on using the repository browser.