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 Class Reference

#include <client.h>

Public Types

enum  Loginstate {
  CONNECTED, WAITLISTED, LOGGEDIN, SAVEDGAME,
  INGAME
}
 

Public Member Functions

 Client ()
 
 Client (SOCKETALT &s)
 
 ~Client ()
 
void setLatestTimestamp (unsigned int ts)
 
void setUDP (SOCKETALT *udpSock, AddressIP &cltudpadr)
 
void setTCP ()
 
void clearLatestTimestamp ()
 
unsigned int getLatestTimestamp () const
 
double getDeltatime () const
 
double getNextDeltatime () const
 
void versionBuf (NetBuffer &buf) const
 

Public Attributes

UnitContainer game_unit
 
AddressIP cltadr
 
AddressIP cltudpadr
 
SOCKETALTlossy_socket
 
SOCKETALT tcp_sock
 
double old_timeout
 
double latest_timeout
 
double elapsed_since_packet
 
string callsign
 
string name
 
string passwd
 
string server_ip
 
unsigned short server_port
 
bool ingame
 
int loginstate
 
char webcam
 
char portaudio
 
char secured
 
char jumpok
 
string jumpfile
 
ObjSerial netversion
 
vector< string > savegame
 
float comm_freq
 
ClientState last_packet
 
string _disconnectReason
 
Predictionprediction
 

Friends

std::ostream & operator<< (std::ostream &ostr, const Client &c)
 

Detailed Description

Definition at line 60 of file client.h.

Member Enumeration Documentation

Enumerator
CONNECTED 
WAITLISTED 
LOGGEDIN 
SAVEDGAME 
INGAME 

Definition at line 87 of file client.h.

Constructor & Destructor Documentation

Client::Client ( )

Definition at line 33 of file client.cpp.

References lossy_socket.

34 {
35  lossy_socket = NULL;
36  this->Init();
37 }
Client::Client ( SOCKETALT s)

Definition at line 40 of file client.cpp.

References cltadr, SOCKETALT::getRemoteAddress(), lossy_socket, and tcp_sock.

40  :
41  tcp_sock( s )
42 {
45  this->Init();
46 }
Client::~Client ( )

Definition at line 48 of file client.cpp.

References prediction.

49 {
50  if (prediction) {
51  delete prediction;
52  prediction = NULL;
53  }
54 }

Member Function Documentation

void Client::clearLatestTimestamp ( )

Definition at line 88 of file client.cpp.

89 {
90  _latest_timestamp = 0;
91  _old_timestamp = 0;
92  _deltatime = 0;
93  //cerr << "Clearing deltatime for "<<(game_unit.GetUnit()?game_unit.GetUnit()->GetSerial():1)<<", next="<<_next_deltatime<<endl;
94 }
double Client::getDeltatime ( ) const

Definition at line 101 of file client.cpp.

102 {
103  return _deltatime;
104 }
unsigned int Client::getLatestTimestamp ( ) const

Definition at line 96 of file client.cpp.

97 {
98  return _latest_timestamp;
99 }
double Client::getNextDeltatime ( ) const

Definition at line 106 of file client.cpp.

107 {
108  return _next_deltatime;
109 }
void Client::setLatestTimestamp ( unsigned int  ts)

Definition at line 73 of file client.cpp.

74 {
75 //COUT << "set latest client timestamp " << ts << " (old=" << _old_timestamp << ")" << endl;
76  _old_timestamp = _latest_timestamp;
77  _latest_timestamp = ts;
78  //Compute the deltatime in seconds that is time between packet_timestamp
79  //in ms and the old_timestamp in ms
80  //If the timestamp values are precicely 0 then that means we don't have any good data yet.
81  if (_old_timestamp != 0 && ts != 0) {
82  _deltatime = ( (double) (ts-_old_timestamp) )/1000;
83  _next_deltatime = .33*_deltatime+.67*_next_deltatime;
84  //cerr<<"Unit "<<(game_unit.GetUnit()?game_unit.GetUnit()->GetSerial():-1)<<" has DELTATIME = "<<(_deltatime)<<", NEXT = "<<(_next_deltatime)<<" s ------"<<endl;
85  }
86 }
void Client::setTCP ( )

Definition at line 62 of file client.cpp.

References cltadr, cltudpadr, lossy_socket, and tcp_sock.

63 {
64  this->lossy_socket = &this->tcp_sock;
65  this->cltudpadr = this->cltadr;
66 }
void Client::setUDP ( SOCKETALT udpSock,
AddressIP cltudpadr 
)

Definition at line 56 of file client.cpp.

References cltudpadr, and lossy_socket.

57 {
58  this->lossy_socket = udpSock;
59  this->cltudpadr = udpadr;
60 }
void Client::versionBuf ( NetBuffer buf) const

Definition at line 68 of file client.cpp.

References netversion, and NetBuffer::setVersion().

69 {
70  buf.setVersion( netversion );
71 }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ostr,
const Client c 
)
friend

Definition at line 166 of file vsnet_clientstate.cpp.

167 {
168  ostr<<"(clnt addr "<<c.cltadr
169  <<" tcpsock="<<c.tcp_sock<<", lossysock=";
170  if (c.lossy_socket)
171  ostr<<*c.lossy_socket;
172  else
173  ostr<<"NULL";
174  return ostr;
175 }

Member Data Documentation

string Client::_disconnectReason

Definition at line 100 of file client.h.

string Client::callsign

Definition at line 77 of file client.h.

Referenced by ZoneInfo::display().

AddressIP Client::cltadr

Definition at line 67 of file client.h.

Referenced by Client(), operator<<(), and setTCP().

AddressIP Client::cltudpadr

Definition at line 68 of file client.h.

Referenced by setTCP(), and setUDP().

float Client::comm_freq

Definition at line 97 of file client.h.

double Client::elapsed_since_packet

Definition at line 76 of file client.h.

UnitContainer Client::game_unit

Definition at line 64 of file client.h.

Referenced by ZoneInfo::display().

bool Client::ingame

Definition at line 86 of file client.h.

string Client::jumpfile

Definition at line 94 of file client.h.

char Client::jumpok

Definition at line 93 of file client.h.

ClientState Client::last_packet

Definition at line 98 of file client.h.

double Client::latest_timeout

Definition at line 75 of file client.h.

int Client::loginstate

Definition at line 88 of file client.h.

SOCKETALT* Client::lossy_socket

Definition at line 69 of file client.h.

Referenced by Client(), operator<<(), setTCP(), and setUDP().

string Client::name

Definition at line 78 of file client.h.

ObjSerial Client::netversion

Definition at line 95 of file client.h.

Referenced by versionBuf().

double Client::old_timeout

Definition at line 74 of file client.h.

string Client::passwd

Definition at line 79 of file client.h.

char Client::portaudio

Definition at line 91 of file client.h.

Prediction* Client::prediction

Definition at line 102 of file client.h.

Referenced by ~Client().

vector< string > Client::savegame

Definition at line 96 of file client.h.

char Client::secured

Definition at line 92 of file client.h.

string Client::server_ip

Definition at line 82 of file client.h.

unsigned short Client::server_port

Definition at line 83 of file client.h.

SOCKETALT Client::tcp_sock

Definition at line 70 of file client.h.

Referenced by Client(), operator<<(), NetServer::sendCommunication(), and setTCP().

char Client::webcam

Definition at line 90 of file client.h.


The documentation for this class was generated from the following files: