Compare commits

..
Author SHA1 Message Date
James R ec757ceb2c Pass const pointer to all netxcmd handlers
Ensure buffer data is read-only and not modified by
handler
2025-11-01 21:21:06 +01:00
Alug e00783da82 fix stuff from merge conflict 2025-11-01 21:21:03 +01:00
toaster 52a9486974 Remove heinous pointer-sent-over-the-network hack remnants
This used to be used for `P_RelinkPointers()`, but was superseded by the far saner mobjnum. HOWEVER, its lingering effect was to leave `mobj->info` in an invalid state until a later `P_FinishMobjs()` was called. This is memory unsafety :D

After removing the last remnants of this ancient hack, it is now once again possible to connect to a server without crashing immediately. However, I did get a crash after a few seconds, so there is definitely still *something* nasty going on under the hood.
2025-11-01 21:20:58 +01:00
Alug 26b26b8f25 consolelib: fix some early returns not properly cleaning lua stack 2025-11-01 21:20:53 +01:00
James R 81f7335b05 Got_Luacmd: always read netxcmd data, even if command is not executed 2025-11-01 21:20:48 +01:00
Eidolon f603106ac8 Check Lua stack before pushing cons args
Prevents a Lua stack overrun when executing absurd console commands for
local-only lua commands.
2025-11-01 21:20:43 +01:00
James R 5675eefeb2 Got_Luacmd: ensure lua stack is large enough for command arguments 2025-11-01 21:20:39 +01:00
Monster Iestyn 1d0fb17da4 Fixes for lib_cvRegisterVar (the Lua version of CV_RegisterVar):
* Make sure the consvar's properties are all initialised to zeros as defaults
* Error if the consvar is not given a name
* Error if the consvar has CV_CALL but no call function
* Error if the consvar has CV_NOINIT but not CV_CALL
2025-11-01 21:20:31 +01:00
James R f53d37052a Replace LUA_PushLightUserdata with LUA_PushUserdata
See c92378fa and a7e20f70. I didn't realize that light
userdata's metatable is shared--like numbers or strings.
So it cannot be paired with a metatable.

I also made a few minor tweaks to Lua cvars, other than
accounting for the double pointer in the userdata.
2025-11-01 21:20:22 +01:00
Alug cae5e73d7d LUA_RawPushUserdata
"Same as LUA_PushUserdata but don't set a metatable yet."
from RR
2025-11-01 21:20:17 +01:00
49 changed files with 646 additions and 722 deletions

No files matched your search

