Fixed r_showshaders crashing on a surface without shadername.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5335 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Eukara 2018-11-10 08:26:51 +00:00
parent 2d539675cf
commit 4cabdb80c5

View file

@ -7300,21 +7300,23 @@ char *Shader_GetShaderBody(shader_t *s, char *fname, size_t fnamesize)
} }
} }
if (!strchr(parsename, ':')) if ( parsename ) {
{ if (!strchr(parsename, ':'))
//if the named shader is a .shader file then just directly load it.
const char *token = COM_GetFileExtension(parsename, NULL);
if (!strcmp(token, ".shader") || !*token)
{ {
char shaderfile[MAX_QPATH]; //if the named shader is a .shader file then just directly load it.
if (!*token) const char *token = COM_GetFileExtension(parsename, NULL);
if (!strcmp(token, ".shader") || !*token)
{ {
Q_snprintfz(shaderfile, sizeof(shaderfile), "%s.shader", parsename); char shaderfile[MAX_QPATH];
if (COM_FCheckExists(shaderfile)) if (!*token)
Q_snprintfz(fname, fnamesize, "%s:%i", shaderfile, 1); {
Q_snprintfz(shaderfile, sizeof(shaderfile), "%s.shader", parsename);
if (COM_FCheckExists(shaderfile))
Q_snprintfz(fname, fnamesize, "%s:%i", shaderfile, 1);
}
else if (COM_FCheckExists(parsename))
Q_snprintfz(fname, fnamesize, "%s:%i", parsename, 1);
} }
else if (COM_FCheckExists(parsename))
Q_snprintfz(fname, fnamesize, "%s:%i", parsename, 1);
} }
} }
} }