Merge conflicts: 48

This commit is contained in:
TotallyNotElite 2018-12-24 13:51:40 +01:00
parent 384ea4f8f6
commit 3d4233c739
25 changed files with 75 additions and 181 deletions

View File

@ -1,16 +0,0 @@
/*
* AutoDetonator.cpp
*
* Created on: Mar 21, 2018
* Author: nullifiedcat & Lighty
*/
#pragma once
#include "common.hpp"
namespace hacks::tf::autodetonator
{
void CreateMove();
}

View File

@ -1,16 +0,0 @@
/*
* AutoSticky.h
*
* Created on: Dec 2, 2016
* Author: nullifiedcat
*/
#pragma once
#include "common.hpp"
namespace hacks::tf::autosticky
{
bool ShouldDetonate(CachedEntity *bomb);
void CreateMove();
} // namespace hacks::tf::autosticky

View File

@ -3,13 +3,19 @@
#include "core/profiler.hpp"
#include "functional"
#include <set>
#include <array>
namespace EC
{
enum ec_types : int8_t
enum ec_types
{
/* Note: engine prediction is run on this kind of CreateMove */
CreateMove = 0,
/* This kind of CreateMove will run earlier than all CreateMove events
* and guranteed to run before EnginePrediction
*/
CreateMove_NoEnginePred,
#if ENABLE_VISUALS
Draw,
#endif
@ -21,7 +27,7 @@ enum ec_types : int8_t
EcTypesSize
};
enum priority : int8_t
enum ec_priority
{
very_early = -2,
early,

View File

@ -1284,7 +1284,7 @@ static InitRoutine EC([]() {
EC::Register(EC::LevelShutdown, Reset, "RESET_Aimbot", EC::average);
EC::Register(EC::CreateMove, CreateMove, "CM_Aimbot", EC::average);
#if ENABLE_VISUALS
EC::Register<EC::Draw>(DrawText, "DRAW_Aimbot", EC::average);
EC::Register(EC::Draw, DrawText, "DRAW_Aimbot", EC::average);
#endif
});
} // namespace hacks::shared::aimbot

View File

@ -67,5 +67,5 @@ static void CreateMove()
current_user_cmd->buttons |= IN_ATTACK2;
}
}
static InitRoutine EC([]() { EC::Register<EC::CreateMove>(CreateMove, "AutoDeadringer", EC::average); });
static InitRoutine EC([]() { EC::Register(EC::CreateMove, CreateMove, "AutoDeadringer", EC::average); });
} // namespace hacks::shared::deadringer

View File

@ -126,4 +126,8 @@ void CreateMove()
// End of function, just return
return;
}
static InitRoutine EC([]() {
EC::Register(EC::CreateMove, CreateMove, "auto_detonator", EC::average);
});
} // namespace hacks::tf::autodetonator

View File

@ -130,5 +130,5 @@ void onShutdown()
tfmm::startQueue();
}
static InitRoutine init([]() { EC::Register<EC::CreateMove>(update, "cm_autojoin", EC::average); });
static InitRoutine init([]() { EC::Register(EC::CreateMove, update, "cm_autojoin", EC::average); });
} // namespace hacks::shared::autojoin

View File

@ -6,7 +6,6 @@
*/
#include "common.hpp"
#include <hacks/AutoSticky.hpp>
#include <PlayerTools.hpp>
#include <settings/Bool.hpp>
@ -179,4 +178,8 @@ void CreateMove()
}
}
}
static InitRoutine EC([]() {
EC::Register(EC::CreateMove, CreateMove, "auto_sticky", EC::average);
});
} // namespace hacks::tf::autosticky

View File

@ -358,7 +358,7 @@ static InitRoutine EC([]() {
EC::Register(EC::LevelInit, Init, "INIT_Backtrack", EC::average);
EC::Register(EC::CreateMove, Run, "CM_Backtrack", EC::early);
#if ENABLE_VISUALS
EC::Register<EC::Draw>(Draw, "DRAW_Backtrack", EC::average);
EC::Register(EC::Draw, Draw, "DRAW_Backtrack", EC::average);
#endif
});
} // namespace hacks::shared::backtrack

View File

