setup_maps.sh: Improve renaming of maps' screenshot textures

Screenshot textures would be renamed to "<mapname>_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.
master
ANAND 2 years ago
parent 8d0df46821
commit 6b33820447
No known key found for this signature in database
GPG Key ID: 3AD8A3C4A51AAB97
  1. 2
      mods/ctf/ctf_map/ctf_map_core/init.lua
  2. 6
      mods/ctf/ctf_map/ctf_map_core/maps_catalog.lua
  3. 2
      setup_maps.sh

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

@ -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 "<mapdir>_screenshot.png"
fs = fs .. "image[4,1.5;6.5,3.5;" .. map.dirname .. "_screenshot.png" .. "]"
y = y + 3.5
end

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

Loading…
Cancel
Save