From 9e84763478218430c52ee925bf1099ef4e0276f7 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 5 Mar 2019 14:19:57 +0100 Subject: [PATCH] mcl_skins: USe fallback if no preview img --- mods/PLAYER/mcl_skins/init.lua | 23 +++++++++++++++--- .../mcl_skins/textures/player_dummy.png | Bin 0 -> 982 bytes 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 mods/PLAYER/mcl_skins/textures/player_dummy.png diff --git a/mods/PLAYER/mcl_skins/init.lua b/mods/PLAYER/mcl_skins/init.lua index d8d4ebba5..53e73f975 100644 --- a/mods/PLAYER/mcl_skins/init.lua +++ b/mods/PLAYER/mcl_skins/init.lua @@ -1,7 +1,7 @@ -- Skins for MineClone 2 mcl_skins = { - skins = {}, list = {}, previews = {}, meta = {}, + skins = {}, list = {}, previews = {}, meta = {}, has_preview = {}, modpath = minetest.get_modpath("mcl_skins"), skin_count = 0, -- counter of _custom_ skins (all skins except character.png) } @@ -18,10 +18,12 @@ while true do if id == 0 then skin = "character" + mcl_skins.has_preview[id] = true else skin = "character_" .. id + local preview = "player_" .. id - -- does skin file exist ? + -- Does skin file exist? f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png") -- escape loop if not found @@ -29,6 +31,16 @@ while true do break end f:close() + + -- Does skin preview file exist? + local file_preview = io.open(mcl_skins.modpath .. "/textures/" .. preview .. ".png") + if file_preview == nil then + minetest.log("warning", "[mcl_skins] Player skin #"..id.." does not have preview image (player_"..id..".png)") + mcl_skins.has_preview[id] = false + else + mcl_skins.has_preview[id] = true + file_preview:close() + end end mcl_skins.list[id] = skin @@ -78,7 +90,12 @@ mcl_skins.set_player_skin = function(player, skin_id) preview = "player" else skin = "character_" .. tostring(skin_id) - preview = "player_" .. tostring(skin_id) + if mcl_skins.has_preview[skin_id] then + preview = "player_" .. tostring(skin_id) + else + -- Fallback preview image if preview image is missing + preview = "player_dummy" + end end skin_file = skin .. ".png" mcl_skins.skins[playername] = skin diff --git a/mods/PLAYER/mcl_skins/textures/player_dummy.png b/mods/PLAYER/mcl_skins/textures/player_dummy.png new file mode 100644 index 0000000000000000000000000000000000000000..d1f7dc20aa3dd99924ce8f2f65a2d010c90a9246 GIT binary patch literal 982 zcmV;{11bE8P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+U=EHmLn$&h2L34mQa!q63d||I43)p<>x}-fA=Kq z^y7eCP_npyK7m8~^>+_{p-}V~qME0i(uNXq%v{j%?JQ?YTb$4JvRyh4_Q01P7$!k0 z=WA-qzre1y0T!2if3ydyOUIWGU4>_nG4tpzKVL$^r=8Y&$ZK4QciUNCu1j`_Kfgyq zFb;*DaNs5+8=gL95v)M66tps*%EJ<8f7n^#``88lB6!!{Q|z{~?D80ju%+dYo?^7@ zq)&FaPQwo?qT9?5KkR9X+kLreylhu>&-B)EX!gBifxJ9aN}On{B0vB}Q&+XqhX^w7D2(u5uzkrOpNnM-T^z3Tgr~ zU)Mr&-aO~4UQ(7{F|0gm&S8)J;7FDsvBTrB{hlEi=p2L-TVROFB0BFeF-Xbh^F z)YLU=Ns?mHl#-=!M->x`rk2diEn9K%=<3PM-Lsd>S#X7EPT4~CoO3Cdv_QIGbb&`H zJMXf`UH7!x?t9)#Mf%iOwWey-Yp&(sLk=AOBOMkFKk`u;HKbCDOs2Ws?0?)TJaQ5(eK^s^f^n9VK{G_DgJ%s`AIfw&Cal%s3Rvphi0295jf5U~I(N>B{a#?zh~6#&2=sugHag?kC8Ffo_p|<@Sc!QRY92 zOhDrlj+k!Jaj~_+K0ckjYd!n0>auF=xRI9ixoxGbvEhF3i`zHE!t+W#6$|anwmuOH z_xt>QjBaiCH;4b){t@~*5ifwkCt3V1Rl=u7;#n+wdL*93!v8s6FERQFvG5Zo|K%FN zwUxs^GVa87H8c1700006VoOIv0RI600RN!9r;`8x010qNS#tmYE+YT{E+YYWr9XB6 z000McNliru;{yc^2^i)K`62)S06$4YK~zY`V>~mjjsY2Ly#N0{10LY7$jFGyXJVib zj2bW)3}7J?@8|$s{b(SL8Zcb)0(u!YS|*MfFhUIg0F7=Dy0Zh%7ytkO07*qoM6N<$ Eg6UDq0RR91 literal 0 HcmV?d00001