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
netbuffer.h
Go to the documentation of this file.
1
#ifndef __NETBUFFER_H
2
#define __NETBUFFER_H
3
4
#include <string.h>
5
#include "
cmd/weapon_xml.h
"
6
#include "
gfx/vec.h
"
7
#include "
gfx/matrix.h
"
8
#include "
gfx/quaternion.h
"
9
#include "
networking/lowlevel/vsnet_clientstate.h
"
10
#include "
cmd/unit_armorshield.h
"
11
#include "
gfxlib_struct.h
"
12
13
struct
GFXColor
;
14
std::string
getSimpleString
( std::string &input );
15
char
getSimpleChar
( std::string &input );
16
int
getSimpleInt
( std::string &input );
17
void
addSimpleString
( std::string &input,
const
std::string
adder
);
18
void
addSimpleChar
( std::string &input,
const
char
adder
);
19
void
addSimpleInt
( std::string &input,
const
int
adder
);
20
class
NetBuffer
21
{
22
char
*buffer;
23
unsigned
int
offset;
24
unsigned
int
size;
25
ObjSerial
ver;
26
27
public
:
NetBuffer
();
28
NetBuffer
(
int
bufsize
);
29
NetBuffer
(
const
char
*buf,
int
bufsize );
30
~NetBuffer
();
31
32
void
Reset
();
33
ObjSerial
version
();
34
void
setVersion
(
ObjSerial
ver );
35
char
*
getData
();
36
unsigned
int
getOffset
()
const
37
{
38
return
offset;
39
}
//useful to see if it's at the end of data
40
//Extends the buffer if we exceed its size
41
void
resizeBuffer
(
unsigned
int
newsize );
42
//Check if there is still enough data for 'len' to be read in buffer
43
bool
checkBuffer
(
int
len,
const
char
*fun );
44
45
void
addClientState
(
ClientState
cs );
46
ClientState
getClientState
();
47
void
addVector
(
Vector
v
);
48
Vector
getVector
();
49
void
addQVector
(
QVector
v
);
50
QVector
getQVector
();
51
void
addColor
(
GFXColor
col );
52
GFXColor
getColor
();
53
void
addMatrix
(
Matrix
m );
54
Matrix
getMatrix
();
55
void
addQuaternion
(
Quaternion
quat );
56
Quaternion
getQuaternion
();
57
void
addTransformation
(
Transformation
trans );
58
Transformation
getTransformation
();
59
60
/*
61
* void addWeaponInfo( weapon_info wi)
62
* {
63
* wi.netswap();
64
* char * buf = NULL;
65
* int wi_size = 0;
66
* setWeaponInfoToBuffer( wi, buf, wi_size);
67
* resizeBuffer( offset+wi_size);
68
* memcpy( buffer+offset, buf, wi_size);
69
* offset += wi_size;
70
* delete buf;
71
* }
72
*/
73
/*
74
* weapon_info getWeaponInfo()
75
* {
76
* int wisize=0;
77
* weapon_info tmp = getWeaponInfoFromBuffer( buffer+offset, wisize);
78
* tmp.netswap();
79
* offset += wisize;
80
* return tmp;
81
* }
82
*/
83
void
addShield
(
const
Shield
&shield );
84
Shield
getShield
();
85
void
addArmor
(
const
Armor
&armor );
86
Armor
getArmor
();
87
88
void
addSerial
(
ObjSerial
serial );
89
ObjSerial
getSerial
();
90
void
addFloat
(
float
f );
91
float
getFloat
();
92
void
addFloat8
(
float
f );
93
float
getFloat8
();
94
void
addDouble
(
double
d );
95
double
getDouble
();
96
void
addShort
(
unsigned
short
s );
97
unsigned
short
getShort
();
98
void
addInt32
(
int
i );
99
int
getInt32
();
100
void
addUInt32
(
unsigned
int
i );
101
unsigned
int
getUInt32
();
102
void
addChar
(
char
c
);
103
char
getChar
();
104
void
addType
(
unsigned
char
t );
105
bool
checkType
(
unsigned
char
t );
106
unsigned
char
getType
();
107
void
addBuffer
(
const
unsigned
char
*buf,
int
bufsize );
108
unsigned
char
*
extAddBuffer
(
int
bufsize );
109
unsigned
char
*
getBuffer
(
int
offt );
110
//Add and get a string with its length before the char * buffer part
111
void
addString
(
const
string
&str );
112
string
getString
();
113
114
GFXMaterial
getGFXMaterial
();
115
void
addGFXMaterial
(
const
GFXMaterial
&mat );
116
GFXLight
getGFXLight
();
117
void
addGFXLight
(
const
GFXLight
&light );
118
GFXLightLocal
getGFXLightLocal
();
119
void
addGFXLightLocal
(
const
GFXLightLocal
&light );
120
121
unsigned
int
getDataLength
();
122
unsigned
int
getSize
();
123
};
124
125
#endif
126
src
networking
lowlevel
netbuffer.h
Generated on Fri May 29 2015 23:07:34 for Vegastrike 0.5.1 rc1 by
1.8.4