Commit f3f78857 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

engine: this condition should never happen, but mdgetskinmap() can return null...

engine: this condition should never happen, but mdgetskinmap() can return null and we weren't checking it
parent 899769f9
......@@ -2281,34 +2281,40 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
//POGOTODO: if we add support for palette indexing on model skins, the texture for the palswap could be setup here
texunits += 4;
i = r_detailmapping ? mdloadskin((md2model_t *) m, skinNum, DETAILPAL, surfi) : 0;
if (i)
if ((i = r_detailmapping ? mdloadskin((md2model_t *) m, skinNum, DETAILPAL, surfi) : 0))
{
polymost_useDetailMapping(true);
auto sk = mdgetskinmap(m, DETAILPAL, skinNum, surfi);
f = sk->param;
polymost_setupdetailtexture(GL_TEXTURE3, i, (sk->flags& HICR_FORCEFILTER) ? (PTH_HIGHTILE | PTH_FORCEFILTER) : PTH_HIGHTILE);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(xpanning, ypanning, 1.0f);
glScalef(f, f, 1.0f);
glMatrixMode(GL_MODELVIEW);
if (sk != nullptr)
{
polymost_useDetailMapping(true);
polymost_setupdetailtexture(GL_TEXTURE3, i, (sk->flags & HICR_FORCEFILTER) ? (PTH_HIGHTILE | PTH_FORCEFILTER) : PTH_HIGHTILE);
f = sk->param;
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(xpanning, ypanning, 1.0f);
glScalef(f, f, 1.0f);
glMatrixMode(GL_MODELVIEW);
}
else VLOG_F(LOG_ENGINE, "polymost_md3draw: detail skin %d has no skinmap", skinNum);
}
i = r_glowmapping ? mdloadskin((md2model_t *) m, skinNum, GLOWPAL, surfi) : 0;
if (i)
if ((i = r_glowmapping ? mdloadskin((md2model_t *) m, skinNum, GLOWPAL, surfi) : 0))
{
polymost_useGlowMapping(true);
auto sk = mdgetskinmap(m, GLOWPAL, skinNum, surfi);
polymost_setupglowtexture(GL_TEXTURE4, i, (sk->flags& HICR_FORCEFILTER) ? (PTH_HIGHTILE | PTH_FORCEFILTER) : PTH_HIGHTILE);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(xpanning, ypanning, 1.0f);
glMatrixMode(GL_MODELVIEW);
if (sk != nullptr)
{
polymost_useGlowMapping(true);
polymost_setupglowtexture(GL_TEXTURE4, i, (sk->flags & HICR_FORCEFILTER) ? (PTH_HIGHTILE | PTH_FORCEFILTER) : PTH_HIGHTILE);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(xpanning, ypanning, 1.0f);
glMatrixMode(GL_MODELVIEW);
}
else VLOG_F(LOG_ENGINE, "polymost_md3draw: glow skin %d has no skinmap", skinNum);
}
if (r_vertexarrays)
......@@ -2554,7 +2560,7 @@ mdmodel_t *mdload(const char *filnam)
// smuggle the file name into the model struct.
// head.nam is unused as far as I can tell
Bstrncpyz(vm3->head.nam, filnam, sizeof(vm3->head.nam));
Bstrncpyz(vm3->head.nam, filnam, sizeof(vm3->head.nam)-1);
md3postload_common(vm3);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment