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
vsnet_clientstate.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 VSNET_CLIENTSTATE_H
22 #define VSNET_CLIENTSTATE_H
23 
24 #include <iostream>
25 #include <string.h>
26 #include "gfx/quaternion.h"
27 #include "networking/const.h"
28 #include "configxml.h"
29 
30 class Unit;
31 class NetBuffer;
32 
33 //Structure used to transmit client updates
35 {
36 //float delay;
37  ObjSerial client_serial;
38  Transformation pos;
39  Vector veloc;
40 //NO longer supproted--wasnt indicative of actual accel Vector accel;
41  Vector angveloc;
42 
43  float SPECRampCounter; //negative means ramping down
44  float SPECWarpMultiplier; //=1.0 and RampCounter=0 means !InWarp
45 public: ClientState();
46  ClientState( ObjSerial serial );
47  ClientState( ObjSerial serial, QVector posit, Quaternion orientat, Vector velocity, Vector acc, Vector angvel );
48  ClientState( ObjSerial serial,
49  QVector posit,
50  Quaternion orientat,
51  Vector velocity,
52  Vector acc,
53  Vector angvel,
54  unsigned int del );
55  ClientState( ObjSerial serial, Transformation trans, Vector velocity, Vector acc, Vector angvel, unsigned int del );
56  ClientState( const Unit *un );
57 
58  const QVector& getPosition() const
59  {
60  return this->pos.position;
61  }
62  const Quaternion& getOrientation() const
63  {
64  return this->pos.orientation;
65  }
67  {
68  return this->pos;
69  }
70  const Vector& getVelocity() const
71  {
72  return this->veloc;
73  }
74  const Vector& getAngularVelocity() const
75  {
76  return this->angveloc;
77  }
78  float getSpecRamp() const
79  {
80  return this->SPECRampCounter;
81  }
82  float getSpecMult() const
83  {
84  return this->SPECWarpMultiplier;
85  }
86 //NO longer supported--wasn't indicative of actual aggregated accel Vector getAcceleration() const { retu //rn if you change this, change setAcceleration too, and all consturctor this->accel;}
87  void setAcceleration( Vector acc ) {}
88 
89  void setUnitState( Unit *un ) const;
90 
92  {
93  return this->client_serial;
94  }
95 //float getDelay() const { return this->delay;}
96 //void setDelay( float del) { this->delay = del;}
97  void setSerial( ObjSerial ser )
98  {
99  this->client_serial = ser;
100  }
101  void setPosition( QVector posit )
102  {
103  this->pos.position = posit;
104  }
105  void setOrientation( Quaternion orient )
106  {
107  this->pos.orientation = orient;
108  }
109  void setVelocity( Vector vel )
110  {
111  this->veloc = vel;
112  }
114  {
115  this->angveloc = vel;
116  }
117  void setSpecRamp( float rc )
118  {
119  this->SPECRampCounter = rc;
120  }
121  void setSpecMult( float wfm )
122  {
123  this->SPECWarpMultiplier = wfm;
124  }
125 
126  void display( std::ostream &ostr ) const;
127  void display() const;
128  int operator==( const ClientState &ctmp ) const;
129 //void netswap();
130 
131  friend class NetBuffer;
132 };
133 
134 std::ostream&operator<<( std::ostream &ostr, const ClientState &cs );
135 
136 #endif
137