From 33eff5886985a2b501488eeb1ddac4adaf36b301 Mon Sep 17 00:00:00 2001 From: jdolan Date: Sat, 29 Jun 2013 10:16:29 -0400 Subject: [PATCH] Try skin.tga in the model directory as a last-ditch-effort to load model skins. This fixes all of the Quake2World models in Radiant. --- plugins/model/cpicosurface.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/model/cpicosurface.cpp b/plugins/model/cpicosurface.cpp index 470623f..9f5665e 100644 --- a/plugins/model/cpicosurface.cpp +++ b/plugins/model/cpicosurface.cpp @@ -33,6 +33,20 @@ CPicoSurface::CPicoSurface( picoSurface_t *pSurface ){ AccumulateBBox(); m_shader = QERApp_Shader_ForName( GetShaderName() ); + + // jdolan: If the shader fails to load, try skin.tga in the model's + // directory as a fall-back. This is a hack for malformed models. + + if ( m_shader->IsDefault()) { + gchar *dir = g_path_get_dirname(m_pSurface->model->name); + gchar *skin = g_strdup_printf("%s/skin.tga", dir); + + m_shader->DecRef(); + m_shader = QERApp_Shader_ForName( skin ); + + g_free(skin); + g_free(dir); + } } CPicoSurface::~CPicoSurface(){