From 86b44ecd8280d8304aa26a600fc004d40a970020 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 20 Oct 2021 19:50:16 +0000 Subject: Add no_texture.png as fallback for unspecified textures --- src/client/hud.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/client/hud.cpp') diff --git a/src/client/hud.cpp b/src/client/hud.cpp index 0620759da..e08d2ef02 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -1007,11 +1007,15 @@ void drawItemStack( bool draw_overlay = false; + bool has_mesh = false; + ItemMesh *imesh; + // Render as mesh if animated or no inventory image if ((enable_animations && rotation_kind < IT_ROT_NONE) || def.inventory_image.empty()) { - ItemMesh *imesh = client->idef()->getWieldMesh(def.name, client); - if (!imesh || !imesh->mesh) - return; + imesh = client->idef()->getWieldMesh(def.name, client); + has_mesh = imesh && imesh->mesh; + } + if (has_mesh) { scene::IMesh *mesh = imesh->mesh; driver->clearBuffers(video::ECBF_DEPTH); s32 delta = 0; @@ -1103,10 +1107,17 @@ void drawItemStack( draw_overlay = def.type == ITEM_NODE && def.inventory_image.empty(); } else { // Otherwise just draw as 2D video::ITexture *texture = client->idef()->getInventoryTexture(def.name, client); - if (!texture) - return; - video::SColor color = - client->idef()->getItemstackColor(item, client); + video::SColor color; + if (texture) { + color = client->idef()->getItemstackColor(item, client); + } else { + color = video::SColor(255, 255, 255, 255); + ITextureSource *tsrc = client->getTextureSource(); + texture = tsrc->getTexture("no_texture.png"); + if (!texture) + return; + } + const video::SColor colors[] = { color, color, color, color }; draw2DImageFilterScaled(driver, texture, rect, -- cgit v1.2.3