Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
"
29
#include "
networking/lowlevel/vsnet_clientstate.h
"
30
#include "
networking/lowlevel/vsnet_address.h
"
31
#include "
networking/lowlevel/vsnet_socket.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 );
43
enum
accountServerCommands
44
{
45
ACCT_LOGIN
=
'l'
,
46
ACCT_NEWCHAR
=
'c'
,
47
ACCT_NEWSUBSCRIBE
=
'u'
,
48
ACCT_LOGIN_DATA
=
'd'
,
49
ACCT_LOGIN_ERROR
=
'e'
,
50
ACCT_LOGIN_ALREADY
=
'f'
,
51
ACCT_LOGIN_NEW
=
'n'
,
52
ACCT_LOGIN_ACCEPT
=
'a'
,
53
ACCT_LOGOUT
=
'o'
,
54
ACCT_RESYNC
=
'r'
,
55
ACCT_SAVE
=
's'
,
56
ACCT_SAVE_LOGOUT
=
'S'
,
57
ACCT_SUCCESS
=
'!'
,
58
};
59
//Network part of a client description
60
class
Client
61
{
62
public
:
63
/* Network and identification properties */
64
UnitContainer
game_unit
;
65
66
//NETFIXME: Move to server subclass.
67
AddressIP
cltadr
;
68
AddressIP
cltudpadr
;
69
SOCKETALT
*
lossy_socket
;
70
SOCKETALT
tcp_sock
;
71
72
//2 timeout vals to check a timeout for client connections
73
//those vals are server times
74
double
old_timeout
;
75
double
latest_timeout
;
76
double
elapsed_since_packet
;
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
;
87
enum
Loginstate
{
CONNECTED
,
WAITLISTED
,
LOGGEDIN
,
SAVEDGAME
,
INGAME
};
88
int
loginstate
;
89
90
char
webcam
;
91
char
portaudio
;
92
char
secured
;
93
char
jumpok
;
94
string
jumpfile
;
95
ObjSerial
netversion
;
96
vector< string >
savegame
;
97
float
comm_freq
;
98
ClientState
last_packet
;
//Last FullUpdate packet recieved.
99
100
string
_disconnectReason
;
101
102
Prediction
*
prediction
;
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
src
networking
client.h
Generated on Fri May 29 2015 23:07:34 for Vegastrike 0.5.1 rc1 by
1.8.4