1 /*********************************************************************
2 Copyright 2013 Karl Jones
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 1. Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 For Further Information Please Contact me at
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 #include "./GED_BasicGroundCombatVehicle.h"
33 using namespace DATA_TYPE
;
34 using namespace ENUMS
;
35 using namespace UTILS
;
37 //////////////////////////////////////////////////////////////////////////
39 //////////////////////////////////////////////////////////////////////////
41 GED_BasicGroundCombatVehicle::GED_BasicGroundCombatVehicle() :
49 for( KINT8 i
= 0; i
< 3; ++i
)
56 //////////////////////////////////////////////////////////////////////////
58 GED_BasicGroundCombatVehicle::GED_BasicGroundCombatVehicle( KDataStream
& stream
)
63 //////////////////////////////////////////////////////////////////////////
65 GED_BasicGroundCombatVehicle::GED_BasicGroundCombatVehicle( KUINT16 ID
, KINT16 XOffset
, KINT16 YOffset
, KINT16 ZOffset
, const EntityAppearance
& EA
,
66 KINT8 Psi
, KINT8 Theta
, KINT8 Phi
, KINT8 Speed
, KINT8 TurretAzimuth
, KINT8 GunElevation
,
67 KINT8 TurretSlewRate
, KINT8 GunElevationRate
) :
71 m_i8TrrtAz( TurretAzimuth
),
72 m_i8GnElv( GunElevation
),
73 m_i8TrrtSlwRt( TurretSlewRate
),
74 m_i8GnElvRt( GunElevationRate
)
76 m_i16Offsets
[0] = XOffset
;
77 m_i16Offsets
[1] = YOffset
;
78 m_i16Offsets
[2] = ZOffset
;
84 //////////////////////////////////////////////////////////////////////////
86 GED_BasicGroundCombatVehicle::~GED_BasicGroundCombatVehicle()
90 //////////////////////////////////////////////////////////////////////////
92 GroupedEntityCategory
GED_BasicGroundCombatVehicle::GetGroupedEntityCategory() const
94 return BasicGroundCombatVehicleGEC
;
97 //////////////////////////////////////////////////////////////////////////
99 KUINT8
GED_BasicGroundCombatVehicle::GetLength() const
101 return GED_BASIC_GROUND_COMBAT_VEHICLE_SIZE
;
104 //////////////////////////////////////////////////////////////////////////
106 void GED_BasicGroundCombatVehicle::SetEntityID( KUINT16 ID
)
111 //////////////////////////////////////////////////////////////////////////
113 KUINT16
GED_BasicGroundCombatVehicle::GetEntityID() const
115 return m_ui16EntityID
;
118 //////////////////////////////////////////////////////////////////////////
120 void GED_BasicGroundCombatVehicle::SetEntityLocation( KINT16 XOffset
, KINT16 YOffset
, KINT16 ZOffset
)
122 m_i16Offsets
[0] = XOffset
;
123 m_i16Offsets
[1] = YOffset
;
124 m_i16Offsets
[2] = ZOffset
;
127 //////////////////////////////////////////////////////////////////////////
129 void GED_BasicGroundCombatVehicle::SetEntityLocation( KINT16 Offsets
[3] )
131 for( KUINT8 i
= 0; i
< 3; ++i
)
133 m_i16Offsets
[i
] = Offsets
[i
];
137 //////////////////////////////////////////////////////////////////////////
139 void GED_BasicGroundCombatVehicle::SetEntityLocationXOffset( KINT16 X
)
144 //////////////////////////////////////////////////////////////////////////
146 void GED_BasicGroundCombatVehicle::SetEntityLocationYOffset( KINT16 Y
)
151 //////////////////////////////////////////////////////////////////////////
153 void GED_BasicGroundCombatVehicle::SetEntityLocationZOffset( KINT16 Z
)
158 //////////////////////////////////////////////////////////////////////////
160 KINT16
GED_BasicGroundCombatVehicle::GetEntityLocationXOffset() const
162 return m_i16Offsets
[0];
165 //////////////////////////////////////////////////////////////////////////
167 KINT16
GED_BasicGroundCombatVehicle::GetEntityLocationYOffset() const
169 return m_i16Offsets
[1];
172 //////////////////////////////////////////////////////////////////////////
174 KINT16
GED_BasicGroundCombatVehicle::GetEntityLocationZOffset() const
176 return m_i16Offsets
[2];
179 //////////////////////////////////////////////////////////////////////////
181 void GED_BasicGroundCombatVehicle::SetEntityAppearance( const EntityAppearance
& EA
)
186 //////////////////////////////////////////////////////////////////////////
188 const EntityAppearance
& GED_BasicGroundCombatVehicle::GetEntityAppearance() const
193 //////////////////////////////////////////////////////////////////////////
195 EntityAppearance
& GED_BasicGroundCombatVehicle::GetEntityAppearance()
200 //////////////////////////////////////////////////////////////////////////
202 void GED_BasicGroundCombatVehicle::SetEntityOrientation( KINT8 Psi
, KINT8 Theta
, KINT8 Phi
)
209 //////////////////////////////////////////////////////////////////////////
211 void GED_BasicGroundCombatVehicle::SetEntityOrientation( KINT8 Ori
[3] )
213 for( KINT8 i
= 0; i
< 3; ++i
)
219 //////////////////////////////////////////////////////////////////////////
221 void GED_BasicGroundCombatVehicle::SetEntityOrientationPsi( KINT8 P
)
226 //////////////////////////////////////////////////////////////////////////
228 void GED_BasicGroundCombatVehicle::SetEntityOrientationTheta( KINT8 T
)
233 //////////////////////////////////////////////////////////////////////////
235 void GED_BasicGroundCombatVehicle::SetEntityOrientationPhi( KINT8 P
)
240 //////////////////////////////////////////////////////////////////////////
242 KINT8
GED_BasicGroundCombatVehicle::GetEntityOrientationPsi() const
247 //////////////////////////////////////////////////////////////////////////
249 KINT8
GED_BasicGroundCombatVehicle::GetEntityOrientationTheta() const
254 //////////////////////////////////////////////////////////////////////////
256 KINT8
GED_BasicGroundCombatVehicle::GetEntityOrientationPhi() const
261 //////////////////////////////////////////////////////////////////////////
263 void GED_BasicGroundCombatVehicle::SetSpeed( KINT8 S
)
268 //////////////////////////////////////////////////////////////////////////
270 KINT8
GED_BasicGroundCombatVehicle::GetSpeed() const
275 //////////////////////////////////////////////////////////////////////////
277 void GED_BasicGroundCombatVehicle::SetTurretAzimuth( KINT8 T
)
282 //////////////////////////////////////////////////////////////////////////
284 KINT8
GED_BasicGroundCombatVehicle::GetTurretAzimuth() const
289 //////////////////////////////////////////////////////////////////////////
291 void GED_BasicGroundCombatVehicle::SetGunElevation( KINT8 G
)
296 //////////////////////////////////////////////////////////////////////////
298 KINT8
GED_BasicGroundCombatVehicle::GetGunElevation() const
303 //////////////////////////////////////////////////////////////////////////
305 void GED_BasicGroundCombatVehicle::SetTurretSlewRate( KINT8 T
)
310 //////////////////////////////////////////////////////////////////////////
312 KINT8
GED_BasicGroundCombatVehicle::GetTurretSlewRate() const
314 return m_i8TrrtSlwRt
;
317 //////////////////////////////////////////////////////////////////////////
319 void GED_BasicGroundCombatVehicle::SetGunElevationRate( KINT8 G
)
324 //////////////////////////////////////////////////////////////////////////
326 KINT8
GED_BasicGroundCombatVehicle::GetGunElevationRate() const
331 //////////////////////////////////////////////////////////////////////////
333 KString
GED_BasicGroundCombatVehicle::GetAsString() const
337 ss
<< "GED Basic Ground Combat Vehicle\n"
338 << "\tEntity ID: " << m_ui16EntityID
<< "\n"
339 << "\tLocation Offsets(x,y,z): " << m_i16Offsets
[0] << " " << m_i16Offsets
[1] << " " << m_i16Offsets
[2] << "\n"
340 << IndentString( m_EA
.GetAsString( EntityType( Platform
, Land
, 0, 0, 0, 0, 0 ) ), 1 )
341 << "\tOrientation(Psi,Theta,Phi): " << ( KINT16
)m_i8Ori
[0] << " " << ( KINT16
)m_i8Ori
[1] << " " << ( KINT16
)m_i8Ori
[2] << "\n"
342 << "\tSpeed: " << ( KINT16
)m_i8Spd
<< "m/s\n"
343 << "\tTurret Azimuth: " << ( KINT16
)m_i8TrrtAz
<< "\n"
344 << "\tGun Elevation: " << ( KINT16
)m_i8GnElv
<< "\n"
345 << "\tTurret Slew Rate: " << ( KINT16
)m_i8TrrtSlwRt
<< "\n"
346 << "\tGun Elevation Rate: " << ( KINT16
)m_i8GnElvRt
<< "\n";
351 //////////////////////////////////////////////////////////////////////////
353 void GED_BasicGroundCombatVehicle::Decode( KDataStream
& stream
)
355 if( stream
.GetBufferSize() < GED_BASIC_GROUND_COMBAT_VEHICLE_SIZE
)throw KException( __FUNCTION__
, NOT_ENOUGH_DATA_IN_BUFFER
);
357 stream
>> m_ui16EntityID
372 //////////////////////////////////////////////////////////////////////////
374 KDataStream
GED_BasicGroundCombatVehicle::Encode() const
378 GED_BasicGroundCombatVehicle::Encode( stream
);
383 //////////////////////////////////////////////////////////////////////////
385 void GED_BasicGroundCombatVehicle::Encode( KDataStream
& stream
) const
387 stream
<< m_ui16EntityID
402 //////////////////////////////////////////////////////////////////////////
404 KBOOL
GED_BasicGroundCombatVehicle::operator == ( const GED_BasicGroundCombatVehicle
& Value
) const
406 if( m_ui16EntityID
!= Value
.m_ui16EntityID
) return false;
407 if( m_i16Offsets
[0] != Value
.m_i16Offsets
[0] ) return false;
408 if( m_i16Offsets
[1] != Value
.m_i16Offsets
[1] ) return false;
409 if( m_i16Offsets
[2] != Value
.m_i16Offsets
[2] ) return false;
410 if( m_EA
!= Value
.m_EA
) return false;
411 if( m_i8Ori
[0] != Value
.m_i8Ori
[0] ) return false;
412 if( m_i8Ori
[1] != Value
.m_i8Ori
[1] ) return false;
413 if( m_i8Ori
[2] != Value
.m_i8Ori
[2] ) return false;
414 if( m_i8Spd
!= Value
.m_i8Spd
) return false;
415 if( m_i8TrrtAz
!= Value
.m_i8TrrtAz
) return false;
416 if( m_i8GnElv
!= Value
.m_i8GnElv
) return false;
417 if( m_i8TrrtSlwRt
!= Value
.m_i8TrrtSlwRt
) return false;
418 if( m_i8GnElvRt
!= Value
.m_i8GnElvRt
) return false;
422 //////////////////////////////////////////////////////////////////////////
424 KBOOL
GED_BasicGroundCombatVehicle::operator != ( const GED_BasicGroundCombatVehicle
& Value
) const
426 return !( *this == Value
);
429 //////////////////////////////////////////////////////////////////////////