This commit is contained in:
nullifiedcat 2017-01-05 00:03:09 +03:00
parent 448f8e6229
commit 75ba2ca36c
7 changed files with 59 additions and 35 deletions

View File

@ -32,7 +32,7 @@
#define DEG2RAD(x) (float)(x) * (PI / 180.0f) #define DEG2RAD(x) (float)(x) * (PI / 180.0f)
#define DEBUG_SEGV true #define DEBUG_SEGV false
#if DEBUG_SEGV == true #if DEBUG_SEGV == true

View File

@ -37,6 +37,11 @@ IClientEntity* CachedEntity::InternalEntity() {
return m_pEntity; return m_pEntity;
} }
void EntityCache::Invalidate() {
delete [] m_pArray;
m_pArray = new CachedEntity[4096]();
}
void CachedEntity::Update(int idx) { void CachedEntity::Update(int idx) {
SEGV_BEGIN SEGV_BEGIN
@ -243,7 +248,7 @@ EntityCache::~EntityCache() {
void EntityCache::Update() { void EntityCache::Update() {
m_nMax = interfaces::entityList->GetHighestEntityIndex(); m_nMax = interfaces::entityList->GetHighestEntityIndex();
for (int i = 0; i < m_nMax && i < 1024; i++) { for (int i = 0; i < m_nMax && i < 4096; i++) {
//logging::Info("Updating %i", i); //logging::Info("Updating %i", i);
m_pArray[i].Update(i); m_pArray[i].Update(i);
//logging::Info("Back!"); //logging::Info("Back!");
@ -253,17 +258,19 @@ void EntityCache::Update() {
if (time(0) != m_lLastLog) { if (time(0) != m_lLastLog) {
m_lLastLog = time(0); m_lLastLog = time(0);
if (g_vEntityCacheProfiling && g_vEntityCacheProfiling->GetBool()) { if (g_vEntityCacheProfiling && g_vEntityCacheProfiling->GetBool()) {
logging::Info("[EntityCache] TOTAL: UPS=%i QPS=%i SQPS=%i SAPS=%i REAPS=%i", m_nUpdates, m_nQueues, m_nStringsQueued, m_nStringsAdded, m_nRawEntityAccesses); logging::Info("[EntityCache] TOTAL: UPS=%i QPS=%i SQPS=%i SAPS=%i REAPS=%i HBPS=%i", m_nUpdates, m_nQueues, m_nStringsQueued, m_nStringsAdded, m_nRawEntityAccesses, m_nHitboxQueued);
if (m_nUpdates != 0) logging::Info("[EntityCache] AVG: QPU=%i SQPU=%i SAPU=%i REAPU=%i", if (m_nUpdates != 0) logging::Info("[EntityCache] AVG: QPU=%i SQPU=%i SAPU=%i REAPU=%i HBPU=%i",
m_nQueues / m_nUpdates, m_nQueues / m_nUpdates,
m_nStringsQueued / m_nUpdates, m_nStringsQueued / m_nUpdates,
m_nStringsAdded / m_nUpdates, m_nStringsAdded / m_nUpdates,
m_nRawEntityAccesses / m_nUpdates); m_nRawEntityAccesses / m_nUpdates,
m_nHitboxQueued / m_nUpdates);
m_nUpdates = 0; m_nUpdates = 0;
m_nQueues = 0; m_nQueues = 0;
m_nStringsQueued = 0; m_nStringsQueued = 0;
m_nStringsAdded = 0; m_nStringsAdded = 0;
m_nRawEntityAccesses = 0; m_nRawEntityAccesses = 0;
m_nHitboxQueued = 0;
} }
} }
#endif #endif

View File

@ -158,6 +158,7 @@ public:
~EntityCache(); ~EntityCache();
void Update(); void Update();
void Invalidate();
CachedEntity* GetEntity(int idx); CachedEntity* GetEntity(int idx);
CachedEntity* m_pArray; CachedEntity* m_pArray;
@ -167,6 +168,7 @@ public:
int m_nUpdates; int m_nUpdates;
int m_nStringsAdded; int m_nStringsAdded;
int m_nStringsQueued; int m_nStringsQueued;
int m_nHitboxQueued;
unsigned long m_lLastLog; unsigned long m_lLastLog;
int m_nMax; int m_nMax;

View File

@ -59,12 +59,13 @@ bool EntityHitboxCache::VisibilityCheck(int id) {
// TODO corners // TODO corners
CachedHitbox* hitbox = GetHitbox(id); CachedHitbox* hitbox = GetHitbox(id);
if (!hitbox) return 0; if (!hitbox) return 0;
m_VisCheck[id] = (IsEntityVectorVisible(m_pParentEntity, hitbox->center)); SAFE_CALL(m_VisCheck[id] = (IsEntityVectorVisible(m_pParentEntity, hitbox->center)));
m_VisCheckValidationFlags[id] = true; m_VisCheckValidationFlags[id] = true;
return m_VisCheck[id]; return m_VisCheck[id];
} }
CachedHitbox* EntityHitboxCache::GetHitbox(int id) { CachedHitbox* EntityHitboxCache::GetHitbox(int id) {
gEntityCache.m_nHitboxQueued++;
if (id < 0 || id >= m_nNumHitboxes) return 0; if (id < 0 || id >= m_nNumHitboxes) return 0;
if (!m_bSuccess) return 0; if (!m_bSuccess) return 0;
if (!m_CacheValidationFlags[id]) { if (!m_CacheValidationFlags[id]) {

View File

@ -129,6 +129,7 @@ void hack::Hk_PaintTraverse(void* p, unsigned int vp, bool fr, bool ar) {
g_Settings.bInvalid = true; g_Settings.bInvalid = true;
} }
if (g_Settings.bInvalid) return; if (g_Settings.bInvalid) return;
if (CE_BAD(g_pLocalPlayer->entity)) return;
if (draw::panel_top == vp) { if (draw::panel_top == vp) {
ResetStrings(); ResetStrings();
if (g_Settings.bShowLogo->GetBool()) { if (g_Settings.bShowLogo->GetBool()) {
@ -212,7 +213,7 @@ typedef void(Shutdown_t)(void*, const char*);
void Hk_Shutdown(void* thisptr, const char* reason) { void Hk_Shutdown(void* thisptr, const char* reason) {
SEGV_BEGIN; SEGV_BEGIN;
const char* new_reason; const char* new_reason;
if (g_Settings.sDisconnectMsg->m_StringLength > 1) { if (g_Settings.sDisconnectMsg->m_StringLength > 3) {
new_reason = g_Settings.sDisconnectMsg->GetString(); new_reason = g_Settings.sDisconnectMsg->GetString();
} else { } else {
new_reason = reason; new_reason = reason;
@ -255,41 +256,48 @@ bool hack::Hk_CreateMove(void* thisptr, float inputSample, CUserCmd* cmd) {
interfaces::gvars->curtime = servertime; interfaces::gvars->curtime = servertime;
time_replaced = true; time_replaced = true;
} }
if (g_Settings.bInvalid) {
gEntityCache.Invalidate();
}
SAFE_CALL(gEntityCache.Update()); SAFE_CALL(gEntityCache.Update());
SAFE_CALL(g_pPlayerResource->Update()); SAFE_CALL(g_pPlayerResource->Update());
SAFE_CALL(g_pLocalPlayer->Update()); SAFE_CALL(g_pLocalPlayer->Update());
g_pLocalPlayer->v_OrigViewangles = cmd->viewangles; if (CE_GOOD(g_pLocalPlayer->entity)) {
SAFE_CALL(CREATE_MOVE(Bunnyhop)); g_pLocalPlayer->v_OrigViewangles = cmd->viewangles;
//RunEnginePrediction(g_pLocalPlayer->entity, cmd); SAFE_CALL(CREATE_MOVE(Bunnyhop));
SAFE_CALL(CREATE_MOVE(ESP)); //RunEnginePrediction(g_pLocalPlayer->entity, cmd);
SAFE_CALL(CREATE_MOVE(Aimbot)); SAFE_CALL(CREATE_MOVE(ESP));
SAFE_CALL(CREATE_MOVE(Airstuck)); SAFE_CALL(CREATE_MOVE(Aimbot));
SAFE_CALL(CREATE_MOVE(AntiAim)); SAFE_CALL(CREATE_MOVE(Airstuck));
SAFE_CALL(CREATE_MOVE(AntiDisguise)); SAFE_CALL(CREATE_MOVE(AntiAim));
SAFE_CALL(CREATE_MOVE(AutoHeal)); SAFE_CALL(CREATE_MOVE(AntiDisguise));
SAFE_CALL(CREATE_MOVE(AutoSticky)); SAFE_CALL(CREATE_MOVE(AutoHeal));
SAFE_CALL(CREATE_MOVE(AutoReflect)); SAFE_CALL(CREATE_MOVE(AutoSticky));
SAFE_CALL(CREATE_MOVE(AutoStrafe)); SAFE_CALL(CREATE_MOVE(AutoReflect));
SAFE_CALL(CREATE_MOVE(FollowBot)); SAFE_CALL(CREATE_MOVE(AutoStrafe));
SAFE_CALL(CREATE_MOVE(Misc)); SAFE_CALL(CREATE_MOVE(FollowBot));
SAFE_CALL(CREATE_MOVE(Triggerbot)); SAFE_CALL(CREATE_MOVE(Misc));
SAFE_CALL(CREATE_MOVE(HuntsmanCompensation)); SAFE_CALL(CREATE_MOVE(Triggerbot));
if (time_replaced) interfaces::gvars->curtime = curtime_old; SAFE_CALL(CREATE_MOVE(HuntsmanCompensation));
if (time_replaced) interfaces::gvars->curtime = curtime_old;
}
/*for (IHack* i_hack : hack::hacks) { /*for (IHack* i_hack : hack::hacks) {
if (!i_hack->CreateMove(thisptr, inputSample, cmd)) { if (!i_hack->CreateMove(thisptr, inputSample, cmd)) {
ret = false; ret = false;
} }
}*/ }*/
g_Settings.bInvalid = false; g_Settings.bInvalid = false;
if (g_pLocalPlayer->bUseSilentAngles) { if (CE_GOOD(g_pLocalPlayer->entity)) {
Vector vsilent(cmd->forwardmove, cmd->sidemove, cmd->upmove); if (g_pLocalPlayer->bUseSilentAngles) {
float speed = sqrt(vsilent.x * vsilent.x + vsilent.y * vsilent.y); Vector vsilent(cmd->forwardmove, cmd->sidemove, cmd->upmove);
Vector ang; float speed = sqrt(vsilent.x * vsilent.x + vsilent.y * vsilent.y);
VectorAngles(vsilent, ang); Vector ang;
float yaw = DEG2RAD(ang.y - g_pLocalPlayer->v_OrigViewangles.y + cmd->viewangles.y); VectorAngles(vsilent, ang);
cmd->forwardmove = cos(yaw) * speed; float yaw = DEG2RAD(ang.y - g_pLocalPlayer->v_OrigViewangles.y + cmd->viewangles.y);
cmd->sidemove = sin(yaw) * speed; cmd->forwardmove = cos(yaw) * speed;
ret = false; cmd->sidemove = sin(yaw) * speed;
ret = false;
}
} }
if (cmd) if (cmd)
last_angles = cmd->viewangles; last_angles = cmd->viewangles;

View File

@ -238,6 +238,7 @@ float RandFloatRange(float min, float max)
} }
bool IsEntityVisible(CachedEntity* entity, int hb) { bool IsEntityVisible(CachedEntity* entity, int hb) {
if (g_Settings.bInvalid) return false;
if (entity == g_pLocalPlayer->entity) return true; if (entity == g_pLocalPlayer->entity) return true;
Vector hit; Vector hit;
if (hb == -1) { if (hb == -1) {
@ -249,8 +250,10 @@ bool IsEntityVisible(CachedEntity* entity, int hb) {
} }
bool IsEntityVectorVisible(CachedEntity* entity, Vector endpos) { bool IsEntityVectorVisible(CachedEntity* entity, Vector endpos) {
if (g_Settings.bInvalid) return false;
if (entity == g_pLocalPlayer->entity) return true; if (entity == g_pLocalPlayer->entity) return true;
if (CE_BAD(g_pLocalPlayer->entity)) return false; if (CE_BAD(g_pLocalPlayer->entity)) return false;
if (CE_BAD(entity)) return false;
trace_t trace_object; trace_t trace_object;
Ray_t ray; Ray_t ray;
trace::g_pFilterDefault->SetSelf(RAW_ENT(g_pLocalPlayer->entity)); trace::g_pFilterDefault->SetSelf(RAW_ENT(g_pLocalPlayer->entity));
@ -378,7 +381,7 @@ bool IsProjectileCrit(CachedEntity* ent) {
weaponmode GetWeaponMode(CachedEntity* player) { weaponmode GetWeaponMode(CachedEntity* player) {
int weapon_handle = CE_INT(player, netvar.hActiveWeapon); int weapon_handle = CE_INT(player, netvar.hActiveWeapon);
if (IDX_BAD((weapon_handle & 0xFFF))) { if (IDX_BAD((weapon_handle & 0xFFF))) {
logging::Info("IDX_BAD: %i", weapon_handle & 0xFFF); //logging::Info("IDX_BAD: %i", weapon_handle & 0xFFF);
return weaponmode::weapon_invalid; return weaponmode::weapon_invalid;
} }
CachedEntity* weapon = (ENTITY(weapon_handle & 0xFFF)); CachedEntity* weapon = (ENTITY(weapon_handle & 0xFFF));

View File

@ -12,7 +12,10 @@ void LocalPlayer::Update() {
entity_idx = interfaces::engineClient->GetLocalPlayer(); entity_idx = interfaces::engineClient->GetLocalPlayer();
entity = ENTITY(entity_idx); entity = ENTITY(entity_idx);
if (!entity) logging::Info("Local Player is NULL!"); if (!entity) logging::Info("Local Player is NULL!");
if (CE_BAD(entity)) logging::Info("Local Player is BAD CACHED ENTITY!"); if (CE_BAD(entity)) {
logging::Info("Local Player is BAD CACHED ENTITY!");
return;
}
team = CE_INT(entity, netvar.iTeamNum); team = CE_INT(entity, netvar.iTeamNum);
life_state = CE_BYTE(entity, netvar.iLifeState); life_state = CE_BYTE(entity, netvar.iLifeState);
v_ViewOffset = CE_VECTOR(entity, netvar.vViewOffset); v_ViewOffset = CE_VECTOR(entity, netvar.vViewOffset);