share/hedgewars/Data/Scripts/SimpleMission.lua
changeset 14489 764ba6182389
parent 14488 310b167141cc
child 14816 d65e25e211d4
--- a/share/hedgewars/Data/Scripts/SimpleMission.lua	Thu Dec 20 18:23:13 2018 +0100
+++ b/share/hedgewars/Data/Scripts/SimpleMission.lua	Thu Dec 20 19:03:34 2018 +0100
@@ -660,9 +660,9 @@
 				clanID = teamData.clanID
 			end
 
-			local idx
+			local realName
 			if teamData.isMissionTeam then
-				idx = AddMissionTeam(-(clanID+1))
+				realName = AddMissionTeam(-(clanID+1))
 				_G.sm.playerClan = clanID
 			else
 				grave = def(teamData.grave, defaultGraves[math.min(teamID, 8)])
@@ -670,19 +670,19 @@
 				voice = def(teamData.voice, "Default")
 				flag = def(teamData.flag, defaultFlags[math.min(teamID, 8)])
 
-				idx = AddTeam(name, -(clanID+1), grave, fort, voice, flag)
-				local realName = GetTeamName(idx)
-				-- Update all teamDefeat goals if the real team name differs from the
-				-- team configuration.
-				-- (AddTeam might change the name due to naming collisions)
-				if name ~= realName then
-					local checks = { params.customGoals, params.customNonGoals }
-					for c=1, 2 do
-						if checks[c] then
-							for k,goal in pairs(checks[c]) do
-								if goal.type == "teamDefeat" and goal.teamName == name then
-									goal.teamName = realName
-								end
+				realName = AddTeam(name, -(clanID+1), grave, fort, voice, flag)
+			end
+
+			-- Update all teamDefeat goals if the real team name differs from the
+			-- team configuration.
+			-- (AddTeam might change the name due to naming collisions)
+			if name ~= realName then
+				local checks = { params.customGoals, params.customNonGoals }
+				for c=1, 2 do
+					if checks[c] then
+						for k,goal in pairs(checks[c]) do
+							if goal.type == "teamDefeat" and goal.teamName == name then
+								goal.teamName = realName
 							end
 						end
 					end