gDestination Class Reference

#include <gCycleMovement.h>

Collaboration diagram for gDestination:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 gDestination (const gCycleMovement &takeitfrom)
 gDestination (const gCycle &takeitfrom)
 gDestination (nMessage &m, unsigned short &cycle_id)
void CopyFrom (const gCycleMovement &other)
void CopyFrom (const gCycle &other)
int CompareWith (const gDestination &other) const
 compare two destinations
void WriteCreate (nMessage &m, unsigned short cycle_id)
void InsertIntoList (gDestination **list)
void RemoveFromList ()
bool Chatting ()
 ~gDestination ()
gDestinationSetGameTime (REAL gameTime)
 Sets game time of the command.
REAL GetGameTime (void) const
 Gets game time of the command.
gDestination const & GetGameTime (REAL &gameTime) const
 Gets game time of the command.

Static Public Member Functions

static gDestinationRightBefore (gDestination *list, REAL dist)
static gDestinationRightAfter (gDestination *list, REAL dist)

Private Attributes

eCoord position
eCoord direction
REAL gameTime
REAL distance
REAL speed
bool braking
bool chatting
unsigned short turns
bool hasBeenUsed
unsigned short messageID
bool missable
gDestinationnext
gDestination ** list

Friends

class gCycleMovement
class gCycle
class gCycleExtrapolator


Detailed Description

Definition at line 314 of file gCycleMovement.h.


Constructor & Destructor Documentation

gDestination::gDestination ( const gCycleMovement takeitfrom  )  [explicit]

Definition at line 1079 of file gCycle.cpp.

References CopyFrom().

Referenced by new_destination_handler().

01080         :chatting(false)
01081         ,turns(0)
01082         ,hasBeenUsed(false)
01083         ,messageID(1)
01084         ,missable(true)
01085         ,next(NULL)
01086         ,list(NULL)
01087 {
01088     CopyFrom( c );
01089 }

Here is the call graph for this function:

Here is the caller graph for this function:

gDestination::gDestination ( const gCycle takeitfrom  )  [explicit]

Definition at line 1091 of file gCycle.cpp.

References CopyFrom().

01092         :chatting(false)
01093         ,turns(0)
01094         ,hasBeenUsed(false)
01095         ,messageID(1)
01096         ,missable(true)
01097         ,next(NULL)
01098         ,list(NULL)
01099 {
01100     CopyFrom( c );
01101 }

Here is the call graph for this function:

gDestination::gDestination ( nMessage m,
unsigned short &  cycle_id 
) [explicit]

Definition at line 1104 of file gCycle.cpp.

References braking, chatting, direction, distance, nMessage::End(), gameTime, nMessage::MessageID(), messageID, position, nMessage::Read(), and turns.

01105         :gameTime(0),distance(0),speed(0),
01106         hasBeenUsed(false),
01107         messageID(1),
01108         missable(true),
01109 next(NULL),list(NULL){
01110     m >> position;
01111     m >> direction;
01112     m >> distance;
01113 
01114     unsigned short flags;
01115     m >> flags;
01116     braking  = flags & 0x01;
01117     chatting = flags & 0x02;
01118 
01119     messageID = m.MessageID();
01120 
01121     turns = 0;
01122 
01123     m.Read( cycle_id );
01124 
01125     if ( !m.End() )
01126         m >> gameTime;
01127     else
01128         gameTime = -1000;
01129 
01130     if ( !m.End() )
01131     {
01132         m.Read( turns );
01133     }
01134 }

Here is the call graph for this function:

gDestination::~gDestination (  )  [inline]

Definition at line 366 of file gCycleMovement.h.

References RemoveFromList().

00366 {RemoveFromList();}

Here is the call graph for this function:


Member Function Documentation

void gDestination::CopyFrom ( const gCycleMovement other  ) 

Definition at line 1136 of file gCycle.cpp.

References braking, chatting, gCycleMovement::Direction(), direction, distance, gameTime, gCycleMovement::GetBraking(), gCycleMovement::GetDistance(), gCycleMovement::GetTurns(), ePlayerNetID::IsChatting(), eGameObject::LastTime(), nNetObject::Owner(), eNetGameObject::Player(), eGameObject::Position(), position, gCycleMovement::Speed(), speed, st_Breakpoint(), and turns.

Referenced by CopyFrom(), and gDestination().

