SuperTuxKart
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
LinearWorld Class Reference
Inheritance diagram for LinearWorld:
Inheritance graph
[legend]

Classes

class  KartInfo
 Some additional info that needs to be kept for each kart in this kind of race. More...
 

Public Member Functions

 LinearWorld ()
 Constructs the linear world.
 
virtual void init () OVERRIDE
 call just after instanciating.
 
virtual ~LinearWorld ()
 The destructor frees al data structures.
 
virtual void update (int ticks) OVERRIDE
 General update function called once per frame.
 
virtual void updateGraphics (float dt) OVERRIDE
 This updates all only graphical elements.It is only called once per rendered frame, not once per time step.
 
float getDistanceDownTrackForKart (const int kart_id, bool account_for_checklines) const
 Returns the distance the kart has travelled along the track since crossing the start line.
 
void updateTrackSectors ()
 
void updateRacePosition ()
 Find the position (rank) of every kart.
 
float getDistanceToCenterForKart (const int kart_id) const
 Gets the distance of the kart from the center of the driveline.
 
float getEstimatedFinishTime (const int kart_id) const
 Returns the estimated finishing time.
 
int getLapForKart (const int kart_id) const
 
int getTicksAtLapForKart (const int kart_id) const
 
float getLiveTimeDifference () const
 
bool hasValidTimeDifference () const
 
virtual void getKartsDisplayInfo (std::vector< RaceGUIBase::KartIconDisplayInfo > *info) OVERRIDE
 Called by the code that draws the list of karts on the race GUI to know what needs to be drawn in the current mode.
 
virtual unsigned int getNumberOfRescuePositions () const OVERRIDE
 Returns the number of rescue positions on a given track, which in linear races is just the number of driveline quads.
 
virtual unsigned int getRescuePositionIndex (AbstractKart *kart) OVERRIDE
 Determines the rescue position for a kart.
 
virtual btTransform getRescueTransform (unsigned int index) const OVERRIDE
 Returns the bullet transformation for the specified rescue index.
 
virtual void reset (bool restart=false) OVERRIDE
 Called before a race is started (or restarted).
 
virtual void newLap (unsigned int kart_index) OVERRIDE
 Is called by check structures if a kart starts a new lap.
 
virtual bool raceHasLaps () OVERRIDE
 Returns if this race mode has laps.
 
virtual bool haveBonusBoxes () OVERRIDE
 Returns if this race mode has bonus items.
 
virtual bool useChecklineRequirements () const OVERRIDE
 Override settings from base class.
 
int getFinishedLapsOfKart (unsigned int kart_index) const OVERRIDE
 Returns the number of laps a kart has completed.
 
void setLastTriggeredCheckline (unsigned int kart_index, int index)
 
