semi-stable

This commit is contained in:
nullifiedcat 2017-01-08 14:52:34 +03:00
parent 75ba2ca36c
commit 186259d3c1
19 changed files with 288 additions and 109 deletions

View File

@ -22,6 +22,7 @@
#include "trace.h"
#include "cvwrapper.h"
#include "netvars.h"
#include "vfunc.h"
#include "prediction.h"
#include "sdk.h"

View File

@ -147,7 +147,7 @@ Color colors::EntityB(CachedEntity* ent) {
if (GetRelation(ent) == relation::DEVELOPER) result = Transparent(black, 0.6f);
}
if (!ent->m_bIsVisible) result = Transparent(result, 0.833f);
if (!ent->IsVisible()) result = Transparent(result, 0.833f);
}
return result;
}
@ -208,7 +208,7 @@ Color colors::EntityF(CachedEntity* ent) {
result = RainbowCurrent(); break;
}
}
if (!ent->m_bIsVisible) result = Transparent(result);
if (!ent->IsVisible()) result = Transparent(result);
}
return result;

View File

@ -31,9 +31,6 @@ CachedEntity::~CachedEntity() {
}
IClientEntity* CachedEntity::InternalEntity() {
#if ENTITY_CACHE_PROFILER == true
gEntityCache.m_nRawEntityAccesses++;
#endif
return m_pEntity;
}
@ -45,6 +42,10 @@ void EntityCache::Invalidate() {
void CachedEntity::Update(int idx) {
SEGV_BEGIN
#if ENTITY_CACHE_PROFILER == true
long p_begin = gECP.CurrentTime();
#endif
m_ESPOrigin.Zero();
m_nESPStrings = 0;
m_IDX = idx;
@ -59,7 +60,9 @@ void CachedEntity::Update(int idx) {
m_bVisCheckComplete = false;
if (m_pHitboxCache) {
long p_begin = gECP.CurrentTime();
SAFE_CALL(m_pHitboxCache->Update());
gECP.StoreData(ECPNodes::ECPN_HITBOX_UPDATE, p_begin);
}
switch (m_iClassID) {
@ -107,12 +110,6 @@ void CachedEntity::Update(int idx) {
m_lLastSeen = 0;
m_lSeenTicks = 0;*/
if (PERFORMANCE_HIGH) {
m_bIsVisible = IsEntityVectorVisible(this, m_vecOrigin);
} else {
SAFE_CALL(m_bIsVisible = IsVisible());
}
if (CE_BAD(g_pLocalPlayer->entity)) return;
if (m_Type == EntityType::ENTITY_PROJECTILE) {
@ -127,18 +124,13 @@ void CachedEntity::Update(int idx) {
delete m_pPlayerInfo;
m_pPlayerInfo = 0;
}
if (PERFORMANCE_HIGH) {
if (IsEntityVisible(this, 0) || IsEntityVisible(this, 14)) {
m_bIsVisible = true;
}
}
m_pPlayerInfo = new player_info_s;
interfaces::engineClient->GetPlayerInfo(m_IDX, m_pPlayerInfo);
m_iTeam = CE_INT(this, netvar.iTeamNum); // TODO
m_bEnemy = (m_iTeam != g_pLocalPlayer->team);
m_iHealth = CE_INT(this, netvar.iHealth);
m_iMaxHealth = g_pPlayerResource->GetMaxHealth(this);
if (m_bIsVisible) {
if (IsVisible()) {
m_lLastSeen = 0;
m_lSeenTicks++;
} else {
@ -151,7 +143,7 @@ void CachedEntity::Update(int idx) {
m_bEnemy = (m_iTeam != g_pLocalPlayer->team);
m_iHealth = CE_INT(this, netvar.iBuildingHealth);
m_iMaxHealth = CE_INT(this, netvar.iBuildingMaxHealth);
if (m_bIsVisible) {
if (IsVisible()) {
m_lLastSeen = 0;
m_lSeenTicks++;
} else {
@ -160,10 +152,15 @@ void CachedEntity::Update(int idx) {
}
}
#if ENTITY_CACHE_PROFILER == true
gECP.StoreData(ECPN_UPDATE, p_begin);
#endif
SEGV_END_INFO("Updating entity")
}
bool CachedEntity::IsVisible() {
long p_begin = gECP.CurrentTime();
if (m_bVisCheckComplete) return m_bAnyHitboxVisible;
bool vischeck0 = false;
@ -172,6 +169,7 @@ bool CachedEntity::IsVisible() {
if (vischeck0) {
m_bAnyHitboxVisible = true;
m_bVisCheckComplete = true;
gECP.StoreData(ECPN_VISCHECK, p_begin);
return true;
}
@ -181,10 +179,11 @@ bool CachedEntity::IsVisible() {
if (vischeck) {
m_bAnyHitboxVisible = true;
m_bVisCheckComplete = true;
gECP.StoreData(ECPN_VISCHECK, p_begin);
return true;
}
}
gECP.StoreData(ECPN_VISCHECK, p_begin);
m_bAnyHitboxVisible = false;
m_bVisCheckComplete = true;
@ -192,9 +191,6 @@ bool CachedEntity::IsVisible() {
}
void CachedEntity::AddESPString(Color color, Color background, const char* fmt, ...) {
#if ENTITY_CACHE_PROFILER == true
gEntityCache.m_nStringsAdded++;
#endif
if (m_Strings[m_nESPStrings].m_String) {
delete m_Strings[m_nESPStrings].m_String;
}
@ -219,9 +215,6 @@ void CachedEntity::AddESPString(Color color, Color background, const char* fmt,
}
ESPStringCompound CachedEntity::GetESPString(int idx) {
#if ENTITY_CACHE_PROFILER == true
gEntityCache.m_nStringsQueued++;
#endif
if (idx >= 0 && idx < m_nESPStrings) {
return m_Strings[idx];
} else {
@ -238,7 +231,6 @@ matrix3x4_t* CachedEntity::GetBones() {
EntityCache::EntityCache() {
m_pArray = new CachedEntity[4096]();
m_lLastLog = 0;
}
EntityCache::~EntityCache() {
@ -247,6 +239,9 @@ EntityCache::~EntityCache() {
}
void EntityCache::Update() {
#if ENTITY_CACHE_PROFILER == true
long p_begin = gECP.CurrentTime();
#endif
m_nMax = interfaces::entityList->GetHighestEntityIndex();
for (int i = 0; i < m_nMax && i < 4096; i++) {
//logging::Info("Updating %i", i);
@ -254,37 +249,65 @@ void EntityCache::Update() {
//logging::Info("Back!");
}
#if ENTITY_CACHE_PROFILER == true
m_nUpdates++;
if (time(0) != m_lLastLog) {
m_lLastLog = time(0);
if (g_vEntityCacheProfiling && g_vEntityCacheProfiling->GetBool()) {
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 HBPU=%i",
m_nQueues / m_nUpdates,
m_nStringsQueued / m_nUpdates,
m_nStringsAdded / m_nUpdates,
m_nRawEntityAccesses / m_nUpdates,
m_nHitboxQueued / m_nUpdates);
m_nUpdates = 0;
m_nQueues = 0;
m_nStringsQueued = 0;
m_nStringsAdded = 0;
m_nRawEntityAccesses = 0;
m_nHitboxQueued = 0;
}
}
if (g_vEntityCacheProfiling->GetBool()) gECP.DoLog();
#endif
}
EntityCacheProfiling::EntityCacheProfiling() {
m_DataAvg = new long[ECPNodes::ECPN_TOTAL];
m_DataMax = new long[ECPNodes::ECPN_TOTAL];
Reset();
m_DataAvgAmount = 0;
m_nLastLog = 0;
}
EntityCacheProfiling::~EntityCacheProfiling() {
delete [] m_DataAvg;
delete [] m_DataMax;
}
long EntityCacheProfiling::CurrentTime() {
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return ts.tv_nsec;
}
void EntityCacheProfiling::Reset() {
for (int i = 0; i < ECPNodes::ECPN_TOTAL; i++) {
m_DataAvg[i] = 0;
m_DataMax[i] = 0;
}
m_nLastReset = CurrentTime();
m_DataAvgAmount = 0;
}
void EntityCacheProfiling::StoreData(int id, long begin) {
m_DataAvg[id] = (m_DataAvg[id] + (CurrentTime() - begin)) / 2;
if ((CurrentTime() - begin) > m_DataMax[id]) {
m_DataMax[id] = (CurrentTime() - begin);
}
}
void EntityCacheProfiling::DoLog() {
//if (CurrentTime() - m_nLastReset > 5000000000l) Reset();
if (time(0) - m_nLastLog > 2) {
logging::Info("[ECP] AVG: U:%lu (%.1f%%) | H:%lu (%.1f%%) | V:%lu (%.1f%%)",
m_DataAvg[ECPNodes::ECPN_UPDATE], 100.0f * (float)((float)m_DataAvg[ECPNodes::ECPN_UPDATE] / (float)m_DataAvg[ECPNodes::ECPN_UPDATE]),
m_DataAvg[ECPNodes::ECPN_HITBOX_UPDATE], 100.0f * (float)((float)m_DataAvg[ECPNodes::ECPN_HITBOX_UPDATE] / (float)m_DataAvg[ECPNodes::ECPN_UPDATE]),
m_DataAvg[ECPNodes::ECPN_VISCHECK], 100.0f * (float)((float)m_DataAvg[ECPNodes::ECPN_VISCHECK] / (float)m_DataAvg[ECPNodes::ECPN_UPDATE])
);
logging::Info("[ECP] MAX: U:%lu | H:%lu | V:%lu", m_DataMax[ECPNodes::ECPN_UPDATE], m_DataMax[ECPNodes::ECPN_HITBOX_UPDATE], m_DataMax[ECPNodes::ECPN_UPDATE]);
m_nLastLog = time(0);
}
}
CachedEntity* EntityCache::GetEntity(int idx) {
if (idx < 0 || idx >= m_nMax) {
logging::Info("Requested invalid entity: %i max %i", idx, m_nMax);
}
//logging::Info("Request entity: %i, 0x%08x", idx, m_pArray[idx].m_pEntity);
#if ENTITY_CACHE_PROFILER == true
m_nQueues++;
#endif
return &(m_pArray[idx]);
}
EntityCacheProfiling gECP;
EntityCache gEntityCache;

View File

@ -129,7 +129,6 @@ public:
int m_iMaxHealth;
int m_iHealth;
bool m_bIsVisible;
unsigned long m_lSeenTicks;
unsigned long m_lLastSeen;
@ -162,18 +161,33 @@ public:
CachedEntity* GetEntity(int idx);
CachedEntity* m_pArray;
// Profiling variables.
int m_nRawEntityAccesses;
int m_nQueues;
int m_nUpdates;
int m_nStringsAdded;
int m_nStringsQueued;
int m_nHitboxQueued;
unsigned long m_lLastLog;
int m_nMax;
};
enum ECPNodes {
ECPN_UPDATE,
ECPN_HITBOX_UPDATE,
ECPN_VISCHECK,
ECPN_TOTAL
};
class EntityCacheProfiling {
public:
EntityCacheProfiling();
~EntityCacheProfiling();
void Reset();
long CurrentTime();
void StoreData(int id, long time);
void DoLog();
long m_nLastReset;
long m_nLastLog;
long* m_DataAvg;
long m_DataAvgAmount;
long* m_DataMax;
};
extern EntityCacheProfiling gECP;
extern EntityCache gEntityCache;
#if ENTITY_CACHE_PROFILER == true

View File

@ -65,7 +65,6 @@ bool EntityHitboxCache::VisibilityCheck(int id) {
}
CachedHitbox* EntityHitboxCache::GetHitbox(int id) {
gEntityCache.m_nHitboxQueued++;
if (id < 0 || id >= m_nNumHitboxes) return 0;
if (!m_bSuccess) return 0;
if (!m_CacheValidationFlags[id]) {

View File

@ -50,6 +50,7 @@
#include "cvwrapper.h"
#include "sdk.h"
#include "vfunc.h"
#include "copypasted/CSignature.h"
#include "copypasted/Netvar.h"
#include "CDumper.h"
@ -212,21 +213,25 @@ bool Hk_SendNetMsg(void* thisptr, INetMessage& msg, bool bForceReliable = false,
typedef void(Shutdown_t)(void*, const char*);
void Hk_Shutdown(void* thisptr, const char* reason) {
SEGV_BEGIN;
const char* new_reason;
if (g_Settings.sDisconnectMsg->m_StringLength > 3) {
new_reason = g_Settings.sDisconnectMsg->GetString();
if (g_Settings.bHackEnabled->GetBool()) {
const char* new_reason = reason;
if (g_Settings.sDisconnectMsg->m_StringLength > 3) {
new_reason = g_Settings.sDisconnectMsg->GetString();
}
((Shutdown_t*)hooks::hkNetChannel->GetMethod(hooks::offShutdown))(thisptr, new_reason);
} else {
new_reason = reason;
((Shutdown_t*)hooks::hkNetChannel->GetMethod(hooks::offShutdown))(thisptr, reason);
}
((Shutdown_t*)hooks::hkNetChannel->GetMethod(hooks::offShutdown))(thisptr, new_reason);
SEGV_END;
}
bool hack::Hk_CreateMove(void* thisptr, float inputSample, CUserCmd* cmd) {
SEGV_BEGIN;
bool ret = ((CreateMove_t*)hooks::hkClientMode->GetMethod(hooks::offCreateMove))(thisptr, inputSample, cmd);
if (!g_Settings.bHackEnabled->GetBool()) return ret;
if (!interfaces::engineClient->IsInGame()) {
@ -234,6 +239,8 @@ bool hack::Hk_CreateMove(void* thisptr, float inputSample, CUserCmd* cmd) {
return true;
}
PROF_BEGIN();
INetChannel* ch = (INetChannel*)interfaces::engineClient->GetNetChannelInfo();
if (ch && !hooks::IsHooked((void*)((uintptr_t)ch))) {
logging::Info("Hooking INetChannel!");
@ -259,11 +266,14 @@ bool hack::Hk_CreateMove(void* thisptr, float inputSample, CUserCmd* cmd) {
if (g_Settings.bInvalid) {
gEntityCache.Invalidate();
}
PROF_BEGIN();
SAFE_CALL(gEntityCache.Update());
PROF_END("Entity Cache updating");
SAFE_CALL(g_pPlayerResource->Update());
SAFE_CALL(g_pLocalPlayer->Update());
if (CE_GOOD(g_pLocalPlayer->entity)) {
g_pLocalPlayer->v_OrigViewangles = cmd->viewangles;
PROF_BEGIN();
SAFE_CALL(CREATE_MOVE(Bunnyhop));
//RunEnginePrediction(g_pLocalPlayer->entity, cmd);
SAFE_CALL(CREATE_MOVE(ESP));
@ -279,6 +289,7 @@ bool hack::Hk_CreateMove(void* thisptr, float inputSample, CUserCmd* cmd) {
SAFE_CALL(CREATE_MOVE(Misc));
SAFE_CALL(CREATE_MOVE(Triggerbot));
SAFE_CALL(CREATE_MOVE(HuntsmanCompensation));
PROF_END("Hacks processing");
if (time_replaced) interfaces::gvars->curtime = curtime_old;
}
/*for (IHack* i_hack : hack::hacks) {
@ -302,6 +313,8 @@ bool hack::Hk_CreateMove(void* thisptr, float inputSample, CUserCmd* cmd) {
if (cmd)
last_angles = cmd->viewangles;
PROF_END("CreateMove");
return ret;
SEGV_END;
@ -312,36 +325,40 @@ void hack::Hk_FrameStageNotify(void* thisptr, int stage) {
SEGV_BEGIN;
//logging::Info("FrameStageNotify %i", stage);
// Ambassador to festive ambassador changer. simple.
if (g_pLocalPlayer->weapon) {
int defidx = CE_INT(g_pLocalPlayer->weapon, netvar.iItemDefinitionIndex);
if (defidx == 61) {
CE_INT(g_pLocalPlayer->weapon, netvar.iItemDefinitionIndex) = 1006;
if (g_Settings.bHackEnabled->GetBool()) {
if (CE_GOOD(g_pLocalPlayer->weapon)) {
int defidx = CE_INT(g_pLocalPlayer->weapon, netvar.iItemDefinitionIndex);
if (defidx == 61) {
CE_INT(g_pLocalPlayer->weapon, netvar.iItemDefinitionIndex) = 1006;
}
}
}
if (g_Settings.bThirdperson->GetBool() && g_pLocalPlayer->entity) {
CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 1;
}
if (stage == 5 && g_Settings.bShowAntiAim->GetBool() && interfaces::iinput->CAM_IsThirdPerson()) {
if (g_pLocalPlayer->entity) {
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 4) = last_angles.x;
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 8) = last_angles.y;
if (g_Settings.bThirdperson->GetBool() && g_pLocalPlayer->entity) {
CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 1;
}
if (stage == 5 && g_Settings.bShowAntiAim->GetBool() && interfaces::iinput->CAM_IsThirdPerson()) {
if (g_pLocalPlayer->entity) {
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 4) = last_angles.x;
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 8) = last_angles.y;
}
}
}
((FrameStageNotify_t*)hooks::hkClient->GetMethod(hooks::offFrameStageNotify))(thisptr, stage);
if (stage == 5 && g_Settings.bNoFlinch->GetBool()) {
static Vector oldPunchAngles = Vector();
Vector punchAngles = CE_VECTOR(g_pLocalPlayer->entity, netvar.vecPunchAngle);
QAngle viewAngles;
interfaces::engineClient->GetViewAngles(viewAngles);
viewAngles -= VectorToQAngle(punchAngles - oldPunchAngles);
oldPunchAngles = punchAngles;
interfaces::engineClient->SetViewAngles(viewAngles);
}
if (g_Settings.bHackEnabled->GetBool()) {
if (stage == 5 && g_Settings.bNoFlinch->GetBool()) {
static Vector oldPunchAngles = Vector();
Vector punchAngles = CE_VECTOR(g_pLocalPlayer->entity, netvar.vecPunchAngle);
QAngle viewAngles;
interfaces::engineClient->GetViewAngles(viewAngles);
viewAngles -= VectorToQAngle(punchAngles - oldPunchAngles);
oldPunchAngles = punchAngles;
interfaces::engineClient->SetViewAngles(viewAngles);
}
if (g_Settings.bNoZoom->GetBool()) {
if (g_pLocalPlayer->entity) {
//g_pLocalPlayer->bWasZoomed = NET_INT(g_pLocalPlayer->entity, netvar.iCond) & cond::zoomed;
CE_INT(g_pLocalPlayer->entity, netvar.iCond) = CE_INT(g_pLocalPlayer->entity, netvar.iCond) &~ cond::zoomed;
if (g_Settings.bNoZoom->GetBool()) {
if (g_pLocalPlayer->entity) {
//g_pLocalPlayer->bWasZoomed = NET_INT(g_pLocalPlayer->entity, netvar.iCond) & cond::zoomed;
CE_INT(g_pLocalPlayer->entity, netvar.iCond) = CE_INT(g_pLocalPlayer->entity, netvar.iCond) &~ cond::zoomed;
}
}
}
SEGV_END;
@ -389,12 +406,6 @@ void hack::CC_Cat(const CCommand& args) {
interfaces::cvar->ConsoleColorPrintf(colors::red, "[DEVELOPER BUILD]\n");
}
typedef bool(HandleInputEvent_t)(IMatSystemSurface* thisptr, const InputEvent_t& event);
bool hk_HandleInputEvent(IMatSystemSurface* thisptr, const InputEvent_t& event) {
//logging::Info("Handling event %u [%u]", event.m_nType, event.m_nData);
return ((HandleInputEvent_t*)hooks::hkMatSurface->GetMethod(hooks::offHandleInputEvent))(thisptr, event);
}
void hack::Initialize() {
logging::Initialize();
prctl(PR_SET_DUMPABLE,0,42,42,42);
@ -487,6 +498,7 @@ void hack::Shutdown() {
if (hooks::hkClientMode) hooks::hkClientMode->Kill();
if (hooks::hkClient) hooks::hkClient->Kill();
if (hooks::hkMatSurface) hooks::hkMatSurface->Kill();
if (hooks::hkNetChannel) hooks::hkNetChannel->Kill();
for (IHack* i_hack : hack::hacks) {
delete i_hack;
}

View File

@ -258,9 +258,9 @@ bool IsEntityVectorVisible(CachedEntity* entity, Vector endpos) {
Ray_t ray;
trace::g_pFilterDefault->SetSelf(RAW_ENT(g_pLocalPlayer->entity));
ray.Init(g_pLocalPlayer->v_Eye, endpos);
interfaces::trace->TraceRay(ray, 0x4200400B, trace::g_pFilterDefault, &trace_object);
interfaces::trace->TraceRay(ray, MASK_SHOT_HULL, trace::g_pFilterDefault, &trace_object);
if (trace_object.m_pEnt) {
return (((IClientEntity*)trace_object.m_pEnt)->entindex()) == entity->m_IDX;
return (((IClientEntity*)trace_object.m_pEnt)) == RAW_ENT(entity);
} else return false;
}
@ -417,7 +417,7 @@ weaponmode GetWeaponMode(CachedEntity* player) {
// TODO FIX this function
bool GetProjectileData(CachedEntity* weapon, float& speed, float& gravity) {
if (!CE_BAD(weapon)) return false;
if (CE_BAD(weapon)) return false;
float rspeed = 0.0f;
float rgrav = 0.0f;
typedef float(GetProjectileData)(IClientEntity*);
@ -435,8 +435,10 @@ bool GetProjectileData(CachedEntity* weapon, float& speed, float& gravity) {
rgrav = 0.5f;
break;
case ClassID::CTFCompoundBow: {
rspeed = ((GetProjectileData*) *(*(const void ***) weapon + 527))(RAW_ENT(weapon));
rgrav = ((GetProjectileData*) *(*(const void ***) weapon + 528))(RAW_ENT(weapon));
rspeed = vfunc<GetProjectileData*>(RAW_ENT(weapon), 527)(RAW_ENT(weapon));
rgrav = vfunc<GetProjectileData*>(RAW_ENT(weapon), 528)(RAW_ENT(weapon));
//rspeed = ((GetProjectileData*) *(*(const void ***) weapon + 527))(RAW_ENT(weapon));
//rgrav = ((GetProjectileData*) *(*(const void ***) weapon + 528))(RAW_ENT(weapon));
} break;
case ClassID::CTFBat_Wood:
rspeed = 3000.0f;
@ -492,7 +494,7 @@ bool IsVectorVisible(Vector origin, Vector target) {
Ray_t ray;
vec_filter->SetSelf(RAW_ENT(g_pLocalPlayer->entity));
ray.Init(origin, target);
interfaces::trace->TraceRay(ray, 0x4200400B, vec_filter, &trace_visible);
interfaces::trace->TraceRay(ray, MASK_SHOT_HULL, vec_filter, &trace_visible);
float dist2 = origin.DistToSqr(trace_visible.endpos);
float dist1 = origin.DistToSqr(target);
//logging::Info("Target: %.1f, %.1f, %.1f; ENDPOS: %.1f, %.1f, %.1f", target.x, target.y, target.z, trace_visible.endpos.x, trace_visible.endpos.y, trace_visible.endpos.z);
@ -633,7 +635,7 @@ bool IsEntityVisiblePenetration(CachedEntity* entity, int hb) {
return false;
}
ray.Init(g_pLocalPlayer->v_Origin + g_pLocalPlayer->v_ViewOffset, hit);
interfaces::trace->TraceRay(ray, 0x4200400B, trace::g_pFilterPenetration, &trace_visible);
interfaces::trace->TraceRay(ray, MASK_SHOT_HULL, trace::g_pFilterPenetration, &trace_visible);
bool s = false;
if (trace_visible.m_pEnt) {
s = ((IClientEntity*)trace_visible.m_pEnt) == RAW_ENT(entity);

View File

@ -52,7 +52,8 @@ void hooks::VMTHook::Init(void* inst, unsigned int offset) {
}
void hooks::VMTHook::Kill() {
*vmt = oldvmt;
if (vmt)
*vmt = oldvmt;
vmt = 0;
free(array);
array = 0;

View File

@ -0,0 +1,14 @@
/*
* CreateMove.cpp
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/
#include "CreateMove.h"
#include "../common.h"
bool CreateMove_hook(void* thisptr, float f, CUserCmd* cmd) {
}

View File

@ -0,0 +1,16 @@
/*
* CreateMove.h
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/
#ifndef CREATEMOVE_H_
#define CREATEMOVE_H_
class CUserCmd;
typedef bool(CreateMove_t)(void*, float, CUserCmd*);
bool CreateMove_hook(void*, float, CUserCmd*);
#endif /* CREATEMOVE_H_ */

View File

@ -0,0 +1,10 @@
/*
* PaintTraverse.cpp
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/

View File

@ -0,0 +1,14 @@
/*
* PaintTraverse.h
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/
#ifndef PAINTTRAVERSE_H_
#define PAINTTRAVERSE_H_
typedef void(PaintTraverse_t)(void*, unsigned int, bool, bool);
void PaintTraverse_hook(void*, unsigned int, bool, bool);
#endif /* PAINTTRAVERSE_H_ */

15
cathook/src/hooks/hooks.h Normal file
View File

@ -0,0 +1,15 @@
/*
* hooks.h
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/
#ifndef HOOKS_H_
#define HOOKS_H_
#include "CreateMove.h"
#include "PaintTraverse.h"
#include "others.h"
#endif /* HOOKS_H_ */

View File

@ -0,0 +1,10 @@
/*
* others.cpp
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/

View File

@ -0,0 +1,26 @@
/*
* others.h
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/
#ifndef OTHERS_H_
#define OTHERS_H_
class INetMessage;
class CViewSetup;
typedef bool(CanPacket_t)(void*);
typedef int(IN_KeyEvent_t)(void*, int, int, const char*);
typedef bool(SendNetMsg_t)(void*, INetMessage&, bool, bool);
typedef void(Shutdown_t)(void*, const char*);
typedef void(OverrideView_t)(void*, CViewSetup*);
bool CanPacket_hook(void*);
int IN_KeyEvent_hook(void*, int, int, const char*);
bool SendNetMsg_hook(void*, INetMessage&, bool, bool);
void Shutdown_hook(void*, const char*);
void OverrideView_hook(void*, CViewSetup*);
#endif /* OTHERS_H_ */

View File

@ -46,7 +46,7 @@ Vector ProjectilePrediction(CachedEntity* ent, int hb, float speed, float gravit
bool ground = (flags & (1 << 0));
if (!ground) result.z -= ttt * ttt * 400;
result += vel * ttt;
if (oz - result.z > dtg) { result.z = oz - dtg; }
if (!ground) if (oz - result.z > dtg) { result.z = oz - dtg; }
result.z += (400 * ttt * ttt * gravitymod);
// S = at^2/2 ; t = sqrt(2S/a)
return result;

View File

@ -11,7 +11,7 @@
#include "sdk.h"
int g_ProfilerDepth = 0;
time_t g_ProfilerSections[MAX_PROFILER_SECTIONS];
long g_ProfilerSections[MAX_PROFILER_SECTIONS];
void PROFILER_BeginSection() {
if (!ENABLE_PROFILER) return;
@ -20,7 +20,9 @@ void PROFILER_BeginSection() {
return;
}
g_ProfilerDepth++;
g_ProfilerSections[g_ProfilerDepth] = time(0);
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
g_ProfilerSections[g_ProfilerDepth] = ts.tv_nsec;
}
void PROFILER_EndSection(char* name) {
@ -29,7 +31,10 @@ void PROFILER_EndSection(char* name) {
logging::Info("Profiler underflow!");
return;
}
if (g_ProfilerDepth <= PROFILER_OUTPUT_DEPTH && g_Settings.bProfiler->GetBool())
logging::Info("[PROF] %s took %ims!", name, (time(0) - g_ProfilerSections[g_ProfilerDepth]));
if (g_ProfilerDepth <= PROFILER_OUTPUT_DEPTH && g_Settings.bProfiler->GetBool()) {
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
logging::Info("[PROF] %s took %ldus!", name, (ts.tv_nsec - g_ProfilerSections[g_ProfilerDepth]));
}
g_ProfilerDepth--;
}

View File

@ -13,7 +13,7 @@
// TODO this whole profiler thing could be done a lot better..
#define ENABLE_PROFILER false
#define PROFILER_OUTPUT_DEPTH 1
#define PROFILER_OUTPUT_DEPTH 7
#define MAX_PROFILER_SECTIONS 16
#if ENABLE_PROFILER == true

17
cathook/src/vfunc.h Normal file
View File

@ -0,0 +1,17 @@
/*
* vfunc.h
*
* Created on: Jan 8, 2017
* Author: nullifiedcat
*/
#ifndef VFUNC_H_
#define VFUNC_H_
template<typename F>
inline F vfunc(void* thisptr, uintptr_t idx, uintptr_t offset = 0) {
void** vmt = *reinterpret_cast<void***>((uintptr_t)thisptr + offset);
return reinterpret_cast<F>((vmt)[idx]);
}
#endif /* VFUNC_H_ */