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`
This commit is contained in:
ANAND 2019-07-11 12:27:10 +05:30 committed by Thomas--S
parent 99bb09def6
commit d4c612d2fb

View file

@ -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)