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/game/client/ammo.h b/src/game/client/ammo.h index 3ca1b1cd..acdb5791 100644 --- a/src/game/client/ammo.h +++ b/src/game/client/ammo.h @@ -16,11 +16,9 @@ #ifndef __AMMO_H__ #define __AMMO_H__ -#define MAX_WEAPON_NAME 128 - -#define WEAPON_FLAGS_SELECTONEMPTY 1 - -#define WEAPON_IS_ONTARGET 0x40 +constexpr int MAX_WEAPON_NAME = 128; +constexpr int WEAPON_FLAGS_SELECTONEMPTY = 1; +constexpr int WEAPON_IS_ONTARGET = 0x40; struct WEAPON { diff --git a/src/game/client/ammo_secondary.cpp b/src/game/client/ammo_secondary.cpp index 7b374912..81e80dff 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(); @@ -68,8 +68,8 @@ int CHudAmmoSecondary ::Draw(float flTime) AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; - y = ScreenHeight - (gHUD.m_iFontHeight * 4); // this is one font height higher than the weapon ammo values - x = ScreenWidth - AmmoWidth; + y = ScreenHeight() - (gHUD.m_iFontHeight * 4); // this is one font height higher than the weapon ammo values + x = ScreenWidth() - AmmoWidth; if (m_HUD_ammoicon) { @@ -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..d3daf501 100644 --- a/src/game/client/ammohistory.cpp +++ b/src/game/client/ammohistory.cpp @@ -29,7 +29,7 @@ HistoryResource gHR; #define AMMO_PICKUP_GAP (gHR.iHistoryGap + 5) #define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2)) -#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100) +#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight() - 100) #define MAX_ITEM_NAME 32 int HISTORY_DRAW_TIME = 5; @@ -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; @@ -127,8 +127,8 @@ int HistoryResource ::DrawAmmoHistory(float flTime) ScaleColors(r, g, b, min(scale, 255) ); // Draw the pic - int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); - int xpos = ScreenWidth - 24; + int ypos = ScreenHeight() - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); + int xpos = ScreenWidth() - 24; if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic { // the dll has to make sure it has sent info the weapons you need SPR_Set( *spr, r, g, b ); @@ -154,8 +154,8 @@ int HistoryResource ::DrawAmmoHistory(float flTime) float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; ScaleColors(r, g, b, min(scale, 255) ); - int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); - int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left); + int ypos = ScreenHeight() - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); + int xpos = ScreenWidth() - (weap->rcInactive.right - weap->rcInactive.left); SPR_Set( weap->hInactive, r, g, b ); SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive ); } @@ -172,8 +172,8 @@ int HistoryResource ::DrawAmmoHistory(float flTime) float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; ScaleColors(r, g, b, min(scale, 255) ); - int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); - int xpos = ScreenWidth - (rect.right - rect.left) - 10; + int ypos = ScreenHeight() - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); + int xpos = ScreenWidth() - (rect.right - rect.left) - 10; SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b ); SPR_DrawAdditive( 0, xpos, ypos, &rect ); diff --git a/src/game/client/ammohistory.h b/src/game/client/ammohistory.h index 9d4d6870..71969039 100644 --- a/src/game/client/ammohistory.h +++ b/src/game/client/ammohistory.h @@ -17,7 +17,6 @@ // // this is the max number of items in each bucket -#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS class WeaponsResource { @@ -65,7 +64,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]); @@ -94,7 +93,7 @@ class WeaponsResource extern WeaponsResource gWR; -#define MAX_HISTORY 12 +constexpr int MAX_HISTORY = 12; enum { HISTSLOT_EMPTY, diff --git a/src/game/client/angelscript/ASClientBindings.cpp b/src/game/client/angelscript/ASClientBindings.cpp index ec54d71c..522042c0 100644 --- a/src/game/client/angelscript/ASClientBindings.cpp +++ b/src/game/client/angelscript/ASClientBindings.cpp @@ -853,7 +853,7 @@ static CBeam* AS_CreateBeamEntPoint(int startIdx, int attachment, const Vector3& static void AS_CreateSpark(const Vector3& origin) { - vec3_t pos = {origin.x, origin.y, origin.z}; + Vector pos = {origin.x, origin.y, origin.z}; gEngfuncs.pEfxAPI->R_SparkEffect(pos, 5, -200, 200); } @@ -862,7 +862,7 @@ static void AS_CreateSparkOnModel(int entityIndex, int attachment) cl_entity_t* pEnt = gEngfuncs.GetEntityByIndex(entityIndex); if (pEnt) { - vec3_t pos; + Vector pos; VectorCopy(pEnt->origin, pos); gEngfuncs.pEfxAPI->R_SparkEffect(pos, 5, -200, 200); } @@ -956,7 +956,7 @@ class CClientSound void PlaySoundAtPosition(const Vector3& pos, const std::string& soundPath, float volume) { - vec3_t position = {pos.x, pos.y, pos.z}; + Vector position = {pos.x, pos.y, pos.z}; gEngfuncs.pEfxAPI->R_RicochetSound((float*)&position); } }; @@ -975,8 +975,8 @@ static CClientSound* AS_GetClientSound() static Vector3 AS_GetGroundHeight(const Vector3& origin) { pmtrace_t trace; - vec3_t start = {origin.x, origin.y, origin.z}; - vec3_t end = {origin.x, origin.y, origin.z - 8192.0f}; + Vector start = {origin.x, origin.y, origin.z}; + Vector end = {origin.x, origin.y, origin.z - 8192.0f}; gEngfuncs.pEventAPI->EV_PlayerTrace(start, end, PM_WORLD_ONLY, -1, &trace); return Vector3(trace.endpos[0], trace.endpos[1], trace.endpos[2]); } @@ -984,8 +984,8 @@ static Vector3 AS_GetGroundHeight(const Vector3& origin) static Vector3 AS_GetSkyHeight(const Vector3& origin) { pmtrace_t trace; - vec3_t start = {origin.x, origin.y, origin.z}; - vec3_t end = {origin.x, origin.y, origin.z + 8192.0f}; + Vector start = {origin.x, origin.y, origin.z}; + Vector end = {origin.x, origin.y, origin.z + 8192.0f}; gEngfuncs.pEventAPI->EV_PlayerTrace(start, end, PM_WORLD_ONLY, -1, &trace); return Vector3(trace.endpos[0], trace.endpos[1], trace.endpos[2]); } @@ -993,8 +993,8 @@ static Vector3 AS_GetSkyHeight(const Vector3& origin) static bool AS_IsUnderSky(const Vector3& origin) { pmtrace_t trace; - vec3_t start = {origin.x, origin.y, origin.z}; - vec3_t end = {origin.x, origin.y, origin.z + 8192.0f}; + Vector start = {origin.x, origin.y, origin.z}; + Vector end = {origin.x, origin.y, origin.z + 8192.0f}; gEngfuncs.pEventAPI->EV_PlayerTrace(start, end, PM_WORLD_ONLY, -1, &trace); return trace.fraction >= 1.0f || trace.ent == 0; } @@ -1002,8 +1002,8 @@ static bool AS_IsUnderSky(const Vector3& origin) static Vector3 AS_TraceLine(const Vector3& start, const Vector3& end, bool worldOnly) { pmtrace_t trace; - vec3_t vStart = {start.x, start.y, start.z}; - vec3_t vEnd = {end.x, end.y, end.z}; + Vector vStart = {start.x, start.y, start.z}; + Vector vEnd = {end.x, end.y, end.z}; gEngfuncs.pEventAPI->EV_PlayerTrace(vStart, vEnd, worldOnly ? PM_WORLD_ONLY : PM_NORMAL, -1, &trace); return Vector3(trace.endpos[0], trace.endpos[1], trace.endpos[2]); } @@ -1011,15 +1011,15 @@ static Vector3 AS_TraceLine(const Vector3& start, const Vector3& end, bool world static int AS_TraceLineEntity(const Vector3& start, const Vector3& end) { pmtrace_t trace; - vec3_t vStart = {start.x, start.y, start.z}; - vec3_t vEnd = {end.x, end.y, end.z}; + Vector vStart = {start.x, start.y, start.z}; + Vector vEnd = {end.x, end.y, end.z}; gEngfuncs.pEventAPI->EV_PlayerTrace(vStart, vEnd, PM_NORMAL, -1, &trace); return trace.ent; } static int AS_GetContents(const Vector3& origin) { - vec3_t pos = {origin.x, origin.y, origin.z}; + Vector pos = {origin.x, origin.y, origin.z}; return gEngfuncs.PM_PointContents(pos, nullptr); } diff --git a/src/game/client/camera.h b/src/game/client/camera.h index 041d373f..35442bff 100644 --- a/src/game/client/camera.h +++ b/src/game/client/camera.h @@ -2,10 +2,10 @@ // NOTE: must include quakedef.h first #ifndef _CAMERA_H_ -#define _CAMEA_H_ +#define _CAMERA_H_ // pitch, yaw, dist -extern vec3_t cam_ofs; +extern Vector cam_ofs; // Using third person camera //extern int cam_thirdperson; //Master Sword - Moved to MSCLGlobals diff --git a/src/game/client/cdll_int.cpp b/src/game/client/cdll_int.cpp index cef6d494..208d3a43 100644 --- a/src/game/client/cdll_int.cpp +++ b/src/game/client/cdll_int.cpp @@ -499,7 +499,7 @@ void DLLEXPORT HUD_ChatInputPosition(int* x, int* y) { if (g_iUser1 != 0 || gEngfuncs.IsSpectateOnly()) { - if (gHUD.m_Spectator.m_pip->value == INSET_OFF) + if ((int)gHUD.m_Spectator.m_pip->value == INSET_OFF) { *y = YRES(64); } diff --git a/src/game/client/cl_util.h b/src/game/client/cl_util.h index e3bfefce..18d22fa8 100644 --- a/src/game/client/cl_util.h +++ b/src/game/client/cl_util.h @@ -15,16 +15,29 @@ // // cl_util.h // + #include "sharedutil.h" #include "msdebug.h" #include "cvardef.h" -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif +// ScreenHeight() returns the height of the screen, in pixels + +inline int ScreenHeight(void) { + return gHUD.m_scrinfo.iHeight; +} + +inline int ScreenWidth(void){ + return gHUD.m_scrinfo.iWidth; +} + + +//#define ScreenHeight() (gHUD.m_scrinfo.iHeight) +// ScreenWidth() returns the width of the screen, in pixels +//#define ScreenWidth() (gHUD.m_scrinfo.iWidth) + +//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 +70,7 @@ gHUD.y->UserCmd_##x(); \ } //------------------------------------------ - +//end required macros //Master Sword #undef CVAR_GET_FLOAT #undef CVAR_GET_STRING @@ -66,44 +79,115 @@ 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); } -#define SPR_Load (*gEngfuncs.pfnSPR_Load) -#define SPR_Set (*gEngfuncs.pfnSPR_Set) -#define SPR_Frames (*gEngfuncs.pfnSPR_Frames) -#define SPR_GetList (*gEngfuncs.pfnSPR_GetList) +//#define SPR_Load (gEngfuncs.pfnSPR_Load( +//#define SPR_Set (*gEngfuncs.pfnSPR_Set) +//#define SPR_Frames (*gEngfuncs.pfnSPR_Frames) +//#define SPR_GetList (*gEngfuncs.pfnSPR_GetList) // SPR_Draw draws a the current sprite as solid -#define SPR_Draw (*gEngfuncs.pfnSPR_Draw) -// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent) -#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles) +//#define SPR_Draw (*gEngfuncs.pfnSPR_Draw) + +//#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles) // SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency) -#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive) +//#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive) // SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen. -#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor) -// SPR_DisableScissor disables the clipping rect -#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor) -// -#define FillRGBA (*gEngfuncs.pfnFillRGBA) +//#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor) -// ScreenHeight returns the height of the screen, in pixels -#define ScreenHeight (gHUD.m_scrinfo.iHeight) -// ScreenWidth returns the width of the screen, in pixels -#define ScreenWidth (gHUD.m_scrinfo.iWidth) +// SPR_DisableScissor disables the clipping rect +//#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor) +//#define FillRGBA (*gEngfuncs.pfnFillRGBA) // Use this to set any co-ords in 640x480 space -#define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f)) -#define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f)) +//#define XRES(x) ((int)(float(x) * ((float)ScreenWidth() / 640.0f) + 0.5f)) +//#define YRES(y) ((int)(float(y) * ((float)ScreenHeight() / 480.0f) + 0.5f)) // use this to project world coordinates to screen coordinates -#define XPROJECT(x) ((1.0f + (x)) * ScreenWidth * 0.5f) -#define YPROJECT(y) ((1.0f - (y)) * ScreenHeight * 0.5f) +//#define XPROJECT(x) ((1.0f + (x)) * ScreenWidth() * 0.5f) +//#define YPROJECT(y) ((1.0f - (y)) * ScreenHeight() * 0.5f) -#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo) -#define ServerCmd (*gEngfuncs.pfnServerCmd) -#define ClientCmd (*gEngfuncs.pfnClientCmd) -#define SetCrosshair (*gEngfuncs.pfnSetCrosshair) +//#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo) +//#define ServerCmd (*gEngfuncs.pfnServerCmd) +//#define ClientCmd (*gEngfuncs.pfnClientCmd) +//#define SetCrosshair (*gEngfuncs.pfnSetCrosshair) //#define AngleVectors (*gEngfuncs.pfnAngleVectors) + +inline HLSPRITE SPR_Load(const char* sprName) { + return gEngfuncs.pfnSPR_Load(sprName); +}; + +inline void SPR_Set(HLSPRITE hpic, const int r, const int g, const int b) { + gEngfuncs.pfnSPR_Set(hpic, r, g, b); +}; + +inline int SPR_Frames(HLSPRITE hpic) { + return gEngfuncs.pfnSPR_Frames(hpic); +}; + +inline client_sprite_s* SPR_GetList(const char* psz, int* piCount) { + return gEngfuncs.pfnSPR_GetList(psz, piCount); +}; + +//SPR_Draw draws the current sprite as solid +inline void SPR_Draw(const int frame, const int x, const int y, const Rect* pRect) { + gEngfuncs.pfnSPR_Draw(frame, x, y, pRect); +}; + +// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent) +inline void SPR_DrawHoles(const int frame, const int x, const int y, const Rect* pRect) { + gEngfuncs.pfnSPR_DrawHoles(frame, x, y, pRect); +} + +inline void SPR_DrawAdditive(const int frame, const int x, const int y, const Rect* pRect) { + gEngfuncs.pfnSPR_DrawAdditive(frame, x, y, pRect); +} + +inline void SPR_EnableScissor(const int x, const int y, const int width, const int height) { + gEngfuncs.pfnSPR_EnableScissor(x, y, width, height); +} + +inline void SPR_DisableScissor() { + gEngfuncs.pfnSPR_DisableScissor(); +} + +inline void FillRGBA(const int x, const int y, const int width, const int height, const int r, const int b, const int g, const int a) { + gEngfuncs.pfnFillRGBA(x, y, width, height, r, g, b, a); +} + + +inline int XRES(const int x) { + return (int)(float(x) * ((float)ScreenWidth() / 640.0f) + 0.5f); +} + +inline int YRES(const int y) { + return (int)(float(y) * ((float)ScreenHeight() / 480.0f) + 0.5f); +} + +inline float XPROJECT(const float x) { + return (float)(1.0f + x) * ScreenWidth() * 0.5f; +} + +inline float YPROJECT(const float y) { + return (float)(1.0f - y) * ScreenHeight() * 0.5f; +} + +inline int GetScreenInfo(SCREENINFO_s * psScreenInfo) { + return gEngfuncs.pfnGetScreenInfo(psScreenInfo); +} + +inline int ServerCmd(const char* pszCmdString) { + return gEngfuncs.pfnServerCmd(pszCmdString); +} + +inline int ClientCmd(const char* pszCmdString) { + return gEngfuncs.pfnClientCmd(pszCmdString); +} + +inline void SetCrosshair(const HLSPRITE hSprite, const Rect rt, const int r, const int g, const int b) { + gEngfuncs.pfnSetCrosshair(hSprite, rt, r, g, b); +} + // Gets the height & width of a sprite, at the specified frame inline int SPR_Height(HLSPRITE x, int f) { return gEngfuncs.pfnSPR_Height(x, f); } inline int SPR_Width(HLSPRITE x, int f) { return gEngfuncs.pfnSPR_Width(x, f); } @@ -142,28 +226,35 @@ inline void CenterPrint(const char *string) gEngfuncs.pfnCenterPrint(string); } -// returns the players name of entity no. -#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo) +inline void GetPlayerInfo(const int enum_num, hud_player_info_s* pInfo ) { + gEngfuncs.pfnGetPlayerInfo(enum_num, pInfo); +} + +// returnsthe players name of entity no. +//#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo) // sound functions inline void PlaySound(const char *szSound, float vol) { gEngfuncs.pfnPlaySoundByName(szSound, vol); } 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)) - 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; +// extern Vector 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) { diff --git a/src/game/client/com_weapons.cpp b/src/game/client/com_weapons.cpp index 70ce421c..b16e3c33 100644 --- a/src/game/client/com_weapons.cpp +++ b/src/game/client/com_weapons.cpp @@ -130,8 +130,8 @@ Directly queue up an event on the client void HUD_PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2) { - vec3_t org; - vec3_t ang; + Vector org; + Vector ang; if (!g_runfuncs || !g_finalstate) return; diff --git a/src/game/client/com_weapons.h b/src/game/client/com_weapons.h index 1638fad1..5fdfa247 100644 --- a/src/game/client/com_weapons.h +++ b/src/game/client/com_weapons.h @@ -33,7 +33,7 @@ void stub_SetModel(struct edict_s *e, const char *m); extern cvar_t *cl_lw; extern int g_runfuncs; -extern vec3_t v_angles; +extern Vector v_angles; extern float g_lastFOV; extern struct local_state_s *g_finalstate; diff --git a/src/game/client/death.cpp b/src/game/client/death.cpp index 18dd983a..9e8b6443 100644 --- a/src/game/client/death.cpp +++ b/src/game/client/death.cpp @@ -39,17 +39,16 @@ struct DeathNoticeItem float *VictimColor; }; -#define MAX_DEATHNOTICES 4 +constexpr int MAX_DEATHNOTICES = 4; static int DEATHNOTICE_DISPLAY_TIME = 6; - -#define DEATHNOTICE_TOP 20 +constexpr int DEATHNOTICE_TOP = 20; DeathNoticeItem rgDeathNoticeList[MAX_DEATHNOTICES + 1]; -float g_ColorBlue[3] = {0.6, 0.8, 1.0}; -float g_ColorRed[3] = {1.0, 0.25, 0.25}; -float g_ColorGreen[3] = {0.6, 1.0, 0.6}; -float g_ColorYellow[3] = {1.0, 0.7, 0.0}; +constexpr float g_ColorBlue[3] = {0.6, 0.8, 1.0}; +constexpr float g_ColorRed[3] = {1.0, 0.25, 0.25}; +constexpr float g_ColorGreen[3] = {0.6, 1.0, 0.6}; +constexpr float g_ColorYellow[3] = {1.0, 0.7, 0.0}; float *GetClientColor(int clientIndex) { @@ -91,7 +90,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 @@ -113,7 +112,7 @@ int CHudDeathNotice ::Draw(float flTime) y = DEATHNOTICE_TOP + (20 * i); //!!! int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; - x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); + x = ScreenWidth() - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); if (!rgDeathNoticeList[i].iSuicide) { @@ -142,7 +141,7 @@ int CHudDeathNotice ::Draw(float flTime) x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); // Draw victims name (if it was a player that was killed) - if (rgDeathNoticeList[i].iNonPlayerKill == FALSE) + if (rgDeathNoticeList[i].iNonPlayerKill == false) { if (rgDeathNoticeList[i].VictimColor) gEngfuncs.pfnDrawSetTextColor(rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2]); @@ -222,7 +221,7 @@ int CHudDeathNotice ::MsgFunc_DeathMsg(const char *pszName, int iSize, void *pbu // Is it a non-player object kill? if (((char)victim) == -1) { - rgDeathNoticeList[i].iNonPlayerKill = TRUE; + rgDeathNoticeList[i].iNonPlayerKill = true; // Store the object's name in the Victim slot (skip the d_ bit) strncpy(rgDeathNoticeList[i].szVictim, killedwith + 2, MAX_PLAYER_NAME_LENGTH); @@ -230,10 +229,10 @@ int CHudDeathNotice ::MsgFunc_DeathMsg(const char *pszName, int iSize, void *pbu else { if (killer == victim || killer == 0) - rgDeathNoticeList[i].iSuicide = TRUE; + rgDeathNoticeList[i].iSuicide = true; if (!strcmp(killedwith, "d_teammate")) - rgDeathNoticeList[i].iTeamKill = TRUE; + rgDeathNoticeList[i].iTeamKill = true; } // Find the sprite in the list diff --git a/src/game/client/entity.cpp b/src/game/client/entity.cpp index 60b5a9ad..31fc8b2f 100644 --- a/src/game/client/entity.cpp +++ b/src/game/client/entity.cpp @@ -31,7 +31,7 @@ #undef DLLEXPORT //Master Sword #define DLLEXPORT EXPORT -#define MAX_TEMPENT_EXTRA 4096 +constexpr int MAX_TEMPENT_EXTRA = 4096; void Game_AddObjects(void); void SetClEntityProp(cl_entity_t &Ent, msstring &Cmd, mslist &ValueParams); @@ -108,7 +108,7 @@ int DLLEXPORT HUD_AddEntity(int type, struct cl_entity_s *ent, const char *model { gHUD.m_Spectator.AddOverviewEntity(type, ent, modelname); - if ((g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE) && + if ((g_iUser1 == OBS_IN_EYE || (int)gHUD.m_Spectator.m_pip->value == INSET_IN_EYE) && ent->index == g_iUser2) return 0; // don't draw the player we are following in eye } @@ -464,7 +464,7 @@ void TempEnts( void ) TEMPENTITY *p; int i, j; struct model_s *mod; - vec3_t origin; + Vector origin; int index; mod = gEngfuncs.CL_LoadModel( "sprites/laserdot.spr", &index ); @@ -544,10 +544,14 @@ void DLLEXPORT HUD_CreateEntities(void) //Put here because all the cool headers are already defined here TEMPENTITY *g_CurrentTempEnt = NULL; cl_entity_t *g_CurrentEnt = NULL; -#define MSTEMPENT_ID (1 << 0) -#define MSTEMPENT_CALLBACK (1 << 1) -#define MSTEMPENT_GRAVITY (1 << 2) -#define MSTEMPENT_FOLLOWENT (1 << 3) + +enum { + + MSTEMPENT_ID = (1 << 0), + MSTEMPENT_CALLBACK = (1 << 1), + MSTEMPENT_GRAVITY = (1 << 2), + MSTEMPENT_FOLLOWENT = (1 << 3) +}; void TempEntCallback(struct tempent_s *ent, float frametime, float currenttime) { @@ -555,7 +559,7 @@ void TempEntCallback(struct tempent_s *ent, float frametime, float currenttime) return; g_CurrentTempEnt = ent; - HUDScript->Effects_UpdateTempEnt(STRING(ent->entity.curstate.iuser3)); + gHUD.m_HUDScript->Effects_UpdateTempEnt(STRING(ent->entity.curstate.iuser3)); g_CurrentTempEnt = nullptr; } @@ -579,7 +583,7 @@ void TempEntHitCallback(struct tempent_s *ent, struct pmtrace_s *ptr) { Params.add("world"); } - HUDScript->Effects_UpdateTempEnt(TempEntExtra.CBCollide_CallbackEvent, &Params); + gHUD.m_HUDScript->Effects_UpdateTempEnt(TempEntExtra.CBCollide_CallbackEvent, &Params); } g_CurrentTempEnt = NULL; } @@ -588,7 +592,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) @@ -606,14 +610,14 @@ void CHudScript::Effects_UpdateTempEnt(const char* EventName, msstringlist *Para const char* CScript::CLGetCurrentTempEntProp(msstring &Prop) { if (!g_CurrentTempEnt) - RETURN_NOTHING; + return RETURN_NOTHING(); TEMPENTITY *p = g_CurrentTempEnt; static msstring Return; if (Prop == "deathtime") - RETURN_FLOAT(p->die) + return RETURN_FLOAT( p->die); else if (Prop == "bouncefactor") - RETURN_FLOAT(p->bounceFactor) + return RETURN_FLOAT( p->bounceFactor); else { static msstringlist Params; @@ -623,9 +627,42 @@ const char* CScript::CLGetCurrentTempEntProp(msstring &Prop) return CLGetEntProp(&p->entity, Params); } - RETURN_NOTHING; + return RETURN_NOTHING(); } +const char* RETURN_COLOR(const char* Prop, const char* name, const color24& color) { + + if (Prop == name) + { + Vector vTemp = Vector(color.r, color.g, color.b); + return VecToString(vTemp); + } + + std::string NameExt; + NameExt = name; + NameExt += ".r"; + + + if (Prop == NameExt) + return RETURN_INT(color.r); + + NameExt = name; + NameExt += ".g"; + + + if (Prop == NameExt) + return RETURN_INT(color.g); + + NameExt = name; + NameExt += ".b"; + + if (Prop == NameExt) + return RETURN_INT(color.b); + + return RETURN_NOTHING(); + +} +/* #define RETURN_COLOR(name, color) \ { \ if (Prop == name) \ @@ -634,13 +671,14 @@ const char* CScript::CLGetCurrentTempEntProp(msstring &Prop) return (Return = VecToString(vTemp)); \ } \ else if (Prop == name ".r") \ - RETURN_INT(color.r) \ + return RETURN_INT(color.r); \ else if (Prop == name ".g") \ - RETURN_INT(color.g) \ + return RETURN_INT(color.g); \ else if (Prop == name ".b") \ - RETURN_INT(color.b) \ + return RETURN_INT(color.b); \ } +*/ //[begin] DEC2014_09 Thothie - beam_update //$getcl_beam(,) const char* CScript::CLGetBeamProp(int beamid, msstringlist &Params) @@ -649,7 +687,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 ) @@ -673,35 +711,33 @@ const char* CScript::CLGetBeamProp(int beamid, msstringlist &Params) else if (Prop == "delta") beamret = VecToString(pBeam->delta); else if (Prop == "width") - beamret = FloatToString(pBeam->width); + beamret = UTIL_VarArgs("%.2f", pBeam->width); else if (Prop == "amplitude") - beamret = FloatToString(pBeam->amplitude); + beamret = UTIL_VarArgs("%.2f", pBeam->amplitude); else if (Prop == "color") - { beamret = UTIL_VarArgs("(%f,%f,%f)", pBeam->r, pBeam->g, pBeam->b); - } else if (Prop == "brightness") - beamret = FloatToString(pBeam->brightness); + beamret = UTIL_VarArgs("%.2f", pBeam->brightness); else if (Prop == "speed") - beamret = FloatToString(pBeam->speed); + beamret = UTIL_VarArgs("%.2f", pBeam->speed); else if (Prop == "life") - beamret = FloatToString(pBeam->die); + beamret = UTIL_VarArgs("%.2f", pBeam->die); else if (Prop == "segments") - beamret = IntToString(pBeam->segments); + beamret = UTIL_VarArgs("%i", pBeam->segments); else if (Prop == "framerate") - beamret = FloatToString(pBeam->frameRate); + beamret = UTIL_VarArgs("%.2f", pBeam->frameRate); else if (Prop == "framecount") - beamret = IntToString(pBeam->frameCount); + beamret = UTIL_VarArgs("%i", pBeam->frameCount); else if (Prop == "sprite") - beamret = IntToString(pBeam->modelIndex); + beamret = UTIL_VarArgs("%i", pBeam->modelIndex); else if (Prop == "startent") - beamret = IntToString(pBeam->startEntity); + beamret = UTIL_VarArgs("%i", pBeam->startEntity); else if (Prop == "endent") - beamret = IntToString(pBeam->endEntity); + beamret = UTIL_VarArgs("%i", pBeam->endEntity); else if (Prop == "flags") - beamret = IntToString(pBeam->flags); + beamret = UTIL_VarArgs("%i", pBeam->flags); else if (Prop == "t") - beamret = FloatToString(pBeam->t); + beamret = UTIL_VarArgs("%.2f", pBeam->t); return beamret; } else @@ -714,21 +750,21 @@ const char* CScript::CLGetBeamProp(int beamid, msstringlist &Params) const char* CScript::CLGetEntProp(cl_entity_t *pclEntity, msstringlist &Params) { if (!pclEntity) - RETURN_NOTHING; + return RETURN_NOTHING(); cl_entity_t &ent = *pclEntity; static msstring Return; msstring &Prop = Params[1]; if (Prop.starts_with("origin")) - RETURN_POSITION("origin", ent.origin) + return RETURN_POSITION( Prop, "origin", ent.origin); else if (Prop.starts_with("center")) { Vector vecCenter = ent.curstate.origin + ((ent.curstate.mins + ent.curstate.maxs) * 0.5); - RETURN_POSITION("center", vecCenter) + return RETURN_POSITION( Prop, "center", vecCenter); } else if (Prop.starts_with("angles")) - RETURN_ANGLE("angles", ent.angles) + return RETURN_ANGLE( Prop, "angles", ent.angles); else if (Prop.starts_with("velocity")) - RETURN_POSITION("velocity", ent.baseline.vuser1) //can't use baseline.origin - it's used by networked ents + return RETURN_POSITION( Prop, "velocity", ent.baseline.vuser1); //can't use baseline.origin - it's used by networked ents else if (Prop.starts_with("inwater")) return EngineFunc::Shared_PointContents(Vector(ent.origin.x, ent.origin.y, ent.origin.z + ent.curstate.mins.z)) == CONTENTS_WATER ? "1" : "0"; else if (Prop.starts_with("underwater")) @@ -740,7 +776,7 @@ const char* CScript::CLGetEntProp(cl_entity_t *pclEntity, msstringlist &Params) { Origin.x = ent.origin.x; Origin.y = ent.origin.y; - RETURN_POSITION("waterorigin", Origin) + return RETURN_POSITION( Prop, "waterorigin", Origin); } } else if (Prop == "model") @@ -760,106 +796,106 @@ const char* CScript::CLGetEntProp(cl_entity_t *pclEntity, msstringlist &Params) //however you can store the time the tempent began on fuserX in the creation event //then guess how far along the anim has gotten in that time based on the frame rate /* - else if( Prop == "animtime" ) RETURN_FLOAT( ent.curstate.animtime ) //FEB2009_19 - experimenting - else if( Prop == "starttime" ) RETURN_FLOAT( ent.curstate.starttime ) //FEB2009_19 - experimenting + else if( Prop == "animtime" ) return RETURN_FLOAT( ent.curstate.animtime ); //FEB2009_19 - experimenting + else if( Prop == "starttime" ) return RETURN_FLOAT( ent.curstate.starttime ); //FEB2009_19 - experimenting */ else if (Prop == "ducking") return FBitSet(player.pev->flags, FL_DUCKING) ? "1" : "0"; //Thothie JUN2010_25 else if (Prop == "modelidx") - RETURN_INT(ent.curstate.modelindex) + return RETURN_INT( ent.curstate.modelindex); else if (Prop == "anim") - RETURN_INT(ent.curstate.sequence) + return RETURN_INT( ent.curstate.sequence); else if (Prop == "height") - RETURN_FLOAT((ent.curstate.maxs.z) - (ent.curstate.mins.z)) //Thothie SEP2018_15 - return height/width for $getcl + return RETURN_FLOAT( (ent.curstate.maxs.z) - (ent.curstate.mins.z)); //Thothie SEP2018_15 - return height/width for $getcl else if (Prop == "width") - RETURN_FLOAT((ent.curstate.maxs.x) - (ent.curstate.mins.x)) //Thothie SEP2018_15 - return height/width for $getcl + return RETURN_FLOAT( (ent.curstate.maxs.x) - (ent.curstate.mins.x)); //Thothie SEP2018_15 - return height/width for $getcl else if (Prop == "mins") - RETURN_VECTOR(ent.curstate.mins) + return RETURN_VECTOR( ent.curstate.mins); else if (Prop == "maxs") - RETURN_VECTOR(ent.curstate.maxs) + return RETURN_VECTOR( ent.curstate.maxs); else if (Prop == "frame") - RETURN_FLOAT(ent.curstate.frame) + return RETURN_FLOAT( ent.curstate.frame); else if (Prop == "framerate") - RETURN_FLOAT(ent.curstate.framerate) + return RETURN_FLOAT( ent.curstate.framerate); else if (Prop == "exists") return pclEntity->Exists() ? "1" : "0"; else if (Prop == "gravity") - RETURN_FLOAT(ent.curstate.gravity) + return RETURN_FLOAT( ent.curstate.gravity); else if (Prop == "scale") - RETURN_FLOAT(ent.curstate.scale) + return RETURN_FLOAT( ent.curstate.scale); //NOV2014_16 dealing with the fact that MSC scripts can't hanle percision more than 2f else if (Prop == "scaleHD") - RETURN_FLOAT(ent.curstate.scale * 1000) + return RETURN_FLOAT( ent.curstate.scale * 1000); else if (Prop == "fuser1HD") - RETURN_FLOAT(ent.curstate.fuser1 * 1000) + return RETURN_FLOAT( ent.curstate.fuser1 * 1000); else if (Prop == "renderfx") - RETURN_INT(ent.curstate.renderfx) + return RETURN_INT( ent.curstate.renderfx); else if (Prop == "rendermode") - RETURN_INT(ent.curstate.rendermode) + return RETURN_INT( ent.curstate.rendermode); else if (Prop == "renderamt") - RETURN_INT(ent.curstate.renderamt) + return RETURN_INT( ent.curstate.renderamt); else if (Prop.starts_with("rendercolor")) - RETURN_COLOR("rendercolor", ent.curstate.rendercolor) + return RETURN_COLOR( Prop,"rendercolor", ent.curstate.rendercolor); else if (Prop == "visible") return FBitSet(ent.curstate.effects, EF_NODRAW) ? "0" : "1"; else if (Prop == "isplayer") return ent.player ? "1" : "0"; else if (Prop.starts_with("attachment0")) - RETURN_POSITION("attachment0", ent.attachment[0]) + return RETURN_POSITION( Prop, "attachment0", ent.attachment[0]); else if (Prop.starts_with("attachment1")) - RETURN_POSITION("attachment1", ent.attachment[1]) + return RETURN_POSITION( Prop, "attachment1", ent.attachment[1]); else if (Prop.starts_with("attachment2")) - RETURN_POSITION("attachment2", ent.attachment[2]) + return RETURN_POSITION( Prop, "attachment2", ent.attachment[2]); else if (Prop.starts_with("attachment3")) - RETURN_POSITION("attachment3", ent.attachment[3]) + return RETURN_POSITION( Prop, "attachment3", ent.attachment[3]); else if (Prop == "iuser1") - RETURN_INT(ent.curstate.iuser1) + return RETURN_INT(ent.curstate.iuser1); else if (Prop == "iuser2") - RETURN_INT(ent.curstate.iuser2) + return RETURN_INT(ent.curstate.iuser2); else if (Prop == "iuser3") - RETURN_INT(ent.curstate.iuser3) + return RETURN_INT(ent.curstate.iuser3); else if (Prop == "iuser4") - RETURN_INT(ent.curstate.iuser4) + return RETURN_INT(ent.curstate.iuser4); else if (Prop == "fuser1") - RETURN_FLOAT(ent.curstate.fuser1) + return RETURN_FLOAT(ent.curstate.fuser1); else if (Prop == "fuser2") - RETURN_FLOAT(ent.curstate.fuser2) + return RETURN_FLOAT(ent.curstate.fuser2); else if (Prop == "fuser3") - RETURN_FLOAT(ent.curstate.fuser3) + return RETURN_FLOAT(ent.curstate.fuser3); else if (Prop == "fuser4") - RETURN_FLOAT(ent.curstate.fuser4) + return RETURN_FLOAT(ent.curstate.fuser4); else if (Prop == "prevstate.iuser1") - RETURN_INT(ent.prevstate.iuser1) + return RETURN_INT(ent.prevstate.iuser1); else if (Prop == "prevstate.iuser2") - RETURN_INT(ent.prevstate.iuser2) + return RETURN_INT( ent.prevstate.iuser2); else if (Prop == "prevstate.iuser3") - RETURN_INT(ent.prevstate.iuser3) + return RETURN_INT(ent.prevstate.iuser3); else if (Prop == "prevstate.iuser4") - RETURN_INT(ent.prevstate.iuser4) + return RETURN_INT( ent.prevstate.iuser4); else if (Prop == "prevstate.fuser1") - RETURN_FLOAT(ent.prevstate.fuser1) + return RETURN_FLOAT( ent.prevstate.fuser1); else if (Prop == "prevstate.fuser2") - RETURN_FLOAT(ent.prevstate.fuser2) + return RETURN_FLOAT(ent.prevstate.fuser2); else if (Prop == "prevstate.fuser3") - RETURN_FLOAT(ent.prevstate.fuser3) + return RETURN_FLOAT( ent.prevstate.fuser3); else if (Prop == "prevstate.fuser4") - RETURN_FLOAT(ent.prevstate.fuser4) + return RETURN_FLOAT( ent.prevstate.fuser4); else if (Prop == "baseline.iuser1") - RETURN_INT(ent.baseline.iuser1) //Baseline props are not overriden by + return RETURN_INT(ent.baseline.iuser1); //Baseline props are not overriden by; else if (Prop == "baseline.iuser2") - RETURN_INT(ent.baseline.iuser2) //incoming server packets + return RETURN_INT(ent.baseline.iuser2); //incoming server packets; else if (Prop == "baseline.iuser3") - RETURN_INT(ent.baseline.iuser3) //Stuff stored here is persistent + return RETURN_INT(ent.baseline.iuser3); //Stuff stored here is persistent; else if (Prop == "baseline.iuser4") - RETURN_INT(ent.baseline.iuser4) + return RETURN_INT(ent.baseline.iuser4); else if (Prop == "baseline.fuser1") - RETURN_FLOAT(ent.baseline.fuser1) + return RETURN_FLOAT( ent.baseline.fuser1); else if (Prop == "baseline.fuser2") - RETURN_FLOAT(ent.baseline.fuser2) + return RETURN_FLOAT( ent.baseline.fuser2); else if (Prop == "baseline.fuser3") - RETURN_FLOAT(ent.baseline.fuser3) + return RETURN_FLOAT( ent.baseline.fuser3); else if (Prop == "baseline.fuser4") - RETURN_FLOAT(ent.baseline.fuser4) + return RETURN_FLOAT( ent.baseline.fuser4); else if (Prop == "bonepos") { //Thothie (Comment Only) - We may want to move this up, as it is sometimes used every frame @@ -867,33 +903,33 @@ const char* CScript::CLGetEntProp(cl_entity_t *pclEntity, msstringlist &Params) //Vector Pos; /* if( !pclEntity->GetBonePos( atoi(Params[2]), Pos ) ) - RETURN_ZERO; + return RETURN_ZERO(); */ //AUG2013_25 Thothie - attempting to fix client side bonepos function Vector Pos; ent.GetBonePosVec(atoi(Params[2]), Pos); //GetBonePos is boolean, wtf? //pclEntity->GetBonePosVec( atoi(Params[2]), Pos ); - RETURN_VECTOR(Pos); + return RETURN_VECTOR( Pos); } else if (Prop.starts_with("bonecount")) { //AUG2013_25 - enabling getting bone count (be good to have this serverside too) - RETURN_INT(ent.GetBoneCount()) + return RETURN_INT(ent.GetBoneCount()); } else if (Prop.starts_with("viewangles")) { //MIB AUG2010_05 - vec3_t viewangles; + Vector viewangles; gEngfuncs.GetViewAngles((float *)viewangles); - RETURN_ANGLE("viewangles", viewangles) + RETURN_ANGLE( Prop, "viewangles", viewangles); } /* else if ( Prop.starts_with("eyepos") ) { //Thoth APR2012_05 - attempting to return eye position (fail) - vec3_t eyepos = player.pev->view_ofs; - RETURN_ANGLE( "eyepos", eyepos ) + Vector eyepos = player.pev->view_ofs; + return RETURN_ANGLE(Prop, "eyepos", eyepos ); } */ @@ -907,7 +943,7 @@ const char* CScript::CLGetEntProp(cl_entity_t *pclEntity, msstringlist &Params) else if ( Prop == "race" ) return pPlayer->m_Race; } */ - RETURN_ZERO; + return RETURN_ZERO(); } int CL_LoadModel(const char* RelativePathname, model_s **ppModel = NULL) @@ -963,7 +999,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 +1151,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 +1217,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 +1243,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 +1258,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 +1421,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 +1454,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 +1469,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 +1566,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) { @@ -1725,7 +1761,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) @@ -1897,7 +1933,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; @@ -2028,7 +2064,7 @@ void DLLEXPORT HUD_TempEntUpdate( TempExtra.CBTimer_Enabled = false; g_CurrentTempEnt = pTemp; - HUDScript->Effects_UpdateTempEnt(TempExtra.CBTimer_CallbackEvent); + gHUD.m_HUDScript->Effects_UpdateTempEnt(TempExtra.CBTimer_CallbackEvent); g_CurrentTempEnt = NULL; } @@ -2049,7 +2085,7 @@ void DLLEXPORT HUD_TempEntUpdate( { TempExtra.CBWater_Enabled = false; g_CurrentTempEnt = pTemp; - HUDScript->Effects_UpdateTempEnt(TempExtra.CBWater_CallbackEvent); + gHUD.m_HUDScript->Effects_UpdateTempEnt(TempExtra.CBWater_CallbackEvent); g_CurrentTempEnt = NULL; } } @@ -2155,7 +2191,7 @@ void DLLEXPORT HUD_TempEntUpdate( if (pTemp->flags & (FTENT_COLLIDEALL | FTENT_COLLIDEWORLD)) { - vec3_t traceNormal; + Vector traceNormal; float traceFraction = 1; if (pTemp->flags & FTENT_COLLIDEALL) diff --git a/src/game/client/ev_common.cpp b/src/game/client/ev_common.cpp index 63418887..bf4faff8 100644 --- a/src/game/client/ev_common.cpp +++ b/src/game/client/ev_common.cpp @@ -98,7 +98,7 @@ Figure out the height of the gun void EV_GetGunPosition(event_args_t *args, float *pos, float *origin) { int idx; - vec3_t view_ofs; + Vector view_ofs; idx = args->entindex; @@ -130,7 +130,7 @@ Bullet shell casings */ void EV_EjectBrass(float *origin, float *velocity, float rotation, int model, int soundtype) { - vec3_t endpos; + Vector endpos; VectorClear(endpos); endpos[1] = rotation; gEngfuncs.pEfxAPI->R_TempModel(origin, velocity, endpos, 2.5, model, soundtype); @@ -146,7 +146,7 @@ Determine where to eject shells from void EV_GetDefaultShellInfo(event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale) { int i; - vec3_t view_ofs; + Vector view_ofs; float fR, fU; int idx; diff --git a/src/game/client/ev_hldm.cpp b/src/game/client/ev_hldm.cpp index 9ba4734d..162de8e4 100644 --- a/src/game/client/ev_hldm.cpp +++ b/src/game/client/ev_hldm.cpp @@ -52,18 +52,20 @@ extern "C" void EV_TrainPitchAdjust(struct event_args_s *args); } -#define VECTOR_CONE_1DEGREES Vector(0.00873, 0.00873, 0.00873) -#define VECTOR_CONE_2DEGREES Vector(0.01745, 0.01745, 0.01745) -#define VECTOR_CONE_3DEGREES Vector(0.02618, 0.02618, 0.02618) -#define VECTOR_CONE_4DEGREES Vector(0.03490, 0.03490, 0.03490) -#define VECTOR_CONE_5DEGREES Vector(0.04362, 0.04362, 0.04362) -#define VECTOR_CONE_6DEGREES Vector(0.05234, 0.05234, 0.05234) -#define VECTOR_CONE_7DEGREES Vector(0.06105, 0.06105, 0.06105) -#define VECTOR_CONE_8DEGREES Vector(0.06976, 0.06976, 0.06976) -#define VECTOR_CONE_9DEGREES Vector(0.07846, 0.07846, 0.07846) -#define VECTOR_CONE_10DEGREES Vector(0.08716, 0.08716, 0.08716) -#define VECTOR_CONE_15DEGREES Vector(0.13053, 0.13053, 0.13053) -#define VECTOR_CONE_20DEGREES Vector(0.17365, 0.17365, 0.17365) + + +constexpr Vector VECTOR_CONE_1DEGREES = Vector(0.00873, 0.00873, 0.00873); +constexpr Vector VECTOR_CONE_2DEGREES = Vector(0.01745, 0.01745, 0.01745); +constexpr Vector VECTOR_CONE_3DEGREES = Vector(0.02618, 0.02618, 0.02618); +constexpr Vector VECTOR_CONE_4DEGREES = Vector(0.03490, 0.03490, 0.03490); +constexpr Vector VECTOR_CONE_5DEGREES = Vector(0.04362, 0.04362, 0.04362); +constexpr Vector VECTOR_CONE_6DEGREES = Vector(0.05234, 0.05234, 0.05234); +constexpr Vector VECTOR_CONE_7DEGREES = Vector(0.06105, 0.06105, 0.06105); +constexpr Vector VECTOR_CONE_8DEGREES = Vector(0.06976, 0.06976, 0.06976); +constexpr Vector VECTOR_CONE_9DEGREES = Vector(0.07846, 0.07846, 0.07846); +constexpr Vector VECTOR_CONE_10DEGREES = Vector(0.08716, 0.08716, 0.08716); +constexpr Vector VECTOR_CONE_15DEGREES = Vector(0.13053, 0.13053, 0.13053); +constexpr Vector VECTOR_CONE_20DEGREES = Vector(0.17365, 0.17365, 0.17365); // play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the // original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture. @@ -115,7 +117,7 @@ float EV_HLDM_PlayTextureSound(int idx, pmtrace_t *ptr, float *vecSrc, float *ve // '}}' strncpy(szbuffer, pTextureName, sizeof(szbuffer)); - szbuffer[CBTEXTURENAMEMAX - 1] = 0; + szbuffer[MAX_CBTEXTURENAME - 1] = 0; // get texture type chTextureType = PM_FindTextureType(szbuffer); @@ -325,11 +327,11 @@ int EV_HLDM_CheckTracer(int idx, float *vecSrc, float *end, float *forward, floa if (iTracerFreq != 0 && ((*tracerCount)++ % iTracerFreq) == 0) { - vec3_t vecTracerSrc; + Vector vecTracerSrc; if (player) { - vec3_t offset(0, 0, -4); + Vector offset(0, 0, -4); // adjust tracer position for player for (i = 0; i < 3; i++) @@ -367,12 +369,12 @@ FireBullets Go to the trouble of combining multiple pellets into a single damage call. ================ */ -void EV_HLDM_FireBullets(int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float *vecSpread, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount) +void EV_HLDM_FireBullets(int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount) { int i; pmtrace_t tr; int iShot; - vec3_t vecRight, vecUp; + Vector vecRight, vecUp; int tracer; VectorCopy(right, vecRight); @@ -380,10 +382,10 @@ void EV_HLDM_FireBullets(int idx, float *forward, float *right, float *up, int c for (iShot = 1; iShot <= cShots; iShot++) { - vec3_t vecDir, vecEnd; + Vector vecDir, vecEnd; // get circular gaussian spread - vec3_t spread; + Vector spread; do { spread[0] = gEngfuncs.pfnRandomFloat(-0.5, 0.5) + gEngfuncs.pfnRandomFloat(-0.5, 0.5); @@ -453,18 +455,18 @@ void EV_HLDM_FireBullets(int idx, float *forward, float *right, float *up, int c void EV_FireGlock1(event_args_t *args) { int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; + Vector origin; + Vector angles; + Vector velocity; int empty; int i; - vec3_t ShellVelocity; - vec3_t ShellOrigin; + Vector ShellVelocity; + Vector ShellOrigin; int shell; - vec3_t vecSrc, vecAiming; - vec3_t vecSpread; - vec3_t up, right, forward; + Vector vecSrc, vecAiming; + Vector vecSpread; + Vector up, right, forward; float flSpread = 0.01; idx = args->entindex; @@ -509,17 +511,17 @@ void EV_FireGlock1(event_args_t *args) void EV_FireGlock2(event_args_t *args) { int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; + Vector origin; + Vector angles; + Vector velocity; int i; - vec3_t ShellVelocity; - vec3_t ShellOrigin; + Vector ShellVelocity; + Vector ShellOrigin; int shell; - vec3_t vecSrc, vecAiming; - vec3_t vecSpread; - vec3_t up, right, forward; + Vector vecSrc, vecAiming; + Vector vecSpread; + Vector up, right, forward; float flSpread = 0.1; idx = args->entindex; @@ -564,17 +566,17 @@ void EV_FireGlock2(event_args_t *args) void EV_FireShotGunDouble(event_args_t *args) { int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; + Vector origin; + Vector angles; + Vector velocity; int i, j; - vec3_t ShellVelocity; - vec3_t ShellOrigin; + Vector ShellVelocity; + Vector ShellOrigin; int shell; - vec3_t vecSrc, vecAiming; - vec3_t vecSpread; - vec3_t up, right, forward; + Vector vecSrc, vecAiming; + Vector vecSpread; + Vector up, right, forward; float flSpread = 0.01; idx = args->entindex; @@ -630,17 +632,17 @@ void EV_FireShotGunDouble(event_args_t *args) void EV_FireShotGunSingle(event_args_t *args) { int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; + Vector origin; + Vector angles; + Vector velocity; int i; - vec3_t ShellVelocity; - vec3_t ShellOrigin; + Vector ShellVelocity; + Vector ShellOrigin; int shell; - vec3_t vecSrc, vecAiming; - vec3_t vecSpread; - vec3_t up, right, forward; + Vector vecSrc, vecAiming; + Vector vecSpread; + Vector up, right, forward; float flSpread = 0.01; idx = args->entindex; @@ -693,15 +695,15 @@ void EV_FireShotGunSingle(event_args_t *args) void EV_FireMP5(event_args_t *args) { int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; + Vector origin; + Vector angles; + Vector velocity; - vec3_t ShellVelocity; - vec3_t ShellOrigin; + Vector ShellVelocity; + Vector ShellOrigin; int shell; - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; + Vector vecSrc, vecAiming; + Vector up, right, forward; float flSpread = 0.01; idx = args->entindex; @@ -755,12 +757,12 @@ void EV_FireMP5(event_args_t *args) void EV_FirePython(event_args_t *args) { int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; + Vector origin; + Vector angles; + Vector velocity; - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; + Vector vecSrc, vecAiming; + Vector up, right, forward; float flSpread = 0.01; idx = args->entindex; @@ -802,14 +804,16 @@ void EV_FirePython(event_args_t *args) } } -#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch +enum { + SND_CHANGE_PITCH = (1 << 7) // duplicated in protocol.h change sound pitch +}; void EV_SpinGauss(event_args_t *args) { int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; + Vector origin; + Vector angles; + Vector velocity; int iSoundState = 0; int pitch; @@ -830,16 +834,16 @@ void EV_SpinGauss(event_args_t *args) void EV_FireGauss(event_args_t *args) { int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; + Vector origin; + Vector angles; + Vector velocity; float flDamage = args->fparam1; int primaryfire = args->bparam1; int m_fPrimaryFire = args->bparam1; int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; - vec3_t vecSrc; - vec3_t vecDest; + Vector vecSrc; + Vector vecDest; edict_t *pentIgnore; pmtrace_t tr, beam_tr; float flMaxFrac = 1.0; @@ -849,7 +853,7 @@ void EV_FireGauss(event_args_t *args) int nMaxHits = 10; physent_t *pEntity; int m_iBeam, m_iGlow, m_iBalls; - vec3_t up, right, forward; + Vector up, right, forward; idx = args->entindex; VectorCopy(args->origin, origin); @@ -956,7 +960,7 @@ void EV_FireGauss(event_args_t *args) { // ALERT( at_console, "reflect %f\n", n ); // reflect - vec3_t r; + Vector r; VectorMA(forward, 2.0 * n, tr.plane.normal, r); @@ -970,7 +974,7 @@ void EV_FireGauss(event_args_t *args) gEngfuncs.pEfxAPI->R_TempSprite(tr.endpos, Vector(0,0,0), 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage * n / 255.0, flDamage * n * 0.5 * 0.1, FTENT_FADEOUT); { - vec3_t fwd; + Vector fwd; VectorAdd(tr.endpos, tr.plane.normal, fwd); gEngfuncs.pEfxAPI->R_Sprite_Trail(TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, (int)(n * flDamage * 0.3), 0.1, gEngfuncs.pfnRandomFloat(10, 20) / 100.0, 100, 255, 200); @@ -1001,7 +1005,7 @@ void EV_FireGauss(event_args_t *args) // try punching through wall if secondary attack (primary is incapable of breaking through) if (!m_fPrimaryFire) { - vec3_t start; + Vector start; VectorMA(tr.endpos, 8.0, forward, start); @@ -1016,7 +1020,7 @@ void EV_FireGauss(event_args_t *args) if (!beam_tr.allsolid) { - vec3_t delta; + Vector delta; float n; // trace backwards to find exit point @@ -1035,7 +1039,7 @@ void EV_FireGauss(event_args_t *args) // absorption balls { - vec3_t fwd; + Vector fwd; VectorSubtract(tr.endpos, forward, fwd); gEngfuncs.pEfxAPI->R_Sprite_Trail(TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat(10, 20) / 100.0, 100, 255, 100); @@ -1050,7 +1054,7 @@ void EV_FireGauss(event_args_t *args) // balls { - vec3_t fwd; + Vector fwd; VectorSubtract(beam_tr.endpos, forward, fwd); gEngfuncs.pEfxAPI->R_Sprite_Trail(TE_SPRITETRAIL, beam_tr.endpos, fwd, m_iBalls, (int)(flDamage * 0.3), 0.1, gEngfuncs.pfnRandomFloat(10, 20) / 100.0, 200, 255, 40); @@ -1075,7 +1079,7 @@ void EV_FireGauss(event_args_t *args) gEngfuncs.pEfxAPI->R_TempSprite(tr.endpos, Vector(0,0,0), 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, 200.0 / 255.0, 0.3, FTENT_FADEOUT); { - vec3_t fwd; + Vector fwd; VectorAdd(tr.endpos, tr.plane.normal, fwd); gEngfuncs.pEfxAPI->R_Sprite_Trail(TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 8, 0.6, gEngfuncs.pfnRandomFloat(10, 20) / 100.0, 100, 255, 200); @@ -1102,7 +1106,7 @@ void EV_TrainPitchAdjust(event_args_t *args) int stop; int idx = args->entindex; - vec3_t origin; + Vector origin; VectorCopy(args->origin, origin); us_params = (unsigned short)args->iparam1; diff --git a/src/game/client/ev_hldm.h b/src/game/client/ev_hldm.h index fb3279ce..885f5ddc 100644 --- a/src/game/client/ev_hldm.h +++ b/src/game/client/ev_hldm.h @@ -68,9 +68,12 @@ enum python_e PYTHON_IDLE3 }; -#define GAUSS_PRIMARY_CHARGE_VOLUME 256 // how loud gauss is while charging -#define GAUSS_PRIMARY_FIRE_VOLUME 450 // how loud gauss is when discharged +enum { + GAUSS_PRIMARY_CHARGE_VOLUME = 256, // how loud gauss is while charging + GAUSS_PRIMARY_FIRE_VOLUME = 450 // how loud gauss is when discharged + +}; enum gauss_e { GAUSS_IDLE = 0, diff --git a/src/game/client/eventscripts.h b/src/game/client/eventscripts.h index 169819d1..0fd02e45 100644 --- a/src/game/client/eventscripts.h +++ b/src/game/client/eventscripts.h @@ -3,53 +3,50 @@ #define EVENTSCRIPTSH // defaults for clientinfo messages -#define DEFAULT_VIEWHEIGHT 28 -#define VEC_DUCK_VIEW 12 - -#define FTENT_FADEOUT 0x00000080 - -#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) +inline constexpr int DEFAULT_VIEWHEIGHT = 28; +inline constexpr int VEC_DUCK_VIEW = 12; +//inline constexpr int FTENT_FADEOUT = 0x00000080; already defines as enum in a different file. + + +enum { + DMG_GENERIC = 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. + + // time-based damage + //mask off TF-specific stuff too + DMG_TIMEBASED = (~(0xff003fff)), // mask for time-based damage + DMG_DROWN = (1 << 14), // Drowning + DMG_FIRSTTIMEBASED = DMG_DROWN, + 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_IGNITE = (1 << 24), // Players hit by this begin to burn + DMG_RADIUS_MAX = (1 << 25), // Radius damage with this flag doesn't decrease over distance + DMG_RADIUS_QUAKE = (1 << 26), // Radius damage is done like Quake. 1/2 damage at 1/2 radius. + DMG_IGNOREARMOR = (1 << 27), // Damage ignores target's armor + DMG_AIMED = (1 << 28), // Does Hit location damage + DMG_WALLPIERCING = (1 << 29), // Blast Damages ents through walls + DMG_CALTROP = (1 << 30), + DMG_HALLUC = (1 << 31) +}; // Some of these are HL/TFC specific? void EV_EjectBrass(float *origin, float *velocity, float rotation, int model, int soundtype); diff --git a/src/game/client/hl/hl_baseentity.cpp b/src/game/client/hl/hl_baseentity.cpp index db98d1f9..f073ee53 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; } -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 ::IsDormant(void) { return NULL; } +BOOL CBaseEntity ::IsInWorld(void) { return true; } +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; } @@ -94,9 +95,9 @@ void UTIL_BloodDrips(const Vector &origin, const Vector &direction, int color, i void UTIL_DecalTrace(TraceResult *pTrace, int decalNumber) {} void UTIL_GunshotDecalTrace(TraceResult *pTrace, int decalNumber) {} void UTIL_MakeVectors(const Vector &vecAngles) {} -BOOL UTIL_IsValidEntity(edict_t *pent) { return TRUE; } +BOOL UTIL_IsValidEntity(edict_t *pent) { return true; } void UTIL_SetOrigin(entvars_t *, const Vector &org) {} -BOOL UTIL_GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) { return TRUE; } +BOOL UTIL_GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) { return true; } void UTIL_LogPrintf(const char *, ...) {} void UTIL_ClientPrintAll(int, char const *, char const *, char const *, char const *, char const *) {} void PrintNotifyMsg(char *pszmsg); @@ -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 @@ -120,118 +121,118 @@ void CGrenade::Spawn(void) {} CBaseEntity *CBaseMonster ::CheckTraceHullAttack(float flDist, int iDamage, int iDmgType) { return NULL; } void CBaseMonster ::Eat(float flFullDuration) {} -BOOL CBaseMonster ::FShouldEat(void) { return TRUE; } +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; } -BOOL CBaseMonster ::FValidateHintType(short sHint) { return FALSE; } +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::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; } -BOOL CBaseMonster::MoveToNode(Activity movementAct, float waitTime, const Vector &goal) { return FALSE; } -int ShouldSimplify(int routeType) { return TRUE; } +BOOL CBaseMonster ::FRouteClear(void) { return false; } +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; } +BOOL CBaseMonster::MoveToNode(Activity movementAct, float waitTime, const Vector &goal) { return false; } +int ShouldSimplify(int routeType) { return true; } void CBaseMonster ::RouteSimplify(CBaseEntity *pTargetEnt) {} -BOOL CBaseMonster ::FBecomeProne(void) { return TRUE; } -BOOL CBaseMonster ::CheckRangeAttack1(float flDot, float flDist) { return FALSE; } -BOOL CBaseMonster ::CheckRangeAttack2(float flDot, float flDist) { return FALSE; } -BOOL CBaseMonster ::CheckMeleeAttack1(float flDot, float flDist) { return FALSE; } -BOOL CBaseMonster ::CheckMeleeAttack2(float flDot, float flDist) { return FALSE; } +BOOL CBaseMonster ::FBecomeProne(void) { return true; } +BOOL CBaseMonster ::CheckRangeAttack1(float flDot, float flDist) { return false; } +BOOL CBaseMonster ::CheckRangeAttack2(float flDot, float flDist) { return false; } +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; } +BOOL CBaseMonster ::FCanCheckAttacks(void) { return false; } +int CBaseMonster ::CheckEnemy(CBaseEntity *pEnemy) { return false; } void CBaseMonster ::PushEnemy(CBaseEntity *pEnemy, Vector &vecLastKnownPos) {} -BOOL CBaseMonster ::PopEnemy() { return FALSE; } +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; } -BOOL CBaseMonster ::BuildRoute(const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget) { return FALSE; } +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; } +BOOL CBaseMonster ::FTriangulate(const Vector &vecStart, const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex) { return false; } void CBaseMonster ::Move(float flInterval) {} -BOOL CBaseMonster::ShouldAdvanceRoute(float flWaypointDist) { return FALSE; } +BOOL CBaseMonster::ShouldAdvanceRoute(float flWaypointDist) { return false; } void CBaseMonster::MoveExecute(CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval) {} 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; } -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; } +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; } -bool CBaseMonster ::FInViewCone(CBaseEntity *pEntity) { return FALSE; } -bool CBaseMonster ::FInViewCone(Vector &Origin) { return FALSE; } -BOOL CBaseEntity ::FVisible(CBaseEntity *pEntity) { return FALSE; } -BOOL CBaseEntity ::FVisible(const Vector &vecOrigin) { return FALSE; } -BOOL CBaseEntity ::FMVisible(CBaseEntity *pEntity) { return FALSE; } -BOOL CBaseEntity ::FMVisible(const Vector &vecOrigin) { return FALSE; } +bool CBaseMonster ::FInViewCone(CBaseEntity *pEntity) { return false; } +bool CBaseMonster ::FInViewCone(Vector &Origin) { return false; } +BOOL CBaseEntity ::FVisible(CBaseEntity *pEntity) { return false; } +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; } +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) {} void CBaseMonster ::MakeDamageBloodDecal(int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir) {} -BOOL CBaseMonster ::FGetNodeRoute(Vector vecDest) { return TRUE; } +BOOL CBaseMonster ::FGetNodeRoute(Vector vecDest) { return true; } int CBaseMonster ::FindHintNode(void) { return NO_NODE; } void CBaseMonster::ReportAIState(void) {} void CBaseMonster ::KeyValue(KeyValueData *pkvd) {} -BOOL CBaseMonster ::FCheckAITrigger(void) { return FALSE; } -int CBaseMonster ::CanPlaySequence(BOOL fDisregardMonsterState, int interruptLevel) { return FALSE; } -BOOL CBaseMonster ::FindLateralCover(const Vector &vecThreat, const Vector &vecViewOffset) { return FALSE; } +BOOL CBaseMonster ::FCheckAITrigger(void) { return false; } +int CBaseMonster ::CanPlaySequence(BOOL fDisregardMonsterState, int interruptLevel) { return false; } +BOOL CBaseMonster ::FindLateralCover(const Vector &vecThreat, const Vector &vecViewOffset) { return false; } Vector CBaseMonster ::ShootAtEnemy(const Vector &shootOrigin) { return g_vecZero; } -BOOL CBaseMonster ::FacingIdeal(void) { return FALSE; } -BOOL CBaseMonster ::FCanActiveIdle(void) { return FALSE; } +BOOL CBaseMonster ::FacingIdeal(void) { return false; } +BOOL CBaseMonster ::FCanActiveIdle(void) { return false; } void CBaseMonster::PlaySentence(const char *pszSentence, float duration, float volume, float attenuation) {} void CBaseMonster::PlayScriptedSentence(const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener) {} void CBaseMonster::SentenceStop(void) {} void CBaseMonster::CorpseFallThink(void) {} void CBaseMonster ::MonsterInitDead(void) {} -BOOL CBaseMonster ::BBoxFlat(void) { return TRUE; } -BOOL CBaseMonster ::GetEnemy(void) { return FALSE; } +BOOL CBaseMonster ::BBoxFlat(void) { return true; } +BOOL CBaseMonster ::GetEnemy(void) { return false; } void CBaseMonster ::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) {} CBaseEntity *CBaseMonster ::DropItem(char *pszItemName, const Vector &vecPos, const Vector &vecAng) { return NULL; } -BOOL CBaseMonster ::ShouldFadeOnDeath(void) { return FALSE; } +BOOL CBaseMonster ::ShouldFadeOnDeath(void) { return false; } void CBaseMonster ::RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) {} void CBaseMonster ::RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) {} void CBaseMonster::FadeMonster(void) {} void CBaseMonster ::GibMonster(void) {} -BOOL CBaseMonster ::HasHumanGibs(void) { return FALSE; } -BOOL CBaseMonster ::HasAlienGibs(void) { return FALSE; } +BOOL CBaseMonster ::HasHumanGibs(void) { return false; } +BOOL CBaseMonster ::HasAlienGibs(void) { return false; } Activity CBaseMonster ::GetDeathActivity(void) { return ACT_DIE_HEADSHOT; } MONSTERSTATE CBaseMonster ::GetIdealState(void) { return MONSTERSTATE_ALERT; } Schedule_t *CBaseMonster ::GetScheduleOfType(int Type) { return NULL; } @@ -242,35 +243,35 @@ 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; } +BOOL CBasePlayer::IsOnLadder(void) { return false; } void CBasePlayer::PlayerDeathThink(void) {} void CBasePlayer::StartDeathCam(void) {} 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,14 +280,14 @@ 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; } +BOOL CBasePlayer::HasWeapons(void) { return false; } void CBasePlayer::SelectPrevItem(int iItem) {} CBaseEntity *FindEntityForward(CBaseEntity *pMe) { return NULL; } -//BOOL CBasePlayer :: FlashlightIsOn( void ) { return FALSE; } +//BOOL CBasePlayer :: FlashlightIsOn( void ) { return false; } //void CBasePlayer :: FlashlightTurnOn( void ) { } //void CBasePlayer :: FlashlightTurnOff( void ) { } //void CBasePlayer :: ForceClientDllUpdate( void ) { } @@ -294,25 +295,25 @@ 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; } +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() {} bool CBasePlayer::AcceptOffer() { return false; } tradeinfo_t *CBasePlayer::TradeItem(tradeinfo_t *ptiTradeInfo) { return NULL; } -BOOL CBasePlayer::SkinMonster(CMSMonster *pDeadMonster) { return FALSE; } +BOOL CBasePlayer::SkinMonster(CMSMonster *pDeadMonster) { return false; } void CBasePlayer::AddNoise(float flNoiseAmt) {} void CBasePlayer::Attacked(CBaseEntity *pAttacker, float flDamage, int bitsDamageType) {} void CBasePlayer::Seen(CMSMonster *pMonster) {} diff --git a/src/game/client/hud.cpp b/src/game/client/hud.cpp index 53628b5c..c084f356 100644 --- a/src/game/client/hud.cpp +++ b/src/game/client/hud.cpp @@ -48,6 +48,11 @@ #include "fmod/soundengine.h" #include "mslogger.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h +#endif + + //----------------- extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes, int iCount); extern cvar_t *sensitivity; @@ -236,10 +241,7 @@ int __MsgFunc_ViewModel(const char *pszName, int iSize, void *pbuf) return 1; } -#define SetMSHUD(ptr, type) \ - ptr = new (type); \ - strncpy(ptr->Name, #type, 32 ) - + // This is called every time the DLL is loaded void CHud::Init(void) { @@ -247,15 +249,15 @@ void CHud::Init(void) //ClientCmd( "r_shadows 1" ); ClientCmd("cl_himodels 0"); - SetMSHUD(m_Menu, CHudMenu); - SetMSHUD(m_Fatigue, CHudFatigue); - SetMSHUD(m_Magic, CHudMagic); - SetMSHUD(m_Music, CHudMusic); - SetMSHUD(m_Action, CHudAction); - SetMSHUD(m_Health, CHudHealth); - SetMSHUD(m_HUDScript, CHudScript); - SetMSHUD(m_Misc, CHudMisc); - SetMSHUD(m_HUDId, CHudID); + m_Menu = new(CHudMenu); + m_Fatigue = new(CHudFatigue); + m_Magic = new(CHudMagic); + m_Music = new(CHudMusic); + m_Action = new(CHudAction); + m_Health = new(CHudHealth); + m_HUDScript = new(CHudScript); + m_Misc = new(CHudMisc); + m_HUDId = new(CHudID); //MS commands and messages //HOOK_COMMAND( "use", PlayerUseItem ); @@ -383,7 +385,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); @@ -466,7 +468,7 @@ int CHud::Redraw(float flTime, int intermission) // SPR_Set(m_hsprLogo, 250, 250, 250); // x = SPR_Width(m_hsprLogo, 0); - // x = ScreenWidth - x; + // x = ScreenWidth() - x; // y = SPR_Height(m_hsprLogo, 0) / 2; // // Draw the logo at 20 fps @@ -566,7 +568,7 @@ void CHud::VidInit(void) m_hsprLogo = 0; m_hsprCursor = 0; - if (ScreenWidth < 640) + if (ScreenWidth() < 640) m_iRes = 320; else m_iRes = 640; diff --git a/src/game/client/hud.h b/src/game/client/hud.h index 225ef6c4..82f6b356 100644 --- a/src/game/client/hud.h +++ b/src/game/client/hud.h @@ -39,20 +39,27 @@ class CHudMisc; ///////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\// -#define RGB_YELLOWISH 0x00FFA000 //255,160,0 -#define RGB_REDISH 0x00FF1010 //255,160,0 -#define RGB_GREENISH 0x0000A000 //0,160,0 +enum { + RGB_YELLOWISH = 0x00FFA000, //255,160,0 + RGB_REDISH = 0x00FF1010, //255,160,0 + RGB_GREENISH = 0x0000A000 //0,160,0 +}; #include "wrect.h" #include "cl_dll.h" #include "ammo.h" -#define DHN_DRAWZERO 1 -#define DHN_2DIGITS 2 -#define DHN_3DIGITS 4 -#define MIN_ALPHA 100 +enum { + DHN_DRAWZERO = 1, + DHN_2DIGITS = 2, + DHN_3DIGITS = 4 +}; + +constexpr int MIN_ALPHA = 100; -#define HUDELEM_ACTIVE 1 +enum { + HUDELEM_ACTIVE = 1 +}; enum { @@ -73,12 +80,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 +107,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 +158,7 @@ class CHudAmmoSecondary : public CHudBase float m_fFade; }; -#define FADE_TIME 100 +constexpr int FADE_TIME = 100; // //----------------------------------------------------- @@ -210,7 +218,7 @@ class CHudStatusBar : public CHudBase char m_szStatusBar[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // the constructed bar that is drawn int m_iStatusValues[MAX_STATUSBAR_VALUES]; // an array of values for use in the status bar - int m_bReparseString; // set to TRUE whenever the m_szStatusBar needs to be recalculated + int m_bReparseString; // set to true whenever the m_szStatusBar needs to be recalculated }; extern int g_IsSpectator[MAX_PLAYERS + 1]; @@ -255,7 +263,7 @@ class CHudSayText : public CHudBase // //----------------------------------------------------- // -const int maxHUDMessages = 16; +constexpr int maxHUDMessages = 16; struct message_parms_t { client_textmessage_t *pMessage; @@ -447,7 +455,7 @@ class CHud void ReloadClient(); int UpdateClientData(client_data_t *cdata, float time); - CHud() = default; + CHud() = default; ~CHud() = default; // destructor, frees allocated memory // user messages diff --git a/src/game/client/hud_msg.cpp b/src/game/client/hud_msg.cpp index f7d37d35..00f6c5c7 100644 --- a/src/game/client/hud_msg.cpp +++ b/src/game/client/hud_msg.cpp @@ -49,7 +49,7 @@ int CHud ::MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf) return 1; } -#define CLPERMENT_TOTALK 3 +constexpr unsigned int CLPERMENT_TOTALK = 3; void CHud ::MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf) { @@ -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_redraw.cpp b/src/game/client/hud_redraw.cpp index a96f4a3e..1dba4ff7 100644 --- a/src/game/client/hud_redraw.cpp +++ b/src/game/client/hud_redraw.cpp @@ -26,7 +26,7 @@ #include "clglobal.h" #include "sharedutil.h" -#define MAX_LOGO_FRAMES 56 +constexpr unsigned int MAX_LOGO_FRAMES = 56; int grgLogoFrame[MAX_LOGO_FRAMES] = { diff --git a/src/game/client/hud_spectator.cpp b/src/game/client/hud_spectator.cpp index fe79639f..295405c3 100644 --- a/src/game/client/hud_spectator.cpp +++ b/src/game/client/hud_spectator.cpp @@ -43,10 +43,10 @@ extern void V_ResetChaseCam(); extern void V_GetChasePos(int target, float *cl_angles, float *origin, float *angles); extern float *GetClientColor(int clientIndex); -extern vec3_t v_origin; // last view origin -extern vec3_t v_angles; // last view angle -extern vec3_t v_cl_angles; // last client/mouse angle -extern vec3_t v_sim_org; // last sim origin +extern Vector v_origin; // last view origin +extern Vector v_angles; // last view angle +extern Vector v_cl_angles; // last client/mouse angle +extern Vector v_sim_org; // last sim origin void SpectatorMode(void) { @@ -65,13 +65,13 @@ void SpectatorMode(void) void SpectatorSpray(void) { - vec3_t forward; + Vector forward; char string[128]; if (!gEngfuncs.IsSpectateOnly()) return; - AngleVectors(v_angles, &forward, NULL, NULL); + AngleVectors(v_angles, &forward, nullptr, nullptr); VectorScale(forward, 128, forward); VectorAdd(forward, v_origin, forward); pmtrace_t *trace = gEngfuncs.PM_TraceLine(v_origin, forward, PM_TRACELINE_PHYSENTSONLY, 2, -1); @@ -174,16 +174,18 @@ int CHudSpectator::Init() void UTIL_StringToVector(float *pVector, const char *pString) { - char *pstr, *pfront, tempString[128]; + + const unsigned int bufferLength = 128; + char* pstr, * pfront, tempString[bufferLength] = { 0 }; int j; - strncpy(tempString, pString, sizeof(tempString) ); - pstr = pfront = tempString; + strcpy(tempString, pString); + pstr = tempString; + pfront = tempString; for (j = 0; j < 3; j++) { pVector[j] = atof(pfront); - while (*pstr && *pstr != ' ') pstr++; if (!*pstr) @@ -250,6 +252,7 @@ int UTIL_FindEntityInMap(const char *name, float *origin, float *angle) }; strncpy(keyname, token, sizeof(keyname) ); + keyname[255] = '\0'; // another hack to fix keynames with trailing spaces n = strlen(keyname); @@ -386,7 +389,7 @@ int CHudSpectator::Draw(float flTime) int lx; char string[256]; - float *color; + float *color = nullptr; // draw only in spectator mode if (!g_iUser1) @@ -407,12 +410,12 @@ int CHudSpectator::Draw(float flTime) // if user moves in map mode, change map origin if ((m_moveDelta != 0.0f) && (g_iUser1 != OBS_ROAMING)) { - vec3_t right; + Vector right; AngleVectors(v_angles, NULL, &right, NULL); 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 @@ -426,14 +429,14 @@ 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 ? continue; // check if name would be in inset window - if (m_pip->value != INSET_OFF) + if ((int)m_pip->value != INSET_OFF) { if (m_vPlayerPos[i][0] > XRES(m_OverviewData.insetWindowX) && m_vPlayerPos[i][1] > YRES(m_OverviewData.insetWindowY) && @@ -1054,7 +1057,7 @@ void CHudSpectator::DrawOverviewLayer() float screenaspect, xs, ys, xStep, yStep, x, y, z; int ix, iy, i, xTiles, yTiles, frame; - qboolean hasMapImage = m_MapSprite ? TRUE : FALSE; + qboolean hasMapImage = m_MapSprite ? true : false; model_t *dummySprite = (struct model_s *)gEngfuncs.GetSpritePointer(m_hsprUnkownMap); if (hasMapImage) @@ -1172,7 +1175,7 @@ void CHudSpectator::DrawOverviewEntities() { int i, ir, ig, ib; struct model_s *hSpriteModel; - vec3_t origin, angles, point, forward, right, left, up, world, screen, offset; + Vector origin, angles, point, forward, right, left, up, world, screen, offset; float x, y, z, r, g, b, sizeScale = 4.0f; cl_entity_t *ent; float rmatrix[3][4]; // transformation matrix @@ -1307,11 +1310,11 @@ void CHudSpectator::DrawOverviewEntities() // get current camera position and angle - if (m_pip->value == INSET_IN_EYE || g_iUser1 == OBS_IN_EYE) + if ((int)m_pip->value == INSET_IN_EYE || g_iUser1 == OBS_IN_EYE) { V_GetInEyePos(g_iUser2, origin, angles); } - else if (m_pip->value == INSET_CHASE_FREE || g_iUser1 == OBS_CHASE_FREE) + else if ((int)m_pip->value == INSET_CHASE_FREE || g_iUser1 == OBS_CHASE_FREE) { V_GetChasePos(g_iUser2, v_cl_angles, origin, angles); } @@ -1321,7 +1324,7 @@ void CHudSpectator::DrawOverviewEntities() VectorCopy(v_cl_angles, angles); } else - V_GetChasePos(g_iUser2, NULL, origin, angles); + V_GetChasePos(g_iUser2, nullptr, origin, angles); // draw camera sprite @@ -1337,7 +1340,7 @@ void CHudSpectator::DrawOverviewEntities() gEngfuncs.pTriAPI->Color4f(r, g, b, 1.0); - AngleVectors(angles, &forward, NULL, NULL); + AngleVectors(angles, &forward, nullptr, nullptr); VectorScale(forward, 512.0f, forward); offset[0] = 0.0f; @@ -1370,10 +1373,10 @@ void CHudSpectator::DrawOverview() return; // Only draw the overview if Map Mode is selected for this view - if (m_iDrawCycle == 0 && ((g_iUser1 != OBS_MAP_FREE) && (g_iUser1 != OBS_MAP_CHASE))) + if (!m_iDrawCycle && ((g_iUser1 != OBS_MAP_FREE) && (g_iUser1 != OBS_MAP_CHASE))) return; - if (m_iDrawCycle == 1 && m_pip->value < INSET_MAP_FREE) + if (m_iDrawCycle && (int)m_pip->value < INSET_MAP_FREE) return; DrawOverviewLayer(); @@ -1385,7 +1388,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 +1448,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) @@ -1465,13 +1468,13 @@ void CHudSpectator::CheckSettings() m_pip->value = (int)m_pip->value; - if ((g_iUser1 < OBS_MAP_FREE) && (m_pip->value == INSET_CHASE_FREE || m_pip->value == INSET_IN_EYE)) + if ((g_iUser1 < OBS_MAP_FREE) && ((int)m_pip->value == INSET_CHASE_FREE || (int)m_pip->value == INSET_IN_EYE)) { // otherwise both would show in World picures m_pip->value = INSET_MAP_FREE; } - if ((g_iUser1 >= OBS_MAP_FREE) && (m_pip->value >= INSET_MAP_FREE)) + if ((g_iUser1 >= OBS_MAP_FREE) && ((int)m_pip->value >= INSET_MAP_FREE)) { // both would show map views m_pip->value = INSET_CHASE_FREE; @@ -1520,7 +1523,7 @@ void CHudSpectator::CheckSettings() m_pip->value = INSET_OFF; // draw small border around inset view, adjust upper black bar - gViewPort->m_pSpectatorPanel->EnableInsetView(m_pip->value != INSET_OFF); + gViewPort->m_pSpectatorPanel->EnableInsetView((int)m_pip->value != INSET_OFF); } int CHudSpectator::ToggleInset(bool allowOff) diff --git a/src/game/client/hud_spectator.h b/src/game/client/hud_spectator.h index 0fc474f6..6ca7a3af 100644 --- a/src/game/client/hud_spectator.h +++ b/src/game/client/hud_spectator.h @@ -11,16 +11,18 @@ #include "cl_entity.h" -#define INSET_OFF 0 -#define INSET_CHASE_FREE 1 -#define INSET_IN_EYE 2 -#define INSET_MAP_FREE 3 -#define INSET_MAP_CHASE 4 +enum { + INSET_OFF = 0, + INSET_CHASE_FREE = 1, + INSET_IN_EYE = 2, + INSET_MAP_FREE = 3, + INSET_MAP_CHASE = 4 +}; -#define MAX_SPEC_HUD_MESSAGES 8 -#define OVERVIEW_TILE_SIZE 128 // don't change this -#define OVERVIEW_MAX_LAYERS 1 +constexpr int MAX_SPEC_HUD_MESSAGES = 8; +constexpr int OVERVIEW_TILE_SIZE = 128;// don't change this +constexpr int OVERVIEW_MAX_LAYERS = 1; //----------------------------------------------------------------------------- // Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it ) @@ -29,7 +31,7 @@ typedef struct overviewInfo_s { char map[64]; // cl.levelname or empty - vec3_t origin; // center of map + Vector origin; // center of map float zoom; // zoom of map images int layers; // how may layers do we have float layersHeights[OVERVIEW_MAX_LAYERS]; @@ -50,7 +52,7 @@ typedef struct overviewEntity_s double killTime; } overviewEntity_t; -#define MAX_OVERVIEW_ENTITIES 128 +constexpr int MAX_OVERVIEW_ENTITIES = 128; class CHudSpectator : public CHudBase { @@ -91,7 +93,7 @@ class CHudSpectator : public CHudBase int m_iSpectatorNumber; float m_mapZoom; // zoom the user currently uses - vec3_t m_mapOrigin; // origin where user rotates around + Vector m_mapOrigin; // origin where user rotates around cvar_t *m_drawnames; cvar_t *m_drawcone; cvar_t *m_drawstatus; @@ -100,11 +102,11 @@ class CHudSpectator : public CHudBase qboolean m_chatEnabled; - vec3_t m_cameraOrigin; // a help camera - vec3_t m_cameraAngles; // and it's angles + Vector m_cameraOrigin; // a help camera + Vector m_cameraAngles; // and it's angles private: - vec3_t m_vPlayerPos[MAX_PLAYERS]; + Vector m_vPlayerPos[MAX_PLAYERS]; HLSPRITE m_hsprPlayerBlue; HLSPRITE m_hsprPlayerRed; HLSPRITE m_hsprPlayer; diff --git a/src/game/client/hud_update.cpp b/src/game/client/hud_update.cpp index 4cf8a0f0..290b52ad 100644 --- a/src/game/client/hud_update.cpp +++ b/src/game/client/hud_update.cpp @@ -31,8 +31,8 @@ extern void HUD_SetCmdBits(int bits); int CHud::UpdateClientData(client_data_t *cdata, float time) { - memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t)); - memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t)); + memcpy(m_vecOrigin, cdata->origin, sizeof(Vector )); + memcpy(m_vecAngles, cdata->viewangles, sizeof(Vector )); m_iKeyBits = CL_ButtonBits(0); m_iWeaponBits = cdata->iWeaponBits; diff --git a/src/game/client/in_camera.cpp b/src/game/client/in_camera.cpp index 9ee1df09..dfd67acc 100644 --- a/src/game/client/in_camera.cpp +++ b/src/game/client/in_camera.cpp @@ -33,16 +33,16 @@ extern cl_enginefunc_t gEngfuncs; //-------------------------------------------------- Constants -#define CAM_DIST_DELTA 1.0 -#define CAM_ANGLE_DELTA 2.5 -#define CAM_ANGLE_SPEED 2.5 -#define CAM_MIN_DIST 30.0 -#define CAM_ANGLE_MOVE .5 -#define MAX_ANGLE_DIFF 10.0 -#define PITCH_MAX 90.0 -#define PITCH_MIN 0 -#define YAW_MAX 135.0 -#define YAW_MIN -135.0 +constexpr float CAM_DIST_DELTA = 1.0; +constexpr float CAM_ANGLE_DELTA = 2.5; +constexpr float CAM_ANGLE_SPEED = 2.5; +constexpr float CAM_MIN_DIST = 30.0; +constexpr float CAM_ANGLE_MOVE = .5; +constexpr float MAX_ANGLE_DIFF = 10.0; +constexpr float PITCH_MAX = 90.0; +constexpr float PITCH_MIN = 0; +constexpr float YAW_MAX = 135.0; +constexpr float YAW_MIN = -135.0; enum ECAM_Command { @@ -68,7 +68,7 @@ cvar_t *c_maxdistance; cvar_t *c_mindistance; // pitch, yaw, dist -vec3_t cam_ofs; +Vector cam_ofs; // In third person int cam_mousemove; //true if we are moving the cam with the mouse, False if not @@ -148,9 +148,9 @@ float MoveToward(float cur, float goal, float maxspeed) /*typedef struct { - vec3_t boxmins, boxmaxs;// enclose the test object along entire move + Vector boxmins, boxmaxs;// enclose the test object along entire move float *mins, *maxs; // size of the moving object - vec3_t mins2, maxs2; // size when clipping against mosnters + Vector mins2, maxs2; // size when clipping against mosnters float *start, *end; trace_t trace; int type; @@ -158,20 +158,20 @@ float MoveToward(float cur, float goal, float maxspeed) qboolean monsterclip; } moveclip_t; -extern trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); +extern trace_t SV_ClipMoveToEntity (edict_t *ent, Vector start, Vector mins, Vector maxs, Vector end); */ void DLLEXPORT CAM_Think(void) { - vec3_t origin; - vec3_t ext, pnt, camForward, camRight, camUp; + Vector origin; + Vector ext, pnt, camForward, camRight, camUp; //moveclip_t clip; float dist; - vec3_t camAngles; + Vector camAngles; float flSensitivity; /*#ifdef LATER int i; #endif*/ - vec3_t viewangles; + Vector viewangles; switch ((int)cam_command->value) { @@ -477,7 +477,7 @@ void CAM_OutUp(void) { KeyUp(&cam_out); } void CAM_ToThirdPerson(void) { - vec3_t viewangles; + Vector viewangles; Cam_SwitchingTo1StPerson = false; gEngfuncs.GetViewAngles((float *)viewangles); @@ -548,7 +548,7 @@ void CAM_Init(void) void CAM_ClearStates(void) { - vec3_t viewangles; + Vector viewangles; gEngfuncs.GetViewAngles((float *)viewangles); diff --git a/src/game/client/in_defs.h b/src/game/client/in_defs.h index 102f8a3a..00f996a5 100644 --- a/src/game/client/in_defs.h +++ b/src/game/client/in_defs.h @@ -2,12 +2,14 @@ #define IN_DEFSH #pragma once -// up / down -#define PITCH 0 +enum { + // up / down + PITCH = 0, // left / right -#define YAW 1 + YAW = 1, // fall over -#define ROLL 2 + ROLL = 2 +}; #define DLLEXPORT EXPORT diff --git a/src/game/client/input.cpp b/src/game/client/input.cpp index 5229a540..5e93e02b 100644 --- a/src/game/client/input.cpp +++ b/src/game/client/input.cpp @@ -140,7 +140,7 @@ typedef struct kblist_s char name[32]; } kblist_t; -kblist_t *g_kbkeys = NULL; +kblist_t *g_kbkeys = nullptr; /* ============ @@ -163,7 +163,7 @@ int KB_ConvertString(char *in, char **ppout) if (!ppout) return 0; - *ppout = NULL; + *ppout = nullptr; p = in; pOut = sz; while (*p) @@ -178,7 +178,7 @@ int KB_ConvertString(char *in, char **ppout) *pEnd = '\0'; - pBinding = NULL; + pBinding = nullptr; if (strlen(binding + 1) > 0) { // See if there is a binding for binding? @@ -240,7 +240,7 @@ struct kbutton_s DLLEXPORT *KB_Find(const char *name) p = p->next; } - return NULL; + return nullptr; } /* @@ -279,7 +279,7 @@ Add kbutton_t definitions that the engine can query if needed */ void KB_Init(void) { - g_kbkeys = NULL; + g_kbkeys = nullptr; KB_Add("in_graph", &in_graph); KB_Add("in_mlook", &in_mlook); @@ -303,7 +303,7 @@ void KB_Shutdown(void) free(p); p = n; } - g_kbkeys = NULL; + g_kbkeys = nullptr; } /* @@ -442,7 +442,11 @@ void IN_ForwardUp(void) gHUD.m_Spectator.HandleButtonsUp(IN_FORWARD); } -#define GAME_LEAP(dir) ServerCmd(UTIL_VarArgs("game_leap %s %f", dir, player.Stamina)) +//#define GAME_LEAP(dir) ServerCmd(UTIL_VarArgs("game_leap %s %f", dir, player.Stamina)) + +inline void GAME_LEAP(const char * dir, float& stamina){ + ServerCmd(UTIL_VarArgs("game_leap %s %f", dir, stamina)); +} void IN_BackDown(void) { @@ -452,7 +456,7 @@ void IN_BackDown(void) float cvar_flDtapDelay = CVAR_GET_FLOAT("ms_doubletap_delay"); if ((!strcmp(CVAR_GET_STRING("ms_doubletapdodge"), "1") && lastMoveBackUp + cvar_flDtapDelay > gpGlobals->time)) - GAME_LEAP("back"); + GAME_LEAP("back", player.Stamina); } void IN_BackUp(void) @@ -475,7 +479,7 @@ void IN_MoveleftDown(void) float cvar_flDtapDelay = CVAR_GET_FLOAT("ms_doubletap_delay"); if ((!strcmp(CVAR_GET_STRING("ms_doubletapdodge"), "1") && lastMoveLeftUp + cvar_flDtapDelay > gpGlobals->time)) - GAME_LEAP("left"); + GAME_LEAP("left", player.Stamina); } void IN_MoveleftUp(void) @@ -493,7 +497,7 @@ void IN_MoverightDown(void) float cvar_flDtapDelay = CVAR_GET_FLOAT("ms_doubletap_delay"); if ((!strcmp(CVAR_GET_STRING("ms_doubletapdodge"), "1") && lastMoveRightUp + cvar_flDtapDelay > gpGlobals->time)) - GAME_LEAP("right"); + GAME_LEAP("right", player.Stamina); } void IN_MoverightUp(void) @@ -749,12 +753,12 @@ if active == 1 then we are 1) not playing back demos ( where our commands are ig void DLLEXPORT CL_CreateMove(float frametime, struct usercmd_s *cmd, int active) { float spd; - vec3_t viewangles; - static vec3_t oldangles; + Vector viewangles; + static Vector oldangles; if (active) { - //memset( viewangles, 0, sizeof( vec3_t ) ); + //memset( viewangles, 0, sizeof( Vector ) ); //viewangles[ 0 ] = viewangles[ 1 ] = viewangles[ 2 ] = 0.0; gEngfuncs.GetViewAngles((float *)viewangles); diff --git a/src/game/client/inputw32.cpp b/src/game/client/inputw32.cpp index 8c76655c..c80d25dd 100644 --- a/src/game/client/inputw32.cpp +++ b/src/game/client/inputw32.cpp @@ -27,7 +27,7 @@ #include #include -#define MOUSE_BUTTON_COUNT 5 +constexpr int MOUSE_BUTTON_COUNT = 5; // Set this to 1 to show mouse cursor. Experimental int g_iVisibleMouse = 0; @@ -95,15 +95,18 @@ static bool g_ReceivedFirstMouseActivate = false; // joystick defines and variables // where should defines be moved? -#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick -#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball -#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V -#define JOY_AXIS_X 0 -#define JOY_AXIS_Y 1 -#define JOY_AXIS_Z 2 -#define JOY_AXIS_R 3 -#define JOY_AXIS_U 4 -#define JOY_AXIS_V 5 + +enum { + JOY_ABSOLUTE_AXIS = 0x00000000, // control like a joystick + JOY_RELATIVE_AXIS = 0x00000010, // control like a mouse, spinner, trackball + JOY_MAX_AXES = 6, // X, Y, Z, R, U, V + JOY_AXIS_X = 0, + JOY_AXIS_Y = 1, + JOY_AXIS_Z = 2, + JOY_AXIS_R = 3, + JOY_AXIS_U = 4, + JOY_AXIS_V = 5 +}; enum _ControlList { @@ -165,7 +168,7 @@ Force_CenterView_f */ void Force_CenterView_f(void) { - vec3_t viewangles; + Vector viewangles; if (!iMouseInUse) { @@ -187,7 +190,7 @@ long ThreadInterlockedExchange(long *pDest, long value) DWORD WINAPI MousePos_ThreadFunction(LPVOID p) { - s_hMouseDoneQuitEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + s_hMouseDoneQuitEvent = CreateEvent(NULL, false, false, NULL); while (1) { @@ -317,6 +320,7 @@ void IN_Shutdown(void) if (s_hMouseThread) { + TerminateThread(s_hMouseThread, 0); CloseHandle(s_hMouseThread); s_hMouseThread = (HANDLE)0; @@ -463,7 +467,7 @@ IN_MouseMove void IN_MouseMove(float frametime, usercmd_t *cmd) { int mx, my; - vec3_t viewangles; + Vector viewangles; gEngfuncs.GetViewAngles((float *)viewangles); @@ -655,10 +659,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)) { @@ -857,7 +862,7 @@ void IN_JoyMove(float frametime, usercmd_t *cmd) float speed, aspeed; float fAxisValue, fTemp; int i; - vec3_t viewangles; + Vector viewangles; gEngfuncs.GetViewAngles((float *)viewangles); @@ -1091,7 +1096,7 @@ void IN_Init(void) { s_mouseDeltaX = s_mouseDeltaY = 0; - s_hMouseQuitEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + s_hMouseQuitEvent = CreateEvent(NULL, false, false, NULL); if (s_hMouseQuitEvent) { s_hMouseThread = CreateThread(NULL, 0, MousePos_ThreadFunction, NULL, 0, &s_hMouseThreadId); diff --git a/src/game/client/message.cpp b/src/game/client/message.cpp index 105eefdc..7add57e7 100644 --- a/src/game/client/message.cpp +++ b/src/game/client/message.cpp @@ -88,18 +88,18 @@ int CHudMessage::XPosition(float x, int width, int totalWidth) if (x == -1) { - xPos = (ScreenWidth - width) / 2; + xPos = (ScreenWidth() - width) / 2; } else { if (x < 0) - xPos = (1.0 + x) * ScreenWidth - totalWidth; // Alight right + xPos = (1.0 + x) * ScreenWidth() - totalWidth; // Alight right else - xPos = x * ScreenWidth; + xPos = x * ScreenWidth(); } - if (xPos + width > ScreenWidth) - xPos = ScreenWidth - width; + if (xPos + width > ScreenWidth()) + xPos = ScreenWidth() - width; else if (xPos < 0) xPos = 0; @@ -111,18 +111,18 @@ int CHudMessage::YPosition(float y, int height) int yPos; if (y == -1) // Centered? - yPos = (ScreenHeight - height) * 0.5; + yPos = (ScreenHeight() - height) * 0.5; else { // Alight bottom? if (y < 0) - yPos = (1.0 + y) * ScreenHeight - height; // Alight bottom + yPos = (1.0 + y) * ScreenHeight() - height; // Alight bottom else // align top - yPos = y * ScreenHeight; + yPos = y * ScreenHeight(); } - if (yPos + height > ScreenHeight) - yPos = ScreenHeight - height; + if (yPos + height > ScreenHeight()) + yPos = ScreenHeight() - height; else if (yPos < 0) yPos = 0; @@ -187,7 +187,7 @@ void CHudMessage::MessageScanNextChar(void) if (m_parms.pMessage->effect == 1 && m_parms.charTime != 0) { - if (m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text]) <= ScreenWidth) + if (m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text]) <= ScreenWidth()) TextMessageDrawChar(m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2); } } @@ -292,7 +292,7 @@ void CHudMessage::MessageDrawScan(client_textmessage_t *pMessage, float time) int next = m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text]; MessageScanNextChar(); - if (m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth) + if (m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth()) TextMessageDrawChar(m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b); m_parms.x = next; } @@ -456,7 +456,7 @@ int CHudMessage::MsgFunc_HudText(const char *pszName, int iSize, void *pbuf) int CHudMessage::MsgFunc_GameTitle(const char *pszName, int iSize, void *pbuf) { m_pGameTitle = TextMessageGet("GAMETITLE"); - if (m_pGameTitle != NULL) + if (m_pGameTitle != nullptr) { m_gameTitleTime = gHUD.m_flTime; 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/action.h b/src/game/client/ms/action.h index 149c8870..0b1a47d1 100644 --- a/src/game/client/ms/action.h +++ b/src/game/client/ms/action.h @@ -16,7 +16,7 @@ class CHudAction : public CHudBase int MsgFunc_Action(const char *pszName, int iSize, void *pbuf); void UserCmd_Action(void); void SelectMenuItem(int menu_item); - + char Name[32] = "CHudAction"; mslist PlayerActions; }; #endif //HUD_ACTION_H diff --git a/src/game/client/ms/clglobal.cpp b/src/game/client/ms/clglobal.cpp index bdf8f3a8..eecf0804 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); @@ -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(); } @@ -149,17 +82,17 @@ void MSCLGlobals::InitializePlayer() player.CreateStats(); player.m_CharacterState = CHARSTATE_UNLOADED; player.m_DisplayName = "Adventurer"; - player.PlayerHands = NULL; + player.PlayerHands = nullptr; player.ClearConditions(MONSTER_OPENCONTAINER); player.Gear.clear(); player.m_HP = player.m_MP = 0; - player.m_fGameHUDInitialized = TRUE; + player.m_fGameHUDInitialized = true; //player.pbs.fMaxForwardPressTime = 0; 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]; @@ -182,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(); @@ -197,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()); } @@ -206,7 +139,7 @@ void MSCLGlobals::RemoveAllEntities() //Delete all entites if (player.m_CharacterState == CHARSTATE_LOADED) { - player.Killed(NULL, 0); + player.Killed(nullptr, 0); player.RemoveAllItems(false, true); } @@ -215,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; @@ -225,7 +158,7 @@ void MSCLGlobals::RemoveAllEntities() //unset player hands (should happen in CBasePlayer::RemoveAllItems() first...) if (pEntity == (CBaseEntity *)player.PlayerHands) - player.PlayerHands = NULL; + player.PlayerHands = nullptr; Print("Cleanup Item %i: %s\n", killed++, pEntity->DisplayName()); @@ -302,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; @@ -400,6 +333,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DLLAttach(hinstDLL); else if (fdwReason == DLL_PROCESS_DETACH) DLLDetach(); - return TRUE; + return true; } #endif diff --git a/src/game/client/ms/clplayer.cpp b/src/game/client/ms/clplayer.cpp index f49766a1..99e1cbc7 100644 --- a/src/game/client/ms/clplayer.cpp +++ b/src/game/client/ms/clplayer.cpp @@ -438,7 +438,7 @@ For debugging, draw a box around a player made out of particles void UTIL_ParticleBox(CBasePlayer* player, float* mins, float* maxs, float life, unsigned char r, unsigned char g, unsigned char b) { int i; - vec3_t mmin, mmax; + Vector mmin, mmax; for (i = 0; i < 3; i++) { @@ -461,7 +461,7 @@ void UTIL_ParticleBoxes(void) int idx; physent_t* pe; cl_entity_t* player; - vec3_t mins, maxs; + Vector mins, maxs; gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction(false, true); @@ -509,7 +509,7 @@ physent_t* MSUTIL_EntityByIndex(int playerindex) } } gEngfuncs.pEventAPI->EV_PopPMStates(); - return NULL; + return nullptr; } /* ===================== @@ -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; @@ -665,7 +666,7 @@ void HUD_WeaponsPostThink(local_state_s* from, local_state_s* to, usercmd_t* cmd player.m_afButtonLast = KeyHistory[0].Buttons; //player.pev->button; // Wipe it so we can't use it after this frame - g_finalstate = NULL; + g_finalstate = nullptr; } /* ===================== @@ -730,7 +731,7 @@ void ShowWeaponDesc(CGenericItem* pItem) msg.fadein = 2.0; msg.holdtime = 5.0; msg.fadeout = 3.0; - msg.pName = NULL; + msg.pName = nullptr; msg.pMessage = cDescString; gHUD.m_Message.MessageAdd(msg); } @@ -1028,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) @@ -1093,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 @@ -1126,8 +1127,8 @@ void Player_ToggleInventory() return; } - CGenericItem* pWearable = NULL; //Fallback, in case a pack isn't found - for (int i = 0; i < player.Gear.size(); i++) + CGenericItem* pWearable = nullptr; //Fallback, in case a pack isn't found + 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) @@ -1231,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)); @@ -1299,7 +1300,7 @@ int __MsgFunc_CLDllFunc(const char* pszName, int iSize, void* pbuf) case 1: //Killed if (player.m_CharacterState == CHARSTATE_UNLOADED) break; - player.Killed(NULL, NULL); + player.Killed(nullptr, NULL); break; case 2: //[OPEN] @@ -1380,7 +1381,7 @@ int __MsgFunc_CLDllFunc(const char* pszName, int iSize, void* pbuf) //Set up a variable to switch back if (g_SwitchToHand == -1) g_SwitchToHand = player.m_CurrentHand; - if (player.SwitchHands(iHand, FALSE)) + if (player.SwitchHands(iHand, false)) player.BlockButton(IN_ATTACK); else g_SwitchToHand = -1; @@ -1476,7 +1477,7 @@ int __MsgFunc_CLDllFunc(const char* pszName, int iSize, void* pbuf) msg.fadein = 0.01; msg.holdtime = 3.0; msg.fadeout = 1.0; - msg.pName = NULL; + msg.pName = nullptr; msg.fxtime = 4.0; static char msgtext[256]; @@ -1499,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/fatigue.cpp b/src/game/client/ms/fatigue.cpp index 710b642b..89bee72c 100644 --- a/src/game/client/ms/fatigue.cpp +++ b/src/game/client/ms/fatigue.cpp @@ -31,7 +31,7 @@ MS_DECLARE_MESSAGE(m_Fatigue, Fatigue); int CHudFatigue::Init(void) { - m_DrawFatigue = FALSE; + m_DrawFatigue = false; HOOK_MESSAGE(Fatigue); //HOOK_COMMAND("fatigue", ToggleFatigue); @@ -47,8 +47,8 @@ int CHudFatigue::Draw(float flTime) { if (m_DrawFatigue) { - gHUD.DrawHudNumberSML(ScreenWidth - 40, ScreenHeight - 40, NULL, player.Stamina, 255, 255, 255); - gHUD.DrawHudNumberSML(ScreenWidth - 20, ScreenHeight - 40, NULL, player.MaxStamina(), 255, 255, 255); + gHUD.DrawHudNumberSML(ScreenWidth() - 40, ScreenHeight() - 40, NULL, player.Stamina, 255, 255, 255); + gHUD.DrawHudNumberSML(ScreenWidth() - 20, ScreenHeight() - 40, NULL, player.MaxStamina(), 255, 255, 255); } return 1; } diff --git a/src/game/client/ms/fatigue.h b/src/game/client/ms/fatigue.h index 153d604b..8fa86c67 100644 --- a/src/game/client/ms/fatigue.h +++ b/src/game/client/ms/fatigue.h @@ -13,6 +13,7 @@ class CHudFatigue : public CHudBase void InitHUDData(void); int MsgFunc_Fatigue(const char *pszName, int iSize, void *pbuf); void UserCmd_ToggleFatigue(void); + char Name[32] = "CHudFatigue"; private: float fBreatheTime; diff --git a/src/game/client/ms/health.cpp b/src/game/client/ms/health.cpp index aad8e4c0..eea96b4a 100644 --- a/src/game/client/ms/health.cpp +++ b/src/game/client/ms/health.cpp @@ -39,26 +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) { @@ -76,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; } @@ -95,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; } @@ -160,9 +153,9 @@ int CHudHealth::MsgFunc_Damage(const char *pszName, int iSize, void *pbuf) int damageTaken = READ_BYTE(); // health long bitsDamage = READ_LONG(); // damage bits - vec3_t vecFrom; + Vector 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); @@ -184,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; @@ -208,97 +201,13 @@ 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) +void CHudHealth::CalcDamageDirection(Vector vecFrom) { - vec3_t forward, right, up; + Vector forward, right, up; float side, front; - vec3_t vecOrigin, vecAngles; + Vector vecOrigin, vecAngles; if (!vecFrom[0] && !vecFrom[1] && !vecFrom[2]) { @@ -306,8 +215,8 @@ void CHudHealth::CalcDamageDirection(vec3_t vecFrom) return; } - memcpy(vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t)); - memcpy(vecAngles, gHUD.m_vecAngles, sizeof(vec3_t)); + memcpy(vecOrigin, gHUD.m_vecOrigin, sizeof(Vector )); + memcpy(vecAngles, gHUD.m_vecAngles, sizeof(Vector )); VectorSubtract(vecFrom, vecOrigin, vecFrom); @@ -372,8 +281,8 @@ int CHudHealth::DrawPain(float flTime) ScaleColors(r, g, b, shade); SPR_Set(m_hSprite, r, g, b); - x = ScreenWidth / 2 - SPR_Width(m_hSprite, 0) / 2; - y = ScreenHeight / 2 - SPR_Height(m_hSprite, 0) * 3; + x = ScreenWidth() / 2 - SPR_Width(m_hSprite, 0) / 2; + y = ScreenHeight() / 2 - SPR_Height(m_hSprite, 0) * 3; SPR_DrawAdditive(0, x, y, NULL); m_fAttackFront = V_max(0, m_fAttackFront - fFade); } @@ -387,8 +296,8 @@ int CHudHealth::DrawPain(float flTime) ScaleColors(r, g, b, shade); SPR_Set(m_hSprite, r, g, b); - x = ScreenWidth / 2 + SPR_Width(m_hSprite, 1) * 2; - y = ScreenHeight / 2 - SPR_Height(m_hSprite, 1) / 2; + x = ScreenWidth() / 2 + SPR_Width(m_hSprite, 1) * 2; + y = ScreenHeight() / 2 - SPR_Height(m_hSprite, 1) / 2; SPR_DrawAdditive(1, x, y, NULL); m_fAttackRight = V_max(0, m_fAttackRight - fFade); } @@ -402,8 +311,8 @@ int CHudHealth::DrawPain(float flTime) ScaleColors(r, g, b, shade); SPR_Set(m_hSprite, r, g, b); - x = ScreenWidth / 2 - SPR_Width(m_hSprite, 2) / 2; - y = ScreenHeight / 2 + SPR_Height(m_hSprite, 2) * 2; + x = ScreenWidth() / 2 - SPR_Width(m_hSprite, 2) / 2; + y = ScreenHeight() / 2 + SPR_Height(m_hSprite, 2) * 2; SPR_DrawAdditive(2, x, y, NULL); m_fAttackRear = V_max(0, m_fAttackRear - fFade); } @@ -417,8 +326,8 @@ int CHudHealth::DrawPain(float flTime) ScaleColors(r, g, b, shade); SPR_Set(m_hSprite, r, g, b); - x = ScreenWidth / 2 - SPR_Width(m_hSprite, 3) * 3; - y = ScreenHeight / 2 - SPR_Height(m_hSprite, 3) / 2; + x = ScreenWidth() / 2 - SPR_Width(m_hSprite, 3) * 3; + y = ScreenHeight() / 2 - SPR_Height(m_hSprite, 3) / 2; SPR_DrawAdditive(3, x, y, NULL); m_fAttackLeft = V_max(0, m_fAttackLeft - fFade); @@ -429,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; @@ -496,14 +345,14 @@ 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]; // 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; } @@ -513,8 +362,8 @@ 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->y = ScreenHeight() - giDmgHeight * 2; + pdmg->fExpire = flTime + static_cast(DMG_IMAGE_LIFE); // move everyone else up for (int j = 0; j < NUM_DMG_TYPES; j++) diff --git a/src/game/client/ms/health.h b/src/game/client/ms/health.h index 6fef6538..171efbb8 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 { @@ -108,6 +59,7 @@ class CHudHealth : public CHudBase int m_HUD_dmg_bio; int m_HUD_cross; float flChangeTime; + char Name[32] = "CHudHealth"; private: HLSPRITE m_hSprite; @@ -120,6 +72,6 @@ class CHudHealth : public CHudBase int DrawPain(float fTime); int DrawDamage(float fTime); float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight; - void CalcDamageDirection(vec3_t vecFrom); + void CalcDamageDirection(Vector vecFrom); void UpdateTiles(float fTime, long bits); }; diff --git a/src/game/client/ms/hudid.cpp b/src/game/client/ms/hudid.cpp index 47dc589a..73efc944 100644 --- a/src/game/client/ms/hudid.cpp +++ b/src/game/client/ms/hudid.cpp @@ -50,7 +50,7 @@ void CHudID::Reset(void) m_iFlags |= HUD_ACTIVE; TimeDecAlpha = 0; Alpha = 0; - pActiveInfo = pDrawInfo = NULL; + pActiveInfo = pDrawInfo = nullptr; } void CHudID ::InitHUDData(void) { @@ -81,10 +81,10 @@ int CHudID::Draw(float flTime) GetConsoleStringSize( pDrawInfo->Name, &TextWidth, &TextHeight ); int Y_START; - if ( ScreenHeight >= 480 ) - Y_START = ScreenHeight - 128; + if ( ScreenHeight() >= 480 ) + Y_START = ScreenHeight() - 128; else - Y_START = ScreenHeight - 64; + Y_START = ScreenHeight() - 64; int x = 5; int y = Y_START - TextHeight; // draw along bottom of screen @@ -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; @@ -168,7 +168,7 @@ entinfo_t *CHudID::GetEntInFrontOfMe(float Range) Vector vViewAngle; gEngfuncs.GetViewAngles(vViewAngle); cl_entity_s *clplayer = gEngfuncs.GetLocalPlayer(); - AngleVectors(vViewAngle, &vForward, NULL, NULL); + AngleVectors(vViewAngle, &vForward, nullptr, nullptr); Vector vecSrc = clplayer->origin, vecEnd, viewOfs; gEngfuncs.pEventAPI->EV_LocalPlayerViewheight(viewOfs); @@ -179,7 +179,7 @@ entinfo_t *CHudID::GetEntInFrontOfMe(float Range) physent_t *pPhyplayer = gEngfuncs.pEventAPI->EV_GetPhysent(clplayer->index); if (!pPhyplayer) - return NULL; + return nullptr; // Now add in all of the players. gEngfuncs.pEventAPI->EV_SetSolidPlayers(clplayer->index - 1); @@ -190,10 +190,10 @@ 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]; } - return NULL; + return nullptr; } diff --git a/src/game/client/ms/hudid.h b/src/game/client/ms/hudid.h index cdc812b2..3c93fc1c 100644 --- a/src/game/client/ms/hudid.h +++ b/src/game/client/ms/hudid.h @@ -16,10 +16,10 @@ class CHudID : public CHudBase void SearchThink(void); entinfo_t *GetEntInFrontOfMe(float Range); - entinfo_t *pActiveInfo, *pDrawInfo; float Alpha; float TimeDecAlpha; + char Name[32] = "CHudID"; }; #endif //__HUDID 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) diff --git a/src/game/client/ms/hudmagic.h b/src/game/client/ms/hudmagic.h index 2c02d36d..c70975b8 100644 --- a/src/game/client/ms/hudmagic.h +++ b/src/game/client/ms/hudmagic.h @@ -18,5 +18,6 @@ class CHudMagic : public CHudBase void InitHUDData(void); int SpellMenuIndex[256]; + char Name[32] = "CHudMagic"; }; #endif //HUD_MAGIC_H diff --git a/src/game/client/ms/hudmisc.cpp b/src/game/client/ms/hudmisc.cpp index 3c6665b7..11a03abb 100644 --- a/src/game/client/ms/hudmisc.cpp +++ b/src/game/client/ms/hudmisc.cpp @@ -113,7 +113,7 @@ int CHudMisc::Draw(float flTime) } SPR_Set(gHUD.GetSprite(SpriteIndex), 255, 255, 255 ); - SPR_DrawAdditive( 0, ScreenWidth - 70, ScreenHeight - 70, &gHUD.GetSpriteRect(SpriteIndex));*/ + SPR_DrawAdditive( 0, ScreenWidth() - 70, ScreenHeight() - 70, &gHUD.GetSpriteRect(SpriteIndex));*/ return 1; } @@ -199,17 +199,17 @@ void CHudMisc ::UserCmd_RemovePack(void) int test = *(int *)&m_RemoveList; int test2 = m_RemoveList.size(); - strncpy(MenuText, "Remove item:\n\n", sizeof(MenuText) ); + 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) continue; msstring ItemName; - ItemName += SPEECH_GetItemName(pGearItem); + ItemName += SPEECH::ItemName(pGearItem); msstring SendString; int Size = m_RemoveList.size(); @@ -315,12 +315,12 @@ 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; - const char *arg = UTIL_VarArgs("%i. %s hand: %s\n", r + 2, SPEECH_IntToHand(i, true), SPEECH::ItemName(player.Hand(i), true)); + const char *arg = UTIL_VarArgs("%i. %s hand: %s\n", r + 2, SPEECH::HandName(i, true), SPEECH::ItemName(player.Hand(i), true)); strncat(MenuText, arg, strlen(arg)); m_OfferInfo.OfferItem[r] = i; iBitsValid |= (1 << (++r)); //Starts at 1 diff --git a/src/game/client/ms/hudmisc.h b/src/game/client/ms/hudmisc.h index e89720a3..74c47099 100644 --- a/src/game/client/ms/hudmisc.h +++ b/src/game/client/ms/hudmisc.h @@ -3,8 +3,8 @@ #include "hudbase.h" //typedef struct cl_entity_s cl_entity_t; -#define MAX_ARROWS 5 - +inline constexpr int MAX_ARROWS = 5; +inline constexpr int MAX_GOLD_OFFER = 1000000; class CHudMisc : public CHudBase { public: @@ -19,7 +19,7 @@ class CHudMisc : public CHudBase void UserCmd_Accept(void); //void UserCmd_ListSkills( void ); void SelectMenuItem(int menu_item, TCallbackMenu *pcbMenu); - + char Name[32] = "CHudMisc"; entinfo_t m_OfferTarget; private: @@ -29,8 +29,6 @@ class CHudMisc : public CHudBase Rect m_rcCrosshair; HLSPRITE GetCrosshairSprite(int type); -#define MAX_GOLD_OFFER 1000000 - struct offerinfo_t { bool GoldScreen; //Whether I'm currently determining an amount of gold to offer diff --git a/src/game/client/ms/hudmusic.h b/src/game/client/ms/hudmusic.h index edb1c3dc..0039c656 100644 --- a/src/game/client/ms/hudmusic.h +++ b/src/game/client/ms/hudmusic.h @@ -13,6 +13,7 @@ class CHudMusic : public CHudBase void Shutdown(void); void Reload(void); int MsgFunc_Music(const char* pszName, int iSize, void* pbuf); + char Name[32] = "CHudMusic"; private: CMusicSystem m_MP3; diff --git a/src/game/client/ms/hudscript.cpp b/src/game/client/ms/hudscript.cpp index cc667a5d..bc58328d 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.y += atof(Script->GetVar(ScriptVarCustomYOffset.c_str())); + if (Script->VarExists(ScriptVarCustomZOffset.c_str())) vec.z += 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.y = atof(Script->GetVar(ScriptVarCustomYSet.c_str())); + if (Script->VarExists(ScriptVarCustomZSet.c_str())) vec.z = 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 ) { @@ -80,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 ); } @@ -101,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() ); - Script->RunScriptEventByName( EventName, Parameters.size() ? &Parameters : NULL ); + 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 : nullptr ); 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; @@ -143,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; @@ -154,7 +228,7 @@ CScript *CHudScript::CreateScript(const char* ScriptName, msstringlist &Paramete //Create a new script if not latching onto a prev copy CScript *Script = Script_Add( ScriptName, &player ); - if( !Script ) return NULL; + if( !Script ) return nullptr; Script->m.pScriptedInterface = &player; @@ -175,13 +249,13 @@ void CHudScript::HandleAnimEvent(const char* Options, const cl_entity_s *clEntit const char* ScriptName = ParsedOptions[0]; const char* EventName = ParsedOptions[1]; - CScript *Script = NULL; + CScript *Script = nullptr; //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; } } @@ -198,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 ); @@ -206,23 +280,23 @@ 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; 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( ) { 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" )); @@ -235,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" )); @@ -250,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" )) ) @@ -281,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; @@ -301,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/hudscript.h b/src/game/client/ms/hudscript.h index 21eabc1b..f0544dc9 100644 --- a/src/game/client/ms/hudscript.h +++ b/src/game/client/ms/hudscript.h @@ -34,7 +34,9 @@ class CHudScript : public CHudBase, public IScripted void Effects_PreRender(); void Effects_Render(cl_entity_t &Ent, bool InMirror); void Effects_DrawTransPararentTriangles(); + + char Name[32] = "CHudScript"; }; -#define HUDScript gHUD.m_HUDScript + #endif //HUDSCRIPT_H diff --git a/src/game/client/ms/menu.cpp b/src/game/client/ms/menu.cpp index e0bfccd0..77f1a9ae 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]; @@ -66,7 +65,7 @@ void CHudMenu ::InitHUDData(void) void CHudMenu ::Reset(void) { g_szPrelocalisedMenuString[0] = 0; - m_fWaitingForMore = FALSE; + m_fWaitingForMore = false; } int CHudMenu ::VidInit(void) @@ -95,14 +94,14 @@ 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++; } // center it - int y = (ScreenHeight / 2) - ((nlc / 2) * 12) - 40; // make sure it is above the say text + int y = (ScreenHeight() / 2) - ((nlc / 2) * 12) - 40; // make sure it is above the say text int x = 20; int i = 0; @@ -145,7 +144,7 @@ void Menu_ServerMenuCallback(int idx, struct TCallbackMenu *pcbMenu) // takes four values: // short: a bitfield of keys that are valid input // char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen. -// byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string +// byte : a boolean, true if there is more string yet to be received before displaying the menu, false if it's the last string // string: menu string to display // if this message is never received, then scores will simply be the combined totals of the players. int CHudMenu ::MsgFunc_ShowMenu(const char *pszName, int iSize, void *pbuf) @@ -204,7 +203,7 @@ int CHudMenu ::MsgFunc_ShowMenu(const char *pszName, int iSize, void *pbuf) } int CHudMenu ::ShowMenu(int bitsValidSlots, const char *pcMenuText, MenuCallback CallBack, MenuType mtMenuType, float ShutOffTime) { - // if( !pcMenuText ) return FALSE; + // if( !pcMenuText ) return false; m_fOfferedNextMenu = true; m_bitsValidSlots = bitsValidSlots; strncpy(m.cMenuText, pcMenuText, sizeof(m.cMenuText) ); @@ -213,7 +212,7 @@ int CHudMenu ::ShowMenu(int bitsValidSlots, const char *pcMenuText, MenuCallback m_flShutoffTime = ShutOffTime; m_fMenuDisplayed = 1; m_iFlags |= HUD_ACTIVE; - return TRUE; + return true; } //Hides a certain menu only if that menu is open diff --git a/src/game/client/ms/menu.h b/src/game/client/ms/menu.h index 014a9ddb..bc496b06 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: @@ -29,11 +31,12 @@ class CHudMenu : public CHudBase float m_flShutoffTime; int m_fWaitingForMore; bool m_fOfferedNextMenu; + char Name[32] = "CHudMenu"; //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); //------------ }; diff --git a/src/game/client/overview.cpp b/src/game/client/overview.cpp index 5f2d2108..09019876 100644 --- a/src/game/client/overview.cpp +++ b/src/game/client/overview.cpp @@ -110,7 +110,7 @@ int CHudOverview::Draw(float flTime) gEngfuncs.pTriAPI->Color4f(r, g, bc, 1.0f); // calculate rotational matrix - vec3_t a, b, angles; + Vector a, b, angles; float rmatrix[3][4]; // transformation matrix VectorCopy(pl->angles, angles); angles[0] = 0.0f; diff --git a/src/game/client/parsemsg.cpp b/src/game/client/parsemsg.cpp index ab8ce165..659f8523 100644 --- a/src/game/client/parsemsg.cpp +++ b/src/game/client/parsemsg.cpp @@ -16,7 +16,7 @@ // parsemsg.cpp // typedef unsigned char byte; -#define true 1 + static byte *gpBuf; static int giSize; @@ -68,6 +68,12 @@ int READ_BYTE( void ) return c; } + +bool READ_BOOL( void ) { + return (READ_BYTE() == 1); +} + + int READ_SHORT( void ) { int c; diff --git a/src/game/client/parsemsg.h b/src/game/client/parsemsg.h index 72b3b3bf..e3cbe734 100644 --- a/src/game/client/parsemsg.h +++ b/src/game/client/parsemsg.h @@ -16,8 +16,7 @@ // parsemsg.h // -#define READ_BOOL() ( READ_BYTE() == 1 ) // MIB FEB2019_23 [LOCAL_PANEL_IMAGE] - +bool READ_BOOL(void);// MIB FEB2019_23 [LOCAL_PANEL_IMAGE] void BEGIN_READ(void *buf, int size); int READ_CHAR(void); int READ_BYTE(void); diff --git a/src/game/client/render/clrender.cpp b/src/game/client/render/clrender.cpp index fa2e0162..125a2902 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" @@ -26,8 +25,8 @@ //OGL void DeleteGLTextures(); #ifdef _WIN32 -PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL; -PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL; +PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = nullptr; +PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = nullptr; #endif //Environment Manager @@ -44,7 +43,6 @@ extern "C" }; //TWHL Project - Thothie JUN2010_22 -#include "r_studioint.h" extern engine_studio_api_t IEngineStudio; @@ -60,7 +58,7 @@ CParticle::CParticle() { m_Width = 0; m_Origin = g_vecZero; - m_Texture = NULL; + m_Texture = nullptr; m_Color = Color4F(1.0f, 1.0f, 1.0f, 1.0f); m_Brightness = 1.0f; m_DirForward = g_vecZero; @@ -186,7 +184,7 @@ struct skyface_t //Vector Offset; }; -#define SKYFILENAME_PREFIX "gfx/env/" +constexpr const char* SKYFILENAME_PREFIX = "gfx/env/"; struct { Vector Dir; //Dir the wall is facing. It gets scooted back in the opp. direction @@ -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); } @@ -394,7 +392,9 @@ uint CRender::m_RT_Height = 256; float CRender::m_RT_TexU = 1.0f; float CRender::m_RT_TexV = 1.0f; -#define MS_GL_ATTRIBUTES GL_ALL_ATTRIB_BITS +enum { + MS_GL_ATTRIBUTES = GL_ALL_ATTRIB_BITS +}; //#define MS_GL_ATTRIBUTES void CRender::PushHLStates() @@ -557,7 +557,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 +647,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 +667,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 +706,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 d70001e2..f566a2b0 100644 --- a/src/game/client/render/clrender.h +++ b/src/game/client/render/clrender.h @@ -1,37 +1,41 @@ //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 +}; typedef struct msurface_s msurface_t; typedef struct decal_s decal_t; @@ -136,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) { @@ -180,7 +184,7 @@ class Plane class CSurface { public: - CSurface() { m_Surface = NULL; } + CSurface() { m_Surface = nullptr; } CSurface(msurface_t *Surface) { m_Surface = Surface; } void Draw(); void DrawProjective(); @@ -199,14 +203,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 +313,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 diff --git a/src/game/client/render/clrenderent.cpp b/src/game/client/render/clrenderent.cpp index 9ef48685..dd029cc8 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); @@ -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..615d9ee7 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" @@ -57,7 +56,7 @@ extern int OldVisFrame, OldContents; //#define DEBUG_MIRRORS //Enable viewing mirrors at world origin //#define MIRROR_STENCIL_MASK 0x3 -#define MIRROR_STENCIL_MASK 0xFFFFFFFF +constexpr unsigned int MIRROR_STENCIL_MASK = 0xFFFFFFFF; class CFrustum { @@ -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]); @@ -181,8 +180,8 @@ bool CheckSurface(TraverseInfo_t &Info, msurface_t *pSurface) if( Surface.plane->dist != -64 ) return false;*/ - mstexture_t *pCustomTexture = NULL; - for (int t = 0; t < MSCLGlobals::Textures.size(); t++) + mstexture_t *pCustomTexture = nullptr; + 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]; @@ -274,7 +273,7 @@ bool CheckSurface(TraverseInfo_t &Info, msurface_t *pSurface) pUseMirror->m_OnWorld = !Info.pEntity->index ? true : false; //Surface.texinfo->texture->gl_texturenum = 0; //The texture must have dimensions 2^X - float Power = logf(ScreenWidth) / logf(2); //Use ScreenHeight because it's smaller than width + float Power = logf(ScreenWidth()) / logf(2); //Use ScreenHeight() because it's smaller than width int IntPower = (int)Power; if (Power > IntPower) IntPower++; //Screen Width is in-between standardized texure sizes. Use the next highest size @@ -288,7 +287,7 @@ bool CheckSurface(TraverseInfo_t &Info, msurface_t *pSurface) pUseMirror->TexSize.x = pUseMirror->TexSize.y = TexSize; - //logfile << "Mirror #" << CMirrorMgr::m_LevelMirrors.size() << " - Screen: " << ScreenWidth << "x" << ScreenHeight << " Power: " << Power << " (" << IntPower << ")" << endl; + //logfile << "Mirror #" << CMirrorMgr::m_LevelMirrors.size() << " - Screen: " << ScreenWidth() << "x" << ScreenHeight() << " Power: " << Power << " (" << IntPower << ")" << endl; //logfile << "Mirror #" << CMirrorMgr::m_LevelMirrors.size() << " - Size: " << pUseMirror->TexSize.x << "x" << pUseMirror->TexSize.y << " Max: " << TexSizeMax << "x" << TexSizeMax << endl; pUseMirror->CreateMatrix(); @@ -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]; @@ -565,13 +564,13 @@ void CMirrorMgr::SetupNormalView() //Only use a portion of the screen, so I can see what the mirror sees in the top left Params.viewport[0] = MIRRORTEX_W; Params.viewport[1] = MIRRORTEX_H; - Params.viewport[2] = ScreenWidth - MIRRORTEX_W; - Params.viewport[3] = ScreenHeight - MIRRORTEX_H; + Params.viewport[2] = ScreenWidth() - MIRRORTEX_W; + Params.viewport[3] = ScreenHeight() - MIRRORTEX_H; #else*/ Params.viewport[0] = 0; Params.viewport[1] = 0; - Params.viewport[2] = ScreenWidth; - Params.viewport[3] = ScreenHeight; + Params.viewport[2] = ScreenWidth(); + Params.viewport[3] = ScreenHeight(); //#endif m_CurrentMirror.Enabled = false; } @@ -620,10 +619,7 @@ void CMirrorMgr::SetupNextView() }*/ } -#define PLANE_X 0 -#define PLANE_Y 1 -#define PLANE_Z 2 -//extern vec3_t v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles; +//extern Vector v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles; bool Mirror_TraverseVis(TraverseInfo_t &Info); void DrawVisLeafs(model_t *pModel, mleaf_t *pStartLeaf, TraverseInfo_t &Info); void rdrsky(); @@ -639,7 +635,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 +708,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 +804,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 +847,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 +872,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 +893,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 +959,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 +979,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 +1039,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 +1147,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; @@ -1393,8 +1389,8 @@ void CMirror::Draw(int Flags) //have extra space (For compatibility, I force them to be 2^x, but I dont use all the space). //So below is the modified equation - float RatioW = (float)ScreenWidth / TexSize.x; - float RatioH = (float)ScreenHeight / TexSize.y; + float RatioW = (float)ScreenWidth() / TexSize.x; + float RatioH = (float)ScreenHeight() / TexSize.y; //glTranslatef( 0.5f * RatioW, 0.5f * (1-(1-RatioH)), 0.0f ); glTranslatef(0.5f * RatioW, 0.5f * RatioH, 0.0f); glScalef(0.5f * RatioW, 0.5f * RatioH, 1); @@ -1492,7 +1488,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/gamestudiomodelrenderer.cpp b/src/game/client/render/gamestudiomodelrenderer.cpp index 63b1cd22..373b8614 100644 --- a/src/game/client/render/gamestudiomodelrenderer.cpp +++ b/src/game/client/render/gamestudiomodelrenderer.cpp @@ -75,7 +75,7 @@ R_StudioDrawModel int R_StudioDrawModel(int flags) { //return g_StudioRenderer.StudioDrawModel( flags ); - return CModelMgr::MSStudioDrawModel(flags, NULL); + return CModelMgr::MSStudioDrawModel(flags, nullptr); } extern cl_entity_t *DrawEnt; @@ -91,7 +91,7 @@ int CModelMgr::MSStudioDrawModel(int flags, entity_state_t *pplayer) { OldEntity = *CurrentEnt; *CurrentEnt = *DrawEnt; - DrawEnt = NULL; + DrawEnt = nullptr; Replaced = true; } diff --git a/src/game/client/render/opengl/clopengl.cpp b/src/game/client/render/opengl/clopengl.cpp index 9eb76b33..8a79a67e 100644 --- a/src/game/client/render/opengl/clopengl.cpp +++ b/src/game/client/render/opengl/clopengl.cpp @@ -308,15 +308,15 @@ bool CMirrorMgr::InitMirrors() int pf_attr[] = { - WGL_SUPPORT_OPENGL_ARB, TRUE, // P-buffer will be used with OpenGL - WGL_DRAW_TO_PBUFFER_ARB, TRUE, // Enable render to p-buffer - WGL_BIND_TO_TEXTURE_RGBA_ARB, TRUE, // P-buffer will be used as a texture + WGL_SUPPORT_OPENGL_ARB, true, // P-buffer will be used with OpenGL + WGL_DRAW_TO_PBUFFER_ARB, true, // Enable render to p-buffer + WGL_BIND_TO_TEXTURE_RGBA_ARB, true, // P-buffer will be used as a texture WGL_RED_BITS_ARB, 8, // At least 8 bits for RED channel WGL_GREEN_BITS_ARB, 8, // At least 8 bits for GREEN channel WGL_BLUE_BITS_ARB, 8, // At least 8 bits for BLUE channel WGL_ALPHA_BITS_ARB, 8, // At least 8 bits for ALPHA channel WGL_DEPTH_BITS_ARB, 16, // At least 16 bits for depth buffer - WGL_DOUBLE_BUFFER_ARB, FALSE, // We don't require double buffering + WGL_DOUBLE_BUFFER_ARB, false, // We don't require double buffering 0 // Zero terminates the list }; @@ -347,7 +347,7 @@ bool CMirrorMgr::InitMirrors() // Create the p-buffer... // - GetCompatibleTextureSize(ScreenWidth * CRender::m_RT_SizeRatio, ScreenHeight * CRender::m_RT_SizeRatio, CRender::m_RT_Width, CRender::m_RT_Height, CRender::m_RT_TexU, CRender::m_RT_TexV); + GetCompatibleTextureSize(ScreenWidth() * CRender::m_RT_SizeRatio, ScreenHeight() * CRender::m_RT_SizeRatio, CRender::m_RT_Width, CRender::m_RT_Height, CRender::m_RT_TexU, CRender::m_RT_TexV); g_pbuffer.hPBuffer = wglCreatePbufferARB(OldhDC, pixelFormat, CRender::m_RT_Width, CRender::m_RT_Height, pb_attr); g_pbuffer.hDC = wglGetPbufferDCARB(g_pbuffer.hPBuffer); diff --git a/src/game/client/render/studio_util.cpp b/src/game/client/render/studio_util.cpp index 78bfded6..bfc476d1 100644 --- a/src/game/client/render/studio_util.cpp +++ b/src/game/client/render/studio_util.cpp @@ -11,6 +11,10 @@ #include "const.h" #include "com_model.h" #include "studio_util.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h +#endif + // angles index are not the same as ROLL, PITCH, YAW diff --git a/src/game/client/render/studio_util.h b/src/game/client/render/studio_util.h index 7a2aa47b..9248f80d 100644 --- a/src/game/client/render/studio_util.h +++ b/src/game/client/render/studio_util.h @@ -7,21 +7,31 @@ #pragma once -#ifndef M_PI -#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h -#endif - -#ifndef PITCH +//#ifndef PITCH // MOVEMENT INFO // up / down -#define PITCH 0 -// left / right -#define YAW 1 -// fall over -#define ROLL 2 -#endif +enum { + PITCH = 0, + // left / right + YAW = 1, + // fall over + ROLL = 2 +}; +//#endif + +#undef PLANE_ANYZ + +enum planes_e { + PLANE_X = 0, + PLANE_Y = 1, + PLANE_Z = 2, + PLANE_ANYZ = 5 +}; -#define FDotProduct(a, b) (fabs((a[0]) * (b[0])) + fabs((a[1]) * (b[1])) + fabs((a[2]) * (b[2]))) +template +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]); +} void AngleMatrix(const float *angles, float (*matrix)[4]); bool VectorCompare (const float *v1, const float *v2); diff --git a/src/game/client/render/studiomodelrenderer.cpp b/src/game/client/render/studiomodelrenderer.cpp index 917f33ed..ccd40676 100644 --- a/src/game/client/render/studiomodelrenderer.cpp +++ b/src/game/client/render/studiomodelrenderer.cpp @@ -49,10 +49,10 @@ void ViewModel_InactiveModelVisible(bool fVisible, const cl_entity_s* ActiveEnti { ViewModel_ExclusiveViewHand = fVisible ? ActiveEntity->curstate.iuser2 : -1; } -extern vec3_t v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles; +extern Vector v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles; //CStudioModelRenderer *g_StudioRender = NULL; -cl_entity_t* DrawEnt = NULL; +cl_entity_t* DrawEnt = nullptr; ///////////////////// // Implementation of CStudioModelRenderer.h @@ -89,24 +89,24 @@ CStudioModelRenderer */ CStudioModelRenderer::CStudioModelRenderer(void) { - m_fDoInterp = 1; - m_fGaitEstimation = 1; - m_pCurrentEntity = NULL; - m_pCvarHiModels = NULL; - m_pCvarDeveloper = NULL; - m_pCvarDrawEntities = NULL; - m_pChromeSprite = NULL; - m_pStudioModelCount = NULL; - m_pModelsDrawn = NULL; - m_protationmatrix = NULL; - m_paliastransform = NULL; - m_pbonetransform = NULL; - m_plighttransform = NULL; - m_pStudioHeader = NULL; - m_pBodyPart = NULL; - m_pSubModel = NULL; - m_pPlayerInfo = NULL; - m_pRenderModel = NULL; + m_fDoInterp = 1; + m_fGaitEstimation = 1; + m_pCurrentEntity = nullptr; + m_pCvarHiModels = nullptr; + m_pCvarDeveloper = nullptr; + m_pCvarDrawEntities = nullptr; + m_pChromeSprite = nullptr; + m_pStudioModelCount = nullptr; + m_pModelsDrawn = nullptr; + m_protationmatrix = nullptr; + m_paliastransform = nullptr; + m_pbonetransform = nullptr; + m_plighttransform = nullptr; + m_pStudioHeader = nullptr; + m_pBodyPart = nullptr; + m_pSubModel = nullptr; + m_pPlayerInfo = nullptr; + m_pRenderModel = nullptr; //m_MirrorRender = false; /*AngleMatrix( g_vecZero, m_FlipMatrix ); float scalemat[ 3 ][ 4 ] = @@ -216,7 +216,7 @@ void CStudioModelRenderer::StudioCalcBoneQuaterion(int frame, float s, mstudiobo { int j, k; vec4_t q1, q2; - vec3_t angle1, angle2; + Vector angle1, angle2; mstudioanimvalue_t* panimvalue; for (j = 0; j < 3; j++) @@ -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 ) { @@ -520,8 +520,8 @@ Copies model origin and rotation into the transform matrix for rendering void CStudioModelRenderer::StudioSetUpTransform(int trivial_accept) { int i; - vec3_t angles; - vec3_t modelpos; + Vector angles; + Vector modelpos; cl_entity_t& Ent = *m_pCurrentEntity; @@ -928,7 +928,7 @@ void CStudioModelRenderer::StudioSetupBones(void) static vec4_t q4[MAXSTUDIOBONES]; cl_entity_t& Ent = *m_pCurrentEntity; - if (Ent.curstate.sequence >= m_pStudioHeader->numseq) + if (Ent.curstate.sequence >= static_cast(m_pStudioHeader->numseq)) { Ent.curstate.sequence = 0; } @@ -977,14 +977,14 @@ 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]; static vec4_t q1b[MAXSTUDIOBONES]; float s; - if (Ent.latched.prevsequence >= m_pStudioHeader->numseq) + if (Ent.latched.prevsequence >= static_cast(m_pStudioHeader->numseq)) Ent.latched.prevsequence = 0; pseqdesc = (mstudioseqdesc_t*)((byte*)m_pStudioHeader + m_pStudioHeader->seqindex) + Ent.latched.prevsequence; @@ -1028,7 +1028,7 @@ void CStudioModelRenderer::StudioSetupBones(void) pbones = (mstudiobone_t*)((byte*)m_pStudioHeader + m_pStudioHeader->boneindex); // bounds checking - if (m_pPlayerInfo && (m_pPlayerInfo->gaitsequence >= m_pStudioHeader->numseq)) + if (m_pPlayerInfo && (m_pPlayerInfo->gaitsequence >= static_cast(m_pStudioHeader->numseq))) m_pPlayerInfo->gaitsequence = 0; // calc gait animation @@ -1137,7 +1137,7 @@ void CStudioModelRenderer::StudioMergeBones(model_t* m_pSubModel) float bonematrix[3][4]; static vec4_t q[MAXSTUDIOBONES]; - if (Ent.curstate.sequence >= m_pStudioHeader->numseq) + if (Ent.curstate.sequence >= static_cast(m_pStudioHeader->numseq)) { Ent.curstate.sequence = 0; } @@ -1340,7 +1340,7 @@ int CStudioModelRenderer::StudioDrawModel(int flags) studiohdr_t* pStudioHeader = (studiohdr_t*)IEngineStudio.Mod_Extradata(RenderEnt.model); cl_entity_s* view = gEngfuncs.GetViewModel(); - view->model = NULL; //MiB JUN2010_21 - Disable the HL viewmodel. We use our own. + view->model = nullptr; //MiB JUN2010_21 - Disable the HL viewmodel. We use our own. RenderEnt.SetBody(pItem->m_ViewModelPart, pItem->m_ViewModelSubmodel); //Set the specified submodel on the item @@ -1522,7 +1522,7 @@ int CStudioModelRenderer::StudioDrawModel(int flags) m_pPlayerInfo = IEngineStudio.PlayerInfo(ZeroBasedPlayerIdx); m_pPlayerInfo->prevgaitorigin = PrevOrigin; - m_pPlayerInfo = NULL; + m_pPlayerInfo = nullptr; m_pCurrentEntity->curstate.number = oldnum; m_pCurrentEntity->index = oldidx; @@ -1607,7 +1607,7 @@ int CStudioModelRenderer::StudioDrawModel(int flags) cl_entity_t* ent = gEngfuncs.GetEntityByIndex(m_pCurrentEntity->index); if (ent) - memcpy(ent->attachment, m_pCurrentEntity->attachment, sizeof(vec3_t) * 4); + memcpy(ent->attachment, m_pCurrentEntity->attachment, sizeof(Vector ) * 4); } } @@ -1647,7 +1647,7 @@ StudioEstimateGait void CStudioModelRenderer::StudioEstimateGait(entity_state_t* pplayer) { float frametime = (m_clTime - m_clOldTime); - vec3_t est_velocity; + Vector est_velocity; if (frametime < 0) frametime = 0; @@ -1732,13 +1732,13 @@ StudioProcessGait */ void CStudioModelRenderer::StudioProcessGait(entity_state_t* pplayer) { - mstudioseqdesc_t* pseqdesc = NULL; + mstudioseqdesc_t* pseqdesc = nullptr; //float frametime; int iBlend = 0; float flYaw = 0; // view direction relative to movement float frametime = 0; - if (m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq) + if (m_pCurrentEntity->curstate.sequence >= static_cast(m_pStudioHeader->numseq)) m_pCurrentEntity->curstate.sequence = 0; pseqdesc = (mstudioseqdesc_t*)((byte*)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence; @@ -1817,7 +1817,7 @@ void CStudioModelRenderer::StudioProcessGait(entity_state_t* pplayer) m_pCurrentEntity->latched.prevcontroller[3] = m_pCurrentEntity->curstate.controller[3]; } - if (pplayer->gaitsequence >= m_pStudioHeader->numseq) + if (pplayer->gaitsequence >= static_cast(m_pStudioHeader->numseq)) pplayer->gaitsequence = 0; pseqdesc = (mstudioseqdesc_t*)((byte*)m_pStudioHeader + m_pStudioHeader->seqindex) + pplayer->gaitsequence; @@ -1913,7 +1913,7 @@ int CStudioModelRenderer::StudioDrawPlayer(int flags, entity_state_t* pplayer) return 0; m_pRenderModel = IEngineStudio.SetupPlayerModel(m_nPlayerIndex); - if (m_pRenderModel == NULL) + if (m_pRenderModel == nullptr) return 0; m_pStudioHeader = (studiohdr_t*)IEngineStudio.Mod_Extradata(m_pRenderModel); @@ -1944,7 +1944,7 @@ int CStudioModelRenderer::StudioDrawPlayer(int flags, entity_state_t* pplayer) } else { - modelinfo_t* pModelInfo = NULL; + modelinfo_t* pModelInfo = nullptr; if (Ent.HasExtra()) pModelInfo = &CModelMgr::m_ModelInfo[Ent.index]; @@ -1975,7 +1975,7 @@ int CStudioModelRenderer::StudioDrawPlayer(int flags, entity_state_t* pplayer) if (pplayer->gaitsequence) { - vec3_t orig_angles; + Vector orig_angles; m_pPlayerInfo = IEngineStudio.PlayerInfo(m_nPlayerIndex); VectorCopy(m_pCurrentEntity->angles, orig_angles); @@ -2035,7 +2035,7 @@ int CStudioModelRenderer::StudioDrawPlayer(int flags, entity_state_t* pplayer) { cl_entity_t* ent = gEngfuncs.GetEntityByIndex(m_pCurrentEntity->index); - memcpy(ent->attachment, m_pCurrentEntity->attachment, sizeof(vec3_t) * 4); + memcpy(ent->attachment, m_pCurrentEntity->attachment, sizeof(Vector ) * 4); } } @@ -2108,7 +2108,7 @@ int CStudioModelRenderer::StudioDrawPlayer(int flags, entity_state_t* pplayer) //Instead, the bodypart attachmets are rendered -- UNDONE StudioRenderModel(); - m_pPlayerInfo = NULL; + m_pPlayerInfo = nullptr; /* Master Sword - don't render the weaponmodel @@ -2182,9 +2182,9 @@ StudioRenderModel void CStudioModelRenderer::StudioRenderModel(void) { alight_t lighting; - vec3_t lightdir; + Vector lightdir; - HUDScript->Effects_Render(*m_pCurrentEntity, CMirrorMgr::m_CurrentMirror.Enabled); + gHUD.m_HUDScript->Effects_Render(*m_pCurrentEntity, CMirrorMgr::m_CurrentMirror.Enabled); lighting.plightvec = lightdir; IEngineStudio.StudioDynamicLight(m_pCurrentEntity, &lighting); @@ -2480,8 +2480,8 @@ void CStudioModelRenderer::FlipModel( bool Enable ) index = index % pbodypart->nummodels; mstudiomodel_t *m_pmodel = (mstudiomodel_t *)((byte *)m_pStudioHeader + pbodypart->modelindex) + index; - vec3_t *pstudioverts = (vec3_t *)((byte *)m_pStudioHeader + m_pmodel->vertindex); - vec3_t *pstudionorms = (vec3_t *)((byte *)m_pStudioHeader + m_pmodel->normindex); + Vector *pstudioverts = (Vector *)((byte *)m_pStudioHeader + m_pmodel->vertindex); + Vector *pstudionorms = (Vector *)((byte *)m_pStudioHeader + m_pmodel->normindex); for( int v = 0; v < m_pmodel->numverts; v++ ) pstudioverts[v][0] *= -1; //Flip the vertices for( int n = 0; n < m_pmodel->numnorms; n++) pstudionorms[n][0] *= -1; //Flip the normals diff --git a/src/game/client/richpresence.cpp b/src/game/client/richpresence.cpp index 623b52d6..677b71e6 100644 --- a/src/game/client/richpresence.cpp +++ b/src/game/client/richpresence.cpp @@ -15,7 +15,7 @@ #include "discord/discord_rpc.h" #include -#define DISCORD_RPC_UPDATE_TIME 35.0 // sec +constexpr float DISCORD_RPC_UPDATE_TIME = 35.0; // sec void CRichPresence::Init(void) { @@ -57,7 +57,7 @@ void CRichPresence::Update(void) { for (int i = 1; i < MAX_PLAYERS; i++) { - if (g_PlayerInfoList[i].name == NULL) + if (g_PlayerInfoList[i].name == nullptr) continue; if (g_PlayerInfoList[i].thisplayer) diff --git a/src/game/client/saytext.cpp b/src/game/client/saytext.cpp index d4ec5aca..111305a4 100644 --- a/src/game/client/saytext.cpp +++ b/src/game/client/saytext.cpp @@ -29,12 +29,12 @@ extern float *GetClientColor( int clientIndex ); -#define MAX_LINES 5 -#define MAX_CHARS_PER_LINE 256 /* it can be less than this, depending on char size */ +constexpr int MAX_LINES = 5; +constexpr int MAX_CHARS_PER_LINE = 256; /* it can be less than this, depending on char size */ // allow 20 pixels on either side of the text -#define MAX_LINE_WIDTH ( ScreenWidth - 40 ) -#define LINE_START 10 +const int MAX_LINE_WIDTH = (ScreenWidth() - 40); +constexpr int LINE_START = 10; static float SCROLL_SPEED = 5; static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ]; @@ -42,7 +42,7 @@ static float *g_pflNameColors[ MAX_LINES + 1 ]; static int g_iNameLengths[ MAX_LINES + 1 ]; static float flScrollTime = 0; // the time at which the lines next scroll up -#define SAYTEXT_START_Y ( ScreenHeight - YRES(160) ) +const int SAYTEXT_START_Y = (ScreenHeight() - YRES(160)); static int Y_START = 0; //varies static int line_height = 0; @@ -99,7 +99,7 @@ int CHudSayText :: Draw( float flTime ) { int y = Y_START; - if ( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE) || !m_HUD_saytext->value ) + if ( ( gViewPort && gViewPort->AllowedToPrintText() == false) || !m_HUD_saytext->value ) return 1; // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset @@ -184,7 +184,7 @@ int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ) void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex ) { ConsolePrint( pszBuf ); - if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE ) + if ( gViewPort && gViewPort->AllowedToPrintText() == false ) { // Print it straight to the console return; @@ -225,7 +225,7 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn } }*/ - strncpy( g_szLineBuffer[i], pszBuf, V_max(iBufSize -1, MAX_CHARS_PER_LINE-1) ); + strncpy( g_szLineBuffer[i], pszBuf, V_max(iBufSize -1, MAX_CHARS_PER_LINE - 1) ); // make sure the text fits in one line EnsureTextFitsInOneLineAndWrapIfHaveTo( i ); @@ -239,10 +239,10 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn m_iFlags |= HUD_ACTIVE; PlaySound( "misc/talk.wav", 1 ); - //if ( ScreenHeight >= 480 ) + //if ( ScreenHeight() >= 480 ) Y_START = SAYTEXT_START_Y; //else - // Y_START = ScreenHeight - 45; + // Y_START = ScreenHeight() - 45; Y_START -= (line_height * (MAX_LINES+1)); } diff --git a/src/game/client/status_icons.cpp b/src/game/client/status_icons.cpp index 28141280..6255b5da 100644 --- a/src/game/client/status_icons.cpp +++ b/src/game/client/status_icons.cpp @@ -54,10 +54,10 @@ int CHudStatusIcons::Draw(float flTime) { // find starting position to draw from, along right-hand side of screen int x = 5; - int y = ScreenHeight / 2; + 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) { @@ -73,7 +73,7 @@ int CHudStatusIcons::Draw(float flTime) // Message handler for StatusIcon message // accepts five values: -// byte : TRUE = ENABLE icon, FALSE = DISABLE icon +// byte : true = ENABLE icon, false = DISABLE icon // string : the sprite name to display // byte : red // byte : green @@ -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..0fa06298 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,22 +166,22 @@ 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; + 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); int Y_START; - if (ScreenHeight >= 480) - Y_START = ScreenHeight - 55; + if (ScreenHeight() >= 480) + Y_START = ScreenHeight() - 55; else - Y_START = ScreenHeight - 45; + Y_START = ScreenHeight() - 45; int x = 5; int y = Y_START - (TextHeight * i); // draw along bottom of screen @@ -189,8 +189,8 @@ int CHudStatusBar ::Draw(float fTime) // let user set status ID bar centering if ((i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid")) { - x = V_max(0, V_max(2, (ScreenWidth - TextWidth)) / 2); - y = (ScreenHeight / 2) + (TextHeight * CVAR_GET_FLOAT("hud_centerid")); + x = V_max(0, V_max(2, (ScreenWidth() - TextWidth)) / 2); + y = (ScreenHeight() / 2) + (TextHeight * CVAR_GET_FLOAT("hud_centerid")); } DrawConsoleString(x, y, m_szStatusBar[i]); @@ -228,7 +228,7 @@ int CHudStatusBar ::MsgFunc_StatusText(const char *pszName, int iSize, void *pbu else m_iFlags |= HUD_ACTIVE; // we have status text, so turn on the status bar - m_bReparseString = TRUE; + m_bReparseString = true; return 1; } @@ -247,7 +247,7 @@ int CHudStatusBar ::MsgFunc_StatusValue(const char *pszName, int iSize, void *pb m_iStatusValues[index] = READ_SHORT(); - m_bReparseString = TRUE; + m_bReparseString = true; return 1; } \ No newline at end of file diff --git a/src/game/client/text_message.cpp b/src/game/client/text_message.cpp index 5de0cf34..8296b862 100644 --- a/src/game/client/text_message.cpp +++ b/src/game/client/text_message.cpp @@ -166,7 +166,7 @@ char *ConvertCRtoNL(char *str) // the next (optional) one to four strings are parameters for that string (which can also be message names if they begin with '#') int CHudTextMessage::MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf) { - #define MSG_BUF_SIZE 128 + constexpr unsigned int MSG_BUF_SIZE = 128; BEGIN_READ(pbuf, iSize); int msg_dest = READ_BYTE(); @@ -190,7 +190,7 @@ int CHudTextMessage::MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf) StripEndNewlineFromString(sstr4); char* psz = szBuf[5]; - if (gViewPort && gViewPort->AllowedToPrintText() == FALSE) + if (gViewPort && gViewPort->AllowedToPrintText() == false) return 1; switch (msg_dest) diff --git a/src/game/client/train.cpp b/src/game/client/train.cpp index 0bf0e8a7..b0b81e78 100644 --- a/src/game/client/train.cpp +++ b/src/game/client/train.cpp @@ -58,8 +58,8 @@ int CHudTrain::Draw(float fTime) SPR_Set(m_hSprite, r, g, b ); // This should show up to the right and part way up the armor number - y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight; - x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4; + y = ScreenHeight() - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight; + x = ScreenWidth()/3 + SPR_Width(m_hSprite,0)/4; SPR_DrawAdditive( m_iPos - 1, x, y, NULL); diff --git a/src/game/client/ui/ms/vgui_choosecharacter.cpp b/src/game/client/ui/ms/vgui_choosecharacter.cpp index f74e2e31..472294b4 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; @@ -400,9 +400,9 @@ int GetCenteredItemX( int WorkSpaceSizeX, int ItemSizeX, int Items, int SpaceBew // Creation CMenuPanel *CreateNewCharacterPanel( ) { - return new CNewCharacterPanel( 1, true, 0, 0, ScreenWidth, ScreenHeight); + return new CNewCharacterPanel( 1, true, 0, 0, ScreenWidth(), ScreenHeight()); } -CNewCharacterPanel::CNewCharacterPanel( int iTrans, int iRemoveMe, int x, int y, int wide,int tall ) : CMenuPanel( 0, TRUE, x, y, wide, tall ) +CNewCharacterPanel::CNewCharacterPanel( int iTrans, int iRemoveMe, int x, int y, int wide,int tall ) : CMenuPanel( 0, true, x, y, wide, tall ) { SetBits( m_Flags, MENUFLAG_TRAPNUMINPUT ); @@ -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()) { @@ -343,7 +343,7 @@ void VGUI_ItemInfoPanel::Update(containeritem_t &Item) } // Creation -VGUI_ContainerPanel::VGUI_ContainerPanel() : CMenuPanel(100, FALSE, 0, 0, ScreenWidth, ScreenHeight), VGUI_ItemCallbackPanel() +VGUI_ContainerPanel::VGUI_ContainerPanel() : CMenuPanel(100, false, 0, 0, ScreenWidth(), ScreenHeight()), VGUI_ItemCallbackPanel() { COLOR Color_TitleText = COLOR(255, 100, 100, 0), Color_SubtitleText = COLOR(160, 160, 160, 0), @@ -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..c97627e8 100644 --- a/src/game/client/ui/ms/vgui_container.h +++ b/src/game/client/ui/ms/vgui_container.h @@ -16,7 +16,7 @@ #define ITEM_CONTAINER_X (GEARPNL_X + GEARPNL_SIZE_X) + CONTAINERMENU_SPACER_X #define ITEM_CONTAINER_Y GEARPNL_Y -#define ITEM_CONTAINER_SIZE_X (ScreenWidth - (ITEM_CONTAINER_X + CONTAINERMENU_SPACER_X)) +#define ITEM_CONTAINER_SIZE_X (ScreenWidth() - (ITEM_CONTAINER_X + CONTAINERMENU_SPACER_X)) #define ITEM_CONTAINER_SIZE_Y YRES(340) #define ACTBTN_SIZE_X XRES(130) @@ -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..eb23611d 100644 --- a/src/game/client/ui/ms/vgui_health.h +++ b/src/game/client/ui/ms/vgui_health.h @@ -6,7 +6,7 @@ #include "vgui_ihud.h" //Scales flasks down to only 40% wide of the screen if sprites are too big -#define BAR_SCALE (1.0f - ((730 - (ScreenWidth * 0.40f)) / ScreenHeight)) +#define BAR_SCALE (1.0f - ((730 - (ScreenWidth() * 0.40f)) / ScreenHeight())) #define BAR_W (320 * BAR_SCALE) #define BAR_H (40 * BAR_SCALE) @@ -144,7 +144,7 @@ namespace PrimaryHUD public: //Main HUD Image - VGUI_Health(Panel* pParent) : Panel(0, 0, ScreenWidth, ScreenHeight) + VGUI_Health(Panel* pParent) : Panel(0, 0, ScreenWidth(), ScreenHeight()) { CHARGE_W = XRES(30); CHARGE_H = YRES(6); @@ -157,7 +157,7 @@ namespace PrimaryHUD float coords[2]; coords[0] = 10; //x - coords[1] = (ScreenHeight - (2 * BAR_H) - YRES(10)); //y, from the bottom of the screen, as high as the sprites are + coords[1] = (ScreenHeight() - (2 * BAR_H) - YRES(10)); //y, from the bottom of the screen, as high as the sprites are // Status Bars @@ -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..7d5bb1e9 100644 --- a/src/game/client/ui/ms/vgui_healthretro.h +++ b/src/game/client/ui/ms/vgui_healthretro.h @@ -136,7 +136,7 @@ namespace RetroHUD VGUI_Image3D m_HUDImage; public: - VGUI_Health(Panel *pParent) : Panel(0, 0, ScreenWidth, ScreenHeight) + VGUI_Health(Panel *pParent) : Panel(0, 0, ScreenWidth(), ScreenHeight()) { FLASK_SPACER = XRES(10); @@ -165,7 +165,7 @@ namespace RetroHUD // m_HUDImage.LoadImg("hud_main3", true, false); // m_HUDImage.setFgColor(255, 255, 255, 255); // m_HUDImage.setSize(256, 256); - // m_HUDImage.setPos(0, ScreenHeight - 256); + // m_HUDImage.setPos(0, ScreenHeight() - 256); //Health and mana flasks m_Flask[0] = new VGUI_Flask(this, 0, FLASK_START_X, FLASK_START_Y); @@ -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..9d4df689 100644 --- a/src/game/client/ui/ms/vgui_hud.cpp +++ b/src/game/client/ui/ms/vgui_hud.cpp @@ -151,7 +151,7 @@ class CHUDPanel : public VGUI_MainPanel VGUI_MainPanel* CreateHUDPanel(Panel* pParent) { return new CHUDPanel(pParent); } -CHUDPanel::CHUDPanel(Panel* pParent) : VGUI_MainPanel(0, 0, 0, ScreenWidth, ScreenHeight) +CHUDPanel::CHUDPanel(Panel* pParent) : VGUI_MainPanel(0, 0, 0, ScreenWidth(), ScreenHeight()) { setParent(pParent); @@ -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..807802ea 100644 --- a/src/game/client/ui/ms/vgui_localizedpanel.cpp +++ b/src/game/client/ui/ms/vgui_localizedpanel.cpp @@ -16,8 +16,8 @@ #define LOCAL_TRANSPARENCY 60 #define LOCAL_MAINPANEL_RATIO (.875) -#define LOCAL_MAINPANEL_WIDTH (LOCAL_MAINPANEL_RATIO * ScreenWidth) -#define LOCAL_MAINPANEL_HEIGHT (LOCAL_MAINPANEL_RATIO * ScreenHeight) +#define LOCAL_MAINPANEL_WIDTH (LOCAL_MAINPANEL_RATIO * ScreenWidth()) +#define LOCAL_MAINPANEL_HEIGHT (LOCAL_MAINPANEL_RATIO * ScreenHeight()) #define LOCAL_SCROLLPANEL_X_SPACE_L XRES(10) #define LOCAL_SCROLLPANEL_X_SPACE_R LOCAL_SCROLLPANEL_X_SPACE_L @@ -49,7 +49,7 @@ bool LocalExists(msstring title) } CLocalizedPanel::CLocalizedPanel(Panel *pParent) - : CMenuPanel(LOCAL_TRANSPARENCY, false, 0, 0, ScreenWidth, ScreenHeight) + : CMenuPanel(LOCAL_TRANSPARENCY, false, 0, 0, ScreenWidth(), ScreenHeight()) { setParent(pParent); m_Name = LOCAL_MENU_NAME; @@ -59,8 +59,8 @@ CLocalizedPanel::CLocalizedPanel(Panel *pParent) m_iButtonTotal = 0; m_iSubPanelTotal = 0; - int xMainPanel = GetCenteredItem(ScreenWidth, LOCAL_MAINPANEL_WIDTH, 1, 0); - int yMainPanel = GetCenteredItem(ScreenHeight, LOCAL_MAINPANEL_HEIGHT, 1, 0); + int xMainPanel = GetCenteredItem(ScreenWidth(), LOCAL_MAINPANEL_WIDTH, 1, 0); + int yMainPanel = GetCenteredItem(ScreenHeight(), LOCAL_MAINPANEL_HEIGHT, 1, 0); m_pMainPanel = new CTransparentPanel(LOCAL_TRANSPARENCY, xMainPanel, yMainPanel, LOCAL_MAINPANEL_WIDTH, LOCAL_MAINPANEL_HEIGHT); m_pMainPanel->setParent(this); m_pMainPanel->setVisible(true); @@ -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..6087c3df 100644 --- a/src/game/client/ui/ms/vgui_menu_interact.h +++ b/src/game/client/ui/ms/vgui_menu_interact.h @@ -42,12 +42,12 @@ class VGUI_MenuInteract : public VGUI_MenuBase int w, h; m_pMainPanel->getPos(w, h); - m_pMainPanel->setPos(ScreenWidth - m_pMainPanel->getWide() - XRES(80), h); //Thothie JAN2008a was XRES(20) + m_pMainPanel->setPos(ScreenWidth() - m_pMainPanel->getWide() - XRES(80), h); //Thothie JAN2008a was XRES(20) 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..2c2f23fc 100644 --- a/src/game/client/ui/ms/vgui_menubase.cpp +++ b/src/game/client/ui/ms/vgui_menubase.cpp @@ -90,7 +90,7 @@ void CAction_SelectMainOption::actionPerformed(Panel *panel) int GetCenteredItemX(int WorkSpaceSizeX, int ItemSizeX, int Items, int SpaceBewteenItems); // Creation -VGUI_MenuBase::VGUI_MenuBase(Panel *myParent) : CMenuPanel(255, 0, 0, 0, ScreenWidth, ScreenHeight) +VGUI_MenuBase::VGUI_MenuBase(Panel *myParent) : CMenuPanel(255, 0, 0, 0, ScreenWidth(), ScreenHeight()) { m_AllowKeys = true; // MiB NOV2014_25, block number shortcuts: NpcInteractMenus.rft setParent(myParent); @@ -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_quickslot.h b/src/game/client/ui/ms/vgui_quickslot.h index f73b82b7..b1ab31a4 100644 --- a/src/game/client/ui/ms/vgui_quickslot.h +++ b/src/game/client/ui/ms/vgui_quickslot.h @@ -46,7 +46,7 @@ class VGUI_QuickSlot : public Panel, public IHUD #define QUICKSLOT_H YRES(14) - VGUI_QuickSlot(Panel *pParent) : Panel(XRES(170), ScreenHeight - QUICKSLOT_H, ScreenWidth, QUICKSLOT_H) + VGUI_QuickSlot(Panel *pParent) : Panel(XRES(170), ScreenHeight() - QUICKSLOT_H, ScreenWidth(), QUICKSLOT_H) { setParent(pParent); SetBGColorRGB(Color_Transparent); diff --git a/src/game/client/ui/ms/vgui_spawn.cpp b/src/game/client/ui/ms/vgui_spawn.cpp index 9d583f2c..a9fe4ffa 100644 --- a/src/game/client/ui/ms/vgui_spawn.cpp +++ b/src/game/client/ui/ms/vgui_spawn.cpp @@ -76,7 +76,7 @@ #define MSG_H YRES(60) // Creation -CSpawnPanel::CSpawnPanel(Panel *pParent) : CMenuPanel(1, false, 0, 0, ScreenWidth, ScreenHeight) +CSpawnPanel::CSpawnPanel(Panel *pParent) : CMenuPanel(1, false, 0, 0, ScreenWidth(), ScreenHeight()) { // Get the scheme used for the Titles CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); diff --git a/src/game/client/ui/ms/vgui_stats.cpp b/src/game/client/ui/ms/vgui_stats.cpp index 29304499..15a386e7 100644 --- a/src/game/client/ui/ms/vgui_stats.cpp +++ b/src/game/client/ui/ms/vgui_stats.cpp @@ -64,7 +64,7 @@ static COLOR Color_TitleText = COLOR(255, 255, 255, 0), Color_TransparentText = COLOR(0, 0, 0, 255); // Creation -CStatPanel::CStatPanel(Panel *pParent) : CMenuPanel(0, false, 0, 0, ScreenWidth, ScreenHeight) +CStatPanel::CStatPanel(Panel *pParent) : CMenuPanel(0, false, 0, 0, ScreenWidth(), ScreenHeight()) { setParent(pParent); setVisible(false); @@ -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); @@ -330,7 +330,7 @@ void CStatPanel::Update() Percent = 0.0; const char* Name = ""; - if (iSubStats <= STATPROP_TOTAL) + if (iSubStats <= STAT_PROP_TOTAL) Name = SkillTypeList[i]; else Name = SpellTypeList[i]; @@ -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..cb79334b 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 ); @@ -154,7 +154,7 @@ CStoreMenuPanel::CStoreMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide m_pButtons[i]->setContentAlignment( vgui::Label::a_west ); if( i != 2 ) m_pButtons[i]->addActionSignal( new CStoreBtn(iMenuToShow[i]) ); - else m_pButtons[i]->addActionSignal( new CMenuHandler_StringCommand( "trade sell 0", TRUE ) ); + else m_pButtons[i]->addActionSignal( new CMenuHandler_StringCommand( "trade sell 0", true ) ); m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver(this, i) ); m_pButtons[i]->setParent( this ); @@ -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_storemainwin.cpp b/src/game/client/ui/ms/vgui_storemainwin.cpp index 86c7cecb..9cdbd369 100644 --- a/src/game/client/ui/ms/vgui_storemainwin.cpp +++ b/src/game/client/ui/ms/vgui_storemainwin.cpp @@ -56,7 +56,7 @@ CStorePanel::CStorePanel() : VGUI_ContainerPanel() m_SaleLabel->setText("Selling 0 Items (0 Gold)"); //Set up the cancel button - m_pCancelButton->addActionSignal(new CMenuHandler_StringCommand("trade stop", TRUE)); + m_pCancelButton->addActionSignal(new CMenuHandler_StringCommand("trade stop", true)); m_pCancelButton->setText(Localized("#CLOSE")); Text_StoreGold = "GOLD"; 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/ms/vgui_vote.h b/src/game/client/ui/ms/vgui_vote.h index 267ec1e8..b224b5a9 100644 --- a/src/game/client/ui/ms/vgui_vote.h +++ b/src/game/client/ui/ms/vgui_vote.h @@ -14,7 +14,7 @@ class VGUI_VoteInfo : public Panel, public IHUD *m_pVoteDesc; TextPanel *m_YesVotes; - VGUI_VoteInfo(Panel *pParent) : Panel(0, 0, ScreenWidth, ScreenHeight) + VGUI_VoteInfo(Panel *pParent) : Panel(0, 0, ScreenWidth(), ScreenHeight()) { setParent(pParent); setBgColor(0, 0, 0, 255); diff --git a/src/game/client/ui/vgui_customobjects.cpp b/src/game/client/ui/vgui_customobjects.cpp index 739a1f25..af23b5b4 100644 --- a/src/game/client/ui/vgui_customobjects.cpp +++ b/src/game/client/ui/vgui_customobjects.cpp @@ -54,7 +54,7 @@ char *GetTGANameForRes(const char *pszName) static char gd[256]; int i = 640; - if (ScreenWidth < 640) + if (ScreenWidth() < 640) i = 320; snprintf(sz, sizeof(sz), pszName, i); 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..46b075af 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); } @@ -120,7 +120,7 @@ ScorePanel::ScorePanel(int x, int y, int wide, int tall) : Panel(x, y, wide, tal setPaintBorderEnabled(true); int xpos = g_ColumnInfo[0].m_Width + 3; - if (ScreenWidth >= 640) + if (ScreenWidth() >= 640) { // only expand column size for res greater than 640 xpos = XRES(xpos); @@ -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)); @@ -141,11 +141,11 @@ ScorePanel::ScorePanel(int x, int y, int wide, int tall) : Panel(x, y, wide, tal m_HeaderLabels[i].setText(g_ColumnInfo[i].m_pTitle); int xwide = g_ColumnInfo[i].m_Width; - if (ScreenWidth >= 640) + if (ScreenWidth() >= 640) { xwide = XRES(xwide); } - else if (ScreenWidth == 400) + else if (ScreenWidth() == 400) { // hack to make 400x300 resolution scoreboard fit if (i == 1) @@ -168,7 +168,7 @@ ScorePanel::ScorePanel(int x, int y, int wide, int tall) : Panel(x, y, wide, tal m_HeaderLabels[i].setContentAlignment(g_ColumnInfo[i].m_Alignment); int yres = 12; - if (ScreenHeight >= 480) + if (ScreenHeight() >= 480) { yres = YRES(yres); } @@ -341,9 +341,9 @@ void ScorePanel::SortTeams() g_TeamInfo[j].packetloss += g_PlayerInfoList[i].packetloss; if (g_PlayerInfoList[i].thisplayer) - g_TeamInfo[j].ownteam = TRUE; + g_TeamInfo[j].ownteam = true; else - g_TeamInfo[j].ownteam = FALSE; + g_TeamInfo[j].ownteam = false; // Set the team's number (used for team colors) g_TeamInfo[j].teamnumber = g_PlayerExtraInfo[i].teamnumber; @@ -352,7 +352,7 @@ void ScorePanel::SortTeams() // find team ping/packetloss averages for (i = 1; i <= m_iNumTeams; i++) { - g_TeamInfo[i].already_drawn = FALSE; + g_TeamInfo[i].already_drawn = false; if (g_TeamInfo[i].players > 0) { @@ -391,7 +391,7 @@ void ScorePanel::SortTeams() // Put this team in the sorted list m_iSortedRows[m_iRows] = best_team; m_iIsATeam[m_iRows] = TEAM_YES; - g_TeamInfo[best_team].already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get sorted again + g_TeamInfo[best_team].already_drawn = true; // set the already_drawn to be true, so this team won't get sorted again m_iRows++; // Now sort all the players on this team @@ -573,7 +573,7 @@ void ScorePanel::FillGrid() pLabel->setTextOffset(0, 0); int rowheight = 13; - if (ScreenHeight > 480) + if (ScreenHeight() > 480) { rowheight = YRES(rowheight); } @@ -608,7 +608,7 @@ void ScorePanel::FillGrid() // different height for team header rows rowheight = 20; - if (ScreenHeight >= 480) + if (ScreenHeight() >= 480) { rowheight = YRES(rowheight); } @@ -630,7 +630,7 @@ void ScorePanel::FillGrid() // different height for team header rows rowheight = 20; - if (ScreenHeight >= 480) + if (ScreenHeight() >= 480) { rowheight = YRES(rowheight); } @@ -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_spectatorpanel.cpp b/src/game/client/ui/vgui_spectatorpanel.cpp index 98e139d6..55a179cb 100644 --- a/src/game/client/ui/vgui_spectatorpanel.cpp +++ b/src/game/client/ui/vgui_spectatorpanel.cpp @@ -87,10 +87,10 @@ void SpectatorPanel::Initialize() SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Team Info Text"); - m_TopBorder = new CTransparentPanel(64, 0, 0, ScreenWidth, YRES(PANEL_HEIGHT)); + m_TopBorder = new CTransparentPanel(64, 0, 0, ScreenWidth(), YRES(PANEL_HEIGHT)); m_TopBorder->setParent(this); - m_BottomBorder = new CTransparentPanel(64, 0, ScreenHeight - YRES(32), ScreenWidth, YRES(PANEL_HEIGHT)); + m_BottomBorder = new CTransparentPanel(64, 0, ScreenHeight() - YRES(32), ScreenWidth(), YRES(PANEL_HEIGHT)); m_BottomBorder->setParent(this); setPaintBackgroundEnabled(false); @@ -143,7 +143,7 @@ void SpectatorPanel::Initialize() m_OptionButton->setUnArmedColor(143, 143, 54, 0); m_OptionButton->setArmedColor(194, 202, 54, 0); - m_CamButton = new ColorButton(CHudTextMessage::BufferedLocaliseTextString("#CAM_OPTIONS"), ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15), YRES(6), XRES(CAMOPTIONS_BUTTON_X), YRES(20), false, false); + m_CamButton = new ColorButton(CHudTextMessage::BufferedLocaliseTextString("#CAM_OPTIONS"), ScreenWidth() - (XRES(CAMOPTIONS_BUTTON_X) + 15), YRES(6), XRES(CAMOPTIONS_BUTTON_X), YRES(20), false, false); m_CamButton->setParent(m_BottomBorder); m_CamButton->setContentAlignment(vgui::Label::a_center); m_CamButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name @@ -163,7 +163,7 @@ void SpectatorPanel::Initialize() m_PrevPlayerButton->setUnArmedColor(143, 143, 54, 0); m_PrevPlayerButton->setArmedColor(194, 202, 54, 0); - m_NextPlayerButton = new ColorButton(">", (ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15), YRES(6), XRES(24), YRES(20), false, false); + m_NextPlayerButton = new ColorButton(">", (ScreenWidth() - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15), YRES(6), XRES(24), YRES(20), false, false); m_NextPlayerButton->setParent(m_BottomBorder); m_NextPlayerButton->setContentAlignment(vgui::Label::a_center); m_NextPlayerButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name @@ -175,7 +175,7 @@ void SpectatorPanel::Initialize() // Initialize the bottom title. - float flLabelSize = ((ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15)) - XRES((15 + OPTIONS_BUTTON_X + 15) + 38); + float flLabelSize = ((ScreenWidth() - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15)) - XRES((15 + OPTIONS_BUTTON_X + 15) + 38); m_BottomMainLabel = new Label("Spectator Bottom", XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6), flLabelSize, YRES(20)); m_BottomMainLabel->setParent(m_BottomBorder); @@ -222,7 +222,7 @@ void SpectatorPanel::ShowMenu(bool isVisible) { int iLabelSizeX, iLabelSizeY; m_BottomMainLabel->getSize(iLabelSizeX, iLabelSizeY); - m_BottomMainLabel->setPos((ScreenWidth / 2) - (iLabelSizeX / 2), YRES(6)); + m_BottomMainLabel->setPos((ScreenWidth() / 2) - (iLabelSizeX / 2), YRES(6)); } else m_BottomMainLabel->setPos(XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6)); @@ -315,7 +315,7 @@ void SpectatorPanel::EnableInsetView(bool isEnabled) else m_TopBanner->setVisible(false); - m_TopBorder->setBounds(0, 0, ScreenWidth, YRES(PANEL_HEIGHT)); + m_TopBorder->setBounds(0, 0, ScreenWidth(), YRES(PANEL_HEIGHT)); m_InsetViewButton->setVisible(false); } @@ -360,7 +360,7 @@ void SpectatorPanel::Update() if (iTimeWidth > iTextWidth) iTextWidth = iTimeWidth; - int xPos = ScreenWidth - (iTextWidth + XRES(4 + offset)); + int xPos = ScreenWidth() - (iTextWidth + XRES(4 + offset)); m_ExtraInfo->setBounds(xPos, YRES(1), iTextWidth, iTextHeight); @@ -368,7 +368,7 @@ void SpectatorPanel::Update() m_CurrentTime->setBounds(xPos + XRES(14 + 1), YRES(2) + iTextHeight, iTimeWidth, iTimeHeight); - m_Separator->setPos(ScreenWidth - (iTextWidth + XRES(4 + 2 + 4 + offset)), YRES(1)); + m_Separator->setPos(ScreenWidth() - (iTextWidth + XRES(4 + 2 + 4 + offset)), YRES(1)); m_Separator->setSize(XRES(4), YRES(PANEL_HEIGHT - 2)); for (j = 0; j < TEAM_NUMBER; j++) @@ -376,6 +376,6 @@ void SpectatorPanel::Update() int iwidth, iheight; m_TeamScores[j]->getTextSize(iwidth, iheight); - m_TeamScores[j]->setBounds(ScreenWidth - (iTextWidth + XRES(4 + 2 + 4 + 2 + offset) + iwidth), YRES(1) + (iheight * j), iwidth, iheight); + m_TeamScores[j]->setBounds(ScreenWidth() - (iTextWidth + XRES(4 + 2 + 4 + 2 + offset) + iwidth), YRES(1) + (iheight * j), iwidth, iheight); } } diff --git a/src/game/client/ui/vgui_status.h b/src/game/client/ui/vgui_status.h index 15737c07..ee4f618e 100644 --- a/src/game/client/ui/vgui_status.h +++ b/src/game/client/ui/vgui_status.h @@ -133,8 +133,8 @@ class VGUI_ImgIcon : public Panel //thothie messes JAN2010_29 - sloppy but works //moved to side that calls this /* - float fimgsize_w = ScreenWidth * (w*0.01); - float fimgsize_h = ScreenHeight * (h*0.01); + float fimgsize_w = ScreenWidth() * (w*0.01); + float fimgsize_h = ScreenHeight() * (h*0.01); int imgsize_w = (int)fimgsize_w; int imgsize_h = (int)fimgsize_h; */ @@ -186,7 +186,7 @@ class VGUI_Status : public Panel, public IHUD CImageDelayed m_FN; bool m_bFN; - VGUI_Status(Panel *pParent) : Panel(0, 0, ScreenWidth, ScreenHeight) + VGUI_Status(Panel *pParent) : Panel(0, 0, ScreenWidth(), ScreenHeight()) { StatusIcons = this; @@ -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)) { @@ -287,13 +287,13 @@ static void AddImg(const char *Img, const char *Name, if (!found) { //Thothie JAN2010_29 - convert x/y/h/w coords to % of screen - float fimg_x = ScreenWidth * (x * 0.01); - float fimg_y = ScreenHeight * (y * 0.01); + float fimg_x = ScreenWidth() * (x * 0.01); + float fimg_y = ScreenHeight() * (y * 0.01); int img_x = (int)fimg_x; int img_y = (int)fimg_y; - float fimg_w = ScreenWidth * (w * 0.01); - float fimg_h = ScreenHeight * (h * 0.01); + float fimg_w = ScreenWidth() * (w * 0.01); + float fimg_h = ScreenHeight() * (h * 0.01); int img_w = (int)fimg_w; int img_h = (int)fimg_h; @@ -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..3507464a 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) @@ -343,10 +343,10 @@ void CCommandMenu::RecalculatePositions(int iYOffset) // Calculate if this is going to fit onscreen, and shuffle it up if it won't int iBottom = iNewYPos + _size[1]; - if (iBottom > ScreenHeight) + if (iBottom > ScreenHeight()) { // Move in increments of button sizes - while (iAdjust < (iBottom - ScreenHeight)) + while (iAdjust < (iBottom - ScreenHeight())) { iAdjust += BUTTON_SIZE_Y - 1; } @@ -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) ) { @@ -568,7 +568,7 @@ TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) : P //CreateCommandMenu(); // Create the spectator Panel - m_pSpectatorPanel = new SpectatorPanel(0, 0, ScreenWidth, ScreenHeight); + m_pSpectatorPanel = new SpectatorPanel(0, 0, ScreenWidth(), ScreenHeight()); m_pSpectatorPanel->setParent(this); m_pSpectatorPanel->setVisible(false); @@ -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; @@ -1180,18 +1180,18 @@ void TeamFortressViewport::UpdateSpectatorPanel() void TeamFortressViewport::CreateScoreBoard(void) { int xdent = SBOARD_INDENT_X, ydent = SBOARD_INDENT_Y; - if (ScreenWidth == 512) + if (ScreenWidth() == 512) { xdent = SBOARD_INDENT_X_512; ydent = SBOARD_INDENT_Y_512; } - else if (ScreenWidth == 400) + else if (ScreenWidth() == 400) { xdent = SBOARD_INDENT_X_400; ydent = SBOARD_INDENT_Y_400; } - m_pScoreBoard = new ScorePanel(xdent, ydent, ScreenWidth - (xdent * 2), ScreenHeight - (ydent * 2)); + m_pScoreBoard = new ScorePanel(xdent, ydent, ScreenWidth() - (xdent * 2), ScreenHeight() - (ydent * 2)); m_pScoreBoard->setParent(this); m_pScoreBoard->setVisible(false); @@ -1322,7 +1322,7 @@ CMenuPanel *TeamFortressViewport::CreateTextWindow(int iTextToShow) }*/ // if we're in the game (ie. have selected a class), flag the menu to be only grayed in the dialog box, instead of full screen - CMenuPanel *pMOTDPanel = CMessageWindowPanel_Create(cText, cTitle, g_iPlayerClass == PC_UNDEFINED, false, 0, 0, ScreenWidth, ScreenHeight); + CMenuPanel *pMOTDPanel = CMessageWindowPanel_Create(cText, cTitle, g_iPlayerClass == PC_UNDEFINED, false, 0, 0, ScreenWidth(), ScreenHeight()); pMOTDPanel->setParent(this); if (pfile) @@ -1478,7 +1478,7 @@ void TeamFortressViewport::HideTopMenu() UpdateCursorState(); } -// Return TRUE if the HUD's allowed to print text messages +// Return true if the HUD's allowed to print text messages bool TeamFortressViewport::AllowedToPrintText(void) { // Prevent text messages when fullscreen menus are up @@ -1488,10 +1488,10 @@ bool TeamFortressViewport::AllowedToPrintText(void) { int iId = m_pCurrentMenu->GetMenuID(); if ( iId == MENU_SPAWN || iId == MENU_NEWCHARACTER ) - return FALSE; + return false; }*/ - return TRUE; + return true; } //====================================================================================== @@ -1510,7 +1510,7 @@ bool TeamFortressViewport::AllowedToPrintText(void) void TeamFortressViewport::CreateTeamMenu() { // Create the panel - m_pTeamMenu = new CTeamMenuPanel(100, false, 0, 0, ScreenWidth, ScreenHeight); + m_pTeamMenu = new CTeamMenuPanel(100, false, 0, 0, ScreenWidth(), ScreenHeight()); m_pTeamMenu->setParent( this ); m_pTeamMenu->setVisible( false ); }*/ @@ -1558,12 +1558,12 @@ void TeamFortressViewport::CreateStoreMenu() if (m_pStoreMenu) return; // Create the panel - m_pStoreMenu = new CStoreMenuPanel(100, false, 0, 0, ScreenWidth, ScreenHeight); + m_pStoreMenu = new CStoreMenuPanel(100, false, 0, 0, ScreenWidth(), ScreenHeight()); m_pStoreMenu->setParent(this); m_pStoreMenu->setVisible(false); // Create the buy panel - m_pStoreBuyMenu = new CStoreBuyPanel(100, false, 0, 0, ScreenWidth, ScreenHeight); + m_pStoreBuyMenu = new CStoreBuyPanel(100, false, 0, 0, ScreenWidth(), ScreenHeight()); m_pStoreBuyMenu->setParent(this); // Create the sell panel @@ -1573,7 +1573,7 @@ void TeamFortressViewport::CreateStoreMenu() m_pStoreStorageMenu = new CStoragePanel(this); // Create the container panel - m_pContainerMenu = new CContainerPanel(100, false, 0, 0, ScreenWidth, ScreenHeight); + m_pContainerMenu = new CContainerPanel(100, false, 0, 0, ScreenWidth(), ScreenHeight()); m_pContainerMenu->setParent(this); m_pContainerMenu->setVisible(false); } @@ -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); @@ -1601,7 +1601,7 @@ void TeamFortressViewport::CreateVGUIMenus() /*void TeamFortressViewport::CreateSpectatorMenu() { // Create the Panel - m_pSpectatorMenu = new CTransparentPanel(100, 0, ScreenHeight - YRES(60), ScreenWidth, YRES(60)); + m_pSpectatorMenu = new CTransparentPanel(100, 0, ScreenHeight() - YRES(60), ScreenWidth(), YRES(60)); m_pSpectatorMenu->setParent(this); m_pSpectatorMenu->setVisible(false); @@ -1616,7 +1616,7 @@ void TeamFortressViewport::CreateVGUIMenus() int r, g, b, a; // Create the title - m_pSpectatorLabel = new Label( "Spectator", 0, 0, ScreenWidth, YRES(25) ); + m_pSpectatorLabel = new Label( "Spectator", 0, 0, ScreenWidth(), YRES(25) ); m_pSpectatorLabel->setParent( m_pSpectatorMenu ); m_pSpectatorLabel->setFont( pSchemes->getFont(hTitleScheme) ); pSchemes->getFgColor( hTitleScheme, r, g, b, a ); @@ -1626,7 +1626,7 @@ void TeamFortressViewport::CreateVGUIMenus() m_pSpectatorLabel->setContentAlignment( vgui::Label::a_north ); // Create the Help - Label *pLabel = new Label( CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help" ), 0, YRES(25), ScreenWidth, YRES(15) ); + Label *pLabel = new Label( CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help" ), 0, YRES(25), ScreenWidth(), YRES(15) ); pLabel->setParent( m_pSpectatorMenu ); pLabel->setFont( pSchemes->getFont(hHelpText) ); pSchemes->getFgColor( hHelpText, r, g, b, a ); @@ -1635,7 +1635,7 @@ void TeamFortressViewport::CreateVGUIMenus() pLabel->setBgColor( r, g, b, 255 ); pLabel->setContentAlignment( vgui::Label::a_north ); - pLabel = new Label( CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help2" ), 0, YRES(40), ScreenWidth, YRES(20) ); + pLabel = new Label( CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help2" ), 0, YRES(40), ScreenWidth(), YRES(20) ); pLabel->setParent( m_pSpectatorMenu ); pLabel->setFont( pSchemes->getFont(hHelpText) ); pSchemes->getFgColor( hHelpText, r, g, b, a ); @@ -1803,7 +1803,7 @@ bool TeamFortressViewport::SlotInput(int iSlot) if (m_pCurrentMenu) return m_pCurrentMenu->SlotInput(iSlot); - return FALSE; + return false; } // Direct Key Input @@ -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; @@ -2075,7 +2075,7 @@ int TeamFortressViewport::MsgFunc_TeamScore(const char *pszName, int iSize, void return 1; // use this new score data instead of combined player scoresw - g_TeamInfo[i].scores_overriden = TRUE; + g_TeamInfo[i].scores_overriden = true; g_TeamInfo[i].frags = READ_SHORT(); g_TeamInfo[i].deaths = READ_SHORT(); diff --git a/src/game/client/ui/vgui_teamfortressviewport.h b/src/game/client/ui/vgui_teamfortressviewport.h index c6d74ad7..d736559e 100644 --- a/src/game/client/ui/vgui_teamfortressviewport.h +++ b/src/game/client/ui/vgui_teamfortressviewport.h @@ -97,20 +97,20 @@ extern int iTeamColors[5][3]; #define MAPBRIEF_INDENT 30 // Team Menu -#define TMENU_INDENT_X (30 * ((float)ScreenHeight / 640)) +#define TMENU_INDENT_X (30 * ((float)ScreenHeight() / 640)) #define TMENU_HEADER 100 -#define TMENU_SIZE_X (ScreenWidth - (TMENU_INDENT_X * 2)) +#define TMENU_SIZE_X (ScreenWidth() - (TMENU_INDENT_X * 2)) #define TMENU_SIZE_Y (TMENU_HEADER + BUTTON_SIZE_Y * 7) #define TMENU_PLAYER_INDENT (((float)TMENU_SIZE_X / 3) * 2) -#define TMENU_INDENT_Y (((float)ScreenHeight - TMENU_SIZE_Y) / 2) +#define TMENU_INDENT_Y (((float)ScreenHeight() - TMENU_SIZE_Y) / 2) // Class Menu -#define CLMENU_INDENT_X (30 * ((float)ScreenHeight / 640)) +#define CLMENU_INDENT_X (30 * ((float)ScreenHeight() / 640)) #define CLMENU_HEADER 100 -#define CLMENU_SIZE_X (ScreenWidth - (CLMENU_INDENT_X * 2)) +#define CLMENU_SIZE_X (ScreenWidth() - (CLMENU_INDENT_X * 2)) #define CLMENU_SIZE_Y (CLMENU_HEADER + BUTTON_SIZE_Y * 11) #define CLMENU_PLAYER_INDENT (((float)CLMENU_SIZE_X / 3) * 2) -#define CLMENU_INDENT_Y (((float)ScreenHeight - CLMENU_SIZE_Y) / 2) +#define CLMENU_INDENT_Y (((float)ScreenHeight() - CLMENU_SIZE_Y) / 2) // Arrows enum @@ -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/ui/vgui_voice_tweakdlg.cpp b/src/game/client/ui/vgui_voice_tweakdlg.cpp index d59d9ecb..b4636fb4 100644 --- a/src/game/client/ui/vgui_voice_tweakdlg.cpp +++ b/src/game/client/ui/vgui_voice_tweakdlg.cpp @@ -175,8 +175,8 @@ void CVoiceVGUITweakDlg::Open() g_bTweakDlgOpen = true; - m_DlgWidth = ScreenWidth; - m_DlgHeight = ScreenHeight; + m_DlgWidth = ScreenWidth(); + m_DlgHeight = ScreenHeight(); m_pVoiceTweak = gEngfuncs.pVoiceTweak; @@ -184,7 +184,7 @@ void CVoiceVGUITweakDlg::Open() m_pVoiceTweak->StartVoiceTweakMode(); // Set our size. - setPos((ScreenWidth - m_DlgWidth) / 2, (ScreenHeight - m_DlgHeight) / 2); + setPos((ScreenWidth() - m_DlgWidth) / 2, (ScreenHeight() - m_DlgHeight) / 2); setSize(m_DlgWidth, m_DlgHeight); int curY = ITEM_BORDER; diff --git a/src/game/client/util.cpp b/src/game/client/util.cpp index 71af8638..81062d5f 100644 --- a/src/game/client/util.cpp +++ b/src/game/client/util.cpp @@ -30,7 +30,7 @@ HLSPRITE LoadSprite(const char *pszName) int i; char sz[256]; - if (ScreenWidth < 640) + if (ScreenWidth() < 640) i = 320; else i = 640; diff --git a/src/game/client/view.cpp b/src/game/client/view.cpp index 6aee0ffd..1469277a 100644 --- a/src/game/client/view.cpp +++ b/src/game/client/view.cpp @@ -72,7 +72,7 @@ extern "C" float Distance(Vector a, Vector b) { - vec3_t d; + Vector d; VectorSubtract(b, a, d); return Length(d); } @@ -97,10 +97,12 @@ extern cvar_t *chase_active; extern cvar_t *scr_ofsx, *scr_ofsy, *scr_ofsz; extern cvar_t *cl_vsmoothing; -#define CAM_MODE_RELAX 1 -#define CAM_MODE_FOCUS 2 +enum { + CAM_MODE_RELAX = 1, + CAM_MODE_FOCUS = 2 +}; -vec3_t v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles; +Vector v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles; Vector g_ViewForward, g_ViewRight, g_ViewUp; float v_frametime, v_lastDistance; float v_cameraRelaxAngle = 5.0f; @@ -109,7 +111,7 @@ int v_cameraMode = CAM_MODE_FOCUS; qboolean v_resetCamera = 1; float v_ViewDist = 4096; -vec3_t ev_punchangle; +Vector ev_punchangle; cvar_t *scr_ofsx; cvar_t *scr_ofsy; @@ -200,7 +202,7 @@ float V_CalcBob(struct ref_params_s *pparams) static float bob; float cycle; static float lasttime; - vec3_t vel; + Vector vel; if (pparams->onground == -1 || pparams->time == lasttime) @@ -242,12 +244,12 @@ V_CalcRoll Used by view and sv_user =============== */ -float V_CalcRoll(vec3_t angles, vec3_t velocity, float rollangle, float rollspeed) +float V_CalcRoll(Vector angles, Vector velocity, float rollangle, float rollspeed) { float sign; float side; float value; - vec3_t forward, right, up; + Vector forward, right, up; AngleVectors(angles, &forward, &right, &up); @@ -489,8 +491,8 @@ void V_CalcIntermissionRefdef(struct ref_params_s *pparams) v_angles = pparams->viewangles; } -#define ORIGIN_BACKUP 64 -#define ORIGIN_MASK (ORIGIN_BACKUP - 1) +constexpr unsigned int ORIGIN_BACKUP = 64; +constexpr unsigned int ORIGIN_MASK = (ORIGIN_BACKUP - 1); typedef struct { @@ -513,15 +515,15 @@ V_CalcRefdef void V_CalcNormalRefdef(struct ref_params_s *pparams) { cl_entity_t *ent; - int i; - vec3_t angles; + unsigned int i; + Vector angles; float bob, waterOffset; static viewinterp_t ViewInterp; static float oldz = 0; static float lasttime; - vec3_t camAngles, camForward, camRight, camUp; + Vector camAngles, camForward, camRight, camUp; cl_entity_t *pwater; V_DriftPitch(pparams); @@ -566,13 +568,13 @@ void V_CalcNormalRefdef(struct ref_params_s *pparams) if (pparams->waterlevel >= 2) { int i, contents, waterDist, waterEntity; - vec3_t point; + Vector point; waterDist = cl_waterdist->value; 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)) @@ -640,7 +642,7 @@ void V_CalcNormalRefdef(struct ref_params_s *pparams) // Treating cam_ofs[2] as the distance if (MSCLGlobals::CamThirdPerson) { - vec3_t ofs; + Vector ofs; ofs[0] = ofs[1] = ofs[2] = 0.0; @@ -748,7 +750,7 @@ void V_CalcNormalRefdef(struct ref_params_s *pparams) { static float lastorg[3]; - vec3_t delta; + Vector delta; VectorSubtract(pparams->simorg, lastorg, delta); @@ -787,10 +789,10 @@ void V_CalcNormalRefdef(struct ref_params_s *pparams) if (i < ORIGIN_MASK && ViewInterp.OriginTime[foundidx & ORIGIN_MASK] != 0.0) { // Interpolate - vec3_t delta; + Vector delta; double frac; double dt; - vec3_t neworg; + Vector neworg; dt = ViewInterp.OriginTime[(foundidx + 1) & ORIGIN_MASK] - ViewInterp.OriginTime[foundidx & ORIGIN_MASK]; if (dt > 0.0) @@ -890,7 +892,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]; @@ -942,9 +944,9 @@ void V_SmoothInterpolateAngles(float *startAngle, float *endAngle, float *finalA // Get the origin of the Observer based around the target's position and angles void V_GetChaseOrigin(float *angles, float *origin, float distance, float *returnvec) { - vec3_t vecEnd; - vec3_t forward; - vec3_t vecStart; + Vector vecEnd; + Vector forward; + Vector vecStart; pmtrace_t *trace = NULL; int maxLoops = 8; @@ -1119,7 +1121,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) @@ -1367,8 +1369,8 @@ void V_GetInEyePos(int target, float *origin, float *angles) void V_GetMapFreePosition(float *cl_angles, float *origin, float *angles) { - vec3_t forward; - vec3_t zScaledTarget; + Vector forward; + Vector zScaledTarget; VectorCopy(cl_angles, angles); @@ -1388,7 +1390,7 @@ void V_GetMapFreePosition(float *cl_angles, float *origin, float *angles) void V_GetMapChasePosition(int target, float *cl_angles, float *origin, float *angles) { - vec3_t forward; + Vector forward; if (target) { @@ -1481,7 +1483,7 @@ V_CalcSpectatorRefdef */ void V_CalcSpectatorRefdef(struct ref_params_s *pparams) { - static vec3_t velocity(0.0f, 0.0f, 0.0f); + static Vector velocity(0.0f, 0.0f, 0.0f); static int lastWeaponModelIndex = 0; static int lastViewModelIndex = 0; @@ -1498,14 +1500,14 @@ void V_CalcSpectatorRefdef(struct ref_params_s *pparams) VectorCopy(pparams->viewangles, v_angles); VectorCopy(pparams->vieworg, v_origin); - if ((g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE) && ent) + if ((g_iUser1 == OBS_IN_EYE || (int)gHUD.m_Spectator.m_pip->value == INSET_IN_EYE) && ent) { // calculate player velocity float timeDiff = ent->curstate.msg_time - ent->prevstate.msg_time; if (timeDiff > 0) { - vec3_t distance; + Vector distance; VectorSubtract(ent->prevstate.origin, ent->curstate.origin, distance); VectorScale(distance, 1 / timeDiff, distance); @@ -1648,8 +1650,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) @@ -1820,11 +1822,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; } @@ -1838,16 +1840,16 @@ void V_Move(int mx, int my) float dx, dy; float c_x, c_y; float dX, dY; - vec3_t forward, up, right; - vec3_t newangles; + Vector forward, up, right; + Vector newangles; - vec3_t farpoint; + Vector farpoint; pmtrace_t tr; - fov = CalcFov(in_fov, (float)ScreenWidth, (float)ScreenHeight); + fov = CalcFov(in_fov, (float)ScreenWidth(), (float)ScreenHeight()); - c_x = (float)ScreenWidth / 2.0; - c_y = (float)ScreenHeight / 2.0; + c_x = (float)ScreenWidth() / 2.0; + c_y = (float)ScreenHeight() / 2.0; dx = (float)mx - c_x; dy = (float)my - c_y; diff --git a/src/game/server/basemonster.h b/src/game/server/basemonster.h index eeb652f0..1aa3ec6a 100644 --- a/src/game/server/basemonster.h +++ b/src/game/server/basemonster.h @@ -235,7 +235,7 @@ class CBaseMonster : public CBaseToggle BOOL FindLateralCover(const Vector &vecThreat, const Vector &vecViewOffset); virtual BOOL FindCover(Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist); - virtual BOOL FValidateCover(const Vector &vecCoverLocation) { return TRUE; }; + virtual BOOL FValidateCover(const Vector &vecCoverLocation) { return true; }; virtual float CoverRadius(void) { return 784; } // Default cover radius virtual BOOL FCanCheckAttacks(void); @@ -247,14 +247,14 @@ class CBaseMonster : public CBaseToggle inline BOOL HasConditions(int iConditions) { if (m_afConditions & iConditions) - return TRUE; - return FALSE; + return true; + return false; } inline BOOL HasAllConditions(int iConditions) { if ((m_afConditions & iConditions) == iConditions) - return TRUE; - return FALSE; + return true; + return false; } virtual BOOL FValidateHintType(short sHint); @@ -340,14 +340,14 @@ class CBaseMonster : public CBaseToggle inline BOOL HasMemory(int iMemory) { if (m_afMemory & iMemory) - return TRUE; - return FALSE; + return true; + return false; } inline BOOL HasAllMemories(int iMemory) { if ((m_afMemory & iMemory) == iMemory) - return TRUE; - return FALSE; + return true; + return false; } BOOL ExitScriptedSequence(); diff --git a/src/game/server/bmodels.cpp b/src/game/server/bmodels.cpp index e66a1998..7d292f97 100644 --- a/src/game/server/bmodels.cpp +++ b/src/game/server/bmodels.cpp @@ -25,16 +25,16 @@ extern DLL_GLOBAL Vector g_vecAttackDir; -#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled -#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed -#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid. + // covering cheesy noise1, noise2, & noise3 fields so they make more sense (for rotating fans) + +//overloaded generic variable names #define noiseStart noise1 #define noiseStop noise2 #define noiseRunning noise3 -#define SF_PENDULUM_SWING 2 // spawnflag that makes a pendulum a rope swing. + // // BModelOrigin - calculates origin of a bmodel from absmin/size because all bmodel origins are 0 0 0 // @@ -79,7 +79,6 @@ void CFuncWall ::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use CScriptedEnt::Use(pActivator, pCaller, useType, value); } -#define SF_WALL_START_OFF 0x0001 class CFuncWallToggle : public CFuncWall { @@ -117,8 +116,8 @@ void CFuncWallToggle ::TurnOn(void) BOOL CFuncWallToggle ::IsOn(void) { if (pev->solid == SOLID_NOT) - return FALSE; - return TRUE; + return false; + return true; } void CFuncWallToggle ::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -135,9 +134,6 @@ void CFuncWallToggle ::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY CScriptedEnt::Use(pActivator, pCaller, useType, value); } -#define SF_CONVEYOR_VISUAL 0x0001 -#define SF_CONVEYOR_NOTSOLID 0x0002 -#define SF_CONVEYOR_TOGGLE 0x0004 //Thothie AUG2011_30 toggle conveyors class CFuncConveyor : public CFuncWall { @@ -241,7 +237,7 @@ void CFuncIllusionary ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "skin")) //skin is used for content type { pev->skin = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseToggle::KeyValue(pkvd); @@ -274,7 +270,7 @@ void CFuncIllusionary ::Spawn(void) // // ------------------------------------------------------------------------------- -#define SF_MONSTERCLIP_START_OFF 0x0001 + class CFuncMonsterClip : public CFuncWallToggle { @@ -338,9 +334,9 @@ void CFuncMonsterClip::TurnOn(void) BOOL CFuncMonsterClip::IsOn(void) { if (pev->flags & FL_MONSTERCLIP) - return TRUE; + return true; else - return FALSE; + return false; } // ------------------------------------------------------------------------------- @@ -352,7 +348,7 @@ BOOL CFuncMonsterClip::IsOn(void) // // ------------------------------------------------------------------------------- -#define SF_PLAYERCLIP_START_OFF 0x0001 + class CMSFuncPlayerClip : public CFuncWallToggle { @@ -426,9 +422,9 @@ void CMSFuncPlayerClip::TurnOn(void) BOOL CMSFuncPlayerClip::IsOn(void) { if (pev->solid & SOLID_TRIGGER) - return TRUE; + return true; else - return FALSE; + return false; } // ------------------------------------------------------------------------------- @@ -500,7 +496,7 @@ void CFuncRotating ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "fanfriction")) { m_flFanFriction = atof(pkvd->szValue) / 100; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "volume")) { @@ -510,7 +506,7 @@ void CFuncRotating ::KeyValue(KeyValueData *pkvd) m_flVolume = 1.0; if (m_flVolume < 0.0) m_flVolume = 0.0; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "spawnorigin")) { @@ -522,7 +518,7 @@ void CFuncRotating ::KeyValue(KeyValueData *pkvd) else if (FStrEq(pkvd->szKeyName, "sounds")) { m_sounds = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else BaseClass::KeyValue(pkvd); @@ -717,8 +713,8 @@ void CFuncRotating ::HurtTouch(CBaseEntity *pOther) // RampPitchVol - ramp pitch and volume up to final values, based on difference // between how fast we're going vs how fast we plan to go // -#define FANPITCHMIN 30 -#define FANPITCHMAX 100 +constexpr float FANPITCHMIN = 30; +constexpr float FANPITCHMAX = 100; void CFuncRotating ::RampPitchVol(int fUp) { @@ -787,7 +783,7 @@ void CFuncRotating ::SpinUp(void) } else { - RampPitchVol(TRUE); + RampPitchVol(true); } } @@ -828,7 +824,7 @@ void CFuncRotating ::SpinDown(void) } else { - RampPitchVol(FALSE); + RampPitchVol(false); } } @@ -923,8 +919,8 @@ class CPendulum : public CScriptedEnt float m_damp; float m_maxSpeed; float m_dampSpeed; - vec3_t m_center; - vec3_t m_start; + Vector m_center; + Vector m_start; }; LINK_ENTITY_TO_CLASS(func_pendulum, CPendulum); @@ -948,12 +944,12 @@ void CPendulum ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "distance")) { m_distance = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "damp")) { m_damp = atof(pkvd->szValue) * 0.001; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CScriptedEnt::KeyValue(pkvd); diff --git a/src/game/server/cdll_dll.h b/src/game/server/cdll_dll.h index 00519cee..665a0dfc 100644 --- a/src/game/server/cdll_dll.h +++ b/src/game/server/cdll_dll.h @@ -20,26 +20,30 @@ #ifndef CDLL_DLL_H #define CDLL_DLL_H -#define MAX_WEAPONS 32 // ??? +constexpr int MAX_WEAPONS = 32; // ??? +constexpr int MAX_NORMAL_BATTERY = 100; +constexpr int WEAPON_NOCLIP = -1; +constexpr int MAX_WEAPON_SLOTS = 5; // hud item selection slots +constexpr int MAX_ITEM_TYPES = 6; // hud item selection slots +constexpr int MAX_ITEMS = 5; // hard coded item types +constexpr int MAX_WEAPON_POSITIONS = MAX_WEAPON_SLOTS; + +enum { + HIDEHUD_WEAPONS = (1 << 0), + HIDEHUD_FLASHLIGHT = (1 << 1), + HIDEHUD_ALL = (1 << 2), + HIDEHUD_HEALTH = (1 << 3) +}; + +constexpr int MAX_AMMO_TYPES = 32;// ??? +constexpr int MAX_AMMO_SLOTS = 32;// not really slots + +enum { + HUD_PRINTNOTIFY = 1, + HUD_PRINTCONSOLE = 2, + HUD_PRINTTALK = 3, + HUD_PRINTCENTER = 4 +}; -#define MAX_WEAPON_SLOTS 5 // hud item selection slots -#define MAX_ITEM_TYPES 6 // hud item selection slots - -#define MAX_ITEMS 5 // hard coded item types - -#define HIDEHUD_WEAPONS (1 << 0) -#define HIDEHUD_FLASHLIGHT (1 << 1) -#define HIDEHUD_ALL (1 << 2) -#define HIDEHUD_HEALTH (1 << 3) - -#define MAX_AMMO_TYPES 32 // ??? -#define MAX_AMMO_SLOTS 32 // not really slots - -#define HUD_PRINTNOTIFY 1 -#define HUD_PRINTCONSOLE 2 -#define HUD_PRINTTALK 3 -#define HUD_PRINTCENTER 4 - -#define WEAPON_SUIT 31 #endif \ No newline at end of file diff --git a/src/game/server/client.cpp b/src/game/server/client.cpp index 42fd0743..31e53e1f 100644 --- a/src/game/server/client.cpp +++ b/src/game/server/client.cpp @@ -50,7 +50,7 @@ extern void PlayerPrecache(); // Temp -#define MAX_MONSTERS 5 +constexpr int MAX_MONSTERS = 5; int g_SummonedMonsters = 0; extern DLL_GLOBAL unsigned long g_ulModelIndexPlayer; @@ -186,6 +186,7 @@ void ClientDisconnect(edict_t *pEntity) // Try to get Steam ID from client info int iPlayerIndex = ENTINDEX(pEntity) - 1; + if (iPlayerIndex >= 0 && iPlayerIndex < gpGlobals->maxClients) { clientaddr_t &ClientInfo = g_NewClients[iPlayerIndex]; @@ -350,16 +351,16 @@ void Host_Say(edict_t *pEntity, int teamonly) } // make sure the text has content - char *pc = NULL; - for (pc = p; pc != NULL && *pc != 0; pc++) + char *pc = nullptr; + for (pc = p; pc != nullptr && *pc != 0; pc++) { if (isprint(*pc) && !isspace(*pc)) { - pc = NULL; // we've found an alphanumeric character, so text is valid + pc = nullptr; // we've found an alphanumeric character, so text is valid break; } } - if (pc != NULL) + if (pc != nullptr) return; // no character found, so say nothing // turn on color set 2 (color on, no sound) @@ -382,8 +383,8 @@ void Host_Say(edict_t *pEntity, int teamonly) // This may return the world in single player if the client types something between levels or during spawn // so check it, or it will infinite loop - client = NULL; - while (((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player")) != NULL) && (!FNullEnt(client->edict()))) + client = nullptr; + while (((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player")) != nullptr) && (!FNullEnt(client->edict()))) { if (!client->pev) continue; @@ -401,14 +402,14 @@ void Host_Say(edict_t *pEntity, int teamonly) if (teamonly && g_pGameRules->PlayerRelationship(client, CBaseEntity::Instance(pEntity)) != GR_TEAMMATE) continue; - MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, client->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, client->pev); WRITE_BYTE(ENTINDEX(pEntity)); WRITE_STRING(text); MESSAGE_END(); } // print to the sending client - MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, &pEntity->v); + MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, &pEntity->v); WRITE_BYTE(ENTINDEX(pEntity)); WRITE_STRING(text); MESSAGE_END(); @@ -511,8 +512,8 @@ void ClientCommand2(edict_t *pEntity) msstring Text = msstring(Args).find_str(" "); //skip the first parameter Text = Text.substr(1); - CBaseEntity* pGameMasterEnt = UTIL_FindEntityByString(NULL, "netname", msstring("-") + "game_master"); - IScripted* pGMScript = (pGameMasterEnt ? pGameMasterEnt->GetScripted() : NULL); + CBaseEntity* pGameMasterEnt = UTIL_FindEntityByString(nullptr, "netname", msstring("-") + "game_master"); + IScripted* pGMScript = (pGameMasterEnt ? pGameMasterEnt->GetScripted() : nullptr); if (pGMScript) { msstringlist Parameters; @@ -650,7 +651,7 @@ void ClientCommand2(edict_t *pEntity) if (CMD_ARGC() >= 3) { CBaseEntity *pEntity = StringToEnt(CMD_ARGV(1)); - IScripted *pScript = NULL; + IScripted *pScript = nullptr; if (pEntity && (pScript = pEntity->GetScripted())) { static msstringlist Params; @@ -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) { @@ -810,11 +811,11 @@ void ClientCommand2(edict_t *pEntity) //Stealing disabled //else if (FStrEq(pcmd, "steal")) - // pPlayer->StealAnyItems( NULL ); + // pPlayer->StealAnyItems( nullptr ); else if (FStrEq(pcmd, "getmenuoptions")) { - CMSMonster *pMonster = NULL; + CMSMonster *pMonster = nullptr; if (CMD_ARGC() >= 2) { @@ -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; @@ -993,7 +994,7 @@ void ClientCommand2(edict_t *pEntity) return; int ItemID = atoi(CMD_ARGV(2)); - genericitem_t *pStorageItem = NULL; + genericitem_t *pStorageItem = nullptr; int StorageItemIdx = 0; for (unsigned int i = 0; i < pStorage->Items.size(); i++) if (pStorage->Items[i].ID == ItemID) @@ -1111,7 +1112,7 @@ void ClientCommand2(edict_t *pEntity) //syntax: "drop " if (bCanUseInventory) { - CGenericItem *pItem = NULL; + CGenericItem *pItem = nullptr; if (CMD_ARGC() > 1) pItem = MSUtil_GetItemByID(atol(CMD_ARGV(1)), pPlayer); else @@ -1188,7 +1189,7 @@ void ClientCommand2(edict_t *pEntity) if( pItem->GiveTo( pPlayer, true, false ) ) { - MESSAGE_BEGIN( MSG_ONE, g_netmsg[NETMSG_PACK], NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, g_netmsg[NETMSG_PACK], nullptr, pPlayer->pev ); WRITE_BYTE( 1 ); WRITE_LONG( pItem->m_iId ); WRITE_BYTE( iHand + 1 ); @@ -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) @@ -1451,7 +1452,7 @@ void ClientCommand2(edict_t *pEntity) pAddToHand->iQuantity = vNewStackAmount; pItem->iQuantity -= vNewStackAmount; - MESSAGE_BEGIN(MSG_ONE, g_netmsg[NETMSG_ITEM], NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, g_netmsg[NETMSG_ITEM], nullptr, pPlayer->pev); WRITE_BYTE(1); SendGenericItem(pPlayer, pItem, false); MESSAGE_END(); @@ -1510,7 +1511,7 @@ void ClientCommand2(edict_t *pEntity) //#else /*if( IsGM(GETPLAYERWONID(pPlayer->edict())) ) pPlayer->m_fIsElite = !pPlayer->m_fIsElite; - else return FALSE;*/ + else return false;*/ // pPlayer->m_fIsElite = true; //#endif @@ -1520,7 +1521,7 @@ void ClientCommand2(edict_t *pEntity) pPlayer->SendInfoMsg("You are now Elite\n"); else pPlayer->SendInfoMsg("You are now Normal\n"); - MESSAGE_BEGIN(MSG_ONE, g_netmsg[NETMSG_CLDLLFUNC], NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, g_netmsg[NETMSG_CLDLLFUNC], nullptr, pPlayer->pev); WRITE_BYTE(7); WRITE_BYTE(pPlayer->m_fIsElite); MESSAGE_END(); @@ -1606,7 +1607,7 @@ void ClientCommand2(edict_t *pEntity) if (iProp > -1) { int value = atoi(CMD_ARGV(2)); - pStat->m_SubStats[iProp].Value = min(value, STATPROP_MAX_VALUE); + pStat->m_SubStats[iProp].Value = min(value, STAT_PROP_MAX_VALUE); } } } @@ -1618,7 +1619,7 @@ void ClientCommand2(edict_t *pEntity) int iSubStat = atoi(CMD_ARGV(2)); int value = atoi(CMD_ARGV(3)); if (iSubStat < (signed)pStat->m_SubStats.size()) - pStat->m_SubStats[iSubStat].Value = min(value, STATPROP_MAX_VALUE); + pStat->m_SubStats[iSubStat].Value = min(value, STAT_PROP_MAX_VALUE); } } } @@ -1725,14 +1726,14 @@ void ClientCommand2(edict_t *pEntity) ClearBits(pPlayer->m_afPhysicsFlags, PFLAG_OBSERVER); ClearBits(pPlayer->pev->flags, FL_NOTARGET); //pPlayer->SetSpeed( 0 ); - MESSAGE_BEGIN(MSG_ONE, gmsgHideWeapon, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgHideWeapon, nullptr, pPlayer->pev); WRITE_BYTE(0); MESSAGE_END(); } break; case 1: - //pPlayer->RemoveAllItems( FALSE, TRUE ); - MESSAGE_BEGIN(MSG_ONE, gmsgHideWeapon, NULL, pPlayer->pev); + //pPlayer->RemoveAllItems( false, true ); + MESSAGE_BEGIN(MSG_ONE, gmsgHideWeapon, nullptr, pPlayer->pev); WRITE_BYTE(HIDEHUD_ALL); MESSAGE_END(); //--- NO BREAK --- @@ -1788,7 +1789,7 @@ void ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) { char text[256]; _snprintf(text, sizeof(text), "* %s prefers the name %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); - MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); + MESSAGE_BEGIN( MSG_ALL, gmsgSayText, nullptr ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); MESSAGE_END(); @@ -1921,7 +1922,7 @@ void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) // If not found via global, search by netname if (!pGameMasterEnt) { - pGameMasterEnt = UTIL_FindEntityByString(NULL, "netname", msstring("-") + "game_master"); + pGameMasterEnt = UTIL_FindEntityByString(nullptr, "netname", msstring("-") + "game_master"); if (pGameMasterEnt) { MS_INFO("Game master found via search at index %d", pGameMasterEnt->entindex()); @@ -1947,7 +1948,7 @@ void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) MS_INFO("ServerActivate event fired successfully"); // After ServerActivate, try to find the game_master again - pGameMasterEnt = UTIL_FindEntityByString(NULL, "netname", msstring("-") + "game_master"); + pGameMasterEnt = UTIL_FindEntityByString(nullptr, "netname", msstring("-") + "game_master"); if (pGameMasterEnt) { MS_INFO("Game master created by AngelScript at index %d", pGameMasterEnt->entindex()); @@ -1971,7 +1972,7 @@ void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) } else { - CBaseEntity* pGameMasterEnt = UTIL_FindEntityByString(NULL, "netname", msstring("-") + "game_master"); + CBaseEntity* pGameMasterEnt = UTIL_FindEntityByString(nullptr, "netname", msstring("-") + "game_master"); if (!pGameMasterEnt) { MS_INFO("Creating legacy game master"); @@ -2197,7 +2198,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; @@ -2324,8 +2325,8 @@ void SetupVisibility(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs if (pClient->v.flags & FL_PROXY) { - *pvs = NULL; // the spectator proxy sees - *pas = NULL; // and hears everything + *pvs = nullptr; // the spectator proxy sees + *pas = nullptr; // and hears everything return; } @@ -2591,7 +2592,7 @@ int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *ho } // defaults for clientinfo messages -#define DEFAULT_VIEWHEIGHT 28 +constexpr int DEFAULT_VIEWHEIGHT = 28; /* =================== @@ -2600,7 +2601,7 @@ CreateBaseline Creates baselines used for network encoding, especially for player data since players are not spawned until connect time. =================== */ -void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs) +void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, Vector player_mins, Vector player_maxs) { baseline->origin = entity->v.origin; baseline->angles = entity->v.angles; @@ -2848,15 +2849,17 @@ void Player_Encode(struct delta_s *pFields, const unsigned char *from, const uns } } -#define CUSTOMFIELD_ORIGIN0 0 -#define CUSTOMFIELD_ORIGIN1 1 -#define CUSTOMFIELD_ORIGIN2 2 -#define CUSTOMFIELD_ANGLES0 3 -#define CUSTOMFIELD_ANGLES1 4 -#define CUSTOMFIELD_ANGLES2 5 -#define CUSTOMFIELD_SKIN 6 -#define CUSTOMFIELD_SEQUENCE 7 -#define CUSTOMFIELD_ANIMTIME 8 +enum { + CUSTOMFIELD_ORIGIN0 = 0, + CUSTOMFIELD_ORIGIN1 = 1, + CUSTOMFIELD_ORIGIN2 = 2, + CUSTOMFIELD_ANGLES0 = 3, + CUSTOMFIELD_ANGLES1 = 4, + CUSTOMFIELD_ANGLES2 = 5, + CUSTOMFIELD_SKIN = 6, + CUSTOMFIELD_SEQUENCE = 7, + CUSTOMFIELD_ANIMTIME = 8 +}; entity_field_alias_t custom_entity_field_alias[] = { diff --git a/src/game/server/effects.cpp b/src/game/server/effects.cpp index f4b8a2c8..ab671feb 100644 --- a/src/game/server/effects.cpp +++ b/src/game/server/effects.cpp @@ -21,9 +21,6 @@ #include "func_break.h" #include "shake.h" -#define SF_GIBSHOOTER_REPEATABLE 1 // allows a gibshooter to be refired - -#define SF_FUNNEL_REVERSE 1 // funnel effect repels particles instead of attracting them. // Lightning target, just alias landmark LINK_ENTITY_TO_CLASS(info_target, CPointEntity); @@ -62,7 +59,6 @@ TYPEDESCRIPTION CBubbling::m_SaveData[] = IMPLEMENT_SAVERESTORE(CBubbling, CBaseEntity); -#define SF_BUBBLES_STARTOFF 0x0001 void CBubbling::Spawn(void) { @@ -116,17 +112,17 @@ void CBubbling::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "density")) { m_density = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "frequency")) { m_frequency = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "current")) { pev->speed = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); @@ -365,8 +361,8 @@ class CLightning : public CBeam inline BOOL ServerSide(void) { if (m_life == 0 && !(pev->spawnflags & SF_BEAM_RING)) - return TRUE; - return FALSE; + return true; + return false; } virtual int Save(CSave &save); @@ -496,57 +492,57 @@ void CLightning::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "LightningStart")) { m_iszStartEntity = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "LightningEnd")) { m_iszEndEntity = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "life")) { m_life = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "BoltWidth")) { m_boltWidth = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude")) { m_noiseAmplitude = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "TextureScroll")) { m_speed = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "StrikeTime")) { m_restrike = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "texture")) { m_iszSpriteName = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "framestart")) { m_frameStart = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "Radius")) { m_radius = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "damage")) { pev->dmg = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBeam::KeyValue(pkvd); @@ -847,8 +843,8 @@ void CLightning::BeamUpdateVars(void) int beamType; int pointStart, pointEnd; - edict_t *pStart = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszStartEntity)); - edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEndEntity)); + edict_t *pStart = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_iszStartEntity)); + edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_iszEndEntity)); pointStart = IsPointEntity(CBaseEntity::Instance(pStart)); pointEnd = IsPointEntity(CBaseEntity::Instance(pEnd)); @@ -933,7 +929,7 @@ void CLaser::Spawn(void) PointsInit(pev->origin, pev->origin); if (!m_pSprite && m_iszSpriteName) - m_pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteName), pev->origin, TRUE); + m_pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteName), pev->origin, true); else m_pSprite = NULL; @@ -958,42 +954,42 @@ void CLaser::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "LaserTarget")) { pev->message = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "width")) { SetWidth(atof(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude")) { SetNoise(atoi(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "TextureScroll")) { SetScrollRate(atoi(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "texture")) { pev->model = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "EndSprite")) { m_iszSpriteName = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "framestart")) { pev->frame = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "damage")) { pev->dmg = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBeam::KeyValue(pkvd); @@ -1352,22 +1348,22 @@ void CGibShooter::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "m_iGibs")) { m_iGibs = m_iGibCapacity = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_flVelocity")) { m_flGibVelocity = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_flVariance")) { m_flVariance = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_flGibLife")) { m_flGibLife = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else { @@ -1488,12 +1484,12 @@ void CEnvShooter ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "shootmodel")) { pev->model = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "shootsounds")) { int iNoise = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; switch (iNoise) { case 0: @@ -1678,11 +1674,6 @@ class CBlood : public CPointEntity LINK_ENTITY_TO_CLASS(env_blood, CBlood); -#define SF_BLOOD_RANDOM 0x0001 -#define SF_BLOOD_STREAM 0x0002 -#define SF_BLOOD_PLAYER 0x0004 -#define SF_BLOOD_DECAL 0x0008 - void CBlood::Spawn(void) { pev->solid = SOLID_NOT; @@ -1707,12 +1698,12 @@ void CBlood::KeyValue(KeyValueData *pkvd) break; } - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "amount")) { SetBloodAmount(atof(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CPointEntity::KeyValue(pkvd); @@ -1794,10 +1785,7 @@ LINK_ENTITY_TO_CLASS(env_shake, CShake); // radius of 0 means all players // NOTE: UTIL_ScreenShake() will only shake players who are on the ground -#define SF_SHAKE_EVERYONE 0x0001 // Don't check radius -// UNDONE: These don't work yet -#define SF_SHAKE_DISRUPT 0x0002 // Disrupt controls -#define SF_SHAKE_INAIR 0x0004 // Shake players in air + void CShake::Spawn(void) { @@ -1815,22 +1803,22 @@ void CShake::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "amplitude")) { SetAmplitude(atof(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "frequency")) { SetFrequency(atof(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "duration")) { SetDuration(atof(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "radius")) { SetRadius(atof(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CPointEntity::KeyValue(pkvd); @@ -1861,9 +1849,6 @@ LINK_ENTITY_TO_CLASS(env_fade, CFade); // pev->dmg_take is duration // pev->dmg_save is hold duration -#define SF_FADE_IN 0x0001 // Fade in, not out -#define SF_FADE_MODULATE 0x0002 // Modulate, don't blend -#define SF_FADE_ONLYONE 0x0004 void CFade::Spawn(void) { @@ -1878,12 +1863,12 @@ void CFade::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "duration")) { SetDuration(atof(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "holdtime")) { SetHoldTime(atof(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CPointEntity::KeyValue(pkvd); @@ -1970,17 +1955,17 @@ void CMessage::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "messagesound")) { pev->noise = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "messagevolume")) { pev->scale = atof(pkvd->szValue) * 0.1; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "messageattenuation")) { pev->impulse = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CPointEntity::KeyValue(pkvd); diff --git a/src/game/server/effects/mseffects.cpp b/src/game/server/effects/mseffects.cpp index a0432398..43c38a10 100644 --- a/src/game/server/effects/mseffects.cpp +++ b/src/game/server/effects/mseffects.cpp @@ -5,6 +5,9 @@ #include "ms/angelscript/CAngelScriptManager.h" // For AngelScript map transitions //#include "monsters/bodyparts/bodyparts.h" +#include "player.h" + + void UTIL_ScreenFadeBuild(ScreenFade &fade, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags); void UTIL_ScreenFadeWrite(const ScreenFade &fade, CBaseEntity *pEntity); @@ -114,7 +117,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 +147,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,13 +169,12 @@ 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(); } LINK_ENTITY_TO_CLASS(ms_torchlight, CTorchLight); -#include "player.h" class CChangePlayerSpeed : public CBaseDelay { @@ -231,7 +233,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 +269,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) { @@ -293,7 +295,7 @@ void CChangePlayerSpeed ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "duration")) { m_Duration = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); @@ -306,7 +308,7 @@ CEntGlow *CEntGlow::Create(CBaseEntity *pTarget, Vector Color, float Amount, flo pGlowEnt->m_Target = pTarget; pGlowEnt->m_Color = Color; pGlowEnt->m_Amount = Amount; - pGlowEnt->m_CurentAmount = pGlowEnt->m_Amount; + pGlowEnt->m_CurrentAmount = pGlowEnt->m_Amount; pGlowEnt->m_Duration = Duration; pGlowEnt->m_FadeDuration = FadeDuration; pGlowEnt->m_StartTime = gpGlobals->time; @@ -340,7 +342,7 @@ void CEntGlow::SetGlow(bool On) { pEntity->pev->renderfx = kRenderFxGlowShell; pEntity->pev->rendercolor = m_Color; - pEntity->pev->renderamt = m_CurentAmount; + pEntity->pev->renderamt = m_CurrentAmount; } } else @@ -381,7 +383,7 @@ void CEntGlow::Think() if (FadeAmt > 1) FadeAmt = 1; - m_CurentAmount = m_Amount * (1 - FadeAmt); + m_CurrentAmount = m_Amount * (1 - FadeAmt); SetGlow(true); pev->nextthink = gpGlobals->time; //MiB } @@ -445,12 +447,12 @@ class CMSChangeLevel : public CBaseEntity if (FStrEq(pkvd->szKeyName, "destmap")) { sDestMap = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "desttrans")) { sDestTrans = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); @@ -458,12 +460,24 @@ class CMSChangeLevel : public CBaseEntity }; LINK_ENTITY_TO_CLASS(mstrig_changelevel, CMSChangeLevel); -#define REQPARAMS(a) \ - if (Params.size() < a) \ - { \ - ALERT(at_console, "Script: %s, effect '%s' missing parameters!\n", m.ScriptFile.c_str(), Params[0].c_str()); \ - return; \ + +bool REQPARAMS(msstring& ScriptFileName, msstringlist& Params, unsigned int count) { + + if (Params.size() < count) { + ALERT(at_console, "Script: %s, effect '%s' missing parameters!\n", ScriptFileName.c_str(), Params[0].c_str()); + return false; } + else return true; +} + +//#define REQPARAMS(a) +// if (Params.size() < a) +// { +// ALERT(at_console, "Script: %s, effect '%s' missing parameters!\n", m.ScriptFile.c_str(), Params[0].c_str()); +// return; +// } +// + void CScript::ScriptedEffect(msstringlist &Params) { @@ -500,7 +514,11 @@ void CScript::ScriptedEffect(msstringlist &Params) if (Params[0] == "beam") { - REQPARAMS(4); + + if (!REQPARAMS(m.ScriptFile, Params, 4)) { + return; + } + int Type = 0; if (Params[1] == "end") Type = 0; @@ -720,17 +738,23 @@ void CScript::ScriptedEffect(msstringlist &Params) if (Params[1] == "gibs") { Type = 0; - REQPARAMS(9); + if (!REQPARAMS(m.ScriptFile, Params, 9)) { + return; + } } else if (Params[1] == "spray") { Type = 1; - REQPARAMS(8); + if (!REQPARAMS(m.ScriptFile, Params, 8)) { + return; + } } else if (Params[1] == "trail") { Type = 2; - REQPARAMS(10); + if (!REQPARAMS(m.ScriptFile, Params, 10)) { + return; + } } const char* ModelName = GetFullResourceName(Params[2]); @@ -850,7 +874,9 @@ void CScript::ScriptedEffect(msstringlist &Params) } else if (Params[0] == "screenshake") { - REQPARAMS(6); + if (!REQPARAMS(m.ScriptFile, Params, 6)) { + return; + } Vector Origin = StringToVec(Params[1]); float Amplitude = atof(Params[2]); @@ -864,7 +890,9 @@ void CScript::ScriptedEffect(msstringlist &Params) { //Thothie APR2016_08 - allow screen shake vs. single client //effect screenshake_one - REQPARAMS(5); + if (!REQPARAMS(m.ScriptFile, Params, 5)) { + return; + } CBaseEntity* pEntity = (m.pScriptedEnt ? m.pScriptedEnt->RetrieveEntity(Params[1]) : NULL); if (pEntity && pEntity->IsPlayer()) { @@ -909,7 +937,9 @@ void CScript::ScriptedEffect(msstringlist &Params) } else if (Params[0] == "glow") { - REQPARAMS(6); + if (!REQPARAMS(m.ScriptFile, Params, 6)) { + return; + } CBaseEntity *pTarget = m.pScriptedEnt->RetrieveEntity(Params[1]); if (!pTarget) diff --git a/src/game/server/effects/mseffects.h b/src/game/server/effects/mseffects.h index e4a67ce0..8d402909 100644 --- a/src/game/server/effects/mseffects.h +++ b/src/game/server/effects/mseffects.h @@ -1,3 +1,16 @@ + + + + +#ifndef EFFECTS_H +#include "effects.h" +#endif // !EFFECTS_H + + + +constexpr int SPRITE_TORCH = 1; +constexpr int TORCH_LIGHTS = 2; + class CPortal : public CBaseEntity { public: @@ -8,9 +21,6 @@ class CPortal : public CBaseEntity void CloseSpawnPortal(void); }; -#define SPRITE_TORCH 1 - -#include "effects.h" class CMSSprite : public CSprite { @@ -22,7 +32,7 @@ class CMSSprite : public CSprite void Think(); }; -#define TORCH_LIGHTS 2 + class CTorchLight : public CBaseEntity { @@ -47,9 +57,12 @@ class CEntGlow : public CBaseEntity void SetGlow(bool On); entityinfo_t m_Target; - float m_Amount, m_CurentAmount; + float m_Amount, m_CurrentAmount; float m_StartTime; float m_Duration; float m_FadeDuration; Vector m_Color; }; + + +bool REQPARAMS(msstring& ScriptFileName, msstringlist& Params, unsigned int count); \ No newline at end of file diff --git a/src/game/server/enginecallback.h b/src/game/server/enginecallback.h index 24aaf5a7..4829bebc 100644 --- a/src/game/server/enginecallback.h +++ b/src/game/server/enginecallback.h @@ -22,7 +22,7 @@ extern enginefuncs_t g_engfuncs; extern unsigned int g_iNumBytesWritten; extern int g_iUserMessageType; -#define MAX_USERMESSAGE_SIZE 192 +inline constexpr int MAX_USERMESSAGE_SIZE = 192; // The actual engine callbacks #define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId) @@ -41,7 +41,12 @@ void SET_MODEL( edict_t *e, const char *szModel ); #define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms) #define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms) #define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw) -#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles) +//#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles) + +inline void VEC_TO_ANGLES(const float* rgflVectorIn, float* rgflVectorOut ) { + g_engfuncs.pfnVecToAngles(rgflVectorIn, rgflVectorOut); +} + #define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin) #define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw) #define CHANGE_PITCH (*g_engfuncs.pfnChangePitch) @@ -72,9 +77,41 @@ void SET_MODEL( edict_t *e, const char *szModel ); #define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer) #define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte) #define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final) -#define RANDOM_LONG (*g_engfuncs.pfnRandomLong) -#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) -#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) +//#define RANDOM_LONG (*g_engfuncs.pfnRandomLong) +//#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) +//#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) + +template +int32 RANDOM_LONG(const Type1 &lLow, const Type2 &lHigh) { + + if (lLow > lHigh) { + return g_engfuncs.pfnRandomLong(static_cast(lHigh), static_cast(lLow)); + } + + return g_engfuncs.pfnRandomLong(static_cast(lLow), static_cast(lHigh)); + + +} + + +template +float RANDOM_FLOAT(const Type1 &flLow, const Type2 &flHigh) { + + if (flLow > flHigh) { + return g_engfuncs.pfnRandomFloat( static_cast(flHigh), static_cast(flLow) ); + } + + return g_engfuncs.pfnRandomFloat(static_cast(flLow), static_cast(flHigh)); + +} + + +inline const char* GETPLAYERAUTHID(edict_t* e) { + return g_engfuncs.pfnGetPlayerAuthId(e); +} + + +//undoing this would just invite more macros, will keep this and any others that user variadic args / fmt #define ALERT (*g_engfuncs.pfnAlertMessage) //MIB JUN2010_17 - enable total disable of debug alert messages @@ -160,10 +197,10 @@ inline void WRITE_STRING(const char* sz) } #ifdef VALVE_DLL -#define WRITE_STRING_MAX 180 // Upper limit for a usermessage is around 192 bytes, keep this in mind! +constexpr unsigned int 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) @@ -188,7 +225,12 @@ inline void *GET_PRIVATE(edict_t *pent) int ALLOC_STRING(const char *szValue); //Master Sword - Keep track of all string allocations on server void ClearStringPool(); #else -#define ALLOC_STRING (*g_engfuncs.pfnAllocString) + +inline unsigned int ALLOC_STRING(const char* szValue) { + return g_engfuncs.pfnAllocString(szValue); +} + +//#define ALLOC_STRING (*g_engfuncs.pfnAllocString) #endif #define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString) 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/fn/FNSharedDefs.cpp b/src/game/server/fn/FNSharedDefs.cpp index bb94b51f..f8e493fc 100644 --- a/src/game/server/fn/FNSharedDefs.cpp +++ b/src/game/server/fn/FNSharedDefs.cpp @@ -20,7 +20,7 @@ #include "LoadCharacterReq.h" #include "DeleteCharacterReq.h" -#define STRING_BUFFER 1024 +constexpr unsigned int STRING_BUFFER = 1024; // AsyncSendRequest does not make use the connection pooling. // Frequent requests should make use the RequestManager to take advantage of @@ -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..c6285423 100644 --- a/src/game/server/func_break.cpp +++ b/src/game/server/func_break.cpp @@ -64,12 +64,12 @@ void CBreakable::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "scriptevent")) { m_scriptevent = pkvd->szValue; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "killtarget")) { m_iszKillTarget = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // UNDONE_WC: explicitly ignoring these fields, but they shouldn't be in the map file! @@ -82,7 +82,7 @@ void CBreakable::KeyValue(KeyValueData *pkvd) else m_Explosion = expRandom; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "material")) { @@ -95,21 +95,21 @@ void CBreakable::KeyValue(KeyValueData *pkvd) else m_Material = (Materials)i; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "deadmodel")) { - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "shards")) { // m_iShards = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "gibmodel")) { m_iszGibModel = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "spawnobject")) { @@ -117,16 +117,16 @@ void CBreakable::KeyValue(KeyValueData *pkvd) //if ( object > 0 && object < ARRAYSIZE(pSpawnObjects) ) // m_iszSpawnObject = MAKE_STRING( pSpawnObjects[object] ); - //pkvd->fHandled = TRUE; + //pkvd->fHandled = true; CBaseDelay::KeyValue(pkvd); } else if (FStrEq(pkvd->szKeyName, "explodemagnitude")) { ExplosionSetMagnitude(atoi(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "lip")) - pkvd->fHandled = TRUE; + pkvd->fHandled = true; else CBaseDelay::KeyValue(pkvd); } @@ -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()); @@ -651,7 +651,7 @@ void CBreakable::Die(void) { Vector vecSpot; // shard origin Vector vecVelocity; // shard velocity - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; char cFlag = 0; int pitch; float fvol; @@ -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; @@ -826,7 +826,7 @@ void CBreakable::Die(void) if (Explodable()) { - ExplosionCreate(Center(), pev->angles, edict(), ExplosionMagnitude(), TRUE); + ExplosionCreate(Center(), pev->angles, edict(), ExplosionMagnitude(), true); } } @@ -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) @@ -927,7 +927,7 @@ void CPushable ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "size")) { int bbox = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; switch (bbox) { @@ -952,7 +952,7 @@ void CPushable ::KeyValue(KeyValueData *pkvd) else if (FStrEq(pkvd->szKeyName, "buoyancy")) { pev->skin = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBreakable::KeyValue(pkvd); diff --git a/src/game/server/gamerules/gamerules.cpp b/src/game/server/gamerules/gamerules.cpp index c10a19c5..91101ddf 100644 --- a/src/game/server/gamerules/gamerules.cpp +++ b/src/game/server/gamerules/gamerules.cpp @@ -35,7 +35,7 @@ extern int gmsgMOTD; //========================================================= BOOL CGameRules::CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry) { - return FALSE; + return false; } //========================================================= @@ -51,7 +51,7 @@ edict_t *CGameRules ::GetPlayerSpawnSpot(CBasePlayer *pPlayer) { // only living players can have items if ( pPlayer->pev->deadflag != DEAD_NO ) - return FALSE; + return false; if ( pWeapon->pszAmmo1() ) { @@ -61,7 +61,7 @@ edict_t *CGameRules ::GetPlayerSpawnSpot(CBasePlayer *pPlayer) // have the gun if we aren't already carrying one of this type if ( pPlayer->HasPlayerItem( pWeapon ) ) { - return FALSE; + return false; } } } @@ -70,12 +70,12 @@ edict_t *CGameRules ::GetPlayerSpawnSpot(CBasePlayer *pPlayer) // weapon doesn't use ammo, don't take another if you already have it. if ( pPlayer->HasPlayerItem( pWeapon ) ) { - return FALSE; + return false; } } // note: will fall through to here if GetItemInfo doesn't fill the struct! - return TRUE; + return true; }*/ //========================================================= diff --git a/src/game/server/gamerules/gamerules.h b/src/game/server/gamerules/gamerules.h index 40eb1cce..3ce7856e 100644 --- a/src/game/server/gamerules/gamerules.h +++ b/src/game/server/gamerules/gamerules.h @@ -70,7 +70,7 @@ class CGameRules // Functions to verify the single/multiplayer status of a game virtual BOOL IsMultiplayer(void) = 0; // is this a multiplayer game? (either coop or deathmatch) virtual BOOL IsDeathmatch(void) = 0; //is this a deathmatch game? - virtual BOOL IsTeamplay(void) { return FALSE; }; // is this deathmatch game being played with team rules? + virtual BOOL IsTeamplay(void) { return false; }; // is this deathmatch game being played with team rules? virtual BOOL IsCoOp(void) = 0; // is this a coop game? virtual const char *GetGameDescription(void) { return "Half-Life"; } // this is the game name that gets seen in the server browser @@ -82,8 +82,8 @@ class CGameRules // Client damage rules virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0; // this client just hit the ground after a fall. How much damage? - virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) { return TRUE; }; // can this player take damage from this attacker? - virtual BOOL ShouldAutoAim(CBasePlayer *pPlayer, edict_t *target) { return TRUE; } + virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) { return true; }; // can this player take damage from this attacker? + virtual BOOL ShouldAutoAim(CBasePlayer *pPlayer, edict_t *target) { return true; } // Client spawn/respawn control virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; // called by CBasePlayer::Spawn just before releasing player into the game @@ -92,8 +92,8 @@ class CGameRules virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0; // When in the future will this player be able to spawn? virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer); // Place this player on their spawnspot and face them the proper direction. - virtual BOOL AllowAutoTargetCrosshair(void) { return TRUE; }; - virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) { return FALSE; }; // handles the user commands; returns TRUE if command handled properly + virtual BOOL AllowAutoTargetCrosshair(void) { return true; }; + virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) { return false; }; // handles the user commands; returns true if command handled properly virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) {} // the player has changed userinfo; can change it now // Client kills/scoring @@ -144,13 +144,13 @@ class CGameRules virtual int PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget) = 0; // What is the player's relationship with this entity? virtual int GetTeamIndex(const char *pTeamName) { return -1; } virtual const char *GetIndexedTeamName(int teamIndex) { return ""; } - virtual BOOL IsValidTeam(const char *pTeamName) { return TRUE; } + virtual BOOL IsValidTeam(const char *pTeamName) { return true; } virtual void ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib) {} virtual const char *SetDefaultPlayerTeam(CBasePlayer *pPlayer) { return ""; } // Sounds - virtual BOOL PlayTextureSounds(void) { return TRUE; } - virtual BOOL PlayFootstepSounds(CBasePlayer *pl, float fvol) { return TRUE; } + virtual BOOL PlayTextureSounds(void) { return true; } + virtual BOOL PlayFootstepSounds(CBasePlayer *pl, float fvol) { return true; } // Monsters virtual BOOL FAllowMonsters(void) = 0; //are monsters allowed @@ -173,7 +173,7 @@ class CHalfLifeRules : public CGameRules // GR_Think virtual void Think(void); virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity); - virtual BOOL FAllowFlashlight(void) { return TRUE; }; + virtual BOOL FAllowFlashlight(void) { return true; }; virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon); diff --git a/src/game/server/gamerules/multiplay_gamerules.cpp b/src/game/server/gamerules/multiplay_gamerules.cpp index 677f3eca..0bed2c09 100644 --- a/src/game/server/gamerules/multiplay_gamerules.cpp +++ b/src/game/server/gamerules/multiplay_gamerules.cpp @@ -34,6 +34,9 @@ #include "trains.h" // for CFuncVehicle #include +#ifndef DOORS_H +#include "doors.h" +#endif #include #include #include @@ -48,12 +51,12 @@ extern int gmsgMOTD; bool CheckBanned(const char* SteamID ); //float g_TimeTryValidate = 0.0f; -#define VALIDATE_DELAY (60 * 30)// 30 mins +constexpr int VALIDATE_DELAY = (60 * 30);// 30 mins float g_ServerResetTimer = 0.0f; -#define ITEM_RESPAWN_TIME 30 -#define WEAPON_RESPAWN_TIME 20 -#define AMMO_RESPAWN_TIME 20 +constexpr int ITEM_RESPAWN_TIME = 30; +constexpr int WEAPON_RESPAWN_TIME = 20; +constexpr int AMMO_RESPAWN_TIME = 20; CVoiceGameMgr g_VoiceGameMgr; @@ -136,7 +139,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 ); @@ -153,8 +156,7 @@ void CHalfLifeMultiplay::RefreshSkillData( void ) } // longest the intermission can last, in seconds -#define MAX_INTERMISSION_TIME 120 - +constexpr int MAX_INTERMISSION_TIME = 120; //Master Sword //bool CheckData( ); //------------ @@ -261,14 +263,14 @@ bool CHalfLifeMultiplay::IsAnyPlayerAllowedInMap() //========================================================= BOOL CHalfLifeMultiplay::IsMultiplayer( void ) { - return TRUE; + return true; } //========================================================= //========================================================= BOOL CHalfLifeMultiplay::IsDeathmatch( void ) { - return TRUE; + return true; } //========================================================= @@ -285,33 +287,33 @@ BOOL CHalfLifeMultiplay::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerI if ( !pWeapon->CanDeploy() ) { // that weapon can't deploy anyway. - return FALSE; + return false; } if ( !pPlayer->m_pActiveItem ) { // player doesn't have an active item! - return TRUE; + return true; } if ( !pPlayer->m_pActiveItem->CanHolster() ) { // can't put away the active item. - return FALSE; + return false; } if ( pWeapon->iWeight() > pPlayer->m_pActiveItem->iWeight() ) { - return TRUE; + return true; } - return FALSE; + return false; } BOOL CHalfLifeMultiplay::GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { //Function unused - return FALSE; + return false; } //========================================================= @@ -326,12 +328,12 @@ BOOL CHalfLifeMultiplay::ClientConnected(edict_t *pEntity, const char *pszName, if( CheckBanned( AuthID ) ) { strncpy(szRejectReason, "You are BANNED\n", 128); - return FALSE; + return false; } g_ServerResetTimer = NULL; - return TRUE; + return true; } extern int gmsgSayText; @@ -364,7 +366,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(int i = 1; i < gpGlobals->maxEntities; i++ ) { pEdict = g_engfuncs.pfnPEntityOfEntIndex( i ); @@ -394,7 +396,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 (int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pOtherPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); if( !pOtherPlayer ) continue; @@ -474,7 +476,7 @@ float CHalfLifeMultiplay::FlPlayerFallDamage( CBasePlayer *pPlayer ) { case 1://progressive pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED; - return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED; + return pPlayer->m_flFallVelocity * PLAYER_DAMAGE_FOR_FALL_SPEED; break; default: case 0:// fixed @@ -487,7 +489,7 @@ float CHalfLifeMultiplay::FlPlayerFallDamage( CBasePlayer *pPlayer ) //========================================================= BOOL CHalfLifeMultiplay::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) { - return TRUE; + return true; } //========================================================= @@ -498,7 +500,7 @@ void CHalfLifeMultiplay::PlayerThink( CBasePlayer *pPlayer ) { // check for button presses if ( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) ) - m_iEndIntermissionButtonHit = TRUE; + m_iEndIntermissionButtonHit = true; // clear attack/use commands from player pPlayer->m_afButtonPressed = 0; @@ -518,7 +520,7 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer ) //========================================================= BOOL CHalfLifeMultiplay::FPlayerCanRespawn( CBasePlayer *pPlayer ) { - return TRUE; + return true; } //========================================================= @@ -530,7 +532,7 @@ float CHalfLifeMultiplay::FlPlayerSpawnTime( CBasePlayer *pPlayer ) BOOL CHalfLifeMultiplay::AllowAutoTargetCrosshair( void ) { - return FALSE; + return false; } //========================================================= @@ -772,7 +774,7 @@ float CHalfLifeMultiplay::FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) // when we are within this close to running out of entities, items // marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn -#define ENTITY_INTOLERANCE 100 +constexpr int ENTITY_INTOLERANCE = 100; //========================================================= // FlWeaponRespawnTime - Returns 0 if the weapon can respawn @@ -783,7 +785,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 (NUMBER_OF_ENTITIES() < (gpGlobals->maxEntities - ENTITY_INTOLERANCE) ) return 0; // we're past the entity tolerance level, so delay the respawn @@ -817,7 +819,7 @@ int CHalfLifeMultiplay::WeaponShouldRespawn( CBasePlayerItem *pWeapon ) } //========================================================= -// CanHaveWeapon - returns FALSE if the player is not allowed +// CanHaveWeapon - returns false if the player is not allowed // to pick up this weapon //========================================================= /*BOOL CHalfLifeMultiplay::CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pItem ) @@ -836,7 +838,7 @@ int CHalfLifeMultiplay::WeaponShouldRespawn( CBasePlayerItem *pWeapon ) { if ( it->m_iId == pItem->m_iId ) { - return FALSE; + return false; } it = it->m_pNext; @@ -851,7 +853,7 @@ int CHalfLifeMultiplay::WeaponShouldRespawn( CBasePlayerItem *pWeapon ) //========================================================= BOOL CHalfLifeMultiplay::CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ) { - return TRUE; + return true; } //========================================================= @@ -900,7 +902,7 @@ void CHalfLifeMultiplay::PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int //========================================================= BOOL CHalfLifeMultiplay::IsAllowedToSpawn( CBaseEntity *pEntity ) { - return TRUE; + return true; } //========================================================= @@ -973,30 +975,30 @@ int CHalfLifeMultiplay::PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *p BOOL CHalfLifeMultiplay::PlayFootstepSounds( CBasePlayer *pl, float fvol ) { if ( g_footsteps && g_footsteps->value == 0 ) - return FALSE; + return false; if ( pl->IsOnLadder() || pl->pev->velocity.Length2D() > 220 ) - return TRUE; // only make step sounds in multiplayer if the player is moving fast enough + return true; // only make step sounds in multiplayer if the player is moving fast enough - return FALSE; + return false; } BOOL CHalfLifeMultiplay::FAllowFlashlight( void ) { - return FALSE; + return false; } //========================================================= //========================================================= BOOL CHalfLifeMultiplay::FAllowMonsters( void ) { - return TRUE; + return true; //return ( CVAR_GET_FLOAT( "mp_allowmonsters" ) != 0 ); } //========================================================= //======== CHalfLifeMultiplay private functions =========== -#define INTERMISSION_TIME 6 +constexpr int INTERMISSION_TIME = 6; void CHalfLifeMultiplay::GoToIntermission( void ) { @@ -1007,18 +1009,17 @@ void CHalfLifeMultiplay::GoToIntermission( void ) MESSAGE_END(); m_flIntermissionEndTime = gpGlobals->time + INTERMISSION_TIME; - g_fGameOver = TRUE; - m_iEndIntermissionButtonHit = FALSE; + g_fGameOver = true; + m_iEndIntermissionButtonHit = false; } - -#define MAX_RULE_BUFFER 1024 +constexpr int MAX_RULE_BUFFER = 1024; typedef struct mapcycle_item_s { struct mapcycle_item_s *next; char mapname[ 32 ]; - int minplayers, maxplayers; + int minplayers, maxplayers; char rulebuffer[ MAX_RULE_BUFFER ]; } mapcycle_item_t; @@ -1214,6 +1215,7 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) item->minplayers = 0; item->maxplayers = 0; + int Minimum = 0; memset( item->rulebuffer, 0, MAX_RULE_BUFFER ); @@ -1223,14 +1225,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 +1338,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,8 +1419,8 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) int minplayers = 0, maxplayers = 0; strncpy(szFirstMapInList, "edana", sizeof(szFirstMapInList)); // the absolute default level is edana - int curplayers; - BOOL do_cycle = TRUE; + int curplayers; + BOOL do_cycle = true; // find the map to change to char *mapcfile = (char*)CVAR_GET_STRING( "mapcyclefile" ); @@ -1439,14 +1441,14 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) if ( !ReloadMapCycleFile( mapcfile, &mapcycle ) || ( !mapcycle.items ) ) { ALERT( at_console, "Unable to load map cycle file %s\n", mapcfile ); - do_cycle = FALSE; + do_cycle = false; } } if ( do_cycle && mapcycle.items ) { - BOOL keeplooking = FALSE; - BOOL found = FALSE; + BOOL keeplooking = false; + BOOL found = false; mapcycle_item_s *item; // Assume current map @@ -1456,7 +1458,7 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) // Traverse list for ( item = mapcycle.next_item; item->next != mapcycle.next_item; item = item->next ) { - keeplooking = FALSE; + keeplooking = false; ASSERT( item != NULL ); @@ -1464,12 +1466,12 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) { if ( curplayers >= item->minplayers ) { - found = TRUE; + found = true; minplayers = item->minplayers; } else { - keeplooking = TRUE; + keeplooking = true; } } @@ -1477,19 +1479,19 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) { if ( curplayers <= item->maxplayers ) { - found = TRUE; + found = true; maxplayers = item->maxplayers; } else { - keeplooking = TRUE; + keeplooking = true; } } if ( keeplooking ) continue; - found = TRUE; + found = true; break; } @@ -1513,7 +1515,7 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) strncpy(szNextMap, szFirstMapInList, sizeof(szNextMap) ); } - g_fGameOver = TRUE; + g_fGameOver = true; ALERT( at_console, "CHANGE LEVEL: %s\n", szNextMap ); if ( minplayers || maxplayers ) @@ -1532,8 +1534,8 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) } } -#define MAX_MOTD_CHUNK 60 -#define MAX_MOTD_LENGTH (MAX_MOTD_CHUNK * 4) +constexpr int MAX_MOTD_CHUNK = 60; +constexpr int MAX_MOTD_LENGTH = (MAX_MOTD_CHUNK * 4); void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) { @@ -1571,7 +1573,7 @@ void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) *pFileList = 0; MESSAGE_BEGIN( MSG_ONE, gmsgMOTD, NULL, client ); - WRITE_BYTE( *pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come + WRITE_BYTE( *pFileList ? false : true ); // false means there is still more message to come WRITE_STRING_LIMIT(chunk, sizeof(chunk)); MESSAGE_END(); } @@ -1587,13 +1589,13 @@ void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { if(g_VoiceGameMgr.ClientCommand(pPlayer, pcmd)) - return TRUE; + return true; int OldMenu; if( FStrEq( pcmd, "menuselect" ) ) { if ( CMD_ARGC() < 2 ) - return FALSE; + return false; int slot = atoi( CMD_ARGV(1) );//Starts at 1 @@ -1602,7 +1604,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd //Check if you've set a different menu first if( pPlayer->CurrentMenu == OldMenu && !pPlayer->CurrentCallbackMenu ) pPlayer->CurrentMenu = NULL; - return TRUE; + return true; } else if( FStrEq( pcmd, "forgive" ) ) { @@ -1628,7 +1630,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd else { pPlayer->SendInfoMsg( "Forgive: Use this command to remove your accidental death from the killer's record\n" ); } - return TRUE; + return true; } else if( FStrEq( pcmd, "joinparty" ) ) { @@ -1637,7 +1639,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd if( pPlayer->m_pTeam ) { pPlayer->SendInfoMsg( "You are already in a party! Type 'leaveparty' to leave it\n" ); - return TRUE; + return true; } //Get the party name char Name[MAX_TEAMNAME_LEN+1]; @@ -1686,7 +1688,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd pPlayer->SetTeam( pTeam ); } } - return TRUE; + return true; } else if( FStrEq( pcmd, "leaveparty" ) ) { @@ -1697,7 +1699,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 @@ -1713,7 +1715,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd else { pPlayer->SendInfoMsg( "You aren't in a party!\n" ); } - return TRUE; + return true; } else if (FStrEq(pcmd, "startvote") && CMD_ARGC() >= 3 ) { @@ -1731,13 +1733,13 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd else pPlayer->SendInfoMsg( "This server doesn't allow time voting\n" ); } - else return FALSE; - return TRUE; + else return false; + return true; } else if (FStrEq(pcmd, "vote") && CMD_ARGV(1)) { TallyVote( pPlayer, atoi(CMD_ARGV(1)) ? true : false ); - return TRUE; + return true; } else if( FStrEq( pcmd, "accept" ) ) { @@ -1754,7 +1756,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(int n = 1; n <= gpGlobals->maxClients; n++ ) { pCheckPlayer = (CBasePlayer *)UTIL_PlayerByIndex( n ); if( pCheckPlayer && pCheckPlayer->m_pJoinTeam == pPlayer->m_pTeam ) @@ -1771,7 +1773,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) ); @@ -1800,7 +1802,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd AcceptType = 3; } } - return TRUE; + return true; } else if( FStrEq( pcmd, "as_reload_scripts" ) ) { @@ -1813,7 +1815,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd { pPlayer->SendInfoMsg("Error: This command requires developer permissions."); ALERT(at_console, "as_reload_scripts: Permission denied for %s (Steam ID: %s)\n", pPlayer->DisplayName(), pszSteamID ? pszSteamID : "Unknown"); - return TRUE; + return true; } } @@ -1822,7 +1824,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd { pPlayer->SendInfoMsg("Error: Development mode must be enabled (ms_dev_mode 1)."); ALERT(at_console, "as_reload_scripts: Development mode not enabled\n"); - return TRUE; + return true; } pPlayer->SendInfoMsg("Initiating script hot-reload..."); @@ -1840,7 +1842,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(int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer* pOtherPlayer = (CBasePlayer*)UTIL_PlayerByIndex( i ); if( pOtherPlayer && pOtherPlayer != pPlayer ) @@ -1861,13 +1863,13 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd ALERT(at_console, "as_reload_scripts: Module system not available\n"); } - return TRUE; + return true; } else if( FStrEq( pcmd, "as_pak_status" ) ) { // Console command to check PAK file status if( !pPlayer ) - return TRUE; + return true; // Check developer permissions msstring steamid = pPlayer->AuthID(); @@ -1876,7 +1878,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd if( !( szSteamID && ( FStrEq( szSteamID, "STEAM_0:1:630973602" ) || pPlayer->IsElite() ) ) ) { pPlayer->SendInfoMsg("Access denied. Developer permissions required."); - return TRUE; + return true; } // Display PAK file diagnostic information @@ -1928,13 +1930,13 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd ALERT(at_console, "Module System: NOT AVAILABLE\n"); } - return TRUE; + return true; } else if( FStrEq( pcmd, "as_pak_test" ) ) { // Console command to test PAK file access if( !pPlayer ) - return TRUE; + return true; // Check developer permissions msstring steamid = pPlayer->AuthID(); @@ -1943,7 +1945,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd if( !( szSteamID && ( FStrEq( szSteamID, "STEAM_0:1:630973602" ) || pPlayer->IsElite() ) ) ) { pPlayer->SendInfoMsg("Access denied. Developer permissions required."); - return TRUE; + return true; } pPlayer->SendInfoMsg("Testing PAK file refresh..."); @@ -1971,7 +1973,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd ALERT(at_console, "as_pak_test: Module system not available\n"); } - return TRUE; + return true; } else if( FStrEq( pcmd, "say" ) ) { @@ -1982,7 +1984,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd if( !pszText ) { ALERT( at_console, "Say command: CMD_ARGS() returned NULL pointer\n" ); - return FALSE; // Let default handling continue + return false; // Let default handling continue } // Additional memory validation - check if pointer is in valid memory range @@ -1990,14 +1992,14 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd /*if( IsBadReadPtr( pszText, 1 ) ) { ALERT( at_console, "Say command: CMD_ARGS() returned invalid memory pointer\n" ); - return FALSE; + return false; }*/ // Check for empty string if( !*pszText ) { // Empty text - let default handling continue - return FALSE; + return false; } // Safe length calculation with additional bounds checking @@ -2014,21 +2016,21 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd if( textLen == 0 ) { - return FALSE; // Empty text + return false; // Empty text } if( textLen >= MAX_SAFE_LENGTH ) { ALERT( at_console, "Say command: Text length exceeds safety limit (%zu >= %zu)\n", textLen, MAX_SAFE_LENGTH ); ClientPrint( pPlayer->pev, HUD_PRINTCENTER, "Message too long" ); - return TRUE; // Block this command + return true; // Block this command } if( textLen > 256 ) { // Reject excessively long messages ClientPrint( pPlayer->pev, HUD_PRINTCENTER, "Message too long" ); - return TRUE; // Block this command + return true; // Block this command } // Create a safe copy of the text for further processing @@ -2045,7 +2047,7 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd else { ALERT( at_console, "Say command: Text length invalid for safe copy (%zu)\n", textLen ); - return FALSE; + return false; } // Use the safe copy for all further operations @@ -2111,13 +2113,13 @@ BOOL CHalfLifeMultiplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd if( isVoteCommand ) { // Block the normal chat message since this is a command - return TRUE; + return true; } // Let normal chat messages continue through default handling - return FALSE; + return false; } - return FALSE; + return false; } //========================================================= @@ -2164,7 +2166,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 +2274,7 @@ void CHalfLifeMultiplay :: UpdateVote( ) //Count SPAWNED players (Connecting players don't count) int iTotalPlayers = 0; - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for (int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); if( pPlayer && pPlayer->m_fGameHUDInitialized ) diff --git a/src/game/server/gamerules/team.cpp b/src/game/server/gamerules/team.cpp index 187f20ca..bb7578eb 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 @@ -34,7 +33,7 @@ CTeam *CTeam::GetTeam(const char *pszName) { if (!pszName || !pszName[0]) return NULL; - for (int i = 0; i < Teams.size(); i++) + for (unsigned int i = 0; i < Teams.size(); i++) if (FStrEq(Teams[i]->TeamName(), pszName)) return Teams[i]; @@ -42,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]; @@ -51,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) @@ -99,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); @@ -122,17 +121,17 @@ void CTeam ::RemoveFromTeam(CBasePlayer *pPlayer) BOOL CTeam ::ExistsInList(CBasePlayer *pPlayer) { if (!pPlayer) - return FALSE; + 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; + return true; + return false; } 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) @@ -161,15 +160,15 @@ void CTeam ::SetSolidMembers(BOOL fSolid) BOOL SameTeam(CBaseEntity *pObject1, CBaseEntity *pObject2) { //Original: - /*if( !pObject1->TeamID()[0] || !pObject2->TeamID()[0] ) return FALSE; - if( pObject1->TeamID() == pObject2->TeamID() ) return TRUE; - return FALSE;*/ + /*if( !pObject1->TeamID()[0] || !pObject2->TeamID()[0] ) return false; + if( pObject1->TeamID() == pObject2->TeamID() ) return true; + return false;*/ if (!pObject1->TeamID()[0] || !pObject2->TeamID()[0]) - return FALSE; + return false; if (strcmp(pObject1->TeamID(), pObject2->TeamID()) == 0) - return TRUE; //MiB AUG2007a: Comparing with == is bad. Bad, Dogg. Bad. - return FALSE; + return true; //MiB AUG2007a: Comparing with == is bad. Bad, Dogg. Bad. + return false; } /*int CBaseEntity::TeamID( void ) { return m_pTeam ? m_pTeam->TeamID() : -1; } void CBaseEntity::SetTeam( CTeam *pTeam ) { diff --git a/src/game/server/gamerules/teams.h b/src/game/server/gamerules/teams.h index 4950a482..9d3906f1 100644 --- a/src/game/server/gamerules/teams.h +++ b/src/game/server/gamerules/teams.h @@ -1,7 +1,7 @@ #ifndef TEAM_H #define TEAM_H -#define MAX_TEAMNAME_LEN 12 +constexpr int MAX_TEAMNAME_LEN = 12; #ifdef VALVE_DLL #ifdef CBASE_H diff --git a/src/game/server/ggrenade.cpp b/src/game/server/ggrenade.cpp index 25f0e7cf..4d73aa3d 100644 --- a/src/game/server/ggrenade.cpp +++ b/src/game/server/ggrenade.cpp @@ -25,12 +25,15 @@ #include "soundent.h" #include "decals.h" +#ifndef EFFECTS_H +#include "effects.h" +#endif + //===================grenade LINK_ENTITY_TO_CLASS(grenade, CGrenade); // Grenades flagged with this will be triggered when the owner calls detonateSatchelCharges -#define SF_DETONATE 0x0001 // // Grenade Explode @@ -121,8 +124,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); } } @@ -250,7 +253,7 @@ void CGrenade::BounceTouch(CBaseEntity *pOther) // register a radius louder than the explosion, so we make sure everyone gets out of the way CSoundEnt::InsertSound(bits_SOUND_DANGER, pev->origin, pev->dmg / 0.4, 0.3); - m_fRegisteredSound = TRUE; + m_fRegisteredSound = true; } if (pev->flags & FL_ONGROUND) @@ -351,7 +354,7 @@ void CGrenade::Spawn(void) UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); pev->dmg = 100; - m_fRegisteredSound = FALSE; + m_fRegisteredSound = false; } CGrenade *CGrenade::ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity) diff --git a/src/game/server/h_export.cpp b/src/game/server/h_export.cpp index 78ecb7a6..2dea9b62 100644 --- a/src/game/server/h_export.cpp +++ b/src/game/server/h_export.cpp @@ -57,7 +57,7 @@ BOOL WINAPI DllMain( else if (fdwReason == DLL_PROCESS_DETACH) MSGlobals::DLLDetach(); - return TRUE; + return true; } #endif diff --git a/src/game/server/hl/animating.cpp b/src/game/server/hl/animating.cpp index 856ab391..5c829afc 100644 --- a/src/game/server/hl/animating.cpp +++ b/src/game/server/hl/animating.cpp @@ -21,6 +21,9 @@ */ #define VALVE_DLL 1 +#ifndef M_PI +#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h +#endif #include "msdllheaders.h" #include "animation.h" @@ -64,7 +67,7 @@ float CBaseAnimating ::StudioFrameAdvance(float flInterval) pev->frame -= (int)(pev->frame / 256.0) * 256.0; else pev->frame = (pev->frame < 0.0) ? 0 : 255; - m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents + m_fSequenceFinished = true; // just in case it wasn't caught in GetEvents } return flInterval; @@ -113,7 +116,7 @@ void CBaseAnimating ::ResetSequenceInfo() m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0); pev->animtime = gpGlobals->time; pev->framerate = 1.0; - m_fSequenceFinished = FALSE; + m_fSequenceFinished = false; m_flLastEventCheck = gpGlobals->time; } @@ -154,9 +157,9 @@ void CBaseAnimating ::DispatchAnimEvents(float flInterval) float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate; m_flLastEventCheck = pev->animtime + flInterval; - m_fSequenceFinished = FALSE; + m_fSequenceFinished = false; if (flEnd >= 256 || flEnd <= 0.0) - m_fSequenceFinished = TRUE; + m_fSequenceFinished = true; int index = 0; @@ -279,7 +282,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..74666866 100644 --- a/src/game/server/hl/animation.cpp +++ b/src/game/server/hl/animation.cpp @@ -22,15 +22,14 @@ typedef bool BOOL; // hack into header files that we can ship typedef int qboolean; typedef unsigned char byte; -#include "../utils/common/mathlib.h" +//#include "../utils/common/mathlib.h" +#include "hl/vector.h" #include "const.h" - +#include "mathlib.h" #include "progdefs.h" #include "edict.h" #include "eiface.h" - #include "studio.h" - #include "../engine/studio.h" #ifndef ACTIVITY_H @@ -291,6 +290,7 @@ int GetAnimationEvent(void* pmodel, entvars_t* pev, MonsterEvent_t* pMonsterEven { studiohdr_t* pstudiohdr; + pstudiohdr = (studiohdr_t*)pmodel; if (!pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent) return 0; @@ -303,7 +303,7 @@ int GetAnimationEvent(void* pmodel, entvars_t* pev, MonsterEvent_t* pMonsterEven pseqdesc = (mstudioseqdesc_t*)((byte*)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; pevent = (mstudioevent_t*)((byte*)pstudiohdr + pseqdesc->eventindex); - if (pseqdesc->numevents == 0 || index > pseqdesc->numevents) + if (pseqdesc->numevents == 0 || static_cast(index) > pseqdesc->numevents) return 0; if (pseqdesc->numframes > 1) @@ -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) diff --git a/src/game/server/hl/animation.h b/src/game/server/hl/animation.h index 21a64bc9..658f706e 100644 --- a/src/game/server/hl/animation.h +++ b/src/game/server/hl/animation.h @@ -12,10 +12,17 @@ * without written permission from Valve LLC. * ****/ + +#ifndef STUDIO_H +#include "studio.h" +#endif + #ifndef ANIMATION_H #define ANIMATION_H -#define ACTIVITY_NOT_AVAILABLE -1 +enum { + ACTIVITY_NOT_AVAILABLE = -1 +}; #ifndef MONSTEREVENT_H #include "monsterevent.h" @@ -41,7 +48,4 @@ 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 ExtractBbox(void *pmodel, int sequence, float *mins, float *maxs); -// From /engine/studio.h -#define STUDIO_LOOPING 0x0001 - #endif //ANIMATION_H diff --git a/src/game/server/hl/buttons.cpp b/src/game/server/hl/buttons.cpp index abfac579..3f5ce2b9 100644 --- a/src/game/server/hl/buttons.cpp +++ b/src/game/server/hl/buttons.cpp @@ -24,13 +24,6 @@ #include "saverestore.h" #include "doors.h" -#define SF_BUTTON_DONTMOVE 1 -#define SF_ROTBUTTON_NOTSOLID 1 -#define SF_BUTTON_TOGGLE 32 // button stays pushed until reactivated -#define SF_BUTTON_SPARK_IF_OFF 64 // button sparks in OFF state -#define SF_BUTTON_TOUCH_ONLY 256 // button only fires as a result of USE key. - -#define SF_GLOBAL_SET 1 // Set global state to initial state on spawn class CEnvGlobal : public CPointEntity { @@ -62,7 +55,7 @@ LINK_ENTITY_TO_CLASS(env_global, CEnvGlobal); void CEnvGlobal::KeyValue(KeyValueData *pkvd) { - pkvd->fHandled = TRUE; + pkvd->fHandled = true; if (FStrEq(pkvd->szKeyName, "globalstate")) // State name m_globalstate = ALLOC_STRING(pkvd->szValue); @@ -147,18 +140,16 @@ void CMultiSource::KeyValue(KeyValueData *pkvd) FStrEq(pkvd->szKeyName, "value1") || FStrEq(pkvd->szKeyName, "value2") || FStrEq(pkvd->szKeyName, "value3")) - pkvd->fHandled = TRUE; + pkvd->fHandled = true; else if (FStrEq(pkvd->szKeyName, "globalstate")) { m_globalstate = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CPointEntity::KeyValue(pkvd); } -#define SF_MULTI_INIT 1 - void CMultiSource::Spawn() { // set up think for later registration @@ -402,32 +393,32 @@ void CBaseButton::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "changetarget")) { m_strChangeTarget = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "locked_sound")) { m_bLockedSound = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "locked_sentence")) { m_bLockedSentence = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "unlocked_sound")) { m_bUnlockedSound = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "unlocked_sentence")) { m_bUnlockedSentence = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "sounds")) { m_sounds = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseToggle::KeyValue(pkvd); @@ -531,8 +522,8 @@ void CBaseButton::Spawn() if (((m_vecPosition2 - m_vecPosition1).Length() < 1) || (pev->spawnflags & SF_BUTTON_DONTMOVE)) m_vecPosition2 = m_vecPosition1; - m_fStayPushed = (m_flWait == -1 ? TRUE : FALSE); - m_fRotating = FALSE; + m_fStayPushed = (m_flWait == -1 ? true : false); + m_fRotating = false; // if the button is flagged for USE button activation only, take away it's touch function and add a use function @@ -736,7 +727,7 @@ void CBaseButton::ButtonTouch(CBaseEntity *pOther) if (!UTIL_IsMasterTriggered(m_sMaster, pOther)) { // play button locked sound - PlayLockSounds(pev, &m_ls, TRUE, TRUE); + PlayLockSounds(pev, &m_ls, true, true); return; } @@ -763,18 +754,20 @@ void CBaseButton::ButtonActivate() if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) { // button is locked, play locked sound - PlayLockSounds(pev, &m_ls, TRUE, TRUE); + PlayLockSounds(pev, &m_ls, true, true); return; } else { // button is unlocked, play unlocked sound - PlayLockSounds(pev, &m_ls, FALSE, TRUE); + PlayLockSounds(pev, &m_ls, false, true); } ASSERT(m_toggle_state == TS_AT_BOTTOM); m_toggle_state = TS_GOING_UP; + + SetMoveDone(&CBaseButton::TriggerAndWait); if (!m_fRotating) LinearMove(m_vecPosition2, pev->speed); @@ -939,8 +932,8 @@ void CRotButton::Spawn(void) m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; ASSERTSZ(m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal"); - m_fStayPushed = (m_flWait == -1 ? TRUE : FALSE); - m_fRotating = TRUE; + m_fStayPushed = (m_flWait == -1 ? true : false); + m_fRotating = true; // if the button is flagged for USE button activation only, take away it's touch function and add a use function if (!FBitSet(pev->spawnflags, SF_BUTTON_TOUCH_ONLY)) @@ -958,7 +951,7 @@ void CRotButton::Spawn(void) // This will disable use and make the button solid // rotating buttons were made SOLID_NOT by default since their were some // collision problems with them... -#define SF_MOMENTARY_DOOR 0x0001 + class CMomentaryRotButton : public CBaseToggle { @@ -991,8 +984,8 @@ class CMomentaryRotButton : public CBaseToggle int m_lastUsed; int m_direction; float m_returnSpeed; - vec3_t m_start; - vec3_t m_end; + Vector m_start; + Vector m_end; int m_sounds; }; TYPEDESCRIPTION CMomentaryRotButton::m_SaveData[] = @@ -1050,12 +1043,12 @@ void CMomentaryRotButton::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "returnspeed")) { m_returnSpeed = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "sounds")) { m_sounds = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseToggle::KeyValue(pkvd); @@ -1104,11 +1097,11 @@ void CMomentaryRotButton::UpdateAllButtons(float value, int start) void CMomentaryRotButton::UpdateSelf(float value) { - BOOL fplaysound = FALSE; + BOOL fplaysound = false; if (!m_lastUsed) { - fplaysound = TRUE; + fplaysound = true; m_direction = -m_direction; } m_lastUsed = 1; @@ -1271,7 +1264,7 @@ void CEnvSpark::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "MaxDelay")) { m_flDelay = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "style") || FStrEq(pkvd->szKeyName, "height") || @@ -1279,7 +1272,7 @@ void CEnvSpark::KeyValue(KeyValueData *pkvd) FStrEq(pkvd->szKeyName, "value1") || FStrEq(pkvd->szKeyName, "value2") || FStrEq(pkvd->szKeyName, "value3")) - pkvd->fHandled = TRUE; + pkvd->fHandled = true; else CBaseEntity::KeyValue(pkvd); } @@ -1303,9 +1296,6 @@ void EXPORT CEnvSpark::SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, SetThink(NULL); } -#define SF_BTARGET_USE 0x0001 -#define SF_BTARGET_ON 0x0002 - class CButtonTarget : public CBaseEntity { public: diff --git a/src/game/server/hl/cbase.cpp b/src/game/server/hl/cbase.cpp index c9e88996..48dead1e 100644 --- a/src/game/server/hl/cbase.cpp +++ b/src/game/server/hl/cbase.cpp @@ -109,11 +109,11 @@ extern "C" { { if (!pFunctionTable || interfaceVersion != INTERFACE_VERSION) { - return FALSE; + return false; } memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS)); - return TRUE; + return true; } int GetEntityAPI2(DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion) @@ -122,11 +122,11 @@ extern "C" { { // Tell engine what version we had, so it can figure out who is out of date. *interfaceVersion = INTERFACE_VERSION; - return FALSE; + return false; } memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS)); - return TRUE; + return true; } int GetNewDLLFunctions(NEW_DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion) @@ -134,11 +134,11 @@ extern "C" { if (!pFunctionTable || *interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) { *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION; - return FALSE; + return false; } memcpy(pFunctionTable, &gNewDLLFunctions, sizeof(gNewDLLFunctions)); - return TRUE; + return true; } } @@ -228,7 +228,7 @@ void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) // HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers) // while it builds the graph -BOOL gTouchDisabled = FALSE; +BOOL gTouchDisabled = false; void DispatchTouch(edict_t *pentTouched, edict_t *pentOther) { @@ -761,32 +761,32 @@ BOOL CBaseEntity ::IsInWorld(void) { // position if (pev->origin.x >= 4096) - return FALSE; + return false; if (pev->origin.y >= 4096) - return FALSE; + return false; if (pev->origin.z >= 4096) - return FALSE; + return false; if (pev->origin.x <= -4096) - return FALSE; + return false; if (pev->origin.y <= -4096) - return FALSE; + return false; if (pev->origin.z <= -4096) - return FALSE; + return false; // speed if (pev->velocity.x >= 2000) - return FALSE; + return false; if (pev->velocity.y >= 2000) - return FALSE; + return false; if (pev->velocity.z >= 2000) - return FALSE; + return false; if (pev->velocity.x <= -2000) - return FALSE; + return false; if (pev->velocity.y <= -2000) - return FALSE; + return false; if (pev->velocity.z <= -2000) - return FALSE; + return false; - return TRUE; + return true; } int CBaseEntity::ShouldToggle(USE_TYPE useType, BOOL currentState) diff --git a/src/game/server/hl/cbase.h b/src/game/server/hl/cbase.h index ec3361e2..552e89b1 100644 --- a/src/game/server/hl/cbase.h +++ b/src/game/server/hl/cbase.h @@ -27,28 +27,30 @@ CBaseEntity #ifndef CBASE_H #define CBASE_H -#define MAX_PATH_SIZE 10 // max number of nodes available for a path. +constexpr int MAX_PATH_SIZE = 10; // max number of nodes available for a path. // These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions) -#define FCAP_CUSTOMSAVE 0x00000001 -#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions -#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore -#define FCAP_DONT_SAVE 0x80000000 // Don't save this -#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player -#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player -#define FCAP_ONOFF_USE 0x00000020 // can be used by the player -#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) -#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) - -// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! -#define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions +enum fcap_bits_e { + FCAP_CUSTOMSAVE = 0x00000001, + FCAP_ACROSS_TRANSITION = 0x00000002,// should transfer between transitions + FCAP_MUST_SPAWN = 0x00000004, // Spawn after restore + FCAP_DONT_SAVE = 0x80000000, // Don't save this + FCAP_IMPULSE_USE = 0x00000008, // can be used by the player + FCAP_CONTINUOUS_USE = 0x00000010, // can be used by the player + FCAP_ONOFF_USE = 0x00000020, // can be used by the player + FCAP_DIRECTIONAL_USE = 0x00000040, // Player sends +/- 1 when using (currently only tracktrains) + FCAP_MASTER = 0x00000080, // Can be used to "master" other entities (like multisource) + + // UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! + FCAP_FORCE_TRANSITION = 0x00000080 // ALWAYS goes across transitions +}; #include "iscript.h" #include "archtypes.h" // DAL //Master Sword - no save/restore in client dll -#define MAXPLAYERS 32 +constexpr unsigned int MAXPLAYERS = 32; #ifdef VALVE_DLL #include "saverestore.h" #else @@ -117,39 +119,40 @@ typedef void (CBaseEntity::*USEPTR)(CBaseEntity *pActivator, CBaseEntity *pCalle // Master Sword - New CLASS defs: -#define CLASS_NONE 0 -#define CLASS_MACHINE 1 -#define CLASS_PLAYER 2 -#define CLASS_NPC 3 -#define CLASS_MONSTER 4 //CLASS_HUMAN_MILITARY - -// OLD DEFS! -// For CLASSIFY -//#define CLASS_NONE 0 -//#define CLASS_MACHINE 1 -//#define CLASS_PLAYER 2 -#define CLASS_HUMAN_PASSIVE 5 -#define CLASS_HUMAN_MILITARY 6 -#define CLASS_ALIEN_MILITARY 7 -#define CLASS_ALIEN_PASSIVE 8 -#define CLASS_ALIEN_MONSTER 9 -#define CLASS_ALIEN_PREY 10 -#define CLASS_ALIEN_PREDATOR 11 -#define CLASS_INSECT 12 -#define CLASS_PLAYER_ALLY 13 -#define CLASS_PLAYER_BIOWEAPON 14 // hornets and snarks.launched by players -#define CLASS_ALIEN_BIOWEAPON 15 // hornets and snarks.launched by the alien menace -#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures. -#define CHAR_LEVEL_CAP 45 // MiB JAN2010_15 Global Level Cap -#define CLASS_VEHICLE 16 // we use 16 because of MS class defines. +enum class_entity_e { + CLASS_NONE = 0, + CLASS_MACHINE = 1, + CLASS_PLAYER = 2, + CLASS_NPC = 3, + CLASS_MONSTER = 4, //CLASS_HUMAN_MILITARY + + // OLD DEFS! + // For CLASSIFY + //#define CLASS_NONE 0 + //#define CLASS_MACHINE 1 + //#define CLASS_PLAYER 2 + CLASS_HUMAN_PASSIVE = 5, + CLASS_HUMAN_MILITARY = 6, + CLASS_ALIEN_MILITARY = 7, + CLASS_ALIEN_PASSIVE = 8, + CLASS_ALIEN_MONSTER = 9, + CLASS_ALIEN_PREY = 10, + CLASS_ALIEN_PREDATOR = 11, + CLASS_INSECT = 12, + CLASS_PLAYER_ALLY = 13, + CLASS_PLAYER_BIOWEAPON = 14, // hornets and snarks.launched by players + CLASS_ALIEN_BIOWEAPON = 15, // hornets and snarks.launched by the alien menace + CLASS_BARNACLE = 99, // special because no one pays attention to it, and it eats a wide cross-section of creatures. + CLASS_VEHICLE = 16, // we use 16 because of MS class defines. +}; + +constexpr unsigned int CHAR_LEVEL_CAP = 45; // MiB JAN2010_15 Global Level Cap class CBaseEntity; class CBaseMonster; class CBasePlayerItem; class CSquadMonster; -#define SF_NORESPAWN (1 << 30) // !!!set this bit on guns and stuff that should never respawn. - // // EHANDLE. Safe way to point to CBaseEntities who may die between frames // @@ -397,7 +400,7 @@ class CBaseEntity // initialization functions virtual void Spawn(void) {} virtual void Precache(void) { return; } - virtual void KeyValue(KeyValueData *pkvd) { pkvd->fHandled = FALSE; } + virtual void KeyValue(KeyValueData *pkvd) { pkvd->fHandled = false; } virtual int Save(CSave &save); virtual int Restore(CRestore &restore); @@ -421,7 +424,7 @@ class CBaseEntity virtual void Killed(entvars_t *pevAttacker, int iGib); virtual int BloodColor(void) { return DONT_BLEED; } virtual void TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); - virtual BOOL IsTriggered(CBaseEntity *pActivator) { return TRUE; } + virtual BOOL IsTriggered(CBaseEntity *pActivator) { return true; } virtual CBaseMonster *MyMonsterPointer(void) { return NULL; } virtual CSquadMonster *MySquadMonsterPointer(void) { return NULL; } virtual bool IsMSMonster(void) { return false; } @@ -437,15 +440,15 @@ class CBaseEntity virtual void SetToggleState(int state) {} virtual void StartSneaking(void) {} virtual void StopSneaking(void) {} - virtual BOOL OnControls(entvars_t *pev) { return FALSE; } - virtual BOOL IsSneaking(void) { return FALSE; } + virtual BOOL OnControls(entvars_t *pev) { return false; } + virtual BOOL IsSneaking(void) { return false; } virtual BOOL IsAlive(void) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } virtual BOOL IsBSPModel(void) { return pev->solid == SOLID_BSP || pev->movetype == MOVETYPE_PUSHSTEP; } virtual BOOL ReflectGauss(void) { return (IsBSPModel() && !pev->takedamage); } virtual BOOL HasTarget(string_t targetname) { return FStrEq(STRING(targetname), STRING(pev->targetname)); } virtual BOOL IsInWorld(void); - virtual BOOL IsPlayer(void) { return FALSE; } - virtual BOOL IsNetClient(void) { return FALSE; } + virtual BOOL IsPlayer(void) { return false; } + virtual BOOL IsNetClient(void) { return false; } virtual const char *TeamID(void) { return ""; } // virtual void SetActivator( CBaseEntity *pActivator ) {} @@ -516,7 +519,7 @@ class CBaseEntity int Intersects(CBaseEntity *pOther); void MakeDormant(void); int IsDormant(void); - BOOL IsLockedByMaster(void) { return FALSE; } + BOOL IsLockedByMaster(void) { return false; } static CBaseEntity *Instance(edict_t *pent) { @@ -592,7 +595,7 @@ class CBaseEntity // static CBaseEntity *Create(const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL); - virtual BOOL FBecomeProne(void) { return FALSE; }; + virtual BOOL FBecomeProne(void) { return false; }; edict_t *edict() { //Master Sword... Client has no edict_t ! #ifdef VALVE_DLL @@ -690,8 +693,8 @@ void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton); // MultiSouce // -#define MAX_MULTI_TARGETS 16 // maximum number of targets a single multi_manager entity may be assigned. -#define MS_MAX_TARGETS 32 +constexpr int MAX_MULTI_TARGETS = 16; // maximum number of targets a single multi_manager entity may be assigned. +constexpr int MS_MAX_TARGETS = 32; class CMultiSource : public CPointEntity { @@ -779,7 +782,7 @@ class CBaseAnimating : public CBaseDelay // // generic Toggle entity. // -#define SF_ITEM_USE_ONLY 256 // ITEM_USE_ONLY = BUTTON_USE_ONLY = DOOR_USE_ONLY!!! + class CBaseToggle : public CBaseAnimating { @@ -833,121 +836,128 @@ class CBaseToggle : public CBaseAnimating // the button will be allowed to operate. Otherwise, it will be // deactivated. }; -#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 SetMoveDone(a) m_pfnCallWhenMoveDone = static_cast(a) -#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) +// people gib if their health is <= this at the time of death +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_e { + 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_type_e { + 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 dot_type_e { + 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 -#define GIB_NORMAL 0 // gib if entity was overkilled -#define GIB_NEVER 1 // never gib, no matter how much death damage is done ( freezing, etc ) -#define GIB_ALWAYS 2 // always gib ( Houndeye Shock, Barnacle Bite ) +enum gib_setting_e { + GIB_NORMAL = 0, // gib if entity was overkilled + GIB_NEVER = 1, // never gib, no matter how much death damage is done ( freezing, etc ) + GIB_ALWAYS = 2 // always gib ( Houndeye Shock, Barnacle Bite ) +}; class CBaseMonster; class CCineMonster; class CSound; @@ -1018,7 +1028,7 @@ class CBaseButton : public CBaseToggle // Weapons // -#define BAD_WEAPON 0x00007FFF +constexpr unsigned int BAD_WEAPON = 0x00007FFF; // // Converts a entvars_t * to a class pointer @@ -1068,7 +1078,7 @@ env_sound_data push_trigger_data */ -#define TRACER_FREQ 4 // Tracers fire every 4 bullets +constexpr int TRACER_FREQ = 4; // Tracers fire every 4 bullets typedef struct _SelAmmo { diff --git a/src/game/server/hl/client.h b/src/game/server/hl/client.h index 822c4d02..11a72bec 100644 --- a/src/game/server/hl/client.h +++ b/src/game/server/hl/client.h @@ -44,7 +44,7 @@ extern void Sys_Error(const char *error_string); extern void SetupVisibility(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas); extern void UpdateClientData(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd); extern int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet); -extern void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs); +extern void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, Vector player_mins, Vector player_maxs); extern void RegisterEncoders(void); extern int GetWeaponData(struct edict_s *player, struct weapon_data_s *info); diff --git a/src/game/server/hl/doors.cpp b/src/game/server/hl/doors.cpp index 5c7110a0..1120a86a 100644 --- a/src/game/server/hl/doors.cpp +++ b/src/game/server/hl/doors.cpp @@ -25,6 +25,7 @@ extern void SetMovedir(entvars_t *ev); +//overloaded varables with generic names #define noiseMoving noise1 #define noiseArrived noise2 @@ -89,10 +90,6 @@ TYPEDESCRIPTION CBaseDoor::m_SaveData[] = IMPLEMENT_SAVERESTORE(CBaseDoor, CBaseToggle); -#define DOOR_SENTENCEWAIT 6 -#define DOOR_SOUNDWAIT 3 -#define BUTTON_SOUNDWAIT 0.5 - // play door or button locked or unlocked sounds. // pass in pointer to valid locksound struct. // if flocked is true, play 'door is locked' sound, @@ -138,7 +135,7 @@ void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton) int iprev = pls->iLockedSentence; pls->iLockedSentence = SENTENCEG_PlaySequentialSz(ENT(pev), STRING(pls->sLockedSentence), - 0.85, ATTN_NORM, 0, 100, pls->iLockedSentence, FALSE); + 0.85, ATTN_NORM, 0, 100, pls->iLockedSentence, false); pls->iUnlockedSentence = 0; // make sure we don't keep calling last sentence in list @@ -174,7 +171,7 @@ void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton) int iprev = pls->iUnlockedSentence; pls->iUnlockedSentence = SENTENCEG_PlaySequentialSz(ENT(pev), STRING(pls->sUnlockedSentence), - 0.85, ATTN_NORM, 0, 100, pls->iUnlockedSentence, FALSE); + 0.85, ATTN_NORM, 0, 100, pls->iUnlockedSentence, false); pls->iLockedSentence = 0; // make sure we don't keep calling last sentence in list @@ -194,47 +191,47 @@ void CBaseDoor::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "skin")) //skin is used for content type { pev->skin = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "movesnd")) { m_bMoveSnd = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "stopsnd")) { m_bStopSnd = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "healthvalue")) { m_bHealthValue = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "locked_sound")) { m_bLockedSound = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "locked_sentence")) { m_bLockedSentence = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "unlocked_sound")) { m_bUnlockedSound = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "unlocked_sentence")) { m_bUnlockedSentence = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "WaveHeight")) { pev->scale = atof(pkvd->szValue) * (1.0 / 8.0); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseToggle::KeyValue(pkvd); @@ -525,7 +522,7 @@ void CBaseDoor::DoorTouch(CBaseEntity *pOther) // play 'locked' sound if (m_sMaster && !UTIL_IsMasterTriggered(m_sMaster, pOther)) - PlayLockSounds(pev, &m_ls, TRUE, FALSE); + PlayLockSounds(pev, &m_ls, true, false); // If door is somebody's target, then touching does nothing. // You have to activate the owner (e.g. button). @@ -533,7 +530,7 @@ void CBaseDoor::DoorTouch(CBaseEntity *pOther) if (!FStringNull(pev->targetname)) { // play locked sound - PlayLockSounds(pev, &m_ls, TRUE, FALSE); + PlayLockSounds(pev, &m_ls, true, false); return; } @@ -577,7 +574,7 @@ int CBaseDoor::DoorActivate() } // play door unlock sounds - PlayLockSounds(pev, &m_ls, FALSE, FALSE); + PlayLockSounds(pev, &m_ls, false, false); DoorGoUp(); } @@ -1022,17 +1019,17 @@ void CMomentaryDoor::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "movesnd")) { m_bMoveSnd = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "stopsnd")) { // m_bStopSnd = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "healthvalue")) { // m_bHealthValue = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseToggle::KeyValue(pkvd); diff --git a/src/game/server/hl/doors.h b/src/game/server/hl/doors.h index 3fefa635..e9463d59 100644 --- a/src/game/server/hl/doors.h +++ b/src/game/server/hl/doors.h @@ -14,19 +14,63 @@ ****/ #ifndef DOORS_H #define DOORS_H +#endif // doors -#define SF_DOOR_ROTATE_Y 0 -#define SF_DOOR_START_OPEN 1 -#define SF_DOOR_ROTATE_BACKWARDS 2 -#define SF_DOOR_PASSABLE 8 -#define SF_DOOR_ONEWAY 16 -#define SF_DOOR_NO_AUTO_RETURN 32 -#define SF_DOOR_ROTATE_Z 64 -#define SF_DOOR_ROTATE_X 128 -#define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button. -#define SF_DOOR_NOMONSTERS 512 // Monster can't open -#define SF_DOOR_UNBLOCKABLE 1024 //Thothie AUG2011_29 - make door unstoppable -#define SF_DOOR_SILENT 0x80000000 - -#endif //DOORS_H + +constexpr int DOOR_SENTENCEWAIT = 6; +constexpr int DOOR_SOUNDWAIT = 3; +constexpr float BUTTON_SOUNDWAIT = 0.5; + + +enum { + SF_GLOBAL_SET = 1, + SF_MULTI_INIT = 1, + SF_MOMENTARY_DOOR = 0x0001 +}; + +enum { + SF_DOOR_ROTATE_Y = 0, + SF_DOOR_START_OPEN = 1, + SF_DOOR_ROTATE_BACKWARDS = 2, + SF_DOOR_PASSABLE = 8, + SF_DOOR_ONEWAY = 16, + SF_DOOR_NO_AUTO_RETURN = 32, + SF_DOOR_ROTATE_Z = 64, + SF_DOOR_ROTATE_X = 128, + SF_DOOR_USE_ONLY = 256, // door must be opened by player's use button. + SF_DOOR_NOMONSTERS = 512, // Monster can't open + SF_DOOR_UNBLOCKABLE = 1024, //Thothie AUG2011_29 - make door unstoppable + SF_DOOR_SILENT = 0x80000000, + +}; + +enum { + SF_CONVEYOR_VISUAL = 0x0001, + SF_CONVEYOR_NOTSOLID = 0x0002, + SF_CONVEYOR_TOGGLE = 0x0004, //Thothie AUG2011_30 toggle conveyors +}; + +enum { + + SF_ITEM_USE_ONLY = 256, // ITEM_USE_ONLY = BUTTON_USE_ONLY = DOOR_USE_ONLY!!! + SF_BUTTON_USE_ONLY = 256, + SF_PLAYERCLIP_START_OFF = 0x0001, + SF_WALL_START_OFF = 0x0001, + SF_MONSTERCLIP_START_OFF = 0x0001, + SF_PENDULUM_SWING = 2, // spawnflag that makes a pendulum a rope swing. + SF_BRUSH_ACCDCC = 16, // brush should accelerate and decelerate when toggled + SF_BRUSH_HURT = 32, // rotating brush that inflicts pain based on rotation speed + SF_ROTATING_NOT_SOLID = 64, // some special rotating objects are not solid. + SF_NORESPAWN = (1 << 30), // !!!set this bit on guns and stuff that should never respawn. +}; + +enum { + SF_BUTTON_DONTMOVE = 1, + SF_ROTBUTTON_NOTSOLID = 1, + SF_BUTTON_TOGGLE = 32, // button stays pushed until reactivated + SF_BUTTON_SPARK_IF_OFF = 64, // button sparks in OFF state + SF_BUTTON_TOUCH_ONLY = 256, // button only fires as a result of USE key. + SF_BTARGET_USE = 0x0001, + SF_BTARGET_ON = 0x0002 +}; diff --git a/src/game/server/hl/effects.h b/src/game/server/hl/effects.h index 24efca7d..b70f3a66 100644 --- a/src/game/server/hl/effects.h +++ b/src/game/server/hl/effects.h @@ -15,20 +15,69 @@ #ifndef EFFECTS_H #define EFFECTS_H -#define SF_BEAM_STARTON 0x0001 -#define SF_BEAM_TOGGLE 0x0002 -#define SF_BEAM_RANDOM 0x0004 -#define SF_BEAM_RING 0x0008 -#define SF_BEAM_SPARKSTART 0x0010 -#define SF_BEAM_SPARKEND 0x0020 -#define SF_BEAM_DECALS 0x0040 -#define SF_BEAM_SHADEIN 0x0080 -#define SF_BEAM_SHADEOUT 0x0100 -#define SF_BEAM_TEMPORARY 0x8000 - -#define SF_SPRITE_STARTON 0x0001 -#define SF_SPRITE_ONCE 0x0002 -#define SF_SPRITE_TEMPORARY 0x8000 +enum { + SF_BEAM_STARTON = 0x0001, + SF_BEAM_TOGGLE = 0x0002, + SF_BEAM_RANDOM = 0x0004, + SF_BEAM_RING = 0x0008, + SF_BEAM_SPARKSTART = 0x0010, + SF_BEAM_SPARKEND = 0x0020, + SF_BEAM_DECALS = 0x0040, + SF_BEAM_SHADEIN = 0x0080, + SF_BEAM_SHADEOUT = 0x0100, + SF_BEAM_TEMPORARY = 0x8000, + SF_SPRITE_STARTON = 0x0001, + SF_SPRITE_ONCE = 0x0002, + SF_SPRITE_TEMPORARY = 0x8000, + SF_GIBSHOOTER_REPEATABLE = 1, // allows a gibshooter to be refired + SF_FUNNEL_REVERSE = 1, // funnel effect repels particles instead of attracting them. + SF_BUBBLES_STARTOFF = 0x0001, + SF_BLOOD_RANDOM = 0x0001, + SF_BLOOD_STREAM = 0x0002, + SF_BLOOD_PLAYER = 0x0004, + SF_BLOOD_DECAL = 0x0008, + SF_SHAKE_EVERYONE = 0x0001, // Don't check radius + // UNDONE: These don't work yet + SF_SHAKE_DISRUPT = 0x0002, // Disrupt controls + SF_SHAKE_INAIR = 0x0004, // Shake players in air + SF_FADE_IN = 0x0001, // Fade in, not out + SF_FADE_MODULATE = 0x0002, // Modulate, don't blend + SF_FADE_ONLYONE = 0x0004, + SF_MESSAGE_ONCE = 0x0001, // Fade in, not out + SF_MESSAGE_ALL = 0x0002, // Send to all clients + SF_DETONATE = 0x0001, + SF_LOOP = 1, + SF_REMOVE_ON_FIRE = 2, + SF_DECAL_NOTINDEATHMATCH = 2048, + SF_WORLD_DARK = 0x0001, // Fade from black at startup + SF_WORLD_TITLE = 0x0002, // Display game title at startup + SF_WORLD_FORCETEAM = 0x0004 // Force teams + +}; + + +enum { + SF_AUTO_FIREONCE = 0x0001, + SF_TRIGGER_PUSH_START_OFF = 2, //spawnflag that makes trigger_push spawn turned OFF + SF_TRIGGER_HURT_TARGETONCE = 1, // Only fire hurt target once + SF_TRIGGER_HURT_START_OFF = 2, //spawnflag that makes trigger_push spawn turned OFF + SF_TRIGGER_HURT_NO_CLIENTS = 8, //spawnflag that makes trigger_push spawn turned OFF + SF_TRIGGER_HURT_CLIENTONLYFIRE = 16, // trigger hurt will only fire its target if it is hurting a client + SF_TRIGGER_HURT_CLIENTONLYTOUCH = 32, // only clients may touch this trigger. + SF_RELAY_FIREONCE = 0x0001, + SF_MULTIMAN_CLONE = 0x80000000, + SF_MULTIMAN_THREAD = 0x00000001, + SF_RENDER_MASKFX = (1 << 0), + SF_RENDER_MASKAMT = (1 << 1), + SF_RENDER_MASKMODE = (1 << 2), + SF_RENDER_MASKCOLOR = (1 << 3), + SF_CHANGELEVEL_USEONLY = 0x0002, + SF_ENDSECTION_USEONLY = 0x0001, + SF_CAMERA_PLAYER_POSITION = 1, + SF_CAMERA_PLAYER_TARGET = 2, + SF_CAMERA_PLAYER_TAKECONTROL = 4, + SF_CAMERA_PLAYER_ALL = 8 +}; class CSprite : public CPointEntity { @@ -189,8 +238,7 @@ class CBeam : public CBaseEntity } }; -#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out -#define SF_MESSAGE_ALL 0x0002 // Send to all clients + class CLaser : public CBeam { diff --git a/src/game/server/hl/explode.cpp b/src/game/server/hl/explode.cpp index 667285e9..ff5504db 100644 --- a/src/game/server/hl/explode.cpp +++ b/src/game/server/hl/explode.cpp @@ -115,7 +115,7 @@ void CEnvExplosion::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "iMagnitude")) { m_iMagnitude = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); @@ -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/explode.h b/src/game/server/hl/explode.h index 95f183f4..77fabe9c 100644 --- a/src/game/server/hl/explode.h +++ b/src/game/server/hl/explode.h @@ -15,13 +15,14 @@ #ifndef EXPLODE_H #define EXPLODE_H -#define SF_ENVEXPLOSION_NODAMAGE (1 << 0) // when set, ENV_EXPLOSION will not actually inflict damage -#define SF_ENVEXPLOSION_REPEATABLE (1 << 1) // can this entity be refired? -#define SF_ENVEXPLOSION_NOFIREBALL (1 << 2) // don't draw the fireball -#define SF_ENVEXPLOSION_NOSMOKE (1 << 3) // don't draw the smoke -#define SF_ENVEXPLOSION_NODECAL (1 << 4) // don't make a scorch mark -#define SF_ENVEXPLOSION_NOSPARKS (1 << 5) // don't make a scorch mark - +enum sf_envexplosion_e { + SF_ENVEXPLOSION_NODAMAGE = (1 << 0), // when set, ENV_EXPLOSION will not actually inflict damage + SF_ENVEXPLOSION_REPEATABLE = (1 << 1), // can this entity be refired? + SF_ENVEXPLOSION_NOFIREBALL = (1 << 2), // don't draw the fireball + SF_ENVEXPLOSION_NOSMOKE = (1 << 3), // don't draw the smoke + SF_ENVEXPLOSION_NODECAL = (1 << 4), // don't make a scorch mark + SF_ENVEXPLOSION_NOSPARKS = (1 << 5) // don't make a scorch mark +}; //extern DLL_GLOBAL short g_sModelIndexFireball; //extern DLL_GLOBAL short g_sModelIndexSmoke; diff --git a/src/game/server/hl/extdll.h b/src/game/server/hl/extdll.h index b144e690..7b737363 100644 --- a/src/game/server/hl/extdll.h +++ b/src/game/server/hl/extdll.h @@ -25,8 +25,6 @@ #ifdef _WIN32 #include "PlatformWin.h" #else // _WIN32 -#define FALSE 0 -#define TRUE 1 typedef unsigned int uint; typedef int BOOL; @@ -47,7 +45,7 @@ typedef int BOOL; #include "math.h" // Vector class -#include "../../shared/hl/vector.h" +#include "hl/vector.h" // Shared engine/DLL constants #include "const.h" diff --git a/src/game/server/hl/func_break.h b/src/game/server/hl/func_break.h index 81b17ffd..795efa31 100644 --- a/src/game/server/hl/func_break.h +++ b/src/game/server/hl/func_break.h @@ -35,7 +35,7 @@ typedef enum matLastMaterial } Materials; -#define NUM_SHARDS 6 // this many shards spawned when breakable objects break; +constexpr int NUM_SHARDS = 6; // this many shards spawned when breakable objects break; class CBreakable : public CBaseDelay { diff --git a/src/game/server/hl/func_tank.cpp b/src/game/server/hl/func_tank.cpp index 5e018c24..fb058abc 100644 --- a/src/game/server/hl/func_tank.cpp +++ b/src/game/server/hl/func_tank.cpp @@ -20,14 +20,20 @@ #include "explode.h" #include "player.h" - -#define SF_TANK_ACTIVE 0x0001 -#define SF_TANK_PLAYER 0x0002 -#define SF_TANK_HUMANS 0x0004 -#define SF_TANK_ALIENS 0x0008 -#define SF_TANK_LINEOFSIGHT 0x0010 -#define SF_TANK_CANCONTROL 0x0020 -#define SF_TANK_SOUNDON 0x8000 +#ifndef M_PI +#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h +#endif + + +enum sf_tank_e { + SF_TANK_ACTIVE = 0x0001, + SF_TANK_PLAYER = 0x0002, + SF_TANK_HUMANS = 0x0004, + SF_TANK_ALIENS = 0x0008, + SF_TANK_LINEOFSIGHT = 0x0010, + SF_TANK_CANCONTROL = 0x0020, + SF_TANK_SOUNDON = 0x8000, +}; enum TANKBULLET { @@ -64,7 +70,7 @@ class CFuncTank : public CBaseEntity // Bmodels don't go across transitions virtual int ObjectCaps(void) { return CBaseEntity ::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - inline BOOL IsActive(void) { return (pev->spawnflags & SF_TANK_ACTIVE) ? TRUE : FALSE; } + inline BOOL IsActive(void) { return (pev->spawnflags & SF_TANK_ACTIVE) ? true : false; } inline void TankActivate(void) { pev->spawnflags |= SF_TANK_ACTIVE; @@ -178,7 +184,8 @@ static Vector gTankSpread[] = Vector(0.1, 0.1, 0.1), // large cone Vector(0.25, 0.25, 0.25), // extra-large cone }; -#define MAX_FIRING_SPREADS std::size(gTankSpread) + +constexpr size_t MAX_FIRING_SPREADS = std::size(gTankSpread); void CFuncTank ::Spawn(void) { @@ -220,107 +227,107 @@ void CFuncTank ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "yawrate")) { m_yawRate = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "yawrange")) { m_yawRange = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "yawtolerance")) { m_yawTolerance = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "pitchrange")) { m_pitchRange = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "pitchrate")) { m_pitchRate = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "pitchtolerance")) { m_pitchTolerance = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "firerate")) { m_fireRate = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "barrel")) { m_barrelPos.x = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "barrely")) { m_barrelPos.y = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "barrelz")) { m_barrelPos.z = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "spritescale")) { m_spriteScale = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "spritesmoke")) { m_iszSpriteSmoke = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "spriteflash")) { m_iszSpriteFlash = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "rotatesound")) { pev->noise = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "persistence")) { m_persist = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "bullet")) { m_bulletType = (TANKBULLET)atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "bullet_damage")) { m_iBulletDamage = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "firespread")) { m_spread = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "minRange")) { m_minRange = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "maxRange")) { m_maxRange = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "master")) { m_iszMaster = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); @@ -333,26 +340,26 @@ void CFuncTank ::KeyValue(KeyValueData *pkvd) BOOL CFuncTank ::OnControls(entvars_t *pevTest) { if (!(pev->spawnflags & SF_TANK_CANCONTROL)) - return FALSE; + return false; Vector offset = pevTest->origin - pev->origin; if ((m_vecControllerUsePos - pevTest->origin).Length() < 30) - return TRUE; + return true; - return FALSE; + return false; } BOOL CFuncTank ::StartControl(CBasePlayer *pController) { if (m_pController != NULL) - return FALSE; + return false; // Team only or disabled? if (m_iszMaster) { if (!UTIL_IsMasterTriggered(m_iszMaster, pController)) - return FALSE; + return false; } ALERT(at_console, "using TANK!\n"); @@ -370,7 +377,7 @@ BOOL CFuncTank ::StartControl(CBasePlayer *pController) pev->nextthink = pev->ltime + 0.1; - return TRUE; + return true; } void CFuncTank ::StopControl() @@ -461,11 +468,11 @@ edict_t *CFuncTank ::FindTarget(edict_t *pPlayer) BOOL CFuncTank ::InRange(float range) { if (range < m_minRange) - return FALSE; + return false; if (m_maxRange > 0 && range > m_maxRange) - return FALSE; + return false; - return TRUE; + return true; } void CFuncTank ::Think(void) @@ -483,7 +490,7 @@ void CFuncTank::TrackTarget(void) { TraceResult tr; edict_t *pPlayer = FIND_CLIENT_IN_PVS(edict()); - BOOL updateTime = FALSE, lineOfSight; + BOOL updateTime = false, lineOfSight; Vector angles, direction, targetPosition, barrelEnd; edict_t *pTarget = NULL; @@ -522,16 +529,16 @@ void CFuncTank::TrackTarget(void) UTIL_TraceLine(barrelEnd, targetPosition, dont_ignore_monsters, edict(), &tr); - lineOfSight = FALSE; + lineOfSight = false; // No line of sight, don't track if (tr.flFraction == 1.0 || tr.pHit == pTarget) { - lineOfSight = TRUE; + lineOfSight = true; CBaseEntity *pInstance = CBaseEntity::Instance(pTarget); if (InRange(range) && pInstance && pInstance->IsAlive()) { - updateTime = TRUE; + updateTime = true; m_sightOrigin = UpdateTargetPosition(pInstance); } } @@ -557,12 +564,12 @@ void CFuncTank::TrackTarget(void) if (angles.y > m_yawCenter + m_yawRange) { angles.y = m_yawCenter + m_yawRange; - updateTime = FALSE; // Don't update if you saw the player, but out of range + updateTime = false; // Don't update if you saw the player, but out of range } else if (angles.y < (m_yawCenter - m_yawRange)) { angles.y = (m_yawCenter - m_yawRange); - updateTime = FALSE; // Don't update if you saw the player, but out of range + updateTime = false; // Don't update if you saw the player, but out of range } if (updateTime) @@ -596,7 +603,7 @@ void CFuncTank::TrackTarget(void) if (CanFire() && ((fabs(distX) < m_pitchTolerance && fabs(distY) < m_yawTolerance) || (pev->spawnflags & SF_TANK_LINEOFSIGHT))) { - BOOL fire = FALSE; + BOOL fire = false; Vector forward; UTIL_MakeVectorsPrivate(pev->angles, forward, NULL, NULL); @@ -605,10 +612,10 @@ void CFuncTank::TrackTarget(void) float length = direction.Length(); UTIL_TraceLine(barrelEnd, barrelEnd + forward * length, dont_ignore_monsters, edict(), &tr); if (tr.pHit == pTarget) - fire = TRUE; + fire = true; } else - fire = TRUE; + fire = true; if (fire) { @@ -650,7 +657,7 @@ void CFuncTank::Fire(const Vector &barrelEnd, const Vector &forward, entvars_t * { if (m_iszSpriteSmoke) { - CSprite *pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteSmoke), barrelEnd, TRUE); + CSprite *pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteSmoke), barrelEnd, true); pSprite->AnimateAndDie(RANDOM_FLOAT(15.0, 20.0)); pSprite->SetTransparency(kRenderTransAlpha, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, 255, kRenderFxNone); pSprite->pev->velocity.z = RANDOM_FLOAT(40, 80); @@ -658,7 +665,7 @@ void CFuncTank::Fire(const Vector &barrelEnd, const Vector &forward, entvars_t * } if (m_iszSpriteFlash) { - CSprite *pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteFlash), barrelEnd, TRUE); + CSprite *pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteFlash), barrelEnd, true); pSprite->AnimateAndDie(60); pSprite->SetTransparency(kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation); pSprite->SetScale(m_spriteScale); @@ -797,7 +804,7 @@ void CFuncTankLaser::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "laserentity")) { pev->message = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CFuncTank::KeyValue(pkvd); @@ -914,7 +921,7 @@ void CFuncTankMortar::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "iMagnitude")) { pev->impulse = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CFuncTank::KeyValue(pkvd); @@ -935,7 +942,7 @@ void CFuncTankMortar::Fire(const Vector &barrelEnd, const Vector &forward, entva TankTrace(barrelEnd, forward, gTankSpread[m_spread], tr); - ExplosionCreate(tr.vecEndPos, pev->angles, edict(), pev->impulse, TRUE); + ExplosionCreate(tr.vecEndPos, pev->angles, edict(), pev->impulse, true); CFuncTank::Fire(barrelEnd, forward, pev); } diff --git a/src/game/server/hl/items.h b/src/game/server/hl/items.h index 2a2f7f72..82cc2558 100644 --- a/src/game/server/hl/items.h +++ b/src/game/server/hl/items.h @@ -22,7 +22,7 @@ class CItem : public CBaseEntity CBaseEntity *Respawn(void); void EXPORT ItemTouch(CBaseEntity *pOther); void EXPORT Materialize(void); - virtual BOOL MyTouch(CBasePlayer *pPlayer) { return FALSE; }; + virtual BOOL MyTouch(CBasePlayer *pPlayer) { return false; }; }; #endif // ITEMS_H diff --git a/src/game/server/hl/lights.cpp b/src/game/server/hl/lights.cpp index 1edf4c46..050f14e1 100644 --- a/src/game/server/hl/lights.cpp +++ b/src/game/server/hl/lights.cpp @@ -58,17 +58,17 @@ void CLight ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "style")) { m_iStyle = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "pitch")) { pev->angles.x = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "pattern")) { m_iszPattern = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else { @@ -163,7 +163,7 @@ void CEnvLight::KeyValue(KeyValueData *pkvd) g = pow(g / 114.0, 0.6) * 264; b = pow(b / 114.0, 0.6) * 264; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; _snprintf(szColor, sizeof(szColor), "%d", r ); CVAR_SET_STRING("sv_skycolor_r", szColor); _snprintf(szColor, sizeof(szColor), "%d", g ); diff --git a/src/game/server/hl/monsterevent.h b/src/game/server/hl/monsterevent.h index 78d396fc..b9b637dd 100644 --- a/src/game/server/hl/monsterevent.h +++ b/src/game/server/hl/monsterevent.h @@ -21,14 +21,17 @@ typedef struct char *options; } MonsterEvent_t; -#define EVENT_SPECIFIC 0 -#define EVENT_SCRIPTED 1000 -#define EVENT_SHARED 2000 -#define EVENT_CLIENT 5000 +enum { + EVENT_SPECIFIC = 0, + EVENT_SCRIPTED = 1000, + EVENT_SHARED = 2000, + EVENT_CLIENT = 5000 +}; -#define MONSTER_EVENT_BODYDROP_LIGHT 2001 -#define MONSTER_EVENT_BODYDROP_HEAVY 2002 - -#define MONSTER_EVENT_SWISHSOUND 2010 +enum { + MONSTER_EVENT_BODYDROP_LIGHT = 2001, + MONSTER_EVENT_BODYDROP_HEAVY = 2002, + MONSTER_EVENT_SWISHSOUND = 2010 +}; #endif // MONSTEREVENT_H diff --git a/src/game/server/hl/monsters.cpp b/src/game/server/hl/monsters.cpp index c470bdb0..da5a35c6 100644 --- a/src/game/server/hl/monsters.cpp +++ b/src/game/server/hl/monsters.cpp @@ -34,7 +34,7 @@ #include "soundent.h" #include "gamerules.h" -#define MONSTER_CUT_CORNER_DIST 8 // 8 means the monster's bounding box is contained without the box of the node in WC +constexpr float MONSTER_CUT_CORNER_DIST = 8; // 8 means the monster's bounding box is contained without the box of the node in WC Vector VecBModelOrigin(entvars_t *pevBModel); @@ -153,10 +153,10 @@ BOOL CBaseMonster ::FShouldEat(void) { if (m_flHungryTime > gpGlobals->time) { - return FALSE; + return false; } - return TRUE; + return true; } //========================================================= @@ -286,7 +286,7 @@ float CBaseMonster ::FLSoundVolume(CSound *pSound) //========================================================= BOOL CBaseMonster ::FValidateHintType(short sHint) { - return FALSE; + return false; } //========================================================= @@ -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]) @@ -626,15 +626,15 @@ void CBaseMonster ::RouteNew(void) } //========================================================= -// FRouteClear - returns TRUE is the Route is cleared out +// FRouteClear - returns true is the Route is cleared out // ( invalid ) //========================================================= BOOL CBaseMonster ::FRouteClear(void) { if (m_Route[m_iRouteIndex].iType == 0 || m_movementGoal == MOVEGOAL_NONE) - return TRUE; + return true; - return FALSE; + return false; } //========================================================= @@ -650,7 +650,7 @@ BOOL CBaseMonster ::FRefreshRoute(void) RouteNew(); - returnCode = FALSE; + returnCode = false; switch (m_movementGoal) { @@ -674,7 +674,7 @@ BOOL CBaseMonster ::FRefreshRoute(void) i++; } } - returnCode = TRUE; + returnCode = true; break; case MOVEGOAL_ENEMY: @@ -812,8 +812,8 @@ int ShouldSimplify(int routeType) routeType &= ~bits_MF_IS_GOAL; if ((routeType == bits_MF_TO_PATHCORNER) || (routeType & bits_MF_DONT_SIMPLIFY)) - return FALSE; - return TRUE; + return false; + return true; } //========================================================= @@ -937,7 +937,7 @@ BOOL CBaseMonster ::FBecomeProne(void) } m_IdealMonsterState = MONSTERSTATE_PRONE; - return TRUE; + return true; } //========================================================= @@ -947,9 +947,9 @@ BOOL CBaseMonster ::CheckRangeAttack1(float flDot, float flDist) { if (flDist > 64 && flDist <= 784 && flDot >= 0.5) { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= @@ -959,9 +959,9 @@ BOOL CBaseMonster ::CheckRangeAttack2(float flDot, float flDist) { if (flDist > 64 && flDist <= 512 && flDot >= 0.5) { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= @@ -972,9 +972,9 @@ BOOL CBaseMonster ::CheckMeleeAttack1(float flDot, float flDist) // Decent fix to keep folks from kicking/punching hornets and snarks is to check the onground flag(sjb) if (flDist <= 64 && flDot >= 0.7 && m_hEnemy != NULL && FBitSet(m_hEnemy->pev->flags, FL_ONGROUND)) { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= @@ -984,9 +984,9 @@ BOOL CBaseMonster ::CheckMeleeAttack2(float flDot, float flDist) { if (flDist <= 64 && flDot >= 0.7) { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= @@ -1042,23 +1042,23 @@ BOOL CBaseMonster ::FCanCheckAttacks(void) { if (HasConditions(bits_COND_SEE_ENEMY) && !HasConditions(bits_COND_ENEMY_TOOFAR)) { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= // CheckEnemy - part of the Condition collection process, // gets and stores data and conditions pertaining to a monster's -// enemy. Returns TRUE if Enemy LKP was updated. +// enemy. Returns true if Enemy LKP was updated. //========================================================= int CBaseMonster ::CheckEnemy(CBaseEntity *pEnemy) { float flDistToEnemy; - int iUpdatedLKP; // set this to TRUE if you update the EnemyLKP in this function. + int iUpdatedLKP; // set this to true if you update the EnemyLKP in this function. - iUpdatedLKP = FALSE; + iUpdatedLKP = false; ClearConditions(bits_COND_ENEMY_FACING_ME); if (!FVisible(pEnemy)) @@ -1073,7 +1073,7 @@ int CBaseMonster ::CheckEnemy(CBaseEntity *pEnemy) { SetConditions(bits_COND_ENEMY_DEAD); ClearConditions(bits_COND_SEE_ENEMY | bits_COND_ENEMY_OCCLUDED); - return FALSE; + return false; } Vector vecEnemyPos = pEnemy->pev->origin; @@ -1097,7 +1097,7 @@ int CBaseMonster ::CheckEnemy(CBaseEntity *pEnemy) { CBaseMonster *pEnemyMonster; - iUpdatedLKP = TRUE; + iUpdatedLKP = true; m_vecEnemyLKP = pEnemy->pev->origin; pEnemyMonster = pEnemy->MyMonsterPointer(); @@ -1127,7 +1127,7 @@ int CBaseMonster ::CheckEnemy(CBaseEntity *pEnemy) // if the enemy is not occluded, and unseen, that means it is behind or beside the monster. // if the enemy is near enough the monster, we go ahead and let the monster know where the // enemy is. - iUpdatedLKP = TRUE; + iUpdatedLKP = true; m_vecEnemyLKP = pEnemy->pev->origin; } @@ -1204,7 +1204,7 @@ BOOL CBaseMonster ::PopEnemy() m_hEnemy = m_hOldEnemy[i]; m_vecEnemyLKP = m_vecOldEnemy[i]; // ALERT( at_console, "remembering\n"); - return TRUE; + return true; } else { @@ -1212,7 +1212,7 @@ BOOL CBaseMonster ::PopEnemy() } } } - return FALSE; + return false; } //========================================================= @@ -1281,7 +1281,7 @@ void CBaseMonster ::SetSequenceByName(char *szSequence) } //========================================================= -// CheckLocalMove - returns TRUE if the caller can walk a +// CheckLocalMove - returns true if the caller can walk a // straight line from its current origin to the given // location. If so, don't use the node graph! // @@ -1293,7 +1293,7 @@ void CBaseMonster ::SetSequenceByName(char *szSequence) // !!!PERFORMANCE - should we try to load balance this? // DON"T USE SETORIGIN! //========================================================= -#define LOCAL_STEP_SIZE 16 +constexpr float LOCAL_STEP_SIZE = 16; int CBaseMonster ::CheckLocalMove(const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist) { Vector vecStartPos; // record monster's position before trying the move @@ -1329,7 +1329,7 @@ int CBaseMonster ::CheckLocalMove(const Vector &vecStart, const Vector &vecEnd, // since we've actually moved the monster during the check, undo the move. pev->origin = vecStartPos; - return FALSE; + return false; } */ // this loop takes single steps to the goal. @@ -1359,7 +1359,7 @@ int CBaseMonster ::CheckLocalMove(const Vector &vecStart, const Vector &vecEnd, { // If we're going toward an entity, and we're almost getting there, it's OK. // if ( pTarget && fabs( flDist - iStep ) < LOCAL_STEP_SIZE ) - // fReturn = TRUE; + // fReturn = true; // else iReturn = LOCALMOVE_INVALID; break; @@ -1552,7 +1552,7 @@ BOOL CBaseMonster ::BuildRoute(const Vector &vecGoal, int iMoveFlag, CBaseEntity if (iLocalMove == LOCALMOVE_VALID) { // monster can walk straight there! - return TRUE; + return true; } // try to triangulate around any obstacles. else if (iLocalMove != LOCALMOVE_INVALID_DONT_TRIANGULATE && FTriangulate(pev->origin, vecGoal, flDist, pTarget, &vecApex)) @@ -1576,7 +1576,7 @@ BOOL CBaseMonster ::BuildRoute(const Vector &vecGoal, int iMoveFlag, CBaseEntity */ RouteSimplify(pTarget); - return TRUE; + return true; } // last ditch, try nodes @@ -1585,11 +1585,11 @@ BOOL CBaseMonster ::BuildRoute(const Vector &vecGoal, int iMoveFlag, CBaseEntity // ALERT ( at_console, "Can get there on nodes\n" ); m_vecMoveGoal = vecGoal; RouteSimplify(pTarget); - return TRUE; + return true; } // b0rk - return FALSE; + return false; } //========================================================= @@ -1729,7 +1729,7 @@ BOOL CBaseMonster ::FTriangulate(const Vector &vecStart, const Vector &vecEnd, f *pApex = vecRight; } - return TRUE; + return true; } } if (CheckLocalMove(pev->origin, vecLeft, pTargetEnt, NULL) == LOCALMOVE_VALID) @@ -1741,7 +1741,7 @@ BOOL CBaseMonster ::FTriangulate(const Vector &vecStart, const Vector &vecEnd, f *pApex = vecLeft; } - return TRUE; + return true; } } @@ -1757,7 +1757,7 @@ BOOL CBaseMonster ::FTriangulate(const Vector &vecStart, const Vector &vecEnd, f //ALERT(at_aiconsole, "triangulate over\n"); } - return TRUE; + return true; } } #if 1 @@ -1771,7 +1771,7 @@ BOOL CBaseMonster ::FTriangulate(const Vector &vecStart, const Vector &vecEnd, f //ALERT(at_aiconsole, "triangulate under\n"); } - return TRUE; + return true; } } #endif @@ -1786,13 +1786,13 @@ BOOL CBaseMonster ::FTriangulate(const Vector &vecStart, const Vector &vecEnd, f } } - return FALSE; + return false; } //========================================================= // Move - take a single step towards the next ROUTE location //========================================================= -#define DIST_TO_CHECK 200 +constexpr float DIST_TO_CHECK = 200; void CBaseMonster ::Move(float flInterval) { @@ -1968,10 +1968,10 @@ BOOL CBaseMonster::ShouldAdvanceRoute(float flWaypointDist) if (flWaypointDist <= MONSTER_CUT_CORNER_DIST) { // ALERT( at_console, "cut %f\n", flWaypointDist ); - return TRUE; + return true; } - return FALSE; + return false; } void CBaseMonster::MoveExecute(CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval) @@ -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; @@ -2255,7 +2255,7 @@ BOOL CBaseMonster ::FindCover(Vector vecThreat, Vector vecViewOffset, float flMi if (!WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet) { ALERT(at_aiconsole, "Graph not ready for findcover!\n"); - return FALSE; + return false; } iMyNode = WorldGraph.FindNearestNode(pev->origin, this); @@ -2265,13 +2265,13 @@ BOOL CBaseMonster ::FindCover(Vector vecThreat, Vector vecViewOffset, float flMi if (iMyNode == NO_NODE) { ALERT(at_aiconsole, "FindCover() - %s has no nearest node!\n", STRING(pev->classname)); - return FALSE; + return false; } if (iThreatNode == NO_NODE) { // ALERT ( at_aiconsole, "FindCover() - Threat has no nearest node!\n" ); iThreatNode = iMyNode; - // return FALSE; + // return false; } vecLookersOffset = vecThreat + vecViewOffset; // calculate location of enemy's eyes @@ -2315,13 +2315,13 @@ BOOL CBaseMonster ::FindCover(Vector vecThreat, Vector vecViewOffset, float flMi MESSAGE_END(); */ - return TRUE; + return true; } } } } } - return FALSE; + return false; } //========================================================= @@ -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; @@ -2359,7 +2359,7 @@ BOOL CBaseMonster ::BuildNearestRoute(Vector vecThreat, Vector vecViewOffset, fl if (!WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet) { ALERT(at_aiconsole, "Graph not ready for BuildNearestRoute!\n"); - return FALSE; + return false; } iMyNode = WorldGraph.FindNearestNode(pev->origin, this); @@ -2368,7 +2368,7 @@ BOOL CBaseMonster ::BuildNearestRoute(Vector vecThreat, Vector vecViewOffset, fl if (iMyNode == NO_NODE) { ALERT(at_aiconsole, "BuildNearestRoute() - %s has no nearest node!\n", STRING(pev->classname)); - return FALSE; + return false; } vecLookersOffset = vecThreat + vecViewOffset; // calculate location of enemy's eyes @@ -2399,14 +2399,14 @@ BOOL CBaseMonster ::BuildNearestRoute(Vector vecThreat, Vector vecViewOffset, fl { flMaxDist = flDist; m_vecMoveGoal = node.m_vecOrigin; - return TRUE; // UNDONE: keep looking for something closer! + return true; // UNDONE: keep looking for something closer! } } } } } - return FALSE; + return false; } //========================================================= @@ -2656,12 +2656,12 @@ void CBaseMonster ::HandleAnimEvent(MonsterEvent_t *pEvent) case SCRIPT_EVENT_NOINTERRUPT: // Can't be interrupted from now on if (m_pCine) - m_pCine->AllowInterrupt(FALSE); + m_pCine->AllowInterrupt(false); break; case SCRIPT_EVENT_CANINTERRUPT: // OK to interrupt now if (m_pCine) - m_pCine->AllowInterrupt(TRUE); + m_pCine->AllowInterrupt(true); break; #if 0 @@ -2733,8 +2733,8 @@ Vector CBaseMonster ::GetGunPosition() // FGetNodeRoute - tries to build an entire node path from // the callers origin to the passed vector. If this is // possible, ROUTE_SIZE waypoints will be copied into the -// callers m_Route. TRUE is returned if the operation -// succeeds (path is valid) or FALSE if failed (no path +// callers m_Route. true is returned if the operation +// succeeds (path is valid) or false if failed (no path // exists ) //========================================================= BOOL CBaseMonster ::FGetNodeRoute(Vector vecDest) @@ -2752,13 +2752,13 @@ BOOL CBaseMonster ::FGetNodeRoute(Vector vecDest) { // no node nearest self // ALERT ( at_aiconsole, "FGetNodeRoute: No valid node near self!\n" ); - return FALSE; + return false; } else if (iDestNode == -1) { // no node nearest target // ALERT ( at_aiconsole, "FGetNodeRoute: No valid node near target!\n" ); - return FALSE; + return false; } // valid src and dest nodes were found, so it's safe to proceed with @@ -2770,16 +2770,16 @@ BOOL CBaseMonster ::FGetNodeRoute(Vector vecDest) { #if 1 ALERT(at_aiconsole, "No Path from %d to %d!\n", iSrcNode, iDestNode); - return FALSE; + return false; #else BOOL bRoutingSave = WorldGraph.m_fRoutingComplete; - WorldGraph.m_fRoutingComplete = FALSE; + WorldGraph.m_fRoutingComplete = false; iResult = WorldGraph.FindShortestPath(iPath, iSrcNode, iDestNode, iNodeHull, m_afCapability); WorldGraph.m_fRoutingComplete = bRoutingSave; if (!iResult) { ALERT(at_aiconsole, "No Path from %d to %d!\n", iSrcNode, iDestNode); - return FALSE; + return false; } else { @@ -2814,7 +2814,7 @@ BOOL CBaseMonster ::FGetNodeRoute(Vector vecDest) m_Route[iNumToCopy].iType |= bits_MF_IS_GOAL; } - return TRUE; + return true; } //========================================================= @@ -2822,7 +2822,7 @@ BOOL CBaseMonster ::FGetNodeRoute(Vector vecDest) //========================================================= int CBaseMonster ::FindHintNode(void) { - int i; + unsigned int i; TraceResult tr; if (!WorldGraph.m_fGraphPresent) @@ -2953,12 +2953,12 @@ void CBaseMonster ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "TriggerTarget")) { m_iszTriggerTarget = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "TriggerCondition")) { m_iTriggerCondition = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else { @@ -2971,7 +2971,7 @@ void CBaseMonster ::KeyValue(KeyValueData *pkvd) // if there is a condition, then checks to see if condition is // met. If yes, the monster's TriggerTarget is fired. // -// Returns TRUE if the target is fired. +// Returns true if the target is fired. //========================================================= BOOL CBaseMonster ::FCheckAITrigger(void) { @@ -2980,23 +2980,23 @@ BOOL CBaseMonster ::FCheckAITrigger(void) if (m_iTriggerCondition == AITRIGGER_NONE) { // no conditions, so this trigger is never fired. - return FALSE; + return false; } - fFireTarget = FALSE; + fFireTarget = false; switch (m_iTriggerCondition) { case AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER: if (m_hEnemy != NULL && m_hEnemy->IsPlayer() && HasConditions(bits_COND_SEE_ENEMY)) { - fFireTarget = TRUE; + fFireTarget = true; } break; case AITRIGGER_SEEPLAYER_UNCONDITIONAL: if (HasConditions(bits_COND_SEE_CLIENT)) { - fFireTarget = TRUE; + fFireTarget = true; } break; case AITRIGGER_SEEPLAYER_NOT_IN_COMBAT: @@ -3005,25 +3005,25 @@ BOOL CBaseMonster ::FCheckAITrigger(void) m_MonsterState != MONSTERSTATE_PRONE && m_MonsterState != MONSTERSTATE_SCRIPT) { - fFireTarget = TRUE; + fFireTarget = true; } break; case AITRIGGER_TAKEDAMAGE: if (m_afConditions & (bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE)) { - fFireTarget = TRUE; + fFireTarget = true; } break; case AITRIGGER_DEATH: if (pev->deadflag != DEAD_NO) { - fFireTarget = TRUE; + fFireTarget = true; } break; case AITRIGGER_HALFHEALTH: if (IsAlive() && pev->health <= (pev->max_health / 2)) { - fFireTarget = TRUE; + fFireTarget = true; } break; /* @@ -3038,19 +3038,19 @@ BOOL CBaseMonster ::FCheckAITrigger(void) case AITRIGGER_HEARWORLD: if (m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_WORLD) { - fFireTarget = TRUE; + fFireTarget = true; } break; case AITRIGGER_HEARPLAYER: if (m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_PLAYER) { - fFireTarget = TRUE; + fFireTarget = true; } break; case AITRIGGER_HEARCOMBAT: if (m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_COMBAT) { - fFireTarget = TRUE; + fFireTarget = true; } break; } @@ -3061,10 +3061,10 @@ BOOL CBaseMonster ::FCheckAITrigger(void) ALERT(at_aiconsole, "AI Trigger Fire Target\n"); FireTargets(STRING(m_iszTriggerTarget), this, this, USE_TOGGLE, 0); m_iTriggerCondition = AITRIGGER_NONE; - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= @@ -3079,26 +3079,26 @@ int CBaseMonster ::CanPlaySequence(BOOL fDisregardMonsterState, int interruptLev if (m_pCine || !IsAlive() || m_MonsterState == MONSTERSTATE_PRONE) { // monster is already running a scripted sequence or dead! - return FALSE; + return false; } if (fDisregardMonsterState) { // ok to go, no matter what the monster state. (scripted AI) - return TRUE; + return true; } if (m_MonsterState == MONSTERSTATE_NONE || m_MonsterState == MONSTERSTATE_IDLE || m_IdealMonsterState == MONSTERSTATE_IDLE) { // ok to go, but only in these states - return TRUE; + return true; } if (m_MonsterState == MONSTERSTATE_ALERT && interruptLevel >= SS_INTERRUPT_BY_NAME) - return TRUE; + return true; // unknown situation - return FALSE; + return false; } //========================================================= @@ -3106,8 +3106,10 @@ int CBaseMonster ::CanPlaySequence(BOOL fDisregardMonsterState, int interruptLev // directly to the left or right of the caller that will // conceal them from view of pSightEnt //========================================================= -#define COVER_CHECKS 5 // how many checks are made -#define COVER_DELTA 48 // distance between checks + + +constexpr unsigned int COVER_CHECKS = 5; // how many checks are made +constexpr unsigned int COVER_DELTA = 48; // distance between checks BOOL CBaseMonster ::FindLateralCover(const Vector &vecThreat, const Vector &vecViewOffset) { @@ -3139,7 +3141,7 @@ BOOL CBaseMonster ::FindLateralCover(const Vector &vecThreat, const Vector &vecV { if (MoveToLocation(ACT_RUN, 0, vecLeftTest)) { - return TRUE; + return true; } } } @@ -3153,13 +3155,13 @@ BOOL CBaseMonster ::FindLateralCover(const Vector &vecThreat, const Vector &vecV { if (MoveToLocation(ACT_RUN, 0, vecRightTest)) { - return TRUE; + return true; } } } } - return FALSE; + return false; } Vector CBaseMonster ::ShootAtEnemy(const Vector &shootOrigin) @@ -3185,10 +3187,10 @@ BOOL CBaseMonster ::FacingIdeal(void) { if (fabs(FlYawDiff()) <= 0.006) //!!!BUGBUG - no magic numbers!!! { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= @@ -3199,10 +3201,10 @@ BOOL CBaseMonster ::FCanActiveIdle(void) /* if ( m_MonsterState == MONSTERSTATE_IDLE && m_IdealMonsterState == MONSTERSTATE_IDLE && !IsMoving() ) { - return TRUE; + return true; } */ - return FALSE; + return false; } void CBaseMonster::PlaySentence(const char *pszSentence, float duration, float volume, float attenuation) @@ -3294,7 +3296,7 @@ BOOL CBaseMonster ::BBoxFlat(void) flLength2 = (vecPoint - tr.vecEndPos).Length(); if (flLength2 > flLength) { - return FALSE; + return false; } flLength = flLength2; @@ -3304,7 +3306,7 @@ BOOL CBaseMonster ::BBoxFlat(void) flLength2 = (vecPoint - tr.vecEndPos).Length(); if (flLength2 > flLength) { - return FALSE; + return false; } flLength = flLength2; @@ -3314,11 +3316,11 @@ BOOL CBaseMonster ::BBoxFlat(void) flLength2 = (vecPoint - tr.vecEndPos).Length(); if (flLength2 > flLength) { - return FALSE; + return false; } flLength = flLength2; - return TRUE; + return true; } //========================================================= @@ -3373,10 +3375,10 @@ BOOL CBaseMonster ::GetEnemy(void) if (m_hEnemy != NULL) { // monster has an enemy. - return TRUE; + return true; } - return FALSE; // monster has no enemy + return false; // monster has no enemy } //========================================================= @@ -3402,7 +3404,7 @@ CBaseEntity *CBaseMonster ::DropItem(char *pszItemName, const Vector &vecPos, co else { ALERT(at_console, "DropItem() - Didn't create!\n"); - return FALSE; + return nullptr; } } @@ -3410,7 +3412,7 @@ BOOL CBaseMonster ::ShouldFadeOnDeath(void) { // if flagged to fade out or I have an owner (I came from a monster spawner) if ((pev->spawnflags & SF_MONSTER_FADECORPSE) || !FNullEnt(pev->owner)) - return TRUE; + return true; - return FALSE; + return false; } diff --git a/src/game/server/hl/monsters.h b/src/game/server/hl/monsters.h index f2e64b1d..3ac15994 100644 --- a/src/game/server/hl/monsters.h +++ b/src/game/server/hl/monsters.h @@ -25,45 +25,54 @@ */ // CHECKLOCALMOVE result types -#define LOCALMOVE_INVALID 0 // move is not possible -#define LOCALMOVE_INVALID_DONT_TRIANGULATE 1 // move is not possible, don't try to triangulate -#define LOCALMOVE_VALID 2 // move is possible - -// Hit Group standards -#define HITGROUP_GENERIC 0 -#define HITGROUP_HEAD 1 -#define HITGROUP_CHEST 2 -#define HITGROUP_STOMACH 3 -#define HITGROUP_LEFTARM 4 -#define HITGROUP_RIGHTARM 5 -#define HITGROUP_LEFTLEG 6 -#define HITGROUP_RIGHTLEG 7 - -// Monster Spawnflags -#define SF_MONSTER_WAIT_TILL_SEEN 1 // spawnflag that makes monsters wait until player can see them before attacking. -#define SF_MONSTER_GAG 2 // no idle noises from this monster -#define SF_MONSTER_HITMONSTERCLIP 4 -// 8 -#define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him. + +enum localmove_e { + LOCALMOVE_INVALID = 0, // move is not possible + LOCALMOVE_INVALID_DONT_TRIANGULATE = 1, // move is not possible, don't try to triangulate + LOCALMOVE_VALID = 2 // move is possible +}; + +enum hitgroup_e { + // Hit Group standards + + HITGROUP_GENERIC = 0, + HITGROUP_HEAD = 1, + HITGROUP_CHEST = 2, + HITGROUP_STOMACH = 3, + HITGROUP_LEFTARM = 4, + HITGROUP_RIGHTARM = 5, + HITGROUP_LEFTLEG = 6, + HITGROUP_RIGHTLEG = 7 +}; + +enum monster_sf_e { + // Monster Spawnflags + SF_MONSTER_WAIT_TILL_SEEN = 1, // spawnflag that makes monsters wait until player can see them before attacking. + SF_MONSTER_GAG = 2, // no idle noises from this monster + SF_MONSTER_HITMONSTERCLIP = 4, +// 8 + SF_MONSTER_PRISONER = 16, // monster won't attack anyone, no one will attacke him. // 32 // 64 -#define SF_MONSTER_WAIT_FOR_SCRIPT 128 //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked -#define SF_MONSTER_PREDISASTER 256 //this is a predisaster scientist or barney. Influences how they speak. -#define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death -#define SF_MONSTER_FALL_TO_GROUND 0x80000000 + SF_MONSTER_WAIT_FOR_SCRIPT = 128, //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked + SF_MONSTER_PREDISASTER = 256, //this is a predisaster scientist or barney. Influences how they speak. + SF_MONSTER_FADECORPSE = 512, // Fade out corpse after death + SF_MONSTER_FALL_TO_GROUND = 0x80000000, // specialty spawnflags -#define SF_MONSTER_TURRET_AUTOACTIVATE 32 -#define SF_MONSTER_TURRET_STARTINACTIVE 64 -#define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked -// MoveToOrigin stuff -#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal -#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. + SF_MONSTER_TURRET_AUTOACTIVATE = 32, + SF_MONSTER_TURRET_STARTINACTIVE = 64, + SF_MONSTER_WAIT_UNTIL_PROVOKED = 64 // don't attack the player unless provoked +}; -// MoveToOrigin stuff -#define MOVE_NORMAL 0 // normal move in the direction monster is facing -#define MOVE_STRAFE 1 // moves in direction specified, no matter which way monster is facing +enum move_origin_e { + // MoveToOrigin stuff + MOVE_NORMAL = 0 ,// normal move in the direction monster is facing + MOVE_STRAFE = 1 ,// moves in direction specified, no matter which way monster is facing + MOVE_STUCK_DIST = 32, // if a monster can't step this far, it is stuck. + MOVE_START_TURN_DIST = 64 // when this far away from moveGoal, start turning to face next goal +}; // spawn flags 256 and above are already taken by the engine extern void UTIL_MoveToOrigin(edict_t *pent, const Vector &vecGoal, float flDist, int iMoveType); @@ -71,9 +80,9 @@ extern void UTIL_MoveToOrigin(edict_t *pent, const Vector &vecGoal, float flDist Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1.0); Vector VecCheckThrow(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1.0); extern DLL_GLOBAL Vector g_vecAttackDir; -extern DLL_GLOBAL CONSTANT float g_flMeleeRange; -extern DLL_GLOBAL CONSTANT float g_flMediumRange; -extern DLL_GLOBAL CONSTANT float g_flLongRange; +extern DLL_GLOBAL float g_flMeleeRange; +extern DLL_GLOBAL float g_flMediumRange; +extern DLL_GLOBAL float g_flLongRange; extern void EjectBrass(const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype); extern void ExplodeModel(const Vector &vecOrigin, float speed, int model, int count); @@ -81,31 +90,38 @@ BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget); BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0.0); // monster to monster relationship types -#define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable. -#define R_FR -1 // (FEAR)will run -#define R_NO 0 // (NO RELATIONSHIP) disregard -#define R_DL 1 // (DISLIKE) will attack -#define R_HT 2 // (HATE)will attack this character instead of any visible DISLIKEd characters -#define R_NM 3 // (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what + +enum monster_relationship_e { + R_AL = -2, // (ALLY) pals. Good alternative to R_NO when applicable. + R_FR = -1, // (FEAR)will run + R_NO = 0, // (NO RELATIONSHIP) disregard + R_DL = 1, // (DISLIKE) will attack + R_HT = 2, // (HATE)will attack this character instead of any visible DISLIKEd characters + R_NM = 3 // (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what +}; // these bits represent the monster's memory -#define MEMORY_CLEAR 0 -#define bits_MEMORY_PROVOKED (1 << 0) // right now only used for houndeyes. -#define bits_MEMORY_INCOVER (1 << 1) // monster knows it is in a covered position. -#define bits_MEMORY_SUSPICIOUS (1 << 2) // Ally is suspicious of the player, and will move to provoked more easily -#define bits_MEMORY_PATH_FINISHED (1 << 3) // Finished monster path (just used by big momma for now) -#define bits_MEMORY_ON_PATH (1 << 4) // Moving on a path -#define bits_MEMORY_MOVE_FAILED (1 << 5) // Movement has already failed -#define bits_MEMORY_FLINCHED (1 << 6) // Has already flinched -#define bits_MEMORY_KILLED (1 << 7) // HACKHACK -- remember that I've already called my Killed() -#define bits_MEMORY_CUSTOM4 (1 << 28) // Monster-specific memory -#define bits_MEMORY_CUSTOM3 (1 << 29) // Monster-specific memory -#define bits_MEMORY_CUSTOM2 (1 << 30) // Monster-specific memory -#define bits_MEMORY_CUSTOM1 (1 << 31) // Monster-specific memory +enum monster_bits_e { + + MEMORY_CLEAR = 0, + bits_MEMORY_PROVOKED = (1 << 0), // right now only used for houndeyes. + bits_MEMORY_INCOVER = (1 << 1), // monster knows it is in a covered position. + bits_MEMORY_SUSPICIOUS = (1 << 2), // Ally is suspicious of the player, and will move to provoked more easily + bits_MEMORY_PATH_FINISHED = (1 << 3), // Finished monster path (just used by big momma for now) + bits_MEMORY_ON_PATH = (1 << 4), // Moving on a path + bits_MEMORY_MOVE_FAILED = (1 << 5), // Movement has already failed + bits_MEMORY_FLINCHED = (1 << 6), // Has already flinched + bits_MEMORY_KILLED = (1 << 7), // HACKHACK -- remember that I've already called my Killed() + bits_MEMORY_CUSTOM4 = (1 << 28), // Monster-specific memory + bits_MEMORY_CUSTOM3 = (1 << 29), // Monster-specific memory + bits_MEMORY_CUSTOM2 = (1 << 30), // Monster-specific memory + bits_MEMORY_CUSTOM1 = (1 << 31), // Monster-specific memory + +}; // trigger conditions for scripted AI // these MUST match the CHOICES interface in halflife.fgd for the base monster -enum +enum aitrigger_e { AITRIGGER_NONE = 0, AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER, diff --git a/src/game/server/hl/nodes.cpp b/src/game/server/hl/nodes.cpp index 8c4eb71f..2ada603d 100644 --- a/src/game/server/hl/nodes.cpp +++ b/src/game/server/hl/nodes.cpp @@ -26,13 +26,11 @@ #include "doors.h" #include "filesystem_shared.h" -#define HULL_STEP_SIZE 16 // how far the test hull moves on each step -#define NODE_HEIGHT 8 // how high to lift nodes off the ground after we drop them all (make stair/ramp mapping easier) + // to help eliminate node clutter by level designers, this is used to cap how many other nodes // any given node is allowed to 'see' in the first stage of graph creation "LinkVisibleNodes()". -#define MAX_NODE_INITIAL_LINKS 128 -#define MAX_NODES 1024 + extern DLL_GLOBAL edict_t *g_pBodyQueueHead; @@ -53,9 +51,9 @@ void CGraph ::InitGraph(void) // Make the graph unavailable // - m_fGraphPresent = FALSE; - m_fGraphPointersSet = FALSE; - m_fRoutingComplete = FALSE; + m_fGraphPresent = false; + m_fGraphPointersSet = false; + m_fRoutingComplete = false; // Free the link pool // @@ -117,10 +115,10 @@ int CGraph ::AllocNodes(void) if (!WorldGraph.m_pNodes) { ALERT(at_aiconsole, "**ERROR**\nCouldn't malloc %d nodes!\n", WorldGraph.m_cNodes); - return FALSE; + return false; } - return TRUE; + return true; } //========================================================= @@ -213,13 +211,13 @@ int CGraph ::HandleLinkEnt(int iNode, entvars_t *pevLinkEnt, int afCapMask, NODE if (!m_fGraphPresent || !m_fGraphPointersSet) { // protect us in the case that the node graph isn't available ALERT(at_aiconsole, "Graph not ready!\n"); - return FALSE; + return false; } if (FNullEnt(pevLinkEnt)) { ALERT(at_aiconsole, "dead path ent!\n"); - return TRUE; + return true; } pentWorld = NULL; @@ -234,17 +232,17 @@ int CGraph ::HandleLinkEnt(int iNode, entvars_t *pevLinkEnt, int afCapMask, NODE if ((afCapMask & bits_CAP_OPEN_DOORS)) { // let monster right through if he can open doors - return TRUE; + return true; } else { // monster should try for it if the door is open and looks as if it will stay that way if (pDoor->GetToggleState() == TS_AT_TOP && (pevLinkEnt->spawnflags & SF_DOOR_NO_AUTO_RETURN)) { - return TRUE; + return true; } - return FALSE; + return false; } } else @@ -253,35 +251,35 @@ int CGraph ::HandleLinkEnt(int iNode, entvars_t *pevLinkEnt, int afCapMask, NODE // monster should try for it if the door is open and looks as if it will stay that way if (pDoor->GetToggleState() == TS_AT_TOP && (pevLinkEnt->spawnflags & SF_DOOR_NO_AUTO_RETURN)) { - return TRUE; + return true; } if ((afCapMask & bits_CAP_OPEN_DOORS)) { if (!(pevLinkEnt->spawnflags & SF_DOOR_NOMONSTERS) || queryType == NODEGRAPH_STATIC) - return TRUE; + return true; } - return FALSE; + return false; } } // func_breakable else if (FClassnameIs(pevLinkEnt, "func_breakable") && queryType == NODEGRAPH_STATIC) { - return TRUE; + return true; } else { ALERT(at_aiconsole, "Unhandled Ent in Path %s\n", STRING(pevLinkEnt->classname)); - return FALSE; + return false; } - return FALSE; + return false; } #if 0 //========================================================= // FindNearestLink - finds the connection (line) nearest -// the given point. Returns FALSE if fails, or TRUE if it +// the given point. Returns false if fails, or true if it // has stuffed the index into the nearest link pool connection // into the passed int pointer, and a BOOL telling whether or // not the point is along the line into the passed BOOL pointer. @@ -306,7 +304,7 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, TraceResult tr; iNearestLink = -1;// prepare for failure - fSuccess = FALSE; + fSuccess = false; flMinDist = 9999;// anything will be closer than this @@ -370,17 +368,17 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, if ( DotProduct ( vec2Line, ( vec2TestPoint - vec2Spot1 ) ) > 0 ) {// point outside of line flDistToLine = ( vec2TestPoint - vec2Spot1 ).Length(); - fCurrentAlongLine = FALSE; + fCurrentAlongLine = false; } else if ( DotProduct ( vec2Line, ( vec2TestPoint - vec2Spot2 ) ) < 0 ) {// point outside of line flDistToLine = ( vec2TestPoint - vec2Spot2 ).Length(); - fCurrentAlongLine = FALSE; + fCurrentAlongLine = false; } else {// point inside line flDistToLine = fabs( DotProduct ( vec2TestPoint - vec2Spot2, vec2Normal ) ); - fCurrentAlongLine = TRUE; + fCurrentAlongLine = true; } if ( flDistToLine < flMinDist ) @@ -399,7 +397,7 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, } - fSuccess = TRUE;// we know there will be something to return. + fSuccess = true;// we know there will be something to return. flMinDist = flDistToLine; iNearestLink = m_pNodes [ i ].m_iFirstLink + j; *piNearestLink = m_pNodes[ i ].m_iFirstLink + j; @@ -507,15 +505,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 +538,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) @@ -579,13 +577,13 @@ int CGraph ::FindShortestPath(int *piPath, int iStart, int iDest, int iHull, int if (!m_fGraphPresent || !m_fGraphPointersSet) { // protect us in the case that the node graph isn't available or built ALERT(at_aiconsole, "Graph not ready!\n"); - return FALSE; + 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; + return false; } if (iStart == iDest) @@ -651,7 +649,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 +890,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 +932,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 +1132,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 +1188,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 @@ -1204,7 +1202,7 @@ int CGraph ::LinkVisibleNodes(CLink *pLinkPool, CFile &file, int *piBadNode) if (m_cNodes <= 0) { ALERT(at_aiconsole, "No Nodes!\n"); - return FALSE; + return false; } // if the file pointer is bad, don't blow up, just don't write the @@ -1340,13 +1338,13 @@ int CGraph ::LinkVisibleNodes(CLink *pLinkPool, CFile &file, int *piBadNode) ALERT(at_aiconsole, "**LinkVisibleNodes:\nNode %d has NodeLinks > MAX_NODE_INITIAL_LINKS", i); file.Printf("** NODE %d HAS NodeLinks > MAX_NODE_INITIAL_LINKS **\n", i); *piBadNode = i; - return FALSE; + return false; } else if (cTotalLinks > MAX_NODE_INITIAL_LINKS * m_cNodes) { // this is paranoia ALERT(at_aiconsole, "**LinkVisibleNodes:\nTotalLinks > MAX_NODE_INITIAL_LINKS * NUMNODES"); *piBadNode = i; - return FALSE; + return false; } if (cLinksThisNode == 0) @@ -1385,7 +1383,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; @@ -1427,7 +1425,7 @@ int CGraph ::RejectInlineLinks(CLink *pLinkPool, CFile &file) pLinkPool[pSrcNode->m_iFirstLink + j].m_flWeight = flDistToCheckNode; - fRestartLoop = FALSE; + fRestartLoop = false; for (k = 0; k < pSrcNode->m_cNumLinks && !fRestartLoop; k++) { if (k == j) @@ -1458,7 +1456,7 @@ int CGraph ::RejectInlineLinks(CLink *pLinkPool, CFile &file) cRejectedLinks++; // keeping track of how many links are cut, so that we can return that value. - fRestartLoop = TRUE; + fRestartLoop = true; } } } @@ -1550,13 +1548,13 @@ void CNodeEnt ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "hinttype")) { m_sHintType = (short)atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } if (FStrEq(pkvd->szKeyName, "activity")) { m_sHintActivity = (short)atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); @@ -1588,7 +1586,7 @@ void CNodeEnt ::Spawn(void) } WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_vecOriginPeek = - WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_vecOrigin = pev->origin; + WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_vecOrigin = pev->origin; WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_flHintYaw = pev->angles.y; WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_sHintType = m_sHintType; WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_sHintActivity = m_sHintActivity; @@ -1629,9 +1627,9 @@ extern BOOL gTouchDisabled; void CTestHull::CallBuildNodeGraph(void) { // TOUCH HACK -- Don't allow this entity to call anyone's "touch" function - gTouchDisabled = TRUE; + gTouchDisabled = true; BuildNodeGraph(); - gTouchDisabled = FALSE; + gTouchDisabled = false; // Undo TOUCH HACK } @@ -1655,11 +1653,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; @@ -1812,7 +1810,7 @@ void CTestHull ::BuildNodeGraph(void) // if we can't fit a tiny hull through a connection, no other hulls with fit either, so we // should just fall out of the loop. Do so by setting the SkipRemainingHulls flag. - fSkipRemainingHulls = FALSE; + fSkipRemainingHulls = false; for (hull = 0; hull < MAX_NODE_HULLS; hull++) { if (fSkipRemainingHulls && (hull == NODE_HUMAN_HULL || hull == NODE_LARGE_HULL)) // skip the remaining walk hulls @@ -1873,7 +1871,7 @@ void CTestHull ::BuildNodeGraph(void) flDist = (vecSpot - pev->origin).Length2D(); - int fWalkFailed = FALSE; + int fWalkFailed = false; // in this loop we take tiny steps from the current node to the nodes that it links to, one at a time. // pev->angles.y = flYaw; @@ -1887,7 +1885,7 @@ void CTestHull ::BuildNodeGraph(void) if (!WALK_MOVE(ENT(pev), flYaw, stepSize, MoveMode)) { // can't take the next step - fWalkFailed = TRUE; + fWalkFailed = true; break; } } @@ -1896,7 +1894,7 @@ void CTestHull ::BuildNodeGraph(void) { // ALERT( at_console, "bogus walk\n"); // we thought we - fWalkFailed = TRUE; + fWalkFailed = true; } if (fWalkFailed) @@ -1910,12 +1908,12 @@ void CTestHull ::BuildNodeGraph(void) case NODE_SMALL_HULL: // if this hull can't fit, nothing can, so drop the connection file.Printf("NODE_SMALL_HULL step %i\n", step); pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo &= ~(bits_LINK_SMALL_HULL | bits_LINK_HUMAN_HULL | bits_LINK_LARGE_HULL); - fSkipRemainingHulls = TRUE; // don't bother checking larger hulls + fSkipRemainingHulls = true; // don't bother checking larger hulls break; case NODE_HUMAN_HULL: file.Printf("NODE_HUMAN_HULL step %i\n", step); pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo &= ~(bits_LINK_HUMAN_HULL | bits_LINK_LARGE_HULL); - fSkipRemainingHulls = TRUE; // don't bother checking larger hulls + fSkipRemainingHulls = true; // don't bother checking larger hulls break; case NODE_LARGE_HULL: file.Printf("NODE_LARGE_HULL step %i\n", step); @@ -1992,7 +1990,7 @@ void CTestHull ::BuildNodeGraph(void) // WorldGraph.BuildLinkLookups(); - fPairsValid = TRUE; // assume that the connection pairs are all valid to start + fPairsValid = true; // assume that the connection pairs are all valid to start file.Printf("\n\n-------------------------------------------------------------------------------\n"); file.Printf("Link Pairings:\n"); @@ -2008,7 +2006,7 @@ void CTestHull ::BuildNodeGraph(void) WorldGraph.HashSearch(WorldGraph.INodeLink(i, j), i, iLink); if (iLink < 0) { - fPairsValid = FALSE; // unmatched link pair. + fPairsValid = false; // unmatched link pair. file.Printf("WARNING: Node %3d does not connect back to Node %3d\n", WorldGraph.INodeLink(i, j), i); } } @@ -2053,9 +2051,9 @@ void CTestHull ::BuildNodeGraph(void) // We now have some graphing capabilities. // - WorldGraph.m_fGraphPresent = TRUE; //graph is in memory. - WorldGraph.m_fGraphPointersSet = TRUE; // since the graph was generated, the pointers are ready - WorldGraph.m_fRoutingComplete = FALSE; // Optimal routes aren't computed, yet. + WorldGraph.m_fGraphPresent = true; //graph is in memory. + WorldGraph.m_fGraphPointersSet = true; // since the graph was generated, the pointers are ready + WorldGraph.m_fRoutingComplete = false; // Optimal routes aren't computed, yet. // Compute and compress the routing information. // @@ -2262,9 +2260,20 @@ int CQueuePriority ::Remove(float &fPriority) return iReturn; } -#define HEAP_LEFT_CHILD(x) (2 * (x) + 1) -#define HEAP_RIGHT_CHILD(x) (2 * (x) + 2) -#define HEAP_PARENT(x) (((x)-1) / 2) +int HEAP_LEFT_CHILD(int parent) { + return ((2 * parent) + 1); +} +int HEAP_RIGHT_CHILD(int parent) { + return ((2 * parent) + 2); +} + +int HEAP_PARENT(int child) { + return ((child-1) / 2); +} + +//#define HEAP_LEFT_CHILD(x) (2 * (x) + 1) +//#define HEAP_RIGHT_CHILD(x) (2 * (x) + 2) +//#define HEAP_PARENT(x) (((x)-1) / 2) void CQueuePriority::Heap_SiftDown(int iSubRoot) { @@ -2435,7 +2444,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 +2554,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++) @@ -2583,8 +2592,8 @@ int CGraph ::FSetGraphPointers(void) } // the pointers are now set. - m_fGraphPointersSet = TRUE; - return TRUE; + m_fGraphPointersSet = true; + return true; } //========================================================= @@ -2593,7 +2602,7 @@ int CGraph ::FSetGraphPointers(void) // ssociated .NOD file. If the NOD file is not present, or // is older than the BSP file, we rebuild it. // -// returns FALSE if the .NOD file doesn't qualify and needs +// returns false if the .NOD file doesn't qualify and needs // to be rebuilt. // // !!!BUGBUG - the file times we get back are 20 hours ahead! @@ -2630,17 +2639,9 @@ int CGraph ::CheckNODFile(const char *szMapName) return retValue; } -#define ENTRY_STATE_EMPTY -1 - -struct tagNodePair -{ - short iSrc; - short iDest; -}; - void CGraph::HashInsert(int iSrcNode, int iDestNode, int iKey) { - struct tagNodePair np; + struct tagNodePair np {}; np.iSrc = iSrcNode; np.iDest = iDestNode; @@ -2650,7 +2651,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 +2673,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]); @@ -2690,24 +2691,9 @@ void CGraph::HashSearch(int iSrcNode, int iDestNode, int &iKey) iKey = m_pHashLinks[i]; } -#define NUMBER_OF_PRIMES 177 - -int Primes[NUMBER_OF_PRIMES] = - {1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, - 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, - 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, - 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, - 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, - 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, - 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, - 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, - 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, - 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, - 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 0}; - void CGraph::HashChoosePrimes(int TableSize) { - int LargestPrime = TableSize / 2; + unsigned int LargestPrime = TableSize / 2; if (LargestPrime > Primes[NUMBER_OF_PRIMES - 2]) { LargestPrime = Primes[NUMBER_OF_PRIMES - 2]; @@ -2769,14 +2755,14 @@ void CGraph::HashChoosePrimes(int TableSize) // Renumber nodes so that nodes that link together are together. // -#define UNNUMBERED_NODE -1 + void CGraph::SortNodes(void) { // We are using m_iPreviousNode to be the new node number. // 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 +2773,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 +2820,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 +2871,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 +2902,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 +2933,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]; @@ -3018,10 +3004,18 @@ void CGraph::BuildRegionTables(void) memset(m_Cache, 0, sizeof(m_Cache)); } + +//#define FROM_TO(x, y) ((x)*m_cNodes + (y)) + +int FROM_TO(unsigned int iFrom, unsigned int iTo, int nodes) { + return (iFrom * nodes) + iTo; +} + + void CGraph ::ComputeStaticRoutingTables(void) { int nRoutes = m_cNodes * m_cNodes; -#define FROM_TO(x, y) ((x)*m_cNodes + (y)) + short *Routes = new short[nRoutes]; int *pMyPath = new int[m_cNodes]; @@ -3049,20 +3043,20 @@ 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; + Routes[FROM_TO(iFrom, iTo, m_cNodes)] = -1; } } for (iFrom = 0; iFrom < m_cNodes; iFrom++) { - for (iTo = m_cNodes - 1; iTo >= 0; iTo--) + for (iTo = m_cNodes - 1; iTo > 0; iTo--) { - if (Routes[FROM_TO(iFrom, iTo)] != -1) + if (Routes[FROM_TO(iFrom, iTo, m_cNodes)] != -1) continue; int cPathSize = FindShortestPath(pMyPath, iFrom, iTo, iHull, iCapMask); @@ -3078,7 +3072,7 @@ void CGraph ::ComputeStaticRoutingTables(void) for (int iNode1 = iNode + 1; iNode1 < cPathSize; iNode1++) { int iEnd = pMyPath[iNode1]; - Routes[FROM_TO(iStart, iEnd)] = iNext; + Routes[FROM_TO(iStart, iEnd, m_cNodes)] = iNext; } } #if 0 @@ -3094,34 +3088,34 @@ void CGraph ::ComputeStaticRoutingTables(void) for (int iNode1 = iNode-1; iNode1 >= 0; iNode1--) { int iEnd = pMyPath[iNode1]; - Routes[FROM_TO(iStart, iEnd)] = iNext; + Routes[FROM_TO(iStart, iEnd, m_cNodes)] = iNext; } } #endif } else { - Routes[FROM_TO(iFrom, iTo)] = iFrom; - Routes[FROM_TO(iTo, iFrom)] = iTo; + Routes[FROM_TO(iFrom, iTo, m_cNodes)] = iFrom; + Routes[FROM_TO(iTo, iFrom, m_cNodes)] = 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++) { - BestNextNodes[iTo] = Routes[FROM_TO(iFrom, iTo)]; + BestNextNodes[iTo] = Routes[FROM_TO(iFrom, iTo, m_cNodes)]; } // 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 +3259,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 +3289,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; @@ -3320,7 +3315,7 @@ void CGraph ::ComputeStaticRoutingTables(void) #if 0 TestRoutingTables(); #endif - m_fRoutingComplete = TRUE; + m_fRoutingComplete = true; } // Test those routing tables. Doesn't really work, yet. @@ -3331,9 +3326,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 +3342,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); - m_fRoutingComplete = TRUE; - int cPathSize2 = FindShortestPath(pMyPath2, iFrom, iTo, iHull, iCapMask); + m_fRoutingComplete = false; + unsigned int cPathSize1 = FindShortestPath(pMyPath, iFrom, iTo, iHull, iCapMask); + m_fRoutingComplete = true; + 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,22 +3360,22 @@ 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; - BOOL bFound = FALSE; + unsigned int iVisitNode, iLink; + BOOL bFound = false; for (iLink = 0; iLink < m_pNodes[pMyPath[i]].m_cNumLinks; iLink++) { iVisitNode = INodeLink(pMyPath[i], iLink); if (iVisitNode == pMyPath[i + 1]) { flDistance1 += m_pLinkPool[m_pNodes[pMyPath[i]].m_iFirstLink + iLink].m_flWeight; - bFound = TRUE; + bFound = true; break; } } @@ -3398,14 +3393,14 @@ void CGraph ::TestRoutingTables(void) if (pMyPath2[i] == pMyPath2[i + 1]) continue; int iVisitNode; - BOOL bFound = FALSE; - for (int iLink = 0; iLink < m_pNodes[pMyPath2[i]].m_cNumLinks; iLink++) + BOOL bFound = false; + for (unsigned int iLink = 0; iLink < m_pNodes[pMyPath2[i]].m_cNumLinks; iLink++) { iVisitNode = INodeLink(pMyPath2[i], iLink); if (iVisitNode == pMyPath2[i + 1]) { flDistance2 += m_pLinkPool[m_pNodes[pMyPath2[i]].m_iFirstLink + iLink].m_flWeight; - bFound = TRUE; + bFound = true; break; } } @@ -3432,9 +3427,9 @@ void CGraph ::TestRoutingTables(void) ALERT(at_aiconsole, "%d ", pMyPath2[i]); } ALERT(at_aiconsole, "\n"); - m_fRoutingComplete = FALSE; + m_fRoutingComplete = false; cPathSize1 = FindShortestPath(pMyPath, iFrom, iTo, iHull, iCapMask); - m_fRoutingComplete = TRUE; + m_fRoutingComplete = true; cPathSize2 = FindShortestPath(pMyPath2, iFrom, iTo, iHull, iCapMask); goto EnoughSaid; } @@ -3466,7 +3461,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 +3519,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 +3553,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 +3571,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 +3588,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..7e0623ab 100644 --- a/src/game/server/hl/nodes.h +++ b/src/game/server/hl/nodes.h @@ -24,15 +24,47 @@ class CFile; //========================================================= // DEFINE //========================================================= -#define MAX_STACK_NODES 100 -#define NO_NODE -1 -#define MAX_NODE_HULLS 4 -#define bits_NODE_LAND (1 << 0) // Land node, so nudge if necessary. -#define bits_NODE_AIR (1 << 1) // Air node, don't nudge. -#define bits_NODE_WATER (1 << 2) // Water node, don't nudge. -#define bits_NODE_GROUP_REALM (bits_NODE_LAND | bits_NODE_AIR | bits_NODE_WATER) +constexpr unsigned int MAX_STACK_NODES = 100; +constexpr unsigned int MAX_NODE_HULLS = 4; +constexpr unsigned int CACHE_SIZE = 128; +constexpr unsigned int NUM_RANGES = 256; +constexpr unsigned MAX_NODE_INITIAL_LINKS = 128; +constexpr unsigned MAX_NODES = 1024; +constexpr float HULL_STEP_SIZE = 16; // how far the test hull moves on each step +constexpr float NODE_HEIGHT = 8; // how high to lift nodes off the ground after we drop them all (make stair/ramp mapping easier) +constexpr unsigned int NUMBER_OF_PRIMES = 177; +constexpr int NO_NODE = -1; +constexpr int UNNUMBERED_NODE = -1; +constexpr int ENTRY_STATE_EMPTY = -1; + +constexpr unsigned int Primes[NUMBER_OF_PRIMES] = +{ 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, + 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, + 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, + 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, + 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, + 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, + 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, + 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, + 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, + 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, + 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 0 }; + +struct tagNodePair +{ + short iSrc; + short iDest; +}; + +enum bits_node_type_e { + bits_NODE_LAND = (1 << 0), // Land node, so nudge if necessary. + bits_NODE_AIR = (1 << 1), // Air node, don't nudge. + bits_NODE_WATER = (1 << 2), // Water node, don't nudge. + bits_NODE_GROUP_REALM = (bits_NODE_LAND | bits_NODE_AIR | bits_NODE_WATER) + +}; //========================================================= // Instance of a node. //========================================================= @@ -44,8 +76,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. @@ -67,17 +99,23 @@ class CNode //========================================================= // CLink - A link between 2 nodes //========================================================= -#define bits_LINK_SMALL_HULL (1 << 0) // headcrab box can fit through this connection -#define bits_LINK_HUMAN_HULL (1 << 1) // player box can fit through this connection -#define bits_LINK_LARGE_HULL (1 << 2) // big box can fit through this connection -#define bits_LINK_FLY_HULL (1 << 3) // a flying big box can fit through this connection -#define bits_LINK_DISABLED (1 << 4) // link is not valid when the set -#define NODE_SMALL_HULL 0 -#define NODE_HUMAN_HULL 1 -#define NODE_LARGE_HULL 2 -#define NODE_FLY_HULL 3 +enum bits_clink_e { + bits_LINK_SMALL_HULL = (1 << 0), // headcrab box can fit through this connection + bits_LINK_HUMAN_HULL = (1 << 1), // player box can fit through this connection + bits_LINK_LARGE_HULL = (1 << 2), // big box can fit through this connection + bits_LINK_FLY_HULL = (1 << 3), // a flying big box can fit through this connection + bits_LINK_DISABLED = (1 << 4) // link is not valid when the set +}; + +enum node_hull_e { + + NODE_SMALL_HULL = 0, + NODE_HUMAN_HULL = 1, + NODE_LARGE_HULL = 2, + NODE_FLY_HULL = 3 +}; class CLink { public: @@ -121,9 +159,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 @@ -134,11 +172,10 @@ class CGraph // search each range. After the search is exhausted, we know we have the closest // node. // -#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 +186,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; @@ -347,7 +384,7 @@ class CQueuePriority // hints - these MUST coincide with the HINTS listed under // info_node in the FGD file! //========================================================= -enum +enum hint_node_e { HINT_NONE = 0, HINT_WORLD_DOOR, diff --git a/src/game/server/hl/pathcorner.cpp b/src/game/server/hl/pathcorner.cpp index cf9ea94a..becd1332 100644 --- a/src/game/server/hl/pathcorner.cpp +++ b/src/game/server/hl/pathcorner.cpp @@ -56,7 +56,7 @@ void CPathCorner ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "wait")) { m_flWait = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CPointEntity::KeyValue(pkvd); @@ -135,7 +135,7 @@ void CPathTrack ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "altpath")) { m_altName = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CPointEntity::KeyValue(pkvd); diff --git a/src/game/server/hl/plane.cpp b/src/game/server/hl/plane.cpp index 601ceb08..dc8f28e7 100644 --- a/src/game/server/hl/plane.cpp +++ b/src/game/server/hl/plane.cpp @@ -21,7 +21,7 @@ //========================================================= CPlane ::CPlane(void) { - m_fInitialized = FALSE; + m_fInitialized = false; } //========================================================= @@ -32,7 +32,7 @@ void CPlane ::InitializePlane(const Vector &vecNormal, const Vector &vecPoint) { m_vecNormal = vecNormal; m_flDist = DotProduct(m_vecNormal, vecPoint); - m_fInitialized = TRUE; + m_fInitialized = true; } //========================================================= @@ -45,15 +45,15 @@ BOOL CPlane ::PointInFront(const Vector &vecPoint) if (!m_fInitialized) { - return FALSE; + return false; } flFace = DotProduct(m_vecNormal, vecPoint) - m_flDist; if (flFace >= 0) { - return TRUE; + return true; } - return FALSE; + return false; } diff --git a/src/game/server/hl/plats.cpp b/src/game/server/hl/plats.cpp index 51b0a374..734e2c3d 100644 --- a/src/game/server/hl/plats.cpp +++ b/src/game/server/hl/plats.cpp @@ -28,8 +28,10 @@ static void PlatSpawnInsideTrigger(entvars_t *pevPlatform); -#define SF_PLAT_TOGGLE 0x0001 -#define SF_PLAT_ADJUST 0x0002 //MAR2010_10 - Thothie - adjust platform for stuck bugs when reach top +enum sf_plat_e { + SF_PLAT_TOGGLE = 0x0001, + SF_PLAT_ADJUST = 0x0002 //MAR2010_10 - Thothie - adjust platform for stuck bugs when reach top +}; class CBasePlatTrain : public CBaseToggle { @@ -39,9 +41,9 @@ class CBasePlatTrain : public CBaseToggle void Precache(void); // This is done to fix spawn flag collisions between this class and a derived class - virtual BOOL IsTogglePlat(void) { return (pev->spawnflags & SF_PLAT_TOGGLE) ? TRUE : FALSE; } + virtual BOOL IsTogglePlat(void) { return (pev->spawnflags & SF_PLAT_TOGGLE) ? true : false; } - virtual BOOL IsStuckAdjust(void) { return (pev->spawnflags & SF_PLAT_ADJUST) ? TRUE : FALSE; } //MAR2010_10 - Thothie - adjust platform for stuck bugs when reach top + virtual BOOL IsStuckAdjust(void) { return (pev->spawnflags & SF_PLAT_ADJUST) ? true : false; } //MAR2010_10 - Thothie - adjust platform for stuck bugs when reach top virtual int Save(CSave &save); virtual int Restore(CRestore &restore); @@ -66,37 +68,37 @@ void CBasePlatTrain ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "lip")) { m_flLip = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "wait")) { m_flWait = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "height")) { m_flHeight = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "rotation")) { m_vecFinalAngle.x = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "movesnd")) { m_bMoveSnd = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "stopsnd")) { m_bStopSnd = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "volume")) { m_volume = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseToggle::KeyValue(pkvd); @@ -396,7 +398,7 @@ void CFuncPlat ::PlatUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE if (IsTogglePlat()) { // Top is off, bottom is on - BOOL on = (m_toggle_state == TS_AT_BOTTOM) ? TRUE : FALSE; + BOOL on = (m_toggle_state == TS_AT_BOTTOM) ? true : false; if (!ShouldToggle(useType, on)) return; @@ -649,7 +651,7 @@ void CFuncTrain ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "sounds")) { m_sounds = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBasePlatTrain::KeyValue(pkvd); @@ -791,7 +793,7 @@ void CFuncTrain ::Activate(void) // Not yet active, so teleport to first target if (!m_activated) { - m_activated = TRUE; + m_activated = true; entvars_t *pevTarg = VARS(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target))); pev->target = pevTarg->target; @@ -843,7 +845,7 @@ void CFuncTrain ::Spawn(void) UTIL_SetSize(pev, pev->mins, pev->maxs); UTIL_SetOrigin(pev, pev->origin); - m_activated = FALSE; + m_activated = false; if (m_volume == 0) m_volume = 0.85; @@ -932,33 +934,33 @@ void CFuncTrackTrain ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "wheels")) { m_length = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "height")) { m_height = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "startspeed")) { m_startSpeed = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "sounds")) { m_sounds = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "volume")) { m_flVolume = (float)(atoi(pkvd->szValue)); m_flVolume *= 0.1; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "bank")) { m_flBank = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); @@ -1239,7 +1241,7 @@ void CFuncTrackTrain ::Next(void) } } SetThink(&CFuncTrackTrain::Next); - NextThink(pev->ltime + time, TRUE); + NextThink(pev->ltime + time, true); } else // end of path, stop { @@ -1260,7 +1262,7 @@ void CFuncTrackTrain ::Next(void) time = distance / m_oldSpeed; pev->velocity = pev->velocity * (m_oldSpeed / distance); SetThink(&CFuncTrackTrain::DeadEnd); - NextThink(pev->ltime + time, FALSE); + NextThink(pev->ltime + time, false); } else { @@ -1286,7 +1288,7 @@ void CFuncTrackTrain::DeadEnd(void) { do { - pNext = pTrack->ValidPath(pTrack->GetPrevious(), TRUE); + pNext = pTrack->ValidPath(pTrack->GetPrevious(), true); if (pNext) pTrack = pNext; } while (pNext); @@ -1295,7 +1297,7 @@ void CFuncTrackTrain::DeadEnd(void) { do { - pNext = pTrack->ValidPath(pTrack->GetNext(), TRUE); + pNext = pTrack->ValidPath(pTrack->GetNext(), true); if (pNext) pTrack = pNext; } while (pNext); @@ -1327,7 +1329,7 @@ BOOL CFuncTrackTrain ::OnControls(entvars_t *pevTest) Vector offset = pevTest->origin - pev->origin; if (pev->spawnflags & SF_TRACKTRAIN_NOCONTROL) - return FALSE; + return false; // Transform offset into local coordinates UTIL_MakeVectors(pev->angles); @@ -1338,9 +1340,9 @@ BOOL CFuncTrackTrain ::OnControls(entvars_t *pevTest) if (local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z && local.x <= m_controlMaxs.x && local.y <= m_controlMaxs.y && local.z <= m_controlMaxs.z) - return TRUE; + return true; - return FALSE; + return false; } void CFuncTrackTrain ::Find(void) @@ -1372,7 +1374,7 @@ void CFuncTrackTrain ::Find(void) if (pev->spawnflags & SF_TRACKTRAIN_NOPITCH) pev->angles.x = 0; UTIL_SetOrigin(pev, nextPos); - NextThink(pev->ltime + 0.1, FALSE); + NextThink(pev->ltime + 0.1, false); SetThink(&CFuncTrackTrain::Next); pev->speed = m_startSpeed; @@ -1421,14 +1423,14 @@ void CFuncTrackTrain ::NearestPath(void) if (pev->speed != 0) { - NextThink(pev->ltime + 0.1, FALSE); + NextThink(pev->ltime + 0.1, false); SetThink(&CFuncTrackTrain::Next); } } void CFuncTrackTrain::OverrideReset(void) { - NextThink(pev->ltime + 0.1, FALSE); + NextThink(pev->ltime + 0.1, false); SetThink(&CFuncTrackTrain::NearestPath); } @@ -1486,7 +1488,7 @@ void CFuncTrackTrain ::Spawn(void) m_controlMaxs.z += 72; // start trains on the next frame, to make sure their targets have had // a chance to spawn/activate - NextThink(pev->ltime + 0.1, FALSE); + NextThink(pev->ltime + 0.1, false); SetThink(&CFuncTrackTrain::Find); Precache(); } @@ -1621,7 +1623,7 @@ class CFuncTrackChange : public CFuncPlatRot virtual void HitTop(void); void Touch(CBaseEntity *pOther); virtual void UpdateAutoTargets(int toggleState); - virtual BOOL IsTogglePlat(void) { return TRUE; } + virtual BOOL IsTogglePlat(void) { return true; } void DisableUse(void) { m_use = 0; } void EnableUse(void) { m_use = 1; } @@ -1713,17 +1715,17 @@ void CFuncTrackChange ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "train")) { m_trainName = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "toptrack")) { m_trackTopName = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "bottomtrack")) { m_trackBottomName = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else { @@ -1810,7 +1812,7 @@ void CFuncTrackChange ::UpdateTrain(Vector &dest) m_train->pev->velocity = pev->velocity; m_train->pev->avelocity = pev->avelocity; - m_train->NextThink(m_train->pev->ltime + time, FALSE); + m_train->NextThink(m_train->pev->ltime + time, false); // Attempt at getting the train to rotate properly around the origin of the trackchange if (time <= 0) @@ -2122,7 +2124,7 @@ void CGunTarget::Spawn(void) pev->takedamage = DAMAGE_NO; pev->flags |= FL_MONSTER; - m_on = FALSE; + m_on = false; pev->max_health = pev->health; if (pev->spawnflags & FGUNTARGET_START_ON) diff --git a/src/game/server/hl/saverestore.h b/src/game/server/hl/saverestore.h index 644bb44b..f5593f96 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); @@ -85,7 +85,7 @@ class CRestore : public CSaveRestoreBuffer CRestore(SAVERESTOREDATA *pdata) : CSaveRestoreBuffer(pdata) { m_global = 0; - m_precache = TRUE; + m_precache = true; } int ReadEntVars(const char *pname, entvars_t *pev); // entvars_t diff --git a/src/game/server/hl/schedule.cpp b/src/game/server/hl/schedule.cpp index 317dfe4f..9434edb7 100644 --- a/src/game/server/hl/schedule.cpp +++ b/src/game/server/hl/schedule.cpp @@ -27,17 +27,17 @@ extern CGraph WorldGraph; //========================================================= -// FHaveSchedule - Returns TRUE if monster's m_pSchedule +// FHaveSchedule - Returns true if monster's m_pSchedule // is anything other than NULL. //========================================================= BOOL CBaseMonster ::FHaveSchedule(void) { if (m_pSchedule == NULL) { - return FALSE; + return false; } - return TRUE; + return true; } //========================================================= @@ -52,7 +52,7 @@ void CBaseMonster ::ClearSchedule(void) } //========================================================= -// FScheduleDone - Returns TRUE if the caller is on the +// FScheduleDone - Returns true if the caller is on the // last task in the schedule //========================================================= BOOL CBaseMonster ::FScheduleDone(void) @@ -61,10 +61,10 @@ BOOL CBaseMonster ::FScheduleDone(void) if (m_iScheduleIndex == m_pSchedule->cTasks) { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= @@ -164,7 +164,7 @@ int CBaseMonster ::IScheduleFlags(void) } //========================================================= -// FScheduleValid - returns TRUE as long as the current +// FScheduleValid - returns true as long as the current // schedule is still the proper schedule to be executing, // taking into account all conditions //========================================================= @@ -173,7 +173,7 @@ BOOL CBaseMonster ::FScheduleValid(void) if (m_pSchedule == NULL) { // schedule is empty, and therefore not valid. - return FALSE; + return false; } if (HasConditions(m_pSchedule->iInterruptMask | bits_COND_SCHEDULE_DONE | bits_COND_TASK_FAILED)) @@ -191,10 +191,10 @@ BOOL CBaseMonster ::FScheduleValid(void) #endif // DEBUG // some condition has interrupted the schedule, or the schedule is done - return FALSE; + return false; } - return TRUE; + return true; } //========================================================= @@ -524,7 +524,7 @@ void CBaseMonster ::RunTask(Task_t *pTask) if (m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime) { TaskComplete(); - m_pCine->StartSequence((CBaseMonster *)this, m_pCine->m_iszPlay, TRUE); + m_pCine->StartSequence((CBaseMonster *)this, m_pCine->m_iszPlay, true); if (m_fSequenceFinished) ClearSchedule(); pev->framerate = 1.0; @@ -1254,7 +1254,7 @@ void CBaseMonster ::StartTask(Task_t *pTask) { if (m_pCine->m_iszIdle) { - m_pCine->StartSequence((CBaseMonster *)this, m_pCine->m_iszIdle, FALSE); + m_pCine->StartSequence((CBaseMonster *)this, m_pCine->m_iszIdle, false); if (FStrEq(STRING(m_pCine->m_iszIdle), STRING(m_pCine->m_iszPlay))) { pev->framerate = 0; diff --git a/src/game/server/hl/schedule.h b/src/game/server/hl/schedule.h index 43ac067f..211b5050 100644 --- a/src/game/server/hl/schedule.h +++ b/src/game/server/hl/schedule.h @@ -18,63 +18,65 @@ #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_e { + 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,102 +84,102 @@ 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; // These go in the flData member of the TASK_WALK_TO_TARGET, TASK_RUN_TO_TARGET -enum +enum target_move_e { TARGET_MOVE_NORMAL = 0, TARGET_MOVE_SCRIPTED = 1, @@ -188,7 +190,7 @@ enum // The goal index should indicate which schedule (ordinally) the monster is running. // That way, when tasks fail, the AI can make decisions based on the context of the // current goal and sequence rather than just the current schedule. -enum +enum goal_e { GOAL_ATTACK_ENEMY, GOAL_MOVE, @@ -229,62 +231,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 +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_TASK_FAILED ( 1 << 30) -#define bits_COND_SCHEDULE_DONE ( 1 << 31) - - -#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/hl/scripted.cpp b/src/game/server/hl/scripted.cpp index b3e76691..52b525c7 100644 --- a/src/game/server/hl/scripted.cpp +++ b/src/game/server/hl/scripted.cpp @@ -57,37 +57,37 @@ void CCineMonster ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "m_iszIdle")) { m_iszIdle = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_iszPlay")) { m_iszPlay = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_iszEntity")) { m_iszEntity = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_fMoveTo")) { m_fMoveTo = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_flRepeat")) { m_flRepeat = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_flRadius")) { m_flRadius = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "m_iFinishSchedule")) { m_iFinishSchedule = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else { @@ -143,20 +143,20 @@ void CCineMonster ::Spawn(void) m_startTime = gpGlobals->time + 1E6; } if (pev->spawnflags & SF_SCRIPT_NOINTERRUPT) - m_interruptable = FALSE; + m_interruptable = false; else - m_interruptable = TRUE; + m_interruptable = true; } //========================================================= -// FCanOverrideState - returns FALSE, scripted sequences +// FCanOverrideState - returns false, scripted sequences // cannot possess entities regardless of state. //========================================================= BOOL CCineMonster ::FCanOverrideState(void) { if (pev->spawnflags & SF_SCRIPT_OVERRIDESTATE) - return TRUE; - return FALSE; + return true; + return false; } //========================================================= @@ -165,7 +165,7 @@ BOOL CCineMonster ::FCanOverrideState(void) //========================================================= BOOL CCineAI ::FCanOverrideState(void) { - return TRUE; + return true; } // @@ -273,7 +273,7 @@ int CCineMonster ::FindEntity(void) if (pTarget && pTarget->CanPlaySequence(FCanOverrideState(), SS_INTERRUPT_BY_NAME)) { m_hTargetEnt = pTarget; - return TRUE; + return true; } ALERT(at_console, "Found %s, but can't play!\n", STRING(m_iszEntity)); } @@ -294,7 +294,7 @@ int CCineMonster ::FindEntity(void) if (pTarget && pTarget->CanPlaySequence(FCanOverrideState(), SS_INTERRUPT_IDLE)) { m_hTargetEnt = pTarget; - return TRUE; + return true; } } } @@ -302,7 +302,7 @@ int CCineMonster ::FindEntity(void) } pTarget = NULL; m_hTargetEnt = NULL; - return FALSE; + return false; } // make the entity enter a scripted sequence @@ -368,7 +368,7 @@ void CCineMonster ::PossessEntity(void) pTarget->m_IdealMonsterState = MONSTERSTATE_SCRIPT; if (m_iszIdle) { - StartSequence(pTarget, m_iszIdle, FALSE); + StartSequence(pTarget, m_iszIdle, false); if (FStrEq(STRING(m_iszIdle), STRING(m_iszPlay))) { pTarget->pev->framerate = 0; @@ -445,7 +445,7 @@ void CCineAI ::PossessEntity(void) /* if (m_iszIdle) { - StartSequence( pTarget, m_iszIdle, FALSE ); + StartSequence( pTarget, m_iszIdle, false ); if (FStrEq( STRING(m_iszIdle), STRING(m_iszPlay))) { pTarget->pev->framerate = 0; @@ -482,7 +482,7 @@ BOOL CCineMonster ::StartSequence(CBaseMonster *pTarget, int iszSeq, BOOL comple if (!iszSeq && completeOnEmpty) { SequenceDone(pTarget); - return FALSE; + return false; } pTarget->pev->sequence = pTarget->LookupSequence(STRING(iszSeq)); @@ -490,7 +490,7 @@ BOOL CCineMonster ::StartSequence(CBaseMonster *pTarget, int iszSeq, BOOL comple { ALERT(at_error, "%s: unknown scripted sequence \"%s\"\n", STRING(pTarget->pev->targetname), STRING(iszSeq)); pTarget->pev->sequence = 0; - // return FALSE; + // return false; } #if 0 @@ -505,7 +505,7 @@ BOOL CCineMonster ::StartSequence(CBaseMonster *pTarget, int iszSeq, BOOL comple pTarget->pev->frame = 0; pTarget->ResetSequenceInfo(); - return TRUE; + return true; } // lookup a sequence name and setup the target monster to play it @@ -521,7 +521,7 @@ BOOL CCineAI ::StartSequence(CBaseMonster *pTarget, int iszSeq, BOOL completeOnE SequenceDone(pTarget); - return TRUE; + return true; } pTarget->pev->sequence = pTarget->LookupSequence(STRING(iszSeq)); @@ -530,12 +530,12 @@ BOOL CCineAI ::StartSequence(CBaseMonster *pTarget, int iszSeq, BOOL completeOnE { ALERT(at_error, "%s: unknown aiscripted sequence \"%s\"\n", STRING(pTarget->pev->targetname), STRING(iszSeq)); pTarget->pev->sequence = 0; - // return FALSE; + // return false; } pTarget->pev->frame = 0; pTarget->ResetSequenceInfo(); - return TRUE; + return true; } //========================================================= @@ -618,7 +618,7 @@ BOOL CBaseMonster ::ExitScriptedSequence() // is this legal? // BUGBUG -- This doesn't call Killed() m_IdealMonsterState = MONSTERSTATE_DEAD; - return FALSE; + return false; } if (m_pCine) @@ -626,7 +626,7 @@ BOOL CBaseMonster ::ExitScriptedSequence() m_pCine->CancelScript(); } - return TRUE; + return true; } void CCineMonster::AllowInterrupt(BOOL fAllow) @@ -639,14 +639,14 @@ void CCineMonster::AllowInterrupt(BOOL fAllow) BOOL CCineMonster::CanInterrupt(void) { if (!m_interruptable) - return FALSE; + return false; CBaseEntity *pTarget = m_hTargetEnt; if (pTarget != NULL && pTarget->pev->deadflag == DEAD_NO) - return TRUE; + return true; - return FALSE; + return false; } int CCineMonster::IgnoreConditions(void) @@ -815,7 +815,7 @@ BOOL CBaseMonster ::CineCleanup() StopAnimation(); pev->movetype = MOVETYPE_NONE; pev->effects |= EF_NOINTERP; // Don't interpolate either, assume the corpse is positioned in its final resting place - return FALSE; + return false; } // If we actually played a sequence @@ -890,7 +890,7 @@ BOOL CBaseMonster ::CineCleanup() // SetAnimation( m_MonsterState ); ClearBits(pev->spawnflags, SF_MONSTER_WAIT_FOR_SCRIPT); - return TRUE; + return true; } class CScriptedSentence : public CBaseToggle @@ -924,10 +924,7 @@ class CScriptedSentence : public CBaseToggle int m_iszListener; // name of entity to look at while talking }; -#define SF_SENTENCE_ONCE 0x0001 -#define SF_SENTENCE_FOLLOWERS 0x0002 // only say if following player -#define SF_SENTENCE_INTERRUPT 0x0004 // force talking except when dead -#define SF_SENTENCE_CONCURRENT 0x0008 // allow other people to keep talking + TYPEDESCRIPTION CScriptedSentence::m_SaveData[] = { @@ -951,42 +948,42 @@ void CScriptedSentence ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "sentence")) { m_iszSentence = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "entity")) { m_iszEntity = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "duration")) { m_flDuration = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "radius")) { m_flRadius = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "refire")) { m_flRepeat = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "attenuation")) { pev->impulse = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "volume")) { m_flVolume = atof(pkvd->szValue) * 0.1; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "listener")) { m_iszListener = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseToggle::KeyValue(pkvd); @@ -1005,7 +1002,7 @@ void CScriptedSentence ::Spawn(void) { pev->solid = SOLID_NOT; - m_active = TRUE; + m_active = true; // if no targetname, start now if (!pev->targetname) { @@ -1049,7 +1046,7 @@ void CScriptedSentence ::FindThink(void) UTIL_Remove(this); SetThink(&CScriptedSentence::DelayThink); pev->nextthink = gpGlobals->time + m_flDuration + m_flRepeat; - m_active = FALSE; + m_active = false; // ALERT( at_console, "%s: found monster %s\n", STRING(m_iszSentence), STRING(m_iszEntity) ); } else @@ -1061,7 +1058,7 @@ void CScriptedSentence ::FindThink(void) void CScriptedSentence ::DelayThink(void) { - m_active = TRUE; + m_active = true; if (!pev->targetname) pev->nextthink = gpGlobals->time + 0.1; SetThink(&CScriptedSentence::FindThink); @@ -1074,17 +1071,17 @@ BOOL CScriptedSentence ::AcceptableSpeaker(CBaseMonster *pMonster) if (pev->spawnflags & SF_SENTENCE_FOLLOWERS) { if (pMonster->m_hTargetEnt == NULL || !FClassnameIs(pMonster->m_hTargetEnt->pev, "player")) - return FALSE; + return false; } BOOL override; if (pev->spawnflags & SF_SENTENCE_INTERRUPT) - override = TRUE; + override = true; else - override = FALSE; + override = false; if (pMonster->CanPlaySentence(override)) - return TRUE; + return true; } - return FALSE; + return false; } CBaseMonster *CScriptedSentence ::FindEntity(void) @@ -1132,9 +1129,9 @@ BOOL CScriptedSentence ::StartSentence(CBaseMonster *pTarget) return NULL; } - BOOL bConcurrent = FALSE; + BOOL bConcurrent = false; if (!(pev->spawnflags & SF_SENTENCE_CONCURRENT)) - bConcurrent = TRUE; + bConcurrent = true; CBaseEntity *pListener = NULL; if (!FStringNull(m_iszListener)) @@ -1150,7 +1147,7 @@ BOOL CScriptedSentence ::StartSentence(CBaseMonster *pTarget) pTarget->PlayScriptedSentence(STRING(m_iszSentence), m_flDuration, m_flVolume, m_flAttenuation, bConcurrent, pListener); ALERT(at_aiconsole, "Playing sentence %s (%.1f)\n", STRING(m_iszSentence), m_flDuration); SUB_UseTargets(NULL, USE_TOGGLE, 0); - return TRUE; + return true; } /* diff --git a/src/game/server/hl/scripted.h b/src/game/server/hl/scripted.h index 064da13f..8698cb49 100644 --- a/src/game/server/hl/scripted.h +++ b/src/game/server/hl/scripted.h @@ -19,16 +19,24 @@ #include "scriptevent.h" #endif -#define SF_SCRIPT_WAITTILLSEEN 1 -#define SF_SCRIPT_EXITAGITATED 2 -#define SF_SCRIPT_REPEATABLE 4 -#define SF_SCRIPT_LEAVECORPSE 8 -//#define SF_SCRIPT_INTERPOLATE 16 // don't use, old bug -#define SF_SCRIPT_NOINTERRUPT 32 -#define SF_SCRIPT_OVERRIDESTATE 64 -#define SF_SCRIPT_NOSCRIPTMOVEMENT 128 +enum script_conditions_e { + SF_SCRIPT_WAITTILLSEEN = 1, + SF_SCRIPT_EXITAGITATED = 2, + SF_SCRIPT_REPEATABLE = 4, + SF_SCRIPT_LEAVECORPSE = 8, + //SF_SCRIPT_INTERPOLATE = 16, // don't use, old bug + SF_SCRIPT_NOINTERRUPT = 32, + SF_SCRIPT_OVERRIDESTATE = 64, + SF_SCRIPT_NOSCRIPTMOVEMENT = 128, + SCRIPT_BREAK_CONDITIONS = (bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE) +}; -#define SCRIPT_BREAK_CONDITIONS (bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE) +enum sf_sentence_e { + SF_SENTENCE_ONCE = 0x0001, + SF_SENTENCE_FOLLOWERS = 0x0002, // only say if following player + SF_SENTENCE_INTERRUPT = 0x0004, // force talking except when dead + SF_SENTENCE_CONCURRENT = 0x0008 // allow other people to keep talking +}; enum SS_INTERRUPT { @@ -40,8 +48,11 @@ enum SS_INTERRUPT // when a monster finishes an AI scripted sequence, we can choose // a schedule to place them in. These defines are the aliases to // resolve worldcraft input to real schedules (sjb) -#define SCRIPT_FINISHSCHED_DEFAULT 0 -#define SCRIPT_FINISHSCHED_AMBUSH 1 + +enum script_finishedsched_e { + SCRIPT_FINISHSCHED_DEFAULT = 0, + SCRIPT_FINISHSCHED_AMBUSH = 1 +}; class CCineMonster : public CBaseMonster { diff --git a/src/game/server/hl/scriptevent.h b/src/game/server/hl/scriptevent.h index e8b29703..0e11a23d 100644 --- a/src/game/server/hl/scriptevent.h +++ b/src/game/server/hl/scriptevent.h @@ -15,15 +15,18 @@ #ifndef SCRIPTEVENT_H #define SCRIPTEVENT_H -#define SCRIPT_EVENT_DEAD 1000 // character is now dead -#define SCRIPT_EVENT_NOINTERRUPT 1001 // does not allow interrupt -#define SCRIPT_EVENT_CANINTERRUPT 1002 // will allow interrupt -#define SCRIPT_EVENT_FIREEVENT 1003 // event now fires -#define SCRIPT_EVENT_SOUND 1004 // Play named wave file (on CHAN_BODY) -#define SCRIPT_EVENT_SENTENCE 1005 // Play named sentence -#define SCRIPT_EVENT_INAIR 1006 // Leave the character in air at the end of the sequence (don't find the floor) -#define SCRIPT_EVENT_ENDANIMATION 1007 // Set the animation by name after the sequence completes -#define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) -#define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time -#define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) +enum script_event_e { + + SCRIPT_EVENT_DEAD = 1000, // character is now dead + SCRIPT_EVENT_NOINTERRUPT = 1001, // does not allow interrupt + SCRIPT_EVENT_CANINTERRUPT = 1002, // will allow interrupt + SCRIPT_EVENT_FIREEVENT = 1003, // event now fires + SCRIPT_EVENT_SOUND = 1004, // Play named wave file (on CHAN_BODY) + SCRIPT_EVENT_SENTENCE = 1005, // Play named sentence + SCRIPT_EVENT_INAIR = 1006, // Leave the character in air at the end of the sequence (don't find the floor) + SCRIPT_EVENT_ENDANIMATION = 1007, // Set the animation by name after the sequence completes + SCRIPT_EVENT_SOUND_VOICE = 1008, // Play named wave file (on CHAN_VOICE) + SCRIPT_EVENT_SENTENCE_RND1 = 1009, // Play sentence group 25% of the time + SCRIPT_EVENT_NOT_DEAD = 1010 // Bring back to life (for life/death sequences) +}; #endif //SCRIPTEVENT_H diff --git a/src/game/server/hl/skill.h b/src/game/server/hl/skill.h index fd072917..73c9f148 100644 --- a/src/game/server/hl/skill.h +++ b/src/game/server/hl/skill.h @@ -141,6 +141,9 @@ float GetSkillCvar(char *pName); extern DLL_GLOBAL int g_iSkillLevel; -#define SKILL_EASY 1 -#define SKILL_MEDIUM 2 -#define SKILL_HARD 3 + +enum skill_level_e { + SKILL_EASY = 1, + SKILL_MEDIUM = 2, + SKILL_HARD = 3 +}; \ No newline at end of file diff --git a/src/game/server/hl/sound.cpp b/src/game/server/hl/sound.cpp index 5b7ac96e..3a3183b3 100644 --- a/src/game/server/hl/sound.cpp +++ b/src/game/server/hl/sound.cpp @@ -17,8 +17,6 @@ //========================================================= #define VALVE_DLL 1 -#define CHAR_TEX_SNOW 'N' - #include "msdllheaders.h" #include "weapons.h" #include "player.h" @@ -30,6 +28,8 @@ #include #endif +constexpr unsigned int MAX_CDPVPRESET = 27; + // ==================== GENERIC AMBIENT SOUND ====================================== // THOTHIE: I cut and pasted from the original HL1SDK's SOUND.CPP the entire Ambient Generic section in an effort to restore functionality // THOTHIE: Just the ambient_generic entity, I left the rest alone @@ -80,11 +80,9 @@ typedef struct dynpitchvol } dynpitchvol_t; -#define CDPVPRESETMAX 27 - // presets for runtime pitch and vol modulation of ambient sounds -dynpitchvol_t rgdpvpreset[CDPVPRESETMAX] = +dynpitchvol_t rgdpvpreset[MAX_CDPVPRESET] = { // pitch pstart spinup spindwn volrun volstrt fadein fadeout lfotype lforate modptch modvol cspnup {1, 255, 75, 95, 95, 10, 1, 50, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -133,8 +131,8 @@ class CAmbientGeneric : public CBaseEntity float m_flAttenuation; // attenuation value dynpitchvol_t m_dpv; - BOOL m_fActive; // only TRUE when the entity is playing a looping sound - BOOL m_fLooping; // TRUE when the sound played will loop + BOOL m_fActive; // only true when the entity is playing a looping sound + BOOL m_fLooping; // true when the sound played will loop }; LINK_ENTITY_TO_CLASS(ambient_generic, CAmbientGeneric); //Thothie - attempting to build new amb generic ms MSMapEnts - so this needs to be altered @@ -211,12 +209,12 @@ void CAmbientGeneric ::Spawn(void) SetUse(&CAmbientGeneric::ToggleUse); - m_fActive = FALSE; + m_fActive = false; if (FBitSet(pev->spawnflags, AMBIENT_SOUND_NOT_LOOPING)) - m_fLooping = FALSE; + m_fLooping = false; else - m_fLooping = TRUE; + m_fLooping = true; Precache(); } @@ -236,7 +234,7 @@ void CAmbientGeneric ::Precache(void) { // start the sound ASAP if (m_fLooping) - m_fActive = TRUE; + m_fActive = true; } if (m_fActive) { @@ -258,7 +256,7 @@ void CAmbientGeneric ::RampThink(void) int pitch = m_dpv.pitch; int vol = m_dpv.vol; int flags = 0; - int fChanged = 0; // FALSE if pitch and vol remain unchanged this round + int fChanged = 0; // false if pitch and vol remain unchanged this round int prev; if (!m_dpv.spinup && !m_dpv.spindown && !m_dpv.fadein && !m_dpv.fadeout && !m_dpv.lfotype) @@ -462,7 +460,7 @@ void CAmbientGeneric ::InitModulationParms(void) m_dpv.volrun = 0; // get presets - if (m_dpv.preset != 0 && m_dpv.preset <= CDPVPRESETMAX) + if (m_dpv.preset != 0 && m_dpv.preset <= MAX_CDPVPRESET) { // load preset values m_dpv = rgdpvpreset[m_dpv.preset - 1]; @@ -593,7 +591,7 @@ void CAmbientGeneric ::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, // Toggle - // m_fActive is TRUE only if a looping sound is playing. + // m_fActive is true only if a looping sound is playing. if (m_fActive) { // turn sound off @@ -624,7 +622,7 @@ void CAmbientGeneric ::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, } else { - m_fActive = FALSE; + m_fActive = false; // HACKHACK - this makes the code in Precache() work properly after a save/restore pev->spawnflags |= AMBIENT_SOUND_START_SILENT; @@ -653,7 +651,7 @@ void CAmbientGeneric ::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, // and then restarted. if (m_fLooping) - m_fActive = TRUE; + m_fActive = true; else // shut sound off now - may be interrupting a long non-looping sound UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, @@ -681,14 +679,14 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "preset")) { m_dpv.preset = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // pitchrun else if (FStrEq(pkvd->szKeyName, "pitch")) { m_dpv.pitchrun = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; if (m_dpv.pitchrun > 255) m_dpv.pitchrun = 255; @@ -700,7 +698,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) else if (FStrEq(pkvd->szKeyName, "pitchstart")) { m_dpv.pitchstart = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; if (m_dpv.pitchstart > 255) m_dpv.pitchstart = 255; @@ -721,7 +719,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) if (m_dpv.spinup > 0) m_dpv.spinup = (101 - m_dpv.spinup) * 64; m_dpv.spinupsav = m_dpv.spinup; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // spindown @@ -737,7 +735,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) if (m_dpv.spindown > 0) m_dpv.spindown = (101 - m_dpv.spindown) * 64; m_dpv.spindownsav = m_dpv.spindown; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // volstart @@ -752,7 +750,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) m_dpv.volstart *= 10; // 0 - 100 - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // fadein @@ -768,7 +766,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) if (m_dpv.fadein > 0) m_dpv.fadein = (101 - m_dpv.fadein) * 64; m_dpv.fadeinsav = m_dpv.fadein; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // fadeout @@ -784,7 +782,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) if (m_dpv.fadeout > 0) m_dpv.fadeout = (101 - m_dpv.fadeout) * 64; m_dpv.fadeoutsav = m_dpv.fadeout; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // lfotype @@ -793,7 +791,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) m_dpv.lfotype = atoi(pkvd->szValue); if (m_dpv.lfotype > 4) m_dpv.lfotype = LFO_TRIANGLE; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // lforate @@ -808,7 +806,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) m_dpv.lforate *= 256; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // lfomodpitch else if (FStrEq(pkvd->szKeyName, "lfomodpitch")) @@ -819,7 +817,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) if (m_dpv.lfomodpitch < 0) m_dpv.lfomodpitch = 0; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // lfomodvol @@ -831,7 +829,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) if (m_dpv.lfomodvol < 0) m_dpv.lfomodvol = 0; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } // cspinup @@ -843,7 +841,7 @@ void CAmbientGeneric ::KeyValue(KeyValueData *pkvd) if (m_dpv.cspinup < 0) m_dpv.cspinup = 0; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); @@ -882,16 +880,16 @@ void CEnvSound ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "radius")) { m_flRadius = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } if (FStrEq(pkvd->szKeyName, "roomtype")) { m_flRoomtype = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } } -// returns TRUE if the given sound entity (pev) is in range +// returns true if the given sound entity (pev) is in range // and can see the given player entity (pevTarget) BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) @@ -908,7 +906,7 @@ BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) // check if line of sight crosses water boundary, or is blocked if ((tr.fInOpen && tr.fInWater) || tr.flFraction != 1) - return FALSE; + return false; // calc range from sound entity to player @@ -916,12 +914,12 @@ BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) flRange = vecRange.Length(); if (pSound->m_flRadius < flRange) - return FALSE; + return false; if (pflRange) *pflRange = flRange; - return TRUE; + return true; } // @@ -1045,25 +1043,25 @@ void CEnvSound ::Spawn() // ==================== SENTENCE GROUPS, UTILITY FUNCTIONS ====================================== -#define CSENTENCE_LRU_MAX 32 // max number of elements per sentence group +constexpr unsigned int CSENTENCE_LRU_MAX = 32; // max number of elements per sentence group // group of related sentences typedef struct sentenceg { - char szgroupname[CBSENTENCENAME_MAX]; + char szgroupname[MAX_CBSENTENCENAME]; int count; unsigned char rgblru[CSENTENCE_LRU_MAX]; } SENTENCEG; -#define CSENTENCEG_MAX 200 // max number of sentence groups +constexpr unsigned int CSENTENCEG_MAX = 200; // max number of sentence groups // globals SENTENCEG rgsentenceg[CSENTENCEG_MAX]; bool bSentencesInit = false; -char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; +char gszallsentencenames[MAX_CVOXFILESENTENCE][MAX_CBSENTENCENAME]; int gcallsentences = 0; // randomize list of sentence name indices @@ -1121,7 +1119,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres ipick = count - 1; strncpy(szfound, "!", 64); - strncat(szfound, szgroupname, CBSENTENCENAME_MAX); + strncat(szfound, szgroupname, MAX_CBSENTENCENAME); _snprintf(sznum, sizeof(sznum), "%i", ipick); strncat(szfound, sznum, sizeof(sznum)); @@ -1153,7 +1151,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) unsigned char count; char sznum[8]; unsigned char ipick; - int ffound = FALSE; + int ffound = false; if (!bSentencesInit) return -1; @@ -1172,7 +1170,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) { ipick = plru[i]; plru[i] = 0xFF; - ffound = TRUE; + ffound = true; break; } @@ -1181,7 +1179,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) else { strncpy(szfound, "!", 64); - strncat(szfound, szgroupname, CBSENTENCENAME_MAX); + strncat(szfound, szgroupname, MAX_CBSENTENCENAME); _snprintf(sznum, sizeof(sznum), "%i", ipick); strncat(szfound, sznum, sizeof(sznum)); return ipick; @@ -1304,7 +1302,7 @@ void SENTENCEG_Stop(edict_t *entity, int isentenceg, int ipick) return; strncpy(buffer, "!", sizeof(buffer)); - strncat(buffer, rgsentenceg[isentenceg].szgroupname, CBSENTENCENAME_MAX); + strncat(buffer, rgsentenceg[isentenceg].szgroupname, MAX_CBSENTENCENAME); _snprintf(sznum, sizeof(sznum), "%i", ipick); strncat(buffer, sznum, sizeof(sznum)); @@ -1325,7 +1323,7 @@ void SENTENCEG_Init() if (bSentencesInit) return; - memset(gszallsentencenames, 0, CVOXFILESENTENCEMAX * CBSENTENCENAME_MAX); + memset(gszallsentencenames, 0, MAX_CVOXFILESENTENCE * MAX_CBSENTENCENAME); gcallsentences = 0; memset(rgsentenceg, 0, CSENTENCEG_MAX * sizeof(SENTENCEG)); @@ -1359,7 +1357,7 @@ void SENTENCEG_Init() if (!buffer[j]) continue; - if (gcallsentences > CVOXFILESENTENCEMAX) + if (gcallsentences > MAX_CVOXFILESENTENCE) { ALERT(at_error, "Too many sentences in sentences.txt!\n"); break; @@ -1369,10 +1367,10 @@ void SENTENCEG_Init() buffer[j] = 0; const char *pString = buffer + i; - if (strlen(pString) >= CBSENTENCENAME_MAX) - ALERT(at_warning, "Sentence %s longer than %d letters\n", pString, CBSENTENCENAME_MAX - 1); + if (strlen(pString) >= MAX_CBSENTENCENAME) + ALERT(at_warning, "Sentence %s longer than %d letters\n", pString, MAX_CBSENTENCENAME - 1); - strncpy(gszallsentencenames[gcallsentences++], pString, CBSENTENCENAME_MAX); + strncpy(gszallsentencenames[gcallsentences++], pString, MAX_CBSENTENCENAME); j--; if (j <= i) @@ -1403,7 +1401,7 @@ void SENTENCEG_Init() break; } - strncpy(rgsentenceg[isentencegs].szgroupname, &(buffer[i]), CBSENTENCENAME_MAX); + strncpy(rgsentenceg[isentencegs].szgroupname, &(buffer[i]), MAX_CBSENTENCENAME); rgsentenceg[isentencegs].count = 1; strncpy(szgroup, &(buffer[i]), 64); @@ -1528,11 +1526,9 @@ void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname) // Used to detect the texture the player is standing on, map the // texture name to a material type. Play footstep sound based // on material type. -#define CTEXTURESMAX 512 // max number of textures loaded - -int gcTextures = 0; -char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; // texture names -char grgchTextureType[CTEXTURESMAX]; // parallel array of texture types +unsigned int gcTextures = 0; +char grgszTextureName[MAX_CTEXTURES][MAX_CBTEXTURENAME]; // texture names +char grgchTextureType[MAX_CTEXTURES]; // parallel array of texture types // given texture name, find texture type // if not found, return type 'concrete' @@ -1544,9 +1540,9 @@ 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)) + if (!_strnicmp(name, &(grgszTextureName[i][0]), MAX_CBTEXTURENAME - 1)) return (grgchTextureType[i]); } @@ -1609,7 +1605,7 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int pTextureName++; // '}}' strncpy(szbuffer, pTextureName, sizeof(szbuffer) ); - szbuffer[CBTEXTURENAMEMAX - 1] = 0; + szbuffer[MAX_CBTEXTURENAME - 1] = 0; // ALERT ( at_console, "texture hit: %s\n", szbuffer); @@ -1811,8 +1807,9 @@ void CSpeaker ::Spawn(void) Precache(); } -#define ANNOUNCE_MINUTES_MIN 0.25 -#define ANNOUNCE_MINUTES_MAX 2.25 + +constexpr float ANNOUNCE_MINUTES_MIN = 0.25; +constexpr float ANNOUNCE_MINUTES_MAX = 2.25; static float g_talkWaitTime = 0.0f; // time delay until it's ok to speak: used so that two NPCs don't talk at once void CSpeaker ::Precache(void) @@ -1915,7 +1912,7 @@ void CSpeaker ::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP { int fActive = (pev->nextthink > 0.0); - // fActive is TRUE only if an announcement is pending + // fActive is true only if an announcement is pending if (useType != USE_TOGGLE) { @@ -1963,7 +1960,7 @@ void CSpeaker ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "preset")) { m_preset = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity::KeyValue(pkvd); diff --git a/src/game/server/hl/soundent.cpp b/src/game/server/hl/soundent.cpp index 4ec6aa2b..70592469 100644 --- a/src/game/server/hl/soundent.cpp +++ b/src/game/server/hl/soundent.cpp @@ -48,29 +48,29 @@ void CSound :: Reset ( void ) } //========================================================= -// FIsSound - returns TRUE if the sound is an Audible sound +// FIsSound - returns true if the sound is an Audible sound //========================================================= BOOL CSound :: FIsSound ( void ) { if ( m_iType & ( bits_SOUND_COMBAT | bits_SOUND_WORLD | bits_SOUND_PLAYER | bits_SOUND_DANGER ) ) { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= -// FIsScent - returns TRUE if the sound is actually a scent +// FIsScent - returns true if the sound is actually a scent //========================================================= BOOL CSound :: FIsScent ( void ) { if ( m_iType & ( bits_SOUND_CARCASS | bits_SOUND_MEAT | bits_SOUND_GARBAGE ) ) { - return TRUE; + return true; } - return FALSE; + return false; } //========================================================= @@ -102,7 +102,7 @@ void CSoundEnt :: Think ( void ) while ( iSound != SOUNDLIST_EMPTY ) { - if ( m_SoundPool[ iSound ].m_flExpireTime <= gpGlobals->time && m_SoundPool[ iSound ].m_flExpireTime != SOUND_NEVER_EXPIRE ) + if ( m_SoundPool[ iSound ].m_flExpireTime <= gpGlobals->time && (int)m_SoundPool[ iSound ].m_flExpireTime != SOUND_NEVER_EXPIRE ) { int iNext = m_SoundPool[ iSound ].m_iNext; @@ -272,11 +272,11 @@ void CSoundEnt :: Initialize ( void ) if ( CVAR_GET_FLOAT("displaysoundlist") == 1 ) { - m_fShowReport = TRUE; + m_fShowReport = true; } else { - m_fShowReport = FALSE; + m_fShowReport = false; } } @@ -286,8 +286,8 @@ void CSoundEnt :: Initialize ( void ) //========================================================= int CSoundEnt :: ISoundsInList ( int iListType ) { - int i; - int iThisSound; + unsigned int i; + int iThisSound{}; if ( iListType == SOUNDLISTTYPE_FREE ) { diff --git a/src/game/server/hl/soundent.h b/src/game/server/hl/soundent.h index 49e943a4..8ac6faa3 100644 --- a/src/game/server/hl/soundent.h +++ b/src/game/server/hl/soundent.h @@ -18,27 +18,28 @@ // lists. //========================================================= -#define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. - -#define bits_SOUND_NONE 0 -#define bits_SOUND_COMBAT (1 << 0) // gunshots, explosions -#define bits_SOUND_WORLD (1 << 1) // door opening/closing, glass breaking -#define bits_SOUND_PLAYER (1 << 2) // all noises generated by player. walking, shooting, falling, splashing -#define bits_SOUND_CARCASS (1 << 3) // dead body -#define bits_SOUND_MEAT (1 << 4) // gib or pork chop -#define bits_SOUND_DANGER (1 << 5) // pending danger. Grenade that is about to explode, explosive barrel that is damaged, falling crate -#define bits_SOUND_GARBAGE (1 << 6) // trash cans, banana peels, old fast food bags. -#define bits_SOUND_WALKING (1 << 7) // MasterSword: Just walking/moving - -#define bits_ALL_SOUNDS 0xFFFFFFFF - -#define SOUNDLIST_EMPTY -1 - -#define SOUNDLISTTYPE_FREE 1 // identifiers passed to functions that can operate on either list, to indicate which list to operate on. -#define SOUNDLISTTYPE_ACTIVE 2 - -#define SOUND_NEVER_EXPIRE -1 // with this set as a sound's ExpireTime, the sound will never expire. +constexpr int MAX_WORLD_SOUNDS = 64; // maximum number of sounds handled by the world at one time. + + +enum { + bits_SOUND_NONE = 0, + bits_SOUND_COMBAT = (1 << 0), // gunshots, explosions + bits_SOUND_WORLD = (1 << 1), // door opening/closing, glass breaking + bits_SOUND_PLAYER = (1 << 2), // all noises generated by player. walking, shooting, falling, splashing + bits_SOUND_CARCASS = (1 << 3), // dead body + bits_SOUND_MEAT = (1 << 4), // gib or pork chop + bits_SOUND_DANGER = (1 << 5), // pending danger. Grenade that is about to explode, explosive barrel that is damaged, falling crate + bits_SOUND_GARBAGE = (1 << 6), // trash cans, banana peels, old fast food bags. + bits_SOUND_WALKING = (1 << 7), // MasterSword: Just walking/moving + bits_ALL_SOUNDS = 0xFFFFFFFF +}; +enum { + SOUNDLIST_EMPTY = -1, + SOUNDLISTTYPE_FREE = 1, // identifiers passed to functions that can operate on either list, to indicate which list to operate on. + SOUNDLISTTYPE_ACTIVE = 2, + SOUND_NEVER_EXPIRE = -1 // with this set as a sound's ExpireTime, the sound will never expire. +}; //========================================================= // CSound - an instance of a sound in the world. //========================================================= diff --git a/src/game/server/hl/spectator.cpp b/src/game/server/hl/spectator.cpp index c359bd91..4c8b62e2 100644 --- a/src/game/server/hl/spectator.cpp +++ b/src/game/server/hl/spectator.cpp @@ -74,7 +74,7 @@ void CBaseSpectator::SpectatorImpulseCommand(void) // Start at the current goal, skip the world, and stop if we looped // back around - bFound = FALSE; + bFound = false; while (1) { pCurrentGoal = FIND_ENTITY_BY_CLASSNAME(pCurrentGoal, "info_player_deathmatch"); @@ -87,7 +87,7 @@ void CBaseSpectator::SpectatorImpulseCommand(void) // Found a non-world entity, set success, otherwise, look for the next one. if (!FNullEnt(pCurrentGoal)) { - bFound = TRUE; + bFound = true; break; } } @@ -98,7 +98,7 @@ void CBaseSpectator::SpectatorImpulseCommand(void) pGoal = pCurrentGoal; UTIL_SetOrigin(pev, pGoal->v.origin); pev->angles = pGoal->v.angles; - pev->fixangle = FALSE; + pev->fixangle = false; break; default: ALERT(at_console, "Unknown spectator impulse\n"); diff --git a/src/game/server/hl/subs.cpp b/src/game/server/hl/subs.cpp index 4e4ba514..d5a840a8 100644 --- a/src/game/server/hl/subs.cpp +++ b/src/game/server/hl/subs.cpp @@ -71,7 +71,7 @@ void CBaseDMStart::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "master")) { pev->netname = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CPointEntity::KeyValue(pkvd); @@ -80,7 +80,6 @@ void CBaseDMStart::KeyValue(KeyValueData *pkvd) BOOL CBaseDMStart::IsTriggered(CBaseEntity *pEntity) { BOOL master = UTIL_IsMasterTriggered(pev->netname, pEntity); - return master; } @@ -102,7 +101,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) { @@ -161,12 +160,12 @@ void CBaseDelay ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "delay")) { m_flDelay = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "killtarget")) { m_iszKillTarget = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else { @@ -395,22 +394,22 @@ void CBaseToggle::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "lip")) { m_flLip = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "wait")) { m_flWait = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "master")) { m_sMaster = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "distance")) { m_flMoveDistance = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseDelay::KeyValue(pkvd); @@ -469,9 +468,9 @@ void CBaseToggle ::LinearMoveDone(void) BOOL CBaseToggle ::IsLockedByMaster(void) { if (m_sMaster && !UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) - return TRUE; + return true; else - return FALSE; + return false; } /* @@ -560,7 +559,7 @@ float CBaseToggle ::AxisDelta(int flags, const Vector &angle1, const Vector &ang ============= FEntIsVisible -returns TRUE if the passed entity is visible to caller, even if not infront () +returns true if the passed entity is visible to caller, even if not infront () ============= */ BOOL FEntIsVisible( @@ -574,10 +573,10 @@ BOOL FEntIsVisible( UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr); if (tr.fInOpen && tr.fInWater) - return FALSE; // sight line crossed contents + return false; // sight line crossed contents if (tr.flFraction == 1) - return TRUE; + return true; - return FALSE; + return false; } diff --git a/src/game/server/hl/trains.h b/src/game/server/hl/trains.h index 69be4f14..e054da23 100644 --- a/src/game/server/hl/trains.h +++ b/src/game/server/hl/trains.h @@ -15,25 +15,45 @@ #ifndef TRAINS_H #define TRAINS_H +enum train_state_e { + + TRAIN_ACTIVE = 0x80, + TRAIN_NEW = 0xc0, + TRAIN_OFF = 0x00, + TRAIN_NEUTRAL = 0x01, + TRAIN_SLOW = 0x02, + TRAIN_MEDIUM = 0x03, + TRAIN_FAST = 0x04, + TRAIN_BACK = 0x05 + +}; + // Tracktrain spawn flags -#define SF_TRACKTRAIN_NOPITCH 0x0001 -#define SF_TRACKTRAIN_NOCONTROL 0x0002 -#define SF_TRACKTRAIN_FORWARDONLY 0x0004 -#define SF_TRACKTRAIN_PASSABLE 0x0008 -#define SF_TRACKTRAIN_NOYAW 0x0010 //APR2008a - No Yaw option for Tracktrain +enum sf_tracktrain_e { + SF_TRACKTRAIN_NOPITCH = 0x0001, + SF_TRACKTRAIN_NOCONTROL = 0x0002, + SF_TRACKTRAIN_FORWARDONLY = 0x0004, + SF_TRACKTRAIN_PASSABLE = 0x0008, + SF_TRACKTRAIN_NOYAW = 0x0010, //APR2008a - No Yaw option for Tracktrain +}; // Spawnflag for CPathTrack -#define SF_PATH_DISABLED 0x00000001 -#define SF_PATH_FIREONCE 0x00000002 -#define SF_PATH_ALTREVERSE 0x00000004 -#define SF_PATH_DISABLE_TRAIN 0x00000008 -#define SF_PATH_ALTERNATE 0x00008000 + +enum sf_cpathtrack_e { + SF_PATH_DISABLED = 0x00000001, + SF_PATH_FIREONCE = 0x00000002, + SF_PATH_ALTREVERSE = 0x00000004, + SF_PATH_DISABLE_TRAIN = 0x00000008, + SF_PATH_ALTERNATE = 0x00008000 +}; // Spawnflags of CPathCorner -#define SF_CORNER_WAITFORTRIG 0x001 -#define SF_CORNER_TELEPORT 0x002 -#define SF_CORNER_FIREONCE 0x004 +enum sf_cpath_corner_e { + SF_CORNER_WAITFORTRIG = 0x001, + SF_CORNER_TELEPORT = 0x002, + SF_CORNER_FIREONCE = 0x004 +}; //#define PATH_SPARKLE_DEBUG 1 // This makes a particle effect around path_track entities for debugging class CPathTrack : public CPointEntity { diff --git a/src/game/server/hl/util.cpp b/src/game/server/hl/util.cpp index 0ffc2c03..b2d908be 100644 --- a/src/game/server/hl/util.cpp +++ b/src/game/server/hl/util.cpp @@ -316,7 +316,7 @@ TYPEDESCRIPTION gEntvarsDescription[] = DEFINE_ENTITY_FIELD(radsuit_finished, FIELD_TIME), }; -#define ENTVARS_COUNT (sizeof(gEntvarsDescription) / sizeof(gEntvarsDescription[0])) +constexpr unsigned int ENTVARS_COUNT = (sizeof(gEntvarsDescription) / sizeof(gEntvarsDescription[0])); #ifdef DEBUG edict_t *DBG_EntOfVars(const entvars_t *pev) @@ -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()); @@ -992,7 +992,13 @@ void UTIL_MakeAimVectors(const Vector &vecAngles) MAKE_VECTORS(rgflVec); } -#define SWAP(a, b, temp) ((temp) = (a), (a) = (b), (b) = (temp)) +//#define SWAP(a, b, temp) ((temp) = (a), (a) = (b), (b) = (temp)) +template +inline void SWAP (Type &a, Type &b, Type &temp) { + temp = a; + a = b; + b = temp; +} void UTIL_MakeInvVectors(const Vector &vec, globalvars_t *pgv) { @@ -1058,7 +1064,7 @@ void UTIL_ScreenShake(const Vector ¢er, float amplitude, float frequency, fl { int i; float localAmplitude; - ScreenShake shake; + ScreenShake shake{}; shake.duration = FixedUnsigned16(duration, 1 << 12); // 4.12 fixed shake.frequency = FixedUnsigned16(frequency, 1 << 8); // 8.8 fixed @@ -1339,12 +1345,12 @@ void UTIL_TraceLine(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTER void UTIL_TraceLine(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr) { - TRACE_LINE(vecStart, vecEnd, (igmon == ignore_monsters ? TRUE : FALSE), pentIgnore, ptr); + TRACE_LINE(vecStart, vecEnd, (igmon == ignore_monsters ? true : false), pentIgnore, ptr); } void UTIL_TraceHull(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr) { - TRACE_HULL(vecStart, vecEnd, (igmon == ignore_monsters ? TRUE : FALSE), hullNumber, pentIgnore, ptr); + TRACE_HULL(vecStart, vecEnd, (igmon == ignore_monsters ? true : false), hullNumber, pentIgnore, ptr); } void UTIL_TraceModel(const Vector &vecStart, const Vector &vecEnd, int hullNumber, edict_t *pentModel, TraceResult *ptr) @@ -1496,15 +1502,15 @@ BOOL UTIL_ShouldShowBlood(int color) if (color == BLOOD_COLOR_RED) { if (CVAR_GET_FLOAT("violence_hblood") != 0) - return TRUE; + return true; } else { if (CVAR_GET_FLOAT("violence_ablood") != 0) - return TRUE; + return true; } } - return FALSE; + return false; } int UTIL_PointContents(const Vector &vec) @@ -1731,16 +1737,16 @@ BOOL UTIL_TeamsMatch(const char *pTeamName1, const char *pTeamName2) { // Everyone matches unless it's teamplay if (!g_pGameRules->IsTeamplay()) - return TRUE; + return true; // Both on a team? if (*pTeamName1 != 0 && *pTeamName2 != 0) { if (!_stricmp(pTeamName1, pTeamName2)) // Same Team? - return TRUE; + return true; } - return FALSE; + return false; } void UTIL_StringToVector(float *pVector, const char *pString) @@ -1945,8 +1951,8 @@ void UTIL_Remove(CBaseEntity *pEntity) BOOL UTIL_IsValidEntity(edict_t *pent) { if (!pent || pent->free || (pent->v.flags & FL_KILLME)) - return FALSE; - return TRUE; + return false; + return true; } void UTIL_PrecacheOther(const char *szClassname) @@ -2179,10 +2185,10 @@ unsigned short CSaveRestoreBuffer ::TokenHash(const char *pszToken) for (int i = 0; i < m_pdata->tokenCount; i++) { #if _DEBUG - static qboolean beentheredonethat = FALSE; + static qboolean beentheredonethat = false; if (i > 50 && !beentheredonethat) { - beentheredonethat = TRUE; + beentheredonethat = true; ALERT(at_error, "CSaveRestoreBuffer :: TokenHash() is getting too full!"); } #endif @@ -2375,7 +2381,7 @@ void EntvarsKeyvalue(entvars_t *pev, KeyValueData *pkvd) ALERT(at_error, "Bad field in entity!!\n"); break; } - pkvd->fHandled = TRUE; + pkvd->fHandled = true; return; } } @@ -2503,9 +2509,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 4ce391b7..0a655766 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 @@ -71,7 +88,7 @@ inline edict_t *FIND_ENTITY_BY_TARGET(edict_t *entStart, const char *pszName) // Until we figure out why "const" gives the compiler problems, we'll just have to use // this bogus "empty" define to mark things as constant. -#define CONSTANT +//#define CONSTANT // More explicit than "int" typedef int EOFFSET; @@ -80,10 +97,6 @@ typedef int EOFFSET; typedef int BOOL; // In case this ever changes -#ifndef M_PI -#define 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) @@ -149,7 +162,7 @@ inline entvars_t *VARS(entvars_t *pev) { return pev; } inline entvars_t *VARS(edict_t *pent) { if (!pent) - return NULL; + return nullptr; return &pent->v; } @@ -164,34 +177,34 @@ 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; } -inline BOOL FNullEnt(const edict_t *pent) { return pent == NULL || FNullEnt(OFFSET(pent)); } -inline BOOL FNullEnt(entvars_t *pev) { return pev == NULL || FNullEnt(OFFSET(pev)); } +inline BOOL FNullEnt(const edict_t *pent) { return pent == nullptr || FNullEnt(OFFSET(pent)); } +inline BOOL FNullEnt(entvars_t *pev) { return pev == nullptr || 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 -#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 { @@ -251,7 +264,12 @@ extern CBaseEntity *UTIL_FindEntityGeneric(const char *szName, Vector &vecSrc, f // Index is 1 based extern CBaseEntity *UTIL_PlayerByIndex(int playerIndex); -#define UTIL_EntitiesInPVS(pent) (*g_engfuncs.pfnEntitiesInPVS)(pent) +//#define UTIL_EntitiesInPVS(edict_t * pent) (*g_engfuncs.pfnEntitiesInPVS)(pent) + +inline edict_t* UTIL_EntitiesInPVS(edict_t* pent) { + return g_engfuncs.pfnEntitiesInPVS(pent); +} + extern void UTIL_MakeVectors(const Vector &vecAngles); // Pass in an array of pointers and an array size, it fills the array and returns the number inserted @@ -296,20 +314,24 @@ typedef enum dont_ignore_monsters = 0, missile = 2 } IGNORE_MONSTERS; + typedef enum { ignore_glass = 1, dont_ignore_glass = 0 } IGNORE_GLASS; + extern void UTIL_TraceLine(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr); extern void UTIL_TraceLine(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, IGNORE_GLASS ignoreGlass, edict_t *pentIgnore, TraceResult *ptr); -enum + +enum hull_e { point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 }; + extern void UTIL_TraceHull(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr); extern TraceResult UTIL_GetGlobalTrace(void); extern void UTIL_TraceModel(const Vector &vecStart, const Vector &vecEnd, int hullNumber, edict_t *pentModel, TraceResult *ptr); @@ -351,8 +373,8 @@ extern void UTIL_BubbleTrail(Vector from, Vector to, int count); extern void UTIL_PrecacheOther(const char *szClassname); // prints a message to each client -extern void UTIL_ClientPrintAll(int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL); -inline void UTIL_CenterPrintAll(const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL) +extern void UTIL_ClientPrintAll(int msg_dest, const char *msg_name, const char *param1 = nullptr, const char *param2 = nullptr, const char *param3 = nullptr, const char *param4 = nullptr); +inline void UTIL_CenterPrintAll(const char *msg_name, const char *param1 = nullptr, const char *param2 = nullptr, const char *param3 = nullptr, const char *param4 = nullptr) { UTIL_ClientPrintAll(HUD_PRINTCENTER, msg_name, param1, param2, param3, param4); } @@ -366,7 +388,7 @@ extern CBasePlayer* UTIL_PlayerBySteamID(ID64 steamID64); extern ID64 UTIL_ComputeSteamID64(const char* id, char sep = ':'); // prints messages through the HUD -extern void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL); +extern void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const char *param1 = nullptr, const char *param2 = nullptr, const char *param3 = nullptr, const char *param4 = nullptr); // prints a message to the HUD say (chat) extern void UTIL_SayText(const char *pText, CBaseEntity *pEntity); @@ -428,101 +450,121 @@ 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_setting_e { + 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 amient_sound_e { + 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_e { + SPEAKER_START_SILENT = 1 // wait for trigger 'on' to start announcements +}; -// 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 +enum sound_cmd_e { + 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 +}; -// func_pushable (it's also func_breakable, so don't collide with those flags) -#define SF_PUSH_BREAKABLE 128 +enum lfo_wave_e { + LFO_SQUARE = 1, + LFO_TRIANGLE = 2, + LFO_RANDOM = 3 +}; -#define SF_LIGHT_START_OFF 1 +enum sf_brush_e { + 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 +}; -#define SPAWNFLAG_NOMESSAGE 1 -#define SPAWNFLAG_NOTOUCH 1 -#define SPAWNFLAG_DROIDONLY 4 -#define SPAWNFLAG_USEONLY 1 // can't be touched, must be used (buttons) +enum push_block_e { + PUSH_BLOCK_ONLY_X = 1, + PUSH_BLOCK_ONLY_Y = 2 +}; -#define TELE_PLAYER_ONLY 1 -#define TELE_SILENT 2 +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_type_e { + SVC_TEMPENTITY = 23, + SVC_INTERMISSION = 30, + SVC_CDTRACK = 32, + SVC_WEAPONANIM = 35, + SVC_ROOMTYPE = 37, + SVC_DIRECTOR = 51 +}; -#define SF_TRIG_PUSH_ONCE 1 +// triggers + +enum sf_trigger_e { + 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 +}; +// func breakable +enum sf_func_breakable_e { + 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 +}; + +enum sf_light_start_e { + SF_LIGHT_START_OFF = 1 +}; + +enum spawnflag_e { + SPAWNFLAG_NOMESSAGE = 1, + SPAWNFLAG_NOTOUCH = 1, + SPAWNFLAG_USEONLY = 1, + SPAWNFLAG_DROIDONLY = 4 +}; + +enum teleport_sound_e { + 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 MAX_CBSENTENCENAME = 16; +constexpr int MAX_CVOXFILESENTENCE = 1536;// max number of sentences in game. NOTE: this must match CVOXFILESENTENCEMAX in engine\sound.h!!! -extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; +extern char gszallsentencenames[MAX_CVOXFILESENTENCE][MAX_CBSENTENCENAME]; extern int gcallsentences; int USENTENCEG_Pick(int isentenceg, char *szfound); @@ -540,7 +582,7 @@ int SENTENCEG_Lookup(const char *sample, char *sentencenum); char TEXTURETYPE_Find(char *name); float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType); -/*#define CBTEXTURENAMEMAX 13 // only load first n chars of name +/*#define MAX_CBTEXTURENAME 13 // only load first n chars of name #define CHAR_TEX_CONCRETE 'C' // texture types #define CHAR_TEX_METAL 'M' @@ -596,9 +638,12 @@ void EMIT_SOUND_SUIT(edict_t *entity, const char *sample); void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); + +//these don't look used +/* #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]); \ } @@ -609,10 +654,12 @@ void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); #define PLAYBACK_EVENT(flags, who, index) PLAYBACK_EVENT_FULL(flags, who, index, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0); #define PLAYBACK_EVENT_DELAY(flags, who, index, delay) PLAYBACK_EVENT_FULL(flags, who, index, delay, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0); +*/ -#define GROUP_OP_AND 0 -#define GROUP_OP_NAND 1 - +enum { + GROUP_OP_AND = 0, + GROUP_OP_NAND = 1 +}; extern int g_groupmask; extern int g_groupop; @@ -635,5 +682,5 @@ float UTIL_SharedRandomFloat(unsigned int seed, float low, float high); float UTIL_WeaponTimeBase(void); //Master Sword -#include "sharedutil.h" +//#include "sharedutil.h" #endif 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/bodyparts/bodyparts_human.h b/src/game/server/monsters/bodyparts/bodyparts_human.h index 95e4b550..a047cb21 100644 --- a/src/game/server/monsters/bodyparts/bodyparts_human.h +++ b/src/game/server/monsters/bodyparts/bodyparts_human.h @@ -1,5 +1,7 @@ -#include "bodyparts.h" +#ifndef BODYPARTS_HUMAN_H +#include "bodyparts.h" +#define BODYPARTS_HUMAN_H enum { //Human bodyparts @@ -23,4 +25,5 @@ class CHumanBody : public CBaseBody CBaseBody *Duplicate(); }; -int HitGroupToBodyPart(int HitGroup); \ No newline at end of file +int HitGroupToBodyPart(int HitGroup); +#endif \ No newline at end of file diff --git a/src/game/server/monsters/combat.cpp b/src/game/server/monsters/combat.cpp index 1294fbcd..33730080 100644 --- a/src/game/server/monsters/combat.cpp +++ b/src/game/server/monsters/combat.cpp @@ -34,9 +34,11 @@ extern DLL_GLOBAL int g_iSkillLevel; extern Vector VecBModelOrigin(entvars_t *pevBModel); extern entvars_t *g_pevLastInflictor; -#define GERMAN_GIB_COUNT 4 -#define HUMAN_GIB_COUNT 6 -#define ALIEN_GIB_COUNT 4 +enum gib_count_e { + GERMAN_GIB_COUNT = 4, + HUMAN_GIB_COUNT = 6, + ALIEN_GIB_COUNT = 4 +}; // HACKHACK -- The gib velocity equations don't work void CGib ::LimitVelocity(void) @@ -255,9 +257,9 @@ BOOL CBaseMonster ::HasHumanGibs(void) myClass == CLASS_HUMAN_PASSIVE || myClass == CLASS_PLAYER) - return TRUE; + return true; - return FALSE; + return false; } BOOL CBaseMonster ::HasAlienGibs(void) @@ -271,9 +273,9 @@ BOOL CBaseMonster ::HasAlienGibs(void) myClass == CLASS_ALIEN_PREDATOR || myClass == CLASS_ALIEN_PREY) - return TRUE; + return true; - return FALSE; + return false; } void CBaseMonster::FadeMonster(void) @@ -294,7 +296,7 @@ void CBaseMonster::FadeMonster(void) void CBaseMonster ::GibMonster(void) { TraceResult tr; - BOOL gibbed = FALSE; + BOOL gibbed = false; EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/bodysplat.wav", 1, ATTN_NORM); @@ -308,7 +310,7 @@ void CBaseMonster ::GibMonster(void) CGib::SpawnHeadGib(pev); CGib::SpawnRandomGibs(pev, 4, 1); // throw some human gibs. } - gibbed = TRUE; + gibbed = true; } else if (HasAlienGibs()) { @@ -316,7 +318,7 @@ void CBaseMonster ::GibMonster(void) { CGib::SpawnRandomGibs(pev, 4, 0); // Throw alien gibs } - gibbed = TRUE; + gibbed = true; } if (!IsPlayer()) @@ -357,7 +359,7 @@ Activity CBaseMonster ::GetDeathActivity(void) vecSrc = Center(); - fTriedDirection = FALSE; + fTriedDirection = false; deathActivity = ACT_DIESIMPLE; // in case we can't find any special deaths to do. UTIL_MakeVectors(pev->angles); @@ -376,7 +378,7 @@ Activity CBaseMonster ::GetDeathActivity(void) case HITGROUP_GENERIC: // try to pick a death based on attack direction - fTriedDirection = TRUE; + fTriedDirection = true; if (flDot > 0.3) { @@ -390,7 +392,7 @@ Activity CBaseMonster ::GetDeathActivity(void) default: // try to pick a death based on attack direction - fTriedDirection = TRUE; + fTriedDirection = true; if (flDot > 0.3) { @@ -467,7 +469,7 @@ Activity CBaseMonster ::GetSmallFlinchActivity(void) BOOL fTriedDirection; float flDot; - fTriedDirection = FALSE; + fTriedDirection = false; UTIL_MakeVectors(pev->angles); flDot = DotProduct(gpGlobals->v_forward, g_vecAttackDir * -1); @@ -527,24 +529,24 @@ void CBaseMonster::BecomeDead(void) BOOL CBaseMonster::ShouldGibMonster(int iGib) { if ((iGib == GIB_NORMAL && pev->health < GIB_HEALTH_VALUE) || (iGib == GIB_ALWAYS)) - return TRUE; + return true; - return FALSE; + return false; } void CBaseMonster::CallGibMonster(void) { - BOOL fade = FALSE; + BOOL fade = false; if (HasHumanGibs()) { if (CVAR_GET_FLOAT("violence_hgibs") == 0) - fade = TRUE; + fade = true; } else if (HasAlienGibs()) { if (CVAR_GET_FLOAT("violence_agibs") == 0) - fade = TRUE; + fade = true; } pev->takedamage = DAMAGE_NO; @@ -580,7 +582,7 @@ Killed */ void CBaseMonster ::Killed(entvars_t *pevAttacker, int iGib) { - BOOL fDone = FALSE; + BOOL fDone = false; if (HasMemory(bits_MEMORY_KILLED)) { @@ -1046,7 +1048,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) @@ -1165,11 +1167,11 @@ bool CBaseEntity ::FInViewCone(CBaseEntity *pEntity, float m_flFieldOfView) if (flDot > m_flFieldOfView) { - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -1220,14 +1222,14 @@ BOOL CBaseEntity ::FMVisible(CBaseEntity *pEntity) Vector vecTargetOrigin; if (FBitSet(pEntity->pev->flags, FL_NOTARGET)) - return FALSE; + return false; // don't look through water // Thothie APR2011_29 - WTF not? This is causing issues with players in water /* if ((pev->waterlevel != 3 && pEntity->pev->waterlevel == 3) || (pev->waterlevel == 3 && pEntity->pev->waterlevel == 0)) - return FALSE; + return false; */ vecLookerOrigin = pev->origin + pev->view_ofs; //look through the caller's 'eyes' @@ -1238,13 +1240,13 @@ BOOL CBaseEntity ::FMVisible(CBaseEntity *pEntity) if (tr.flFraction != 1.0) { if (tr.pHit == pEntity->edict()) - return TRUE; //hit my target + return true; //hit my target - return FALSE; // Line of sight is not established + return false; // Line of sight is not established } else { - return TRUE; // line of sight is valid. + return true; // line of sight is valid. } } @@ -1263,11 +1265,11 @@ BOOL CBaseEntity ::FMVisible(const Vector &vecOrigin) if (tr.flFraction != 1.0) { - return FALSE; // Line of sight is not established + return false; // Line of sight is not established } else { - return TRUE; // line of sight is valid. + return true; // line of sight is valid. } } //========================================================= @@ -1281,12 +1283,12 @@ BOOL CBaseEntity ::FVisible(CBaseEntity *pEntity) Vector vecTargetOrigin; if (FBitSet(pEntity->pev->flags, FL_NOTARGET)) - return FALSE; + return false; // don't look through water //if ((pev->waterlevel != 3 && pEntity->pev->waterlevel == 3) // || (pev->waterlevel == 3 && pEntity->pev->waterlevel == 0)) - // return FALSE; + // return false; vecLookerOrigin = pev->origin + pev->view_ofs; //look through the caller's 'eyes' vecTargetOrigin = pEntity->EyePosition(); @@ -1295,11 +1297,11 @@ BOOL CBaseEntity ::FVisible(CBaseEntity *pEntity) if (tr.flFraction != 1.0) { - return FALSE; // Line of sight is not established + return false; // Line of sight is not established } else { - return TRUE; // line of sight is valid. + return true; // line of sight is valid. } } @@ -1318,11 +1320,11 @@ BOOL CBaseEntity ::FVisible(const Vector &vecOrigin) if (tr.flFraction != 1.0) { - return FALSE; // Line of sight is not established + return false; // Line of sight is not established } else { - return TRUE; // line of sight is valid. + return true; // line of sight is valid. } } diff --git a/src/game/server/monsters/corpse.cpp b/src/game/server/monsters/corpse.cpp index 4fbca19a..ccb709ae 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]; @@ -123,7 +123,7 @@ bool CCorpse::AddItem(CGenericItem* pItem, bool ToHand, bool CheckWeight, int Fo if (!pItem->WearItem()) { pItem->SUB_Remove(); - fReturn = FALSE; + fReturn = false; } } else diff --git a/src/game/server/monsters/corpse.h b/src/game/server/monsters/corpse.h index a6c4ca32..b326e1ab 100644 --- a/src/game/server/monsters/corpse.h +++ b/src/game/server/monsters/corpse.h @@ -1,4 +1,4 @@ -#define SKELETON_MODEL "models/monsters/skeleton.mdl" +constexpr const char* SKELETON_MODEL = "models/monsters/skeleton.mdl"; class CCorpse : public CMSMonster { @@ -9,12 +9,12 @@ class CCorpse : public CMSMonster CBasePlayer* pPlayerSource; //Overridden int ObjectCaps(void) { return FCAP_DONT_SAVE; } - int MSProperties() { return MS_CORPSE; } + int MSProperties() { return ITEM_MS_CORPSE; } void Spawn(); bool AddItem(CGenericItem* pItem, bool ToHand, bool CheckWeight, int ForceHand = -1); bool RemoveItem(CGenericItem* pItem); - BOOL HasHumanGibs() { return TRUE; } - BOOL HasAlienGibs() { return FALSE; } + BOOL HasHumanGibs() { return true; } + BOOL HasAlienGibs() { return false; } int BloodColor(void) { return BLOOD_COLOR_RED; } bool ShouldGibMonster(int iGib) { return true; } int Classify() { return CLASS_NONE; } diff --git a/src/game/server/monsters/monsteranimation.cpp b/src/game/server/monsters/monsteranimation.cpp index 6ca458af..e96dd8ae 100644 --- a/src/game/server/monsters/monsteranimation.cpp +++ b/src/game/server/monsters/monsteranimation.cpp @@ -2,13 +2,13 @@ #include "weapons/weapons.h" //Shorten things up a lot -#define m_Activity m_pOwner->m_Activity -#define m_fSequenceFinished m_pOwner->m_fSequenceFinished -#define LookupSequence m_pOwner->LookupSequence + +//#define LookupSequence m_pOwner->LookupSequence #undef Wielded -#undef CHWielded -#define CHWielded ((m_pPlayer->Hand[m_pPlayer->iCurrentHand]) ? m_pPlayer->Hand[m_pPlayer->iCurrentHand]->Wielded() : (m_pPlayer->PlayerHands ? m_pPlayer->PlayerHands->Wielded() : FALSE)) + + +//#define CHWielded ((m_pPlayer->Hand[m_pPlayer->iCurrentHand]) ? m_pPlayer->Hand[m_pPlayer->iCurrentHand]->Wielded() : (m_pPlayer->PlayerHands ? m_pPlayer->PlayerHands->Wielded() : false)) CAnimation *CAnimation::ChangeTo(MONSTER_ANIM NewAnim) { @@ -33,7 +33,7 @@ bool CAnimation ::SetAnim(const char* pszSequence) if (!pszSequence || !pszSequence[0]) return false; - int animDesired = LookupSequence(pszSequence); + int animDesired = m_pOwner->LookupSequence(pszSequence); if (animDesired <= -1) { @@ -52,7 +52,7 @@ bool CAnimation ::SetAnim(const char* pszSequence) } bool CAnimation ::SetGaitAnim(const char* pszSequence) { - int animDesired = LookupSequence(pszSequence); + int animDesired = m_pOwner->LookupSequence(pszSequence); if (animDesired <= -1) { m_pOwner->pev->gaitsequence = 0; @@ -86,41 +86,41 @@ void CAnimation ::GaitAnimate() if (speed == 0) { if (bCustomLegs) - NewGait = LookupSequence(UTIL_VarArgs("crouchidle_", m_szAnimLegs)); + NewGait = m_pOwner->LookupSequence(UTIL_VarArgs("crouchidle_", m_szAnimLegs)); if (NewGait < 0) - NewGait = LookupSequence("crouchidle"); + NewGait = m_pOwner->LookupSequence("crouchidle"); } else { if (bCustomLegs) - NewGait = LookupSequence(UTIL_VarArgs("crouchmove_", m_szAnimLegs)); + NewGait = m_pOwner->LookupSequence(UTIL_VarArgs("crouchmove_", m_szAnimLegs)); if (NewGait < 0) - NewGait = LookupSequence("crouch"); + NewGait = m_pOwner->LookupSequence("crouch"); } } - else if (speed > m_pOwner->WalkSpeed(FALSE) + 1) + else if (speed > m_pOwner->WalkSpeed(false) + 1) { if (bCustomLegs) - NewGait = LookupSequence(UTIL_VarArgs("run_%s", m_szAnimLegs)); + NewGait = m_pOwner->LookupSequence(UTIL_VarArgs("run_%s", m_szAnimLegs)); if (NewGait < 0) - NewGait = LookupSequence("run"); + NewGait = m_pOwner->LookupSequence("run"); } else if (speed > 0) { if (bCustomLegs) - NewGait = LookupSequence(UTIL_VarArgs("walk_%s", m_szAnimLegs)); + NewGait = m_pOwner->LookupSequence(UTIL_VarArgs("walk_%s", m_szAnimLegs)); if (NewGait < 0) - NewGait = LookupSequence("walk"); + NewGait = m_pOwner->LookupSequence("walk"); } else { if (bCustomLegs) - NewGait = LookupSequence(UTIL_VarArgs("stand_%s", m_szAnimLegs)); + NewGait = m_pOwner->LookupSequence(UTIL_VarArgs("stand_%s", m_szAnimLegs)); // if( bCustomLegs ) NewGait = 0; if (NewGait < 0) - NewGait = LookupSequence("stand"); + NewGait = m_pOwner->LookupSequence("stand"); //else NewGait = 0; } @@ -157,7 +157,7 @@ void CWalkAnim ::Animate() LegsAnimName = pPlayer->m_szAnimLegs; } - int animDesired = LookupSequence(TorsoAnimName); + int animDesired = m_pOwner->LookupSequence(TorsoAnimName); if (animDesired != m_pOwner->pev->sequence) //Continue playing the same uninterrupted animation until told otherwise SetAnim(TorsoAnimName); @@ -167,18 +167,18 @@ void CWalkAnim ::Animate() } CAnimHold gAnimHold; //Never submits to MONSTER_ANIM_WALK - //Submits to anything else if ReleaseAnim == TRUE + //Submits to anything else if ReleaseAnim == true //Only uses gait if specified with flags void CAnimHold ::Initialize(void *vData) { - ReleaseAnim = TRUE; + ReleaseAnim = true; UseGait = false; //defaults int Flags = (int)vData; if (Flags & (1 << 0)) - ReleaseAnim = FALSE; //Release to any anim besides walk + ReleaseAnim = false; //Release to any anim besides walk if (Flags & (1 << 1)) - UseGait = TRUE; //Use gait - IsNewAnim = TRUE; + UseGait = true; //Use gait + IsNewAnim = true; } bool CAnimHold ::CanChangeTo(MONSTER_ANIM NewAnim, void *vData) { @@ -218,7 +218,7 @@ void CAnimOnce ::Initialize(void *vData) } bool CAnimOnce ::CanChangeTo(MONSTER_ANIM NewAnim, void *vData) { - return m_fSequenceFinished ? true : false; + return m_pOwner->m_fSequenceFinished ? true : false; } void CAnimOnce ::Animate() { @@ -243,13 +243,13 @@ void CAnimOnce ::Animate() /* //stays in the last pose void CAnimAct :: Initialize( void *vData ) { - if( vData ) ReleaseAnim = FALSE; - else ReleaseAnim = TRUE; - IsNewAnim = TRUE; + if( vData ) ReleaseAnim = false; + else ReleaseAnim = true; + IsNewAnim = true; } bool CAnimAct :: CanChangeTo( MONSTER_ANIM NewAnim, void *vData ) { - if( m_fSequenceFinished && ReleaseAnim ) return TRUE; - return FALSE; + if( m_fSequenceFinished && ReleaseAnim ) return true; + return false; } void CAnimAct :: Animate( ) { if( !IsNewAnim ) return; diff --git a/src/game/server/monsters/msmonster.h b/src/game/server/monsters/msmonster.h index fee4544c..bb43b455 100644 --- a/src/game/server/monsters/msmonster.h +++ b/src/game/server/monsters/msmonster.h @@ -78,7 +78,8 @@ enum speech_type SPEECH_LOCAL, SPEECH_PARTY }; -#define SPEECH_LOCAL_RANGE 300 + +constexpr float SPEECH_LOCAL_RANGE = 300; enum gender_e { @@ -200,22 +201,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 frame_condition_monster_e { + 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_conditions_e { + 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 { @@ -267,9 +274,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 @@ -318,7 +325,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 @@ -357,7 +364,7 @@ class CMSMonster : public CBaseMonster virtual float MaxMP() { return m_MaxMP; } virtual float GetDefaultMoveProximity() { return m_Width * 1.1; } - BOOL IsAlive() { return pev ? pev->deadflag == DEAD_NO : FALSE; } + BOOL IsAlive() { return pev ? pev->deadflag == DEAD_NO : false; } virtual void CancelAttack(); //virtual void Step( ); //virtual void Jump( ); @@ -429,8 +436,8 @@ class CMSMonster : public CBaseMonster int MSProperties(); float HearingSensitivity(void) { return m_HearingSensitivity; } int ObjectCaps(void) { return CBaseMonster ::ObjectCaps() | FCAP_IMPULSE_USE; } - BOOL HasHumanGibs() { return TRUE; } - BOOL ShouldFadeOnDeath(void) { return FALSE; } + BOOL HasHumanGibs() { return true; } + BOOL ShouldFadeOnDeath(void) { return false; } #ifdef VALVE_DLL virtual float GiveHP(float flAmount) @@ -456,7 +463,7 @@ class CMSMonster : public CBaseMonster virtual void Used(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); virtual void Trade(); // Handle trading with others virtual bool AcceptOffer(); // Accept an offer from a player or monster - virtual BOOL SkinMonster(CMSMonster *pDeadMonster) { return FALSE; } //Skin other monsters + virtual BOOL SkinMonster(CMSMonster *pDeadMonster) { return false; } //Skin other monsters virtual tradeinfo_t *TradeItem(tradeinfo_t *tiTradeInfo); // Trade an item virtual void Attacked(CBaseEntity *pAttacker, damage_t &Damage); virtual void Seen(CMSMonster *pMonster) {} diff --git a/src/game/server/monsters/msmonsterserver.cpp b/src/game/server/monsters/msmonsterserver.cpp index 553e740f..8d07556d 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; @@ -300,32 +300,32 @@ void CMSMonster::KeyValue(KeyValueData* pkvd) if (FStrEq(pkvd->szKeyName, "killtarget")) { m_iszKillTarget = pkvd->szValue; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "perishtarget")) { m_iszPerishTarget = pkvd->szValue; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "spawnarea")) { m_iszMonsterSpawnArea = pkvd->szValue; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "delaylow")) { m_SpawnDelayLow = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "delayhigh")) { m_SpawnDelayHigh = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "lives")) { m_Lives = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "spawnchance")) { @@ -339,18 +339,18 @@ void CMSMonster::KeyValue(KeyValueData* pkvd) if (!m_SpawnChance) m_SpawnChance = -1; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "spawnstart")) { m_fSpawnOnTrigger = (atoi(pkvd->szValue)) ? true : false; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "nplayers")) { //Thothie - AUG2007a - adding option to only spawn monster if # players present m_ReqPlayers = (atoi(pkvd->szValue)); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "reqhp")) { @@ -375,19 +375,19 @@ void CMSMonster::KeyValue(KeyValueData* pkvd) } if (reqhp_stringlist.size() >= 2 && reqhp_stringlist[1].contains("avg")) m_HPReq_useavg = true; //Thothie OCT2015_28 - allow use average when calculating HP req, if token 2-3 is "avg" - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "title")) { //Thothie - AUG2007b - adding option to change monster name m_title = pkvd->szValue; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "params")) { //Thothie - DEC2007b - adding option to send params to script m_addparams = pkvd->szValue; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "hpmulti")) { @@ -396,7 +396,7 @@ void CMSMonster::KeyValue(KeyValueData* pkvd) if (flHealthMulti > 1) { m_HPMulti = flHealthMulti; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } } else if (FStrEq(pkvd->szKeyName, "dmgmulti")) @@ -406,14 +406,14 @@ void CMSMonster::KeyValue(KeyValueData* pkvd) if (flDamageMulti > 1) { m_DMGMulti = flDamageMulti; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } } else if (FStrEq(pkvd->szKeyName, "scriptfile") || (FStrEq(pkvd->szKeyName, "defscriptfile") && !m_ScriptName)) { m_ScriptName = pkvd->szValue; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } //NOV2014_20 - Thothie msmonster_random [begin] else if (randomdata.starts_with("random_")) //optimize this - dis is stupid lazy @@ -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(); }; @@ -493,7 +493,7 @@ void CMSMonster::KeyValue(KeyValueData* pkvd) } //Gotta use the logfile here, dernitall MS_DEBUG("DEBUG: msmonster_random added rndproperty #%i / tot %i - %s %s", idx, m_nRndMobs, rndproperty.c_str(), pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } //NOV2014_20 - Thothie msmonster_random [end] else @@ -829,7 +829,7 @@ bool CMSMonster::MoveExecute(moveexec_t& MoveExec) return fSuccess; } -BOOL CMSMonster::CanSetVelocity() { return TRUE; } +BOOL CMSMonster::CanSetVelocity() { return true; } void CMSMonster::Float() { @@ -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]); @@ -1402,19 +1402,19 @@ void CMSMonster::Act() if( m_fSequenceFinished ) { //m_Hand->CurrentAttack->tStart = -65534; - //m_Hand->CurrentAttack->fCanCancel = TRUE; + //m_Hand->CurrentAttack->fCanCancel = true; StopWalking( ); CurrentHand->CancelAttack( ); return; } - else CurrentHand->CurrentAttack->fCanCancel = FALSE; + else CurrentHand->CurrentAttack->fCanCancel = false; if( LastEvent.event == 600 ) //call attack this frame { CurrentHand->CurrentAttack->fAttackThisFrame = true; pev->iuser4 = -1; } - else CurrentHand->CurrentAttack->fAttackThisFrame = FALSE; //basically never + else CurrentHand->CurrentAttack->fAttackThisFrame = false; //basically never } //m_Hand->AttackButtonDown( ); @@ -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++; @@ -2129,7 +2129,7 @@ float CMSMonster::TraceAttack(damage_t& Damage) //- maybe internalize Parry for monsters? //- Thothie note of FEB2008a - int ParryValue = GetSkillStat("parry", STATPROP_SKILL); + int ParryValue = GetSkillStat("parry", STAT_PROP_SKILL); if (ParryValue > 60) ParryValue = 60; //Thothie JAN2010_22 - cap out parry (shhh) @@ -2198,14 +2198,14 @@ float CMSMonster::TraceAttack(damage_t& Damage) //Learn parry skill from a successful parry if( !pAttacker->IsPlayer() ) //Can't learn from being attacked by players if ( GetSkillStat( SKILL_PARRY, 0 ) < CHAR_LEVEL_CAP ) - LearnSkill ( SKILL_PARRY, STATPROP_SKILL, max( 0 , pMonster->m_SkillLevel * 2 ) ); + LearnSkill ( SKILL_PARRY, STAT_PROP_SKILL, max( 0 , pMonster->m_SkillLevel * 2 ) ); //MiB Jul2008a (JAN2010_15) - Parry was capped at 40. What say we stop exp gain? /*if (pMonster->m_SkillLevel * 2 > 0) - LearnSkill (SKILL_PARRY, STATPROP_SKILL, pMonster->m_SkillLevel * 2 ); + LearnSkill (SKILL_PARRY, STAT_PROP_SKILL, pMonster->m_SkillLevel * 2 ); else - LearnSkill (SKILL_PARRY, STATPROP_SKILL, 0 ); - //LearnSkill( SKILL_PARRY, STATPROP_SKILL, max(pAttacker->m_SkillLevel * 2,0) );*/ + LearnSkill (SKILL_PARRY, STAT_PROP_SKILL, 0 ); + //LearnSkill( SKILL_PARRY, STAT_PROP_SKILL, max(pAttacker->m_SkillLevel * 2,0) );*/ } } @@ -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" } @@ -2384,7 +2384,7 @@ void CMSMonster::CounterEffect(CBaseEntity* pInflictor, int iEffect, void* pExtr void CMSMonster::Killed(entvars_t* pevAttacker, int iGib) { - BOOL DeleteMe = TRUE; + BOOL DeleteMe = true; //NOV2014_21 Thothie - script side XP management option [begin] bool xp_dump = (strcmp(GetFirstScriptVar("NPC_DUMP_XP"), "1") == 0); //dump hits to array @@ -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 { @@ -2434,7 +2434,7 @@ void CMSMonster::Killed(entvars_t* pevAttacker, int iGib) float mult = V_min(1, m_MaxHP / m_PlayerDamage[i - 1].dmgInTotal); for (int n = SKILL_FIRSTSKILL; n < SKILL_MAX_ATTACK; n++) { - for (int r = 0; r < STATPROP_ALL_TOTAL; r++) + for (int r = 0; r < STAT_PROP_ALL_TOTAL; r++) { float dmg = m_PlayerDamage[i - 1].dmg[n][r]; if (dmg > 0) @@ -2528,7 +2528,7 @@ void CMSMonster::Killed(entvars_t* pevAttacker, int iGib) // ALERT( at_console, "m_flFrameRate: %f\n", m_flFrameRate ); //pev->nextthink = gpGlobals->time + ((256 / m_flFrameRate) * pev->framerate); pev->health = pev->max_health / 2; //Thothie - Dunno what this is about - DeleteMe = FALSE; //live until the body's dead + DeleteMe = false; //live until the body's dead if (FStrEq(STRING(pev->classname), "msmonster_summoned")) g_SummonedMonsters--; @@ -2579,7 +2579,7 @@ void CMSMonster::Killed(entvars_t* pevAttacker, int iGib) m_SkillLevel = 0; //Thothie APR2011_06 - attempt to make sure monster does not give additional skill post mortem } else - DeleteMe = TRUE; // Gibbed, destroy this entity + DeleteMe = true; // Gibbed, destroy this entity } if (DeleteMe) { @@ -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]; @@ -2760,8 +2760,8 @@ std::tuple CMSMonster::LearnSkill(int iStat, int iStatType, int Enemy return std::make_tuple(false, iExpRemaining); SubStat.Value += 1; - if (SubStat.Value > STATPROP_MAX_VALUE) - SubStat.Value = STATPROP_MAX_VALUE; + if (SubStat.Value > MAX_STAT_PROPVALUE) + SubStat.Value = MAX_STAT_PROPVALUE; SubStat.Exp = 0; //Thothie - why's this here twice? I dont see where oldval could change. @@ -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) @@ -2895,7 +2895,7 @@ void CMSMonster::UseMenuOption(CBasePlayer* pPlayer, int Option) MS_ANGEL_INFO("UseMenuOption called for player %s (idx:%d), option %d", pPlayer ? pPlayer->DisplayName() : "NULL", playerIndex, Option); MS_ANGEL_INFO(" Protection flag: %s, Entity: %d", - m_MenuOptionsProtected[playerIndex] ? "TRUE" : "FALSE", entindex()); + m_MenuOptionsProtected[playerIndex] ? "true" : "false", entindex()); pPlayer->InMenu = false; mslist& Menuoptions = m_MenuOptions[playerIndex]; @@ -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/npcact.cpp b/src/game/server/monsters/npcact.cpp index 43ec1a1d..03c97f72 100644 --- a/src/game/server/monsters/npcact.cpp +++ b/src/game/server/monsters/npcact.cpp @@ -198,7 +198,7 @@ void NPCScript ::PlayAnim() pMonster->SetAnimation(MONSTER_ANIM_ONCE, (char *)STRING(m_sActionAnim)); } pMonster->pev->frame = 0; //In case the previous AND current anim is sequence 0 - pMonster->m_fSequenceFinished = FALSE; //ditto... + pMonster->m_fSequenceFinished = false; //ditto... SetThink(&NPCScript::AnimateThink); pev->nextthink = gpGlobals->time + 0.1; } @@ -327,42 +327,42 @@ void NPCScript ::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "type")) { m_iType = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "moveanim")) { m_sMoveAnim = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "actionanim")) { m_sActionAnim = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "eventname")) { m_sEventName = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "firewhendone")) { m_sFireWhenDone = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "fireonbreak")) { m_sFireOnBreak = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "firedelay")) { m_flFireDelay = atof(pkvd->szValue); - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else if (FStrEq(pkvd->szKeyName, "stopai")) { m_fStopAI = atoi(pkvd->szValue) ? true : false; - pkvd->fHandled = TRUE; + pkvd->fHandled = true; } else CBaseEntity ::KeyValue(pkvd); 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 4476a412..b530ef8a 100644 --- a/src/game/server/monsters/npcscript.cpp +++ b/src/game/server/monsters/npcscript.cpp @@ -7,6 +7,11 @@ #include "stats/stats.h" #include "stats/races.h" #include "msitemdefs.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h +#endif + + // TODO: get rid of the macro for logging when we get rid of MSScript. #include "mslogger.h" @@ -108,7 +113,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 +154,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 +408,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 < STAT_PROP_ALL_TOTAL; s++) // m_PlayerDamage[p].dmg[r][s] = 0; // } // m_PlayerDamage[p].dmgInTotal = 0; @@ -435,11 +440,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 < STAT_PROP_ALL_TOTAL; s++) // m_PlayerDamage[p].dmg[r][s] = 0; // } // m_PlayerDamage[p].dmgInTotal = 0; @@ -642,7 +647,7 @@ bool CMSMonster::Script_ExecuteCmd(CScript *Script, SCRIPT_EVENT &Event, scriptc bool inventory_full = false; if (pPlayer) { - if (pPlayer->NumItems() >= NUM_MAX_ITEMS) + if (pPlayer->NumItems() >= MAX_NUM_ITEMS) inventory_full = true; } @@ -695,7 +700,7 @@ bool CMSMonster::Script_ExecuteCmd(CScript *Script, SCRIPT_EVENT &Event, scriptc { //Parameters: