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
Go to the documentation of this file.
1 #include <assert.h>
4 #include "networking/const.h"
5 #include "posh.h"
6 #include "gfxlib_struct.h"
8 
9 std::string getSimpleString( std::string &input )
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 }
19 
20 char getSimpleChar( std::string &input )
21 {
22  char retval = input[0];
23  input = input.substr( 1 );
24  return retval;
25 }
26 
27 int getSimpleInt( std::string &input )
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 }
38 
39 void addSimpleString( std::string &input, const std::string adder )
40 {
41  addSimpleInt( input, adder.length() );
42  input += adder;
43 }
44 
45 void addSimpleChar( std::string &input, const char adder )
46 {
47  char add[2] = {adder, '\0'};
48  input += std::string( add, 1 );
49 }
50 
51 void addSimpleInt( std::string &input, const int adder )
52 {
53  input += XMLSupport::tostring( adder )+" ";
54 }
55 
57 {
58  buffer = new char[MAXBUFFER];
59  offset = 0;
60  size = MAXBUFFER;
61  memset( buffer, 0x20, size );
62  this->buffer[size-1] = 0;
63  ver = NETWORK_VERSION;
64 }
65 
67 {
68  buffer = new char[bufsize];
69  offset = 0;
70  size = bufsize;
71  memset( buffer, 0x20, size );
72  this->buffer[size-1] = 0;
73  ver = NETWORK_VERSION;
74 }
75 
81 NetBuffer::NetBuffer( const char *buf, int bufsize )
82 {
83  offset = 0;
84  ver =
85  size = bufsize+1;
86  this->buffer = new char[size];
87  memset( buffer, 0x20, size );
88  VsnetOSS::memcpy( buffer, buf, bufsize );
89  this->buffer[size-1] = 0;
90  ver = NETWORK_VERSION;
91 }
92 
94 {
95  if (buffer != NULL)
96  delete[] buffer;
97 }
98 
100 {
101  memset( buffer, 0x20, size );
102  offset = 0;
103 }
104 
106 {
107  return buffer;
108 }
109 
111 {
112  ver = newver;
113 }
114 
116 {
117  return ver;
118 }
119 
120 //Extends the buffer if we exceed its size
121 void NetBuffer::resizeBuffer( unsigned int newsize )
122 {
123  if (size-1 < newsize) {
124  char *tmp = new char[newsize+1];
125  memset( tmp, 0, newsize+1 );
126  VsnetOSS::memcpy( tmp, buffer, size );
127  delete[] buffer;
128  buffer = tmp;
129  size = newsize+1;
130  }
131 }
132 
133 //Check the buffer to see if we can still get info from it
134 bool NetBuffer::checkBuffer( int len, const char *fun )
135 {
136  if (offset+len >= size) {
137  std::cerr<<"!!! ERROR : trying to read more data than buffer size (offset="<<offset<<" - size="<<size<<" - to read="
138  <<len<<") in "<<fun<<" !!!"<<std::endl;
139 
140  //NETFIXME: Be more graceful... but this is nice for Debugging in GDB.
141  int *x = NULL;
142  ( const_cast< char* > (fun) )[0] += *x;
143 
144  return false;
145  }
146  return true;
147 }
148 
149 enum NBType
150 {
151  NB_CHAR=187,
156  NB_FLOAT =123,
172 };
173 
174 #define NB_CASE( a ) \
175 case a: \
176  return #a; break
177 
178 char typeerrbuf[32];
179 
180 const char * getTypeStr( unsigned char c )
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 }
210 
211 void NetBuffer::addType( unsigned char c )
212 {
213  int tmpsize = sizeof (c);
214  resizeBuffer( offset+tmpsize );
215  VsnetOSS::memcpy( buffer+offset, &c, sizeof (c) );
216  offset += tmpsize;
217 }
218 
219 unsigned char NetBuffer::getType()
220 {
221  unsigned char c;
222  if ( !checkBuffer( sizeof (c), "getChar" ) )
223  return 0;
224  VsnetOSS::memcpy( &c, buffer+offset, sizeof (c) );
225  offset += sizeof (c);
226  return c;
227 }
228 
229 bool NetBuffer::checkType( unsigned char c )
230 {
231  const char *typ = getTypeStr( c );
232  checkBuffer( 1, typ ); //Does this type exist?
233  unsigned char got = getType();
234  if (got != c) {
235  const char *typgot = getTypeStr( got );
236  std::cerr<<"!!! ERROR : attempt to read invalid data at offset="<<offset<<": Actual type is a "<<typgot
237  <<" but I wanted a "<<typ<<" !!!"<<std::endl;
238 
239  //NETFIXME: Be more graceful... but this is nice for Debugging in GDB.
240  int *x = NULL;
241  ( const_cast< char* > (typ) )[0] += *x;
242 
243  return false;
244  }
245  return true;
246 }
247 
248 #define NETBUF_DEBUG_CLISERV
249 
250 #ifdef NETBUF_DEBUG_CLISERV
251 //Must be enabled or disabled on ALL CLIENTS and ALL SERVERS
252 //Since packets will be incompatible.
253 #define ADD_NB( type ) addType( type )
254 #define CHECK_NB( type ) checkType( type )
255 #else
256 #define ADD_NB( type )
257 #define CHECK_NB( type )
258 #endif
259 
260 //NOTE : IMPORTANT - I ONLY INCREMENT OFFSET IN PRIMARY DATATYPES SINCE ALL OTHER ARE COMPOSED WITH THEM
262 {
264  //this->addFloat( cs.delay);
265  this->addSerial( cs.client_serial );
266  this->addTransformation( cs.pos );
267  this->addVector( cs.veloc );
268  this->addVector( cs.angveloc );
269 }
270 
272 {
274  ClientState cs;
275  //cs.delay = this->getFloat();
276  cs.client_serial = this->getSerial();
277  cs.pos = this->getTransformation();
278  cs.veloc = this->getVector();
279  cs.angveloc = this->getVector();
280 
281  return cs;
282 }
283 
285 {
286  ADD_NB( NB_VECTOR );
287  this->addFloat( v.i );
288  this->addFloat( v.j );
289  this->addFloat( v.k );
290 }
291 
293 {
294  CHECK_NB( NB_VECTOR );
295  Vector v;
296  v.i = this->getFloat();
297  v.j = this->getFloat();
298  v.k = this->getFloat();
299 
300  return v;
301 }
302 
304 {
305  ADD_NB( NB_QVECTOR );
306  this->addDouble( v.i );
307  this->addDouble( v.j );
308  this->addDouble( v.k );
309 }
310 
312 {
313  CHECK_NB( NB_QVECTOR );
314  QVector v;
315  v.i = this->getDouble();
316  v.j = this->getDouble();
317  v.k = this->getDouble();
318  return v;
319 }
320 
322 {
323  ADD_NB( NB_COLOR );
324  this->addFloat( col.r );
325  this->addFloat( col.g );
326  this->addFloat( col.b );
327  this->addFloat( col.a );
328 }
329 
331 {
332  CHECK_NB( NB_COLOR );
333  GFXColor col;
334  col.r = this->getFloat();
335  col.g = this->getFloat();
336  col.b = this->getFloat();
337  col.a = this->getFloat();
338  return col;
339 }
340 
342 {
343  ADD_NB( NB_MATRIX );
344  for (int i = 0; i < 9; i++)
345  this->addFloat( m.r[i] );
346  this->addQVector( m.p );
347 }
349 {
350  CHECK_NB( NB_MATRIX );
351  Matrix m;
352  for (int i = 0; i < 9; i++)
353  m.r[i] = this->getFloat();
354  m.p = this->getQVector();
355  return m;
356 }
358 {
360  this->addFloat( quat.s );
361  this->addVector( quat.v );
362 }
364 {
366  Quaternion q;
367  q.s = this->getFloat();
368  q.v = this->getVector();
369  return q;
370 }
372 {
374  this->addQuaternion( trans.orientation );
375  this->addQVector( trans.position );
376 }
378 {
380  Transformation t;
381  t.orientation = this->getQuaternion();
382  t.position = this->getQVector();
383  return t;
384 }
385 
386 void NetBuffer::addShield( const Shield &shield )
387 {
388  ADD_NB( NB_SHIELD );
389  this->addChar( shield.number );
390  this->addChar( shield.leak );
391  this->addFloat( shield.recharge );
392  this->addFloat( shield.efficiency );
393  switch (shield.number)
394  {
395  case 2:
396  this->addFloat( shield.shield2fb.front );
397  this->addFloat( shield.shield2fb.back );
398  this->addFloat( shield.shield2fb.frontmax );
399  this->addFloat( shield.shield2fb.backmax );
400  break;
401  case 4:
402  this->addFloat( shield.shield4fbrl.front );
403  this->addFloat( shield.shield4fbrl.back );
404  this->addFloat( shield.shield4fbrl.right );
405  this->addFloat( shield.shield4fbrl.left );
406  this->addFloat( shield.shield4fbrl.frontmax );
407  this->addFloat( shield.shield4fbrl.backmax );
408  this->addFloat( shield.shield4fbrl.rightmax );
409  this->addFloat( shield.shield4fbrl.leftmax );
410  break;
411  case 8:
412  this->addFloat( shield.shield8.frontrighttop );
413  this->addFloat( shield.shield8.backrighttop );
414  this->addFloat( shield.shield8.frontlefttop );
415  this->addFloat( shield.shield8.backlefttop );
416  this->addFloat( shield.shield8.frontrightbottom );
417  this->addFloat( shield.shield8.backrightbottom );
418  this->addFloat( shield.shield8.frontleftbottom );
419  this->addFloat( shield.shield8.backleftbottom );
420  this->addFloat( shield.shield8.frontrighttopmax );
421  this->addFloat( shield.shield8.backrighttopmax );
422  this->addFloat( shield.shield8.frontlefttopmax );
423  this->addFloat( shield.shield8.backlefttopmax );
424  this->addFloat( shield.shield8.frontrightbottommax );
425  this->addFloat( shield.shield8.backrightbottommax );
426  this->addFloat( shield.shield8.frontleftbottommax );
427  this->addFloat( shield.shield8.backleftbottommax );
428  break;
429  }
430 }
432 {
433  CHECK_NB( NB_SHIELD );
434  Shield shield;
435  shield.number = this->getChar();
436  shield.leak = this->getChar();
437  shield.recharge = this->getFloat();
438  shield.efficiency = this->getFloat();
439  switch (shield.number)
440  {
441  case 2:
442  shield.shield2fb.front = this->getFloat();
443  shield.shield2fb.back = this->getFloat();
444  shield.shield2fb.frontmax = this->getFloat();
445  shield.shield2fb.backmax = this->getFloat();
446  break;
447  case 4:
448  shield.shield4fbrl.front = this->getFloat();
449  shield.shield4fbrl.back = this->getFloat();
450  shield.shield4fbrl.right = this->getFloat();
451  shield.shield4fbrl.left = this->getFloat();
452  shield.shield4fbrl.frontmax = this->getFloat();
453  shield.shield4fbrl.backmax = this->getFloat();
454  shield.shield4fbrl.rightmax = this->getFloat();
455  shield.shield4fbrl.leftmax = this->getFloat();
456  break;
457  case 8:
458  shield.shield8.frontrighttop = this->getFloat();
459  shield.shield8.backrighttop = this->getFloat();
460  shield.shield8.frontlefttop = this->getFloat();
461  shield.shield8.backlefttop = this->getFloat();
462  shield.shield8.frontrightbottom = this->getFloat();
463  shield.shield8.backrightbottom = this->getFloat();
464  shield.shield8.frontleftbottom = this->getFloat();
465  shield.shield8.backleftbottom = this->getFloat();
466  shield.shield8.frontrighttopmax = this->getFloat();
467  shield.shield8.backrighttopmax = this->getFloat();
468  shield.shield8.frontlefttopmax = this->getFloat();
469  shield.shield8.backlefttopmax = this->getFloat();
470  shield.shield8.frontrightbottommax = this->getFloat();
471  shield.shield8.backrightbottommax = this->getFloat();
472  shield.shield8.frontleftbottommax = this->getFloat();
473  shield.shield8.backleftbottommax = this->getFloat();
474  break;
475  }
476  return shield;
477 }
478 
479 void NetBuffer::addArmor( const Armor &armor )
480 {
481  ADD_NB( NB_ARMOR );
482  this->addFloat( armor.frontrighttop );
483  this->addFloat( armor.backrighttop );
484  this->addFloat( armor.frontlefttop );
485  this->addFloat( armor.backlefttop );
486  this->addFloat( armor.frontrightbottom );
487  this->addFloat( armor.backrightbottom );
488  this->addFloat( armor.frontleftbottom );
489  this->addFloat( armor.backleftbottom );
490 }
491 
493 {
494  CHECK_NB( NB_ARMOR );
495  Armor armor;
496  armor.frontrighttop = this->getFloat();
497  armor.backrighttop = this->getFloat();
498  armor.frontlefttop = this->getFloat();
499  armor.backlefttop = this->getFloat();
500  armor.frontrightbottom = this->getFloat();
501  armor.backrightbottom = this->getFloat();
502  armor.frontleftbottom = this->getFloat();
503  armor.backleftbottom = this->getFloat();
504 
505  return armor;
506 }
507 
509 {
510  ADD_NB( NB_SERIAL );
511  this->addShort( serial );
512 }
513 
515 {
516  CHECK_NB( NB_SERIAL );
517  return this->getShort();
518 }
519 
520 void NetBuffer::addFloat( float f )
521 {
522  ADD_NB( NB_FLOAT );
523  int tmpsize = sizeof (f);
524  resizeBuffer( offset+tmpsize );
526  *( (posh_u32_t*) (this->buffer+offset) ) = bits;
527  offset += tmpsize;
528 }
529 
531 {
532  CHECK_NB( NB_FLOAT );
533  float s;
534  if ( !checkBuffer( sizeof (s), "getFloat" ) )
535  return 0;
536  posh_u32_t bits = *( (posh_u32_t*) (this->buffer+offset) );
537  s = POSH_FloatFromBigBits( bits );
538  offset += sizeof (s);
539  return s;
540 }
541 
542 void NetBuffer::addFloat8( float f )
543 {
544  if (version() < 4500) {
545  addFloat( f );
546  } else {
547  unsigned char ch;
548  if (f > 1.0) ch = 255;
549  else if (f < 0.0)
550  ch = 0;
551  else ch = (unsigned char) (f*255);
552  char sch( ch );
553  addChar( sch );
554  }
555 }
556 
558 {
559  if (version() < 4500) {
560  return getFloat();
561  } else {
562  char sch( getChar() );
563  unsigned char ch( sch );
564  return ( (float) ch )/255.0;
565  }
566 }
567 
568 void NetBuffer::addDouble( double d )
569 {
570  ADD_NB( NB_DOUBLE );
571  int tmpsize = sizeof (d);
572  resizeBuffer( offset+tmpsize );
573  POSH_DoubleBits( d, (posh_byte_t*) this->buffer+offset );
574  offset += tmpsize;
575 }
576 
578 {
579  CHECK_NB( NB_DOUBLE );
580  double s;
581  if ( !checkBuffer( sizeof (s), "getDouble" ) )
582  return 0;
583  s = POSH_DoubleFromBits( (posh_byte_t*) this->buffer+offset );
584  offset += sizeof (s);
585  return s;
586 }
587 
588 void NetBuffer::addShort( unsigned short s )
589 {
590  ADD_NB( NB_SHORT );
591  int tmpsize = sizeof (s);
592  resizeBuffer( offset+tmpsize );
593  POSH_WriteU16ToBig( this->buffer+offset, s );
594  offset += tmpsize;
595 }
596 
597 unsigned short NetBuffer::getShort()
598 {
599  CHECK_NB( NB_SHORT );
600  unsigned short s;
601  if ( !checkBuffer( sizeof (s), "getShort" ) )
602  return 0;
603  s = POSH_ReadU16FromBig( this->buffer+offset );
604  //cerr<<"getShort :: offset="<<offset<<" - length="<<sizeof( s)<<" - value="<<s<<endl;
605  offset += sizeof (s);
606  return s;
607 }
608 
609 void NetBuffer::addInt32( int i )
610 {
611  ADD_NB( NB_INT32 );
612  int tmpsize = sizeof (i);
613  resizeBuffer( offset+tmpsize );
614  POSH_WriteS32ToBig( this->buffer+offset, i );
615  offset += tmpsize;
616 }
617 
619 {
620  CHECK_NB( NB_INT32 );
621  int s;
622  if ( !checkBuffer( sizeof (s), "getInt32" ) )
623  return 0;
624  s = POSH_ReadS32FromBig( this->buffer+offset );
625  offset += sizeof (s);
626  return s;
627 }
628 
629 void NetBuffer::addUInt32( unsigned int i )
630 {
631  ADD_NB( NB_UINT32 );
632  int tmpsize = sizeof (i);
633  resizeBuffer( offset+tmpsize );
634  POSH_WriteU32ToBig( this->buffer+offset, i );
635  offset += tmpsize;
636 }
637 
638 unsigned int NetBuffer::getUInt32()
639 {
640  CHECK_NB( NB_UINT32 );
641  unsigned int s;
642  if ( !checkBuffer( sizeof (s), "getUInt32" ) )
643  return 0;
644  s = POSH_ReadU32FromBig( this->buffer+offset );
645  offset += sizeof (s);
646  return s;
647 }
648 
649 void NetBuffer::addChar( char c )
650 {
651  ADD_NB( NB_CHAR );
652  int tmpsize = sizeof (c);
653  resizeBuffer( offset+tmpsize );
654  VsnetOSS::memcpy( buffer+offset, &c, sizeof (c) );
655  offset += tmpsize;
656 }
657 
659 {
660  CHECK_NB( NB_CHAR );
661  char c;
662  if ( !checkBuffer( sizeof (c), "getChar" ) )
663  return 0;
664  VsnetOSS::memcpy( &c, buffer+offset, sizeof (c) );
665  offset += sizeof (c);
666  return c;
667 }
668 
669 void NetBuffer::addBuffer( const unsigned char *buf, int bufsize )
670 {
671  ADD_NB( NB_BUFFER );
672  resizeBuffer( offset+bufsize );
673  VsnetOSS::memcpy( buffer+offset, buf, bufsize );
674  offset += bufsize;
675 }
676 
677 unsigned char* NetBuffer::extAddBuffer( int bufsize )
678 {
679  ADD_NB( NB_BUFFER );
680  resizeBuffer( offset+bufsize );
681  unsigned char *retval = (unsigned char*) buffer+offset;
682  offset += bufsize;
683  return retval;
684 }
685 
686 static unsigned char null = '\0';
687 
688 unsigned char* NetBuffer::getBuffer( int offt )
689 {
690  CHECK_NB( NB_BUFFER );
691  if ( !checkBuffer( offt, "getBuffer" ) )
692  return &null;
693  unsigned char *tmp = (unsigned char*) buffer+offset;
694  offset += offt;
695  return tmp;
696 }
697 
698 //Add and get a string with its length before the char * buffer part
699 void NetBuffer::addString( const string &str )
700 {
701  ADD_NB( NB_STRING );
702  unsigned int len = str.length();
703  if (len < 0xffff) {
704  unsigned short length = len;
705  this->addShort( length );
706  resizeBuffer( offset+length );
707  VsnetOSS::memcpy( buffer+offset, str.c_str(), length );
708  offset += length;
709  } else {
710  assert( len < 0xffffffff );
711  this->addShort( 0xffff );
712  this->addInt32( len );
713  resizeBuffer( offset+len );
714  VsnetOSS::memcpy( buffer+offset, str.c_str(), len );
715  offset += len;
716  }
717 }
718 
720 {
721  CHECK_NB( NB_STRING );
722  unsigned short s;
723  s = this->getShort();
724  if (s != 0xffff) {
725  if ( !checkBuffer( s, "getString" ) )
726  return std::string();
727  char c = buffer[offset+s];
728  buffer[offset+s] = 0;
729  string str( buffer+offset );
730  buffer[offset+s] = c;
731  offset += s;
732 
733  return str;
734  } else {
735  //NETFIXME: Possible DOS attack here...
736  unsigned int len = this->getInt32();
737  if ( !checkBuffer( len, "getString" ) )
738  return std::string();
739  char c = buffer[offset+len];
740  buffer[offset+len] = 0;
741  string str( buffer+offset );
742  buffer[offset+len] = c;
743  offset += len;
744 
745  return str;
746  }
747 }
748 
750 {
751  CHECK_NB( NB_GFXMAT );
752  GFXMaterial mat;
753 
754  mat.ar = this->getFloat();
755  mat.ag = this->getFloat();
756  mat.ab = this->getFloat();
757  mat.aa = this->getFloat();
758 
759  mat.dr = this->getFloat();
760  mat.dg = this->getFloat();
761  mat.db = this->getFloat();
762  mat.da = this->getFloat();
763 
764  mat.sr = this->getFloat();
765  mat.sg = this->getFloat();
766  mat.sb = this->getFloat();
767  mat.sa = this->getFloat();
768 
769  mat.er = this->getFloat();
770  mat.eg = this->getFloat();
771  mat.eb = this->getFloat();
772  mat.ea = this->getFloat();
773 
774  mat.power = this->getFloat();
775  return mat;
776 }
777 
779 {
780  ADD_NB( NB_GFXMAT );
781  this->addFloat( mat.ar );
782  this->addFloat( mat.ag );
783  this->addFloat( mat.ab );
784  this->addFloat( mat.aa );
785 
786  this->addFloat( mat.dr );
787  this->addFloat( mat.dg );
788  this->addFloat( mat.db );
789  this->addFloat( mat.da );
790 
791  this->addFloat( mat.sr );
792  this->addFloat( mat.sg );
793  this->addFloat( mat.sb );
794  this->addFloat( mat.sa );
795 
796  this->addFloat( mat.er );
797  this->addFloat( mat.eg );
798  this->addFloat( mat.eb );
799  this->addFloat( mat.ea );
800 
801  this->addFloat( mat.power );
802 }
803 
805 {
807  GFXLight light;
808  int i = 0;
809  light.target = this->getInt32();
810  for (i = 0; i < 3; i++)
811  light.vect[i] = this->getFloat();
812  light.options = this->getInt32();
813  for (i = 0; i < 4; i++)
814  light.diffuse[i] = this->getFloat();
815  for (i = 0; i < 4; i++)
816  light.specular[i] = this->getFloat();
817  for (i = 0; i < 4; i++)
818  light.ambient[i] = this->getFloat();
819  for (i = 0; i < 3; i++)
820  light.attenuate[i] = this->getFloat();
821  for (i = 0; i < 3; i++)
822  light.direction[i] = this->getFloat();
823  light.exp = this->getFloat();
824  light.cutoff = this->getFloat();
825 
826  return light;
827 }
828 
829 void NetBuffer::addGFXLight( const GFXLight &light )
830 {
831  ADD_NB( NB_GFXLIGHT );
832  int i = 0;
833  this->addInt32( light.target );
834  for (i = 0; i < 3; i++)
835  this->addFloat( light.vect[i] );
836  this->addInt32( light.options );
837  for (i = 0; i < 4; i++)
838  this->addFloat( light.diffuse[i] );
839  for (i = 0; i < 4; i++)
840  this->addFloat( light.specular[i] );
841  for (i = 0; i < 4; i++)
842  this->addFloat( light.ambient[i] );
843  for (i = 0; i < 3; i++)
844  this->addFloat( light.attenuate[i] );
845  for (i = 0; i < 3; i++)
846  this->addFloat( light.direction[i] );
847  this->addFloat( light.exp );
848  this->addFloat( light.cutoff );
849 }
850 
852 {
854  GFXLightLocal light;
855  light.ligh = this->getGFXLight();
856  light.islocal = this->getChar();
857  return light;
858 }
859 
861 {
863  this->addGFXLight( light.ligh );
864  this->addChar( light.islocal );
865 }
866 
868 {
869  return offset;
870 }
871 
872 unsigned int NetBuffer::getSize()
873 {
874  return size;
875 }
876