Constantifying everything we can

Also add some global constants for player arrays and player count
This commit is contained in:
BenCat07 2019-10-16 19:44:25 +02:00
parent 4a523fb0dd
commit b9e6bfc69c
40 changed files with 126 additions and 110 deletions

17
include/Constants.hpp Normal file
View File

@ -0,0 +1,17 @@
/*
* Constants.hpp
*
* Created on: October 16, 2019
* Author: LightCat
*/
// This file will include global constant expressions
#pragma once
#include <string>
constexpr const char *CON_PREFIX = "cat_";
constexpr int MAX_ENTITIES = 2048;
constexpr int MAX_PLAYERS = 32;
// 0 is "World" but we still can have MAX_PLAYERS players, so consider that
constexpr int PLAYER_ARRAY_SIZE = 1 + MAX_PLAYERS;

View File

@ -77,13 +77,13 @@ struct angle_data_s
int angle_count{ 0 }; int angle_count{ 0 };
}; };
extern angle_data_s data_[32]; extern angle_data_s data_[MAX_PLAYERS];
void Update(); void Update();
inline angle_data_s &data_idx(int index) inline angle_data_s &data_idx(int index)
{ {
if (index < 1 || index > 32) if (index < 1 || index > MAX_PLAYERS)
{ {
throw std::out_of_range("Angle table entity index out of range"); throw std::out_of_range("Angle table entity index out of range");
} }

View File

@ -7,7 +7,7 @@
#pragma once #pragma once
#define CHATSTACK_INTERVAL 0.8f constexpr float CHATSTACK_INTERVAL = 0.8f;
#include "config.h" #include "config.h"
#include <string> #include <string>

View File

@ -47,6 +47,7 @@
#include "averager.hpp" #include "averager.hpp"
#include "core/macros.hpp" #include "core/macros.hpp"
#include "Constants.hpp"
#if ENABLE_VISUALS #if ENABLE_VISUALS
#include <visual/colors.hpp> #include <visual/colors.hpp>
#include <visual/drawing.hpp> #include <visual/drawing.hpp>
@ -121,9 +122,6 @@ template <typename T> constexpr T _clamp(T _min, T _max, T _val)
#define SQR(x) (x) * (x) #define SQR(x) (x) * (x)
#define CON_NAME "cat"
#define CON_PREFIX CON_NAME "_"
#define SUPER_VERBOSE_DEBUG false #define SUPER_VERBOSE_DEBUG false
#if SUPER_VERBOSE_DEBUG == true #if SUPER_VERBOSE_DEBUG == true
#define SVDBG(...) logging::Info(__VA_ARGS__) #define SVDBG(...) logging::Info(__VA_ARGS__)

View File

@ -24,6 +24,7 @@
#include "classinfo/classinfo.hpp" #include "classinfo/classinfo.hpp"
#include "classinfo/tf2.gen.hpp" #include "classinfo/tf2.gen.hpp"
#include "client_class.h" #include "client_class.h"
#include "Constants.hpp"
struct matrix3x4_t; struct matrix3x4_t;
@ -33,8 +34,7 @@ struct model_t;
struct mstudiohitboxset_t; struct mstudiohitboxset_t;
struct mstudiobbox_t; struct mstudiobbox_t;
#define MAX_STRINGS 16 constexpr int MAX_STRINGS = 16;
#define MAX_ENTITIES 2048
#define PROXY_ENTITY true #define PROXY_ENTITY true

View File

@ -15,7 +15,7 @@
#include <stdexcept> #include <stdexcept>
class CachedEntity; class CachedEntity;
#define CACHE_MAX_HITBOXES 64 constexpr int CACHE_MAX_HITBOXES = 64;
namespace hitbox_cache namespace hitbox_cache
{ {

View File

@ -9,6 +9,7 @@
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <time.h> #include <time.h>
#include <mathlib/vector.h> #include <mathlib/vector.h>
#include "Constants.hpp"
class Vector; class Vector;
class CUserCmd; class CUserCmd;
@ -29,9 +30,9 @@ extern int last_cmd_number;
extern time_t time_injected; extern time_t time_injected;
struct brutestruct struct brutestruct
{ {
int brutenum[33]; int brutenum[PLAYER_ARRAY_SIZE];
Vector last_angles[33]; Vector last_angles[PLAYER_ARRAY_SIZE];
std::deque<bool> choke[33]; std::deque<bool> choke[PLAYER_ARRAY_SIZE];
float lastsimtime; float lastsimtime;
}; };
class GlobalSettings class GlobalSettings

View File

@ -52,7 +52,7 @@ struct CIncomingSequence
}; };
typedef boost::circular_buffer_space_optimized<CIncomingSequence> circular_buf; typedef boost::circular_buffer_space_optimized<CIncomingSequence> circular_buf;
extern circular_buf sequences; extern circular_buf sequences;
extern BacktrackData headPositions[33][66]; extern BacktrackData headPositions[PLAYER_ARRAY_SIZE][66];
extern bool isBacktrackEnabled; extern bool isBacktrackEnabled;
extern bool Vischeck_Success; extern bool Vischeck_Success;

View File

@ -23,7 +23,7 @@ struct ac_data
int check_timer; int check_timer;
int last_weapon; int last_weapon;
}; };
extern int amount[32]; extern int amount[MAX_PLAYERS];
void ResetEverything(); void ResetEverything();
std::unordered_map<int, Vector> &player_orgs(); std::unordered_map<int, Vector> &player_orgs();

