Skip to content

Commit

Permalink
Change over to a guard clause
Browse files Browse the repository at this point in the history
  • Loading branch information
CTalvio authored Dec 3, 2023
1 parent a3ffc59 commit 7399343
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut
Original file line number Diff line number Diff line change
Expand Up @@ -931,47 +931,47 @@ void function HandleDistanceAndTimeStats_Threaded()
// track distance stats
foreach ( entity player in GetPlayerArray() )
{
if ( IsValid(player) )
if ( !IsValid( player ) )
continue

if ( player.p.lastPosForDistanceStatValid )
{
if ( player.p.lastPosForDistanceStatValid )
// not 100% sure on using Distance2D over Distance tbh
float distInches = Distance2D( player.p.lastPosForDistanceStat, player.GetOrigin() )
float distMiles = distInches / 63360.0

// more generic distance stats
Stats_IncrementStat( player, "distance_stats", "total", "", distMiles )
if ( player.IsTitan() )
{
Stats_IncrementStat( player, "distance_stats", "asTitan_" + GetTitanCharacterName( player ), "", distMiles )
Stats_IncrementStat( player, "distance_stats", "asTitan", "", distMiles )
}
else
Stats_IncrementStat( player, "distance_stats", "asPilot", "", distMiles )


string state = ""
// specific distance stats
if ( player.IsWallRunning() )
state = "wallrunning"
else if ( PlayerIsRodeoingTitan( player ) )
{
// not 100% sure on using Distance2D over Distance tbh
float distInches = Distance2D( player.p.lastPosForDistanceStat, player.GetOrigin() )
float distMiles = distInches / 63360.0

// more generic distance stats
Stats_IncrementStat( player, "distance_stats", "total", "", distMiles )
if ( player.IsTitan() )
{
Stats_IncrementStat( player, "distance_stats", "asTitan_" + GetTitanCharacterName( player ), "", distMiles )
Stats_IncrementStat( player, "distance_stats", "asTitan", "", distMiles )
}
if ( player.GetTitanSoulBeingRodeoed().GetTeam() == player.GetTeam() )
state = "onFriendlyTitan"
else
Stats_IncrementStat( player, "distance_stats", "asPilot", "", distMiles )


string state = ""
// specific distance stats
if ( player.IsWallRunning() )
state = "wallrunning"
else if ( PlayerIsRodeoingTitan( player ) )
{
if ( player.GetTitanSoulBeingRodeoed().GetTeam() == player.GetTeam() )
state = "onFriendlyTitan"
else
state = "onEnemyTitan"
}
else if ( player.IsZiplining() )
state = "ziplining"
else if ( !player.IsOnGround() )
state = "inAir"

if ( state != "" )
Stats_IncrementStat( player, "distance_stats", state, "", distMiles )
state = "onEnemyTitan"
}
else if ( player.IsZiplining() )
state = "ziplining"
else if ( !player.IsOnGround() )
state = "inAir"

player.p.lastPosForDistanceStat = player.GetOrigin()
if ( state != "" )
Stats_IncrementStat( player, "distance_stats", state, "", distMiles )
}

player.p.lastPosForDistanceStat = player.GetOrigin()
}

float timeSeconds = Time() - lastTickTime
Expand Down

0 comments on commit 7399343

Please sign in to comment.