diff --git a/mods/ctf_pvp_engine/ctf/core.lua b/mods/ctf_pvp_engine/ctf/core.lua index 3a8ada8..3d89f92 100644 --- a/mods/ctf_pvp_engine/ctf/core.lua +++ b/mods/ctf_pvp_engine/ctf/core.lua @@ -212,15 +212,6 @@ function ctf.load() for i = 1, #ctf.registered_on_load do ctf.registered_on_load[i](table) end - -- Convert old data - for teamname,unused in pairs(ctf.teams) do - if not ctf.teams[teamname].power then - ctf.teams[teamname].power = 0 - for player,unused in pairs(ctf.teams[teamname].players) do - ctf.teams[teamname].power = ctf.teams[teamname].power + 1 - end - end - end return end ctf._loaddata = table diff --git a/mods/ctf_pvp_engine/ctf/teams.lua b/mods/ctf_pvp_engine/ctf/teams.lua index a2fa148..8d63715 100644 --- a/mods/ctf_pvp_engine/ctf/teams.lua +++ b/mods/ctf_pvp_engine/ctf/teams.lua @@ -39,8 +39,7 @@ function ctf.create_team(name, data) spawn = nil, players = {}, applications = {}, - access = {}, - power = 0 + access = {} } for i = 1, #ctf.registered_on_new_team do @@ -166,18 +165,18 @@ function ctf.application_join(name, tname) ctf.log("teams", "Missing parameters to ctf.request_join") end local player = ctf.player(name) - + if player.team and player.team == tname then minetest.chat_send_player(name, "You are already a member of team " .. tname) return false end - + if not ctf.setting("players_can_change_team") and player.team and ctf.team(player.team) then ctf.action("teams", name .. " requested to change to " .. tname) minetest.chat_send_player(name, "You are not allowed to switch teams, traitor!") return false end - + local team_data = ctf.team(tname) if not team_data then minetest.chat_send_player(name, "No such team.") @@ -185,7 +184,7 @@ function ctf.application_join(name, tname) minetest.log("action", name .. " requested to join to " .. tname .. ", which doesn't exist") return false end - + table.insert(team_data.applications,name) --ctf.post(tname, {msg = name .. " has applied to join!" }) ctf.needs_save = true @@ -485,7 +484,7 @@ function ctf.access_remove_team_all(name) end ctf.needs_save = true end - + -- Player joins team -- Called by /join, /team join, auto allocate or by response of the team manager. function ctf.join(name, team, force, by) @@ -540,9 +539,7 @@ function ctf.join(name, team, force, by) player.team = team team_data.players[player.name] = player - - ctf.team(team).power = ctf.team(team).power + 1 - + ctf.needs_save = true minetest.log("action", name .. " joined team " .. team) diff --git a/mods/ctf_pvp_engine/ctf_chat/init.lua b/mods/ctf_pvp_engine/ctf_chat/init.lua index 93aa4eb..f259d45 100644 --- a/mods/ctf_pvp_engine/ctf_chat/init.lua +++ b/mods/ctf_pvp_engine/ctf_chat/init.lua @@ -215,7 +215,7 @@ minetest.register_chatcommand("access", { elseif param ~= "" and param ~= nil then minetest.chat_send_player(name, "'"..param.."' is an invalid parameter to /access") access_console_help(name) - else + else access_console_help(name) return true, "Showing access help" end @@ -365,7 +365,6 @@ minetest.register_chatcommand("teamkick", { if ctf.remove_player(param) then ctf.player(param).auth = false ctf.player(param).recuiter = false - ctf.team(team).power = ctf.team(team).power - 1 return true, "Kicked " .. param .. " from " .. team .. "!" else return false, "Failed to kick " .. param.. "!" @@ -386,7 +385,6 @@ minetest.register_chatcommand("teamleave", { if ctf.remove_player(name) then ctf.player(name).auth = false ctf.player(name).recuiter = false - ctf.team(team).power = ctf.team(team).power - 1 -- Disband if there are zero players lefted on team local disband = true local teamdata = ctf.team(team) diff --git a/mods/ctf_pvp_engine/ctf_flag/flag_func.lua b/mods/ctf_pvp_engine/ctf_flag/flag_func.lua index 1806821..fcf347b 100644 --- a/mods/ctf_pvp_engine/ctf_flag/flag_func.lua +++ b/mods/ctf_pvp_engine/ctf_flag/flag_func.lua @@ -1,6 +1,12 @@ local r = ctf.setting("flag.nobuild_radius") local c_air = minetest.get_content_id("air") +local function elementsInTable(t) + local n = 0 + for _ in pairs(t) do n = n + 1 end + return n +end + local function can_place_flag(pos) local lpos = pos local pos1 = {x=lpos.x-r+1,y=lpos.y,z=lpos.z-r+1} @@ -210,7 +216,7 @@ ctf_flag = { minetest.chat_send_player(name, "You are at peace with this team!") return end - + local g_pos = players_glitching[name] if g_pos then minetest.get_player_by_name(name):set_pos(g_pos) @@ -288,13 +294,14 @@ ctf_flag = { return itemstack end - if ctf.team(tplayer.team).power and ctf.team(tplayer.team).power < 1 then - minetest.chat_send_player(name, "You need more members to be-able to place more flags.") + local tname = tplayer.team + local team = ctf.team(tplayer.team) + + if elementsInTable(team.players) <= elementsInTable(team.flags) then + minetest.chat_send_player(name, "You need more members to be able to place more flags.") return itemstack end - local tname = tplayer.team - local team = ctf.team(tplayer.team) meta:set_string("infotext", tname .. "'s flag") -- add flag @@ -333,10 +340,6 @@ ctf_flag = { local meta2 = minetest.get_meta(pos2) meta2:set_string("infotext", tname.."'s flag") - if ctf.team(tplayer.team).power then - ctf.team(tplayer.team).power = ctf.team(tplayer.team).power - 1 - end - itemstack:take_item() return itemstack else diff --git a/mods/ctf_pvp_engine/ctf_flag/gui.lua b/mods/ctf_pvp_engine/ctf_flag/gui.lua index 2f43c10..44efd3e 100644 --- a/mods/ctf_pvp_engine/ctf_flag/gui.lua +++ b/mods/ctf_pvp_engine/ctf_flag/gui.lua @@ -158,10 +158,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end ctf_flag.delete(team,pos) - - if ctf.team(team).power then - ctf.team(team).power = ctf.team(team).power + 1 - end minetest.set_node(pos,{name="air"}) pos.y=pos.y+1