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
netbuffer.cpp File Reference
#include <assert.h>
#include "networking/lowlevel/netbuffer.h"
#include "networking/lowlevel/vsnet_oss.h"
#include "networking/const.h"
#include "posh.h"
#include "gfxlib_struct.h"
#include "networking/netversion.h"

Go to the source code of this file.

Macros

#define NB_CASE(a)
 
#define NETBUF_DEBUG_CLISERV
 
#define ADD_NB(type)   addType( type )
 
#define CHECK_NB(type)   checkType( type )
 

Enumerations

enum  NBType {
  NB_CHAR =187, NB_SHORT, NB_SERIAL, NB_INT32,
  NB_UINT32, NB_FLOAT =123, NB_DOUBLE, NB_STRING =33,
  NB_BUFFER =44, NB_CLIENTSTATE =211, NB_TRANSFORMATION, NB_VECTOR,
  NB_QVECTOR, NB_COLOR, NB_MATRIX, NB_QUATERNION,
  NB_SHIELD, NB_ARMOR, NB_GFXMAT, NB_GFXLIGHT,
  NB_GFXLIGHTLOCAL
}
 

Functions

std::string getSimpleString (std::string &input)
 
char getSimpleChar (std::string &input)
 
int getSimpleInt (std::string &input)
 
void addSimpleString (std::string &input, const std::string adder)
 
void addSimpleChar (std::string &input, const char adder)
 
void addSimpleInt (std::string &input, const int adder)
 
const char * getTypeStr (unsigned char c)
 

Variables

char typeerrbuf [32]
 
static unsigned char null = '\0'
 

Macro Definition Documentation

#define NB_CASE (   a)
Value:
case a: \
return #a; break

Definition at line 174 of file netbuffer.cpp.

Referenced by getTypeStr().

#define NETBUF_DEBUG_CLISERV

Definition at line 248 of file netbuffer.cpp.

Enumeration Type Documentation

enum NBType
Enumerator
NB_CHAR 
NB_SHORT 
NB_SERIAL 
NB_INT32 
NB_UINT32 
NB_FLOAT 
NB_DOUBLE 
NB_STRING 
NB_BUFFER 
NB_CLIENTSTATE 
NB_TRANSFORMATION 
NB_VECTOR 
NB_QVECTOR 
NB_COLOR 
NB_MATRIX 
NB_QUATERNION 
NB_SHIELD 
NB_ARMOR 
NB_GFXMAT 
NB_GFXLIGHT 
NB_GFXLIGHTLOCAL 

Definition at line 149 of file netbuffer.cpp.

150 {
151  NB_CHAR=187,
152  NB_SHORT,
153  NB_SERIAL,
154  NB_INT32,
155  NB_UINT32,
156  NB_FLOAT =123,
157  NB_DOUBLE,
158  NB_STRING=33,
159  NB_BUFFER=44,
160  NB_CLIENTSTATE=211,
162  NB_VECTOR,
163  NB_QVECTOR,
164  NB_COLOR,
165  NB_MATRIX,
167  NB_SHIELD,
168  NB_ARMOR,
169  NB_GFXMAT,
170  NB_GFXLIGHT,
172 };

Function Documentation

void addSimpleChar ( std::string &  input,
const char  adder 
)

Definition at line 45 of file netbuffer.cpp.

Referenced by AcctLogout(), NetClient::loginAcctLoop(), NetServer::saveAccount(), NetServer::sendJump(), and NetServer::start().

46 {
47  char add[2] = {adder, '\0'};
48  input += std::string( add, 1 );
49 }
void addSimpleInt ( std::string &  input,
const int  adder 
)

Definition at line 51 of file netbuffer.cpp.

References XMLSupport::tostring().

Referenced by addSimpleString().

52 {
53  input += XMLSupport::tostring( adder )+" ";
54 }
void addSimpleString ( std::string &  input,
const std::string  adder 
)

Definition at line 39 of file netbuffer.cpp.

References addSimpleInt().

Referenced by AcctLogout(), AddWriteSave(), NetClient::loginAcctLoop(), NetServer::saveAccount(), NetServer::sendJump(), and NetServer::start().

40 {
41  addSimpleInt( input, adder.length() );
42  input += adder;
43 }
char getSimpleChar ( std::string &  input)

Definition at line 20 of file netbuffer.cpp.

21 {
22  char retval = input[0];
23  input = input.substr( 1 );
24  return retval;
25 }
int getSimpleInt ( std::string &  input)

Definition at line 27 of file netbuffer.cpp.

References XMLSupport::parse_int().

Referenced by getSimpleString().

28 {
29  std::string::size_type where = input.find( " " );
30  if (where != string::npos) {
31  std::string num = input.substr( 0, where );
32  int len = XMLSupport::parse_int( num );
33  input = input.substr( where+1 );
34  return len;
35  }
36  return 0;
37 }
std::string getSimpleString ( std::string &  input)

Definition at line 9 of file netbuffer.cpp.

References getSimpleInt().

10 {
11  int len = getSimpleInt( input );
12  if ( len >= 0 && (unsigned int) len <= input.length() ) {
13  std::string retval = input.substr( 0, len );
14  input = input.substr( len );
15  return retval;
16  }
17  return "";
18 }
const char* getTypeStr ( unsigned char  c)

Definition at line 180 of file netbuffer.cpp.

References NB_ARMOR, NB_BUFFER, NB_CASE, NB_CHAR, NB_CLIENTSTATE, NB_COLOR, NB_DOUBLE, NB_FLOAT, NB_GFXLIGHT, NB_GFXLIGHTLOCAL, NB_GFXMAT, NB_INT32, NB_MATRIX, NB_QUATERNION, NB_QVECTOR, NB_SERIAL, NB_SHIELD, NB_SHORT, NB_STRING, NB_TRANSFORMATION, NB_UINT32, NB_VECTOR, and typeerrbuf.

Referenced by NetBuffer::checkType().

181 {
182  switch (c)
183  {
184  NB_CASE( NB_CHAR );
185  NB_CASE( NB_SHORT );
186  NB_CASE( NB_SERIAL );
187  NB_CASE( NB_INT32 );
188  NB_CASE( NB_UINT32 );
189  NB_CASE( NB_FLOAT );
190  NB_CASE( NB_DOUBLE );
191  NB_CASE( NB_STRING );
192  NB_CASE( NB_BUFFER );
195  NB_CASE( NB_VECTOR );
196  NB_CASE( NB_QVECTOR );
197  NB_CASE( NB_COLOR );
198  NB_CASE( NB_MATRIX );
200  NB_CASE( NB_SHIELD );
201  NB_CASE( NB_ARMOR );
202  NB_CASE( NB_GFXMAT );
203  NB_CASE( NB_GFXLIGHT );
205  default:
206  sprintf( typeerrbuf, "<<Byte %d>>", (int) c );
207  return typeerrbuf;
208  }
209 }

Variable Documentation

unsigned char null = '\0'
static

Definition at line 686 of file netbuffer.cpp.

Referenced by NetBuffer::getBuffer().

char typeerrbuf[32]

Definition at line 178 of file netbuffer.cpp.

Referenced by getTypeStr().