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.
This commit is contained in:
ANAND 2020-04-24 00:20:35 +05:30
parent 8d0df46821
commit 6b33820447
No known key found for this signature in database
GPG key ID: 3AD8A3C4A51AAB97
3 changed files with 5 additions and 5 deletions

View file

@ -10,7 +10,7 @@ end
function ctf_map.file_exists(subdir, target) function ctf_map.file_exists(subdir, target)
local list = minetest.get_dir_list(ctf_map.mapdir .. subdir, false) local list = minetest.get_dir_list(ctf_map.mapdir .. subdir, false)
if type(target) == "string" then if type(target) == "string" then
return table.indexof(list, target) ~= 1 return table.indexof(list, target) ~= -1
elseif type(target) == "table" then elseif type(target) == "table" then
for _, filename in pairs(target) do for _, filename in pairs(target) do
if table.indexof(list, filename) == -1 then if table.indexof(list, filename) == -1 then

View file

@ -50,9 +50,9 @@ local function show_catalog(name)
-- Display screenshot if present, and move other elements down -- Display screenshot if present, and move other elements down
local y = 1 local y = 1
if ctf_map.file_exists(map.dirname, "screenshot.png") then if ctf_map.file_exists(map.dirname, "screenshot.png") then
-- Check for mapdir .. "/screenshot.png", but pass in the texture -- Check for mapdir .. "/screenshot.png", but pass in the texture name,
-- name, which would've been renamed to mapdir .. ".png" -- which would've been renamed to "<mapdir>_screenshot.png"
fs = fs .. "image[4,1.5;6.5,3.5;" .. map.dirname .. ".png" .. "]" fs = fs .. "image[4,1.5;6.5,3.5;" .. map.dirname .. "_screenshot.png" .. "]"
y = y + 3.5 y = y + 3.5
end end

View file

@ -5,7 +5,7 @@ for f in *; do
if [ -d ${f} ]; then if [ -d ${f} ]; then
# Screenshot # Screenshot
if [ -f ${f}/screenshot.png ]; then if [ -f ${f}/screenshot.png ]; then
cp ${f}/screenshot.png ../textures/${f}.png cp ${f}/screenshot.png ../textures/${f}_screenshot.png
fi fi
# Skybox textures # Skybox textures