From d4c612d2fba45a950c92b92ed04951c3f657d9ba Mon Sep 17 00:00:00 2001 From: ANAND Date: Thu, 11 Jul 2019 12:27:10 +0530 Subject: [PATCH] Fix flag claimed right after creation (#433) Regression introduced by abbd62ac: - Since abbd62ac, all map metas are loaded at server startup. - In `ctf_match.create_teams`, `map.teams.pos` is passed to `ctf_flag.add`. - As tables are passed by reference, properties added to `ctf.team("team_name").flags[i]` are also added to ctf_map.map.teams. - This means that the next time this table is passed to `ctf_flag.add`, this table would already contain the `claimed` property, that holds the name of the player who last claimed the flag at this pos, and the name of their team. This is fixed by simply passing `map.teams.pos` to `ctf_flag.add` using `table.copy` --- mods/ctf/ctf_map/schem_map.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/schem_map.lua b/mods/ctf/ctf_map/schem_map.lua index f026ded..0cdc0f6 100644 --- a/mods/ctf/ctf_map/schem_map.lua +++ b/mods/ctf/ctf_map/schem_map.lua @@ -351,7 +351,7 @@ function ctf_match.create_teams() for key, value in pairs(ctf_map.map.teams) do local name = key local color = value.color - local flag = value.pos + local flag = table.copy(value.pos) if name and color and flag then print(" - creating " .. key)