From 77482953d992990e915604012bd325a0f8dea7bb Mon Sep 17 00:00:00 2001 From: Sh1ft0x0EF Date: Sat, 18 Feb 2017 22:53:56 +0400 Subject: [PATCH] enum-like defines -> enums --- rehlds/engine/APIProxy.h | 13 +++++++------ rehlds/engine/cdll_int.h | 7 +++++-- rehlds/engine/delta.h | 22 +++++++++++++--------- rehlds/engine/mathlib_e.h | 12 ++++++------ rehlds/engine/model.cpp | 9 ++++++--- rehlds/engine/net.h | 22 ++++++++++++++-------- rehlds/engine/pr_cmds.h | 26 ++++++++++++++++---------- rehlds/engine/server.h | 34 ++++++++++++++++++++-------------- rehlds/engine/sys_engine.h | 5 ++--- 9 files changed, 89 insertions(+), 61 deletions(-) diff --git a/rehlds/engine/APIProxy.h b/rehlds/engine/APIProxy.h index 9869906..54a954b 100644 --- a/rehlds/engine/APIProxy.h +++ b/rehlds/engine/APIProxy.h @@ -910,12 +910,13 @@ typedef struct modfuncs_s int m_nVoid9; } modfuncs_t; - -#define k_nEngineVersion15Base 0 -#define k_nEngineVersion15Patch 1 -#define k_nEngineVersion16Base 2 -#define k_nEngineVersion16Validated 3 // 1.6 engine with built-in validation - +enum +{ + k_nEngineVersion15Base = 0, + k_nEngineVersion15Patch, + k_nEngineVersion16Base, + k_nEngineVersion16Validated // 1.6 engine with built-in validation +}; typedef struct validator_s { diff --git a/rehlds/engine/cdll_int.h b/rehlds/engine/cdll_int.h index 967ae40..5fe55d2 100644 --- a/rehlds/engine/cdll_int.h +++ b/rehlds/engine/cdll_int.h @@ -32,8 +32,11 @@ extern "C" { typedef int HSPRITE_t; // handle to a graphic -#define SCRINFO_SCREENFLASH 1 -#define SCRINFO_STRETCHED 2 +enum +{ + SCRINFO_SCREENFLASH = 1, + SCRINFO_STRETCHED +}; typedef struct SCREENINFO_s { diff --git a/rehlds/engine/delta.h b/rehlds/engine/delta.h index 0712a4f..18d230b 100644 --- a/rehlds/engine/delta.h +++ b/rehlds/engine/delta.h @@ -32,15 +32,19 @@ #define DELTA_MAX_FIELDS 56 // 7*8 -#define DT_BYTE BIT(0) // A byte -#define DT_SHORT BIT(1) // 2 byte field -#define DT_FLOAT BIT(2) // A floating point field -#define DT_INTEGER BIT(3) // 4 byte integer -#define DT_ANGLE BIT(4) // A floating point angle -#define DT_TIMEWINDOW_8 BIT(5) // A floating point timestamp relative to server time -#define DT_TIMEWINDOW_BIG BIT(6) // A floating point timestamp relative to server time (with more precision and custom multiplier) -#define DT_STRING BIT(7) // A null terminated string, sent as 8 byte chars -#define DT_SIGNED BIT(31) // sign modificator +enum +{ + DT_BYTE = BIT(0), // A byte + DT_SHORT = BIT(1), // 2 byte field + DT_FLOAT = BIT(2), // A floating point field + DT_INTEGER = BIT(3), // 4 byte integer + DT_ANGLE = BIT(4), // A floating point angle + DT_TIMEWINDOW_8 = BIT(5), // A floating point timestamp relative to server time + DT_TIMEWINDOW_BIG = BIT(6), // A floating point timestamp relative to server time (with more precision and custom multiplier) + DT_STRING = BIT(7), // A null terminated string, sent as 8 byte chars + + DT_SIGNED = BIT(31) // sign modificator +}; #define FDT_MARK BIT(0) // Delta mark for sending diff --git a/rehlds/engine/mathlib_e.h b/rehlds/engine/mathlib_e.h index ce89bf4..be696d7 100644 --- a/rehlds/engine/mathlib_e.h +++ b/rehlds/engine/mathlib_e.h @@ -31,12 +31,12 @@ #include "maintypes.h" #include "model.h" -// up / down -#define PITCH 0 -// left / right -#define YAW 1 -// fall over -#define ROLL 2 +enum +{ + PITCH = 0, // up / down + YAW, // left / right + ROLL // fall over +}; #define RAD2DEG(x) ((float)(x) * (float)(180.f / M_PI)) #define DEG2RAD(x) ((float)(x) * (float)(M_PI / 180.f)) diff --git a/rehlds/engine/model.cpp b/rehlds/engine/model.cpp index 21713b1..474862f 100644 --- a/rehlds/engine/model.cpp +++ b/rehlds/engine/model.cpp @@ -40,9 +40,12 @@ cachewad_t ad_wad; mod_known_info_t mod_known_info[MAX_KNOWN_MODELS]; // values for model_t's needload -#define NL_PRESENT 0 -#define NL_NEEDS_LOADED 1 -#define NL_UNREFERENCED 2 +enum +{ + NL_PRESENT = 0, + NL_NEEDS_LOADED, + NL_UNREFERENCED +}; void SW_Mod_Init(void) { diff --git a/rehlds/engine/net.h b/rehlds/engine/net.h index e700189..c9e6506 100644 --- a/rehlds/engine/net.h +++ b/rehlds/engine/net.h @@ -82,7 +82,13 @@ #define M2A_CHALLENGE 's' // + challenge value // 0 == regular, 1 == file stream -#define MAX_STREAMS 2 +enum +{ + FRAG_NORMAL_STREAM = 0, + FRAG_FILE_STREAM, + + MAX_STREAMS +}; // Flow control bytes per second limits #define MAX_RATE 100000.0f @@ -214,10 +220,13 @@ typedef enum clc_commands_e clc_endoflist = 255, } clc_commands_t; -#define MAX_FLOWS 2 - -#define FLOW_OUTGOING 0 -#define FLOW_INCOMING 1 +enum +{ + FLOW_OUTGOING = 0, + FLOW_INCOMING, + + MAX_FLOWS +}; // Message data typedef struct flowstats_s @@ -268,9 +277,6 @@ typedef struct flow_s #define UDP_HEADER_SIZE 28 #define MAX_RELIABLE_PAYLOAD 1200 -#define FRAG_NORMAL_STREAM 0 -#define FRAG_FILE_STREAM 1 - #define MAKE_FRAGID(id,count) ( ( ( id & 0xffff ) << 16 ) | ( count & 0xffff ) ) #define FRAG_GETID(fragid) ( ( fragid >> 16 ) & 0xffff ) #define FRAG_GETCOUNT(fragid) ( fragid & 0xffff ) diff --git a/rehlds/engine/pr_cmds.h b/rehlds/engine/pr_cmds.h index 062e153..c074bf0 100644 --- a/rehlds/engine/pr_cmds.h +++ b/rehlds/engine/pr_cmds.h @@ -37,14 +37,17 @@ #define MAX_RANDOM_RANGE 0x7FFFFFFFUL -// TODO: Make enum with bits -#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation -#define AMBIENT_SOUND_EVERYWHERE 1 -#define AMBIENT_SOUND_SMALLRADIUS 2 -#define AMBIENT_SOUND_MEDIUMRADIUS 4 -#define AMBIENT_SOUND_LARGERADIUS 8 -#define AMBIENT_SOUND_START_SILENT 16 -#define AMBIENT_SOUND_NOT_LOOPING 32 +// Ambient sound flags +enum +{ + AMBIENT_SOUND_STATIC = 0, // medium radius attenuation + AMBIENT_SOUND_EVERYWHERE = BIT(0), + AMBIENT_SOUND_SMALLRADIUS = BIT(1), + AMBIENT_SOUND_MEDIUMRADIUS = BIT(2), + AMBIENT_SOUND_LARGERADIUS = BIT(3), + AMBIENT_SOUND_START_SILENT = BIT(4), + AMBIENT_SOUND_NOT_LOOPING = BIT(5) +}; #define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements @@ -88,8 +91,11 @@ extern vec3_t vec_origin; extern int r_visframecount; -#define GROUP_OP_AND 0 -#define GROUP_OP_NAND 1 +enum +{ + GROUP_OP_AND = 0, + GROUP_OP_NAND +}; void PF_makevectors_I(const float *rgflVector); float PF_Time(void); diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index b0ebf80..6a7868f 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -59,22 +59,28 @@ #define DEFAULT_SOUND_PACKET_PITCH 100 // Sound flags -#define SND_FL_VOLUME BIT(0) // send volume -#define SND_FL_ATTENUATION BIT(1) // send attenuation -#define SND_FL_LARGE_INDEX BIT(2) // send sound number as short instead of byte -#define SND_FL_PITCH BIT(3) // send pitch -#define SND_FL_SENTENCE BIT(4) // set if sound num is actually a sentence num -#define SND_FL_STOP BIT(5) // stop the sound -#define SND_FL_CHANGE_VOL BIT(6) // change sound vol -#define SND_FL_CHANGE_PITCH BIT(7) // change sound pitch -#define SND_FL_SPAWNING BIT(8) // we're spawning, used in some cases for ambients (not sent across network) +enum +{ + SND_FL_VOLUME = BIT(0), // send volume + SND_FL_ATTENUATION = BIT(1), // send attenuation + SND_FL_LARGE_INDEX = BIT(2), // send sound number as short instead of byte + SND_FL_PITCH = BIT(3), // send pitch + SND_FL_SENTENCE = BIT(4), // set if sound num is actually a sentence num + SND_FL_STOP = BIT(5), // stop the sound + SND_FL_CHANGE_VOL = BIT(6), // change sound vol + SND_FL_CHANGE_PITCH = BIT(7), // change sound pitch + SND_FL_SPAWNING = BIT(8) // we're spawning, used in some cases for ambients (not sent across network) +}; // Message send destination flags -#define MSG_FL_NONE 0 // No flags -#define MSG_FL_BROADCAST BIT(0) // Broadcast? -#define MSG_FL_PVS BIT(1) // Send to PVS -#define MSG_FL_PAS BIT(2) // Send to PAS -#define MSG_FL_ONE BIT(7) // Send to single client +enum +{ + MSG_FL_NONE = 0, // No flags + MSG_FL_BROADCAST = BIT(0), // Broadcast? + MSG_FL_PVS = BIT(1), // Send to PVS + MSG_FL_PAS = BIT(2), // Send to PAS + MSG_FL_ONE = BIT(7), // Send to single client +}; #define RESOURCE_INDEX_BITS 12 diff --git a/rehlds/engine/sys_engine.h b/rehlds/engine/sys_engine.h index ab65604..c74f98b 100644 --- a/rehlds/engine/sys_engine.h +++ b/rehlds/engine/sys_engine.h @@ -32,9 +32,8 @@ #include "igame.h" #include "iengine.h" -// sleep time when not focus -#define NOT_FOCUS_SLEEP 50 -#define MINIMIZED_SLEEP 20 +const int MINIMIZED_SLEEP = 20; +const int NOT_FOCUS_SLEEP = 50; // sleep time when not focus #ifdef HOOK_ENGINE #define game (*pgame)