@ -52,5 +52,5 @@ static void CreateMove()
if (!jump)
ticks_last_jump = 0;
}
static InitRoutine EC([]() { EC::Register<EC::CreateMove>(CreateMove, "Bunnyhop", -4); });
static InitRoutine EC([]() { EC::Register(EC::CreateMove_NoEnginePred, CreateMove, "Bunnyhop", EC::average); });
} // namespace hacks::shared::bunnyhop

View File

@ -449,7 +449,7 @@ static InitRoutine runinit([]() {
EC::Register(EC::CreateMove, cm, "cm_catbot", EC::average);
EC::Register(EC::Paint, update, "paint_catbot", EC::average);
#if ENABLE_VISUALS
EC::Register<EC::Draw>(draw, "draw_catbot", EC::average);
EC::Register(EC::Draw, draw, "draw_catbot", EC::average);
#endif
init();
});

View File

@ -1446,7 +1446,7 @@ void SetEntityColor(CachedEntity *entity, const rgba_t &color)
}
static InitRoutine init([]() {
EC::Register<EC::CreateMove>(cm, "cm_esp", EC::average);
EC::Register(EC::CreateMove, cm, "cm_esp", EC::average);
#if ENABLE_VISUALS
EC::Register(EC::Draw, Draw, "draw_esp", EC::average);
Init();

View File

@ -584,7 +584,7 @@ static void draw()
static InitRoutine runinit([]() {
#if ENABLE_IPC
EC::Register<EC::CreateMove>(cm, "cm_followbot", EC::average);
EC::Register(EC::CreateMove, cm, "cm_followbot", EC::average);
#endif
#if ENABLE_VISUALS
EC::Register(EC::Draw, draw, "draw_followbot", EC::average);

View File

@ -81,9 +81,9 @@ void draw()
}
static InitRoutine init([]() {
EC::Register<EC::CreateMove>(cm, "cm_lightesp", EC::average);
EC::Register(EC::CreateMove, cm, "cm_lightesp", EC::average);
#if ENABLE_VISUALS
EC::Register<EC::Draw>(draw, "draw_lightesp", EC::average);
EC::Register(EC::Draw, draw, "draw_lightesp", EC::average);
#endif
});

View File

@ -286,4 +286,4 @@ static void CreateMove()
SapperAimbot();
}
static InitRoutine init([]() { EC::Register<EC::CreateMove>(CreateMove, "cm_miscaimbot", EC::late); });
static InitRoutine init([]() { EC::Register(EC::CreateMove, CreateMove, "cm_miscaimbot", EC::late); });

View File

@ -26,5 +26,5 @@ static void CreateMove()
}
}
}
static InitRoutine EC([]() { EC::Register<EC::CreateMove>(CreateMove, "Noisemaker", EC::average); });
static InitRoutine EC([]() { EC::Register(EC::CreateMove, CreateMove, "Noisemaker", EC::average); });
} // namespace hacks::tf2::noisemaker

View File

@ -110,7 +110,7 @@ static void CreateMove()
last_charge = (int) (100.0f * charge);
}
static InitRoutine register_EC([]() { EC::Register<EC::CreateMove>(CreateMove, "Uberspam", EC::priority::average); });
static InitRoutine register_EC([]() { EC::Register(EC::CreateMove, CreateMove, "Uberspam", EC::average); });
// Ready, Used, Ended, %...
const std::vector<std::string> builtin_cathook = { "-> I am charged!", "-> Not a step back! UBERCHARGE USED!", "-> My Ubercharge comes to an end!", "-> I have %i%% of ubercharge!", "-> I have half of the ubercharge!", "-> Ubercharge almost ready! (%i%%)" };

View File

