From 416637e970e7119a13a27b63ba966f6eacc09c5e Mon Sep 17 00:00:00 2001 From: Sh1ft0x0EF Date: Wed, 26 Apr 2017 00:51:29 +0000 Subject: [PATCH] Const-like defines -> consts --- rehlds/dedicated/src/sys_linux.cpp | 2 +- rehlds/engine/APIProxy.h | 2 +- rehlds/engine/cdll_int.h | 2 +- rehlds/engine/client.h | 4 +- rehlds/engine/cmd.h | 6 +-- rehlds/engine/cmodel.h | 2 +- rehlds/engine/common.cpp | 2 +- rehlds/engine/consistency.h | 2 +- rehlds/engine/cvar.h | 4 +- rehlds/engine/decal.h | 5 ++- rehlds/engine/delta.h | 4 +- rehlds/engine/delta_jit.h | 4 +- rehlds/engine/filter.h | 8 ++-- rehlds/engine/host.h | 2 +- rehlds/engine/info.h | 10 ++--- rehlds/engine/inst_baseline.h | 2 +- rehlds/engine/l_studio.h | 3 +- rehlds/engine/net.h | 69 +++++++++++++++--------------- rehlds/engine/net_ws.h | 12 +++--- rehlds/engine/pr_cmds.cpp | 12 +++--- rehlds/engine/server.h | 14 +++--- rehlds/engine/sound.h | 2 +- rehlds/engine/sv_main.cpp | 4 +- rehlds/engine/sv_move.h | 2 +- rehlds/engine/sv_user.h | 2 +- rehlds/engine/sys_dll.h | 2 +- rehlds/engine/sys_dll2.h | 3 +- rehlds/engine/textures.h | 2 +- rehlds/engine/tmessage.h | 20 ++++----- rehlds/engine/wad.h | 2 +- rehlds/engine/zone.cpp | 8 ++-- rehlds/hookers/main.cpp | 8 ++-- rehlds/hookers/memory.h | 2 +- rehlds/hookers/rehlds_debug.cpp | 2 +- rehlds/rehlds/hookchains_impl.h | 2 +- rehlds/testsuite/funccalls.h | 4 +- rehlds/testsuite/player.h | 4 +- rehlds/testsuite/testsuite.h | 4 +- 38 files changed, 125 insertions(+), 119 deletions(-) diff --git a/rehlds/dedicated/src/sys_linux.cpp b/rehlds/dedicated/src/sys_linux.cpp index b266018..99b1fe8 100644 --- a/rehlds/dedicated/src/sys_linux.cpp +++ b/rehlds/dedicated/src/sys_linux.cpp @@ -199,7 +199,7 @@ void CSys::Printf(char *fmt, ...) ConsoleOutput(szText); } -#define MAX_LINUX_CMDLINE 2048 +const int MAX_LINUX_CMDLINE = 2048; static char linuxCmdline[ MAX_LINUX_CMDLINE ]; void BuildCmdLine(int argc, char **argv) diff --git a/rehlds/engine/APIProxy.h b/rehlds/engine/APIProxy.h index d4d1314..af9048a 100644 --- a/rehlds/engine/APIProxy.h +++ b/rehlds/engine/APIProxy.h @@ -8,7 +8,7 @@ #include "enums.h" #endif -#define MAX_ALIAS_NAME 32 +const int MAX_ALIAS_NAME = 32; typedef struct cmdalias_s { diff --git a/rehlds/engine/cdll_int.h b/rehlds/engine/cdll_int.h index 76958a1..dd7eec6 100644 --- a/rehlds/engine/cdll_int.h +++ b/rehlds/engine/cdll_int.h @@ -102,7 +102,7 @@ typedef struct module_s #include "in_buttons.h" #endif -#define CLDLL_INTERFACE_VERSION 7 +const int CLDLL_INTERFACE_VERSION = 7; extern void LoadSecurityModuleFromDisk(char * pszDllName); extern void LoadSecurityModuleFromMemory( unsigned char * pCode, int nSize ); diff --git a/rehlds/engine/client.h b/rehlds/engine/client.h index 787a5d0..f8eb9e2 100644 --- a/rehlds/engine/client.h +++ b/rehlds/engine/client.h @@ -46,8 +46,8 @@ #include "model.h" #include "kbutton.h" -#define MAX_SCOREBOARDNAME 32 -#define MAX_DEMOS 32 +const int MAX_SCOREBOARDNAME = 32; +const int MAX_DEMOS = 32; typedef enum cactive_e { diff --git a/rehlds/engine/cmd.h b/rehlds/engine/cmd.h index 2a26540..d49b534 100644 --- a/rehlds/engine/cmd.h +++ b/rehlds/engine/cmd.h @@ -36,9 +36,9 @@ All command/alias names are case insensitive! Arguments not. */ -#define MAX_CMD_BUFFER 16384 -#define MAX_CMD_TOKENS 80 -#define MAX_CMD_LINE 1024 +const int MAX_CMD_BUFFER = 16384; +const int MAX_CMD_TOKENS = 80; +const int MAX_CMD_LINE = 1024; /* diff --git a/rehlds/engine/cmodel.h b/rehlds/engine/cmodel.h index dff66bd..f1ff8dc 100644 --- a/rehlds/engine/cmodel.h +++ b/rehlds/engine/cmodel.h @@ -33,7 +33,7 @@ // Looks like no more than 8096 visibility leafs per world model -#define MODEL_MAX_PVS 1024 +const int MODEL_MAX_PVS = 1024; #ifdef HOOK_ENGINE diff --git a/rehlds/engine/common.cpp b/rehlds/engine/common.cpp index 169b688..be170ec 100644 --- a/rehlds/engine/common.cpp +++ b/rehlds/engine/common.cpp @@ -2798,7 +2798,7 @@ typedef struct unsigned short wBitsPerSample; } FormatChunk; -#define WAVE_HEADER_LENGTH 128 +const int WAVE_HEADER_LENGTH = 128; unsigned int EXT_FUNC COM_GetApproxWavePlayLength(const char *filepath) { diff --git a/rehlds/engine/consistency.h b/rehlds/engine/consistency.h index 29ebc26..e7bfb90 100644 --- a/rehlds/engine/consistency.h +++ b/rehlds/engine/consistency.h @@ -28,7 +28,7 @@ #pragma once -#define MAX_CONSISTENCY_LIST 512 +const int MAX_CONSISTENCY_LIST = 512; typedef struct consistency_s { diff --git a/rehlds/engine/cvar.h b/rehlds/engine/cvar.h index e6cb507..2cb14b9 100644 --- a/rehlds/engine/cvar.h +++ b/rehlds/engine/cvar.h @@ -32,8 +32,8 @@ #include "cvardef.h" #include "FileSystem.h" -#define MAX_CVAR_VALUE 1024 -#define MAX_CVARLIST_FILES 100 +const int MAX_CVAR_VALUE = 1024; +const int MAX_CVARLIST_FILES = 100; #ifdef HOOK_ENGINE #define cvar_vars (*pcvar_vars) diff --git a/rehlds/engine/decal.h b/rehlds/engine/decal.h index 91e1388..014746e 100644 --- a/rehlds/engine/decal.h +++ b/rehlds/engine/decal.h @@ -32,8 +32,9 @@ #include "model.h" #include "wad.h" -#define MAX_DECALS 512 -#define DECAL_EXTRASIZE sizeof(texture_t) - sizeof(miptex_t) +const int MAX_DECALS = 512; + +#define DECAL_EXTRASIZE sizeof(texture_t) - sizeof(miptex_t) typedef struct decalname_s { diff --git a/rehlds/engine/delta.h b/rehlds/engine/delta.h index 329886b..8562405 100644 --- a/rehlds/engine/delta.h +++ b/rehlds/engine/delta.h @@ -30,7 +30,7 @@ #include "maintypes.h" -#define DELTA_MAX_FIELDS 56 // 7*8 +const int DELTA_MAX_FIELDS = 56; // 7*8 enum { @@ -46,7 +46,7 @@ enum DT_SIGNED = BIT(31) // sign modificator }; -#define FDT_MARK BIT(0) // Delta mark for sending +const int FDT_MARK = BIT(0); // Delta mark for sending typedef struct delta_s delta_t; typedef void(*encoder_t)(delta_t *, const unsigned char *, const unsigned char *); diff --git a/rehlds/engine/delta_jit.h b/rehlds/engine/delta_jit.h index 07e945b..b0c6599 100644 --- a/rehlds/engine/delta_jit.h +++ b/rehlds/engine/delta_jit.h @@ -30,8 +30,8 @@ #include "maintypes.h" -#define DELTAJIT_MAX_BLOCKS 32 -#define DELTAJIT_MAX_FIELDS 56 +const int DELTAJIT_MAX_BLOCKS = 32; +const int DELTAJIT_MAX_FIELDS = 56; struct deltajit_field { unsigned int id; diff --git a/rehlds/engine/filter.h b/rehlds/engine/filter.h index 11f8155..43e9609 100644 --- a/rehlds/engine/filter.h +++ b/rehlds/engine/filter.h @@ -31,11 +31,11 @@ #include "userid.h" #ifdef REHLDS_FIXES -#define MAX_IPFILTERS 4096 -#define MAX_USERFILTERS 4096 +const int MAX_IPFILTERS = 4096; +const int MAX_USERFILTERS = 4096; #else -#define MAX_IPFILTERS 32768 -#define MAX_USERFILTERS 32768 +const int MAX_IPFILTERS = 32768; +const int MAX_USERFILTERS = 32768; #endif // REHLDS_FIXES typedef struct ipfilter_s diff --git a/rehlds/engine/host.h b/rehlds/engine/host.h index bfa3b13..814e7ab 100644 --- a/rehlds/engine/host.h +++ b/rehlds/engine/host.h @@ -34,7 +34,7 @@ #include "server.h" #include "rehlds_api.h" -#define MAX_COMMAND_LINE_PARAMS 50 +const int MAX_COMMAND_LINE_PARAMS = 50; typedef struct quakeparms_s { diff --git a/rehlds/engine/info.h b/rehlds/engine/info.h index ebe2c55..9ac4542 100644 --- a/rehlds/engine/info.h +++ b/rehlds/engine/info.h @@ -31,17 +31,17 @@ #include "maintypes.h" // Max key/value length (with a NULL char) -#define MAX_KV_LEN 127 +const int MAX_KV_LEN = 127; // Key + value + 2 x slash + NULL -#define MAX_INFO_STRING 256 +const int MAX_INFO_STRING = 256; -#define INFO_MAX_BUFFER_VALUES 4 +const int INFO_MAX_BUFFER_VALUES = 4; #ifdef REHLDS_FIXES -#define MAX_LOCALINFO 4096 +const int MAX_LOCALINFO = 4096; #else -#define MAX_LOCALINFO MAX_INFO_STRING * 128 +const int MAX_LOCALINFO = MAX_INFO_STRING * 128; #endif // REHLDS_FIXES const char *Info_ValueForKey(const char *s, const char *key); diff --git a/rehlds/engine/inst_baseline.h b/rehlds/engine/inst_baseline.h index 8851f5c..3a2a74b 100644 --- a/rehlds/engine/inst_baseline.h +++ b/rehlds/engine/inst_baseline.h @@ -30,7 +30,7 @@ #include "entity_state.h" -#define NUM_BASELINES 64 +const int NUM_BASELINES = 64; typedef struct extra_baselines_s { diff --git a/rehlds/engine/l_studio.h b/rehlds/engine/l_studio.h index 34c1c76..7601160 100644 --- a/rehlds/engine/l_studio.h +++ b/rehlds/engine/l_studio.h @@ -33,7 +33,8 @@ #include "commonmacros.h" // header -#define STUDIO_VERSION 10 +const int STUDIO_VERSION = 10; + #define IDSTUDIOHEADER MAKEID('I', 'D', 'S', 'T') // little-endian "IDST" #define IDSEQGRPHEADER MAKEID('I', 'D', 'S', 'Q') // little-endian "IDSQ" diff --git a/rehlds/engine/net.h b/rehlds/engine/net.h index 0341b5e..10cd809 100644 --- a/rehlds/engine/net.h +++ b/rehlds/engine/net.h @@ -33,53 +33,53 @@ #include "enums.h" #include "netadr.h" -#define PROTOCOL_VERSION 48 +const int PROTOCOL_VERSION = 48; // MAX_CHALLENGES is made large to prevent a denial // of service attack that could cycle all of them // out before legitimate users connected #ifdef REHLDS_OPT_PEDANTIC -#define MAX_CHALLENGES 64 +const int MAX_CHALLENGES = 64; #else -#define MAX_CHALLENGES 1024 +const int MAX_CHALLENGES = 1024; #endif // REHLDS_OPT_PEDANTIC // Client connection is initiated by requesting a challenge value // the server sends this value back -#define S2C_CHALLENGE 'A' // + challenge value +const char S2C_CHALLENGE = 'A'; // + challenge value // Send a userid, client remote address, is this server secure and engine build number -#define S2C_CONNECTION 'B' +const char S2C_CONNECTION = 'B'; // HLMaster rejected a server's connection because the server needs to be updated -#define M2S_REQUESTRESTART 'O' +const char M2S_REQUESTRESTART = 'O'; // send a log event as key value -#define S2A_LOGSTRING 'R' +const char S2A_LOGSTRING = 'R'; // Send a log string -#define S2A_LOGKEY 'S' +const char S2A_LOGKEY = 'S'; // Basic information about the server -#define A2S_INFO 'T' +const char A2S_INFO = 'T'; // Details about each player on the server -#define A2S_PLAYER 'U' +const char A2S_PLAYER = 'U'; // The rules the server is using -#define A2S_RULES 'V' +const char A2S_RULES = 'V'; // Another user is requesting a challenge value from this machine -#define A2A_GETCHALLENGE 'W' // Request challenge # from another machine +const char A2A_GETCHALLENGE = 'W'; // Request challenge # from another machine // Generic Ping Request -#define A2A_PING 'i' // respond with an A2A_ACK +const char A2A_PING = 'i'; // respond with an A2A_ACK // Generic Ack -#define A2A_ACK 'j' // general acknowledgement without info +const char A2A_ACK = 'j'; // general acknowledgement without info // Challenge response from master -#define M2A_CHALLENGE 's' // + challenge value +const char M2A_CHALLENGE = 's'; // + challenge value // 0 == regular, 1 == file stream enum @@ -91,25 +91,25 @@ enum }; // Flow control bytes per second limits -#define MAX_RATE 100000.0f -#define MIN_RATE 1000.0f +const float MAX_RATE = 100000.0f; +const float MIN_RATE = 1000.0f; // Default data rate -#define DEFAULT_RATE (9999.0f) +const float DEFAULT_RATE = (9999.0f); // NETWORKING INFO // Max size of udp packet payload -#define MAX_UDP_PACKET 4010 // 9 bytes SPLITHEADER + 4000 payload? +const int MAX_UDP_PACKET = 4010; // 9 bytes SPLITHEADER + 4000 payload? // Max length of a reliable message -#define MAX_MSGLEN 3990 // 10 reserved for fragheader? +const int MAX_MSGLEN = 3990; // 10 reserved for fragheader? // Max length of unreliable message -#define MAX_DATAGRAM 4000 +const int MAX_DATAGRAM = 4000; // This is the packet payload without any header bytes (which are attached for actual sending) -#define NET_MAX_PAYLOAD 65536 +const int NET_MAX_PAYLOAD = 65536; // This is the payload plus any header info (excluding UDP header) @@ -135,7 +135,7 @@ enum // bytes will be stripped by the networking channel layer //#define NET_MAX_MESSAGE PAD_NUMBER( ( MAX_MSGLEN + HEADER_BYTES ), 16 ) // This is currently used value in the engine. TODO: define above gives 4016, check it why. -#define NET_MAX_MESSAGE 4037 +const int NET_MAX_MESSAGE = 4037; typedef enum svc_commands_e @@ -237,7 +237,7 @@ typedef struct flowstats_s double time; } flowstats_t; -#define MAX_LATENT 32 +const int MAX_LATENT = 32; typedef struct flow_s { @@ -252,19 +252,20 @@ typedef struct flow_s float avgkbytespersec; } flow_t; -#define FRAGMENT_C2S_MIN_SIZE 16 -#define FRAGMENT_S2C_MIN_SIZE 256 -#define FRAGMENT_S2C_MAX_SIZE 1024 -#define CLIENT_FRAGMENT_SIZE_ONCONNECT 128 -#define CUSTOMIZATION_MAX_SIZE 20480 +const int FRAGMENT_C2S_MIN_SIZE = 16; +const int FRAGMENT_S2C_MIN_SIZE = 256; +const int FRAGMENT_S2C_MAX_SIZE = 1024; + +const int CLIENT_FRAGMENT_SIZE_ONCONNECT = 128; +const int CUSTOMIZATION_MAX_SIZE = 20480; #ifndef REHLDS_FIXES // Size of fragmentation buffer internal buffers -#define FRAGMENT_MAX_SIZE 1400 +const int FRAGMENT_MAX_SIZE = 1400; -#define MAX_FRAGMENTS 25000 +const int MAX_FRAGMENTS = 25000; #else -#define FRAGMENT_MAX_SIZE 1024 +const int FRAGMENT_MAX_SIZE = 1024; // Client sends normal fragments only while connecting #define MAX_NORMAL_FRAGMENTS (NET_MAX_PAYLOAD / CLIENT_FRAGMENT_SIZE_ONCONNECT) @@ -274,8 +275,8 @@ typedef struct flow_s #define MAX_FILE_FRAGMENTS (CUSTOMIZATION_MAX_SIZE / FRAGMENT_C2S_MIN_SIZE) #endif -#define UDP_HEADER_SIZE 28 -#define MAX_RELIABLE_PAYLOAD 1200 +const int UDP_HEADER_SIZE = 28; +const int MAX_RELIABLE_PAYLOAD = 1200; #define MAKE_FRAGID(id,count) ( ( ( id & 0xffff ) << 16 ) | ( count & 0xffff ) ) #define FRAG_GETID(fragid) ( ( fragid >> 16 ) & 0xffff ) diff --git a/rehlds/engine/net_ws.h b/rehlds/engine/net_ws.h index 27d034e..7c9ec5a 100644 --- a/rehlds/engine/net_ws.h +++ b/rehlds/engine/net_ws.h @@ -46,15 +46,15 @@ #endif // _WIN32 -#define MAX_ROUTEABLE_PACKET 1400 +const int MAX_ROUTEABLE_PACKET = 1400; #define SPLIT_SIZE (MAX_ROUTEABLE_PACKET - sizeof(SPLITPACKET)) // Create general message queues -#define NUM_MSG_QUEUES 40 -#define MSG_QUEUE_SIZE 1536 +const int NUM_MSG_QUEUES = 40; +const int MSG_QUEUE_SIZE = 1536; -#define NET_HEADER_FLAG_SPLITPACKET -2 +const int NET_HEADER_FLAG_SPLITPACKET = -2; typedef struct loopmsg_s { @@ -62,7 +62,7 @@ typedef struct loopmsg_s int datalen; } loopmsg_t; -#define MAX_LOOPBACK 4 +const int MAX_LOOPBACK = 4; typedef struct loopback_s { @@ -110,7 +110,7 @@ typedef struct SPLITPACKET_t } SPLITPACKET; #pragma pack(pop) -#define NET_WS_MAX_FRAGMENTS 5 +const int NET_WS_MAX_FRAGMENTS = 5; #ifdef HOOK_ENGINE #define net_thread_initialized (*pnet_thread_initialized) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 7e164cd..2620f25 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -2361,11 +2361,13 @@ void SeedRandomNumberGenerator(void) } } -#define IA 16807 -#define IM 2147483647 -#define IQ 127773 -#define IR 2836 -#define NTAB 32 +const int IA = 16807; +const int IM = 2147483647; +const int IQ = 127773; +const int IR = 2836; + +const int NTAB = 32; + #define NDIV (1+(IM-1)/NTAB) int32 ran1(void) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 232c4b9..ed24fa0 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -31,8 +31,8 @@ #include "maintypes.h" // TODO: I think this defines must be in /common/ -#define NUM_EDICTS 900 -#define MAX_NAME 32 +const int NUM_EDICTS = 900; +const int MAX_NAME = 32; #include "custom_int.h" #include "crc.h" @@ -54,9 +54,9 @@ #include "inst_baseline.h" #include "net_ws.h" -#define DEFAULT_SOUND_PACKET_VOLUME 255 -#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0f -#define DEFAULT_SOUND_PACKET_PITCH 100 +const int DEFAULT_SOUND_PACKET_VOLUME = 255; +const float DEFAULT_SOUND_PACKET_ATTENUATION = 1.0f; +const int DEFAULT_SOUND_PACKET_PITCH = 100; // Sound flags enum @@ -82,10 +82,10 @@ enum MSG_FL_ONE = BIT(7), // Send to single client }; -#define RESOURCE_INDEX_BITS 12 +const int RESOURCE_INDEX_BITS = 12; #ifdef REHLDS_FIXES -#define RESOURCE_MAX_COUNT (1 << RESOURCE_INDEX_BITS) +const int RESOURCE_MAX_COUNT = BIT(RESOURCE_INDEX_BITS); #endif // REHLDS_FIXES typedef enum redirect_e diff --git a/rehlds/engine/sound.h b/rehlds/engine/sound.h index 3556387..e2bddfe 100644 --- a/rehlds/engine/sound.h +++ b/rehlds/engine/sound.h @@ -31,7 +31,7 @@ #include "quakedef.h" // max number of sentences in game. NOTE: this must match CVOXFILESENTENCEMAX in dlls\util.h!!! -#define CVOXFILESENTENCEMAX 1536 +const int CVOXFILESENTENCEMAX = 1536; typedef struct sfx_s { diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 6dc4432..d7333b0 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -3239,8 +3239,8 @@ void SV_BeginRedirect(redirect_t rd, netadr_t *addr) outputbuf[0] = 0; } -#define MAX_RCON_FAILURES_STORAGE 32 -#define MAX_RCON_FAILURES 20 +const int MAX_RCON_FAILURES_STORAGE = 32; +const int MAX_RCON_FAILURES = 20; typedef struct rcon_failure_s { diff --git a/rehlds/engine/sv_move.h b/rehlds/engine/sv_move.h index c51caf1..d53cd58 100644 --- a/rehlds/engine/sv_move.h +++ b/rehlds/engine/sv_move.h @@ -31,7 +31,7 @@ #include "maintypes.h" #include "server.h" -#define DI_NODIR -1 +const int DI_NODIR = -1; #ifdef HOOK_ENGINE diff --git a/rehlds/engine/sv_user.h b/rehlds/engine/sv_user.h index 18a6a69..92f4808 100644 --- a/rehlds/engine/sv_user.h +++ b/rehlds/engine/sv_user.h @@ -33,7 +33,7 @@ #include "world.h" #include "pm_defs.h" -#define CMD_MAXBACKUP 64 +const int CMD_MAXBACKUP = 64; typedef struct command_s command_t; diff --git a/rehlds/engine/sys_dll.h b/rehlds/engine/sys_dll.h index 0d03870..bbe611b 100644 --- a/rehlds/engine/sys_dll.h +++ b/rehlds/engine/sys_dll.h @@ -52,7 +52,7 @@ #endif -#define MAX_DISCONNECT_REASON 256 +const int MAX_DISCONNECT_REASON = 256; #ifdef HOOK_ENGINE diff --git a/rehlds/engine/sys_dll2.h b/rehlds/engine/sys_dll2.h index 805ae2e..1d19d14 100644 --- a/rehlds/engine/sys_dll2.h +++ b/rehlds/engine/sys_dll2.h @@ -36,7 +36,8 @@ #include "engine_launcher_api.h" #include "idedicatedexports.h" -#define FIFTEEN_MB (15 * 1024 * 1024) +const int FIFTEEN_MB = (15 * 1024 * 1024); + #define MINIMUM_WIN_MEMORY 0x0e00000 #define WARNING_MEMORY 0x0200000 #define MAXIMUM_WIN_MEMORY 0x8000000 // Ask for 128 MB max diff --git a/rehlds/engine/textures.h b/rehlds/engine/textures.h index fc4ecdd..125e822 100644 --- a/rehlds/engine/textures.h +++ b/rehlds/engine/textures.h @@ -31,7 +31,7 @@ #include "maintypes.h" #include "wad.h" -#define MAX_MAP_TEXTURES 512 +const int MAX_MAP_TEXTURES = 512; typedef struct texlumpinfo_s { diff --git a/rehlds/engine/tmessage.h b/rehlds/engine/tmessage.h index 9740210..12b9330 100644 --- a/rehlds/engine/tmessage.h +++ b/rehlds/engine/tmessage.h @@ -30,19 +30,19 @@ #include "maintypes.h" -#define DEMO_MESSAGE "__DEMOMESSAGE__" -#define NETWORK_MESSAGE1 "__NETMESSAGE__1" -#define NETWORK_MESSAGE2 "__NETMESSAGE__2" -#define NETWORK_MESSAGE3 "__NETMESSAGE__3" -#define NETWORK_MESSAGE4 "__NETMESSAGE__4" +static const char *DEMO_MESSAGE = "__DEMOMESSAGE__"; +static const char *NETWORK_MESSAGE1 = "__NETMESSAGE__1"; +static const char *NETWORK_MESSAGE2 = "__NETMESSAGE__2"; +static const char *NETWORK_MESSAGE3 = "__NETMESSAGE__3"; +static const char *NETWORK_MESSAGE4 = "__NETMESSAGE__4"; -#define MAX_NETMESSAGE 4 +const int MAX_NETMESSAGE = 4; -#define MSGFILE_NAME 0 -#define MSGFILE_TEXT 1 +const int MSGFILE_NAME = 0; +const int MSGFILE_TEXT = 1; -#define NAME_HEAP_SIZE 16384 -#define MAX_MESSAGES 1000 +const int NAME_HEAP_SIZE = 16384; +const int MAX_MESSAGES = 1000; #ifdef HOOK_ENGINE diff --git a/rehlds/engine/wad.h b/rehlds/engine/wad.h index e504a65..aabd03c 100644 --- a/rehlds/engine/wad.h +++ b/rehlds/engine/wad.h @@ -68,7 +68,7 @@ typedef struct wadlist_s typedef struct wadlist_s wadlist_t; typedef struct lumpinfo_s lumpinfo_t; -#define NUM_WADS 2 +const int NUM_WADS = 2; #ifdef HOOK_ENGINE #define wads (*pwads) diff --git a/rehlds/engine/zone.cpp b/rehlds/engine/zone.cpp index 2f67b78..63d4046 100644 --- a/rehlds/engine/zone.cpp +++ b/rehlds/engine/zone.cpp @@ -46,7 +46,7 @@ all big things are allocated on the hunk. */ #define ZONEID 0x001d4a11 -#define MINFRAGMENT 64 +const int MINFRAGMENT = 64; typedef struct memblock_s { @@ -285,7 +285,7 @@ void Z_CheckHeap(void) #ifndef Hunk_Functions_region -#define HUNK_NAME_LEN 64 +const int HUNK_NAME_LEN = 64; #define HUNK_SENTINEL 0x1df001ed typedef struct hunk_s @@ -579,7 +579,7 @@ CACHE MEMORY =============================================================================== */ -#define CACHE_NAME_LEN 64 +const int CACHE_NAME_LEN = 64; typedef struct cache_system_s { @@ -1118,7 +1118,7 @@ NOXREF void Cache_Print_Models_And_Totals(void) FS_Close(file); } -#define MAX_SFX 1024 +const int MAX_SFX = 1024; NOXREF void Cache_Print_Sounds_And_Totals(void) { diff --git a/rehlds/hookers/main.cpp b/rehlds/hookers/main.cpp index e68c643..1251a61 100644 --- a/rehlds/hookers/main.cpp +++ b/rehlds/hookers/main.cpp @@ -36,11 +36,11 @@ IBaseInterface* CreateFileSystemInterface(void); InterfaceReg iface = InterfaceReg(CreateFileSystemInterface, "VFileSystem009"); #ifdef _WIN32 -#define ORIGINAL_ENGINE_DLL_NAME "swds.dll" -#define ORIGINAL_FILESYSTEM_DLL_NAME "filesystem_stdio2.dll" +const char *ORIGINAL_ENGINE_DLL_NAME = "swds.dll"; +const char *ORIGINAL_FILESYSTEM_DLL_NAME = "filesystem_stdio2.dll"; #else -#define ORIGINAL_ENGINE_DLL_NAME "engine_i486.so" -#define ORIGINAL_FILESYSTEM_DLL_NAME "filesystem_stdio2.so" +const char *ORIGINAL_ENGINE_DLL_NAME = "engine_i486.so"; +const char *ORIGINAL_FILESYSTEM_DLL_NAME = "filesystem_stdio2.so"; #endif CSysModule *g_pOriginalFileSystemModule = NULL; diff --git a/rehlds/hookers/memory.h b/rehlds/hookers/memory.h index 56b88e1..196eb92 100644 --- a/rehlds/hookers/memory.h +++ b/rehlds/hookers/memory.h @@ -32,7 +32,7 @@ #include "osconfig.h" -#define MAX_PATTERN 128 +const int MAX_PATTERN = 128; struct Section; diff --git a/rehlds/hookers/rehlds_debug.cpp b/rehlds/hookers/rehlds_debug.cpp index 8e9f425..45e379c 100644 --- a/rehlds/hookers/rehlds_debug.cpp +++ b/rehlds/hookers/rehlds_debug.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" -#define REHLDS_DEBUG_MAX_EDICTS 2048 +const int REHLDS_DEBUG_MAX_EDICTS = 2048; uint32 calcFloatChecksum(uint32 crc, const float* pFloat) { uint32 sVal = *reinterpret_cast(pFloat); diff --git a/rehlds/rehlds/hookchains_impl.h b/rehlds/rehlds/hookchains_impl.h index 0c79d68..2c04141 100644 --- a/rehlds/rehlds/hookchains_impl.h +++ b/rehlds/rehlds/hookchains_impl.h @@ -28,7 +28,7 @@ #pragma once #include "hookchains.h" -#define MAX_HOOKS_IN_CHAIN 19 +const int MAX_HOOKS_IN_CHAIN = 19; // Implementation for chains in modules template diff --git a/rehlds/testsuite/funccalls.h b/rehlds/testsuite/funccalls.h index 41c4597..7ac56c7 100644 --- a/rehlds/testsuite/funccalls.h +++ b/rehlds/testsuite/funccalls.h @@ -10,8 +10,8 @@ #include #include -#define HOSTENT_DATA_MAX_ALIASES 10 -#define HOSTENT_DATA_MAX_ADDRS 32 +const int HOSTENT_DATA_MAX_ALIASES = 10; +const int HOSTENT_DATA_MAX_ADDRS = 32; struct hostent_data_t { char hostName[256]; diff --git a/rehlds/testsuite/player.h b/rehlds/testsuite/player.h index 200d037..076a713 100644 --- a/rehlds/testsuite/player.h +++ b/rehlds/testsuite/player.h @@ -1,8 +1,8 @@ #pragma once #ifdef _WIN32 -#define TESTPLAYER_FUNCTREE_DEPTH 8 -#define TESTPLAYER_FUNCCALL_MAXSIZE 17000 +const int TESTPLAYER_FUNCTREE_DEPTH = 8; +const int TESTPLAYER_FUNCCALL_MAXSIZE = 17000; #include "osconfig.h" #include "funccalls.h" diff --git a/rehlds/testsuite/testsuite.h b/rehlds/testsuite/testsuite.h index c8db4c3..f3a912b 100644 --- a/rehlds/testsuite/testsuite.h +++ b/rehlds/testsuite/testsuite.h @@ -10,8 +10,8 @@ #include #include -#define TESTSUITE_PROTOCOL_VERSION_MINOR 5 -#define TESTSUITE_PROTOCOL_VERSION_MAJOR 0 +const int TESTSUITE_PROTOCOL_VERSION_MINOR = 5; +const int TESTSUITE_PROTOCOL_VERSION_MAJOR = 0; void TestSuite_Init(const Module* engine, const Module* executable, const AddressRef* funcRefs);