01137 {
01138     position    = other.Position();
01139     direction   = other.Direction();
01140     gameTime    = other.LastTime();
01141     distance    = other.GetDistance();
01142     speed               = other.Speed();
01143     braking     = other.GetBraking();
01144     turns               = other.GetTurns();
01145 
01146 #ifdef DEBUG
01147     if (!finite(gameTime) || !finite(speed) || !finite(distance))
01148         st_Breakpoint();
01149 #endif
01150     if ( other.Owner() && other.Player() )
01151         chatting = other.Player()->IsChatting();
01152 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gDestination::CopyFrom ( const gCycle other  ) 

Definition at line 1154 of file gCycle.cpp.

References CopyFrom(), gCycle::correctDistanceSmooth, and distance.

01155 {
01156     CopyFrom( static_cast<const gCycleMovement&>(other) );
01157 
01158     // correct distance
01159     distance    += other.correctDistanceSmooth;
01160 }

Here is the call graph for this function:

int gDestination::CompareWith ( const gDestination other  )  const

compare two destinations

Parameters:
other the destination to compare with
Returns:
-1 if this destination came earler, +1 if other was earler, 0 if no difference can be found

Definition at line 1173 of file gCycle.cpp.

References distance, and messageID.

Referenced by InsertIntoList().

01174 {
01175     // compare distances, but use the network message ID ( they are always increasing, the distance may stagnate or in extreme cases run backwards ) as main sort criterion
01176 
01177     // compare message IDs with overflow ( if both are at good values )
01178     if ( messageID > 1 && other.messageID > 1 )
01179     {
01180         short messageIDDifference = messageID - other.messageID;
01181         if ( messageIDDifference < 0 )
01182             return -1;
01183         if ( messageIDDifference > 0 )
01184             return 1;
01185     }
01186 
01187     // compare travelled distance
01188     if ( distance < other.distance )
01189         return -1;
01190     else if ( distance > other.distance )
01191         return 1;
01192 
01193     // no relevant difference found
01194     return 0;
01195 }

Here is the caller graph for this function:

void gDestination::WriteCreate ( nMessage m,
unsigned short  cycle_id 
)

Definition at line 1231 of file gCycle.cpp.

References braking, chatting, direction, distance, gameTime, nMessage::MessageID(), messageID, position, turns, and nMessage::Write().

Referenced by BroadCastNewDestination().

01231                                                                    {
01232     m << position;
01233     m << direction;
01234     m << distance;
01235 
01236     unsigned short flags = 0;
01237     if ( braking )
01238         flags |= 0x01;
01239     if ( chatting )
01240         flags |= 0x02;
01241     m << flags;
01242 
01243     // store message ID for later reference
01244     messageID = m.MessageID();
01245 
01246     m.Write( cycle_id );
01247     m << gameTime;
01248     m.Write( turns );
01249 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gDestination::InsertIntoList ( gDestination **  list  ) 

Definition at line 1274 of file gCycle.cpp.

References CompareWith(), list, next, RemoveFromList(), and tASSERT.

Referenced by gCycleMovement::AddDestination(), and gCycle::Timestep().

01274                                                  {
01275     if (!l)
01276         return;
01277 
01278     RemoveFromList();
01279 
01280     // let message find its place
01281     while (l && *l && CompareWith( **l ) > 0 )
01282         l = &((*l)->next);
01283 
01284     list=l;
01285 
01286     tASSERT(l);
01287 
01288     next=*l;
01289     *l=this;
01290 }

Here is the call graph for this function:

Here is the caller graph for this function:

gDestination * gDestination::RightBefore ( gDestination list,
REAL  dist 
) [static]

Definition at line 1251 of file gCycle.cpp.

References distance, next, and NULL.

01251                                                                     {
01252     if (!list || list->distance > dist)
01253         return NULL;
01254 
01255     gDestination *ret=list;
01256     while (ret && ret->next && ret->next->distance < dist)
01257         ret=ret->next;
01258 
01259     return ret;
01260 }

gDestination * gDestination::RightAfter ( gDestination list,
REAL  dist 
) [static]

Definition at line 1262 of file gCycle.cpp.

References distance, next, and NULL.

01262                                                                    {
01263     if (!list)
01264         return NULL;
01265 
01266     gDestination *ret=list;
01267     while (ret && ret->distance < dist)
01268         ret=ret->next;
01269 
01270     return ret;
01271 }

void gDestination::RemoveFromList (  ) 

Definition at line 1294 of file gCycle.cpp.

References list, and next.

Referenced by InsertIntoList(), and ~gDestination().

01294                                  {
01295     /*
01296        if (!list)
01297            return;
01298 
01299        while (list && *list && *list != this)
01300            list = &((*list)->next);
01301 
01302        tASSERT(list);
01303        tASSERT(*list);
01304 
01305        (*list) = next;
01306        next=NULL;
01307        list=NULL;
01308        
01309       */
01310 
01311     // z-man: HUH? I don't understand the code above any more and it seems to be leaky.
01312     // This simple alternative sounds better:
01313 
01314     if(list)
01315         *list = next;
01316     if(next)
01317         next->list = list;
01318 
01319     next = 0;
01320     list = 0;
01321 }

Here is the caller graph for this function:

bool gDestination::Chatting (  )  [inline]

Definition at line 364 of file gCycleMovement.h.

References chatting.

Referenced by new_destination_handler().

00364 { return chatting; }

Here is the caller graph for this function:

gDestination & gDestination::SetGameTime ( REAL  gameTime  ) 

Sets game time of the command.

Parameters:
gameTime game time of the command to set
Returns:
A reference to this to allow chaining

Definition at line 1366 of file gCycle.cpp.

Referenced by new_destination_handler().

01367 {
01368     this->gameTime = gameTime;
01369     return *this;
01370 }

Here is the caller graph for this function:

REAL gDestination::GetGameTime ( void   )  const

Gets game time of the command.

Returns:
game time of the command

Definition at line 1333 of file gCycle.cpp.

References gameTime.

Referenced by new_destination_handler(), gCycleMovement::NextInterestingTime(), and gCycleMovement::Timestep().

01334 {
01335     return this->gameTime;
01336 }

Here is the caller graph for this function:

gDestination const & gDestination::GetGameTime ( REAL gameTime  )  const

Gets game time of the command.

Parameters:
gameTime game time of the command to fill
Returns:
A reference to this to allow chaining

Definition at line 1349 of file gCycle.cpp.

01350 {
01351     gameTime = this->gameTime;
01352     return *this;
01353 }


Friends And Related Function Documentation

friend class gCycleMovement [friend]

Definition at line 315 of file gCycleMovement.h.

friend class gCycle [friend]

Definition at line 316 of file gCycleMovement.h.

friend class gCycleExtrapolator [friend]

Definition at line 317 of file gCycleMovement.h.


Member Data Documentation

eCoord gDestination::position [private]

Definition at line 319 of file gCycleMovement.h.

Referenced by CopyFrom(), gCycleMovement::DistanceToDestination(), gDestination(), gCycle::OnNotifyNewDestination(), gCycle::ReadSync(), gCycleMovement::Timestep(), and WriteCreate().

eCoord gDestination::direction [private]

Definition at line 320 of file gCycleMovement.h.

Referenced by gCycleMovement::CopyFrom(), CopyFrom(), gCycleMovement::DistanceToDestination(), gDestination(), gCycleMovement::GetDestinationBefore(), gCycleMovement::Timestep(), and WriteCreate().

REAL gDestination::gameTime [private]

Definition at line 321 of file gCycleMovement.h.

Referenced by CopyFrom(), gDestination(), GetGameTime(), gCycle::OnNotifyNewDestination(), gCycle::ReadSync(), and WriteCreate().

REAL gDestination::distance [private]

Definition at line 322 of file gCycleMovement.h.

Referenced by CompareWith(), CopyFrom(), gDestination(), gCycleMovement::GetDestinationBefore(), gCycle::OnNotifyNewDestination(), gCycle::ReadSync(), RightAfter(), RightBefore(), gCycle::Timestep(), and WriteCreate().

REAL gDestination::speed [private]

Definition at line 323 of file gCycleMovement.h.

Referenced by CopyFrom().

bool gDestination::braking [private]

Definition at line 324 of file gCycleMovement.h.

Referenced by gCycleMovement::CopyFrom(), CopyFrom(), gCycleMovement::DistanceToDestination(), gDestination(), gCycleMovement::GetDestinationBefore(), gCycleMovement::Timestep(), and WriteCreate().

bool gDestination::chatting [private]

Definition at line 325 of file gCycleMovement.h.

Referenced by Chatting(), CopyFrom(), gDestination(), and WriteCreate().

unsigned short gDestination::turns [private]

Definition at line 327 of file gCycleMovement.h.

Referenced by CopyFrom(), gDestination(), gCycleMovement::Timestep(), and WriteCreate().

bool gDestination::hasBeenUsed [private]

Definition at line 328 of file gCycleMovement.h.

Referenced by gCycleMovement::AddDestination(), and gCycleMovement::Timestep().

unsigned short gDestination::messageID [private]

Definition at line 329 of file gCycleMovement.h.

Referenced by CompareWith(), gDestination(), gCycleMovement::GetDestinationBefore(), gCycleMovement::Timestep(), gCycle::Timestep(), WriteCreate(), and gCycle::WriteSync().

bool gDestination::missable [private]

Definition at line 330 of file gCycleMovement.h.

gDestination* gDestination::next [private]

Definition at line 332 of file gCycleMovement.h.

Referenced by gCycleMovement::AddDestination(), gCycleMovement::CopyFrom(), gCycleMovement::GetDestinationBefore(), InsertIntoList(), gCycleMovement::NextInterestingTime(), gCycleMovement::OnNotifyNewDestination(), gCycle::ReadSync(), RemoveFromList(), RightAfter(), RightBefore(), and gCycleMovement::Timestep().

gDestination** gDestination::list [private]

Definition at line 333 of file gCycleMovement.h.

Referenced by gCycle::Extrapolate(), InsertIntoList(), and RemoveFromList().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:38:58 2008 for Armagetron Advanced by  doxygen 1.5.4