@ -276,7 +276,11 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs
{
PROF_SECTION(CM_WRAPPER);
EC::RunCreateMove();
EC::run(EC::CreateMove_NoEnginePred);
if (engine_pred)
engine_prediction::RunEnginePrediction(RAW_ENT(LOCAL_E), current_user_cmd);
EC::run(EC::CreateMove);
}
if (CE_GOOD(g_pLocalPlayer->entity))
{
@ -416,14 +420,6 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs
g_Settings.is_create_move = false;
return ret;
}
static InitRoutine EngPred([]() {
EC::Register<EC::CreateMove>(
[]() {
if (engine_pred)
engine_prediction::RunEnginePrediction(RAW_ENT(LOCAL_E), current_user_cmd);
},
"engine_prediction", -3);
});
} // namespace hooked_methods
/*float o_curtime;

View File

@ -75,7 +75,7 @@ void Paint()
previous_name = "";
}
}
static InitRoutine Autobalance([]() { EC::Register<EC::Paint>(Paint, "paint_autobalance", EC::average); });
static InitRoutine Autobalance([]() { EC::Register(EC::Paint, Paint, "paint_autobalance", EC::average); });
DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, bf_read &buf)
{
if (!isHackActive())

View File

@ -176,6 +176,6 @@ static void cm()
}
}
static InitRoutine runinit([]() { EC::Register<EC::CreateMove>(cm, "cm_namesteal", EC::late); });
static InitRoutine runinit([]() { EC::Register(EC::CreateMove, cm, "cm_namesteal", EC::late); });
} // namespace hooked_methods

View File

@ -3,16 +3,43 @@
namespace EC
{
// Ordered set to always keep priorities correct
std::multiset<EventCallbackData<CreateMove>> createmoves;
#if ENABLE_VISUALS
std::multiset<EventCallbackData<Draw>> draws;
#endif
std::multiset<EventCallbackData<Paint>> paints;
std::multiset<EventCallbackData<LevelInit>> levelinits;
template <typename t> inline void run(t &set)
struct EventCallbackData
{
explicit EventCallbackData(const EventFunction &function, std::string name, enum ec_priority priority) : function{ function }, priority{ int(priority) }, event_name{ name }, section{ name }
{
}
EventFunction function;
int priority;
mutable ProfilerSection section;
std::string event_name;
bool operator<(const EventCallbackData &other) const
{
return priority < other.priority;
}
};
// Ordered set to always keep priorities correct
static std::multiset<EventCallbackData> events[ec_types::EcTypesSize];
void Register(enum ec_types type, const EventFunction &function, const std::string &name, enum ec_priority priority)
{
events[type].insert(EventCallbackData(function, name, priority));
}
void Unregister(enum ec_types type, const std::string &name)
{
auto &e = events[type];
for (auto it = e.begin(); it != e.end(); ++it)
if (it->event_name == name)
{
e.erase(it);
break;
}
}
void run(ec_types type)
{
const auto &set = events[type];
for (auto &i : set)
{
#if ENABLE_PROFILER
@ -22,24 +49,4 @@ template <typename t> inline void run(t &set)
}
}
void RunCreateMove()
{
run(createmoves);
}
#if ENABLE_VISUALS
void RunDraw()
{
run(draws);
}
#endif
void RunPaint()
{
run(paints);
}
void RunLevelInit()
{
run(levelinits);
}
} // namespace EC

View File

@ -80,7 +80,7 @@ DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode)
render_cheat_visuals();
#endif
// Call all paint functions
EC::RunPaint();
EC::run(EC::Paint);
}
return original::Paint(this_, mode);

View File

@ -69,4 +69,4 @@ bool IsHoovy(CachedEntity *entity)
return hoovy_list[entity->m_IDX - 1];
}
static InitRoutine init([]() { EC::Register<EC::CreateMove>(UpdateHoovyList, "cm_hoovylist", EC::average); });
static InitRoutine init([]() { EC::Register(EC::CreateMove, UpdateHoovyList, "cm_hoovylist", EC::average); });

View File

@ -395,7 +395,7 @@ template <typename T> void rvarCallback(settings::VariableBase<T> &var, T after)
}
static InitRoutine init([]() {
EC::Register<EC::Paint>(run, "PAINT_irc", EC::average);
EC::Register(EC::Paint, run, "PAINT_irc", EC::average);
updateData();
enabled.installChangeCallback(rvarCallback<bool>);
anon.installChangeCallback(rvarCallback<bool>);

View File

@ -21,11 +21,6 @@
static settings::Bool info_text{ "hack-info.enable", "true" };
static settings::Bool info_text_min{ "hack-info.minimal", "false" };
static settings::Bool draw_snowflakes{ "visual.snowflakes", "true" };
static settings::Float snowflake_min_down{ "visual.snowflakes.fall-speed.min", "0.5f" };
static settings::Float snowflake_max_down{ "visual.snowflakes.fall-speed.max", "2.0f" };
static settings::Float snowflake_min_side{ "visual.snowflakes.sideways-speed.min", "-0.8f" };
static settings::Float snowflake_max_side{ "visual.snowflakes.sideways-speed.max", "0.8f" };
void render_cheat_visuals()
{
@ -57,12 +52,6 @@ void BeginCheatVisuals()
std::mutex drawing_mutex;
struct snowflake
{
Vector2D pos{};
Vector2D angle{};
};
double getRandom(double lower_bound, double upper_bound)
{
std::uniform_real_distribution<double> unif(lower_bound, upper_bound);
@ -72,70 +61,12 @@ double getRandom(double lower_bound, double upper_bound)
return x;
}
static std::vector<snowflake> snowflakes{};
static Timer snowflake_spawn{};
static Timer flake_update{};
void DrawCheatVisuals()
{
/*#if RENDERING_ENGINE_OPENGL
std::lock_guard<std::mutex> draw_lock(drawing_mutex);
#endif*/
{
PROF_SECTION(DRAW_misc);
hacks::shared::misc::DrawText();
}
{
PROF_SECTION(DRAW_SNOWFLAKES);
if (zerokernel::Menu::instance && !zerokernel::Menu::instance->isInGame() && *draw_snowflakes)
{
// used to count current vector index
int idx = 0;
for (snowflake &flake : snowflakes)
{
// Only cache texture once, saves processing time
static textures::sprite snowflake_sprite(256, 0, 16, 16, textures::atlas());
// Draw at the pos
snowflake_sprite.draw(flake.pos.x, flake.pos.y, 16, 16, colors::white);
// about 30fps
if (flake_update.check(33))
{
flake.pos += flake.angle;
// Get a new value so the snowflakes look a bit more natural, don't dip below min/go above max.
float rand_down_min = fminf(*snowflake_min_down, flake.angle.y - 0.01f);
float rand_down_max = fmaxf(*snowflake_max_down, flake.angle.x + 0.01f);
float rand_side_min = fminf(*snowflake_min_side, flake.angle.x - 0.01f);
float rand_side_max = fmaxf(*snowflake_max_side, flake.angle.x + 0.01f);
float new_down = getRandom(rand_down_min, rand_down_max);
float new_side = getRandom(rand_side_min, rand_side_max);
// Store new angle
flake.angle = { new_side, new_down };
// Delet offscreen
if (flake.pos.x > draw::width || flake.pos.x < 0 || flake.pos.y > draw::height)
snowflakes.erase(snowflakes.begin() + idx);
}
idx++;
}
// Update the timer for our 30fps
flake_update.test_and_set(33);
// Spawn a snowflake every 900ms
if (snowflake_spawn.test_and_set(900))
{
// Get speeds
float down_speed = getRandom(*snowflake_min_down, *snowflake_max_down);
float side_speed = getRandom(*snowflake_min_side, *snowflake_max_side);
// Position, prevent offscreen spawns
float start_pos = getRandom(draw::width * 0.1f, draw::width * 0.9f);
snowflake new_flake{};
new_flake.pos = { start_pos, 0.0f };
// x = left right, which is side speed, y = down/up, which is down speed
new_flake.angle = { side_speed, down_speed };
// Store
snowflakes.push_back(new_flake);
}
}
}
{
PROF_SECTION(DRAW_info);
std::string name_s, reason_s;
@ -152,27 +83,6 @@ void DrawCheatVisuals()
AddSideString("Press 'INSERT' key to open/close cheat menu.", GUIColor());
AddSideString("Use mouse to navigate in menu.", GUIColor());
#endif
if (!g_IEngine->IsInGame()
#if ENABLE_GUI
/*
|| g_pGUI->Visible()
*/
#endif
)
{
// FIXME
/*name_s = *force_name;
if (name_s.length() < 3)
name_s = "*Not Set*";
reason_s = disconnect_reason.GetString();
if (reason_s.length() < 3)
reason_s = "*Not Set*";
AddSideString(""); // foolish
AddSideString(format("Custom Name: ", name_s), GUIColor());
AddSideString(
format("Custom Disconnect Reason: ", reason_s),
GUIColor());*/
}
}
}
}
@ -182,7 +92,7 @@ void DrawCheatVisuals()
}
{
PROF_SECTION(DRAW_WRAPPER);
EC::RunDraw();
EC::run(EC::Draw);
}
if (CE_GOOD(g_pLocalPlayer->entity) && !g_Settings.bInvalid)
{