Give a more helpful warning when mods try to play empty sound names.

This commit is contained in:
Shpoike 2021-03-28 12:16:10 +01:00
parent 6c4c739175
commit 61a2d3f6e4
3 changed files with 22 additions and 0 deletions

View file

@ -661,6 +661,12 @@ static void PF_sound (void)
volume = G_FLOAT(OFS_PARM3) * 255; volume = G_FLOAT(OFS_PARM3) * 255;
attenuation = G_FLOAT(OFS_PARM4); attenuation = G_FLOAT(OFS_PARM4);
if (!*sample)
{
PR_RunWarning("PF_sound: empty string\n");
return;
}
/* Spike -- these checks are redundant /* Spike -- these checks are redundant
if (volume < 0 || volume > 255) if (volume < 0 || volume > 255)
Host_Error ("SV_StartSound: volume = %i", volume); Host_Error ("SV_StartSound: volume = %i", volume);

View file

@ -258,6 +258,21 @@ void PR_RunError (const char *error, ...)
Host_Error("Program error"); Host_Error("Program error");
} }
void PR_RunWarning (const char *error, ...)
{
va_list argptr;
char string[1024];
va_start (argptr, error);
q_vsnprintf (string, sizeof(string), error, argptr);
va_end (argptr);
PR_PrintStatement(qcvm->statements + qcvm->xstatement);
PR_StackTrace();
Con_Warning("%s\n", string);
}
/* /*
==================== ====================
PR_EnterFunction PR_EnterFunction

View file

@ -139,6 +139,7 @@ int NUM_FOR_EDICT(edict_t *e);
extern int type_size[8]; extern int type_size[8];
FUNC_NORETURN void PR_RunError (const char *error, ...) FUNC_PRINTF(1,2); FUNC_NORETURN void PR_RunError (const char *error, ...) FUNC_PRINTF(1,2);
void PR_RunWarning (const char *error, ...) FUNC_PRINTF(1,2);
#ifdef __WATCOMC__ #ifdef __WATCOMC__
#pragma aux PR_RunError aborts; #pragma aux PR_RunError aborts;
#endif #endif