Rename "entity.h" to "netvar.h", rename eoffsets to netvars

This commit is contained in:
nullifiedcat 2016-12-22 11:32:33 +03:00
parent 87b6d510c6
commit eebab92cc8
15 changed files with 24 additions and 66 deletions

View File

@ -9,7 +9,6 @@
#define COMMON_H_ #define COMMON_H_
#include "drawing.h" #include "drawing.h"
#include "entity.h"
#include "entitycache.h" #include "entitycache.h"
#include "enums.h" #include "enums.h"
#include "globals.h" #include "globals.h"
@ -22,6 +21,7 @@
#include "usercmd.h" #include "usercmd.h"
#include "trace.h" #include "trace.h"
#include "cvwrapper.h" #include "cvwrapper.h"
#include "netvars.h"
#include "prediction.h" #include "prediction.h"
#define CON_NAME "cat" #define CON_NAME "cat"

View File

@ -406,14 +406,13 @@ void hack::Initialize() {
hack::InitHacks(); hack::InitHacks();
logging::Info("Init global settings"); logging::Info("Init global settings");
g_Settings.Init(); g_Settings.Init();
InitTargetingConVars();
EndConVars(); EndConVars();
g_pGUI = new GUI(); g_pGUI = new GUI();
g_pGUI->Setup(); g_pGUI->Setup();
logging::Info("Initializing NetVar tree..."); logging::Info("Initializing NetVar tree...");
gNetvars.init(); gNetvars.init();
logging::Info("Initializing entity offsets..."); logging::Info("Initializing entity offsets...");
InitEntityOffsets(); InitNetVars();
g_pLocalPlayer = new LocalPlayer(); g_pLocalPlayer = new LocalPlayer();
g_pPlayerResource = new TFPlayerResource(); g_pPlayerResource = new TFPlayerResource();

View File

@ -8,9 +8,9 @@ a * entity.cpp
#include "copypasted/Netvar.h" #include "copypasted/Netvar.h"
#include "common.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->iCond = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCond");
this->iFlags = gNetvars.get_offset("DT_BasePlayer", "m_fFlags"); this->iFlags = gNetvars.get_offset("DT_BasePlayer", "m_fFlags");
this->iHealth = gNetvars.get_offset("DT_BasePlayer", "m_iHealth"); 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"); this->Grenade_bCritical = gNetvars.get_offset("DT_TFWeaponBaseGrenadeProj", "m_bCritical");
} }
void InitEntityOffsets() { void InitNetVars() {
netvar.Init(); netvar.Init();
} }

View File

