diff --git a/cathook/src/common.h b/cathook/src/common.h index 207f6c18..8780a617 100644 --- a/cathook/src/common.h +++ b/cathook/src/common.h @@ -9,7 +9,6 @@ #define COMMON_H_ #include "drawing.h" -#include "entity.h" #include "entitycache.h" #include "enums.h" #include "globals.h" @@ -22,6 +21,7 @@ #include "usercmd.h" #include "trace.h" #include "cvwrapper.h" +#include "netvars.h" #include "prediction.h" #define CON_NAME "cat" diff --git a/cathook/src/hack.cpp b/cathook/src/hack.cpp index 2cce8f8c..429a83bc 100644 --- a/cathook/src/hack.cpp +++ b/cathook/src/hack.cpp @@ -406,14 +406,13 @@ void hack::Initialize() { hack::InitHacks(); logging::Info("Init global settings"); g_Settings.Init(); - InitTargetingConVars(); EndConVars(); g_pGUI = new GUI(); g_pGUI->Setup(); logging::Info("Initializing NetVar tree..."); gNetvars.init(); logging::Info("Initializing entity offsets..."); - InitEntityOffsets(); + InitNetVars(); g_pLocalPlayer = new LocalPlayer(); g_pPlayerResource = new TFPlayerResource(); diff --git a/cathook/src/entity.cpp b/cathook/src/netvars.cpp similarity index 98% rename from cathook/src/entity.cpp rename to cathook/src/netvars.cpp index 95dfb1ec..4b0218e5 100644 --- a/cathook/src/entity.cpp +++ b/cathook/src/netvars.cpp @@ -8,9 +8,9 @@ a * entity.cpp #include "copypasted/Netvar.h" #include "common.h" -EntityVariables netvar; +NetVars netvar; -void EntityVariables::Init() { +void NetVars::Init() { this->iCond = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCond"); this->iFlags = gNetvars.get_offset("DT_BasePlayer", "m_fFlags"); this->iHealth = gNetvars.get_offset("DT_BasePlayer", "m_iHealth"); @@ -63,6 +63,6 @@ void EntityVariables::Init() { this->Grenade_bCritical = gNetvars.get_offset("DT_TFWeaponBaseGrenadeProj", "m_bCritical"); } -void InitEntityOffsets() { +void InitNetVars() { netvar.Init(); } diff --git a/cathook/src/entity.h b/cathook/src/netvars.h similarity index 86% rename from cathook/src/entity.h rename to cathook/src/netvars.h index 46b8481e..5c672105 100644 --- a/cathook/src/entity.h +++ b/cathook/src/netvars.h @@ -5,8 +5,8 @@ * Author: nullifiedcat */ -#ifndef ENTITY_H_ -#define ENTITY_H_ +#ifndef NETVARS_H_ +#define NETVARS_H_ #include "logging.h" @@ -15,7 +15,7 @@ class IClientEntity; typedef unsigned int offset_t; template -inline T GetEntityValue(IClientEntity* ent, unsigned int offset) { +inline T GetVar(IClientEntity* ent, unsigned int offset) { int nullv = 0; if (ent == 0) return *(reinterpret_cast(&nullv)); //logging::Info("GetEntityValue 0x%08x, 0x%08x", ent, offset); @@ -23,15 +23,15 @@ inline T GetEntityValue(IClientEntity* ent, unsigned int offset) { } template -void SetEntityValue(IClientEntity* ent, unsigned int offset, T value) { +void SetVar(IClientEntity* ent, unsigned int offset, T value) { *(reinterpret_cast((unsigned int)ent + offset)) = value; } -void InitEntityOffsets(); +void InitNetVars(); // TODO move this. -class EntityVariables { +class NetVars { public: void Init(); offset_t iTeamNum; @@ -95,6 +95,6 @@ public: offset_t iFOV; }; -extern EntityVariables netvar; +extern NetVars netvar; -#endif /* ENTITY_H_ */ +#endif /* NETVARS_H_ */ diff --git a/cathook/src/playerresource.cpp b/cathook/src/playerresource.cpp index 20a2ed68..0e312183 100644 --- a/cathook/src/playerresource.cpp +++ b/cathook/src/playerresource.cpp @@ -8,8 +8,7 @@ #include "playerresource.h" #include "interfaces.h" #include "enums.h" -#include "entity.h" - +#include "netvars.h" #include "sdk.h" void TFPlayerResource::Update() { diff --git a/cathook/src/targethelper.cpp b/cathook/src/targethelper.cpp index 01f09929..13c8b9cd 100644 --- a/cathook/src/targethelper.cpp +++ b/cathook/src/targethelper.cpp @@ -6,9 +6,9 @@ */ #include "enums.h" -#include "entity.h" #include "localplayer.h" #include "helpers.h" +#include "netvars.h" #include "sdk.h" diff --git a/cathook/src/targeting/ITargetSystem.cpp b/cathook/src/targeting/ITargetSystem.cpp index c6c085c3..7f300cae 100644 --- a/cathook/src/targeting/ITargetSystem.cpp +++ b/cathook/src/targeting/ITargetSystem.cpp @@ -8,15 +8,5 @@ #include "ITargetSystem.h" #include "../common.h" -TargetingConVars* g_pTargetingConVars = 0; - -ITargetSystem::~ITargetSystem() {} - -void InitTargetingConVars() { - g_pTargetingConVars = new TargetingConVars(); - g_pTargetingConVars->bTargetInvisible = CreateConVar(CON_PREFIX "target_ignore_cloak", "0", "Ignore cloak when targeting"); - g_pTargetingConVars->flMaxFOV = CreateConVar(CON_PREFIX "target_max_fov", "0", "Maximum FOV when targeting"); - g_pTargetingConVars->iMaxDistance = CreateConVar(CON_PREFIX "target_max_distance", "0", "Maximum distance when targeting"); -} - +ITargetSystem::~ITargetSystem() {}; diff --git a/cathook/src/targeting/ITargetSystem.h b/cathook/src/targeting/ITargetSystem.h index 8993ca26..e9793bfe 100644 --- a/cathook/src/targeting/ITargetSystem.h +++ b/cathook/src/targeting/ITargetSystem.h @@ -8,24 +8,11 @@ #ifndef ITARGETSYSTEM_H_ #define ITARGETSYSTEM_H_ -// TODO Targeting. - class ITargetSystem { public: virtual ~ITargetSystem(); - virtual bool ShouldTarget(int idx) = 0; virtual int GetScore(int idx) = 0; + virtual const char* Name() = 0; }; -class ConVar; -struct TargetingConVars { - ConVar* bTargetInvisible; - ConVar* flMaxFOV; - ConVar* iMaxDistance; -}; - -extern TargetingConVars* g_pTargetingConVars; - -void InitTargetingConVars(); - #endif /* ITARGETSYSTEM_H_ */ diff --git a/cathook/src/targeting/TargetSystemDistance.cpp b/cathook/src/targeting/TargetSystemDistance.cpp index 0b88e1d8..ee1343b9 100644 --- a/cathook/src/targeting/TargetSystemDistance.cpp +++ b/cathook/src/targeting/TargetSystemDistance.cpp @@ -7,12 +7,6 @@ #include "TargetSystemDistance.h" -bool TargetSystemDistance::ShouldTarget(int idx) { - //CachedEntity* ent = gEntityCache.GetEntity(idx); - //float fov = GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, GetHitboxPosition(ent->m_pEntity, )); - return false; -} - int TargetSystemDistance::GetScore(int idx) { return 0; } diff --git a/cathook/src/targeting/TargetSystemDistance.h b/cathook/src/targeting/TargetSystemDistance.h index 36b572ee..540e723b 100644 --- a/cathook/src/targeting/TargetSystemDistance.h +++ b/cathook/src/targeting/TargetSystemDistance.h @@ -12,8 +12,8 @@ class TargetSystemDistance : public ITargetSystem { public: - bool ShouldTarget(int idx); - int GetScore(int idx); + virtual int GetScore(int idx); + inline virtual const char* Name() { return "CLOSEST ENEMY"; }; }; #endif /* TARGETSYSTEMDISTANCE_H_ */ diff --git a/cathook/src/targeting/TargetSystemFOV.cpp b/cathook/src/targeting/TargetSystemFOV.cpp index dbe8beae..0c6fc2ae 100644 --- a/cathook/src/targeting/TargetSystemFOV.cpp +++ b/cathook/src/targeting/TargetSystemFOV.cpp @@ -7,12 +7,6 @@ #include "TargetSystemFOV.h" -bool TargetSystemFOV::ShouldTarget(int idx) { - //CachedEntity* ent = gEntityCache.GetEntity(idx); - //float fov = GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, GetHitboxPosition(ent->m_pEntity, )); - return false; -} - int TargetSystemFOV::GetScore(int idx) { return 0; } diff --git a/cathook/src/targeting/TargetSystemFOV.h b/cathook/src/targeting/TargetSystemFOV.h index d1a5e4a6..47ce28d8 100644 --- a/cathook/src/targeting/TargetSystemFOV.h +++ b/cathook/src/targeting/TargetSystemFOV.h @@ -12,8 +12,8 @@ class TargetSystemFOV : public ITargetSystem { public: - bool ShouldTarget(int idx); - int GetScore(int idx); + virtual int GetScore(int idx); + inline virtual const char* Name() { return "FOV"; }; }; #endif /* TARGETSYSTEMFOV_H_ */ diff --git a/cathook/src/targeting/TargetSystemSmart.cpp b/cathook/src/targeting/TargetSystemSmart.cpp index 0146062c..a93c2e93 100644 --- a/cathook/src/targeting/TargetSystemSmart.cpp +++ b/cathook/src/targeting/TargetSystemSmart.cpp @@ -7,10 +7,6 @@ #include "TargetSystemSmart.h" -bool TargetSystemSmart::ShouldTarget(int idx) { - return false; -} - int TargetSystemSmart::GetScore(int idx) { return 0; } diff --git a/cathook/src/targeting/TargetSystemSmart.h b/cathook/src/targeting/TargetSystemSmart.h index add085a7..d1ed3b72 100644 --- a/cathook/src/targeting/TargetSystemSmart.h +++ b/cathook/src/targeting/TargetSystemSmart.h @@ -14,8 +14,8 @@ class ConVar; class TargetSystemSmart : public ITargetSystem { public: - bool ShouldTarget(int idx); - int GetScore(int idx); + virtual int GetScore(int idx); + inline virtual const char* Name() { return "SMART"; }; }; #endif /* TARGETSYSTEMSMART_H_ */ diff --git a/cathook/src/weaponprefs.cpp b/cathook/src/weaponprefs.cpp index 5339a772..92011283 100644 --- a/cathook/src/weaponprefs.cpp +++ b/cathook/src/weaponprefs.cpp @@ -7,10 +7,9 @@ #include "weaponprefs.h" -#include "entity.h" - #include "fixsdk.h" #include +#include "netvars.h" //bool IsAmbassador(IClientEntity* weapon) { // return false;