#include <gCycleMovement.h>
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 () | |
gDestination & | SetGameTime (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 gDestination * | RightBefore (gDestination *list, REAL dist) |
static gDestination * | RightAfter (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 |
gDestination * | next |
gDestination ** | list |
Friends | |
class | gCycleMovement |
class | gCycle |
class | gCycleExtrapolator |
Definition at line 314 of file gCycleMovement.h.
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 }
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 }
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 }
gDestination::~gDestination | ( | ) | [inline] |
Definition at line 366 of file gCycleMovement.h.
References RemoveFromList().
00366 {RemoveFromList();}
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 }
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 }
int gDestination::CompareWith | ( | const gDestination & | other | ) | const |
compare two destinations
other | the destination to compare with |
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 }
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 }
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 }
gDestination * gDestination::RightBefore | ( | gDestination * | list, | |
REAL | dist | |||
) | [static] |
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.
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 }
bool gDestination::Chatting | ( | ) | [inline] |
Definition at line 364 of file gCycleMovement.h.
References chatting.
Referenced by new_destination_handler().
00364 { return chatting; }
gDestination & gDestination::SetGameTime | ( | REAL | gameTime | ) |
Sets game time of the command.
gameTime | game time of the command to set |
Definition at line 1366 of file gCycle.cpp.
Referenced by new_destination_handler().
REAL gDestination::GetGameTime | ( | void | ) | const |
Gets 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 }
gDestination const & gDestination::GetGameTime | ( | REAL & | gameTime | ) | const |
Gets game time of the command.
gameTime | game time of the command to fill |
Definition at line 1349 of file gCycle.cpp.
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.
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] |
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().