View File

@ -13,7 +13,7 @@ class CachedEntity;
namespace ac::antiaim namespace ac::antiaim
{ {
extern int amount[32]; extern int amount[MAX_PLAYERS];
void ResetEverything(); void ResetEverything();
void ResetPlayer(int idx); void ResetPlayer(int idx);

View File

@ -19,8 +19,8 @@ class Vector;
class ICvar; class ICvar;
void SetCVarInterface(ICvar *iface); void SetCVarInterface(ICvar *iface);
#define PI 3.14159265358979323846f constexpr float PI = 3.14159265358979323846f;
#define RADPI 57.295779513082f constexpr float RADPI = 57.295779513082f;
//#define DEG2RAD(x) (float)(x) * (float)(PI / 180.0f) //#define DEG2RAD(x) (float)(x) * (float)(PI / 180.0f)
#include <enums.hpp> #include <enums.hpp>

View File

@ -11,29 +11,29 @@
#pragma once #pragma once
#endif #endif
#define IN_ATTACK (1 << 0) constexpr int IN_ATTACK = (1 << 0);
#define IN_JUMP (1 << 1) constexpr int IN_JUMP = (1 << 1);
#define IN_DUCK (1 << 2) constexpr int IN_DUCK = (1 << 2);
#define IN_FORWARD (1 << 3) constexpr int IN_FORWARD = (1 << 3);
#define IN_BACK (1 << 4) constexpr int IN_BACK = (1 << 4);
#define IN_USE (1 << 5) constexpr int IN_USE = (1 << 5);
#define IN_CANCEL (1 << 6) constexpr int IN_CANCEL = (1 << 6);
#define IN_LEFT (1 << 7) constexpr int IN_LEFT = (1 << 7);
#define IN_RIGHT (1 << 8) constexpr int IN_RIGHT = (1 << 8);
#define IN_MOVELEFT (1 << 9) constexpr int IN_MOVELEFT = (1 << 9);
#define IN_MOVERIGHT (1 << 10) constexpr int IN_MOVERIGHT = (1 << 10);
#define IN_ATTACK2 (1 << 11) constexpr int IN_ATTACK2 = (1 << 11);
#define IN_RUN (1 << 12) constexpr int IN_RUN = (1 << 12);
#define IN_RELOAD (1 << 13) constexpr int IN_RELOAD = (1 << 13);
#define IN_ALT1 (1 << 14) constexpr int IN_ALT1 = (1 << 14);
#define IN_ALT2 (1 << 15) constexpr int IN_ALT2 = (1 << 15);
#define IN_SCORE (1 << 16) // Used by client.dll for when scoreboard is held down constexpr int IN_SCORE = (1 << 16); // Used by client.dll for when scoreboard is held down
#define IN_SPEED (1 << 17) // Player is holding the speed key constexpr int IN_SPEED = (1 << 17); // Player is holding the speed key
#define IN_WALK (1 << 18) // Player holding walk key constexpr int IN_WALK = (1 << 18); // Player holding walk key
#define IN_ZOOM (1 << 19) // Zoom key for HUD zoom constexpr int IN_ZOOM = (1 << 19); // Zoom key for HUD zoom
#define IN_WEAPON1 (1 << 20) // weapon defines these bits constexpr int IN_WEAPON1 = (1 << 20); // weapon defines these bits
#define IN_WEAPON2 (1 << 21) // weapon defines these bits constexpr int IN_WEAPON2 = (1 << 21); // weapon defines these bits
#define IN_BULLRUSH (1 << 22) constexpr int IN_BULLRUSH = (1 << 22);
#define IN_GRENADE1 (1 << 23) // grenade 1 constexpr int IN_GRENADE1 = (1 << 23); // grenade 1
#define IN_GRENADE2 (1 << 24) // grenade 2 constexpr int IN_GRENADE2 = (1 << 24); // grenade 2
#define IN_ATTACK3 (1 << 25) constexpr int IN_ATTACK3 = (1 << 25);

View File

@ -9,11 +9,11 @@
namespace angles namespace angles
{ {
angle_data_s data_[32]; angle_data_s data_[MAX_PLAYERS];
void Update() void Update()
{ {
for (int i = 1; i < 33; i++) for (int i = 1; i <= MAX_PLAYERS; i++)
{ {
auto &d = data_idx(i); auto &d = data_idx(i);
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);

View File

@ -1478,7 +1478,7 @@ static void DrawText()
// Debug stuff // Debug stuff
if (!aimbot_debug) if (!aimbot_debug)
return; return;
for (int i = 1; i < 32; i++) for (int i = 1; i < PLAYER_ARRAY_SIZE; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_GOOD(ent)) if (CE_GOOD(ent))

View File

@ -60,7 +60,7 @@ CachedEntity *ClosestSpy()
closest = nullptr; closest = nullptr;
closest_dist = 0.0f; closest_dist = 0.0f;
for (int i = 1; i < 32 && i < g_IEntityList->GetHighestEntityIndex(); i++) for (int i = 1; i < PLAYER_ARRAY_SIZE && i < g_IEntityList->GetHighestEntityIndex(); i++)
{ {
ent = ENTITY(i); ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -72,8 +72,8 @@ int vaccinator_change_ticks = 0;
int vaccinator_ideal_resist = 0; int vaccinator_ideal_resist = 0;
int vaccinator_change_timer = 0; int vaccinator_change_timer = 0;
std::array<Timer, 32> reset_cd{}; std::array<Timer, MAX_PLAYERS> reset_cd{};
std::vector<patient_data_s> data(32); std::vector<patient_data_s> data(MAX_PLAYERS);
struct proj_data_s struct proj_data_s
{ {
@ -212,7 +212,7 @@ int BlastDangerValue(CachedEntity *patient)
return 1; return 1;
} }
// Find rockets/pipes nearby // Find rockets/pipes nearby
for (int i = 32; i <= HIGHEST_ENTITY; i++) for (int i = PLAYER_ARRAY_SIZE; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))
@ -433,7 +433,7 @@ bool IsVaccinator()
void UpdateData() void UpdateData()
{ {
for (int i = 1; i < 32; i++) for (int i = 1; i < MAX_PLAYERS; i++)
{ {
if (reset_cd[i].test_and_set(10000)) if (reset_cd[i].test_and_set(10000))
data[i] = {}; data[i] = {};

View File

@ -30,7 +30,7 @@ void EmptyBacktrackData(BacktrackData &i);
std::pair<int, int> getBestEntBestTick(); std::pair<int, int> getBestEntBestTick();
bool shouldBacktrack(); bool shouldBacktrack();
BacktrackData headPositions[33][66]{}; BacktrackData headPositions[PLAYER_ARRAY_SIZE][66]{};
int lastincomingsequencenumber = 0; int lastincomingsequencenumber = 0;
bool isBacktrackEnabled = false; bool isBacktrackEnabled = false;
bool Vischeck_Success = false; bool Vischeck_Success = false;
@ -69,7 +69,7 @@ void AddLatencyToNetchan(INetChannel *ch)
} }
void Init() void Init()
{ {
for (int i = 0; i < 33; i++) for (int i = 0; i < PLAYER_ARRAY_SIZE; i++)
for (int j = 0; j < 66; j++) for (int j = 0; j < 66; j++)
headPositions[i][j] = {}; headPositions[i][j] = {};
@ -78,8 +78,8 @@ void Init()
int BestTick = -1; int BestTick = -1;
int iBestTarget = -1; int iBestTarget = -1;
bool istickvalid[33][66]{}; bool istickvalid[PLAYER_ARRAY_SIZE][66]{};
bool istickinvalid[33][66]{}; bool istickinvalid[PLAYER_ARRAY_SIZE][66]{};
static float latency_rampup = 0.0f; static float latency_rampup = 0.0f;
static void Run() static void Run()

View File

@ -265,7 +265,7 @@ static void cm()
continue; continue;
ProcessEntity(ent); ProcessEntity(ent);
// Update Bones // Update Bones
if (i <= 32) if (i <= MAX_PLAYERS)
ent->hitboxes.GetHitbox(0); ent->hitboxes.GetHitbox(0);
// Dont know what this check is for // Dont know what this check is for
if (data[i].string_count) if (data[i].string_count)
@ -1198,7 +1198,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent)
{ {
int handle = weapon_list[i]; int handle = weapon_list[i];
int eid = handle & 0xFFF; int eid = handle & 0xFFF;
if (eid >= 32 && eid <= HIGHEST_ENTITY) if (eid > MAX_PLAYERS && eid <= HIGHEST_ENTITY)
{ {
CachedEntity *weapon = ENTITY(eid); CachedEntity *weapon = ENTITY(eid);
if (!CE_INVALID(weapon) && weapon->m_iClassID() == CL_CLASS(CWeaponMedigun) && weapon) if (!CE_INVALID(weapon) && weapon->m_iClassID() == CL_CLASS(CWeaponMedigun) && weapon)

View File

@ -79,7 +79,7 @@ static bool inited = false;
static Timer lastTaunt{}; // time since taunt was last executed, used to avoid kicks static Timer lastTaunt{}; // time since taunt was last executed, used to avoid kicks
static Timer lastJump{}; static Timer lastJump{};
static std::array<Timer, 32> afkTicks; // for how many ms the player hasn't been moving static std::array<Timer, PLAYER_ARRAY_SIZE> afkTicks; // for how many ms the player hasn't been moving
static void checkAFK() static void checkAFK()
{ {

View File

@ -6,10 +6,10 @@ namespace hacks::shared::lightesp
{ {
static settings::Boolean enable{ "lightesp.enable", "false" }; static settings::Boolean enable{ "lightesp.enable", "false" };
static Vector hitp[33]; static Vector hitp[PLAYER_ARRAY_SIZE];
static Vector minp[33]; static Vector minp[PLAYER_ARRAY_SIZE];
static Vector maxp[33]; static Vector maxp[PLAYER_ARRAY_SIZE];
static bool drawEsp[33]; static bool drawEsp[PLAYER_ARRAY_SIZE];
rgba_t LightESPColor(CachedEntity *ent) rgba_t LightESPColor(CachedEntity *ent)
{ {

View File

@ -256,7 +256,7 @@ void DrawText()
} }
if (show_spectators) if (show_spectators)
{ {
for (int i = 0; i < 32; i++) for (int i = 0; i < PLAYER_ARRAY_SIZE; i++)
{ {
// Assign the for loops tick number to an ent // Assign the for loops tick number to an ent
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
@ -671,7 +671,7 @@ UpdateLocalPlayerVisionFlags_t UpdateLocalPlayerVisionFlags_fn;
int *g_nLocalPlayerVisionFlags; int *g_nLocalPlayerVisionFlags;
int *g_nLocalPlayerVisionFlagsWeaponsCheck; int *g_nLocalPlayerVisionFlagsWeaponsCheck;
// If you wish then change this to some other flag you want to apply/remove // If you wish then change this to some other flag you want to apply/remove
#define PYROVISION 1 constexpr int PYROVISION = 1;
static settings::Int force_pyrovision("visual.force-pyrovision", "0"); static settings::Int force_pyrovision("visual.force-pyrovision", "0");

View File

@ -47,7 +47,7 @@ std::string random_mafia_entry(int level, unsigned steamid)
else else
return store.at(rand() % store.size()); return store.at(rand() % store.size());
} }
static std::array<float, 32> death_timer; static std::array<float, PLAYER_ARRAY_SIZE> death_timer;
void Paint() void Paint()
{ {
if (!*draw_kda && !*mafia_city) if (!*draw_kda && !*mafia_city)

View File

@ -35,7 +35,7 @@ static std::vector<std::pair<CNavArea *, Vector>> sniper_spots;
// How long should the bot wait until pathing again? // How long should the bot wait until pathing again?
static Timer wait_until_path{}; static Timer wait_until_path{};
// Time before following target cloaked spy again // Time before following target cloaked spy again
static std::array<Timer, 33> spy_cloak{}; static std::array<Timer, PLAYER_ARRAY_SIZE> spy_cloak{};
// Don't spam spy path thanks // Don't spam spy path thanks
static Timer spy_path{}; static Timer spy_path{};
// What is the bot currently doing // What is the bot currently doing
@ -415,7 +415,7 @@ static inline bool hasLowAmmo()
{ {
int handle = weapon_list[i]; int handle = weapon_list[i];
int eid = handle & 0xFFF; int eid = handle & 0xFFF;
if (eid >= 32 && eid <= HIGHEST_ENTITY) if (eid > MAX_PLAYERS && eid <= HIGHEST_ENTITY)
{ {
IClientEntity *weapon = g_IEntityList->GetClientEntity(eid); IClientEntity *weapon = g_IEntityList->GetClientEntity(eid);
if (weapon and re::C_BaseCombatWeapon::IsBaseCombatWeapon(weapon) && re::C_TFWeaponBase::UsesPrimaryAmmo(weapon) && !re::C_TFWeaponBase::HasPrimaryAmmo(weapon)) if (weapon and re::C_BaseCombatWeapon::IsBaseCombatWeapon(weapon) && re::C_TFWeaponBase::UsesPrimaryAmmo(weapon) && !re::C_TFWeaponBase::HasPrimaryAmmo(weapon))

View File

@ -274,7 +274,7 @@ void FrameStageNotify(int stage)
{ {
handle = weapon_list[i]; handle = weapon_list[i];
eid = handle & 0xFFF; eid = handle & 0xFFF;
if (eid < 32 || eid > HIGHEST_ENTITY) if (eid <= MAX_PLAYERS || eid > HIGHEST_ENTITY)
continue; continue;
// logging::Info("eid, %i", eid); // logging::Info("eid, %i", eid);
entity = g_IEntityList->GetClientEntity(eid); entity = g_IEntityList->GetClientEntity(eid);

View File

@ -39,7 +39,7 @@ void Draw()
spy_count = 0; spy_count = 0;
if (last_say > g_GlobalVars->curtime) if (last_say > g_GlobalVars->curtime)
last_say = 0; last_say = 0;
for (int i = 0; i <= HIGHEST_ENTITY && i < 32; i++) for (int i = 0; i <= HIGHEST_ENTITY && i <= MAX_PLAYERS; i++)
{ {
ent = ENTITY(i); ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -243,7 +243,7 @@ bool HasLowAmmo()
{ {
int handle = weapon_list[i]; int handle = weapon_list[i];
int eid = handle & 0xFFF; int eid = handle & 0xFFF;
if (eid >= 32 && eid <= HIGHEST_ENTITY) if (eid > MAX_PLAYERS && eid <= HIGHEST_ENTITY)
{ {
IClientEntity *weapon = g_IEntityList->GetClientEntity(eid); IClientEntity *weapon = g_IEntityList->GetClientEntity(eid);
if (weapon and re::C_BaseCombatWeapon::IsBaseCombatWeapon(weapon) and re::C_TFWeaponBase::UsesPrimaryAmmo(weapon) and not re::C_TFWeaponBase::HasPrimaryAmmo(weapon)) if (weapon and re::C_BaseCombatWeapon::IsBaseCombatWeapon(weapon) and re::C_TFWeaponBase::UsesPrimaryAmmo(weapon) and not re::C_TFWeaponBase::HasPrimaryAmmo(weapon))

View File

@ -16,8 +16,8 @@ static settings::Boolean enable{ "find-cheaters.aimbot.enable", "true" };
static settings::Float detect_angle{ "find-cheaters.aimbot.angle", "30" }; static settings::Float detect_angle{ "find-cheaters.aimbot.angle", "30" };
static settings::Int detections_warning{ "find-cheaters.aimbot.detections", "3" }; static settings::Int detections_warning{ "find-cheaters.aimbot.detections", "3" };
ac_data data_table[32]; ac_data data_table[MAX_PLAYERS];
int amount[32]; int amount[MAX_PLAYERS];
std::unordered_map<int, Vector> Player_origs{}; std::unordered_map<int, Vector> Player_origs{};
std::unordered_map<int, Vector> &player_orgs() std::unordered_map<int, Vector> &player_orgs()
@ -26,7 +26,7 @@ std::unordered_map<int, Vector> &player_orgs()
} }
void ResetEverything() void ResetEverything()
{ {
memset(&data_table, 0, sizeof(ac_data) * 32); memset(&data_table, 0, sizeof(ac_data) * MAX_PLAYERS);
Player_origs.clear(); Player_origs.clear();
} }
@ -106,7 +106,7 @@ void Event(KeyValues *event)
int victim = event->GetInt("userid"); int victim = event->GetInt("userid");
int eid = g_IEngine->GetPlayerForUserID(attacker); int eid = g_IEngine->GetPlayerForUserID(attacker);
int vid = g_IEngine->GetPlayerForUserID(victim); int vid = g_IEngine->GetPlayerForUserID(victim);
if (eid > 0 && eid < 33 && vid > 0 && vid < 33) if (eid > 0 && eid <= MAX_PLAYERS && vid > 0 && vid <= MAX_PLAYERS)
{ {
CachedEntity *victim = ENTITY(vid); CachedEntity *victim = ENTITY(vid);
CachedEntity *attacker = ENTITY(eid); CachedEntity *attacker = ENTITY(eid);

View File

@ -13,11 +13,11 @@ namespace ac::antiaim
{ {
static settings::Boolean enable{ "find-cheaters.antiaim.enable", "true" }; static settings::Boolean enable{ "find-cheaters.antiaim.enable", "true" };
unsigned long last_accusation[32]{ 0 }; unsigned long last_accusation[MAX_PLAYERS]{ 0 };
void ResetEverything() void ResetEverything()
{ {
memset(last_accusation, 0, sizeof(unsigned long) * 32); memset(last_accusation, 0, sizeof(unsigned long) * MAX_PLAYERS);
} }
void ResetPlayer(int idx) void ResetPlayer(int idx)
@ -34,7 +34,7 @@ void Update(CachedEntity *player)
{ {
if (!enable) if (!enable)
return; return;
int amount[32]; int amount[MAX_PLAYERS];
auto &am = amount[player->m_IDX - 1]; auto &am = amount[player->m_IDX - 1];
if (tickcount - last_accusation[player->m_IDX - 1] < 60 * 60) if (tickcount - last_accusation[player->m_IDX - 1] < 60 * 60)
return; return;

View File

@ -13,11 +13,11 @@ namespace ac::bhop
{ {
static settings::Int bhop_detect_count{ "find-cheaters.bunnyhop.detections", "4" }; static settings::Int bhop_detect_count{ "find-cheaters.bunnyhop.detections", "4" };
ac_data data_table[32]{}; ac_data data_table[MAX_PLAYERS]{};
void ResetEverything() void ResetEverything()
{ {
memset(data_table, 0, sizeof(ac_data) * 32); memset(data_table, 0, sizeof(ac_data) * MAX_PLAYERS);
} }
void ResetPlayer(int idx) void ResetPlayer(int idx)

View File

@ -60,9 +60,9 @@ CatCommand debug_ammo("debug_ammo", "Debug ammo", []() {
logging::Info("%d %d", i, CE_INT(LOCAL_E, netvar.m_iAmmo + i * 4)); logging::Info("%d %d", i, CE_INT(LOCAL_E, netvar.m_iAmmo + i * 4));
} }
}); });
bool brutesoon[33]; bool brutesoon[PLAYER_ARRAY_SIZE];
int lasthits = 0; int lasthits = 0;
std::array<Timer, 33> xd{}; std::array<Timer, PLAYER_ARRAY_SIZE> xd{};
void Update() void Update()
{ {
CachedEntity *weapon = LOCAL_W; CachedEntity *weapon = LOCAL_W;
@ -87,7 +87,7 @@ void Update()
INetChannel *ch = (INetChannel *) g_IEngine->GetNetChannelInfo(); INetChannel *ch = (INetChannel *) g_IEngine->GetNetChannelInfo();
static bool firstcall = true; static bool firstcall = true;
for (int i = 0; i < 33; i++) for (int i = 0; i < PLAYER_ARRAY_SIZE; i++)
{ {
if (firstcall) if (firstcall)
xd[i].update(); xd[i].update();

View File

@ -31,7 +31,7 @@ bool StolenName()
// Array to store potential namestealer targets with a bookkeeper to tell // Array to store potential namestealer targets with a bookkeeper to tell
// how full it is // how full it is
int potential_targets[32]; int potential_targets[MAX_PLAYERS];
int potential_targets_length = 0; int potential_targets_length = 0;
// Go through entities looking for potential targets // Go through entities looking for potential targets

View File

@ -50,7 +50,7 @@ DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name)
else if (holiday->m_nValue == 2) else if (holiday->m_nValue == 2)
holiday->SetValue(0); holiday->SetValue(0);
#endif #endif
for (int i = 0; i < 32; i++) for (int i = 0; i < MAX_PLAYERS; i++)
g_Settings.brute.brutenum[i] = 0; g_Settings.brute.brutenum[i] = 0;
g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec"); g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec");
chat_stack::Reset(); chat_stack::Reset();

View File

@ -32,7 +32,7 @@ struct SpamClass
}; };
// Storage for the spam messages // Storage for the spam messages
std::array<std::vector<SpamClass>, 32> spam_storage; std::array<std::vector<SpamClass>, MAX_PLAYERS> spam_storage;
DEFINE_HOOKED_METHOD(ChatPrintf, void, CHudBaseChat *_this, int player_idx, int iFilter, const char *str, ...) DEFINE_HOOKED_METHOD(ChatPrintf, void, CHudBaseChat *_this, int player_idx, int iFilter, const char *str, ...)
{ {
auto buf = std::make_unique<char[]>(1024); auto buf = std::make_unique<char[]>(1024);

View File

@ -7,7 +7,7 @@
#include "common.hpp" #include "common.hpp"
static bool hoovy_list[33] = { 0 }; static bool hoovy_list[PLAYER_ARRAY_SIZE] = { 0 };
bool HasSandvichOut(CachedEntity *entity) bool HasSandvichOut(CachedEntity *entity)
{ {
@ -43,7 +43,7 @@ void UpdateHoovyList()
return; return;
static CachedEntity *ent; static CachedEntity *ent;
for (int i = 1; i <= 32 && i < g_IEntityList->GetHighestEntityIndex(); i++) for (int i = 1; i <= MAX_PLAYERS && i < g_IEntityList->GetHighestEntityIndex(); i++)
{ {
ent = ENTITY(i); ent = ENTITY(i);
if (CE_GOOD(ent) && CE_BYTE(ent, netvar.iLifeState) == LIFE_ALIVE) if (CE_GOOD(ent) && CE_BYTE(ent, netvar.iLifeState) == LIFE_ALIVE)

View File

@ -116,7 +116,7 @@ peer_t *peer{ nullptr };
CatCommand debug_get_ingame_ipc("ipc_debug_dump_server", "Show other bots on server", []() { CatCommand debug_get_ingame_ipc("ipc_debug_dump_server", "Show other bots on server", []() {
std::vector<unsigned> players{}; std::vector<unsigned> players{};
for (int j = 1; j < 32; j++) for (int j = 1; j <= MAX_PLAYERS; j++)
{ {
player_info_s info; player_info_s info;
if (g_IEngine->GetPlayerInfo(j, &info)) if (g_IEngine->GetPlayerInfo(j, &info))

View File

@ -74,7 +74,7 @@ int TFPlayerResource::GetTeam(int idx)
{ {
IClientEntity *ent; IClientEntity *ent;
if (idx >= 64 || idx < 0) if (idx >= MAX_PLAYERS || idx < 0)
return 0; return 0;
ent = g_IEntityList->GetClientEntity(entity); ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
@ -86,7 +86,7 @@ int TFPlayerResource::GetScore(int idx)
{ {
IClientEntity *ent; IClientEntity *ent;
if (idx >= 32 || idx < 1) if (idx >= MAX_PLAYERS || idx < 1)
return 0; return 0;
ent = g_IEntityList->GetClientEntity(entity); ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
@ -98,7 +98,7 @@ int TFPlayerResource::GetKills(int idx)
{ {
IClientEntity *ent; IClientEntity *ent;
if (idx >= 32 || idx < 1) if (idx >= MAX_PLAYERS || idx < 1)
return 0; return 0;
ent = g_IEntityList->GetClientEntity(entity); ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
@ -110,7 +110,7 @@ int TFPlayerResource::GetDeaths(int idx)
{ {
IClientEntity *ent; IClientEntity *ent;
if (idx >= 32 || idx < 1) if (idx >= MAX_PLAYERS || idx < 1)
return 0; return 0;
ent = g_IEntityList->GetClientEntity(entity); ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
@ -122,7 +122,7 @@ int TFPlayerResource::GetLevel(int idx)
{ {
IClientEntity *ent; IClientEntity *ent;
if (idx >= 32 || idx < 1) if (idx >= MAX_PLAYERS || idx < 1)
return 0; return 0;
ent = g_IEntityList->GetClientEntity(entity); ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
@ -134,7 +134,7 @@ int TFPlayerResource::GetDamage(int idx)
{ {
IClientEntity *ent; IClientEntity *ent;
if (idx >= 32 || idx < 1) if (idx >= MAX_PLAYERS || idx < 1)
return 0; return 0;
ent = g_IEntityList->GetClientEntity(entity); ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
@ -145,7 +145,7 @@ int TFPlayerResource::GetPing(int idx)
{ {
IClientEntity *ent; IClientEntity *ent;
if (idx >= 32 || idx < 1) if (idx >= MAX_PLAYERS || idx < 1)
return 0; return 0;
ent = g_IEntityList->GetClientEntity(entity); ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
@ -162,7 +162,7 @@ int TFPlayerResource::GetClass(CachedEntity *player)
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
return 0; return 0;
idx = player->m_IDX; idx = player->m_IDX;
if (idx >= 64 || idx < 0) if (idx >= MAX_PLAYERS || idx < 0)
return 0; return 0;
return *(int *) ((unsigned) ent + netvar.res_iPlayerClass + 4 * idx); return *(int *) ((unsigned) ent + netvar.res_iPlayerClass + 4 * idx);
} }
@ -172,7 +172,7 @@ bool TFPlayerResource::isAlive(int idx)
IClientEntity *ent = g_IEntityList->GetClientEntity(entity); IClientEntity *ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
return 0; return 0;
if (idx >= 64 || idx < 0) if (idx >= MAX_PLAYERS || idx < 0)
return false; return false;
return *(bool *) ((unsigned) ent + netvar.res_bAlive + idx); return *(bool *) ((unsigned) ent + netvar.res_bAlive + idx);
} }
@ -182,7 +182,7 @@ int TFPlayerResource::getClass(int idx)
IClientEntity *ent = g_IEntityList->GetClientEntity(entity); IClientEntity *ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
return 0; return 0;
if (idx >= 64 || idx < 0) if (idx >= MAX_PLAYERS || idx < 0)
return 0; return 0;
return *(int *) ((unsigned) ent + netvar.res_iPlayerClass + 4 * idx); return *(int *) ((unsigned) ent + netvar.res_iPlayerClass + 4 * idx);
} }
@ -192,7 +192,7 @@ int TFPlayerResource::getTeam(int idx)
IClientEntity *ent = g_IEntityList->GetClientEntity(entity); IClientEntity *ent = g_IEntityList->GetClientEntity(entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE)
return 0; return 0;
if (idx >= 64 || idx < 0) if (idx >= MAX_PLAYERS || idx < 0)
return 0; return 0;
return *(int *) ((unsigned) ent + netvar.res_iTeam + 4 * idx); return *(int *) ((unsigned) ent + netvar.res_iTeam + 4 * idx);
} }

View File

@ -55,8 +55,8 @@ void Prediction_CreateMove()
if (!setup) if (!setup)
{ {
setup = true; setup = true;
predicted_players_engine.resize(33); predicted_players_engine.resize(PLAYER_ARRAY_SIZE);
player_vel.resize(33); player_vel.resize(PLAYER_ARRAY_SIZE);
} }
for (int i = 1; i <= g_GlobalVars->maxClients; i++) for (int i = 1; i <= g_GlobalVars->maxClients; i++)
{ {
@ -272,7 +272,7 @@ Vector EnginePrediction(CachedEntity *entity, float time)
memset(&fakecmd, 0, sizeof(CUserCmd)); memset(&fakecmd, 0, sizeof(CUserCmd));
Vector vel(0.0f); Vector vel(0.0f);
if (entity->m_IDX <= 33 && player_vel[entity->m_IDX].size()) if (entity->m_IDX <= MAX_PLAYERS && player_vel[entity->m_IDX].size())
{ {
for (auto entry : player_vel[entity->m_IDX]) for (auto entry : player_vel[entity->m_IDX])
vel += entry; vel += entry;
@ -328,7 +328,7 @@ Vector ProjectilePrediction_Engine(CachedEntity *ent, int hb, float speed, float
if (speed == 0.0f) if (speed == 0.0f)
return Vector(); return Vector();
Vector velocity(0.0f); Vector velocity(0.0f);
if (ent->m_IDX <= 33 && player_vel[ent->m_IDX].size()) if (ent->m_IDX <= MAX_PLAYERS && player_vel[ent->m_IDX].size())
{ {
for (auto entry : player_vel[ent->m_IDX]) for (auto entry : player_vel[ent->m_IDX])
velocity += entry; velocity += entry;
@ -444,7 +444,7 @@ Vector ProjectilePrediction(CachedEntity *ent, int hb, float speed, float gravit
if (speed == 0.0f) if (speed == 0.0f)
return Vector(); return Vector();
Vector velocity(0.0f); Vector velocity(0.0f);
if (ent->m_IDX <= 33 && player_vel[ent->m_IDX].size()) if (ent->m_IDX <= MAX_PLAYERS && player_vel[ent->m_IDX].size())
{ {
for (auto entry : player_vel[ent->m_IDX]) for (auto entry : player_vel[ent->m_IDX])
velocity += entry; velocity += entry;

View File

@ -90,10 +90,10 @@ void EffectChams::EndRenderChams()
g_IVModelRender->ForcedMaterialOverride(nullptr); g_IVModelRender->ForcedMaterialOverride(nullptr);
#endif #endif
} }
static rgba_t data[33] = { colors::empty }; static rgba_t data[PLAYER_ARRAY_SIZE] = { colors::empty };
void EffectChams::SetEntityColor(CachedEntity *ent, rgba_t color) void EffectChams::SetEntityColor(CachedEntity *ent, rgba_t color)
{ {
if (ent->m_IDX > 32 || ent->m_IDX < 0) if (ent->m_IDX > MAX_PLAYERS || ent->m_IDX < 0)
return; return;
data[ent->m_IDX] = color; data[ent->m_IDX] = color;
} }
@ -162,7 +162,7 @@ rgba_t EffectChams::ChamsColor(IClientEntity *entity)
} }
return disco; return disco;
} }
if (ent->m_IDX <= 32 && ent->m_IDX >= 0) if (ent->m_IDX <= MAX_PLAYERS && ent->m_IDX >= 0)
{ {
if (data[entity->entindex()] != colors::empty) if (data[entity->entindex()] != colors::empty)
{ {

View File

@ -111,7 +111,7 @@ static void handlePlayerSpawn(KeyValues *kv)
static void handlePlayerChangeClass(KeyValues *kv) static void handlePlayerChangeClass(KeyValues *kv)
{ {
int id = kv->GetInt("userid"); int id = kv->GetInt("userid");
if (id > 33 || id < 0) if (id > PLAYER_ARRAY_SIZE || id < 0)
return; return;
player_info_s info{}; player_info_s info{};
if (!g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info)) if (!g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info))

View File

@ -162,7 +162,7 @@ bool gui::handleSdlEvent(SDL_Event *event)
if (controller && CE_GOOD(LOCAL_E) && update_players.test_and_set(10000)) if (controller && CE_GOOD(LOCAL_E) && update_players.test_and_set(10000))
{ {
controller->removeAll(); controller->removeAll();
for (auto i = 1; i < 32; ++i) for (auto i = 1; i <= MAX_PLAYERS; ++i)
{ {
player_info_s info{}; player_info_s info{};
if (g_IEngine->GetPlayerInfo(i, &info)) if (g_IEngine->GetPlayerInfo(i, &info))
@ -202,7 +202,7 @@ void gui::onLevelLoad()
if (controller) if (controller)
{ {
controller->removeAll(); controller->removeAll();
for (auto i = 1; i < 32; ++i) for (auto i = 1; i < MAX_PLAYERS; ++i)
{ {
player_info_s info{}; player_info_s info{};
if (g_IEngine->GetPlayerInfo(i, &info)) if (g_IEngine->GetPlayerInfo(i, &info))