@ -5,8 +5,8 @@
* Author: nullifiedcat * Author: nullifiedcat
*/ */
#ifndef ENTITY_H_ #ifndef NETVARS_H_
#define ENTITY_H_ #define NETVARS_H_
#include "logging.h" #include "logging.h"
@ -15,7 +15,7 @@ class IClientEntity;
typedef unsigned int offset_t; typedef unsigned int offset_t;
template<typename T> template<typename T>
inline T GetEntityValue(IClientEntity* ent, unsigned int offset) { inline T GetVar(IClientEntity* ent, unsigned int offset) {
int nullv = 0; int nullv = 0;
if (ent == 0) return *(reinterpret_cast<T*>(&nullv)); if (ent == 0) return *(reinterpret_cast<T*>(&nullv));
//logging::Info("GetEntityValue 0x%08x, 0x%08x", ent, offset); //logging::Info("GetEntityValue 0x%08x, 0x%08x", ent, offset);
@ -23,15 +23,15 @@ inline T GetEntityValue(IClientEntity* ent, unsigned int offset) {
} }
template<typename T> template<typename T>
void SetEntityValue(IClientEntity* ent, unsigned int offset, T value) { void SetVar(IClientEntity* ent, unsigned int offset, T value) {
*(reinterpret_cast<T*>((unsigned int)ent + offset)) = value; *(reinterpret_cast<T*>((unsigned int)ent + offset)) = value;
} }
void InitEntityOffsets(); void InitNetVars();
// TODO move this. // TODO move this.
class EntityVariables { class NetVars {
public: public:
void Init(); void Init();
offset_t iTeamNum; offset_t iTeamNum;
@ -95,6 +95,6 @@ public:
offset_t iFOV; offset_t iFOV;
}; };
extern EntityVariables netvar; extern NetVars netvar;
#endif /* ENTITY_H_ */ #endif /* NETVARS_H_ */

View File

@ -8,8 +8,7 @@
#include "playerresource.h" #include "playerresource.h"
#include "interfaces.h" #include "interfaces.h"
#include "enums.h" #include "enums.h"
#include "entity.h" #include "netvars.h"
#include "sdk.h" #include "sdk.h"
void TFPlayerResource::Update() { void TFPlayerResource::Update() {

View File

@ -6,9 +6,9 @@
*/ */
#include "enums.h" #include "enums.h"
#include "entity.h"
#include "localplayer.h" #include "localplayer.h"
#include "helpers.h" #include "helpers.h"
#include "netvars.h"
#include "sdk.h" #include "sdk.h"

View File

@ -8,15 +8,5 @@
#include "ITargetSystem.h" #include "ITargetSystem.h"
#include "../common.h" #include "../common.h"
TargetingConVars* g_pTargetingConVars = 0; ITargetSystem::~ITargetSystem() {};
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");
}

View File

@ -8,24 +8,11 @@
#ifndef ITARGETSYSTEM_H_ #ifndef ITARGETSYSTEM_H_
#define ITARGETSYSTEM_H_ #define ITARGETSYSTEM_H_
// TODO Targeting.
class ITargetSystem { class ITargetSystem {
public: public:
virtual ~ITargetSystem(); virtual ~ITargetSystem();
virtual bool ShouldTarget(int idx) = 0;
virtual int GetScore(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_ */ #endif /* ITARGETSYSTEM_H_ */

View File

@ -7,12 +7,6 @@
#include "TargetSystemDistance.h" #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) { int TargetSystemDistance::GetScore(int idx) {
return 0; return 0;
} }

View File

@ -12,8 +12,8 @@
class TargetSystemDistance : public ITargetSystem { class TargetSystemDistance : public ITargetSystem {
public: public:
bool ShouldTarget(int idx); virtual int GetScore(int idx);
int GetScore(int idx); inline virtual const char* Name() { return "CLOSEST ENEMY"; };
}; };
#endif /* TARGETSYSTEMDISTANCE_H_ */ #endif /* TARGETSYSTEMDISTANCE_H_ */

View File

@ -7,12 +7,6 @@
#include "TargetSystemFOV.h" #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) { int TargetSystemFOV::GetScore(int idx) {
return 0; return 0;
} }

View File

@ -12,8 +12,8 @@
class TargetSystemFOV : public ITargetSystem { class TargetSystemFOV : public ITargetSystem {
public: public:
bool ShouldTarget(int idx); virtual int GetScore(int idx);
int GetScore(int idx); inline virtual const char* Name() { return "FOV"; };
}; };
#endif /* TARGETSYSTEMFOV_H_ */ #endif /* TARGETSYSTEMFOV_H_ */

View File

@ -7,10 +7,6 @@
#include "TargetSystemSmart.h" #include "TargetSystemSmart.h"
bool TargetSystemSmart::ShouldTarget(int idx) {
return false;
}
int TargetSystemSmart::GetScore(int idx) { int TargetSystemSmart::GetScore(int idx) {
return 0; return 0;
} }

View File

@ -14,8 +14,8 @@ class ConVar;
class TargetSystemSmart : public ITargetSystem { class TargetSystemSmart : public ITargetSystem {
public: public:
bool ShouldTarget(int idx); virtual int GetScore(int idx);
int GetScore(int idx); inline virtual const char* Name() { return "SMART"; };
}; };
#endif /* TARGETSYSTEMSMART_H_ */ #endif /* TARGETSYSTEMSMART_H_ */

View File

@ -7,10 +7,9 @@
#include "weaponprefs.h" #include "weaponprefs.h"
#include "entity.h"
#include "fixsdk.h" #include "fixsdk.h"
#include <icliententity.h> #include <icliententity.h>
#include "netvars.h"
//bool IsAmbassador(IClientEntity* weapon) { //bool IsAmbassador(IClientEntity* weapon) {
// return false; // return false;