From 0f5f921c0dfb564f4c545e0749d3f70c0e624f7f Mon Sep 17 00:00:00 2001 From: savilli <78875209+savilli@users.noreply.github.com> Date: Tue, 4 May 2021 22:59:33 +0200 Subject: [PATCH] Fix ctf_marker crash (#877) --- mods/ctf/ctf_classes/melee.lua | 4 ++++ mods/ctf/ctf_marker/init.lua | 12 +++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/mods/ctf/ctf_classes/melee.lua b/mods/ctf/ctf_classes/melee.lua index 2b33700..b1d176a 100644 --- a/mods/ctf/ctf_classes/melee.lua +++ b/mods/ctf/ctf_classes/melee.lua @@ -69,6 +69,10 @@ minetest.register_tool("ctf_classes:sword_bronze", { local pteam = ctf.player(pname).team + if not pteam then -- can be nil during map change + return + end + if pointed_thing.type == "object" and pointed_thing.ref:is_player() then if ctf_match.is_in_build_time() then return end diff --git a/mods/ctf/ctf_marker/init.lua b/mods/ctf/ctf_marker/init.lua index 4312d00..3a162cc 100644 --- a/mods/ctf/ctf_marker/init.lua +++ b/mods/ctf/ctf_marker/init.lua @@ -30,17 +30,8 @@ end -- Add waypoint element to all players in the same team as name function ctf_marker.add_marker(name, tname, pos, str) - local player = minetest.get_player_by_name(name) - if not player then - return - end - local team = ctf.team(tname) - if not tname then - minetest.log("error", "Team name not provided to ctf_marker.add_marker()") - end - teams[tname] = { players = {}, time = 0 @@ -101,6 +92,9 @@ minetest.register_chatcommand("m", { end local tname = ctf.player(name).team + if not tname then -- can be nil during map change + return + end -- Handle waypoint string local str = (param and param:trim() ~= "") and ": " .. param or ""