1 /*
2
3 *************************************************************************
4
5 ArmageTron -- Just another Tron Lightcycle Game in 3D.
6 Copyright (C) 2004 Armagetron Advanced Team (http://sourceforge.net/projects/armagetronad/)
7
8 **************************************************************************
9
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 ***************************************************************************
25
26 */
27
28 #ifndef ARMAGETRONAD_SRC_TRON_GCYCLEMOVEMENT_H_INCLUDED
29 #define ARMAGETRONAD_SRC_TRON_GCYCLEMOVEMENT_H_INCLUDED
30
31 #include "eNetGameObject.h"
32 #include <deque>
33
34 class gCycle;
35 class gDestination;
36 class gPlayerWall;
37 class gCycleMovement;
38 class gSensor;
39 struct gMaxSpaceAheadHitInfo;
40
41 //! used to clear out dangerous information from hit info after simulation is done
42 class gMaxSpaceAheadHitInfoClearer
43 {
44 public:
45 gMaxSpaceAheadHitInfoClearer( gMaxSpaceAheadHitInfo * & info );
46 ~gMaxSpaceAheadHitInfoClearer();
47 private:
48 gMaxSpaceAheadHitInfo * & info_;
49 };
50
51 REAL GetTurnSpeedFactor(void);
52
53 class gEnemyInfluence{
54 private:
55 nObserverPtr< ePlayerNetID > lastEnemyInfluence; // the last enemy wall we encountered
56 REAL lastTime; // the time it was drawn at
57
58 public:
59 gEnemyInfluence();
60
61 ePlayerNetID const * GetEnemy() const; // the last enemy possibly responsible for our death
62 REAL GetTime() const; // the time of the influence
63 void AddSensor( const gSensor& sensor, REAL timePenalty, gCycleMovement * thisCycle ); // add the result of the sensor scan to our data
64 void AddWall( const eWall * wall, eCoord const & point, REAL timePenalty, gCycleMovement * thisCycle ); // add the interaction with a wall to our data
65 void AddWall( const gPlayerWall * wall, REAL timeBuilt, gCycleMovement * thisCycle ); // add the interaction with a wall to our data
66 };
67
68 struct gRealColor {
69 REAL r,g,b;
70
gRealColorgRealColor71 gRealColor():r(1), g(1), b(1){}
72
73 };
74
75 //! class handling lightcycle movement aspects ( not networking beyond construction, no rendering, no wall building )
76 class gCycleMovement : public eNetGameObject
77 {
78 public:
79 // accessors
80 static float RubberSpeed () ; //!< returns the rubber speed (decay rate of the distance to the wall in front)
81 static float SpeedMultiplier () ; //!< returns the current speed multiplier
82 static void SetSpeedMultiplier ( REAL mult ) ; //!< sets the current speed multiplier
83 static float MaximalSpeed () ; //!< returns the maximal speed a cycle can reach on its own
84
85 // AI info
86 int WindingNumber () const ; //!< returns the current winding number
87 void SetWindingNumberWrapped ( int newWindingNumberWrapped ) ; //!< sets the new wrapped winding number
88
89 // information about physics state
90 virtual eCoord Direction () const ; //!< returns the current driving direction
91 virtual eCoord LastDirection () const ; //!< returns the last driving direction
92 virtual REAL Speed () const ; //!< returns the current speed
93 virtual bool Alive () const ; //!< returns whether the cycle is still alive
94 virtual bool Vulnerable () const ; //!< returns whether the cycle can be killed
95
96 bool CanMakeTurn (int direction) const ; //!< returns whether a turn is currently possible
97 bool CanMakeTurn ( REAL time, int direction ) const ; //!< returns whether a turn is possible at the given time
98 inline REAL GetDistanceSinceLastTurn( ) const ; //!< returns the distance since the last turn
99 REAL GetTurnDelay ( ) const ; //!< returns the time between turns in different directions
100 REAL GetTurnDelayDb ( ) const ; //!< returns the time between turns in the same direcion
101 REAL GetNextTurn (int direction ) const ; //!< returns the time of the next turn
102
103 // destination handling
104 void AddDestination () ; //!< adds current position as destination
105 void AdvanceDestination () ; //!< proceeds to the next destination
106 void AddDestination ( gDestination * dest ) ; //!< adds given destination
107 gDestination* GetCurrentDestination () const ; //!< returns the current destination
108 void NotifyNewDestination ( gDestination * dest ) ; //!< notifies cycle of the insertion of a new destination ( don't call manually )
109 bool IsDestinationUsed ( const gDestination * dest ) const ; //!< returns whether the given destination is in active use
110
111 inline void DropTempWall ( gPlayerWall * wall
112 , eCoord const & pos
113 , eCoord const & dir ) ; //!< called when another cycle grinds a wall; this cycle should then drop its current wall if the grinding is too close.
114 // information query
115 virtual bool EdgeIsDangerous ( const eWall * wall
116 , REAL time
117 , REAL alpha ) const ; //!< returns whether a given wall is dangerous to this cycle
118
119 // movement commands
120 bool Turn ( REAL dir ) ; //!< Turn left for positive argument, right for negative argument
121 bool Turn ( int dir ) ; //!< Turn left for positive argument, right for negative argument
122
123 void MoveSafely (const eCoord & dest
124 , REAL startTime
125 , REAL endTime ) ; //!< move without throwing exceptions on passing a wall
126
127 virtual bool Timestep ( REAL currentTime ) ; //!< advance to the given time
128
129 virtual REAL NextInterestingTime () const ; //!< the next time something interesting is going to happen with this object
130
131 // existence management
132 virtual void AddRef () ; //!< increase reference count
133
134 gCycleMovement ( eGrid * grid
135 , const eCoord & pos
136 , const eCoord & dir
137 , ePlayerNetID * p=NULL
138 , bool autodelete=1 ) ; //!< local constructor
139 gCycleMovement ( nMessage & message ) ; //!< remote constructor
140 virtual ~gCycleMovement () ; //!< destructor
141 virtual void OnRemoveFromGame(); // called when the cycle is physically removed from the game
142
143 void RequestSync(bool ack=true); //!< request a sync
144 void RequestSync(int user,bool ack); //!< only for a single user
145 protected:
146 //! data from sync message
147 struct SyncData
148 {
149 eCoord pos, dir, lastTurn;
150 REAL distance, speed, time, rubber, rubberMalus, brakingReservoir;
151 unsigned short turns,braking,messageID;
152
SyncDataSyncData153 SyncData()
154 :distance(0), speed(0), time(-10000), rubber(0), rubberMalus(0), brakingReservoir(0)
155 ,turns(0),braking(0),messageID(0)
156 {}
157 };
158
159 void CopyFrom ( const gCycleMovement & other ) ; //!< copies relevant info from other cylce
160
161 void CopyFrom ( const SyncData & sync
162 , const gCycleMovement & other ) ; //!< copies relevant info from sync data and everything else from other cycle
163
164 virtual void InitAfterCreation () ; //!< shared initialization routine
165
166 // acceleration handling
167 virtual void AccelerationDiscontinuity () ; //!< call when you know the acceleration makes a sharp jump now
168 virtual void CalculateAcceleration ( ) ; //!< calculate acceleration to apply later
169 virtual void ApplyAcceleration ( REAL dt ) ; //!< apply acceleration calculated earlier
170
171 // destination handling
172 REAL DistanceToDestination ( gDestination & dest ) const ; //!< calculates the distance to the given destination
173 virtual void OnNotifyNewDestination ( gDestination * dest ) ; //!< notifies cycle of the insertion of a new destination
174 virtual void OnDropTempWall ( gPlayerWall * wall
175 , eCoord const & pos
176 , eCoord const & dir ) ; //!< called when another cycle grinds a wall; this cycle should then drop its current wall if the grinding is too close.
177 virtual bool DoIsDestinationUsed ( const gDestination * dest ) const ; //!< returns whether the given destination is in active use
178 static gDestination* GetDestinationBefore ( const SyncData & sync
179 , gDestination* first ) ; //!< determine the destination from before the sync message
180
181 virtual bool DoTurn ( int dir ) ; //!< turns the cycle in the given direction
182 virtual REAL DoGetDistanceSinceLastTurn ( ) const ; //!< returns the distance since the last turn
183
184 virtual void RightBeforeDeath ( int numTries ) ; //!< called when the cycle is very close to a wall and about to crash
185 virtual void Die ( REAL time ) ; //!< dies at the specified time
186
187 virtual bool TimestepCore ( REAL currentTime
188 , bool calculateAcceleration = true ) ; //!< core physics simulation routine
189 private:
190 void MyInitAfterCreation () ; //!< private shared initialization code
191
192 // void Init_gCycleCore () ; //!< initialisation function
193 // void Finit_gCycleCore () ; //!< finalisation function
194
195 gCycleMovement () ; //!< default constructor
196 gCycleMovement ( gCycleMovement const & other ) ; //!< copy constructor
197 gCycleMovement& operator = ( gCycleMovement const & other ) ; //!< copy operator
198
199 private:
200 short alive_; //!< status: 1: cycle is alive, -1: cycle just died, 0: cycle is dead
201
202 protected:
203 gEnemyInfluence enemyInfluence; //!< keeps track of enemies that influenced this cycle
204
205 gDestination* destinationList; //!< the list of destinations that belong to this cycle ( for memory management )
206 gDestination* currentDestination; //!< the destination this cycle aims for now
207 gDestination* lastDestination; //!< the last destination that was passed
208
209 eCoord dirDrive; //!< the direction we are facing
210 eCoord lastDirDrive; //!< the direction we were facing before the last turn
211 REAL acceleration; //!< current acceleration
212
213 REAL lastTimestep_; //!< the length of the last timestep
214 REAL verletSpeed_; //!< object speed according to verlet (speed of half a frame ago)
215
216 REAL distance; //!< the distance traveled so far
217 // REAL wallContDistance; //!< distance at which the walls will start to build up ( negative if the wall is already building )
218
219 mutable bool refreshSpaceAhead_; //!< flag to set when maximum space in front of cycle should be recalculated
220 REAL maxSpaceMaxCast_; //!< the maximum raycast length to determine the above value
221 mutable gMaxSpaceAheadHitInfo * maxSpaceHit_; //!< detailed information about the wall in front
222
223 unsigned short turns; //!< the number of turns taken so far
224 unsigned short braking; //!< flag indicating status of brakes ( on/off )
225
226 int windingNumber_; //!< number that gets increased on every right turn and decreased on every left turn ( used by the AI )
227 int windingNumberWrapped_; //!< winding number wrapped to be used as an index to the axes code
228
229 mutable REAL gap_[2]; //!< when driving towards a wall, this is set to the maximal distance we need to approach it so that when the cycle turns, it can squeeze through any gaps
230 mutable bool keepLookingForGap_[2]; //!< flags telling the system whether it is worthwile to look for further, smaller, gaps
231
232 eCoord lastTurnPos_; //!< the location of the last turn
233 REAL lastTurnTimeRight_; //!< the time of the last turn right
234 REAL lastTurnTimeLeft_; //!< the time of the last turn left
235 REAL lastTimeAlive_; //!< the time of the last timestep where we would not have been killed
236 std::deque<int> pendingTurns; //!< stores turns ordered by the user, but not yet executed
237
238 REAL brakingReservoir; //!< the reservoir for braking. 1 means full, 0 is empty
239 REAL rubber; //!< the amount rubber used up by the cycle
240 REAL rubberMalus; //!< additional rubber usage factor
241 REAL rubberSpeedFactor; //!< the factor by which the speed is currently multiplied by rubber
242 REAL rubberDepleteTime_; //!< the time rubber got depleted
243
244 REAL brakeUsage; //!< current brake usage
245 REAL rubberUsage; //!< current rubber usage (not from hitting a wall, but from tunneling. Without taking efficiency into account.)
246
247 // room for accessors
248 public:
249 REAL RubberDepleteTime() const; //!< returns the time rubber got fully used (or 0 if it hasn't)
250
251 REAL GetMaxSpaceAhead( REAL maxReport ) const; //< Returns the current maximal space ahead
252
253 inline REAL GetDistance( void ) const; //!< Gets the distance traveled so far
254 inline gCycleMovement const & GetDistance( REAL & distance ) const; //!< Gets the distance traveled so far
255 inline REAL GetRubber( void ) const; //!< Gets the amount rubber used up by the cycle
256 inline gCycleMovement const & GetRubber( REAL & rubber ) const; //!< Gets the amount rubber used up by the cycle
257 inline unsigned short GetTurns( void ) const; //!< Gets the number of turns taken so far
258 inline gCycleMovement const & GetTurns( unsigned short & turns ) const; //!< Gets the number of turns taken so far
259 inline unsigned short GetBraking( void ) const; //!< Gets flag indicating status of brakes ( on/off )
260 inline gCycleMovement const & GetBraking( unsigned short & braking ) const; //!< Gets flag indicating status of brakes ( on/off )
261 inline REAL GetBrakingReservoir( void ) const; //!< Gets the reservoir for braking. 1 means full, 0 is empty
262 inline gCycleMovement const & GetBrakingReservoir( REAL & brakingReservoir ) const; //!< Gets the reservoir for braking. 1 means full, 0 is empty
263 inline REAL GetRubberMalus( void ) const; //!< Gets additional rubber usage factor
264 inline gCycleMovement const & GetRubberMalus( REAL & rubberMalus ) const; //!< Gets additional rubber usage factor
265 static bool RubberMalusActive( void ) ; //!< Returns whether rubber malus code is active
266 inline eCoord const & GetLastTurnPos( void ) const; //!< Gets the location of the last turn
267 inline gCycleMovement const & GetLastTurnPos( eCoord & lastTurnPos ) const; //!< Gets the location of the last turn
268 inline REAL const & GetLastTurnTime( void ) const; //!< Gets the time of the last turn
269 inline gCycleMovement const & GetLastTurnTime( REAL & lastTurnTime ) const; //!< Gets the time of the last turn
270 protected:
271 inline gCycleMovement & SetLastTurnPos( eCoord const & lastTurnPos ); //!< Sets the location of the last turn
272 inline gCycleMovement & SetLastTurnTime( REAL const & lastTurnTime ); //!< Sets the time of the last turn
273 private:
274 inline gCycleMovement & SetDistance( REAL distance ); //!< Sets the distance traveled so far
275 inline gCycleMovement & SetRubber( REAL rubber ); //!< Sets the amount rubber used up by the cycle
276 inline gCycleMovement & SetTurns( unsigned short turns ); //!< Sets the number of turns taken so far
277 inline gCycleMovement & SetBraking( unsigned short braking ); //!< Sets flag indicating status of brakes ( on/off )
278 inline gCycleMovement & SetBrakingReservoir( REAL brakingReservoir ); //!< Sets the reservoir for braking. 1 means full, 0 is empty
279 inline gCycleMovement & SetRubberMalus( REAL rubberMalus ); //!< Sets additional rubber usage factor
280 };
281
282 //! Determines the maximum space ahead of a cycle
283 // float MaxSpaceAhead( const gCycleMovement* cycle, float ts, float lookAhead, float maxReport );
284
285 //! Exception to throw when cycle dies in a simulation frame
286 class gCycleDeath: public eDeath
287 {
288 public:
gCycleDeath(eCoord const & pos)289 gCycleDeath( eCoord const & pos )
290 : pos_(pos)
291 {}
292
293 eCoord pos_;
294 };
295
296 //! Exception thrown to indicate simulation should be held for a while
297 class gCycleStop: public eDeath
298 {
299 };
300
301 // this class describes a point on the map the cycle on another
302 // computer of the game IS at. The copies of the cycle on the
303 // other computers try to reach this position by making the right
304 // turns.
305 class gDestination{
306 friend class gCycleMovement;
307 friend class gCycle; // todo: remove me
308 friend class gCycleExtrapolator; // todo: remove me
309
310 eCoord position; // position of turn/brake command
311 eCoord direction; // driving direction after the command
312 REAL gameTime; // game time of the command
313 REAL distance; // distance travelled so far
314 REAL speed; // speed at the time of the command
315 bool braking; // flag telling whether the brake was active
316 bool chatting; // flag indicating chat status
317
318 unsigned short turns; // the number of turns taken by the cycle so far
319 bool hasBeenUsed; // flag indicating whether the sync code has already used this command
320 unsigned short messageID; // ID of the message this command came from
321 bool missable; // flag indicating that this destination is not to be treated as the one after a missed destination
322
323 gDestination *next; // so they can form a list
324 gDestination **list; // the list we are in
325 public:
326 // take pos,dir and time from a cycle
327 explicit gDestination(const gCycleMovement &takeitfrom);
328 explicit gDestination(const gCycle &takeitfrom);
329
330 // or from a message
331 explicit gDestination( nMessage &m, unsigned short & cycle_id );
332
333 // take pos,dir and time from a cycle
334 void CopyFrom(const gCycleMovement &other);
335 void CopyFrom(const gCycle &other);
336
337 //! compare two destinations
338 int CompareWith( const gDestination& other ) const;
339
340 // write all the data into a nMessage
341 void WriteCreate( nMessage &m, unsigned short cycle_id );
342
343 // insert yourself into a list ordered by distance
344 void InsertIntoList(gDestination **list);
345
346 // find the latest entry in a list before the given distance
347 static gDestination *RightBefore(gDestination *list, REAL dist);
348
349 // find the earliest entry in a list after the given distance
350 static gDestination *RightAfter(gDestination *list, REAL dist);
351
352 // remove yourself again
353 void RemoveFromList();
354
Chatting()355 bool Chatting(){ return chatting; }
356
~gDestination()357 ~gDestination(){RemoveFromList();}
358
359 gDestination & SetGameTime( REAL gameTime ); //!< Sets game time of the command
360 REAL GetGameTime( void ) const; //!< Gets game time of the command
361 gDestination const & GetGameTime( REAL & gameTime ) const; //!< Gets game time of the command
362 };
363
364 // *******************************************************************************************
365 // *
366 // * IsDestinationUsed
367 // *
368 // *******************************************************************************************
369 //!
370 //! @param dest the destination to test
371 //! @return true if the destination is still in active use
372 //!
373 // *******************************************************************************************
374
IsDestinationUsed(const gDestination * dest)375 inline bool gCycleMovement::IsDestinationUsed( const gDestination * dest ) const
376 {
377 // delegate to virtual function
378 return DoIsDestinationUsed( dest );
379 }
380
381 // *******************************************************************************************
382 // *
383 // * DropTempWall
384 // *
385 // *******************************************************************************************
386 //!
387 //! @param wall the wall the other cycle is grinding
388 //! @param pos the position of the grind
389 //! @param dir the direction the raycast triggering the gridding comes from
390 //!
391 // *******************************************************************************************
392
DropTempWall(gPlayerWall * wall,eCoord const & pos,eCoord const & dir)393 inline void gCycleMovement::DropTempWall( gPlayerWall * wall, eCoord const & pos, eCoord const & dir )
394 {
395 this->OnDropTempWall( wall, pos, dir );
396 }
397
398 // *******************************************************************************************
399 // *
400 // * RubberDepleteTime
401 // *
402 // *******************************************************************************************
403 //!
404 //! @return the time rubber got depleted
405 //!
406 // *******************************************************************************************
RubberDepleteTime()407 inline REAL gCycleMovement::RubberDepleteTime() const
408 {
409 return rubberDepleteTime_;
410 }
411
412 // *******************************************************************************************
413 // *
414 // * GetDistance
415 // *
416 // *******************************************************************************************
417 //!
418 //! @return the distance traveled so far
419 //!
420 // *******************************************************************************************
421
GetDistance(void)422 inline REAL gCycleMovement::GetDistance( void ) const
423 {
424 return this->distance;
425 }
426
427 // *******************************************************************************************
428 // *
429 // * GetDistance
430 // *
431 // *******************************************************************************************
432 //!
433 //! @param distance the distance traveled so far to fill
434 //! @return A reference to this to allow chaining
435 //!
436 // *******************************************************************************************
437
GetDistance(REAL & distance)438 inline gCycleMovement const & gCycleMovement::GetDistance( REAL & distance ) const
439 {
440 distance = this->distance;
441 return *this;
442 }
443
444 // *******************************************************************************************
445 // *
446 // * SetDistance
447 // *
448 // *******************************************************************************************
449 //!
450 //! @param distance the distance traveled so far to set
451 //! @return A reference to this to allow chaining
452 //!
453 // *******************************************************************************************
454
SetDistance(REAL distance)455 inline gCycleMovement & gCycleMovement::SetDistance( REAL distance )
456 {
457 this->distance = distance;
458 return *this;
459 }
460
461 // *******************************************************************************************
462 // *
463 // * GetRubber
464 // *
465 // *******************************************************************************************
466 //!
467 //! @return the amount rubber used up by the cycle
468 //!
469 // *******************************************************************************************
470
GetRubber(void)471 inline REAL gCycleMovement::GetRubber( void ) const
472 {
473 return this->rubber;
474 }
475
476 // *******************************************************************************************
477 // *
478 // * GetRubber
479 // *
480 // *******************************************************************************************
481 //!
482 //! @param rubber the amount rubber used up by the cycle to fill
483 //! @return A reference to this to allow chaining
484 //!
485 // *******************************************************************************************
486
GetRubber(REAL & rubber)487 inline gCycleMovement const & gCycleMovement::GetRubber( REAL & rubber ) const
488 {
489 rubber = this->rubber;
490 return *this;
491 }
492
493 // *******************************************************************************************
494 // *
495 // * SetRubber
496 // *
497 // *******************************************************************************************
498 //!
499 //! @param rubber the amount rubber used up by the cycle to set
500 //! @return A reference to this to allow chaining
501 //!
502 // *******************************************************************************************
503
SetRubber(REAL rubber)504 inline gCycleMovement & gCycleMovement::SetRubber( REAL rubber )
505 {
506 this->rubber = rubber;
507 return *this;
508 }
509
510 // *******************************************************************************************
511 // *
512 // * GetTurns
513 // *
514 // *******************************************************************************************
515 //!
516 //! @return the number of turns taken so far
517 //!
518 // *******************************************************************************************
519
GetTurns(void)520 inline unsigned short gCycleMovement::GetTurns( void ) const
521 {
522 return this->turns;
523 }
524
525 // *******************************************************************************************
526 // *
527 // * GetTurns
528 // *
529 // *******************************************************************************************
530 //!
531 //! @param turns the number of turns taken so far to fill
532 //! @return A reference to this to allow chaining
533 //!
534 // *******************************************************************************************
535
GetTurns(unsigned short & turns)536 inline gCycleMovement const & gCycleMovement::GetTurns( unsigned short & turns ) const
537 {
538 turns = this->turns;
539 return *this;
540 }
541
542 // *******************************************************************************************
543 // *
544 // * SetTurns
545 // *
546 // *******************************************************************************************
547 //!
548 //! @param turns the number of turns taken so far to set
549 //! @return A reference to this to allow chaining
550 //!
551 // *******************************************************************************************
552
SetTurns(unsigned short turns)553 inline gCycleMovement & gCycleMovement::SetTurns( unsigned short turns )
554 {
555 this->turns = turns;
556 return *this;
557 }
558
559 // *******************************************************************************************
560 // *
561 // * GetBraking
562 // *
563 // *******************************************************************************************
564 //!
565 //! @return flag indicating status of brakes ( on/off )
566 //!
567 // *******************************************************************************************
568
GetBraking(void)569 inline unsigned short gCycleMovement::GetBraking( void ) const
570 {
571 return this->braking;
572 }
573
574 // *******************************************************************************************
575 // *
576 // * GetBraking
577 // *
578 // *******************************************************************************************
579 //!
580 //! @param braking flag indicating status of brakes ( on/off ) to fill
581 //! @return A reference to this to allow chaining
582 //!
583 // *******************************************************************************************
584
GetBraking(unsigned short & braking)585 inline gCycleMovement const & gCycleMovement::GetBraking( unsigned short & braking ) const
586 {
587 braking = this->braking;
588 return *this;
589 }
590
591 // *******************************************************************************************
592 // *
593 // * SetBraking
594 // *
595 // *******************************************************************************************
596 //!
597 //! @param braking flag indicating status of brakes ( on/off ) to set
598 //! @return A reference to this to allow chaining
599 //!
600 // *******************************************************************************************
601
SetBraking(unsigned short braking)602 inline gCycleMovement & gCycleMovement::SetBraking( unsigned short braking )
603 {
604 this->braking = braking;
605 return *this;
606 }
607
608 // *******************************************************************************************
609 // *
610 // * GetBrakingReservoir
611 // *
612 // *******************************************************************************************
613 //!
614 //! @return the reservoir for braking. 1 means full, 0 is empty
615 //!
616 // *******************************************************************************************
617
GetBrakingReservoir(void)618 inline REAL gCycleMovement::GetBrakingReservoir( void ) const
619 {
620 return this->brakingReservoir;
621 }
622
623 // *******************************************************************************************
624 // *
625 // * GetBrakingReservoir
626 // *
627 // *******************************************************************************************
628 //!
629 //! @param brakingReservoir the reservoir for braking. 1 means full, 0 is empty to fill
630 //! @return A reference to this to allow chaining
631 //!
632 // *******************************************************************************************
633
GetBrakingReservoir(REAL & brakingReservoir)634 inline gCycleMovement const & gCycleMovement::GetBrakingReservoir( REAL & brakingReservoir ) const
635 {
636 brakingReservoir = this->brakingReservoir;
637 return *this;
638 }
639
640 // *******************************************************************************************
641 // *
642 // * SetBrakingReservoir
643 // *
644 // *******************************************************************************************
645 //!
646 //! @param brakingReservoir the reservoir for braking. 1 means full, 0 is empty to set
647 //! @return A reference to this to allow chaining
648 //!
649 // *******************************************************************************************
650
SetBrakingReservoir(REAL brakingReservoir)651 inline gCycleMovement & gCycleMovement::SetBrakingReservoir( REAL brakingReservoir )
652 {
653 this->brakingReservoir = brakingReservoir;
654 return *this;
655 }
656
657 // *******************************************************************************************
658 // *
659 // * GetDistanceSinceLastTurn
660 // *
661 // *******************************************************************************************
662 //!
663 //! @return the distance driven since the last turn
664 //!
665 // *******************************************************************************************
666
GetDistanceSinceLastTurn(void)667 inline REAL gCycleMovement::GetDistanceSinceLastTurn( void ) const
668 {
669 return this->DoGetDistanceSinceLastTurn();
670 }
671
672 // *******************************************************************************************
673 // *
674 // * getRubberMalus
675 // *
676 // *******************************************************************************************
677 //!
678 //! @return additional rubber usage factor
679 //!
680 // *******************************************************************************************
681
GetRubberMalus(void)682 inline REAL gCycleMovement::GetRubberMalus( void ) const
683 {
684 return this->rubberMalus;
685 }
686
687 // *******************************************************************************************
688 // *
689 // * getRubberMalus
690 // *
691 // *******************************************************************************************
692 //!
693 //! @param rubberMalus additional rubber usage factor to fill
694 //! @return A reference to this to allow chaining
695 //!
696 // *******************************************************************************************
697
GetRubberMalus(REAL & rubberMalus)698 inline gCycleMovement const & gCycleMovement::GetRubberMalus( REAL & rubberMalus ) const
699 {
700 rubberMalus = this->rubberMalus;
701 return *this;
702 }
703
704 // *******************************************************************************************
705 // *
706 // * setRubberMalus
707 // *
708 // *******************************************************************************************
709 //!
710 //! @param rubberMalus additional rubber usage factor to set
711 //! @return A reference to this to allow chaining
712 //!
713 // *******************************************************************************************
714
SetRubberMalus(REAL rubberMalus)715 inline gCycleMovement & gCycleMovement::SetRubberMalus( REAL rubberMalus )
716 {
717 this->rubberMalus = rubberMalus;
718 return *this;
719 }
720
721 // *******************************************************************************************
722 // *
723 // * GetLastTurnPos
724 // *
725 // *******************************************************************************************
726 //!
727 //! @return the location of the last turn
728 //!
729 // *******************************************************************************************
730
GetLastTurnPos(void)731 eCoord const & gCycleMovement::GetLastTurnPos( void ) const
732 {
733 return this->lastTurnPos_;
734 }
735
736 // *******************************************************************************************
737 // *
738 // * GetLastTurnPos
739 // *
740 // *******************************************************************************************
741 //!
742 //! @param lastTurnPos the location of the last turn to fill
743 //! @return A reference to this to allow chaining
744 //!
745 // *******************************************************************************************
746
GetLastTurnPos(eCoord & lastTurnPos)747 gCycleMovement const & gCycleMovement::GetLastTurnPos( eCoord & lastTurnPos ) const
748 {
749 lastTurnPos = this->lastTurnPos_;
750 return *this;
751 }
752
753 // *******************************************************************************************
754 // *
755 // * SetLastTurnPos
756 // *
757 // *******************************************************************************************
758 //!
759 //! @param lastTurnPos the location of the last turn to set
760 //! @return A reference to this to allow chaining
761 //!
762 // *******************************************************************************************
763
SetLastTurnPos(eCoord const & lastTurnPos)764 gCycleMovement & gCycleMovement::SetLastTurnPos( eCoord const & lastTurnPos )
765 {
766 this->lastTurnPos_ = lastTurnPos;
767 return *this;
768 }
769
770 // *******************************************************************************************
771 // *
772 // * GetLastTurnTime
773 // *
774 // *******************************************************************************************
775 //!
776 //! @return the time of the last turn
777 //!
778 // *******************************************************************************************
779
GetLastTurnTime(void)780 REAL const & gCycleMovement::GetLastTurnTime( void ) const
781 {
782 return lastTurnTimeRight_ > lastTurnTimeLeft_ ? lastTurnTimeRight_ : lastTurnTimeLeft_;
783 }
784
785 // *******************************************************************************************
786 // *
787 // * GetLastTurnTime
788 // *
789 // *******************************************************************************************
790 //!
791 //! @param lastTurnTime the time of the last turn to fill
792 //! @return A reference to this to allow chaining
793 //!
794 // *******************************************************************************************
795
GetLastTurnTime(REAL & lastTurnTime)796 gCycleMovement const & gCycleMovement::GetLastTurnTime( REAL & lastTurnTime ) const
797 {
798 lastTurnTime = GetLastTurnTime();
799 return *this;
800 }
801
802 // *******************************************************************************************
803 // *
804 // * SetLastTurnTime
805 // *
806 // *******************************************************************************************
807 //!
808 //! @param lastTurnTime the time of the last turn to set
809 //! @return A reference to this to allow chaining
810 //!
811 // *******************************************************************************************
812
SetLastTurnTime(REAL const & lastTurnTime)813 gCycleMovement & gCycleMovement::SetLastTurnTime( REAL const & lastTurnTime )
814 {
815 lastTurnTimeRight_ = lastTurnTimeLeft_ = lastTurnTime;
816 return *this;
817 }
818
819 #endif // ARMAGETRONAD_SRC_TRON_GCYCLEMOVEMENT_H_INCLUDED
820