From 6b338204479eeb45d852762366f2db012a7648b8 Mon Sep 17 00:00:00 2001 From: ANAND Date: Fri, 24 Apr 2020 00:20:35 +0530 Subject: [PATCH] setup_maps.sh: Improve renaming of maps' screenshot textures Screenshot textures would be renamed to "_screenshot.png", making it explicit that this texture is a screenshot texture. This fixes a potential bug wherein the screenshot texture could unintentionally override other textures if the map's name matches the texture name. e.g. moon.png - this would now be renamed to moon_screenshot.png. --- mods/ctf/ctf_map/ctf_map_core/init.lua | 2 +- mods/ctf/ctf_map/ctf_map_core/maps_catalog.lua | 6 +++--- setup_maps.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mods/ctf/ctf_map/ctf_map_core/init.lua b/mods/ctf/ctf_map/ctf_map_core/init.lua index ca88a73..df97149 100644 --- a/mods/ctf/ctf_map/ctf_map_core/init.lua +++ b/mods/ctf/ctf_map/ctf_map_core/init.lua @@ -10,7 +10,7 @@ end function ctf_map.file_exists(subdir, target) local list = minetest.get_dir_list(ctf_map.mapdir .. subdir, false) if type(target) == "string" then - return table.indexof(list, target) ~= 1 + return table.indexof(list, target) ~= -1 elseif type(target) == "table" then for _, filename in pairs(target) do if table.indexof(list, filename) == -1 then diff --git a/mods/ctf/ctf_map/ctf_map_core/maps_catalog.lua b/mods/ctf/ctf_map/ctf_map_core/maps_catalog.lua index 30b07d5..11f2ea3 100644 --- a/mods/ctf/ctf_map/ctf_map_core/maps_catalog.lua +++ b/mods/ctf/ctf_map/ctf_map_core/maps_catalog.lua @@ -50,9 +50,9 @@ local function show_catalog(name) -- Display screenshot if present, and move other elements down local y = 1 if ctf_map.file_exists(map.dirname, "screenshot.png") then - -- Check for mapdir .. "/screenshot.png", but pass in the texture - -- name, which would've been renamed to mapdir .. ".png" - fs = fs .. "image[4,1.5;6.5,3.5;" .. map.dirname .. ".png" .. "]" + -- Check for mapdir .. "/screenshot.png", but pass in the texture name, + -- which would've been renamed to "_screenshot.png" + fs = fs .. "image[4,1.5;6.5,3.5;" .. map.dirname .. "_screenshot.png" .. "]" y = y + 3.5 end diff --git a/setup_maps.sh b/setup_maps.sh index 1322c95..283f188 100755 --- a/setup_maps.sh +++ b/setup_maps.sh @@ -5,7 +5,7 @@ for f in *; do if [ -d ${f} ]; then # Screenshot if [ -f ${f}/screenshot.png ]; then - cp ${f}/screenshot.png ../textures/${f}.png + cp ${f}/screenshot.png ../textures/${f}_screenshot.png fi # Skybox textures