TrophyRace: fix nil error warning, caused by needlessly re-retrieving the name of the best hedgehog (which could be dead at that point)
authorsheepluva
Wed, 07 Oct 2015 23:20:31 +0200
changeset 11205 9301550d2566
parent 11202 cc308446f90d
child 11206 a85b0ef91685
TrophyRace: fix nil error warning, caused by needlessly re-retrieving the name of the best hedgehog (which could be dead at that point)
share/hedgewars/Data/Maps/TrophyRace/map.lua
--- a/share/hedgewars/Data/Maps/TrophyRace/map.lua	Mon Oct 05 13:38:25 2015 +0200
+++ b/share/hedgewars/Data/Maps/TrophyRace/map.lua	Wed Oct 07 23:20:31 2015 +0200
@@ -33,6 +33,7 @@
 local worsthog = nil
 
 local besthog = nil
+local besthogname = ''
 
 -- best time
 local besttime = maxtime + 1
@@ -142,6 +143,7 @@
             if ttime < besttime then
                 besttime = ttime
                 besthog = CurrentHedgehog
+                besthogname = GetHogName(besthog)
                 hscore = hscore .. loc("NEW fastest lap: ")
             else
                 hscore = hscore .. loc("Fastest lap: ")
@@ -150,7 +152,7 @@
                 worsttime = ttime
                 worsthog = CurrentHedgehog
             end
-            hscore = hscore .. GetHogName(besthog) .. " - " .. (besttime / 1000) .. " s | |" .. loc("Best laps per team: ")
+            hscore = hscore .. besthogname .. " - " .. (besttime / 1000) .. " s | |" .. loc("Best laps per team: ")
             
             if clan == ClansCount -1 then
                 -- Time for elimination - worst hog is out and the worst hog vars are reset.