float getOverallDistance (unsigned int kart_index) const
 Returns how far the kart has driven so far (i.e.
 
float getFastestLap () const
 Returns time for the fastest laps.
 
stringw getFastestLapKartName () const
 Returns the kart name that made the fastest lap time.
 
int getFastestLapTicks () const
 Network use: get fastest lap in ticks.
 
void setFastestLapTicks (int ticks)
 Network use: set fastest lap in ticks.
 
void setFastestKartName (const stringw &name)
 Network use: set fastest kart name.
 
virtual std::pair< uint32_t, uint32_t > getGameStartedProgress () const OVERRIDE
 Used by server to get the current started game progress in either or both remaining time or progress in percent.
 
virtual void saveCompleteState (BareNetworkString *bns, STKPeer *peer) OVERRIDE
 
virtual void restoreCompleteState (const BareNetworkString &b) OVERRIDE
 
void updateCheckLinesServer (int check_id, int kart_id)
 Called in server whenever a kart cross a check line, it send server current kart lap count, last triggered checkline and check structure status to all players in game (including spectators so that the lap count is correct)
 
void updateCheckLinesClient (const BareNetworkString &b)
 
void handleServerCheckStructureCount (unsigned count)
 
virtual bool showLapsTarget () OVERRIDE
 If true lap counter shows lap count in format: 4/20 or if false then in format: 4.
 
- Public Member Functions inherited from WorldWithRank
virtual void init () OVERRIDE
 call just after instanciating.
 
virtual void reset (bool restart=false) OVERRIDE
 This function is called before a race is started (i.e.
 
bool displayRank () const
 
void beginSetKartPositions ()
 This function must be called before starting to set all kart positions again.
 
bool setKartPosition (unsigned int kart_id, unsigned int position)
 Sets the position of a kart.
 
void endSetKartPositions ()
 Called once the last position was set.
 
AbstractKartgetKartAtPosition (unsigned int p) const
 Returns the kart with a given position.
 
virtual AbstractKartgetKartAtDrawingPosition (unsigned int p) const
 Returns the kart at which position (start from 1) to draw race icon.
 
virtual int getScoreForPosition (int p)
 Returns the number of points for a kart at a specified position.
 
virtual unsigned int getRescuePositionIndex (AbstractKart *kart) OVERRIDE
 Determines the rescue position for a kart.
 
TrackSectorgetTrackSector (unsigned int kart_index) const
 Returns the track_sector object for the specified kart.
 
bool isOnRoad (unsigned int kart_index) const
 Returns true if the kart is on a valid graph quad.
 
int getSectorForKart (const AbstractKart *kart) const
 Gets the sector a kart is on.
 
- Public Member Functions inherited from World
 World ()
 The main world class is used to handle the track and the karts.
 
virtual const std::string & getIdent () const =0
 Each game mode should have a unique identifier.
 
virtual unsigned int getNumberOfRescuePositions () const
 Returns the number of rescue positions on a given track and game mode.
 
virtual unsigned int getRescuePositionIndex (AbstractKart *kart)=0
 Determines the rescue position index of the specified kart.
 
virtual btTransform getRescueTransform (unsigned int index) const
 Returns the bullet transformation for the specified rescue index.
 
virtual void moveKartAfterRescue (AbstractKart *kart)
 Places a kart that is rescued.
 
virtual bool raceHasLaps ()=0
 Called when it is needed to know whether this kind of race involves counting laps.
 
virtual bool showLapsTarget ()
 If true lap counter shows lap count in format: 4/20 or if false then in format: 4.
 
virtual int getFinishedLapsOfKart (unsigned int kart_index) const
 Returns the number of laps for a given kart.
 
virtual void getKartsDisplayInfo (std::vector< RaceGUIBase::KartIconDisplayInfo > *info)=0
 Called by the code that draws the list of karts on the race GUI to know what needs to be drawn in the current mode.
 
virtual void init ()
 This function is called after instanciating.
 
virtual void updateGraphics (float dt)
 This updates all only graphical elements.
 
virtual void terminateRace () OVERRIDE
 Called at the end of a race.
 
virtual void reset (bool restart=false) OVERRIDE
 This function is called before a race is started (i.e.
 
virtual void pause (Phase phase) OVERRIDE
 Pauses the music (and then pauses WorldStatus).
 
virtual void unpause () OVERRIDE
 Switches back from a pause state to the previous state.
 
virtual void getDefaultCollectibles (int *collectible_type, int *amount)
 Called to determine the default collectibles to give each player at the start for this kind of race.
 
virtual void collectedItem (const AbstractKart *kart, const ItemState *item)
 Receives notification if an item is collected.
 
virtual void endRaceEarly ()
 
virtual bool hasRaceEndedEarly () const
 
virtual bool haveBonusBoxes ()
 Called to determine whether this race mode uses bonus boxes.
 
virtual bool useFastMusicNearEnd () const
 Returns if this mode should use fast music (if available).
 
virtual void kartAdded (AbstractKart *kart, scene::ISceneNode *node)
 If you want to do something to karts or their graphics at the start of the race, override this.
 
virtual void newLap (unsigned int kart_index)
 Called whenever a kart starts a new lap.
 
virtual bool kartHit (int kart_id, int hitter=-1)
 Called when a kart was hit by a projectile.
 
virtual void onMouseClick (int x, int y)
 
HighscoresgetHighscores () const
 
HighscoresgetGPHighscores () const
 
void schedulePause (Phase phase)
 
void scheduleUnpause ()
 
void scheduleExitRace ()
 
void scheduleTutorial ()
 
void updateWorld (int ticks)
 This is the main interface to update the world.
 
void handleExplosion (const Vec3 &xyz, AbstractKart *kart_hit, PhysicalObject *object)
 
AbstractKartgetPlayerKart (unsigned int player) const
 Returns the n-th player kart.
 
AbstractKartgetLocalPlayerKart (unsigned int n) const
 Returns the nth local player kart, i.e.
 
virtual const btTransform & getStartTransform (int index)
 Returns the start coordinates for a kart with a given index.
 
void moveKartTo (AbstractKart *kart, const btTransform &t)
 Places the kart at a given position and rotation.
 
void updateTimeTargetSound ()
 
RaceGUIBasegetRaceGUI () const
 Returns a pointer to the race gui.
 
unsigned int getNumKarts () const
 Returns the number of karts in the race.
 
AbstractKartgetKart (int kartId) const
 Returns the kart with a given world id.
 
const KartList & getKarts () const
 Returns all karts.
 
unsigned int getCurrentNumKarts () const
 Returns the number of currently active (i.e.non-elikminated) karts.
 
unsigned int getCurrentNumPlayers () const
 Returns the number of currently active (i.e.
 
void resetElimination ()
 
virtual void addReservedKart (int kart_id)
 
virtual void saveCompleteState (BareNetworkString *bns, STKPeer *peer)
 
virtual void restoreCompleteState (const BareNetworkString &buffer)
 
virtual bool shouldDrawTimer () const
 The code that draws the timer should call this first to know whether the game mode wants a timer drawn.
 
bool useHighScores () const
 
virtual void onFirePressed (Controller *who)
 Override if you want to know when a kart presses fire.
 
virtual bool useChecklineRequirements () const
 Whether to compute checkline requirements for each world on the quadgraph.
 
virtual void escapePressed ()
 
virtual void loadCustomModels ()
 
void eliminateKart (int kart_number, bool notify_of_elimination=true)
 Remove (eliminate) a kart from the race.
 
void setUnfairTeam (bool val)
 
virtual bool hasTeam () const
 
KartTeam getKartTeam (unsigned int kart_id) const
 Get the team of kart in world (including AIs)
 
int getTeamNum (KartTeam team) const
 
void setNetworkWorld (bool is_networked)
 Set the network mode (true if networked)
 
bool isNetworkWorld () const
 
void initTeamArrows (AbstractKart *k)
 Set the team arrow on karts if necessary.
 
virtual std::pair< uint32_t, uint32_t > getGameStartedProgress () const
 Used by server to get the current started game progress in either or both remaining time or progress in percent.
 
virtual bool isGoalPhase () const
 
- Public Member Functions inherited from WorldStatus
virtual ~WorldStatus ()
 Destructor of WorldStatus.
 
virtual void reset (bool restart)
 Resets all status information, used when starting a new race.
 
virtual void updateTime (int ticks)
 Updates the world time and clock (which might be running backwards), and all status information, called once per frame at the end of the main loop.
 
virtual void update (int ticks)
 Update, called once per frame.
 
void startReadySetGo ()
 
virtual void pause (Phase phase)
 Pauses the game and switches to the specified phase.
 
virtual void unpause ()
 Switches back from a pause state to the previous state.
 
virtual void enterRaceOverState ()
 Called when the race is finished, but it still leaves some time for an end of race animation, and potentially let some more AI karts finish the race.
 
virtual void terminateRace ()
 Called when it's really over (delay over if any).
 
void setTime (const float time)
 Sets the time for the clock.
 
void setTicks (int ticks)
 Sets a new time for the world time, measured in ticks.
 
void setTicksForRewind (int ticks)
 Sets a new time for the world time (used by rewind), measured in ticks.
 
bool isStartPhase () const
 
bool isRacePhase () const
 
bool isActiveRacePhase () const
 
bool isFinishPhase () const
 While the race menu is being displayed, m_phase is limbo, and m_previous_phase is finish.
 
const Phase getPhase () const
 Returns the current race phase.
 
void setPhase (Phase phase)
 Sets the current race phase.
 
void setClockMode (const ClockType mode, const float initial_time=0.0f)
 Call to specify what kind of clock you want.
 
int getClockMode () const
 Returns the current clock mode.
 
float getTime () const
 Returns the current race time.
 
uint64_t getStart () const
 Returns the start time.
 
int getTimeTicks () const
 Returns the current race time in time ticks (i.e.
 
virtual void countdownReachedZero ()
 Will be called to notify your derived class that the clock, which is in COUNTDOWN mode, has reached zero.
 
virtual void onGo ()
 Called when the race actually starts.
 
int getTicksSinceStart () const
 Get the ticks since start regardless of which way the clock counts.
 
int getAuxiliaryTicks () const
 
bool isLiveJoinWorld () const
 
void setLiveJoinWorld (bool val)
 
int getMusicDescriptionTicks () const
 
void endLiveJoinWorld (int ticks_now)
 Base on the network timer set current world count up ticks to tick_now.
 

Protected Member Functions

virtual void checkForWrongDirection (unsigned int i, float dt)
 Checks if a kart is going in the wrong direction.
 
virtual float estimateFinishTimeForKart (AbstractKart *kart) OVERRIDE
 Estimate the arrival time of any karts that haven't arrived yet by using their average speed up to now and the distance still to race.
 
- Protected Member Functions inherited from WorldWithRank
unsigned int getClosestStartPoint (AbstractKart *kart)
 
void updateSectorForKarts ()
 Localize each kart on the graph using its center xyz.
 
- Protected Member Functions inherited from World
void updateHighscores (int *best_highscore_rank)
 Called at the end of a race.
 
void resetAllKarts ()
 Waits till each kart is resting on the ground.
 
ControllerloadAIController (AbstractKart *kart)
 Creates an AI controller for the kart.
 
virtual std::shared_ptr< AbstractKartcreateKart (const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType type, HandicapLevel handicap)
 Creates a kart, having a certain position, starting location, and local and global player id (if applicable).
 
virtual void onGo () OVERRIDE
 Called when 'go' is being displayed for the first time.
 
virtual bool isRaceOver ()=0
 Returns true if the race is over.
 
virtual void update (int ticks) OVERRIDE
 Updates the physics, all karts, the track, and projectile manager.
 
virtual void createRaceGUI ()
 
void updateTrack (int ticks)
 Only updates the track.
 
virtual float estimateFinishTimeForKart (AbstractKart *kart)
 Used for AI karts that are still racing when all player kart finished.
 
void updateAchievementDataEndRace ()
 
void updateAchievementModeCounters (bool start)
 

Protected Attributes

std::vector< KartInfom_kart_info
 This vector contains an 'KartInfo' struct for every kart in the race.
 
- Protected Attributes inherited from WorldWithRank
std::vector< int > m_position_index
 This contains a mapping from race position to kart index.
 
bool m_display_rank
 Whether to display the rank in the race GUI.
 
std::vector< int > m_score_for_position
 The points given to a kart on a given position (index is 0 based, so using race-position - 1.
 
std::vector< TrackSector * > m_kart_track_sector
 Stores the current graph node and track coordinates for each kart.
 
- Protected Attributes inherited from World
int m_red_ai
 
int m_blue_ai
 
std::map< int, KartTeam > m_kart_team_map
 
std::map< int, unsigned int > m_kart_position_map
 
KartList m_karts
 The list of all karts.
 
RandomGenerator m_random
 
AbstractKartm_fastest_kart
 
int m_eliminated_karts
 Number of eliminated karts.
 
int m_eliminated_players
 Number of eliminated players.
 
int m_num_players
 OVerall number of players.
 
bool m_faster_music_active
 
bool m_stop_music_when_dialog_open
 
bool m_unfair_team
 
bool m_use_highscores
 Whether highscores should be used for this kind of race.
 
RaceGUIBasem_race_gui
 Pointer to the race GUI.
 
RaceGUIBasem_saved_race_gui
 The actual race gui needs to be saved when the race result gui is displayed since it is still needed in case of a restart, and it can't simply be created again (since it assumes that it can render to texture without having any scene nodes, but in case of a restart there are scene nodes).
 
bool m_schedule_pause
 Pausing/unpausing are not done immediately, but at next udpdate.
 
bool m_schedule_unpause
 Pausing/unpausing are not done immediately, but at next udpdate.
 
bool m_schedule_exit_race
 
bool m_schedule_tutorial
 
Phase m_scheduled_pause_phase
 
bool m_self_destruct
 Set when the world needs to be deleted but you can't do it immediately because you are e.g.
 
bool m_is_network_world
 Set when the world is online and counts network players.
 
bool m_ended_early
 
- Protected Attributes inherited from WorldStatus
double m_time
 Elasped/remaining time in seconds.
 
int m_time_ticks
 Time in number of ticks (in terms of physics time steps).
 
bool m_play_racestart_sounds
 If the start race should be played, disabled in cutscenes.
 
const ProcessType m_process_type
 Process type of this world (main or child).
 
bool m_play_track_intro_sound
 
bool m_play_ready_set_go_sounds
 
std::atomic< Phase > m_phase
 

Private Member Functions

void updateLiveDifference ()
 This calculate the time difference between the second kart in the race (there must be at least two) and the first kart in the race (who must be a ghost).
 

Private Attributes

SFXBasem_last_lap_sfx
 Sfx for the final lap.
 
bool m_last_lap_sfx_played
 Last lap sfx should only be played once.
 
bool m_last_lap_sfx_playing
 
bool m_check_structure_compatible
 True if clients and server has the same check structure.
 
int m_fastest_lap_ticks
 The fastest lap time, in ticks of physics dt.
 
core::stringw m_fastest_lap_kart_name
 
float m_distance_increase
 The track length returned by Track::getLength() only covers the distance from start line to finish line, i.e.
 
float m_live_time_difference
 This stores the live time difference between a ghost kart and a second kart racing against it (normal or ghost).
 
bool m_valid_reference_time
 True if the live_time_difference is invalid.
 
float m_finish_timeout
 

Additional Inherited Members

- Public Types inherited from World
typedef std::vector< std::shared_ptr< AbstractKart > > KartList
 
- Public Types inherited from WorldStatus
enum  ClockType { CLOCK_NONE , CLOCK_CHRONO , CLOCK_COUNTDOWN }
 Different clock types for a race.
 
enum  Phase {
  TRACK_INTRO_PHASE , SETUP_PHASE , WAIT_FOR_SERVER_PHASE , SERVER_READY_PHASE ,
  READY_PHASE , SET_PHASE , GO_PHASE , MUSIC_PHASE ,
  RACE_PHASE , DELAY_FINISH_PHASE , RESULT_DISPLAY_PHASE , FINISH_PHASE ,
  IN_GAME_MENU_PHASE , UNDEFINED_PHASE
}
 
- Static Public Member Functions inherited from World
static WorldgetWorld ()
 Returns a pointer to the (singleton) world object.
 
static void deleteWorld ()
 Delete the )singleton) world object, if it exists, and sets the singleton pointer to NULL.
 
static void setWorld (World *world)
 Sets the pointer to the world object.
 
static void clear ()
 

Constructor & Destructor Documentation

◆ LinearWorld()

LinearWorld::LinearWorld ( )

Constructs the linear world.

Note that here no functions can be called that use World::getWorld(), since it is not yet defined.

Member Function Documentation

◆ checkForWrongDirection()

void LinearWorld::checkForWrongDirection ( unsigned int  i,
float  dt 
)
protectedvirtual

Checks if a kart is going in the wrong direction.

This is done only for player karts to display a message to the player.

Parameters
iKart id.
dtTime step size.

Reimplemented in EasterEggHunt.

◆ estimateFinishTimeForKart()

float LinearWorld::estimateFinishTimeForKart ( AbstractKart kart)
protectedvirtual

Estimate the arrival time of any karts that haven't arrived yet by using their average speed up to now and the distance still to race.

This approach guarantees that the order of the karts won't change anymore (karts ahead will have covered more distance and have therefore a higher average speed and therefore finish the race earlier than karts further behind), so the position doesn't have to be updated to get the correct scoring. As so often the devil is in the details: a kart that hasn't crossed the starting line has a negative distance (when it is crossing the start line its distance becomes 0), which can result in a negative average speed (and therefore incorrect estimates). This is partly taken care of by adding m_distance_increase to the distance covered by a kart. The value of m_distance_increase is a bit more than the distance the last kart has from the start line at start time. This guarantees that the distance used in computing the average speed is positive in most cases. Only exception is if a kart is driving backwards on purpose. While this shouldn't happen (the AI doesn't do it, and if it's a player the game won't finish so the time estimation won't be called and so the incorrect result won't be displayed), this is still taken care of: if the average speed is negative, the estimated arrival time of the kart is set to 99:00 plus kart position. This means that even in this case all karts will have a different arrival time.

Precondition
The position of the karts are set according to the distance they have covered.
Parameters
kartThe kart for which to estimate the finishing times.

Reimplemented from World.

Reimplemented in EasterEggHunt.

◆ getDistanceDownTrackForKart()

float LinearWorld::getDistanceDownTrackForKart ( const int  kart_id,
bool  account_for_checklines 
) const

Returns the distance the kart has travelled along the track since crossing the start line.

Parameters
kart_idIndex of the kart.

◆ getDistanceToCenterForKart()

float LinearWorld::getDistanceToCenterForKart ( const int  kart_id) const

Gets the distance of the kart from the center of the driveline.

Positive is to the right of the center, negative values to the left.

Parameters
kart_idIndex of kart.

◆ getEstimatedFinishTime()

float LinearWorld::getEstimatedFinishTime ( const int  kart_id) const

Returns the estimated finishing time.

Parameters
kart_idId of the kart.

◆ getFinishedLapsOfKart()

int LinearWorld::getFinishedLapsOfKart ( unsigned int  kart_index) const
inlinevirtual

Returns the number of laps a kart has completed.

Parameters
kart_indexWorld index of the kart.

Reimplemented from World.

◆ getGameStartedProgress()

std::pair< uint32_t, uint32_t > LinearWorld::getGameStartedProgress ( ) const
virtual

Used by server to get the current started game progress in either or both remaining time or progress in percent.

uint32_t max for either or both if not available.

Reimplemented from World.

◆ getKartsDisplayInfo()

void LinearWorld::getKartsDisplayInfo ( std::vector< RaceGUIBase::KartIconDisplayInfo > *  info)
virtual

Called by the code that draws the list of karts on the race GUI to know what needs to be drawn in the current mode.

Implements World.

Reimplemented in LapTrial, EasterEggHunt, and FollowTheLeaderRace.

◆ getNumberOfRescuePositions()

unsigned int LinearWorld::getNumberOfRescuePositions ( ) const
virtual

Returns the number of rescue positions on a given track, which in linear races is just the number of driveline quads.

Reimplemented from World.

Reimplemented in TutorialWorld.

◆ getOverallDistance()

float LinearWorld::getOverallDistance ( unsigned int  kart_index) const
inline

Returns how far the kart has driven so far (i.e.

number-of-laps-finished times track-length plus distance-on-track.

Parameters
kart_indexWorld kart id of the kart.

◆ getRescuePositionIndex()

unsigned int LinearWorld::getRescuePositionIndex ( AbstractKart kart)
virtual

Determines the rescue position for a kart.

The rescue position is the start position which is has the biggest accumulated distance to all other karts, and which has no other kart very close. The latter avoids dropping a kart on top of another kart. This is the method used

Parameters
kartThe kart that is going to be rescued.
Returns
The index of the start position to which the rescued kart should be moved to.

Reimplemented from WorldWithRank.

Reimplemented in TutorialWorld.

◆ getRescueTransform()

btTransform LinearWorld::getRescueTransform ( unsigned int  rescue_pos) const
virtual

Returns the bullet transformation for the specified rescue index.

Returns the start transform with the give index.

Parameters
rescue_posIndex of the start position to be returned.
Returns
The transform of the corresponding start position.

Reimplemented from World.

Reimplemented in TutorialWorld.

◆ haveBonusBoxes()

virtual bool LinearWorld::haveBonusBoxes ( )
inlinevirtual

Returns if this race mode has bonus items.

Reimplemented from World.

Reimplemented in StandardRace.

◆ init()

void LinearWorld::init ( )
virtual

call just after instanciating.

Actually initialises the world, i.e.

can't be moved to the contructor as child classes must be instanciated, otherwise polymorphism will fail and the results will be incorrect

creates all data structures to for all karts etc. In init functions can be called that use World::getWorld().

Reimplemented from WorldWithRank.

Reimplemented in EasterEggHunt, and FollowTheLeaderRace.

◆ newLap()

void LinearWorld::newLap ( unsigned int  kart_index)
virtual

Is called by check structures if a kart starts a new lap.

Parameters
kart_indexIndex of the kart.

Reimplemented from World.

◆ raceHasLaps()

virtual bool LinearWorld::raceHasLaps ( )
inlinevirtual

Returns if this race mode has laps.

Implements World.

Reimplemented in EasterEggHunt, and FollowTheLeaderRace.

◆ reset()

void LinearWorld::reset ( bool  restart = false)
virtual

Called before a race is started (or restarted).

It resets the data structures that keep track of position and distance long track of all karts.

Reimplemented from WorldWithRank.

Reimplemented in EasterEggHunt, FollowTheLeaderRace, and LapTrial.

◆ restoreCompleteState()

void LinearWorld::restoreCompleteState ( const BareNetworkString b)
virtual

Reimplemented from World.

◆ saveCompleteState()

void LinearWorld::saveCompleteState ( BareNetworkString bns,
STKPeer peer 
)
virtual

Reimplemented from World.

◆ showLapsTarget()

virtual bool LinearWorld::showLapsTarget ( )
inlinevirtual

If true lap counter shows lap count in format: 4/20 or if false then in format: 4.

Reimplemented from World.

Reimplemented in LapTrial.

◆ update()

void LinearWorld::update ( int  ticks)
virtual

General update function called once per frame.

This updates the kart sectors, which are then used to determine the kart positions.

Parameters
ticksNumber of physics time steps - should be 1.

Reimplemented from World.

Reimplemented in ProfileWorld, DemoWorld, EasterEggHunt, and LapTrial.

◆ updateCheckLinesServer()

void LinearWorld::updateCheckLinesServer ( int  check_id,
int  kart_id 
)

Called in server whenever a kart cross a check line, it send server current kart lap count, last triggered checkline and check structure status to all players in game (including spectators so that the lap count is correct)

Parameters
check_idThe check structure it it triggered.
kart_idThe kart which triggered a checkline.

◆ updateGraphics()

void LinearWorld::updateGraphics ( float  dt)
virtual

This updates all only graphical elements.It is only called once per rendered frame, not once per time step.

float dt Time since last rame.

Reimplemented from World.

◆ updateLiveDifference()

void LinearWorld::updateLiveDifference ( )
private

This calculate the time difference between the second kart in the race (there must be at least two) and the first kart in the race (who must be a ghost).

This calculate the time difference between the second kart in the race and the first kart in the race (who must be a ghost)

◆ updateRacePosition()

void LinearWorld::updateRacePosition ( )

Find the position (rank) of every kart.

ATM it uses a stable O(n^2) algorithm by counting for each kart how many other karts are ahead of it.

◆ useChecklineRequirements()

virtual bool LinearWorld::useChecklineRequirements ( ) const
inlinevirtual

Override settings from base class.

Reimplemented from World.

Member Data Documentation

◆ m_distance_increase

float LinearWorld::m_distance_increase
private

The track length returned by Track::getLength() only covers the distance from start line to finish line, i.e.

it does not include the distance the karts actually start behind the start line (the karts would have a negative distance till they reach the start line for the first time). This values stores the additional distance by which the track length must be increased, which is important to get valid finish times estimates.

◆ m_kart_info

std::vector<KartInfo> LinearWorld::m_kart_info
protected

This vector contains an 'KartInfo' struct for every kart in the race.

This member is not strictly private but try not to use it directly outside tightly related classes (e.g. AI)


The documentation for this class was generated from the following files: