From 917e7e27c4ccbacace4dea77ef61262c12fc1aa8 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 1 Nov 2023 12:45:53 -0700 Subject: [PATCH 1/6] Save initial stuff position, not just order --- mods/ctf/ctf_modebase/player.lua | 56 ++++++++++++++++++++++---------- mods/other/crafting/gui.lua | 3 +- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/mods/ctf/ctf_modebase/player.lua b/mods/ctf/ctf_modebase/player.lua index 34439b21cc..dd7f64ae46 100644 --- a/mods/ctf/ctf_modebase/player.lua +++ b/mods/ctf/ctf_modebase/player.lua @@ -22,12 +22,31 @@ local simplify_for_saved_stuff = function(iname) return iname end -function ctf_modebase.player.save_initial_stuff_order(player, soft) +local function is_initial_stuff(player, i) + local mode = ctf_modebase:get_current_mode() + if mode and mode.stuff_provider then + for _, item in ipairs(mode.stuff_provider(player)) do + if ItemStack(item):get_name() == i then + return true + end + end + end + + if ctf_map.current_map and ctf_map.current_map.initial_stuff then + for _, item in ipairs(ctf_map.current_map.initial_stuff) do + if ItemStack(item):get_name() == i then + return true + end + end + end +end + +function ctf_modebase.player.save_initial_stuff_positions(player, soft) if not ctf_modebase.current_mode then return end local inv = player:get_inventory() local meta = player:get_meta() - local ssp = meta:get_string("ctf_modebase:player:initial_stuff_order:"..ctf_modebase.current_mode) + local ssp = meta:get_string("ctf_modebase:player:initial_stuff_positions:"..ctf_modebase.current_mode) if ssp == "" then ssp = {} @@ -37,8 +56,10 @@ function ctf_modebase.player.save_initial_stuff_order(player, soft) local done = {} for i, s in pairs(inv:get_list("main")) do - if s:get_name() ~= "" then - local k = simplify_for_saved_stuff(s:get_name():match("[^%s]*")) + local n = s:get_name() + + if n ~= "" and is_initial_stuff(player, n) then + local k = simplify_for_saved_stuff(n:match("[^%s]*")) if not soft or not ssp[k] then if not done[k] or (i < ssp[k]) then @@ -49,9 +70,10 @@ function ctf_modebase.player.save_initial_stuff_order(player, soft) end end - meta:set_string("ctf_modebase:player:initial_stuff_order:"..ctf_modebase.current_mode, minetest.serialize(ssp)) + meta:set_string("ctf_modebase:player:initial_stuff_positions:"..ctf_modebase.current_mode, minetest.serialize(ssp)) end +-- Changes made to this function should also be made to is_initial_stuff() above local function get_initial_stuff(player, f) local mode = ctf_modebase:get_current_mode() if mode and mode.stuff_provider then @@ -113,9 +135,11 @@ function ctf_modebase.player.give_initial_stuff(player) end) -- Check for new items not yet in the order list - ctf_modebase.player.save_initial_stuff_order(player, true) + ctf_modebase.player.save_initial_stuff_positions(player, true) - local saved_stuff_positions = meta:get_string("ctf_modebase:player:initial_stuff_order:"..ctf_modebase.current_mode) + local saved_stuff_positions = meta:get_string( + "ctf_modebase:player:initial_stuff_positions:"..ctf_modebase.current_mode + ) if saved_stuff_positions == "" then saved_stuff_positions = {} @@ -140,16 +164,14 @@ function ctf_modebase.player.give_initial_stuff(player) end for stack, idx in pairs(tmp) do - for i = 1, #new+1 do - if new[i] then - if idx < tmp[new[i]] then - table.insert(new, i, stack) - break - end - else - new[i] = stack - break - end + if not new[idx] then + new[idx] = stack + end + end + + for stack, idx in pairs(tmp) do + if not new[idx] == stack then + table.insert(new, stack) end end diff --git a/mods/other/crafting/gui.lua b/mods/other/crafting/gui.lua index 2e0bbd646d..26cca5033c 100644 --- a/mods/other/crafting/gui.lua +++ b/mods/other/crafting/gui.lua @@ -163,7 +163,6 @@ function crafting.result_select_on_receive_results(player, context, fields) if key:sub(1, 7) == "result_" then local num = string.match(key, "result_([0-9]+)") if num then - local inv = player:get_inventory() local recipe = crafting.get_recipe(tonumber(num)) local name = player:get_player_name() if not crafting.can_craft(name, recipe) then @@ -215,7 +214,7 @@ if minetest.global_exists("sfinv") then end if fields.save_inv_order then - ctf_modebase.player.save_initial_stuff_order(player) + ctf_modebase.player.save_initial_stuff_positions(player) minetest.sound_play("crafting_save_sound", { to_player = player:get_player_name(), From 797abe0cf47ce2a1e186bcfd1f188c6159a59af8 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 1 Nov 2023 12:49:40 -0700 Subject: [PATCH 2/6] Make flag drop sounds quieter --- mods/ctf/ctf_modebase/features.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ctf/ctf_modebase/features.lua b/mods/ctf/ctf_modebase/features.lua index 07b7adeee2..591dfb37e7 100644 --- a/mods/ctf/ctf_modebase/features.lua +++ b/mods/ctf/ctf_modebase/features.lua @@ -151,13 +151,13 @@ local function drop_flag(teamname) if pteam == teamname then minetest.sound_play("ctf_modebase_drop_flag_negative", { to_player = pname, - gain = 0.4, + gain = 0.2, pitch = 1.0, }, true) else minetest.sound_play("ctf_modebase_drop_flag_positive", { to_player = pname, - gain = 0.4, + gain = 0.2, pitch = 1.0, }, true) end From 60b745b325aa2c76730358be8fbeb60336083fb4 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 1 Nov 2023 13:13:30 -0700 Subject: [PATCH 3/6] Add some logging to help catch a rare crash --- mods/apis/ctf_gui/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/apis/ctf_gui/init.lua b/mods/apis/ctf_gui/init.lua index 9ca06e89d7..d2b88231e9 100644 --- a/mods/apis/ctf_gui/init.lua +++ b/mods/apis/ctf_gui/init.lua @@ -144,6 +144,7 @@ do end end + minetest.log("action", "[ctf_gui] unpacking: "..dump(l)) return format(base, unpck(l)) end From 284eda873e580996022899a6a7f67383f4eead62 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 1 Nov 2023 13:39:38 -0700 Subject: [PATCH 4/6] Fix luacheck warning --- mods/ctf/ctf_modebase/player.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_modebase/player.lua b/mods/ctf/ctf_modebase/player.lua index dd7f64ae46..e8e91af728 100644 --- a/mods/ctf/ctf_modebase/player.lua +++ b/mods/ctf/ctf_modebase/player.lua @@ -170,7 +170,7 @@ function ctf_modebase.player.give_initial_stuff(player) end for stack, idx in pairs(tmp) do - if not new[idx] == stack then + if new[idx] ~= stack then table.insert(new, stack) end end From bb242c11ca87c775bd15e19d2957ab46ded77090 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 1 Nov 2023 16:05:39 -0700 Subject: [PATCH 5/6] Remove unused textures --- .../ctf_map/textures/default_chest_front_blue.png | Bin 625 -> 0 bytes .../ctf_map/textures/default_chest_front_red.png | Bin 614 -> 0 bytes .../ctf_map/textures/default_chest_side_blue.png | Bin 564 -> 0 bytes .../ctf_map/textures/default_chest_side_red.png | Bin 556 -> 0 bytes .../ctf_map/textures/default_chest_top_blue.png | Bin 593 -> 0 bytes .../ctf_map/textures/default_chest_top_red.png | Bin 587 -> 0 bytes 6 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 mods/ctf/ctf_map/textures/default_chest_front_blue.png delete mode 100644 mods/ctf/ctf_map/textures/default_chest_front_red.png delete mode 100644 mods/ctf/ctf_map/textures/default_chest_side_blue.png delete mode 100644 mods/ctf/ctf_map/textures/default_chest_side_red.png delete mode 100644 mods/ctf/ctf_map/textures/default_chest_top_blue.png delete mode 100644 mods/ctf/ctf_map/textures/default_chest_top_red.png diff --git a/mods/ctf/ctf_map/textures/default_chest_front_blue.png b/mods/ctf/ctf_map/textures/default_chest_front_blue.png deleted file mode 100644 index 3dabef4c1aab7f834f9a0cdf4815ad337af8307e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 625 zcmV-%0*?KOP)763fO_YV6e?UjH(QJ2%M(Xi9~ z`4s^BuhNZM01A`CIWPu*2B%zyLTVXQP1=(|l?ml6wRbiofMlU@t+D8w%T3YTdh_VP zy@yXfPFD2#rO9WTZ`ZC~C+n18@0u?Gh^W5IggQ3S(V$?Ab^AlVl6?O5WA(zhyX$kC zAKI6fX6lJ|emXott-ZS?0jSDk62}0#LzbT+qa1MiC2mek2koHcq-Z2-FOD%LT#%!J* z4?98!NgPWrECB$F3mSH^--ld!Tn9o2Tu8>ab46i|$HiZ9XEyx@+2+#@T@kli00000 LNkvXXu0mjf*+vN_ diff --git a/mods/ctf/ctf_map/textures/default_chest_front_red.png b/mods/ctf/ctf_map/textures/default_chest_front_red.png deleted file mode 100644 index 02305af6c75c21cf32934c35cb6132b2e7aaca52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 614 zcmV-s0-61ZP)j zK~yNuosvyU8(|cM&-*oB&W8!64#o(Df?^gf+z4H?%Od`Q{ts9F5!d|z;!0?7XS*n3 zp{QV8h(e_Vl7>tYCo}h*_w8aryS8V0c{ul+d)d1*#d9P9ylJ%(DKo7XgaAO+)-%PJ zU`%rE2?0Pd_Tk|{0!XA>k7Mb&UYY`^o}Q}NOhu6lL+*LpaR6AY@6XTY4w=>f{B~Q0 zp>SOQ)>?0Q8G!J80Niyax3^=h=RoRt3o9%6<6}9SIi9EDxXSbK%?*HRHUmIJBcdN! z27vuf=(nvFfYKNXFaW@iDB#=?B9d~fbtI)?jI90C>q!9JBw5?pvDTWh{Bm~o{_ybf z;J|4#8r$1nkB(k%ZCN6w)W?ep0OC~`D#pUW!1Vi!v8OCcJn!fA^^48TmA$>*>1k_Y z!%fp*b#2uXu=Zg({kIZ;VV)0)LUQhK?h8?4c~y-D17C8_WHZpU@JyZboY^AL-dZ}E^~0P|=DIrM`OV$7+>!0u6F#uJ} zM$4yJqK-!fK;8Pi^<}DxgcBt-O90Nt4_|)`A6&Bquox#r!bTB*7~@f07l7+ ztNX6H9RSIAv7F_>QN?XJE75dS0k`1B2cVB5pg)*Goa zV$EsknjNR5AQip6{&dCwMkmi-y?7jBY;D*!c75M9ouA}7Gjt%PNPIj$13<;%i6pi1 z#j1`%2+cA#yqu&(!kOVz(Hvy@~VdFXz3j)3Pi{icQr4ASw1~P$WnSCTT*n zE-;B|yBRc)GUHrZ7jCQ0TC0@uA(9k{qRf!<0e}zjpRK{WB4Ou4net!-NdSFneQ*H2 z=aT`@tS>)b{K$^x)>>jE1pruUgX<*gQJ(aGdVTqq5^Eu;+1<9gRo`-2_D8{WtNM;~ zT9zf7YykA-nq9ZO0YFLNT}Q0@xp$qBbU1r((tiN`q`Yi>5p@m#0000{1F%|uy}M%o z$HsgpOOxkWRRQSt`~Gk+-g8lC=d`r|QV72;FGq(>2msu2$wfg~1|X$mj*e(DA?E<- zEc7~U*tW9SbkEOy)7bf(^87WJGUoj1YIOKs*L-nN zIG0tGb}p+bo=yQMA^_SLE=!tBKCf2a9v>ONJ7c`}im0pWVJ;pH${0nYnNyZU5yf2Z zcB4Z^WM{J|(yiAbVvI?BuZYMw%JUckfYkT@o;AeCMG-?_?}yNu8NkrmP#l2y?d=HM zH_gxM>qVZ6h#`X307RsV(Q56=ascl4`w_52q|~};p4xU;dgfuMi}B^@X+q?^&zVPH u&^CnMT?e2b>iXUijZEJU|7FmdoBj&{Q@k=fC0eWi0000%n*R*Z{C@5?%kGb1wfgcnS zOgYcmMZ36Iv=+dz4?{?my{L0-wKOCFgvg)1r^&&)ZFPEnev(&~GOYkGb6e=#D618K zOv~%r{czk)z|)tn+Cnc^uImSznaWb{(|BiNF zFvU8Xp8(jou-XrXq_dHf)Jl+&Sz;d&DY0C+$st8QE43Tq=IFimF==K90YkFLD8vMS z8CJ{xfbWZp49T|8Q~yc=7+V{Q1Musin}E&Dm(OI%*_roV>xuE+a|}XJQ`*sCeRnef zN?Re7+pW9JZ>2LyW{eyF4}5=k(6(yoit>5_LVq~^`Ida&ZSKbBQ`!neLP!893;_1^ flTk%H_PzfBuWji{(7b_|00000NkvXXu0mjf5n2(Q diff --git a/mods/ctf/ctf_map/textures/default_chest_top_red.png b/mods/ctf/ctf_map/textures/default_chest_top_red.png deleted file mode 100644 index 5bc699b57456f188b682c089e31a67a2f9672077..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 587 zcmV-R0<`^!P)?C8~pgBkvIa@E%gJhp{2^{g5KM zpn8B{3CssPJV1QAy~SsO06g5?&5SuZXNdr0N-^`%dn2V3B9YQaSxu+yPqFe?GQbtF Date: Wed, 1 Nov 2023 16:48:06 -0700 Subject: [PATCH 6/6] Treat class primaries the same in initial stuff positioning --- mods/ctf/ctf_modebase/player.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mods/ctf/ctf_modebase/player.lua b/mods/ctf/ctf_modebase/player.lua index e8e91af728..687e986a5c 100644 --- a/mods/ctf/ctf_modebase/player.lua +++ b/mods/ctf/ctf_modebase/player.lua @@ -11,6 +11,12 @@ local simplify_for_saved_stuff = function(iname) return "shovel" elseif iname:match("ctf_mode_nade_fight:") then return "nade_fight_grenade" + elseif + iname == "ctf_mode_classes:knight_sword" or + iname == "ctf_mode_classes:support_bandage" or + iname == "ctf_mode_classes:ranged_rifle_loaded" + then + return "class_primary" end local mod, match = iname:match("(%a+):sword_(%a+)")