+2 -4
View File
@@ -24,8 +24,6 @@
#include "lauxlib.h" #include "lauxlib.h"
#include "../doomdef.h"
#define FREELIST_REF 0 /* free list of references */ #define FREELIST_REF 0 /* free list of references */
@@ -42,7 +40,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
lua_getinfo(L, "n", &ar); lua_getinfo(L, "n", &ar);
if (fastcmp(ar.namewhat, "method")) { if (strcmp(ar.namewhat, "method") == 0) {
narg--; /* do not count `self' */ narg--; /* do not count `self' */
if (narg == 0) /* error is in the self argument itself? */ if (narg == 0) /* error is in the self argument itself? */
return luaL_error(L, "calling " LUA_QS " on bad self (%s)", return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
@@ -99,7 +97,7 @@ LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
luaL_checkstring(L, narg); luaL_checkstring(L, narg);
int i; int i;
for (i=0; lst[i]; i++) for (i=0; lst[i]; i++)
if (fastcmp(lst[i], name)) if (strcmp(lst[i], name) == 0)
return i; return i;
return luaL_argerror(L, narg, return luaL_argerror(L, narg,
lua_pushfstring(L, "invalid option " LUA_QS, name)); lua_pushfstring(L, "invalid option " LUA_QS, name));
+3 -5
View File
@@ -161,13 +161,12 @@ static int io_tostring (lua_State *L) {
static int StartsWith(const char *a, const char *b) // this is wolfs being lazy yet again static int StartsWith(const char *a, const char *b) // this is wolfs being lazy yet again
{ {
if (strncmp(a, b, strlen(b)) == 0) return 1; if(strncmp(a, b, strlen(b)) == 0) return 1;
return 0; return 0;
} }
static int io_open(lua_State *L) static int io_open (lua_State *L) {
{
FILE **pf; FILE **pf;
const char *filename = luaL_checkstring(L, 1); const char *filename = luaL_checkstring(L, 1);
int pass = 0; int pass = 0;
@@ -179,13 +178,12 @@ static int io_open(lua_State *L)
for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++) for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++)
{ {
if (fasticmp(&filename[length - strlen(whitelist[i])], whitelist[i])) if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
{ {
pass = 1; pass = 1;
break; break;
} }
} }
if (l_unlikely(strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\") if (l_unlikely(strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\")
|| StartsWith(filename, "/") || !pass)) || StartsWith(filename, "/") || !pass))
{ {
+32 -30
View File
@@ -1,7 +1,8 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2 KART
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 2025 by Kart Krew.
// Copyright (C) 1999-2025 by Sonic Team Junior. // Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@@ -24,6 +25,7 @@ extern "C" {
// //
// Little-endian machines // Little-endian machines
// //
#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0)
#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0)
#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0)
@@ -36,25 +38,25 @@ extern "C" {
// what is this? // what is this?
#if defined (__GNUC__) #if defined (__GNUC__)
#define READUINT8(p) ({ UINT8 *p_tmp = (UINT8 *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READUINT8(p) ({ const UINT8 *p_tmp = (const UINT8 *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READSINT8(p) ({ SINT8 *p_tmp = (SINT8 *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READSINT8(p) ({ const SINT8 *p_tmp = (const SINT8 *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READINT16(p) ({ INT16 *p_tmp = (INT16 *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READINT16(p) ({ const INT16 *p_tmp = (const INT16 *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READUINT16(p) ({ UINT16 *p_tmp = (UINT16 *)p; UINT16 b; memcpy(&b, p, sizeof( UINT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READUINT16(p) ({ const UINT16 *p_tmp = (const UINT16 *)p; UINT16 b; memcpy(&b, p, sizeof( UINT16)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READINT32(p) ({ INT32 *p_tmp = (INT32 *)p; INT32 b; memcpy(&b, p, sizeof( INT32)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READINT32(p) ({ const INT32 *p_tmp = (const INT32 *)p; INT32 b; memcpy(&b, p, sizeof( INT32)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READUINT32(p) ({ UINT32 *p_tmp = (UINT32 *)p; UINT32 b; memcpy(&b, p, sizeof( UINT32)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READUINT32(p) ({ const UINT32 *p_tmp = (const UINT32 *)p; UINT32 b; memcpy(&b, p, sizeof( UINT32)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READCHAR(p) ({ char *p_tmp = (char *)p; char b; memcpy(&b, p, sizeof( char)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READCHAR(p) ({ const char *p_tmp = (const char *)p; char b; memcpy(&b, p, sizeof( char)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READFIXED(p) ({ const fixed_t *p_tmp = (const fixed_t *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; }) #define READANGLE(p) ({ const angle_t *p_tmp = (const angle_t *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#else #else
#define READUINT8(p) ((UINT8*)(*(void**)(&(p)) = (void*)&((UINT8*)(p))[1]))[-1] #define READUINT8(p) ((const UINT8*) (*(const void**)(&(p)) = (const void*)&((const UINT8*) (p))[1]))[-1]
#define READSINT8(p) ((SINT8*)(*(void**)(&(p)) = (void*)&((SINT8*)(p))[1]))[-1] #define READSINT8(p) ((const SINT8*) (*(const void**)(&(p)) = (const void*)&((const SINT8*) (p))[1]))[-1]
#define READINT16(p) ((INT16*)(*(void**)(&(p)) = (void*)&((INT16*)(p))[1]))[-1] #define READINT16(p) ((const INT16*) (*(const void**)(&(p)) = (const void*)&((const INT16*) (p))[1]))[-1]
#define READUINT16(p) ((UINT16*)(*(void**)(&(p)) = (void*)&((UINT16*)(p))[1]))[-1] #define READUINT16(p) ((const UINT16*) (*(const void**)(&(p)) = (const void*)&((const UINT16*) (p))[1]))[-1]
#define READINT32(p) ((INT32*)(*(void**)(&(p)) = (void*)&((INT32*)(p))[1]))[-1] #define READINT32(p) ((const INT32*) (*(const void**)(&(p)) = (const void*)&((const INT32*) (p))[1]))[-1]
#define READUINT32(p) ((UINT32*)(*(void**)(&(p)) = (void*)&((UINT32*)(p))[1]))[-1] #define READUINT32(p) ((const UINT32*) (*(const void**)(&(p)) = (const void*)&((const UINT32*) (p))[1]))[-1]
#define READCHAR(p) ((char*)(*(void**)(&(p)) = (void*)&((char*)(p))[1]))[-1] #define READCHAR(p) ((const char*) (*(const void**)(&(p)) = (const void*)&((const char*) (p))[1]))[-1]
#define READFIXED(p) ((fixed_t*)(*(void**)(&(p)) = (void*)&((fixed_t*)(p))[1]))[-1] #define READFIXED(p) ((const fixed_t*)(*(const void**)(&(p)) = (const void*)&((const fixed_t*)(p))[1]))[-1]
#define READANGLE(p) ((angle_t*)(*(void**)(&(p)) = (void*)&((angle_t*)(p))[1]))[-1] #define READANGLE(p) ((const angle_t*)(*(const void**)(&(p)) = (const void*)&((const angle_t*)(p))[1]))[-1]
#endif #endif
#else //SRB2_BIG_ENDIAN #else //SRB2_BIG_ENDIAN
@@ -117,15 +119,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
return (ucp[3] << 24) | (ucp[2] << 16) | (ucp[1] << 8) | ucp[0]; return (ucp[3] << 24) | (ucp[2] << 16) | (ucp[1] << 8) | ucp[0];
} }
#define READUINT8(p) ((UINT8*)(p = (void*)&((UINT8*)p)[1]))[-1] #define READUINT8(p) ((const UINT8*)(p = (const void*)&((const UINT8*)p)[1]))[-1]
#define READSINT8(p) ((SINT8*)(p = (void*)&((SINT8*)p)[1]))[-1] #define READSINT8(p) ((const SINT8*)(p = (const void*)&((const SINT8*)p)[1]))[-1]
#define READINT16(p) readshort(&((INT16*)(p = (void*)&((INT16*)p)[1]))[-1]) #define READINT16(p) readshort(&((const INT16*)(p = (const void*)&((const INT16*)p)[1]))[-1])
#define READUINT16(p) readushort(&((UINT16*)(p = (void*)&((UINT16*)p)[1]))[-1]) #define READUINT16(p) readushort(&((const UINT16*)(p = (const void*)&((const UINT16*)p)[1]))[-1])
#define READINT32(p) readlong(&((INT32*)(p = (void*)&((INT32*)p)[1]))[-1]) #define READINT32(p) readlong(&((const INT32*)(p = (const void*)&((const INT32*)p)[1]))[-1])
#define READUINT32(p) readulong(&((UINT32*)(p = (void*)&((UINT32*)p)[1])) #define READUINT32(p) readulong(&((const UINT32*)(p = (const void*)&((const UINT32*)p)[1]))
#define READCHAR(p) ((char*)(p = (void*)&((char*)p)[1]))[-1] #define READCHAR(p) ((const char*)(p = (const void*)&((const char*)p)[1]))[-1]
#define READFIXED(p) readlong(&((fixed_t*)(p = (void*)&((fixed_t*)p)[1]))[-1]) #define READFIXED(p) readlong(&((const fixed_t*)(p = (const void*)&((const fixed_t*)p)[1]))[-1])
#define READANGLE(p) readulong(&((angle_t*)(p = (void*)&((angle_t*)p)[1]))[-1]) #define READANGLE(p) readulong(&((const angle_t*)(p = (const void*)&((const angle_t*)p)[1]))[-1])
#endif //SRB2_BIG_ENDIAN #endif //SRB2_BIG_ENDIAN
#define WRITESTRINGN(p, s, n) do { \ #define WRITESTRINGN(p, s, n) do { \
+54 -50
View File
@@ -281,7 +281,7 @@ char *com_argv[MAX_ARGS];
static const char *com_null_string = ""; static const char *com_null_string = "";
static char *com_args = NULL; // current command args or NULL static char *com_args = NULL; // current command args or NULL
static void Got_NetVar(UINT8 **p, INT32 playernum); static void Got_NetVar(const UINT8 **p, INT32 playernum);
/** Initializes command buffer and adds basic commands. /** Initializes command buffer and adds basic commands.
*/ */
@@ -359,7 +359,7 @@ size_t COM_CheckParm(const char *check)
size_t i; size_t i;
for (i = 1; i < com_argc; i++) for (i = 1; i < com_argc; i++)
if (fasticmp(check, com_argv[i])) if (!strcasecmp(check, com_argv[i]))
return i; return i;
return 0; return 0;
} }
@@ -456,7 +456,7 @@ void COM_AddCommand(const char *name, com_func_t func)
// fail if the command already exists // fail if the command already exists
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
{ {
if (fasticmp(name, cmd->name)) //case insensitive now that we have lower and uppercase! if (!stricmp(name, cmd->name)) //case insensitive now that we have lower and uppercase!
{ {
// don't I_Error for Lua commands // don't I_Error for Lua commands
// Lua commands can replace game commands, and they have priority. // Lua commands can replace game commands, and they have priority.
@@ -492,7 +492,7 @@ int COM_AddLuaCommand(const char *name)
// command already exists // command already exists
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
{ {
if (fasticmp(name, cmd->name)) //case insensitive now that we have lower and uppercase! if (!stricmp(name, cmd->name)) //case insensitive now that we have lower and uppercase!
{ {
// replace the built in command. // replace the built in command.
cmd->function = COM_Lua_f; cmd->function = COM_Lua_f;
@@ -519,7 +519,7 @@ static boolean COM_Exists(const char *com_name)
xcommand_t *cmd; xcommand_t *cmd;
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
if (fasticmp(com_name, cmd->name)) if (!stricmp(com_name, cmd->name))
return true; return true;
return false; return false;
@@ -571,7 +571,7 @@ static void COM_ExecuteString(char *ptext)
// check functions // check functions
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
{ {
if (fasticmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase!
{ {
cmd->function(); cmd->function();
return; return;
@@ -581,7 +581,7 @@ static void COM_ExecuteString(char *ptext)
// check aliases // check aliases
for (a = com_alias; a; a = a->next) for (a = com_alias; a; a = a->next)
{ {
if (fasticmp(com_argv[0], a->name)) if (!stricmp(com_argv[0], a->name))
{ {
if (recursion > MAX_ALIAS_RECURSION) if (recursion > MAX_ALIAS_RECURSION)
CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n"));
@@ -836,7 +836,7 @@ static void COM_Help_f(void)
if (cvar->PossibleValue) if (cvar->PossibleValue)
{ {
{ {
if (fasticmp(cvar->PossibleValue[0].strvalue, "MIN") && fasticmp(cvar->PossibleValue[1].strvalue, "MAX")) if (!stricmp(cvar->PossibleValue[0].strvalue, "MIN") && !stricmp(cvar->PossibleValue[1].strvalue, "MAX"))
{ {
if (floatmode) if (floatmode)
{ {
@@ -879,7 +879,7 @@ static void COM_Help_f(void)
{ {
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
{ {
if (!fastcmp(cmd->name, help)) if (strcmp(cmd->name, help))
continue; continue;
CONS_Printf("\x82""Command %s:\n", cmd->name); CONS_Printf("\x82""Command %s:\n", cmd->name);
@@ -1176,7 +1176,7 @@ consvar_t *CV_FindVar(const char *name)
consvar_t *cvar; consvar_t *cvar;
for (cvar = consvar_vars; cvar; cvar = cvar->next) for (cvar = consvar_vars; cvar; cvar = cvar->next)
if (fasticmp(name,cvar->name)) if (!stricmp(name,cvar->name))
return cvar; return cvar;
return NULL; return NULL;
@@ -1366,7 +1366,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
v = INT32_MIN; // Invalid integer trigger v = INT32_MIN; // Invalid integer trigger
} }
if (var->PossibleValue[0].strvalue && fasticmp(var->PossibleValue[0].strvalue, "MIN")) // bounded cvar if (var->PossibleValue[0].strvalue && !stricmp(var->PossibleValue[0].strvalue, "MIN")) // bounded cvar
{ {
#define MINVAL 0 #define MINVAL 0
#define MAXVAL 1 #define MAXVAL 1
@@ -1379,21 +1379,21 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
// search for other // search for other
for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++) for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++)
if (v == var->PossibleValue[i].value || fasticmp(var->PossibleValue[i].strvalue, valstr)) if (v == var->PossibleValue[i].value || !stricmp(var->PossibleValue[i].strvalue, valstr))
{ {
var->value = var->PossibleValue[i].value; var->value = var->PossibleValue[i].value;
var->string = var->PossibleValue[i].strvalue; var->string = var->PossibleValue[i].strvalue;
goto finish; goto finish;
} }
if ((v != INT32_MIN && v < var->PossibleValue[MINVAL].value) || fasticmp(valstr, "MIN")) if ((v != INT32_MIN && v < var->PossibleValue[MINVAL].value) || !stricmp(valstr, "MIN"))
{ {
v = var->PossibleValue[MINVAL].value; v = var->PossibleValue[MINVAL].value;
valstr = var->PossibleValue[MINVAL].strvalue; valstr = var->PossibleValue[MINVAL].strvalue;
override = true; override = true;
overrideval = v; overrideval = v;
} }
else if ((v != INT32_MIN && v > var->PossibleValue[MAXVAL].value) || fasticmp(valstr, "MAX")) else if ((v != INT32_MIN && v > var->PossibleValue[MAXVAL].value) || !stricmp(valstr, "MAX"))
{ {
v = var->PossibleValue[MAXVAL].value; v = var->PossibleValue[MAXVAL].value;
valstr = var->PossibleValue[MAXVAL].strvalue; valstr = var->PossibleValue[MAXVAL].strvalue;
@@ -1411,7 +1411,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
// check first strings // check first strings
for (i = 0; var->PossibleValue[i].strvalue; i++) for (i = 0; var->PossibleValue[i].strvalue; i++)
if (fasticmp(var->PossibleValue[i].strvalue, valstr)) if (!stricmp(var->PossibleValue[i].strvalue, valstr))
goto found; goto found;
if (v != INT32_MIN) if (v != INT32_MIN)
{ {
@@ -1424,9 +1424,9 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
if (var->PossibleValue == CV_OnOff || var->PossibleValue == CV_YesNo) if (var->PossibleValue == CV_OnOff || var->PossibleValue == CV_YesNo)
{ {
overrideval = -1; overrideval = -1;
if (fasticmp(valstr, "on") || fasticmp(valstr, "yes")) if (!stricmp(valstr, "on") || !stricmp(valstr, "yes"))
overrideval = 1; overrideval = 1;
else if (fasticmp(valstr, "off") || fasticmp(valstr, "no")) else if (!stricmp(valstr, "off") || !stricmp(valstr, "no"))
overrideval = 0; overrideval = 0;
if (overrideval != -1) if (overrideval != -1)
@@ -1474,7 +1474,7 @@ finish:
var->flags |= CV_MODIFIED; var->flags |= CV_MODIFIED;
// raise 'on change' code // raise 'on change' code
LUA_CVarChanged(var->name); // let consolelib know what cvar this is. LUA_CVarChanged(var); // let consolelib know what cvar this is.
if (var->flags & CV_CALL && !stealth) if (var->flags & CV_CALL && !stealth)
var->func(); var->func();
@@ -1500,11 +1500,11 @@ badinput:
static boolean serverloading = false; static boolean serverloading = false;
static void Got_NetVar(UINT8 **p, INT32 playernum) static void Got_NetVar(const UINT8 **p, INT32 playernum)
{ {
consvar_t *cvar; consvar_t *cvar;
UINT16 netid; UINT16 netid;
char *svalue; const char *svalue;
UINT8 stealth = false; UINT8 stealth = false;
if (playernum != serverplayer && !IsPlayerAdmin(playernum) && !serverloading) if (playernum != serverplayer && !IsPlayerAdmin(playernum) && !serverloading)
@@ -1518,9 +1518,10 @@ static void Got_NetVar(UINT8 **p, INT32 playernum)
} }
return; return;
} }
netid = READUINT16(*p); netid = READUINT16(*p);
cvar = CV_FindNetVar(netid); cvar = CV_FindNetVar(netid);
svalue = (char *)*p; svalue = (const char *)*p;
SKIPSTRING(*p); SKIPSTRING(*p);
stealth = READUINT8(*p); stealth = READUINT8(*p);
@@ -1576,8 +1577,9 @@ void CV_SaveNetVars(UINT8 **p, boolean isdemorecording)
WRITEUINT16(count_p, count); WRITEUINT16(count_p, count);
} }
void CV_LoadNetVars(UINT8 **p) size_t CV_LoadNetVars(const UINT8 *bufstart)
{ {
const UINT8 *p = bufstart;
consvar_t *cvar; consvar_t *cvar;
UINT16 count; UINT16 count;
@@ -1588,11 +1590,13 @@ void CV_LoadNetVars(UINT8 **p)
if (cvar->flags & CV_NETVAR) if (cvar->flags & CV_NETVAR)
Setvalue(cvar, cvar->defaultvalue, true); Setvalue(cvar, cvar->defaultvalue, true);
count = READUINT16(*p); count = READUINT16(p);
while (count--) while (count--)
Got_NetVar(p, 0); Got_NetVar(&p, 0);
serverloading = false; serverloading = false;
return p - bufstart;
} }
static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth); static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth);
@@ -1610,7 +1614,7 @@ void CV_ResetCheatNetVars(void)
// Returns true if the variable's current value is its default value // Returns true if the variable's current value is its default value
boolean CV_IsSetToDefault(consvar_t *v) boolean CV_IsSetToDefault(consvar_t *v)
{ {
return (fastcmp(v->defaultvalue, v->string)); return (!(strcmp(v->defaultvalue, v->string)));
} }
// If any cheats CVars are not at their default settings, return true. // If any cheats CVars are not at their default settings, return true.
@@ -1622,7 +1626,7 @@ UINT8 CV_CheatsEnabled(void)
consvar_t *cvar; consvar_t *cvar;
for (cvar = consvar_vars; cvar; cvar = cvar->next) for (cvar = consvar_vars; cvar; cvar = cvar->next)
if ((cvar->flags & CV_CHEAT) && !fastcmp(cvar->defaultvalue, cvar->string)) if ((cvar->flags & CV_CHEAT) && strcmp(cvar->defaultvalue, cvar->string))
return 1; return 1;
return 0; return 0;
} }
@@ -1643,7 +1647,7 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
if (!var->string) if (!var->string)
I_Error("CV_Set: %s no string set!\n", var->name); I_Error("CV_Set: %s no string set!\n", var->name);
#endif #endif
if (!var || !var->string || !value || fasticmp(var->string, value)) if (!var || !var->string || !value || !stricmp(var->string, value))
return; // no changes return; // no changes
if (var->flags & CV_NETVAR) if (var->flags & CV_NETVAR)
@@ -1665,7 +1669,7 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
if (var == &cv_kartspeed && !M_SecretUnlocked(SECRET_HARDSPEED)) if (var == &cv_kartspeed && !M_SecretUnlocked(SECRET_HARDSPEED))
{ {
if (fasticmp(value, "Hard") || atoi(value) == 2) if (!stricmp(value, "Hard") || atoi(value) == 2)
{ {
CONS_Alert(CONS_NOTICE, "You haven't unlocked this yet!\n"); CONS_Alert(CONS_NOTICE, "You haven't unlocked this yet!\n");
return; return;
@@ -1799,7 +1803,7 @@ void CV_AddValue(consvar_t *var, INT32 increment)
} }
#define MINVAL 0 #define MINVAL 0
#define MAXVAL 1 #define MAXVAL 1
else if (var->PossibleValue[MINVAL].strvalue && fastcmp(var->PossibleValue[MINVAL].strvalue, "MIN")) else if (var->PossibleValue[MINVAL].strvalue && !strcmp(var->PossibleValue[MINVAL].strvalue, "MIN"))
{ // SRB2Kart { // SRB2Kart
#ifdef PARANOIA #ifdef PARANOIA
if (!var->PossibleValue[MAXVAL].strvalue) if (!var->PossibleValue[MAXVAL].strvalue)
@@ -1971,12 +1975,12 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr)
{ {
if (joyaxis_default[i]) if (joyaxis_default[i])
{ {
if (fasticmp(v->name, "joyaxis_fire")) if (!stricmp(v->name, "joyaxis_fire"))
{ {
if (joyaxis_count[i] > 7) return false; if (joyaxis_count[i] > 7) return false;
else if (joyaxis_count[i] == 7) return true; else if (joyaxis_count[i] == 7) return true;
if (fasticmp(valstr, "None")) joyaxis_count[i]++; if (!stricmp(valstr, "None")) joyaxis_count[i]++;
else joyaxis_default[i] = false; else joyaxis_default[i] = false;
} }
// reset all axis settings to defaults // reset all axis settings to defaults
@@ -2008,37 +2012,37 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr)
// Block the Xbox DInput default axes and reset to the current defaults // Block the Xbox DInput default axes and reset to the current defaults
static boolean CV_FilterJoyAxisVars2(consvar_t *v, const char *valstr) static boolean CV_FilterJoyAxisVars2(consvar_t *v, const char *valstr)
{ {
if (fasticmp(v->name, "joyaxis_turn") && fasticmp(valstr, "X-Axis")) if (!stricmp(v->name, "joyaxis_turn") && !stricmp(valstr, "X-Axis"))
return false; return false;
if (fasticmp(v->name, "joyaxis2_turn") && fasticmp(valstr, "X-Axis")) if (!stricmp(v->name, "joyaxis2_turn") && !stricmp(valstr, "X-Axis"))
return false; return false;
if (fasticmp(v->name, "joyaxis3_turn") && fasticmp(valstr, "X-Axis")) if (!stricmp(v->name, "joyaxis3_turn") && !stricmp(valstr, "X-Axis"))
return false; return false;
if (fasticmp(v->name, "joyaxis4_turn") && fasticmp(valstr, "X-Axis")) if (!stricmp(v->name, "joyaxis4_turn") && !stricmp(valstr, "X-Axis"))
return false; return false;
if (fasticmp(v->name, "joyaxis_aim") && fasticmp(valstr, "Y-Axis")) if (!stricmp(v->name, "joyaxis_aim") && !stricmp(valstr, "Y-Axis"))
return false; return false;
if (fasticmp(v->name, "joyaxis2_aim") && fasticmp(valstr, "Y-Axis")) if (!stricmp(v->name, "joyaxis2_aim") && !stricmp(valstr, "Y-Axis"))
return false; return false;
if (fasticmp(v->name, "joyaxis3_aim") && fasticmp(valstr, "Y-Axis")) if (!stricmp(v->name, "joyaxis3_aim") && !stricmp(valstr, "Y-Axis"))
return false; return false;
if (fasticmp(v->name, "joyaxis4_aim") && fasticmp(valstr, "Y-Axis")) if (!stricmp(v->name, "joyaxis4_aim") && !stricmp(valstr, "Y-Axis"))
return false; return false;
if (fasticmp(v->name, "joyaxis_fire") && fasticmp(valstr, "None")) if (!stricmp(v->name, "joyaxis_fire") && !stricmp(valstr, "None"))
return false; return false;
if (fasticmp(v->name, "joyaxis2_fire") && fasticmp(valstr, "None")) if (!stricmp(v->name, "joyaxis2_fire") && !stricmp(valstr, "None"))
return false; return false;
if (fasticmp(v->name, "joyaxis3_fire") && fasticmp(valstr, "None")) if (!stricmp(v->name, "joyaxis3_fire") && !stricmp(valstr, "None"))
return false; return false;
if (fasticmp(v->name, "joyaxis4_fire") && fasticmp(valstr, "None")) if (!stricmp(v->name, "joyaxis4_fire") && !stricmp(valstr, "None"))
return false; return false;
if (fasticmp(v->name, "joyaxis_drift") && fasticmp(valstr, "None")) if (!stricmp(v->name, "joyaxis_drift") && !stricmp(valstr, "None"))
return false; return false;
if (fasticmp(v->name, "joyaxis2_drift") && fasticmp(valstr, "None")) if (!stricmp(v->name, "joyaxis2_drift") && !stricmp(valstr, "None"))
return false; return false;
if (fasticmp(v->name, "joyaxis3_drift") && fasticmp(valstr, "None")) if (!stricmp(v->name, "joyaxis3_drift") && !stricmp(valstr, "None"))
return false; return false;
if (fasticmp(v->name, "joyaxis4_drift") && fasticmp(valstr, "None")) if (!stricmp(v->name, "joyaxis4_drift") && !stricmp(valstr, "None"))
return false; return false;
return true; return true;
@@ -2055,8 +2059,8 @@ static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr)
if (GETMAJOREXECVERSION(cv_execversion.value) < 8) // 8 = 1.4 if (GETMAJOREXECVERSION(cv_execversion.value) < 8) // 8 = 1.4
{ {
if (fasticmp(v->name, "masterserver") // Replaces a hack in MasterServer_OnChange for the original SRB2 MS. if (!stricmp(v->name, "masterserver") // Replaces a hack in MasterServer_OnChange for the original SRB2 MS.
|| fasticmp(v->name, "gamma")) // Too easy to accidentially change in prior versions. || !stricmp(v->name, "gamma")) // Too easy to accidentially change in prior versions.
return false; return false;
} }
@@ -2139,7 +2143,7 @@ void CV_SaveVariables(FILE *f)
char stringtowrite[MAXTEXTCMD+1]; char stringtowrite[MAXTEXTCMD+1];
// Silly hack for Min/Max vars // Silly hack for Min/Max vars
if (fastcmp(cvar->string, "MAX") || fastcmp(cvar->string, "MIN")) if (!strcmp(cvar->string, "MAX") || !strcmp(cvar->string, "MIN"))
{ {
if (cvar->flags & CV_FLOAT) if (cvar->flags & CV_FLOAT)
sprintf(stringtowrite, "%f", FixedToFloat(cvar->value)); sprintf(stringtowrite, "%f", FixedToFloat(cvar->value));
+1 -1
View File
@@ -182,7 +182,7 @@ void CV_SaveVariables(FILE *f);
// load/save gamesate (load and save option and for network join in game) // load/save gamesate (load and save option and for network join in game)
void CV_SaveNetVars(UINT8 **p, boolean isdemorecording); void CV_SaveNetVars(UINT8 **p, boolean isdemorecording);
void CV_LoadNetVars(UINT8 **p); size_t CV_LoadNetVars(const UINT8 *p);
// reset cheat netvars after cheats is deactivated // reset cheat netvars after cheats is deactivated
void CV_ResetCheatNetVars(void); void CV_ResetCheatNetVars(void);
+1 -1
View File
@@ -1010,7 +1010,7 @@ boolean CON_Responder(event_t *ev)
Lock_state(); Lock_state();
// Only add command to history if it differs from previous one // Only add command to history if it differs from previous one
if (!fastcmp(input.buffer, inputlines[(inputline-1) & 31])) if (strcmp(input.buffer, inputlines[(inputline-1) & 31]))
{ {
inputline = (inputline+1) & 31; inputline = (inputline+1) & 31;
M_TextInputInit(&input, inputlines[inputline], CON_MAXPROMPTCHARS); M_TextInputInit(&input, inputlines[inputline], CON_MAXPROMPTCHARS);
+16 -17
View File
@@ -312,9 +312,9 @@ static inline tic_t ExpandTics(INT32 low, tic_t basetic)
// Some extra data function for handle textcmd buffer // Some extra data function for handle textcmd buffer
// ----------------------------------------------------------------- // -----------------------------------------------------------------
static void (*listnetxcmd[MAXNETXCMD])(UINT8 **p, INT32 playernum); static void (*listnetxcmd[MAXNETXCMD])(const UINT8 **p, INT32 playernum);
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)) void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernum))
{ {
#ifdef PARANOIA #ifdef PARANOIA
if (id >= MAXNETXCMD) if (id >= MAXNETXCMD)
@@ -460,12 +460,12 @@ static void ExtraDataTicker(void)
{ {
if (playeringame[i] || i == 0) if (playeringame[i] || i == 0)
{ {
UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i); const UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i);
if (bufferstart) if (bufferstart)
{ {
UINT8 *curpos = bufferstart; const UINT8 *curpos = bufferstart;
UINT8 *bufferend = &curpos[curpos[0]+1]; const UINT8 *bufferend = &curpos[curpos[0]+1];
curpos++; curpos++;
while (curpos < bufferend) while (curpos < bufferend)
@@ -2174,7 +2174,7 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
if (info->subversion != SUBVERSION) if (info->subversion != SUBVERSION)
return; // Close, but no cigar. return; // Close, but no cigar.
if (!fastcmp(info->application, SRB2APPLICATION)) if (strcmp(info->application, SRB2APPLICATION))
return;/* that's a different mod */ return;/* that's a different mod */
i = serverlistcount++; i = serverlistcount++;
@@ -2219,7 +2219,7 @@ void CL_QueryServerList (msg_server_t *server_list)
// thwart nefarious servers who lie to the MS. // thwart nefarious servers who lie to the MS.
/* lol bruh, that version COMES from the servers */ /* lol bruh, that version COMES from the servers */
//if (fastcmp(version, server_list[i].version)) //if (strcmp(version, server_list[i].version) == 0)
{ {
INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port); INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port);
if (node == -1) if (node == -1)
@@ -3215,7 +3215,7 @@ static void Command_connect(void)
server = false; server = false;
if (fasticmp(COM_Argv(1), "self")) if (!stricmp(COM_Argv(1), "self"))
{ {
servernode = 0; servernode = 0;
server = true; server = true;
@@ -3225,7 +3225,7 @@ static void Command_connect(void)
else else
{ {
// used in menu to connect to a server in the list // used in menu to connect to a server in the list
if (netgame && fasticmp(COM_Argv(1), "node")) if (netgame && !stricmp(COM_Argv(1), "node"))
{ {
servernode = (SINT8)atoi(COM_Argv(2)); servernode = (SINT8)atoi(COM_Argv(2));
} }
@@ -3240,7 +3240,7 @@ static void Command_connect(void)
netgame = true; netgame = true;
multiplayer = true; multiplayer = true;
if (fasticmp(COM_Argv(1), "any")) if (!stricmp(COM_Argv(1), "any"))
servernode = BROADCASTADDR; servernode = BROADCASTADDR;
else if (I_NetMakeNodewPort && COM_Argc() >= 3) else if (I_NetMakeNodewPort && COM_Argc() >= 3)
servernode = I_NetMakeNodewPort(COM_Argv(1), COM_Argv(2)); servernode = I_NetMakeNodewPort(COM_Argv(1), COM_Argv(2));
@@ -3264,7 +3264,6 @@ static void Command_connect(void)
splitscreen = cv_splitplayers.value-1; splitscreen = cv_splitplayers.value-1;
SplitScreen_OnChange(); SplitScreen_OnChange();
} }
botingame = false; botingame = false;
botskin = 0; botskin = 0;
CL_ConnectToServer(); CL_ConnectToServer();
@@ -3757,7 +3756,7 @@ static void Command_Kick(void)
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
} }
static void Got_KickCmd(UINT8 **p, INT32 playernum) static void Got_KickCmd(const UINT8 **p, INT32 playernum)
{ {
INT32 pnum, msg; INT32 pnum, msg;
char buf[3 + MAX_REASONLENGTH]; char buf[3 + MAX_REASONLENGTH];
@@ -4147,8 +4146,8 @@ consvar_t cv_connectawaittime = {"connectawaittime", "5", CV_SAVE, connectawaitt
consvar_t cv_serverinfoscreen = {"serverinfoscreen", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_serverinfoscreen = {"serverinfoscreen", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static void Got_AddPlayer(UINT8 **p, INT32 playernum); static void Got_AddPlayer(const UINT8 **p, INT32 playernum);
static void Got_RemovePlayer(UINT8 **p, INT32 playernum); static void Got_RemovePlayer(const UINT8 **p, INT32 playernum);
static void Joinable_OnChange(void) static void Joinable_OnChange(void)
{ {
@@ -4400,7 +4399,7 @@ static inline void SV_AddNode(INT32 node)
} }
// Xcmd XD_ADDPLAYER // Xcmd XD_ADDPLAYER
static void Got_AddPlayer(UINT8 **p, INT32 playernum) static void Got_AddPlayer(const UINT8 **p, INT32 playernum)
{ {
INT16 node, newplayernum; INT16 node, newplayernum;
UINT8 splitscreenplayer = 0; UINT8 splitscreenplayer = 0;
@@ -4487,7 +4486,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
} }
// Xcmd XD_REMOVEPLAYER // Xcmd XD_REMOVEPLAYER
static void Got_RemovePlayer(UINT8 **p, INT32 playernum) static void Got_RemovePlayer(const UINT8 **p, INT32 playernum)
{ {
SINT8 pnum, reason; SINT8 pnum, reason;
@@ -5227,7 +5226,7 @@ static void PT_ServerCFG(SINT8 node)
scp = netbuffer->u.servercfg.varlengthinputs; scp = netbuffer->u.servercfg.varlengthinputs;
CV_LoadPlayerNames(&scp); CV_LoadPlayerNames(&scp);
CV_LoadNetVars(&scp); scp += CV_LoadNetVars(scp);
/// \note Wait. What if a Lua script uses some global custom variables synched with the NetVars hook? /// \note Wait. What if a Lua script uses some global custom variables synched with the NetVars hook?
/// Shouldn't them be downloaded even at intermission time? /// Shouldn't them be downloaded even at intermission time?
+1 -1
View File
@@ -604,7 +604,7 @@ extern consvar_t cv_serverinfoscreen;
void D_ClientServerInit(void); void D_ClientServerInit(void);
// Initialise the other field // Initialise the other field
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)); void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernum));
void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam); void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam);
#define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1 #define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1
void SendKick(UINT8 playernum, UINT8 msg); void SendKick(UINT8 playernum, UINT8 msg);
+9 -12
View File
@@ -1078,19 +1078,19 @@ static INT32 D_DetectFileType(const char* filename)
const size_t len = strlen(filename); const size_t len = strlen(filename);
if (fasticmp(&filename[len - 4], ".wad")) if (!stricmp(&filename[len - 4], ".wad"))
return 2; return 2;
else if (fasticmp(&filename[len - 4], ".pk3")) else if (!stricmp(&filename[len - 4], ".pk3"))
return 3; return 3;
else if (fasticmp(&filename[len - 5], ".kart")) else if (!stricmp(&filename[len - 5], ".kart"))
return 4; return 4;
else if (fasticmp(&filename[len - 4], ".lua")) else if (!stricmp(&filename[len - 4], ".lua"))
return 5; return 5;
else if (fasticmp(&filename[len - 4], ".soc")) else if (!stricmp(&filename[len - 4], ".soc"))
return 6; return 6;
else if (fasticmp(&filename[len - 4], ".cfg")) else if (!stricmp(&filename[len - 4], ".cfg"))
return 7; return 7;
else if (fasticmp(&filename[len - 4], ".txt")) else if (!stricmp(&filename[len - 4], ".txt"))
return 8; return 8;
return 0; return 0;
@@ -1288,7 +1288,7 @@ static void IdentifyVersion(void)
} }
#if (1) // reduce the amount of findfile by only using full cwd in this func #if (1) // reduce the amount of findfile by only using full cwd in this func
if (!fastcmp(tempsrb2path, srb2waddir)) if (strcmp(tempsrb2path, srb2waddir))
#endif #endif
{ {
strlcpy(srb2path, srb2waddir, sizeof (srb2path)); strlcpy(srb2path, srb2waddir, sizeof (srb2path));
@@ -2156,14 +2156,11 @@ void D_SRB2Main(void)
const char *sskill = M_GetNextParm(); const char *sskill = M_GetNextParm();
for (j = 0; kartspeed_cons_t[j].strvalue; j++) for (j = 0; kartspeed_cons_t[j].strvalue; j++)
{ if (!strcasecmp(kartspeed_cons_t[j].strvalue, sskill))
if (fasticmp(kartspeed_cons_t[j].strvalue, sskill))
{ {
newskill = (INT16)kartspeed_cons_t[j].value; newskill = (INT16)kartspeed_cons_t[j].value;
break; break;
} }
}
if (!kartspeed_cons_t[j].strvalue) // reached end of the list with no match if (!kartspeed_cons_t[j].strvalue) // reached end of the list with no match
{ {
j = atoi(sskill); // assume they gave us a skill number, which is okay too j = atoi(sskill); // assume they gave us a skill number, which is okay too
+84 -82
View File
@@ -68,22 +68,22 @@
// protos // protos
// ------ // ------
static void Got_NameAndColor(UINT8 **cp, INT32 playernum); static void Got_NameAndColor(const UINT8 **cp, INT32 playernum);
static void Got_WeaponPref(UINT8 **cp, INT32 playernum); static void Got_WeaponPref(const UINT8 **cp, INT32 playernum);
static void Got_Mapcmd(UINT8 **cp, INT32 playernum); static void Got_Mapcmd(const UINT8 **cp, INT32 playernum);
static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum); static void Got_ExitLevelcmd(const UINT8 **cp, INT32 playernum);
static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum); static void Got_SetupVotecmd(const UINT8 **cp, INT32 playernum);
static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum); static void Got_ModifyVotecmd(const UINT8 **cp, INT32 playernum);
static void Got_PickVotecmd(UINT8 **cp, INT32 playernum); static void Got_PickVotecmd(const UINT8 **cp, INT32 playernum);
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum); static void Got_RequestAddfilecmd(const UINT8 **cp, INT32 playernum);
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum); static void Got_Addfilecmd(const UINT8 **cp, INT32 playernum);
static void Got_Pause(UINT8 **cp, INT32 playernum); static void Got_Pause(const UINT8 **cp, INT32 playernum);
static void Got_Respawn(UINT8 **cp, INT32 playernum); static void Got_Respawn(const UINT8 **cp, INT32 playernum);
static void Got_RandomSeed(UINT8 **cp, INT32 playernum); static void Got_RandomSeed(const UINT8 **cp, INT32 playernum);
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum); static void Got_RunSOCcmd(const UINT8 **cp, INT32 playernum);
static void Got_Teamchange(UINT8 **cp, INT32 playernum); static void Got_Teamchange(const UINT8 **cp, INT32 playernum);
static void Got_Clearscores(UINT8 **cp, INT32 playernum); static void Got_Clearscores(const UINT8 **cp, INT32 playernum);
static void Got_DiscordInfo(UINT8 **cp, INT32 playernum); static void Got_DiscordInfo(const UINT8 **cp, INT32 playernum);
static void PointLimit_OnChange(void); static void PointLimit_OnChange(void);
static void TimeLimit_OnChange(void); static void TimeLimit_OnChange(void);
@@ -178,13 +178,13 @@ static void Command_Clearscores_f(void);
// Remote Administration // Remote Administration
static void Command_Changepassword_f(void); static void Command_Changepassword_f(void);
static void Command_Login_f(void); static void Command_Login_f(void);
static void Got_Login(UINT8 **cp, INT32 playernum); static void Got_Login(const UINT8 **cp, INT32 playernum);
static void Got_Verification(UINT8 **cp, INT32 playernum); static void Got_Verification(const UINT8 **cp, INT32 playernum);
static void Got_Removal(UINT8 **cp, INT32 playernum); static void Got_Removal(const UINT8 **cp, INT32 playernum);
static void Command_Verify_f(void); static void Command_Verify_f(void);
static void Command_RemoveAdmin_f(void); static void Command_RemoveAdmin_f(void);
static void Command_MotD_f(void); static void Command_MotD_f(void);
static void Got_MotD_f(UINT8 **cp, INT32 playernum); static void Got_MotD_f(const UINT8 **cp, INT32 playernum);
static void Command_ShowScores_f(void); static void Command_ShowScores_f(void);
static void Command_ShowTime_f(void); static void Command_ShowTime_f(void);
@@ -1219,7 +1219,7 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
for (ix = 0; ix < MAXPLAYERS; ix++) for (ix = 0; ix < MAXPLAYERS; ix++)
{ {
if (ix != playernum && playeringame[ix] if (ix != playernum && playeringame[ix]
&& fasticmp(name, player_names[ix])) && strcasecmp(name, player_names[ix]) == 0)
{ {
// We shouldn't kick people out just because // We shouldn't kick people out just because
// they joined the game with the same name // they joined the game with the same name
@@ -1336,7 +1336,7 @@ static void CleanupPlayerName(INT32 playernum, const char *newname)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (i != playernum && playeringame[i] if (i != playernum && playeringame[i]
&& fasticmp(tmpname, player_names[i])) && strcasecmp(tmpname, player_names[i]) == 0)
{ {
break; break;
} }
@@ -1386,7 +1386,7 @@ static void SetPlayerName(INT32 playernum, char *newname)
{ {
if (EnsurePlayerNameIsGood(newname, playernum)) if (EnsurePlayerNameIsGood(newname, playernum))
{ {
if (!fasticmp(newname, player_names[playernum])) if (strcasecmp(newname, player_names[playernum]) != 0)
{ {
if (netgame) if (netgame)
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false); HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
@@ -1508,9 +1508,9 @@ static void SendNameAndColor(void)
CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue); CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue);
} }
if (fastcmp(cv_playername.string, player_names[consoleplayer]) if (!strcmp(cv_playername.string, player_names[consoleplayer])
&& cv_playercolor.value == players[consoleplayer].skincolor && cv_playercolor.value == players[consoleplayer].skincolor
&& fastcmp(cv_skin.string, skins[players[consoleplayer].skin].name)) && !strcmp(cv_skin.string, skins[players[consoleplayer].skin].name))
return; return;
// We'll handle it later if we're not playing. // We'll handle it later if we're not playing.
@@ -1913,7 +1913,7 @@ static void SendNameAndColor4(void)
SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf); SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf);
} }
static void Got_NameAndColor(UINT8 **cp, INT32 playernum) static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
{ {
player_t *p = &players[playernum]; player_t *p = &players[playernum];
char name[MAXPLAYERNAME+1]; char name[MAXPLAYERNAME+1];
@@ -1945,7 +1945,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
// set name // set name
if (player_name_changes[playernum] < MAXNAMECHANGES) if (player_name_changes[playernum] < MAXNAMECHANGES)
{ {
if (!fasticmp(player_names[playernum], name)) if (strcasecmp(player_names[playernum], name) != 0)
SetPlayerName(playernum, name); SetPlayerName(playernum, name);
} }
@@ -2041,15 +2041,17 @@ void SendWeaponPref4(void)
SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1); SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1);
} }
static void Got_WeaponPref(UINT8 **cp,INT32 playernum) static void Got_WeaponPref(const UINT8 **cp, INT32 playernum)
{ {
player_t *player = &players[playernum];
UINT8 prefs = READUINT8(*cp); UINT8 prefs = READUINT8(*cp);
players[playernum].pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE); player->pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE);
if (prefs & 1) if (prefs & 1)
players[playernum].pflags |= PF_FLIPCAM; player->pflags |= PF_FLIPCAM;
if (prefs & 2) if (prefs & 2)
players[playernum].pflags |= PF_ANALOGMODE; player->pflags |= PF_ANALOGMODE;
} }
void D_SendPlayerConfig(void) void D_SendPlayerConfig(void)
@@ -2322,8 +2324,8 @@ static void Command_Playdemo_f(void)
CONS_Printf(M_GetText("Playing back demo '%s'.\n"), name); CONS_Printf(M_GetText("Playing back demo '%s'.\n"), name);
demo.loadfiles = fastcmp(COM_Argv(2), "-addfiles"); demo.loadfiles = strcmp(COM_Argv(2), "-addfiles") == 0;
demo.ignorefiles = fastcmp(COM_Argv(2), "-force"); demo.ignorefiles = strcmp(COM_Argv(2), "-force") == 0;
// Internal if no extension, external if one exists // Internal if no extension, external if one exists
// If external, convert the file name to a path in SRB2's home directory // If external, convert the file name to a path in SRB2's home directory
@@ -2848,7 +2850,7 @@ static void Command_Map_f(void)
* ::serverplayer or ::adminplayer. * ::serverplayer or ::adminplayer.
* \sa D_MapChange * \sa D_MapChange
*/ */
static void Got_Mapcmd(UINT8 **cp, INT32 playernum) static void Got_Mapcmd(const UINT8 **cp, INT32 playernum)
{ {
char mapname[MAX_WADPATH+1]; char mapname[MAX_WADPATH+1];
UINT8 flags; UINT8 flags;
@@ -2967,7 +2969,7 @@ static void Command_Pause(void)
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
} }
static void Got_Pause(UINT8 **cp, INT32 playernum) static void Got_Pause(const UINT8 **cp, INT32 playernum)
{ {
UINT8 dedicatedpause = false; UINT8 dedicatedpause = false;
const char *playername; const char *playername;
@@ -3079,7 +3081,7 @@ static void Command_Respawn(void)
SendNetXCmd(XD_RESPAWN, &buf, 4); SendNetXCmd(XD_RESPAWN, &buf, 4);
} }
static void Got_Respawn(UINT8 **cp, INT32 playernum) static void Got_Respawn(const UINT8 **cp, INT32 playernum)
{ {
INT32 respawnplayer = READINT32(*cp); INT32 respawnplayer = READINT32(*cp);
@@ -3114,7 +3116,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum)
* \param playernum Player responsible for the message. Must be ::serverplayer. * \param playernum Player responsible for the message. Must be ::serverplayer.
* \author Graue <graue@oceanbase.org> * \author Graue <graue@oceanbase.org>
*/ */
static void Got_RandomSeed(UINT8 **cp, INT32 playernum) static void Got_RandomSeed(const UINT8 **cp, INT32 playernum)
{ {
UINT32 seed; UINT32 seed;
@@ -3149,7 +3151,7 @@ static void Command_Clearscores_f(void)
* \sa XD_CLEARSCORES, Command_Clearscores_f * \sa XD_CLEARSCORES, Command_Clearscores_f
* \author SSNTails <http://www.ssntails.org> * \author SSNTails <http://www.ssntails.org>
*/ */
static void Got_Clearscores(UINT8 **cp, INT32 playernum) static void Got_Clearscores(const UINT8 **cp, INT32 playernum)
{ {
INT32 i; INT32 i;
@@ -3194,20 +3196,20 @@ static void Command_Teamchange_f(void)
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
if (fasticmp(COM_Argv(1), "red") || fasticmp(COM_Argv(1), "1")) if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (fasticmp(COM_Argv(1), "blue") || fasticmp(COM_Argv(1), "2")) else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0")) else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0")) if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (fasticmp(COM_Argv(1), "playing") || fasticmp(COM_Argv(1), "1")) else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3284,20 +3286,20 @@ static void Command_Teamchange2_f(void)
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
if (fasticmp(COM_Argv(1), "red") || fasticmp(COM_Argv(1), "1")) if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (fasticmp(COM_Argv(1), "blue") || fasticmp(COM_Argv(1), "2")) else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0")) else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0")) if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (fasticmp(COM_Argv(1), "playing") || fasticmp(COM_Argv(1), "1")) else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3375,20 +3377,20 @@ static void Command_Teamchange3_f(void)
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
if (fasticmp(COM_Argv(1), "red") || fasticmp(COM_Argv(1), "1")) if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (fasticmp(COM_Argv(1), "blue") || fasticmp(COM_Argv(1), "2")) else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0")) else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0")) if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (fasticmp(COM_Argv(1), "playing") || fasticmp(COM_Argv(1), "1")) else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3466,20 +3468,20 @@ static void Command_Teamchange4_f(void)
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
if (fasticmp(COM_Argv(1), "red") || fasticmp(COM_Argv(1), "1")) if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (fasticmp(COM_Argv(1), "blue") || fasticmp(COM_Argv(1), "2")) else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0")) else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0")) if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (fasticmp(COM_Argv(1), "playing") || fasticmp(COM_Argv(1), "1")) else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3565,33 +3567,33 @@ static void Command_ServerTeamChange_f(void)
if (G_TagGametype()) if (G_TagGametype())
{ {
if (fasticmp(COM_Argv(2), "it") || fasticmp(COM_Argv(2), "1")) if (!strcasecmp(COM_Argv(2), "it") || !strcasecmp(COM_Argv(2), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (fasticmp(COM_Argv(2), "notit") || fasticmp(COM_Argv(2), "2")) else if (!strcasecmp(COM_Argv(2), "notit") || !strcasecmp(COM_Argv(2), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (fasticmp(COM_Argv(2), "playing") || fasticmp(COM_Argv(2), "3")) else if (!strcasecmp(COM_Argv(2), "playing") || !strcasecmp(COM_Argv(2), "3"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else if (fasticmp(COM_Argv(2), "spectator") || fasticmp(COM_Argv(2), "0")) else if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasTeams()) else if (G_GametypeHasTeams())
{ {
if (fasticmp(COM_Argv(2), "red") || fasticmp(COM_Argv(2), "1")) if (!strcasecmp(COM_Argv(2), "red") || !strcasecmp(COM_Argv(2), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (fasticmp(COM_Argv(2), "blue") || fasticmp(COM_Argv(2), "2")) else if (!strcasecmp(COM_Argv(2), "blue") || !strcasecmp(COM_Argv(2), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (fasticmp(COM_Argv(2), "spectator") || fasticmp(COM_Argv(2), "0")) else if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (fasticmp(COM_Argv(2), "spectator") || fasticmp(COM_Argv(2), "0")) if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (fasticmp(COM_Argv(2), "playing") || fasticmp(COM_Argv(2), "1")) else if (!strcasecmp(COM_Argv(2), "playing") || !strcasecmp(COM_Argv(2), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3666,7 +3668,7 @@ static void Command_ServerTeamChange_f(void)
} }
//todo: This and the other teamchange functions are getting too long and messy. Needs cleaning. //todo: This and the other teamchange functions are getting too long and messy. Needs cleaning.
static void Got_Teamchange(UINT8 **cp, INT32 playernum) static void Got_Teamchange(const UINT8 **cp, INT32 playernum)
{ {
changeteam_union NetPacket; changeteam_union NetPacket;
boolean error = false, wasspectator = false; boolean error = false, wasspectator = false;
@@ -4023,7 +4025,7 @@ static void Command_Login_f(void)
#endif #endif
} }
static void Got_Login(UINT8 **cp, INT32 playernum) static void Got_Login(const UINT8 **cp, INT32 playernum)
{ {
#ifdef NOMD5 #ifdef NOMD5
// If we have no MD5 support then completely disable XD_LOGIN responses for security. // If we have no MD5 support then completely disable XD_LOGIN responses for security.
@@ -4133,7 +4135,7 @@ static void Command_Verify_f(void)
SendNetXCmd(XD_VERIFIED, buf, 1); SendNetXCmd(XD_VERIFIED, buf, 1);
} }
static void Got_Verification(UINT8 **cp, INT32 playernum) static void Got_Verification(const UINT8 **cp, INT32 playernum)
{ {
INT16 num = READUINT8(*cp); INT16 num = READUINT8(*cp);
@@ -4185,7 +4187,7 @@ static void Command_RemoveAdmin_f(void)
SendNetXCmd(XD_DEMOTED, buf, 1); SendNetXCmd(XD_DEMOTED, buf, 1);
} }
static void Got_Removal(UINT8 **cp, INT32 playernum) static void Got_Removal(const UINT8 **cp, INT32 playernum)
{ {
INT16 num = READUINT8(*cp); INT16 num = READUINT8(*cp);
@@ -4261,7 +4263,7 @@ static void Command_MotD_f(void)
Z_Free(mymotd); Z_Free(mymotd);
} }
static void Got_MotD_f(UINT8 **cp, INT32 playernum) static void Got_MotD_f(const UINT8 **cp, INT32 playernum)
{ {
char *mymotd = Z_Malloc(sizeof(motd), PU_STATIC, NULL); char *mymotd = Z_Malloc(sizeof(motd), PU_STATIC, NULL);
INT32 i; INT32 i;
@@ -4328,7 +4330,7 @@ static void Command_RunSOC(void)
SendNetXCmd(XD_RUNSOC, buf, length); SendNetXCmd(XD_RUNSOC, buf, length);
} }
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum) static void Got_RunSOCcmd(const UINT8 **cp, INT32 playernum)
{ {
char filename[256]; char filename[256];
filestatus_t ncs = FS_NOTCHECKED; filestatus_t ncs = FS_NOTCHECKED;
@@ -4606,7 +4608,7 @@ static void Command_GLocalSkin (void)
} }
} }
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) static void Got_RequestAddfilecmd(const UINT8 **cp, INT32 playernum)
{ {
char filename[241]; char filename[241];
filestatus_t ncs = FS_NOTCHECKED; filestatus_t ncs = FS_NOTCHECKED;
@@ -4665,7 +4667,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
COM_BufAddText(va("addfile %s\n", filename)); COM_BufAddText(va("addfile %s\n", filename));
} }
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) static void Got_Addfilecmd(const UINT8 **cp, INT32 playernum)
{ {
char filename[241]; char filename[241];
filestatus_t ncs = FS_NOTCHECKED; filestatus_t ncs = FS_NOTCHECKED;
@@ -5209,14 +5211,14 @@ static void Ringslinger_OnChange(void)
static void Gravity_OnChange(void) static void Gravity_OnChange(void)
{ {
if (!M_SecretUnlocked(SECRET_PANDORA) && !netgame && !cv_debug if (!M_SecretUnlocked(SECRET_PANDORA) && !netgame && !cv_debug
&& !fastcmp(cv_gravity.string, cv_gravity.defaultvalue)) && strcmp(cv_gravity.string, cv_gravity.defaultvalue))
{ {
CONS_Printf(M_GetText("You haven't earned this yet.\n")); CONS_Printf(M_GetText("You haven't earned this yet.\n"));
CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue); CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue);
return; return;
} }
#ifndef NETGAME_GRAVITY #ifndef NETGAME_GRAVITY
if (netgame) if(netgame)
{ {
CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue); CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue);
return; return;
@@ -5465,7 +5467,7 @@ static void Command_ExitLevel_f(void)
SendNetXCmd(XD_EXITLEVEL, NULL, 0); SendNetXCmd(XD_EXITLEVEL, NULL, 0);
} }
static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum) static void Got_ExitLevelcmd(const UINT8 **cp, INT32 playernum)
{ {
(void)cp; (void)cp;
@@ -5486,7 +5488,7 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum)
G_ExitLevel(); G_ExitLevel();
} }
static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum) static void Got_SetupVotecmd(const UINT8 **cp, INT32 playernum)
{ {
INT32 i; INT32 i;
UINT8 gt, secondgt; UINT8 gt, secondgt;
@@ -5538,7 +5540,7 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum)
Y_StartVote(); Y_StartVote();
} }
static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum) static void Got_ModifyVotecmd(const UINT8 **cp, INT32 playernum)
{ {
SINT8 voted = READSINT8(*cp); SINT8 voted = READSINT8(*cp);
UINT8 p = READUINT8(*cp); UINT8 p = READUINT8(*cp);
@@ -5547,7 +5549,7 @@ static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum)
votes[p] = voted; votes[p] = voted;
} }
static void Got_PickVotecmd(UINT8 **cp, INT32 playernum) static void Got_PickVotecmd(const UINT8 **cp, INT32 playernum)
{ {
SINT8 pick = READSINT8(*cp); SINT8 pick = READSINT8(*cp);
SINT8 level = READSINT8(*cp); SINT8 level = READSINT8(*cp);
@@ -6187,7 +6189,7 @@ static void KartEliminateLast_OnChange(void)
P_CheckRacers(); P_CheckRacers();
} }
void Got_DiscordInfo(UINT8 **p, INT32 playernum) void Got_DiscordInfo(const UINT8 **p, INT32 playernum)
{ {
if (playernum != serverplayer /*&& !IsPlayerAdmin(playernum)*/) if (playernum != serverplayer /*&& !IsPlayerAdmin(playernum)*/)
{ {
+16 -17
View File
@@ -550,8 +550,7 @@ INT32 CL_CheckFiles(void)
for (j = mainwads+1; j < numwadfiles; j++) for (j = mainwads+1; j < numwadfiles; j++)
{ {
nameonly(strcpy(wadfilename, wadfiles[j]->filename)); nameonly(strcpy(wadfilename, wadfiles[j]->filename));
if (!stricmp(wadfilename, fileneeded[i].filename) &&
if (fasticmp(wadfilename, fileneeded[i].filename) &&
!memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) !memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16))
{ {
CONS_Debug(DBG_NETPLAY, "already loaded\n"); CONS_Debug(DBG_NETPLAY, "already loaded\n");
@@ -666,7 +665,7 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid)
strlcpy(wadfilename, wadfiles[wadnum]->filename, MAX_WADPATH); strlcpy(wadfilename, wadfiles[wadnum]->filename, MAX_WADPATH);
nameonly(wadfilename); nameonly(wadfilename);
if (fasticmp(wadfilename, p->id.filename)) if (!stricmp(wadfilename, p->id.filename))
{ {
// Copy file name with full path // Copy file name with full path
strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH); strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH);
@@ -947,17 +946,17 @@ void Got_Filetxpak(void)
char *filename = file->filename; char *filename = file->filename;
static INT32 filetime = 0; static INT32 filetime = 0;
if ((fastcmp(filename, "srb2.srb") if (!(strcmp(filename, "srb2.srb")
//|| fastcmp(filename, "srb2.wad") //&& strcmp(filename, "srb2.wad")
//|| fastcmp(filename, "patch.dta") //&& strcmp(filename, "patch.dta")
//|| fastcmp(filename, "music.dta") //&& strcmp(filename, "music.dta")
|| fastcmp(filename, "gfx.kart") && strcmp(filename, "gfx.kart")
|| fastcmp(filename, "textures.kart") && strcmp(filename, "textures.kart")
|| fastcmp(filename, "chars.kart") && strcmp(filename, "chars.kart")
|| fastcmp(filename, "maps.kart") && strcmp(filename, "maps.kart")
|| fastcmp(filename, "sounds.kart") && strcmp(filename, "sounds.kart")
|| fastcmp(filename, "music.kart") && strcmp(filename, "music.kart")
|| fastcmp(filename, "patch.kart") && strcmp(filename, "patch.kart")
)) ))
I_Error("Tried to download \"%s\"", filename); I_Error("Tried to download \"%s\"", filename);
@@ -1198,7 +1197,7 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
} }
// next, check SRB2's "home" directory (if non-'.') // next, check SRB2's "home" directory (if non-'.')
if (!fastcmp(srb2home, ".")) if (strcmp(srb2home, "."))
{ {
homecheck = filesearch(filename, srb2home, wantedmd5sum, completepath, 10); homecheck = filesearch(filename, srb2home, wantedmd5sum, completepath, 10);
@@ -1210,7 +1209,7 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
} }
// next, check SRB2's "path" directory (also if non-'.') // next, check SRB2's "path" directory (also if non-'.')
if (!fastcmp(srb2path, ".")) if (strcmp(srb2path, "."))
{ {
homecheck = filesearch(filename, srb2path, wantedmd5sum, completepath, 10); homecheck = filesearch(filename, srb2path, wantedmd5sum, completepath, 10);
@@ -1555,7 +1554,7 @@ CURLGetLogin (const char *url, HTTP_login ***return_prev_next)
( login = (*prev_next)); ( login = (*prev_next));
prev_next = &login->next prev_next = &login->next
){ ){
if (fastcmp(login->url, url) != 0) if (strcmp(login->url, url) == 0)
{ {
if (return_prev_next) if (return_prev_next)
(*return_prev_next) = prev_next; (*return_prev_next) = prev_next;
+2 -2
View File
@@ -211,12 +211,12 @@ void D_SetupProtocol(void)
if (result) if (result)
{ {
if (!fastcmp(buffer, "no")) if (strcmp(buffer, "no") == 0)
{ {
fclose(fp); fclose(fp);
return; return;
} }
else if (fastcmp(buffer, exe_path)) else if (strcmp(buffer, exe_path) != 0)
{ {
// overwrite // overwrite
fclose(fp); fclose(fp);
+2 -2
View File
@@ -1709,9 +1709,9 @@ char *I_GetUserName(void)
strncpy(username, p, MAXPLAYERNAME); strncpy(username, p, MAXPLAYERNAME);
} }
if (!fastcmp(username, ""))
return username;
if (strcmp(username, "") != 0)
return username;
return NULL; // dummy for platform independent version return NULL; // dummy for platform independent version
} }
+3 -3
View File
@@ -277,7 +277,7 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
while (append != NULL) while (append != NULL)
{ {
// CHECK FOR DUPES!! Ignore any that already exist from the same user. // CHECK FOR DUPES!! Ignore any that already exist from the same user.
if (fastcmp(newRequest->userID, append->userID)) if (!strcmp(newRequest->userID, append->userID))
{ {
Discord_Respond(newRequest->userID, DISCORD_REPLY_IGNORE); Discord_Respond(newRequest->userID, DISCORD_REPLY_IGNORE);
DRPC_RemoveRequest(newRequest); DRPC_RemoveRequest(newRequest);
@@ -419,7 +419,7 @@ static const char *DRPC_GetServerIP(void)
// If you're connected // If you're connected
if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL) if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL)
{ {
if (!fastcmp(address, "self")) if (strcmp(address, "self"))
{ {
// We're not the server, so we could successfully get the IP! // We're not the server, so we could successfully get the IP!
// No need to do anything else :) // No need to do anything else :)
@@ -684,7 +684,7 @@ void DRPC_UpdatePresence(void)
// Character image // Character image
while (supportedSkins[checkSkin] != NULL) while (supportedSkins[checkSkin] != NULL)
{ {
if (fastcmp(skins[players[consoleplayer].skin].name, supportedSkins[checkSkin])) if (!strcmp(skins[players[consoleplayer].skin].name, supportedSkins[checkSkin]))
{ {
snprintf(charimg, 21, "char%s", supportedSkins[checkSkin]); snprintf(charimg, 21, "char%s", supportedSkins[checkSkin]);
discordPresence.smallImageKey = charimg; discordPresence.smallImageKey = charimg;
-2
View File
@@ -69,8 +69,6 @@ extern "C" {
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <ctype.h>
#include "fastcmp.h"
#ifdef _WIN32 #ifdef _WIN32
#include <io.h> #include <io.h>
#endif #endif
+12 -12
View File
@@ -198,7 +198,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
for (; *path != NULL; path++) for (; *path != NULL; path++)
{ {
if (fasticmp(*path, dent->d_name)) if (strcasecmp(*path, dent->d_name) == 0)
{ {
skipfolder = true; skipfolder = true;
break; break;
@@ -212,7 +212,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
} }
} }
if (!fasticmp(".git", dent->d_name) // sanity if you're weird like me if (strcasecmp(".git", dent->d_name) // sanity if you're weird like me
&& (dirhandle[depthleft-1] = opendir(searchpath)) != NULL) && (dirhandle[depthleft-1] = opendir(searchpath)) != NULL)
{ {
// Got read permissions! // Got read permissions!
@@ -227,7 +227,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
// I am a file! // I am a file!
if (!fasticmp(searchname, dent->d_name)) if (strcasecmp(searchname, dent->d_name))
continue; // Not what we're looking for! continue; // Not what we're looking for!
switch (checkfilemd5(searchpath, wantedmd5sum)) switch (checkfilemd5(searchpath, wantedmd5sum))
@@ -353,7 +353,7 @@ void searchfilemenu(char *tempname)
{ {
for (i = first; i < sizedirmenu; i++) for (i = first; i < sizedirmenu; i++)
{ {
if (fastcmp(dirmenu[i]+DIR_STRING, tempname)) if (!strcmp(dirmenu[i]+DIR_STRING, tempname))
{ {
dir_on[menudepthleft] = i; dir_on[menudepthleft] = i;
break; break;
@@ -400,7 +400,7 @@ void searchfilemenu(char *tempname)
{ {
if (filemenucmp(coredirmenu[i]+DIR_STRING, localmenusearch)) if (filemenucmp(coredirmenu[i]+DIR_STRING, localmenusearch))
{ {
if (tempname && fastcmp(coredirmenu[i]+DIR_STRING, tempname)) if (tempname && !strcmp(coredirmenu[i]+DIR_STRING, tempname))
{ {
dir_on[menudepthleft] = sizedirmenu; dir_on[menudepthleft] = sizedirmenu;
Z_Free(tempname); Z_Free(tempname);
@@ -478,14 +478,14 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
if (replayhut) if (replayhut)
{ {
if (!fasticmp(".lmp", dent->d_name+len-5)) if (strcasecmp(".lmp", dent->d_name+len-5))
continue; // Not a replay continue; // Not a replay
} }
else if (!cv_addons_showall.value) else if (!cv_addons_showall.value)
{ {
UINT8 ext; UINT8 ext;
for (ext = 0; ext < NUM_EXT_TABLE; ext++) for (ext = 0; ext < NUM_EXT_TABLE; ext++)
if (fasticmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0])))
break; // extension comparison break; // extension comparison
if (ext == NUM_EXT_TABLE) if (ext == NUM_EXT_TABLE)
@@ -559,7 +559,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
if (replayhut) if (replayhut)
{ {
if (!fasticmp(".lmp", dent->d_name+len-5)) if (strcasecmp(".lmp", dent->d_name+len-5))
continue; // Not a replay continue; // Not a replay
ext = EXT_TXT; // This isn't used anywhere but better safe than sorry for messing with this... ext = EXT_TXT; // This isn't used anywhere but better safe than sorry for messing with this...
@@ -567,7 +567,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
else else
{ {
for (; ext < NUM_EXT_TABLE; ext++) for (; ext < NUM_EXT_TABLE; ext++)
if (fasticmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0])))
break; // extension comparison break; // extension comparison
if (ext == NUM_EXT_TABLE && !cv_addons_showall.value) if (ext == NUM_EXT_TABLE && !cv_addons_showall.value)
@@ -587,7 +587,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
nameonly(filenamebuf[i]); nameonly(filenamebuf[i]);
} }
if (!fastcmp(dent->d_name, filenamebuf[i])) if (strcmp(dent->d_name, filenamebuf[i]))
continue; continue;
if (cv_addons_md5.value && !checkfilemd5(menupath, wadfiles[i]->md5sum)) if (cv_addons_md5.value && !checkfilemd5(menupath, wadfiles[i]->md5sum))
@@ -598,11 +598,11 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
} }
else if (ext == EXT_TXT) else if (ext == EXT_TXT)
{ {
if (!strncmp(dent->d_name, "log-", 4) || fastcmp(dent->d_name, "errorlog.txt")) if (!strncmp(dent->d_name, "log-", 4) || !strcmp(dent->d_name, "errorlog.txt"))
ext |= EXT_LOADED; ext |= EXT_LOADED;
} }
if (fastcmp(dent->d_name, configfile)) if (!strcmp(dent->d_name, configfile))
ext |= EXT_LOADED; ext |= EXT_LOADED;
} }
+12 -12
View File
@@ -264,7 +264,7 @@ void G_ReadDemoExtraData(void)
kartspeed = READUINT8(demobuf.p); kartspeed = READUINT8(demobuf.p);
kartweight = READUINT8(demobuf.p); kartweight = READUINT8(demobuf.p);
if (!fasticmp(skins[players[p].skin].name, name)) if (stricmp(skins[players[p].skin].name, name) != 0)
FindClosestSkinForStats(p, kartspeed, kartweight); FindClosestSkinForStats(p, kartspeed, kartweight);
players[p].kartspeed = kartspeed; players[p].kartspeed = kartspeed;
@@ -277,7 +277,7 @@ void G_ReadDemoExtraData(void)
M_Memcpy(name, demobuf.p, 16); M_Memcpy(name, demobuf.p, 16);
demobuf.p += 16; demobuf.p += 16;
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
if (fasticmp(KartColor_Names[i], name)) // SRB2kart if (!stricmp(KartColor_Names[i], name)) // SRB2kart
{ {
players[p].skincolor = i; players[p].skincolor = i;
if (players[p].mo) if (players[p].mo)
@@ -2289,7 +2289,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
{ {
for (UINT8 j = 0; kartspeed_cons_t[j].strvalue; j++) for (UINT8 j = 0; kartspeed_cons_t[j].strvalue; j++)
{ {
if (fasticmp(kartspeed_cons_t[j].strvalue, svalue)) if (!stricmp(kartspeed_cons_t[j].strvalue, svalue))
pdemo->kartspeed = kartspeed_cons_t[j].value; pdemo->kartspeed = kartspeed_cons_t[j].value;
} }
} }
@@ -2321,7 +2321,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
if (fasticmp(skins[i].name, temp)) if (stricmp(skins[i].name, temp) == 0)
{ {
pdemo->standings[count].skin = i; pdemo->standings[count].skin = i;
break; break;
@@ -2334,7 +2334,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
{ {
if (fasticmp(KartColor_Names[i],temp)) // SRB2kart if (!stricmp(KartColor_Names[i],temp)) // SRB2kart
{ {
pdemo->standings[count].color = i; pdemo->standings[count].color = i;
break; break;
@@ -2807,7 +2807,7 @@ void G_DoPlayDemo(char *defdemoname)
// Set color // Set color
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
{ {
if (fasticmp(KartColor_Names[i],color)) // SRB2kart if (!stricmp(KartColor_Names[i],color)) // SRB2kart
{ {
players[0].skincolor = i; players[0].skincolor = i;
break; break;
@@ -2815,7 +2815,7 @@ void G_DoPlayDemo(char *defdemoname)
} }
// net var data // net var data
CV_LoadNetVars(&demobuf.p); demobuf.p += CV_LoadNetVars(demobuf.p);
// Sigh ... it's an empty demo. // Sigh ... it's an empty demo.
if (*demobuf.p == DEMOMARKER) if (*demobuf.p == DEMOMARKER)
@@ -2853,7 +2853,7 @@ void G_DoPlayDemo(char *defdemoname)
#endif #endif
// net var data // net var data
CV_LoadNetVars(&demobuf.p); demobuf.p += CV_LoadNetVars(demobuf.p);
// Sigh ... it's an empty demo. // Sigh ... it's an empty demo.
if (*demobuf.p == DEMOMARKER) if (*demobuf.p == DEMOMARKER)
@@ -2947,7 +2947,7 @@ void G_DoPlayDemo(char *defdemoname)
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
{ {
if (fasticmp(KartColor_Names[i],color)) // SRB2kart if (!stricmp(KartColor_Names[i],color)) // SRB2kart
{ {
players[p].skincolor = i; players[p].skincolor = i;
break; break;
@@ -2961,7 +2961,7 @@ void G_DoPlayDemo(char *defdemoname)
kartspeed[p] = READUINT8(demobuf.p); kartspeed[p] = READUINT8(demobuf.p);
kartweight[p] = READUINT8(demobuf.p); kartweight[p] = READUINT8(demobuf.p);
if (!fasticmp(skins[players[p].skin].name, skin)) if (stricmp(skins[players[p].skin].name, skin) != 0)
FindClosestSkinForStats(p, kartspeed[p], kartweight[p]); FindClosestSkinForStats(p, kartspeed[p], kartweight[p]);
// Look for the next player // Look for the next player
@@ -3242,7 +3242,7 @@ void G_AddGhost(char *defdemoname)
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
if (fasticmp(skins[i].name, skin)) if (!stricmp(skins[i].name,skin))
{ {
ghskin = &skins[i]; ghskin = &skins[i];
break; break;
@@ -3317,7 +3317,7 @@ void G_AddGhost(char *defdemoname)
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
{ {
if (fasticmp(KartColor_Names[i],color)) // SRB2kart if (!stricmp(KartColor_Names[i],color)) // SRB2kart
{ {
gh->mo->color = (UINT8)i; gh->mo->color = (UINT8)i;
break; break;
+5 -8
View File
@@ -2768,7 +2768,7 @@ INT32 G_GetGametypeByName(const char *gametypestr)
INT32 i; INT32 i;
for (i = 0; i < NUMGAMETYPES; i++) for (i = 0; i < NUMGAMETYPES; i++)
if (fasticmp(gametypestr, Gametype_Names[i])) if (!stricmp(gametypestr, Gametype_Names[i]))
return i; return i;
return -1; // unknown gametype return -1; // unknown gametype
@@ -3463,8 +3463,7 @@ void G_LoadGameData(void)
if (READUINT32(save.p) != 0xFCAFE211) if (READUINT32(save.p) != 0xFCAFE211)
{ {
const char *gdfolder = "the SRB2Kart folder"; const char *gdfolder = "the SRB2Kart folder";
if (strcmp(srb2home,"."))
if (!fastcmp(srb2home,"."))
gdfolder = srb2home; gdfolder = srb2home;
Z_Free(save.buffer); Z_Free(save.buffer);
@@ -3548,8 +3547,7 @@ void G_LoadGameData(void)
datacorrupt: datacorrupt:
{ {
const char *gdfolder = "the SRB2Kart folder"; const char *gdfolder = "the SRB2Kart folder";
if (strcmp(srb2home,"."))
if (!fastcmp(srb2home,"."))
gdfolder = srb2home; gdfolder = srb2home;
Z_Free(save.buffer); Z_Free(save.buffer);
@@ -3760,8 +3758,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride)
memset(vcheck, 0, sizeof (vcheck)); memset(vcheck, 0, sizeof (vcheck));
sprintf(vcheck, "version %d", VERSION); sprintf(vcheck, "version %d", VERSION);
if (strcmp((const char *)save.p, (const char *)vcheck))
if (!fastcmp((const char *)save.p, (const char *)vcheck))
{ {
#ifdef SAVEGAME_OTHERVERSIONS #ifdef SAVEGAME_OTHERVERSIONS
M_StartMessage(M_GetText("Save game from different version.\nYou can load this savegame, but\nsaving afterwards will be disabled.\n\nDo you want to continue anyway?\n\n(Press 'Y' to confirm)\n"), M_StartMessage(M_GetText("Save game from different version.\nYou can load this savegame, but\nsaving afterwards will be disabled.\n\nDo you want to continue anyway?\n\n(Press 'Y' to confirm)\n"),
@@ -4039,7 +4036,7 @@ char *G_BuildMapTitle(INT32 mapnum)
if (!mapheaderinfo[mapnum-1]) if (!mapheaderinfo[mapnum-1])
P_AllocMapHeader(mapnum-1); P_AllocMapHeader(mapnum-1);
if (!fastcmp(mapheaderinfo[mapnum-1]->lvlttl, "")) if (strcmp(mapheaderinfo[mapnum-1]->lvlttl, ""))
{ {
size_t len = 1; size_t len = 1;
const char *zonetext = NULL; const char *zonetext = NULL;
+3 -4
View File
@@ -1033,7 +1033,7 @@ INT32 G_KeyStringtoNum(const char *keystr)
return atoi(&keystr[3]); return atoi(&keystr[3]);
for (j = 0; j < NUMKEYNAMES; j++) for (j = 0; j < NUMKEYNAMES; j++)
if (fasticmp(keynames[j].name, keystr)) if (!stricmp(keynames[j].name, keystr))
return keynames[j].keynum; return keynames[j].keynum;
return 0; return 0;
@@ -1333,15 +1333,14 @@ static void setcontrol(INT32 (*gc)[2])
player = 0; player = 0;
namectrl = COM_Argv(1); namectrl = COM_Argv(1);
for (numctrl = 0; numctrl < num_gamecontrols && !fasticmp(namectrl, gamecontrolname[numctrl]); numctrl++) for (numctrl = 0; numctrl < num_gamecontrols && stricmp(namectrl, gamecontrolname[numctrl]);
numctrl++)
; ;
if (numctrl == num_gamecontrols) if (numctrl == num_gamecontrols)
{ {
CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl); CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl);
return; return;
} }
keynum1 = G_KeyStringtoNum(COM_Argv(2)); keynum1 = G_KeyStringtoNum(COM_Argv(2));
keynum2 = G_KeyStringtoNum(COM_Argv(3)); keynum2 = G_KeyStringtoNum(COM_Argv(3));
keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride); keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride);
+1 -1
View File
@@ -5840,7 +5840,7 @@ static void COM_HWR_glinfo(void)
{ {
argv = COM_Argv(i); argv = COM_Argv(i);
if (fastcmp(argv, "--list-extensions")|| fastcmp(argv, "-l")) if (strcmp(argv, "--list-extensions") == 0 || strcmp(argv, "-l") == 0)
{ {
list_extensions = 1; list_extensions = 1;
} }
+5 -7
View File
@@ -549,7 +549,7 @@ void HWR_InitMD2(void)
{ {
for (i = 0; i < NUMSPRITES; i++) for (i = 0; i < NUMSPRITES; i++)
{ {
if (fasticmp(name, sprnames[i])) if (stricmp(name, sprnames[i]) == 0)
{ {
md2_models[i].scale = scale; md2_models[i].scale = scale;
md2_models[i].offset = offset; md2_models[i].offset = offset;
@@ -561,7 +561,7 @@ void HWR_InitMD2(void)
for (s = 0; s < MAXSKINS; s++) for (s = 0; s < MAXSKINS; s++)
{ {
if (fasticmp(name, skins[s].name)) if (stricmp(name, skins[s].name) == 0)
{ {
md2_playermodels[s].skin = s; md2_playermodels[s].skin = s;
md2_playermodels[s].scale = scale; md2_playermodels[s].scale = scale;
@@ -607,12 +607,11 @@ void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added afte
} }
} }
md2s = (local ? md2_localplayermodels : md2_playermodels); md2s = ( (local) ? md2_localplayermodels : md2_playermodels );
// Check for any MD2s that match the names of player skins! // Check for any MD2s that match the names of player skins!
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{ {
if (fasticmp(name, K_GetSkinArray(local)[skin].name)) if (stricmp(name, K_GetSkinArray(local)[skin].name) == 0)
{ {
md2s[skin].skin = skin; md2s[skin].skin = skin;
md2s[skin].scale = scale; md2s[skin].scale = scale;
@@ -651,7 +650,6 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
if (!f) if (!f)
{ {
f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt"); f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt");
if (!f) if (!f)
{ {
CONS_Printf("%s %s\n", M_GetText("Error while loading mdls.dat:"), strerror(errno)); CONS_Printf("%s %s\n", M_GetText("Error while loading mdls.dat:"), strerror(errno));
@@ -663,7 +661,7 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
// Check for any MD2s that match the names of sprite names! // Check for any MD2s that match the names of sprite names!
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{ {
if (fasticmp(name, sprnames[spritenum])) if (stricmp(name, sprnames[spritenum]) == 0)
{ {
md2_models[spritenum].scale = scale; md2_models[spritenum].scale = scale;
md2_models[spritenum].offset = offset; md2_models[spritenum].offset = offset;
+5 -5
View File
@@ -126,7 +126,7 @@ tag_t *GetTagByName(model_t *model, char *name, int frame)
int i; int i;
for (i = 0; i < model->numTags; i++) for (i = 0; i < model->numTags; i++)
{ {
if (fasticmp(iterator[i].name, name)) if (!stricmp(iterator[i].name, name))
return &iterator[i]; return &iterator[i];
} }
} }
@@ -163,22 +163,22 @@ model_t *LoadModel(const char *filename, int ztag)
return NULL; return NULL;
} }
if (fastcmp(extension, ".md3")) if (!strcmp(extension, ".md3"))
{ {
if (!(model = MD3_LoadModel(filename, ztag, false))) if (!(model = MD3_LoadModel(filename, ztag, false)))
return NULL; return NULL;
} }
else if (fastcmp(extension, ".md3s")) // MD3 that will be converted in memory to use full floats else if (!strcmp(extension, ".md3s")) // MD3 that will be converted in memory to use full floats
{ {
if (!(model = MD3_LoadModel(filename, ztag, true))) if (!(model = MD3_LoadModel(filename, ztag, true)))
return NULL; return NULL;
} }
else if (fastcmp(extension, ".md2")) else if (!strcmp(extension, ".md2"))
{ {
if (!(model = MD2_LoadModel(filename, ztag, false))) if (!(model = MD2_LoadModel(filename, ztag, false)))
return NULL; return NULL;
} }
else if (fastcmp(extension, ".md2s")) else if (!strcmp(extension, ".md2s"))
{ {
if (!(model = MD2_LoadModel(filename, ztag, true))) if (!(model = MD2_LoadModel(filename, ztag, true)))
return NULL; return NULL;
+4 -4
View File
@@ -586,7 +586,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
goto skip_field; goto skip_field;
} }
if (fasticmp(stoken, "GLSL")) if (!stricmp(stoken, "GLSL"))
{ {
value = strtok(NULL, "\r\n "); value = strtok(NULL, "\r\n ");
if (!value) if (!value)
@@ -596,9 +596,9 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
goto skip_lump; goto skip_lump;
} }
if (fasticmp(value, "VERTEX")) if (!stricmp(value, "VERTEX"))
shadertype = 1; shadertype = 1;
else if (fasticmp(value, "FRAGMENT")) else if (!stricmp(value, "FRAGMENT"))
shadertype = 2; shadertype = 2;
skip_lump: skip_lump:
@@ -624,7 +624,7 @@ skip_lump:
for (i = 0; shaderxlat[i].type; i++) for (i = 0; shaderxlat[i].type; i++)
{ {
if (fasticmp(shaderxlat[i].type, stoken)) if (!stricmp(shaderxlat[i].type, stoken))
{ {
size_t shader_string_length; size_t shader_string_length;
char *shader_source; char *shader_source;
+5 -4
View File
@@ -280,7 +280,7 @@ static void Command_Say_f(void);
static void Command_Sayto_f(void); static void Command_Sayto_f(void);
static void Command_Sayteam_f(void); static void Command_Sayteam_f(void);
static void Command_CSay_f(void); static void Command_CSay_f(void);
static void Got_Saycmd(UINT8 **p, INT32 playernum); static void Got_Saycmd(const UINT8 **p, INT32 playernum);
void HU_LoadGraphics(void) void HU_LoadGraphics(void)
{ {
@@ -879,11 +879,12 @@ const char *HU_SkinColorToConsoleColor(skincolors_t color)
* \sa DoSayCommand * \sa DoSayCommand
* \author Graue <graue@oceanbase.org> * \author Graue <graue@oceanbase.org>
*/ */
static void Got_Saycmd(UINT8 **p, INT32 playernum) static void Got_Saycmd(const UINT8 **p, INT32 playernum)
{ {
SINT8 target; SINT8 target;
UINT8 flags; UINT8 flags;
const char *dispname; const char *dispname;
char buf[HU_MAXMSGLEN + 1];
char *msg; char *msg;
boolean action = false; boolean action = false;
char *ptr; char *ptr;
@@ -893,8 +894,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
target = READSINT8(*p); target = READSINT8(*p);
flags = READUINT8(*p); flags = READUINT8(*p);
msg = (char *)*p; msg = buf;
SKIPSTRINGL(*p, HU_MAXMSGLEN + 1); READSTRINGL(*p, msg, HU_MAXMSGLEN + 1);
if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum))) if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum)))
{ {
+1 -4
View File
@@ -637,14 +637,11 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo
UINT8 K_GetKartColorByName(const char *name) UINT8 K_GetKartColorByName(const char *name)
{ {
UINT8 color = (UINT8)atoi(name); UINT8 color = (UINT8)atoi(name);
if (color > 0 && color < MAXSKINCOLORS) if (color > 0 && color < MAXSKINCOLORS)
return color; return color;
for (color = 1; color < MAXSKINCOLORS; color++) for (color = 1; color < MAXSKINCOLORS; color++)
if (fasticmp(KartColor_Names[color], name)) if (!stricmp(KartColor_Names[color], name))
return color; return color;
return 0; return 0;
} }
+62 -57
View File
@@ -28,13 +28,29 @@
#define NOHUD if (hud_running) return luaL_error(L, "HUD rendering code should not call this function!"); #define NOHUD if (hud_running) return luaL_error(L, "HUD rendering code should not call this function!");
static const char *cvname = NULL; static consvar_t *this_cvar;
void Got_Luacmd(UINT8 **cp, INT32 playernum) static void clear_lua_stack(void)
{
if (gL) // check if Lua is actually turned on first, you dummmy -- Monster Iestyn 04/07/18
lua_settop(gL, 0); // clear stack
}
void Got_Luacmd(const UINT8 **cp, INT32 playernum)
{ {
UINT8 i, argc, flags; UINT8 i, argc, flags;
const char *argv[256];
char buf[256]; char buf[256];
argc = READUINT8(*cp);
argv[0] = (const char*)*cp;
SKIPSTRINGN(*cp, 255);
for (i = 1; i < argc; i++)
{
argv[i] = (const char*)*cp;
SKIPSTRINGN(*cp, 255);
}
// don't use I_Assert here, goto the deny code below // don't use I_Assert here, goto the deny code below
// to clean up and kick people who try nefarious exploits // to clean up and kick people who try nefarious exploits
// like sending random junk lua commands to crash the server // like sending random junk lua commands to crash the server
@@ -47,8 +63,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command
if (!lua_istable(gL, -1)) goto deny; if (!lua_istable(gL, -1)) goto deny;
argc = READUINT8(*cp); strlcpy(buf, argv[0], 255);
READSTRINGN(*cp, buf, 255);
strlwr(buf); // must lowercase buffer strlwr(buf); // must lowercase buffer
lua_getfield(gL, -1, buf); // push command info table lua_getfield(gL, -1, buf); // push command info table
if (!lua_istable(gL, -1)) goto deny; if (!lua_istable(gL, -1)) goto deny;
@@ -74,10 +89,17 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
lua_remove(gL, -2); // pop command info table lua_remove(gL, -2); // pop command info table
if (!lua_checkstack(gL, argc)) // player + command arguments
{
clear_lua_stack();
CONS_Alert(CONS_WARNING, "lua command stack overflow from %s (%d, need %d more)\n", player_names[playernum], lua_gettop(gL), argc);
return;
}
LUA_PushUserdata(gL, &players[playernum], META_PLAYER); LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
READSTRINGN(*cp, buf, 255); strlcpy(buf, argv[i], 255);
lua_pushstring(gL, buf); lua_pushstring(gL, buf);
} }
LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too. LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too.
@@ -88,8 +110,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
deny: deny:
//must be hacked/buggy client //must be hacked/buggy client
if (gL) // check if Lua is actually turned on first, you dummmy -- Monster Iestyn 04/07/18 clear_lua_stack();
lua_settop(gL, 0); // clear stack
CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]);
if (server) if (server)
@@ -133,7 +154,7 @@ void COM_Lua_f(void)
{ {
if (!splitscreen) if (!splitscreen)
{ {
lua_pop(gL, 1); // pop command info table lua_pop(gL, 2); // pop command info table and LUA_GetErrorMessage
return; // can't execute splitscreen command without player 2! return; // can't execute splitscreen command without player 2!
} }
@@ -178,6 +199,13 @@ void COM_Lua_f(void)
I_Assert(lua_isfunction(gL, -1)); I_Assert(lua_isfunction(gL, -1));
lua_remove(gL, -2); // pop command info table lua_remove(gL, -2); // pop command info table
if (!lua_checkstack(gL, COM_Argc() + 1))
{
CONS_Alert(CONS_WARNING, "lua command stack overflow (%d, need %s more)\n", lua_gettop(gL), sizeu1(COM_Argc() + 1));
lua_pop(gL, 2); // pop function and LUA_GetErrorMessage
return;
}
LUA_PushUserdata(gL, &players[playernum], META_PLAYER); LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
for (i = 1; i < COM_Argc(); i++) for (i = 1; i < COM_Argc(); i++)
lua_pushstring(gL, COM_Argv(i)); lua_pushstring(gL, COM_Argv(i));
@@ -284,16 +312,13 @@ static int lib_comBufInsertText(lua_State *L)
return 0; return 0;
} }
void LUA_CVarChanged(const char *name) void LUA_CVarChanged(void *cvar)
{ {
cvname = name; this_cvar = cvar;
} }
static void Lua_OnChange(void) static void Lua_OnChange(void)
{ {
I_Assert(gL != NULL);
I_Assert(cvname != NULL);
/// \todo Network this! XD_LUAVAR /// \todo Network this! XD_LUAVAR
// Why?.. // Why?..
@@ -305,13 +330,10 @@ static void Lua_OnChange(void)
// From CV_OnChange registry field, get the function for this cvar by name. // From CV_OnChange registry field, get the function for this cvar by name.
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange"); lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange");
I_Assert(lua_istable(gL, -1)); I_Assert(lua_istable(gL, -1));
lua_getfield(gL, -1, cvname); // get function lua_pushlightuserdata(gL, this_cvar);
lua_rawget(gL, -2); // get function
// From the CV_Vars registry field, get the cvar's userdata by name. LUA_RawPushUserdata(gL, this_cvar);
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_Vars");
I_Assert(lua_istable(gL, -1));
lua_getfield(gL, -1, cvname); // get consvar_t* userdata.
lua_remove(gL, -2); // pop the CV_Vars table.
LUA_Call(gL, 1, 0, error_handler_i); // call function(cvar) LUA_Call(gL, 1, 0, error_handler_i); // call function(cvar)
lua_pop(gL, 2); // pop CV_OnChange table and error handler lua_pop(gL, 2); // pop CV_OnChange table and error handler
@@ -329,9 +351,8 @@ static int lib_cvRegisterVar(lua_State *L)
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
lua_settop(L, 1); // Clear out all other possible arguments, leaving only the first one. lua_settop(L, 1); // Clear out all other possible arguments, leaving only the first one.
NOHUD NOHUD
cvar = lua_newuserdata(L, sizeof(consvar_t)); cvar = ZZ_Calloc(sizeof(consvar_t));
luaL_getmetatable(L, META_CVAR); LUA_PushUserdata(L, cvar, META_CVAR);
lua_setmetatable(L, -2);
#define FIELDERROR(f, e) luaL_error(L, "bad value for " LUA_QL(f) " in table passed to " LUA_QL("CV_RegisterVar") " (%s)", e); #define FIELDERROR(f, e) luaL_error(L, "bad value for " LUA_QL(f) " in table passed to " LUA_QL("CV_RegisterVar") " (%s)", e);
#define TYPEERROR(f, t) FIELDERROR(f, va("%s expected, got %s", lua_typename(L, t), luaL_typename(L, -1))) #define TYPEERROR(f, t) FIELDERROR(f, va("%s expected, got %s", lua_typename(L, t), luaL_typename(L, -1)))
@@ -384,7 +405,7 @@ static int lib_cvRegisterVar(lua_State *L)
lua_getfield(L, LUA_REGISTRYINDEX, "CV_PossibleValue"); lua_getfield(L, LUA_REGISTRYINDEX, "CV_PossibleValue");
I_Assert(lua_istable(L, 5)); I_Assert(lua_istable(L, 5));
lua_pushvalue(L, 2); // cvar userdata lua_pushlightuserdata(L, cvar);
cvpv = lua_newuserdata(L, sizeof(CV_PossibleValue_t) * (count+1)); cvpv = lua_newuserdata(L, sizeof(CV_PossibleValue_t) * (count+1));
lua_rawset(L, 5); lua_rawset(L, 5);
lua_pop(L, 1); // pop CV_PossibleValue registry table lua_pop(L, 1); // pop CV_PossibleValue registry table
@@ -412,13 +433,14 @@ static int lib_cvRegisterVar(lua_State *L)
TYPEERROR("func", LUA_TFUNCTION) TYPEERROR("func", LUA_TFUNCTION)
lua_getfield(L, LUA_REGISTRYINDEX, "CV_OnChange"); lua_getfield(L, LUA_REGISTRYINDEX, "CV_OnChange");
I_Assert(lua_istable(L, 5)); I_Assert(lua_istable(L, 5));
lua_pushlightuserdata(L, cvar);
lua_pushvalue(L, 4); lua_pushvalue(L, 4);
lua_setfield(L, 5, cvar->name); lua_rawset(L, 5);
lua_pop(L, 1); lua_pop(L, 1);
cvar->func = Lua_OnChange; cvar->func = Lua_OnChange;
} }
else if (((i == 5 && !(cvar->flags & CV_CALL)) else if (((i == 5 && !(cvar->flags & CV_CALL))
|| (cvar->flags & CV_CALL && i == 6)) || (cvar->flags & CV_CALL && i == 6))
|| (k && fasticmp(k, "category"))) || (k && fasticmp(k, "category")))
{ {
category = lua_isnoneornil(L, 4) ? NULL : lua_tostring(L, 4); category = lua_isnoneornil(L, 4) ? NULL : lua_tostring(L, 4);
@@ -434,18 +456,12 @@ static int lib_cvRegisterVar(lua_State *L)
#undef FIELDERROR #undef FIELDERROR
#undef TYPEERROR #undef TYPEERROR
// stack: cvar table, cvar userdata if (!cvar->name)
lua_getfield(L, LUA_REGISTRYINDEX, "CV_Vars"); return luaL_error(L, M_GetText("Variable has no name!\n"));
I_Assert(lua_istable(L, 3)); if ((cvar->flags & CV_NOINIT) && !(cvar->flags & CV_CALL))
return luaL_error(L, M_GetText("Variable %s has CV_NOINIT without CV_CALL\n"), cvar->name);
lua_getfield(L, 3, cvar->name); if ((cvar->flags & CV_CALL) && !cvar->func)
if (lua_type(L, -1) != LUA_TNIL) return luaL_error(L, M_GetText("Variable %s has CV_CALL without a function\n"), cvar->name);
return luaL_error(L, M_GetText("Variable %s is already defined\n"), cvar->name);
lua_pop(L, 1);
lua_pushvalue(L, 2);
lua_setfield(L, 3, cvar->name);
lua_pop(L, 1);
// actually time to register it to the console now! Finally! // actually time to register it to the console now! Finally!
cvar->flags |= CV_MODIFIED; cvar->flags |= CV_MODIFIED;
@@ -453,7 +469,7 @@ static int lib_cvRegisterVar(lua_State *L)
if (cvar->flags & CV_MODIFIED) if (cvar->flags & CV_MODIFIED)
return luaL_error(L, "failed to register cvar (probable conflict with internal variable/command names)"); return luaL_error(L, "failed to register cvar (probable conflict with internal variable/command names)");
if (!(((cvar->flags & CV_HIDEN)) || (cvar->flags & CV_NOSHOWHELP)) && (cvar->PossibleValue || !(cvar->value == 0 && !fasticmp(cvar->string, "0")))) if (!(((cvar->flags & CV_HIDEN)) || (cvar->flags & CV_NOSHOWHELP)) && (cvar->PossibleValue || !(cvar->value == 0 && stricmp(cvar->string, "0"))))
{ {
if (!category) if (!category)
{ {
@@ -477,22 +493,9 @@ static int lib_cvRegisterVar(lua_State *L)
static int lib_cvFindVar(lua_State *L) static int lib_cvFindVar(lua_State *L)
{ {
consvar_t *cv; const char *name = luaL_checkstring(L, 1);
if (( cv = CV_FindVar(luaL_checkstring(L,1)) )) LUA_PushUserdata(L, CV_FindVar(name), META_CVAR);
{ return 1;
lua_settop(L,1);/* We only want one argument in the stack. */
lua_pushlightuserdata(L, cv);/* Now the second value on stack. */
luaL_getmetatable(L, META_CVAR);
/*
The metatable is the last value on the stack, so this
applies it to the second value, which is the cvar.
*/
lua_setmetatable(L,2);
lua_pushvalue(L,2);
return 1;
}
else
return 0;
} }
static int CVarSetFunction static int CVarSetFunction
@@ -501,7 +504,7 @@ static int CVarSetFunction
void (*Set)(consvar_t *, const char *), void (*Set)(consvar_t *, const char *),
void (*SetValue)(consvar_t *, INT32) void (*SetValue)(consvar_t *, INT32)
){ ){
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR);
switch (lua_type(L, 2)) switch (lua_type(L, 2))
{ {
@@ -530,7 +533,8 @@ static int lib_cvStealthSet(lua_State *L)
static int lib_cvAddValue(lua_State *L) static int lib_cvAddValue(lua_State *L)
{ {
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR);
CV_AddValue(cvar, (INT32)luaL_checknumber(L, 2)); CV_AddValue(cvar, (INT32)luaL_checknumber(L, 2));
return 0; return 0;
} }
@@ -545,6 +549,7 @@ static int lib_consPrintf(lua_State *L)
if (n < 2) if (n < 2)
return luaL_error(L, "CONS_Printf requires at least two arguments: player and text."); return luaL_error(L, "CONS_Printf requires at least two arguments: player and text.");
//HUDSAFE //HUDSAFE
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!plr) if (!plr)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
@@ -605,7 +610,7 @@ static int cvar_fields_ref = LUA_NOREF;
static int cvar_get(lua_State *L) static int cvar_get(lua_State *L)
{ {
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR);
enum cvar_e field = Lua_optoption(L, 2, -1, cvar_fields_ref); enum cvar_e field = Lua_optoption(L, 2, -1, cvar_fields_ref);
switch (field) switch (field)
+3 -3
View File
@@ -83,7 +83,7 @@ FUNCINLINE static ATTRINLINE unsigned hook_in_list
for (type = 0; list[type] != NULL; ++type) for (type = 0; list[type] != NULL; ++type)
{ {
if (fastcmp(name, list[type])) if (strcmp(name, list[type]) == 0)
break; break;
} }
@@ -240,7 +240,7 @@ static int lib_addHook(lua_State *L)
{ {
add_hook(&hookIds[type]); add_hook(&hookIds[type]);
} }
/*else if (fastcmp(name, "HUD")) // ehh this is cool and all, but i dont want modders potentially breaking vanilla clients lol /*else if (strcmp(name, "HUD") == 0) // ehh this is cool and all, but i dont want modders potentially breaking vanilla clients lol
{ {
add_hud_hook(L, 3); add_hud_hook(L, 3);
}*/ }*/
@@ -818,7 +818,7 @@ typedef struct {
FUNCINLINE static ATTRINLINE boolean checkbotkey(const char *field) FUNCINLINE static ATTRINLINE boolean checkbotkey(const char *field)
{ {
return lua_toboolean(gL, -1) && fastcmp(lua_tostring(gL, -2), field); return lua_toboolean(gL, -1) && strcmp(lua_tostring(gL, -2), field) == 0;
} }
static void res_botai(Hook_State *hook) static void res_botai(Hook_State *hook)
+3 -3
View File
@@ -455,12 +455,12 @@ int mobj_localskin_setter(lua_State *L)
strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin); strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin);
strlwr(skin); // all skin names are lowercase strlwr(skin); // all skin names are lowercase
if (!fasticmp(skin, "none")) if (stricmp(skin, "none"))
{ {
// Try localskins // Try localskins
for (i = 0; i < numlocalskins; i++) for (i = 0; i < numlocalskins; i++)
{ {
if (fasticmp(localskins[i].name, skin)) if (stricmp(localskins[i].name, skin) == 0)
{ {
mo->localskin = &localskins[i]; mo->localskin = &localskins[i];
mo->skinlocal = true; mo->skinlocal = true;
@@ -471,7 +471,7 @@ int mobj_localskin_setter(lua_State *L)
// Try other skins // Try other skins
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
if (fasticmp(skins[i].name, skin)) if (stricmp(skins[i].name, skin) == 0)
{ {
mo->localskin = &skins[i]; mo->localskin = &skins[i];
mo->skinlocal = false; mo->skinlocal = false;
+22 -3
View File
@@ -492,25 +492,37 @@ void LUA_InvalidateMathlibCache(const char *name)
// Pushes it to the stack and stores it in the registry. // Pushes it to the stack and stores it in the registry.
void LUA_PushUserdata(lua_State *L, void *data, const char *meta) void LUA_PushUserdata(lua_State *L, void *data, const char *meta)
{ {
if (LUA_RawPushUserdata(L, data) == LPUSHED_NEW)
{
luaL_getmetatable(L, meta);
lua_setmetatable(L, -2);
}
}
// Same as LUA_PushUserdata but don't set a metatable yet.
lpushed_t LUA_RawPushUserdata(lua_State *L, void *data)
{
lpushed_t status = LPUSHED_NIL;
void **userdata; void **userdata;
if (!data) { // push a NULL if (!data) { // push a NULL
lua_pushnil(L); lua_pushnil(L);
return; return status;
} }
lua_getfield(L, LUA_REGISTRYINDEX, LREG_VALID); lua_getfield(L, LUA_REGISTRYINDEX, LREG_VALID);
I_Assert(lua_istable(L, -1)); I_Assert(lua_istable(L, -1));
lua_pushlightuserdata(L, data); lua_pushlightuserdata(L, data);
lua_rawget(L, -2); lua_rawget(L, -2);
if (lua_isnil(L, -1)) { // no userdata? deary me, we'll have to make one. if (lua_isnil(L, -1)) { // no userdata? deary me, we'll have to make one.
lua_pop(L, 1); // pop the nil lua_pop(L, 1); // pop the nil
// create the userdata // create the userdata
userdata = lua_newuserdata(L, sizeof(void *)); userdata = lua_newuserdata(L, sizeof(void *));
*userdata = data; *userdata = data;
luaL_getmetatable(L, meta);
lua_setmetatable(L, -2);
// Set it in the registry so we can find it again // Set it in the registry so we can find it again
lua_pushlightuserdata(L, data); // k (store the userdata via the data's pointer) lua_pushlightuserdata(L, data); // k (store the userdata via the data's pointer)
@@ -518,8 +530,15 @@ void LUA_PushUserdata(lua_State *L, void *data, const char *meta)
lua_rawset(L, -4); lua_rawset(L, -4);
// stack is left with the userdata on top, as if getting it had originally succeeded. // stack is left with the userdata on top, as if getting it had originally succeeded.
status = LPUSHED_NEW;
} }
else
status = LPUSHED_EXISTING;
lua_remove(L, -2); // remove LREG_VALID lua_remove(L, -2); // remove LREG_VALID
return status;
} }
// When userdata is freed, use this function to remove it from Lua. // When userdata is freed, use this function to remove it from Lua.
+10 -2
View File
@@ -59,7 +59,15 @@ fixed_t LUA_GetConstant(const char *word);
// Need better name for this ;-; // Need better name for this ;-;
void LUA_InvalidateMathlibCache(const char *name); void LUA_InvalidateMathlibCache(const char *name);
typedef enum {
LPUSHED_NIL,
LPUSHED_NEW,
LPUSHED_EXISTING,
} lpushed_t;
void LUA_PushUserdata(lua_State *L, void *data, const char *meta); void LUA_PushUserdata(lua_State *L, void *data, const char *meta);
lpushed_t LUA_RawPushUserdata(lua_State *L, void *data);
void LUA_InvalidateUserdata(void *data); void LUA_InvalidateUserdata(void *data);
void LUA_InvalidateLevel(void); void LUA_InvalidateLevel(void);
void LUA_InvalidateMapthings(void); void LUA_InvalidateMapthings(void);
@@ -68,8 +76,8 @@ void LUA_InvalidatePlayer(player_t *player);
void LUA_Archive(savebuffer_t *save, boolean network); void LUA_Archive(savebuffer_t *save, boolean network);
void LUA_UnArchive(savebuffer_t *save, boolean network); void LUA_UnArchive(savebuffer_t *save, boolean network);
void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c void Got_Luacmd(const UINT8 **cp, INT32 playernum); // lua_consolelib.c
void LUA_CVarChanged(const char *name); // lua_consolelib.c void LUA_CVarChanged(void *cvar); // lua_consolelib.c
int Lua_optoption(lua_State *L, int narg, int def, int list_ref); int Lua_optoption(lua_State *L, int narg, int def, int list_ref);
int Lua_CreateFieldTable(lua_State *L, const char *const lst[]); int Lua_CreateFieldTable(lua_State *L, const char *const lst[]);
void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save); void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save);
+2 -2
View File
@@ -183,7 +183,7 @@ static aatree_node_t *M_AATreeSetString_Node(aatree_node_t *node, UINT32 flags,
else else
{ {
aatree_entry_t *entry = node->value; aatree_entry_t *entry = node->value;
if (entry != NULL && !fastcmp(entry->key, key)) if (entry != NULL && strcmp(entry->key, key) != 0)
entry = entry->next; entry = entry->next;
if (entry != NULL) if (entry != NULL)
{ {
@@ -252,7 +252,7 @@ void *M_AATreeGetString(aatree_t *aatree, const char *key)
I_Assert((aatree->flags & AATREE_STRING) == AATREE_STRING); I_Assert((aatree->flags & AATREE_STRING) == AATREE_STRING);
UINT32 hash = FNV1a_HashString(key); UINT32 hash = FNV1a_HashString(key);
aatree_entry_t *entry = M_AATreeGet_Node(aatree->root, hash); aatree_entry_t *entry = M_AATreeGet_Node(aatree->root, hash);
while (entry != NULL && !fastcmp(entry->key, key)) while (entry != NULL && strcmp(entry->key, key) != 0)
entry = entry->next; entry = entry->next;
return entry != NULL ? entry->value : NULL; return entry != NULL ? entry->value : NULL;
} }
+1 -1
View File
@@ -49,7 +49,7 @@ INT32 M_CheckParm(const char *check)
for (i = 1; i < myargc; i++) for (i = 1; i < myargc; i++)
{ {
if (fasticmp(check, myargv[i])) if (!strcasecmp(check, myargv[i]))
{ {
found = i; found = i;
return i; return i;
+2 -2
View File
@@ -112,7 +112,7 @@ void M_LoadEmotes(UINT16 wadnum)
trim(field); trim(field);
trim(value); trim(value);
if (fasticmp(field.c_str(), "frames")) if (stricmp(field.c_str(), "frames") == 0)
{ {
UINT8 numframes = 0; UINT8 numframes = 0;
@@ -158,7 +158,7 @@ void M_LoadEmotes(UINT16 wadnum)
emote->numframes = numframes; emote->numframes = numframes;
} }
else if (fasticmp(field.c_str(), "timeperframe")) else if (stricmp(field.c_str(), "timeperframe") == 0)
{ {
emote->timeperframe = std::stoi(value); emote->timeperframe = std::stoi(value);
+7 -7
View File
@@ -3719,10 +3719,10 @@ static void M_HandleAddons(INT32 choice)
break; break;
case EXT_TXT: case EXT_TXT:
case EXT_CFG: case EXT_CFG:
if (fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, CONFIGFILENAME) if ((strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, CONFIGFILENAME) == 0)
|| fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, AUTOLOADCONFIGFILENAME) || (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, AUTOLOADCONFIGFILENAME) == 0)
|| fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartserv.cfg") || (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartserv.cfg") == 0)
|| fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartexec.cfg")) || (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartexec.cfg") == 0))
{ {
M_StartMessage(va("%c%s\x80\nYou can't autoload this builds' base console scripts, silly!\n They're already autoloaded on startup! \n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); M_StartMessage(va("%c%s\x80\nYou can't autoload this builds' base console scripts, silly!\n They're already autoloaded on startup! \n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING);
S_StartSound(NULL, sfx_s26d); S_StartSound(NULL, sfx_s26d);
@@ -3830,7 +3830,7 @@ static void ReplayNamesLoadThread(void* userdata)
Lock_search_state(); Lock_search_state();
if (fastcmp(menupath, replaydirpath)) if (strcmp(menupath, replaydirpath) == 0)
{ {
memcpy(demolist_all, demolist_all_local, sizeof(menudemo_t)*sizedirmenu); memcpy(demolist_all, demolist_all_local, sizeof(menudemo_t)*sizedirmenu);
replaynamesloaded = true; replaynamesloaded = true;
@@ -8808,7 +8808,7 @@ static boolean M_QuitMultiPlayerMenu(void)
size_t l; size_t l;
// send name if changed // send name if changed
if (!fastcmp(setupm_name, setupm_cvname->string)) if (strcmp(setupm_name, setupm_cvname->string))
{ {
// remove trailing whitespaces // remove trailing whitespaces
for (l= strlen(setupm_name)-1; for (l= strlen(setupm_name)-1;
@@ -9469,7 +9469,7 @@ static void M_VideoModeMenu(INT32 choice)
// VESA mode, which is always a higher modenum // VESA mode, which is always a higher modenum
for (j = 0; j < vidm_nummodes; j++) for (j = 0; j < vidm_nummodes; j++)
{ {
if (fastcmp(modedescs[j].desc, desc)) if (!strcmp(modedescs[j].desc, desc))
{ {
// mode(0): 320x200 is always standard VGA, not vesa // mode(0): 320x200 is always standard VGA, not vesa
if (modedescs[j].modenum) if (modedescs[j].modenum)
+1 -1
View File
@@ -423,7 +423,7 @@ void Command_SaveConfig_f(void)
FIL_ForceExtension(tmpstr, ".cfg"); FIL_ForceExtension(tmpstr, ".cfg");
M_SaveConfig(tmpstr); M_SaveConfig(tmpstr);
if (!fasticmp(COM_Argv(2), "-silent")) if (stricmp(COM_Argv(2), "-silent"))
CONS_Printf(M_GetText("config saved as %s\n"), configfile); CONS_Printf(M_GetText("config saved as %s\n"), configfile);
} }
+1 -1
View File
@@ -916,7 +916,7 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook)
int len = (int)strlen(str); int len = (int)strlen(str);
char* str_ptr; char* str_ptr;
if (fastcmp(".lua", str + len - 4)) if (strcmp(".lua", str + len - 4) == 0)
{ {
str[len-4] = '\0'; // remove .lua at end str[len-4] = '\0'; // remove .lua at end
} }
+5 -27
View File
@@ -1203,7 +1203,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8
if (diff & MD_MORE) if (diff & MD_MORE)
WRITEUINT16(save->p, diff2); WRITEUINT16(save->p, diff2);
// save pointer, at load time we will search this pointer to reinitilize pointers // keep here for vanilla compat
WRITEUINT32(save->p, (size_t)mobj); WRITEUINT32(save->p, (size_t)mobj);
WRITEFIXED(save->p, mobj->z); // Force this so 3dfloor problems don't arise. WRITEFIXED(save->p, mobj->z); // Force this so 3dfloor problems don't arise.
@@ -1982,7 +1982,6 @@ static void CalculateDoomednumToMobjtype(void)
static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
{ {
thinker_t *next;
mobj_t *mobj; mobj_t *mobj;
UINT32 diff; UINT32 diff;
UINT16 diff2; UINT16 diff2;
@@ -1995,7 +1994,8 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
else else
diff2 = 0; diff2 = 0;
next = (void *)(size_t)READUINT32(save->p); // here for vanilla compat
save->p += sizeof(UINT32);
z = READFIXED(save->p); // Force this so 3dfloor problems don't arise. z = READFIXED(save->p); // Force this so 3dfloor problems don't arise.
floorz = READFIXED(save->p); floorz = READFIXED(save->p);
@@ -2234,8 +2234,6 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
if (diff2 & MD2_WAYPOINTCAP) if (diff2 & MD2_WAYPOINTCAP)
P_SetTarget(&waypointcap, mobj); P_SetTarget(&waypointcap, mobj);
mobj->info = (mobjinfo_t *)next; // temporarily, set when leave this function
R_AddMobjInterpolator(mobj); R_AddMobjInterpolator(mobj);
} }
@@ -3200,25 +3198,6 @@ FUNCINLINE static ATTRINLINE void P_UnArchivePolyObjects(savebuffer_t *save)
for (i = 0; i < numSavedPolys; ++i) for (i = 0; i < numSavedPolys; ++i)
P_UnArchivePolyObj(save, &PolyObjects[i]); P_UnArchivePolyObj(save, &PolyObjects[i]);
} }
//
// P_FinishMobjs
//
FUNCINLINE static ATTRINLINE void P_FinishMobjs(void)
{
thinker_t *currentthinker;
mobj_t *mobj;
// put info field there real value
for (currentthinker = thinkercap.next; currentthinker != &thinkercap;
currentthinker = currentthinker->next)
{
if (currentthinker->function != (actionf_p1)P_MobjThinker)
continue;
mobj = (mobj_t *)currentthinker;
mobj->info = &mobjinfo[mobj->type];
}
}
FUNCINLINE static ATTRINLINE mobj_t *RelinkMobj(mobj_t **ptr) FUNCINLINE static ATTRINLINE mobj_t *RelinkMobj(mobj_t **ptr)
{ {
@@ -3391,7 +3370,7 @@ FUNCINLINE static ATTRINLINE void P_UnArchiveSPGame(savebuffer_t *save, INT16 ma
READSTRINGN(save->p, testname, sizeof(testname)); READSTRINGN(save->p, testname, sizeof(testname));
if (!fastcmp(testname, timeattackfolder)) if (strcmp(testname, timeattackfolder))
{ {
if (modifiedgame) if (modifiedgame)
I_Error("Save game not for this modification."); I_Error("Save game not for this modification.");
@@ -3793,7 +3772,7 @@ boolean P_LoadGame(savebuffer_t *save, INT16 mapoverride)
boolean P_LoadNetGame(savebuffer_t *save, boolean reloading) boolean P_LoadNetGame(savebuffer_t *save, boolean reloading)
{ {
CV_LoadNetVars(&save->p); save->p += CV_LoadNetVars(save->p);
if (!P_NetUnArchiveMisc(save, reloading)) if (!P_NetUnArchiveMisc(save, reloading))
return false; return false;
@@ -3807,7 +3786,6 @@ boolean P_LoadNetGame(savebuffer_t *save, boolean reloading)
P_NetUnArchiveThinkers(save); P_NetUnArchiveThinkers(save);
P_NetUnArchiveSpecials(save); P_NetUnArchiveSpecials(save);
P_RelinkPointers(); P_RelinkPointers();
P_FinishMobjs();
} }
LUA_UnArchive(save, true); LUA_UnArchive(save, true);
+14 -38
View File
@@ -324,7 +324,6 @@ void P_InitPicAnims(void)
lastanim->speed = LONG(animdefs[i].speed); lastanim->speed = LONG(animdefs[i].speed);
lastanim++; lastanim++;
} }
lastanim->istexture = -1; lastanim->istexture = -1;
R_ClearTextureNumCache(false); R_ClearTextureNumCache(false);
@@ -332,7 +331,6 @@ void P_InitPicAnims(void)
// We'll only be using anims from now on. // We'll only be using anims from now on.
if (animdefs != harddefs) if (animdefs != harddefs)
Z_Free(animdefs); Z_Free(animdefs);
animdefs = NULL; animdefs = NULL;
} }
@@ -363,21 +361,20 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum)
// Now, let's start parsing this thing // Now, let's start parsing this thing
p = animdefsText; p = animdefsText;
animdefsToken = M_GetToken(p); animdefsToken = M_GetToken(p);
while (animdefsToken != NULL) while (animdefsToken != NULL)
{ {
if (fasticmp(animdefsToken, "TEXTURE")) if (stricmp(animdefsToken, "TEXTURE") == 0)
{ {
Z_Free(animdefsToken); Z_Free(animdefsToken);
P_ParseAnimationDefintion(1); P_ParseAnimationDefintion(1);
} }
else if (fasticmp(animdefsToken, "FLAT")) else if (stricmp(animdefsToken, "FLAT") == 0)
{ {
Z_Free(animdefsToken); Z_Free(animdefsToken);
P_ParseAnimationDefintion(0); P_ParseAnimationDefintion(0);
} }
else if (fasticmp(animdefsToken, "OSCILLATE")) else if (stricmp(animdefsToken, "OSCILLATE") == 0)
{ {
// This probably came off the tail of an earlier definition. It's technically legal syntax, but we don't support it. // This probably came off the tail of an earlier definition. It's technically legal syntax, but we don't support it.
I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"OSCILLATE\" (the animation plays in reverse when it reaches the end) are not supported by SRB2"); I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"OSCILLATE\" (the animation plays in reverse when it reaches the end) are not supported by SRB2");
@@ -386,17 +383,11 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum)
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"TEXTURE\" or \"FLAT\", got \"%s\"",animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"TEXTURE\" or \"FLAT\", got \"%s\"",animdefsToken);
} }
// parse next line // parse next line
while (*p != '\0' && *p != '\n') while (*p != '\0' && *p != '\n') ++p;
++p; if (*p == '\n') ++p;
if (*p == '\n')
++p;
animdefsToken = M_GetToken(p); animdefsToken = M_GetToken(p);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
Z_Free((void *)animdefsText); Z_Free((void *)animdefsText);
} }
@@ -415,8 +406,7 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where start texture/flat name should be"); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where start texture/flat name should be");
} }
if (stricmp(animdefsToken, "OPTIONAL") == 0)
if (fasticmp(animdefsToken, "OPTIONAL"))
{ {
// This is meaningful to ZDoom - it tells the program NOT to bomb out // This is meaningful to ZDoom - it tells the program NOT to bomb out
// if the textures can't be found - but it's useless in SRB2, so we'll // if the textures can't be found - but it's useless in SRB2, so we'll
@@ -428,7 +418,7 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where start texture/flat name should be"); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where start texture/flat name should be");
} }
else if (fasticmp(animdefsToken, "RANGE")) else if (stricmp(animdefsToken, "RANGE") == 0)
{ {
// Oh. Um. Apparently "OPTIONAL" is a texture name. Naughty. // Oh. Um. Apparently "OPTIONAL" is a texture name. Naughty.
// I should probably handle this more gracefully, but right now // I should probably handle this more gracefully, but right now
@@ -437,17 +427,15 @@ void P_ParseAnimationDefintion(SINT8 istexture)
I_Error("Error parsing ANIMDEFS lump: \"OPTIONAL\" is a keyword; you cannot use it as the startname of an animation"); I_Error("Error parsing ANIMDEFS lump: \"OPTIONAL\" is a keyword; you cannot use it as the startname of an animation");
} }
} }
animdefsTokenLength = strlen(animdefsToken); animdefsTokenLength = strlen(animdefsToken);
if (animdefsTokenLength > 8) if (animdefsTokenLength>8)
{ {
I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken); I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken);
} }
// Search for existing animdef // Search for existing animdef
for (i = 0; i < maxanims; i++) for (i = 0; i < maxanims; i++)
{ if (stricmp(animdefsToken, animdefs[i].startname) == 0)
if (fasticmp(animdefsToken, animdefs[i].startname))
{ {
//CONS_Alert(CONS_NOTICE, "Duplicate animation: %s\n", animdefsToken); //CONS_Alert(CONS_NOTICE, "Duplicate animation: %s\n", animdefsToken);
@@ -456,7 +444,6 @@ void P_ParseAnimationDefintion(SINT8 istexture)
Z_Free(animdefsToken); Z_Free(animdefsToken);
return; return;
} }
}
// Not found // Not found
if (i == maxanims) if (i == maxanims)
@@ -480,25 +467,21 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"RANGE\" after \"%s\"'s startname should be", animdefs[i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"RANGE\" after \"%s\"'s startname should be", animdefs[i].startname);
} }
if (stricmp(animdefsToken, "ALLOWDECALS") == 0)
if (fasticmp(animdefsToken, "ALLOWDECALS"))
{ {
// Another ZDoom keyword, ho-hum. Skip it, move on to the next token. // Another ZDoom keyword, ho-hum. Skip it, move on to the next token.
Z_Free(animdefsToken); Z_Free(animdefsToken);
animdefsToken = M_GetToken(NULL); animdefsToken = M_GetToken(NULL);
} }
if (stricmp(animdefsToken, "PIC") == 0)
if (fasticmp(animdefsToken, "PIC"))
{ {
// This is technically legitimate ANIMDEFS syntax, but SRB2 doesn't support it. // This is technically legitimate ANIMDEFS syntax, but SRB2 doesn't support it.
I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"PIC\" (specific frames instead of a consecutive range) are not supported by SRB2"); I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"PIC\" (specific frames instead of a consecutive range) are not supported by SRB2");
} }
if (stricmp(animdefsToken, "RANGE") != 0)
if (!fasticmp(animdefsToken, "RANGE"))
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"RANGE\" after \"%s\"'s startname, got \"%s\"", animdefs[i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"RANGE\" after \"%s\"'s startname, got \"%s\"", animdefs[i].startname, animdefsToken);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
// Endname // Endname
@@ -507,13 +490,11 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s end texture/flat name should be", animdefs[i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s end texture/flat name should be", animdefs[i].startname);
} }
animdefsTokenLength = strlen(animdefsToken); animdefsTokenLength = strlen(animdefsToken);
if (animdefsTokenLength>8) if (animdefsTokenLength>8)
{ {
I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken); I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken);
} }
strncpy(animdefs[i].endname, animdefsToken, 9); strncpy(animdefs[i].endname, animdefsToken, 9);
Z_Free(animdefsToken); Z_Free(animdefsToken);
@@ -523,18 +504,15 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s \"TICS\" should be", animdefs[i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s \"TICS\" should be", animdefs[i].startname);
} }
if (stricmp(animdefsToken, "RAND") == 0)
if (fasticmp(animdefsToken, "RAND"))
{ {
// This is technically legitimate ANIMDEFS syntax, but SRB2 doesn't support it. // This is technically legitimate ANIMDEFS syntax, but SRB2 doesn't support it.
I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"RAND\" (random duration per frame) are not supported by SRB2"); I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"RAND\" (random duration per frame) are not supported by SRB2");
} }
if (stricmp(animdefsToken, "TICS") != 0)
if (!fasticmp(animdefsToken, "TICS"))
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"TICS\" in animation definition for \"%s\", got \"%s\"", animdefs[i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"TICS\" in animation definition for \"%s\", got \"%s\"", animdefs[i].startname, animdefsToken);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
// Speed // Speed
@@ -543,7 +521,6 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s animation speed should be", animdefs[i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s animation speed should be", animdefs[i].startname);
} }
endPos = NULL; endPos = NULL;
#ifndef AVOID_ERRNO #ifndef AVOID_ERRNO
errno = 0; errno = 0;
@@ -558,7 +535,6 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Expected a positive integer for \"%s\"'s animation speed, got \"%s\"", animdefs[i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected a positive integer for \"%s\"'s animation speed, got \"%s\"", animdefs[i].startname, animdefsToken);
} }
animdefs[i].speed = animSpeed; animdefs[i].speed = animSpeed;
Z_Free(animdefsToken); Z_Free(animdefsToken);
} }
+13 -30
View File
@@ -867,7 +867,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after \"%s\"'s patch name should be",patchName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after \"%s\"'s patch name should be",patchName);
} }
if (!fastcmp(texturesToken,",")) if (strcmp(texturesToken,",")!=0)
{ {
I_Error("Error parsing TEXTURES lump: Expected \",\" after %s's patch name, got \"%s\"",patchName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \",\" after %s's patch name, got \"%s\"",patchName,texturesToken);
} }
@@ -907,7 +907,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after patch \"%s\"'s x coordinate should be",patchName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after patch \"%s\"'s x coordinate should be",patchName);
} }
if (!fastcmp(texturesToken,",")) if (strcmp(texturesToken,",")!=0)
{ {
I_Error("Error parsing TEXTURES lump: Expected \",\" after patch \"%s\"'s x coordinate, got \"%s\"",patchName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \",\" after patch \"%s\"'s x coordinate, got \"%s\"",patchName,texturesToken);
} }
@@ -976,9 +976,8 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where texture name should be"); I_Error("Error parsing TEXTURES lump: Unexpected end of file where texture name should be");
} }
texturesTokenLength = strlen(texturesToken); texturesTokenLength = strlen(texturesToken);
if (texturesTokenLength > 8) if (texturesTokenLength>8)
{ {
I_Error("Error parsing TEXTURES lump: Texture name \"%s\" exceeds 8 characters",texturesToken); I_Error("Error parsing TEXTURES lump: Texture name \"%s\" exceeds 8 characters",texturesToken);
} }
@@ -989,7 +988,6 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
// ^^ we've confirmed that the token is <= 8 characters so it will never overflow a 9 byte char buffer // ^^ we've confirmed that the token is <= 8 characters so it will never overflow a 9 byte char buffer
strupr(newTextureName); // Just do this now so we don't have to worry about it strupr(newTextureName); // Just do this now so we don't have to worry about it
} }
Z_Free(texturesToken); Z_Free(texturesToken);
// Comma 1 // Comma 1
@@ -998,11 +996,10 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after texture \"%s\"'s name should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after texture \"%s\"'s name should be",newTextureName);
} }
else if (!fastcmp(texturesToken, ",")) else if (strcmp(texturesToken,",")!=0)
{ {
I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s name, got \"%s\"",newTextureName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s name, got \"%s\"",newTextureName,texturesToken);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
// Width // Width
@@ -1033,12 +1030,10 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after texture \"%s\"'s width should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after texture \"%s\"'s width should be",newTextureName);
} }
if (strcmp(texturesToken,",")!=0)
if (!fastcmp(texturesToken, ","))
{ {
I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s width, got \"%s\"",newTextureName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s width, got \"%s\"",newTextureName,texturesToken);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
// Height // Height
@@ -1071,7 +1066,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where open curly brace for texture \"%s\" should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where open curly brace for texture \"%s\" should be",newTextureName);
} }
if (fastcmp(texturesToken, "{")) if (strcmp(texturesToken,"{")==0)
{ {
if (actuallyLoadTexture) if (actuallyLoadTexture)
{ {
@@ -1083,18 +1078,15 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
resultTexture->height = newTextureHeight; resultTexture->height = newTextureHeight;
resultTexture->type = TEXTURETYPE_COMPOSITE; resultTexture->type = TEXTURETYPE_COMPOSITE;
} }
Z_Free(texturesToken); Z_Free(texturesToken);
texturesToken = M_GetToken(NULL); texturesToken = M_GetToken(NULL);
if (texturesToken == NULL) if (texturesToken == NULL)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch definition for texture \"%s\" should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch definition for texture \"%s\" should be",newTextureName);
} }
while (strcmp(texturesToken,"}")!=0)
while (!fastcmp(texturesToken, "}"))
{ {
if (fasticmp(texturesToken, "PATCH")) if (stricmp(texturesToken, "PATCH")==0)
{ {
Z_Free(texturesToken); Z_Free(texturesToken);
if (resultTexture) if (resultTexture)
@@ -1126,7 +1118,6 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch declaration or right curly brace for texture \"%s\" should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch declaration or right curly brace for texture \"%s\" should be",newTextureName);
} }
} }
if (resultTexture && resultTexture->patchcount == 0) if (resultTexture && resultTexture->patchcount == 0)
{ {
I_Error("Error parsing TEXTURES lump: Texture \"%s\" must have at least one patch",newTextureName); I_Error("Error parsing TEXTURES lump: Texture \"%s\" must have at least one patch",newTextureName);
@@ -1136,13 +1127,10 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
{ {
I_Error("Error parsing TEXTURES lump: Expected \"{\" for texture \"%s\", got \"%s\"",newTextureName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \"{\" for texture \"%s\", got \"%s\"",newTextureName,texturesToken);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
if (actuallyLoadTexture) if (actuallyLoadTexture) return resultTexture;
return resultTexture; else return NULL;
return NULL;
} }
// Parses the TEXTURES lump... but just to count the number of textures. // Parses the TEXTURES lump... but just to count the number of textures.
@@ -1174,7 +1162,7 @@ int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum)
texturesToken = M_GetToken(texturesText); texturesToken = M_GetToken(texturesText);
while (texturesToken != NULL) while (texturesToken != NULL)
{ {
if (fasticmp(texturesToken, "WALLTEXTURE")) if (stricmp(texturesToken, "WALLTEXTURE")==0)
{ {
numTexturesInLump++; numTexturesInLump++;
Z_Free(texturesToken); Z_Free(texturesToken);
@@ -1184,10 +1172,8 @@ int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum)
{ {
I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken); I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken);
} }
texturesToken = M_GetToken(NULL); texturesToken = M_GetToken(NULL);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
Z_Free((void *)texturesText); Z_Free((void *)texturesText);
@@ -1225,7 +1211,7 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex)
texturesToken = M_GetToken(texturesText); texturesToken = M_GetToken(texturesText);
while (texturesToken != NULL) while (texturesToken != NULL)
{ {
if (fasticmp(texturesToken, "WALLTEXTURE")) if (stricmp(texturesToken, "WALLTEXTURE")==0)
{ {
Z_Free(texturesToken); Z_Free(texturesToken);
// Get the new texture // Get the new texture
@@ -1241,10 +1227,8 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex)
{ {
I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken); I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken);
} }
texturesToken = M_GetToken(NULL); texturesToken = M_GetToken(NULL);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
Z_Free((void *)texturesText); Z_Free((void *)texturesText);
} }
@@ -1350,9 +1334,8 @@ lumpnum_t R_GetFlatNumForName(const char *name)
if (lump == LUMPERROR) if (lump == LUMPERROR)
{ {
if (!fastcmp(name, SKYFLATNAME)) if (strcmp(name, SKYFLATNAME))
CONS_Debug(DBG_SETUP, "R_GetFlatNumForName: Could not find flat %.8s\n", name); CONS_Debug(DBG_SETUP, "R_GetFlatNumForName: Could not find flat %.8s\n", name);
lump = W_CheckNumForName("REDFLR"); lump = W_CheckNumForName("REDFLR");
} }
+46 -58
View File
@@ -46,14 +46,13 @@ static void R_ParseSpriteInfoFrame(spriteinfo_t *info)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite frame should be"); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite frame should be");
} }
sprinfoTokenLength = strlen(sprinfoToken); sprinfoTokenLength = strlen(sprinfoToken);
if (sprinfoTokenLength != 1) if (sprinfoTokenLength != 1)
{ {
I_Error("Error parsing SPRTINFO lump: Invalid frame \"%s\"",sprinfoToken); I_Error("Error parsing SPRTINFO lump: Invalid frame \"%s\"",sprinfoToken);
} }
else
frameChar = sprinfoToken; frameChar = sprinfoToken;
frameFrame = R_Char2Frame(frameChar[0]); frameFrame = R_Char2Frame(frameChar[0]);
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
@@ -62,53 +61,53 @@ static void R_ParseSpriteInfoFrame(spriteinfo_t *info)
sprinfoToken = M_GetToken(NULL); sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL) if (sprinfoToken == NULL)
I_Error("Error parsing SPRTINFO lump: Missing sprite info"); I_Error("Error parsing SPRTINFO lump: Missing sprite info");
else
if (fastcmp(sprinfoToken, "{"))
{ {
Z_Free(sprinfoToken); if (strcmp(sprinfoToken,"{")==0)
sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info should be");
}
while (!fastcmp(sprinfoToken, "}"))
{
if (fasticmp(sprinfoToken, "XPIVOT"))
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
frameXPivot = atoi(sprinfoToken);
}
else if (fasticmp(sprinfoToken, "YPIVOT"))
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
frameYPivot = atoi(sprinfoToken);
}
else if (fasticmp(sprinfoToken, "ROTAXIS"))
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
if (fasticmp(sprinfoToken, "X") || fasticmp(sprinfoToken, "XAXIS") || fasticmp(sprinfoToken, "ROLL"))
frameRotAxis = ROTAXIS_X;
else if (fasticmp(sprinfoToken, "Y") || fasticmp(sprinfoToken, "YAXIS") || fasticmp(sprinfoToken, "PITCH"))
frameRotAxis = ROTAXIS_Y;
else if (fasticmp(sprinfoToken, "Z") || fasticmp(sprinfoToken, "ZAXIS") || fasticmp(sprinfoToken, "YAW"))
frameRotAxis = ROTAXIS_Z;
}
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL); sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL) if (sprinfoToken == NULL)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info or right curly brace should be"); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info should be");
}
while (strcmp(sprinfoToken,"}")!=0)
{
if (stricmp(sprinfoToken, "XPIVOT")==0)
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
frameXPivot = atoi(sprinfoToken);
}
else if (stricmp(sprinfoToken, "YPIVOT")==0)
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
frameYPivot = atoi(sprinfoToken);
}
else if (stricmp(sprinfoToken, "ROTAXIS")==0)
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
if ((stricmp(sprinfoToken, "X")==0) || (stricmp(sprinfoToken, "XAXIS")==0) || (stricmp(sprinfoToken, "ROLL")==0))
frameRotAxis = ROTAXIS_X;
else if ((stricmp(sprinfoToken, "Y")==0) || (stricmp(sprinfoToken, "YAXIS")==0) || (stricmp(sprinfoToken, "PITCH")==0))
frameRotAxis = ROTAXIS_Y;
else if ((stricmp(sprinfoToken, "Z")==0) || (stricmp(sprinfoToken, "ZAXIS")==0) || (stricmp(sprinfoToken, "YAW")==0))
frameRotAxis = ROTAXIS_Z;
}
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL)
{
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info or right curly brace should be");
}
} }
} }
Z_Free(sprinfoToken);
} }
Z_Free(sprinfoToken);
// set fields // set fields
info->pivot[frameFrame].x = frameXPivot; info->pivot[frameFrame].x = frameXPivot;
info->pivot[frameFrame].y = frameYPivot; info->pivot[frameFrame].y = frameYPivot;
@@ -138,7 +137,6 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite name should be"); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite name should be");
} }
sprinfoTokenLength = strlen(sprinfoToken); sprinfoTokenLength = strlen(sprinfoToken);
if (sprinfoTokenLength != 4) if (sprinfoTokenLength != 4)
{ {
@@ -151,7 +149,6 @@ static void R_ParseSpriteInfo(boolean spr2)
// ^^ we've confirmed that the token is == 4 characters so it will never overflow a 5 byte char buffer // ^^ we've confirmed that the token is == 4 characters so it will never overflow a 5 byte char buffer
strupr(newSpriteName); // Just do this now so we don't have to worry about it strupr(newSpriteName); // Just do this now so we don't have to worry about it
} }
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
if (!spr2) if (!spr2)
@@ -160,8 +157,7 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
if (i == NUMSPRITES) if (i == NUMSPRITES)
I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName); I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName);
if (!memcmp(newSpriteName,sprnames[i],4))
if (!memcmp(newSpriteName,sprnames[i], 4))
{ {
sprnum = static_cast<spritenum_t>(i); sprnum = static_cast<spritenum_t>(i);
break; break;
@@ -179,20 +175,17 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where open curly brace for sprite \"%s\" should be",newSpriteName); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where open curly brace for sprite \"%s\" should be",newSpriteName);
} }
if (strcmp(sprinfoToken,"{")==0)
if (fastcmp(sprinfoToken, "{"))
{ {
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL); sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL) if (sprinfoToken == NULL)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where definition for sprite \"%s\" should be",newSpriteName); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where definition for sprite \"%s\" should be",newSpriteName);
} }
while (strcmp(sprinfoToken,"}")!=0)
while (!fastcmp(sprinfoToken, "}"))
{ {
if (fasticmp(sprinfoToken, "SKIN")) if (stricmp(sprinfoToken, "SKIN")==0)
{ {
INT32 skinnum; INT32 skinnum;
char *skinName = NULL; char *skinName = NULL;
@@ -223,11 +216,10 @@ static void R_ParseSpriteInfo(boolean spr2)
skinnumbers[foundskins] = skinnum; skinnumbers[foundskins] = skinnum;
foundskins++; foundskins++;
} }
else if (fasticmp(sprinfoToken, "FRAME")) else if (stricmp(sprinfoToken, "FRAME")==0)
{ {
R_ParseSpriteInfoFrame(info); R_ParseSpriteInfoFrame(info);
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
if (spr2) if (spr2)
{ {
if (!foundskins) if (!foundskins)
@@ -262,7 +254,6 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
I_Error("Error parsing SPRTINFO lump: Expected \"{\" for sprite \"%s\", got \"%s\"",newSpriteName,sprinfoToken); I_Error("Error parsing SPRTINFO lump: Expected \"{\" for sprite \"%s\", got \"%s\"",newSpriteName,sprinfoToken);
} }
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
Z_Free(info); Z_Free(info);
} }
@@ -300,18 +291,15 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum)
while (sprinfoToken != NULL) while (sprinfoToken != NULL)
{ {
CONS_Printf("Attempting to parse le SPRTINFO lump for ya..\n"); CONS_Printf("Attempting to parse le SPRTINFO lump for ya..\n");
if (!stricmp(sprinfoToken, "SPRITE"))
if (fasticmp(sprinfoToken, "SPRITE"))
R_ParseSpriteInfo(false); R_ParseSpriteInfo(false);
else if (fasticmp(sprinfoToken, "SPRITE2")) else if (!stricmp(sprinfoToken, "SPRITE2"))
R_ParseSpriteInfo(true); R_ParseSpriteInfo(true);
else else
I_Error("Error parsing SPRTINFO lump: Unknown keyword \"%s\"", sprinfoToken); I_Error("Error parsing SPRTINFO lump: Unknown keyword \"%s\"", sprinfoToken);
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL); sprinfoToken = M_GetToken(NULL);
} }
Z_Free((void *)sprinfoText); Z_Free((void *)sprinfoText);
} }
+134 -154
View File
@@ -33,7 +33,7 @@
#include "qs22j.h" #include "qs22j.h"
CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; // huehuehuehuehue CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2];
#include "discord.h" #include "discord.h"
@@ -41,7 +41,6 @@ INT32 numskins = 0;
INT32 numallskins = 0; INT32 numallskins = 0;
INT32 numlocalskins = 0; INT32 numlocalskins = 0;
skin_t skins[MAXSKINS]; skin_t skins[MAXSKINS];
UINT8 skinstats[9][9][MAXSKINS]; UINT8 skinstats[9][9][MAXSKINS];
UINT8 skinstatscount[9][9] = { UINT8 skinstatscount[9][9] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
@@ -54,7 +53,6 @@ UINT8 skinstatscount[9][9] = {
{0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, 0, 0, 0}
}; };
UINT8 skinsorted[MAXSKINS]; UINT8 skinsorted[MAXSKINS];
skin_t localskins[MAXLOCALSKINS]; skin_t localskins[MAXLOCALSKINS];
skin_t allskins[MAXSKINS+MAXLOCALSKINS]; skin_t allskins[MAXSKINS+MAXLOCALSKINS];
@@ -72,15 +70,14 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local)
// //
// set default skin values // set default skin values
// //
memset(skin, 0, sizeof(skin_t)); memset(skin, 0, sizeof (skin_t));
snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local)); snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local));
skin->name[sizeof skin->name - 1] = '\0'; skin->name[sizeof skin->name - 1] = '\0';
skin->wadnum = INT16_MAX; skin->wadnum = INT16_MAX;
strcpy(skin->sprite, ""); strcpy(skin->sprite, "");
skin->flags = 0;
strcpy(skin->realname, "Someone"); strcpy(skin->realname, "Someone");
strcpy(skin->hudname, "???"); strcpy(skin->hudname, "???");
strncpy(skin->facerank, "PLAYRANK", 9); strncpy(skin->facerank, "PLAYRANK", 9);
@@ -98,12 +95,8 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local)
skin->highresscale = FRACUNIT>>1; skin->highresscale = FRACUNIT>>1;
for (i = 0; i < sfx_skinsoundslot0; i++) for (i = 0; i < sfx_skinsoundslot0; i++)
{ if (S_sfx[i].skinsound != -1)
const INT32 skinsound = S_sfx[i].skinsound; skin->soundsid[S_sfx[i].skinsound] = i;
if (skinsound != -1)
skin->soundsid[skinsound] = i;
}
} }
// //
@@ -131,7 +124,6 @@ void R_InitSkins(void)
skin = &skins[0]; skin = &skins[0];
numskins = 1; numskins = 1;
Sk_SetDefaultValue(skin, false); Sk_SetDefaultValue(skin, false);
memset(skinstats, 0, sizeof(skinstats)); memset(skinstats, 0, sizeof(skinstats));
memset(skinsorted, 0, sizeof(skinsorted)); memset(skinsorted, 0, sizeof(skinsorted));
@@ -140,16 +132,13 @@ void R_InitSkins(void)
#ifdef SKINVALUES #ifdef SKINVALUES
skin_cons_t[0].strvalue = skins[0].name; skin_cons_t[0].strvalue = skins[0].name;
#endif #endif
skin->flags = 0;
strcpy(skin->realname, "Sonic"); strcpy(skin->realname, "Sonic");
strcpy(skin->hudname, "SONIC"); strcpy(skin->hudname, "SONIC");
strncpy(skin->facerank, "PLAYRANK", 9); strncpy(skin->facerank, "PLAYRANK", 9);
strncpy(skin->facewant, "PLAYWANT", 9); strncpy(skin->facewant, "PLAYWANT", 9);
strncpy(skin->facemmap, "PLAYMMAP", 9); strncpy(skin->facemmap, "PLAYMMAP", 9);
skin->flags = 0;
skin->wadnum = 0; // god what have you brought to this world skin->wadnum = 0; // god what have you brought to this world
skin->prefcolor = SKINCOLOR_BLUE; skin->prefcolor = SKINCOLOR_BLUE;
skin->localskin = false; skin->localskin = false;
@@ -188,10 +177,9 @@ INT32 R_SkinAvailable(const char *name)
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
if (fasticmp(skins[i].name, name)) if (stricmp(skins[i].name,name) == 0)
return i; return i;
} }
return -1; return -1;
} }
@@ -203,10 +191,9 @@ INT32 R_AnySkinAvailable(const char *name)
for (i = 0; i < numallskins; i++) for (i = 0; i < numallskins; i++)
{ {
if (fasticmp(allskins[i].name, name)) if (stricmp(allskins[i].name,name) == 0)
return i; return i;
} }
return -1; return -1;
} }
@@ -218,32 +205,32 @@ INT32 R_LocalSkinAvailable(const char *name, boolean local)
{ {
for (i = 0; i < numlocalskins; i++) for (i = 0; i < numlocalskins; i++)
{ {
if (fasticmp(localskins[i].name, name)) if (stricmp(localskins[i].name,name) == 0)
return i; return i;
} }
return -1; return -1;
} }
else
return R_SkinAvailable(name); return R_SkinAvailable(name);
} }
// network code calls this when a 'skin change' is received // network code calls this when a 'skin change' is received
boolean SetPlayerSkin(INT32 playernum, const char *skinname) boolean SetPlayerSkin(INT32 playernum, const char *skinname)
{ {
INT32 i; INT32 i;
player_t *player = &players[playernum];
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
// search in the skin list // search in the skin list
if (fasticmp(skins[i].name, skinname)) if (stricmp(skins[i].name, skinname) == 0)
{ {
SetPlayerSkinByNum(playernum, i); SetPlayerSkinByNum(playernum, i);
return true; return true;
} }
} }
if (P_IsLocalPlayer(&players[playernum])) if (P_IsLocalPlayer(player))
CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname);
else if (server || IsPlayerAdmin(consoleplayer)) else if (server || IsPlayerAdmin(consoleplayer))
CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname);
@@ -257,16 +244,15 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
INT32 i; INT32 i;
player_t *player = &players[playernum]; player_t *player = &players[playernum];
if (!fasticmp(skinname, "none")) if (stricmp(skinname, "none"))
{ {
for (i = 0; i < numlocalskins; i++) for (i = 0; i < numlocalskins; i++)
{ {
// search in the localskin list // search in the localskin list
if (fasticmp(localskins[i].name, skinname)) if (stricmp(localskins[i].name, skinname) == 0)
{ {
player->localskin = 1 + i; player->localskin = 1 + i;
player->skinlocal = true; player->skinlocal = true;
if (player->mo) if (player->mo)
{ {
player->mo->localskin = &localskins[i]; player->mo->localskin = &localskins[i];
@@ -280,11 +266,10 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
// search in the skin list // search in the skin list
if (fasticmp(skins[i].name, skinname)) if (stricmp(skins[i].name, skinname) == 0)
{ {
player->localskin = 1 + i; player->localskin = 1 + i;
player->skinlocal = false; player->skinlocal = false;
if (player->mo) if (player->mo)
{ {
player->mo->localskin = &skins[i]; player->mo->localskin = &skins[i];
@@ -299,7 +284,6 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
{ {
player->localskin = 0; player->localskin = 0;
player->skinlocal = false; player->skinlocal = false;
if (player->mo) if (player->mo)
{ {
player->mo->localskin = 0; player->mo->localskin = 0;
@@ -334,7 +318,6 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
if (skinnum >= 0 && skinnum < numskins) // Make sure it exists! if (skinnum >= 0 && skinnum < numskins) // Make sure it exists!
{ {
player->skin = skinnum; player->skin = skinnum;
if (player->mo) if (player->mo)
player->mo->skin = skin; player->mo->skin = skin;
@@ -377,97 +360,117 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump)
{ {
UINT16 i; UINT16 i;
const char *S_SKIN = "S_SKIN";
lumpinfo_t *lump_p; lumpinfo_t *lump_p;
// scan forward, start at <startlump> // scan forward, start at <startlump>
if (startlump < wadfiles[wadid]->numlumps) if (startlump < wadfiles[wadid]->numlumps)
{ {
lump_p = wadfiles[wadid]->lumpinfo + startlump; lump_p = wadfiles[wadid]->lumpinfo + startlump;
for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++)
{ if (memcmp(lump_p->name,S_SKIN,6)==0)
if (memcmp(lump_p->name, "S_SKIN", 6) == 0)
return i; return i;
}
} }
return INT16_MAX; // not found return INT16_MAX; // not found
} }
//sort function for sorting skin names //sort function for sorting skin names
static int skinSortFunc(const void *a, const void *b) // tbh i have no clue what the naming conventions for local functions are static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what the naming conventions for local functions are
{ {
int diff = 0; const skin_t *in1 = &skins[*(const UINT8 *)a];
const UINT8 val_a = *(const UINT8 *)a; const skin_t *in2 = &skins[*(const UINT8 *)b];
const UINT8 val_b = *(const UINT8 *)b; INT32 temp = 0;
const skin_t *in1 = &skins[val_a]; const UINT8 val_a = *((const UINT8 *)a);
const skin_t *in2 = &skins[val_b]; const UINT8 val_b = *((const UINT8 *)b);
// return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==); //return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==);
switch (cv_skinselectgridsort.value) switch (cv_skinselectgridsort.value)
{ {
case SKINMENUSORT_REALNAME: case SKINMENUSORT_REALNAME:
// CONS_Printf("Sorting by realname\n"); //CONS_Printf("Sorting by realname\n");
// check name // check name
diff = strcmp(in1->realname, in2->realname); if ((temp = strcmp(in1->realname, in2->realname)))
if (diff != 0) return diff; return temp;
// sort by internal name
return strcmp(in1->name, in2->name);
break; break;
case SKINMENUSORT_SPEED:
// CONS_Printf("Sorting by speed\n");
// check speed
diff = in1->kartspeed - in2->kartspeed;
if (diff != 0) return diff;
// then check weight
diff = in1->kartweight - in2->kartweight;
if (diff != 0) return diff;
// then check name
diff = strcmp(in1->realname, in2->realname);
if (diff != 0) return diff;
break;
case SKINMENUSORT_WEIGHT:
// CONS_Printf("Sorting by weight\n");
// check weight
diff = in1->kartweight - in2->kartweight;
if (diff != 0) return diff;
// then check speed
diff = in1->kartspeed - in2->kartspeed;
if (diff != 0) return diff;
// then check name
diff = strcmp(in1->realname, in2->realname);
if (diff != 0) return diff;
break;
case SKINMENUSORT_PREFCOLOR:
// CONS_Printf("Sorting by prefcolor\n");
// check prefcolor
diff = in1->prefcolor - in2->prefcolor;
if (diff != 0) return diff;
// then check name
diff = strcmp(in1->realname, in2->realname);
if (diff != 0) return diff;
break;
case SKINMENUSORT_ID:
// CONS_Printf("Sorting by id\n");
// how do i do by ID?????
// wait why dont i just convert the inputs to UINT32s
// please tell me im allowed to define variables in here since its a block
return (int)val_a - (int)val_b;
case SKINMENUSORT_NAME: case SKINMENUSORT_NAME:
//CONS_Printf("Sorting by name\n");
return strcmp(in1->name, in2->name);
break;
case SKINMENUSORT_SPEED:
//CONS_Printf("Sorting by speed\n");
// check speed
if (in1->kartspeed < in2->kartspeed)
return -1;
else if (in2->kartspeed < in1->kartspeed)
return 1;
// then check weight
if (in1->kartweight < in2->kartweight)
return -1;
else if (in2->kartweight < in1->kartweight)
return 1;
// then check name
if ((temp = strcmp(in1->realname, in2->realname)))
return temp;
// sort by internal name
return strcmp(in1->name, in2->name);
break;
case SKINMENUSORT_WEIGHT:
//CONS_Printf("Sorting by weight\n");
// check weight
if (in1->kartweight < in2->kartweight)
return -1;
else if (in2->kartweight < in1->kartweight)
return 1;
// then check speed
if (in1->kartspeed < in2->kartspeed)
return -1;
else if (in2->kartspeed < in1->kartspeed)
return 1;
// then check name
if ((temp = strcmp(in1->realname, in2->realname)))
return temp;
// sort by internal name
return strcmp(in1->name, in2->name);
break;
case SKINMENUSORT_PREFCOLOR:
//CONS_Printf("Sorting by prefcolor\n");
// check prefcolor
if (in1->prefcolor < in2->prefcolor)
return -1;
else if (in2->prefcolor < in1->prefcolor)
return 1;
// then check name
if ((temp = strcmp(in1->realname, in2->realname)))
return temp;
// sort by internal name
return strcmp(in1->name, in2->name);
break;
case SKINMENUSORT_ID:
//CONS_Printf("Sorting by id\n");
//how do i do by ID?????
//wait why dont i just convert the inputs to UINT32s
//please tell me im allowed to define variables in here since its a block
if (val_a == val_b)
return 0;
else if (val_a < val_b)
return -1;
else
return 1;
default: default:
return strcmp(in1->name, in2->name);
break; break;
} }
//im scared this somehow will sometimes end up here so im gonna add this here just to be safe
// im scared this somehow will sometimes end up here so im gonna add this here just to be safe
// now it will often end up here >:3
return strcmp(in1->name, in2->name); return strcmp(in1->name, in2->name);
} }
@@ -528,9 +531,8 @@ void R_AddSkins(UINT16 wadnum, boolean local)
Sk_SetDefaultValue(skin, local); Sk_SetDefaultValue(skin, local);
skin->wadnum = wadnum; skin->wadnum = wadnum;
hudname = realname = false; hudname = realname = false;
// parse // parse
stoken = strtok(buf2, "\r\n= "); stoken = strtok (buf2, "\r\n= ");
while (stoken) while (stoken)
{ {
if ((stoken[0] == '/' && stoken[1] == '/') if ((stoken[0] == '/' && stoken[1] == '/')
@@ -546,7 +548,7 @@ void R_AddSkins(UINT16 wadnum, boolean local)
if (!value) if (!value)
I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename);
if (fasticmp(stoken, "name")) if (!stricmp(stoken, "name"))
{ {
// the skin name must uniquely identify a single skin // the skin name must uniquely identify a single skin
// I'm lazy so if name is already used I leave the 'skin x' // I'm lazy so if name is already used I leave the 'skin x'
@@ -560,18 +562,18 @@ void R_AddSkins(UINT16 wadnum, boolean local)
// using the default skin name's number set above // using the default skin name's number set above
else else
{ {
const size_t stringspace = strlen(value) + sizeof lnumskins + 1; const size_t stringspace =
strlen(value) + sizeof lnumskins + 1;
char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL);
snprintf(value2, stringspace,
snprintf(value2, stringspace, "%s%d", value, lnumskins); "%s%d", value, lnumskins);
value2[stringspace - 1] = '\0'; value2[stringspace - 1] = '\0';
if (R_LocalSkinAvailable(value2, local) == -1) if (R_LocalSkinAvailable(value2, local) == -1)
{ {
STRBUFCPY(skin->name, value2); STRBUFCPY(skin->name,
value2);
strlwr(skin->name); strlwr(skin->name);
} }
Z_Free(value2); Z_Free(value2);
} }
@@ -587,134 +589,115 @@ void R_AddSkins(UINT16 wadnum, boolean local)
{ {
STRBUFCPY(skin->hudname, skin->name); STRBUFCPY(skin->hudname, skin->name);
strupr(skin->hudname); strupr(skin->hudname);
for (value = skin->hudname; *value; value++) for (value = skin->hudname; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces. if (*value == '_') *value = ' '; // turn _ into spaces.
} }
} }
else if (fasticmp(stoken, "realname")) else if (!stricmp(stoken, "realname"))
{ // Display name (eg. "Knuckles") { // Display name (eg. "Knuckles")
realname = true; realname = true;
STRBUFCPY(skin->realname, value); STRBUFCPY(skin->realname, value);
for (value = skin->realname; *value; value++) for (value = skin->realname; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces. if (*value == '_') *value = ' '; // turn _ into spaces.
if (!hudname) if (!hudname)
STRBUFCPY(skin->hudname, skin->realname); STRBUFCPY(skin->hudname, skin->realname);
} }
else if (fasticmp(stoken, "hudname")) else if (!stricmp(stoken, "hudname"))
{ // Life icon name (eg. "K.T.E") { // Life icon name (eg. "K.T.E")
hudname = true; hudname = true;
STRBUFCPY(skin->hudname, value); STRBUFCPY(skin->hudname, value);
for (value = skin->hudname; *value; value++) for (value = skin->hudname; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces. if (*value == '_') *value = ' '; // turn _ into spaces.
if (!realname) if (!realname)
STRBUFCPY(skin->realname, skin->hudname); STRBUFCPY(skin->realname, skin->hudname);
} }
else if (fasticmp(stoken, "sprite"))
else if (!stricmp(stoken, "sprite"))
{ {
strupr(value); strupr(value);
memcpy(skin->sprite, value, sizeof skin->sprite); memcpy(skin->sprite, value, sizeof skin->sprite);
} }
else if (fasticmp(stoken, "facerank")) else if (!stricmp(stoken, "facerank"))
{ {
strupr(value); strupr(value);
memcpy(skin->facerank, value, sizeof(skin->facerank)-1); memcpy(skin->facerank, value, sizeof(skin->facerank)-1);
skin->facerank[sizeof(skin->facerank)-1] = '\0'; skin->facerank[sizeof(skin->facerank)-1] = '\0';
} }
else if (fasticmp(stoken, "facewant")) else if (!stricmp(stoken, "facewant"))
{ {
strupr(value); strupr(value);
memcpy(skin->facewant, value, sizeof(skin->facewant)-1); memcpy(skin->facewant, value, sizeof(skin->facewant)-1);
skin->facewant[sizeof(skin->facewant)-1] = '\0'; skin->facewant[sizeof(skin->facewant)-1] = '\0';
} }
else if (fasticmp(stoken, "facemmap")) else if (!stricmp(stoken, "facemmap"))
{ {
strupr(value); strupr(value);
strncpy(skin->facemmap, value, sizeof(skin->facemmap)-1); strncpy(skin->facemmap, value, sizeof(skin->facemmap)-1);
skin->facemmap[sizeof(skin->facemmap)-1] = '\0'; skin->facemmap[sizeof(skin->facemmap)-1] = '\0';
} }
else if (fasticmp(stoken, "flags")) // character type identification else if (!stricmp(stoken, "flags")) // character type identification
{ {
skin->flags = get_number(value); skin->flags = get_number(value);
} }
else if (fasticmp(stoken, "kartspeed")) else if (!stricmp(stoken, "kartspeed"))
{ {
skin->kartspeed = atoi(value); skin->kartspeed = atoi(value);
if (skin->kartspeed < 1) if (skin->kartspeed < 1)
skin->kartspeed = 1; skin->kartspeed = 1;
if (skin->kartspeed > 9) if (skin->kartspeed > 9)
skin->kartspeed = 9; skin->kartspeed = 9;
} }
else if (fasticmp(stoken, "kartweight")) else if (!stricmp(stoken, "kartweight"))
{ {
skin->kartweight = atoi(value); skin->kartweight = atoi(value);
if (skin->kartweight < 1) if (skin->kartweight < 1)
skin->kartweight = 1; skin->kartweight = 1;
if (skin->kartweight > 9) if (skin->kartweight > 9)
skin->kartweight = 9; skin->kartweight = 9;
} }
// custom translation table // custom translation table
else if (fasticmp(stoken, "startcolor")) else if (!stricmp(stoken, "startcolor"))
{
skin->starttranscolor = atoi(value); skin->starttranscolor = atoi(value);
} else if (!stricmp(stoken, "prefcolor"))
else if (fasticmp(stoken, "prefcolor"))
{
skin->prefcolor = K_GetKartColorByName(value); skin->prefcolor = K_GetKartColorByName(value);
} else if (!stricmp(stoken, "highresscale"))
else if (fasticmp(stoken, "highresscale"))
{
skin->highresscale = FLOAT_TO_FIXED(atof(value)); skin->highresscale = FLOAT_TO_FIXED(atof(value));
}
else else
{ {
INT32 found = false; INT32 found = false;
sfxenum_t i; sfxenum_t i;
// copy name of sounds that are remapped // copy name of sounds that are remapped
// for this skin // for this skin
for (i = 0; i < sfx_skinsoundslot0; i++) for (i = 0; i < sfx_skinsoundslot0; i++)
{ {
const sfxinfo_t *sfx = &S_sfx[i]; if (!S_sfx[i].name)
if (!sfx->name)
continue; continue;
if (S_sfx[i].skinsound != -1
if (sfx->skinsound != -1 && !stricmp(S_sfx[i].name,
&& fasticmp(sfx->name, stoken + 2)) stoken + 2))
{ {
skin->soundsid[sfx->skinsound] = S_AddSoundFx(value+2, sfx->singularity, sfx->pitch, true); skin->soundsid[S_sfx[i].skinsound] =
S_AddSoundFx(value+2, S_sfx[i].singularity, S_sfx[i].pitch, true);
found = true; found = true;
} }
} }
if (!found) if (!found)
CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump# %d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump# %d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename);
} }
stoken = strtok(NULL, "\r\n= "); stoken = strtok(NULL, "\r\n= ");
} }
free(buf2); free(buf2);
lump++; // if no sprite defined use spirte just after this one lump++; // if no sprite defined use spirte just after this one
if (skin->sprite[0] == '\0') if (skin->sprite[0] == '\0')
{ {
const char *csprname = W_CheckNameForNumPwad(wadnum, lump); const char *csprname = W_CheckNameForNumPwad(wadnum, lump);
// skip to end of this skin's frames // skip to end of this skin's frames
lastlump = lump; lastlump = lump;
while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname,4)==0) while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname,4)==0)
lastlump++; lastlump++;
// allocate (or replace) sprite frames, and set spritedef // allocate (or replace) sprite frames, and set spritedef
R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump); R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump);
} }
@@ -724,15 +707,12 @@ void R_AddSkins(UINT16 wadnum, boolean local)
size_t name; size_t name;
boolean found = false; boolean found = false;
const char *sprname = skin->sprite; const char *sprname = skin->sprite;
for (name = 0;sprnames[name][0] != '\0';name++)
for (name = 0; sprnames[name][0] != '\0'; name++)
{
if (strncmp(sprnames[name], sprname, 4) == 0) if (strncmp(sprnames[name], sprname, 4) == 0)
{ {
skin->spritedef = sprites[name];
found = true; found = true;
skin->spritedef = sprites[name];
} }
}
// not found so make a new one // not found so make a new one
// go through the entire current wad looking for our sprite // go through the entire current wad looking for our sprite
@@ -746,7 +726,7 @@ void R_AddSkins(UINT16 wadnum, boolean local)
while ((lname = W_CheckNameForNumPwad(wadnum, localllump))) while ((lname = W_CheckNameForNumPwad(wadnum, localllump)))
{ {
// If this is a valid sprite... // If this is a valid sprite...
if (!memcmp(lname, sprname, 4) && lname[4] && lname[5] && lname[5] >= '0' && lname[5] <= '8') if (!memcmp(lname, sprname,4) && lname[4] && lname[5] && lname[5] >= '0' && lname[5] <= '8')
{ {
if (lstart == UINT16_MAX) if (lstart == UINT16_MAX)
lstart = localllump; lstart = localllump;
@@ -761,7 +741,6 @@ void R_AddSkins(UINT16 wadnum, boolean local)
} }
// If not already set do nothing // If not already set do nothing
} }
++localllump; ++localllump;
} }
@@ -781,6 +760,7 @@ void R_AddSkins(UINT16 wadnum, boolean local)
(local ? localskin_cons_t : skin_cons_t)[lnumskins].value = lnumskins; (local ? localskin_cons_t : skin_cons_t)[lnumskins].value = lnumskins;
(local ? localskin_cons_t : skin_cons_t)[lnumskins].strvalue = skin->name; (local ? localskin_cons_t : skin_cons_t)[lnumskins].strvalue = skin->name;
#endif #endif
if (!local) if (!local)
{ {
// Update the forceskin possiblevalues // Update the forceskin possiblevalues
+18 -23
View File
@@ -1095,12 +1095,9 @@ void S_StartSoundName(void *mo, const char *soundname)
// Search existing sounds... // Search existing sounds...
for (i = sfx_None + 1; i < NUMSFX; i++) for (i = sfx_None + 1; i < NUMSFX; i++)
{ {
const sfxinfo_t *sfx = &S_sfx[i]; if (!S_sfx[i].name)
if (!sfx->name)
continue; continue;
if (!stricmp(S_sfx[i].name, soundname))
if (fasticmp(sfx->name, soundname))
{ {
soundnum = i; soundnum = i;
break; break;
@@ -1113,7 +1110,6 @@ void S_StartSoundName(void *mo, const char *soundname)
{ {
if (newsounds[i] == 0) if (newsounds[i] == 0)
break; break;
if (!S_IdPlaying(newsounds[i])) if (!S_IdPlaying(newsounds[i]))
{ {
S_RemoveSoundFx(newsounds[i]); S_RemoveSoundFx(newsounds[i]);
@@ -1270,7 +1266,7 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp)
char *value; char *value;
char *textline; char *textline;
if (fasticmp(stoken, "lump")) if (!stricmp(stoken, "lump"))
{ {
value = strtok(NULL, " "); value = strtok(NULL, " ");
@@ -1345,24 +1341,24 @@ skip_lump:
for (textline = def->field; *textline; textline++)\ for (textline = def->field; *textline; textline++)\
if (*textline == '_') *textline = ' '; if (*textline == '_') *textline = ' ';
if (fasticmp(stoken, "usage")) if (!stricmp(stoken, "usage"))
{ {
ADDDEF(usage); ADDDEF(usage);
} }
else if (fasticmp(stoken, "source")) else if (!stricmp(stoken, "source"))
{ {
ADDDEF(source); ADDDEF(source);
} }
else if (fasticmp(stoken, "title")) else if (!stricmp(stoken, "title"))
{ {
def->use_info = true; def->use_info = true;
ADDDEF(title); ADDDEF(title);
} }
else if (fasticmp(stoken, "alttitle")) else if (!stricmp(stoken, "alttitle"))
{ {
ADDDEF(alttitle); ADDDEF(alttitle);
} }
else if (fasticmp(stoken, "authors")) else if (!stricmp(stoken, "authors"))
{ {
ADDDEF(authors); ADDDEF(authors);
} }
@@ -1483,8 +1479,7 @@ musicdef_t *S_FindMusicCredit(const char *musname)
if (hash != def->hash) if (hash != def->hash)
continue; continue;
if (stricmp(def->name, musname))
if (!fasticmp(def->name, musname))
continue; continue;
return def; return def;
@@ -1833,7 +1828,7 @@ void S_StopMusic(void)
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music || demo.title) // SRB2Kart: Demos don't interrupt title screen music
return; return;
mapmusic.resume = (cv_birdmusic.value && fasticmp(music.name, mapmusic.name)) ? I_GetSongPosition() : 0; mapmusic.resume = (cv_birdmusic.value && (strcasecmp(music.name, mapmusic.name) == 0)) ? I_GetSongPosition() : 0;
S_SetKeepMusResume(); S_SetKeepMusResume();
@@ -1939,7 +1934,7 @@ static const char *musicexception_list[] = {
// check if the current music is smth we dont want to keep (vote music, etc) // check if the current music is smth we dont want to keep (vote music, etc)
static boolean S_CheckMusicException(void) static boolean S_CheckMusicException(void)
{ {
if (!fasticmp(music.name, mapmusic.name)) if (stricmp(music.name, mapmusic.name))
return true; return true;
// dumb hack but dont keepmusic music that is supposed to reset // dumb hack but dont keepmusic music that is supposed to reset
@@ -1949,7 +1944,7 @@ static boolean S_CheckMusicException(void)
// in case somehow the mapmusic was replaced with smth we dont want to keep // in case somehow the mapmusic was replaced with smth we dont want to keep
for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++)
{ {
if (fasticmp(music.name, musicexception_list[i]) || fasticmp(checkmusic, musicexception_list[i])) if (!stricmp(music.name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i]))
{ {
return true; return true;
} }
@@ -1969,7 +1964,7 @@ static void S_SetKeepMusResume(void)
{ {
keepmusic.resume = 0; keepmusic.resume = 0;
if (fasticmp(music.name, mapmusic.name)) if (strcasecmp(music.name, mapmusic.name) == 0)
{ {
keepmusic.resume = I_GetSongPosition(); keepmusic.resume = I_GetSongPosition();
} }
@@ -2035,12 +2030,12 @@ static boolean S_SkipIntroMusic(void)
return false; return false;
// check if menu music is playing, otherwise it may continue playing // check if menu music is playing, otherwise it may continue playing
if (fasticmp(music.name, "titles")) if (!stricmp(music.name, "titles"))
return false; return false;
char *maptitle = G_BuildMapTitle(gamemap); // Zzz... char *maptitle = G_BuildMapTitle(gamemap); // Zzz...
if (maptitle && fasticmp(maptitle, "Wandering Falls")) // wandering balls changes its song when the race starts Zzz... if (maptitle && !stricmp(maptitle, "Wandering Falls")) // wandering balls changes its song when the race starts Zzz...
{ {
Z_Free(maptitle); Z_Free(maptitle);
return false; return false;
@@ -2153,19 +2148,19 @@ static void Command_Tunes_f(void)
tunenum = (UINT16)atoi(tunearg); tunenum = (UINT16)atoi(tunearg);
track = 0; track = 0;
if (fasticmp(tunearg, "-show")) if (!strcasecmp(tunearg, "-show"))
{ {
CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"), CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"),
mapmusic.name, (mapmusic.flags & MUSIC_TRACKMASK)); mapmusic.name, (mapmusic.flags & MUSIC_TRACKMASK));
return; return;
} }
if (fasticmp(tunearg, "-none")) if (!strcasecmp(tunearg, "-none"))
{ {
S_StopMusic(); S_StopMusic();
return; return;
} }
else if (fasticmp(tunearg, "-default")) else if (!strcasecmp(tunearg, "-default"))
{ {
tunearg = mapheaderinfo[gamemap-1]->musname; tunearg = mapheaderinfo[gamemap-1]->musname;
track = mapheaderinfo[gamemap-1]->mustrack; track = mapheaderinfo[gamemap-1]->mustrack;
+3
View File
@@ -35,6 +35,9 @@
#define _CREATE_DLL_ // necessary for Unix AND Windows #define _CREATE_DLL_ // necessary for Unix AND Windows
#define GETFUNC(func) \
else if (0 == strcmp(#func, funcName)) \
funcPointer = &func \
// //
// //
/** \brief The *hwSym function /** \brief The *hwSym function
+1 -2
View File
@@ -2288,9 +2288,8 @@ char *I_GetUserName(void)
} }
if (!fastcmp(username, "")) if (strcmp(username, "") != 0)
return username; return username;
return NULL; // dummy for platform independent version return NULL; // dummy for platform independent version
} }
+6 -6
View File
@@ -905,7 +905,7 @@ static void Impl_HandleControllerAddedEvent(SDL_Event evt)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
if (fastcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value) if (!strcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value)
cv_usejoystick[i].value = 0; cv_usejoystick[i].value = 0;
else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
&& cv_usejoystick[i].value) // update the cvar ONLY if a device exists && cv_usejoystick[i].value) // update the cvar ONLY if a device exists
@@ -977,7 +977,7 @@ static void Impl_HandleControllerRemovedEvent(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
if (fastcmp(cv_usejoystick[i].string, "0")) if (!strcmp(cv_usejoystick[i].string, "0"))
{ {
cv_usejoystick[i].value = 0; cv_usejoystick[i].value = 0;
} }
@@ -1785,11 +1785,11 @@ void I_StartupGraphics(void)
if (rendermode == render_none) if (rendermode == render_none)
{ {
if (fasticmp(word, "software")) if (strcasecmp(word, "software") == 0)
{ {
rendermode = render_soft; rendermode = render_soft;
} }
else if (fasticmp(word, "opengl")) else if (strcasecmp(word, "opengl") == 0)
{ {
rendermode = render_opengl; rendermode = render_opengl;
} }
@@ -1802,7 +1802,7 @@ void I_StartupGraphics(void)
if (!msaa_set) if (!msaa_set)
{ {
if (fasticmp(word, "msaa")) if (strcasecmp(word, "msaa") == 0)
{ {
const char *nextword = strtok(NULL, " \n"); const char *nextword = strtok(NULL, " \n");
@@ -1819,7 +1819,7 @@ void I_StartupGraphics(void)
if (!a2c_set) if (!a2c_set)
{ {
if (fasticmp(word, "a2c")) if (strcasecmp(word, "a2c") == 0)
{ {
a2c = true; a2c = true;
CONS_Printf("Using a2c because it was specified to be used earlier\n"); CONS_Printf("Using a2c because it was specified to be used earlier\n");
+3 -3
View File
@@ -266,13 +266,13 @@ void I_UpdateSound(void)
// this is as fast as I can possibly make it. // this is as fast as I can possibly make it.
// sorry. more asm needed. // sorry. more asm needed.
static Mix_Chunk *ds2chunk(void *stream) static Mix_Chunk *ds2chunk(const void *stream)
{ {
UINT16 ver, freq; UINT16 ver, freq;
UINT32 samples, i, newsamples; UINT32 samples, i, newsamples;
UINT8 *sound; UINT8 *sound;
SINT8 *s; const SINT8 *s;
INT16 *d; INT16 *d;
INT16 o; INT16 o;
fixed_t step, frac; fixed_t step, frac;
@@ -325,7 +325,7 @@ static Mix_Chunk *ds2chunk(void *stream)
sound = Z_Malloc(newsamples<<2, PU_SOUND, NULL); // samples * frequency shift * bytes per sample * channels sound = Z_Malloc(newsamples<<2, PU_SOUND, NULL); // samples * frequency shift * bytes per sample * channels
s = (SINT8 *)stream; s = (const SINT8 *)stream;
d = (INT16 *)sound; d = (INT16 *)sound;
i = 0; i = 0;
+2 -2
View File
@@ -170,8 +170,8 @@ boolean OglSdlSurface(INT32 w, INT32 h)
} }
} }
if (fastcmp((const char*)gl_renderer, "GDI Generic") && if (strcmp((const char*)gl_renderer, "GDI Generic") == 0 &&
fastcmp((const char*)gl_version, "1.1.0")) strcmp((const char*)gl_version, "1.1.0") == 0)
{ {
// Oh no... Windows gave us the GDI Generic rasterizer, so something is wrong... // Oh no... Windows gave us the GDI Generic rasterizer, so something is wrong...
// The game will crash later on when unsupported OpenGL commands are encountered. // The game will crash later on when unsupported OpenGL commands are encountered.
+3 -2
View File
@@ -23,6 +23,7 @@
#include "r_main.h" #include "r_main.h"
#include "r_fps.h" #include "r_fps.h"
#include "console.h" #include "console.h"
#include "i_video.h" // rendermode #include "i_video.h" // rendermode
#include "z_zone.h" #include "z_zone.h"
#include "m_misc.h" #include "m_misc.h"
@@ -133,7 +134,7 @@ static boolean InitCube(void)
if (!loaded_config) if (!loaded_config)
return false; return false;
#define diffcons(cv) (!fastcmp(cv.string, cv.defaultvalue)) #define diffcons(cv) (strcmp(cv.string, cv.defaultvalue))
#define diffconsgamma(cv) (cv.value != 0) #define diffconsgamma(cv) (cv.value != 0)
#define diffconssat(cv) (cv.value != 10) #define diffconssat(cv) (cv.value != 10)
@@ -595,7 +596,7 @@ void V_ResetPaletteCVars(void)
if (!loaded_config) if (!loaded_config)
return; return;
#define diffcons(cv) (!fastcmp(cv.string, cv.defaultvalue)) #define diffcons(cv) (strcmp(cv.string, cv.defaultvalue))
if diffcons(cv_palette) if diffcons(cv_palette)
CV_StealthSetValue(&cv_palette, atoi(cv_palette.defaultvalue)); CV_StealthSetValue(&cv_palette, atoi(cv_palette.defaultvalue));
if diffcons(cv_palettenum) if diffcons(cv_palettenum)
+5 -5
View File
@@ -375,11 +375,11 @@ static restype_t ResourceFileDetect(const char* filename)
{ {
size_t len = strlen(filename) - 4; size_t len = strlen(filename) - 4;
if (fasticmp(&filename[len], ".pk3")) if (!stricmp(&filename[len], ".pk3"))
return RET_PK3; return RET_PK3;
if (fasticmp(&filename[len], ".soc")) if (!stricmp(&filename[len], ".soc"))
return RET_SOC; return RET_SOC;
if (fasticmp(&filename[len], ".lua")) if (!stricmp(&filename[len], ".lua"))
return RET_LUA; return RET_LUA;
return RET_WAD; return RET_WAD;
@@ -1130,7 +1130,7 @@ UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump)
{ {
if (lump_p->longnamelength == namelen if (lump_p->longnamelength == namelen
&& lump_p->hash.longname == hash && lump_p->hash.longname == hash
&& fasticmp(lump_p->longname, name)) && !stricmp(lump_p->longname, name))
return i; return i;
} }
} }
@@ -1230,7 +1230,7 @@ static lumpnum_t CheckLumpInCache(const char *name, boolean longname)
for (INT32 i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--) for (INT32 i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--)
{ {
if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].hash == hash if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].hash == hash
&& fasticmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name)) && stricmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name) == 0)
{ {
lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1); lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1);
return lumpnumcache[lumpnumcacheindex].lumpnum; return lumpnumcache[lumpnumcacheindex].lumpnum;