Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
client.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have recvbufd a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */
16 
17 /*
18  * client structures - written by Stephane Vaxelaire <svax@free.fr>
19  */
20 
21 #ifndef __CLIENTSTRUCTS_H
22 #define __CLIENTSTRUCTS_H
23 
24 #include <iostream>
25 #include <string.h>
26 #include "gfx/quaternion.h"
27 #include "networking/const.h"
28 #include "configxml.h"
32 //#include "cmd/unit_generic.h"
33 #include "cmd/container.h"
34 #include "savegame.h"
35 
36 class Unit;
37 class UnitContainer;
38 class Prediction;
39 
40 extern VegaConfig *vs_config;
41 
42 void displayError( ObjSerial error_code );
44 {
45  ACCT_LOGIN ='l',
55  ACCT_SAVE='s',
58 };
59 //Network part of a client description
60 class Client
61 {
62 public:
63 /* Network and identification properties */
65 
66 //NETFIXME: Move to server subclass.
71 
72 //2 timeout vals to check a timeout for client connections
73 //those vals are server times
74  double old_timeout;
77  string callsign;
78  string name;
79  string passwd;
80 
81 /* Accountserver sends this info to us. */
82  string server_ip;
83  unsigned short server_port;
84 
85 /* In-game parameters */
86  bool ingame;
89 
90  char webcam;
91  char portaudio;
92  char secured;
93  char jumpok;
94  string jumpfile;
96  vector< string >savegame;
97  float comm_freq;
98  ClientState last_packet; //Last FullUpdate packet recieved.
99 
101 
103 
104  Client();
105  Client( SOCKETALT &s );
106  ~Client();
107 
108  void setLatestTimestamp( unsigned int ts );
109  void setUDP( SOCKETALT *udpSock, AddressIP &cltudpadr );
110  void setTCP();
111  void clearLatestTimestamp();
112  unsigned int getLatestTimestamp() const;
113  double getDeltatime() const;
114  double getNextDeltatime() const;
115  void versionBuf( NetBuffer &buf ) const; //Sets the netbuffer to this version.
116 
117  friend std::ostream&operator<<( std::ostream &ostr, const Client &c );
118 
119 private:
120 //2 timestamps vals from client time to check receiving old packet after
121 //newer ones (allowed in case of UDP only)
122  unsigned int _old_timestamp;
123  unsigned int _latest_timestamp;
124  double _deltatime;
125  double _next_deltatime;
126 
127 private: Client( const Client& );
128  Client& operator=( const Client& );
129 
130  void Init();
131 };
132 
133 std::ostream&operator<<( std::ostream &ostr, const Client &c );
134 
135 #endif
136