common.hpp and include refactor

This commit is contained in:
TotallyNotElite 2019-10-17 10:29:58 +02:00
parent c84488478a
commit 749f6d8623
26 changed files with 358 additions and 376 deletions

View File

@ -7,69 +7,16 @@
#pragma once #pragma once
#include "common.hpp" #include "mathlib/vector.h"
#include <core/logging.hpp> #include "entitycache.hpp"
namespace angles namespace angles
{ {
struct angle_data_s struct angle_data_s
{ {
static constexpr size_t count = 16; static constexpr size_t count = 16;
inline void push(const Vector &angle) void push(const Vector &angle);
{ float deviation(int steps) const;
if (not angle.x and not angle.y)
return;
good = true;
angles[angle_index] = angle;
if (++angle_index >= count)
{
angle_index = 0;
}
/*if (angle_count > 0) {
int ai = angle_index - 2;
if (ai < 0) ai = count - 1;
float dx = std::abs(angles[ai].x - angle.x);
float dy = std::abs(angles[ai].y - angle.y);
if (sqrt(dx * dx + dy * dy) > 45.0f) {
//logging::Info("%.2f %.2f %.2f", dx, dy, sqrt(dx * dx + dy *
dy));
}
}*/
if (angle_count < count)
{
angle_count++;
}
}
inline float deviation(int steps) const
{
int j = angle_index - 2;
int k = j + 1;
float hx = 0, hy = 0;
for (int i = 0; i < steps && i < angle_count; i++)
{
if (j < 0)
j = count + j;
if (k < 0)
k = count + k;
float dev_x = std::abs(angles[k].x - angles[j].x);
float dev_y = std::abs(angles[k].y - angles[j].y);
if (dev_x > hx)
hx = dev_x;
if (dev_y > hy)
hy = dev_y;
// logging::Info("1: %.2f %.2f | 2: %.2f %.2f | dev: %.2f",
// angles[k].x, angles[k].y, angles[j].x, angles[j].y, sqrt(dev_x *
// dev_x + dev_y * dev_y));
--j;
--k;
}
if (hy > 180)
hy = 360 - hy;
return sqrt(hx * hx + hy * hy);
}
Vector angles[count]{}; Vector angles[count]{};
bool good{ false }; bool good{ false };
@ -80,18 +27,6 @@ struct angle_data_s
extern angle_data_s data_[32]; extern angle_data_s data_[32];
void Update(); void Update();
angle_data_s &data_idx(int index);
inline angle_data_s &data_idx(int index) angle_data_s &data(const CachedEntity *entity);
{
if (index < 1 || index > 32)
{
throw std::out_of_range("Angle table entity index out of range");
}
return data_[index - 1];
}
inline angle_data_s &data(const CachedEntity *entity)
{
return data_idx(entity->m_IDX);
}
} // namespace angles } // namespace angles

View File

@ -11,52 +11,31 @@
#include "config.h" #include "config.h"
#include <emmintrin.h>
#include <vector> #include <vector>
#include <bitset>
#include <string> #include <string>
#include <array> #include <array>
#include <cassert>
#include <functional>
#include <mutex> #include <mutex>
#include <atomic>
#include <cmath> #include <cmath>
#include <memory> #include <memory>
#include <iomanip>
#include <list>
#include <fstream> #include <fstream>
#include <set>
#include <unordered_map> #include <unordered_map>
#include <algorithm> #include <algorithm>
#include <csignal>
#include <sys/prctl.h>
#include <unistd.h> #include <unistd.h>
#include <link.h> #include <link.h>
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
#include <dlfcn.h>
#include <elf.h>
#include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <pwd.h>
#include <cstring> #include <cstring>
#include <cstdio>
#include <cassert>
#include "timer.hpp" #include "timer.hpp"
#include "averager.hpp"
#include "core/macros.hpp" #include "core/macros.hpp"
#if ENABLE_VISUALS #if ENABLE_VISUALS
#include <visual/colors.hpp> #include <visual/colors.hpp>
#include <visual/drawing.hpp> #include <visual/drawing.hpp>
#include "visual/fidgetspinner.hpp"
#include <visual/EffectGlow.hpp>
#include <visual/atlas.hpp> #include <visual/atlas.hpp>
#include <visual/EffectChams.hpp>
#include <visual/drawmgr.hpp>
#endif #endif
#include "core/profiler.hpp" #include "core/profiler.hpp"
@ -66,8 +45,6 @@
#include <enums.hpp> #include <enums.hpp>
#include "projlogging.hpp" #include "projlogging.hpp"
#include "velocity.hpp" #include "velocity.hpp"
#include "angles.hpp"
#include "entityhitboxcache.hpp"
#include "globals.h" #include "globals.h"
#include <helpers.hpp> #include <helpers.hpp>
#include "playerlist.hpp" #include "playerlist.hpp"
@ -75,7 +52,6 @@
#include <localplayer.hpp> #include <localplayer.hpp>
#include <conditions.hpp> #include <conditions.hpp>
#include <core/logging.hpp> #include <core/logging.hpp>
#include <targethelper.hpp>
#include "playerresource.h" #include "playerresource.h"
#include "sdk/usercmd.hpp" #include "sdk/usercmd.hpp"
#include "trace.hpp" #include "trace.hpp"
@ -84,7 +60,6 @@
#include "core/vfunc.hpp" #include "core/vfunc.hpp"
#include "hooks.hpp" #include "hooks.hpp"
#include <prediction.hpp> #include <prediction.hpp>
#include <conditions.hpp>
#include <itemtypes.hpp> #include <itemtypes.hpp>
#include <chatstack.hpp> #include <chatstack.hpp>
#include "textfile.hpp" #include "textfile.hpp"
@ -92,7 +67,6 @@
#include "tfmm.hpp" #include "tfmm.hpp"
#include "hooks/HookedMethods.hpp" #include "hooks/HookedMethods.hpp"
#include "classinfo/classinfo.hpp" #include "classinfo/classinfo.hpp"
#include "votelogger.hpp"
#include "crits.hpp" #include "crits.hpp"
#include "textmode.hpp" #include "textmode.hpp"
#include "core/sharedobj.hpp" #include "core/sharedobj.hpp"

View File

@ -10,7 +10,6 @@
#include "entityhitboxcache.hpp" #include "entityhitboxcache.hpp"
#include "averager.hpp" #include "averager.hpp"
#include <mathlib/vector.h> #include <mathlib/vector.h>
#include <mathlib/mathlib.h>
#include <icliententity.h> #include <icliententity.h>
#include <icliententitylist.h> #include <icliententitylist.h>
#include <cdll_int.h> #include <cdll_int.h>
@ -22,7 +21,6 @@
#include "playerresource.h" #include "playerresource.h"
#include "globals.h" #include "globals.h"
#include "classinfo/classinfo.hpp" #include "classinfo/classinfo.hpp"
#include "classinfo/tf2.gen.hpp"
#include "client_class.h" #include "client_class.h"
struct matrix3x4_t; struct matrix3x4_t;

View File

@ -7,13 +7,11 @@
#pragma once #pragma once
#include <mathlib/vector.h>
#include <mathlib/mathlib.h>
#include <cdll_int.h> #include <cdll_int.h>
#include <entitycache.hpp>
#include <studio.h> #include <studio.h>
#include <stdexcept> #include <stdexcept>
// Forward declaration from entitycache.hpp
class CachedEntity; class CachedEntity;
#define CACHE_MAX_HITBOXES 64 #define CACHE_MAX_HITBOXES 64

View File

@ -2,7 +2,6 @@
#include "core/profiler.hpp" #include "core/profiler.hpp"
#include "functional" #include "functional"
#include <set>
#include <array> #include <array>
namespace EC namespace EC

View File

@ -1,7 +1,10 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <CNavFile.h> #include "mathlib/vector.h"
class CNavFile;
class CNavArea;
namespace nav namespace nav
{ {

View File

@ -1,15 +0,0 @@
/*
* fidgetspinner.hpp
*
* Created on: Jul 4, 2017
* Author: nullifiedcat
*/
#pragma once
#include <visual/atlas.hpp>
#include "common.hpp"
extern std::array<textures::sprite, 4> spinner_states;
void InitSpinner();
void DrawSpinner();

View File

@ -4,6 +4,7 @@
* Created on: Jun 5, 2017 * Created on: Jun 5, 2017
* Author: nullifiedcat * Author: nullifiedcat
*/ */
#include "common.hpp"
#include "angles.hpp" #include "angles.hpp"
namespace angles namespace angles
@ -11,6 +12,77 @@ namespace angles
angle_data_s data_[32]; angle_data_s data_[32];
void angle_data_s::push(const Vector &angle)
{
if (not angle.x and not angle.y)
return;
good = true;
angles[angle_index] = angle;
if (++angle_index >= count)
{
angle_index = 0;
}
/*if (angle_count > 0) {
int ai = angle_index - 2;
if (ai < 0) ai = count - 1;
float dx = std::abs(angles[ai].x - angle.x);
float dy = std::abs(angles[ai].y - angle.y);
if (sqrt(dx * dx + dy * dy) > 45.0f) {
//logging::Info("%.2f %.2f %.2f", dx, dy, sqrt(dx * dx + dy *
dy));
}
}*/
if (angle_count < count)
{
angle_count++;
}
}
float angle_data_s::deviation(int steps) const
{
int j = angle_index - 2;
int k = j + 1;
float hx = 0, hy = 0;
for (int i = 0; i < steps && i < angle_count; i++)
{
if (j < 0)
j = count + j;
if (k < 0)
k = count + k;
float dev_x = std::abs(angles[k].x - angles[j].x);
float dev_y = std::abs(angles[k].y - angles[j].y);
if (dev_x > hx)
hx = dev_x;
if (dev_y > hy)
hy = dev_y;
// logging::Info("1: %.2f %.2f | 2: %.2f %.2f | dev: %.2f",
// angles[k].x, angles[k].y, angles[j].x, angles[j].y, sqrt(dev_x *
// dev_x + dev_y * dev_y));
--j;
--k;
}
if (hy > 180)
hy = 360 - hy;
return sqrt(hx * hx + hy * hy);
}
angle_data_s &data_idx(int index)
{
if (index < 1 || index > 32)
{
throw std::out_of_range("Angle table entity index out of range");
}
return data_[index - 1];
}
angle_data_s &data(const CachedEntity *entity)
{
return data_idx(entity->m_IDX);
}
void Update() void Update()
{ {
for (int i = 1; i < 33; i++) for (int i = 1; i < 33; i++)

View File

@ -6,6 +6,7 @@
*/ */
#include "common.hpp" #include "common.hpp"
#include <bitset>
static CatCommand dump_conditions("debug_conditions", "Shows conditions for entity #", [](const CCommand &args) { static CatCommand dump_conditions("debug_conditions", "Shows conditions for entity #", [](const CCommand &args) {
int id = atoi(args.Arg(1)); int id = atoi(args.Arg(1));

View File

@ -17,6 +17,8 @@
#include "hack.hpp" #include "hack.hpp"
#include "common.hpp" #include "common.hpp"
#include "MiscTemporary.hpp" #include "MiscTemporary.hpp"
#include <link.h>
#include <pwd.h>
#include <hacks/hacklist.hpp> #include <hacks/hacklist.hpp>
#if EXTERNAL_DRAWING #if EXTERNAL_DRAWING
@ -354,26 +356,8 @@ free(logname);*/
playerlist::Load(); playerlist::Load();
#if ENABLE_VISUALS #if ENABLE_VISUALS
InitStrings(); InitStrings();
#ifndef FEATURE_EFFECTS_DISABLED
if (g_ppScreenSpaceRegistrationHead && g_pScreenSpaceEffects)
{
effect_chams::g_pEffectChams = new CScreenSpaceEffectRegistration("_cathook_chams", &effect_chams::g_EffectChams);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_chams");
effect_glow::g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &effect_glow::g_EffectGlow);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow");
}
logging::Info("SSE enabled..");
#endif
#endif /* TEXTMODE */ #endif /* TEXTMODE */
#if ENABLE_VISUALS
#ifndef FEATURE_FIDGET_SPINNER_ENABLED
InitSpinner();
logging::Info("Initialized Fidget Spinner");
#endif
#endif
logging::Info("Clearing initializer stack"); logging::Info("Clearing initializer stack");
while (!init_stack().empty()) while (!init_stack().empty())
{ {

View File

@ -14,6 +14,13 @@
#include <settings/Bool.hpp> #include <settings/Bool.hpp>
#include "common.hpp" #include "common.hpp"
#include "MiscTemporary.hpp" #include "MiscTemporary.hpp"
#include <targethelper.hpp>
#if ENABLE_VISUALS
#ifndef FEATURE_EFFECTS_DISABLED
#include "EffectChams.hpp"
#endif
#endif
namespace hacks::shared::aimbot namespace hacks::shared::aimbot
{ {

View File

@ -12,6 +12,7 @@
#include "common.hpp" #include "common.hpp"
#include "PlayerTools.hpp" #include "PlayerTools.hpp"
#include "hack.hpp" #include "hack.hpp"
#include "angles.hpp"
namespace hacks::shared::anticheat namespace hacks::shared::anticheat
{ {

View File

@ -9,10 +9,8 @@
#include <unistd.h> #include <unistd.h>
#include <regex> #include <regex>
#include <sys/types.h> #include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <link.h>
#include <hacks/AntiAim.hpp> #include <hacks/AntiAim.hpp>
#include <settings/Bool.hpp> #include <settings/Bool.hpp>

View File

@ -9,6 +9,7 @@
#include <hacks/AntiCheat.hpp> #include <hacks/AntiCheat.hpp>
#include <settings/Float.hpp> #include <settings/Float.hpp>
#include "common.hpp" #include "common.hpp"
#include "angles.hpp"
namespace ac::aimbot namespace ac::aimbot
{ {

View File

@ -8,6 +8,7 @@
#include <hacks/AntiCheat.hpp> #include <hacks/AntiCheat.hpp>
#include <settings/Bool.hpp> #include <settings/Bool.hpp>
#include "common.hpp" #include "common.hpp"
#include "angles.hpp"
namespace ac::antiaim namespace ac::antiaim
{ {

View File

@ -13,6 +13,8 @@
#include "CatBot.hpp" #include "CatBot.hpp"
#include "ChatCommands.hpp" #include "ChatCommands.hpp"
#include "MiscTemporary.hpp" #include "MiscTemporary.hpp"
#include <iomanip>
#include "votelogger.hpp"
static settings::Boolean dispatch_log{ "debug.log-dispatch-user-msg", "false" }; static settings::Boolean dispatch_log{ "debug.log-dispatch-user-msg", "false" };
static settings::Boolean chat_filter_enable{ "chat.censor.enable", "false" }; static settings::Boolean chat_filter_enable{ "chat.censor.enable", "false" };

View File

@ -16,10 +16,6 @@ DEFINE_HOOKED_METHOD(LevelShutdown, void, void *this_)
playerlist::Save(); playerlist::Save();
g_Settings.bInvalid = true; g_Settings.bInvalid = true;
chat_stack::Reset(); chat_stack::Reset();
#if ENABLE_VISUALS
effect_glow::g_EffectGlow.Shutdown();
effect_chams::g_EffectChams.Shutdown();
#endif
EC::run(EC::LevelShutdown); EC::run(EC::LevelShutdown);
#if ENABLE_IPC #if ENABLE_IPC
if (ipc::peer) if (ipc::peer)

View File

@ -11,6 +11,7 @@
#include "common.hpp" #include "common.hpp"
#include "hitrate.hpp" #include "hitrate.hpp"
#include "hack.hpp" #include "hack.hpp"
#include "drawmgr.hpp"
extern settings::Boolean die_if_vac; extern settings::Boolean die_if_vac;
static Timer checkmmban{}; static Timer checkmmban{};
namespace hooked_methods namespace hooked_methods

View File

@ -7,6 +7,7 @@
#include <settings/Bool.hpp> #include <settings/Bool.hpp>
#include "HookedMethods.hpp" #include "HookedMethods.hpp"
#include "MiscTemporary.hpp" #include "MiscTemporary.hpp"
#include "votelogger.hpp"
settings::Boolean die_if_vac{ "misc.die-if-vac", "false" }; settings::Boolean die_if_vac{ "misc.die-if-vac", "false" };
static settings::Boolean autoabandon{ "misc.auto-abandon", "false" }; static settings::Boolean autoabandon{ "misc.auto-abandon", "false" };

View File

@ -10,6 +10,7 @@
#include <SDL2/SDL_syswm.h> #include <SDL2/SDL_syswm.h>
#include <menu/menu/Menu.hpp> #include <menu/menu/Menu.hpp>
#include "clip.h" #include "clip.h"
#include "drawmgr.hpp"
static bool swapwindow_init{ false }; static bool swapwindow_init{ false };
static bool init_wminfo{ false }; static bool init_wminfo{ false };

View File

@ -8,6 +8,7 @@
#include <chrono> #include <chrono>
#include "soundcache.hpp" #include "soundcache.hpp"
#include "MiscTemporary.hpp" #include "MiscTemporary.hpp"
#include <CNavFile.h>
namespace nav namespace nav
{ {
@ -21,7 +22,7 @@ static settings::Boolean look{ "misc.pathing.look-at-path", "false" };
static settings::Int stuck_time{ "misc.pathing.stuck-time", "4000" }; static settings::Int stuck_time{ "misc.pathing.stuck-time", "4000" };
static settings::Int unreachable_time{ "misc.pathing.unreachable-time", "1000" }; static settings::Int unreachable_time{ "misc.pathing.unreachable-time", "1000" };
static std::vector<CNavArea*> crumbs; static std::vector<CNavArea *> crumbs;
static Vector startPoint, endPoint; static Vector startPoint, endPoint;
enum ignore_status : uint8_t enum ignore_status : uint8_t
@ -54,10 +55,10 @@ struct ignoredata
Vector GetClosestCornerToArea(CNavArea *CornerOf, const Vector &target) Vector GetClosestCornerToArea(CNavArea *CornerOf, const Vector &target)
{ {
std::array<Vector, 4> corners{ std::array<Vector, 4> corners{
CornerOf->m_nwCorner, // NW CornerOf->m_nwCorner, // NW
CornerOf->m_seCorner, // SE CornerOf->m_seCorner, // SE
{ CornerOf->m_seCorner.x, CornerOf->m_nwCorner.y, CornerOf->m_nwCorner.z },// NE { CornerOf->m_seCorner.x, CornerOf->m_nwCorner.y, CornerOf->m_nwCorner.z }, // NE
{ CornerOf->m_nwCorner.x, CornerOf->m_seCorner.y, CornerOf->m_seCorner.z } // SW { CornerOf->m_nwCorner.x, CornerOf->m_seCorner.y, CornerOf->m_seCorner.z } // SW
}; };
Vector *bestVec = &corners[0], *bestVec2 = bestVec; Vector *bestVec = &corners[0], *bestVec2 = bestVec;
@ -91,243 +92,245 @@ float getZBetweenAreas(CNavArea *start, CNavArea *end)
return z2 - z1; return z2 - z1;
} }
static std::unordered_map<std::pair<CNavArea *, CNavArea *>, ignoredata, boost::hash<std::pair<CNavArea *, CNavArea *>>> ignores; static std::unordered_map<std::pair<CNavArea *, CNavArea *>, ignoredata, boost::hash<std::pair<CNavArea *, CNavArea *>>> ignores;
namespace ignoremanager namespace ignoremanager
{ {
static bool vischeck(CNavArea *begin, CNavArea *end) static bool vischeck(CNavArea *begin, CNavArea *end)
{
Vector first = begin->m_center;
Vector second = end->m_center;
first.z += 42;
second.z += 42;
return IsVectorVisible(first, second, true, LOCAL_E, MASK_PLAYERSOLID);
}
static ignore_status runIgnoreChecks(CNavArea *begin, CNavArea *end)
{
if (getZBetweenAreas(begin, end) > 42)
return const_ignored;
if (!vischecks)
return vischeck_success;
if (vischeck(begin, end))
return vischeck_success;
else
return vischeck_failed;
}
static void updateDanger()
{
for (size_t i = 0; i <= HIGHEST_ENTITY; i++)
{ {
Vector first = begin->m_center; CachedEntity *ent = ENTITY(i);
Vector second = end->m_center; if (CE_INVALID(ent))
first.z += 42; continue;
second.z += 42; if (ent->m_iClassID() == CL_CLASS(CObjectSentrygun))
return IsVectorVisible(first, second, true, LOCAL_E, MASK_PLAYERSOLID);
}
static ignore_status runIgnoreChecks(CNavArea *begin, CNavArea *end)
{
if (getZBetweenAreas(begin, end) > 42)
return const_ignored;
if (!vischecks)
return vischeck_success;
if (vischeck(begin, end))
return vischeck_success;
else
return vischeck_failed;
}
static void updateDanger()
{
for (size_t i = 0; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); if (!ent->m_bEnemy())
if (CE_INVALID(ent))
continue; continue;
if (ent->m_iClassID() == CL_CLASS(CObjectSentrygun)) if (HasCondition<TFCond_Disguised>(LOCAL_E))
{
if (!ent->m_bEnemy())
continue;
if (HasCondition<TFCond_Disguised>(LOCAL_E))
continue;
Vector loc = GetBuildingPosition(ent);
if (RAW_ENT(ent)->IsDormant())
{
auto vec = ent->m_vecDormantOrigin();
if (vec)
{
loc -= RAW_ENT(ent)->GetCollideable()->GetCollisionOrigin();
loc += *vec;
}
else
continue;
}
for (auto &i : navfile->m_areas)
{
Vector area = i.m_center;
area.z += 41.5f;
if (loc.DistTo(area) > 1100)
continue;
// Check if sentry can see us
if (!IsVectorVisible(loc, area, true))
continue;
ignoredata &data = ignores[{ &i, nullptr }];
data.status = danger_found;
data.ignoreTimeout.update();
data.ignoreTimeout.last -= std::chrono::seconds(17);
}
}
else if (ent->m_iClassID() == CL_CLASS(CTFGrenadePipebombProjectile))
{
if (!ent->m_bEnemy())
continue;
if (CE_INT(ent, netvar.iPipeType) == 1)
continue;
Vector loc = ent->m_vecOrigin();
for (auto &i : navfile->m_areas)
{
Vector area = i.m_center;
if (loc.DistTo(area) > 130)
continue;
area.z += 41.5f;
// Check if We can see stickies
if (!IsVectorVisible(loc, area, true))
continue;
ignoredata &data = ignores[{ &i, nullptr }];
data.status = danger_found;
data.ignoreTimeout.update();
data.ignoreTimeout.last -= std::chrono::seconds(17);
}
}
}
}
static void checkPath()
{
bool perform_repath = false;
// Vischecks
for (size_t i = 0; i < crumbs.size() - 1; i++)
{
CNavArea *begin = crumbs[i];
CNavArea *end = crumbs[i + 1];
if (!begin || !end)
continue; continue;
ignoredata &data = ignores[{ begin, end }]; Vector loc = GetBuildingPosition(ent);
if (data.status == vischeck_failed) if (RAW_ENT(ent)->IsDormant())
return;
if (!vischeck(begin, end))
{ {
data.status = vischeck_failed; auto vec = ent->m_vecDormantOrigin();
if (vec)
{
loc -= RAW_ENT(ent)->GetCollideable()->GetCollisionOrigin();
loc += *vec;
}
else
continue;
}
for (auto &i : navfile->m_areas)
{
Vector area = i.m_center;
area.z += 41.5f;
if (loc.DistTo(area) > 1100)
continue;
// Check if sentry can see us
if (!IsVectorVisible(loc, area, true))
continue;
ignoredata &data = ignores[{ &i, nullptr }];
data.status = danger_found;
data.ignoreTimeout.update(); data.ignoreTimeout.update();
perform_repath = true; data.ignoreTimeout.last -= std::chrono::seconds(17);
} }
else if (ignores[{ end, nullptr }].status == danger_found) }
{ else if (ent->m_iClassID() == CL_CLASS(CTFGrenadePipebombProjectile))
perform_repath = true; {
if (!ent->m_bEnemy())
continue;
if (CE_INT(ent, netvar.iPipeType) == 1)
continue;
Vector loc = ent->m_vecOrigin();
for (auto &i : navfile->m_areas)
{
Vector area = i.m_center;
if (loc.DistTo(area) > 130)
continue;
area.z += 41.5f;
// Check if We can see stickies
if (!IsVectorVisible(loc, area, true))
continue;
ignoredata &data = ignores[{ &i, nullptr }];
data.status = danger_found;
data.ignoreTimeout.update();
data.ignoreTimeout.last -= std::chrono::seconds(17);
} }
} }
if (perform_repath)
repath();
} }
// 0 = Not ignored, 1 = low priority, 2 = ignored }
static int isIgnored(CNavArea *begin, CNavArea *end)
{
if (ignores[{ end, nullptr }].status == danger_found)
return 2;
ignore_status status = ignores[{ begin, end }].status;
if (status == unknown)
status = runIgnoreChecks(begin, end);
if (status == vischeck_success)
return 0;
else if (status == vischeck_failed)
return 1;
else
return 2;
}
static bool addTime(ignoredata &connection, ignore_status status)
{
connection.status = status;
connection.ignoreTimeout.update();
static void checkPath()
{
bool perform_repath = false;
// Vischecks
for (size_t i = 0; i < crumbs.size() - 1; i++)
{
CNavArea *begin = crumbs[i];
CNavArea *end = crumbs[i + 1];
if (!begin || !end)
continue;
ignoredata &data = ignores[{ begin, end }];
if (data.status == vischeck_failed)
return;
if (!vischeck(begin, end))
{
data.status = vischeck_failed;
data.ignoreTimeout.update();
perform_repath = true;
}
else if (ignores[{ end, nullptr }].status == danger_found)
{
perform_repath = true;
}
}
if (perform_repath)
repath();
}
// 0 = Not ignored, 1 = low priority, 2 = ignored
static int isIgnored(CNavArea *begin, CNavArea *end)
{
if (ignores[{ end, nullptr }].status == danger_found)
return 2;
ignore_status status = ignores[{ begin, end }].status;
if (status == unknown)
status = runIgnoreChecks(begin, end);
if (status == vischeck_success)
return 0;
else if (status == vischeck_failed)
return 1;
else
return 2;
}
static bool addTime(ignoredata &connection, ignore_status status)
{
connection.status = status;
connection.ignoreTimeout.update();
return true;
}
static bool addTime(CNavArea *begin, CNavArea *end, ignore_status status)
{
logging::Info("Ignored Connection %i-%i", begin->m_id, end->m_id);
return addTime(ignores[{ begin, end }], status);
}
static bool addTime(CNavArea *begin, CNavArea *end, Timer &time)
{
if (!begin || !end)
{
// We can't reach the destination vector. Destination vector might
// be out of bounds/reach.
clearInstructions();
return true; return true;
} }
static bool addTime(CNavArea *begin, CNavArea *end, ignore_status status) using namespace std::chrono;
// Check if connection is already known
if (ignores.find({ begin, end }) == ignores.end())
{
ignores[{ begin, end }] = {};
}
ignoredata &connection = ignores[{ begin, end }];
connection.stucktime += duration_cast<milliseconds>(system_clock::now() - time.last).count();
if (connection.stucktime >= *stuck_time)
{ {
logging::Info("Ignored Connection %i-%i", begin->m_id, end->m_id); logging::Info("Ignored Connection %i-%i", begin->m_id, end->m_id);
return addTime(ignores[{ begin, end }], status); return addTime(connection, explicit_ignored);
} }
static bool addTime(CNavArea *begin, CNavArea *end, Timer &time) return false;
}
static void reset()
{
ignores.clear();
ResetPather();
}
static void updateIgnores()
{
static Timer update{};
static Timer last_pather_reset{};
static bool reset_pather = false;
if (!update.test_and_set(500))
return;
updateDanger();
if (crumbs.empty())
{ {
if (!begin || !end) for (auto &i : ignores)
{ {
// We can't reach the destination vector. Destination vector might switch (i.second.status)
// be out of bounds/reach.
clearInstructions();
return true;
}
using namespace std::chrono;
// Check if connection is already known
if (ignores.find({ begin, end }) == ignores.end())
{
ignores[{ begin, end }] = {};
}
ignoredata &connection = ignores[{ begin, end }];
connection.stucktime += duration_cast<milliseconds>(system_clock::now() - time.last).count();
if (connection.stucktime >= *stuck_time)
{
logging::Info("Ignored Connection %i-%i", begin->m_id, end->m_id);
return addTime(connection, explicit_ignored);
}
return false;
}
static void reset()
{
ignores.clear();
ResetPather();
}
static void updateIgnores()
{
static Timer update{};
static Timer last_pather_reset{};
static bool reset_pather = false;
if (!update.test_and_set(500))
return;
updateDanger();
if (crumbs.empty())
{
for (auto &i : ignores)
{ {
switch (i.second.status) case explicit_ignored:
if (i.second.ignoreTimeout.check(60000))
{ {
case explicit_ignored: i.second.status = unknown;
if (i.second.ignoreTimeout.check(60000)) i.second.stucktime = 0;
{ reset_pather = true;
i.second.status = unknown;
i.second.stucktime = 0;
reset_pather = true;
}
break;
case unknown:
break;
case danger_found:
if (i.second.ignoreTimeout.check(20000))
{
i.second.status = unknown;
reset_pather = true;
}
break;
case vischeck_failed:
case vischeck_success:
default:
if (i.second.ignoreTimeout.check(30000))
{
i.second.status = unknown;
i.second.stucktime = 0;
reset_pather = true;
}
break;
} }
break;
case unknown:
break;
case danger_found:
if (i.second.ignoreTimeout.check(20000))
{
i.second.status = unknown;
reset_pather = true;
}
break;
case vischeck_failed:
case vischeck_success:
default:
if (i.second.ignoreTimeout.check(30000))
{
i.second.status = unknown;
i.second.stucktime = 0;
reset_pather = true;
}
break;
} }
} }
else
checkPath();
if (reset_pather && last_pather_reset.test_and_set(10000))
{
reset_pather = false;
ResetPather();
}
} }
static bool isSafe(CNavArea *area) else
checkPath();
if (reset_pather && last_pather_reset.test_and_set(10000))
{ {
return !(ignores[{ area, nullptr }].status == danger_found); reset_pather = false;
ResetPather();
} }
}; }
static bool isSafe(CNavArea *area)
{
return !(ignores[{ area, nullptr }].status == danger_found);
}
}; // namespace ignoremanager
struct Graph : public micropather::Graph struct Graph : public micropather::Graph
{ {
std::unique_ptr<micropather::MicroPather> pather; std::unique_ptr<micropather::MicroPather> pather;
Graph() { Graph()
{
pather = std::make_unique<micropather::MicroPather>(this, 3000, 6, true); pather = std::make_unique<micropather::MicroPather>(this, 3000, 6, true);
} }
~Graph() override {} ~Graph() override
{
}
void AdjacentCost(void *state, MP_VECTOR<micropather::StateCost> *adjacent) override void AdjacentCost(void *state, MP_VECTOR<micropather::StateCost> *adjacent) override
{ {
CNavArea *center = static_cast<CNavArea *>(state); CNavArea *center = static_cast<CNavArea *>(state);
@ -338,7 +341,8 @@ struct Graph : public micropather::Graph
if (isIgnored == 2) if (isIgnored == 2)
continue; continue;
float distance = center->m_center.DistTo(i.area->m_center); float distance = center->m_center.DistTo(i.area->m_center);
if (isIgnored == 1) { if (isIgnored == 1)
{
if (*vischeckBlock) if (*vischeckBlock)
continue; continue;
distance += 50000; distance += 50000;
@ -352,7 +356,9 @@ struct Graph : public micropather::Graph
CNavArea *end = reinterpret_cast<CNavArea *>(stateEnd); CNavArea *end = reinterpret_cast<CNavArea *>(stateEnd);
return start->m_center.DistTo(end->m_center); return start->m_center.DistTo(end->m_center);
} }
void PrintStateInfo(void *) override {} void PrintStateInfo(void *) override
{
}
}; };
// Navfile containing areas // Navfile containing areas
@ -435,8 +441,7 @@ CNavArea *findClosestNavSquare(const Vector &vec)
for (auto &i : navfile->m_areas) for (auto &i : navfile->m_areas)
{ {
// Make sure we're not stuck on the same area for too long // Make sure we're not stuck on the same area for too long
if (isLocal && std::count(findClosestNavSquare_localAreas.begin(), if (isLocal && std::count(findClosestNavSquare_localAreas.begin(), findClosestNavSquare_localAreas.end(), &i) >= 3)
findClosestNavSquare_localAreas.end(), &i) >= 3)
{ {
continue; continue;
} }
@ -447,8 +452,7 @@ CNavArea *findClosestNavSquare(const Vector &vec)
bestSquare = &i; bestSquare = &i;
} }
// Check if we are within x and y bounds of an area // Check if we are within x and y bounds of an area
if (ovBestDist >= dist || !i.IsOverlapping(vec) || if (ovBestDist >= dist || !i.IsOverlapping(vec) || !IsVectorVisible(vec, i.m_center, true, LOCAL_E, MASK_PLAYERSOLID))
!IsVectorVisible(vec, i.m_center, true, LOCAL_E, MASK_PLAYERSOLID))
{ {
continue; continue;
} }
@ -464,7 +468,7 @@ CNavArea *findClosestNavSquare(const Vector &vec)
return ovBestSquare; return ovBestSquare;
} }
std::vector<CNavArea*> findPath(const Vector &start, const Vector &end) std::vector<CNavArea *> findPath(const Vector &start, const Vector &end)
{ {
using namespace std::chrono; using namespace std::chrono;
@ -478,13 +482,11 @@ std::vector<CNavArea*> findPath(const Vector &start, const Vector &end)
logging::Info("Start: (%f,%f,%f)", local->m_center.x, local->m_center.y, local->m_center.z); logging::Info("Start: (%f,%f,%f)", local->m_center.x, local->m_center.y, local->m_center.z);
logging::Info("End: (%f,%f,%f)", dest->m_center.x, dest->m_center.y, dest->m_center.z); logging::Info("End: (%f,%f,%f)", dest->m_center.x, dest->m_center.y, dest->m_center.z);
float cost; float cost;
std::vector<CNavArea*> pathNodes; std::vector<CNavArea *> pathNodes;
time_point begin_pathing = high_resolution_clock::now(); time_point begin_pathing = high_resolution_clock::now();
int result = Map.pather->Solve(reinterpret_cast<void *>(local), int result = Map.pather->Solve(reinterpret_cast<void *>(local), reinterpret_cast<void *>(dest), reinterpret_cast<std::vector<void *> *>(&pathNodes), &cost);
reinterpret_cast<void*>(dest), long long timetaken = duration_cast<nanoseconds>(high_resolution_clock::now() - begin_pathing).count();
reinterpret_cast<std::vector<void*>*>(&pathNodes), &cost);
long long timetaken = duration_cast<nanoseconds>(high_resolution_clock::now() - begin_pathing).count();
logging::Info("Pathing: Pather result: %i. Time taken (NS): %lld", result, timetaken); logging::Info("Pathing: Pather result: %i. Time taken (NS): %lld", result, timetaken);
// If no result found, return empty Vector // If no result found, return empty Vector
if (result == micropather::MicroPather::NO_SOLUTION) if (result == micropather::MicroPather::NO_SOLUTION)
@ -495,7 +497,7 @@ std::vector<CNavArea*> findPath(const Vector &start, const Vector &end)
static Vector loc(0.0f, 0.0f, 0.0f); static Vector loc(0.0f, 0.0f, 0.0f);
static CNavArea *last_area = nullptr; static CNavArea *last_area = nullptr;
bool ReadyForCommands = true; bool ReadyForCommands = true;
static Timer inactivity{}; static Timer inactivity{};
int curr_priority = 0; int curr_priority = 0;
static bool ensureArrival = false; static bool ensureArrival = false;
@ -611,15 +613,13 @@ static void cm()
} }
if (look && LookAtPathTimer.check(1000)) if (look && LookAtPathTimer.check(1000))
{ {
Vector next{crumb_vec->x, crumb_vec->y, g_pLocalPlayer->v_Eye.z}; Vector next{ crumb_vec->x, crumb_vec->y, g_pLocalPlayer->v_Eye.z };
next = GetAimAtAngles(g_pLocalPlayer->v_Eye, next); next = GetAimAtAngles(g_pLocalPlayer->v_Eye, next);
DoSlowAim(next); DoSlowAim(next);
current_user_cmd->viewangles = next; current_user_cmd->viewangles = next;
} }
// Detect when jumping is necessary // Detect when jumping is necessary
if ((!(g_pLocalPlayer->holding_sniper_rifle && g_pLocalPlayer->bZoomed) && if ((!(g_pLocalPlayer->holding_sniper_rifle && g_pLocalPlayer->bZoomed) && crumb_vec->z - g_pLocalPlayer->v_Origin.z > 18 && last_jump.test_and_set(200)) || (last_jump.test_and_set(200) && inactivity.check(*stuck_time / 2)))
crumb_vec->z - g_pLocalPlayer->v_Origin.z > 18 && last_jump.test_and_set(200)) ||
(last_jump.test_and_set(200) && inactivity.check(*stuck_time / 2)))
{ {
current_user_cmd->buttons |= IN_JUMP; current_user_cmd->buttons |= IN_JUMP;
} }
@ -629,9 +629,7 @@ static void cm()
* ignore that connection * ignore that connection
* Or if inactive for too long * Or if inactive for too long
*/ */
if (inactivity.check(*stuck_time) || (inactivity.check(*unreachable_time) && if (inactivity.check(*stuck_time) || (inactivity.check(*unreachable_time) && !IsVectorVisible(g_pLocalPlayer->v_Origin, *crumb_vec + Vector(.0f, .0f, 41.5f), false, LOCAL_E, MASK_PLAYERSOLID)))
!IsVectorVisible(g_pLocalPlayer->v_Origin, *crumb_vec + Vector(.0f, .0f, 41.5f),
false, LOCAL_E, MASK_PLAYERSOLID)))
{ {
/* crumb is invalid if endPoint is used */ /* crumb is invalid if endPoint is used */
if (crumb_vec != &endPoint) if (crumb_vec != &endPoint)
@ -656,12 +654,14 @@ static void drawcrumbs()
for (size_t i = 0; i < crumbs.size(); i++) for (size_t i = 0; i < crumbs.size(); i++)
{ {
Vector wts1, wts2, *o1, *o2; Vector wts1, wts2, *o1, *o2;
if (crumbs.size() - 1 == i) { if (crumbs.size() - 1 == i)
{
if (!endPoint.IsValid()) if (!endPoint.IsValid())
break; break;
o2 = &endPoint; o2 = &endPoint;
} else }
else
o2 = &crumbs[i + 1]->m_center; o2 = &crumbs[i + 1]->m_center;
o1 = &crumbs[i]->m_center; o1 = &crumbs[i]->m_center;

View File

@ -368,4 +368,14 @@ void EffectChams::Render(int x, int y, int w, int h)
} }
EffectChams g_EffectChams; EffectChams g_EffectChams;
CScreenSpaceEffectRegistration *g_pEffectChams = nullptr; CScreenSpaceEffectRegistration *g_pEffectChams = nullptr;
static InitRoutine init([]() {
EC::Register(
EC::LevelShutdown, []() { g_EffectChams.Shutdown(); }, "chams");
if (g_ppScreenSpaceRegistrationHead && g_pScreenSpaceEffects)
{
effect_chams::g_pEffectChams = new CScreenSpaceEffectRegistration("_cathook_chams", &effect_chams::g_EffectChams);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_chams");
}
});
} // namespace effect_chams } // namespace effect_chams

View File

@ -509,4 +509,15 @@ void EffectGlow::Render(int x, int y, int w, int h)
EffectGlow g_EffectGlow; EffectGlow g_EffectGlow;
CScreenSpaceEffectRegistration *g_pEffectGlow = nullptr; CScreenSpaceEffectRegistration *g_pEffectGlow = nullptr;
static InitRoutine init([]() {
EC::Register(
EC::LevelShutdown, []() { g_EffectGlow.Shutdown(); }, "glow");
if (g_ppScreenSpaceRegistrationHead && g_pScreenSpaceEffects)
{
effect_glow::g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &effect_glow::g_EffectGlow);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow");
}
} // namespace effect_glow
);
} // namespace effect_glow } // namespace effect_glow

View File

@ -22,6 +22,7 @@
#include "visual/drawing.hpp" #include "visual/drawing.hpp"
#include "hack.hpp" #include "hack.hpp"
#include "menu/menu/Menu.hpp" #include "menu/menu/Menu.hpp"
#include "drawmgr.hpp"
static settings::Boolean info_text{ "hack-info.enable", "true" }; static settings::Boolean info_text{ "hack-info.enable", "true" };
static settings::Boolean info_text_min{ "hack-info.minimal", "false" }; static settings::Boolean info_text_min{ "hack-info.minimal", "false" };
@ -108,9 +109,6 @@ void DrawCheatVisuals()
PROF_SECTION(DRAW_skinchanger); PROF_SECTION(DRAW_skinchanger);
hacks::tf2::skinchanger::DrawText(); hacks::tf2::skinchanger::DrawText();
} }
#ifndef FEATURE_FIDGET_SPINNER_ENABLED
DrawSpinner();
#endif
Prediction_PaintTraverse(); Prediction_PaintTraverse();
} }
{ {

View File

@ -5,7 +5,6 @@
* Author: nullifiedcat * Author: nullifiedcat
*/ */
#include "visual/fidgetspinner.hpp"
#include "common.hpp" #include "common.hpp"
#include "../../external/libglez/ftgl/freetype-gl.h" #include "../../external/libglez/ftgl/freetype-gl.h"
@ -87,4 +86,9 @@ void DrawSpinner()
angle -= PI * 4; angle -= PI * 4;
} }
static InitRoutine init([]() {
InitSpinner();
EC::Register(EC::Draw, DrawSpinner, "spinner");
});
#endif #endif

View File

@ -9,6 +9,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <settings/Bool.hpp> #include <settings/Bool.hpp>
#include "CatBot.hpp" #include "CatBot.hpp"
#include "votelogger.hpp"
static settings::Boolean vote_kicky{ "votelogger.autovote.yes", "false" }; static settings::Boolean vote_kicky{ "votelogger.autovote.yes", "false" };
static settings::Boolean vote_kickn{ "votelogger.autovote.no", "false" }; static settings::Boolean vote_kickn{ "votelogger.autovote.no", "false" };