diff --git a/src/byteptr.h b/src/byteptr.h index 058e81b25..85141c21c 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -1,7 +1,8 @@ -// SONIC ROBO BLAST 2 +// SONIC ROBO BLAST 2 KART //----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2025 by Sonic Team Junior. +// Copyright (C) 2025 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -24,6 +25,7 @@ extern "C" { // // 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 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) @@ -36,25 +38,25 @@ extern "C" { // what is this? #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 READSINT8(p) ({ SINT8 *p_tmp = (SINT8 *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; *(void**)(&(p)) = (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 READUINT16(p) ({ UINT16 *p_tmp = (UINT16 *)p; UINT16 b; memcpy(&b, p, sizeof( UINT16)); p_tmp++; *(void**)(&(p)) = (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 READUINT32(p) ({ UINT32 *p_tmp = (UINT32 *)p; UINT32 b; memcpy(&b, p, sizeof( UINT32)); p_tmp++; *(void**)(&(p)) = (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 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 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 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) ({ 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) ({ 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) ({ 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) ({ 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) ({ 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) ({ 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) ({ 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) ({ 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 -#define READUINT8(p) ((UINT8*)(*(void**)(&(p)) = (void*)&((UINT8*)(p))[1]))[-1] -#define READSINT8(p) ((SINT8*)(*(void**)(&(p)) = (void*)&((SINT8*)(p))[1]))[-1] -#define READINT16(p) ((INT16*)(*(void**)(&(p)) = (void*)&((INT16*)(p))[1]))[-1] -#define READUINT16(p) ((UINT16*)(*(void**)(&(p)) = (void*)&((UINT16*)(p))[1]))[-1] -#define READINT32(p) ((INT32*)(*(void**)(&(p)) = (void*)&((INT32*)(p))[1]))[-1] -#define READUINT32(p) ((UINT32*)(*(void**)(&(p)) = (void*)&((UINT32*)(p))[1]))[-1] -#define READCHAR(p) ((char*)(*(void**)(&(p)) = (void*)&((char*)(p))[1]))[-1] -#define READFIXED(p) ((fixed_t*)(*(void**)(&(p)) = (void*)&((fixed_t*)(p))[1]))[-1] -#define READANGLE(p) ((angle_t*)(*(void**)(&(p)) = (void*)&((angle_t*)(p))[1]))[-1] +#define READUINT8(p) ((const UINT8*) (*(const void**)(&(p)) = (const void*)&((const UINT8*) (p))[1]))[-1] +#define READSINT8(p) ((const SINT8*) (*(const void**)(&(p)) = (const void*)&((const SINT8*) (p))[1]))[-1] +#define READINT16(p) ((const INT16*) (*(const void**)(&(p)) = (const void*)&((const INT16*) (p))[1]))[-1] +#define READUINT16(p) ((const UINT16*) (*(const void**)(&(p)) = (const void*)&((const UINT16*) (p))[1]))[-1] +#define READINT32(p) ((const INT32*) (*(const void**)(&(p)) = (const void*)&((const INT32*) (p))[1]))[-1] +#define READUINT32(p) ((const UINT32*) (*(const void**)(&(p)) = (const void*)&((const UINT32*) (p))[1]))[-1] +#define READCHAR(p) ((const char*) (*(const void**)(&(p)) = (const void*)&((const char*) (p))[1]))[-1] +#define READFIXED(p) ((const fixed_t*)(*(const void**)(&(p)) = (const void*)&((const fixed_t*)(p))[1]))[-1] +#define READANGLE(p) ((const angle_t*)(*(const void**)(&(p)) = (const void*)&((const angle_t*)(p))[1]))[-1] #endif #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]; } -#define READUINT8(p) ((UINT8*)(p = (void*)&((UINT8*)p)[1]))[-1] -#define READSINT8(p) ((SINT8*)(p = (void*)&((SINT8*)p)[1]))[-1] -#define READINT16(p) readshort(&((INT16*)(p = (void*)&((INT16*)p)[1]))[-1]) -#define READUINT16(p) readushort(&((UINT16*)(p = (void*)&((UINT16*)p)[1]))[-1]) -#define READINT32(p) readlong(&((INT32*)(p = (void*)&((INT32*)p)[1]))[-1]) -#define READUINT32(p) readulong(&((UINT32*)(p = (void*)&((UINT32*)p)[1])) -#define READCHAR(p) ((char*)(p = (void*)&((char*)p)[1]))[-1] -#define READFIXED(p) readlong(&((fixed_t*)(p = (void*)&((fixed_t*)p)[1]))[-1]) -#define READANGLE(p) readulong(&((angle_t*)(p = (void*)&((angle_t*)p)[1]))[-1]) +#define READUINT8(p) ((const UINT8*)(p = (const void*)&((const UINT8*)p)[1]))[-1] +#define READSINT8(p) ((const SINT8*)(p = (const void*)&((const SINT8*)p)[1]))[-1] +#define READINT16(p) readshort(&((const INT16*)(p = (const void*)&((const INT16*)p)[1]))[-1]) +#define READUINT16(p) readushort(&((const UINT16*)(p = (const void*)&((const UINT16*)p)[1]))[-1]) +#define READINT32(p) readlong(&((const INT32*)(p = (const void*)&((const INT32*)p)[1]))[-1]) +#define READUINT32(p) readulong(&((const UINT32*)(p = (const void*)&((const UINT32*)p)[1])) +#define READCHAR(p) ((const char*)(p = (const void*)&((const char*)p)[1]))[-1] +#define READFIXED(p) readlong(&((const fixed_t*)(p = (const void*)&((const fixed_t*)p)[1]))[-1]) +#define READANGLE(p) readulong(&((const angle_t*)(p = (const void*)&((const angle_t*)p)[1]))[-1]) #endif //SRB2_BIG_ENDIAN #define WRITESTRINGN(p, s, n) do { \ diff --git a/src/command.c b/src/command.c index 8b46f95d1..faf978e3e 100644 --- a/src/command.c +++ b/src/command.c @@ -281,7 +281,7 @@ char *com_argv[MAX_ARGS]; static const char *com_null_string = ""; 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. */ @@ -1500,11 +1500,11 @@ badinput: static boolean serverloading = false; -static void Got_NetVar(UINT8 **p, INT32 playernum) +static void Got_NetVar(const UINT8 **p, INT32 playernum) { consvar_t *cvar; UINT16 netid; - char *svalue; + const char *svalue; UINT8 stealth = false; if (playernum != serverplayer && !IsPlayerAdmin(playernum) && !serverloading) @@ -1518,9 +1518,10 @@ static void Got_NetVar(UINT8 **p, INT32 playernum) } return; } + netid = READUINT16(*p); cvar = CV_FindNetVar(netid); - svalue = (char *)*p; + svalue = (const char *)*p; SKIPSTRING(*p); stealth = READUINT8(*p); @@ -1576,8 +1577,9 @@ void CV_SaveNetVars(UINT8 **p, boolean isdemorecording) WRITEUINT16(count_p, count); } -void CV_LoadNetVars(UINT8 **p) +size_t CV_LoadNetVars(const UINT8 *bufstart) { + const UINT8 *p = bufstart; consvar_t *cvar; UINT16 count; @@ -1588,11 +1590,13 @@ void CV_LoadNetVars(UINT8 **p) if (cvar->flags & CV_NETVAR) Setvalue(cvar, cvar->defaultvalue, true); - count = READUINT16(*p); + count = READUINT16(p); while (count--) - Got_NetVar(p, 0); + Got_NetVar(&p, 0); serverloading = false; + + return p - bufstart; } static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth); diff --git a/src/command.h b/src/command.h index 6d1944f9a..7074158e1 100644 --- a/src/command.h +++ b/src/command.h @@ -182,7 +182,7 @@ void CV_SaveVariables(FILE *f); // load/save gamesate (load and save option and for network join in game) 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 void CV_ResetCheatNetVars(void); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1d94946dc..303cba79b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -324,9 +324,9 @@ static inline tic_t ExpandTics(INT32 low, tic_t basetic) // 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 if (id >= MAXNETXCMD) @@ -472,12 +472,12 @@ static void ExtraDataTicker(void) { if (playeringame[i] || i == 0) { - UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i); + const UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i); if (bufferstart) { - UINT8 *curpos = bufferstart; - UINT8 *bufferend = &curpos[curpos[0]+1]; + const UINT8 *curpos = bufferstart; + const UINT8 *bufferend = &curpos[curpos[0]+1]; curpos++; while (curpos < bufferend) @@ -3834,7 +3834,7 @@ static void Command_Kick(void) 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; char buf[3 + MAX_REASONLENGTH]; @@ -4224,8 +4224,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}; -static void Got_AddPlayer(UINT8 **p, INT32 playernum); -static void Got_RemovePlayer(UINT8 **p, INT32 playernum); +static void Got_AddPlayer(const UINT8 **p, INT32 playernum); +static void Got_RemovePlayer(const UINT8 **p, INT32 playernum); static void Joinable_OnChange(void) { @@ -4477,7 +4477,7 @@ static inline void SV_AddNode(INT32 node) } // Xcmd XD_ADDPLAYER -static void Got_AddPlayer(UINT8 **p, INT32 playernum) +static void Got_AddPlayer(const UINT8 **p, INT32 playernum) { INT16 node, newplayernum; UINT8 splitscreenplayer = 0; @@ -4564,7 +4564,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) } // Xcmd XD_REMOVEPLAYER -static void Got_RemovePlayer(UINT8 **p, INT32 playernum) +static void Got_RemovePlayer(const UINT8 **p, INT32 playernum) { SINT8 pnum, reason; @@ -5293,7 +5293,7 @@ static void PT_ServerCFG(SINT8 node) scp = netbuffer->u.servercfg.varlengthinputs; 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? /// Shouldn't them be downloaded even at intermission time? diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 4b5c3702a..5919b54ce 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -606,7 +606,7 @@ extern consvar_t cv_serverinfoscreen; void D_ClientServerInit(void); // 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); #define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1 void SendKick(UINT8 playernum, UINT8 msg); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 538d98781..9e9fa8fa0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -68,22 +68,22 @@ // protos // ------ -static void Got_NameAndColor(UINT8 **cp, INT32 playernum); -static void Got_WeaponPref(UINT8 **cp, INT32 playernum); -static void Got_Mapcmd(UINT8 **cp, INT32 playernum); -static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum); -static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum); -static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum); -static void Got_PickVotecmd(UINT8 **cp, INT32 playernum); -static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum); -static void Got_Addfilecmd(UINT8 **cp, INT32 playernum); -static void Got_Pause(UINT8 **cp, INT32 playernum); -static void Got_Respawn(UINT8 **cp, INT32 playernum); -static void Got_RandomSeed(UINT8 **cp, INT32 playernum); -static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum); -static void Got_Teamchange(UINT8 **cp, INT32 playernum); -static void Got_Clearscores(UINT8 **cp, INT32 playernum); -static void Got_DiscordInfo(UINT8 **cp, INT32 playernum); +static void Got_NameAndColor(const UINT8 **cp, INT32 playernum); +static void Got_WeaponPref(const UINT8 **cp, INT32 playernum); +static void Got_Mapcmd(const UINT8 **cp, INT32 playernum); +static void Got_ExitLevelcmd(const UINT8 **cp, INT32 playernum); +static void Got_SetupVotecmd(const UINT8 **cp, INT32 playernum); +static void Got_ModifyVotecmd(const UINT8 **cp, INT32 playernum); +static void Got_PickVotecmd(const UINT8 **cp, INT32 playernum); +static void Got_RequestAddfilecmd(const UINT8 **cp, INT32 playernum); +static void Got_Addfilecmd(const UINT8 **cp, INT32 playernum); +static void Got_Pause(const UINT8 **cp, INT32 playernum); +static void Got_Respawn(const UINT8 **cp, INT32 playernum); +static void Got_RandomSeed(const UINT8 **cp, INT32 playernum); +static void Got_RunSOCcmd(const UINT8 **cp, INT32 playernum); +static void Got_Teamchange(const UINT8 **cp, INT32 playernum); +static void Got_Clearscores(const UINT8 **cp, INT32 playernum); +static void Got_DiscordInfo(const UINT8 **cp, INT32 playernum); static void PointLimit_OnChange(void); static void TimeLimit_OnChange(void); @@ -178,13 +178,13 @@ static void Command_Clearscores_f(void); // Remote Administration static void Command_Changepassword_f(void); static void Command_Login_f(void); -static void Got_Login(UINT8 **cp, INT32 playernum); -static void Got_Verification(UINT8 **cp, INT32 playernum); -static void Got_Removal(UINT8 **cp, INT32 playernum); +static void Got_Login(const UINT8 **cp, INT32 playernum); +static void Got_Verification(const UINT8 **cp, INT32 playernum); +static void Got_Removal(const UINT8 **cp, INT32 playernum); static void Command_Verify_f(void); static void Command_RemoveAdmin_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_ShowTime_f(void); @@ -1911,7 +1911,7 @@ static void SendNameAndColor4(void) 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]; char name[MAXPLAYERNAME+1]; @@ -2039,15 +2039,17 @@ void SendWeaponPref4(void) 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); - players[playernum].pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE); + player->pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE); if (prefs & 1) - players[playernum].pflags |= PF_FLIPCAM; + player->pflags |= PF_FLIPCAM; if (prefs & 2) - players[playernum].pflags |= PF_ANALOGMODE; + player->pflags |= PF_ANALOGMODE; } void D_SendPlayerConfig(void) @@ -2846,7 +2848,7 @@ static void Command_Map_f(void) * ::serverplayer or ::adminplayer. * \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]; UINT8 flags; @@ -2965,7 +2967,7 @@ static void Command_Pause(void) 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; const char *playername; @@ -3077,7 +3079,7 @@ static void Command_Respawn(void) 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); @@ -3112,7 +3114,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum) * \param playernum Player responsible for the message. Must be ::serverplayer. * \author Graue */ -static void Got_RandomSeed(UINT8 **cp, INT32 playernum) +static void Got_RandomSeed(const UINT8 **cp, INT32 playernum) { UINT32 seed; @@ -3147,7 +3149,7 @@ static void Command_Clearscores_f(void) * \sa XD_CLEARSCORES, Command_Clearscores_f * \author SSNTails */ -static void Got_Clearscores(UINT8 **cp, INT32 playernum) +static void Got_Clearscores(const UINT8 **cp, INT32 playernum) { INT32 i; @@ -3664,7 +3666,7 @@ static void Command_ServerTeamChange_f(void) } //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; boolean error = false, wasspectator = false; @@ -4021,7 +4023,7 @@ static void Command_Login_f(void) #endif } -static void Got_Login(UINT8 **cp, INT32 playernum) +static void Got_Login(const UINT8 **cp, INT32 playernum) { #ifdef NOMD5 // If we have no MD5 support then completely disable XD_LOGIN responses for security. @@ -4131,7 +4133,7 @@ static void Command_Verify_f(void) 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); @@ -4183,7 +4185,7 @@ static void Command_RemoveAdmin_f(void) 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); @@ -4259,7 +4261,7 @@ static void Command_MotD_f(void) 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); INT32 i; @@ -4326,7 +4328,7 @@ static void Command_RunSOC(void) 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]; filestatus_t ncs = FS_NOTCHECKED; @@ -4604,7 +4606,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]; filestatus_t ncs = FS_NOTCHECKED; @@ -4663,7 +4665,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) 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]; filestatus_t ncs = FS_NOTCHECKED; @@ -5463,7 +5465,7 @@ static void Command_ExitLevel_f(void) SendNetXCmd(XD_EXITLEVEL, NULL, 0); } -static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum) +static void Got_ExitLevelcmd(const UINT8 **cp, INT32 playernum) { (void)cp; @@ -5484,7 +5486,7 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum) G_ExitLevel(); } -static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum) +static void Got_SetupVotecmd(const UINT8 **cp, INT32 playernum) { INT32 i; UINT8 gt, secondgt; @@ -5536,7 +5538,7 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum) Y_StartVote(); } -static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum) +static void Got_ModifyVotecmd(const UINT8 **cp, INT32 playernum) { SINT8 voted = READSINT8(*cp); UINT8 p = READUINT8(*cp); @@ -5545,7 +5547,7 @@ static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum) 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 level = READSINT8(*cp); @@ -6185,7 +6187,7 @@ static void KartEliminateLast_OnChange(void) P_CheckRacers(); } -void Got_DiscordInfo(UINT8 **p, INT32 playernum) +void Got_DiscordInfo(const UINT8 **p, INT32 playernum) { if (playernum != serverplayer /*&& !IsPlayerAdmin(playernum)*/) { diff --git a/src/g_demo.c b/src/g_demo.c index bd3905160..f5268ad02 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2815,7 +2815,7 @@ void G_DoPlayDemo(char *defdemoname) } // net var data - CV_LoadNetVars(&demobuf.p); + demobuf.p += CV_LoadNetVars(demobuf.p); // Sigh ... it's an empty demo. if (*demobuf.p == DEMOMARKER) @@ -2853,7 +2853,7 @@ void G_DoPlayDemo(char *defdemoname) #endif // net var data - CV_LoadNetVars(&demobuf.p); + demobuf.p += CV_LoadNetVars(demobuf.p); // Sigh ... it's an empty demo. if (*demobuf.p == DEMOMARKER) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 093003e18..3ed978e95 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -280,7 +280,7 @@ static void Command_Say_f(void); static void Command_Sayto_f(void); static void Command_Sayteam_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) { @@ -879,11 +879,12 @@ const char *HU_SkinColorToConsoleColor(skincolors_t color) * \sa DoSayCommand * \author Graue */ -static void Got_Saycmd(UINT8 **p, INT32 playernum) +static void Got_Saycmd(const UINT8 **p, INT32 playernum) { SINT8 target; UINT8 flags; const char *dispname; + char buf[HU_MAXMSGLEN + 1]; char *msg; boolean action = false; char *ptr; @@ -893,8 +894,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) target = READSINT8(*p); flags = READUINT8(*p); - msg = (char *)*p; - SKIPSTRINGL(*p, HU_MAXMSGLEN + 1); + msg = buf; + READSTRINGL(*p, msg, HU_MAXMSGLEN + 1); if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum))) { diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 91bf6ea4f..d4ae2bb50 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -36,7 +36,7 @@ static void clear_lua_stack(void) lua_settop(gL, 0); // clear stack } -void Got_Luacmd(UINT8 **cp, INT32 playernum) +void Got_Luacmd(const UINT8 **cp, INT32 playernum) { UINT8 i, argc, flags; const char *argv[256]; diff --git a/src/lua_script.h b/src/lua_script.h index c52f8394b..6dd9be685 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -76,7 +76,7 @@ void LUA_InvalidatePlayer(player_t *player); void LUA_Archive(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(void *cvar); // lua_consolelib.c int Lua_optoption(lua_State *L, int narg, int def, int list_ref); int Lua_CreateFieldTable(lua_State *L, const char *const lst[]); diff --git a/src/p_saveg.c b/src/p_saveg.c index 756c413b1..46d52917a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3772,7 +3772,7 @@ boolean P_LoadGame(savebuffer_t *save, INT16 mapoverride) boolean P_LoadNetGame(savebuffer_t *save, boolean reloading) { - CV_LoadNetVars(&save->p); + save->p += CV_LoadNetVars(save->p); if (!P_NetUnArchiveMisc(save, reloading)) return false; diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 59cffed4a..3239da9b2 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -266,13 +266,13 @@ void I_UpdateSound(void) // this is as fast as I can possibly make it. // sorry. more asm needed. -static Mix_Chunk *ds2chunk(void *stream) +static Mix_Chunk *ds2chunk(const void *stream) { UINT16 ver, freq; UINT32 samples, i, newsamples; UINT8 *sound; - SINT8 *s; + const SINT8 *s; INT16 *d; INT16 o; 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 - s = (SINT8 *)stream; + s = (const SINT8 *)stream; d = (INT16 *)sound; i = 0;