From 2ec2873b3ed1aff4f27481593093cb6501c3da26 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 1 Aug 2022 07:46:35 -0700 Subject: [PATCH] Fix compiler warnings --- src/d_netcmd.c | 2 +- src/i_tcp.c | 110 ++++++++++++++++++++++++------------------------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1675b29de..2a28a454b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5339,7 +5339,7 @@ static void Got_Automatecmd(UINT8 **cp, INT32 playernum) if (server || consoleplayer == playernum) { - if (command == NULL || strlen(command) == 0) + if (command[0] == '\0') { CONS_Printf( "Removed the %s automate command.\n", diff --git a/src/i_tcp.c b/src/i_tcp.c index 7b3db6f9d..46af0fdf1 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1555,6 +1555,61 @@ static boolean SOCK_Ban(INT32 node) #endif } +static boolean SOCK_SetBanUsername(const char *username) +{ +#ifdef NONET + (void)username; + return false; +#else + if (username == NULL || strlen(username) == 0) + { + username = "Direct IP ban"; + } + + if (banned[numbans - 1].username) + { + Z_Free(banned[numbans - 1].username); + banned[numbans - 1].username = NULL; + } + + banned[numbans - 1].username = Z_StrDup(username); + return true; +#endif +} + +static boolean SOCK_SetBanReason(const char *reason) +{ +#ifdef NONET + (void)reason; + return false; +#else + if (reason == NULL || strlen(reason) == 0) + { + reason = "No reason given"; + } + + if (banned[numbans - 1].reason) + { + Z_Free(banned[numbans - 1].reason); + banned[numbans - 1].reason = NULL; + } + + banned[numbans - 1].reason = Z_StrDup(reason); + return true; +#endif +} + +static boolean SOCK_SetUnbanTime(time_t timestamp) +{ +#ifdef NONET + (void)reason; + return false; +#else + banned[numbans - 1].timestamp = timestamp; + return true; +#endif +} + static boolean SOCK_SetBanAddress(const char *address, const char *mask) { #ifdef NONET @@ -1619,61 +1674,6 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask) #endif } -static boolean SOCK_SetBanUsername(const char *username) -{ -#ifdef NONET - (void)username; - return false; -#else - if (username == NULL || strlen(username) == 0) - { - username = "Direct IP ban"; - } - - if (banned[numbans - 1].username) - { - Z_Free(banned[numbans - 1].username); - banned[numbans - 1].username = NULL; - } - - banned[numbans - 1].username = Z_StrDup(username); - return true; -#endif -} - -static boolean SOCK_SetBanReason(const char *reason) -{ -#ifdef NONET - (void)reason; - return false; -#else - if (reason == NULL || strlen(reason) == 0) - { - reason = "No reason given"; - } - - if (banned[numbans - 1].reason) - { - Z_Free(banned[numbans - 1].reason); - banned[numbans - 1].reason = NULL; - } - - banned[numbans - 1].reason = Z_StrDup(reason); - return true; -#endif -} - -static boolean SOCK_SetUnbanTime(time_t timestamp) -{ -#ifdef NONET - (void)reason; - return false; -#else - banned[numbans - 1].timestamp = timestamp; - return true; -#endif -} - static void SOCK_ClearBans(void) { numbans = 0;