From 391526cf73cce1050632173d2533f410a3c0d1db Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Thu, 5 Mar 2026 22:35:59 -0500 Subject: [PATCH 001/291] Changed Macro definitions to constexpr --- src/common/beamdef.h | 24 +-- src/common/cl_entity.h | 4 +- src/common/com_model.h | 47 +++-- src/common/const.h | 439 ++++++++++++++++++++--------------------- 4 files changed, 254 insertions(+), 260 deletions(-) diff --git a/src/common/beamdef.h b/src/common/beamdef.h index cc4d3047..ecd14bcf 100644 --- a/src/common/beamdef.h +++ b/src/common/beamdef.h @@ -18,18 +18,18 @@ #pragma once #endif -#define FBEAM_STARTENTITY 0x00000001 -#define FBEAM_ENDENTITY 0x00000002 -#define FBEAM_FADEIN 0x00000004 -#define FBEAM_FADEOUT 0x00000008 -#define FBEAM_SINENOISE 0x00000010 -#define FBEAM_SOLID 0x00000020 -#define FBEAM_SHADEIN 0x00000040 -#define FBEAM_SHADEOUT 0x00000080 -#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet? -#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet? -#define FBEAM_ISACTIVE 0x40000000 -#define FBEAM_FOREVER 0x80000000 +constexpr int FBEAM_STARTENTITY = 0x00000001; +constexpr int FBEAM_ENDENTITY = 0x00000002; +constexpr int FBEAM_FADEIN = 0x00000004; +constexpr int FBEAM_FADEOUT = 0x00000008; +constexpr int FBEAM_SINENOISE = 0x00000010; +constexpr int FBEAM_SOLID = 0x00000020; +constexpr int FBEAM_SHADEIN = 0x00000040; +constexpr int FBEAM_SHADEOUT = 0x00000080; +constexpr int FBEAM_STARTVISIBLE = 0x10000000; // Has this client actually seen this beam's start e= ntity yet?; +constexpr int FBEAM_ENDVISIBLE = 0x20000000; // Has this client actually seen this beam's end e= ntity yet?; +constexpr int FBEAM_ISACTIVE = 0x40000000; +constexpr int FBEAM_FOREVER = 0x80000000; typedef struct beam_s BEAM; struct beam_s diff --git a/src/common/cl_entity.h b/src/common/cl_entity.h index dbf3981d..0ff88bc8 100644 --- a/src/common/cl_entity.h +++ b/src/common/cl_entity.h @@ -60,8 +60,8 @@ typedef struct typedef struct cl_entity_s cl_entity_t; -#define HISTORY_MAX 64 // Must be power of 2 -#define HISTORY_MASK (HISTORY_MAX - 1) +constexpr unsigned int HISTORY_MAX = 64; // Must be power of 2 +constexpr unsigned int HISTORY_MASK = (HISTORY_MAX - 1); #if !defined(ENTITY_STATEH) #include "entity_state.h" diff --git a/src/common/com_model.h b/src/common/com_model.h index 1694a5c9..e138cf38 100644 --- a/src/common/com_model.h +++ b/src/common/com_model.h @@ -24,33 +24,30 @@ #pragma once #endif -#define STUDIO_RENDER 1 -#define STUDIO_EVENTS 2 - -#define MAX_CLIENTS 32 -#define MAX_EDICTS 2048 - -#define MAX_MODEL_NAME 64 -#define MAX_MAP_HULLS 4 -#define MIPLEVELS 4 -#define NUM_AMBIENTS 4 // automatic ambient sounds -#define MAXLIGHTMAPS 4 -#define PLANE_ANYZ 5 - -#define ALIAS_Z_CLIP_PLANE 5 +constexpr unsigned int STUDIO_RENDER = 1; +constexpr unsigned int STUDIO_EVENTS = 2; +constexpr unsigned int MAX_MAP_HULLS = 4; +constexpr unsigned int MIPLEVELS = 4; +constexpr unsigned int NUM_AMBIENTS = 4; // automatic ambient sounds +constexpr unsigned int MAXLIGHTMAPS = 4; +constexpr unsigned int PLANE_ANYZ = 5; +constexpr unsigned int MAX_CLIENTS = 32; +constexpr unsigned int MAX_MODEL_NAME = 64; +constexpr unsigned int MAX_EDICTS = 2048; + +constexpr unsigned int ALIAS_Z_CLIP_PLANE = 5; // flags in finalvert_t.flags -#define ALIAS_LEFT_CLIP 0x0001 -#define ALIAS_TOP_CLIP 0x0002 -#define ALIAS_RIGHT_CLIP 0x0004 -#define ALIAS_BOTTOM_CLIP 0x0008 -#define ALIAS_Z_CLIP 0x0010 -#define ALIAS_ONSEAM 0x0020 -#define ALIAS_XY_CLIP_MASK 0x000F - -#define ZISCALE ((float)0x8000) +constexpr int ALIAS_LEFT_CLIP = 0x0001; +constexpr int ALIAS_TOP_CLIP = 0x0002; +constexpr int ALIAS_RIGHT_CLIP = 0x0004; +constexpr int ALIAS_BOTTOM_CLIP = 0x0008; +constexpr int ALIAS_Z_CLIP = 0x0010; +constexpr int ALIAS_ONSEAM = 0x0020; +constexpr int ALIAS_XY_CLIP_MASK = 0x000F; +constexpr float ZISCALE = ((float)0x8000); -#define CACHE_SIZE 32 // used to align key data structures +constexpr int CACHE_SIZE = 32; // used to align key data structures typedef enum { @@ -159,7 +156,7 @@ typedef struct #ifdef HARDWARE_MODE // 06/23/2002 MAH // This structure is only need for hardware rendering -#define VERTEXSIZE 7 +constexpr int VERTEXSIZE = 7; typedef struct glpoly_s { diff --git a/src/common/const.h b/src/common/const.h index c37c7ab2..1db60ce8 100644 --- a/src/common/const.h +++ b/src/common/const.h @@ -22,23 +22,23 @@ #include "Platform.h" // edict->flags -#define FL_FLY (1 << 0) // Changes the SV_Movestep() behavior to not need to be on ground -#define FL_SWIM (1 << 1) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) -#define FL_CONVEYOR (1 << 2) -#define FL_CLIENT (1 << 3) -#define FL_INWATER (1 << 4) -#define FL_MONSTER (1 << 5) -#define FL_GODMODE (1 << 6) -#define FL_NOTARGET (1 << 7) -#define FL_SKIPLOCALHOST (1 << 8) // Don't send entity to local host, it's predicting this entity itself -#define FL_ONGROUND (1 << 9) // At rest / on the ground -#define FL_PARTIALGROUND (1 << 10) // not all corners are valid -#define FL_WATERJUMP (1 << 11) // player jumping out of water -#define FL_FROZEN (1 << 12) // Player is frozen for 3rd person camera -#define FL_FAKECLIENT (1 << 13) // JAC: fake client, simulated server side; don't send network messages to them -#define FL_DUCKING (1 << 14) // Player flag -- Player is fully crouched -#define FL_FLOAT (1 << 15) // Apply floating force to this entity when in water -#define FL_GRAPHED (1 << 16) // worldgraph has this ent listed as something that blocks a connection +constexpr int FL_FLY = (1 << 0); // Changes the SV_Movestep() behavior to not need to be on ground +constexpr int FL_SWIM = (1 << 1); // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) +constexpr int FL_CONVEYOR = (1 << 2); +constexpr int FL_CLIENT = (1 << 3); +constexpr int FL_INWATER = (1 << 4); +constexpr int FL_MONSTER = (1 << 5); +constexpr int FL_GODMODE = (1 << 6); +constexpr int FL_NOTARGET = (1 << 7); +constexpr int FL_SKIPLOCALHOST = (1 << 8); // Don't send entity to local host, it's predicting this entity itself +constexpr int FL_ONGROUND = (1 << 9); // At rest / on the ground +constexpr int FL_PARTIALGROUND = (1 << 10);// not all corners are valid +constexpr int FL_WATERJUMP = (1 << 11); // player jumping out of water +constexpr int FL_FROZEN = (1 << 12); // Player is frozen for 3rd person camera +constexpr int FL_FAKECLIENT = (1 << 13); // JAC: fake client, simulated server side; don't send network messages to them +constexpr int FL_DUCKING = (1 << 14); // Player flag -- Player is fully crouched +constexpr int FL_FLOAT = (1 << 15); // Apply floating force to this entity when in water +constexpr int FL_GRAPHED = (1 << 16); // worldgraph has this ent listed as something that blocks a connection // UNDONE: Do we need these? #define FL_IMMUNE_WATER (1 << 17) @@ -46,79 +46,79 @@ #define FL_CLIENTONLY (1 << 18) // Strip edicts #define FL_IMMUNE_LAVA (1 << 19) -#define FL_PROXY (1 << 20) // This is a spectator proxy -#define FL_ALWAYSTHINK (1 << 21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) -#define FL_BASEVELOCITY (1 << 22) // Base velocity has been applied this frame (used to convert base velocity into momentum) -#define FL_MONSTERCLIP (1 << 23) // Only collide in with monsters who have FL_MONSTERCLIP set -#define FL_ONTRAIN (1 << 24) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. -#define FL_WORLDBRUSH (1 << 25) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) -#define FL_SPECTATOR (1 << 26) // This client is a spectator, don't run touch functions, etc. -#define FL_CUSTOMENTITY (1 << 29) // This is a custom entity -#define FL_KILLME (1 << 30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time -#define FL_DORMANT (1 << 31) // Entity is dormant, no updates to client +constexpr int FL_PROXY = (1 << 20); // This is a spectator proxy +constexpr int FL_ALWAYSTHINK = (1 << 21); // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) +constexpr int FL_BASEVELOCITY = (1 << 22);// Base velocity has been applied this frame (used to convert base velocity into momentum) +constexpr int FL_MONSTERCLIP = (1 << 23); // Only collide in with monsters who have FL_MONSTERCLIP set +constexpr int FL_ONTRAIN = (1 << 24); // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. +constexpr int FL_WORLDBRUSH = (1 << 25); // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) +constexpr int FL_SPECTATOR = (1 << 26); // This client is a spectator, don't run touch functions, etc. +constexpr int FL_CUSTOMENTITY = (1 << 29); // This is a custom entity +constexpr int FL_KILLME = (1 << 30); // This entity is marked for death -- This allows the engine to kill ents at the appropriate time +constexpr int FL_DORMANT = (1 << 31); // Entity is dormant, no updates to client // Goes into globalvars_t.trace_flags -#define FTRACE_SIMPLEBOX (1 << 0) // Traceline with a simple box +constexpr int FTRACE_SIMPLEBOX = (1 << 0); // Traceline with a simple box // walkmove modes -#define WALKMOVE_NORMAL 0 // normal walkmove -#define WALKMOVE_WORLDONLY 1 // doesn't hit ANY entities, no matter what the solid type -#define WALKMOVE_CHECKONLY 2 // move, but don't touch triggers + constexpr int WALKMOVE_NORMAL = 0; // normal walkmove + constexpr int WALKMOVE_WORLDONLY = 1; // doesn't hit ANY entities, no matter what the solid type + constexpr int WALKMOVE_CHECKONLY = 2; // move, but don't touch triggers // edict->movetype values -#define MOVETYPE_NONE 0 // never moves -//#define MOVETYPE_ANGLENOCLIP 1 -//#define MOVETYPE_ANGLECLIP 2 -#define MOVETYPE_WALK 3 // Player only - moving on the ground -#define MOVETYPE_STEP 4 // gravity, special edge handling -- monsters use this -#define MOVETYPE_FLY 5 // No gravity, but still collides with stuff -#define MOVETYPE_TOSS 6 // gravity/collisions -#define MOVETYPE_PUSH 7 // no clip to world, push and crush -#define MOVETYPE_NOCLIP 8 // No gravity, no collisions, still do velocity/avelocity -#define MOVETYPE_FLYMISSILE 9 // extra size to monsters -#define MOVETYPE_BOUNCE 10 // Just like Toss, but reflect velocity when contacting surfaces -#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity -#define MOVETYPE_FOLLOW 12 // track movement of aiment -#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision) + constexpr int MOVETYPE_NONE = 0; + constexpr int MOVETYPE_ANGLENOCLIP = 1; + constexpr int MOVETYPE_ANGLECLIP = 2; + constexpr int MOVETYPE_WALK = 3; // Player only - moving on the ground + constexpr int MOVETYPE_STEP = 4; // gravity, special edge handling -- monsters use this + constexpr int MOVETYPE_FLY = 5; // No gravity, but still collides with stuff + constexpr int MOVETYPE_TOSS = 6; // gravity/collisions + constexpr int MOVETYPE_PUSH = 7; // no clip to world, push and crush + constexpr int MOVETYPE_NOCLIP = 8; // No gravity, no collisions, still do velocity/avelocity + constexpr int MOVETYPE_FLYMISSILE = 9; // extra size to monsters + constexpr int MOVETYPE_BOUNCE = 10; // Just like Toss, but reflect velocity when contacting surfaces + constexpr int MOVETYPE_BOUNCEMISSILE = 11;// bounce w/o gravity + constexpr int MOVETYPE_FOLLOW = 12; // track movement of aiment + constexpr int MOVETYPE_PUSHSTEP = 13; // BSP model that needs physics/world collisions (uses nearest hull for world collision) // edict->solid values // NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves // SOLID only effects OTHER entities colliding with this one when they move - UGH! -#define SOLID_NOT 0 // no interaction with other objects -#define SOLID_TRIGGER 1 // touch on edge, but not blocking -#define SOLID_BBOX 2 // touch on edge, block -#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground -#define SOLID_BSP 4 // bsp clip, touch on edge, block +constexpr int SOLID_NOT = 0; // no interaction with other objects +constexpr int SOLID_TRIGGER = 1; // touch on edge, but not blocking +constexpr int SOLID_BBOX = 2; // touch on edge, block +constexpr int SOLID_SLIDEBOX = 3;// touch on edge, but not an onground +constexpr int SOLID_BSP = 4; // bsp clip, touch on edge, block // edict->deadflag values -#define DEAD_NO 0 // alive -#define DEAD_DYING 1 // playing death animation or still falling off of a ledge waiting to hit ground -#define DEAD_DEAD 2 // dead. lying still. -#define DEAD_RESPAWNABLE 3 -#define DEAD_DISCARDBODY 4 +constexpr int DEAD_NO = 0; // alive +constexpr int DEAD_DYING = 1; // playing death animation or still falling off of a ledge waiting to hit ground +constexpr int DEAD_DEAD = 2; // dead. lying still. +constexpr int DEAD_RESPAWNABLE = 3; +constexpr int DEAD_DISCARDBODY = 4; -#define DAMAGE_NO 0 -#define DAMAGE_YES 1 -#define DAMAGE_AIM 2 +constexpr int DAMAGE_NO = 0; +constexpr int DAMAGE_YES = 1; +constexpr int DAMAGE_AIM = 2; // entity effects -#define EF_BRIGHTFIELD 1 // swirling cloud of particles -#define EF_MUZZLEFLASH 2 // single frame ELIGHT on entity attachment 0 -#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin -#define EF_DIMLIGHT 8 // player flashlight -#define EF_INVLIGHT 16 // get lighting from ceiling -#define EF_NOINTERP 32 // don't interpolate the next frame -#define EF_LIGHT 64 // rocket flare glow sprite -#define EF_NODRAW 128 // don't draw entity +constexpr int EF_BRIGHTFIELD = 1; // swirling cloud of particles +constexpr int EF_MUZZLEFLASH = 2; // single frame ELIGHT on entity attachment 0 +constexpr int EF_BRIGHTLIGHT = 4;// DLIGHT centered at entity origin +constexpr int EF_DIMLIGHT = 8; // player flashlight +constexpr int EF_INVLIGHT = 16; // get lighting from ceiling +constexpr int EF_NOINTERP = 32; // don't interpolate the next frame +constexpr int EF_LIGHT = 64; // rocket flare glow sprite +constexpr int EF_NODRAW = 128; // don't draw entity // entity flags -#define EFLAG_SLERP 1 // do studio interpolation of this entity -#define EFLAG_FLESH_SOUND 2 +constexpr int EFLAG_SLERP = 1; // do studio interpolation of this entity +constexpr int EFLAG_FLESH_SOUND = 2; // // temp entity events // -#define TE_BEAMPOINTS 0 // beam effect between two points +constexpr int TE_BEAMPOINTS = 0; // beam effect between two points // coord coord coord (start position) // coord coord coord (end position) // short (sprite index) @@ -131,7 +131,7 @@ // byte (brightness) // byte (scroll speed in 0.1's) -#define TE_BEAMENTPOINT 1 // beam effect between point and entity +constexpr int TE_BEAMENTPOINT = 1; // beam effect between point and entity // short (start entity) // coord coord coord (end position) // short (sprite index) @@ -144,10 +144,10 @@ // byte (brightness) // byte (scroll speed in 0.1's) -#define TE_GUNSHOT 2 // particle effect plus ricochet sound +constexpr int TE_GUNSHOT = 2; // particle effect plus ricochet sound // coord coord coord (position) -#define TE_EXPLOSION 3 // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps +constexpr int TE_EXPLOSION = 3; // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps // coord coord coord (position) // short (sprite index) // byte (scale in 0.1's) @@ -155,26 +155,26 @@ // byte (flags) // // The Explosion effect has some flags to control performance/aesthetic features: -#define TE_EXPLFLAG_NONE 0 // all flags clear makes default Half-Life explosion -#define TE_EXPLFLAG_NOADDITIVE 1 // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) -#define TE_EXPLFLAG_NODLIGHTS 2 // do not render dynamic lights -#define TE_EXPLFLAG_NOSOUND 4 // do not play client explosion sound -#define TE_EXPLFLAG_NOPARTICLES 8 // do not draw particles +constexpr int TE_EXPLFLAG_NONE = 0; // all flags clear makes default Half-Life explosion +constexpr int TE_EXPLFLAG_NOADDITIVE = 1; // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) +constexpr int TE_EXPLFLAG_NODLIGHTS = 2; // do not render dynamic lights +constexpr int TE_EXPLFLAG_NOSOUND = 4; // do not play client explosion sound +constexpr int TE_EXPLFLAG_NOPARTICLES = 8; // do not draw particles -#define TE_TAREXPLOSION 4 // Quake1 "tarbaby" explosion with sound +constexpr int TE_TAREXPLOSION = 4; // Quake1 "tarbaby" explosion with sound // coord coord coord (position) -#define TE_SMOKE 5 // alphablend sprite, move vertically 30 pps +constexpr int TE_SMOKE = 5; // alphablend sprite, move vertically 30 pps // coord coord coord (position) // short (sprite index) // byte (scale in 0.1's) // byte (framerate) -#define TE_TRACER 6 // tracer effect from point to point +constexpr int TE_TRACER = 6; // tracer effect from point to point // coord, coord, coord (start) // coord, coord, coord (end) -#define TE_LIGHTNING 7 // TE_BEAMPOINTS with simplified parameters +constexpr int TE_LIGHTNING = 7; // TE_BEAMPOINTS with simplified parameters // coord, coord, coord (start) // coord, coord, coord (end) // byte (life in 0.1's) @@ -182,7 +182,7 @@ // byte (amplitude in 0.01's) // short (sprite model index) -#define TE_BEAMENTS 8 +constexpr int TE_BEAMENTS = 8; // short (start entity) // short (end entity) // short (sprite index) @@ -195,33 +195,33 @@ // byte (brightness) // byte (scroll speed in 0.1's) -#define TE_SPARKS 9 // 8 random tracers with gravity, ricochet sprite +constexpr int TE_SPARKS = 9; // 8 random tracers with gravity, ricochet sprite // coord coord coord (position) -#define TE_LAVASPLASH 10 // Quake1 lava splash +constexpr int TE_LAVASPLASH = 10; // Quake1 lava splash // coord coord coord (position) -#define TE_TELEPORT 11 // Quake1 teleport splash +constexpr int TE_TELEPORT = 11; // Quake1 teleport splash // coord coord coord (position) -#define TE_EXPLOSION2 12 // Quake1 colormaped (base palette) particle explosion with sound +constexpr int TE_EXPLOSION2 = 12; // Quake1 colormaped (base palette) particle explosion with sound // coord coord coord (position) // byte (starting color) // byte (num colors) -#define TE_BSPDECAL 13 // Decal from the .BSP file +constexpr int TE_BSPDECAL = 13; // Decal from the .BSP file // coord, coord, coord (x,y,z), decal position (center of texture in world) // short (texture index of precached decal texture name) // short (entity index) // [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity) -#define TE_IMPLOSION 14 // tracers moving toward a point +constexpr int TE_IMPLOSION = 14; // tracers moving toward a point // coord, coord, coord (position) // byte (radius) // byte (count) // byte (life in 0.1's) -#define TE_SPRITETRAIL 15 // line of moving glow sprites with gravity, fadeout, and collisions +constexpr int TE_SPRITETRAIL = 15; // line of moving glow sprites with gravity, fadeout, and collisions // coord, coord, coord (start) // coord, coord, coord (end) // short (sprite index) @@ -231,21 +231,21 @@ // byte (velocity along vector in 10's) // byte (randomness of velocity in 10's) -#define TE_BEAM 16 // obsolete +constexpr int TE_BEAM = 16; // obsolete -#define TE_SPRITE 17 // additive sprite, plays 1 cycle +constexpr int TE_SPRITE = 17; // additive sprite, plays 1 cycle // coord, coord, coord (position) // short (sprite index) // byte (scale in 0.1's) // byte (brightness) -#define TE_BEAMSPRITE 18 // A beam with a sprite at the end +constexpr int TE_BEAMSPRITE = 18; // A beam with a sprite at the end // coord, coord, coord (start position) // coord, coord, coord (end position) // short (beam sprite index) // short (end sprite index) -#define TE_BEAMTORUS 19 // screen aligned beam ring, expands to max radius over lifetime +constexpr int TE_BEAMTORUS = 19; // screen aligned beam ring, expands to max radius over lifetime // coord coord coord (center position) // coord coord coord (axis and radius) // short (sprite index) @@ -258,7 +258,7 @@ // byte (brightness) // byte (scroll speed in 0.1's) -#define TE_BEAMDISK 20 // disk that expands to max radius over lifetime +constexpr int TE_BEAMDISK = 20; // disk that expands to max radius over lifetime // coord coord coord (center position) // coord coord coord (axis and radius) // short (sprite index) @@ -271,7 +271,7 @@ // byte (brightness) // byte (scroll speed in 0.1's) -#define TE_BEAMCYLINDER 21 // cylinder that expands to max radius over lifetime +constexpr int TE_BEAMCYLINDER = 21; // cylinder that expands to max radius over lifetime // coord coord coord (center position) // coord coord coord (axis and radius) // short (sprite index) @@ -284,7 +284,7 @@ // byte (brightness) // byte (scroll speed in 0.1's) -#define TE_BEAMFOLLOW 22 // create a line of decaying beam segments until entity stops moving +constexpr int TE_BEAMFOLLOW = 22; // create a line of decaying beam segments until entity stops moving // short (entity:attachment to follow) // short (sprite index) // byte (life in 0.1's) @@ -292,10 +292,10 @@ // byte,byte,byte (color) // byte (brightness) -#define TE_GLOWSPRITE 23 +constexpr int TE_GLOWSPRITE = 23; // coord, coord, coord (pos) short (model index) byte (scale / 10) -#define TE_BEAMRING 24 // connect a beam ring to two entities +constexpr int TE_BEAMRING = 24; // connect a beam ring to two entities // short (start entity) // short (end entity) // short (sprite index) @@ -308,7 +308,7 @@ // byte (brightness) // byte (scroll speed in 0.1's) -#define TE_STREAK_SPLASH 25 // oriented shower of tracers +constexpr int TE_STREAK_SPLASH = 25; // oriented shower of tracers // coord coord coord (start position) // coord coord coord (direction vector) // byte (color) @@ -316,9 +316,9 @@ // short (base speed) // short (ramdon velocity) -#define TE_BEAMHOSE 26 // obsolete +constexpr int TE_BEAMHOSE = 26; // obsolete -#define TE_DLIGHT 27 // dynamic light, effect world, minor entity effect +constexpr int TE_DLIGHT = 27; // dynamic light, effect world, minor entity effect // coord, coord, coord (pos) // byte (radius in 10's) // byte byte byte (color) @@ -326,7 +326,7 @@ // byte (life in 10's) // byte (decay rate in 10's) -#define TE_ELIGHT 28 // point entity light, no world effect +constexpr int TE_ELIGHT = 28; // point entity light, no world effect // short (entity:attachment to follow) // coord coord coord (initial position) // coord (radius) @@ -334,7 +334,7 @@ // byte (life in 0.1's) // coord (decay rate) -#define TE_TEXTMESSAGE 29 +constexpr int TE_TEXTMESSAGE = 29; // short 1.2.13 x (-1 = center) // short 1.2.13 y (-1 = center) // byte Effect 0 = fade in/fade out @@ -348,53 +348,53 @@ // ushort 8.8 hold time // optional ushort 8.8 fxtime (time the highlight lags behing the leading text in effect 2) // string text message (512 chars max sz string) -#define TE_LINE 30 +constexpr int TE_LINE = 30; // coord, coord, coord startpos // coord, coord, coord endpos // short life in 0.1 s // 3 bytes r, g, b -#define TE_BOX 31 +constexpr int TE_BOX = 31; // coord, coord, coord boxmins // coord, coord, coord boxmaxs // short life in 0.1 s // 3 bytes r, g, b -#define TE_KILLBEAM 99 // kill all beams attached to entity +constexpr int TE_KILLBEAM = 99; // kill all beams attached to entity // short (entity) -#define TE_LARGEFUNNEL 100 +constexpr int TE_LARGEFUNNEL = 100; // coord coord coord (funnel position) // short (sprite index) // short (flags) -#define TE_BLOODSTREAM 101 // particle spray +constexpr int TE_BLOODSTREAM = 101; // particle spray // coord coord coord (start position) // coord coord coord (spray vector) // byte (color) // byte (speed) -#define TE_SHOWLINE 102 // line of particles every 5 units, dies in 30 seconds +constexpr int TE_SHOWLINE = 102; // line of particles every 5 units, dies in 30 seconds // coord coord coord (start position) // coord coord coord (end position) -#define TE_BLOOD 103 // particle spray +constexpr int TE_BLOOD = 103; // particle spray // coord coord coord (start position) // coord coord coord (spray vector) // byte (color) // byte (speed) -#define TE_DECAL 104 // Decal applied to a brush entity (not the world) +constexpr int TE_DECAL = 104; // Decal applied to a brush entity (not the world) // coord, coord, coord (x,y,z), decal position (center of texture in world) // byte (texture index of precached decal texture name) // short (entity index) -#define TE_FIZZ 105 // create alpha sprites inside of entity, float upwards +constexpr int TE_FIZZ = 105; // create alpha sprites inside of entity, float upwards // short (entity) // short (sprite index) // byte (density) -#define TE_MODEL 106 // create a moving model that bounces and makes a sound when it hits +constexpr int TE_MODEL = 106; // create a moving model that bounces and makes a sound when it hits // coord, coord, coord (position) // coord, coord, coord (velocity) // angle (initial yaw) @@ -402,14 +402,14 @@ // byte (bounce sound type) // byte (life in 0.1's) -#define TE_EXPLODEMODEL 107 // spherical shower of models, picks from set +constexpr int TE_EXPLODEMODEL = 107; // spherical shower of models, picks from set // coord, coord, coord (origin) // coord (velocity) // short (model index) // short (count) // byte (life in 0.1's) -#define TE_BREAKMODEL 108 // box of models or sprites +constexpr int TE_BREAKMODEL = 108; // box of models or sprites // coord, coord, coord (position) // coord, coord, coord (size) // coord, coord, coord (velocity) @@ -419,12 +419,12 @@ // byte (life in 0.1 secs) // byte (flags) -#define TE_GUNSHOTDECAL 109 // decal and ricochet sound +constexpr int TE_GUNSHOTDECAL = 109; // decal and ricochet sound // coord, coord, coord (position) // short (entity index???) // byte (decal???) -#define TE_SPRITE_SPRAY 110 // spay of alpha sprites +constexpr int TE_SPRITE_SPRAY = 110; // spay of alpha sprites // coord, coord, coord (position) // coord, coord, coord (velocity) // short (sprite index) @@ -432,18 +432,18 @@ // byte (speed) // byte (noise) -#define TE_ARMOR_RICOCHET 111 // quick spark sprite, client ricochet sound. +constexpr int TE_ARMOR_RICOCHET = 111; // quick spark sprite, client ricochet sound. // coord, coord, coord (position) // byte (scale in 0.1's) -#define TE_PLAYERDECAL 112 // ??? +constexpr int TE_PLAYERDECAL = 112; // ??? // byte (playerindex) // coord, coord, coord (position) // short (entity???) // byte (decal number???) // [optional] short (model index???) -#define TE_BUBBLES 113 // create alpha sprites inside of box, float upwards +constexpr int TE_BUBBLES = 113; // create alpha sprites inside of box, float upwards // coord, coord, coord (min start position) // coord, coord, coord (max start position) // coord (float height) @@ -451,7 +451,7 @@ // byte (count) // coord (speed) -#define TE_BUBBLETRAIL 114 // create alpha sprites along a line, float upwards +constexpr int TE_BUBBLETRAIL = 114; // create alpha sprites along a line, float upwards // coord, coord, coord (min start position) // coord, coord, coord (max start position) // coord (float height) @@ -459,34 +459,34 @@ // byte (count) // coord (speed) -#define TE_BLOODSPRITE 115 // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent) +constexpr int TE_BLOODSPRITE = 115; // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent) // coord, coord, coord (position) // short (sprite1 index) // short (sprite2 index) // byte (color) // byte (scale) -#define TE_WORLDDECAL 116 // Decal applied to the world brush +constexpr int TE_WORLDDECAL = 116; // Decal applied to the world brush // coord, coord, coord (x,y,z), decal position (center of texture in world) // byte (texture index of precached decal texture name) -#define TE_WORLDDECALHIGH 117 // Decal (with texture index > 256) applied to world brush +constexpr int TE_WORLDDECALHIGH = 117; // Decal (with texture index > 256) applied to world brush // coord, coord, coord (x,y,z), decal position (center of texture in world) // byte (texture index of precached decal texture name - 256) -#define TE_DECALHIGH 118 // Same as TE_DECAL, but the texture index was greater than 256 +constexpr int TE_DECALHIGH = 118; // Same as TE_DECAL, but the texture index was greater than 256 // coord, coord, coord (x,y,z), decal position (center of texture in world) // byte (texture index of precached decal texture name - 256) // short (entity index) -#define TE_PROJECTILE 119 // Makes a projectile (like a nail) (this is a high-priority tent) +constexpr int TE_PROJECTILE = 119; // Makes a projectile (like a nail) (this is a high-priority tent) // coord, coord, coord (position) // coord, coord, coord (velocity) // short (modelindex) // byte (life) // byte (owner) projectile won't collide with owner (if owner == 0, projectile will hit any client). -#define TE_SPRAY 120 // Throws a shower of sprites or models +constexpr int TE_SPRAY = 120; // Throws a shower of sprites or models // coord, coord, coord (position) // coord, coord, coord (direction) // short (modelindex) @@ -495,19 +495,19 @@ // byte (noise) // byte (rendermode) -#define TE_PLAYERSPRITES 121 // sprites emit from a player's bounding box (ONLY use for players!) +constexpr int TE_PLAYERSPRITES = 121; // sprites emit from a player's bounding box (ONLY use for players!) // byte (playernum) // short (sprite modelindex) // byte (count) // byte (variance) (0 = no variance in size) (10 = 10% variance in size) -#define TE_PARTICLEBURST 122 // very similar to lavasplash. +constexpr int TE_PARTICLEBURST = 122; // very similar to lavasplash. // coord (origin) // short (radius) // byte (particle color) // byte (duration * 10) (will be randomized a bit) -#define TE_FIREFIELD 123 // makes a field of fire. +constexpr int TE_FIREFIELD = 123; // makes a field of fire. // coord (origin) // short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius) // short (modelindex) @@ -516,23 +516,23 @@ // byte (duration (in seconds) * 10) (will be randomized a bit) // // to keep network traffic low, this message has associated flags that fit into a byte: -#define TEFIRE_FLAG_ALLFLOAT 1 // all sprites will drift upwards as they animate -#define TEFIRE_FLAG_SOMEFLOAT 2 // some of the sprites will drift upwards. (50% chance) -#define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. -#define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque -#define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube. -#define TEFIRE_FLAG_ADDITIVE 32 // if set, sprite is rendered non-opaque with additive - -#define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent) +constexpr int TEFIRE_FLAG_ALLFLOAT = 1; // all sprites will drift upwards as they animate +constexpr int TEFIRE_FLAG_SOMEFLOAT = 2; // some of the sprites will drift upwards. (50% chance) +constexpr int TEFIRE_FLAG_LOOP = 4; // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. +constexpr int TEFIRE_FLAG_ALPHA = 8; // if set, sprite is rendered alpha blended at 50% else, opaque +constexpr int TEFIRE_FLAG_PLANAR = 16;// if set, all fire sprites have same initial Z instead of randomly filling a cube. +constexpr int TEFIRE_FLAG_ADDITIVE = 32; // if set, sprite is rendered non-opaque with additive + +constexpr int TE_PLAYERATTACHMENT = 124; // attaches a TENT to a player (this is a high-priority tent) // byte (entity index of player) // coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset ) // short (model index) // short (life * 10 ); -#define TE_KILLPLAYERATTACHMENTS 125 // will expire all TENTS attached to a player. +constexpr int TE_KILLPLAYERATTACHMENTS = 125; // will expire all TENTS attached to a player. // byte (entity index of player) -#define TE_MULTIGUNSHOT 126 // much more compact shotgun message +constexpr int TE_MULTIGUNSHOT = 126; // much more compact shotgun message // This message is used to make a client approximate a 'spray' of gunfire. // Any weapon that fires more than one bullet per frame and fires in a bit of a spread is // a good candidate for MULTIGUNSHOT use. (shotguns) @@ -551,7 +551,7 @@ // byte (count) // byte (bullethole decal texture index) -#define TE_USERTRACER 127 // larger message than the standard tracer, but allows some customization. +constexpr int TE_USERTRACER = 127; // larger message than the standard tracer, but allows some customization. // coord (origin) // coord (origin) // coord (origin) @@ -562,81 +562,79 @@ // byte ( color ) this is an index into an array of color vectors in the engine. (0 - ) // byte ( length * 10 ) -#define MSG_BROADCAST 0 // unreliable to all -#define MSG_ONE 1 // reliable to one (msg_entity) -#define MSG_ALL 2 // reliable to all -#define MSG_INIT 3 // write to the init string -#define MSG_PVS 4 // Ents in PVS of org -#define MSG_PAS 5 // Ents in PAS of org -#define MSG_PVS_R 6 // Reliable to PVS -#define MSG_PAS_R 7 // Reliable to PAS -#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) -#define MSG_SPEC 9 // Sends to all spectator proxies +constexpr int MSG_BROADCAST = 0; // unreliable to all +constexpr int MSG_ONE = 1; // reliable to one (msg_entity) +constexpr int MSG_ALL = 2; // reliable to all +constexpr int MSG_INIT = 3; // write to the init string +constexpr int MSG_PVS = 4; // Ents in PVS of org +constexpr int MSG_PAS = 5; // Ents in PAS of org +constexpr int MSG_PVS_R = 6; // Reliable to PVS +constexpr int MSG_PAS_R = 7; // Reliable to PAS +constexpr int MSG_ONE_UNRELIABLE = 8; // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) +constexpr int MSG_SPEC = 9; // Sends to all spectator proxies // contents of a spot in the world -#define CONTENTS_EMPTY -1 -#define CONTENTS_SOLID -2 -#define CONTENTS_WATER -3 -#define CONTENTS_SLIME -4 -#define CONTENTS_LAVA -5 -#define CONTENTS_SKY -6 +constexpr int CONTENTS_EMPTY = -1; +constexpr int CONTENTS_SOLID = -2; +constexpr int CONTENTS_WATER = -3; +constexpr int CONTENTS_SLIME = -4; +constexpr int CONTENTS_LAVA = -5; +constexpr int CONTENTS_SKY = -6; /* These additional contents constants are defined in bspfile.h -#define CONTENTS_ORIGIN -7 // removed at csg time -#define CONTENTS_CLIP -8 // changed to contents_solid -#define CONTENTS_CURRENT_0 -9 -#define CONTENTS_CURRENT_90 -10 -#define CONTENTS_CURRENT_180 -11 -#define CONTENTS_CURRENT_270 -12 -#define CONTENTS_CURRENT_UP -13 -#define CONTENTS_CURRENT_DOWN -14 - -#define CONTENTS_TRANSLUCENT -15 +constexpr int CONTENTS_ORIGIN -7 // removed at csg time +constexpr int CONTENTS_CLIP -8 // changed to contents_solid +constexpr int CONTENTS_CURRENT_0 -9 +constexpr int CONTENTS_CURRENT_90 -10 +constexpr int CONTENTS_CURRENT_180 -11 +constexpr int CONTENTS_CURRENT_270 -12 +constexpr int CONTENTS_CURRENT_UP -13 +constexpr int CONTENTS_CURRENT_DOWN -14 + +constexpr int CONTENTS_TRANSLUCENT -15 */ -#define CONTENTS_LADDER -16 - -#define CONTENT_FLYFIELD -17 -#define CONTENT_GRAVITY_FLYFIELD -18 -#define CONTENT_FOG -19 - -#define CONTENT_EMPTY -1 -#define CONTENT_SOLID -2 -#define CONTENT_WATER -3 -#define CONTENT_SLIME -4 -#define CONTENT_LAVA -5 -#define CONTENT_SKY -6 +constexpr int CONTENTS_LADDER = -16; +constexpr int CONTENT_FLYFIELD = -17; +constexpr int CONTENT_GRAVITY_FLYFIELD = -18; +constexpr int CONTENT_FOG = -19; +constexpr int CONTENT_EMPTY = -1; +constexpr int CONTENT_SOLID = -2; +constexpr int CONTENT_WATER = -3; +constexpr int CONTENT_SLIME = -4; +constexpr int CONTENT_LAVA = -5; +constexpr int CONTENT_SKY = -6; // channels -#define CHAN_AUTO 0 -#define CHAN_WEAPON 1 -#define CHAN_VOICE 2 -#define CHAN_ITEM 3 -#define CHAN_BODY 4 -#define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area -#define CHAN_STATIC 6 // allocate channel from the static area -#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network -#define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). +constexpr int CHAN_AUTO = 0; +constexpr int CHAN_WEAPON = 1; +constexpr int CHAN_VOICE = 2; +constexpr int CHAN_ITEM = 3; +constexpr int CHAN_BODY = 4; +constexpr int CHAN_STREAM = 5; // allocate stream channel from the static or dynamic area +constexpr int CHAN_STATIC = 6; // allocate channel from the static area +constexpr int CHAN_NETWORKVOICE_BASE = 7; // voice data coming across the network +constexpr int CHAN_NETWORKVOICE_END = 500; // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). // attenuation values -#define ATTN_NONE 0 -#define ATTN_NORM (float)0.8 -#define ATTN_IDLE (float)2 -#define ATTN_STATIC (float)1.25 +constexpr float ATTN_NONE = 0.0f; +constexpr float ATTN_NORM = 0.8f; +constexpr float ATTN_IDLE = 2.0f; +constexpr float ATTN_STATIC = 1.25f; // pitch values -#define PITCH_NORM 100 // non-pitch shifted -#define PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high -#define PITCH_HIGH 120 +constexpr int PITCH_NORM = 100; // non-pitch shifted +constexpr int PITCH_LOW = 95; // other values are possible - 0-255, where 255 is very high +constexpr int PITCH_HIGH = 120; // volume values -#define VOL_NORM 1.0 +constexpr float VOL_NORM = 1.0; // plats -#define PLAT_LOW_TRIGGER 1 +constexpr int PLAT_LOW_TRIGGER = 1; // Trains -#define SF_TRAIN_WAIT_RETRIGGER 1 -#define SF_TRAIN_START_ON 4 // Train is initially moving -#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains +constexpr int SF_TRAIN_WAIT_RETRIGGER = 1; +constexpr int SF_TRAIN_START_ON = 4; // Train is initially moving +constexpr int SF_TRAIN_PASSABLE = 8; // Train is not solid -- used to make water trains // buttons #ifndef IN_BUTTONS_H @@ -645,32 +643,31 @@ // Break Model Defines -#define BREAK_TYPEMASK 0x4F -#define BREAK_GLASS 0x01 -#define BREAK_METAL 0x02 -#define BREAK_FLESH 0x04 -#define BREAK_WOOD 0x08 - -#define BREAK_SMOKE 0x10 -#define BREAK_TRANS 0x20 -#define BREAK_CONCRETE 0x40 -#define BREAK_2 0x80 +constexpr int BREAK_TYPEMASK = 0x4F; +constexpr int BREAK_GLASS = 0x01; +constexpr int BREAK_METAL = 0x02; +constexpr int BREAK_FLESH = 0x04; +constexpr int BREAK_WOOD = 0x08; +constexpr int BREAK_SMOKE = 0x10; +constexpr int BREAK_TRANS = 0x20; +constexpr int BREAK_CONCRETE = 0x40; +constexpr int BREAK_2 = 0x80; // Colliding temp entity sounds -#define BOUNCE_GLASS BREAK_GLASS -#define BOUNCE_METAL BREAK_METAL -#define BOUNCE_FLESH BREAK_FLESH -#define BOUNCE_WOOD BREAK_WOOD -#define BOUNCE_SHRAP 0x10 -#define BOUNCE_SHELL 0x20 -#define BOUNCE_CONCRETE BREAK_CONCRETE -#define BOUNCE_SHOTSHELL 0x80 +constexpr int BOUNCE_GLASS = BREAK_GLASS; +constexpr int BOUNCE_METAL = BREAK_METAL; +constexpr int BOUNCE_FLESH = BREAK_FLESH; +constexpr int BOUNCE_WOOD = BREAK_WOOD; +constexpr int BOUNCE_SHRAP = 0x10; +constexpr int BOUNCE_SHELL = 0x20; +constexpr int BOUNCE_CONCRETE = BREAK_CONCRETE; +constexpr int BOUNCE_SHOTSHELL = 0x80; // Temp entity bounce sound types -#define TE_BOUNCE_NULL 0 -#define TE_BOUNCE_SHELL 1 -#define TE_BOUNCE_SHOTSHELL 2 +constexpr int TE_BOUNCE_NULL = 0; +constexpr int TE_BOUNCE_SHELL = 1; +constexpr int TE_BOUNCE_SHOTSHELL = 2; // Rendering constants enum From 12f1fb1e9cedcd2f22dbee5f6afc0bb13f22dd2a Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Fri, 6 Mar 2026 00:03:50 -0500 Subject: [PATCH 002/291] resolving merge conflict --- src/common/const.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/const.h b/src/common/const.h index 1db60ce8..6a2fdcb8 100644 --- a/src/common/const.h +++ b/src/common/const.h @@ -41,10 +41,10 @@ constexpr int FL_FLOAT = (1 << 15); // Apply floating force to this entity wh constexpr int FL_GRAPHED = (1 << 16); // worldgraph has this ent listed as something that blocks a connection // UNDONE: Do we need these? -#define FL_IMMUNE_WATER (1 << 17) +constexpr int FL_IMMUNE_WATER = (1 << 17); //#define FL_IMMUNE_SLIME (1 << 18) -#define FL_CLIENTONLY (1 << 18) // Strip edicts -#define FL_IMMUNE_LAVA (1 << 19) +constexpr int FL_CLIENTONLY = (1 << 18); // Strip edicts +constexpr int FL_IMMUNE_LAVA = (1 << 19); constexpr int FL_PROXY = (1 << 20); // This is a spectator proxy constexpr int FL_ALWAYSTHINK = (1 << 21); // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) From 4702e80b2d95bff92975d742000c7a56009e0b74 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Fri, 6 Mar 2026 00:04:32 -0500 Subject: [PATCH 003/291] Remove debug call causing compile error. ItemThinkProgress type not found. --- src/game/shared/weapons/giattack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/shared/weapons/giattack.cpp b/src/game/shared/weapons/giattack.cpp index 78b440c6..0f20fd9f 100644 --- a/src/game/shared/weapons/giattack.cpp +++ b/src/game/shared/weapons/giattack.cpp @@ -780,7 +780,7 @@ void CGenericItem::StrikeLand() if (bUnderleveled) flDamage *= 0.5; //this might be working - SetDebugProgress(ItemThinkProgress, "CGenericItem::StrikeLand - Call DoDamage"); + //SetDebugProgress(ItemThinkProgress, "CGenericItem::StrikeLand - Call DoDamage"); int bitsDamage = DMG_CLUB; if (!m_pPlayer) bitsDamage |= DMG_SIMPLEBBOX; From b6225f308f71dc792b1b86f07f5330b07d0e52e8 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Fri, 6 Mar 2026 08:59:57 -0500 Subject: [PATCH 004/291] Removed unsigned --- src/common/beamdef.h | 4 ++-- src/common/cl_entity.h | 4 ++-- src/common/com_model.h | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/common/beamdef.h b/src/common/beamdef.h index ecd14bcf..69876ceb 100644 --- a/src/common/beamdef.h +++ b/src/common/beamdef.h @@ -26,8 +26,8 @@ constexpr int FBEAM_SINENOISE = 0x00000010; constexpr int FBEAM_SOLID = 0x00000020; constexpr int FBEAM_SHADEIN = 0x00000040; constexpr int FBEAM_SHADEOUT = 0x00000080; -constexpr int FBEAM_STARTVISIBLE = 0x10000000; // Has this client actually seen this beam's start e= ntity yet?; -constexpr int FBEAM_ENDVISIBLE = 0x20000000; // Has this client actually seen this beam's end e= ntity yet?; +constexpr int FBEAM_STARTVISIBLE = 0x10000000; // Has this client actually seen this beam's start entity yet?; +constexpr int FBEAM_ENDVISIBLE = 0x20000000; // Has this client actually seen this beam's end entity yet?; constexpr int FBEAM_ISACTIVE = 0x40000000; constexpr int FBEAM_FOREVER = 0x80000000; diff --git a/src/common/cl_entity.h b/src/common/cl_entity.h index 0ff88bc8..c6b2f646 100644 --- a/src/common/cl_entity.h +++ b/src/common/cl_entity.h @@ -60,8 +60,8 @@ typedef struct typedef struct cl_entity_s cl_entity_t; -constexpr unsigned int HISTORY_MAX = 64; // Must be power of 2 -constexpr unsigned int HISTORY_MASK = (HISTORY_MAX - 1); +constexpr int HISTORY_MAX = 64; // Must be power of 2 +constexpr int HISTORY_MASK = (HISTORY_MAX - 1); #if !defined(ENTITY_STATEH) #include "entity_state.h" diff --git a/src/common/com_model.h b/src/common/com_model.h index e138cf38..0299728f 100644 --- a/src/common/com_model.h +++ b/src/common/com_model.h @@ -24,16 +24,16 @@ #pragma once #endif -constexpr unsigned int STUDIO_RENDER = 1; -constexpr unsigned int STUDIO_EVENTS = 2; -constexpr unsigned int MAX_MAP_HULLS = 4; -constexpr unsigned int MIPLEVELS = 4; -constexpr unsigned int NUM_AMBIENTS = 4; // automatic ambient sounds -constexpr unsigned int MAXLIGHTMAPS = 4; -constexpr unsigned int PLANE_ANYZ = 5; -constexpr unsigned int MAX_CLIENTS = 32; -constexpr unsigned int MAX_MODEL_NAME = 64; -constexpr unsigned int MAX_EDICTS = 2048; +constexpr int STUDIO_RENDER = 1; +constexpr int STUDIO_EVENTS = 2; +constexpr int MAX_MAP_HULLS = 4; +constexpr int MIPLEVELS = 4; +constexpr int NUM_AMBIENTS = 4; // automatic ambient sounds +constexpr int MAXLIGHTMAPS = 4; +constexpr int PLANE_ANYZ = 5; +constexpr int MAX_CLIENTS = 32; +constexpr int MAX_MODEL_NAME = 64; +constexpr int MAX_EDICTS = 2048; constexpr unsigned int ALIAS_Z_CLIP_PLANE = 5; From 39b0bc983a0946a0906c0125e23d90cb78bed538 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:04:37 -0500 Subject: [PATCH 005/291] Fixed commented line syntax as precaution incase uncommented. --- src/common/const.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/common/const.h b/src/common/const.h index 6a2fdcb8..d505c04f 100644 --- a/src/common/const.h +++ b/src/common/const.h @@ -581,16 +581,16 @@ constexpr int CONTENTS_SLIME = -4; constexpr int CONTENTS_LAVA = -5; constexpr int CONTENTS_SKY = -6; /* These additional contents constants are defined in bspfile.h -constexpr int CONTENTS_ORIGIN -7 // removed at csg time -constexpr int CONTENTS_CLIP -8 // changed to contents_solid -constexpr int CONTENTS_CURRENT_0 -9 -constexpr int CONTENTS_CURRENT_90 -10 -constexpr int CONTENTS_CURRENT_180 -11 -constexpr int CONTENTS_CURRENT_270 -12 -constexpr int CONTENTS_CURRENT_UP -13 -constexpr int CONTENTS_CURRENT_DOWN -14 - -constexpr int CONTENTS_TRANSLUCENT -15 +constexpr int CONTENTS_ORIGIN = -7; // removed at csg time +constexpr int CONTENTS_CLIP = -8; // changed to contents_solid +constexpr int CONTENTS_CURRENT_0 = -9; +constexpr int CONTENTS_CURRENT_90 = -10; +constexpr int CONTENTS_CURRENT_180 = -11; +constexpr int CONTENTS_CURRENT_270 = -12; +constexpr int CONTENTS_CURRENT_UP = -13; +constexpr int CONTENTS_CURRENT_DOWN = -14; + +constexpr int CONTENTS_TRANSLUCENT = -15; */ constexpr int CONTENTS_LADDER = -16; constexpr int CONTENT_FLYFIELD = -17; From 99c7d3012af03246093cfb0f3dc4ecab78985ca7 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sat, 7 Mar 2026 03:19:35 -0500 Subject: [PATCH 006/291] changes more macros to constexpr --- src/common/const.h | 2 +- src/common/cvardef.h | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/common/const.h b/src/common/const.h index d505c04f..b0ab4a66 100644 --- a/src/common/const.h +++ b/src/common/const.h @@ -42,7 +42,7 @@ constexpr int FL_GRAPHED = (1 << 16); // worldgraph has this ent listed as so // UNDONE: Do we need these? constexpr int FL_IMMUNE_WATER = (1 << 17); -//#define FL_IMMUNE_SLIME (1 << 18) +//constexpr int FL_IMMUNE_SLIME (1 << 18); constexpr int FL_CLIENTONLY = (1 << 18); // Strip edicts constexpr int FL_IMMUNE_LAVA = (1 << 19); diff --git a/src/common/cvardef.h b/src/common/cvardef.h index 979e7e42..fcde0475 100644 --- a/src/common/cvardef.h +++ b/src/common/cvardef.h @@ -15,20 +15,20 @@ #ifndef CVARDEF_H #define CVARDEF_H -#define FCVAR_ARCHIVE (1 << 0) // set to cause it to be saved to vars.rc -#define FCVAR_USERINFO (1 << 1) // changes the client's info string -#define FCVAR_SERVER (1 << 2) // notifies players when changed -#define FCVAR_EXTDLL (1 << 3) // defined by external DLL -#define FCVAR_CLIENTDLL (1 << 4) // defined by the client dll -#define FCVAR_PROTECTED (1 << 5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value -#define FCVAR_SPONLY (1 << 6) // This cvar cannot be changed by clients connected to a multiplayer server. -#define FCVAR_PRINTABLEONLY (1 << 7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). -#define FCVAR_UNLOGGED (1 << 8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log -#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar -#define FCVAR_PRIVILEGED (1 << 10) // only available in privileged mode -#define FCVAR_FILTERABLE (1 << 11) // filtered in unprivileged mode if cl_filterstuffcmd is 1 -#define FCVAR_ISEXECUTED (1 << 12) // This cvar's string contains a value that will be executed as a cfg file; don't allow commands to be appended to it -#define FCVAR_ISPATH (1 << 13) // This cvar's string is a path or filename; don't allow absolute paths, escaping to another directory or backslashes +constexpr int FCVAR_ARCHIVE = (1 << 0); // set to cause it to be saved to vars.rc +constexpr int FCVAR_USERINFO = (1 << 1); // changes the client's info string +constexpr int FCVAR_SERVER = (1 << 2); // notifies players when changed +constexpr int FCVAR_EXTDLL = (1 << 3); // defined by external DLL +constexpr int FCVAR_CLIENTDLL = (1 << 4); // defined by the client dll +constexpr int FCVAR_PROTECTED = (1 << 5); // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value +constexpr int FCVAR_SPONLY = (1 << 6); // This cvar cannot be changed by clients connected to a multiplayer server. +constexpr int FCVAR_PRINTABLEONLY = (1 << 7);// This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). +constexpr int FCVAR_UNLOGGED = (1 << 8); // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log +constexpr int FCVAR_NOEXTRAWHITEPACE = (1 << 9); // strip trailing/leading white space from this cvar +constexpr int FCVAR_PRIVILEGED = (1 << 10); // only available in privileged mode +constexpr int FCVAR_FILTERABLE = (1 << 11); // filtered in unprivileged mode if cl_filterstuffcmd is 1 +constexpr int FCVAR_ISEXECUTED = (1 << 12);// This cvar's string contains a value that will be executed as a cfg file; don't allow commands to be appended to it +constexpr int FCVAR_ISPATH = (1 << 13);// This cvar's string is a path or filename; don't allow absolute paths, escaping to another directory or backslashes typedef struct cvar_s { From 1e75ea2603274e78f0d33bdd792c0e1dd7ad06b7 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sat, 7 Mar 2026 03:23:37 -0500 Subject: [PATCH 007/291] changed more macros to constexpr --- src/common/director_cmds.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/common/director_cmds.h b/src/common/director_cmds.h index ddff7e08..852b955c 100644 --- a/src/common/director_cmds.h +++ b/src/common/director_cmds.h @@ -8,26 +8,26 @@ // director_cmds.h // sub commands for svc_director -#define DRC_ACTIVE 0 // tells client that he's an spectator and will get director command -#define DRC_STATUS 1 // send status infos about proxy -#define DRC_CAMERA 2 // set the actual director camera position -#define DRC_EVENT 3 // informs the dircetor about ann important game event +constexpr int DRC_ACTIVE = 0; // tells client that he's an spectator and will get director command +constexpr int DRC_STATUS = 1; // send status infos about proxy +constexpr int DRC_CAMERA = 2; // set the actual director camera position +constexpr int DRC_EVENT = 3; // informs the dircetor about ann important game event -#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) -#define DRC_FLAG_SIDE (1 << 4) -#define DRC_FLAG_DRAMATIC (1 << 5) +constexpr int DRC_FLAG_PRIO_MASK = 0x0F; // priorities between 0 and 15 (15 most important) +constexpr int DRC_FLAG_SIDE = (1 << 4); +constexpr int DRC_FLAG_DRAMATIC = (1 << 5); // commands of the director API function CallDirectorProc(...) -#define DRCAPI_NOP 0 // no operation -#define DRCAPI_ACTIVE 1 // de/acivates director mode in engine -#define DRCAPI_STATUS 2 // request proxy information -#define DRCAPI_SETCAM 3 // set camera n to given position and angle -#define DRCAPI_GETCAM 4 // request camera n position and angle -#define DRCAPI_DIRPLAY 5 // set director time and play with normal speed -#define DRCAPI_DIRFREEZE 6 // freeze directo at this time -#define DRCAPI_SETVIEWMODE 7 // overview or 4 cameras -#define DRCAPI_SETOVERVIEWPARAMS 8 // sets parameter for overview mode -#define DRCAPI_SETFOCUS 9 // set the camera which has the input focus -#define DRCAPI_GETTARGETS 10 // queries engine for player list -#define DRCAPI_SETVIEWPOINTS 11 // gives engine all waypoints +constexpr int DRCAPI_NOP = 0; // no operation +constexpr int DRCAPI_ACTIVE = 1; // de/acivates director mode in engine +constexpr int DRCAPI_STATUS = 2; // request proxy information +constexpr int DRCAPI_SETCAM = 3; // set camera n to given position and angle +constexpr int DRCAPI_GETCAM = 4; // request camera n position and angle +constexpr int DRCAPI_DIRPLAY = 5; // set director time and play with normal speed +constexpr int DRCAPI_DIRFREEZE = 6; // freeze directo at this time +constexpr int DRCAPI_SETVIEWMODE = 7; // overview or 4 cameras +constexpr int DRCAPI_SETOVERVIEWPARAMS = 8; // sets parameter for overview mode +constexpr int DRCAPI_SETFOCUS = 9; // set the camera which has the input focus +constexpr int DRCAPI_GETTARGETS = 10; // queries engine for player list +constexpr int DRCAPI_SETVIEWPOINTS = 11; // gives engine all waypoints From b8c0fda959cd28debc19474fc52b7c76e8942fbb Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sat, 7 Mar 2026 03:25:00 -0500 Subject: [PATCH 008/291] Changed more macros to constexpr int --- src/common/dll_state.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/common/dll_state.h b/src/common/dll_state.h index a23ae742..9fb3eba2 100644 --- a/src/common/dll_state.h +++ b/src/common/dll_state.h @@ -7,17 +7,17 @@ //DLL State Flags -#define DLL_INACTIVE 0 // no dll -#define DLL_ACTIVE 1 // dll is running -#define DLL_PAUSED 2 // dll is paused -#define DLL_CLOSE 3 // closing down dll -#define DLL_TRANS 4 // Level Transition +constexpr int DLL_INACTIVE = 0; // no dll +constexpr int DLL_ACTIVE = 1; // dll is running +constexpr int DLL_PAUSED = 2; // dll is paused +constexpr int DLL_CLOSE = 3; // closing down dll +constexpr int DLL_TRANS = 4; // Level Transition // DLL Pause reasons -#define DLL_NORMAL 0 // User hit Esc or something. -#define DLL_QUIT 4 // Quit now -#define DLL_RESTART 6 // Switch to launcher for linux, does a quit but returns 1 +constexpr int DLL_NORMAL = 0; // User hit Esc or something. +constexpr int DLL_QUIT = 4; // Quit now +constexpr int DLL_RESTART = 6; // Switch to launcher for linux, does a quit but returns 1 // DLL Substate info ( not relevant ) -#define ENG_NORMAL (1 << 0) +constexpr int ENG_NORMAL = (1 << 0); From fb982ece5878535311cd6fda6b48d6f7a5a9eb7a Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sat, 7 Mar 2026 03:26:11 -0500 Subject: [PATCH 009/291] changed more macros to constexpr --- src/common/engine_launcher_api.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/engine_launcher_api.h b/src/common/engine_launcher_api.h index 503c7aad..59bc7563 100644 --- a/src/common/engine_launcher_api.h +++ b/src/common/engine_launcher_api.h @@ -14,11 +14,11 @@ //typedef void ( *xcommand_t ) ( void ); -#define RENDERTYPE_UNDEFINED 0 -#define RENDERTYPE_SOFTWARE 1 -#define RENDERTYPE_HARDWARE 2 +constexpr int RENDERTYPE_UNDEFINED = 0; +constexpr int RENDERTYPE_SOFTWARE = 1; +constexpr int RENDERTYPE_HARDWARE = 2; -#define ENGINE_LAUNCHER_API_VERSION 1 +constexpr int ENGINE_LAUNCHER_API_VERSION = 1; typedef struct engine_api_s { From bbd769817bf54886f6fbe3af2692cea8ba93664e Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sat, 7 Mar 2026 03:27:12 -0500 Subject: [PATCH 010/291] Changed more macros to constexpr --- src/common/entity_state.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/entity_state.h b/src/common/entity_state.h index e26c99a4..7acc136a 100644 --- a/src/common/entity_state.h +++ b/src/common/entity_state.h @@ -19,8 +19,8 @@ #endif // For entityType below -#define ENTITY_NORMAL (1 << 0) -#define ENTITY_BEAM (1 << 1) +constexpr int ENTITY_NORMAL = (1 << 0); +constexpr int ENTITY_BEAM = (1 << 1); // Entity state is used for the baseline and for delta compression of a packet of // entities that is sent to a client. From 993ccc5b0f22a4f3041507cf118edeb48f7d947d Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sat, 7 Mar 2026 03:29:25 -0500 Subject: [PATCH 011/291] fixed constexpr inited as unsignedf. --- src/common/com_model.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/com_model.h b/src/common/com_model.h index 0299728f..ffdfb681 100644 --- a/src/common/com_model.h +++ b/src/common/com_model.h @@ -35,7 +35,7 @@ constexpr int MAX_CLIENTS = 32; constexpr int MAX_MODEL_NAME = 64; constexpr int MAX_EDICTS = 2048; -constexpr unsigned int ALIAS_Z_CLIP_PLANE = 5; +constexpr int ALIAS_Z_CLIP_PLANE = 5; // flags in finalvert_t.flags constexpr int ALIAS_LEFT_CLIP = 0x0001; From 00255a5927096a2407375266c25cd3c8a8ecb74a Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sat, 7 Mar 2026 03:54:21 -0500 Subject: [PATCH 012/291] Changed macros to constexpr where applicable --- src/common/entity_types.h | 10 +++---- src/common/event_args.h | 4 +-- src/common/event_flags.h | 14 ++++----- src/common/hltv.h | 61 +++++++++++++++++++-------------------- src/common/interface.cpp | 1 + src/common/interface.h | 3 +- src/public/interface.h | 2 +- 7 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/common/entity_types.h b/src/common/entity_types.h index 473793f5..3cfd8ca6 100644 --- a/src/common/entity_types.h +++ b/src/common/entity_types.h @@ -16,11 +16,11 @@ #if !defined(ENTITY_TYPESH) #define ENTITY_TYPESH -#define ET_NORMAL 0 -#define ET_PLAYER 1 -#define ET_TEMPENTITY 2 -#define ET_BEAM 3 +constexpr int ET_NORMAL = 0; +constexpr int ET_PLAYER = 1; +constexpr int ET_TEMPENTITY = 2; +constexpr int ET_BEAM = 3; // BMODEL or SPRITE that was split across BSP nodes -#define ET_FRAGMENTED 4 +constexpr int ET_FRAGMENTED = 4; #endif // !ENTITY_TYPESH diff --git a/src/common/event_args.h b/src/common/event_args.h index 01bfe051..e4d732d9 100644 --- a/src/common/event_args.h +++ b/src/common/event_args.h @@ -19,10 +19,10 @@ #endif // Event was invoked with stated origin -#define FEVENT_ORIGIN (1 << 0) +constexpr int FEVENT_ORIGIN = (1 << 0); // Event was invoked with stated angles -#define FEVENT_ANGLES (1 << 1) +constexpr int FEVENT_ANGLES = (1 << 1); typedef struct event_args_s { diff --git a/src/common/event_flags.h b/src/common/event_flags.h index ba4a768d..7e6c4f7d 100644 --- a/src/common/event_flags.h +++ b/src/common/event_flags.h @@ -19,29 +19,29 @@ #endif // Skip local host for event send. -#define FEV_NOTHOST (1 << 0) +constexpr int FEV_NOTHOST = (1 << 0); // Send the event reliably. You must specify the origin and angles and use // PLAYBACK_EVENT_FULL for this to work correctly on the server for anything // that depends on the event origin/angles. I.e., the origin/angles are not // taken from the invoking edict for reliable events. -#define FEV_RELIABLE (1 << 1) +constexpr int FEV_RELIABLE = (1 << 1); // Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC // sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ). -#define FEV_GLOBAL (1 << 2) +constexpr int FEV_GLOBAL = (1 << 2); // If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate // -#define FEV_UPDATE (1 << 3) +constexpr int FEV_UPDATE = (1 << 3); // Only send to entity specified as the invoker -#define FEV_HOSTONLY (1 << 4) +constexpr int FEV_HOSTONLY = (1 << 4); // Only send if the event was created on the server. -#define FEV_SERVER (1 << 5) +constexpr int FEV_SERVER = (1 << 5); // Only issue event client side ( from shared code ) -#define FEV_CLIENT (1 << 6) +constexpr int FEV_CLIENT = (1 << 6); #endif diff --git a/src/common/hltv.h b/src/common/hltv.h index 4b6deca1..8dafe189 100644 --- a/src/common/hltv.h +++ b/src/common/hltv.h @@ -11,43 +11,42 @@ #ifndef HLTV_H #define HLTV_H -#define TYPE_CLIENT 0 // client is a normal HL client (default) -#define TYPE_PROXY 1 // client is another proxy -#define TYPE_COMMENTATOR 3 // client is a commentator -#define TYPE_DEMO 4 // client is a demo file +constexpr int TYPE_CLIENT = 0; // client is a normal HL client (default) +constexpr int TYPE_PROXY = 1; // client is another proxy +constexpr int TYPE_COMMENTATOR = 3; // client is a commentator +constexpr int TYPE_DEMO = 4; // client is a demo file // sub commands of svc_hltv: -#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands -#define HLTV_STATUS 1 // send status infos about proxy -#define HLTV_LISTEN 2 // tell client to listen to a multicast stream +constexpr int HLTV_ACTIVE = 0; // tells client that he's an spectator and will get director commands +constexpr int HLTV_STATUS = 1; // send status infos about proxy +constexpr int HLTV_LISTEN = 2; // tell client to listen to a multicast stream // sub commands of svc_director: -#define DRC_CMD_NONE 0 // NULL director command -#define DRC_CMD_START 1 // start director mode -#define DRC_CMD_EVENT 2 // informs about director command -#define DRC_CMD_MODE 3 // switches camera modes -#define DRC_CMD_CAMERA 4 // sets camera registers -#define DRC_CMD_TIMESCALE 5 // sets time scale -#define DRC_CMD_MESSAGE 6 // send HUD centerprint -#define DRC_CMD_SOUND 7 // plays a particular sound -#define DRC_CMD_STATUS 8 // status info about broadcast -#define DRC_CMD_BANNER 9 // banner file name for HLTV gui -#define DRC_CMD_FADE 10 // send screen fade command -#define DRC_CMD_SHAKE 11 // send screen shake command -#define DRC_CMD_STUFFTEXT 12 // like the normal svc_stufftext but as director command +constexpr int DRC_CMD_NONE = 0; // NULL director command +constexpr int DRC_CMD_START = 1; // start director mode +constexpr int DRC_CMD_EVENT = 2; // informs about director command +constexpr int DRC_CMD_MODE = 3; // switches camera modes +constexpr int DRC_CMD_CAMERA = 4; // sets camera registers +constexpr int DRC_CMD_TIMESCALE = 5; // sets time scale +constexpr int DRC_CMD_MESSAGE = 6; // send HUD centerprint +constexpr int DRC_CMD_SOUND = 7; // plays a particular sound +constexpr int DRC_CMD_STATUS = 8; // status info about broadcast +constexpr int DRC_CMD_BANNER = 9; // banner file name for HLTV gui +constexpr int DRC_CMD_FADE = 10; // send screen fade command +constexpr int DRC_CMD_SHAKE = 11; // send screen shake command +constexpr int DRC_CMD_STUFFTEXT = 12; // like the normal svc_stufftext but as director command #define DRC_CMD_LAST 12 // HLTV_EVENT event flags -#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) -#define DRC_FLAG_SIDE (1 << 4) // -#define DRC_FLAG_DRAMATIC (1 << 5) // is a dramatic scene -#define DRC_FLAG_SLOWMOTION (1 << 6) // would look good in SloMo -#define DRC_FLAG_FACEPLAYER (1 << 7) // player is doning something (reload/defuse bomb etc) -#define DRC_FLAG_INTRO (1 << 8) // is a introduction scene -#define DRC_FLAG_FINAL (1 << 9) // is a final scene -#define DRC_FLAG_NO_RANDOM (1 << 10) // don't randomize event data - -#define MAX_DIRECTOR_CMD_PARAMETERS 4 -#define MAX_DIRECTOR_CMD_STRING 128 +constexpr int DRC_FLAG_PRIO_MASK = 0x0F; // priorities between 0 and 15 (15 most important) +constexpr int DRC_FLAG_SIDE = (1 << 4); // +constexpr int DRC_FLAG_DRAMATIC = (1 << 5); // is a dramatic scene +constexpr int DRC_FLAG_SLOWMOTION = (1 << 6); // would look good in SloMo +constexpr int DRC_FLAG_FACEPLAYER = (1 << 7); // player is doning something (reload/defuse bomb etc) +constexpr int DRC_FLAG_INTRO = (1 << 8); // is a introduction scene +constexpr int DRC_FLAG_FINAL = (1 << 9); // is a final scene +constexpr int DRC_FLAG_NO_RANDOM = (1 << 10); // don't randomize event data +constexpr int MAX_DIRECTOR_CMD_PARAMETERS = 4; +constexpr int MAX_DIRECTOR_CMD_STRING = 128; #endif // HLTV_H diff --git a/src/common/interface.cpp b/src/common/interface.cpp index 3a4e1ea8..40c5900c 100644 --- a/src/common/interface.cpp +++ b/src/common/interface.cpp @@ -61,6 +61,7 @@ EXPORT_FUNCTION IBaseInterface *CreateInterface(const char *pName, int *pReturnC #ifdef _WIN32 HINTERFACEMODULE Sys_LoadModule(const char *pModuleName) { + //preprocessor protection return (HINTERFACEMODULE)LoadLibrary(pModuleName); } diff --git a/src/common/interface.h b/src/common/interface.h index bdbd57c8..16b467fa 100644 --- a/src/common/interface.h +++ b/src/common/interface.h @@ -32,7 +32,7 @@ class IBaseInterface virtual ~IBaseInterface() {} }; -#define CREATEINTERFACE_PROCNAME "CreateInterface" +constexpr const char* CREATEINTERFACE_PROCNAME = "CreateInterface"; typedef IBaseInterface *(*CreateInterfaceFn)(const char *pName, int *pReturnCode); typedef IBaseInterface *(*InstantiateInterfaceFn)(); @@ -80,6 +80,7 @@ class InterfaceReg EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton) #ifdef WIN32 +//this is recommended standard practice, keep this as macro. #define EXPORT_FUNCTION __declspec(dllexport) #else #define EXPORT_FUNCTION diff --git a/src/public/interface.h b/src/public/interface.h index 82b8fe04..39cc0bf8 100644 --- a/src/public/interface.h +++ b/src/public/interface.h @@ -43,8 +43,8 @@ class IBaseInterface virtual ~IBaseInterface() {} }; +constexpr const char* CREATEINTERFACE_PROCNAME = "CreateInterface"; -#define CREATEINTERFACE_PROCNAME "CreateInterface" typedef IBaseInterface* (*CreateInterfaceFn)(const char *pName, int *pReturnCode); From fadbe4edb87d30c846ef2bb2dcd9ef265e60788d Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sat, 7 Mar 2026 18:36:25 -0500 Subject: [PATCH 013/291] Changed macros to constexpr --- src/common/in_buttons.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/common/in_buttons.h b/src/common/in_buttons.h index 79129201..c16a2bc4 100644 --- a/src/common/in_buttons.h +++ b/src/common/in_buttons.h @@ -18,21 +18,21 @@ #pragma once #endif -#define IN_ATTACK (1 << 0) -#define IN_JUMP (1 << 1) -#define IN_DUCK (1 << 2) -#define IN_FORWARD (1 << 3) -#define IN_BACK (1 << 4) -#define IN_USE (1 << 5) -#define IN_CANCEL (1 << 6) -#define IN_LEFT (1 << 7) -#define IN_RIGHT (1 << 8) -#define IN_MOVELEFT (1 << 9) -#define IN_MOVERIGHT (1 << 10) -#define IN_ATTACK2 (1 << 11) -#define IN_RUN (1 << 12) -#define IN_RELOAD (1 << 13) -#define IN_ALT1 (1 << 14) -#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down +constexpr int IN_ATTACK = (1 << 0); +constexpr int IN_JUMP = (1 << 1); +constexpr int IN_DUCK = (1 << 2); +constexpr int IN_FORWARD = (1 << 3); +constexpr int IN_BACK = (1 << 4); +constexpr int IN_USE = (1 << 5); +constexpr int IN_CANCEL = (1 << 6); +constexpr int IN_LEFT = (1 << 7); +constexpr int IN_RIGHT = (1 << 8); +constexpr int IN_MOVELEFT = (1 << 9); +constexpr int IN_MOVERIGHT = (1 << 10); +constexpr int IN_ATTACK2 = (1 << 11); +constexpr int IN_RUN = (1 << 12); +constexpr int IN_RELOAD = (1 << 13); +constexpr int IN_ALT1 = (1 << 14); +constexpr int IN_SCORE = (1 << 15);// Used by client.dll for when scoreboard is held down #endif // IN_BUTTONS_H From b3057a935dce3056fc5726f7d34aeb30bb34a422 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 14:34:19 -0400 Subject: [PATCH 014/291] Changes some Macros to functions. --- src/common/mathlib.h | 50 ++++++++++++++++---------- src/game/client/hud_spectator.cpp | 2 +- src/game/client/view.cpp | 4 +-- src/game/server/hl/util.h | 5 +-- src/game/shared/hl/vector.h | 29 ++++++++------- src/game/shared/movement/pm_math.cpp | 46 +++++++++--------------- src/game/shared/movement/pm_shared.cpp | 4 +-- 7 files changed, 72 insertions(+), 68 deletions(-) diff --git a/src/common/mathlib.h b/src/common/mathlib.h index 583acdf1..ee70e6f3 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -39,34 +39,46 @@ typedef int fixed16_t; struct mplane_s; extern Vector vec3_origin; -extern int nanmask; +constexpr int nanmask = 255 << 23; -#define IS_NAN(x) (((*(int*)&x) & nanmask) == nanmask) +inline static bool IS_NAN(float x) { -#define VectorSubtract(a, b, c) \ - { \ - (c)[0] = (a)[0] - (b)[0]; \ - (c)[1] = (a)[1] - (b)[1]; \ - (c)[2] = (a)[2] - (b)[2]; \ + if ((((*(int*)&x) & nanmask) == nanmask)) { + return true; } -#define VectorAdd(a, b, c) \ - { \ - (c)[0] = (a)[0] + (b)[0]; \ - (c)[1] = (a)[1] + (b)[1]; \ - (c)[2] = (a)[2] + (b)[2]; \ - } -#define VectorCopy(a, b) \ - { \ - (b)[0] = (a)[0]; \ - (b)[1] = (a)[1]; \ - (b)[2] = (a)[2]; \ + else { + return false; } +}; + + +inline void VectorSubtract(const float* a, const float* b, float* c) +{ + c[0] = a[0] - b[0]; + c[1] = a[1] - b[1]; + c[2] = a[2] - b[2]; +}; + +inline void VectorAdd(const float* a, const float* b, float* c) +{ + (c)[0] = (a)[0] + (b)[0]; + (c)[1] = (a)[1] + (b)[1]; + (c)[2] = (a)[2] + (b)[2]; +}; + +inline void VectorCopy(const float* source, float* destination) +{ + (destination)[0] = (source)[0]; + (destination)[1] = (source)[1]; + (destination)[2] = (source)[2]; +}; + inline void VectorClear(float* a) { a[0] = 0.0; a[1] = 0.0; a[2] = 0.0; -} +}; void VectorMA(const float* veca, float scale, const float* vecb, float* vecc); diff --git a/src/game/client/hud_spectator.cpp b/src/game/client/hud_spectator.cpp index fe79639f..0f330464 100644 --- a/src/game/client/hud_spectator.cpp +++ b/src/game/client/hud_spectator.cpp @@ -412,7 +412,7 @@ int CHudSpectator::Draw(float flTime) VectorNormalize(right); VectorScale(right, m_moveDelta, right); - VectorAdd(m_mapOrigin, right, m_mapOrigin) + VectorAdd(m_mapOrigin, right, m_mapOrigin); } // Only draw the icon names only if map mode is in Main Mode diff --git a/src/game/client/view.cpp b/src/game/client/view.cpp index 6aee0ffd..b60cc2fa 100644 --- a/src/game/client/view.cpp +++ b/src/game/client/view.cpp @@ -1648,8 +1648,8 @@ void V_CalcSpectatorRefdef(struct ref_params_s *pparams) // write back new values into pparams VectorCopy(v_cl_angles, pparams->cl_viewangles); - VectorCopy(v_angles, pparams->viewangles) - VectorCopy(v_origin, pparams->vieworg); + VectorCopy(v_angles, pparams->viewangles); + VectorCopy(v_origin, pparams->vieworg); } extern float newfov; void V_CalcMirrorRefdef(struct ref_params_s *pparams) diff --git a/src/game/server/hl/util.h b/src/game/server/hl/util.h index 4ce391b7..0f7aa26b 100644 --- a/src/game/server/hl/util.h +++ b/src/game/server/hl/util.h @@ -80,8 +80,9 @@ typedef int EOFFSET; typedef int BOOL; // In case this ever changes -#ifndef M_PI -#define M_PI 3.14159265358979323846 +#ifndef PI +#define PI +constexpr double M_PI = 3.14159265358979323846; #endif // Keeps clutter down a bit, when declaring external entity/global method prototypes diff --git a/src/game/shared/hl/vector.h b/src/game/shared/hl/vector.h index 5fcb01f7..92a90a72 100644 --- a/src/game/shared/hl/vector.h +++ b/src/game/shared/hl/vector.h @@ -87,13 +87,13 @@ class Vector // same data-layout as engine's vec3_t, } // Operators - inline Vector operator-(void) const { return Vector(-x, -y, -z); } - inline int operator==(const Vector &v) const { return x == v.x && y == v.y && z == v.z; } - inline int operator!=(const Vector &v) const { return !(*this == v); } - inline Vector operator+(const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); } - inline Vector operator-(const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); } - inline Vector operator*(float fl) const { return Vector(x * fl, y * fl, z * fl); } - inline Vector operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); } + inline Vector operator- (void) const { return Vector(-x, -y, -z); } + inline bool operator==(const Vector &v) const { return x == v.x && y == v.y && z == v.z; } + inline bool operator!=(const Vector &v) const { return !(*this == v); } + inline Vector operator+ (const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); } + inline Vector operator- (const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); } + inline Vector operator* (float fl) const { return Vector(x * fl, y * fl, z * fl); } + inline Vector operator/ (float fl) const { return Vector(x / fl, y / fl, z / fl); } // By Dogg inline Vector& operator+=(const Vector &v) { x += v.x; y += v.y; z += v.z; return *this; } @@ -103,16 +103,17 @@ class Vector // same data-layout as engine's vec3_t, // Methods inline void CopyToArray(float *rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } - inline float Length(void) const { return sqrt(x * x + y * y + z * z); } + inline float Length(void) const { return sqrt((x * x) + (y * y) + (z * z)); } operator float *() { return &x; } // Vectors will now automatically convert to float * when needed operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed + inline Vector Normalize(void) const { float flLen = Length(); if (flLen == 0) - return Vector(0, 0, 1); // ???? + return Vector{0, 0, 1 }; // ???? flLen = 1 / flLen; - return Vector(x * flLen, y * flLen, z * flLen); + return Vector{ x * flLen, y * flLen, z * flLen }; } inline Vector2D Make2D(void) const @@ -124,12 +125,14 @@ class Vector // same data-layout as engine's vec3_t, return Vec2; } - inline float Length2D(void) const { return sqrt(x * x + y * y); } + + inline float Length2D(void) const { return sqrt( (x * x) + (y * y) ); } // Members - vec_t x, y, z; + vec_t x, y, z; //just floats }; -inline Vector operator*(float fl, const Vector &v) { return v * fl; } + +inline Vector operator*(float fl, const Vector& v) { return v * fl; } inline float DotProduct(const Vector &a, const Vector &b) { return (a.x * b.x + a.y * b.y + a.z * b.z); } inline Vector CrossProduct(const Vector &a, const Vector &b) { return Vector(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } diff --git a/src/game/shared/movement/pm_math.cpp b/src/game/shared/movement/pm_math.cpp index d4e6bcf4..9086983f 100644 --- a/src/game/shared/movement/pm_math.cpp +++ b/src/game/shared/movement/pm_math.cpp @@ -19,16 +19,14 @@ #include "const.h" // up / down -#define PITCH 0 +constexpr int PITCH = 0; // left / right -#define YAW 1 +constexpr int YAW = 1; // fall over -#define ROLL 2 +constexpr int ROLL = 2; #pragma warning(disable : 4244) -int nanmask = 255 << 23; - float anglemod(float a) { a = static_cast(360.0f / 65536) * (static_cast(a * static_cast(65536 / 360.0f)) & 65535); @@ -395,28 +393,18 @@ ConcatTransforms */ void ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]) { - out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + - in1[0][2] * in2[2][0]; - out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + - in1[0][2] * in2[2][1]; - out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + - in1[0][2] * in2[2][2]; - out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + - in1[0][2] * in2[2][3] + in1[0][3]; - out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + - in1[1][2] * in2[2][0]; - out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + - in1[1][2] * in2[2][1]; - out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + - in1[1][2] * in2[2][2]; - out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + - in1[1][2] * in2[2][3] + in1[1][3]; - out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + - in1[2][2] * in2[2][0]; - out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + - in1[2][2] * in2[2][1]; - out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + - in1[2][2] * in2[2][2]; - out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + - in1[2][2] * in2[2][3] + in1[2][3]; + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + in1[0][2] * in2[2][0]; + out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + in1[0][2] * in2[2][1]; + out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + in1[0][2] * in2[2][2]; + out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + in1[0][2] * in2[2][3] + in1[0][3]; + + out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + in1[1][2] * in2[2][0]; + out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + in1[1][2] * in2[2][1]; + out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + in1[1][2] * in2[2][2]; + out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + in1[1][2] * in2[2][3] + in1[1][3]; + + out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + in1[2][2] * in2[2][0]; + out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + in1[2][2] * in2[2][1]; + out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + in1[2][2] * in2[2][2]; + out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3]; } diff --git a/src/game/shared/movement/pm_shared.cpp b/src/game/shared/movement/pm_shared.cpp index bf6086cc..85a2d760 100644 --- a/src/game/shared/movement/pm_shared.cpp +++ b/src/game/shared/movement/pm_shared.cpp @@ -1991,7 +1991,7 @@ void PM_SpectatorMove(void) speed = Length(pmove->velocity); if (speed < 1) { - VectorCopy(vec3_origin, pmove->velocity) + VectorCopy(vec3_origin, pmove->velocity); } else { @@ -2560,7 +2560,7 @@ void PM_Physics_Toss() VectorScale(pmove->velocity, (1.0 - trace.fraction) * pmove->frametime * 0.9, move); trace = PM_PushEntity(move); } - VectorSubtract(pmove->velocity, base, pmove->velocity) + VectorSubtract(pmove->velocity, base, pmove->velocity); } // check for in water From 57cddfabc309a88f3801aec90d75a64938d4dc86 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 14:36:55 -0400 Subject: [PATCH 015/291] Renamed M_PI to PI. Changes macro to constexpr int. Rename M_PI to PI in used routines --- src/common/const.h | 2 ++ src/common/mathlib.h | 4 --- src/game/client/hud.cpp | 2 +- src/game/client/render/studio_util.cpp | 4 +-- src/game/client/render/studio_util.h | 10 ++----- .../client/render/studiomodelrenderer.cpp | 14 ++++----- src/game/client/view.cpp | 8 ++--- src/game/server/hl/animating.cpp | 2 +- src/game/server/hl/func_tank.cpp | 4 +-- src/game/server/hl/util.h | 5 ---- src/game/server/monsters/npcscript.cpp | 2 +- src/game/shared/movement/pm_math.cpp | 30 +++++++++---------- src/game/shared/ms/script.cpp | 4 +-- src/game/shared/weapons/giattack.cpp | 2 +- 14 files changed, 41 insertions(+), 52 deletions(-) diff --git a/src/common/const.h b/src/common/const.h index b0ab4a66..b6c6e46f 100644 --- a/src/common/const.h +++ b/src/common/const.h @@ -21,6 +21,8 @@ #include "Platform.h" +constexpr double PI = 3.14159265358979323846; + // edict->flags constexpr int FL_FLY = (1 << 0); // Changes the SV_Movestep() behavior to not need to be on ground constexpr int FL_SWIM = (1 << 1); // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) diff --git a/src/common/mathlib.h b/src/common/mathlib.h index ee70e6f3..69ee49ec 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -32,10 +32,6 @@ typedef int fixed4_t; typedef int fixed8_t; typedef int fixed16_t; -#ifndef M_PI -#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h -#endif - struct mplane_s; extern Vector vec3_origin; diff --git a/src/game/client/hud.cpp b/src/game/client/hud.cpp index 53628b5c..211952e9 100644 --- a/src/game/client/hud.cpp +++ b/src/game/client/hud.cpp @@ -765,7 +765,7 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf) m_iFOV = newfov; } - ClFOV = cosf((m_iFOV / 2.0) * (M_PI / 180)); + ClFOV = cosf((m_iFOV / 2.0) * (PI / 180)); // the clients fov is actually set in the client data update section of the hud diff --git a/src/game/client/render/studio_util.cpp b/src/game/client/render/studio_util.cpp index 78bfded6..a172878a 100644 --- a/src/game/client/render/studio_util.cpp +++ b/src/game/client/render/studio_util.cpp @@ -96,8 +96,8 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ) qt[1] = q[0]; qt[2] = -q[3]; qt[3] = q[2]; - sclp = sin( (1.0 - t) * (0.5 * M_PI)); - sclq = sin( t * (0.5 * M_PI)); + sclp = sin( (1.0 - t) * (0.5 * PI)); + sclq = sin( t * (0.5 * PI)); for (i = 0; i < 3; i++) { qt[i] = sclp * p[i] + sclq * qt[i]; diff --git a/src/game/client/render/studio_util.h b/src/game/client/render/studio_util.h index 7a2aa47b..aa784528 100644 --- a/src/game/client/render/studio_util.h +++ b/src/game/client/render/studio_util.h @@ -7,18 +7,14 @@ #pragma once -#ifndef M_PI -#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h -#endif - #ifndef PITCH // MOVEMENT INFO // up / down -#define PITCH 0 +constexpr int PITCH = 0; // left / right -#define YAW 1 +constexpr int YAW = 1; // fall over -#define ROLL 2 +constexpr int ROLL = 2; #endif #define FDotProduct(a, b) (fabs((a[0]) * (b[0])) + fabs((a[1]) * (b[1])) + fabs((a[2]) * (b[2]))) diff --git a/src/game/client/render/studiomodelrenderer.cpp b/src/game/client/render/studiomodelrenderer.cpp index 917f33ed..df3f2400 100644 --- a/src/game/client/render/studiomodelrenderer.cpp +++ b/src/game/client/render/studiomodelrenderer.cpp @@ -186,7 +186,7 @@ void CStudioModelRenderer::StudioCalcBoneAdj(float dadt, float* adj, const byte* case STUDIO_XR: case STUDIO_YR: case STUDIO_ZR: - adj[j] = value * (M_PI / 180.0); + adj[j] = value * (PI / 180.0); break; case STUDIO_X: case STUDIO_Y: @@ -280,13 +280,13 @@ void CStudioModelRenderer::StudioCalcBoneQuaterion(int frame, float s, mstudiobo if( pbone->parent == -1 ) { animrot += orig1; - animrot -= M_PI/2; + animrot -= PI/2; } animrot *= -1; if( pbone->parent == -1 ) { - animrot += M_PI/2; + animrot += PI/2; animrot -= (-orig1); } @@ -317,8 +317,8 @@ void CStudioModelRenderer::StudioCalcBoneQuaterion(int frame, float s, mstudiobo /*if( FBitSet(m_pCurrentEntity->curstate.oldbuttons,MSRDR_FLIPPED) ) if( pbone->parent != -1 ) { - if( angle[0] > M_PI ) angle[0] -= M_PI*2; - if( angle[0] < -M_PI ) angle[0] += M_PI*2; + if( angle[0] > PI ) angle[0] -= PI*2; + if( angle[0] < -PI ) angle[0] += PI*2; for (int j = 0; j < 2; j++) if( panim->offset[j+1+3] == 0 ) { @@ -1704,7 +1704,7 @@ void CStudioModelRenderer::StudioEstimateGait(entity_state_t* pplayer) } else { - m_pPlayerInfo->gaityaw = (atan2(est_velocity[1], est_velocity[0]) * 180 / M_PI); + m_pPlayerInfo->gaityaw = (atan2(est_velocity[1], est_velocity[0]) * 180 / PI); if (m_pPlayerInfo->gaityaw > 180) m_pPlayerInfo->gaityaw = 180; if (m_pPlayerInfo->gaityaw < -180) @@ -2593,7 +2593,7 @@ void CStudioModelRenderer::ModifyBone(mstudiobone_t* pbone, Vector& angle) if (Bone == 2) Value = Pitch * 0.3f; //0.2 - angle.z += -Value * (M_PI / 180.0); + angle.z += -Value * (PI / 180.0); } void CStudioModelRenderer::RegisterExtraData(cl_entity_t& Ent) diff --git a/src/game/client/view.cpp b/src/game/client/view.cpp index b60cc2fa..26ae18f4 100644 --- a/src/game/client/view.cpp +++ b/src/game/client/view.cpp @@ -217,11 +217,11 @@ float V_CalcBob(struct ref_params_s *pparams) if (cycle < cl_bobup->value) { - cycle = M_PI * cycle / cl_bobup->value; + cycle = PI * cycle / cl_bobup->value; } else { - cycle = M_PI + M_PI * (cycle - cl_bobup->value) / (1.0 - cl_bobup->value); + cycle = PI + PI * (cycle - cl_bobup->value) / (1.0 - cl_bobup->value); } // bob is proportional to simulated velocity in the xy plane @@ -1820,11 +1820,11 @@ float CalcFov(float fov_x, float width, float height) if (fov_x < 1 || fov_x > 179) fov_x = 90; // error, set to 90 - x = width / tan(fov_x / 360 * M_PI); + x = width / tan(fov_x / 360 * PI); a = atan(height / x); - a = a * 360 / M_PI; + a = a * 360 / PI; return a; } diff --git a/src/game/server/hl/animating.cpp b/src/game/server/hl/animating.cpp index 856ab391..c801872c 100644 --- a/src/game/server/hl/animating.cpp +++ b/src/game/server/hl/animating.cpp @@ -263,7 +263,7 @@ void CBaseAnimating ::SetSequenceBox(void) { // expand box for rotation // find min / max for rotations - float yaw = pev->angles.y * (M_PI / 180.0); + float yaw = pev->angles.y * (PI / 180.0); Vector xvector, yvector; xvector.x = cos(yaw); diff --git a/src/game/server/hl/func_tank.cpp b/src/game/server/hl/func_tank.cpp index 5e018c24..d7a529d9 100644 --- a/src/game/server/hl/func_tank.cpp +++ b/src/game/server/hl/func_tank.cpp @@ -633,12 +633,12 @@ void CFuncTank::AdjustAnglesForBarrel(Vector &angles, float distance) if (m_barrelPos.y) { r2 = m_barrelPos.y * m_barrelPos.y; - angles.y += (180.0 / M_PI) * atan2(m_barrelPos.y, sqrt(d2 - r2)); + angles.y += (180.0 / PI) * atan2(m_barrelPos.y, sqrt(d2 - r2)); } if (m_barrelPos.z) { r2 = m_barrelPos.z * m_barrelPos.z; - angles.x += (180.0 / M_PI) * atan2(-m_barrelPos.z, sqrt(d2 - r2)); + angles.x += (180.0 / PI) * atan2(-m_barrelPos.z, sqrt(d2 - r2)); } } } diff --git a/src/game/server/hl/util.h b/src/game/server/hl/util.h index 0f7aa26b..570ff87b 100644 --- a/src/game/server/hl/util.h +++ b/src/game/server/hl/util.h @@ -80,11 +80,6 @@ typedef int EOFFSET; typedef int BOOL; // In case this ever changes -#ifndef PI -#define PI -constexpr double M_PI = 3.14159265358979323846; -#endif - // Keeps clutter down a bit, when declaring external entity/global method prototypes #define DECLARE_GLOBAL_METHOD(MethodName) extern void UTIL_DLLEXPORT MethodName( void ) #define GLOBAL_METHOD(funcname) void UTIL_DLLEXPORT funcname(void) diff --git a/src/game/server/monsters/npcscript.cpp b/src/game/server/monsters/npcscript.cpp index 4476a412..3fea933e 100644 --- a/src/game/server/monsters/npcscript.cpp +++ b/src/game/server/monsters/npcscript.cpp @@ -270,7 +270,7 @@ bool CMSMonster::Script_ExecuteCmd(CScript *Script, SCRIPT_EVENT &Event, scriptc else if (Cmd.Name() == "fov") { if (Params.size() >= 1) - m_flFieldOfView = cosf((atof(Params[0]) / 2.0) * (M_PI / 180)); + m_flFieldOfView = cosf((atof(Params[0]) / 2.0) * (PI / 180)); else ERROR_MISSING_PARMS; diff --git a/src/game/shared/movement/pm_math.cpp b/src/game/shared/movement/pm_math.cpp index 9086983f..095ac6db 100644 --- a/src/game/shared/movement/pm_math.cpp +++ b/src/game/shared/movement/pm_math.cpp @@ -38,13 +38,13 @@ void AngleVectors(const Vector& angles, Vector* forward, Vector* right, Vector* float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * (M_PI * 2 / 360); + angle = angles[YAW] * (PI * 2 / 360); sy = sin(angle); cy = cos(angle); - angle = angles[PITCH] * (M_PI * 2 / 360); + angle = angles[PITCH] * (PI * 2 / 360); sp = sin(angle); cp = cos(angle); - angle = angles[ROLL] * (M_PI * 2 / 360); + angle = angles[ROLL] * (PI * 2 / 360); sr = sin(angle); cr = cos(angle); @@ -73,13 +73,13 @@ void AngleVectorsTranspose(const Vector& angles, Vector* forward, Vector* right, float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * (M_PI * 2 / 360); + angle = angles[YAW] * (PI * 2 / 360); sy = sin(angle); cy = cos(angle); - angle = angles[PITCH] * (M_PI * 2 / 360); + angle = angles[PITCH] * (PI * 2 / 360); sp = sin(angle); cp = cos(angle); - angle = angles[ROLL] * (M_PI * 2 / 360); + angle = angles[ROLL] * (PI * 2 / 360); sr = sin(angle); cr = cos(angle); @@ -108,13 +108,13 @@ void AngleMatrix(const float* angles, float (*matrix)[4]) float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * (M_PI * 2 / 360); + angle = angles[YAW] * (PI * 2 / 360); sy = sin(angle); cy = cos(angle); - angle = angles[PITCH] * (M_PI * 2 / 360); + angle = angles[PITCH] * (PI * 2 / 360); sp = sin(angle); cp = cos(angle); - angle = angles[ROLL] * (M_PI * 2 / 360); + angle = angles[ROLL] * (PI * 2 / 360); sr = sin(angle); cr = cos(angle); @@ -138,13 +138,13 @@ void AngleIMatrix(const Vector& angles, float matrix[3][4]) float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * (M_PI * 2 / 360); + angle = angles[YAW] * (PI * 2 / 360); sy = sin(angle); cy = cos(angle); - angle = angles[PITCH] * (M_PI * 2 / 360); + angle = angles[PITCH] * (PI * 2 / 360); sp = sin(angle); cp = cos(angle); - angle = angles[ROLL] * (M_PI * 2 / 360); + angle = angles[ROLL] * (PI * 2 / 360); sr = sin(angle); cr = cos(angle); @@ -236,7 +236,7 @@ float AngleBetweenVectors(const Vector& v1, const Vector& v2) return 0.0f; angle = acos(DotProduct(v1, v2)) / (l1 * l2); - angle = (angle * 180.0f) / M_PI; + angle = (angle * 180.0f) / PI; return angle; } @@ -370,12 +370,12 @@ void VectorAngles(const float* forward, float* angles) } else { - yaw = (atan2(forward[1], forward[0]) * 180 / M_PI); + yaw = (atan2(forward[1], forward[0]) * 180 / PI); if (yaw < 0) yaw += 360; tmp = sqrt(forward[0] * forward[0] + forward[1] * forward[1]); - pitch = (atan2(forward[2], tmp) * 180 / M_PI); + pitch = (atan2(forward[2], tmp) * 180 / PI); if (pitch < 0) pitch += 360; } diff --git a/src/game/shared/ms/script.cpp b/src/game/shared/ms/script.cpp index 0ee2f575..d9610df2 100644 --- a/src/game/shared/ms/script.cpp +++ b/src/game/shared/ms/script.cpp @@ -610,7 +610,7 @@ msstring CScript::ScriptGetter_Angles3d(msstring& FullName, msstring& ParserName else { if (Vec_Org.x) - lyaw = (atan2(Vec_Org.y, Vec_Org.x) * 180 / M_PI); + lyaw = (atan2(Vec_Org.y, Vec_Org.x) * 180 / PI); else if (Vec_Org.y > 0) lyaw = 90; else @@ -620,7 +620,7 @@ msstring CScript::ScriptGetter_Angles3d(msstring& FullName, msstring& ParserName lyaw += 360; lforward = sqrt(Vec_Org.x*Vec_Org.x + Vec_Org.y*Vec_Org.y); - lpitch = (atan2(Vec_Org.y, lforward) * 180 / M_PI); + lpitch = (atan2(Vec_Org.y, lforward) * 180 / PI); if (lpitch < 0) lpitch += 360; } diff --git a/src/game/shared/weapons/giattack.cpp b/src/game/shared/weapons/giattack.cpp index 0f20fd9f..2c579a50 100644 --- a/src/game/shared/weapons/giattack.cpp +++ b/src/game/shared/weapons/giattack.cpp @@ -1048,7 +1048,7 @@ void CGenericItem::ChargeThrowProj() float LoweredSpreadDeg = CurrentAttack->flAccBest + ((CurrentAttack->flAccuracyDefault - CurrentAttack->flAccBest) * (1 - flTimeHeldAdjusted)); float Spread = V_max(LoweredSpreadDeg, 0); - float VeerAng = RANDOM_FLOAT(0.0f, M_PI); + float VeerAng = RANDOM_FLOAT(0.0f, PI); vAngle.x += cosf(VeerAng) * Spread; //Veer off at the angle, multiplied by the spread vAngle.y += sinf(VeerAng) * Spread; From 5767676942575826d128135b74c1efbabefcc09d Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 14:48:42 -0400 Subject: [PATCH 016/291] commented out unused macro --- src/common/mathlib.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common/mathlib.h b/src/common/mathlib.h index 69ee49ec..7c64983f 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -160,10 +160,11 @@ extern DLONG dlong; #define restore_fpu_cw() /* */ #endif -#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ - (((p)->type < 3) ? ( \ - ((p)->dist <= (emins)[(p)->type]) ? 1 \ - : ( \ - ((p)->dist >= (emaxs)[(p)->type]) ? 2 \ - : 3)) \ - : BoxOnPlaneSide((emins), (emaxs), (p))) +//#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ +// (((p)->type < 3) ? ( \ +// ((p)->dist <= (emins)[(p)->type]) ? 1 \ +// : ( \ +// ((p)->dist >= (emaxs)[(p)->type]) ? 2 \ +// : 3)) \ +// : BoxOnPlaneSide((emins), (emaxs), (p))) +// \ No newline at end of file From 2ae701a4adbc73bd8ed3a72aaf0705bca5ae5d19 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:01:10 -0400 Subject: [PATCH 017/291] Chanced V_min and V_max from macros to templated functions. --- src/common/Platform.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/common/Platform.h b/src/common/Platform.h index bcfb4a8d..ff2ea200 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -3,7 +3,7 @@ // Allow "DEBUG" in addition to default "_DEBUG" #ifdef _DEBUG -#define DEBUG 1 +constexpr int DEBUG = 1 #endif // Silence certain warnings @@ -41,7 +41,16 @@ using word = unsigned short; // #undef ARRAYSIZE // #endif // #define ARRAYSIZE(p) (sizeof(p) / sizeof(p[0])) -#define V_min(a, b) (((a) < (b)) ? (a) : (b)) -#define V_max(a, b) (((a) > (b)) ? (a) : (b)) + + +template +auto V_min(const T1& a, const T2& b) { + return (a < b) ? a : b; +} + +template +auto V_max(const T1& a, const T2& b) { + return (a > b) ? a : b; +} #endif \ No newline at end of file From ac0e5709f10f5a9780b02947b5766760fb925307 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:01:58 -0400 Subject: [PATCH 018/291] Added semicolons to template blocks for sureness. --- src/common/Platform.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Platform.h b/src/common/Platform.h index ff2ea200..6089b66c 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -46,11 +46,11 @@ using word = unsigned short; template auto V_min(const T1& a, const T2& b) { return (a < b) ? a : b; -} +}; template auto V_max(const T1& a, const T2& b) { return (a > b) ? a : b; -} +}; #endif \ No newline at end of file From 5d8f4f03952f26ee052f51d4bb5b1117d1841eaf Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:03:24 -0400 Subject: [PATCH 019/291] changes macro defines to constexpr --- src/common/net_api.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/common/net_api.h b/src/common/net_api.h index e4af8269..980d92e9 100644 --- a/src/common/net_api.h +++ b/src/common/net_api.h @@ -15,22 +15,22 @@ #include "netadr.h" #endif -#define NETAPI_REQUEST_SERVERLIST (0) // Doesn't need a remote address -#define NETAPI_REQUEST_PING (1) -#define NETAPI_REQUEST_RULES (2) -#define NETAPI_REQUEST_PLAYERS (3) -#define NETAPI_REQUEST_DETAILS (4) +constexpr int NETAPI_REQUEST_SERVERLIST = 0; // Doesn't need a remote address +constexpr int NETAPI_REQUEST_PING = 1; +constexpr int NETAPI_REQUEST_RULES = 2; +constexpr int NETAPI_REQUEST_PLAYERS = 3; +constexpr int NETAPI_REQUEST_DETAILS = 4; // Set this flag for things like broadcast requests, etc. where the engine should not // kill the request hook after receiving the first response -#define FNETAPI_MULTIPLE_RESPONSE (1 << 0) +constexpr int FNETAPI_MULTIPLE_RESPONSE = (1 << 0); typedef void (*net_api_response_func_t)(struct net_response_s *response); -#define NET_SUCCESS (0) -#define NET_ERROR_TIMEOUT (1 << 0) -#define NET_ERROR_PROTO_UNSUPPORTED (1 << 1) -#define NET_ERROR_UNDEFINED (1 << 2) +constexpr int NET_SUCCESS = 0; +constexpr int NET_ERROR_TIMEOUT = 1 << 0; +constexpr int NET_ERROR_PROTO_UNSUPPORTED = 1 << 1; +constexpr int NET_ERROR_UNDEFINED = 1 << 2; typedef struct net_adrlist_s { From 1cd9519d8702b4512523c59338a556219c37f2e4 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:09:09 -0400 Subject: [PATCH 020/291] Changed macros to constexpr. Fixed Vector not accurately being passed into sscanf : 377 in findentities.cpp --- src/common/qfont.h | 2 +- src/game/shared/ms/findentities.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/qfont.h b/src/common/qfont.h index 665ed97d..f6f7831d 100644 --- a/src/common/qfont.h +++ b/src/common/qfont.h @@ -20,7 +20,7 @@ // Font stuff -#define NUM_GLYPHS 256 +constexpr int NUM_GLYPHS = 256; typedef struct { diff --git a/src/game/shared/ms/findentities.cpp b/src/game/shared/ms/findentities.cpp index 952621a0..e0a16f91 100644 --- a/src/game/shared/ms/findentities.cpp +++ b/src/game/shared/ms/findentities.cpp @@ -374,7 +374,7 @@ bool CCylinderFilter::SetFromString(msstring vsString) float vRadiusSquared; float vPosZ; float vNegZ; - bool bOk = sscanf(vsString.c_str(), "Cyl((%f,%f,%f),%f,%f,%f,%f)", &vOrigin, &vRadius, &vRadiusSquared, &vPosZ, &vNegZ) == 7; + bool bOk = sscanf(vsString.c_str(), "Cyl((%f,%f,%f),%f,%f,%f,%f)", &vOrigin.x, &vOrigin.y, &vOrigin.z, &vRadius, &vRadiusSquared, &vPosZ, &vNegZ) == 7; if (bOk) { mOrigin = vOrigin; From f335879fb15a096f76c63602d004ea31dbd907f1 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:09:41 -0400 Subject: [PATCH 021/291] Changes more macro definitions to constexpr --- src/common/r_efx.h | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/common/r_efx.h b/src/common/r_efx.h index d42c4ee9..eb638cb2 100644 --- a/src/common/r_efx.h +++ b/src/common/r_efx.h @@ -59,32 +59,32 @@ color24 gTracerColors[] = */ // Temporary entity array -#define TENTPRIORITY_LOW 0 -#define TENTPRIORITY_HIGH 1 +constexpr int TENTPRIORITY_LOW = 0; +constexpr int TENTPRIORITY_HIGH = 1; // TEMPENTITY flags -#define FTENT_NONE 0x00000000 -#define FTENT_SINEWAVE 0x00000001 -#define FTENT_GRAVITY 0x00000002 -#define FTENT_ROTATE 0x00000004 -#define FTENT_SLOWGRAVITY 0x00000008 -#define FTENT_SMOKETRAIL 0x00000010 -#define FTENT_COLLIDEWORLD 0x00000020 -#define FTENT_FLICKER 0x00000040 -#define FTENT_FADEOUT 0x00000080 -#define FTENT_SPRANIMATE 0x00000100 -#define FTENT_HITSOUND 0x00000200 -#define FTENT_SPIRAL 0x00000400 -#define FTENT_SPRCYCLE 0x00000800 -#define FTENT_COLLIDEALL 0x00001000 // will collide with world and slideboxes -#define FTENT_PERSIST 0x00002000 // tent is not removed when unable to draw -#define FTENT_COLLIDEKILL 0x00004000 // tent is removed upon collision with anything -#define FTENT_PLYRATTACHMENT 0x00008000 // tent is attached to a player (owner) -#define FTENT_SPRANIMATELOOP 0x00010000 // animating sprite doesn't die when last frame is displayed -#define FTENT_SPARKSHOWER 0x00020000 -#define FTENT_NOMODEL 0x00040000 // Doesn't have a model, never try to draw ( it just triggers other things ) -#define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) -#define FTENT_SKIPENT 0x00100000 // AUG2013_25 Thothie - Skip collision checks for stored ent index +constexpr int FTENT_NONE = 0x00000000; +constexpr int FTENT_SINEWAVE = 0x00000001; +constexpr int FTENT_GRAVITY = 0x00000002; +constexpr int FTENT_ROTATE = 0x00000004; +constexpr int FTENT_SLOWGRAVITY = 0x00000008; +constexpr int FTENT_SMOKETRAIL = 0x00000010; +constexpr int FTENT_COLLIDEWORLD = 0x00000020; +constexpr int FTENT_FLICKER = 0x00000040; +constexpr int FTENT_FADEOUT = 0x00000080; +constexpr int FTENT_SPRANIMATE = 0x00000100; +constexpr int FTENT_HITSOUND = 0x00000200; +constexpr int FTENT_SPIRAL = 0x00000400; +constexpr int FTENT_SPRCYCLE = 0x00000800; +constexpr int FTENT_COLLIDEALL = 0x00001000; // will collide with world and slideboxes +constexpr int FTENT_PERSIST = 0x00002000; // tent is not removed when unable to draw +constexpr int FTENT_COLLIDEKILL = 0x00004000; // tent is removed upon collision with anything +constexpr int FTENT_PLYRATTACHMENT = 0x00008000; // tent is attached to a player (owner) +constexpr int FTENT_SPRANIMATELOOP = 0x00010000; // animating sprite doesn't die when last frame is displayed +constexpr int FTENT_SPARKSHOWER = 0x00020000; +constexpr int FTENT_NOMODEL = 0x00040000; // Doesn't have a model, never try to draw ( it just triggers other things ) +constexpr int FTENT_CLIENTCUSTOM = 0x00080000; // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) +constexpr int FTENT_SKIPENT = 0x00100000; // AUG2013_25 Thothie - Skip collision checks for stored ent index typedef struct tempent_s TEMPENTITY; typedef struct tempent_s From fa3ecbfb262e683e37b4fd837440b499a13393d5 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:12:52 -0400 Subject: [PATCH 022/291] Changed more macrodefines to constexpr --- src/common/r_studioint.h | 4 ++-- src/common/triangleapi.h | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/common/r_studioint.h b/src/common/r_studioint.h index 3e9caa52..7d28782a 100644 --- a/src/common/r_studioint.h +++ b/src/common/r_studioint.h @@ -11,7 +11,7 @@ #pragma once #endif -#define STUDIO_INTERFACE_VERSION 1 +constexpr int STUDIO_INTERFACE_VERSION = 1; typedef struct engine_studio_api_s { @@ -126,7 +126,7 @@ typedef struct r_studio_interface_s extern r_studio_interface_t *pStudioAPI; // server blending -#define SV_BLENDING_INTERFACE_VERSION 1 +constexpr int SV_BLENDING_INTERFACE_VERSION = 1; typedef struct sv_blending_interface_s { diff --git a/src/common/triangleapi.h b/src/common/triangleapi.h index 5e85cb03..3440f7c9 100644 --- a/src/common/triangleapi.h +++ b/src/common/triangleapi.h @@ -24,15 +24,14 @@ typedef enum TRI_NONE = 1, } TRICULLSTYLE; -#define TRI_API_VERSION 1 - -#define TRI_TRIANGLES 0 -#define TRI_TRIANGLE_FAN 1 -#define TRI_QUADS 2 -#define TRI_POLYGON 3 -#define TRI_LINES 4 -#define TRI_TRIANGLE_STRIP 5 -#define TRI_QUAD_STRIP 6 +constexpr int TRI_API_VERSION = 1; +constexpr int TRI_TRIANGLES = 0; +constexpr int TRI_TRIANGLE_FAN = 1; +constexpr int TRI_QUADS = 2; +constexpr int TRI_POLYGON = 3; +constexpr int TRI_LINES = 4; +constexpr int TRI_TRIANGLE_STRIP = 5; +constexpr int TRI_QUAD_STRIP = 6; typedef struct triangleapi_s { From b78ed64d6dfecc7baee95d1c74b6d706970b376e Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:39:44 -0400 Subject: [PATCH 023/291] Removed unused dyanmic defines. Changed macro defs to constexpr --- src/game/server/player/player.h | 54 +++++++++++++++------------------ 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/game/server/player/player.h b/src/game/server/player/player.h index 4d235087..b5d08053 100644 --- a/src/game/server/player/player.h +++ b/src/game/server/player/player.h @@ -22,12 +22,12 @@ #include "mscharacter.h" #include "iscript.h" -#define MAX_ID_RANGE 2048 -#define SBAR_STRING_SIZE 128 -#define NUM_MAX_ITEMS 100 //Thothie APR2011_28 +constexpr int MAX_ID_RANGE = 2048; +constexpr int SBAR_STRING_SIZE = 128; +constexpr int NUM_MAX_ITEMS = 100; //Thothie APR2011_28 // was 1500, but there shouldn't be any issues with increasing. -#define NUM_MAX_STACK 9999 //stack is stored as either a unsigned short, so that's the actual max it can be. +constexpr int NUM_MAX_STACK = 9999; //stack is stored as either a unsigned short, so that's the actual max it can be. enum sbar_data { @@ -37,7 +37,7 @@ enum sbar_data SBAR_END, }; -#define CHAT_INTERVAL 1.0f +constexpr float CHAT_INTERVAL = 1.0f; //Master Sword class CStat; @@ -100,7 +100,7 @@ struct quickslot_t //Quickslots for items, spells quickslottype_e Type; uint ID; }; -#define MAX_QUICKSLOTS 36 //MiB MAR2012 - Increase quickslots +constexpr int MAX_QUICKSLOTS = 36; //MiB MAR2012 - Increase quickslots #include "sharedmenu.h" @@ -114,10 +114,9 @@ void MSGSend_PlayerInfo(CBasePlayer *pSendToPlayer, CBasePlayer *pPlayer); //macros (just to shorten things up a bit) #define CREATE_ENT(item) (CBaseEntity *)GET_PRIVATE(CREATE_NAMED_ENTITY(MAKE_STRING(item))); -#define VAR_NPC_ANIM_TORSO "game.monster.torso_anim" -#define VAR_NPC_ANIM_LEGS "game.monster.legs_anim" - -#define PLAYER_SCRIPT "player/player" +constexpr const char* VAR_NPC_ANIM_TORSO = "game.monster.torso_anim"; +constexpr const char* VAR_NPC_ANIM_LEGS = "game.monster.legs_anim"; +constexpr const char* PLAYER_SCRIPT = "player/player"; //#define mCH m_pOwner->iCurrentHand /*//#define Wielded( iHand ) ((Hand[iHand])?Hand[iHand]->Wielded:(PlayerHands?PlayerHands->Wielded:FALSE)) @@ -125,34 +124,31 @@ void MSGSend_PlayerInfo(CBasePlayer *pSendToPlayer, CBasePlayer *pPlayer); //#define CHWielded ((Hand[iCurrentHand])?Hand[iCurrentHand]->Wielded:(PlayerHands?PlayerHands->Wielded:FALSE)) #define CHWielded Wielded(iCurrentHand)*/ -#define CH Hand[iCurrentHand] -#define MAX_PLAYER_HANDS 2 -#define MAX_PLAYER_HANDITEMS 3 -#define MAX_KEYHISTORY 10 +constexpr int MAX_PLAYER_HANDS = 2; +constexpr int MAX_PLAYER_HANDITEMS = 3; +constexpr int MAX_KEYHISTORY = 10; +constexpr int MSGFLAG_SPAWN = (1 << 0); -#define mSStat m_pOwner->GetSkillStat -#define mNStat m_pOwner->GetNatStat -#define MSGFLAG_SPAWN (1 << 0) //----------------- -#define PLAYER_FATAL_FALL_SPEED 1024 // approx 60 feet -#define PLAYER_MAX_SAFE_FALL_SPEED 580 // approx 20 feet -#define DAMAGE_FOR_FALL_SPEED (float)100 / (PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED) // damage per unit per second. -#define PLAYER_MIN_BOUNCE_SPEED 200 -#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast. +constexpr int PLAYER_FATAL_FALL_SPEED = 1024; // approx 60 feet +constexpr int PLAYER_MAX_SAFE_FALL_SPEED = 580; // approx 20 feet +constexpr float DAMAGE_FOR_FALL_SPEED = 100.0f / (PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED); // damage per unit per second. +constexpr int PLAYER_MIN_BOUNCE_SPEED = 200; +constexpr float PLAYER_FALL_PUNCH_THRESHHOLD = 350.0f;// won't punch player's screen/make scrape noise unless player falling at least this fast. // // Player PHYSICS FLAGS bits // -#define PFLAG_ONLADDER (1 << 0) -#define PFLAG_ONSWING (1 << 0) -#define PFLAG_ONTRAIN (1 << 1) -#define PFLAG_ONBARNACLE (1 << 2) -#define PFLAG_DUCKING (1 << 3) // In the process of ducking, but totally squatted yet -#define PFLAG_USING (1 << 4) // Using a continuous entity -#define PFLAG_OBSERVER (1 << 5) // player is locked in stationary cam mode. Spectators can move, observers can't. +constexpr int PFLAG_ONLADDER = (1 << 0); +constexpr int PFLAG_ONSWING = (1 << 0); +constexpr int PFLAG_ONTRAIN = (1 << 1); +constexpr int PFLAG_ONBARNACLE = (1 << 2); +constexpr int PFLAG_DUCKING = (1 << 3); // In the process of ducking, but totally squatted yet +constexpr int PFLAG_USING = (1 << 4); // Using a continuous entity +constexpr int PFLAG_OBSERVER = (1 << 5); // player is locked in stationary cam mode. Spectators can move, observers can't. // // generic player From a7fdc164510a3f829101dccbb09303c7c734af50 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:17:33 -0400 Subject: [PATCH 024/291] Removed unreferenced variable --- src/game/server/gamerules/team.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/game/server/gamerules/team.cpp b/src/game/server/gamerules/team.cpp index 187f20ca..cbf25b27 100644 --- a/src/game/server/gamerules/team.cpp +++ b/src/game/server/gamerules/team.cpp @@ -20,7 +20,6 @@ CTeam *CTeam::CreateTeam(const char *pszName, ulong ID) //Create new team CTeam* NewTeam = msnew CTeam; - char pszTeamName[MAX_TEAMNAME_LEN + 1]; strncpy((char*)NewTeam->m_TeamName, pszName, MAX_TEAMNAME_LEN); NewTeam->m_ID = RANDOM_LONG(0, LONG_MAX); //Assign Unique ID From f2742aded67d41eea48592ce7e741a018a1dc3a3 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:18:10 -0400 Subject: [PATCH 025/291] changed defines to enums --- src/game/server/hl/schedule.h | 382 ++++++++++++++------------- src/game/server/monsters/msmonster.h | 34 ++- 2 files changed, 212 insertions(+), 204 deletions(-) diff --git a/src/game/server/hl/schedule.h b/src/game/server/hl/schedule.h index 43ac067f..173da264 100644 --- a/src/game/server/hl/schedule.h +++ b/src/game/server/hl/schedule.h @@ -19,62 +19,62 @@ #ifndef SCHEDULE_H #define SCHEDULE_H -#define TASKSTATUS_NEW 0 // Just started -#define TASKSTATUS_RUNNING 1 // Running task & movement -#define TASKSTATUS_RUNNING_MOVEMENT 2 // Just running movement -#define TASKSTATUS_RUNNING_TASK 3 // Just running task -#define TASKSTATUS_COMPLETE 4 // Completed, get next task - +enum { + TASKSTATUS_NEW = 0, // Just started + TASKSTATUS_RUNNING = 1, // Running task & movement + TASKSTATUS_RUNNING_MOVEMENT = 2, // Just running movement + TASKSTATUS_RUNNING_TASK = 3, // Just running task + TASKSTATUS_COMPLETE = 4 // Completed, get next task +}; //========================================================= // These are the schedule types //========================================================= typedef enum { - SCHED_NONE = 0, - SCHED_IDLE_STAND, - SCHED_IDLE_WALK, - SCHED_WAKE_ANGRY, - SCHED_WAKE_CALLED, - SCHED_ALERT_FACE, - SCHED_ALERT_SMALL_FLINCH, - SCHED_ALERT_BIG_FLINCH, - SCHED_ALERT_STAND, - SCHED_INVESTIGATE_SOUND, - SCHED_COMBAT_FACE, - SCHED_COMBAT_STAND, - SCHED_CHASE_ENEMY, - SCHED_CHASE_ENEMY_FAILED, - SCHED_VICTORY_DANCE, - SCHED_TARGET_FACE, - SCHED_TARGET_CHASE, - SCHED_SMALL_FLINCH, - SCHED_TAKE_COVER_FROM_ENEMY, - SCHED_TAKE_COVER_FROM_BEST_SOUND, - SCHED_TAKE_COVER_FROM_ORIGIN, - SCHED_COWER, // usually a last resort! - SCHED_MELEE_ATTACK1, - SCHED_MELEE_ATTACK2, - SCHED_RANGE_ATTACK1, - SCHED_RANGE_ATTACK2, - SCHED_SPECIAL_ATTACK1, - SCHED_SPECIAL_ATTACK2, - SCHED_STANDOFF, - SCHED_ARM_WEAPON, - SCHED_RELOAD, - SCHED_GUARD, - SCHED_AMBUSH, - SCHED_DIE, - SCHED_WAIT_TRIGGER, - SCHED_FOLLOW, - SCHED_SLEEP, - SCHED_WAKE, - SCHED_BARNACLE_VICTIM_GRAB, - SCHED_BARNACLE_VICTIM_CHOMP, - SCHED_AISCRIPT, - SCHED_FAIL, - - LAST_COMMON_SCHEDULE // Leave this at the bottom + SCHED_NONE = 0, + SCHED_IDLE_STAND, + SCHED_IDLE_WALK, + SCHED_WAKE_ANGRY, + SCHED_WAKE_CALLED, + SCHED_ALERT_FACE, + SCHED_ALERT_SMALL_FLINCH, + SCHED_ALERT_BIG_FLINCH, + SCHED_ALERT_STAND, + SCHED_INVESTIGATE_SOUND, + SCHED_COMBAT_FACE, + SCHED_COMBAT_STAND, + SCHED_CHASE_ENEMY, + SCHED_CHASE_ENEMY_FAILED, + SCHED_VICTORY_DANCE, + SCHED_TARGET_FACE, + SCHED_TARGET_CHASE, + SCHED_SMALL_FLINCH, + SCHED_TAKE_COVER_FROM_ENEMY, + SCHED_TAKE_COVER_FROM_BEST_SOUND, + SCHED_TAKE_COVER_FROM_ORIGIN, + SCHED_COWER, // usually a last resort! + SCHED_MELEE_ATTACK1, + SCHED_MELEE_ATTACK2, + SCHED_RANGE_ATTACK1, + SCHED_RANGE_ATTACK2, + SCHED_SPECIAL_ATTACK1, + SCHED_SPECIAL_ATTACK2, + SCHED_STANDOFF, + SCHED_ARM_WEAPON, + SCHED_RELOAD, + SCHED_GUARD, + SCHED_AMBUSH, + SCHED_DIE, + SCHED_WAIT_TRIGGER, + SCHED_FOLLOW, + SCHED_SLEEP, + SCHED_WAKE, + SCHED_BARNACLE_VICTIM_GRAB, + SCHED_BARNACLE_VICTIM_CHOMP, + SCHED_AISCRIPT, + SCHED_FAIL, + LAST_COMMON_SCHEDULE // Leave this at the bottom } SCHEDULE_TYPE; //========================================================= @@ -82,97 +82,97 @@ typedef enum //========================================================= typedef enum { - TASK_INVALID = 0, - TASK_WAIT, - TASK_WAIT_FACE_ENEMY, - TASK_WAIT_PVS, - TASK_SUGGEST_STATE, - TASK_WALK_TO_TARGET, - TASK_RUN_TO_TARGET, - TASK_MOVE_TO_TARGET_RANGE, - TASK_GET_PATH_TO_ENEMY, - TASK_GET_PATH_TO_ENEMY_LKP, - TASK_GET_PATH_TO_ENEMY_CORPSE, - TASK_GET_PATH_TO_LEADER, - TASK_GET_PATH_TO_SPOT, - TASK_GET_PATH_TO_TARGET, - TASK_GET_PATH_TO_HINTNODE, - TASK_GET_PATH_TO_LASTPOSITION, - TASK_GET_PATH_TO_BESTSOUND, - TASK_GET_PATH_TO_BESTSCENT, - TASK_RUN_PATH, - TASK_WALK_PATH, - TASK_STRAFE_PATH, - TASK_CLEAR_MOVE_WAIT, - TASK_STORE_LASTPOSITION, - TASK_CLEAR_LASTPOSITION, - TASK_PLAY_ACTIVE_IDLE, - TASK_FIND_HINTNODE, - TASK_CLEAR_HINTNODE, - TASK_SMALL_FLINCH, - TASK_FACE_IDEAL, - TASK_FACE_ROUTE, - TASK_FACE_ENEMY, - TASK_FACE_HINTNODE, - TASK_FACE_TARGET, - TASK_FACE_LASTPOSITION, - TASK_RANGE_ATTACK1, - TASK_RANGE_ATTACK2, - TASK_MELEE_ATTACK1, - TASK_MELEE_ATTACK2, - TASK_RELOAD, - TASK_RANGE_ATTACK1_NOTURN, - TASK_RANGE_ATTACK2_NOTURN, - TASK_MELEE_ATTACK1_NOTURN, - TASK_MELEE_ATTACK2_NOTURN, - TASK_RELOAD_NOTURN, - TASK_SPECIAL_ATTACK1, - TASK_SPECIAL_ATTACK2, - TASK_CROUCH, - TASK_STAND, - TASK_GUARD, - TASK_STEP_LEFT, - TASK_STEP_RIGHT, - TASK_STEP_FORWARD, - TASK_STEP_BACK, - TASK_DODGE_LEFT, - TASK_DODGE_RIGHT, - TASK_SOUND_ANGRY, - TASK_SOUND_DEATH, - TASK_SET_ACTIVITY, - TASK_SET_SCHEDULE, - TASK_SET_FAIL_SCHEDULE, - TASK_CLEAR_FAIL_SCHEDULE, - TASK_PLAY_SEQUENCE, - TASK_PLAY_SEQUENCE_FACE_ENEMY, - TASK_PLAY_SEQUENCE_FACE_TARGET, - TASK_SOUND_IDLE, - TASK_SOUND_WAKE, - TASK_SOUND_PAIN, - TASK_SOUND_DIE, - TASK_FIND_COVER_FROM_BEST_SOUND,// tries lateral cover first, then node cover - TASK_FIND_COVER_FROM_ENEMY,// tries lateral cover first, then node cover - TASK_FIND_LATERAL_COVER_FROM_ENEMY, - TASK_FIND_NODE_COVER_FROM_ENEMY, - TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY,// data for this one is the MAXIMUM acceptable distance to the cover. - TASK_FIND_FAR_NODE_COVER_FROM_ENEMY,// data for this one is there MINIMUM aceptable distance to the cover. - TASK_FIND_COVER_FROM_ORIGIN, - TASK_EAT, - TASK_DIE, - TASK_WAIT_FOR_SCRIPT, - TASK_PLAY_SCRIPT, - TASK_ENABLE_SCRIPT, - TASK_PLANT_ON_SCRIPT, - TASK_FACE_SCRIPT, - TASK_WAIT_RANDOM, - TASK_WAIT_INDEFINITE, - TASK_STOP_MOVING, - TASK_TURN_LEFT, - TASK_TURN_RIGHT, - TASK_REMEMBER, - TASK_FORGET, - TASK_WAIT_FOR_MOVEMENT, // wait until MovementIsComplete() - LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM!! (sjb) + TASK_INVALID = 0, + TASK_WAIT, + TASK_WAIT_FACE_ENEMY, + TASK_WAIT_PVS, + TASK_SUGGEST_STATE, + TASK_WALK_TO_TARGET, + TASK_RUN_TO_TARGET, + TASK_MOVE_TO_TARGET_RANGE, + TASK_GET_PATH_TO_ENEMY, + TASK_GET_PATH_TO_ENEMY_LKP, + TASK_GET_PATH_TO_ENEMY_CORPSE, + TASK_GET_PATH_TO_LEADER, + TASK_GET_PATH_TO_SPOT, + TASK_GET_PATH_TO_TARGET, + TASK_GET_PATH_TO_HINTNODE, + TASK_GET_PATH_TO_LASTPOSITION, + TASK_GET_PATH_TO_BESTSOUND, + TASK_GET_PATH_TO_BESTSCENT, + TASK_RUN_PATH, + TASK_WALK_PATH, + TASK_STRAFE_PATH, + TASK_CLEAR_MOVE_WAIT, + TASK_STORE_LASTPOSITION, + TASK_CLEAR_LASTPOSITION, + TASK_PLAY_ACTIVE_IDLE, + TASK_FIND_HINTNODE, + TASK_CLEAR_HINTNODE, + TASK_SMALL_FLINCH, + TASK_FACE_IDEAL, + TASK_FACE_ROUTE, + TASK_FACE_ENEMY, + TASK_FACE_HINTNODE, + TASK_FACE_TARGET, + TASK_FACE_LASTPOSITION, + TASK_RANGE_ATTACK1, + TASK_RANGE_ATTACK2, + TASK_MELEE_ATTACK1, + TASK_MELEE_ATTACK2, + TASK_RELOAD, + TASK_RANGE_ATTACK1_NOTURN, + TASK_RANGE_ATTACK2_NOTURN, + TASK_MELEE_ATTACK1_NOTURN, + TASK_MELEE_ATTACK2_NOTURN, + TASK_RELOAD_NOTURN, + TASK_SPECIAL_ATTACK1, + TASK_SPECIAL_ATTACK2, + TASK_CROUCH, + TASK_STAND, + TASK_GUARD, + TASK_STEP_LEFT, + TASK_STEP_RIGHT, + TASK_STEP_FORWARD, + TASK_STEP_BACK, + TASK_DODGE_LEFT, + TASK_DODGE_RIGHT, + TASK_SOUND_ANGRY, + TASK_SOUND_DEATH, + TASK_SET_ACTIVITY, + TASK_SET_SCHEDULE, + TASK_SET_FAIL_SCHEDULE, + TASK_CLEAR_FAIL_SCHEDULE, + TASK_PLAY_SEQUENCE, + TASK_PLAY_SEQUENCE_FACE_ENEMY, + TASK_PLAY_SEQUENCE_FACE_TARGET, + TASK_SOUND_IDLE, + TASK_SOUND_WAKE, + TASK_SOUND_PAIN, + TASK_SOUND_DIE, + TASK_FIND_COVER_FROM_BEST_SOUND,// tries lateral cover first, then node cover + TASK_FIND_COVER_FROM_ENEMY,// tries lateral cover first, then node cover + TASK_FIND_LATERAL_COVER_FROM_ENEMY, + TASK_FIND_NODE_COVER_FROM_ENEMY, + TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY,// data for this one is the MAXIMUM acceptable distance to the cover. + TASK_FIND_FAR_NODE_COVER_FROM_ENEMY,// data for this one is there MINIMUM aceptable distance to the cover. + TASK_FIND_COVER_FROM_ORIGIN, + TASK_EAT, + TASK_DIE, + TASK_WAIT_FOR_SCRIPT, + TASK_PLAY_SCRIPT, + TASK_ENABLE_SCRIPT, + TASK_PLANT_ON_SCRIPT, + TASK_FACE_SCRIPT, + TASK_WAIT_RANDOM, + TASK_WAIT_INDEFINITE, + TASK_STOP_MOVING, + TASK_TURN_LEFT, + TASK_TURN_RIGHT, + TASK_REMEMBER, + TASK_FORGET, + TASK_WAIT_FOR_MOVEMENT, // wait until MovementIsComplete() + LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM!! (sjb) } SHARED_TASKS; @@ -229,62 +229,64 @@ struct WayPoint_t // these MoveFlag values are assigned to a WayPoint's TYPE in order to demonstrate the // type of movement the monster should use to get there. -#define bits_MF_TO_TARGETENT ( 1 << 0 ) // local move to targetent. -#define bits_MF_TO_ENEMY ( 1 << 1 ) // local move to enemy -#define bits_MF_TO_COVER ( 1 << 2 ) // local move to a hiding place -#define bits_MF_TO_DETOUR ( 1 << 3 ) // local move to detour point. -#define bits_MF_TO_PATHCORNER ( 1 << 4 ) // local move to a path corner -#define bits_MF_TO_NODE ( 1 << 5 ) // local move to a node -#define bits_MF_TO_LOCATION ( 1 << 6 ) // local move to an arbitrary point -#define bits_MF_IS_GOAL ( 1 << 7 ) // this waypoint is the goal of the whole move. -#define bits_MF_DONT_SIMPLIFY ( 1 << 8 ) // Don't let the route code simplify this waypoint +enum { + bits_MF_TO_TARGETENT = ( 1 << 0 ), // local move to targetent. + bits_MF_TO_ENEMY = ( 1 << 1 ), // local move to enemy + bits_MF_TO_COVER = ( 1 << 2 ), // local move to a hiding place + bits_MF_TO_DETOUR = ( 1 << 3 ), // local move to detour point. + bits_MF_TO_PATHCORNER = ( 1 << 4 ), // local move to a path corner + bits_MF_TO_NODE = ( 1 << 5 ), // local move to a node + bits_MF_TO_LOCATION = ( 1 << 6 ), // local move to an arbitrary point + bits_MF_IS_GOAL = ( 1 << 7 ), // this waypoint is the goal of the whole move. + bits_MF_DONT_SIMPLIFY = ( 1 << 8 ), // Don't let the route code simplify this waypoint + bits_MF_NOT_TO_MASK = (bits_MF_IS_GOAL | bits_MF_DONT_SIMPLIFY) +}; // If you define any flags that aren't _TO_ flags, add them here so we can mask // them off when doing compares. -#define bits_MF_NOT_TO_MASK (bits_MF_IS_GOAL | bits_MF_DONT_SIMPLIFY) - -#define MOVEGOAL_NONE (0) -#define MOVEGOAL_TARGETENT (bits_MF_TO_TARGETENT) -#define MOVEGOAL_ENEMY (bits_MF_TO_ENEMY) -#define MOVEGOAL_PATHCORNER (bits_MF_TO_PATHCORNER) -#define MOVEGOAL_LOCATION (bits_MF_TO_LOCATION) -#define MOVEGOAL_NODE (bits_MF_TO_NODE) +enum { + MOVEGOAL_NONE = 0, + MOVEGOAL_TARGETENT = bits_MF_TO_TARGETENT, + MOVEGOAL_ENEMY = bits_MF_TO_ENEMY, + MOVEGOAL_PATHCORNER = bits_MF_TO_PATHCORNER, + MOVEGOAL_LOCATION = bits_MF_TO_LOCATION, + MOVEGOAL_NODE = bits_MF_TO_NODE +}; // these bits represent conditions that may befall the monster, of which some are allowed // to interrupt certain schedules. -#define bits_COND_NO_AMMO_LOADED ( 1 << 0 ) // weapon needs to be reloaded! -#define bits_COND_SEE_HATE ( 1 << 1 ) // see something that you hate -#define bits_COND_SEE_FEAR ( 1 << 2 ) // see something that you are afraid of -#define bits_COND_SEE_DISLIKE ( 1 << 3 ) // see something that you dislike -#define bits_COND_SEE_ENEMY ( 1 << 4 ) // target entity is in full view. -#define bits_COND_ENEMY_OCCLUDED ( 1 << 5 ) // target entity occluded by the world -#define bits_COND_SMELL_FOOD ( 1 << 6 ) -#define bits_COND_ENEMY_TOOFAR ( 1 << 7 ) -#define bits_COND_LIGHT_DAMAGE ( 1 << 8 ) // hurt a little -#define bits_COND_HEAVY_DAMAGE ( 1 << 9 ) // hurt a lot -#define bits_COND_CAN_RANGE_ATTACK1 ( 1 << 10) -#define bits_COND_CAN_MELEE_ATTACK1 ( 1 << 11) -#define bits_COND_CAN_RANGE_ATTACK2 ( 1 << 12) -#define bits_COND_CAN_MELEE_ATTACK2 ( 1 << 13) -// #define bits_COND_CAN_RANGE_ATTACK3 ( 1 << 14) -#define bits_COND_PROVOKED ( 1 << 15) -#define bits_COND_NEW_ENEMY ( 1 << 16) -#define bits_COND_HEAR_SOUND ( 1 << 17) // there is an interesting sound -#define bits_COND_SMELL ( 1 << 18) // there is an interesting scent -#define bits_COND_ENEMY_FACING_ME ( 1 << 19) // enemy is facing me -#define bits_COND_ENEMY_DEAD ( 1 << 20) // enemy was killed. If you get this in combat, try to find another enemy. If you get it in alert, victory dance. -#define bits_COND_SEE_CLIENT ( 1 << 21) // see a client -#define bits_COND_SEE_NEMESIS ( 1 << 22) // see my nemesis - -#define bits_COND_SPECIAL1 ( 1 << 28) // Defined by individual monster -#define bits_COND_SPECIAL2 ( 1 << 29) // Defined by individual monster - -#define bits_COND_TASK_FAILED ( 1 << 30) -#define bits_COND_SCHEDULE_DONE ( 1 << 31) +enum { + bits_COND_NO_AMMO_LOADED = (1 << 0),// weapon needs to be reloaded! + bits_COND_SEE_HATE = (1 << 1),// see something that you hate + bits_COND_SEE_FEAR = (1 << 2),// see something that you are afraid of + bits_COND_SEE_DISLIKE = (1 << 3),// see something that you dislike + bits_COND_SEE_ENEMY = (1 << 4),// target entity is in full view. + bits_COND_ENEMY_OCCLUDED = (1 << 5),// target entity occluded by the world + bits_COND_SMELL_FOOD = (1 << 6), + bits_COND_ENEMY_TOOFAR = (1 << 7), + bits_COND_LIGHT_DAMAGE = (1 << 8),// hurt a little + bits_COND_HEAVY_DAMAGE = (1 << 9),// hurt a lot + bits_COND_CAN_RANGE_ATTACK1 = (1 << 10), + bits_COND_CAN_MELEE_ATTACK1 = (1 << 11), + bits_COND_CAN_RANGE_ATTACK2 = (1 << 12), + bits_COND_CAN_MELEE_ATTACK2 = (1 << 13), + //bits_COND_CAN_RANGE_ATTACK3 = ( 1 << 14), + bits_COND_PROVOKED = (1 << 15), + bits_COND_NEW_ENEMY = (1 << 16), + bits_COND_HEAR_SOUND = (1 << 17),// there is an interesting sound + bits_COND_SMELL = (1 << 18),// there is an interesting scent + bits_COND_ENEMY_FACING_ME = (1 << 19),// enemy is facing me + bits_COND_ENEMY_DEAD = (1 << 20),// enemy was killed. If you get this in combat, try to find another enemy. If you get it in alert, victory dance. + bits_COND_SEE_CLIENT = (1 << 21),// see a client + bits_COND_SEE_NEMESIS = (1 << 22),// see my nemesis + bits_COND_SPECIAL1 = (1 << 28),// Defined by individual monster + bits_COND_SPECIAL2 = (1 << 29),// Defined by individual monster + bits_COND_TASK_FAILED = (1 << 30), + bits_COND_SCHEDULE_DONE = (1 << 31), + bits_COND_ALL_SPECIAL = (bits_COND_SPECIAL1 | bits_COND_SPECIAL2), + bits_COND_CAN_ATTACK = (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2) -#define bits_COND_ALL_SPECIAL (bits_COND_SPECIAL1 | bits_COND_SPECIAL2) - -#define bits_COND_CAN_ATTACK (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2) +}; #endif // SCHEDULE_H diff --git a/src/game/server/monsters/msmonster.h b/src/game/server/monsters/msmonster.h index fee4544c..95d51bf0 100644 --- a/src/game/server/monsters/msmonster.h +++ b/src/game/server/monsters/msmonster.h @@ -200,22 +200,28 @@ struct random_monster_t //NOV2014_20 - Thothie msmonster_random [end] //Frame conditions -#define FC_STEP (1 << 1) //Monster walked up a step this frame -#define FC_JUMP (1 << 2) //Monster began a jump this frame -#define FC_AVOID (1 << 3) //Monster is avoiding an object this frame + +enum { + FC_STEP = (1 << 1), //Monster walked up a step this frame + FC_JUMP = (1 << 2), //Monster began a jump this frame + FC_AVOID = (1 << 3) //Monster is avoiding an object this frame +}; //General Conditions (Added to those defined in schedule.h) -#define MONSTER_ROAM (1 << 23) // Monster should roam around -#define MONSTER_HASMOVEDEST (1 << 24) // vMoveDest is valid -#define MONSTER_TRADING (1 << 25) // NPC is trading with a player -#define MONSTER_REFLECTIVEDMG (1 << 26) // Damage is reflected back to attacker -#define MONSTER_NOAI (1 << 27) // Don't normal script events -#define MONSTER_OPENCONTAINER (1 << 28) // Player is looking inside a pack -#define MONSTER_BLIND (1 << 29) // MAR2008b - Monster is blind -#define MONSTER_INVISIBLE (1 << 30) // MAR2008b - Monster is invisible - -#define MAX_ENEMYLIST 12 -#define MAX_NPC_HANDS 3 + +enum { + MONSTER_ROAM = (1 << 23),// Monster should roam around + MONSTER_HASMOVEDEST = (1 << 24),// vMoveDest is valid + MONSTER_TRADING = (1 << 25),// NPC is trading with a player + MONSTER_REFLECTIVEDMG = (1 << 26),// Damage is reflected back to attacker + MONSTER_NOAI = (1 << 27),// Don't normal script events + MONSTER_OPENCONTAINER = (1 << 28),// Player is looking inside a pack + MONSTER_BLIND = (1 << 29),// MAR2008b - Monster is blind + MONSTER_INVISIBLE = (1 << 30),// MAR2008b - Monster is invisible +}; + +constexpr int MAX_ENEMYLIST = 12; +constexpr int MAX_NPC_HANDS = 3; class CMSMonster : public CBaseMonster { From 51ffb9d83a59a929f019ab50dc0d1dd4653b6b2a Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:22:11 -0400 Subject: [PATCH 026/291] Changed to enum --- src/common/beamdef.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/common/beamdef.h b/src/common/beamdef.h index 69876ceb..7c80afc1 100644 --- a/src/common/beamdef.h +++ b/src/common/beamdef.h @@ -18,18 +18,20 @@ #pragma once #endif -constexpr int FBEAM_STARTENTITY = 0x00000001; -constexpr int FBEAM_ENDENTITY = 0x00000002; -constexpr int FBEAM_FADEIN = 0x00000004; -constexpr int FBEAM_FADEOUT = 0x00000008; -constexpr int FBEAM_SINENOISE = 0x00000010; -constexpr int FBEAM_SOLID = 0x00000020; -constexpr int FBEAM_SHADEIN = 0x00000040; -constexpr int FBEAM_SHADEOUT = 0x00000080; -constexpr int FBEAM_STARTVISIBLE = 0x10000000; // Has this client actually seen this beam's start entity yet?; -constexpr int FBEAM_ENDVISIBLE = 0x20000000; // Has this client actually seen this beam's end entity yet?; -constexpr int FBEAM_ISACTIVE = 0x40000000; -constexpr int FBEAM_FOREVER = 0x80000000; +enum { + FBEAM_STARTENTITY = 0x00000001, + FBEAM_ENDENTITY = 0x00000002, + FBEAM_FADEIN = 0x00000004, + FBEAM_FADEOUT = 0x00000008, + FBEAM_SINENOISE = 0x00000010, + FBEAM_SOLID = 0x00000020, + FBEAM_SHADEIN = 0x00000040, + FBEAM_SHADEOUT = 0x00000080, + FBEAM_STARTVISIBLE = 0x10000000, // Has this client actually seen this beam's start entity yet?; + FBEAM_ENDVISIBLE = 0x20000000, // Has this client actually seen this beam's end entity yet?; + FBEAM_ISACTIVE = 0x40000000, + FBEAM_FOREVER = 0x80000000 +}; typedef struct beam_s BEAM; struct beam_s From 5ebc2ec17d3961b502c8ae7daef1c13668a64fb6 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:25:08 -0400 Subject: [PATCH 027/291] changes flags to enum. --- src/common/com_model.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/common/com_model.h b/src/common/com_model.h index ffdfb681..c8466505 100644 --- a/src/common/com_model.h +++ b/src/common/com_model.h @@ -38,15 +38,19 @@ constexpr int MAX_EDICTS = 2048; constexpr int ALIAS_Z_CLIP_PLANE = 5; // flags in finalvert_t.flags -constexpr int ALIAS_LEFT_CLIP = 0x0001; -constexpr int ALIAS_TOP_CLIP = 0x0002; -constexpr int ALIAS_RIGHT_CLIP = 0x0004; -constexpr int ALIAS_BOTTOM_CLIP = 0x0008; -constexpr int ALIAS_Z_CLIP = 0x0010; -constexpr int ALIAS_ONSEAM = 0x0020; -constexpr int ALIAS_XY_CLIP_MASK = 0x000F; -constexpr float ZISCALE = ((float)0x8000); + +enum { + ALIAS_LEFT_CLIP = 0x0001, + ALIAS_TOP_CLIP = 0x0002, + ALIAS_RIGHT_CLIP = 0x0004, + ALIAS_BOTTOM_CLIP = 0x0008, + ALIAS_Z_CLIP = 0x0010, + ALIAS_ONSEAM = 0x0020, + ALIAS_XY_CLIP_MASK = 0x000F +}; + +constexpr float ZISCALE = (float)0x8000; constexpr int CACHE_SIZE = 32; // used to align key data structures typedef enum From a7782eef343c5129345fe25a3f84a84330763be8 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:28:41 -0400 Subject: [PATCH 028/291] Fixed cast warning --- src/game/shared/ms/mscharacter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/shared/ms/mscharacter.cpp b/src/game/shared/ms/mscharacter.cpp index 8ec41031..002f3eec 100644 --- a/src/game/shared/ms/mscharacter.cpp +++ b/src/game/shared/ms/mscharacter.cpp @@ -303,7 +303,7 @@ void WriteItem(CPlayer_DataBuffer &gFile, genericitem_full_t &Item) //Writing contained items should be the *LAST* thing you do if (FBitSet(Item.Properties, ITEM_CONTAINER)) { - gFile.WriteShort(Item.ContainerItems.size()); //[SHORT] Container Item Total + gFile.WriteShort(static_cast(Item.ContainerItems.size())); //[SHORT] Container Item Total for (int i = 0; i < Item.ContainerItems.size(); i++) WriteItem(gFile, Item.ContainerItems[i]); From 364c1cbe56d6097a89d17ca056b355b0eee55f6d Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:28:51 -0400 Subject: [PATCH 029/291] fixed posix warning --- src/game/server/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/server/client.cpp b/src/game/server/client.cpp index c7e3bcbb..b35faa01 100644 --- a/src/game/server/client.cpp +++ b/src/game/server/client.cpp @@ -2197,7 +2197,7 @@ const char *GetGameDescription() #else char build[8] = {__DATE__[0], __DATE__[1], __DATE__[2], __DATE__[7], __DATE__[8], __DATE__[9], __DATE__[10]}; static char gameDesc[64]; - sprintf(gameDesc, "MS:R - %sa", strupr(build)); + sprintf(gameDesc, "MS:R - %sa", _strupr(build)); #endif return gameDesc; From df1c90ecb54b23687596b343663394132bbf5191 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:02:01 -0400 Subject: [PATCH 030/291] Fixed cast warnings. --- src/game/server/sv_character.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/game/server/sv_character.cpp b/src/game/server/sv_character.cpp index 1f49890f..0dd83ac8 100644 --- a/src/game/server/sv_character.cpp +++ b/src/game/server/sv_character.cpp @@ -584,11 +584,11 @@ void MSChar_Interface::SaveChar(CBasePlayer *pPlayer, savedata_t *pData) //Save skills gFile.WriteByte(CHARDATA_SKILLS1); //[BYTE - CHUNK - STATS] statlist &StatList = pPlayer->m_Stats; - gFile.WriteByte(StatList.size()); //[BYTE] + gFile.WriteByte(static_cast(StatList.size())); //[BYTE] for (int i = 0; i < StatList.size(); i++) { CStat &Stat = StatList[i]; - gFile.WriteByte(Stat.m_SubStats.size()); //[BYTE] + gFile.WriteByte(static_cast(Stat.m_SubStats.size())); //[BYTE] for (int r = 0; r < Stat.m_SubStats.size(); r++) { CSubStat &SubStat = Stat.m_SubStats[r]; @@ -600,7 +600,7 @@ void MSChar_Interface::SaveChar(CBasePlayer *pPlayer, savedata_t *pData) //Save magic spells spellgroup_v &SpellList = pPlayer->m_SpellList; gFile.WriteByte(CHARDATA_SPELLS1); //[BYTE - CHUNK - SPELLS] - gFile.WriteByte(SpellList.size()); //[BYTE] + gFile.WriteByte(static_cast(SpellList.size())); //[BYTE] for (int s = 0; s < SpellList.size(); s++) gFile.WriteString(SpellList[s]); //[X STRINGS] @@ -615,7 +615,7 @@ void MSChar_Interface::SaveChar(CBasePlayer *pPlayer, savedata_t *pData) if (pPlayer->Gear[i] != pPlayer->PlayerHands) //Skip player hands WriteList.add(pPlayer->Gear[i]); - gFile.WriteByte(WriteList.size()); //[BYTE] + gFile.WriteByte(static_cast(WriteList.size())); //[BYTE] for (int i = 0; i < WriteList.size(); i++) { @@ -625,21 +625,21 @@ void MSChar_Interface::SaveChar(CBasePlayer *pPlayer, savedata_t *pData) //Save storage items gFile.WriteByte(CHARDATA_STORAGE1); //[BYTE - CHUNK - STORAGE ITEMS] - gFile.WriteShort(pPlayer->m_Storages.size()); //[SHORT] + gFile.WriteShort(static_cast(pPlayer->m_Storages.size())); //[SHORT] for (int s = 0; s < pPlayer->m_Storages.size(); s++) { storage_t &Storage = pPlayer->m_Storages[s]; gFile.WriteString(Storage.Name); //[STRING] - gFile.WriteShort(Storage.Items.size()); //[SHORT] + gFile.WriteShort(static_cast(Storage.Items.size())); //[SHORT] for (int i = 0; i < Storage.Items.size(); i++) WriteItem(gFile, Storage.Items[i]); //[X ITEMS] } //Save Companions gFile.WriteByte(CHARDATA_COMPANIONS1); //[BYTE - CHUNK - COMPANIONS] - gFile.WriteShort(pPlayer->m_Companions.size()); //[SHORT] + gFile.WriteShort(static_cast(pPlayer->m_Companions.size())); //[SHORT] static msstringlist SaveVarName, SaveVarValue; SaveVarName.clearitems(); SaveVarValue.clearitems(); @@ -667,7 +667,7 @@ void MSChar_Interface::SaveChar(CBasePlayer *pPlayer, savedata_t *pData) SaveVarValue.add(Script->m_Variables[v].Value); } - gFile.WriteShort(SaveVarName.size()); //[SHORT] + gFile.WriteShort(static_cast(SaveVarName.size())); //[SHORT] for (int var = 0; var < SaveVarName.size(); var++) { gFile.WriteString(SaveVarName[var]); //[STRING] @@ -679,7 +679,7 @@ void MSChar_Interface::SaveChar(CBasePlayer *pPlayer, savedata_t *pData) //Save Help tips gFile.WriteByte(CHARDATA_HELPTIPS1); //[BYTE - CHUNK - HELPTIPS] - gFile.WriteShort(pPlayer->m_ViewedHelpTips.size()); //[SHORT] + gFile.WriteShort(static_cast(pPlayer->m_ViewedHelpTips.size())); //[SHORT] for (int t = 0; t < pPlayer->m_ViewedHelpTips.size(); t++) gFile.WriteString(pPlayer->m_ViewedHelpTips[t]); //[STRING] From f6d7864fc369396ccf9cac91185cb53616160506 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:02:27 -0400 Subject: [PATCH 031/291] changed constexpr to enum where appropriate --- src/common/const.h | 1238 +++++++++++++++++++++++--------------------- 1 file changed, 638 insertions(+), 600 deletions(-) diff --git a/src/common/const.h b/src/common/const.h index b6c6e46f..765cd275 100644 --- a/src/common/const.h +++ b/src/common/const.h @@ -24,620 +24,660 @@ constexpr double PI = 3.14159265358979323846; // edict->flags -constexpr int FL_FLY = (1 << 0); // Changes the SV_Movestep() behavior to not need to be on ground -constexpr int FL_SWIM = (1 << 1); // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) -constexpr int FL_CONVEYOR = (1 << 2); -constexpr int FL_CLIENT = (1 << 3); -constexpr int FL_INWATER = (1 << 4); -constexpr int FL_MONSTER = (1 << 5); -constexpr int FL_GODMODE = (1 << 6); -constexpr int FL_NOTARGET = (1 << 7); -constexpr int FL_SKIPLOCALHOST = (1 << 8); // Don't send entity to local host, it's predicting this entity itself -constexpr int FL_ONGROUND = (1 << 9); // At rest / on the ground -constexpr int FL_PARTIALGROUND = (1 << 10);// not all corners are valid -constexpr int FL_WATERJUMP = (1 << 11); // player jumping out of water -constexpr int FL_FROZEN = (1 << 12); // Player is frozen for 3rd person camera -constexpr int FL_FAKECLIENT = (1 << 13); // JAC: fake client, simulated server side; don't send network messages to them -constexpr int FL_DUCKING = (1 << 14); // Player flag -- Player is fully crouched -constexpr int FL_FLOAT = (1 << 15); // Apply floating force to this entity when in water -constexpr int FL_GRAPHED = (1 << 16); // worldgraph has this ent listed as something that blocks a connection - -// UNDONE: Do we need these? -constexpr int FL_IMMUNE_WATER = (1 << 17); -//constexpr int FL_IMMUNE_SLIME (1 << 18); -constexpr int FL_CLIENTONLY = (1 << 18); // Strip edicts -constexpr int FL_IMMUNE_LAVA = (1 << 19); - -constexpr int FL_PROXY = (1 << 20); // This is a spectator proxy -constexpr int FL_ALWAYSTHINK = (1 << 21); // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) -constexpr int FL_BASEVELOCITY = (1 << 22);// Base velocity has been applied this frame (used to convert base velocity into momentum) -constexpr int FL_MONSTERCLIP = (1 << 23); // Only collide in with monsters who have FL_MONSTERCLIP set -constexpr int FL_ONTRAIN = (1 << 24); // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. -constexpr int FL_WORLDBRUSH = (1 << 25); // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) -constexpr int FL_SPECTATOR = (1 << 26); // This client is a spectator, don't run touch functions, etc. -constexpr int FL_CUSTOMENTITY = (1 << 29); // This is a custom entity -constexpr int FL_KILLME = (1 << 30); // This entity is marked for death -- This allows the engine to kill ents at the appropriate time -constexpr int FL_DORMANT = (1 << 31); // Entity is dormant, no updates to client +enum { + FL_FLY = (1 << 0), // Changes the SV_Movestep() behavior to not need to be on ground + FL_SWIM = (1 << 1), // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) + FL_CONVEYOR = (1 << 2), + FL_CLIENT = (1 << 3), + FL_INWATER = (1 << 4), + FL_MONSTER = (1 << 5), + FL_GODMODE = (1 << 6), + FL_NOTARGET = (1 << 7), + FL_SKIPLOCALHOST = (1 << 8), // Don't send entity to local host, it's predicting this entity itself + FL_ONGROUND = (1 << 9), // At rest / on the ground + FL_PARTIALGROUND = (1 << 10),// not all corners are valid + FL_WATERJUMP = (1 << 11), // player jumping out of water + FL_FROZEN = (1 << 12), // Player is frozen for 3rd person camera + FL_FAKECLIENT = (1 << 13), // JAC: fake client, simulated server side; don't send network messages to them + FL_DUCKING = (1 << 14), // Player flag -- Player is fully crouched + FL_FLOAT = (1 << 15), // Apply floating force to this entity when in water + FL_GRAPHED = (1 << 16), // worldgraph has this ent listed as something that blocks a connection + // UNDONE: Do we need these? + FL_IMMUNE_WATER = (1 << 17), + //FL_IMMUNE_SLIME (1 << 18); + FL_CLIENTONLY = (1 << 18), // Strip edicts + FL_IMMUNE_LAVA = (1 << 19), + FL_PROXY = (1 << 20), // This is a spectator proxy + FL_ALWAYSTHINK = (1 << 21), // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) + FL_BASEVELOCITY = (1 << 22),// Base velocity has been applied this frame (used to convert base velocity into momentum) + FL_MONSTERCLIP = (1 << 23), // Only collide in with monsters who have FL_MONSTERCLIP set + FL_ONTRAIN = (1 << 24), // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. + FL_WORLDBRUSH = (1 << 25), // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) + FL_SPECTATOR = (1 << 26), // This client is a spectator, don't run touch functions, etc. + FL_CUSTOMENTITY = (1 << 29), // This is a custom entity + FL_KILLME = (1 << 30), // This entity is marked for death -- This allows the engine to kill ents at the appropriate time + FL_DORMANT = (1 << 31) // Entity is dormant, no updates to client +}; // Goes into globalvars_t.trace_flags + constexpr int FTRACE_SIMPLEBOX = (1 << 0); // Traceline with a simple box // walkmove modes - constexpr int WALKMOVE_NORMAL = 0; // normal walkmove - constexpr int WALKMOVE_WORLDONLY = 1; // doesn't hit ANY entities, no matter what the solid type - constexpr int WALKMOVE_CHECKONLY = 2; // move, but don't touch triggers +enum { + WALKMOVE_NORMAL = 0, // normal walkmove + WALKMOVE_WORLDONLY = 1, // doesn't hit ANY entities, no matter what the solid type + WALKMOVE_CHECKONLY = 2 // move, but don't touch triggers +}; // edict->movetype values - constexpr int MOVETYPE_NONE = 0; - constexpr int MOVETYPE_ANGLENOCLIP = 1; - constexpr int MOVETYPE_ANGLECLIP = 2; - constexpr int MOVETYPE_WALK = 3; // Player only - moving on the ground - constexpr int MOVETYPE_STEP = 4; // gravity, special edge handling -- monsters use this - constexpr int MOVETYPE_FLY = 5; // No gravity, but still collides with stuff - constexpr int MOVETYPE_TOSS = 6; // gravity/collisions - constexpr int MOVETYPE_PUSH = 7; // no clip to world, push and crush - constexpr int MOVETYPE_NOCLIP = 8; // No gravity, no collisions, still do velocity/avelocity - constexpr int MOVETYPE_FLYMISSILE = 9; // extra size to monsters - constexpr int MOVETYPE_BOUNCE = 10; // Just like Toss, but reflect velocity when contacting surfaces - constexpr int MOVETYPE_BOUNCEMISSILE = 11;// bounce w/o gravity - constexpr int MOVETYPE_FOLLOW = 12; // track movement of aiment - constexpr int MOVETYPE_PUSHSTEP = 13; // BSP model that needs physics/world collisions (uses nearest hull for world collision) - +enum { + MOVETYPE_NONE = 0, + MOVETYPE_ANGLENOCLIP = 1, + MOVETYPE_ANGLECLIP = 2, + MOVETYPE_WALK = 3, // Player only - moving on the ground + MOVETYPE_STEP = 4, // gravity, special edge handling -- monsters use this + MOVETYPE_FLY = 5, // No gravity, but still collides with stuff + MOVETYPE_TOSS = 6, // gravity/collisions + MOVETYPE_PUSH = 7, // no clip to world, push and crush + MOVETYPE_NOCLIP = 8, // No gravity, no collisions, still do velocity/avelocity + MOVETYPE_FLYMISSILE = 9, // extra size to monsters + MOVETYPE_BOUNCE = 10, // Just like Toss, but reflect velocity when contacting surfaces + MOVETYPE_BOUNCEMISSILE = 11,// bounce w/o gravity + MOVETYPE_FOLLOW = 12, // track movement of aiment + MOVETYPE_PUSHSTEP = 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision) +}; // edict->solid values // NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves // SOLID only effects OTHER entities colliding with this one when they move - UGH! -constexpr int SOLID_NOT = 0; // no interaction with other objects -constexpr int SOLID_TRIGGER = 1; // touch on edge, but not blocking -constexpr int SOLID_BBOX = 2; // touch on edge, block -constexpr int SOLID_SLIDEBOX = 3;// touch on edge, but not an onground -constexpr int SOLID_BSP = 4; // bsp clip, touch on edge, block +enum { + SOLID_NOT = 0, // no interaction with other objects + SOLID_TRIGGER = 1, // touch on edge, but not blocking + SOLID_BBOX = 2, // touch on edge, block + SOLID_SLIDEBOX = 3,// touch on edge, but not an onground + SOLID_BSP = 4 // bsp clip, touch on edge, block +}; // edict->deadflag values -constexpr int DEAD_NO = 0; // alive -constexpr int DEAD_DYING = 1; // playing death animation or still falling off of a ledge waiting to hit ground -constexpr int DEAD_DEAD = 2; // dead. lying still. -constexpr int DEAD_RESPAWNABLE = 3; -constexpr int DEAD_DISCARDBODY = 4; - -constexpr int DAMAGE_NO = 0; -constexpr int DAMAGE_YES = 1; -constexpr int DAMAGE_AIM = 2; - -// entity effects -constexpr int EF_BRIGHTFIELD = 1; // swirling cloud of particles -constexpr int EF_MUZZLEFLASH = 2; // single frame ELIGHT on entity attachment 0 -constexpr int EF_BRIGHTLIGHT = 4;// DLIGHT centered at entity origin -constexpr int EF_DIMLIGHT = 8; // player flashlight -constexpr int EF_INVLIGHT = 16; // get lighting from ceiling -constexpr int EF_NOINTERP = 32; // don't interpolate the next frame -constexpr int EF_LIGHT = 64; // rocket flare glow sprite -constexpr int EF_NODRAW = 128; // don't draw entity + +enum { + DEAD_NO = 0, // alive + DEAD_DYING = 1, // playing death animation or still falling off of a ledge waiting to hit ground + DEAD_DEAD = 2, // dead. lying still. + DEAD_RESPAWNABLE = 3, + DEAD_DISCARDBODY = 4 +}; + +enum { + DAMAGE_NO = 0, + DAMAGE_YES = 1, + DAMAGE_AIM = 2 +}; + +enum { + // entity effects + EF_BRIGHTFIELD = 1, // swirling cloud of particles + EF_MUZZLEFLASH = 2, // single frame ELIGHT on entity attachment 0 + EF_BRIGHTLIGHT = 4,// DLIGHT centered at entity origin + EF_DIMLIGHT = 8, // player flashlight + EF_INVLIGHT = 16, // get lighting from ceiling + EF_NOINTERP = 32, // don't interpolate the next frame + EF_LIGHT = 64, // rocket flare glow sprite + EF_NODRAW = 128 // don't draw entity +}; // entity flags -constexpr int EFLAG_SLERP = 1; // do studio interpolation of this entity -constexpr int EFLAG_FLESH_SOUND = 2; +enum { + EFLAG_SLERP = 1, // do studio interpolation of this entity + EFLAG_FLESH_SOUND = 2 +}; + +//temp entity explode flags + +enum { + TE_EXPLFLAG_NONE = 0, // all flags clear makes default Half-Life explosion + TE_EXPLFLAG_NOADDITIVE = 1, // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) + TE_EXPLFLAG_NODLIGHTS = 2, // do not render dynamic lights + TE_EXPLFLAG_NOSOUND = 4, // do not play client explosion sound + TE_EXPLFLAG_NOPARTICLES = 8 // do not draw particles +}; + + +//temp entity fire flags +enum { + TEFIRE_FLAG_ALLFLOAT = 1, // all sprites will drift upwards as they animate + TEFIRE_FLAG_SOMEFLOAT = 2, // some of the sprites will drift upwards. (50% chance) + TEFIRE_FLAG_LOOP = 4, // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. + TEFIRE_FLAG_ALPHA = 8, // if set, sprite is rendered alpha blended at 50% else, opaque + TEFIRE_FLAG_PLANAR = 16,// if set, all fire sprites have same initial Z instead of randomly filling a cube. + TEFIRE_FLAG_ADDITIVE = 32 // if set, sprite is rendered non-opaque with additive +}; + +// Temp entity bounce sound types + +enum { + TE_BOUNCE_NULL = 0, + TE_BOUNCE_SHELL = 1, + TE_BOUNCE_SHOTSHELL = 2 +}; // // temp entity events // -constexpr int TE_BEAMPOINTS = 0; // beam effect between two points -// coord coord coord (start position) -// coord coord coord (end position) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -constexpr int TE_BEAMENTPOINT = 1; // beam effect between point and entity -// short (start entity) -// coord coord coord (end position) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -constexpr int TE_GUNSHOT = 2; // particle effect plus ricochet sound -// coord coord coord (position) - -constexpr int TE_EXPLOSION = 3; // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps -// coord coord coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (framerate) -// byte (flags) -// -// The Explosion effect has some flags to control performance/aesthetic features: -constexpr int TE_EXPLFLAG_NONE = 0; // all flags clear makes default Half-Life explosion -constexpr int TE_EXPLFLAG_NOADDITIVE = 1; // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) -constexpr int TE_EXPLFLAG_NODLIGHTS = 2; // do not render dynamic lights -constexpr int TE_EXPLFLAG_NOSOUND = 4; // do not play client explosion sound -constexpr int TE_EXPLFLAG_NOPARTICLES = 8; // do not draw particles - -constexpr int TE_TAREXPLOSION = 4; // Quake1 "tarbaby" explosion with sound -// coord coord coord (position) - -constexpr int TE_SMOKE = 5; // alphablend sprite, move vertically 30 pps -// coord coord coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (framerate) - -constexpr int TE_TRACER = 6; // tracer effect from point to point -// coord, coord, coord (start) -// coord, coord, coord (end) - -constexpr int TE_LIGHTNING = 7; // TE_BEAMPOINTS with simplified parameters -// coord, coord, coord (start) -// coord, coord, coord (end) -// byte (life in 0.1's) -// byte (width in 0.1's) -// byte (amplitude in 0.01's) -// short (sprite model index) - -constexpr int TE_BEAMENTS = 8; -// short (start entity) -// short (end entity) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -constexpr int TE_SPARKS = 9; // 8 random tracers with gravity, ricochet sprite -// coord coord coord (position) - -constexpr int TE_LAVASPLASH = 10; // Quake1 lava splash -// coord coord coord (position) - -constexpr int TE_TELEPORT = 11; // Quake1 teleport splash -// coord coord coord (position) - -constexpr int TE_EXPLOSION2 = 12; // Quake1 colormaped (base palette) particle explosion with sound -// coord coord coord (position) -// byte (starting color) -// byte (num colors) - -constexpr int TE_BSPDECAL = 13; // Decal from the .BSP file -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// short (texture index of precached decal texture name) -// short (entity index) -// [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity) - -constexpr int TE_IMPLOSION = 14; // tracers moving toward a point -// coord, coord, coord (position) -// byte (radius) -// byte (count) -// byte (life in 0.1's) - -constexpr int TE_SPRITETRAIL = 15; // line of moving glow sprites with gravity, fadeout, and collisions -// coord, coord, coord (start) -// coord, coord, coord (end) -// short (sprite index) -// byte (count) -// byte (life in 0.1's) -// byte (scale in 0.1's) -// byte (velocity along vector in 10's) -// byte (randomness of velocity in 10's) - -constexpr int TE_BEAM = 16; // obsolete - -constexpr int TE_SPRITE = 17; // additive sprite, plays 1 cycle -// coord, coord, coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (brightness) - -constexpr int TE_BEAMSPRITE = 18; // A beam with a sprite at the end -// coord, coord, coord (start position) -// coord, coord, coord (end position) -// short (beam sprite index) -// short (end sprite index) - -constexpr int TE_BEAMTORUS = 19; // screen aligned beam ring, expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -constexpr int TE_BEAMDISK = 20; // disk that expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -constexpr int TE_BEAMCYLINDER = 21; // cylinder that expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -constexpr int TE_BEAMFOLLOW = 22; // create a line of decaying beam segments until entity stops moving -// short (entity:attachment to follow) -// short (sprite index) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte,byte,byte (color) -// byte (brightness) - -constexpr int TE_GLOWSPRITE = 23; -// coord, coord, coord (pos) short (model index) byte (scale / 10) - -constexpr int TE_BEAMRING = 24; // connect a beam ring to two entities -// short (start entity) -// short (end entity) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -constexpr int TE_STREAK_SPLASH = 25; // oriented shower of tracers -// coord coord coord (start position) -// coord coord coord (direction vector) -// byte (color) -// short (count) -// short (base speed) -// short (ramdon velocity) - -constexpr int TE_BEAMHOSE = 26; // obsolete - -constexpr int TE_DLIGHT = 27; // dynamic light, effect world, minor entity effect -// coord, coord, coord (pos) -// byte (radius in 10's) -// byte byte byte (color) -// byte (brightness) -// byte (life in 10's) -// byte (decay rate in 10's) - -constexpr int TE_ELIGHT = 28; // point entity light, no world effect -// short (entity:attachment to follow) -// coord coord coord (initial position) -// coord (radius) -// byte byte byte (color) -// byte (life in 0.1's) -// coord (decay rate) - -constexpr int TE_TEXTMESSAGE = 29; -// short 1.2.13 x (-1 = center) -// short 1.2.13 y (-1 = center) -// byte Effect 0 = fade in/fade out -// 1 is flickery credits -// 2 is write out (training room) - -// 4 bytes r,g,b,a color1 (text color) -// 4 bytes r,g,b,a color2 (effect color) -// ushort 8.8 fadein time -// ushort 8.8 fadeout time -// ushort 8.8 hold time -// optional ushort 8.8 fxtime (time the highlight lags behing the leading text in effect 2) -// string text message (512 chars max sz string) -constexpr int TE_LINE = 30; -// coord, coord, coord startpos -// coord, coord, coord endpos -// short life in 0.1 s -// 3 bytes r, g, b - -constexpr int TE_BOX = 31; -// coord, coord, coord boxmins -// coord, coord, coord boxmaxs -// short life in 0.1 s -// 3 bytes r, g, b - -constexpr int TE_KILLBEAM = 99; // kill all beams attached to entity -// short (entity) - -constexpr int TE_LARGEFUNNEL = 100; -// coord coord coord (funnel position) -// short (sprite index) -// short (flags) - -constexpr int TE_BLOODSTREAM = 101; // particle spray -// coord coord coord (start position) -// coord coord coord (spray vector) -// byte (color) -// byte (speed) - -constexpr int TE_SHOWLINE = 102; // line of particles every 5 units, dies in 30 seconds -// coord coord coord (start position) -// coord coord coord (end position) - -constexpr int TE_BLOOD = 103; // particle spray -// coord coord coord (start position) -// coord coord coord (spray vector) -// byte (color) -// byte (speed) - -constexpr int TE_DECAL = 104; // Decal applied to a brush entity (not the world) -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name) -// short (entity index) - -constexpr int TE_FIZZ = 105; // create alpha sprites inside of entity, float upwards -// short (entity) -// short (sprite index) -// byte (density) - -constexpr int TE_MODEL = 106; // create a moving model that bounces and makes a sound when it hits -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// angle (initial yaw) -// short (model index) -// byte (bounce sound type) -// byte (life in 0.1's) - -constexpr int TE_EXPLODEMODEL = 107; // spherical shower of models, picks from set -// coord, coord, coord (origin) -// coord (velocity) -// short (model index) -// short (count) -// byte (life in 0.1's) - -constexpr int TE_BREAKMODEL = 108; // box of models or sprites -// coord, coord, coord (position) -// coord, coord, coord (size) -// coord, coord, coord (velocity) -// byte (random velocity in 10's) -// short (sprite or model index) -// byte (count) -// byte (life in 0.1 secs) -// byte (flags) - -constexpr int TE_GUNSHOTDECAL = 109; // decal and ricochet sound -// coord, coord, coord (position) -// short (entity index???) -// byte (decal???) - -constexpr int TE_SPRITE_SPRAY = 110; // spay of alpha sprites -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// short (sprite index) -// byte (count) -// byte (speed) -// byte (noise) - -constexpr int TE_ARMOR_RICOCHET = 111; // quick spark sprite, client ricochet sound. -// coord, coord, coord (position) -// byte (scale in 0.1's) - -constexpr int TE_PLAYERDECAL = 112; // ??? -// byte (playerindex) -// coord, coord, coord (position) -// short (entity???) -// byte (decal number???) -// [optional] short (model index???) - -constexpr int TE_BUBBLES = 113; // create alpha sprites inside of box, float upwards -// coord, coord, coord (min start position) -// coord, coord, coord (max start position) -// coord (float height) -// short (model index) -// byte (count) -// coord (speed) - -constexpr int TE_BUBBLETRAIL = 114; // create alpha sprites along a line, float upwards -// coord, coord, coord (min start position) -// coord, coord, coord (max start position) -// coord (float height) -// short (model index) -// byte (count) -// coord (speed) - -constexpr int TE_BLOODSPRITE = 115; // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent) -// coord, coord, coord (position) -// short (sprite1 index) -// short (sprite2 index) -// byte (color) -// byte (scale) - -constexpr int TE_WORLDDECAL = 116; // Decal applied to the world brush -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name) - -constexpr int TE_WORLDDECALHIGH = 117; // Decal (with texture index > 256) applied to world brush -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name - 256) - -constexpr int TE_DECALHIGH = 118; // Same as TE_DECAL, but the texture index was greater than 256 -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name - 256) -// short (entity index) - -constexpr int TE_PROJECTILE = 119; // Makes a projectile (like a nail) (this is a high-priority tent) -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// short (modelindex) -// byte (life) -// byte (owner) projectile won't collide with owner (if owner == 0, projectile will hit any client). - -constexpr int TE_SPRAY = 120; // Throws a shower of sprites or models -// coord, coord, coord (position) -// coord, coord, coord (direction) -// short (modelindex) -// byte (count) -// byte (speed) -// byte (noise) -// byte (rendermode) - -constexpr int TE_PLAYERSPRITES = 121; // sprites emit from a player's bounding box (ONLY use for players!) -// byte (playernum) -// short (sprite modelindex) -// byte (count) -// byte (variance) (0 = no variance in size) (10 = 10% variance in size) - -constexpr int TE_PARTICLEBURST = 122; // very similar to lavasplash. -// coord (origin) -// short (radius) -// byte (particle color) -// byte (duration * 10) (will be randomized a bit) - -constexpr int TE_FIREFIELD = 123; // makes a field of fire. -// coord (origin) -// short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius) -// short (modelindex) -// byte (count) -// byte (flags) -// byte (duration (in seconds) * 10) (will be randomized a bit) -// -// to keep network traffic low, this message has associated flags that fit into a byte: -constexpr int TEFIRE_FLAG_ALLFLOAT = 1; // all sprites will drift upwards as they animate -constexpr int TEFIRE_FLAG_SOMEFLOAT = 2; // some of the sprites will drift upwards. (50% chance) -constexpr int TEFIRE_FLAG_LOOP = 4; // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. -constexpr int TEFIRE_FLAG_ALPHA = 8; // if set, sprite is rendered alpha blended at 50% else, opaque -constexpr int TEFIRE_FLAG_PLANAR = 16;// if set, all fire sprites have same initial Z instead of randomly filling a cube. -constexpr int TEFIRE_FLAG_ADDITIVE = 32; // if set, sprite is rendered non-opaque with additive - -constexpr int TE_PLAYERATTACHMENT = 124; // attaches a TENT to a player (this is a high-priority tent) -// byte (entity index of player) -// coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset ) -// short (model index) -// short (life * 10 ); - -constexpr int TE_KILLPLAYERATTACHMENTS = 125; // will expire all TENTS attached to a player. -// byte (entity index of player) - -constexpr int TE_MULTIGUNSHOT = 126; // much more compact shotgun message -// This message is used to make a client approximate a 'spray' of gunfire. -// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is -// a good candidate for MULTIGUNSHOT use. (shotguns) -// -// NOTE: This effect makes the client do traces for each bullet, these client traces ignore -// entities that have studio models.Traces are 4096 long. -// -// coord (origin) -// coord (origin) -// coord (origin) -// coord (direction) -// coord (direction) -// coord (direction) -// coord (x noise * 100) -// coord (y noise * 100) -// byte (count) -// byte (bullethole decal texture index) - -constexpr int TE_USERTRACER = 127; // larger message than the standard tracer, but allows some customization. -// coord (origin) -// coord (origin) -// coord (origin) -// coord (velocity) -// coord (velocity) -// coord (velocity) -// byte ( life * 10 ) -// byte ( color ) this is an index into an array of color vectors in the engine. (0 - ) -// byte ( length * 10 ) - -constexpr int MSG_BROADCAST = 0; // unreliable to all -constexpr int MSG_ONE = 1; // reliable to one (msg_entity) -constexpr int MSG_ALL = 2; // reliable to all -constexpr int MSG_INIT = 3; // write to the init string -constexpr int MSG_PVS = 4; // Ents in PVS of org -constexpr int MSG_PAS = 5; // Ents in PAS of org -constexpr int MSG_PVS_R = 6; // Reliable to PVS -constexpr int MSG_PAS_R = 7; // Reliable to PAS -constexpr int MSG_ONE_UNRELIABLE = 8; // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) -constexpr int MSG_SPEC = 9; // Sends to all spectator proxies + +enum { + TE_BEAMPOINTS = 0, // beam effect between two points + // coord coord coord (start position) + // coord coord coord (end position) + // short (sprite index) + // byte (starting frame) + // byte (frame rate in 0.1's) + // byte (life in 0.1's) + // byte (line width in 0.1's) + // byte (noise amplitude in 0.01's) + // byte,byte,byte (color) + // byte (brightness) + // byte (scroll speed in 0.1's) + + TE_BEAMENTPOINT = 1, // beam effect between point and entity + // short (start entity) + // coord coord coord (end position) + // short (sprite index) + // byte (starting frame) + // byte (frame rate in 0.1's) + // byte (life in 0.1's) + // byte (line width in 0.1's) + // byte (noise amplitude in 0.01's) + // byte,byte,byte (color) + // byte (brightness) + // byte (scroll speed in 0.1's) + + TE_GUNSHOT = 2, // particle effect plus ricochet sound + // coord coord coord (position) + + TE_EXPLOSION = 3, // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps + // coord coord coord (position) + // short (sprite index) + // byte (scale in 0.1's) + // byte (framerate) + // byte (flags) + // + // The Explosion effect has some flags to control performance/aesthetic features: + + TE_TAREXPLOSION = 4, // Quake1 "tarbaby" explosion with sound + // coord coord coord (position) + + TE_SMOKE = 5, // alphablend sprite, move vertically 30 pps + // coord coord coord (position) + // short (sprite index) + // byte (scale in 0.1's) + // byte (framerate) + + TE_TRACER = 6, // tracer effect from point to point + // coord, coord, coord (start) + // coord, coord, coord (end) + + TE_LIGHTNING = 7, // TE_BEAMPOINTS with simplified parameters + // coord, coord, coord (start) + // coord, coord, coord (end) + // byte (life in 0.1's) + // byte (width in 0.1's) + // byte (amplitude in 0.01's) + // short (sprite model index) + + TE_BEAMENTS = 8, + // short (start entity) + // short (end entity) + // short (sprite index) + // byte (starting frame) + // byte (frame rate in 0.1's) + // byte (life in 0.1's) + // byte (line width in 0.1's) + // byte (noise amplitude in 0.01's) + // byte,byte,byte (color) + // byte (brightness) + // byte (scroll speed in 0.1's) + + TE_SPARKS = 9, // 8 random tracers with gravity, ricochet sprite + // coord coord coord (position) + + TE_LAVASPLASH = 10, // Quake1 lava splash + // coord coord coord (position) + + TE_TELEPORT = 11, // Quake1 teleport splash + // coord coord coord (position) + + TE_EXPLOSION2 = 12, // Quake1 colormaped (base palette) particle explosion with sound + // coord coord coord (position) + // byte (starting color) + // byte (num colors) + + TE_BSPDECAL = 13, // Decal from the .BSP file + // coord, coord, coord (x,y,z), decal position (center of texture in world) + // short (texture index of precached decal texture name) + // short (entity index) + // [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity) + + TE_IMPLOSION = 14, // tracers moving toward a point + // coord, coord, coord (position) + // byte (radius) + // byte (count) + // byte (life in 0.1's) + + TE_SPRITETRAIL = 15, // line of moving glow sprites with gravity, fadeout, and collisions + // coord, coord, coord (start) + // coord, coord, coord (end) + // short (sprite index) + // byte (count) + // byte (life in 0.1's) + // byte (scale in 0.1's) + // byte (velocity along vector in 10's) + // byte (randomness of velocity in 10's) + + TE_BEAM = 16, // obsolete + + TE_SPRITE = 17, // additive sprite, plays 1 cycle + // coord, coord, coord (position) + // short (sprite index) + // byte (scale in 0.1's) + // byte (brightness) + + TE_BEAMSPRITE = 18, // A beam with a sprite at the end + // coord, coord, coord (start position) + // coord, coord, coord (end position) + // short (beam sprite index) + // short (end sprite index) + + TE_BEAMTORUS = 19, // screen aligned beam ring, expands to max radius over lifetime + // coord coord coord (center position) + // coord coord coord (axis and radius) + // short (sprite index) + // byte (starting frame) + // byte (frame rate in 0.1's) + // byte (life in 0.1's) + // byte (line width in 0.1's) + // byte (noise amplitude in 0.01's) + // byte,byte,byte (color) + // byte (brightness) + // byte (scroll speed in 0.1's) + + TE_BEAMDISK = 20, // disk that expands to max radius over lifetime + // coord coord coord (center position) + // coord coord coord (axis and radius) + // short (sprite index) + // byte (starting frame) + // byte (frame rate in 0.1's) + // byte (life in 0.1's) + // byte (line width in 0.1's) + // byte (noise amplitude in 0.01's) + // byte,byte,byte (color) + // byte (brightness) + // byte (scroll speed in 0.1's) + + TE_BEAMCYLINDER = 21, // cylinder that expands to max radius over lifetime + // coord coord coord (center position) + // coord coord coord (axis and radius) + // short (sprite index) + // byte (starting frame) + // byte (frame rate in 0.1's) + // byte (life in 0.1's) + // byte (line width in 0.1's) + // byte (noise amplitude in 0.01's) + // byte,byte,byte (color) + // byte (brightness) + // byte (scroll speed in 0.1's) + + TE_BEAMFOLLOW = 22, // create a line of decaying beam segments until entity stops moving + // short (entity:attachment to follow) + // short (sprite index) + // byte (life in 0.1's) + // byte (line width in 0.1's) + // byte,byte,byte (color) + // byte (brightness) + + TE_GLOWSPRITE = 23, + // coord, coord, coord (pos) short (model index) byte (scale / 10) + + TE_BEAMRING = 24, // connect a beam ring to two entities + // short (start entity) + // short (end entity) + // short (sprite index) + // byte (starting frame) + // byte (frame rate in 0.1's) + // byte (life in 0.1's) + // byte (line width in 0.1's) + // byte (noise amplitude in 0.01's) + // byte,byte,byte (color) + // byte (brightness) + // byte (scroll speed in 0.1's) + + TE_STREAK_SPLASH = 25, // oriented shower of tracers + // coord coord coord (start position) + // coord coord coord (direction vector) + // byte (color) + // short (count) + // short (base speed) + // short (ramdon velocity) + + TE_BEAMHOSE = 26, // obsolete + + TE_DLIGHT = 27, // dynamic light, effect world, minor entity effect + // coord, coord, coord (pos) + // byte (radius in 10's) + // byte byte byte (color) + // byte (brightness) + // byte (life in 10's) + // byte (decay rate in 10's) + + TE_ELIGHT = 28, // point entity light, no world effect + // short (entity:attachment to follow) + // coord coord coord (initial position) + // coord (radius) + // byte byte byte (color) + // byte (life in 0.1's) + // coord (decay rate) + + TE_TEXTMESSAGE = 29, + // short 1.2.13 x (-1 = center) + // short 1.2.13 y (-1 = center) + // byte Effect 0 = fade in/fade out + // 1 is flickery credits + // 2 is write out (training room) + + // 4 bytes r,g,b,a color1 (text color) + // 4 bytes r,g,b,a color2 (effect color) + // ushort 8.8 fadein time + // ushort 8.8 fadeout time + // ushort 8.8 hold time + // optional ushort 8.8 fxtime (time the highlight lags behing the leading text in effect 2) + // string text message (512 chars max sz string) + TE_LINE = 30, + // coord, coord, coord startpos + // coord, coord, coord endpos + // short life in 0.1 s + // 3 bytes r, g, b + + TE_BOX = 31, + // coord, coord, coord boxmins + // coord, coord, coord boxmaxs + // short life in 0.1 s + // 3 bytes r, g, b + + TE_KILLBEAM = 99, // kill all beams attached to entity + // short (entity) + + TE_LARGEFUNNEL = 100, + // coord coord coord (funnel position) + // short (sprite index) + // short (flags) + + TE_BLOODSTREAM = 101, // particle spray + // coord coord coord (start position) + // coord coord coord (spray vector) + // byte (color) + // byte (speed) + + TE_SHOWLINE = 102, // line of particles every 5 units, dies in 30 seconds + // coord coord coord (start position) + // coord coord coord (end position) + + TE_BLOOD = 103, // particle spray + // coord coord coord (start position) + // coord coord coord (spray vector) + // byte (color) + // byte (speed) + + TE_DECAL = 104, // Decal applied to a brush entity (not the world) + // coord, coord, coord (x,y,z), decal position (center of texture in world) + // byte (texture index of precached decal texture name) + // short (entity index) + + TE_FIZZ = 105, // create alpha sprites inside of entity, float upwards + // short (entity) + // short (sprite index) + // byte (density) + + TE_MODEL = 106, // create a moving model that bounces and makes a sound when it hits + // coord, coord, coord (position) + // coord, coord, coord (velocity) + // angle (initial yaw) + // short (model index) + // byte (bounce sound type) + // byte (life in 0.1's) + + TE_EXPLODEMODEL = 107, // spherical shower of models, picks from set + // coord, coord, coord (origin) + // coord (velocity) + // short (model index) + // short (count) + // byte (life in 0.1's) + + TE_BREAKMODEL = 108, // box of models or sprites + // coord, coord, coord (position) + // coord, coord, coord (size) + // coord, coord, coord (velocity) + // byte (random velocity in 10's) + // short (sprite or model index) + // byte (count) + // byte (life in 0.1 secs) + // byte (flags) + + TE_GUNSHOTDECAL = 109, // decal and ricochet sound + // coord, coord, coord (position) + // short (entity index???) + // byte (decal???) + + TE_SPRITE_SPRAY = 110, // spay of alpha sprites + // coord, coord, coord (position) + // coord, coord, coord (velocity) + // short (sprite index) + // byte (count) + // byte (speed) + // byte (noise) + + TE_ARMOR_RICOCHET = 111, // quick spark sprite, client ricochet sound. + // coord, coord, coord (position) + // byte (scale in 0.1's) + + TE_PLAYERDECAL = 112, // ??? + // byte (playerindex) + // coord, coord, coord (position) + // short (entity???) + // byte (decal number???) + // [optional] short (model index???) + + TE_BUBBLES = 113, // create alpha sprites inside of box, float upwards + // coord, coord, coord (min start position) + // coord, coord, coord (max start position) + // coord (float height) + // short (model index) + // byte (count) + // coord (speed) + + TE_BUBBLETRAIL = 114, // create alpha sprites along a line, float upwards + // coord, coord, coord (min start position) + // coord, coord, coord (max start position) + // coord (float height) + // short (model index) + // byte (count) + // coord (speed) + + TE_BLOODSPRITE = 115, // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent) + // coord, coord, coord (position) + // short (sprite1 index) + // short (sprite2 index) + // byte (color) + // byte (scale) + + TE_WORLDDECAL = 116, // Decal applied to the world brush + // coord, coord, coord (x,y,z), decal position (center of texture in world) + // byte (texture index of precached decal texture name) + + TE_WORLDDECALHIGH = 117, // Decal (with texture index > 256) applied to world brush + // coord, coord, coord (x,y,z), decal position (center of texture in world) + // byte (texture index of precached decal texture name - 256) + + TE_DECALHIGH = 118, // Same as TE_DECAL, but the texture index was greater than 256 + // coord, coord, coord (x,y,z), decal position (center of texture in world) + // byte (texture index of precached decal texture name - 256) + // short (entity index) + + TE_PROJECTILE = 119, // Makes a projectile (like a nail) (this is a high-priority tent) + // coord, coord, coord (position) + // coord, coord, coord (velocity) + // short (modelindex) + // byte (life) + // byte (owner) projectile won't collide with owner (if owner == 0, projectile will hit any client). + + TE_SPRAY = 120, // Throws a shower of sprites or models + // coord, coord, coord (position) + // coord, coord, coord (direction) + // short (modelindex) + // byte (count) + // byte (speed) + // byte (noise) + // byte (rendermode) + + TE_PLAYERSPRITES = 121, // sprites emit from a player's bounding box (ONLY use for players!) + // byte (playernum) + // short (sprite modelindex) + // byte (count) + // byte (variance) (0 = no variance in size) (10 = 10% variance in size) + + TE_PARTICLEBURST = 122, // very similar to lavasplash. + // coord (origin) + // short (radius) + // byte (particle color) + // byte (duration * 10) (will be randomized a bit) + + TE_FIREFIELD = 123, // makes a field of fire. + // coord (origin) + // short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius) + // short (modelindex) + // byte (count) + // byte (flags) + // byte (duration (in seconds) * 10) (will be randomized a bit) + // + // to keep network traffic low, this message has associated flags that fit into a byte: + + TE_PLAYERATTACHMENT = 124, // attaches a TENT to a player (this is a high-priority tent) + // byte (entity index of player) + // coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset ) + // short (model index) + // short (life * 10 ), + + TE_KILLPLAYERATTACHMENTS = 125, // will expire all TENTS attached to a player. + // byte (entity index of player) + + TE_MULTIGUNSHOT = 126, // much more compact shotgun message + // This message is used to make a client approximate a 'spray' of gunfire. + // Any weapon that fires more than one bullet per frame and fires in a bit of a spread is + // a good candidate for MULTIGUNSHOT use. (shotguns) + // + // NOTE: This effect makes the client do traces for each bullet, these client traces ignore + // entities that have studio models.Traces are 4096 long. + // + // coord (origin) + // coord (origin) + // coord (origin) + // coord (direction) + // coord (direction) + // coord (direction) + // coord (x noise * 100) + // coord (y noise * 100) + // byte (count) + // byte (bullethole decal texture index) + + TE_USERTRACER = 127 // larger message than the standard tracer, but allows some customization. + // coord (origin) + // coord (origin) + // coord (origin) + // coord (velocity) + // coord (velocity) + // coord (velocity) + // byte ( life * 10 ) + // byte ( color ) this is an index into an array of color vectors in the engine. (0 - ) + // byte ( length * 10 ) +}; + +enum { + MSG_BROADCAST = 0, // unreliable to all + MSG_ONE = 1, // reliable to one (msg_entity) + MSG_ALL = 2, // reliable to all + MSG_INIT = 3, // write to the init string + MSG_PVS = 4, // Ents in PVS of org + MSG_PAS = 5, // Ents in PAS of org + MSG_PVS_R = 6, // Reliable to PVS + MSG_PAS_R = 7, // Reliable to PAS + MSG_ONE_UNRELIABLE = 8, // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) + MSG_SPEC = 9 // Sends to all spectator proxies +}; // contents of a spot in the world -constexpr int CONTENTS_EMPTY = -1; -constexpr int CONTENTS_SOLID = -2; -constexpr int CONTENTS_WATER = -3; -constexpr int CONTENTS_SLIME = -4; -constexpr int CONTENTS_LAVA = -5; -constexpr int CONTENTS_SKY = -6; -/* These additional contents constants are defined in bspfile.h -constexpr int CONTENTS_ORIGIN = -7; // removed at csg time -constexpr int CONTENTS_CLIP = -8; // changed to contents_solid -constexpr int CONTENTS_CURRENT_0 = -9; -constexpr int CONTENTS_CURRENT_90 = -10; -constexpr int CONTENTS_CURRENT_180 = -11; -constexpr int CONTENTS_CURRENT_270 = -12; -constexpr int CONTENTS_CURRENT_UP = -13; -constexpr int CONTENTS_CURRENT_DOWN = -14; - -constexpr int CONTENTS_TRANSLUCENT = -15; -*/ -constexpr int CONTENTS_LADDER = -16; -constexpr int CONTENT_FLYFIELD = -17; -constexpr int CONTENT_GRAVITY_FLYFIELD = -18; -constexpr int CONTENT_FOG = -19; -constexpr int CONTENT_EMPTY = -1; -constexpr int CONTENT_SOLID = -2; -constexpr int CONTENT_WATER = -3; -constexpr int CONTENT_SLIME = -4; -constexpr int CONTENT_LAVA = -5; -constexpr int CONTENT_SKY = -6; +enum { + CONTENTS_EMPTY = -1, + CONTENTS_SOLID = -2, + CONTENTS_WATER = -3, + CONTENTS_SLIME = -4, + CONTENTS_LAVA = -5, + CONTENTS_SKY = -6, + /* These additional contents constants are defined in bspfile.h + CONTENTS_ORIGIN = -7, // removed at csg time + CONTENTS_CLIP = -8, // changed to contents_solid + CONTENTS_CURRENT_0 = -9, + CONTENTS_CURRENT_90 = -10, + CONTENTS_CURRENT_180 = -11, + CONTENTS_CURRENT_270 = -12, + CONTENTS_CURRENT_UP = -13, + CONTENTS_CURRENT_DOWN = -14, + CONTENTS_TRANSLUCENT = -15, + */ + CONTENTS_LADDER = -16, + CONTENTS_FLYFIELD = -17, + CONTENTS_GRAVITY_FLYFIELD = -18, + CONTENTS_FOG = -19 +}; // channels -constexpr int CHAN_AUTO = 0; -constexpr int CHAN_WEAPON = 1; -constexpr int CHAN_VOICE = 2; -constexpr int CHAN_ITEM = 3; -constexpr int CHAN_BODY = 4; -constexpr int CHAN_STREAM = 5; // allocate stream channel from the static or dynamic area -constexpr int CHAN_STATIC = 6; // allocate channel from the static area -constexpr int CHAN_NETWORKVOICE_BASE = 7; // voice data coming across the network -constexpr int CHAN_NETWORKVOICE_END = 500; // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). +enum { + CHAN_AUTO = 0, + CHAN_WEAPON = 1, + CHAN_VOICE = 2, + CHAN_ITEM = 3, + CHAN_BODY = 4, + CHAN_STREAM = 5, // allocate stream channel from the static or dynamic area + CHAN_STATIC = 6, // allocate channel from the static area + CHAN_NETWORKVOICE_BASE = 7, // voice data coming across the network + CHAN_NETWORKVOICE_END = 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). +}; // attenuation values + + constexpr float ATTN_NONE = 0.0f; constexpr float ATTN_NORM = 0.8f; constexpr float ATTN_IDLE = 2.0f; constexpr float ATTN_STATIC = 1.25f; // pitch values -constexpr int PITCH_NORM = 100; // non-pitch shifted -constexpr int PITCH_LOW = 95; // other values are possible - 0-255, where 255 is very high -constexpr int PITCH_HIGH = 120; - +enum { + PITCH_NORM = 100, // non-pitch shifted + PITCH_LOW = 95, // other values are possible - 0-255, where 255 is very high + PITCH_HIGH = 120 +}; // volume values + constexpr float VOL_NORM = 1.0; // plats constexpr int PLAT_LOW_TRIGGER = 1; // Trains -constexpr int SF_TRAIN_WAIT_RETRIGGER = 1; -constexpr int SF_TRAIN_START_ON = 4; // Train is initially moving -constexpr int SF_TRAIN_PASSABLE = 8; // Train is not solid -- used to make water trains - +enum { + SF_TRAIN_WAIT_RETRIGGER = 1, + SF_TRAIN_START_ON = 4, // Train is initially moving + SF_TRAIN_PASSABLE = 8 // Train is not solid -- used to make water trains +}; // buttons #ifndef IN_BUTTONS_H #include "in_buttons.h" @@ -645,31 +685,29 @@ constexpr int SF_TRAIN_PASSABLE = 8; // Train is not solid -- used to make water // Break Model Defines -constexpr int BREAK_TYPEMASK = 0x4F; -constexpr int BREAK_GLASS = 0x01; -constexpr int BREAK_METAL = 0x02; -constexpr int BREAK_FLESH = 0x04; -constexpr int BREAK_WOOD = 0x08; -constexpr int BREAK_SMOKE = 0x10; -constexpr int BREAK_TRANS = 0x20; -constexpr int BREAK_CONCRETE = 0x40; -constexpr int BREAK_2 = 0x80; - +enum { + BREAK_TYPEMASK = 0x4F, + BREAK_GLASS = 0x01, + BREAK_METAL = 0x02, + BREAK_FLESH = 0x04, + BREAK_WOOD = 0x08, + BREAK_SMOKE = 0x10, + BREAK_TRANS = 0x20, + BREAK_CONCRETE = 0x40, + BREAK_2 = 0x80 +}; // Colliding temp entity sounds -constexpr int BOUNCE_GLASS = BREAK_GLASS; -constexpr int BOUNCE_METAL = BREAK_METAL; -constexpr int BOUNCE_FLESH = BREAK_FLESH; -constexpr int BOUNCE_WOOD = BREAK_WOOD; -constexpr int BOUNCE_SHRAP = 0x10; -constexpr int BOUNCE_SHELL = 0x20; -constexpr int BOUNCE_CONCRETE = BREAK_CONCRETE; -constexpr int BOUNCE_SHOTSHELL = 0x80; - -// Temp entity bounce sound types -constexpr int TE_BOUNCE_NULL = 0; -constexpr int TE_BOUNCE_SHELL = 1; -constexpr int TE_BOUNCE_SHOTSHELL = 2; +enum { + BOUNCE_GLASS = BREAK_GLASS, + BOUNCE_METAL = BREAK_METAL, + BOUNCE_FLESH = BREAK_FLESH, + BOUNCE_WOOD = BREAK_WOOD, + BOUNCE_SHRAP = 0x10, + BOUNCE_SHELL = 0x20, + BOUNCE_CONCRETE = BREAK_CONCRETE, + BOUNCE_SHOTSHELL = 0x80 +}; // Rendering constants enum From f7bd6bf5acf0b447e649a32e773df60531f0eaee Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:02:46 -0400 Subject: [PATCH 032/291] FIxed enum name typo after removing duplicate declaration. --- src/game/server/player/player.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/server/player/player.cpp b/src/game/server/player/player.cpp index d8af019d..0cbc83d8 100644 --- a/src/game/server/player/player.cpp +++ b/src/game/server/player/player.cpp @@ -914,12 +914,12 @@ void CBasePlayer::WaterMove() } } - if (pev->watertype == CONTENT_LAVA) // do damage + if (pev->watertype == CONTENTS_LAVA) // do damage { if (pev->dmgtime < gpGlobals->time) TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), 10 * pev->waterlevel, DMG_BURN); } - else if (pev->watertype == CONTENT_SLIME) // do damage + else if (pev->watertype == CONTENTS_SLIME) // do damage { pev->dmgtime = gpGlobals->time + 1; TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), 4 * pev->waterlevel, DMG_ACID); @@ -2118,7 +2118,7 @@ void CBasePlayer::PostThink() { // ALERT ( at_console, "%f\n", m_flFallVelocity ); - if (pev->watertype == CONTENT_WATER) + if (pev->watertype == CONTENTS_WATER) { // Did he hit the world or a non-moving entity? // BUG - this happens all the time in water, especially when From 4d347e8f426fecc7a90e51d55f850714b8b74585 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:05:29 -0400 Subject: [PATCH 033/291] Changed macro defines to constexpr --- src/game/server/svglobals.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game/server/svglobals.h b/src/game/server/svglobals.h index a506d8b7..2563ae9f 100644 --- a/src/game/server/svglobals.h +++ b/src/game/server/svglobals.h @@ -18,7 +18,7 @@ class CBaseEntity; // Global game_master entity handle extern CBaseEntity* g_pGameMasterEntity; -#define SCRIPT_TYPES 4 +constexpr int SCRIPT_TYPES = 4; class CSVGlobals { @@ -35,10 +35,10 @@ class CSVGlobals static mslist ScriptList[SCRIPT_TYPES]; }; -#define SPAWN_GENERIC "ms_player_spawn" -#define SPAWN_BEGIN "ms_player_begin" -#define SPAWN_SPECTATE "ms_player_spec" -#define OLD_GENERIC_SPAWN "info_player_start" +constexpr const char* SPAWN_GENERIC = "ms_player_spawn"; +constexpr const char* SPAWN_BEGIN = "ms_player_begin"; +constexpr const char* SPAWN_SPECTATE = "ms_player_spec"; +constexpr const char* OLD_GENERIC_SPAWN = "info_player_start"; #ifdef CVARDEF_H extern cvar_s ms_joinreset; From 45fe66e56a214661f6323fd92de526cc33ef8aac Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:07:03 -0400 Subject: [PATCH 034/291] changed constexpr to enum --- src/common/cvardef.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/common/cvardef.h b/src/common/cvardef.h index fcde0475..d742c1a2 100644 --- a/src/common/cvardef.h +++ b/src/common/cvardef.h @@ -15,21 +15,22 @@ #ifndef CVARDEF_H #define CVARDEF_H -constexpr int FCVAR_ARCHIVE = (1 << 0); // set to cause it to be saved to vars.rc -constexpr int FCVAR_USERINFO = (1 << 1); // changes the client's info string -constexpr int FCVAR_SERVER = (1 << 2); // notifies players when changed -constexpr int FCVAR_EXTDLL = (1 << 3); // defined by external DLL -constexpr int FCVAR_CLIENTDLL = (1 << 4); // defined by the client dll -constexpr int FCVAR_PROTECTED = (1 << 5); // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value -constexpr int FCVAR_SPONLY = (1 << 6); // This cvar cannot be changed by clients connected to a multiplayer server. -constexpr int FCVAR_PRINTABLEONLY = (1 << 7);// This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). -constexpr int FCVAR_UNLOGGED = (1 << 8); // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log -constexpr int FCVAR_NOEXTRAWHITEPACE = (1 << 9); // strip trailing/leading white space from this cvar -constexpr int FCVAR_PRIVILEGED = (1 << 10); // only available in privileged mode -constexpr int FCVAR_FILTERABLE = (1 << 11); // filtered in unprivileged mode if cl_filterstuffcmd is 1 -constexpr int FCVAR_ISEXECUTED = (1 << 12);// This cvar's string contains a value that will be executed as a cfg file; don't allow commands to be appended to it -constexpr int FCVAR_ISPATH = (1 << 13);// This cvar's string is a path or filename; don't allow absolute paths, escaping to another directory or backslashes - +enum { + FCVAR_ARCHIVE = (1 << 0), // set to cause it to be saved to vars.rc + FCVAR_USERINFO = (1 << 1), // changes the client's info string + FCVAR_SERVER = (1 << 2), // notifies players when changed + FCVAR_EXTDLL = (1 << 3), // defined by external DLL + FCVAR_CLIENTDLL = (1 << 4), // defined by the client dll + FCVAR_PROTECTED = (1 << 5), // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value + FCVAR_SPONLY = (1 << 6), // This cvar cannot be changed by clients connected to a multiplayer server. + FCVAR_PRINTABLEONLY = (1 << 7),// This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). + FCVAR_UNLOGGED = (1 << 8), // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log + FCVAR_NOEXTRAWHITEPACE = (1 << 9), // strip trailing/leading white space from this cvar + FCVAR_PRIVILEGED = (1 << 10), // only available in privileged mode + FCVAR_FILTERABLE = (1 << 11), // filtered in unprivileged mode if cl_filterstuffcmd is 1 + FCVAR_ISEXECUTED = (1 << 12),// This cvar's string contains a value that will be executed as a cfg file; don't allow commands to be appended to it + FCVAR_ISPATH = (1 << 13) // This cvar's string is a path or filename; don't allow absolute paths, escaping to another directory or backslashes +}; typedef struct cvar_s { const char *name; From 56706fe4182aade63b0575198a24aeb2b7af03c5 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:10:58 -0400 Subject: [PATCH 035/291] Fixed warning C5055 after change to enum. --- src/game/server/entity.cpp | 2 +- src/game/server/monsters/combat.cpp | 2 +- src/game/shared/weapons/giattack.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/server/entity.cpp b/src/game/server/entity.cpp index 866db8a5..324f2043 100644 --- a/src/game/server/entity.cpp +++ b/src/game/server/entity.cpp @@ -57,7 +57,7 @@ void CBaseEntity::SetFollow(CBaseEntity *pTarget, int Flags) bool CBaseEntity::CanDamage(CBaseEntity *pOther) { - return (pOther->pev->takedamage > DAMAGE_NO) && //The entity can take damage + return (static_cast(pOther->pev->takedamage) > DAMAGE_NO) && //The entity can take damage (!FBitSet(pOther->pev->flags, FL_GODMODE)); //The entity is not invulnerable; } diff --git a/src/game/server/monsters/combat.cpp b/src/game/server/monsters/combat.cpp index 1294fbcd..f3335eba 100644 --- a/src/game/server/monsters/combat.cpp +++ b/src/game/server/monsters/combat.cpp @@ -1046,7 +1046,7 @@ void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker // iterate on all entities in the vicinity. while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius)) != NULL) { - if (pEntity->pev->takedamage != DAMAGE_NO) + if (static_cast(pEntity->pev->takedamage) != DAMAGE_NO) { // UNDONE: this should check a damage mask, not an ignore if (iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore) diff --git a/src/game/shared/weapons/giattack.cpp b/src/game/shared/weapons/giattack.cpp index 2c579a50..1575461a 100644 --- a/src/game/shared/weapons/giattack.cpp +++ b/src/game/shared/weapons/giattack.cpp @@ -1501,7 +1501,7 @@ void DoDamage(damage_t &Damage, hitent_list &Hits) CBaseEntity *pTarget = NULL, *pClosestHit = NULL; while ((pTarget = UTIL_FindEntityInSphere(pTarget, Damage.vecSrc, Damage.flRange)) != NULL) { - if (pTarget->pev->takedamage == DAMAGE_NO || //Don't hurt world objects, godmode entities, or the entity I originally struck + if (static_cast(pTarget->pev->takedamage) == DAMAGE_NO || //Don't hurt world objects, godmode entities, or the entity I originally struck FBitSet(pTarget->pev->flags, FL_GODMODE) || !pTarget->IsAlive() || pTarget == Damage.pInflictor || From 4da85782e4665db7e9b43b48910f8a88b6499f27 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:13:57 -0400 Subject: [PATCH 036/291] changed const expr to enum --- src/common/director_cmds.h | 45 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/common/director_cmds.h b/src/common/director_cmds.h index 852b955c..a1f08bf0 100644 --- a/src/common/director_cmds.h +++ b/src/common/director_cmds.h @@ -8,26 +8,31 @@ // director_cmds.h // sub commands for svc_director -constexpr int DRC_ACTIVE = 0; // tells client that he's an spectator and will get director command -constexpr int DRC_STATUS = 1; // send status infos about proxy -constexpr int DRC_CAMERA = 2; // set the actual director camera position -constexpr int DRC_EVENT = 3; // informs the dircetor about ann important game event - -constexpr int DRC_FLAG_PRIO_MASK = 0x0F; // priorities between 0 and 15 (15 most important) -constexpr int DRC_FLAG_SIDE = (1 << 4); -constexpr int DRC_FLAG_DRAMATIC = (1 << 5); +enum { + DRC_ACTIVE = 0, // tells client that he's an spectator and will get director command + DRC_STATUS = 1, // send status infos about proxy + DRC_CAMERA = 2, // set the actual director camera position + DRC_EVENT = 3 // informs the dircetor about ann important game event +}; +enum { + DRC_FLAG_PRIO_MASK = 0x0F, // priorities between 0 and 15 (15 most important) + DRC_FLAG_SIDE = (1 << 4), + DRC_FLAG_DRAMATIC = (1 << 5) +}; // commands of the director API function CallDirectorProc(...) -constexpr int DRCAPI_NOP = 0; // no operation -constexpr int DRCAPI_ACTIVE = 1; // de/acivates director mode in engine -constexpr int DRCAPI_STATUS = 2; // request proxy information -constexpr int DRCAPI_SETCAM = 3; // set camera n to given position and angle -constexpr int DRCAPI_GETCAM = 4; // request camera n position and angle -constexpr int DRCAPI_DIRPLAY = 5; // set director time and play with normal speed -constexpr int DRCAPI_DIRFREEZE = 6; // freeze directo at this time -constexpr int DRCAPI_SETVIEWMODE = 7; // overview or 4 cameras -constexpr int DRCAPI_SETOVERVIEWPARAMS = 8; // sets parameter for overview mode -constexpr int DRCAPI_SETFOCUS = 9; // set the camera which has the input focus -constexpr int DRCAPI_GETTARGETS = 10; // queries engine for player list -constexpr int DRCAPI_SETVIEWPOINTS = 11; // gives engine all waypoints +enum { + DRCAPI_NOP = 0, // no operation + DRCAPI_ACTIVE = 1, // de/acivates director mode in engine + DRCAPI_STATUS = 2, // request proxy information + DRCAPI_SETCAM = 3, // set camera n to given position and angle + DRCAPI_GETCAM = 4, // request camera n position and angle + DRCAPI_DIRPLAY = 5, // set director time and play with normal speed + DRCAPI_DIRFREEZE = 6, // freeze directo at this time + DRCAPI_SETVIEWMODE = 7, // overview or 4 cameras + DRCAPI_SETOVERVIEWPARAMS = 8, // sets parameter for overview mode + DRCAPI_SETFOCUS = 9, // set the camera which has the input focus + DRCAPI_GETTARGETS = 10, // queries engine for player list + DRCAPI_SETVIEWPOINTS = 11 // gives engine all waypoints +}; \ No newline at end of file From a8c5d428f0cf16f38be10ec86d89ddab79192d54 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:23:54 -0400 Subject: [PATCH 037/291] changes some constexpr to enums --- src/common/const.h | 8 ++++++-- src/common/dll_state.h | 28 +++++++++++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/common/const.h b/src/common/const.h index 765cd275..9960916f 100644 --- a/src/common/const.h +++ b/src/common/const.h @@ -667,10 +667,14 @@ enum { }; // volume values -constexpr float VOL_NORM = 1.0; +enum { + VOL_NORM = 1 +}; // plats -constexpr int PLAT_LOW_TRIGGER = 1; +enum { + PLAT_LOW_TRIGGER = 1 +}; // Trains enum { diff --git a/src/common/dll_state.h b/src/common/dll_state.h index 9fb3eba2..341b6908 100644 --- a/src/common/dll_state.h +++ b/src/common/dll_state.h @@ -7,17 +7,19 @@ //DLL State Flags -constexpr int DLL_INACTIVE = 0; // no dll -constexpr int DLL_ACTIVE = 1; // dll is running -constexpr int DLL_PAUSED = 2; // dll is paused -constexpr int DLL_CLOSE = 3; // closing down dll -constexpr int DLL_TRANS = 4; // Level Transition - -// DLL Pause reasons - -constexpr int DLL_NORMAL = 0; // User hit Esc or something. -constexpr int DLL_QUIT = 4; // Quit now -constexpr int DLL_RESTART = 6; // Switch to launcher for linux, does a quit but returns 1 - +enum { + DLL_INACTIVE = 0, // no dll + DLL_ACTIVE = 1, // dll is running + DLL_PAUSED = 2, // dll is paused + DLL_CLOSE = 3, // closing down dll + DLL_TRANS = 4, // Level Transition + // DLL Pause reasons + DLL_NORMAL = 0, // User hit Esc or something. + DLL_QUIT = 4, // Quit now + DLL_RESTART = 6 // Switch to launcher for linux, does a quit but returns 1 +}; // DLL Substate info ( not relevant ) -constexpr int ENG_NORMAL = (1 << 0); + +enum { + ENG_NORMAL = (1 << 0); +}; \ No newline at end of file From c1e1a9fde2e04ad125f6551eed11f19969ebbc2f Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:24:37 -0400 Subject: [PATCH 038/291] Changed constexpr to enum --- src/common/entity_state.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/entity_state.h b/src/common/entity_state.h index 7acc136a..3c6b0a94 100644 --- a/src/common/entity_state.h +++ b/src/common/entity_state.h @@ -19,8 +19,10 @@ #endif // For entityType below -constexpr int ENTITY_NORMAL = (1 << 0); -constexpr int ENTITY_BEAM = (1 << 1); +enum { + ENTITY_NORMAL = (1 << 0), + ENTITY_BEAM = (1 << 1) +}; // Entity state is used for the baseline and for delta compression of a packet of // entities that is sent to a client. From 7570a31f031d04027337b33097fd89c1ca9e5d19 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:25:32 -0400 Subject: [PATCH 039/291] changed constexpr to enum --- src/common/entity_types.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/common/entity_types.h b/src/common/entity_types.h index 3cfd8ca6..d472c3cc 100644 --- a/src/common/entity_types.h +++ b/src/common/entity_types.h @@ -16,11 +16,13 @@ #if !defined(ENTITY_TYPESH) #define ENTITY_TYPESH -constexpr int ET_NORMAL = 0; -constexpr int ET_PLAYER = 1; -constexpr int ET_TEMPENTITY = 2; -constexpr int ET_BEAM = 3; -// BMODEL or SPRITE that was split across BSP nodes -constexpr int ET_FRAGMENTED = 4; +enum { + ET_NORMAL = 0, + ET_PLAYER = 1, + ET_TEMPENTITY = 2, + ET_BEAM = 3, + // BMODEL or SPRITE that was split across BSP nodes + ET_FRAGMENTED = 4 +}; #endif // !ENTITY_TYPESH From 9cd0a706cd9d37a5e73b52a6473ba25bb8f92894 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:46:41 -0400 Subject: [PATCH 040/291] changed constexpr to enums --- src/common/event_api.h | 2 +- src/common/event_args.h | 10 +++--- src/common/event_flags.h | 20 ++++++----- src/common/hltv.h | 73 ++++++++++++++++++++++------------------ 4 files changed, 59 insertions(+), 46 deletions(-) diff --git a/src/common/event_api.h b/src/common/event_api.h index 2564d9e7..1bc0595b 100644 --- a/src/common/event_api.h +++ b/src/common/event_api.h @@ -18,7 +18,7 @@ #pragma once #endif -#define EVENT_API_VERSION 1 +constexpr int EVENT_API_VERSION = 1; typedef struct event_api_s { diff --git a/src/common/event_args.h b/src/common/event_args.h index e4d732d9..e58d0a74 100644 --- a/src/common/event_args.h +++ b/src/common/event_args.h @@ -18,11 +18,13 @@ #pragma once #endif -// Event was invoked with stated origin -constexpr int FEVENT_ORIGIN = (1 << 0); +enum { + // Event was invoked with stated origin + FEVENT_ORIGIN = (1 << 0), -// Event was invoked with stated angles -constexpr int FEVENT_ANGLES = (1 << 1); + // Event was invoked with stated angles + FEVENT_ANGLES = (1 << 1); +}; typedef struct event_args_s { diff --git a/src/common/event_flags.h b/src/common/event_flags.h index 7e6c4f7d..acf8fd93 100644 --- a/src/common/event_flags.h +++ b/src/common/event_flags.h @@ -18,30 +18,32 @@ #pragma once #endif -// Skip local host for event send. -constexpr int FEV_NOTHOST = (1 << 0); + +enum { + // Skip local host for event send. + FEV_NOTHOST = (1 << 0), // Send the event reliably. You must specify the origin and angles and use // PLAYBACK_EVENT_FULL for this to work correctly on the server for anything // that depends on the event origin/angles. I.e., the origin/angles are not // taken from the invoking edict for reliable events. -constexpr int FEV_RELIABLE = (1 << 1); + FEV_RELIABLE = (1 << 1), // Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC // sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ). -constexpr int FEV_GLOBAL = (1 << 2); + FEV_GLOBAL = (1 << 2), // If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate // -constexpr int FEV_UPDATE = (1 << 3); + FEV_UPDATE = (1 << 3), // Only send to entity specified as the invoker -constexpr int FEV_HOSTONLY = (1 << 4); + FEV_HOSTONLY = (1 << 4), // Only send if the event was created on the server. -constexpr int FEV_SERVER = (1 << 5); + FEV_SERVER = (1 << 5), // Only issue event client side ( from shared code ) -constexpr int FEV_CLIENT = (1 << 6); - + FEV_CLIENT = (1 << 6) +}; #endif diff --git a/src/common/hltv.h b/src/common/hltv.h index 8dafe189..6ca800e4 100644 --- a/src/common/hltv.h +++ b/src/common/hltv.h @@ -10,42 +10,51 @@ #ifndef HLTV_H #define HLTV_H - -constexpr int TYPE_CLIENT = 0; // client is a normal HL client (default) -constexpr int TYPE_PROXY = 1; // client is another proxy -constexpr int TYPE_COMMENTATOR = 3; // client is a commentator -constexpr int TYPE_DEMO = 4; // client is a demo file +enum { + TYPE_CLIENT = 0, // client is a normal HL client (default) + TYPE_PROXY = 1, // client is another proxy + TYPE_COMMENTATOR = 3, // client is a commentator + TYPE_DEMO = 4 // client is a demo file +}; // sub commands of svc_hltv: -constexpr int HLTV_ACTIVE = 0; // tells client that he's an spectator and will get director commands -constexpr int HLTV_STATUS = 1; // send status infos about proxy -constexpr int HLTV_LISTEN = 2; // tell client to listen to a multicast stream - +enum { + HLTV_ACTIVE = 0, // tells client that he's an spectator and will get director commands + HLTV_STATUS = 1, // send status infos about proxy + HLTV_LISTEN = 2 // tell client to listen to a multicast stream +}; // sub commands of svc_director: -constexpr int DRC_CMD_NONE = 0; // NULL director command -constexpr int DRC_CMD_START = 1; // start director mode -constexpr int DRC_CMD_EVENT = 2; // informs about director command -constexpr int DRC_CMD_MODE = 3; // switches camera modes -constexpr int DRC_CMD_CAMERA = 4; // sets camera registers -constexpr int DRC_CMD_TIMESCALE = 5; // sets time scale -constexpr int DRC_CMD_MESSAGE = 6; // send HUD centerprint -constexpr int DRC_CMD_SOUND = 7; // plays a particular sound -constexpr int DRC_CMD_STATUS = 8; // status info about broadcast -constexpr int DRC_CMD_BANNER = 9; // banner file name for HLTV gui -constexpr int DRC_CMD_FADE = 10; // send screen fade command -constexpr int DRC_CMD_SHAKE = 11; // send screen shake command -constexpr int DRC_CMD_STUFFTEXT = 12; // like the normal svc_stufftext but as director command - -#define DRC_CMD_LAST 12 + +enum { + DRC_CMD_NONE = 0, // NULL director command + DRC_CMD_START = 1, // start director mode + DRC_CMD_EVENT = 2, // informs about director command + DRC_CMD_MODE = 3, // switches camera modes + DRC_CMD_CAMERA = 4, // sets camera registers + DRC_CMD_TIMESCALE = 5, // sets time scale + DRC_CMD_MESSAGE = 6, // send HUD centerprint + DRC_CMD_SOUND = 7, // plays a particular sound + DRC_CMD_STATUS = 8, // status info about broadcast + DRC_CMD_BANNER = 9, // banner file name for HLTV gui + DRC_CMD_FADE = 10, // send screen fade command + DRC_CMD_SHAKE = 11, // send screen shake command + DRC_CMD_STUFFTEXT = 12, // like the normal svc_stufftext but as director command + DRC_CMD_LAST = 12 +}; + // HLTV_EVENT event flags -constexpr int DRC_FLAG_PRIO_MASK = 0x0F; // priorities between 0 and 15 (15 most important) -constexpr int DRC_FLAG_SIDE = (1 << 4); // -constexpr int DRC_FLAG_DRAMATIC = (1 << 5); // is a dramatic scene -constexpr int DRC_FLAG_SLOWMOTION = (1 << 6); // would look good in SloMo -constexpr int DRC_FLAG_FACEPLAYER = (1 << 7); // player is doning something (reload/defuse bomb etc) -constexpr int DRC_FLAG_INTRO = (1 << 8); // is a introduction scene -constexpr int DRC_FLAG_FINAL = (1 << 9); // is a final scene -constexpr int DRC_FLAG_NO_RANDOM = (1 << 10); // don't randomize event data + +enum { + DRC_FLAG_PRIO_MASK = 0x0F, // priorities between 0 and 15 (15 most important) + DRC_FLAG_SIDE = (1 << 4), // + DRC_FLAG_DRAMATIC = (1 << 5), // is a dramatic scene + DRC_FLAG_SLOWMOTION = (1 << 6), // would look good in SloMo + DRC_FLAG_FACEPLAYER = (1 << 7), // player is doning something (reload/defuse bomb etc) + DRC_FLAG_INTRO = (1 << 8), // is a introduction scene + DRC_FLAG_FINAL = (1 << 9), // is a final scene + DRC_FLAG_NO_RANDOM = (1 << 10) // don't randomize event data +}; + constexpr int MAX_DIRECTOR_CMD_PARAMETERS = 4; constexpr int MAX_DIRECTOR_CMD_STRING = 128; From 894bf5f9296cdcc6241359c5a564d7944787adfb Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:53:01 -0400 Subject: [PATCH 041/291] fixed Vector passing to IS_NAN need const float * for x,y,z vars. Changed constexpr to enum --- src/common/event_args.h | 2 +- src/common/in_buttons.h | 35 ++++++++++++++++++----------------- src/common/mathlib.h | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/common/event_args.h b/src/common/event_args.h index e58d0a74..25d94bd6 100644 --- a/src/common/event_args.h +++ b/src/common/event_args.h @@ -23,7 +23,7 @@ enum { FEVENT_ORIGIN = (1 << 0), // Event was invoked with stated angles - FEVENT_ANGLES = (1 << 1); + FEVENT_ANGLES = (1 << 1) }; typedef struct event_args_s diff --git a/src/common/in_buttons.h b/src/common/in_buttons.h index c16a2bc4..dc20d5f5 100644 --- a/src/common/in_buttons.h +++ b/src/common/in_buttons.h @@ -18,21 +18,22 @@ #pragma once #endif -constexpr int IN_ATTACK = (1 << 0); -constexpr int IN_JUMP = (1 << 1); -constexpr int IN_DUCK = (1 << 2); -constexpr int IN_FORWARD = (1 << 3); -constexpr int IN_BACK = (1 << 4); -constexpr int IN_USE = (1 << 5); -constexpr int IN_CANCEL = (1 << 6); -constexpr int IN_LEFT = (1 << 7); -constexpr int IN_RIGHT = (1 << 8); -constexpr int IN_MOVELEFT = (1 << 9); -constexpr int IN_MOVERIGHT = (1 << 10); -constexpr int IN_ATTACK2 = (1 << 11); -constexpr int IN_RUN = (1 << 12); -constexpr int IN_RELOAD = (1 << 13); -constexpr int IN_ALT1 = (1 << 14); -constexpr int IN_SCORE = (1 << 15);// Used by client.dll for when scoreboard is held down - +enum { + IN_ATTACK = (1 << 0), + IN_JUMP = (1 << 1), + IN_DUCK = (1 << 2), + IN_FORWARD = (1 << 3), + IN_BACK = (1 << 4), + IN_USE = (1 << 5), + IN_CANCEL = (1 << 6), + IN_LEFT = (1 << 7), + IN_RIGHT = (1 << 8), + IN_MOVELEFT = (1 << 9), + IN_MOVERIGHT = (1 << 10), + IN_ATTACK2 = (1 << 11), + IN_RUN = (1 << 12), + IN_RELOAD = (1 << 13), + IN_ALT1 = (1 << 14), + IN_SCORE = (1 << 15) // Used by client.dll for when scoreboard is held down +}; #endif // IN_BUTTONS_H diff --git a/src/common/mathlib.h b/src/common/mathlib.h index 7c64983f..4040e01d 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -37,7 +37,7 @@ struct mplane_s; extern Vector vec3_origin; constexpr int nanmask = 255 << 23; -inline static bool IS_NAN(float x) { +inline static bool IS_NAN(const float* x) { if ((((*(int*)&x) & nanmask) == nanmask)) { return true; From e93b7e4e88ce9e90ee5c23f4ee4c4c4f034eabce Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:57:18 -0400 Subject: [PATCH 042/291] changed constexpr to enum --- src/common/net_api.h | 27 ++++++++++++++-------- src/common/r_efx.h | 54 ++++++++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/src/common/net_api.h b/src/common/net_api.h index 980d92e9..38f15d11 100644 --- a/src/common/net_api.h +++ b/src/common/net_api.h @@ -15,22 +15,29 @@ #include "netadr.h" #endif -constexpr int NETAPI_REQUEST_SERVERLIST = 0; // Doesn't need a remote address -constexpr int NETAPI_REQUEST_PING = 1; -constexpr int NETAPI_REQUEST_RULES = 2; -constexpr int NETAPI_REQUEST_PLAYERS = 3; -constexpr int NETAPI_REQUEST_DETAILS = 4; + +enum { + NETAPI_REQUEST_SERVERLIST = 0, // Doesn't need a remote address + NETAPI_REQUEST_PING = 1, + NETAPI_REQUEST_RULES = 2, + NETAPI_REQUEST_PLAYERS = 3, + NETAPI_REQUEST_DETAILS = 4 +}; // Set this flag for things like broadcast requests, etc. where the engine should not // kill the request hook after receiving the first response -constexpr int FNETAPI_MULTIPLE_RESPONSE = (1 << 0); +enum { + FNETAPI_MULTIPLE_RESPONSE = (1 << 0); +}; typedef void (*net_api_response_func_t)(struct net_response_s *response); -constexpr int NET_SUCCESS = 0; -constexpr int NET_ERROR_TIMEOUT = 1 << 0; -constexpr int NET_ERROR_PROTO_UNSUPPORTED = 1 << 1; -constexpr int NET_ERROR_UNDEFINED = 1 << 2; +enum { + NET_SUCCESS = 0, + NET_ERROR_TIMEOUT = 1 << 0, + NET_ERROR_PROTO_UNSUPPORTED = 1 << 1, + NET_ERROR_UNDEFINED = 1 << 2 +}; typedef struct net_adrlist_s { diff --git a/src/common/r_efx.h b/src/common/r_efx.h index eb638cb2..ae34b02a 100644 --- a/src/common/r_efx.h +++ b/src/common/r_efx.h @@ -59,32 +59,38 @@ color24 gTracerColors[] = */ // Temporary entity array -constexpr int TENTPRIORITY_LOW = 0; -constexpr int TENTPRIORITY_HIGH = 1; + +enum { + TENTPRIORITY_LOW = 0, + TENTPRIORITY_HIGH = 1 +}; // TEMPENTITY flags -constexpr int FTENT_NONE = 0x00000000; -constexpr int FTENT_SINEWAVE = 0x00000001; -constexpr int FTENT_GRAVITY = 0x00000002; -constexpr int FTENT_ROTATE = 0x00000004; -constexpr int FTENT_SLOWGRAVITY = 0x00000008; -constexpr int FTENT_SMOKETRAIL = 0x00000010; -constexpr int FTENT_COLLIDEWORLD = 0x00000020; -constexpr int FTENT_FLICKER = 0x00000040; -constexpr int FTENT_FADEOUT = 0x00000080; -constexpr int FTENT_SPRANIMATE = 0x00000100; -constexpr int FTENT_HITSOUND = 0x00000200; -constexpr int FTENT_SPIRAL = 0x00000400; -constexpr int FTENT_SPRCYCLE = 0x00000800; -constexpr int FTENT_COLLIDEALL = 0x00001000; // will collide with world and slideboxes -constexpr int FTENT_PERSIST = 0x00002000; // tent is not removed when unable to draw -constexpr int FTENT_COLLIDEKILL = 0x00004000; // tent is removed upon collision with anything -constexpr int FTENT_PLYRATTACHMENT = 0x00008000; // tent is attached to a player (owner) -constexpr int FTENT_SPRANIMATELOOP = 0x00010000; // animating sprite doesn't die when last frame is displayed -constexpr int FTENT_SPARKSHOWER = 0x00020000; -constexpr int FTENT_NOMODEL = 0x00040000; // Doesn't have a model, never try to draw ( it just triggers other things ) -constexpr int FTENT_CLIENTCUSTOM = 0x00080000; // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) -constexpr int FTENT_SKIPENT = 0x00100000; // AUG2013_25 Thothie - Skip collision checks for stored ent index + +enum { + FTENT_NONE = 0x00000000, + FTENT_SINEWAVE = 0x00000001, + FTENT_GRAVITY = 0x00000002, + FTENT_ROTATE = 0x00000004, + FTENT_SLOWGRAVITY = 0x00000008, + FTENT_SMOKETRAIL = 0x00000010, + FTENT_COLLIDEWORLD = 0x00000020, + FTENT_FLICKER = 0x00000040, + FTENT_FADEOUT = 0x00000080, + FTENT_SPRANIMATE = 0x00000100, + FTENT_HITSOUND = 0x00000200, + FTENT_SPIRAL = 0x00000400, + FTENT_SPRCYCLE = 0x00000800, + FTENT_COLLIDEALL = 0x00001000, // will collide with world and slideboxes + FTENT_PERSIST = 0x00002000, // tent is not removed when unable to draw + FTENT_COLLIDEKILL = 0x00004000, // tent is removed upon collision with anything + FTENT_PLYRATTACHMENT = 0x00008000, // tent is attached to a player (owner) + FTENT_SPRANIMATELOOP = 0x00010000, // animating sprite doesn't die when last frame is displayed + FTENT_SPARKSHOWER = 0x00020000, + FTENT_NOMODEL = 0x00040000, // Doesn't have a model, never try to draw ( it just triggers other things ) + FTENT_CLIENTCUSTOM = 0x00080000, // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) + FTENT_SKIPENT = 0x00100000 // AUG2013_25 Thothie - Skip collision checks for stored ent index +}; typedef struct tempent_s TEMPENTITY; typedef struct tempent_s From a112db4b872cbc7c40a2aea12b5e9b71de446326 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:57:59 -0400 Subject: [PATCH 043/291] removed whitespace --- src/common/Sequence.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/Sequence.h b/src/common/Sequence.h index 708c5c69..4b7bf978 100644 --- a/src/common/Sequence.h +++ b/src/common/Sequence.h @@ -73,7 +73,6 @@ enum sequenceCommandEnum_ SEQUENCE_COMMAND_MODIFIER, SEQUENCE_COMMAND_POSTMODIFIER, SEQUENCE_COMMAND_NOOP, - SEQUENCE_MODIFIER_EFFECT, SEQUENCE_MODIFIER_POSITION, SEQUENCE_MODIFIER_COLOR, From a4ed474b60899397fb421bf2404cc5bfbfc565d7 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:59:11 -0400 Subject: [PATCH 044/291] changed constexpr to enum --- src/common/triangleapi.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/common/triangleapi.h b/src/common/triangleapi.h index 3440f7c9..c498fb09 100644 --- a/src/common/triangleapi.h +++ b/src/common/triangleapi.h @@ -24,14 +24,18 @@ typedef enum TRI_NONE = 1, } TRICULLSTYLE; + constexpr int TRI_API_VERSION = 1; -constexpr int TRI_TRIANGLES = 0; -constexpr int TRI_TRIANGLE_FAN = 1; -constexpr int TRI_QUADS = 2; -constexpr int TRI_POLYGON = 3; -constexpr int TRI_LINES = 4; -constexpr int TRI_TRIANGLE_STRIP = 5; -constexpr int TRI_QUAD_STRIP = 6; + +enum { + TRI_TRIANGLES = 0, + TRI_TRIANGLE_FAN = 1, + TRI_QUADS = 2, + TRI_POLYGON = 3, + TRI_LINES = 4, + TRI_TRIANGLE_STRIP = 5, + TRI_QUAD_STRIP = 6 +}; typedef struct triangleapi_s { From b5c3f01b8fd0d11f35cbaa5f112d01de9c57aad5 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 18:01:34 -0400 Subject: [PATCH 045/291] Fixed syntax. change pointer to reference. --- src/common/mathlib.h | 2 +- src/common/net_api.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/mathlib.h b/src/common/mathlib.h index 4040e01d..b04b67cf 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -37,7 +37,7 @@ struct mplane_s; extern Vector vec3_origin; constexpr int nanmask = 255 << 23; -inline static bool IS_NAN(const float* x) { +inline static bool IS_NAN(const float &x) { if ((((*(int*)&x) & nanmask) == nanmask)) { return true; diff --git a/src/common/net_api.h b/src/common/net_api.h index 38f15d11..a2937c1b 100644 --- a/src/common/net_api.h +++ b/src/common/net_api.h @@ -27,7 +27,7 @@ enum { // Set this flag for things like broadcast requests, etc. where the engine should not // kill the request hook after receiving the first response enum { - FNETAPI_MULTIPLE_RESPONSE = (1 << 0); + FNETAPI_MULTIPLE_RESPONSE = (1 << 0) }; typedef void (*net_api_response_func_t)(struct net_response_s *response); From 5d5208582ab16915d98b1491ee73ae52ec8fcbdf Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 18:02:12 -0400 Subject: [PATCH 046/291] Removed static keyword --- src/common/mathlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/mathlib.h b/src/common/mathlib.h index b04b67cf..522e6d04 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -37,7 +37,7 @@ struct mplane_s; extern Vector vec3_origin; constexpr int nanmask = 255 << 23; -inline static bool IS_NAN(const float &x) { +inline bool IS_NAN(const float &x) { if ((((*(int*)&x) & nanmask) == nanmask)) { return true; From a4c36d8fd565875bfba5310c67e9b14077dc00ee Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 18:18:37 -0400 Subject: [PATCH 047/291] Removed magic numbers in favor of defines for NULL/TRUE/FALSE --- src/game/client/hl/hl_baseentity.cpp | 105 ++++++++++++++------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/src/game/client/hl/hl_baseentity.cpp b/src/game/client/hl/hl_baseentity.cpp index db98d1f9..a44f5100 100644 --- a/src/game/client/hl/hl_baseentity.cpp +++ b/src/game/client/hl/hl_baseentity.cpp @@ -38,6 +38,7 @@ const Vector g_vecZero = Vector(0, 0, 0); int gmsgWeapPickup = 0; enginefuncs_t g_engfuncs; globalvars_t *gpGlobals; +constexpr int NEG_REF = -1; //----------- @@ -52,23 +53,23 @@ void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volu } // CBaseEntity Stubs -int CBaseEntity ::TakeHealth(float flHealth, int bitsDamageType) { return 1; } -int CBaseEntity ::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { return 1; } +int CBaseEntity ::TakeHealth(float flHealth, int bitsDamageType) { return NULL; } +int CBaseEntity ::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { return NULL; } CBaseEntity *CBaseEntity::GetNextTarget(void) { return NULL; } -int CBaseEntity::Save(CSave &save) { return 1; } -int CBaseEntity::Restore(CRestore &restore) { return 1; } +int CBaseEntity::Save(CSave &save) { return NULL; } +int CBaseEntity::Restore(CRestore &restore) { return NULL; } void CBaseEntity::SetObjectCollisionBox(void) {} -int CBaseEntity ::Intersects(CBaseEntity *pOther) { return 0; } +int CBaseEntity ::Intersects(CBaseEntity *pOther) { return NULL; } void CBaseEntity ::MakeDormant(void) {} -int CBaseEntity ::IsDormant(void) { return 0; } +int CBaseEntity ::IsDormant(void) { return NULL; } BOOL CBaseEntity ::IsInWorld(void) { return TRUE; } -int CBaseEntity::ShouldToggle(USE_TYPE useType, BOOL currentState) { return 0; } -int CBaseEntity ::DamageDecal(int bitsDamageType) { return -1; } +int CBaseEntity::ShouldToggle(USE_TYPE useType, BOOL currentState) { return NULL; } +int CBaseEntity ::DamageDecal(int bitsDamageType) { return NEG_REF; } CBaseEntity *CBaseEntity::Create(const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner) { return NULL; } void CBaseEntity::SUB_Remove(void) { Deactivate(); - MS_DEBUG("DELETE ITEM: %s (%i)", DisplayName(), IsMSItem() ? ((CBasePlayerItem*)this)->m_iId : 0); + MS_DEBUG("DELETE ITEM: %s (%i)", DisplayName(), IsMSItem() ? ((CBasePlayerItem*)this)->m_iId : NULL); MSCLGlobals::RemoveEnt(this, true); } //void CBaseEntity::StruckSound( CBaseEntity *pInflicter, CBaseEntity *pAttacker, float flDamage, TraceResult *ptr, int bitsDamageType ) { } @@ -76,13 +77,13 @@ void CBaseEntity::CounterEffect(CBaseEntity *pInflictor, int iEffect, void *pExt // CBaseDelay Stubs void CBaseDelay ::KeyValue(struct KeyValueData_s *) {} -int CBaseDelay::Restore(class CRestore &) { return 1; } -int CBaseDelay::Save(class CSave &) { return 1; } +int CBaseDelay::Restore(class CRestore &) { return TRUE; } +int CBaseDelay::Save(class CSave &) { return TRUE; } CBaseEntity *CBaseDelay::GetSelf() { return this; } // CBaseAnimating Stubs -int CBaseAnimating::Restore(class CRestore &) { return 1; } -int CBaseAnimating::Save(class CSave &) { return 1; } +int CBaseAnimating::Restore(class CRestore &) { return TRUE; } +int CBaseAnimating::Save(class CSave &) { return TRUE; } // DEBUG Stubs edict_t *DBG_EntOfVars(const entvars_t *pev) { return NULL; } @@ -107,8 +108,8 @@ void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const ch } // CBaseToggle Stubs -int CBaseToggle::Restore(class CRestore &) { return 1; } -int CBaseToggle::Save(class CSave &) { return 1; } +int CBaseToggle::Restore(class CRestore &) { return TRUE; } +int CBaseToggle::Save(class CSave &) { return TRUE; } void CBaseToggle ::KeyValue(struct KeyValueData_s *) {} // CGrenade Stubs @@ -124,20 +125,20 @@ BOOL CBaseMonster ::FShouldEat(void) { return TRUE; } void CBaseMonster ::BarnacleVictimBitten(entvars_t *pevBarnacle) {} void CBaseMonster ::BarnacleVictimReleased(void) {} void CBaseMonster ::Listen(void) {} -float CBaseMonster ::FLSoundVolume(CSound *pSound) { return 0.0; } +float CBaseMonster::FLSoundVolume(CSound* pSound) { return NULL; } BOOL CBaseMonster ::FValidateHintType(short sHint) { return FALSE; } void CBaseMonster ::Look(int iDistance) {} -int CBaseMonster ::ISoundMask(void) { return 0; } +int CBaseMonster ::ISoundMask(void) { return NULL; } CSound *CBaseMonster ::PBestSound(void) { return NULL; } CSound *CBaseMonster ::PBestScent(void) { return NULL; } -float CBaseAnimating ::StudioFrameAdvance(float flInterval) { return 0.0; } +float CBaseAnimating ::StudioFrameAdvance(float flInterval) { return NULL; } void CBaseMonster ::MonsterThink(void) {} void CBaseMonster ::MonsterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) {} -int CBaseMonster ::IgnoreConditions(void) { return 0; } +int CBaseMonster ::IgnoreConditions(void) { return NULL; } void CBaseMonster ::RouteClear(void) {} void CBaseMonster ::RouteNew(void) {} BOOL CBaseMonster ::FRouteClear(void) { return FALSE; } -BOOL CBaseMonster ::FRefreshRoute(void) { return 0; } +BOOL CBaseMonster ::FRefreshRoute(void) { return FALSE; } BOOL CBaseMonster::MoveToEnemy(Activity movementAct, float waitTime) { return FALSE; } BOOL CBaseMonster::MoveToLocation(Activity movementAct, float waitTime, const Vector &goal) { return FALSE; } BOOL CBaseMonster::MoveToTarget(Activity movementAct, float waitTime) { return FALSE; } @@ -151,15 +152,15 @@ BOOL CBaseMonster ::CheckMeleeAttack1(float flDot, float flDist) { return FALSE; BOOL CBaseMonster ::CheckMeleeAttack2(float flDot, float flDist) { return FALSE; } void CBaseMonster ::CheckAttacks(CBaseEntity *pTarget, float flDist) {} BOOL CBaseMonster ::FCanCheckAttacks(void) { return FALSE; } -int CBaseMonster ::CheckEnemy(CBaseEntity *pEnemy) { return 0; } +int CBaseMonster ::CheckEnemy(CBaseEntity *pEnemy) { return FALSE; } void CBaseMonster ::PushEnemy(CBaseEntity *pEnemy, Vector &vecLastKnownPos) {} BOOL CBaseMonster ::PopEnemy() { return FALSE; } void CBaseMonster ::SetActivity(Activity NewActivity) {} void CBaseMonster ::SetSequenceByName(char *szSequence) {} -int CBaseMonster ::CheckLocalMove(const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist) { return 0; } -float CBaseMonster ::OpenDoorAndWait(entvars_t *pevDoor) { return 0.0; } +int CBaseMonster ::CheckLocalMove(const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist) { return NULL; } +float CBaseMonster::OpenDoorAndWait(entvars_t* pevDoor) { return NULL; } void CBaseMonster ::AdvanceRoute(float distance) {} -int CBaseMonster ::RouteClassify(int iMoveFlag) { return 0; } +int CBaseMonster::RouteClassify(int iMoveFlag) { return NULL; } BOOL CBaseMonster ::BuildRoute(const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget) { return FALSE; } void CBaseMonster ::InsertWaypoint(Vector vecLocation, int afMoveFlags) {} BOOL CBaseMonster ::FTriangulate(const Vector &vecStart, const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex) { return FALSE; } @@ -170,8 +171,8 @@ void CBaseMonster ::MonsterInit(void) {} void CBaseMonster ::MonsterInitThink(void) {} void CBaseMonster ::StartMonster(void) {} void CBaseMonster ::MovementComplete(void) {} -int CBaseMonster::TaskIsRunning(void) { return 0; } -int CBaseMonster::IRelationship(CBaseEntity *pTarget) { return 0; } +int CBaseMonster::TaskIsRunning(void) { return FALSE; } +int CBaseMonster::IRelationship(CBaseEntity *pTarget) { return NULL; } BOOL CBaseMonster ::FindCover(Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist) { return FALSE; } BOOL CBaseMonster ::BuildNearestRoute(Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist) { return FALSE; } CBaseEntity *CBaseMonster ::BestVisibleEnemy(void) { return NULL; } @@ -182,26 +183,26 @@ BOOL CBaseEntity ::FVisible(const Vector &vecOrigin) { return FALSE; } BOOL CBaseEntity ::FMVisible(CBaseEntity *pEntity) { return FALSE; } BOOL CBaseEntity ::FMVisible(const Vector &vecOrigin) { return FALSE; } void CBaseMonster ::MakeIdealYaw(Vector vecTarget) {} -float CBaseMonster::FlYawDiff(void) { return 0.0; } -float CBaseMonster::ChangeYaw(int yawSpeed) { return 0; } -float CBaseMonster::VecToYaw(Vector vecDir) { return 0.0; } -int CBaseAnimating ::LookupActivity(int activity) { return 0; } -int CBaseAnimating ::LookupActivityHeaviest(int activity) { return 0; } +float CBaseMonster::FlYawDiff(void) { return NULL; } +float CBaseMonster::ChangeYaw(int yawSpeed) { return NULL; } +float CBaseMonster::VecToYaw(Vector vecDir) { return NULL; } +int CBaseAnimating ::LookupActivity(int activity) { return NULL; } +int CBaseAnimating ::LookupActivityHeaviest(int activity) { return NULL; } void CBaseMonster ::SetEyePosition(void) {} -int CBaseAnimating ::LookupSequence(const char *label) { return 0; } +int CBaseAnimating ::LookupSequence(const char *label) { return NULL; } void CBaseAnimating ::ResetSequenceInfo() {} BOOL CBaseAnimating ::GetSequenceFlags() { return FALSE; } void CBaseAnimating ::DispatchAnimEvents(float flInterval) {} void CBaseMonster ::HandleAnimEvent(MonsterEvent_t *pEvent) {} -float CBaseAnimating ::SetBoneController(int iController, float flValue) { return 0.0; } +float CBaseAnimating::SetBoneController(int iController, float flValue) { return NULL; } void CBaseAnimating ::InitBoneControllers(void) {} -float CBaseAnimating ::SetBlending(int iBlender, float flValue) { return 0; } +float CBaseAnimating ::SetBlending(int iBlender, float flValue) { return NULL; } void CBaseAnimating ::GetBonePosition(int iBone, Vector &origin, Vector &angles) {} void CBaseAnimating ::GetAttachment(int iAttachment, Vector &origin, Vector &angles) {} -int CBaseAnimating ::FindTransition(int iEndingSequence, int iGoalSequence, int *piDir) { return -1; } +int CBaseAnimating ::FindTransition(int iEndingSequence, int iGoalSequence, int *piDir) { return NEG_REF; } void CBaseAnimating ::GetAutomovement(Vector &origin, Vector &angles, float flInterval) {} void CBaseAnimating ::SetBodygroup(int iGroup, int iValue) {} -int CBaseAnimating ::GetBodygroup(int iGroup) { return 0; } +int CBaseAnimating ::GetBodygroup(int iGroup) { return NULL; } Vector CBaseMonster ::GetGunPosition(void) { return g_vecZero; } void CBaseEntity::FireBullets(unsigned long cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) {} void CBaseEntity ::TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) {} @@ -242,25 +243,25 @@ Schedule_t *CBaseMonster::ScheduleFromName(const char *pName) { return NULL; } void CBaseMonster::BecomeDead(void) {} void CBaseMonster ::RunAI(void) {} void CBaseMonster ::Killed(entvars_t *pevAttacker, int iGib) {} -int CBaseMonster ::TakeHealth(float flHealth, int bitsDamageType) { return 0; } -int CBaseMonster ::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { return 0; } -int CBaseMonster::Restore(class CRestore &) { return 1; } -int CBaseMonster::Save(class CSave &) { return 1; } +int CBaseMonster ::TakeHealth(float flHealth, int bitsDamageType) { return NULL; } +int CBaseMonster::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) {return NULL;} +int CBaseMonster::Restore(class CRestore &) { return TRUE; } +int CBaseMonster::Save(class CSave &) { return TRUE; } -int TrainSpeed(int iSpeed, int iMax) { return 0; } +int TrainSpeed(int iSpeed, int iMax) { return NULL; } //Master Sword void CBasePlayer::PainSound() {} void CBasePlayer::TakeDamageEffect(CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType) {} -int CBasePlayer::IRelationship(CBaseEntity *pTarget) { return 0; } +int CBasePlayer::IRelationship(CBaseEntity *pTarget) { return NULL; } -int CBasePlayerWeapon::Restore(class CRestore &) { return 1; } -int CBasePlayerWeapon::Save(class CSave &) { return 1; } +int CBasePlayerWeapon::Restore(class CRestore &) { return TRUE; } +int CBasePlayerWeapon::Save(class CSave &) { return TRUE; } void CBasePlayer::StruckSound(CBaseEntity *pInflicter, CBaseEntity *pAttacker, float flDamage, TraceResult *ptr, int bitsDamageType) {} void CBasePlayer::DeathSound(void) {} -int CBasePlayer::TakeHealth(float flHealth, int bitsDamageType) { return 0; } -int CBasePlayer::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { return 0; } +int CBasePlayer::TakeHealth(float flHealth, int bitsDamageType) { return NULL; } +int CBasePlayer::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { return NULL; } void CBasePlayer::PackDeadPlayerItems(void) {} void CBasePlayer::WaterMove() {} BOOL CBasePlayer::IsOnLadder(void) { return FALSE; } @@ -270,7 +271,7 @@ void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) {} void CBasePlayer::PlayerUse(void) {} void CBasePlayer::Jump() {} void CBasePlayer::Duck() {} -int CBasePlayer::Classify(void) { return 0; } +int CBasePlayer::Classify(void) { return NULL; } //void CBasePlayer :: PlayStepSound(int step, float fvol) { } //void CBasePlayer :: UpdateStepSound( void ) { } void CBasePlayer::PreThink(void) {} @@ -279,9 +280,9 @@ void CBasePlayer ::UpdateGeigerCounter(void) {} void CBasePlayer ::UpdatePlayerSound(void) {} void CBasePlayer::PostThink() {} void CBasePlayer ::Precache(void) {} -int CBasePlayer::Save(CSave &save) { return 0; } +int CBasePlayer::Save(CSave &save) { return NULL; } void CBasePlayer::RenewItems(void) {} -int CBasePlayer::Restore(CRestore &restore) { return 0; } +int CBasePlayer::Restore(CRestore &restore) { return NULL; } void CBasePlayer::SelectNextItem(int iItem) {} BOOL CBasePlayer::HasWeapons(void) { return FALSE; } void CBasePlayer::SelectPrevItem(int iItem) {} @@ -294,19 +295,19 @@ void CBasePlayer::ImpulseCommands() {} void CBasePlayer::CheatImpulseCommands(int iImpulse) {} void CBasePlayer::ItemPreFrame() {} void CBasePlayer::ItemPostFrame() {} -int CBasePlayer::AmmoInventory(int iAmmoIndex) { return -1; } +int CBasePlayer::AmmoInventory(int iAmmoIndex) { return NEG_REF; } //Master Sword void CBasePlayer ::UpdateClientData(void) {} BOOL CBasePlayer ::FBecomeProne(void) { return TRUE; } void CBasePlayer ::BarnacleVictimBitten(entvars_t *pevBarnacle) {} void CBasePlayer ::BarnacleVictimReleased(void) {} -int CBasePlayer ::Illumination(void) { return 0; } +int CBasePlayer ::Illumination(void) { return NULL; } void CBasePlayer ::EnableControl(BOOL fControl) {} Vector CBasePlayer ::GetAutoaimVector(float flDelta) { return g_vecZero; } //Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; } void CBasePlayer ::ResetAutoaim() {} void CBasePlayer ::SetCustomDecalFrames(int nFrames) {} -int CBasePlayer ::GetCustomDecalFrames(void) { return -1; } +int CBasePlayer ::GetCustomDecalFrames(void) { return NEG_REF; } Vector CBasePlayer ::GetGunPosition(void) { return g_vecZero; } //Master Sword void CBasePlayer::Trade() {} From 6b2b930d92b15cbd696a9950ff145eacd32e898a Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 18:20:31 -0400 Subject: [PATCH 048/291] Removed massive comment block from 2011. --- src/game/client/ms/clglobal.cpp | 67 --------------------------------- 1 file changed, 67 deletions(-) diff --git a/src/game/client/ms/clglobal.cpp b/src/game/client/ms/clglobal.cpp index bdf8f3a8..72657b75 100644 --- a/src/game/client/ms/clglobal.cpp +++ b/src/game/client/ms/clglobal.cpp @@ -69,74 +69,7 @@ void MSCLGlobals::Initialize() // Set up pointer // Fill in current time gpGlobals->time = gEngfuncs.GetClientTime(); - - // //Client CVARs - // CVAR_CREATE("ms_status_icons", "1", FCVAR_CLIENTDLL); // Drigien MAY2008 - Shows/Hides The HUD Status Icons - // //JAN2010_11 - not optional - used to blind player sometimes - // //CVAR_CREATE( "ms_showhudimgs", "1", FCVAR_CLIENTDLL ); // Drigien MAY2008 - Shows/Hides The HUD Images - // CVAR_CREATE("hud_classautokill", "1", FCVAR_ARCHIVE); // controls whether or not to suicide immediately on TF class switch - // CVAR_CREATE("hud_takesshots", "0", FCVAR_ARCHIVE); // controls whether or not to automatically take screenshots at the end of a round - // CVAR_CREATE("ms_hidehud", "0", FCVAR_ARCHIVE); // Hides the HUD and viewmodel completely - // CVAR_CREATE("ms_lildude", "1", FCVAR_ARCHIVE); // Thothie MAR2007a - Hides the 3d Guy if set 0 - // CVAR_CREATE("ms_clgender", "0", FCVAR_CLIENTDLL); // Thothie FEB2011_22 - Adding a cvar to store client gender - // CVAR_CREATE("ms_xpdisplay", "0", FCVAR_ARCHIVE); // Thothie AUG2007a - XP Display Options - // CVAR_CREATE("ms_developer", "0", FCVAR_CLIENTDLL); // Thothie MAR2007b - Hides client side developer messages when set to 0 - // CVAR_CREATE("ms_evthud_decaytime", "5", FCVAR_ARCHIVE); // Time each line in the Event Console lasts before it shrinks - // CVAR_CREATE("ms_evthud_history", "10", FCVAR_ARCHIVE); // Max number of text lines to keep in the Event Console history - // CVAR_CREATE("ms_evthud_size", "5", FCVAR_ARCHIVE); // Max number of text lines shown at once - // CVAR_CREATE("ms_evthud_bgtrans", "0", FCVAR_CLIENTDLL); // Transparency of the background - // CVAR_CREATE("ms_txthud_decaytime", "9", FCVAR_ARCHIVE); // Time each line in the Event Console lasts before it shrinks - // CVAR_CREATE("ms_txthud_history", "50", FCVAR_ARCHIVE); // Max number of text lines to keep in the Event Console history - // CVAR_CREATE("ms_txthud_size", "8", FCVAR_ARCHIVE); // Max number of text lines shown at once - // CVAR_CREATE("ms_txthud_bgtrans", "0", FCVAR_ARCHIVE); // Transparency of the background - // CVAR_CREATE("ms_txthud_width", "640", FCVAR_ARCHIVE); // Width of console - // CVAR_CREATE(CVAR_HELPTIPS, "1", FCVAR_ARCHIVE /*|FCVAR_USERINFO*/); // Whether help tips are shown - // CVAR_CREATE("ms_reflect", "1", FCVAR_ARCHIVE); // Allow reflective surfaces - // CVAR_CREATE("ms_reflect_dbg", "0", FCVAR_ARCHIVE); // Debug reflective surfaces - // CVAR_CREATE("ms_bloom_darken", "-1", FCVAR_ARCHIVE); // MiB DEC2010 - Darken bloom - // CVAR_CREATE("ms_bloom_level", "0", FCVAR_ARCHIVE); // Thothie DEC2010_30 - Fix ms_bloom_level stickiness - // //CVAR_CREATE("ms_reconnect_delay", "5", FCVAR_ARCHIVE); // Thothie AUG2017 - Make reconnect delay adjustable client side - // CVAR_CREATE(MSCVAR_QUICKSLOT_TIMEOUT, "2.5", FCVAR_ARCHIVE); // Timeout for the quickslots - // CVAR_CREATE("ms_autocharge", "1", FCVAR_ARCHIVE); // MiB MAR2012_05 - Let's you auto-charge your attack - // CVAR_CREATE("ms_doubletapdodge", "0", FCVAR_ARCHIVE); // MiB MAR2012_05 -Enable/Disable double tapping to dodge - // CVAR_CREATE("ms_invtype", "1", FCVAR_ARCHIVE); // MiB FEB2012_12 - Inventory types (added post-doc by Thothie) - // CVAR_CREATE("ms_showotherglow", "1", FCVAR_ARCHIVE); - // CVAR_CREATE("ms_chargebar_sound", "magic/chargebar_alt1.wav", FCVAR_ARCHIVE); - // CVAR_CREATE("ms_chargebar_volume", "15", FCVAR_ARCHIVE); - // CVAR_CREATE("ms_doubletap_delay", "0.45", FCVAR_ARCHIVE); // The higher the amount, the longer the player has to hit left/right/back for a second time - // CVAR_CREATE("ms_sprint_verbose", "2", FCVAR_ARCHIVE); // 0 for no messages , 1 for only warnings , 2 for everything - // CVAR_CREATE("ms_sprint_toggle", "1", FCVAR_ARCHIVE); - // CVAR_CREATE("ms_sprint_doubletap", "1", FCVAR_ARCHIVE); - - //CVAR_CREATE("ms_alpha_inventory", "0", FCVAR_ARCHIVE); // MiB FEB2019_24 [ALPHABETICAL_INVENTORY] - //CVAR_CREATE("ms_hands_display", "2", FCVAR_ARCHIVE); - //CVAR_CREATE("ms_hands_display_y", "20", FCVAR_ARCHIVE); - //CVAR_CREATE("ms_scrollamount", "30", FCVAR_ARCHIVE); - //CVAR_CREATE("ms_doubleclicktime", "1", FCVAR_ARCHIVE); - - /*msstring DefaultLANID = "this_must_be_unique"; - gEngfuncs.pfnRegisterVariable( "ms_id", DefaultID, FCVAR_USERINFO|FCVAR_ARCHIVE ); - - if( DefaultLANID == (const char *)gEngfuncs.pfnGetCvarString("ms_id") ) - { - //If I'm still using the default ID, generate a random one - char ID[8]; - for (int i = 0; i < 6; i++) - { - int CharType = RANDOM_LONG(0,2); - int Low, High; - switch( CharType ) { - case 0: Low = '0'; High = '9'; break; - case 1: Low = 'a'; High = 'z'; break; - case 2: Low = 'A'; High = 'Z'; break; - } - ID[i] = RANDOM_LONG( Low, High ); ID[i+1] = 0; - } - gEngfuncs.pfnClientCmd( msstring("ms_id ") + ID + "\n" ); - }*/ - InitializePlayer(); - MSGlobalItemInit(); } From 60cd2fdf4bed6a03a658fc5cec96737c4cd23da7 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:20:39 -0400 Subject: [PATCH 049/291] Removed some comments. Addeec constexpr to defined constants. FIxed warning C5055 after enum changes. --- src/game/client/ms/health.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/client/ms/health.cpp b/src/game/client/ms/health.cpp index aad8e4c0..3b94e44d 100644 --- a/src/game/client/ms/health.cpp +++ b/src/game/client/ms/health.cpp @@ -55,6 +55,7 @@ int giDmgFlags[NUM_DMG_TYPES] = DMG_NERVEGAS, DMG_RADIATION, DMG_SHOCK, + DMG_CALTROP, DMG_TRANQ, DMG_CONCUSS, From bfa30bc1dcecd3bebaf19bb3974951cad94c96e0 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:20:50 -0400 Subject: [PATCH 050/291] Removed whitespace --- src/game/client/ms/health.cpp | 192 ++++------------------------------ 1 file changed, 20 insertions(+), 172 deletions(-) diff --git a/src/game/client/ms/health.cpp b/src/game/client/ms/health.cpp index 3b94e44d..f0f0abc7 100644 --- a/src/game/client/ms/health.cpp +++ b/src/game/client/ms/health.cpp @@ -39,27 +39,27 @@ MS_DECLARE_MESSAGE(m_Health, HP) MS_DECLARE_MESSAGE(m_Health, MP) MS_DECLARE_MESSAGE(m_Health, Damage) -#define MOVE_INC 3 -#define PAIN_NAME "sprites/%d_pain.spr" -#define DAMAGE_NAME "sprites/%d_dmg.spr" +constexpr int MOVE_INC = 3; +constexpr const char* PAIN_NAME = "sprites/%d_pain.spr"; +constexpr const char* DAMAGE_NAME = "sprites/%d_dmg.spr"; int giDmgHeight, giDmgWidth; int giDmgFlags[NUM_DMG_TYPES] = - { - DMG_POISON, - DMG_ACID, - DMG_FREEZE | DMG_SLOWFREEZE, - DMG_DROWN, - DMG_BURN | DMG_SLOWBURN, - DMG_NERVEGAS, - DMG_RADIATION, - DMG_SHOCK, - - DMG_CALTROP, - DMG_TRANQ, - DMG_CONCUSS, - DMG_HALLUC}; +{ + DMG_POISON, + DMG_ACID, + DMG_FREEZE | DMG_SLOWFREEZE, + DMG_DROWN, + DMG_BURN | DMG_SLOWBURN, + DMG_NERVEGAS, + DMG_RADIATION, + DMG_SHOCK, + DMG_CALTROP, + DMG_TRANQ, + DMG_CONCUSS, + DMG_HALLUC +}; int CHudHealth::Init(void) { @@ -77,14 +77,6 @@ int CHudHealth::Init(void) m_iTempHP = m_iTempMP = 0; memset(m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES); - - /* if( !CVAR_GET_FLOAT("gl_polyoffset") ) { - char a[64]; - _snprintf(a, sizeof(a), "Software mode detected! Disabling Health/Mana Flasks!.\n", CVAR_GET_FLOAT("gl_polyoffset") ); - ConsolePrint( a ); - m_iFlags = 0; - }*/ - gHUD.AddHudElem(this); return 1; } @@ -185,7 +177,7 @@ void CHudHealth::GetPainColor(int &r, int &g, int &b) iHealth -= 25; else if (iHealth < 0) iHealth = 0; -#if 0 +#if 0 g = iHealth * 255 / 100; r = 255 - g; b = 0; @@ -209,90 +201,6 @@ void CHudHealth::GetPainColor(int &r, int &g, int &b) int CHudHealth::Draw(float flTime) { return 1; - /* int HPr, HPg, HPb; - int x, y; - int xFlask, yFlask; - int iHealth = player.m_HP, - iMaxHP = player.m_MaxHP, - iMana = player.m_MP, - iMaxMP = player.m_MaxMP; - - if( player.m_HP < 1.0f && player.m_HP > 0 ) iHealth = 1; //Cap integers at 1 - if( player.m_MP < 1.0f && player.m_MP > 0 ) iMana = 1; - - if ( gHUD.m_iHideHUDDisplay & (HIDEHUD_HEALTH|HIDEHUD_ALL) || !(m_iFlags&HUD_ACTIVE) ) - return 1; - - if ( !m_hSprite ) - m_hSprite = LoadSprite(PAIN_NAME); - - - // If health is getting low, make it bright red - //if (m_iHealth <= 15) ScaleColors(r, g, b, a ); - - if( (gHUD.m_flTime-flChangeTime) >= .007) { - float inc = (100/MOVE_INC); - if( m_iTempHP > iHealth ) { m_iTempHP -= (iHealth/inc)+1; if(m_iTempHPiHealth) m_iTempHP = iHealth; } - if( m_iTempMP > iMana ) { m_iTempMP -= (iMana/inc)+1; if(m_iTempMPiMana) m_iTempMP = iMana; } - flChangeTime = gHUD.m_flTime; - } - -// if( m_iTempHP < iHealth ) m_iTempHP = iHealth; -// if( m_iTempMP < iMana ) m_iTempMP = iMana; - -// ScaleColors(r, g, b, a ); - - int iHealthFlask = gHUD.GetSpriteIndex("healthflask"), - iManaFlask = gHUD.GetSpriteIndex("manaflask"), - iframe; - int SMLNumWidth = gHUD.GetSpriteRect(gHUD.m_HUD_numberSML_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_numberSML_0).left, - SMLSlashWidth = gHUD.GetSpriteRect(gHUD.m_HUD_char_slashSML).right - gHUD.GetSpriteRect(gHUD.m_HUD_char_slashSML).left, - HFlaskWidth = gHUD.GetSpriteRect(iHealthFlask).right - gHUD.GetSpriteRect(iHealthFlask).left, - MFlaskWidth = gHUD.GetSpriteRect(iManaFlask).right - gHUD.GetSpriteRect(iManaFlask).left; - int xStart, yStart; - - //y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; - yFlask = ScreenHeight - 110; xFlask = XRES(15); - - xStart = (xFlask+(HFlaskWidth/2))-(((numofdigits(m_iTempHP)*SMLNumWidth)+(numofdigits(iMaxHP)*SMLNumWidth)+SMLSlashWidth)/2); yStart = ScreenHeight - 40; - - y = yStart; x = xStart; - - - float fltemp; int maxframes; - maxframes = (SPR_Frames(gHUD.GetSprite(iHealthFlask))-1); - fltemp = (float)((float)m_iTempHP/(float)iMaxHP) * maxframes; - iframe = min(fltemp,maxframes); //round up if not at integer - SPR_Set(gHUD.GetSprite(iHealthFlask), 128, 128, 128 ); - SPR_DrawHoles( iframe, xFlask, yFlask, &gHUD.GetSpriteRect(iHealthFlask)); - - GetPainColor( HPr, HPg, HPb ); - x = gHUD.DrawHudNumberSML(x, y, NULL, m_iTempHP, HPr, HPg, HPb); - - x = gHUD.DrawHudStringSML( x, y, "/", 255, 255, 255 ); - - x = gHUD.DrawHudNumberSML(x, y, NULL, iMaxHP, 255, 255, 255); - - xFlask += (gHUD.GetSpriteRect(iHealthFlask).right - gHUD.GetSpriteRect(iHealthFlask).left) + XRES(10); - - maxframes = (SPR_Frames(gHUD.GetSprite(iManaFlask))-1); - fltemp = (float)((float)m_iTempMP/(float)iMaxMP) * maxframes; - iframe = min(fltemp,maxframes); //round up if not at integer - SPR_Set(gHUD.GetSprite(iManaFlask), 128, 128, 128 ); - SPR_DrawHoles( iframe, xFlask, yFlask, &gHUD.GetSpriteRect(iManaFlask)); - - x = (xFlask+(MFlaskWidth/2))-(((numofdigits(m_iTempMP)*SMLNumWidth)+(numofdigits(iMaxMP)*SMLNumWidth)+SMLSlashWidth)/2); yStart = ScreenHeight - 40; - - x = gHUD.DrawHudNumberSML(x, y, NULL, m_iTempMP, 255, 255, 255); - - x = gHUD.DrawHudStringSML( x, y, "/", 255, 255, 255 ); - - x = gHUD.DrawHudNumberSML(x, y, NULL, iMaxMP, 255, 255, 255); - - DrawDamage(flTime); - return DrawPain(flTime);*/ } void CHudHealth::CalcDamageDirection(vec3_t vecFrom) @@ -430,66 +338,6 @@ int CHudHealth::DrawPain(float flTime) return 1; } -/*int CHudHealth::DrawDamage(float flTime) -{ - int r, g, b, a; - DAMAGE_IMAGE *pdmg; - - if (!m_bitsDamage) - return 1; - - UnpackRGB(r,g,b, RGB_YELLOWISH); - - a = (int)( fabs(sin(flTime*2)) * 256.0); - - ScaleColors(r, g, b, a); - - // Draw all the items - for (int i = 0; i < NUM_DMG_TYPES; i++) - { - if (m_bitsDamage & giDmgFlags[i]) - { - pdmg = &m_dmg[i]; - SPR_Set(gHUD.GetSprite(m_HUD_dmg_bio + i), r, g, b ); - SPR_DrawAdditive(0, pdmg->x, pdmg->y, &gHUD.GetSpriteRect(m_HUD_dmg_bio + i)); - } - } - - - // check for bits that should be expired - for ( i = 0; i < NUM_DMG_TYPES; i++ ) - { - DAMAGE_IMAGE *pdmg = &m_dmg[i]; - - if ( m_bitsDamage & giDmgFlags[i] ) - { - pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire ); - - if ( pdmg->fExpire <= flTime // when the time has expired - && a < 40 ) // and the flash is at the low point of the cycle - { - pdmg->fExpire = 0; - - int y = pdmg->y; - pdmg->x = pdmg->y = 0; - - // move everyone above down - for (int j = 0; j < NUM_DMG_TYPES; j++) - { - pdmg = &m_dmg[j]; - if ((pdmg->y) && (pdmg->y < y)) - pdmg->y += giDmgHeight; - - } - - m_bitsDamage &= ~giDmgFlags[i]; // clear the bits - } - } - } - - return 1; -}*/ - void CHudHealth::UpdateTiles(float flTime, long bitsDamage) { DAMAGE_IMAGE *pdmg; @@ -504,7 +352,7 @@ void CHudHealth::UpdateTiles(float flTime, long bitsDamage) // Is this one already on? if (m_bitsDamage & giDmgFlags[i]) { - pdmg->fExpire = flTime + DMG_IMAGE_LIFE; // extend the duration + pdmg->fExpire = flTime + static_cast(DMG_IMAGE_LIFE); // extend the duration if (!pdmg->fBaseline) pdmg->fBaseline = flTime; } @@ -515,7 +363,7 @@ void CHudHealth::UpdateTiles(float flTime, long bitsDamage) // put this one at the bottom pdmg->x = giDmgWidth / 8; pdmg->y = ScreenHeight - giDmgHeight * 2; - pdmg->fExpire = flTime + DMG_IMAGE_LIFE; + pdmg->fExpire = flTime + static_cast(DMG_IMAGE_LIFE); // move everyone else up for (int j = 0; j < NUM_DMG_TYPES; j++) From 15929402a7e659113fdf531184ddaca29eb2e55d Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:21:29 -0400 Subject: [PATCH 051/291] Removed multiple enum definitions, MS defines are in cbase.h --- src/game/client/ms/health.h | 85 ++++++++----------------------------- 1 file changed, 18 insertions(+), 67 deletions(-) diff --git a/src/game/client/ms/health.h b/src/game/client/ms/health.h index 6fef6538..4442334e 100644 --- a/src/game/client/ms/health.h +++ b/src/game/client/ms/health.h @@ -13,75 +13,26 @@ * ****/ -#define DMG_IMAGE_LIFE 2 // seconds that image is up +enum { -#define DMG_IMAGE_POISON 0 -#define DMG_IMAGE_ACID 1 -#define DMG_IMAGE_COLD 2 -#define DMG_IMAGE_DROWN 3 -#define DMG_IMAGE_BURN 4 -#define DMG_IMAGE_NERVE 5 -#define DMG_IMAGE_RAD 6 -#define DMG_IMAGE_SHOCK 7 -//tf defines -#define DMG_IMAGE_CALTROP 8 -#define DMG_IMAGE_TRANQ 9 -#define DMG_IMAGE_CONCUSS 10 -#define DMG_IMAGE_HALLUC 11 -#define NUM_DMG_TYPES 12 -// instant damage - -#define DMG_GENERIC 0 // generic damage was done -#define DMG_CRUSH (1 << 0) // crushed by falling or moving object -#define DMG_BULLET (1 << 1) // shot -#define DMG_SLASH (1 << 2) // cut, clawed, stabbed -#define DMG_BURN (1 << 3) // heat burned -#define DMG_FREEZE (1 << 4) // frozen -#define DMG_FALL (1 << 5) // fell too far -#define DMG_BLAST (1 << 6) // explosive blast damage -#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt -#define DMG_SHOCK (1 << 8) // electric shock -#define DMG_SONIC (1 << 9) // sound pulse shockwave -#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam -#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death -#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. - -// time-based damage -//mask off TF-specific stuff too -//#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage - -#define DMG_DROWN (1 << 14) // Drowning -#define DMG_FIRSTTIMEBASED DMG_DROWN - -#define DMG_PARALYZE (1 << 15) // slows affected creature down -#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad -#define DMG_POISON (1 << 17) // blood poisioning -#define DMG_RADIATION (1 << 18) // radiation exposure -#define DMG_DROWNRECOVER (1 << 19) // drowning recovery -#define DMG_ACID (1 << 20) // toxic chemicals or acid burns -#define DMG_SLOWBURN (1 << 21) // in an oven -#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer -#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar) - -//TF ADDITIONS -#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn -#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance -#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius. -#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor -#define DMG_AIMED (1 << 28) // Does Hit location damage -#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls - -#define DMG_CALTROP (1 << 30) -#define DMG_HALLUC (1 << 31) - -// TF Healing Additions for TakeHealth -#define DMG_IGNORE_MAXHEALTH DMG_IGNITE -// TF Redefines since we never use the originals -#define DMG_NAIL DMG_SLASH -#define DMG_NOT_SELF DMG_FREEZE + DMG_IMAGE_POISON = 0, + DMG_IMAGE_ACID = 1, + DMG_IMAGE_COLD = 2, + DMG_IMAGE_LIFE = 2,// seconds that image is up + DMG_IMAGE_DROWN = 3, + DMG_IMAGE_BURN = 4, + DMG_IMAGE_NERVE = 5, + DMG_IMAGE_RAD = 6, + DMG_IMAGE_SHOCK = 7, + //tf defines + DMG_IMAGE_CALTROP = 8, + DMG_IMAGE_TRANQ = 9, + DMG_IMAGE_CONCUSS = 10, + DMG_IMAGE_HALLUC = 11 +}; -#define DMG_TRANQ DMG_MORTAR -#define DMG_CONCUSS DMG_SONIC +constexpr int NUM_DMG_TYPES = 12; +// instant damage typedef struct { From 41d162368c8e910b1a785b79a17db0a8e85db4fd Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:22:02 -0400 Subject: [PATCH 052/291] Added missing enums in DMG types to to remove multiple declarations. --- src/game/server/hl/cbase.h | 187 +++++++++++++++++++------------------ 1 file changed, 94 insertions(+), 93 deletions(-) diff --git a/src/game/server/hl/cbase.h b/src/game/server/hl/cbase.h index ec3361e2..2534cd58 100644 --- a/src/game/server/hl/cbase.h +++ b/src/game/server/hl/cbase.h @@ -836,111 +836,112 @@ class CBaseToggle : public CBaseAnimating #define SetMoveDone(a) m_pfnCallWhenMoveDone = static_cast(a) // people gib if their health is <= this at the time of death -#define GIB_HEALTH_VALUE -30 - -#define ROUTE_SIZE 8 // how many waypoints a monster can store at one time -#define MAX_OLD_ENEMIES 4 // how many old enemies to remember - -#define bits_CAP_DUCK (1 << 0) // crouch -#define bits_CAP_JUMP (1 << 1) // jump/leap -#define bits_CAP_STRAFE (1 << 2) // strafe ( walk/run sideways) -#define bits_CAP_SQUAD (1 << 3) // can form squads -#define bits_CAP_SWIM (1 << 4) // proficiently navigate in water -#define bits_CAP_CLIMB (1 << 5) // climb ladders/ropes -#define bits_CAP_USE (1 << 6) // open doors/push buttons/pull levers -#define bits_CAP_HEAR (1 << 7) // can hear forced sounds -#define bits_CAP_AUTO_DOORS (1 << 8) // can trigger auto doors -#define bits_CAP_OPEN_DOORS (1 << 9) // can open manual doors -#define bits_CAP_TURN_HEAD (1 << 10) // can turn head, always bone controller 0 - -#define bits_CAP_RANGE_ATTACK1 (1 << 11) // can do a range attack 1 -#define bits_CAP_RANGE_ATTACK2 (1 << 12) // can do a range attack 2 -#define bits_CAP_MELEE_ATTACK1 (1 << 13) // can do a melee attack 1 -#define bits_CAP_MELEE_ATTACK2 (1 << 14) // can do a melee attack 2 - -#define bits_CAP_FLY (1 << 15) // can fly, move all around - -#define bits_CAP_DOORS_GROUP (bits_CAP_USE | bits_CAP_AUTO_DOORS | bits_CAP_OPEN_DOORS) - +constexpr int GIB_HEALTH_VALUE = -30; +constexpr int ROUTE_SIZE = 8; // how many waypoints a monster can store at one time +constexpr int MAX_OLD_ENEMIES = 4; // how many old enemies to remember + +enum { + bits_CAP_DUCK = (1 << 0), // crouch + bits_CAP_JUMP = (1 << 1), // jump/leap + bits_CAP_STRAFE = (1 << 2), // strafe ( walk/run sideways) + bits_CAP_SQUAD = (1 << 3), // can form squads + bits_CAP_SWIM = (1 << 4), // proficiently navigate in water + bits_CAP_CLIMB = (1 << 5), // climb ladders/ropes + bits_CAP_USE = (1 << 6), // open doors/push buttons/pull levers + bits_CAP_HEAR = (1 << 7), // can hear forced sounds + bits_CAP_AUTO_DOORS = (1 << 8), // can trigger auto doors + bits_CAP_OPEN_DOORS = (1 << 9), // can open manual doors + bits_CAP_TURN_HEAD = (1 << 10), // can turn head, always bone controller 0 + bits_CAP_RANGE_ATTACK1 = (1 << 11), // can do a range attack 1 + bits_CAP_RANGE_ATTACK2 = (1 << 12), // can do a range attack 2 + bits_CAP_MELEE_ATTACK1 = (1 << 13), // can do a melee attack 1 + bits_CAP_MELEE_ATTACK2 = (1 << 14), // can do a melee attack 2 + bits_CAP_FLY = (1 << 15), // can fly, move all around + bits_CAP_DOORS_GROUP = (bits_CAP_USE | bits_CAP_AUTO_DOORS | bits_CAP_OPEN_DOORS) +}; // used by suit voice to indicate damage sustained and repaired type to player // instant damage - -#define DMG_GENERIC 0 // generic damage was done -#define DMG_CRUSH (1 << 0) // crushed by falling or moving object -#define DMG_BULLET (1 << 1) // shot -#define DMG_SLASH (1 << 2) // cut, clawed, stabbed -#define DMG_BURN (1 << 3) // heat burned -#define DMG_FREEZE (1 << 4) // frozen -#define DMG_FALL (1 << 5) // fell too far -#define DMG_BLAST (1 << 6) // explosive blast damage -#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt -#define DMG_SHOCK (1 << 8) // electric shock -#define DMG_SONIC (1 << 9) // sound pulse shockwave -#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam -#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death -#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. -#define DMG_DROWN (1 << 14) // Drowning -// time-based damage -#define DMG_TIMEBASED (~(0x3fff)) // mask for time-based damage - -#define DMG_PARALYZE (1 << 15) // slows affected creature down -#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad -#define DMG_POISON (1 << 17) // blood poisioning -#define DMG_RADIATION (1 << 18) // radiation exposure -#define DMG_DROWNRECOVER (1 << 19) // drowning recovery -#define DMG_ACID (1 << 20) // toxic chemicals or acid burns -#define DMG_SLOWBURN (1 << 21) // in an oven -#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer -#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar) -//Master Sword -- -#define DMG_NOKILL (1 << 24) // (Dogg) This damage cannot kill you (fists reflective damage...) -#define DMG_SIMPLEBBOX (1 << 25) // (Dogg) Use a simple BBox for tracelines -#define DMG_DIRECT (1 << 26) // (Dogg) Ignore the traceline and just do damage to the target -#define DMG_REFLECTIVE (1 << 27) // (Dogg) This damage can hurt you -#define DMG_AOE (1 << 28) // (Dogg) Area of Effect Damage -#define DMG_NONE (1 << 29) // (Dogg) Find a target, but don't damage it -#define DMG_NOSKIN (1 << 30) // (Dogg) This damage won't skin creatures (arrows, fireball, etc.) -#define DMG_MARTIALARTS (1 << 31) // (Dogg) Martial arts attack (punch, kick, jumpkick...) -//--------------- -// these are the damage types that are allowed to gib corpses -#define DMG_GIB_CORPSE (DMG_CRUSH | DMG_FALL | DMG_BLAST | DMG_SONIC | DMG_CLUB) - -// these are the damage types that have client hud art -#define DMG_SHOWNHUD (DMG_POISON | DMG_ACID | DMG_FREEZE | DMG_SLOWFREEZE | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK) - + +enum { + DMG_GENERIC = (0 << 0), // generic damage was done + DMG_CRUSH = (1 << 0), // crushed by falling or moving object + DMG_BULLET = (1 << 1), // shot + DMG_SLASH = (1 << 2), // cut, clawed, stabbed + DMG_BURN = (1 << 3), // heat burned + DMG_FREEZE = (1 << 4), // frozen + DMG_FALL = (1 << 5), // fell too far + DMG_BLAST = (1 << 6), // explosive blast damage + DMG_CLUB = (1 << 7), // crowbar, punch, headbutt + DMG_SHOCK = (1 << 8), // electric shock + DMG_SONIC = (1 << 9), // sound pulse shockwave + DMG_ENERGYBEAM = (1 << 10), // laser or other high energy beam + DMG_NEVERGIB = (1 << 12), // with this bit OR'd in, no damage type will be able to gib victims upon death + DMG_ALWAYSGIB = (1 << 13), // with this bit OR'd in, any damage type can be made to gib victims upon death. + DMG_DROWN = (1 << 14), // Drowning + DMG_TIMEBASED = (~(0x3fff)), // mask for time-based damage + DMG_PARALYZE = (1 << 15), // slows affected creature down + DMG_NERVEGAS = (1 << 16), // nerve toxins, very bad + DMG_POISON = (1 << 17), // blood poisioning + DMG_RADIATION = (1 << 18), // radiation exposure + DMG_DROWNRECOVER = (1 << 19), // drowning recovery + DMG_ACID = (1 << 20), // toxic chemicals or acid burns + DMG_SLOWBURN = (1 << 21), // in an oven + DMG_SLOWFREEZE = (1 << 22), // in a subzero freezer + DMG_MORTAR = (1 << 23), // Hit by air raid (done to distinguish grenade from mortar) + DMG_CALTROP = (1 << 30), + DMG_HALLUC = (1 << 31), + DMG_TRANQ = DMG_MORTAR, + DMG_CONCUSS = DMG_SONIC, + //Master Sword -- + DMG_NOKILL = (1 << 24), // (Dogg) This damage cannot kill you (fists reflective damage...) + DMG_SIMPLEBBOX = (1 << 25), // (Dogg) Use a simple BBox for tracelines + DMG_DIRECT = (1 << 26), // (Dogg) Ignore the traceline and just do damage to the target + DMG_REFLECTIVE = (1 << 27), // (Dogg) This damage can hurt you + DMG_AOE = (1 << 28), // (Dogg) Area of Effect Damage + DMG_NONE = (1 << 29), // (Dogg) Find a target, but don't damage it + DMG_NOSKIN = (1 << 30), // (Dogg) This damage won't skin creatures (arrows, fireball, etc.) + DMG_MARTIALARTS = (1 << 31), // (Dogg) Martial arts attack (punch, kick, jumpkick...) + //--------------- + // these are the damage types that are allowed to gib corpses + DMG_GIB_CORPSE = (DMG_CRUSH | DMG_FALL | DMG_BLAST | DMG_SONIC | DMG_CLUB), + // these are the damage types that have client hud art + DMG_SHOWNHUD = (DMG_POISON | DMG_ACID | DMG_FREEZE | DMG_SLOWFREEZE | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK) +}; // NOTE: tweak these values based on gameplay feedback: -#define PARALYZE_DURATION 2 // number of 2 second intervals to take damage -#define PARALYZE_DAMAGE 1.0 // damage to take each 2 second interval +constexpr int PARALYZE_DURATION = 2; // number of 2 second intervals to take damage +constexpr float PARALYZE_DAMAGE = 1.0;// damage to take each 2 second interval -#define NERVEGAS_DURATION 2 -#define NERVEGAS_DAMAGE 5.0 +constexpr int NERVEGAS_DURATION = 2; +constexpr float NERVEGAS_DAMAGE = 5.0; -#define POISON_DURATION 5 -#define POISON_DAMAGE 2.0 +constexpr int POISON_DURATION = 5; +constexpr float POISON_DAMAGE = 2.0; -#define RADIATION_DURATION 2 -#define RADIATION_DAMAGE 1.0 +constexpr int RADIATION_DURATION = 2; +constexpr float RADIATION_DAMAGE = 1.0; -#define ACID_DURATION 2 -#define ACID_DAMAGE 5.0 +constexpr int ACID_DURATION = 2; +constexpr float ACID_DAMAGE = 5.0; -#define SLOWBURN_DURATION 2 -#define SLOWBURN_DAMAGE 1.0 +constexpr int SLOWBURN_DURATION = 2; +constexpr float SLOWBURN_DAMAGE = 1.0; -#define SLOWFREEZE_DURATION 2 -#define SLOWFREEZE_DAMAGE 1.0 +constexpr int SLOWFREEZE_DURATION = 2; +constexpr float SLOWFREEZE_DAMAGE = 1.0; -#define itbd_Paralyze 0 -#define itbd_NerveGas 1 -#define itbd_Poison 2 -#define itbd_Radiation 3 -#define itbd_DrownRecover 4 -#define itbd_Acid 5 -#define itbd_SlowBurn 6 -#define itbd_SlowFreeze 7 -#define CDMG_TIMEBASED 8 +enum { + itbd_Paralyze = 0, + itbd_NerveGas = 1, + itbd_Poison = 2, + itbd_Radiation = 3, + itbd_DrownRecover = 4, + itbd_Acid = 5, + itbd_SlowBurn = 6, + itbd_SlowFreeze = 7, + CDMG_TIMEBASED = 8 +}; // when calling KILLED(), a value that governs gib behavior is expected to be // one of these three values From b18cd736c2efadce705e2224d5553862d392d48d Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:22:18 -0400 Subject: [PATCH 053/291] Changes defines to enums and constexpr where appropriate --- src/game/server/msitemdefs.h | 91 ++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/src/game/server/msitemdefs.h b/src/game/server/msitemdefs.h index f9b3d963..a1a3e736 100644 --- a/src/game/server/msitemdefs.h +++ b/src/game/server/msitemdefs.h @@ -7,7 +7,7 @@ //#define DG_WEAPONBEAMS //Show weapon tracelines //Expiretime was 60, upped -#define MSITEM_TIME_EXPIRE 120 //Time until an item on the ground disappears +constexpr int MSITEM_TIME_EXPIRE = 120; //Time until an item on the ground disappears enum item_flags { @@ -51,61 +51,74 @@ enum //MS-Specifiv client-side effects for studio-model-based entities, sent through pev->playerclass //Don't use for brush models because the engine uses playerclass on brushes to specify that it can be decaled -#define ENT_EFFECT_FOLLOW_ROTATE (1 << 0) //An entity that follows another on the client. Rotates with the host entity. pev->basevelocity.x specifies distance out from the host -#define ENT_EFFECT_FOLLOW_ALIGN_BOTTOM (1 << 1) //The follow entity is aligned to the bottom of the host's bounding box (in players, the bottom is 36 units lower) -//#define ENT_EFFECT_FOLLOW_FACE_HOST (1<<2) //The follow entity always faces the host (pitch ignored) +enum { + ENT_EFFECT_FOLLOW_ROTATE = (1 << 0), //An entity that follows another on the client. Rotates with the host entity. pev->basevelocity.x specifies distance out from the host + ENT_EFFECT_FOLLOW_ALIGN_BOTTOM = (1 << 1)//The follow entity is aligned to the bottom of the host's bounding box (in players, the bottom is 36 units lower) + //ENT_EFFECT_FOLLOW_FACE_HOST = (1<<2) //The follow entity always faces the host (pitch ignored) +}; // ***** Player ***** -#define PLAYER_GIB_HEATH -40 + +constexpr int PLAYER_GIB_HEATH = -40; //These are for CBasePlayer::MoreBTNSDown -#define BTN_SPECIAL (IN_SCORE * 2) -#define BTN_ATTACKLEFT (BTN_SPECIAL * 2) -#define BTN_ATTACKRIGHT (BTN_ATTACKLEFT * 2) + +enum { + BTN_SPECIAL = (IN_SCORE * 2), + BTN_ATTACKLEFT = (BTN_SPECIAL * 2), + BTN_ATTACKRIGHT = (BTN_ATTACKLEFT * 2) +}; //These are for CBasePlayer::m_StatusFlags -#define PLAYER_MOVE_RUNNING (1 << 0) -#define PLAYER_MOVE_ATTACKING (1 << 1) -#define PLAYER_MOVE_JUMPING (1 << 2) -#define PLAYER_MOVE_SWIMMING (1 << 3) //Set by script.. really just an indicator for the client that it should rotate the model by pitch -#define PLAYER_MOVE_NORUN (1 << 3) -#define PLAYER_MOVE_NOJUMP (1 << 4) -#define PLAYER_MOVE_NODUCK (1 << 5) -#define PLAYER_MOVE_NOATTACK (1 << 6) -#define PLAYER_MOVE_NOMOVE (1 << 7) -#define PLAYER_MOVE_SITTING (1 << 8) //JAN2010_09 Thothie - Attempting to allow inventory access while sittin again -#define PLAYER_MOVE_STOPRUN (1 << 9) +enum { + PLAYER_MOVE_RUNNING = (1 << 0), + PLAYER_MOVE_ATTACKING = (1 << 1), + PLAYER_MOVE_JUMPING = (1 << 2), + PLAYER_MOVE_SWIMMING = (1 << 3) ,//Set by script.. really just an indicator for the client that it should rotate the model by pitch + PLAYER_MOVE_NORUN = (1 << 3), + PLAYER_MOVE_NOJUMP = (1 << 4), + PLAYER_MOVE_NODUCK = (1 << 5), + PLAYER_MOVE_NOATTACK = (1 << 6), + PLAYER_MOVE_NOMOVE = (1 << 7), + PLAYER_MOVE_SITTING = (1 << 8), //JAN2010_09 Thothie - Attempting to allow inventory access while sittin again + PLAYER_MOVE_STOPRUN = (1 << 9) +}; //#define PLAYER_MOVE_SPECTATE (1<<3) //#define PLAYER_MOVE_SPECTATE_MOVE (1<<4) -//#define PLAYER_MOVE_STUNNED (1<<3) +//#define PLAYER_MOVE_STUNNED (1<<3) //***** Item properties ***** -#define ITEM_WEARABLE (1 << 0) -#define ITEM_SHIELD (1 << 1) -#define ITEM_ARMOR (1 << 2) -#define ITEM_GENERIC (1 << 3) -#define ITEM_GROUPABLE (1 << 4) -#define ITEM_CONTAINER (1 << 5) -#define ITEM_PROJECTILE (1 << 6) -#define ITEM_DRINKABLE (1 << 7) -#define ITEM_PERISHABLE (1 << 8) -#define ITEM_SPELL (1 << 9) -#define ITEM_NOPICKUP (1 << 15) //MIB FEB2010_13 [thothie: 1<<10 is taken below - switched to 1<<15] + +enum { + ITEM_WEARABLE = (1 << 0), + ITEM_SHIELD = (1 << 1), + ITEM_ARMOR = (1 << 2), + ITEM_GENERIC = (1 << 3), + ITEM_GROUPABLE = (1 << 4), + ITEM_CONTAINER = (1 << 5), + ITEM_PROJECTILE = (1 << 6), + ITEM_DRINKABLE = (1 << 7), + ITEM_PERISHABLE = (1 << 8), + ITEM_SPELL = (1 << 9), + ITEM_NOPICKUP = (1 << 15) //MIB FEB2010_13 [thothie: 1<<10 is taken below - switched to 1<<15] +}; //***** Others ***** -#define ENT_BODYPART (1 << 10) -#define MS_NPC (1 << 11) -#define MS_PLAYER (1 << 12) -#define MS_CORPSE (1 << 13) -#define MS_SHIELD (1 << 14) +enum { + MS_BODYPART = (1 << 10), + MS_NPC = (1 << 11), + MS_PLAYER = (1 << 12), + MS_CORPSE = (1 << 13), + MS_SHIELD = (1 << 14) +}; //Shield Sounds -#define SOUND_IRONSHIELD_HIT1 "weapons/cbar_hit1.wav" //global sounds -#define SOUND_IRONSHIELD_HIT2 "weapons/cbar_hit2.wav" +constexpr const char* SOUND_IRONSHIELD_HIT1 = "weapons/cbar_hit1.wav"; //global sounds +constexpr const char* SOUND_IRONSHIELD_HIT2 = "weapons/cbar_hit2.wav"; //Corpse -#define CLASS_CORPSE "corpse" +constexpr const char* CLASS_CORPSE = "corpse"; #endif //MSITEMDEFS \ No newline at end of file From 12e30ae7a26ffea60fa9303fde97e90495ec81c2 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:27:16 -0400 Subject: [PATCH 054/291] Changes macro define to enum --- src/common/engine_launcher_api.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/engine_launcher_api.h b/src/common/engine_launcher_api.h index 59bc7563..fa568d00 100644 --- a/src/common/engine_launcher_api.h +++ b/src/common/engine_launcher_api.h @@ -14,9 +14,12 @@ //typedef void ( *xcommand_t ) ( void ); -constexpr int RENDERTYPE_UNDEFINED = 0; -constexpr int RENDERTYPE_SOFTWARE = 1; -constexpr int RENDERTYPE_HARDWARE = 2; +enum { + RENDERTYPE_UNDEFINED = 0, + RENDERTYPE_SOFTWARE = 1, + RENDERTYPE_HARDWARE = 2 +}; + constexpr int ENGINE_LAUNCHER_API_VERSION = 1; From e65d0435978d7ca09ae74065783bf5c5e1fea462 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:32:28 -0400 Subject: [PATCH 055/291] Changed macros to constexpr/enums --- src/game/client/hud.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/game/client/hud.h b/src/game/client/hud.h index 225ef6c4..8b50ecee 100644 --- a/src/game/client/hud.h +++ b/src/game/client/hud.h @@ -73,12 +73,13 @@ typedef struct typedef struct cvar_s cvar_t; -#define HUD_ACTIVE 1 -#define HUD_INTERMISSION 2 - -#define MAX_PLAYER_NAME_LENGTH 32 +enum { + HUD_ACTIVE = 1, + HUD_INTERMISSION = 2 +}; -#define MAX_MOTD_LENGTH 1024 +constexpr int MAX_PLAYER_NAME_LENGTH = 32; +constexpr int MAX_MOTD_LENGTH = 1024; // Master Sword //----------------------------------------------------- @@ -99,7 +100,7 @@ typedef int BOOL; #endif //Moved here from CHudStatusIcons -#define MAX_SPRITE_NAME_LENGTH 24 +constexpr int MAX_SPRITE_NAME_LENGTH = 24; typedef struct { @@ -150,7 +151,7 @@ class CHudAmmoSecondary : public CHudBase float m_fFade; }; -#define FADE_TIME 100 +constexpr int FADE_TIME = 100; // //----------------------------------------------------- @@ -255,7 +256,7 @@ class CHudSayText : public CHudBase // //----------------------------------------------------- // -const int maxHUDMessages = 16; +constexpr int maxHUDMessages = 16; struct message_parms_t { client_textmessage_t *pMessage; From 67d02992b1982cce62a4558913c1e37964633af3 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:34:03 -0400 Subject: [PATCH 056/291] Removed commented logic --- src/game/client/ms/hudmagic.cpp | 42 ++------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/src/game/client/ms/hudmagic.cpp b/src/game/client/ms/hudmagic.cpp index c39a77f9..6220f49a 100644 --- a/src/game/client/ms/hudmagic.cpp +++ b/src/game/client/ms/hudmagic.cpp @@ -25,15 +25,13 @@ void CHudMagic_SelectMenuItem(int menu_item, TCallbackMenu *pcbMenu); MS_DECLARE_MESSAGE(m_Magic, Spells); -//MS_DECLARE_COMMAND( m_Magic, ListSpells ); + int CHudMagic::Init(void) { gHUD.AddHudElem(this); HOOK_MESSAGE(Spells); - //HOOK_COMMAND("listspells", ListSpells); - Reset(); return 1; @@ -64,48 +62,12 @@ void CHudMagic::Think() int CHudMagic::MsgFunc_Spells(const char *pszName, int iSize, void *pbuf) { BEGIN_READ(pbuf, iSize); - - /*short Spells = READ_SHORT( ); //The number of spells have I memorized - short VerboseIdx = READ_SHORT( ); //If Verbose: Which spell was learned (incremented by 1 | 0 = Non-verbose) - - bool Verbose = VerboseIdx ? true : false; - if( Verbose ) VerboseIdx--; //The index is offset by 1, so that 0 == Non-verbose - - player.m_SpellList.clear(); - for (int s = 0; s < Spells; s++) - player.LearnSpell( READ_STRING(), (Verbose && (VerboseIdx == s)) ? true : false ); //Spell scriptname*/ - - bool Verbose = READ_BYTE() == 1; + bool Verbose = (READ_BYTE() == 1); player.LearnSpell(READ_STRING(), Verbose); return 1; } -/*void CHudMagic::UserCmd_ListSpells(void) -{ - if( gHUD.m_Menu->HideMyMenu( MENU_LISTSPELLS ) ) return; - - //Disallow choosing spells by unsetting HUD_ACTIVE - if( !FBitSet(m_iFlags,HUD_ACTIVE) ) - return; - int iBitsValid = 0; - char MenuText[1024]; - //Activate - if( !SpellsMemorized() ) return; - strncpy(MenuText, "Cast spell:\n\n", sizeof(MenuText) ); - spellgroup_v &SpellList = player.m_SpellList; - for (int n = 0; n < SpellList.size(); n++) - { - CGenericItem *pItem = NewGenericItem( SpellList[n] ); - if( pItem ) - strcat( MenuText, UTIL_VarArgs("%i. %s\n", n+1, pItem->DisplayName() ) ); - else - strcat( MenuText, UTIL_VarArgs("%i. %s\n", n+1, SpellList[n].c_str() ) ); - iBitsValid += pow(2,n); - SpellMenuIndex[n] = n; - } - gHUD.m_Menu->ShowMenu( iBitsValid, MenuText, CHudMagic_SelectMenuItem, MENU_LISTSPELLS ); -}*/ void CHudMagic_SelectMenuItem(int idx, TCallbackMenu *pcbMenu) { if (!gHUD.m_Magic) From 56dddf61c28ec601a78bc40f7212bcf9e9f5db34 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 20:12:06 -0400 Subject: [PATCH 057/291] Fixed warninng on sign mismatch. Fixed wasrning on unintialized variables. Templated clrmem() macro --- src/game/shared/ms/netcodeshared.cpp | 4 ++-- src/game/shared/ms/stackstring.h | 10 +++++++++- src/game/shared/stats/races.cpp | 4 ++-- src/game/shared/stats/stats.cpp | 6 +++--- src/game/shared/stats/stats.h | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/game/shared/ms/netcodeshared.cpp b/src/game/shared/ms/netcodeshared.cpp index cac8a58d..79cd4d1f 100644 --- a/src/game/shared/ms/netcodeshared.cpp +++ b/src/game/shared/ms/netcodeshared.cpp @@ -51,7 +51,7 @@ void CBasePlayer::SendChar(charinfo_base_t &CharBase) WRITE_LONG(SendInfo.DataLen); MESSAGE_END(); - hudtextparms_t htp; + hudtextparms_t htp = {}; clrmem(htp); htp.x = 0.02; htp.y = 0.6; @@ -143,7 +143,7 @@ void MSChar_Interface::Think_SendChar(CBasePlayer *pPlayer) SendInfo.Status = CSS_DORMANT; #ifdef VALVE_DLL - hudtextparms_t htp; + hudtextparms_t htp = {}; clrmem(htp); htp.x = 0.02; htp.y = 0.6; diff --git a/src/game/shared/ms/stackstring.h b/src/game/shared/ms/stackstring.h index a9e5377f..c9c10ddd 100644 --- a/src/game/shared/ms/stackstring.h +++ b/src/game/shared/ms/stackstring.h @@ -27,7 +27,15 @@ extern "C" char *strlwr(char *str); #include "strhelper.h" -#define clrmem(a) memset(&a, 0, sizeof(a)); + +//what a mess + +//#define clrmem(a) memset(&a, 0, sizeof(a)); + +template +void clrmem(T type) { + memset(&type, 0, sizeof(type)); +}; //Deuplicated from msdebug.h #ifdef DEV_BUILD diff --git a/src/game/shared/stats/races.cpp b/src/game/shared/stats/races.cpp index ad6f0c75..623c814f 100644 --- a/src/game/shared/stats/races.cpp +++ b/src/game/shared/stats/races.cpp @@ -20,7 +20,7 @@ race_t *CRaceManager::GetRacePtr(const char* pszName) if (!pszName || strlen(pszName) < 1) //Null or empty string return NULL; - for (int r = 0; r < Races.size(); r++) + for (unsigned int r = 0; r < Races.size(); r++) { race_t &Race = Races[r]; if (!_stricmp(Race.Name, pszName)) @@ -30,7 +30,7 @@ race_t *CRaceManager::GetRacePtr(const char* pszName) } bool CRaceManager::RelationshipContains(msstringlist &RaceList, const char* pszTargetRace) { - for (int i = 0; i < RaceList.size(); i++) + for (unsigned int i = 0; i < RaceList.size(); i++) { const char* pszRaceName = RaceList[i]; diff --git a/src/game/shared/stats/stats.cpp b/src/game/shared/stats/stats.cpp index 0bd13b6e..ef51710e 100644 --- a/src/game/shared/stats/stats.cpp +++ b/src/game/shared/stats/stats.cpp @@ -189,7 +189,7 @@ void CStat::Update() // Updates the stat to current - no updates sent { bNeedsUpdate = false; - for (int i = 0; i < m_SubStats.size(); i++) + for (unsigned int i = 0; i < m_SubStats.size(); i++) { m_SubStats[i].OldValue = m_SubStats[i].Value; m_SubStats[i].OldExp = m_SubStats[i].Exp; @@ -202,7 +202,7 @@ bool CStat::Changed() return true; // If any values changed -> update. - for (int i = 0; i < m_SubStats.size(); i++) + for (unsigned int i = 0; i < m_SubStats.size(); i++) if ((m_SubStats[i].Exp != m_SubStats[i].OldExp) || (m_SubStats[i].Value != m_SubStats[i].OldValue)) return true; @@ -212,7 +212,7 @@ bool CStat::Changed() bool CStat::operator!=(const CStat& Other) { // Just check the substats - for (int i = 0; i < m_SubStats.size(); i++) + for (unsigned int i = 0; i < m_SubStats.size(); i++) { if (i >= (signed)Other.m_SubStats.size()) break; diff --git a/src/game/shared/stats/stats.h b/src/game/shared/stats/stats.h index 2f5a2c4c..ca9d29ae 100644 --- a/src/game/shared/stats/stats.h +++ b/src/game/shared/stats/stats.h @@ -65,7 +65,7 @@ class CStat CSubStat* GetSubStat(int index) { - if ((index < 0) || (index >= m_SubStats.size())) + if ((index < 0) || (static_cast(index) >= m_SubStats.size())) return NULL; return &m_SubStats[index]; } From 9fa0a99ed7c8110ae84780c75196480564aae2c1 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Sun, 8 Mar 2026 21:47:34 -0400 Subject: [PATCH 058/291] Fixed pass by reference not in template --- src/game/shared/ms/stackstring.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/shared/ms/stackstring.h b/src/game/shared/ms/stackstring.h index c9c10ddd..bae4f0f6 100644 --- a/src/game/shared/ms/stackstring.h +++ b/src/game/shared/ms/stackstring.h @@ -32,8 +32,9 @@ extern "C" char *strlwr(char *str); //#define clrmem(a) memset(&a, 0, sizeof(a)); + template -void clrmem(T type) { +void clrmem(T& type) { memset(&type, 0, sizeof(type)); }; From 2aa27c7a5cd41892bd8066d7a16107c302e44861 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 22:15:20 -0400 Subject: [PATCH 059/291] changed define to constexpr. moved include to top of file. --- src/game/client/ms/menu.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/client/ms/menu.h b/src/game/client/ms/menu.h index 014a9ddb..f04263d2 100644 --- a/src/game/client/ms/menu.h +++ b/src/game/client/ms/menu.h @@ -1,5 +1,7 @@ //Master Sword -#define MAX_MENU_STRING 512 +#include "sharedmenu.h" + +constexpr int MAX_MENU_STRING = 512; enum MenuType { //menutypes @@ -11,7 +13,7 @@ enum MenuType MENU_DYNAMICNPC, }; //------------ -#include "sharedmenu.h" + class CHudMenu : public CHudBase { public: From 580655e2bdfd38b98c58003eeba62016434e386c Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 22:16:40 -0400 Subject: [PATCH 060/291] Changed enum to reference enum name. --- src/game/client/ms/menu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/ms/menu.h b/src/game/client/ms/menu.h index f04263d2..cc6bf7d2 100644 --- a/src/game/client/ms/menu.h +++ b/src/game/client/ms/menu.h @@ -35,7 +35,7 @@ class CHudMenu : public CHudBase //Master Sword TCallbackMenu m; - int ShowMenu(int bitsValidSlots, const char *pszMenuString, MenuCallback CallBack, MenuType mtMenuType = MENU_NORMAL, float ShutOffTime = 0); + int ShowMenu(int bitsValidSlots, const char *pszMenuString, MenuCallback CallBack, MenuType mtMenuType = MenuType::MENU_NORMAL, float ShutOffTime = 0); bool HideMyMenu(int mtMenuType); //------------ }; From f7acd222dce05e4e3f3865c88938fe230c52917d Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 22:18:31 -0400 Subject: [PATCH 061/291] removed unneded define with menu.h include. --- src/game/client/ms/menu.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/game/client/ms/menu.cpp b/src/game/client/ms/menu.cpp index e0bfccd0..6231f2e6 100644 --- a/src/game/client/ms/menu.cpp +++ b/src/game/client/ms/menu.cpp @@ -35,7 +35,6 @@ #include "action.h" #include "menu.h" -#define MAX_MENU_STRING 512 //char m.cMenuText[MAX_MENU_STRING]; char g_szPrelocalisedMenuString[MAX_MENU_STRING]; From 0255cea265cea78e2b3e95182b74949cbc5f6117 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:30:12 -0400 Subject: [PATCH 062/291] Converted macros to wrapper functions. --- src/game/client/ms/hudscript.cpp | 87 +++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 6 deletions(-) diff --git a/src/game/client/ms/hudscript.cpp b/src/game/client/ms/hudscript.cpp index cc667a5d..20e48f30 100644 --- a/src/game/client/ms/hudscript.cpp +++ b/src/game/client/ms/hudscript.cpp @@ -31,6 +31,81 @@ extern physent_t *MSUTIL_EntityByIndex( int playerindex ); + +static void SCRIPT_CONTROLVEC_POS(CScript* Script, const char* name, Vector& vec) { + + const char* ofsX = "_ofs.x"; + const char* ofsY = "_ofs.y"; + const char* ofsZ = "_ofs.z"; + const char* setX = "_set.x"; + const char* setY = "_set.y"; + const char* setZ = "_set.z"; + + std::string ScriptVarNameX = name; ScriptVarNameX += ofsX; + std::string ScriptVarNameY = name; ScriptVarNameY += ofsY; + std::string ScriptVarNameZ = name; ScriptVarNameZ += ofsZ; + + std::string ScriptVarSetNameX = {name}; ScriptVarSetNameX += setX; + std::string ScriptVarSetNameY = {name}; ScriptVarSetNameY += setY; + std::string ScriptVarSetNameZ = {name}; ScriptVarSetNameZ += setZ; + + if (Script->VarExists(ScriptVarNameX.c_str())) vec.x += atof(Script->GetVar(ScriptVarNameX.c_str())); + if (Script->VarExists(ScriptVarNameY.c_str())) vec.y += atof(Script->GetVar(ScriptVarNameY.c_str())); + if (Script->VarExists(ScriptVarNameZ.c_str())) vec.z += atof(Script->GetVar(ScriptVarNameZ.c_str())); + if (Script->VarExists(ScriptVarSetNameX.c_str())) vec.x += atof(Script->GetVar(ScriptVarNameX.c_str())); + if (Script->VarExists(ScriptVarSetNameY.c_str())) vec.y += atof(Script->GetVar(ScriptVarNameY.c_str())); + if (Script->VarExists(ScriptVarSetNameZ.c_str())) vec.z += atof(Script->GetVar(ScriptVarNameZ.c_str())); + + +}; + +static void SCRIPT_CONTROLVEC_ANG(CScript* Script, const char* name, Vector& vec) { + + const char* ofsPitch = "_ofs.pitch"; + const char* ofsYaw = "_ofs.yaw"; + const char* ofsRoll = "_ofs.roll"; + const char* setPitch = "_set.pitch"; + const char* setYaw = "_set.yaw"; + const char* setRoll = "_set.roll"; + + std::string ScriptVarPitch = { name }; ScriptVarPitch += ofsPitch; + std::string ScriptVarYaw = {name}; ScriptVarYaw += ofsYaw; + std::string ScriptVarRoll = {name}; ScriptVarRoll += ofsRoll; + + std::string ScriptVarSetPitch = {name}; ScriptVarSetPitch += setPitch; + std::string ScriptVarSetYaw = {name}; ScriptVarSetYaw += setYaw; + std::string ScriptVarSetRoll = {name}; ScriptVarSetRoll += setRoll; + + if (Script->VarExists(ScriptVarPitch.c_str())) vec.x += atof(Script->GetVar(ScriptVarPitch.c_str())); + if (Script->VarExists(ScriptVarYaw.c_str())) vec.y += atof(Script->GetVar(ScriptVarYaw.c_str())); + if (Script->VarExists(ScriptVarRoll.c_str())) vec.z += atof(Script->GetVar(ScriptVarRoll.c_str())); + if (Script->VarExists(ScriptVarSetPitch.c_str())) vec.x = atof(Script->GetVar(ScriptVarSetPitch.c_str())); + if (Script->VarExists(ScriptVarSetYaw.c_str())) vec.y = atof(Script->GetVar(ScriptVarSetYaw.c_str())); + if (Script->VarExists(ScriptVarSetRoll.c_str())) vec.z = atof(Script->GetVar(ScriptVarSetRoll.c_str())); +}; + +static void SCRIPT_CONTROLVEC_POS_CUSTOM(CScript* Script, const char* name, Vector& vec, const char* xname, const char* yname, const char* zname) { + + const char* ofs = "_ofs."; + const char* set = "_set."; + + std::string ScriptVarCustomXOffset{ name }; ScriptVarCustomXOffset += ofs; ScriptVarCustomXOffset += xname; + std::string ScriptVarCustomYOffset{ name }; ScriptVarCustomYOffset += ofs; ScriptVarCustomYOffset += yname; + std::string ScriptVarCustomZOffset{ name }; ScriptVarCustomZOffset += ofs; ScriptVarCustomZOffset += zname; + + std::string ScriptVarCustomXSet{ name }; ScriptVarCustomXSet += set; ScriptVarCustomXSet += xname; + std::string ScriptVarCustomYSet{ name }; ScriptVarCustomYSet += set; ScriptVarCustomYSet += yname; + std::string ScriptVarCustomZSet{ name }; ScriptVarCustomZSet += set; ScriptVarCustomZSet += zname; + + if (Script->VarExists(ScriptVarCustomXOffset.c_str())) vec.x += atof(Script->GetVar(ScriptVarCustomXOffset.c_str())); + if (Script->VarExists(ScriptVarCustomYOffset.c_str())) vec.x += atof(Script->GetVar(ScriptVarCustomYOffset.c_str())); + if (Script->VarExists(ScriptVarCustomZOffset.c_str())) vec.x += atof(Script->GetVar(ScriptVarCustomZOffset.c_str())); + if (Script->VarExists(ScriptVarCustomXSet.c_str())) vec.x += atof(Script->GetVar(ScriptVarCustomXSet.c_str())); + if (Script->VarExists(ScriptVarCustomYSet.c_str())) vec.x += atof(Script->GetVar(ScriptVarCustomYSet.c_str())); + if (Script->VarExists(ScriptVarCustomZSet.c_str())) vec.x += atof(Script->GetVar(ScriptVarCustomZSet.c_str())); + +}; +/* #define SCRIPT_CONTROLVEC_POS( name, vec ) \ if( Script->VarExists( name "_ofs.x" ) ) vec.x += atof(Script->GetVar( name "_ofs.x" )); \ if( Script->VarExists( name "_ofs.y" ) ) vec.y += atof(Script->GetVar( name "_ofs.y" )); \ @@ -54,10 +129,10 @@ extern physent_t *MSUTIL_EntityByIndex( int playerindex ); if( Script->VarExists( name "_set." xname ) ) vec.x = atof(Script->GetVar( name "_set." xname )); \ if( Script->VarExists( name "_set." yname ) ) vec.y = atof(Script->GetVar( name "_set." yname )); \ if( Script->VarExists( name "_set." zname ) ) vec.z = atof(Script->GetVar( name "_set." zname )); - +\ +*/ //---------------- -#include "hudscript.h" int CHudScript::Init( void ) { @@ -213,10 +288,10 @@ void CHudScript::Effects_GetView( ref_params_s *pparams, cl_entity_t *ViewModel Vector &ViewAng = *(Vector *)&pparams->viewangles; Vector &ViewMdlOfs = *(Vector *)&ViewModel->origin; Vector &ViewMdlAng = *(Vector *)&ViewModel->angles; - SCRIPT_CONTROLVEC_POS( "game.cleffect.view", ViewOfs ); - SCRIPT_CONTROLVEC_ANG( "game.cleffect.view", ViewAng ); - SCRIPT_CONTROLVEC_POS( "game.cleffect.viewmodel", ViewMdlOfs ); - SCRIPT_CONTROLVEC_ANG( "game.cleffect.viewmodel", ViewMdlAng ); + SCRIPT_CONTROLVEC_POS(Script, "game.cleffect.view", ViewOfs ); + SCRIPT_CONTROLVEC_ANG(Script, "game.cleffect.view", ViewAng ); + SCRIPT_CONTROLVEC_POS(Script, "game.cleffect.viewmodel", ViewMdlOfs ); + SCRIPT_CONTROLVEC_ANG(Script, "game.cleffect.viewmodel", ViewMdlAng ); } } Vector CHudScript::Effects_GetMoveScale( ) From 4d4e42363ae309cb32a0722495df30cb563c7663 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:30:33 -0400 Subject: [PATCH 063/291] templated clrmem macro into function. --- src/game/shared/ms/stackstring.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/game/shared/ms/stackstring.h b/src/game/shared/ms/stackstring.h index bae4f0f6..11aa17f2 100644 --- a/src/game/shared/ms/stackstring.h +++ b/src/game/shared/ms/stackstring.h @@ -27,14 +27,10 @@ extern "C" char *strlwr(char *str); #include "strhelper.h" - -//what a mess - //#define clrmem(a) memset(&a, 0, sizeof(a)); - -template -void clrmem(T& type) { +template +inline void clrmem(Type& type) { memset(&type, 0, sizeof(type)); }; From 6d4d87e6add2025a3fdbc8aceb3cd2f4bdcb288a Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:38:03 -0400 Subject: [PATCH 064/291] Reworked IS_NAN function. thanks copilot for type safety. --- src/common/mathlib.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/common/mathlib.h b/src/common/mathlib.h index 522e6d04..1b6eae27 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -37,16 +37,12 @@ struct mplane_s; extern Vector vec3_origin; constexpr int nanmask = 255 << 23; -inline bool IS_NAN(const float &x) { +static inline bool IS_NAN(float flVelocity) { - if ((((*(int*)&x) & nanmask) == nanmask)) { - return true; - } - else { - return false; - } -}; + int i = *(int*)&flVelocity; + return (i & 0x7F800000) == 0x7F800000 && (i & 0x007FFFFF) != 0; +}; inline void VectorSubtract(const float* a, const float* b, float* c) { From c65fd646eb53acaf23db875f173700a8746e2230 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:47:19 -0400 Subject: [PATCH 065/291] Added nanmask to reworkedd IS_NAN --- src/common/mathlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/mathlib.h b/src/common/mathlib.h index 1b6eae27..3e289b93 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -40,7 +40,7 @@ constexpr int nanmask = 255 << 23; static inline bool IS_NAN(float flVelocity) { int i = *(int*)&flVelocity; - return (i & 0x7F800000) == 0x7F800000 && (i & 0x007FFFFF) != 0; + return (i & nanmask) == 0x7F800000 && (i & 0x007FFFFF) != 0; }; From ba0c4bb2f2ecb6f0b3521d903b6e20226dab64a7 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:57:50 -0400 Subject: [PATCH 066/291] Changed defines to enums/constexpr --- src/game/client/render/clrender.h | 102 +++++++++++++++++------------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/src/game/client/render/clrender.h b/src/game/client/render/clrender.h index d70001e2..c32a9094 100644 --- a/src/game/client/render/clrender.h +++ b/src/game/client/render/clrender.h @@ -1,37 +1,42 @@ //curstate.oldbuttons -#define MSRDR_VIEWMODEL (1 << 0) //Model is a view model (parent view model... never rendered fully) -#define MSRDR_FLIPPED (1 << 1) //Model is flipped across the verical axis, changing it from the right to left hand -#define MSRDR_SKIP (1 << 2) //Do all setup (for attachments later), but don't render -#define MSRDR_NOREFLECT (1 << 3) //Don't render to mirrors -#define MSRDR_FULLROT (1 << 4) //Use full rotation this frame (automatically unset in ) - -//Separate flags from the above -- stored in curstate.colormap -#define MSRDR_GLOW_GRN (1 << 0) //Green glow -#define MSRDR_GLOW_RED (1 << 1) //Highlight slected weapons - Red Glow -#define MSRDR_DARK (1 << 2) //Dim lights on the inset player model -#define MSRDR_LIGHT_DIM (1 << 3) -#define MSRDR_LIGHT_NORMAL (1 << 4) //Give a moderate amount of artificial light -#define MSRDR_LIGHT_BRIGHT (1 << 5) //Make it fullbright -#define MSRDR_ANIM_ONCE (1 << 6) //Only play the client-side anim once (no loop) -#define MSRDR_ASPLAYER (1 << 7) //Render as player -#define MSRDR_COPYPLAYER (1 << 8) //Copy the local player's anims -#define MSRDR_HANDMODEL (1 << 9) //This is one of the two hand models (coming off the viewmodel) - -//mouth.sndavg -#define MSRDR_HASEXTRA (1 << 0) //The extra info is initialied -//Specifics -#define INSET_SCALE 0.026f //0.02f -#define ANIM_RUN 11 -#define ANIM_CROUCH 0 -#define ANIM_CRAWL 1 -#define ANIM_SIT 19 -#define ANIM_ATTENTION 4 -#define ANIM_DEEPIDLE 5 -#define ANIM_JUMP 6 -#define ANIM_SIT 19 +enum { + MSRDR_VIEWMODEL = (1 << 0), //Model is a view model (parent view model... never rendered fully) + MSRDR_FLIPPED = (1 << 1), //Model is flipped across the verical axis, changing it from the right to left hand + MSRDR_SKIP = (1 << 2), //Do all setup (for attachments later), but don't render + MSRDR_NOREFLECT = (1 << 3), //Don't render to mirrors + MSRDR_FULLROT = (1 << 4), //Use full rotation this frame (automatically unset in ) + + //Separate flags from the above -- stored in curstate.colormap + MSRDR_GLOW_GRN = (1 << 0), //Green glow + MSRDR_GLOW_RED = (1 << 1), //Highlight slected weapons - Red Glow + MSRDR_DARK = (1 << 2), //Dim lights on the inset player model + MSRDR_LIGHT_DIM = (1 << 3), + MSRDR_LIGHT_NORMAL = (1 << 4), //Give a moderate amount of artificial light + MSRDR_LIGHT_BRIGHT = (1 << 5), //Make it fullbright + MSRDR_ANIM_ONCE = (1 << 6), //Only play the client-side anim once (no loop) + MSRDR_ASPLAYER = (1 << 7), //Render as player + MSRDR_COPYPLAYER = (1 << 8), //Copy the local player's anims + MSRDR_HANDMODEL = (1 << 9), //This is one of the two hand models (coming off the viewmodel) + + //mouth.sndavg + MSRDR_HASEXTRA (1 << 0) //The extra info is initialied +} + +//Specifics +constexpr float INSET_SCALE = 0.026f; //0.02f +enum { + ANIM_RUN = 11, + ANIM_CROUCH = 0, + ANIM_CRAWL = 1, + ANIM_SIT = 19, + ANIM_ATTENTION = 4, + ANIM_DEEPIDLE = 5, + ANIM_JUMP = 6, + ANIM_SIT = 19 +}; typedef struct msurface_s msurface_t; typedef struct decal_s decal_t; @@ -199,14 +204,16 @@ class CSurface Vector m_SurfaceNormal; }; -#define RDR_TEXTURE (1 << 0) -#define RDR_PROJECTIVE (1 << 1) -#define RDR_ALPHATEST (1 << 2) -#define RDR_STENCIL (1 << 3) -#define RDR_CLRSTENCIL (1 << 4) -#define RDR_CHKSTENCIL (1 << 5) -#define RDR_CLEARZ (1 << 6) -#define RDR_CLRALPHA (1 << 7) +enum { + RDR_TEXTURE = (1 << 0), + RDR_PROJECTIVE = (1 << 1), + RDR_ALPHATEST = (1 << 2), + RDR_STENCIL = (1 << 3), + RDR_CLRSTENCIL = (1 << 4), + RDR_CHKSTENCIL = (1 << 5), + RDR_CLEARZ = (1 << 6), + RDR_CLRALPHA = (1 << 7) +}; class CMirror { @@ -307,13 +314,18 @@ class CMirrorMgr }; void RenderModel(cl_entity_t *pEntity); -#define SURF_PLANEBACK 2 -#define SURF_DRAWSKY 4 -#define SURF_DRAWSPRITE 8 -#define SURF_DRAWTURB 0x10 -#define SURF_DRAWTILED 0x20 -#define SURF_DRAWBACKGROUND 0x40 -#define SURF_UNDERWATER 0x80 + +enum { + + SURF_PLANEBACK = 2, + SURF_DRAWSKY = 4, + SURF_DRAWSPRITE = 8, + SURF_DRAWTURB = 0x10, + SURF_DRAWTILED = 0x20, + SURF_DRAWBACKGROUND = 0x40, + SURF_UNDERWATER = 0x80 + +}; #include // Header File For The OpenGL32 Library #include From be897458acf901aba8f048204129fe6d79a4e27e Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:58:32 -0400 Subject: [PATCH 067/291] Fixed missing semi colon. --- src/game/client/render/clrender.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/client/render/clrender.h b/src/game/client/render/clrender.h index c32a9094..c79eaeed 100644 --- a/src/game/client/render/clrender.h +++ b/src/game/client/render/clrender.h @@ -22,8 +22,8 @@ enum { MSRDR_HANDMODEL = (1 << 9), //This is one of the two hand models (coming off the viewmodel) //mouth.sndavg - MSRDR_HASEXTRA (1 << 0) //The extra info is initialied -} + MSRDR_HASEXTRA(1 << 0) //The extra info is initialied +}; //Specifics constexpr float INSET_SCALE = 0.026f; //0.02f From 5e44f6fcab7e9ed4b099baa3d43de8368873442e Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:59:10 -0400 Subject: [PATCH 068/291] Fixed missing equals. Removed duplicate enum def. --- src/game/client/render/clrender.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/game/client/render/clrender.h b/src/game/client/render/clrender.h index c79eaeed..a8b68645 100644 --- a/src/game/client/render/clrender.h +++ b/src/game/client/render/clrender.h @@ -22,7 +22,7 @@ enum { MSRDR_HANDMODEL = (1 << 9), //This is one of the two hand models (coming off the viewmodel) //mouth.sndavg - MSRDR_HASEXTRA(1 << 0) //The extra info is initialied + MSRDR_HASEXTRA = (1 << 0) //The extra info is initialied }; //Specifics @@ -34,8 +34,7 @@ enum { ANIM_SIT = 19, ANIM_ATTENTION = 4, ANIM_DEEPIDLE = 5, - ANIM_JUMP = 6, - ANIM_SIT = 19 + ANIM_JUMP = 6 }; typedef struct msurface_s msurface_t; typedef struct decal_s decal_t; From 2d9d0ea067063585f5c55e75821dbdbc190037da Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 00:39:02 -0400 Subject: [PATCH 069/291] Changed vector.h class to allow for constexpr initialization. Changes macros to constexpr/enums in util.h --- src/game/server/hl/util.h | 192 ++++++++++++++++++++---------------- src/game/shared/hl/vector.h | 16 +-- 2 files changed, 115 insertions(+), 93 deletions(-) diff --git a/src/game/server/hl/util.h b/src/game/server/hl/util.h index 570ff87b..1b9260e4 100644 --- a/src/game/server/hl/util.h +++ b/src/game/server/hl/util.h @@ -178,16 +178,16 @@ inline BOOL FStringNull(int iString) #define cchMapNameMost 32 // Dot products for view cone checking -#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees -#define VIEW_FIELD_WIDE (float)-0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks -#define VIEW_FIELD_NARROW (float)0.7 // +-45 degrees, more narrow check used to set up ranged attacks -#define VIEW_FIELD_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks +constexpr float VIEW_FIELD_FULL = -1.0f; // +-180 degrees +constexpr float VIEW_FIELD_WIDE = -0.7f; // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks +constexpr float VIEW_FIELD_NARROW = 0.7f; // +-45 degrees, more narrow check used to set up ranged attacks +constexpr float VIEW_FIELD_ULTRA_NARROW = 0.9f; // +-25 degrees, more narrow check used to set up ranged attacks // All monsters need this data -#define DONT_BLEED -1 -#define BLOOD_COLOR_RED (byte)247 -#define BLOOD_COLOR_YELLOW (byte)195 -#define BLOOD_COLOR_GREEN BLOOD_COLOR_YELLOW +constexpr int DONT_BLEED = -1; +constexpr byte BLOOD_COLOR_RED = (byte)247; +constexpr byte BLOOD_COLOR_YELLOW = (byte)195; +constexpr byte BLOOD_COLOR_GREEN = BLOOD_COLOR_YELLOW; typedef enum { @@ -424,99 +424,119 @@ extern DLL_GLOBAL const Vector g_vecZero; // // Un-comment only as needed // -#define LANGUAGE_ENGLISH 0 -#define LANGUAGE_GERMAN 1 -#define LANGUAGE_FRENCH 2 -#define LANGUAGE_BRITISH 3 +enum { + LANGUAGE_ENGLISH = 0, + LANGUAGE_GERMAN = 1, + LANGUAGE_FRENCH = 2, + LANGUAGE_BRITISH = 3 +}; extern DLL_GLOBAL int g_Language; -#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 - -#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements - -#define SND_SPAWNING (1 << 8) // duplicated in protocol.h we're spawing, used in some cases for ambients -#define SND_STOP (1 << 5) // duplicated in protocol.h stop sound -#define SND_CHANGE_VOL (1 << 6) // duplicated in protocol.h change sound vol -#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch - -#define LFO_SQUARE 1 -#define LFO_TRIANGLE 2 -#define LFO_RANDOM 3 - -// func_rotating -#define SF_BRUSH_ROTATE_Y_AXIS 0 -#define SF_BRUSH_ROTATE_INSTANT 1 -#define SF_BRUSH_ROTATE_BACKWARDS 2 -#define SF_BRUSH_ROTATE_Z_AXIS 4 -#define SF_BRUSH_ROTATE_X_AXIS 8 -#define SF_PENDULUM_AUTO_RETURN 16 -#define SF_PENDULUM_PASSABLE 32 - -#define SF_BRUSH_ROTATE_SMALLRADIUS 128 -#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 -#define SF_BRUSH_ROTATE_LARGERADIUS 512 - -#define PUSH_BLOCK_ONLY_X 1 -#define PUSH_BLOCK_ONLY_Y 2 - -#define VEC_HULL_MIN Vector(-16, -16, -36) -#define VEC_HULL_MAX Vector(16, 16, 36) -#define VEC_HUMAN_HULL_MIN Vector(-16, -16, 0) -#define VEC_HUMAN_HULL_MAX Vector(16, 16, 72) -#define VEC_HUMAN_HULL_DUCK Vector(16, 16, 36) - -#define VEC_VIEW Vector(0, 0, 28) - -#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18) -#define VEC_DUCK_HULL_MAX Vector(16, 16, 18) -#define VEC_DUCK_VIEW Vector(0, 0, 12) - -#define SVC_TEMPENTITY 23 -#define SVC_INTERMISSION 30 -#define SVC_CDTRACK 32 -#define SVC_WEAPONANIM 35 -#define SVC_ROOMTYPE 37 -#define SVC_DIRECTOR 51 +enum { + AMBIENT_SOUND_STATIC = 0,// medium radius attenuation + AMBIENT_SOUND_EVERYWHERE = 1, + AMBIENT_SOUND_SMALLRADIUS = 2, + AMBIENT_SOUND_MEDIUMRADIUS = 4, + AMBIENT_SOUND_LARGERADIUS = 8, + AMBIENT_SOUND_START_SILENT = 16, + AMBIENT_SOUND_NOT_LOOPING = 32 +}; -// triggers -#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger -#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger -#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger +enum { + SPEAKER_START_SILENT = 1 // wait for trigger 'on' to start announcements +}; + +enum { + SND_STOP = (1 << 5), // duplicated in protocol.h stop sound + SND_CHANGE_VOL = (1 << 6), // duplicated in protocol.h change sound vol + SND_CHANGE_PITCH = (1 << 7), // duplicated in protocol.h change sound pitch + SND_SPAWNING = (1 << 8) // duplicated in protocol.h we're spawing, used in some cases for ambients +}; + +enum { + LFO_SQUARE = 1, + LFO_TRIANGLE = 2, + LFO_RANDOM = 3 +}; + +enum { + SF_BRUSH_ROTATE_Y_AXIS = 0, + SF_BRUSH_ROTATE_INSTANT = 1, + SF_BRUSH_ROTATE_BACKWARDS = 2, + SF_BRUSH_ROTATE_Z_AXIS = 4, + SF_BRUSH_ROTATE_X_AXIS = 8, + SF_PENDULUM_AUTO_RETURN = 16, + SF_PENDULUM_PASSABLE = 32, + SF_BRUSH_ROTATE_SMALLRADIUS = 128, + SF_BRUSH_ROTATE_MEDIUMRADIUS = 256, + SF_BRUSH_ROTATE_LARGERADIUS = 512 +}; -// func breakable -#define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger -#define SF_BREAK_TOUCH 2 // can be 'crashed through' by running player (plate glass) -#define SF_BREAK_PRESSURE 4 // can be broken by a player standing on it -#define SF_BREAK_CROWBAR 256 // instant break if hit with crowbar -// func_pushable (it's also func_breakable, so don't collide with those flags) -#define SF_PUSH_BREAKABLE 128 +enum { + PUSH_BLOCK_ONLY_X = 1, + PUSH_BLOCK_ONLY_Y = 2 +}; -#define SF_LIGHT_START_OFF 1 +constexpr Vector VEC_HULL_MIN = Vector(-16,-16,-36); +constexpr Vector VEC_HULL_MAX = Vector(16, 16, 36); +constexpr Vector VEC_HUMAN_HULL_MIN = Vector(-16, -16, 0); +constexpr Vector VEC_HUMAN_HULL_MAX = Vector(16, 16, 72); +constexpr Vector VEC_HUMAN_HULL_DUCK = Vector(16, 16, 36); +constexpr Vector VEC_VIEW = Vector(0, 0, 28); +constexpr Vector VEC_DUCK_HULL_MIN = Vector(-16, -16, -18); +constexpr Vector VEC_DUCK_HULL_MAX = Vector(16, 16, 18); +constexpr Vector VEC_DUCK_VIEW = Vector(0, 0, 12); + +enum { + SVC_TEMPENTITY = 23, + SVC_INTERMISSION = 30, + SVC_CDTRACK = 32, + SVC_WEAPONANIM = 35, + SVC_ROOMTYPE = 37, + SVC_DIRECTOR = 51 +}; -#define SPAWNFLAG_NOMESSAGE 1 -#define SPAWNFLAG_NOTOUCH 1 -#define SPAWNFLAG_DROIDONLY 4 +// triggers -#define SPAWNFLAG_USEONLY 1 // can't be touched, must be used (buttons) +enum { + SF_TRIG_PUSH_ONCE = 1, + SF_TRIGGER_ALLOWMONSTERS = 1, // monsters allowed to fire this trigger + SF_TRIGGER_NOCLIENTS = 2, // players not allowed to fire this trigger + SF_TRIGGER_PUSHABLES = 4 // only pushables can fire this trigger +}; -#define TELE_PLAYER_ONLY 1 -#define TELE_SILENT 2 +// func breakable +enum { + SF_BREAK_TRIGGER_ONLY = 1, // may only be broken by trigger + SF_BREAK_TOUCH = 2, // can be 'crashed through' by running player (plate glass) + SF_BREAK_PRESSURE = 4, // can be broken by a player standing on it + SF_PUSH_BREAKABLE = 128, // func_pushable (it's also func_breakable, so don't collide with those flags) + SF_BREAK_CROWBAR = 256 // instant break if hit with crowbar +}; -#define SF_TRIG_PUSH_ONCE 1 +enum { + SF_LIGHT_START_OFF = 1 +}; + +enum { + SPAWNFLAG_NOMESSAGE = 1, + SPAWNFLAG_NOTOUCH = 1, + SPAWNFLAG_USEONLY = 1, + SPAWNFLAG_DROIDONLY = 4 +}; +enum { + TELE_PLAYER_ONLY = 1, + TELE_SILENT = 2 +}; // Sound Utilities + // sentence groups -#define CBSENTENCENAME_MAX 16 -#define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match CVOXFILESENTENCEMAX in engine\sound.h!!! +constexpr int CBSENTENCENAME_MAX = 16; +constexpr int CVOXFILESENTENCEMAX = 1536;// max number of sentences in game. NOTE: this must match CVOXFILESENTENCEMAX in engine\sound.h!!! extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; extern int gcallsentences; diff --git a/src/game/shared/hl/vector.h b/src/game/shared/hl/vector.h index 92a90a72..8ffbfe47 100644 --- a/src/game/shared/hl/vector.h +++ b/src/game/shared/hl/vector.h @@ -64,22 +64,22 @@ class Vector // same data-layout as engine's vec3_t, { // which is a vec_t[3] public: // Construction/destruction - inline Vector(void) {} - inline Vector(float X, float Y, float Z) - { + inline constexpr Vector(void) {} + inline constexpr Vector(float X, float Y, float Z) { x = X; y = Y; - z = Z; + x = Z; } + //inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } //inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector(const Vector &v) + inline constexpr Vector(const Vector &v) { x = v.x; y = v.y; z = v.z; } - inline Vector(float rgfl[3]) + inline constexpr Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; @@ -129,7 +129,9 @@ class Vector // same data-layout as engine's vec3_t, inline float Length2D(void) const { return sqrt( (x * x) + (y * y) ); } // Members - vec_t x, y, z; //just floats + vec_t x{}; + vec_t y{}; + vec_t z{}; //just floats }; inline Vector operator*(float fl, const Vector& v) { return v * fl; } From acf2e2cc28d89f2ee9348353076fe02e9edb8ba7 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 00:43:28 -0400 Subject: [PATCH 070/291] fixed accidental change to var in init. --- src/game/shared/hl/vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/shared/hl/vector.h b/src/game/shared/hl/vector.h index 8ffbfe47..c9752171 100644 --- a/src/game/shared/hl/vector.h +++ b/src/game/shared/hl/vector.h @@ -68,7 +68,7 @@ class Vector // same data-layout as engine's vec3_t, inline constexpr Vector(float X, float Y, float Z) { x = X; y = Y; - x = Z; + z = Z; } //inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } From aeb28bbe7686b77bee7edfea70ac46a1c9cc5523 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 17:25:59 -0400 Subject: [PATCH 071/291] Reverted init change for member vars --- src/game/shared/hl/vector.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/game/shared/hl/vector.h b/src/game/shared/hl/vector.h index c9752171..31cc3efc 100644 --- a/src/game/shared/hl/vector.h +++ b/src/game/shared/hl/vector.h @@ -129,9 +129,7 @@ class Vector // same data-layout as engine's vec3_t, inline float Length2D(void) const { return sqrt( (x * x) + (y * y) ); } // Members - vec_t x{}; - vec_t y{}; - vec_t z{}; //just floats + vec_t x, y, z; //just floats }; inline Vector operator*(float fl, const Vector& v) { return v * fl; } From 107934e2f3c5940fd6a49ec6dad1111bbfc9da9b Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 17:51:03 -0400 Subject: [PATCH 072/291] templated fabs and DotProduct functions --- src/game/client/cl_util.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/game/client/cl_util.h b/src/game/client/cl_util.h index e3bfefce..237111d8 100644 --- a/src/game/client/cl_util.h +++ b/src/game/client/cl_util.h @@ -150,20 +150,30 @@ inline void PlaySound(const char *szSound, float vol) { gEngfuncs.pfnPlaySoundBy inline void PlaySound(int iSound, float vol) { gEngfuncs.pfnPlaySoundByIndex(iSound, vol); } inline void PlayHUDSound(const char *Sound, float vol) { PlaySound((char *)Sound, vol); } -#define fabs(x) ((x) > 0 ? (x) : 0 - (x)) +template +Type fabs(Type x) { + if (x > 0) return x; + else return (0 - x); +}; + void ScaleColors(int &r, int &g, int &b, int a); -#define DotProduct(x, y) ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2]) +template +float DotProduct(Type* x, Type* y) { + return (x[0] * y[0]) + (x[1] * y[1]) + (x[2] + y[2]); +}; + +//#define DotProduct(x, y) ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2]) // ugh, some bits of the client code expect a float[3] while others expect a Vector, and there's a macro that pretends they're the same // handle the extern with the correct types in the places where it's required // extern vec3_t vec3_origin; // disable 'possible loss of data converting float to int' warning message -#pragma warning(disable : 4244) +//#pragma warning(disable : 4244) // disable 'truncation from 'const double' to 'float' warning message -#pragma warning(disable : 4305) +//#pragma warning(disable : 4305) inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB) { From bf2e80e13f44cf1d0c96a2ec57c85feeba3d1b37 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 18:09:57 -0400 Subject: [PATCH 073/291] Changed macros to templated functions. Fixed / changed unneeded assignment. --- src/game/client/entity.cpp | 2 +- src/game/client/ms/clplayer.cpp | 3 ++- src/game/server/hl/util.h | 29 ++++++++++++++++++++----- src/game/shared/weapons/genericitem.cpp | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/game/client/entity.cpp b/src/game/client/entity.cpp index 60b5a9ad..f42b1100 100644 --- a/src/game/client/entity.cpp +++ b/src/game/client/entity.cpp @@ -1725,7 +1725,7 @@ void SetClEntityProp(cl_entity_t &Ent, msstring &Cmd, mslist &Params else if (Cmd == "frame") Ent.curstate.frame = atof(Value); else if (Cmd == "update") - Ent.curstate.iuser4 = atoi(Value) ? SetBits(Ent.curstate.iuser4, MSTEMPENT_CALLBACK) : ClearBits(Ent.curstate.iuser4, MSTEMPENT_CALLBACK); + atoi(Value) ? SetBits(Ent.curstate.iuser4, MSTEMPENT_CALLBACK) : ClearBits(Ent.curstate.iuser4, MSTEMPENT_CALLBACK); else if (Cmd == "rendermode") { if (Value.find("normal") != msstring_error) diff --git a/src/game/client/ms/clplayer.cpp b/src/game/client/ms/clplayer.cpp index f49766a1..f62bbf53 100644 --- a/src/game/client/ms/clplayer.cpp +++ b/src/game/client/ms/clplayer.cpp @@ -595,7 +595,8 @@ void HUD_WeaponsPostThink(local_state_s* from, local_state_s* to, usercmd_t* cmd static int PreserveMask = PLAYER_MOVE_RUNNING | PLAYER_MOVE_ATTACKING; //These are client-side bits to be saved int PreserveBits = (player.m_StatusFlags & PreserveMask); //Save the client-side bits - player.m_StatusFlags = ClearBits(from->client.iuser3, PreserveMask); //Copy all the flags except the client-side ones + ClearBits(from->client.iuser3, PreserveMask); //clear flags execpt client side ones + player.m_StatusFlags = from->client.iuser3; //Copy all the flags except the client-side ones SetBits(player.m_StatusFlags, PreserveBits); //Copy the client-side bits back over to->playerstate.iuser3 = from->playerstate.iuser3; diff --git a/src/game/server/hl/util.h b/src/game/server/hl/util.h index 1b9260e4..065ae53a 100644 --- a/src/game/server/hl/util.h +++ b/src/game/server/hl/util.h @@ -61,9 +61,26 @@ inline edict_t *FIND_ENTITY_BY_TARGET(edict_t *entStart, const char *pszName) ENGINE_FPRINTF(pf, "\"%s\" \"%f %f %f\"\n", szKeyName, flX, flY, flZ) // Keeps clutter down a bit, when using a float as a bit-vector -#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits)) -#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits)) -#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit)) + +template +void SetBits(Type& vector, const int bits) { + vector = (int)vector | bits; +} + +template +void ClearBits(Type& vector, const int bits) { + vector = (int)vector & ~bits; +} + +template +bool FBitSet(const Type& vector, const int bit) { + return (int)vector & bit; +} + + +//#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits)) +//#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits)) +//#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit)) // Makes these more explicit, and easier to find #define FILE_GLOBAL static @@ -160,7 +177,7 @@ inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float* pOrigin, entv } // Testing the three types of "entity" for nullity -#define eoNullEntity 0 +constexpr int eoNullEntity = 0; inline BOOL FNullEnt(EOFFSET eoffset) { return eoffset == 0; @@ -169,13 +186,13 @@ inline BOOL FNullEnt(const edict_t *pent) { return pent == NULL || FNullEnt(OFFS inline BOOL FNullEnt(entvars_t *pev) { return pev == NULL || FNullEnt(OFFSET(pev)); } // Testing strings for nullity -#define iStringNull 0 +constexpr int iStringNull = 0; inline BOOL FStringNull(int iString) { return iString == iStringNull; } -#define cchMapNameMost 32 +constexpr int cchMapNameMost = 32; // Dot products for view cone checking constexpr float VIEW_FIELD_FULL = -1.0f; // +-180 degrees diff --git a/src/game/shared/weapons/genericitem.cpp b/src/game/shared/weapons/genericitem.cpp index 005ca938..4dab5ee7 100644 --- a/src/game/shared/weapons/genericitem.cpp +++ b/src/game/shared/weapons/genericitem.cpp @@ -598,7 +598,7 @@ float CGenericItem::Weight() float MyVolume = CBaseEntity::m_Weight; if (FBitSet(MSProperties(), ITEM_CONTAINER)) MyVolume += Container_Weight(); - else if FBitSet(MSProperties(), ITEM_GROUPABLE) + else if (FBitSet(MSProperties(), ITEM_GROUPABLE)) MyVolume *= iQuantity; return MyVolume; } From a0c0671924d358edb3f0a53cc2edd6128bb373d8 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 18:31:26 -0400 Subject: [PATCH 074/291] templated FDotProduct function --- src/game/client/cl_util.h | 2 +- src/game/client/render/studio_util.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/game/client/cl_util.h b/src/game/client/cl_util.h index 237111d8..a890bbea 100644 --- a/src/game/client/cl_util.h +++ b/src/game/client/cl_util.h @@ -152,7 +152,7 @@ inline void PlayHUDSound(const char *Sound, float vol) { PlaySound((char *)Sound template Type fabs(Type x) { - if (x > 0) return x; + if (x >= 0) return x; else return (0 - x); }; diff --git a/src/game/client/render/studio_util.h b/src/game/client/render/studio_util.h index aa784528..a69eba5d 100644 --- a/src/game/client/render/studio_util.h +++ b/src/game/client/render/studio_util.h @@ -17,7 +17,10 @@ constexpr int YAW = 1; constexpr int ROLL = 2; #endif -#define FDotProduct(a, b) (fabs((a[0]) * (b[0])) + fabs((a[1]) * (b[1])) + fabs((a[2]) * (b[2]))) +template +float FDotProduct(Type* a, Type* b) { + return fabs(a[0] * b[0]) + fabs(a[1] * b[1]) + fabs(a[2] * b[2]); +} void AngleMatrix(const float *angles, float (*matrix)[4]); bool VectorCompare (const float *v1, const float *v2); From 2a5f233411266a938ba3aad38c7a16df33f6f6d9 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 18:31:39 -0400 Subject: [PATCH 075/291] consted var pass in --- src/game/client/render/studio_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/render/studio_util.h b/src/game/client/render/studio_util.h index a69eba5d..c630d0dc 100644 --- a/src/game/client/render/studio_util.h +++ b/src/game/client/render/studio_util.h @@ -18,7 +18,7 @@ constexpr int ROLL = 2; #endif template -float FDotProduct(Type* a, Type* b) { +Type FDotProduct(const Type a, const Type b) { return fabs(a[0] * b[0]) + fabs(a[1] * b[1]) + fabs(a[2] * b[2]); } From 47e72d403a6027d97e333c1ba142305e4efe27b3 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 20:47:39 -0400 Subject: [PATCH 076/291] changes header functions to be specified as inline --- src/common/Platform.h | 4 ++-- src/game/client/cl_util.h | 16 +++++++++++++--- src/game/client/render/studio_util.h | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/common/Platform.h b/src/common/Platform.h index 6089b66c..7ea5474e 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -44,12 +44,12 @@ using word = unsigned short; template -auto V_min(const T1& a, const T2& b) { +inline auto V_min(const T1& a, const T2& b) { return (a < b) ? a : b; }; template -auto V_max(const T1& a, const T2& b) { +inline auto V_max(const T1& a, const T2& b) { return (a > b) ? a : b; }; diff --git a/src/game/client/cl_util.h b/src/game/client/cl_util.h index a890bbea..90ed772d 100644 --- a/src/game/client/cl_util.h +++ b/src/game/client/cl_util.h @@ -15,6 +15,7 @@ // // cl_util.h // + #include "sharedutil.h" #include "msdebug.h" @@ -25,6 +26,7 @@ #define FALSE 0 #endif +//these must stay macros, or we need to make a msg function for every command. // Macros to hook function calls into the HUD object #define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x); @@ -57,7 +59,7 @@ gHUD.y->UserCmd_##x(); \ } //------------------------------------------ - +//end required macros //Master Sword #undef CVAR_GET_FLOAT #undef CVAR_GET_STRING @@ -66,6 +68,15 @@ inline float CVAR_GET_FLOAT(const char *x) { return gEngfuncs.pfnGetCvarFloat(x) inline const char *CVAR_GET_STRING(const char *x) { return gEngfuncs.pfnGetCvarString(x); } inline struct cvar_s *CVAR_CREATE(const char *cv, const char *val, const int flags) { return gEngfuncs.pfnRegisterVariable(cv, val, flags); } +//HLSPRITE SPR_Load(const char* sprName) { +//return gEngfuncs.pfnSPR_Load(sprName); +//} + + +//void SPR_Set(HLSPRITE& hPic, const int r, const int g, const int b ) { +// gEngfuncs.pfnSPR_Set(&hPic, r, g, b); +//} + #define SPR_Load (*gEngfuncs.pfnSPR_Load) #define SPR_Set (*gEngfuncs.pfnSPR_Set) #define SPR_Frames (*gEngfuncs.pfnSPR_Frames) @@ -150,8 +161,7 @@ inline void PlaySound(const char *szSound, float vol) { gEngfuncs.pfnPlaySoundBy inline void PlaySound(int iSound, float vol) { gEngfuncs.pfnPlaySoundByIndex(iSound, vol); } inline void PlayHUDSound(const char *Sound, float vol) { PlaySound((char *)Sound, vol); } -template -Type fabs(Type x) { +inline float fabs(float x) { if (x >= 0) return x; else return (0 - x); }; diff --git a/src/game/client/render/studio_util.h b/src/game/client/render/studio_util.h index c630d0dc..76c628ff 100644 --- a/src/game/client/render/studio_util.h +++ b/src/game/client/render/studio_util.h @@ -18,7 +18,7 @@ constexpr int ROLL = 2; #endif template -Type FDotProduct(const Type a, const Type b) { +inline Type FDotProduct(const Type a, const Type b) { return fabs(a[0] * b[0]) + fabs(a[1] * b[1]) + fabs(a[2] * b[2]); } From 803fe461224e8f2892a3b43f409fe243b9af148a Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 20:50:30 -0400 Subject: [PATCH 077/291] removed fabs unneeded redefinition --- src/game/client/cl_util.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/game/client/cl_util.h b/src/game/client/cl_util.h index 90ed772d..39684dd7 100644 --- a/src/game/client/cl_util.h +++ b/src/game/client/cl_util.h @@ -161,12 +161,6 @@ inline void PlaySound(const char *szSound, float vol) { gEngfuncs.pfnPlaySoundBy inline void PlaySound(int iSound, float vol) { gEngfuncs.pfnPlaySoundByIndex(iSound, vol); } inline void PlayHUDSound(const char *Sound, float vol) { PlaySound((char *)Sound, vol); } -inline float fabs(float x) { - if (x >= 0) return x; - else return (0 - x); -}; - - void ScaleColors(int &r, int &g, int &b, int a); template From fb753344c000e11cda822f5539d5c4321c8a9a8e Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 20:51:33 -0400 Subject: [PATCH 078/291] Moved VecMutiply definition to inline header function. Converted from macro. --- src/game/shared/ms/script.cpp | 1 - src/game/shared/ms/script.h | 4 ++++ src/game/shared/ms/scriptcmds.cpp | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/shared/ms/script.cpp b/src/game/shared/ms/script.cpp index d9610df2..47903c2e 100644 --- a/src/game/shared/ms/script.cpp +++ b/src/game/shared/ms/script.cpp @@ -35,7 +35,6 @@ bool GetModelBounds(CBaseEntity* pEntity, Vector Bounds[2]); //#include #undef SCRIPTVAR -#define VecMultiply( a, b ) Vector( a[0] * b[0], a[1] * b[1], a[2] * b[2] ) //Thothie APR2016_25 - seems we need this here too #define SCRIPTVAR GetVar //A script-wide or global variable #define SCRIPTCONST( a ) SCRIPTVAR(GetConst(a)) //A const, script-wide, or global variable - loadtime only #define GETCONST_COMPATIBLE( a ) ( a.c_str()[0] == '$' ? GetConst(a) : SCRIPTCONST(a) ) //Loadtime - Only parse it as a var if it's not a $parser diff --git a/src/game/shared/ms/script.h b/src/game/shared/ms/script.h index 4f47b911..d4ee10e1 100644 --- a/src/game/shared/ms/script.h +++ b/src/game/shared/ms/script.h @@ -6,6 +6,10 @@ #include #include +inline Vector VecMultiply(Vector a, Vector b) { + return Vector(a[0] * b[0], a[1] * b[1], a[2] * b[2]); +}; + class CEventList : public mslist //This class was created so I can store Events as pointers, but still access them as { //dereferenced objects public: diff --git a/src/game/shared/ms/scriptcmds.cpp b/src/game/shared/ms/scriptcmds.cpp index 695dec33..3acd0cef 100644 --- a/src/game/shared/ms/scriptcmds.cpp +++ b/src/game/shared/ms/scriptcmds.cpp @@ -34,7 +34,6 @@ #undef SCRIPTVAR #define SCRIPTVAR GetVar //A script-wide or global variable #define ERROR_MISSING_PARMS MS_ERROR("ExecuteScriptCmd: Script: %s, %s - not enough parameters!", m.ScriptFile.c_str(), Cmd.Name().c_str()) -#define VecMultiply( a, b ) Vector( a[0] * b[0], a[1] * b[1], a[2] * b[2] ) void Player_UseStamina(float flAddAmt); extern "C" playermove_t *pmove; From 28f1f34248406b9c8e5623799afd04bcb042b92d Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:25:22 -0400 Subject: [PATCH 079/291] changes two defines to constexpr --- src/common/com_model.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/com_model.h b/src/common/com_model.h index c8466505..92fc4ce9 100644 --- a/src/common/com_model.h +++ b/src/common/com_model.h @@ -493,8 +493,8 @@ typedef struct auxvert_s // #include "custom.h" -#define MAX_INFO_STRING 256 -#define MAX_SCOREBOARDNAME 32 +constexpr int MAX_INFO_STRING = 256; +constexpr int MAX_SCOREBOARDNAME = 32; typedef struct player_info_s { // User id on server From 44f03a21a524f73bb8e578718999b4eb1a741d4c Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:27:24 -0400 Subject: [PATCH 080/291] fixed ifndef syntax --- src/common/engine_launcher_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/engine_launcher_api.h b/src/common/engine_launcher_api.h index fa568d00..92c3be7b 100644 --- a/src/common/engine_launcher_api.h +++ b/src/common/engine_launcher_api.h @@ -6,7 +6,7 @@ //============================================================================= // engine/launcher interface -#if !defined(ENGINE_LAUNCHER_APIH) +#ifndef ENGINE_LAUNCHER_APIH #define ENGINE_LAUNCHER_APIH #ifdef _WIN32 #pragma once From 16b7088f165aaa2a1a00d8c8f0a1b0673b0b1cd0 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:30:52 -0400 Subject: [PATCH 081/291] Revferted syntax change --- src/common/engine_launcher_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/engine_launcher_api.h b/src/common/engine_launcher_api.h index 92c3be7b..fa568d00 100644 --- a/src/common/engine_launcher_api.h +++ b/src/common/engine_launcher_api.h @@ -6,7 +6,7 @@ //============================================================================= // engine/launcher interface -#ifndef ENGINE_LAUNCHER_APIH +#if !defined(ENGINE_LAUNCHER_APIH) #define ENGINE_LAUNCHER_APIH #ifdef _WIN32 #pragma once From 6a61dec8b9d04257d3751cc9063c2db9741d81d2 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:35:39 -0400 Subject: [PATCH 082/291] Removed macro --- src/common/mathlib.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/mathlib.h b/src/common/mathlib.h index 3e289b93..dab9927e 100644 --- a/src/common/mathlib.h +++ b/src/common/mathlib.h @@ -91,7 +91,6 @@ int GreatestCommonDivisor(int i1, int i2); void AngleVectors(const Vector& angles, Vector* forward, Vector* right, Vector* up); void AngleVectorsTranspose(const Vector& angles, Vector* forward, Vector* right, Vector* up); -#define AngleIVectors AngleVectorsTranspose void AngleMatrix(const float* angles, float (*matrix)[4]); void AngleIMatrix(const Vector& angles, float (*matrix)[4]); From ceefc46992c5fb6d80ff88db7c602b5b92bc1190 Mon Sep 17 00:00:00 2001 From: Rederick5 <73010056+Rederick5@users.noreply.github.com> Date: Wed, 11 Mar 2026 02:25:25 -0400 Subject: [PATCH 083/291] Fixed warning 4018 signed/unsigned mismatches --- lib/include/vgui/VGUI_Dar.h | 2 +- lib/include/vgui/VGUI_String.h | 2 +- src/common/Platform.h | 6 +- src/common/cl_entity.h | 2 +- src/common/com_model.h | 6 +- src/common/entity_state.h | 4 +- src/common/ref_params.h | 2 +- src/game/client/ammo_secondary.cpp | 4 +- src/game/client/ammohistory.cpp | 2 +- src/game/client/ammohistory.h | 2 +- src/game/client/death.cpp | 2 +- src/game/client/entity.cpp | 24 +-- src/game/client/hud.cpp | 2 +- src/game/client/hud_msg.cpp | 4 +- src/game/client/hud_spectator.cpp | 6 +- src/game/client/inputw32.cpp | 5 +- src/game/client/ms/action.cpp | 6 +- src/game/client/ms/clglobal.cpp | 12 +- src/game/client/ms/clplayer.cpp | 12 +- src/game/client/ms/health.cpp | 6 +- src/game/client/ms/hudid.cpp | 4 +- src/game/client/ms/hudmisc.cpp | 4 +- src/game/client/ms/hudscript.cpp | 43 +++-- src/game/client/ms/menu.cpp | 2 +- src/game/client/render/clrender.cpp | 24 ++- src/game/client/render/clrender.h | 2 +- src/game/client/render/clrenderent.cpp | 24 +-- src/game/client/render/clrendermirror.cpp | 49 +++-- .../client/render/studiomodelrenderer.cpp | 2 +- src/game/client/status_icons.cpp | 4 +- src/game/client/statusbar.cpp | 6 +- .../client/ui/ms/vgui_choosecharacter.cpp | 42 ++--- src/game/client/ui/ms/vgui_choosecharacter.h | 4 +- src/game/client/ui/ms/vgui_container.cpp | 28 +-- src/game/client/ui/ms/vgui_container.h | 8 +- src/game/client/ui/ms/vgui_containerlist.cpp | 8 +- src/game/client/ui/ms/vgui_eventconsole.h | 22 +-- src/game/client/ui/ms/vgui_health.h | 10 +- src/game/client/ui/ms/vgui_healthretro.h | 10 +- src/game/client/ui/ms/vgui_hud.cpp | 18 +- src/game/client/ui/ms/vgui_id.h | 10 +- src/game/client/ui/ms/vgui_infowin.h | 4 +- src/game/client/ui/ms/vgui_localizedpanel.cpp | 8 +- src/game/client/ui/ms/vgui_localizedpanel.h | 4 +- src/game/client/ui/ms/vgui_menu_interact.h | 6 +- src/game/client/ui/ms/vgui_menu_main.h | 4 +- src/game/client/ui/ms/vgui_menubase.cpp | 4 +- src/game/client/ui/ms/vgui_moveitempanel.cpp | 6 +- src/game/client/ui/ms/vgui_mscontrols.cpp | 24 +-- src/game/client/ui/ms/vgui_mscontrols.h | 12 +- src/game/client/ui/ms/vgui_options.cpp | 16 +- src/game/client/ui/ms/vgui_stats.cpp | 10 +- src/game/client/ui/ms/vgui_storage.cpp | 14 +- src/game/client/ui/ms/vgui_store.cpp | 6 +- src/game/client/ui/ms/vgui_storebuy.cpp | 4 +- src/game/client/ui/ms/vgui_storesell.cpp | 12 +- src/game/client/ui/vgui_global.cpp | 2 +- src/game/client/ui/vgui_loadtga.cpp | 2 +- src/game/client/ui/vgui_schememanager.cpp | 6 +- src/game/client/ui/vgui_schememanager.h | 4 +- src/game/client/ui/vgui_scorepanel.cpp | 6 +- src/game/client/ui/vgui_scrollbar2.cpp | 4 +- src/game/client/ui/vgui_slider2.cpp | 2 +- src/game/client/ui/vgui_status.h | 8 +- .../client/ui/vgui_teamfortressviewport.cpp | 24 +-- .../client/ui/vgui_teamfortressviewport.h | 8 +- src/game/client/view.cpp | 8 +- .../server/angelscript/ASServerEngineImpl.cpp | 8 +- src/game/server/client.cpp | 15 +- src/game/server/effects/mseffects.cpp | 16 +- src/game/server/enginecallback.h | 2 +- src/game/server/fn/FNSharedDefs.cpp | 2 +- src/game/server/func_break.cpp | 10 +- .../server/gamerules/multiplay_gamerules.cpp | 35 ++-- src/game/server/gamerules/team.cpp | 16 +- src/game/server/ggrenade.cpp | 4 +- src/game/server/hl/animating.cpp | 2 +- src/game/server/hl/animation.cpp | 16 +- src/game/server/hl/animation.h | 2 +- src/game/server/hl/explode.cpp | 4 +- src/game/server/hl/monsters.cpp | 10 +- src/game/server/hl/nodes.cpp | 89 ++++----- src/game/server/hl/nodes.h | 18 +- src/game/server/hl/saverestore.h | 2 +- src/game/server/hl/sound.cpp | 4 +- src/game/server/hl/soundent.cpp | 4 +- src/game/server/hl/subs.cpp | 2 +- src/game/server/hl/util.cpp | 40 ++--- src/game/server/hl/util.h | 2 +- .../server/monsters/bodyparts/bodyparts.cpp | 14 +- .../monsters/bodyparts/bodyparts_human.cpp | 4 +- src/game/server/monsters/corpse.cpp | 4 +- src/game/server/monsters/msmonster.h | 4 +- src/game/server/monsters/msmonsterserver.cpp | 46 ++--- src/game/server/monsters/npcglobal.cpp | 2 +- src/game/server/monsters/npcscript.cpp | 36 ++-- src/game/server/msmapents.cpp | 39 ++-- src/game/server/player/player.cpp | 115 ++++++------ src/game/server/player/player.h | 2 +- src/game/server/player/playershared.cpp | 70 ++++---- src/game/server/player/playerstats.cpp | 4 +- src/game/server/shield.cpp | 2 +- src/game/server/shurispritedefs.h | 2 +- src/game/server/store.cpp | 8 +- src/game/server/store.h | 2 +- src/game/server/sv_character.cpp | 56 +++--- src/game/server/svglobals.cpp | 20 +-- src/game/server/triggers.cpp | 22 +-- src/game/server/world.cpp | 2 +- src/game/shared/movement/pm_shared.cpp | 2 +- src/game/shared/ms/angelscript/ASBindings.cpp | 18 +- .../ms/angelscript/ASBuiltinFunctions.cpp | 31 ++-- src/game/shared/ms/angelscript/ASDebugger.cpp | 12 +- .../ms/angelscript/ASEngineEventManager.cpp | 2 +- .../ms/angelscript/ASEntityBindings.cpp | 22 +-- .../shared/ms/angelscript/ASModuleSystem.cpp | 6 +- .../shared/ms/angelscript/CAngelScript.cpp | 4 +- .../ms/angelscript/CAngelScriptManager.cpp | 4 +- .../shared/ms/angelscript/IAngelScript.cpp | 4 +- src/game/shared/ms/findentities.cpp | 4 +- src/game/shared/ms/global.cpp | 14 +- src/game/shared/ms/globalmem.cpp | 4 +- src/game/shared/ms/groupfile.cpp | 4 +- src/game/shared/ms/mscharacter.cpp | 6 +- src/game/shared/ms/mscharacter.h | 4 +- src/game/shared/ms/msfileio.cpp | 2 +- src/game/shared/ms/msfileio.h | 2 + src/game/shared/ms/mslogger.cpp | 2 +- src/game/shared/ms/msmonstershared.cpp | 46 ++--- src/game/shared/ms/netcodeshared.cpp | 18 +- src/game/shared/ms/script.cpp | 164 ++++++++--------- src/game/shared/ms/script.h | 2 +- src/game/shared/ms/scriptcmds.cpp | 170 +++++++++--------- src/game/shared/ms/scriptedeffects.cpp | 4 +- src/game/shared/ms/stackstring.cpp | 4 +- src/game/shared/stats/statdefs.h | 2 +- src/game/shared/stats/stats.cpp | 14 +- src/game/shared/voice_banmgr.cpp | 14 +- src/game/shared/voice_gamemgr.cpp | 2 +- src/game/shared/voice_status.cpp | 18 +- src/game/shared/weapons/genericitem.cpp | 40 ++--- src/game/shared/weapons/genericitem.h | 8 +- src/game/shared/weapons/giarmor.cpp | 2 +- src/game/shared/weapons/giattack.cpp | 18 +- src/game/shared/weapons/gipack.cpp | 25 +-- src/game/shared/weapons/weapons.cpp | 2 +- src/game/shared/weapons/weapons.h | 2 +- src/public/engine/eiface.h | 2 +- src/public/engine/progdefs.h | 6 +- src/public/engine/studio.h | 4 +- thirdparty/tartan/textureloader.cpp | 2 +- 151 files changed, 1066 insertions(+), 1050 deletions(-) diff --git a/lib/include/vgui/VGUI_Dar.h b/lib/include/vgui/VGUI_Dar.h index 6f8eb513..2d5c6496 100644 --- a/lib/include/vgui/VGUI_Dar.h +++ b/lib/include/vgui/VGUI_Dar.h @@ -66,7 +66,7 @@ template class VGUIAPI Dar } _count=count; } - int getCount() + unsigned int getCount() { return _count; } diff --git a/lib/include/vgui/VGUI_String.h b/lib/include/vgui/VGUI_String.h index 9cdebadf..289e1af7 100644 --- a/lib/include/vgui/VGUI_String.h +++ b/lib/include/vgui/VGUI_String.h @@ -37,7 +37,7 @@ class VGUIAPI String public: - int getCount(); + unsigned int getCount(); String operator+(String text); String operator+(const char* text); bool operator==(String text); diff --git a/src/common/Platform.h b/src/common/Platform.h index 7ea5474e..12b18f5b 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -12,7 +12,7 @@ constexpr int DEBUG = 1 #pragma warning(disable : 4201) // nameless struct/union #pragma warning(disable : 4514) // unreferenced inline function removed #pragma warning(disable : 4100) // unreferenced formal parameter -#pragma warning(disable : 4018) // signed/unsigned mismatch, this this probably isn't a good idea... +//#pragma warning(disable : 4018) // signed/unsigned mismatch, this this probably isn't a good idea... #pragma warning(disable : 26495) // Variable is uninitialized #pragma warning(disable : 26451) // Arithmetic overflow #pragma warning(disable : 26812) // The enum type is unscoped @@ -45,12 +45,12 @@ using word = unsigned short; template inline auto V_min(const T1& a, const T2& b) { - return (a < b) ? a : b; + return (a <= b) ? a : b; }; template inline auto V_max(const T1& a, const T2& b) { - return (a > b) ? a : b; + return (a >= b) ? a : b; }; #endif \ No newline at end of file diff --git a/src/common/cl_entity.h b/src/common/cl_entity.h index c6b2f646..dbdbca62 100644 --- a/src/common/cl_entity.h +++ b/src/common/cl_entity.h @@ -42,7 +42,7 @@ typedef struct vec3_t prevorigin; vec3_t prevangles; - int prevsequence; + unsigned int prevsequence; float prevframe; byte prevcontroller[4]; diff --git a/src/common/com_model.h b/src/common/com_model.h index 92fc4ce9..d3be02e6 100644 --- a/src/common/com_model.h +++ b/src/common/com_model.h @@ -280,7 +280,7 @@ typedef struct mleaf_s struct efrag_s *efrags; msurface_t **firstmarksurface; - int nummarksurfaces; + unsigned int nummarksurfaces; int key; // BSP sequence number for leaf's contents byte ambient_sound_level[NUM_AMBIENTS]; } mleaf_t; @@ -420,7 +420,7 @@ typedef struct model_s // // brush model // - int firstmodelsurface, nummodelsurfaces; // +0x070, +0x074 + unsigned int firstmodelsurface, nummodelsurfaces; // +0x070, +0x074 int numsubmodels; // +0x078 dmodel_t *submodels; // +0x07C @@ -521,7 +521,7 @@ typedef struct player_info_s int renderframe; // Gait frame estimation - int gaitsequence; + unsigned int gaitsequence; float gaitframe; float gaityaw; vec3_t prevgaitorigin; diff --git a/src/common/entity_state.h b/src/common/entity_state.h index 3c6b0a94..3d8120ab 100644 --- a/src/common/entity_state.h +++ b/src/common/entity_state.h @@ -44,7 +44,7 @@ struct entity_state_s vec3_t angles; int modelindex; - int sequence; + unsigned int sequence; float frame; int colormap; short skin; @@ -87,7 +87,7 @@ struct entity_state_s int health; qboolean spectator; int weaponmodel; - int gaitsequence; + unsigned int gaitsequence; // If standing on conveyor, e.g. vec3_t basevelocity; // Use the crouched hull, or the regular player hull. diff --git a/src/common/ref_params.h b/src/common/ref_params.h index f8a8d361..084166b1 100644 --- a/src/common/ref_params.h +++ b/src/common/ref_params.h @@ -60,7 +60,7 @@ typedef struct ref_params_s int maxclients; int viewentity; int playernum; - int max_entities; + unsigned int max_entities; int demoplayback; int hardware; diff --git a/src/game/client/ammo_secondary.cpp b/src/game/client/ammo_secondary.cpp index 7b374912..2f14d1a3 100644 --- a/src/game/client/ammo_secondary.cpp +++ b/src/game/client/ammo_secondary.cpp @@ -35,7 +35,7 @@ int CHudAmmoSecondary ::Init(void) gHUD.AddHudElem(this); m_HUD_ammoicon = 0; - for (int i = 0; i < MAX_SEC_AMMO_VALUES; i++) + for (unsigned int i = 0; i < MAX_SEC_AMMO_VALUES; i++) m_iAmmoAmounts[i] = -1; // -1 means don't draw this value Reset(); @@ -139,7 +139,7 @@ int CHudAmmoSecondary ::MsgFunc_SecAmmoVal(const char *pszName, int iSize, void // check to see if there is anything left to draw int count = 0; - for (int i = 0; i < MAX_SEC_AMMO_VALUES; i++) + for (unsigned int i = 0; i < MAX_SEC_AMMO_VALUES; i++) { count += V_max(0, m_iAmmoAmounts[i]); } diff --git a/src/game/client/ammohistory.cpp b/src/game/client/ammohistory.cpp index 40aa30c7..b9403817 100644 --- a/src/game/client/ammohistory.cpp +++ b/src/game/client/ammohistory.cpp @@ -91,7 +91,7 @@ void HistoryResource ::AddToHistory(int iType, const char *szName, int iCount) void HistoryResource ::CheckClearHistory(void) { - for (int i = 0; i < MAX_HISTORY; i++) + for (unsigned int i = 0; i < MAX_HISTORY; i++) { if (rgAmmoHistory[i].type) return; diff --git a/src/game/client/ammohistory.h b/src/game/client/ammohistory.h index 9d4d6870..f2e1f46a 100644 --- a/src/game/client/ammohistory.h +++ b/src/game/client/ammohistory.h @@ -65,7 +65,7 @@ class WeaponsResource void DropAllWeapons(void) { - for (int i = 0; i < MAX_WEAPONS; i++) + for (unsigned int i = 0; i < MAX_WEAPONS; i++) { if (rgWeapons[i].iId) DropWeapon(&rgWeapons[i]); diff --git a/src/game/client/death.cpp b/src/game/client/death.cpp index 18dd983a..98e45ae1 100644 --- a/src/game/client/death.cpp +++ b/src/game/client/death.cpp @@ -91,7 +91,7 @@ int CHudDeathNotice ::Draw(float flTime) { int x, y, r, g, b; - for (int i = 0; i < MAX_DEATHNOTICES; i++) + for (unsigned int i = 0; i < MAX_DEATHNOTICES; i++) { if (rgDeathNoticeList[i].iId == 0) break; // we've gone through them all diff --git a/src/game/client/entity.cpp b/src/game/client/entity.cpp index f42b1100..a837a885 100644 --- a/src/game/client/entity.cpp +++ b/src/game/client/entity.cpp @@ -588,7 +588,7 @@ void CHudScript::Effects_UpdateTempEnt(const char* EventName, msstringlist *Para { //Update tempents TEMPENTITY *pTempEnt = g_CurrentTempEnt; //Save a copy, because this could get set to NULL during RunScriptEventByName - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) { CScript *Script = m_Scripts[i]; if (pTempEnt->entity.curstate.iuser2 != (int)Script) @@ -649,7 +649,7 @@ const char* CScript::CLGetBeamProp(int beamid, msstringlist &Params) BEAM *pBeam = found_beam ? m_Beams[beamid] : NULL; /* bool found_beam = false; - for (int i = 0; i < m_Beams.size(); i++) + for (unsigned int i = 0; i < m_Beams.size(); i++) { Print("DEBUG: $get_clbeam checking %i for %i\n",i,beamid); if ( m_Beams[i]->id == beamid ) @@ -963,7 +963,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) p->die += 1.0; int Spot = 0; - for (int i = 0; i < MAX_TEMPENT_EXTRA; i++) + for (unsigned int i = 0; i < MAX_TEMPENT_EXTRA; i++) if (!g_TempEntExtra[i].Active) { Spot = i; @@ -1115,7 +1115,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) static mslist ValueParams; ValueParams.clearitems(); - for (int i = 0; i < Params.size() - 3; i++) + for (unsigned int i = 0; i < Params.size() - 3; i++) ValueParams.add(&(Params[i + 3])); SetClEntityProp(p->entity, Cmd, ValueParams); @@ -1181,7 +1181,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) static mslist ValueParams; ValueParams.clearitems(); - for (int i = 0; i < Params.size() - 3; i++) + for (unsigned int i = 0; i < Params.size() - 3; i++) ValueParams.add(&Params[i + 3]); SetClEntityProp(*g_CurrentEnt, Cmd, ValueParams); @@ -1207,7 +1207,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) static mslist ValueParams; ValueParams.clearitems(); - for (int i = 0; i < Params.size() - 3; i++) + for (unsigned int i = 0; i < Params.size() - 3; i++) ValueParams.add(&Params[i + 3]); SetClEntityProp(*pEnt, Cmd, ValueParams); @@ -1222,7 +1222,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) dlight_t NewLight; clrmem(NewLight); bool EntityLight = false; - int NextParm = 2; + unsigned int NextParm = 2; NewLight.origin = StringToVec(Params[NextParm++]); NewLight.radius = atof(Params[NextParm++]); @@ -1385,7 +1385,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) if ( m_Beams.size() > 0 ) { float gcltime = gEngfuncs.GetClientTime(); - for (int i = 0; i < m_Beams.size(); i++) + for (unsigned int i = 0; i < m_Beams.size(); i++) if ( m_Beams[i]->die > 0 && m_Beams[i]->die < gcltime ) m_Beams.erase(i); } @@ -1418,7 +1418,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) if (Params.size() >= 2 && Params[1] == "removeall") { size_t size = m_Beams.size(); - for (int i = 0; i < size; i++) + for (unsigned int i = 0; i < size; i++) { BEAM* pBeam = m_Beams[i]; if ( pBeam ) pBeam->die = 0; @@ -1433,7 +1433,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) /* bool found_beam =false; - for (int i = 0; i < m_Beams.size(); i++) + for (unsigned int i = 0; i < m_Beams.size(); i++) { Print("DEBUG: beam_update checking %i for %i\n",i,beamid); if ( m_Beams[i]->id == beamid ) @@ -1530,7 +1530,7 @@ void CScript::CLScriptedEffect(msstringlist &Params) /*if(Params[2].contains("clmsg")) { msstring sTemp = "ce"; - for (int i = 0; i < Params.size(); i++) //Thothie SEP2019_03 - fix need for "x" param (was Params.size()-1 ) + for (unsigned int i = 0; i < Params.size(); i++) //Thothie SEP2019_03 - fix need for "x" param (was Params.size()-1 ) { if (i > 0) { @@ -1897,7 +1897,7 @@ void DLLEXPORT HUD_TempEntUpdate( { if (g_TempEntNewLevel) { - for (int i = 0; i < MAX_TEMPENT_EXTRA; i++) //On level change, this is called. Clear all tempent extra data from last level + for (unsigned int i = 0; i < MAX_TEMPENT_EXTRA; i++) //On level change, this is called. Clear all tempent extra data from last level clrmem(g_TempEntExtra[i]); g_TempEntNewLevel = false; diff --git a/src/game/client/hud.cpp b/src/game/client/hud.cpp index 211952e9..2e216d46 100644 --- a/src/game/client/hud.cpp +++ b/src/game/client/hud.cpp @@ -383,7 +383,7 @@ void CHud::Shutdown() int CHud::GetSpriteIndex(const char *SpriteName) { // look through the loaded sprite name list for SpriteName - for (int i = 0; i < m_Sprites.size() - 1; ++i) + for (unsigned int i = 0; i < m_Sprites.size() - 1; ++i) { if (m_Sprites[i].Name == SpriteName) return static_cast(i); diff --git a/src/game/client/hud_msg.cpp b/src/game/client/hud_msg.cpp index f7d37d35..c1e97b3f 100644 --- a/src/game/client/hud_msg.cpp +++ b/src/game/client/hud_msg.cpp @@ -65,7 +65,7 @@ void CHud ::MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf) //g_NetCode.m.HostIP = READ_STRING(); MS_INFO("[MsgFunc_InitHUD: CLEnt Readin]"); - for (int i = 0; i < CLPERMENT_TOTALK; i++) + for (unsigned int i = 0; i < CLPERMENT_TOTALK; i++) MSGlobals::ClEntities[i] = READ_SHORT(); int flags = READ_BYTE(); @@ -86,7 +86,7 @@ void CHud ::MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf) MS_INFO("[MsgFunc_InitHUD: Clearvotes]"); vote_t::VotesTypesAllowed.clearitems(); - for (int i = 0; i < vote_t::VotesTypes.size(); i++) + for (unsigned int i = 0; i < vote_t::VotesTypes.size(); i++) if (FBitSet(VotesAllowed, (1 << i))) vote_t::VotesTypesAllowed.add(vote_t::VotesTypes[i]); diff --git a/src/game/client/hud_spectator.cpp b/src/game/client/hud_spectator.cpp index 0f330464..c6f07553 100644 --- a/src/game/client/hud_spectator.cpp +++ b/src/game/client/hud_spectator.cpp @@ -426,7 +426,7 @@ int CHudSpectator::Draw(float flTime) gViewPort->GetAllPlayersInfo(); // loop through all the players and draw additional infos to their sprites on the map - for (int i = 0; i < MAX_PLAYERS; i++) + for (unsigned int i = 0; i < MAX_PLAYERS; i++) { if (m_vPlayerPos[i][2] < 0) // marked as invisible ? @@ -1385,7 +1385,7 @@ void CHudSpectator::CheckOverviewEntities() double time = gEngfuncs.GetClientTime(); // removes old entities from list - for (int i = 0; i < MAX_OVERVIEW_ENTITIES; i++) + for (unsigned int i = 0; i < MAX_OVERVIEW_ENTITIES; i++) { // remove entity from list if it is too old if (m_OverviewEntities[i].killTime < time) @@ -1445,7 +1445,7 @@ void CHudSpectator::DeathMessage(int victim) bool CHudSpectator::AddOverviewEntityToList(HLSPRITE sprite, cl_entity_t *ent, double killTime) { - for (int i = 0; i < MAX_OVERVIEW_ENTITIES; i++) + for (unsigned int i = 0; i < MAX_OVERVIEW_ENTITIES; i++) { // find empty entity slot if (m_OverviewEntities[i].entity == NULL) diff --git a/src/game/client/inputw32.cpp b/src/game/client/inputw32.cpp index 8c76655c..47c05641 100644 --- a/src/game/client/inputw32.cpp +++ b/src/game/client/inputw32.cpp @@ -655,10 +655,11 @@ void IN_StartupJoystick(void) // assume no joystick joy_avail = 0; - int nJoysticks = SDL_NumJoysticks(); + unsigned int nJoysticks = SDL_NumJoysticks(); + if (nJoysticks > 0) { - for (int i = 0; i < nJoysticks; i++) + for (unsigned int i = 0; i < nJoysticks; i++) { if (SDL_IsGameController(i)) { diff --git a/src/game/client/ms/action.cpp b/src/game/client/ms/action.cpp index 04de0345..c5b1c8ec 100644 --- a/src/game/client/ms/action.cpp +++ b/src/game/client/ms/action.cpp @@ -49,7 +49,7 @@ int CHudAction::MsgFunc_Action(const char *pszName, int iSize, void *pbuf) NewAction.Name = READ_STRING(); NewAction.ID = ID; - for (int i = 0; i < PlayerActions.size(); i++) + for (unsigned int i = 0; i < PlayerActions.size(); i++) if (PlayerActions[i].ID == NewAction.ID) { PlayerActions[i] = NewAction; @@ -60,7 +60,7 @@ int CHudAction::MsgFunc_Action(const char *pszName, int iSize, void *pbuf) } else //Remove { - for (int i = 0; i < PlayerActions.size(); i++) + for (unsigned int i = 0; i < PlayerActions.size(); i++) if (PlayerActions[i].ID == ID) { PlayerActions.erase(i); @@ -90,7 +90,7 @@ void CHudAction::UserCmd_Action(void) int iBitsValid = 0; msstring MenuText(msstring(Localized("#ACTION_QUERY")) + "\n\n"); - for (int i = 0; i < PlayerActions.size(); i++) + for (unsigned int i = 0; i < PlayerActions.size(); i++) { //Print("DEBUG: UserCmd_Action: loop: %i %s %s\n",i,PlayerActions[i].Name.c_str(),PlayerActions[i].ID.c_str()); MenuText += (i + 1); diff --git a/src/game/client/ms/clglobal.cpp b/src/game/client/ms/clglobal.cpp index 72657b75..b1ba96d3 100644 --- a/src/game/client/ms/clglobal.cpp +++ b/src/game/client/ms/clglobal.cpp @@ -46,7 +46,7 @@ void MSCLGlobals::AddEnt(CBaseEntity *pEntity) } void MSCLGlobals::RemoveEnt(CBaseEntity *pEntity, bool fDelete) { - for (int e = 0; e < m_ClEntites.size(); e++) + for (unsigned int e = 0; e < m_ClEntites.size(); e++) if (m_ClEntites[e] == pEntity) { m_ClEntites.erase(e); @@ -92,7 +92,7 @@ void MSCLGlobals::InitializePlayer() player.m_SprintDelay = gpGlobals->time; player.m_Initialized = false; - for (int i = 0; i < MAX_PLAYER_HANDITEMS; i++) + for (unsigned int i = 0; i < MAX_PLAYER_HANDITEMS; i++) { MSCLGlobals::CLViewEntities[i].index = MSGlobals::ClEntities[(i != 2) ? CLPERMENT_LEFTVIEW + i : CLPERMENT_LEFTVIEW]; MSCLGlobals::CLViewEntities[i].curstate.number = MSGlobals::ClEntities[(i != 2) ? CLPERMENT_LEFTVIEW + i : CLPERMENT_LEFTVIEW]; @@ -115,7 +115,7 @@ void MSCLGlobals::Think() RemoveEnt(m_ClEntites[e], m_ClEntites[e] != &player); //Call entity Think() functions - for (int e = 0; e < m_ClEntites.size(); e++) + for (unsigned int e = 0; e < m_ClEntites.size(); e++) if (flLastThinkTime <= m_ClEntites[e]->pev->nextthink && m_ClEntites[e]->pev->nextthink < gpGlobals->time) m_ClEntites[e]->Think(); @@ -130,7 +130,7 @@ void MSCLGlobals::PrintAllEntites() Print("Global Items...\n"); int items = 0; - for (int e = 0; e < m_ClEntites.size(); e++) + for (unsigned int e = 0; e < m_ClEntites.size(); e++) Print("Item %i: %s", items++, m_ClEntites[e]->DisplayName()); } @@ -148,7 +148,7 @@ void MSCLGlobals::RemoveAllEntities() //deleted beforehand //(presumably within RemoveAllItems() somewhere) int killed = 0; - for (int e = 0; e < m_ClEntites.size(); e++) + for (unsigned int e = 0; e < m_ClEntites.size(); e++) { CBaseEntity *pEntity = m_ClEntites[e]; if (!pEntity) continue; @@ -235,7 +235,7 @@ string_t MSCLGlobals::AllocString(const char *pszString) return 0; size_t size = m_Strings.size(); - for (int s = 0; s < size; s++) + for (unsigned int s = 0; s < size; s++) { if (FStrEq(m_Strings[s].c_str(), pszString)) return m_Strings[s].c_str() - gpGlobals->pStringBase; diff --git a/src/game/client/ms/clplayer.cpp b/src/game/client/ms/clplayer.cpp index f62bbf53..b7362327 100644 --- a/src/game/client/ms/clplayer.cpp +++ b/src/game/client/ms/clplayer.cpp @@ -1029,11 +1029,11 @@ int __MsgFunc_Item(const char* pszName, int iSize, void* pbuf) CGenericItem* pItem = MSUtil_GetItemByID(lID); msstring Event = READ_STRING(); - int numParams = READ_BYTE(); + unsigned int numParams = READ_BYTE(); msstringlist Params; Params.clear(); - for (int i = 0; i < numParams; i++) + for (unsigned int i = 0; i < numParams; i++) Params.add(READ_STRING()); if (pItem) @@ -1094,7 +1094,7 @@ int __MsgFunc_SetProp(const char* pszName, int iSize, void* pbuf) //Memory dellocation errors when using '.erase()', so I'm now using this loop int idx = READ_BYTE(); msstringlist newSpells; - for (int i = 0; i < player.m_SpellList.size(); i++) + for (unsigned int i = 0; i < player.m_SpellList.size(); i++) if (i != idx) newSpells.add(player.m_SpellList[i]); //Add all spells to the new list except the one to erase player.m_SpellList = newSpells; //Overwrite the player spells with the new list @@ -1128,7 +1128,7 @@ void Player_ToggleInventory() } CGenericItem* pWearable = NULL; //Fallback, in case a pack isn't found - for (int i = 0; i < player.Gear.size(); i++) + for (unsigned int i = 0; i < player.Gear.size(); i++) { CGenericItem* pPack = player.Gear[i]; if (FBitSet(pPack->MSProperties(), ITEM_CONTAINER) && pPack->m_Location > ITEMPOS_HANDS) @@ -1232,7 +1232,7 @@ void __CmdFunc_DynamicNPC(void) } int iBitsValid = 0; - for (int i = 0; i < NPCList.size(); i++) + for (unsigned int i = 0; i < NPCList.size(); i++) { const char* arg = UTIL_VarArgs("%i. %s\n", i + 1, NPCList[i].c_str()); strncat(MenuText, arg, strlen(arg)); @@ -1500,7 +1500,7 @@ int __MsgFunc_CLDllFunc(const char* pszName, int iSize, void* pbuf) case 21: //Retrieve all quickslots (Sent at spawn) { - for (int i = 0; i < MAX_QUICKSLOTS; i++) + for (unsigned int i = 0; i < MAX_QUICKSLOTS; i++) { quickslot_t& QuickSlot = player.m_QuickSlots[i]; QuickSlot.Active = READ_BYTE() ? true : false; diff --git a/src/game/client/ms/health.cpp b/src/game/client/ms/health.cpp index f0f0abc7..48c4cc5f 100644 --- a/src/game/client/ms/health.cpp +++ b/src/game/client/ms/health.cpp @@ -88,7 +88,7 @@ void CHudHealth::Reset(void) // force all the flashing damage icons to expire m_bitsDamage = 0; - for (int i = 0; i < NUM_DMG_TYPES; i++) + for (unsigned int i = 0; i < NUM_DMG_TYPES; i++) { m_dmg[i].fExpire = 0; } @@ -155,7 +155,7 @@ int CHudHealth::MsgFunc_Damage(const char *pszName, int iSize, void *pbuf) vec3_t vecFrom; - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) vecFrom[i] = READ_COORD(); UpdateTiles(gHUD.m_flTime, bitsDamage); @@ -345,7 +345,7 @@ void CHudHealth::UpdateTiles(float flTime, long bitsDamage) // Which types are new? long bitsOn = ~m_bitsDamage & bitsDamage; - for (int i = 0; i < NUM_DMG_TYPES; i++) + for (unsigned int i = 0; i < NUM_DMG_TYPES; i++) { pdmg = &m_dmg[i]; diff --git a/src/game/client/ms/hudid.cpp b/src/game/client/ms/hudid.cpp index 47dc589a..b760180b 100644 --- a/src/game/client/ms/hudid.cpp +++ b/src/game/client/ms/hudid.cpp @@ -148,7 +148,7 @@ int CHudID::MsgFunc_EntInfo(const char *pszName, int iSize, void *pbuf) EntData.Type = (EntType)READ_BYTE(); //Search for a current entry with this info - for (int i = 0; i < player.m_EntInfo.size(); i++) + for (unsigned int i = 0; i < player.m_EntInfo.size(); i++) if (player.m_EntInfo[i].entindex == EntData.entindex) { player.m_EntInfo[i] = EntData; @@ -190,7 +190,7 @@ entinfo_t *CHudID::GetEntInFrontOfMe(float Range) if (tr.fraction < 1.0 && tr.ent) { physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent(tr.ent); - for (int i = 0; i < player.m_EntInfo.size(); i++) + for (unsigned int i = 0; i < player.m_EntInfo.size(); i++) if (player.m_EntInfo[i].entindex == pe->info) return &player.m_EntInfo[i]; } diff --git a/src/game/client/ms/hudmisc.cpp b/src/game/client/ms/hudmisc.cpp index 3c6665b7..2095a559 100644 --- a/src/game/client/ms/hudmisc.cpp +++ b/src/game/client/ms/hudmisc.cpp @@ -202,7 +202,7 @@ void CHudMisc ::UserCmd_RemovePack(void) strncpy(MenuText, "Remove item:\n\n", sizeof(MenuText) ); m_RemoveList.clear(); - for (int i = 0; i < player.Gear.size(); i++) + for (unsigned int i = 0; i < player.Gear.size(); i++) { CGenericItem *pGearItem = player.Gear[i]; if (!FBitSet(pGearItem->MSProperties(), ITEM_WEARABLE) || pGearItem->m_Location == ITEMPOS_HANDS) @@ -315,7 +315,7 @@ void CHudMisc ::UserCmd_Offer(void) } int r = 0; - for (int i = 0; i < MAX_PLAYER_HANDS; i++) + for (unsigned int i = 0; i < MAX_PLAYER_HANDS; i++) { if (!player.Hand(i)) continue; diff --git a/src/game/client/ms/hudscript.cpp b/src/game/client/ms/hudscript.cpp index 20e48f30..8100f70d 100644 --- a/src/game/client/ms/hudscript.cpp +++ b/src/game/client/ms/hudscript.cpp @@ -155,8 +155,7 @@ void CHudScript::Reset( void ) } void CHudScript::InitHUDData( void ) { - int scriptnum = m_Scripts.size(); - for (int i = 0; i < scriptnum; i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) Script_Remove( 0 ); } @@ -176,31 +175,31 @@ int CHudScript::MsgFunc_ClientScript( const char *pszName, int iSize, void *pbuf if( !Action ) //Add Script { msstring ScriptName = READ_STRING( ); - int iParameters = READ_BYTE( ); - for (int i = 0; i < iParameters; i++) Parameters.add(READ_STRING()); + unsigned int iParameters = READ_BYTE( ); + for (unsigned int i = 0; i < iParameters; i++) Parameters.add(READ_STRING()); CScript *Script = CreateScript( ScriptName, Parameters, true, ID ); } else if( Action == 1 ) //Send Msg to Script { - int iParameters = READ_BYTE( ); + unsigned int iParameters = READ_BYTE( ); msstring EventName = READ_STRING( ); //First parameter is the eventname - for (int i = 0; i < (iParameters - 1); i++) Parameters.add(READ_STRING()); + for (unsigned int i = 0; i < (iParameters - 1); i++) Parameters.add(READ_STRING()); - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) { CScript *Script = m_Scripts[i]; if( Script->m.UniqueID != ID ) continue; - for (int p = 0; p < Parameters.size(); p++) - Script->SetVar( msstring("PARAM") + (p+1), Parameters[p].c_str() ); + for (unsigned int p = 0; p < Parameters.size(); p++) + Script->SetVar( msstring("PARAM") + ((int)p+1), Parameters[p].c_str() ); Script->RunScriptEventByName( EventName, Parameters.size() ? &Parameters : NULL ); break; } } else //Remove script { - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) { if( m_Scripts[i]->m.UniqueID != ID ) continue; @@ -218,8 +217,8 @@ CScript *CHudScript::CreateScript(const char* ScriptName, msstringlist &Paramete //If I don't allow dupes, try to find a prev copy of this script if( !AllowDupe ) { - int events = m_Scripts.size(); - for (int i = 0; i < events; i++) + unsigned int events = m_Scripts.size(); + for (unsigned int i = 0; i < events; i++) if( strstr( m_Scripts[i]->m.ScriptFile.c_str(), ScriptName ) ) { UniqueID = m_Scripts[i]->m.UniqueID; @@ -255,8 +254,8 @@ void CHudScript::HandleAnimEvent(const char* Options, const cl_entity_s *clEntit //Latch onto an existing script if( Type == HAE_EITHER || Type == HAE_ATTACH ) { - int events = m_Scripts.size( ); - for (int i = 0; i < events; i++) + unsigned int events = m_Scripts.size( ); + for (unsigned int i = 0; i < events; i++) if( strstr( m_Scripts[i]->m.ScriptFile.c_str(), ScriptName ) ) { Script = m_Scripts[i]; break; } } @@ -273,7 +272,7 @@ void CHudScript::HandleAnimEvent(const char* Options, const cl_entity_s *clEntit static msstringlist Params; Params.clearitems( ); - for (int i = 0; i < ParsedOptions.size()-2; i++) + for (unsigned int i = 0; i < ParsedOptions.size()-2; i++) Params.add( ParsedOptions[i+2] ); Script->RunScriptEventByName( EventName, &Params ); @@ -281,7 +280,7 @@ void CHudScript::HandleAnimEvent(const char* Options, const cl_entity_s *clEntit void CHudScript::Effects_GetView( ref_params_s *pparams, cl_entity_t *ViewModel ) { - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) { CScript *Script = m_Scripts[i]; Vector &ViewOfs = *(Vector *)&pparams->vieworg; @@ -297,7 +296,7 @@ void CHudScript::Effects_GetView( ref_params_s *pparams, cl_entity_t *ViewModel Vector CHudScript::Effects_GetMoveScale( ) { Vector NewScale( 1.0f, 1.0f, 1.0f ); - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) { CScript *Script = m_Scripts[i]; if( Script->VarExists( "game.cleffect.move_scale.forward" ) ) NewScale.x *= atof(Script->GetVar( "game.cleffect.move_scale.forward" )); @@ -310,7 +309,7 @@ Vector CHudScript::Effects_GetMoveScale( ) Vector CHudScript::Effects_GetMove( Vector &OriginalMove ) { Vector NewMove = OriginalMove; - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) { CScript *Script = m_Scripts[i]; NewMove.x += atof(Script->GetVar( "game.cleffect.move_ofs.forward" )); @@ -325,7 +324,7 @@ void CHudScript::Effects_GetFade( screenfade_t &ScreenFade ) { float OldScreenAlpha = ScreenFade.fadealpha; ScreenFade.fadeFlags = 0; - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) { CScript *Script = m_Scripts[i]; if( !atoi(Script->GetVar( "game.cleffect.screenfade.newfade" )) ) @@ -356,14 +355,14 @@ void CHudScript::Effects_GetFade( screenfade_t &ScreenFade ) } void CHudScript::Effects_PreRender( ) { - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) if( m_Scripts[i]->m.m_HandleRender ) m_Scripts[i]->RunScriptEventByName( "game_prerender" ); } void CHudScript::Effects_Render( cl_entity_t &Ent, bool InMirror ) { - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) if( m_Scripts[i]->m.m_HandleRender ) { static msstringlist Params; @@ -376,7 +375,7 @@ void CHudScript::Effects_Render( cl_entity_t &Ent, bool InMirror ) void CHudScript::Effects_DrawTransPararentTriangles( ) { - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) if( m_Scripts[i]->m.m_HandleRender ) m_Scripts[i]->RunScriptEventByName( "game_render_transparent" ); } diff --git a/src/game/client/ms/menu.cpp b/src/game/client/ms/menu.cpp index 6231f2e6..c70aa768 100644 --- a/src/game/client/ms/menu.cpp +++ b/src/game/client/ms/menu.cpp @@ -94,7 +94,7 @@ int CHudMenu ::Draw(float flTime) // count the number of newlines int nlc = 0; - for (int i = 0; i < MAX_MENU_STRING && m.cMenuText[i] != '\0'; i++) + for (unsigned int i = 0; i < MAX_MENU_STRING && m.cMenuText[i] != '\0'; i++) { if (m.cMenuText[i] == '\n') nlc++; diff --git a/src/game/client/render/clrender.cpp b/src/game/client/render/clrender.cpp index fa2e0162..e9c0997e 100644 --- a/src/game/client/render/clrender.cpp +++ b/src/game/client/render/clrender.cpp @@ -14,10 +14,9 @@ #include "entity_state.h" #include "cl_entity.h" #include "triangleapi.h" -#include "const.h" + #include "com_model.h" #include "studio.h" -#include "entity_state.h" #include "studio_util.h" #include "r_studioint.h" #include "ref_params.h" @@ -44,7 +43,6 @@ extern "C" }; //TWHL Project - Thothie JUN2010_22 -#include "r_studioint.h" extern engine_studio_api_t IEngineStudio; @@ -214,7 +212,7 @@ class CSkyBox m_uiNextTexIdx = 1; m_SkyName = "g_morning"; - for (int i = 0; i < 6; i++) + for (unsigned int i = 0; i < 6; i++) { Faces.add(skyface_t()); @@ -227,7 +225,7 @@ class CSkyBox //Called once each level load void Setup() //Be sure to call after EngineFunc stuff is valid { - for (int i = 0; i < Faces.size(); i++) + for (unsigned int i = 0; i < Faces.size(); i++) { CParticle &Face = Faces[i].Face; Face.SetAngles(g_SkyBoxInfo[i].Dir); @@ -248,7 +246,7 @@ class CSkyBox void ChangeTexture(const char* NewTexture) { m_SkyName = NewTexture; - for (int i = 0; i < Faces.size(); i++) + for (unsigned int i = 0; i < Faces.size(); i++) { msstring FileName = /*msstring(EngineFunc::GetGameDir()) + "/" +*/ msstring(SKYFILENAME_PREFIX) + NewTexture + g_SkyBoxInfo[i].FileNameSuffix + ".tga"; Faces[i].Face.m_GLTex = 0; @@ -261,7 +259,7 @@ class CSkyBox //if( MSGlobals::GameScript ) // MSGlobals::GameScript->CallScriptEvent( "game_render_sky" ); - for (int i = 0; i < Faces.size(); i++) + for (unsigned int i = 0; i < Faces.size(); i++) { CParticle &Face = Faces[i].Face; Face.m_Width = v_ViewDist - 1; @@ -322,12 +320,12 @@ void TraverseAllNodes(mnode_t *pNode, void *Func) { //Call Function on Leaf mleaf_t &Leaf = *(mleaf_t *)&Node; - for (int s = 0; s < Leaf.nummarksurfaces; s++) + for (unsigned int s = 0; s < Leaf.nummarksurfaces; s++) (*(ParseAllSurfacesFunc *)Func)(Leaf.firstmarksurface[s]); return; } - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) TraverseAllNodes(Node.children[i], Func); } @@ -557,7 +555,7 @@ mslist g_VGUIImages; void VGUIImages_NewLevel() { //Reload the TGA textures for the 3D VGUI Images - for (int i = 0; i < g_VGUIImages.size(); i++) + for (unsigned int i = 0; i < g_VGUIImages.size(); i++) { if (g_VGUIImages[i]->m_TGAorSprite) { @@ -647,7 +645,7 @@ void VGUI_Image3D::paintBackground() VGUI_Image3D::~VGUI_Image3D() { - for (int i = 0; i < g_VGUIImages.size(); i++) + for (unsigned int i = 0; i < g_VGUIImages.size(); i++) if (g_VGUIImages[i] == this) { g_VGUIImages.erase(i); @@ -667,7 +665,7 @@ bool LoadGLTexture(const char *FileName, loadtex_t &LoadTex) { bool Loaded = false; - for (int i = 0; i < g_TextureList.size(); i++) + for (unsigned int i = 0; i < g_TextureList.size(); i++) { if (g_TextureList[i].Name == FileName) { @@ -706,7 +704,7 @@ bool LoadGLTexture(const char *FileName, uint &TextureID) void DeleteGLTextures() { - for (int i = 0; i < g_TextureList.size(); i++) + for (unsigned int i = 0; i < g_TextureList.size(); i++) glDeleteTextures(1, &g_TextureList[i].GLTexureID); g_TextureList.clear(); } diff --git a/src/game/client/render/clrender.h b/src/game/client/render/clrender.h index a8b68645..60162660 100644 --- a/src/game/client/render/clrender.h +++ b/src/game/client/render/clrender.h @@ -140,7 +140,7 @@ class Plane bool BBoxIsInFront(Vector Bounds[2]) { Vector Point; - for (int i = 0; i < 6; i++) + for (unsigned int i = 0; i < 6; i++) { switch (i) { diff --git a/src/game/client/render/clrenderent.cpp b/src/game/client/render/clrenderent.cpp index 9ef48685..5d74afe0 100644 --- a/src/game/client/render/clrenderent.cpp +++ b/src/game/client/render/clrenderent.cpp @@ -35,7 +35,7 @@ void Game_AddObjects(void) { g_FirstRender = true; - for (int i = 0; i < MSCLGlobals::m_ClModels.size(); i++) + for (unsigned int i = 0; i < MSCLGlobals::m_ClModels.size(); i++) { cl_entity_t &Entity = MSCLGlobals::m_ClModels[i]; CLFrameShowModel(Entity); @@ -108,7 +108,7 @@ bool cl_entity_s::PlayAnim(const char* Anim) pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); - for (int i = 0; i < pstudiohdr->numseq; i++) + for (unsigned int i = 0; i < pstudiohdr->numseq; i++) { if (_stricmp(pseqdesc[i].label, Anim) != 0) continue; @@ -206,7 +206,7 @@ void CBasePlayer::BeginRender() void CBasePlayer::Render() { - for (int i = 0; i < g_RenderEnts.size(); i++) + for (unsigned int i = 0; i < g_RenderEnts.size(); i++) g_RenderEnts[i]->Render(); } void CBasePlayer::RenderCleanup() @@ -214,8 +214,8 @@ void CBasePlayer::RenderCleanup() mslist RenderEntListCopy; RenderEntListCopy = g_RenderEnts; - int size = RenderEntListCopy.size(); - for (int i = 0; i < size; i++) + unsigned int size = RenderEntListCopy.size(); + for (unsigned int i = 0; i < size; i++) { CRenderEntity *pRdrEnt = RenderEntListCopy[i]; if (pRdrEnt->IsPermanent()) @@ -236,7 +236,7 @@ void CRenderEntity::Render() } void CRenderEntity::UnRegister() { - for (int i = 0; i < g_RenderEnts.size(); i++) + for (unsigned int i = 0; i < g_RenderEnts.size(); i++) if (g_RenderEnts[i] == this) { g_RenderEnts.erase(i--); @@ -261,7 +261,7 @@ void CRenderPlayer::Render() //m_Ent.origin and m_Ent.angles are calulated in V_CalcRefdef for precise accuracy. cl_entity_t &Ent = GetEntity(); - /* for (int i = 0; i < HUMAN_BODYPARTS; i++) + /* for (unsigned int i = 0; i < HUMAN_BODYPARTS; i++) { cl_entity_t &BPEnt = m_BodyParts[i]; BPEnt.SetModel( ModelList[i][m_Gender] ); @@ -282,10 +282,10 @@ void CRenderPlayer::Render() CRenderEntity::Render(); CItemList &Gear = GetGear(); - for (int i = 0; i < Gear.size(); i++) + for (unsigned int i = 0; i < Gear.size(); i++) RenderGearItem(*Gear[i]); - /* for (int i = 0; i < HUMAN_BODYPARTS; i++) + /* for (unsigned int i = 0; i < HUMAN_BODYPARTS; i++) { cl_entity_t &BPEnt = m_BodyParts[i]; if( BPEnt.curstate.number != 0 ) CLFrameShowModel( BPEnt ); @@ -312,7 +312,7 @@ void CRenderPlayer::RenderGearItem(CGenericItem &Item) // foreach( i, Item.m_WearModelPositions.size( ) ) // Ent.SetBody( Item.m_WearModelPositions[i], 1 ); - /* for (int i = 0; i < HUMAN_BODYPARTS; i++) + /* for (unsigned int i = 0; i < HUMAN_BODYPARTS; i++) { cl_entity_t &BPEnt = m_BodyParts[i]; int PlayerBody = Item.Armor_GetBody( i ); @@ -375,11 +375,11 @@ void CRenderPlayerInset::Render() //m_Ent.index = clplayer->index; //m_Ent.curstate.number = clplayer->index; - /* for (int i = 0; i < 4; i++) + /* for (unsigned int i = 0; i < 4; i++) m_Ent.latched.prevcontroller[i] = m_Ent.curstate.controller[i] = 127; m_Ent.curstate.gaitsequence = 0; m_Ent.curstate.framerate = 1; - for (int i = 0; i < 4; i++) + for (unsigned int i = 0; i < 4; i++) m_Ent.attachment[i] = clplayer->attachment[i]; ClearBits( m_Ent.curstate.colormap, MSRDR_ANIM_ONCE ); diff --git a/src/game/client/render/clrendermirror.cpp b/src/game/client/render/clrendermirror.cpp index 02aa8397..6bc258db 100644 --- a/src/game/client/render/clrendermirror.cpp +++ b/src/game/client/render/clrendermirror.cpp @@ -9,7 +9,6 @@ #include "cl_entity.h" #include "dlight.h" #include "triangleapi.h" -#include "com_model.h" #include "studio_util.h" #include "../r_studioint.h" #include "studiomodelrenderer.h" @@ -70,7 +69,7 @@ class CFrustum float FOV = gHUD.m_iFOV ? ((float)gHUD.m_iFOV / 2.0f) : 45; float RightPlaneYaw = FOV; float UpPlanePitch = FOV; - for (int i = 0; i < 6; i++) + for (unsigned int i = 0; i < 6; i++) { Plane &plane = Planes[i]; switch (i) @@ -128,7 +127,7 @@ class CFrustum bool IsBBoxVisible(Vector Bounds[2]) { - for (int i = 0; i < 6; i++) + for (unsigned int i = 0; i < 6; i++) { Plane &plane = Planes[i]; if (!plane.BBoxIsInFront(Bounds)) @@ -147,7 +146,7 @@ bool CheckBBox(Vector Bounds[2]) void CMirrorMgr::Cleanup() { //Clear out old mirror data - for (int m = 0; m < CMirrorMgr::m_MirrorTextures.size(); m++) + for (unsigned int m = 0; m < CMirrorMgr::m_MirrorTextures.size(); m++) { //CMirror &Mirror = CMirrorMgr::m_LevelMirrors[m]; glDeleteTextures(1, &m_MirrorTextures[m]); @@ -182,7 +181,7 @@ bool CheckSurface(TraverseInfo_t &Info, msurface_t *pSurface) return false;*/ mstexture_t *pCustomTexture = NULL; - for (int t = 0; t < MSCLGlobals::Textures.size(); t++) + for (unsigned int t = 0; t < MSCLGlobals::Textures.size(); t++) { mstexture_t &MSTexture = MSCLGlobals::Textures[t]; @@ -204,7 +203,7 @@ bool CheckSurface(TraverseInfo_t &Info, msurface_t *pSurface) { CMirror *pUseMirror = NULL; - for (int m = 0; m < CMirrorMgr::m_Mirrors.size(); m++) + for (unsigned int m = 0; m < CMirrorMgr::m_Mirrors.size(); m++) { CMirror &Mirror = CMirrorMgr::m_Mirrors[m]; if (Mirror.Normal == SurfaceNormal && @@ -223,7 +222,7 @@ bool CheckSurface(TraverseInfo_t &Info, msurface_t *pSurface) for (int t = 0; t < Surface.polys->numverts; t++, Vertex += VERTEXSIZE) { Vector Vert = Vector(Vertex); - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) { if (Vert[i] < Bounds[0][i]) Bounds[0][i] = Vert[i]; @@ -357,7 +356,7 @@ void CMirrorMgr::MarkCustomTextures() if (!m_pStartLeaf || m_pStartLeaf->contents == CONTENTS_SOLID) return; - for (int e = 0; e < ViewMgr.Params->max_entities; e++) //MAX_MAP_MODELS + for (unsigned int e = 0; e < ViewMgr.Params->max_entities; e++) //MAX_MAP_MODELS { cl_entity_t *pEntity = gEngfuncs.GetEntityByIndex(e); if (!pEntity || !pEntity->model) @@ -382,7 +381,7 @@ void CMirrorMgr::MarkCustomTextures() //This is being called on a frame basis. Don't search the world, just check cached level mirrors //Find any cached mirrors with at least one surface close enough to the camera - for (int wm = 0; wm < m_WorldMirrors.size(); wm++) + for (unsigned int wm = 0; wm < m_WorldMirrors.size(); wm++) { CMirror &Mirror = m_WorldMirrors[wm]; @@ -416,17 +415,17 @@ void CMirrorMgr::MarkCustomTextures() continue; //Success = false; - for (int s = 0; s < Model.nummodelsurfaces; s++) + for (unsigned int s = 0; s < Model.nummodelsurfaces; s++) CheckSurface(Info, &Model.surfaces[Model.firstmodelsurface + s]); } } //Store a lookup table. //Surface --> mirror, So I can find child mirrors by the surface - for (int i = 0; i < m_Mirrors.size(); i++) + for (unsigned int i = 0; i < m_Mirrors.size(); i++) { CMirror &Mirror = m_Mirrors[i]; - for (int s = 0; s < Mirror.m_Surfaces.size(); s++) + for (unsigned int s = 0; s < Mirror.m_Surfaces.size(); s++) { rendersurface_t RendSurface; RendSurface.Mirror = &m_Mirrors[i]; @@ -469,7 +468,7 @@ void CMirrorMgr::Render_SetupViewReflection() { // cl_entity_t &WorldEntity = *gEngfuncs.GetEntityByIndex( 0 ); - for (int i = 0; i < m_Mirrors.size(); i++) + for (unsigned int i = 0; i < m_Mirrors.size(); i++) { CMirror &Mirror = m_Mirrors[i]; @@ -639,7 +638,7 @@ void CMirrorMgr::HUD_DrawTransparentTriangles() { CRender::SyncOffScreenSurface(); - for (int i = 0; i < CMirrorMgr::m_RdrMirrors.size(); i++) + for (unsigned int i = 0; i < CMirrorMgr::m_RdrMirrors.size(); i++) { CMirrorMgr::SetupMirrorView(i); CMirrorMgr::m_RdrMirrors[i]->RenderMirroredWorld(0); @@ -712,7 +711,7 @@ bool CMirror::Vis_Eye() //Check if the camera is facing the mirror and not behin } bool CMirror::Vis_Surface() //Check if the camera is close enough to the mirror { - for (int s = 0; s < m_Surfaces.size(); s++) + for (unsigned int s = 0; s < m_Surfaces.size(); s++) { CSurface &Surface = m_Surfaces[s]; @@ -808,7 +807,7 @@ void CMirror::RenderMirroredWorld(int RecurseCall) gEngfuncs.pTriAPI->CullFace(TRI_NONE); - for (int i = 0; i < CMirrorMgr::m_BrushEnts.size(); i++) + for (unsigned int i = 0; i < CMirrorMgr::m_BrushEnts.size(); i++) { cl_entity_t *pEntity = CMirrorMgr::m_BrushEnts[i]; if (!pEntity || !pEntity->model) @@ -851,7 +850,7 @@ void CMirror::RenderMirroredWorld(int RecurseCall) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - for (int s = 0; s < Model.nummodelsurfaces; s++) + for (unsigned int s = 0; s < Model.nummodelsurfaces; s++) Mirror_DrawSurface(Info, &Model.surfaces[Model.firstmodelsurface + s]); } @@ -876,7 +875,7 @@ void CMirror::RenderMirroredWorld(int RecurseCall) //Warning: Drawing entites causes half-life to kill the culling order, so restore it afterwards if (!Mirror.m_Texture->Mirror.NoEnts) - for (int i = 0; i < CMirrorMgr::m_FrameEnts.size(); i++) + for (unsigned int i = 0; i < CMirrorMgr::m_FrameEnts.size(); i++) RenderModel(CMirrorMgr::m_FrameEnts[i]); gEngfuncs.pTriAPI->CullFace(TRI_NONE); //Warning: This must be reset after calling RenderModel. HL changes the mode @@ -897,7 +896,7 @@ void CMirror::RenderMirroredWorld(int RecurseCall) int ChildMirrors = 0; if (!m_Parent && !m_Texture->Mirror.NoWorld) - for (int m = 0; m < m_ChildMirrors.size(); m++) + for (unsigned int m = 0; m < m_ChildMirrors.size(); m++) { CMirror &ChildMirror = *m_ChildMirrors[m]; if (m_ChildMirrors[m] == this) @@ -963,7 +962,7 @@ mleaf_t *FindLeaf(Vector &Origin, mnode_t *pNode) int Side = (Dist >= 0) ? 0 : 1; - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) { mleaf_t *pLeaf = FindLeaf(Origin, Node.children[(i == 0) ? Side : !Side]); if (pLeaf) @@ -983,7 +982,7 @@ inline bool ParseLeaf(TraverseInfo_t &Info, mleaf_t &Leaf) CallFunc = Info.ClipPlane.BBoxIsInFront(Bounds); if (CallFunc) - for (int s = 0; s < Leaf.nummarksurfaces; s++) + for (unsigned int s = 0; s < Leaf.nummarksurfaces; s++) if ((*(ParseSurfaceFunc *)Info.Func)(Info, Leaf.firstmarksurface[s])) Success = true; @@ -1043,7 +1042,7 @@ bool IsLeafVisible(cl_entity_t *pEntity, mnode_t *pNode, mleaf_t *pSearchLeaf) } //Search child nodes - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) { bool Found = IsLeafVisible(pEntity, Node.children[i], pSearchLeaf); if (Found) @@ -1151,14 +1150,14 @@ bool Mirror_DrawSurface(TraverseInfo_t &Info, msurface_t *pSurface) glStencilOp(GL_REPLACE, GL_KEEP, GL_REPLACE); IsMirrorSurface = true; - for (int r = 0; r < CMirrorMgr::m_RenderSurfaces.size(); r++) + for (unsigned int r = 0; r < CMirrorMgr::m_RenderSurfaces.size(); r++) { rendersurface_t &Rend = CMirrorMgr::m_RenderSurfaces[r]; if (Rend.Surface != pSurface || Rend.Mirror == Info.Mirror) continue; bool MirrorAlreadyFound = false; - for (int m = 0; m < Mirror.m_ChildMirrors.size(); m++) + for (unsigned int m = 0; m < Mirror.m_ChildMirrors.size(); m++) if (Mirror.m_ChildMirrors[m] == Rend.Mirror) { MirrorAlreadyFound = true; @@ -1492,7 +1491,7 @@ void CMirror::Draw(int Flags) glMultMatrixf((float *)m_Parent->MirrorMatrix); } - for (int s = 0; s < m_Surfaces.size(); s++) + for (unsigned int s = 0; s < m_Surfaces.size(); s++) { //if( !Mirror.Surfaces[s]->visframe )//!= Mirror.Entity->model->nodes[0].visframe ) // continue; diff --git a/src/game/client/render/studiomodelrenderer.cpp b/src/game/client/render/studiomodelrenderer.cpp index df3f2400..bc39d678 100644 --- a/src/game/client/render/studiomodelrenderer.cpp +++ b/src/game/client/render/studiomodelrenderer.cpp @@ -977,7 +977,7 @@ void CStudioModelRenderer::StudioSetupBones(void) if (m_fDoInterp && Ent.latched.sequencetime && (Ent.latched.sequencetime + 0.2 > m_clTime) && - (Ent.latched.prevsequence < m_pStudioHeader->numseq)) + (Ent.latched.prevsequence < (float)m_pStudioHeader->numseq)) { // blend from last sequence static float pos1b[MAXSTUDIOBONES][3]; diff --git a/src/game/client/status_icons.cpp b/src/game/client/status_icons.cpp index 28141280..81338703 100644 --- a/src/game/client/status_icons.cpp +++ b/src/game/client/status_icons.cpp @@ -57,7 +57,7 @@ int CHudStatusIcons::Draw(float flTime) int y = ScreenHeight / 2; // loop through icon list, and draw any valid icons drawing up from the middle of screen - for (int i = 0; i < MAX_ICONSPRITES; i++) + for (unsigned int i = 0; i < MAX_ICONSPRITES; i++) { if (m_IconList[i].spr) { @@ -149,7 +149,7 @@ void CHudStatusIcons::EnableIcon(const char *pszIconName, unsigned char red, uns void CHudStatusIcons::DisableIcon(const char *pszIconName) { // find the sprite is in the current list - for (int i = 0; i < MAX_ICONSPRITES; i++) + for (unsigned int i = 0; i < MAX_ICONSPRITES; i++) { if (!_stricmp(m_IconList[i].szSpriteName, pszIconName)) { diff --git a/src/game/client/statusbar.cpp b/src/game/client/statusbar.cpp index e766c529..00c15125 100644 --- a/src/game/client/statusbar.cpp +++ b/src/game/client/statusbar.cpp @@ -56,7 +56,7 @@ int CHudStatusBar ::VidInit(void) void CHudStatusBar ::Reset(void) { m_iFlags &= ~HUD_ACTIVE; // start out inactive - for (int i = 0; i < MAX_STATUSBAR_LINES; i++) + for (unsigned int i = 0; i < MAX_STATUSBAR_LINES; i++) m_szStatusText[i][0] = 0; memset(m_iStatusValues, 0, sizeof m_iStatusValues); @@ -166,13 +166,13 @@ int CHudStatusBar ::Draw(float fTime) { if (m_bReparseString) { - for (int i = 0; i < MAX_STATUSBAR_LINES; i++) + for (unsigned int i = 0; i < MAX_STATUSBAR_LINES; i++) ParseStatusString(i); m_bReparseString = FALSE; } // Draw the status bar lines - for (int i = 0; i < MAX_STATUSBAR_LINES; i++) + for (unsigned int i = 0; i < MAX_STATUSBAR_LINES; i++) { int TextHeight, TextWidth; GetConsoleStringSize(m_szStatusBar[i], &TextWidth, &TextHeight); diff --git a/src/game/client/ui/ms/vgui_choosecharacter.cpp b/src/game/client/ui/ms/vgui_choosecharacter.cpp index f74e2e31..679ffb8b 100644 --- a/src/game/client/ui/ms/vgui_choosecharacter.cpp +++ b/src/game/client/ui/ms/vgui_choosecharacter.cpp @@ -73,7 +73,7 @@ #include "mslogger.h" extern engine_studio_api_t IEngineStudio; -int ChooseChar_Interface::ServerCharNum = 0; +unsigned int ChooseChar_Interface::ServerCharNum = 0; bool ChooseChar_Interface::CentralServer; const char *GenderPanel_MainBtnText[] = @@ -96,7 +96,7 @@ class CAction_SelectOption : public ActionSignal { //protected: CNewCharacterPanel *m_pPanel; - int m_Option, m_Value; + unsigned int m_Option, m_Value; static createchar_t m_NewChar; public: CAction_SelectOption( CNewCharacterPanel *pPanel, int iOption, int iValue ) @@ -141,7 +141,7 @@ class CAction_SelectOption : public ActionSignal } else { - msstring CharCmd = msstring("char ") + m_Value + "\n"; + msstring CharCmd = msstring("char ") + (int)m_Value + "\n"; ServerCmd( CharCmd ); } return; @@ -558,7 +558,7 @@ CNewCharacterPanel::CNewCharacterPanel( int iTrans, int iRemoveMe, int x, int y, Gender_GenderLabel->addInputSignal( new GenderInput_ChangeName( this, 1 ) ); StartX = GetCenteredItemX( m_ChoosePanel->getWide(), CHOOSE_BTNWIDTH, 2, XRES(32) ); - for (int i = 0; i < GENDERPANEL_MAINBTNS; i++) + for (unsigned int i = 0; i < GENDERPANEL_MAINBTNS; i++) { int ix = StartX + i * CHOOSE_BTNWIDTH + i * CHOOSE_BTNSPACERX, iy = CHOOSE_BTNY + CHOOSE_CHARHANDLING_H; //int ix = StartX + i * CHOOSE_BTNWIDTH + i * CHOOSE_BTNSPACERX, iy = GENDER_BTNY; @@ -585,7 +585,7 @@ CNewCharacterPanel::CNewCharacterPanel( int iTrans, int iRemoveMe, int x, int y, StartX = GetCenteredItemX( m_ChoosePanel->getWide(), WEAPON_BTN_SIZEX, 3, CHOOSE_BTNSPACERX ); int WeaponPanelSizeY = m_WeaponPanel->getTall( ); - for (int i = 0; i < WEAPONPANEL_MAINBTNS; i++) + for (unsigned int i = 0; i < WEAPONPANEL_MAINBTNS; i++) { if( i >= WEAPONPANEL_MAINBTNMAX ) break; //Max of 9 starting weapon choices @@ -693,7 +693,7 @@ void CNewCharacterPanel::Update() m_ChoosePanel->setVisible( true ); iButtons = CHOOSEPANEL_MAINBTNS; - for (int i = 0; i < iButtons; i++) + for (unsigned int i = 0; i < iButtons; i++) { //Only certain fields can be assumed valid in this savedata //If client-side characters - all savedata_t info is valid; @@ -812,7 +812,7 @@ void CNewCharacterPanel::Update() iButtons = GENDERPANEL_MAINBTNS; break; case STG_CHOOSEWEAPON: - for (int i = 0; i < WEAPONPANEL_MAINBTNS; i++) + for (unsigned int i = 0; i < WEAPONPANEL_MAINBTNS; i++) Weapon_MainBtnImg[i]->LoadImg( ); m_WeaponPanel->setVisible( true ); m_BackBtn->setVisible( true ); @@ -849,7 +849,7 @@ void CNewCharacterPanel::Gender_SelectItem( int Btn ) Gender_CharEnts[0].m_Gender = GENDER_MALE; //Thothie FEB2011_02 gender bender fixes Gender_CharEnts[1].m_Gender = GENDER_FEMALE; //Thothie FEB2011_02 gender bender fixes - for (int i = 0; i < GENDERPANEL_MAINBTNS; i++) + for (unsigned int i = 0; i < GENDERPANEL_MAINBTNS; i++) { Gender_CharEnts[i].SetActive( Btn == 1 ? true : false ); Gender_MainBtn[i]->setEnabled( Btn == 1 ? true : false ); @@ -905,13 +905,13 @@ void CNewCharacterPanel::Close( void ) return; }*/ - for (int i = 0; i < CHOOSEPANEL_MAINBTNS; i++) + for (unsigned int i = 0; i < CHOOSEPANEL_MAINBTNS; i++) { CRenderChar &CharEnt = m_CharEnts[i]; CharEnt.UnRegister( ); } - for (int i = 0; i < GENDERPANEL_MAINBTNS; i++) + for (unsigned int i = 0; i < GENDERPANEL_MAINBTNS; i++) { CRenderChar &CharEnt = Gender_CharEnts[i]; CharEnt.UnRegister( ); @@ -958,7 +958,7 @@ void CNewCharacterPanel::Close( void ) //gViewPort->HideTopMenu( ); //Remove from menu list - for (int i = 0; i < gViewPort->m_Menus.size(); i++) + for (unsigned int i = 0; i < gViewPort->m_Menus.size(); i++) if( gViewPort->m_Menus[i] == this ) { gViewPort->m_Menus.erase( i ); break; } @@ -966,7 +966,7 @@ void CNewCharacterPanel::Close( void ) } //====================================== // Key inputs for the Class Menu -bool CNewCharacterPanel::SlotInput( int iSlot ) +bool CNewCharacterPanel::SlotInput( unsigned int iSlot ) { //Convert iSlot to be zero-based iSlot--; @@ -1013,7 +1013,7 @@ void CNewCharacterPanel::Open( void ) CMenuPanel::Open(); - for (int i = 0; i < CHOOSEPANEL_MAINBTNS; i++) + for (unsigned int i = 0; i < CHOOSEPANEL_MAINBTNS; i++) { CRenderChar &CharEnt = m_CharEnts[i]; CharEnt.m_Stage = STG_CHOOSECHAR; @@ -1021,7 +1021,7 @@ void CNewCharacterPanel::Open( void ) CharEnt.Init( i ); } - for (int i = 0; i < GENDERPANEL_MAINBTNS; i++) + for (unsigned int i = 0; i < GENDERPANEL_MAINBTNS; i++) { CRenderChar &CharEnt = Gender_CharEnts[i]; CharEnt.m_Stage = STG_CHOOSEGENDER; @@ -1088,8 +1088,8 @@ int __MsgFunc_CharInfo(const char* pszName, int iSize, void* pbuf) if (CharMsgType == CHAR_TYPE_ITEMS) { - int GearItems = READ_BYTE(); - for (int i = 0; i < GearItems; i++) + unsigned int GearItems = READ_BYTE(); + for (unsigned int i = 0; i < GearItems; i++) { gearinfo_t GearInfo; GearInfo.Flags = READ_BYTE(); @@ -1183,7 +1183,7 @@ void CRenderChar::Init( int Idx, msstring model ) m_Gender = GENDER_MALE; - for (int i = 0; i < 4; i++) + for (unsigned int i = 0; i < 4; i++) m_Ent.latched.prevcontroller[i] = m_Ent.curstate.controller[i] = 127; m_Ent.curstate.gaitsequence = 0; @@ -1225,7 +1225,7 @@ void CRenderChar::Render( ) m_Gear.clear(); uint BodyParts[HUMAN_BODYPARTS] = { 0 }; - for (int i = 0; i < player.m_CharInfo[m_Idx].GearInfo.size(); i++) + for (unsigned int i = 0; i < player.m_CharInfo[m_Idx].GearInfo.size(); i++) { gearinfo_t &GearInfo = player.m_CharInfo[m_Idx].GearInfo[i]; CGenericItem pItem = CGenericItem(); @@ -1241,7 +1241,7 @@ void CRenderChar::Render( ) ItemEnt.curstate.skin = GearInfo.Skin; ItemEnt.PlayAnim( GearInfo.Anim ); - for (int i = 0; i < HUMAN_BODYPARTS; i++) + for (unsigned int i = 0; i < HUMAN_BODYPARTS; i++) { if( FBitSet( GearInfo.Flags, (1<Reset(); GearItemButtonTotal = 0; } -void VGUI_InventoryPanel::Select(int Idx) +void VGUI_InventoryPanel::Select(unsigned int Idx) { if (Idx < 0 || Idx >= GearItemButtonTotal) return; - for (int i = 0; i < GearItemButtonTotal; i++) + for (unsigned int i = 0; i < GearItemButtonTotal; i++) GearItemButtons[i]->DeSelect(); m_Selected = Idx; @@ -246,7 +246,7 @@ CTFScrollPanel* VGUI_InventoryPanel::GetScrollForStepInput() { if ( mbScrollHighlighted ) return m_Scroll; - for (int i = 0; i < GearItemButtons.size(); i++) + for (unsigned int i = 0; i < GearItemButtons.size(); i++) { if (GearItemButtons[i]->IsMouseOver()) { @@ -412,7 +412,7 @@ void VGUI_ContainerPanel::Update() void VGUI_ContainerPanel::AddInventoryItems() { gearitem_t GearItem; - const int gearSize = player.Gear.size(); + const unsigned int gearSize = player.Gear.size(); std::vector sortedItems; std::vector sortedOther; sortedItems.reserve(gearSize); @@ -422,7 +422,7 @@ void VGUI_ContainerPanel::AddInventoryItems() GearItem.ID = 0; GearItem.IsContainer = true; VGUI_Inv_GearItem *pGearItemButton = m_GearPanel->AddGearItem(GearItem); - for (int i = 0; i < MAX_PLAYER_HANDS; i++) + for (unsigned int i = 0; i < MAX_PLAYER_HANDS; i++) { if (player.Hand(i)) { @@ -431,7 +431,7 @@ void VGUI_ContainerPanel::AddInventoryItems() } } - for (int i = 0; i < gearSize; i++) + for (unsigned int i = 0; i < gearSize; i++) { CGenericItem *pGearItem = player.Gear[i]; const auto props = pGearItem->MSProperties(); // cache property lookup @@ -530,7 +530,7 @@ VGUI_InvTypePanel::VGUI_InvTypePanel(Panel *pParent, VGUI_Container *pCallback) pAlphaCheckBox->SetHandler(new AlphabetizeCheckBoxHandler(pCallback)); addChild(pAlphaCheckBox); - for (int i = 0; i < INVTYPE_BUTTONS_TOTAL; i++) + for (unsigned int i = 0; i < INVTYPE_BUTTONS_TOTAL; i++) { int x = 0, y; @@ -569,7 +569,7 @@ void VGUI_ContainerPanel::Close(void) m_AllowUpdate = false; } -bool VGUI_ContainerPanel::SlotInput(int iSlot) +bool VGUI_ContainerPanel::SlotInput(unsigned int iSlot) { iSlot--; @@ -601,10 +601,10 @@ void VGUI_ContainerPanel::ItemHighlighted(void *pData) bool VGUI_ContainerPanel::HasSelectedItems() { - for(int i = 0; i < m_GearPanel->GearItemButtonTotal; i++) + for(unsigned int i = 0; i < m_GearPanel->GearItemButtonTotal; i++) { VGUI_Inv_GearItem &GearItem = *m_GearPanel->GearItemButtons[i]; - for(int g = 0; g < GearItem.m_ItemContainer->m_ItemButtonTotal; g++) + for(unsigned int g = 0; g < GearItem.m_ItemContainer->m_ItemButtonTotal; g++) { VGUI_ItemButton &ItemButton = *GearItem.m_ItemContainer->m_ItemButtons[g]; if(ItemButton.m_Selected) @@ -619,10 +619,10 @@ void VGUI_ContainerPanel::GetSelectedItems(mslist &SelectedIt { SelectedItems.clear(); - for (int g = 0; g < m_GearPanel->GearItemButtonTotal; g++) + for (unsigned int g = 0; g < m_GearPanel->GearItemButtonTotal; g++) { VGUI_Inv_GearItem &GearItem = *m_GearPanel->GearItemButtons[g]; - for (int i = 0; i < GearItem.m_ItemContainer->m_ItemButtonTotal; i++) + for (unsigned int i = 0; i < GearItem.m_ItemContainer->m_ItemButtonTotal; i++) { VGUI_ItemButton &ItemButton = *GearItem.m_ItemContainer->m_ItemButtons[i]; if (!ItemButton.m_Selected) @@ -636,6 +636,6 @@ void VGUI_ContainerPanel::UnSelectAllItems() { mslist SelectedItems; GetSelectedItems(SelectedItems); - for (int i = 0; i < SelectedItems.size(); i++) + for (unsigned int i = 0; i < SelectedItems.size(); i++) SelectedItems[i]->Select(false); } \ No newline at end of file diff --git a/src/game/client/ui/ms/vgui_container.h b/src/game/client/ui/ms/vgui_container.h index a98c378a..ac639e9d 100644 --- a/src/game/client/ui/ms/vgui_container.h +++ b/src/game/client/ui/ms/vgui_container.h @@ -61,9 +61,9 @@ class VGUI_InventoryPanel : public CTransparentPanel, public VGUI_ItemCallbackPa { public: mslist GearItemButtons; - int GearItemButtonTotal; + unsigned int GearItemButtonTotal; int m_Selected; - int m_InitializedItemButtons; + unsigned int m_InitializedItemButtons; VGUI_ItemCallbackPanel *m_pCallbackPanel; CTFScrollPanel *m_Scroll; bool mbScrollHighlighted; @@ -71,7 +71,7 @@ class VGUI_InventoryPanel : public CTransparentPanel, public VGUI_ItemCallbackPa VGUI_InventoryPanel(VGUI_ItemCallbackPanel *pCallbackPanel, Panel *pParent); virtual VGUI_Inv_GearItem *AddGearItem(gearitem_t &GearItem); - virtual void Select(int Idx); + virtual void Select(unsigned int Idx); virtual void Reset(); //Callbacks @@ -118,7 +118,7 @@ class VGUI_ContainerPanel : public CMenuPanel, public VGUI_ItemCallbackPanel virtual void Close(void); virtual void Update(void); virtual void Initialize(void); - virtual bool SlotInput(int iSlot); + virtual bool SlotInput(unsigned int iSlot); //Callbacks virtual void ItemHighlighted(void* pData); diff --git a/src/game/client/ui/ms/vgui_containerlist.cpp b/src/game/client/ui/ms/vgui_containerlist.cpp index 929217ad..1892b5e1 100644 --- a/src/game/client/ui/ms/vgui_containerlist.cpp +++ b/src/game/client/ui/ms/vgui_containerlist.cpp @@ -169,7 +169,7 @@ void CContainerPanel::DropAllSelected() { mslist vSelectedItems; GetSelectedItems( vSelectedItems ); - for(int i = 0; i < vSelectedItems.size(); i++) + for(unsigned int i = 0; i < vSelectedItems.size(); i++) { ServerCmd( msstring("drop ") + (int)vSelectedItems[i]->m_Data.ID + "\n" ); } @@ -293,13 +293,13 @@ bool CContainerPanel::GearItemClicked(ulong ID) //Extract the IDs of the selected items. I can't keep the list of selected items because the itembuttons get //modified when I start moving items around /*mslist SelectedIDs; - for (int i = 0; i < SelectedItems.size(); i++) + for (unsigned int i = 0; i < SelectedItems.size(); i++) { SelectedIDs.push_back( SelectedItems[i]->m_Data.ID ); SelectedItems[i]->Select( false ); }*/ - for (int i = 0; i < SelectedItems.size(); i++) + for (unsigned int i = 0; i < SelectedItems.size(); i++) { CGenericItem *pItem = MSUtil_GetItemByID(SelectedItems[i]->m_Data.ID, &player); if (!pItem) @@ -358,7 +358,7 @@ void CContainerPanel::Open(void) VGUI_ContainerPanel::Open(); //Select the open pack - for (int i = 0; i < m_GearPanel->GearItemButtonTotal; i++) + for (unsigned int i = 0; i < m_GearPanel->GearItemButtonTotal; i++) { if (player.HasConditions(MONSTER_OPENCONTAINER)) { diff --git a/src/game/client/ui/ms/vgui_eventconsole.h b/src/game/client/ui/ms/vgui_eventconsole.h index b8214231..2ce308ef 100644 --- a/src/game/client/ui/ms/vgui_eventconsole.h +++ b/src/game/client/ui/ms/vgui_eventconsole.h @@ -89,7 +89,7 @@ class VGUI_EventConsole : public Panel m_ScrollBarWidth = m_ScrollPanel->getVerticalScrollBar()->getWide(); int ScrollClientWidth = m_ScrollPanel->getWide() - m_ScrollBarWidth; - for (int i = 0; i < EVENTCON_PREF_MAXLINES; i++) + for (unsigned int i = 0; i < EVENTCON_PREF_MAXLINES; i++) { m_Line[i] = new EventConsoleText( 0, 0, ScrollClientWidth, EVENTCON_LINE_SIZE_Y, NULL ); if( TextFont ) @@ -109,7 +109,7 @@ class VGUI_EventConsole : public Panel if (!Text || !Text[0]) return; - int MaxLines = V_min(EVENTCON_PREF_MAXLINES, EVENTCON_MAXLINES); + unsigned int MaxLines = V_min(EVENTCON_PREF_MAXLINES, EVENTCON_MAXLINES); if( m_TotalLines >= MaxLines ) { @@ -121,7 +121,7 @@ class VGUI_EventConsole : public Panel } // The newest line is always at logical index (m_TotalLines - 1) - int iNewLine = m_TotalLines - 1; + unsigned int iNewLine = m_TotalLines - 1; // If the active line was tracking the bottom, keep it there if( m_ActiveLine >= (iNewLine - 1) ) @@ -129,7 +129,7 @@ class VGUI_EventConsole : public Panel // Reposition all active lines in the scroll panel // (VGUI needs the panels laid out top-to-bottom by logical order) - for( int i = 0; i < m_TotalLines; i++ ) + for (unsigned int i = 0; i < m_TotalLines; i++) { EventConsoleText *line = GetLine(i); line->setParent( m_ScrollPanel->getClient() ); @@ -150,11 +150,11 @@ class VGUI_EventConsole : public Panel char ctemp[512] = ""; int w, h; - int MaxWidth = NewLine.getWide(); - int MaxHeight = EVENTCON_LINE_SIZE_Y; + unsigned int MaxWidth = NewLine.getWide(); + unsigned int MaxHeight = EVENTCON_LINE_SIZE_Y; NewLine.getTextImage()->getFont()->getTextSize( ThisLineText, w, h ); - if( w > MaxWidth || h > MaxHeight ) + if( (unsigned int)w > MaxWidth || (unsigned int)h > MaxHeight ) { int TextLen = (int)strlen(Text); int WrapPos = -1; @@ -170,7 +170,7 @@ class VGUI_EventConsole : public Panel ctemp[mid + 1] = 0; int testw, testh; NewLine.getTextImage()->getFont()->getTextSize( ctemp, testw, testh ); - if( testw > MaxWidth || testh > MaxHeight ) + if( (unsigned int)testw > MaxWidth || (unsigned int)testh > MaxHeight ) hi = mid; else lo = mid + 1; @@ -258,7 +258,7 @@ class VGUI_EventConsole : public Panel if( m_DynamicWidth ) { w = 0; - for (int i = 0; i < m_VisibleLines; i++) + for (unsigned int i = 0; i < m_VisibleLines; i++) { int logIdx = m_ActiveLine - i; EventConsoleText *line = GetLine(logIdx); @@ -303,7 +303,7 @@ class VGUI_EventConsole : public Panel m_VisibleLines--; Resize( ); - int TopLine = V_max( m_ActiveLine - (m_VisibleLines - 1), 0 ); + int TopLine = V_max( m_ActiveLine - (m_VisibleLines - 1), (unsigned int)0 ); EventConsoleText *topLine = GetLine(TopLine); if (topLine != nullptr && !topLine->m_SpansFromPrevLine) @@ -337,7 +337,7 @@ class VGUI_EventConsole : public Panel CTFScrollPanel *m_ScrollPanel; EventConsoleText *m_Line[EVENTCON_MAXLINES]; int m_Head; // index of the oldest (logical 0) line - int m_VisibleLines, + unsigned int m_VisibleLines, m_TotalLines, m_ActiveLine, m_StartY, diff --git a/src/game/client/ui/ms/vgui_health.h b/src/game/client/ui/ms/vgui_health.h index 48afdd25..87636034 100644 --- a/src/game/client/ui/ms/vgui_health.h +++ b/src/game/client/ui/ms/vgui_health.h @@ -179,7 +179,7 @@ namespace PrimaryHUD m_HUDImage.setPos(coords[0] + BAR_W, coords[1] - (7 * BAR_SCALE)); //Charge system - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) { int Multiplier = (i == 0) ? -1 : 1; float OffsetW = CHARGE_SPACER_W + (i == 0) ? CHARGE_W : 0; @@ -196,14 +196,14 @@ namespace PrimaryHUD void Update() { //Update flasks - for (int i = 0; i < 4; i++) + for (unsigned int i = 0; i < 4; i++) m_Bar[i]->Update(); bool bShowHealth = ShowHealth(); m_HUDImage.setVisible(bShowHealth); - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) { m_Charge[i]->setVisible(false); m_ChargeLbl[i]->setVisible(false); @@ -213,7 +213,7 @@ namespace PrimaryHUD std::vector *vHandsItems = new std::vector; //get all hands items - for (int i = 0; i < player.Gear.size(); i++) + for (unsigned int i = 0; i < player.Gear.size(); i++) { CGenericItem* Item = player.Gear[i]; if (Item->m_Location != ITEMPOS_HANDS) @@ -222,7 +222,7 @@ namespace PrimaryHUD vHandsItems->push_back(Item); } - for (int i = 0; i < vHandsItems->size(); i++) + for (unsigned int i = 0; i < vHandsItems->size(); i++) { CGenericItem* Item = vHandsItems->at(i); diff --git a/src/game/client/ui/ms/vgui_healthretro.h b/src/game/client/ui/ms/vgui_healthretro.h index ec9d5c43..c705a561 100644 --- a/src/game/client/ui/ms/vgui_healthretro.h +++ b/src/game/client/ui/ms/vgui_healthretro.h @@ -191,7 +191,7 @@ namespace RetroHUD pLabel->SetFGColorRGB(Color_Text_White); //Charge system - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) { int Multiplier = (i == 0) ? -1 : 1; float OffsetW = CHARGE_SPACER_W + (i == 0) ? CHARGE_W : 0; @@ -208,7 +208,7 @@ namespace RetroHUD void Update() { //Update Health & Mana flasks - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) m_Flask[i]->Update(); bool bShowHealth = ShowHealth(); @@ -229,7 +229,7 @@ namespace RetroHUD m_pWeight->Set(player.Weight(), player.Volume()); - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) { m_Charge[i]->setVisible(false); m_ChargeLbl[i]->setVisible(false); @@ -239,7 +239,7 @@ namespace RetroHUD std::vector *vHandsItems = new std::vector; //get all hands items - for (int i = 0; i < player.Gear.size(); i++) + for (unsigned int i = 0; i < player.Gear.size(); i++) { CGenericItem* Item = player.Gear[i]; if (Item->m_Location != ITEMPOS_HANDS) @@ -248,7 +248,7 @@ namespace RetroHUD vHandsItems->push_back(Item); } - for (int i = 0; i < vHandsItems->size(); i++) + for (unsigned int i = 0; i < vHandsItems->size(); i++) { CGenericItem* Item = vHandsItems->at(i); diff --git a/src/game/client/ui/ms/vgui_hud.cpp b/src/game/client/ui/ms/vgui_hud.cpp index cd0a655a..400884f7 100644 --- a/src/game/client/ui/ms/vgui_hud.cpp +++ b/src/game/client/ui/ms/vgui_hud.cpp @@ -211,12 +211,12 @@ CHUDPanel::~CHUDPanel() delete m_StartSayText; delete m_DebugText; - for(int i = 0; i < m_HUDElements.size(); i++) + for(unsigned int i = 0; i < m_HUDElements.size(); i++) { delete m_HUDElements[i]; } - for(int i = 0; i < m_Consoles.size(); i++) + for(unsigned int i = 0; i < m_Consoles.size(); i++) { delete m_Consoles[i]; } @@ -241,12 +241,12 @@ void CHUDPanel::Cleanup() delete m_StartSayText; delete m_DebugText; - for(int i = 0; i < m_HUDElements.size(); i++) + for(unsigned int i = 0; i < m_HUDElements.size(); i++) { delete m_HUDElements[i]; } - for(int i = 0; i < m_Consoles.size(); i++) + for(unsigned int i = 0; i < m_Consoles.size(); i++) { delete m_Consoles[i]; } @@ -283,8 +283,8 @@ void CHUDPanel::AddHelpWin(const char* Title, const char* Text) return; //Replaces '|' with '\n' - int size = strlen(Text); - for (int i = 0; i < size; i++) + unsigned int size = strlen(Text); + for (unsigned int i = 0; i < size; i++) { if (Text[i] == '|') ((char*)Text)[i] = '\n'; @@ -325,7 +325,7 @@ void CHUDPanel::Think() m_ID->Update(); //Update HUD Elements - for (int i = 0; i < m_HUDElements.size(); i++) + for (unsigned int i = 0; i < m_HUDElements.size(); i++) { msstring d = "HUD Elements loop: "; d += i; @@ -347,7 +347,7 @@ void CHUDPanel::Think() UpdateInfoWindows(m_HelpWindows); //Update Help windows //Update Text Consoles - for (int i = 0; i < m_Consoles.size(); i++) + for (unsigned int i = 0; i < m_Consoles.size(); i++) { msstring d = "Text Consoles: "; d += i; @@ -464,7 +464,7 @@ int __MsgFunc_HUDInfoMsg(const char* pszName, int iSize, void* pbuf) msstring sTitle = READ_STRING(); std::string buffer = ""; - for (int i = 0; i < HelpParts.size(); i++) + for (unsigned int i = 0; i < HelpParts.size(); i++) buffer += static_cast(HelpParts[i]); HUD_ShowHelpWin(sTitle, buffer.c_str()); diff --git a/src/game/client/ui/ms/vgui_id.h b/src/game/client/ui/ms/vgui_id.h index b1b32eaf..00f86927 100644 --- a/src/game/client/ui/ms/vgui_id.h +++ b/src/game/client/ui/ms/vgui_id.h @@ -26,7 +26,7 @@ class VGUI_ID : public Panel setParent(pParent); setBgColor(0, 0, 0, 255); - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) { m_Label[i] = new VGUI_FadeText(this, 0.2, "", 0, i * g_FontID->getTall(), MSLabel::a_center); m_Label[i]->setFont(g_FontID); @@ -155,7 +155,7 @@ class VGUI_ID : public Panel } else { - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) { float PrevDelta = gpGlobals->time - m_Label[i]->m_StartTime; PrevDelta = V_min(PrevDelta, m_Label[i]->m_FadeDuration); @@ -167,12 +167,12 @@ class VGUI_ID : public Panel m_LastID = pEntInfo; m_pClientEnt = (pEntInfo ? gEngfuncs.GetEntityByIndex(pEntInfo->entindex) : NULL); SetStatus(); - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) m_Label[i]->Update(); } void Update() { - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) m_Label[i]->Update(); //get our wanted position @@ -248,7 +248,7 @@ class VGUI_ID : public Panel void NewLevel() { m_LastID = NULL; - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) { m_Label[i]->m_StartTime = -1000; //Ensure ID doesn't show up after a level change m_Label[i]->setText(""); diff --git a/src/game/client/ui/ms/vgui_infowin.h b/src/game/client/ui/ms/vgui_infowin.h index 06df4828..9c6628ef 100644 --- a/src/game/client/ui/ms/vgui_infowin.h +++ b/src/game/client/ui/ms/vgui_infowin.h @@ -85,7 +85,7 @@ class CInfoWindow : public CTransparentPanel setSize(x, y); } - void Update(std::vector &Windows, int idx) + void Update(std::vector &Windows, unsigned int idx) { float elapsedtime = gpGlobals->time - m_TimeDisplayed; @@ -108,7 +108,7 @@ class CInfoWindow : public CTransparentPanel m_iTransparency = 255 - ((255 - INFOWIN_BKTRANS) * fadeamt); int yPos = m_StartY; - for (int i = 0; i < idx; i++) + for (unsigned int i = 0; i < idx; i++) yPos += Windows[i]->getTall() + INFOWIN_DISPLAY_SPACER_Y; if (idx > 0) diff --git a/src/game/client/ui/ms/vgui_localizedpanel.cpp b/src/game/client/ui/ms/vgui_localizedpanel.cpp index 9e9325ed..1075e4bf 100644 --- a/src/game/client/ui/ms/vgui_localizedpanel.cpp +++ b/src/game/client/ui/ms/vgui_localizedpanel.cpp @@ -120,7 +120,7 @@ void CLocalizedPanel::Hide(void) void CLocalizedPanel::Close(void) { - for (int i = 0; i < m_iButtonTotal; i++) + for (unsigned int i = 0; i < m_iButtonTotal; i++) m_ButtonList[i]->setArmed(false); m_pCloseButton->setArmed(false); setVisible(false); @@ -196,7 +196,7 @@ void CLocalizedPanel::AddButton(msstring sText, bool bEnabled, bool bCloseOnClic void CLocalizedPanel::PositionButtons(void) { int x = GetCenteredItem(m_pMainPanel->getWide(), LOCAL_BUTTON_WIDTH, m_iButtonTotal, LOCAL_BUTTON_SPACE); - for (int i = 0; i < m_iButtonTotal; i++) + for (unsigned int i = 0; i < m_iButtonTotal; i++) { m_ButtonList[i]->setPos(x + i * (LOCAL_BUTTON_WIDTH + LOCAL_BUTTON_SPACE), LOCAL_BUTTON_Y); } @@ -204,7 +204,7 @@ void CLocalizedPanel::PositionButtons(void) void CLocalizedPanel::ClearButtons(void) { - for (int i = 0; i < m_iButtonTotal; i++) + for (unsigned int i = 0; i < m_iButtonTotal; i++) { m_ButtonList[i]->setVisible(false); m_pMainPanel->removeChild(m_ButtonList[i]); @@ -284,7 +284,7 @@ void CLocalizedPanel::AddSubPanel( Panel *pPanel ) void CLocalizedPanel::ClearSubPanels( void ) { - for(int i = 0; i < m_iSubPanelTotal; i++) + for(unsigned int i = 0; i < m_iSubPanelTotal; i++) { m_pTextPanel->removeChild( m_SubPanelList[i] ); delete m_SubPanelList[i]; diff --git a/src/game/client/ui/ms/vgui_localizedpanel.h b/src/game/client/ui/ms/vgui_localizedpanel.h index be1774ed..50180df7 100644 --- a/src/game/client/ui/ms/vgui_localizedpanel.h +++ b/src/game/client/ui/ms/vgui_localizedpanel.h @@ -14,10 +14,10 @@ class CLocalizedPanel : public CMenuPanel TextPanel *m_pTitle; // Title label mslist m_ButtonList; // List of all dynamic buttons - int m_iButtonTotal; // Total number of buttons allocated + unsigned int m_iButtonTotal; // Total number of buttons allocated mslist m_SubPanelList; // List of all dynamic sub-panels - int m_iSubPanelTotal; // Total number of sub-panels + unsigned int m_iSubPanelTotal; // Total number of sub-panels CTFScrollPanel *m_pScroll; // Scrolling window Panel *m_pTextPanel; // Panel inside scrolling window diff --git a/src/game/client/ui/ms/vgui_menu_interact.h b/src/game/client/ui/ms/vgui_menu_interact.h index 81378a98..d362d005 100644 --- a/src/game/client/ui/ms/vgui_menu_interact.h +++ b/src/game/client/ui/ms/vgui_menu_interact.h @@ -46,8 +46,8 @@ class VGUI_MenuInteract : public VGUI_MenuBase m_ButtonY = BTN_START_Y; - for (int i = 0; i < INTERACT_MAX_BUTTONS; i++) //Create all the buttons now. Fill them in later - AddButton("", 0, i); + for (unsigned int i = 0; i < INTERACT_MAX_BUTTONS; i++) //Create all the buttons now. Fill them in later + AddButton("", 0, (int)i); // MiB NOV2014_25, center the title and separator NpcInteractMenus.rft m_AllowKeys = true; // MiB 25NOV_2014 - Disable key-input @@ -63,7 +63,7 @@ class VGUI_MenuInteract : public VGUI_MenuBase m_EntIdx = -1; m_Options.clearitems(); - for (int i = 0; i < m_Buttons.size(); i++) //Reset all buttons except cance + for (unsigned int i = 0; i < m_Buttons.size(); i++) //Reset all buttons except cance { m_Buttons[i]->setVisible(false); m_Buttons[i]->setEnabled(true); diff --git a/src/game/client/ui/ms/vgui_menu_main.h b/src/game/client/ui/ms/vgui_menu_main.h index c36bf9a0..2a7aaa04 100644 --- a/src/game/client/ui/ms/vgui_menu_main.h +++ b/src/game/client/ui/ms/vgui_menu_main.h @@ -41,7 +41,7 @@ class VGUI_MenuMain : public VGUI_MenuBase "#CANCEL", XRES(33), 0}; m_ButtonY = BTN_START_Y; - for (int i = 0; i < std::size(g_ButtonNames); i++) + for (unsigned int i = 0; i < std::size(g_ButtonNames); i++) MSButton *pButton = AddButton(Localized(g_ButtonNames[i].Name), g_ButtonNames[i].Width, msvariant(g_ButtonNames[i].OptionScreen)); m_OptionsPanel = new CPanel_Options(this); @@ -53,7 +53,7 @@ class VGUI_MenuMain : public VGUI_MenuBase { m_Buttons[OPT_VOTEKICK]->setEnabled(false); m_Buttons[OPT_VOTETIME]->setEnabled(false); - for (int i = 0; i < vote_t::VotesTypesAllowed.size(); i++) + for (unsigned int i = 0; i < vote_t::VotesTypesAllowed.size(); i++) { if (vote_t::VotesTypesAllowed[i] == "kick") m_Buttons[OPT_VOTEKICK]->setEnabled(true); diff --git a/src/game/client/ui/ms/vgui_menubase.cpp b/src/game/client/ui/ms/vgui_menubase.cpp index 3dc2a08d..38401ddd 100644 --- a/src/game/client/ui/ms/vgui_menubase.cpp +++ b/src/game/client/ui/ms/vgui_menubase.cpp @@ -176,7 +176,7 @@ bool VGUI_MenuBase::SlotInput(int iSlot) // Update the menu before opening it void VGUI_MenuBase::Open(void) { - for (int i = 0; i < m_Buttons.size(); i++) + for (unsigned int i = 0; i < m_Buttons.size(); i++) m_Buttons[i]->setArmed(false); Reset(); @@ -208,7 +208,7 @@ void VGUI_MenuBase::UpdateFade(void) //m_pMainPanel->setBorder( NULL ); //m_pMainPanel->setBorder( m_Border ); - for (int i = 0; i < m_Buttons.size(); i++) + for (unsigned int i = 0; i < m_Buttons.size(); i++) { m_Buttons[i]->m_ArmedColor.a = InveserdFade; m_Buttons[i]->m_UnArmedColor.a = InveserdFade; diff --git a/src/game/client/ui/ms/vgui_moveitempanel.cpp b/src/game/client/ui/ms/vgui_moveitempanel.cpp index ee417289..8155a03d 100644 --- a/src/game/client/ui/ms/vgui_moveitempanel.cpp +++ b/src/game/client/ui/ms/vgui_moveitempanel.cpp @@ -12,7 +12,7 @@ VGUI_MoveItemPanel::VGUI_MoveItemPanel(CContainerPanel *pParent) : CTransparentP int y = 0; int w = 0; - for(int i = 0; i < gNumMoveNumbers + 1; i++) + for(unsigned int i = 0; i < gNumMoveNumbers + 1; i++) { int vNumMove; msstring vsText; @@ -57,7 +57,7 @@ void VGUI_MoveItemPanel::ShowForButton(VGUI_ItemButton *pButton) pButton->getAbsExtents(x, y, w, h); setPos(x,y); - for(int i = 0; i < gNumMoveNumbers; i++) + for(unsigned int i = 0; i < gNumMoveNumbers; i++) { mButtons[i]->setEnabled(pButton->m_Data.Quantity >= gMoveNumbers[i]); } @@ -76,7 +76,7 @@ void VGUI_MoveItemPanel::Move(int vNumMove) void VGUI_MoveItemPanel::setVisible(bool bVisible) { CTransparentPanel::setVisible(bVisible); - for(int i = 0; i < gNumMoveNumbers + 1; i++) + for(unsigned int i = 0; i < gNumMoveNumbers + 1; i++) { mButtons[i]->setArmed(false); } diff --git a/src/game/client/ui/ms/vgui_mscontrols.cpp b/src/game/client/ui/ms/vgui_mscontrols.cpp index c3f07711..3e91f226 100644 --- a/src/game/client/ui/ms/vgui_mscontrols.cpp +++ b/src/game/client/ui/ms/vgui_mscontrols.cpp @@ -30,7 +30,7 @@ BitmapTGA *MSBitmap::GetTGA(const char *pszImageName) if( !pszImageName ) return NULL; - for (int i = 0; i < g_Bitmaps.size(); i++) + for (unsigned int i = 0; i < g_Bitmaps.size(); i++) { if( g_Bitmaps[i].m_TGAorSprite && !strcmp(g_Bitmaps[i].sImageName, pszImageName) ) return g_Bitmaps[i].m_TGA; //Return existing TGA @@ -55,7 +55,7 @@ HLSPRITE MSBitmap::GetSprite(const char *pszImageName) if( !pszImageName ) return NULL; - for (int i = 0; i < g_Bitmaps.size(); i++) + for (unsigned int i = 0; i < g_Bitmaps.size(); i++) if( !g_Bitmaps[i].m_TGAorSprite && !strcmp(g_Bitmaps[i].sImageName, pszImageName) ) return g_Bitmaps[i].m_Sprite; //Return existing Sprite @@ -82,7 +82,7 @@ HLSPRITE MSBitmap::LoadSprite(const char *pszImageName) void MSBitmap::ReloadSprites() { //Reload sprites after a video or level change - for (int i = 0; i < g_Bitmaps.size(); i++) + for (unsigned int i = 0; i < g_Bitmaps.size(); i++) if( !g_Bitmaps[i].m_TGAorSprite ) g_Bitmaps[i].m_Sprite = LoadSprite( g_Bitmaps[i].sImageName ); } @@ -363,7 +363,7 @@ VGUI_ItemButton::VGUI_ItemButton( int x, int y, VGUI_ItemCallbackPanel *pCallbac m_Image.setParent( this ); //Set the label - for (int i = 0; i < ITEMBTN_LABELS_MAX; i++) + for (unsigned int i = 0; i < ITEMBTN_LABELS_MAX; i++) m_Labels[i] = new MSLabel( this, "Item", 0, 0, 1, 1, MSLabel::a_center ); m_Description = new TextPanel( "", 0, 0, 1, 1 ); @@ -385,7 +385,7 @@ VGUI_ItemButton::VGUI_ItemButton( int x, int y, VGUI_ItemCallbackPanel *pCallbac m_Button->removeInputSignal( m_Signal ); removeChild( m_Button ); - for (int i = 0; i < ITEMBTN_LABELS; i++) + for (unsigned int i = 0; i < ITEMBTN_LABELS; i++) { removeChild( Labels[i] ); delete Labels[i]; @@ -435,7 +435,7 @@ void VGUI_ItemButton::Update( ) int lblx, lbly; int w, h; - for (int i = 0; i < ITEMBTN_LABELS_MAX; i++) + for (unsigned int i = 0; i < ITEMBTN_LABELS_MAX; i++) { switch( i ) { @@ -567,7 +567,7 @@ void VGUI_ItemButton::paint( ) } m_Image.SetFGColorRGB( ImageColor ); - for (int i = 0; i < ITEMBTN_LABELS_MAX; i++) + for (unsigned int i = 0; i < ITEMBTN_LABELS_MAX; i++) m_Labels[i]->SetFGColorRGB( LabelColor ); m_Description->SetFGColorRGB( LabelColor ); } @@ -654,7 +654,7 @@ VGUI_ItemButton *VGUI_Container::AddItem(containeritem_t &Item) VGUI_ItemButton &NewItemButton = *m_ItemButtons[m_ItemButtonTotal]; NewItemButton.SetItem(Item); - int iAlphaLoc = m_ItemButtonTotal; + unsigned int iAlphaLoc = m_ItemButtonTotal; if (m_ItemButtonTotal > 0) { @@ -672,7 +672,7 @@ VGUI_ItemButton *VGUI_Container::AddItem(containeritem_t &Item) } iAlphaLoc = lo; - for (int i = m_ItemButtonTotal; i > iAlphaLoc; --i) + for (unsigned int i = m_ItemButtonTotal; i > iAlphaLoc; --i) m_AlphabetizedItemButtons[i] = m_AlphabetizedItemButtons[i - 1]; } @@ -684,7 +684,7 @@ VGUI_ItemButton *VGUI_Container::AddItem(containeritem_t &Item) const int invType = atoi(gEngfuncs.pfnGetCvarString("ms_invtype")); if (IsAlphabetical()) { - for (int i = iAlphaLoc; i < m_ItemButtonTotal; ++i) + for (unsigned int i = iAlphaLoc; i < m_ItemButtonTotal; ++i) UpdatePosition(i, invType); } else @@ -700,7 +700,7 @@ void VGUI_Container::Update( ) { bool bIsAlpha = IsAlphabetical(); const int invType = atoi(gEngfuncs.pfnGetCvarString("ms_invtype")); - for (int i = 0; i < m_ItemButtonTotal; i++) + for (unsigned int i = 0; i < m_ItemButtonTotal; i++) { // MiB FEB2019_24 [ALPHABETICAL_INVENTORY] if ( bIsAlpha ) @@ -749,7 +749,7 @@ void VGUI_Container::UpdatePosition(int idx, int invType) void VGUI_Container::PurgeButtons( ) { //Reset the old buttons - for (int i = 0; i < m_ItemButtonTotal; i++) + for (unsigned int i = 0; i < m_ItemButtonTotal; i++) m_ItemButtons[i]->Reset( ); m_ItemButtonTotal = 0; diff --git a/src/game/client/ui/ms/vgui_mscontrols.h b/src/game/client/ui/ms/vgui_mscontrols.h index 205766de..c6726a8b 100644 --- a/src/game/client/ui/ms/vgui_mscontrols.h +++ b/src/game/client/ui/ms/vgui_mscontrols.h @@ -460,8 +460,8 @@ class VGUI_Container : public CTransparentPanel public: std::vector m_ItemButtons; std::vector m_AlphabetizedItemButtons; // MiB FEB2019_24 [ALPHABETICAL_INVENTORY] - int m_ItemButtonTotal; - int m_InitializedItemButtons; + unsigned int m_ItemButtonTotal; + unsigned int m_InitializedItemButtons; CTFScrollPanel *m_pScrollPanel; VGUI_ItemCallbackPanel *m_CallbackPanel; MSLabel *m_NoItems; @@ -619,7 +619,7 @@ class VGUI_TextPanel : public CTransparentPanel int w, h; m_MessageLabel->getTextSize( w, h ); x += w + 1; - for (int i = 0; i < m_FadeLabels.size(); i++) { m_FadeLabels[i]->getTextSize(w, h); x += w; } + for (unsigned int i = 0; i < m_FadeLabels.size(); i++) { m_FadeLabels[i]->getTextSize(w, h); x += w; } m_FadeLabels.add( new VGUI_FadeText( this, 0, Letter, x, y, XRES(16), m_MessageLabel->getTall() ) ); m_Message += Letter; @@ -636,8 +636,8 @@ class VGUI_TextPanel : public CTransparentPanel { m_VisibleMsg = m_Message; m_MessageLabel->setText( m_Message ); - int sz = m_FadeLabels.size(); - for (int i = 0; i < sz; i++) + unsigned int sz = m_FadeLabels.size(); + for (unsigned int i = 0; i < sz; i++) { m_FadeLabels[0]->setParent( NULL ); delete m_FadeLabels[0]; @@ -654,7 +654,7 @@ class VGUI_TextPanel : public CTransparentPanel void Update( ) { - for (int i = 0; i < m_FadeLabels.size(); i++) + for (unsigned int i = 0; i < m_FadeLabels.size(); i++) { VGUI_FadeText *pFadeText = m_FadeLabels[i]; pFadeText->Update( ); diff --git a/src/game/client/ui/ms/vgui_options.cpp b/src/game/client/ui/ms/vgui_options.cpp index f33a63d1..d424c799 100644 --- a/src/game/client/ui/ms/vgui_options.cpp +++ b/src/game/client/ui/ms/vgui_options.cpp @@ -202,7 +202,7 @@ class VGUI_Options : public CTransparentPanel //m_pScrollPanel->setBorder( new LineBorder( Color(255,255,255,0) ) ); int yPos = PLAYERBTN_START_Y; - for (int i = 0; i < MAX_VOTE_PLAYERS; i++) + for (unsigned int i = 0; i < MAX_VOTE_PLAYERS; i++) { ListButton *pButton = m_pListButton[i] = new ListButton(this, i, PLAYERBTN_X, yPos, PLAYERBTN_SIZE_X, PLAYERBTN_SIZE_Y); pButton->setFont(pSchemes->getFont(hClassWindowText)); @@ -225,7 +225,7 @@ class VGUI_Options : public CTransparentPanel { m_Target = -1; setVisible(true); - for (int i = 0; i < MAX_VOTE_PLAYERS; i++) + for (unsigned int i = 0; i < MAX_VOTE_PLAYERS; i++) { m_pListButton[i]->setArmed(false); m_pListButton[i]->SetBGColorRGB(Color_Transparent); @@ -251,7 +251,7 @@ class VGUI_Options : public CTransparentPanel virtual void ButtonClicked(int idx) { m_Target = idx; - for (int i = 0; i < MAX_VOTE_PLAYERS; i++) + for (unsigned int i = 0; i < MAX_VOTE_PLAYERS; i++) m_pListButton[i]->SetBgColor(Color_Transparent); m_pListButton[m_Target]->SetBgColor(Color_BG_NameHightlight); m_pBegin->setEnabled(true); @@ -290,7 +290,7 @@ class CInitVotePanel : public VGUI_Options if (m_VoteType == "kick") { - for (int i = 0; i < MAX_VOTE_PLAYERS; i++) + for (unsigned int i = 0; i < MAX_VOTE_PLAYERS; i++) if (g_PlayerInfoList[i].name && i != MSCLGlobals::GetLocalPlayerIndex()) { @@ -303,10 +303,10 @@ class CInitVotePanel : public VGUI_Options } else if (m_VoteType == "advtime") { - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) { m_pListButton[i]->setParent(m_pScrollPanel->getClient()); - m_pListButton[i]->setText(Localized(msstring("#VOTE_ADVTIME_OPT") + i)); + m_pListButton[i]->setText(Localized(msstring("#VOTE_ADVTIME_OPT") + (int)i)); UsedBtns++; } } @@ -329,7 +329,7 @@ class CInitVotePanel : public VGUI_Options virtual void ButtonClicked(int idx) { m_Target = idx; - for (int i = 0; i < MAX_VOTE_PLAYERS; i++) + for (unsigned int i = 0; i < MAX_VOTE_PLAYERS; i++) m_pListButton[i]->SetBgColor(Color_Transparent); m_pListButton[m_Target]->SetBgColor(Color_BG_NameHightlight); m_pBegin->setEnabled(true); @@ -435,7 +435,7 @@ class CPartyPanel : public VGUI_Options void Update() { int r = 0; - for (int i = 0; i < MAX_VOTE_PLAYERS; i++) + for (unsigned int i = 0; i < MAX_VOTE_PLAYERS; i++) if (g_PlayerExtraInfo[i].teamname[0] /*&& i != GetLocalPlayerIndex()*/ ) diff --git a/src/game/client/ui/ms/vgui_stats.cpp b/src/game/client/ui/ms/vgui_stats.cpp index 29304499..1e90fd71 100644 --- a/src/game/client/ui/ms/vgui_stats.cpp +++ b/src/game/client/ui/ms/vgui_stats.cpp @@ -145,7 +145,7 @@ CStatPanel::CStatPanel(Panel *pParent) : CMenuPanel(0, false, 0, 0, ScreenWidth, pLabel->getPos(ix, iy); offset = iy + pLabel->getTall(); - for (int i = 0; i < SKILL_MAX_STATS + 1; i++) + for (unsigned int i = 0; i < SKILL_MAX_STATS + 1; i++) { TextPanel *pTextbox = Skill_StatLabel[i] = new TextPanel("", TITLE_SKILLS_X, offset + i * MAINBUTTON_SIZE_Y, MAINBUTTON_SIZE_X, MAINBUTTON_SIZE_Y); @@ -267,7 +267,7 @@ void CStatPanel::Update() } bool FOUND_PARRY = false; - for (int i = 0; i < SKILL_MAX_STATS; i++) + for (unsigned int i = 0; i < SKILL_MAX_STATS; i++) { FOUND_PARRY = FOUND_PARRY || msstring(SkillStatList[i].Name) == "Parry"; bool blank = i == SKILL_MAX_STATS - 1; @@ -306,9 +306,9 @@ void CStatPanel::Update() { int Height = SKILLINFOPANEL_TITLE_Y + SKILLINFOPANEL_TITLE_H + SKILLINFOPANEL_BTM_BORDERSPACER_H; int UnusedSlots = 0; - for (int i = 0; i < STAT_MAGIC_TOTAL; i++) + for (unsigned int i = 0; i < STAT_MAGIC_TOTAL; i++) { - int iSubStats = pStat->m_SubStats.size(); + unsigned int iSubStats = pStat->m_SubStats.size(); if (i >= iSubStats) { m_StatTypeLabel[i]->setVisible(false); @@ -467,7 +467,7 @@ int __MsgFunc_SetStat(const char *pszName, int iSize, void *pbuf) if (iStat < (signed)player.m_Stats.size()) { CStat &Stat = player.m_Stats[iStat]; - for (int i = 0; i < Stat.m_SubStats.size(); i++) + for (unsigned int i = 0; i < Stat.m_SubStats.size(); i++) { Stat.m_SubStats[i].Value = READ_BYTE(); if (Stat.m_Type == CStat::STAT_SKILL) diff --git a/src/game/client/ui/ms/vgui_storage.cpp b/src/game/client/ui/ms/vgui_storage.cpp index f2d1b594..ebb13c9d 100644 --- a/src/game/client/ui/ms/vgui_storage.cpp +++ b/src/game/client/ui/ms/vgui_storage.cpp @@ -76,7 +76,7 @@ void CStoragePanel::AddInventoryItems() { //Find the storage on the player storage_t *pStorage = NULL; - for (int s = 0; s < player.m_Storages.size(); s++) + for (unsigned int s = 0; s < player.m_Storages.size(); s++) if (player.m_Storages[s].Name == player.m_CurrentStorage.StorageName) { pStorage = &player.m_Storages[s]; @@ -100,7 +100,7 @@ void CStoragePanel::AddInventoryItems() //Add the storage items storage_t &Storage = *pStorage; - for (int i = 0; i < Storage.Items.size(); i++) + for (unsigned int i = 0; i < Storage.Items.size(); i++) { containeritem_t vNewItem = containeritem_t(Storage.Items[i]); pGearItemButton->m_ItemContainer->AddItem(vNewItem); @@ -166,7 +166,7 @@ bool CStoragePanel::GearItemClicked(ulong ID) bool leftAnItemOff = false; - for (int i = 0; i < m_SelectedItems.size(); i++) + for (unsigned int i = 0; i < m_SelectedItems.size(); i++) { if (checkValid(m_SelectedItems[i])) //Check it against the bank mask (MiB Feb2008a) { @@ -246,10 +246,10 @@ void CStoragePanel::ItemSelectChanged(ulong ID, bool fSelected) int Valuetotal = 0; - for (int g = 0; g < m_GearPanel->GearItemButtonTotal; g++) + for (unsigned int g = 0; g < m_GearPanel->GearItemButtonTotal; g++) { VGUI_Inv_GearItem &GearItem = *m_GearPanel->GearItemButtons[g]; - for (int i = 0; i < GearItem.m_ItemContainer->m_ItemButtonTotal; i++) + for (unsigned int i = 0; i < GearItem.m_ItemContainer->m_ItemButtonTotal; i++) { VGUI_ItemButton &ItemButton = *GearItem.m_ItemContainer->m_ItemButtons[i]; if (!ItemButton.m_Selected) @@ -282,7 +282,7 @@ void CStoragePanel::ItemSelectChanged(ulong ID, bool fSelected) if( m_SelectedItems.size() > 0 ) { CommandString = "trade sell"; - for (int i = 0; i < m_SelectedItems.size(); i++) + for (unsigned int i = 0; i < m_SelectedItems.size(); i++) { CommandString += " "; CommandString += (int)m_SelectedItems[i].ID; @@ -320,7 +320,7 @@ void Storage_ItemMsg() msstring StorageName = READ_STRING(); storage_t *pStorage = NULL; - for (int s = 0; s < player.m_Storages.size(); s++) + for (unsigned int s = 0; s < player.m_Storages.size(); s++) if (player.m_Storages[s].Name == StorageName) { pStorage = &player.m_Storages[s]; diff --git a/src/game/client/ui/ms/vgui_store.cpp b/src/game/client/ui/ms/vgui_store.cpp index 9004d166..1538011b 100644 --- a/src/game/client/ui/ms/vgui_store.cpp +++ b/src/game/client/ui/ms/vgui_store.cpp @@ -145,7 +145,7 @@ CStoreMenuPanel::CStoreMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide m_pScrollPanel->validate(); // Create the Store buttons - for (int i = 0; i < STORE_BUTTONS; i++) + for (unsigned int i = 0; i < STORE_BUTTONS; i++) { int iYPos = STORE_SIDEBUTTON_TOPLEFT_Y + ( (STORE_SIDEBUTTON_SIZE_Y + STORE_SIDEBUTTON_SPACER_Y) * i ); @@ -205,7 +205,7 @@ void CStoreMenuPanel::Update() char sz[256]; int width, height; pTitleLabel->setText( "%s's Shop", CStorePanel::StoreVendorName.c_str() ); - for (int i = 0; i < STORE_BUTTONS; i++) + for (unsigned int i = 0; i < STORE_BUTTONS; i++) { //Don't show buttons if not activated m_pButtons[i]->setVisible( false ); @@ -256,7 +256,7 @@ void CStoreMenuPanel::Initialize( void ) void CStoreMenuPanel::SetActiveInfo( int iInput ) { // Remove all the Info panels and bring up the specified one - for (int i = 0; i < STORE_BUTTONS; i++) + for (unsigned int i = 0; i < STORE_BUTTONS; i++) { m_pButtons[i]->setArmed( false ); m_pClassInfoPanel[i]->setVisible( false ); diff --git a/src/game/client/ui/ms/vgui_storebuy.cpp b/src/game/client/ui/ms/vgui_storebuy.cpp index 53835f01..f3c84976 100644 --- a/src/game/client/ui/ms/vgui_storebuy.cpp +++ b/src/game/client/ui/ms/vgui_storebuy.cpp @@ -41,7 +41,7 @@ void CStoreBuyPanel::AddInventoryItems() pGearItemButton->setVisible(false); //Add store items with at least 1 in inventory to the container - for (int i = 0; i < StoreItems.size(); i++) + for (unsigned int i = 0; i < StoreItems.size(); i++) if (StoreItems[i].Quantity > 0) pGearItemButton->m_ItemContainer->AddItem(StoreItems[i]); @@ -91,7 +91,7 @@ void CStoreBuyPanel::ItemHighlighted(void *pData) m_InfoPanel->m_SaleText->setText("Price"); containeritem_t &Item = ItemButton.m_Data; - for (int s = 0; s < CStorePanel::StoreItems.size(); s++) + for (unsigned int s = 0; s < CStorePanel::StoreItems.size(); s++) { storeitem_t &StoreItem = CStorePanel::StoreItems[s]; if (Item.Name != StoreItem.Name) diff --git a/src/game/client/ui/ms/vgui_storesell.cpp b/src/game/client/ui/ms/vgui_storesell.cpp index c31154ab..bb1305bf 100644 --- a/src/game/client/ui/ms/vgui_storesell.cpp +++ b/src/game/client/ui/ms/vgui_storesell.cpp @@ -79,7 +79,7 @@ CStoreSellPanel::CStoreSellPanel(Panel *pParent) : CStorePanel() bool CStoreSellPanel::InterestedInItem(const char* pszItemName) { - for (int i = 0; i < CStorePanel::StoreItems.size(); i++) + for (unsigned int i = 0; i < CStorePanel::StoreItems.size(); i++) if (CStorePanel::StoreItems[i].Name == pszItemName) return true; @@ -104,7 +104,7 @@ void CStoreSellPanel::ItemHighlighted(void *pData) m_InfoPanel->m_SaleText->setText("Worthless"); containeritem_t &Item = ItemButton.m_Data; - for (int s = 0; s < CStorePanel::StoreItems.size(); s++) + for (unsigned int s = 0; s < CStorePanel::StoreItems.size(); s++) { storeitem_t &StoreItem = CStorePanel::StoreItems[s]; if (Item.Name != StoreItem.Name) @@ -126,17 +126,17 @@ void CStoreSellPanel::ItemSelectChanged(ulong ID, bool fSelected) int Valuetotal = 0; - for (int g = 0; g < m_GearPanel->GearItemButtonTotal; g++) + for (unsigned int g = 0; g < m_GearPanel->GearItemButtonTotal; g++) { VGUI_Inv_GearItem &GearItem = *m_GearPanel->GearItemButtons[g]; - for (int i = 0; i < GearItem.m_ItemContainer->m_ItemButtonTotal; i++) + for (unsigned int i = 0; i < GearItem.m_ItemContainer->m_ItemButtonTotal; i++) { VGUI_ItemButton &ItemButton = *GearItem.m_ItemContainer->m_ItemButtons[i]; if (!ItemButton.m_Selected) continue; containeritem_t &Item = ItemButton.m_Data; - for (int s = 0; s < CStorePanel::StoreItems.size(); s++) + for (unsigned int s = 0; s < CStorePanel::StoreItems.size(); s++) { storeitem_t &StoreItem = CStorePanel::StoreItems[s]; if (Item.Name != StoreItem.Name) @@ -159,7 +159,7 @@ void CStoreSellPanel::SellAll() if (m_SelectedItems.size() > 0) { CommandString = "trade sell"; - for (int i = 0; i < m_SelectedItems.size(); i++) + for (unsigned int i = 0; i < m_SelectedItems.size(); i++) { CommandString += " "; CommandString += (int)m_SelectedItems[i].ID; diff --git a/src/game/client/ui/vgui_global.cpp b/src/game/client/ui/vgui_global.cpp index a011837e..d8875863 100644 --- a/src/game/client/ui/vgui_global.cpp +++ b/src/game/client/ui/vgui_global.cpp @@ -75,7 +75,7 @@ bool VGUI::HideMenu(VGUI_MainPanel *pPanel) VGUI_MainPanel *VGUI::FindPanel(const char* Name) { - for (int i = 0; i < gViewPort->m_Menus.size(); i++) + for (unsigned int i = 0; i < gViewPort->m_Menus.size(); i++) { VGUI_MainPanel *pPanel = gViewPort->m_Menus[i]; if (pPanel->m_Name == Name) diff --git a/src/game/client/ui/vgui_loadtga.cpp b/src/game/client/ui/vgui_loadtga.cpp index 25016180..771bcbad 100644 --- a/src/game/client/ui/vgui_loadtga.cpp +++ b/src/game/client/ui/vgui_loadtga.cpp @@ -64,7 +64,7 @@ class MemoryInputStream : public vgui::InputStream void readUChar(uchar* buf, int count, bool& success) override { - for (int i = 0; i < count; i++) + for (unsigned int i = 0; i < (unsigned int)count; i++) buf[i] = readUChar(success); } diff --git a/src/game/client/ui/vgui_schememanager.cpp b/src/game/client/ui/vgui_schememanager.cpp index ebc127cc..faae8fff 100644 --- a/src/game/client/ui/vgui_schememanager.cpp +++ b/src/game/client/ui/vgui_schememanager.cpp @@ -379,12 +379,12 @@ CSchemeManager::CSchemeManager(int xRes, int yRes) memcpy(m_pSchemeList, tmpSchemes, sizeof(CScheme) * m_iNumSchemes); // create the fonts - for (int i = 0; i < m_iNumSchemes; i++) + for (unsigned int i = 0; i < m_iNumSchemes; i++) { m_pSchemeList[i].font = NULL; // see if the current font values exist in a previously loaded font - for (int j = 0; j < i; j++) + for (unsigned int j = 0; j < i; j++) { // check if the font name, size, and weight are the same if ( @@ -483,7 +483,7 @@ CSchemeManager::~CSchemeManager() SchemeHandle_t CSchemeManager::getSchemeHandle(const char *schemeName) { // iterate through the list - for (int i = 0; i < m_iNumSchemes; i++) + for (unsigned int i = 0; i < m_iNumSchemes; i++) { if (!_stricmp(schemeName, m_pSchemeList[i].schemeName)) return i; diff --git a/src/game/client/ui/vgui_schememanager.h b/src/game/client/ui/vgui_schememanager.h index f0befbbf..38913d8b 100644 --- a/src/game/client/ui/vgui_schememanager.h +++ b/src/game/client/ui/vgui_schememanager.h @@ -1,7 +1,7 @@ #include // handle to an individual scheme -typedef int SchemeHandle_t; +typedef unsigned int SchemeHandle_t; // Register console variables, etc.. void Scheme_Init(); @@ -33,7 +33,7 @@ class CSchemeManager private: class CScheme; CScheme *m_pSchemeList; - int m_iNumSchemes; + unsigned int m_iNumSchemes; // Resolution we were initted at. int m_xRes; diff --git a/src/game/client/ui/vgui_scorepanel.cpp b/src/game/client/ui/vgui_scorepanel.cpp index 41b2f082..1337f29f 100644 --- a/src/game/client/ui/vgui_scorepanel.cpp +++ b/src/game/client/ui/vgui_scorepanel.cpp @@ -87,7 +87,7 @@ SBColumnInfo g_ColumnInfo[NUM_COLUMNS] = void ScorePanel::HitTestPanel::internalMousePressed(MouseCode code) { - for (int i = 0; i < _inputSignalDar.getCount(); i++) + for (unsigned int i = 0; i < _inputSignalDar.getCount(); i++) { _inputSignalDar[i]->mousePressed(code, this); } @@ -133,7 +133,7 @@ ScorePanel::ScorePanel(int x, int y, int wide, int tall) : Panel(x, y, wide, tal m_HeaderGrid.SetDimensions(NUM_COLUMNS, 1); m_HeaderGrid.SetSpacing(0, 0); - for (int i = 0; i < NUM_COLUMNS; i++) + for (unsigned int i = 0; i < NUM_COLUMNS; i++) { if (g_ColumnInfo[i].m_pTitle && g_ColumnInfo[i].m_pTitle[0] == '#') m_HeaderLabels[i].setText(CHudTextMessage::BufferedLocaliseTextString(g_ColumnInfo[i].m_pTitle)); @@ -900,7 +900,7 @@ void ScorePanel::cursorMoved(int x, int y, Panel *panel) if (GetClientVoiceMgr()->IsInSquelchMode()) { // look for which cell the mouse is currently over - for (int i = 0; i < NUM_ROWS; i++) + for (unsigned int i = 0; i < NUM_ROWS; i++) { int row, col; if (m_PlayerGrids[i].getCellAtPoint(x, y, row, col)) diff --git a/src/game/client/ui/vgui_scrollbar2.cpp b/src/game/client/ui/vgui_scrollbar2.cpp index e07bf708..c19b42cc 100644 --- a/src/game/client/ui/vgui_scrollbar2.cpp +++ b/src/game/client/ui/vgui_scrollbar2.cpp @@ -189,7 +189,7 @@ void ScrollBar2::setRange(int min, int max) void ScrollBar2::fireIntChangeSignal() { - for (int i = 0; i < _intChangeSignalDar.getCount(); i++) + for (unsigned int i = 0; i < _intChangeSignalDar.getCount(); i++) { _intChangeSignalDar[i]->intChanged(_slider->getValue(), this); } @@ -280,7 +280,7 @@ void ScrollBar2::validate() { int buttonOffset = 0; - for (int i = 0; i < 2; i++) + for (unsigned int i = 0; i < 2; i++) { if (_button[i] != null) { diff --git a/src/game/client/ui/vgui_slider2.cpp b/src/game/client/ui/vgui_slider2.cpp index a06345ba..4d3031a2 100644 --- a/src/game/client/ui/vgui_slider2.cpp +++ b/src/game/client/ui/vgui_slider2.cpp @@ -254,7 +254,7 @@ void Slider2::addIntChangeSignal(IntChangeSignal* s) void Slider2::fireIntChangeSignal() { - for(int i=0;i<_intChangeSignalDar.getCount();i++) + for(unsigned int i=0;i<_intChangeSignalDar.getCount();i++) { _intChangeSignalDar[i]->intChanged(getValue(),this); } diff --git a/src/game/client/ui/vgui_status.h b/src/game/client/ui/vgui_status.h index 15737c07..c5265d68 100644 --- a/src/game/client/ui/vgui_status.h +++ b/src/game/client/ui/vgui_status.h @@ -259,7 +259,7 @@ static void SetFN(bool Up) static void AddStatus(const char* Icon, const char* Name, float Dur, bool bSprite = false) { // MiB FEB2019_22 - When sent a duplicate name, reset the duration - for (int i = 0; i < StatusIcons->m_Status.size(); i++) + for (unsigned int i = 0; i < StatusIcons->m_Status.size(); i++) { VGUI_StatusIcon* pIcon = StatusIcons->m_Status[i]; if (pIcon == NULL) continue; @@ -276,7 +276,7 @@ static void AddImg(const char *Img, const char *Name, int x, int y, int w, int h, float Dur = -1.0) { bool found = false; - for (int i = 0; i < StatusIcons->m_Img.size(); i++) + for (unsigned int i = 0; i < StatusIcons->m_Img.size(); i++) //Check for ID conflictions if (!strcmp(Name, StatusIcons->m_Img[i]->m_Name)) { @@ -304,7 +304,7 @@ static void AddImg(const char *Img, const char *Name, void KillStatus(const char *Name) { - for (int i = 0; i < StatusIcons->m_Status.size(); i++) + for (unsigned int i = 0; i < StatusIcons->m_Status.size(); i++) { if (!strcmp(StatusIcons->m_Status[i]->m_Name, Name)) { @@ -316,7 +316,7 @@ void KillStatus(const char *Name) } void KillImg(const char *Name) { - for (int i = 0; i < StatusIcons->m_Img.size(); i++) + for (unsigned int i = 0; i < StatusIcons->m_Img.size(); i++) { if (!strcmp(StatusIcons->m_Img[i]->m_Name, Name)) { diff --git a/src/game/client/ui/vgui_teamfortressviewport.cpp b/src/game/client/ui/vgui_teamfortressviewport.cpp index 40a0a250..b46e30d9 100644 --- a/src/game/client/ui/vgui_teamfortressviewport.cpp +++ b/src/game/client/ui/vgui_teamfortressviewport.cpp @@ -98,7 +98,7 @@ void VGUI_Think() if (!gViewPort) return; - for (int i = 0; i < gViewPort->m_Menus.size(); i++) + for (unsigned int i = 0; i < gViewPort->m_Menus.size(); i++) { gViewPort->m_Menus[i]->Think(); } @@ -224,7 +224,7 @@ void CCommandMenu::AddButton(CommandButton *pButton) bool CCommandMenu::KeyInput(int keyNum) { // loop through all our buttons looking for one bound to keyNum - for (int i = 0; i < m_iButtons; i++) + for (unsigned int i = 0; i < m_iButtons; i++) { if (!m_aButtons[i]->IsNotValid()) { @@ -256,7 +256,7 @@ bool CCommandMenu::KeyInput(int keyNum) //----------------------------------------------------------------------------- void CCommandMenu::ClearButtonsOfArmedState(void) { - for (int i = 0; i < GetNumButtons(); i++) + for (unsigned int i = 0; i < GetNumButtons(); i++) { m_aButtons[i]->setArmed(false); @@ -274,7 +274,7 @@ void CCommandMenu::ClearButtonsOfArmedState(void) //----------------------------------------------------------------------------- CommandButton *CCommandMenu::FindButtonWithSubmenu(CCommandMenu *pSubMenu) { - for (int i = 0; i < GetNumButtons(); i++) + for (unsigned int i = 0; i < GetNumButtons(); i++) { if (m_aButtons[i]->GetSubMenu() == pSubMenu) return m_aButtons[i]; @@ -294,7 +294,7 @@ bool CCommandMenu::RecalculateVisibles(int iNewYPos, bool bHideAll) setPos(_pos[0], iNewYPos); // Cycle through all the buttons in this menu, and see which will be visible - for (int i = 0; i < m_iButtons; i++) + for (unsigned int i = 0; i < m_iButtons; i++) { int iClass = m_aButtons[i]->GetPlayerClass(); if ((iClass && iClass != g_iPlayerClass) || (m_aButtons[i]->IsNotValid()) || bHideAll) @@ -362,7 +362,7 @@ void CCommandMenu::RecalculatePositions(int iYOffset) // We need to force all menus below this one to update their positions now, because they // might have submenus riding off buttons in this menu that have just shifted. - for (int i = 0; i < m_iButtons; i++) + for (unsigned int i = 0; i < m_iButtons; i++) m_aButtons[i]->UpdateSubMenus(iAdjust); setPos(_pos[0], iNewYPos); @@ -373,7 +373,7 @@ void CCommandMenu::MakeVisible(CCommandMenu *pChildMenu) { /* // Push down the button leading to the child menu - for (int i = 0; i < m_iButtons; i++) + for (unsigned int i = 0; i < m_iButtons; i++) { if ( (pChildMenu != NULL) && (m_aButtons[i]->GetSubMenu() == pChildMenu) ) { @@ -643,7 +643,7 @@ void TeamFortressViewport::Initialize(void) strncpy(m_sMapName, "", sizeof(m_sMapName) ); strncpy(m_szServerName, "", sizeof(m_szServerName) ); - for (int i = 0; i < 5; i++) + for (unsigned int i = 0; i < 5; i++) { m_iValidClasses[i] = 0; strncpy(m_sTeamNames[i], "", MAX_TEAMNAME_SIZE); @@ -1003,7 +1003,7 @@ void TeamFortressViewport::HideScoreBoard(void) // Set the submenu of the Command Menu void TeamFortressViewport::SetCurrentCommandMenu(CCommandMenu *pNewMenu) { - for (int i = 0; i < m_iNumMenus; i++) + for (unsigned int i = 0; i < m_iNumMenus; i++) m_pCommandMenus[i]->setVisible(false); m_pCurrentCommandMenu = pNewMenu; @@ -1586,7 +1586,7 @@ void TeamFortressViewport::CreateVGUIMenus() m_Menus.add(CreateHUD_MenuInteract(this)); //Create Interact menu m_Menus.add(m_pLocalizedMenu = new CLocalizedPanel(this)); // MiB MAR2015_01 [LOCAL_PANEL] - Add local panel to list and set pointer - for (int i = 0; i < m_Menus.size(); i++) + for (unsigned int i = 0; i < m_Menus.size(); i++) m_Menus[i]->setVisible(false); m_pHUDPanel->setVisible(true); @@ -1912,7 +1912,7 @@ int TeamFortressViewport::MsgFunc_ValClass(const char *pszName, int iSize, void { BEGIN_READ(pbuf, iSize); - for (int i = 0; i < 5; i++) + for (unsigned int i = 0; i < 5; i++) m_iValidClasses[i] = READ_SHORT(); // Force the menu to update @@ -1927,7 +1927,7 @@ int TeamFortressViewport::MsgFunc_TeamNames(const char *pszName, int iSize, void m_iNumberOfTeams = READ_BYTE(); - for (int i = 0; i < m_iNumberOfTeams; i++) + for (unsigned int i = 0; i < m_iNumberOfTeams; i++) { int teamNum = i + 1; diff --git a/src/game/client/ui/vgui_teamfortressviewport.h b/src/game/client/ui/vgui_teamfortressviewport.h index c6d74ad7..9070fe1d 100644 --- a/src/game/client/ui/vgui_teamfortressviewport.h +++ b/src/game/client/ui/vgui_teamfortressviewport.h @@ -243,7 +243,7 @@ class CCommandMenu : public Panel // Buttons in this menu CommandButton *m_aButtons[MAX_BUTTONS]; - int m_iButtons; + unsigned int m_iButtons; public: CCommandMenu(CCommandMenu *pParentMenu, int x, int y, int wide, int tall) : Panel(x, y, wide, tall) @@ -264,7 +264,7 @@ class CCommandMenu : public Panel CCommandMenu *GetParentMenu() { return m_pParentMenu; }; int GetXOffset() { return m_iXOffset; }; int GetYOffset() { return m_iYOffset; }; - int GetNumButtons() { return m_iButtons; }; + unsigned int GetNumButtons() { return m_iButtons; }; CommandButton *FindButtonWithSubmenu(CCommandMenu *pSubMenu); void ClearButtonsOfArmedState(void); @@ -290,7 +290,7 @@ class TeamFortressViewport : public Panel float m_flMenuOpenTime; float m_flScoreBoardLastUpdated; float m_flSpectatorPanelLastUpdated; - int m_iNumMenus; + unsigned int m_iNumMenus; int m_iCurrentTeamNumber; int m_iCurrentPlayerClass; int m_iUser1; @@ -333,7 +333,7 @@ class TeamFortressViewport : public Panel int m_iValidClasses[5]; int m_iIsFeigning; int m_iIsSettingDetpack; - int m_iNumberOfTeams; + unsigned int m_iNumberOfTeams; int m_iBuildState; int m_iRandomPC; char m_sTeamNames[5][MAX_TEAMNAME_SIZE]; diff --git a/src/game/client/view.cpp b/src/game/client/view.cpp index 26ae18f4..1d7dc7af 100644 --- a/src/game/client/view.cpp +++ b/src/game/client/view.cpp @@ -513,7 +513,7 @@ V_CalcRefdef void V_CalcNormalRefdef(struct ref_params_s *pparams) { cl_entity_t *ent; - int i; + unsigned int i; vec3_t angles; float bob, waterOffset; static viewinterp_t ViewInterp; @@ -572,7 +572,7 @@ void V_CalcNormalRefdef(struct ref_params_s *pparams) if (pparams->hardware) { waterEntity = gEngfuncs.PM_WaterEntity(pparams->simorg); - if (waterEntity >= 0 && waterEntity < pparams->max_entities) + if (waterEntity >= 0 && (unsigned int)waterEntity < pparams->max_entities) { pwater = gEngfuncs.GetEntityByIndex(waterEntity); if (pwater && (pwater->model != NULL)) @@ -890,7 +890,7 @@ void V_SmoothInterpolateAngles(float *startAngle, float *endAngle, float *finalA NormalizeAngles(startAngle); NormalizeAngles(endAngle); - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) { d = endAngle[i] - startAngle[i]; @@ -1119,7 +1119,7 @@ float MaxAngleBetweenAngles(float *a1, float *a2) NormalizeAngles(a1); NormalizeAngles(a2); - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) { d = a2[i] - a1[i]; if (d > 180) diff --git a/src/game/server/angelscript/ASServerEngineImpl.cpp b/src/game/server/angelscript/ASServerEngineImpl.cpp index b2749bf0..22c2b768 100644 --- a/src/game/server/angelscript/ASServerEngineImpl.cpp +++ b/src/game/server/angelscript/ASServerEngineImpl.cpp @@ -244,7 +244,7 @@ bool ASServerEngine::IsValidPlayerImpl(void* player) const MinimalEntity* pEntity = (MinimalEntity*)player; if (pEntity && pEntity->edict_ptr) { int index = g_engfuncs.pfnIndexOfEdict(pEntity->edict_ptr); - return (index > 0 && index <= gpGlobals->maxClients); + return (index > 0 && (unsigned int)index <= gpGlobals->maxClients); } return false; } @@ -317,7 +317,7 @@ void* ASServerEngine::GetEdict(void* entity) const int ASServerEngine::GetPlayerCountImpl() const { int count = 0; - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer* pPlayer = static_cast(UTIL_PlayerByIndex(i)); if (pPlayer && IsValidPlayerImpl(pPlayer)) @@ -546,7 +546,7 @@ void* ASServerEngine::FindPlayerBySteamID(const std::string& steamID) const { if (steamID.empty()) return nullptr; - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer* pPlayer = static_cast(UTIL_PlayerByIndex(i)); if (!pPlayer || !IsValidPlayerImpl(pPlayer)) continue; @@ -567,7 +567,7 @@ void* ASServerEngine::FindPlayerByName(const std::string& playerName) const { if (playerName.empty()) return nullptr; - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer* pPlayer = static_cast(UTIL_PlayerByIndex(i)); if (!pPlayer || !IsValidPlayerImpl(pPlayer)) continue; diff --git a/src/game/server/client.cpp b/src/game/server/client.cpp index b35faa01..8aff1767 100644 --- a/src/game/server/client.cpp +++ b/src/game/server/client.cpp @@ -186,7 +186,8 @@ void ClientDisconnect(edict_t *pEntity) // Try to get Steam ID from client info int iPlayerIndex = ENTINDEX(pEntity) - 1; - if (iPlayerIndex >= 0 && iPlayerIndex < gpGlobals->maxClients) + + if (iPlayerIndex >= 0 && (unsigned int)iPlayerIndex < gpGlobals->maxClients) { clientaddr_t &ClientInfo = g_NewClients[iPlayerIndex]; if (ClientInfo.Addr[0]) @@ -624,7 +625,7 @@ void ClientCommand2(edict_t *pEntity) ALERT(at_console, "[AS_RELOAD_SCRIPTS] Script hot-reload completed successfully\n"); // Send notification to all players - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer* pOtherPlayer = (CBasePlayer*)UTIL_PlayerByIndex(i); if (pOtherPlayer && pOtherPlayer != pPlayer && pOtherPlayer->m_Initialized) @@ -754,7 +755,7 @@ void ClientCommand2(edict_t *pEntity) //Validate default weapon spawn bool validItem = false; - for (int i = 0; i < MSGlobals::DefaultWeapons.size(); i++) + for (unsigned int i = 0; i < MSGlobals::DefaultWeapons.size(); i++) { if (MSGlobals::DefaultWeapons[i] == NewChar.Weapon) { @@ -968,7 +969,7 @@ void ClientCommand2(edict_t *pEntity) for (unsigned int ID = 0; ID < SHRT_MAX; ID++) { bool Duplicate = false; - for (int i = 0; i < pStorage->Items.size(); i++) + for (unsigned int i = 0; i < pStorage->Items.size(); i++) if (pStorage->Items[i].ID == ID) { Duplicate = true; @@ -1385,7 +1386,7 @@ void ClientCommand2(edict_t *pEntity) else if (FStrEq(CMD_ARGV(1), "open")) { //Thothie MAR2011_18 - moved item stacker here to prevent overflow - for (int i = 0; i < pPlayer->Gear.size(); i++) + for (unsigned int i = 0; i < pPlayer->Gear.size(); i++) { CGenericItem *pItem = pPlayer->Gear[i]; if (pItem) @@ -1473,7 +1474,7 @@ void ClientCommand2(edict_t *pEntity) else if (FStrEq(pcmd, "entcount")) { int e = 0; - for (int i = 0; i < gpGlobals->maxEntities; i++) + for (unsigned int i = 0; i < gpGlobals->maxEntities; i++) { edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex(i); if (!pEdict) @@ -2535,7 +2536,7 @@ int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *ho state->owner = 0; if (ent->v.owner) { - int owner = ENTINDEX(ent->v.owner); + unsigned int owner = ENTINDEX(ent->v.owner); // Only care if owned by a player or using special follow if ((owner >= 1 && owner <= gpGlobals->maxClients)) diff --git a/src/game/server/effects/mseffects.cpp b/src/game/server/effects/mseffects.cpp index a0432398..289f0b9d 100644 --- a/src/game/server/effects/mseffects.cpp +++ b/src/game/server/effects/mseffects.cpp @@ -114,7 +114,7 @@ void CTorchLight ::Create(float flDuration, edict_t *peOwner) } void CTorchLight ::Spawn() { - for (int i = 0; i < TORCH_LIGHTS; i++) + for (unsigned int i = 0; i < TORCH_LIGHTS; i++) { pLight[i] = GetClassPtr((CBaseEntity *)NULL); SET_MODEL(pLight[i]->edict(), "models/null.mdl"); @@ -144,13 +144,13 @@ void CTorchLight ::Think() if (FBitSet(pTorchTouse->pev->effects, EF_NODRAW) || pTorchTouse->pev->waterlevel > 2) - for (int i = 0; i < TORCH_LIGHTS; i++) + for (unsigned int i = 0; i < TORCH_LIGHTS; i++) SetBits(pLight[i]->pev->effects, EF_NODRAW); else - for (int i = 0; i < TORCH_LIGHTS; i++) + for (unsigned int i = 0; i < TORCH_LIGHTS; i++) ClearBits(pLight[i]->pev->effects, EF_NODRAW); - for (int i = 0; i < TORCH_LIGHTS; i++) + for (unsigned int i = 0; i < TORCH_LIGHTS; i++) { if (pLight[i]) { @@ -166,7 +166,7 @@ void CTorchLight ::Think() } void CTorchLight ::SUB_Remove() { - for (int i = 0; i < TORCH_LIGHTS; i++) + for (unsigned int i = 0; i < TORCH_LIGHTS; i++) pLight[i]->SUB_Remove(); CBaseEntity ::SUB_Remove(); } @@ -231,7 +231,7 @@ void CChangePlayerSpeed ::Spawn(void) void CChangePlayerSpeed ::Think(void) { - for (int i = 0; i < 256; i++) + for (unsigned int i = 0; i < 256; i++) { playerinfo_t *pInfo = &m_PlayerInfo[i]; if (!pInfo->pePlayer) @@ -267,7 +267,7 @@ void CChangePlayerSpeed ::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE return; playerinfo_t *pInfo = NULL; - for (int i = 0; i < 256; i++) + for (unsigned int i = 0; i < 256; i++) { if (!m_PlayerInfo[i].pePlayer) { @@ -398,7 +398,7 @@ class CMSChangeLevel : public CBaseEntity string_t sDestMap, sDestTrans; void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); if (!pPlayer) diff --git a/src/game/server/enginecallback.h b/src/game/server/enginecallback.h index 24aaf5a7..b070b102 100644 --- a/src/game/server/enginecallback.h +++ b/src/game/server/enginecallback.h @@ -163,7 +163,7 @@ inline void WRITE_STRING(const char* sz) #define WRITE_STRING_MAX 180 // Upper limit for a usermessage is around 192 bytes, keep this in mind! extern char g_pTempStringLimit[WRITE_STRING_MAX]; // Use this to ensure that we only write this many bytes, ensure null terminated string, prevent overflows. -#define WRITE_STRING_LIMIT(src, len) memset(g_pTempStringLimit, 0, WRITE_STRING_MAX); strncpy(g_pTempStringLimit, src, WRITE_STRING_MAX); g_pTempStringLimit[V_min(WRITE_STRING_MAX-1, len)] = 0; WRITE_STRING(g_pTempStringLimit) +#define WRITE_STRING_LIMIT(src, len) memset(g_pTempStringLimit, 0, WRITE_STRING_MAX); strncpy(g_pTempStringLimit, src, WRITE_STRING_MAX); g_pTempStringLimit[V_min((unsigned int)WRITE_STRING_MAX-1, (unsigned int)len)] = 0; WRITE_STRING(g_pTempStringLimit) #endif #define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister) diff --git a/src/game/server/fn/FNSharedDefs.cpp b/src/game/server/fn/FNSharedDefs.cpp index bb94b51f..084900c6 100644 --- a/src/game/server/fn/FNSharedDefs.cpp +++ b/src/game/server/fn/FNSharedDefs.cpp @@ -150,7 +150,7 @@ void FNShared::LoadCharacter(CBasePlayer* pPlayer) if ((pPlayer == NULL) || (pPlayer->steamID64 == 0ULL)) return; - for (int i = 0; i < MAX_CHARSLOTS; i++) + for (unsigned int i = 0; i < MAX_CHARSLOTS; i++) { if (pPlayer->m_CharInfo[i].Status == CDS_LOADING) continue; diff --git a/src/game/server/func_break.cpp b/src/game/server/func_break.cpp index 7acac0ee..2b2a5b70 100644 --- a/src/game/server/func_break.cpp +++ b/src/game/server/func_break.cpp @@ -597,7 +597,7 @@ int CBreakable ::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, flo if (Tokens.size() > 1) { - for (int i = 0; i < Tokens.size(); i++) + for (unsigned int i = 0; i < Tokens.size(); i++) { if (i > 0) Params.add(Tokens[i].c_str()); @@ -623,7 +623,7 @@ int CBreakable ::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, flo Params.clearitems(); if (Tokens.size() > 1) { - for (int i = 0; i < Tokens.size(); i++) + for (unsigned int i = 0; i < Tokens.size(); i++) { if (i > 0) Params.add(Tokens[i].c_str()); @@ -802,10 +802,10 @@ void CBreakable::Die(void) // BUGBUG -- can only find 256 entities on a breakable -- should be enough CBaseEntity *pList[256]; - int count = UTIL_EntitiesInBox(pList, 256, mins, maxs, FL_ONGROUND); + unsigned int count = UTIL_EntitiesInBox(pList, 256, mins, maxs, FL_ONGROUND); if (count) { - for (int i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) { ClearBits(pList[i]->pev->flags, FL_ONGROUND); pList[i]->pev->groundentity = NULL; @@ -915,7 +915,7 @@ void CPushable ::Spawn(void) void CPushable ::Precache(void) { - for (int i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) PRECACHE_SOUND(m_soundNames[i]); if (pev->spawnflags & SF_PUSH_BREAKABLE) diff --git a/src/game/server/gamerules/multiplay_gamerules.cpp b/src/game/server/gamerules/multiplay_gamerules.cpp index 677f3eca..3bbb95a6 100644 --- a/src/game/server/gamerules/multiplay_gamerules.cpp +++ b/src/game/server/gamerules/multiplay_gamerules.cpp @@ -136,7 +136,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() SERVER_EXECUTE( ); m_CurrentVote.fActive = false; - for (int i = 0; i < CLPERMENT_TOTAL; i++) + for (unsigned int i = 0; i < CLPERMENT_TOTAL; i++) { CBaseEntity *pInvEntity = GetClassPtr( (CBaseEntity *)NULL ); SetBits( pInvEntity->pev->flags, FL_DORMANT ); @@ -238,7 +238,7 @@ void CHalfLifeMultiplay::Think( void ) bool CHalfLifeMultiplay::IsAnyPlayerAllowedInMap() { - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer* pPlayer = (CBasePlayer*)UTIL_PlayerByIndex(i); if (!pPlayer) continue; @@ -364,7 +364,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pPlayer ) //Notify all the entities with scripts CBaseEntity *pEntity = NULL; edict_t *pEdict = NULL; - for( int i = 1; i < gpGlobals->maxEntities; i++ ) + for( unsigned int i = 1; i < gpGlobals->maxEntities; i++ ) { pEdict = g_engfuncs.pfnPEntityOfEntIndex( i ); @@ -394,7 +394,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pPlayer ) //SendMOTDToClient( pl->edict() ); // loop through all active players and send their score info to the new client - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pOtherPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); if( !pOtherPlayer ) continue; @@ -783,7 +783,7 @@ float CHalfLifeMultiplay::FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) { if ( pWeapon && pWeapon->m_iId && (pWeapon->iFlags() & ITEM_FLAG_LIMITINWORLD) ) { - if ( NUMBER_OF_ENTITIES() < (gpGlobals->maxEntities - ENTITY_INTOLERANCE) ) + if ( (unsigned int)NUMBER_OF_ENTITIES() < (gpGlobals->maxEntities - ENTITY_INTOLERANCE) ) return 0; // we're past the entity tolerance level, so delay the respawn @@ -1018,7 +1018,7 @@ typedef struct mapcycle_item_s struct mapcycle_item_s *next; char mapname[ 32 ]; - int minplayers, maxplayers; + unsigned int minplayers, maxplayers; char rulebuffer[ MAX_RULE_BUFFER ]; } mapcycle_item_t; @@ -1214,6 +1214,7 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) item->minplayers = 0; item->maxplayers = 0; + unsigned int Minimum = 0; memset( item->rulebuffer, 0, MAX_RULE_BUFFER ); @@ -1223,14 +1224,14 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) if ( s && s[0] ) { item->minplayers = atoi( s ); - item->minplayers = V_max( item->minplayers, 0 ); + item->minplayers = V_max( item->minplayers, Minimum); item->minplayers = V_min( item->minplayers, gpGlobals->maxClients ); } s = g_engfuncs.pfnInfoKeyValue( szBuffer, "maxplayers" ); if ( s && s[0] ) { item->maxplayers = atoi( s ); - item->maxplayers = V_max( item->maxplayers, 0 ); + item->maxplayers = V_max( item->maxplayers, Minimum); item->maxplayers = V_min( item->maxplayers, gpGlobals->maxClients ); } @@ -1336,7 +1337,7 @@ bool CheckBanned(const char* SteamID ) { if( g_BanList.size() <= 0 ) return false; - for (int b = 0; b < g_BanList.size(); b++) + for (unsigned int b = 0; b < g_BanList.size(); b++) if( g_BanList[b] == (const char *)SteamID ) return true; @@ -1417,7 +1418,7 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) int minplayers = 0, maxplayers = 0; strncpy(szFirstMapInList, "edana", sizeof(szFirstMapInList)); // the absolute default level is edana - int curplayers; + unsigned int curplayers; BOOL do_cycle = TRUE; // find the map to change to @@ -1697,7 +1698,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd pPlayer->SendInfoMsg( "You leave the %s party\n", pTeam->TeamName() ); int iTeamPlayers = pTeam->MemberList.size(); if( iTeamPlayers ) - for (int i = 0; i < pTeam->MemberList.size(); i++) + for (unsigned int i = 0; i < pTeam->MemberList.size(); i++) { CBasePlayer *pOtherPlayer = pTeam->GetPlayer( i ); //Send to all other players, but not myself @@ -1754,7 +1755,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd if( pPlayer->m_pTeam && pPlayer->m_pTeam->GetPlayer( 0 ) == pPlayer ) { CBasePlayer *pCheckPlayer = NULL; - for( int n = 1; n <= gpGlobals->maxClients; n++ ) + for(unsigned int n = 1; n <= gpGlobals->maxClients; n++ ) { pCheckPlayer = (CBasePlayer *)UTIL_PlayerByIndex( n ); if( pCheckPlayer && pCheckPlayer->m_pJoinTeam == pPlayer->m_pTeam ) @@ -1771,7 +1772,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd msstring JoinMsg = msstring(pCheckPlayer->DisplayName()) + " joins your party"; pTeam->ValidateUnits( ); - for (int i = 0; i < pTeam->MemberList.size(); i++) + for (unsigned int i = 0; i < pTeam->MemberList.size(); i++) { CBasePlayer *pOtherPlayer = pTeam->GetPlayer( i ); //if( pOtherPlayer ) pOtherPlayer->SendInfoMsg( "%s joins your party\n", STRING(pCheckPlayer->DisplayName) ); @@ -1840,7 +1841,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd ALERT(at_console, "as_reload_scripts: Script hot-reload completed successfully\n"); // Send notification to all players - for( int i = 1; i <= gpGlobals->maxClients; i++ ) + for(unsigned int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer* pOtherPlayer = (CBasePlayer*)UTIL_PlayerByIndex( i ); if( pOtherPlayer && pOtherPlayer != pPlayer ) @@ -2164,7 +2165,7 @@ void CHalfLifeMultiplay::ClientUserInfoChanged( CBasePlayer *pPlayer, const char void CHalfLifeMultiplay::EndMultiplayerGame( void ) { //Delete all the teams - for (int i = 0; i < CTeam::Teams.size(); i++) + for (unsigned int i = 0; i < CTeam::Teams.size(); i++) delete CTeam::Teams[0]; CTeam::Teams.clear(); @@ -2272,7 +2273,7 @@ void CHalfLifeMultiplay :: UpdateVote( ) //Count SPAWNED players (Connecting players don't count) int iTotalPlayers = 0; - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); if( pPlayer && pPlayer->m_fGameHUDInitialized ) @@ -2285,7 +2286,7 @@ void CHalfLifeMultiplay :: UpdateVote( ) //Count votes int iYesVotes = 0; - for(int i = 0; i < gpGlobals->maxClients; i++ ) + for(unsigned int i = 0; i < gpGlobals->maxClients; i++ ) { if( FBitSet( m_CurrentVote.VoteTally,(1<TeamName(), pszName)) return Teams[i]; @@ -41,7 +41,7 @@ CTeam *CTeam::GetTeam(const char *pszName) } CTeam *CTeam::GetTeam(ulong ID) { - for (int i = 0; i < Teams.size(); i++) + for (unsigned int i = 0; i < Teams.size(); i++) if (Teams[i]->m_ID == ID) return Teams[i]; @@ -50,7 +50,7 @@ CTeam *CTeam::GetTeam(ulong ID) void CTeam ::ValidateUnits() { - for (int i = 0; i < MemberList.size(); i++) + for (unsigned int i = 0; i < MemberList.size(); i++) { teamunit_t &Unit = MemberList[i]; if ((ulong)UTIL_PlayerByIndex(Unit.idx) != Unit.ID) @@ -84,7 +84,7 @@ void CTeam ::AddToTeam(CBasePlayer *pPlayer) MemberList.add(Unit); //Update everyone - for (int n = 1; n <= gpGlobals->maxClients; n++) + for (unsigned int n = 1; n <= gpGlobals->maxClients; n++) { CBasePlayer *pSendPlayer = (CBasePlayer *)UTIL_PlayerByIndex(n); if (!pSendPlayer) @@ -98,7 +98,7 @@ void CTeam ::RemoveFromTeam(CBasePlayer *pPlayer) if (!pPlayer || !ExistsInList(pPlayer)) return; - for (int i = 0; i < MemberList.size(); i++) + for (unsigned int i = 0; i < MemberList.size(); i++) if (GetPlayer(i) == pPlayer) { MemberList.erase(i); @@ -106,7 +106,7 @@ void CTeam ::RemoveFromTeam(CBasePlayer *pPlayer) } //Update everyone - for (int n = 1; n <= gpGlobals->maxClients; n++) + for (unsigned int n = 1; n <= gpGlobals->maxClients; n++) { CBasePlayer *pSendPlayer = (CBasePlayer *)UTIL_PlayerByIndex(n); if (!pSendPlayer) @@ -123,7 +123,7 @@ BOOL CTeam ::ExistsInList(CBasePlayer *pPlayer) if (!pPlayer) return FALSE; ValidateUnits(); - for (int i = 0; i < MemberList.size(); i++) + for (unsigned int i = 0; i < MemberList.size(); i++) if (MemberList[i].idx == pPlayer->entindex() && MemberList[i].ID == (ulong)pPlayer) return TRUE; return FALSE; @@ -131,7 +131,7 @@ BOOL CTeam ::ExistsInList(CBasePlayer *pPlayer) CTeam::~CTeam() { ValidateUnits(); - for (int i = 0; i < MemberList.size(); i++) + for (unsigned int i = 0; i < MemberList.size(); i++) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(MemberList[i].idx); if (!pPlayer || (ulong)pPlayer != MemberList[i].ID) diff --git a/src/game/server/ggrenade.cpp b/src/game/server/ggrenade.cpp index 25f0e7cf..2d30d306 100644 --- a/src/game/server/ggrenade.cpp +++ b/src/game/server/ggrenade.cpp @@ -121,8 +121,8 @@ void CGrenade::Explode(TraceResult *pTrace, int bitsDamageType) if (iContents != CONTENTS_WATER) { - int sparkCount = RANDOM_LONG(0, 3); - for (int i = 0; i < sparkCount; i++) + unsigned int sparkCount = RANDOM_LONG(0, 3); + for (unsigned int i = 0; i < sparkCount; i++) Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL); } } diff --git a/src/game/server/hl/animating.cpp b/src/game/server/hl/animating.cpp index c801872c..4b904cfa 100644 --- a/src/game/server/hl/animating.cpp +++ b/src/game/server/hl/animating.cpp @@ -279,7 +279,7 @@ void CBaseAnimating ::SetSequenceBox(void) Vector rmax(-9999, -9999, -9999); Vector base, transformed; - for (int i = 0; i <= 1; i++) + for (unsigned int i = 0; i <= 1; i++) { base.x = bounds[i].x; for (int j = 0; j <= 1; j++) diff --git a/src/game/server/hl/animation.cpp b/src/game/server/hl/animation.cpp index ab8ce426..36db1bad 100644 --- a/src/game/server/hl/animation.cpp +++ b/src/game/server/hl/animation.cpp @@ -92,7 +92,7 @@ int LookupActivity(void *pmodel, entvars_t *pev, int activity) int weighttotal = 0; int seq = ACTIVITY_NOT_AVAILABLE; - for (int i = 0; i < pstudiohdr->numseq; i++) + for (unsigned int i = 0; i < pstudiohdr->numseq; i++) { if (pseqdesc[i].activity == activity) { @@ -119,7 +119,7 @@ int LookupActivityHeaviest(void *pmodel, entvars_t *pev, int activity) int weight = 0; int seq = ACTIVITY_NOT_AVAILABLE; - for (int i = 0; i < pstudiohdr->numseq; i++) + for (unsigned int i = 0; i < pstudiohdr->numseq; i++) { if (pseqdesc[i].activity == activity) { @@ -162,7 +162,7 @@ int LookupSequence(void* pmodel, const char* label) pseqdesc = (mstudioseqdesc_t*)((byte*)pstudiohdr + pstudiohdr->seqindex); - for (int i = 0; i < pstudiohdr->numseq; i++) + for (unsigned int i = 0; i < pstudiohdr->numseq; i++) { if (_stricmp(pseqdesc[i].label, label) == 0) return i; @@ -202,7 +202,7 @@ int IsSoundEvent(int eventNumber) void SequencePrecache(void *pmodel, const char *pSequenceName) { - int index = LookupSequence(pmodel, pSequenceName); + unsigned int index = LookupSequence(pmodel, pSequenceName); if (index >= 0) { studiohdr_t *pstudiohdr; @@ -217,7 +217,7 @@ void SequencePrecache(void *pmodel, const char *pSequenceName) pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + index; pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); - for (int i = 0; i < pseqdesc->numevents; i++) + for (unsigned int i = 0; i < pseqdesc->numevents; i++) { // Don't send client-side events to the server AI if (pevent[i].event >= EVENT_CLIENT) @@ -287,7 +287,7 @@ int GetSequenceFlags(void *pmodel, entvars_t *pev) return pseqdesc->flags; } -int GetAnimationEvent(void* pmodel, entvars_t* pev, MonsterEvent_t* pMonsterEvent, float flStart, float flEnd, int index) +int GetAnimationEvent(void* pmodel, entvars_t* pev, MonsterEvent_t* pMonsterEvent, float flStart, float flEnd, unsigned int index) { studiohdr_t* pstudiohdr; @@ -317,7 +317,7 @@ int GetAnimationEvent(void* pmodel, entvars_t* pev, MonsterEvent_t* pMonsterEven flEnd = 1.0; } - for (; index < pseqdesc->numevents; index++) + for (index; index < pseqdesc->numevents; index++) { // Don't send client-side events to the server AI if (pevent[index].event >= EVENT_CLIENT) @@ -477,7 +477,7 @@ int FindTransition(void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir) if (iInternNode == 0) return iGoalAnim; - int i; + unsigned int i; // look for someone going for (i = 0; i < pstudiohdr->numseq; i++) diff --git a/src/game/server/hl/animation.h b/src/game/server/hl/animation.h index 21a64bc9..591cff15 100644 --- a/src/game/server/hl/animation.h +++ b/src/game/server/hl/animation.h @@ -38,7 +38,7 @@ int FindTransition(void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir); void SetBodygroup(void *pmodel, entvars_t *pev, int iGroup, int iValue); int GetBodygroup(void *pmodel, entvars_t *pev, int iGroup); -int GetAnimationEvent(void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index); +int GetAnimationEvent(void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, unsigned int index); int ExtractBbox(void *pmodel, int sequence, float *mins, float *maxs); // From /engine/studio.h diff --git a/src/game/server/hl/explode.cpp b/src/game/server/hl/explode.cpp index 667285e9..a7195bfb 100644 --- a/src/game/server/hl/explode.cpp +++ b/src/game/server/hl/explode.cpp @@ -232,9 +232,9 @@ void CEnvExplosion::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE // draw sparks if (!(pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS)) { - int sparkCount = RANDOM_LONG(0, 3); + unsigned int sparkCount = RANDOM_LONG(0, 3); - for (int i = 0; i < sparkCount; i++) + for (unsigned int i = 0; i < sparkCount; i++) { Create("spark_shower", pev->origin, tr.vecPlaneNormal, NULL); } diff --git a/src/game/server/hl/monsters.cpp b/src/game/server/hl/monsters.cpp index c470bdb0..a6034588 100644 --- a/src/game/server/hl/monsters.cpp +++ b/src/game/server/hl/monsters.cpp @@ -321,8 +321,8 @@ void CBaseMonster ::Look(int iDistance) // Find only monsters/clients in box, NOT limited to PVS //dbg("Entities in box"); - int count = UTIL_EntitiesInBox(pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT | FL_MONSTER); - for (int i = 0; i < count; i++) + unsigned int count = UTIL_EntitiesInBox(pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT | FL_MONSTER); + for (unsigned int i = 0; i < count; i++) { //dbg("Assign ent Pre"); if (!pList[i]) @@ -2230,7 +2230,7 @@ int CBaseMonster::IRelationship(CBaseEntity *pTarget) BOOL CBaseMonster ::FindCover(Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist) { - int i; + unsigned int i; int iMyHullIndex; int iMyNode; int iThreatNode; @@ -2335,7 +2335,7 @@ BOOL CBaseMonster ::FindCover(Vector vecThreat, Vector vecViewOffset, float flMi //========================================================= BOOL CBaseMonster ::BuildNearestRoute(Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist) { - int i; + unsigned int i; int iMyHullIndex; int iMyNode; float flDist; @@ -2822,7 +2822,7 @@ BOOL CBaseMonster ::FGetNodeRoute(Vector vecDest) //========================================================= int CBaseMonster ::FindHintNode(void) { - int i; + unsigned int i; TraceResult tr; if (!WorldGraph.m_fGraphPresent) diff --git a/src/game/server/hl/nodes.cpp b/src/game/server/hl/nodes.cpp index 8c4eb71f..91becd8a 100644 --- a/src/game/server/hl/nodes.cpp +++ b/src/game/server/hl/nodes.cpp @@ -507,15 +507,15 @@ float CGraph::PathLength(int iStart, int iDest, int iHull, int afCapMask) // Parse the routing table at iCurrentNode for the next node on the shortest path to iDest int CGraph::NextNodeInRoute(int iCurrentNode, int iDest, int iHull, int iCap) { - int iNext = iCurrentNode; - int nCount = iDest + 1; + unsigned int iNext = iCurrentNode; + unsigned int nCount = iDest + 1; char *pRoute = m_pRouteInfo + m_pNodes[iCurrentNode].m_pNextBestNode[iHull][iCap]; // Until we decode the next best node // while (nCount > 0) { - char ch = *pRoute++; + unsigned char ch = *pRoute++; //ALERT(at_aiconsole, "C(%d)", ch); if (ch < 0) { @@ -540,7 +540,7 @@ int CGraph::NextNodeInRoute(int iCurrentNode, int iDest, int iHull, int iCap) // Repeat phrase // - if (nCount <= ch + 1) + if (nCount <= unsigned char(ch + 1)) { iNext = iCurrentNode + *pRoute; if (iNext >= m_cNodes) @@ -582,7 +582,7 @@ int CGraph ::FindShortestPath(int *piPath, int iStart, int iDest, int iHull, int return FALSE; } - if (iStart < 0 || iStart > m_cNodes) + if (iStart < 0 || (unsigned int)iStart > m_cNodes) { // The start node is bad? ALERT(at_aiconsole, "Can't build a path, iStart is %d!\n", iStart); return FALSE; @@ -651,7 +651,7 @@ int CGraph ::FindShortestPath(int *piPath, int iStart, int iDest, int iHull, int // Mark all the nodes as unvisited. // - int i; + unsigned int i; for (i = 0; i < m_cNodes; i++) { m_pNodes[i].m_flClosestSoFar = -1.0; @@ -892,7 +892,7 @@ int CGraph ::FindNearestNode(const Vector &vecOrigin, int afNodeTypes) m_CheckedCounter++; if (m_CheckedCounter == 0) { - for (int i = 0; i < m_cNodes; i++) + for (unsigned int i = 0; i < m_cNodes; i++) { m_di[i].m_CheckedEvent = 0; } @@ -934,7 +934,7 @@ int CGraph ::FindNearestNode(const Vector &vecOrigin, int afNodeTypes) int halfY = (m_minY + m_maxY) / 2; int halfZ = (m_minZ + m_maxZ) / 2; - int j; + unsigned int j; for (i = halfX; i >= m_minX; i--) { @@ -1134,7 +1134,7 @@ void CGraph ::ShowNodeConnections(int iNode) Vector vecSpot; CNode *pNode; CNode *pLinkNode; - int i; + unsigned int i; if (!m_fGraphPresent || !m_fGraphPointersSet) { // protect us in the case that the node graph isn't available or built @@ -1190,9 +1190,9 @@ void CGraph ::ShowNodeConnections(int iNode) //========================================================= int CGraph ::LinkVisibleNodes(CLink *pLinkPool, CFile &file, int *piBadNode) { - int i, j, z; + unsigned int i, j, z; edict_t *pTraceEnt; - int cTotalLinks, cLinksThisNode, cMaxInitialLinks; + unsigned int cTotalLinks, cLinksThisNode, cMaxInitialLinks; TraceResult tr; // !!!BUGBUG - this function returns 0 if there is a problem in the middle of connecting the graph @@ -1385,7 +1385,7 @@ int CGraph ::LinkVisibleNodes(CLink *pLinkPool, CFile &file, int *piBadNode) //========================================================= int CGraph ::RejectInlineLinks(CLink *pLinkPool, CFile &file) { - int i, j, k; + unsigned int i, j, k; int cRejectedLinks; @@ -1655,11 +1655,11 @@ void CTestHull ::BuildNodeGraph(void) BOOL fSkipRemainingHulls; //if smallest hull can't fit, don't check any others BOOL fPairsValid; // are all links in the graph evenly paired? - int i, j, hull; + unsigned int i, j, hull; int iBadNode; // this is the node that caused graph generation to fail - int iPoolIndex = 0; + unsigned int iPoolIndex = 0; int cPoolLinks; // number of links in the pool. Vector vecDirToCheckNode; @@ -2435,7 +2435,7 @@ int CGraph ::FLoadGraph(const char *szMapName) return false; } m_CheckedCounter = 0; - for (int i = 0; i < m_cNodes; i++) + for (unsigned int i = 0; i < m_cNodes; i++) { m_di[i].m_CheckedEvent = 0; } @@ -2545,7 +2545,7 @@ if (0 == m_fGraphPresent || 0 == m_fGraphPointersSet) //========================================================= int CGraph ::FSetGraphPointers(void) { - int i; + unsigned int i; edict_t *pentLinkEnt; for (i = 0; i < m_cLinks; i++) @@ -2650,7 +2650,7 @@ void CGraph::HashInsert(int iSrcNode, int iDestNode, int iKey) dwHash = CRC32_FINAL(dwHash); int di = m_HashPrimes[dwHash & 15]; - int i = (dwHash >> 4) % m_nHashLinks; + unsigned int i = (dwHash >> 4) % m_nHashLinks; while (m_pHashLinks[i] != ENTRY_STATE_EMPTY) { i += di; @@ -2672,7 +2672,7 @@ void CGraph::HashSearch(int iSrcNode, int iDestNode, int &iKey) dwHash = CRC32_FINAL(dwHash); int di = m_HashPrimes[dwHash & 15]; - int i = (dwHash >> 4) % m_nHashLinks; + unsigned int i = (dwHash >> 4) % m_nHashLinks; while (m_pHashLinks[i] != ENTRY_STATE_EMPTY) { CLink &link = Link(m_pHashLinks[i]); @@ -2776,7 +2776,7 @@ void CGraph::SortNodes(void) // After assigning new node numbers to everything, we move // things and patchup the links. // - int i, iNodeCnt = 0; + unsigned int i, iNodeCnt = 0; m_pNodes[0].m_iPreviousNode = iNodeCnt++; for (i = 1; i < m_cNodes; i++) { @@ -2787,7 +2787,7 @@ void CGraph::SortNodes(void) { // Run through all of this node's neighbors // - for (int j = 0; j < m_pNodes[i].m_cNumLinks; j++) + for (unsigned int j = 0; j < m_pNodes[i].m_cNumLinks; j++) { int iDestNode = INodeLink(i, j); if (m_pNodes[iDestNode].m_iPreviousNode == UNNUMBERED_NODE) @@ -2834,7 +2834,7 @@ void CGraph::SortNodes(void) void CGraph::BuildLinkLookups(void) { - int i; + unsigned int i; m_nHashLinks = 3 * m_cLinks / 2 + 3; HashChoosePrimes(m_nHashLinks); @@ -2885,7 +2885,7 @@ void CGraph::BuildRegionTables(void) // Calculate regions for all the nodes. // // - int i; + unsigned int i; for (i = 0; i < 3; i++) { m_RegionMin[i] = 999999999.0; // just a big number out there; @@ -2916,7 +2916,7 @@ void CGraph::BuildRegionTables(void) for (i = 0; i < 3; i++) { - int j; + unsigned int j; for (j = 0; j < NUM_RANGES; j++) { m_RangeStart[i][j] = 255; @@ -2947,7 +2947,7 @@ void CGraph::BuildRegionTables(void) break; } - for (int k = j + 1; k < m_cNodes; k++) + for (unsigned int k = j + 1; k < m_cNodes; k++) { int kNode = m_di[k].m_SortedBy[i]; int kCodeX = m_pNodes[kNode].m_Region[0]; @@ -3049,10 +3049,10 @@ void CGraph ::ComputeStaticRoutingTables(void) // Initialize Routing table to uncalculated. // - int iFrom, iTo; + unsigned int iFrom, iTo; for (iFrom = 0; iFrom < m_cNodes; iFrom++) { - for (int iTo = 0; iTo < m_cNodes; iTo++) + for (unsigned int iTo = 0; iTo < m_cNodes; iTo++) { Routes[FROM_TO(iFrom, iTo)] = -1; } @@ -3109,19 +3109,19 @@ void CGraph ::ComputeStaticRoutingTables(void) for (iFrom = 0; iFrom < m_cNodes; iFrom++) { - for (int iTo = 0; iTo < m_cNodes; iTo++) + for (unsigned int iTo = 0; iTo < m_cNodes; iTo++) { BestNextNodes[iTo] = Routes[FROM_TO(iFrom, iTo)]; } // Compress this node's routing table. // - int iLastNode = 9999999; // just really big. + unsigned int iLastNode = 9999999; // just really big. int cSequence = 0; int cRepeats = 0; int CompressedSize = 0; char *p = pRoute; - int i; + unsigned int i; for (i = 0; i < m_cNodes; i++) { BOOL CanRepeat = ((BestNextNodes[i] == iLastNode) && cRepeats < 127); @@ -3265,7 +3265,7 @@ void CGraph ::ComputeStaticRoutingTables(void) // Go find a place to store this thing and point to it. // - int nRoute = p - pRoute; + unsigned int nRoute = p - pRoute; if (m_pRouteInfo) { for (i = 0; i < m_nRouteInfo - nRoute; i++) @@ -3295,6 +3295,7 @@ void CGraph ::ComputeStaticRoutingTables(void) { m_nRouteInfo = nRoute; m_pRouteInfo = (char *)calloc(sizeof(char), nRoute); + memcpy(m_pRouteInfo, pRoute, nRoute); m_pNodes[iFrom].m_pNextBestNode[iHull][iCap] = 0; nTotalCompressedSize += CompressedSize; @@ -3331,9 +3332,9 @@ void CGraph ::TestRoutingTables(void) int *pMyPath2 = new int[m_cNodes]; if (pMyPath && pMyPath2) { - for (int iHull = 0; iHull < MAX_NODE_HULLS; iHull++) + for (unsigned int iHull = 0; iHull < MAX_NODE_HULLS; iHull++) { - for (int iCap = 0; iCap < 2; iCap++) + for (unsigned int iCap = 0; iCap < 2; iCap++) { int iCapMask; switch (iCap) @@ -3347,14 +3348,14 @@ void CGraph ::TestRoutingTables(void) break; } - for (int iFrom = 0; iFrom < m_cNodes; iFrom++) + for (unsigned int iFrom = 0; iFrom < m_cNodes; iFrom++) { - for (int iTo = 0; iTo < m_cNodes; iTo++) + for (unsigned int iTo = 0; iTo < m_cNodes; iTo++) { m_fRoutingComplete = FALSE; - int cPathSize1 = FindShortestPath(pMyPath, iFrom, iTo, iHull, iCapMask); + unsigned int cPathSize1 = FindShortestPath(pMyPath, iFrom, iTo, iHull, iCapMask); m_fRoutingComplete = TRUE; - int cPathSize2 = FindShortestPath(pMyPath2, iFrom, iTo, iHull, iCapMask); + unsigned int cPathSize2 = FindShortestPath(pMyPath2, iFrom, iTo, iHull, iCapMask); // Unless we can look at the entire path, we can verify that it's correct. // @@ -3365,14 +3366,14 @@ void CGraph ::TestRoutingTables(void) // #if 1 float flDistance1 = 0.0; - int i; + unsigned int i; for (i = 0; i < cPathSize1 - 1; i++) { // Find the link from pMyPath[i] to pMyPath[i+1] // if (pMyPath[i] == pMyPath[i + 1]) continue; - int iVisitNode, iLink; + unsigned int iVisitNode, iLink; BOOL bFound = FALSE; for (iLink = 0; iLink < m_pNodes[pMyPath[i]].m_cNumLinks; iLink++) { @@ -3399,7 +3400,7 @@ void CGraph ::TestRoutingTables(void) continue; int iVisitNode; BOOL bFound = FALSE; - for (int iLink = 0; iLink < m_pNodes[pMyPath2[i]].m_cNumLinks; iLink++) + for (unsigned int iLink = 0; iLink < m_pNodes[pMyPath2[i]].m_cNumLinks; iLink++) { iVisitNode = INodeLink(pMyPath2[i], iLink); if (iVisitNode == pMyPath2[i + 1]) @@ -3466,7 +3467,7 @@ class CNodeViewer : public CBaseEntity int m_iBaseNode; int m_iDraw; - int m_nVisited; + unsigned int m_nVisited; int m_aFrom[128]; int m_aTo[128]; int m_iHull; @@ -3524,7 +3525,7 @@ void CNodeViewer::Spawn() if (WorldGraph.m_cNodes < 128) { - for (int i = 0; i < WorldGraph.m_cNodes; i++) + for (unsigned int i = 0; i < WorldGraph.m_cNodes; i++) { AddNode(i, WorldGraph.NextNodeInRoute(i, m_iBaseNode, m_iHull, 0)); } @@ -3558,7 +3559,7 @@ void CNodeViewer::Spawn() void CNodeViewer ::FindNodeConnections(int iNode) { AddNode(iNode, WorldGraph.NextNodeInRoute(iNode, m_iBaseNode, m_iHull, 0)); - for (int i = 0; i < WorldGraph.m_pNodes[iNode].m_cNumLinks; i++) + for (unsigned int i = 0; i < WorldGraph.m_pNodes[iNode].m_cNumLinks; i++) { CLink *pToLink = &WorldGraph.NodeLink(iNode, i); AddNode(pToLink->m_iDestNode, WorldGraph.NextNodeInRoute(pToLink->m_iDestNode, m_iBaseNode, m_iHull, 0)); @@ -3576,7 +3577,7 @@ void CNodeViewer::AddNode(int iFrom, int iTo) if (iFrom == iTo) return; - for (int i = 0; i < m_nVisited; i++) + for (unsigned int i = 0; i < m_nVisited; i++) { if (m_aFrom[i] == iFrom && m_aTo[i] == iTo) return; @@ -3593,7 +3594,7 @@ void CNodeViewer ::DrawThink(void) { /*pev->nextthink = gpGlobals->time; - for (int i = 0; i < 10; i++) + for (unsigned int i = 0; i < 10; i++) { if (m_iDraw == m_nVisited) { diff --git a/src/game/server/hl/nodes.h b/src/game/server/hl/nodes.h index a6233e60..27738047 100644 --- a/src/game/server/hl/nodes.h +++ b/src/game/server/hl/nodes.h @@ -44,8 +44,8 @@ class CNode byte m_Region[3]; // Which of 256 regions do each of the coordinate belong? int m_afNodeInfo; // bits that tell us more about this location - int m_cNumLinks; // how many links this node has - int m_iFirstLink; // index of this node's first link in the link pool. + unsigned int m_cNumLinks; // how many links this node has + unsigned int m_iFirstLink; // index of this node's first link in the link pool. // Where to start looking in the compressed routing table (offset into m_pRouteInfo). // (4 hull sizes -- smallest to largest + fly/swim), and secondly, door capability. @@ -121,9 +121,9 @@ class CGraph CLink *m_pLinkPool; // big list of all node connections char *m_pRouteInfo; // compressed routing information the nodes use. - int m_cNodes; // total number of nodes - int m_cLinks; // total number of links - int m_nRouteInfo; // size of m_pRouteInfo in bytes. + unsigned int m_cNodes; // total number of nodes + unsigned int m_cLinks; // total number of links + unsigned int m_nRouteInfo; // size of m_pRouteInfo in bytes. // Tables for making nearest node lookup faster. SortedBy provided nodes in a // order of a particular coordinate. Instead of doing a binary search, RangeStart @@ -137,8 +137,8 @@ class CGraph #define CACHE_SIZE 128 #define NUM_RANGES 256 DIST_INFO *m_di; // This is m_cNodes long, but the entries don't correspond to CNode entries. - int m_RangeStart[3][NUM_RANGES]; - int m_RangeEnd[3][NUM_RANGES]; + unsigned int m_RangeStart[3][NUM_RANGES]; + unsigned int m_RangeEnd[3][NUM_RANGES]; float m_flShortest; int m_iNearest; int m_minX, m_minY, m_minZ, m_maxX, m_maxY, m_maxZ; @@ -149,12 +149,12 @@ class CGraph int m_HashPrimes[16]; short *m_pHashLinks; - int m_nHashLinks; + unsigned int m_nHashLinks; // kinda sleazy. In order to allow variety in active idles for monster groups in a room with more than one node, // we keep track of the last node we searched from and store it here. Subsequent searches by other monsters will pick // up where the last search stopped. - int m_iLastActiveIdleSearch; + unsigned int m_iLastActiveIdleSearch; // another such system used to track the search for cover nodes, helps greatly with two monsters trying to get to the same node. int m_iLastCoverSearch; diff --git a/src/game/server/hl/saverestore.h b/src/game/server/hl/saverestore.h index 644bb44b..53e61678 100644 --- a/src/game/server/hl/saverestore.h +++ b/src/game/server/hl/saverestore.h @@ -65,7 +65,7 @@ class CSave : public CSaveRestoreBuffer int WriteFields(const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); private: - int DataEmpty(const char *pdata, int size); + int DataEmpty(const char *pdata, unsigned int size); void BufferField(const char *pname, int size, const char *pdata); void BufferString(char *pdata, int len); void BufferData(const char *pdata, int size); diff --git a/src/game/server/hl/sound.cpp b/src/game/server/hl/sound.cpp index 5b7ac96e..e5fd1732 100644 --- a/src/game/server/hl/sound.cpp +++ b/src/game/server/hl/sound.cpp @@ -1530,7 +1530,7 @@ void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname) // on material type. #define CTEXTURESMAX 512 // max number of textures loaded -int gcTextures = 0; +unsigned int gcTextures = 0; char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; // texture names char grgchTextureType[CTEXTURESMAX]; // parallel array of texture types @@ -1544,7 +1544,7 @@ char TEXTURETYPE_Find(char *name) { // CONSIDER: pre-sort texture names and perform faster binary search here - for (int i = 0; i < gcTextures; i++) + for (unsigned int i = 0; i < gcTextures; i++) { if (!_strnicmp(name, &(grgszTextureName[i][0]), CBTEXTURENAMEMAX - 1)) return (grgchTextureType[i]); diff --git a/src/game/server/hl/soundent.cpp b/src/game/server/hl/soundent.cpp index 4ec6aa2b..e0b32ce8 100644 --- a/src/game/server/hl/soundent.cpp +++ b/src/game/server/hl/soundent.cpp @@ -240,7 +240,7 @@ int CSoundEnt :: InsertSound ( int iType, const Vector &vecOrigin, int iVolume, //========================================================= void CSoundEnt :: Initialize ( void ) { - int i; + unsigned int i; int iSound; m_cLastActiveSounds; @@ -286,7 +286,7 @@ void CSoundEnt :: Initialize ( void ) //========================================================= int CSoundEnt :: ISoundsInList ( int iListType ) { - int i; + unsigned int i; int iThisSound; if ( iListType == SOUNDLISTTYPE_FREE ) diff --git a/src/game/server/hl/subs.cpp b/src/game/server/hl/subs.cpp index 4e4ba514..c8c1125d 100644 --- a/src/game/server/hl/subs.cpp +++ b/src/game/server/hl/subs.cpp @@ -102,7 +102,7 @@ void CBaseEntity::UpdateOnRemove(void) { // this entity was a LinkEnt in the world node graph, so we must remove it from // the graph since we are removing it from the world. - for (int i = 0; i < WorldGraph.m_cLinks; i++) + for (unsigned int i = 0; i < WorldGraph.m_cLinks; i++) { if (WorldGraph.m_pLinkPool[i].m_pLinkEnt == pev) { diff --git a/src/game/server/hl/util.cpp b/src/game/server/hl/util.cpp index 0ffc2c03..719fd630 100644 --- a/src/game/server/hl/util.cpp +++ b/src/game/server/hl/util.cpp @@ -407,7 +407,7 @@ void UTIL_MoveToOrigin(edict_t *pent, const Vector &vecGoal, float flDist, int i int UTIL_EntitiesInBox(CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask, int startIndex) { - if (startIndex >= gpGlobals->maxEntities) //End recursion if you have no more entities to search (shouldn't happen anyway) MiB Feb2008a + if ((unsigned int)startIndex >= gpGlobals->maxEntities) //End recursion if you have no more entities to search (shouldn't happen anyway) MiB Feb2008a return 0; edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex(startIndex); @@ -423,7 +423,7 @@ int UTIL_EntitiesInBox(CBaseEntity **pList, int listMax, const Vector &mins, con //return count; } - for (int i = startIndex + 1; i < gpGlobals->maxEntities; i++, pEdict++) //MAR2008b - zapping neo-chatbug + for (unsigned int i = startIndex + 1; i < gpGlobals->maxEntities; i++, pEdict++) //MAR2008b - zapping neo-chatbug { if (pEdict->free || !pEdict->pvPrivateData) //MAR2008b - zapping neo-chatbug continue; @@ -455,7 +455,7 @@ int UTIL_EntitiesInBox(CBaseEntity **pList, int listMax, const Vector &mins, con int UTIL_MonstersInSphere(CBaseEntity **pList, int listMax, const Vector ¢er, float radius, int startIndex) { - if (startIndex >= gpGlobals->maxEntities) //End recursion if you have no more entities to search (shouldn't happen anyway) MiB Feb2008a + if ((unsigned int)startIndex >= gpGlobals->maxEntities) //End recursion if you have no more entities to search (shouldn't happen anyway) MiB Feb2008a return 0; edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex(startIndex); @@ -474,7 +474,7 @@ int UTIL_MonstersInSphere(CBaseEntity **pList, int listMax, const Vector ¢er //return count; } - for (int i = startIndex + 1; i < gpGlobals->maxEntities; i++, pEdict++) //MAR2008b - zapping neo-chatbug + for (unsigned int i = startIndex + 1; i < gpGlobals->maxEntities; i++, pEdict++) //MAR2008b - zapping neo-chatbug { if (pEdict->free || !pEdict->pvPrivateData) //MAR2008b - zapping neo-chatbug continue; @@ -588,7 +588,7 @@ CBaseEntity *UTIL_PlayerByIndex(int playerIndex) { CBaseEntity *pPlayer = NULL; - if (playerIndex > 0 && playerIndex <= gpGlobals->maxClients) + if (playerIndex > 0 && (unsigned int)playerIndex <= gpGlobals->maxClients) { edict_t *pPlayerEdict = INDEXENT(playerIndex); if (pPlayerEdict && !pPlayerEdict->free) @@ -602,7 +602,7 @@ CBaseEntity *UTIL_PlayerByIndex(int playerIndex) CBasePlayer* UTIL_PlayerBySteamID(ID64 steamID64) { - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity* pEntity = UTIL_PlayerByIndex(i); CBasePlayer* pPlayer = (pEntity ? (CBasePlayer*)pEntity : NULL); @@ -683,7 +683,7 @@ void UTIL_DoTokenScriptEvent(const char *tokenevents, CBaseEntity *pTarget) TokenizeString(m_scriptevent.c_str(), Tokens); if (Tokens.size() > 1) { - for (int i = 0; i < Tokens.size(); i++) + for (unsigned int i = 0; i < Tokens.size(); i++) { if (i > 0) Params.add(Tokens[i].c_str()); @@ -711,7 +711,7 @@ void UTIL_DoTokenScriptEvent(const char *tokenevents, CBaseEntity *pTarget) Params.clearitems(); if (Tokens.size() > 1) { - for (int i = 0; i < Tokens.size(); i++) + for (unsigned int i = 0; i < Tokens.size(); i++) { if (i > 0) Params.add(Tokens[i].c_str()); @@ -845,7 +845,7 @@ void Util_ScriptArray(CBaseEntity *pEntity, const char *array_operation, const c int UTIL_NumPlayers() { int total_valid_players = 0; - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pEntity = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = pEntity ? (CBasePlayer *)pEntity : NULL; @@ -869,7 +869,7 @@ int UTIL_NumActivePlayers() { int total_valid_players = 0; bool flagged_invalid = false; - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pEntity = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = pEntity ? (CBasePlayer *)pEntity : NULL; @@ -905,7 +905,7 @@ float UTIL_TotalHP() int total_valid_players = 0; bool flagged_invalid = false; float total_hp = 0; - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pEntity = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = pEntity ? (CBasePlayer *)pEntity : NULL; @@ -942,7 +942,7 @@ float UTIL_AvgHP() int total_valid_players = 0; bool flagged_invalid = false; float total_hp = 0; - for (int i = 1; i <= gpGlobals->maxClients; i++) + for (unsigned int i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pEntity = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = pEntity ? (CBasePlayer *)pEntity : NULL; @@ -1056,7 +1056,7 @@ static short FixedSigned16(float value, float scale) // UNDONE: Affect user controls? void UTIL_ScreenShake(const Vector ¢er, float amplitude, float frequency, float duration, float radius) { - int i; + unsigned int i; float localAmplitude; ScreenShake shake; @@ -1154,7 +1154,7 @@ void UTIL_ScreenFadeWrite(const ScreenFade &fade, CBaseEntity *pEntity) void UTIL_ScreenFadeAll(const Vector &color, float fadeTime, float fadeHold, int alpha, int flags) { - int i; + unsigned int i; ScreenFade fade; UTIL_ScreenFadeBuild(fade, color, fadeTime, fadeHold, alpha, flags); @@ -1211,7 +1211,7 @@ void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms, cons void UTIL_HudMessageAll(const hudtextparms_t &textparms, const char *pMessage) { - int i = 0; + unsigned int i = 0; //UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "Game_text reached UTIL_HudMessageAll","test"); for (i = 1; i <= gpGlobals->maxClients; i++) { @@ -1319,7 +1319,7 @@ void UTIL_ShowMessage(const char *pString, CBaseEntity *pEntity) void UTIL_ShowMessageAll(const char *pString) { - int i; + unsigned int i; // loop through all players @@ -2176,7 +2176,7 @@ unsigned short CSaveRestoreBuffer ::TokenHash(const char *pszToken) ALERT(at_error, "No token table array in TokenHash()!"); #endif - for (int i = 0; i < m_pdata->tokenCount; i++) + for (unsigned int i = 0; i < m_pdata->tokenCount; i++) { #if _DEBUG static qboolean beentheredonethat = FALSE; @@ -2187,7 +2187,7 @@ unsigned short CSaveRestoreBuffer ::TokenHash(const char *pszToken) } #endif - int index = hash + i; + unsigned int index = hash + i; if (index >= m_pdata->tokenCount) index -= m_pdata->tokenCount; @@ -2503,9 +2503,9 @@ void CSave ::BufferString(char *pdata, int len) BufferData(&c, 1); // Write a null terminator } -int CSave ::DataEmpty(const char *pdata, int size) +int CSave ::DataEmpty(const char *pdata, unsigned int size) { - for (int i = 0; i < size; i++) + for (unsigned int i = 0; i < size; i++) { if (pdata[i]) return 0; diff --git a/src/game/server/hl/util.h b/src/game/server/hl/util.h index 065ae53a..9600f275 100644 --- a/src/game/server/hl/util.h +++ b/src/game/server/hl/util.h @@ -631,7 +631,7 @@ void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); #define PRECACHE_SOUND_ARRAY(a) \ { \ - for (int i = 0; i < std::size(a); i++) \ + for (unsigned int i = 0; i < std::size(a); i++) \ PRECACHE_SOUND((char *)a[i]); \ } diff --git a/src/game/server/monsters/bodyparts/bodyparts.cpp b/src/game/server/monsters/bodyparts/bodyparts.cpp index 251258c6..43c1201c 100644 --- a/src/game/server/monsters/bodyparts/bodyparts.cpp +++ b/src/game/server/monsters/bodyparts/bodyparts.cpp @@ -47,7 +47,7 @@ CBodypart *CBodypart::Duplicate(CBodypart *pExistingBodypart) CMSMonster *pOwner = (CMSMonster *)MSInstance( pev->owner ); if( !pOwner ) return flDamage; - for (int i = 0; i < pOwner->Gear.size(); i++) + for (unsigned int i = 0; i < pOwner->Gear.size(); i++) { CGenericItem *pItemWorn = pOwner->Gear[ i ]; @@ -66,7 +66,7 @@ CBodypart *CBodypart::Duplicate(CBodypart *pExistingBodypart) CMSMonster *pOwner = (CMSMonster *)MSInstance( pev->owner ); if( !pOwner ) return flDamage; - for (int i = 0; i < pOwner->Gear.size(); i++) + for (unsigned int i = 0; i < pOwner->Gear.size(); i++) { CGenericItem *Item = *pOwner->Gear[ i ]; if( FBitSet(Item.MSProperties(),ITEM_ARMOR) ) @@ -127,16 +127,16 @@ void CBodypart::Set(int iState, void *vData) } void CBaseBody::Set(int iState, void *vData) { - for (int i = 0; i < Bodyparts.size(); i++) + for (unsigned int i = 0; i < Bodyparts.size(); i++) Bodyparts[i]->Set(iState, vData); } void CBaseBody::Think(CMSMonster *pOwner) { - for (int b = 0; b < Bodyparts.size(); b++) + for (unsigned int b = 0; b < Bodyparts.size(); b++) { int Body = 0; bool Visible = true; - for (int i = 0; i < pOwner->Gear.size(); i++) + for (unsigned int i = 0; i < pOwner->Gear.size(); i++) { if (pOwner->Gear[i]->m_Location <= ITEMPOS_HANDS) continue; @@ -157,13 +157,13 @@ void CBaseBody::Think(CMSMonster *pOwner) CBaseBody *CBaseBody::Duplicate() { CBaseBody &NewBody = *msnew(CBaseBody); - for (int i = 0; i < Bodyparts.size(); i++) + for (unsigned int i = 0; i < Bodyparts.size(); i++) NewBody.Bodyparts[i] = Bodyparts[i]->Duplicate(); return &NewBody; } void CBaseBody::Delete() { - for (int i = 0; i < Bodyparts.size(); i++) + for (unsigned int i = 0; i < Bodyparts.size(); i++) { Bodyparts[i]->SUB_Remove(); Bodyparts.erase(i--); diff --git a/src/game/server/monsters/bodyparts/bodyparts_human.cpp b/src/game/server/monsters/bodyparts/bodyparts_human.cpp index 1a723d87..7d63a766 100644 --- a/src/game/server/monsters/bodyparts/bodyparts_human.cpp +++ b/src/game/server/monsters/bodyparts/bodyparts_human.cpp @@ -12,7 +12,7 @@ CHumanBodypart *CHumanBodypart::Duplicate() void CHumanBody::Initialize(CBaseEntity *pOwner, void *pvData) { - for (int i = 0; i < HUMAN_BODYPARTS; i++) + for (unsigned int i = 0; i < HUMAN_BODYPARTS; i++) { CHumanBodypart& HumanBodypart = *(CHumanBodypart*)GetClassPtr((CHumanBodypart*)NULL); @@ -27,7 +27,7 @@ void CHumanBody::Initialize(CBaseEntity *pOwner, void *pvData) CBaseBody *CHumanBody::Duplicate() { CHumanBody *NewBody = new CHumanBody; - for (int i = 0; i < Bodyparts.size(); i++) + for (unsigned int i = 0; i < Bodyparts.size(); i++) NewBody->Bodyparts.add(Bodyparts[i]->Duplicate()); return NewBody; diff --git a/src/game/server/monsters/corpse.cpp b/src/game/server/monsters/corpse.cpp index 4fbca19a..72827bbb 100644 --- a/src/game/server/monsters/corpse.cpp +++ b/src/game/server/monsters/corpse.cpp @@ -56,8 +56,8 @@ void CCorpse::CreateCorpse(CMSMonster* pSource, float LoseGoldPercent) float CheckRange = 1024; Vector delta = Vector(CheckRange, CheckRange, CheckRange); CBaseEntity* pEnt[100]; - int count = UTIL_EntitiesInBox(pEnt, 100, pev->origin - delta, pev->origin + delta, NULL); - for (int i = 0; i < count; i++) + unsigned int count = UTIL_EntitiesInBox(pEnt, 100, pev->origin - delta, pev->origin + delta, NULL); + for (unsigned int i = 0; i < count; i++) { //Cut every corpse's expire time in half pCorpse = pEnt[i]; diff --git a/src/game/server/monsters/msmonster.h b/src/game/server/monsters/msmonster.h index 95d51bf0..1c7604b3 100644 --- a/src/game/server/monsters/msmonster.h +++ b/src/game/server/monsters/msmonster.h @@ -273,9 +273,9 @@ class CMSMonster : public CBaseMonster m_HPReq_min, //Thothie AUG2007a - adding optional req total hp on server to spawn monster m_HPReq_max, //Thothie FEB2011_22 - adding option for "min;max" hpreq m_ReqPlayers, //Thothie AUG2007a - adding optional REQ players to spawn monster - m_nRndMobs, //NOV2014_20 - Thothie msmonster_random m_HPReq_useavg; + unsigned int m_nRndMobs; //NOV2014_20 - Thothie msmonster_random float m_HPMulti, //Thothie SEP2007a - multiply HP by this amount m_DMGMulti; //Thothie SEP2007a - multiply DMG by this amount @@ -324,7 +324,7 @@ class CMSMonster : public CBaseMonster //a relationship better than R_NO) EHANDLE m_hEnemyList[MAX_ENEMYLIST], m_LastEnemy; - int m_EnemyListNum; + unsigned int m_EnemyListNum; CBaseBody *Body; //If this monster uses body parts CItemList Gear; //This monster's gear diff --git a/src/game/server/monsters/msmonsterserver.cpp b/src/game/server/monsters/msmonsterserver.cpp index 553e740f..80948615 100644 --- a/src/game/server/monsters/msmonsterserver.cpp +++ b/src/game/server/monsters/msmonsterserver.cpp @@ -136,7 +136,7 @@ void CMSMonster::Spawn() m_OldGold = 0; // Initialize menu protection flags to false for all players - for (int i = 0; i < MAXPLAYERS; i++) + for (unsigned int i = 0; i < MAXPLAYERS; i++) { m_MenuOptionsProtected[i] = false; } @@ -150,7 +150,7 @@ void CMSMonster::Spawn() { //precache all random mob scripts msstring orig_scriptName = m_ScriptName; - for (int i = 0; i < m_nRndMobs; i++) + for (unsigned int i = 0; i < m_nRndMobs; i++) { MS_DEBUG("DEBUG: msmonster_random precache #%i / %i as %s", i, m_nRndMobs, random_monsterdata[i].m_ScriptName.c_str()); CScript TempScript; @@ -430,7 +430,7 @@ void CMSMonster::KeyValue(KeyValueData* pkvd) if (random_monsterdata.size() == 0) { //random_monster_t tmp; - for (int i = 0; i < 32; i++) + for (unsigned int i = 0; i < 32; i++) { random_monsterdata.add_blank(); }; @@ -1262,7 +1262,7 @@ void CMSMonster::AvoidFrontObject(float MoveAmt) Vector vAng, vAvoidDir, SideAng[2]; float Dist[2]; - for (int i = 0; i < 2; i++) //Try each side + for (unsigned int i = 0; i < 2; i++) //Try each side { //Finds the forward vector of the avoidance direction vAng.y = UTIL_AngleMod(m_LastYaw + ang * -Side[i]); @@ -1613,13 +1613,13 @@ void CMSMonster::Speak(char* pszSentence, speech_type SpeechType) CBaseEntity* pList[255], * pEnt = NULL; // Fill pList with a all the monsters and players on the level including players that have died. - int count = UTIL_EntitiesInBox(pList, 255, Vector(-6000, -6000, -6000), Vector(6000, 6000, 6000), FL_MONSTER | FL_CLIENT | FL_SPECTATOR); + unsigned int count = UTIL_EntitiesInBox(pList, 255, Vector(-6000, -6000, -6000), Vector(6000, 6000, 6000), FL_MONSTER | FL_CLIENT | FL_SPECTATOR); // Keep track of players that have already received a message; std::set pTrackAlreadySent = {}; // Now try to speak to each one - for (int i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) { pEnt = pList[i]; if (pEnt == NULL) @@ -1727,18 +1727,18 @@ void CMSMonster::HearPhrase(CMSMonster* pSpeaker, const char* phrase) listenphrase_t* BestPhrase = NULL; float BestMatchedRatio = 0; - for (int i = 0; i < m_Phrases.size(); i++) + for (unsigned int i = 0; i < m_Phrases.size(); i++) { listenphrase_t& Phrase = m_Phrases[i]; - for (int p = 0; p < Phrase.Phrases.size(); p++) + for (unsigned int p = 0; p < Phrase.Phrases.size(); p++) { const char* CheckPhrase = Phrase.Phrases[p]; const char* SubPhrase = NULL; if (SubPhrase = strstr(cTemp1, CheckPhrase)) { int Matched = 0; - int len = strlen(CheckPhrase); - for (int x = 0; x < len; x++) + unsigned int len = strlen(CheckPhrase); + for (unsigned int x = 0; x < len; x++) if (SubPhrase[x] == CheckPhrase[x]) Matched++; @@ -2213,7 +2213,7 @@ float CMSMonster::TraceAttack(damage_t& Damage) //Damage Modifiers ( takedmg xxx ) Damage.flDamage *= m.GenericTDM; if (Damage.sDamageType) - for (int i = 0; i < m.TakeDamageModifiers.size(); i++) + for (unsigned int i = 0; i < m.TakeDamageModifiers.size(); i++) { takedamagemodifier_t& TDM = m.TakeDamageModifiers[i]; //msstring thoth_my_dmgtype = TDM.DamageType; @@ -2260,7 +2260,7 @@ float CMSMonster::TraceAttack(damage_t& Damage) //Each script sets a ratio of damage you should take. Factor each one into the damage msstringlist DamageRatios; TokenizeString(m_ReturnData, DamageRatios); - for (int i = 0; i < DamageRatios.size(); i++) + for (unsigned int i = 0; i < DamageRatios.size(); i++) Damage.flDamage *= atof(DamageRatios[i]); //Script can reject the damage with "returndata" } @@ -2408,7 +2408,7 @@ void CMSMonster::Killed(entvars_t* pevAttacker, int iGib) IScripted* pScripted = (pTarget ? pTarget->GetScripted() : NULL); if (pScripted) { - for (int i = 0; i < pScripted->m_Scripts.size(); i++) // Check each + for (unsigned int i = 0; i < pScripted->m_Scripts.size(); i++) // Check each { if (pScripted->m_Scripts[i]->VarExists("game.effect.id")) //This is an effect { @@ -2707,7 +2707,7 @@ std::tuple CMSMonster::LearnSkill(int iStat, int iStatType, int Enemy //Look through the other SubStats for one that's not at the cap, yet. //Not random, but good enough. - for (int i = 0; i < 1; i++) + for (unsigned int i = 0; i < 1; i++) { iStatType = (iStatType + 1) % 3; CSubStat& SubStat = pStat->m_SubStats[iStatType]; @@ -2795,7 +2795,7 @@ void CMSMonster::SetSpeed() float SpeedPercent = 100.0f; m_Framerate_Modifier = 1.0; - for (int i = 0; i < m_Scripts.size(); i++) + for (unsigned int i = 0; i < m_Scripts.size(); i++) { if (!m_Scripts[i]->VarExists("game.effect.id")) continue; @@ -2819,7 +2819,7 @@ void CMSMonster::SetSpeed() //Can't move while a spell is preparing //Thothie/Orochi APR2011_04 - undone /* - for (int i = 0; i < MAX_NPC_HANDS; i++) + for (unsigned int i = 0; i < MAX_NPC_HANDS; i++) if( Hand(i) && !Hand(i)->Spell_CanAttack() ) SpeedPercent = 0; //Percentage of normal speed */ @@ -2869,7 +2869,7 @@ void CMSMonster::OpenMenu(CBasePlayer* pPlayer) m_MenuCurrentOptions = NULL; - for (int i = 0; i < Menuoptions.size(); i++) + for (unsigned int i = 0; i < Menuoptions.size(); i++) { menuoption_t& MenuOption = Menuoptions[i]; if (MenuOption.Access != MOA_ALL) @@ -2973,7 +2973,7 @@ void CMSMonster::UseMenuOption(CBasePlayer* pPlayer, int Option) static mslist TotalFoundItems; TotalFoundItems.clearitems(); - for (int i = 0; i < Payments.size(); i++) + for (unsigned int i = 0; i < Payments.size(); i++) { msstring& Payment = Payments[i]; if (Payment.starts_with("gold")) @@ -3019,7 +3019,7 @@ void CMSMonster::UseMenuOption(CBasePlayer* pPlayer, int Option) break; } - for (int x = 0; x < FoundItems.size(); x++) + for (unsigned int x = 0; x < FoundItems.size(); x++) TotalFoundItems.add(FoundItems[x]); } } @@ -3035,7 +3035,7 @@ void CMSMonster::UseMenuOption(CBasePlayer* pPlayer, int Option) if (PlayerCanPay) { pPlayer->m_Gold -= TotalGold; - for (int i = 0; i < TotalFoundItems.size(); i++) + for (unsigned int i = 0; i < TotalFoundItems.size(); i++) TotalFoundItems[i]->SUB_Remove(); //MIB JUN2010_14 (original line commented below) //pPlayer->RemoveItem( TotalFoundItems[i] ); } @@ -3131,7 +3131,7 @@ void CMSMonster::UseMenuOption(CBasePlayer* pPlayer, int Option) static mslist TotalFoundItems; TotalFoundItems.clearitems(); - for (int i = 0; i < Payments.size(); i++) + for (unsigned int i = 0; i < Payments.size(); i++) { msstring& Payment = Payments[i]; if (Payment.starts_with("gold")) @@ -3177,7 +3177,7 @@ void CMSMonster::UseMenuOption(CBasePlayer* pPlayer, int Option) break; } - for (int x = 0; x < FoundItems.size(); x++) + for (unsigned int x = 0; x < FoundItems.size(); x++) TotalFoundItems.add(FoundItems[x]); } } @@ -3193,7 +3193,7 @@ void CMSMonster::UseMenuOption(CBasePlayer* pPlayer, int Option) if (PlayerCanPay) { pPlayer->m_Gold -= TotalGold; - for (int i = 0; i < TotalFoundItems.size(); i++) + for (unsigned int i = 0; i < TotalFoundItems.size(); i++) TotalFoundItems[i]->SUB_Remove(); //MIB JUN2010_14 (original line commented below) //pPlayer->RemoveItem( TotalFoundItems[i] ); } diff --git a/src/game/server/monsters/npcglobal.cpp b/src/game/server/monsters/npcglobal.cpp index 74ef031a..36d613df 100644 --- a/src/game/server/monsters/npcglobal.cpp +++ b/src/game/server/monsters/npcglobal.cpp @@ -12,7 +12,7 @@ void CMSMonster::DynamicPrecache() TokenizeString(pszString, NPCs); - for (int i = 0; i < NPCs.size(); i++) + for (unsigned int i = 0; i < NPCs.size(); i++) { const char* ScriptFile = NPCs[i]; diff --git a/src/game/server/monsters/npcscript.cpp b/src/game/server/monsters/npcscript.cpp index 3fea933e..74edd0bd 100644 --- a/src/game/server/monsters/npcscript.cpp +++ b/src/game/server/monsters/npcscript.cpp @@ -108,7 +108,7 @@ bool CMSMonster::Script_ExecuteCmd(CScript *Script, SCRIPT_EVENT &Event, scriptc { //say [mouth open length] if (Params.size() >= 1) { - for (int i = 0; i < Params.size(); i++) + for (unsigned int i = 0; i < Params.size(); i++) { float fDuration = 0.2; msstring &FullWord = Params[i]; @@ -149,7 +149,7 @@ bool CMSMonster::Script_ExecuteCmd(CScript *Script, SCRIPT_EVENT &Event, scriptc CBaseEntity *pTarget = RetrieveEntity(ENT_ME); IScripted *pScripted = pTarget->GetScripted(); // UScripted? IScripted. - for (int i = 0; i < pScripted->m_Scripts.size(); i++) // Check each + for (unsigned int i = 0; i < pScripted->m_Scripts.size(); i++) // Check each { if (pScripted->m_Scripts[i]->VarExists("game.effect.id")) //This is an effect { @@ -403,11 +403,11 @@ bool CMSMonster::Script_ExecuteCmd(CScript *Script, SCRIPT_EVENT &Event, scriptc } //[end] - for (int p = 0; p < m_PlayerDamage.size(); p++) + for (unsigned int p = 0; p < m_PlayerDamage.size(); p++) { // for (int r = 0; r < SKILL_MAX_ATTACK; r++) // { - // for (int s = 0; s < STATPROP_ALL_TOTAL; s++) + // for (unsigned int s = 0; s < STATPROP_ALL_TOTAL; s++) // m_PlayerDamage[p].dmg[r][s] = 0; // } // m_PlayerDamage[p].dmgInTotal = 0; @@ -435,11 +435,11 @@ bool CMSMonster::Script_ExecuteCmd(CScript *Script, SCRIPT_EVENT &Event, scriptc if (atof(GetFirstScriptVar("NPC_ORIG_EXP")) > 0) { //first, wipe player hits, otherwise, we'll have problems - for (int p = 0; p < m_PlayerDamage.size(); p++) + for (unsigned int p = 0; p < m_PlayerDamage.size(); p++) { // for (int r = 0; r < SKILL_MAX_ATTACK; r++) // { - // for (int s = 0; s < STATPROP_ALL_TOTAL; s++) + // for (unsigned int s = 0; s < STATPROP_ALL_TOTAL; s++) // m_PlayerDamage[p].dmg[r][s] = 0; // } // m_PlayerDamage[p].dmgInTotal = 0; @@ -695,7 +695,7 @@ bool CMSMonster::Script_ExecuteCmd(CScript *Script, SCRIPT_EVENT &Event, scriptc { //Parameters: