stack corruption

This commit is contained in:
nullifiedcat 2017-11-12 14:15:20 +03:00
parent 918b23fc92
commit c3b41f9acb
27 changed files with 192 additions and 137 deletions

View File

@ -35,7 +35,7 @@
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1168214098." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.965909756" name="Linux GCC" nonInternalBuilderId="cdt.managedbuild.target.gnu.builder.exe.debug" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1799148153" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder arguments="build-debug-tf2" buildPath="${workspace_loc:/cathook}" command="bash" id="cdt.managedbuild.target.gnu.builder.exe.debug.1548213350" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<builder arguments="BUILD_DEBUG=1" buildPath="${workspace_loc:/cathook}" command="make" id="cdt.managedbuild.target.gnu.builder.exe.debug.1548213350" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.782611349" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.883030293" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.908662295" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>

View File

@ -12,7 +12,7 @@
# NO_TF2_RENDERING - disable in-game rendering (does not work yet)
# TEXTMODE_STDIN - allows using console with textmode tf2
# TEXTMODE_VAC - allows joining VAC-secured servers in textmode
# EXTERNAL_RENDERING - enabled Xoverlay rendering, disables ImGui
# RENDERING_ENGINE - (OPENGL, XOVERLAY)
#
GAME=tf2
@ -23,7 +23,7 @@ ENABLE_IPC=1
ENABLE_NULL_GRAPHICS=0
TEXTMODE_STDIN=0
TEXTMODE_VAC=0
EXTERNAL_RENDERING=0
RENDERING_ENGINE=XOVERLAY
DATA_PATH="/opt/cathook/data"
NO_LTO=0
ifdef CLANG
@ -77,7 +77,7 @@ ENABLE_GUI=0
endif
DEFINES+=_GLIBCXX_USE_CXX11_ABI=0 _POSIX=1 FREETYPE_GL_USE_VAO=1 RAD_TELEMETRY_DISABLED=1 LINUX=1 USE_SDL=1 _LINUX=1 POSIX=1 GNUC=1 NO_MALLOC_OVERRIDE=1
DEFINES+=XOVERLAY=$(EXTERNAL_RENDERING) ENABLE_VISUALS=$(ENABLE_VISUALS) ENABLE_GUI=$(ENABLE_GUI) ENABLE_IPC=$(ENABLE_IPC) BUILD_GAME=$(GAME) ENABLE_NULL_GRAPHICS=$(ENABLE_NULL_GRAPHICS) TEXTMODE_STDIN=$(TEXTMODE_STDIN) TEXTMODE_VAC=$(TEXTMODE_VAC) DATA_PATH="\"$(DATA_PATH)\""
DEFINES+=RENDERING_ENGINE_$(RENDERING_ENGINE)=1 ENABLE_VISUALS=$(ENABLE_VISUALS) ENABLE_GUI=$(ENABLE_GUI) ENABLE_IPC=$(ENABLE_IPC) BUILD_GAME=$(GAME) ENABLE_NULL_GRAPHICS=$(ENABLE_NULL_GRAPHICS) TEXTMODE_STDIN=$(TEXTMODE_STDIN) TEXTMODE_VAC=$(TEXTMODE_VAC) DATA_PATH="\"$(DATA_PATH)\""
WARNING_FLAGS=-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef
COMMON_FLAGS=-fpermissive -O3 -shared -Wno-unknown-pragmas -fmessage-length=0 -m32 -fvisibility=hidden -fPIC -march=native -mtune=native
@ -106,7 +106,7 @@ CXXFLAGS+=$(WARNING_FLAGS)
endif
ifeq ($(ENABLE_VISUALS),1)
ifeq ($(EXTERNAL_RENDERING), 1)
ifeq ($(RENDERING_ENGINE), xoverlay)
LDLIBS+=-loverlay
endif
INCLUDES+=-isystemsrc/freetype-gl -isystemsrc/imgui -isystem/usr/local/include/freetype2 -isystem/usr/include/freetype2
@ -114,7 +114,7 @@ LDLIBS+=-lssl -l:libSDL2-2.0.so.0 -l:libGLEW.so -l:libfreetype.so
CXXFLAGS+=$(shell sdl2-config --cflags)
CFLAGS+=$(shell sdl2-config --cflags)
else
EXCL_SOURCES:=xoverlay.cpp catpclient.c pipepacket.c hacks/ESP.cpp hacks/SkinChanger.cpp hacks/SpyAlert.cpp hacks/Radar.cpp fidgetspinner.cpp ftrender.cpp hooks/sdl.cpp drawing.cpp drawmgr.cpp drawgl.cpp hooks/PaintTraverse.cpp EffectChams.cpp EffectGlow.cpp atlas.cpp
EXCL_SOURCES:=drawex.cpp catpclient.c pipepacket.c hacks/ESP.cpp hacks/SkinChanger.cpp hacks/SpyAlert.cpp hacks/Radar.cpp fidgetspinner.cpp ftrender.cpp hooks/sdl.cpp drawing.cpp drawmgr.cpp drawgl.cpp hooks/PaintTraverse.cpp EffectChams.cpp EffectGlow.cpp atlas.cpp
EXCL_SOURCES:=$(addprefix $(SRC_DIR)/,$(EXCL_SOURCES))
SOURCES:=$(filter-out $(shell find $(SRC_DIR)/gui -name "*.cpp" -print),$(SOURCES))
@ -194,11 +194,11 @@ src/freetype-gl/vertex-buffer.o : CFLAGS+=-w
.cpp.o:
@echo Compiling $<
@$(CXX) $(CXXFLAGS) -c $< -o $@
$(CXX) $(CXXFLAGS) -c $< -o $@
.c.o:
@echo Compiling $<
@$(CC) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) -c $< -o $@
%.d: %.cpp
@$(CXX) -M $(CXXFLAGS) $< > $@

View File

@ -10,7 +10,6 @@
#include "atlas.hpp"
#include "drawing.h"
#include "drawgl.hpp"
#include "logging.h"
namespace textures {
@ -20,8 +19,8 @@ AtlasTexture::AtlasTexture(float x, float y, float sx, float sy) {
tex_coords[1] = ftgl::vec2{ (x - 0.5f + sx) / atlas_width, (y + 0.5f) / atlas_height };
}
void AtlasTexture::Draw(float x, float y, float sx, float sy) {
drawgl::draw_rect_textured(x, y, sx, sy, tex_coords[0].x, tex_coords[0].y, tex_coords[1].x, tex_coords[1].y);
void AtlasTexture::Draw(float x, float y, const float *color, float sx, float sy) {
draw_api::draw_rect_textured(x, y, sx, sy, color, tex_coords[0].x, tex_coords[0].y, tex_coords[1].x, tex_coords[1].y);
}
GLuint texture;

View File

@ -25,7 +25,7 @@ constexpr float atlas_height = 512.0f;
class AtlasTexture {
public:
AtlasTexture(float x, float y, float sx, float sy);
void Draw(float x, float y, float sx, float sy);
void Draw(float x, float y, const float *color, float sx, float sy);
public:
ftgl::vec2 tex_coords[2];
};

View File

@ -10,7 +10,7 @@
#include "pipepacket.h"
void
cat_send_render_packet_begin(int fd, float *world_to_screen)
cat_send_render_packet_begin(int fd, const float *world_to_screen)
{
struct catp_draw_begin_t packet;
memcpy(packet.world_to_screen, world_to_screen, sizeof(float) * 16);
@ -24,7 +24,7 @@ cat_send_render_packet_end(int fd)
}
void
cat_send_render_packet_rect(int fd, float x, float y, float w, float h, float *rgba)
cat_send_render_packet_rect(int fd, float x, float y, float w, float h, const float *rgba)
{
struct catp_draw_rect_t packet;
packet.x = x;
@ -36,7 +36,7 @@ cat_send_render_packet_rect(int fd, float x, float y, float w, float h, float *r
}
void
cat_send_render_packet_rect_outline(int fd, float x, float y, float w, float h, float *rgba, float thickness)
cat_send_render_packet_rect_outline(int fd, float x, float y, float w, float h, const float *rgba, float thickness)
{
struct catp_draw_rect_outline_t packet;
packet.x = x;
@ -49,7 +49,7 @@ cat_send_render_packet_rect_outline(int fd, float x, float y, float w, float h,
}
void
cat_send_render_packet_line(int fd, float x, float y, float dx, float dy, float *rgba, float thickness)
cat_send_render_packet_line(int fd, float x, float y, float dx, float dy, const float *rgba, float thickness)
{
struct catp_draw_line_t packet;
packet.x = x;
@ -62,7 +62,7 @@ cat_send_render_packet_line(int fd, float x, float y, float dx, float dy, float
}
void
cat_send_render_packet_string(int fd, float x, float y, const char *string, float *rgba)
cat_send_render_packet_string(int fd, float x, float y, const char *string, const float *rgba)
{
struct catp_draw_string_t packet;
packet.x = x;
@ -74,7 +74,7 @@ cat_send_render_packet_string(int fd, float x, float y, const char *string, floa
}
void
cat_send_render_packet_circle(int fd, float x, float y, float radius, float *rgba, float thickness, int steps)
cat_send_render_packet_circle(int fd, float x, float y, float radius, const float *rgba, float thickness, int steps)
{
struct catp_draw_circle_t packet;
packet.x = x;

View File

@ -8,7 +8,7 @@
#pragma once
void
cat_send_render_packet_begin(int fd, float *world_to_screen);
cat_send_render_packet_begin(int fd, const float *world_to_screen);
void
cat_send_render_packet_end(int fd);

View File

@ -51,7 +51,7 @@ extern "C" {
#include "ftrender.hpp"
#include "drawing.h"
#include "fidgetspinner.hpp"
#include "drawgl.hpp"
#include DRAW_API
#include "EffectGlow.hpp"
#include "atlas.hpp"
#include "EffectChams.hpp"

View File

@ -5,6 +5,8 @@
* Author: nullifiedcat
*/
#include "drawing.h"
#include "colors.hpp"
#include "drawex.hpp"
#include "catpclient.h"
@ -14,6 +16,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
const char *drawex_pipe_name = "/tmp/cathook-rendering-pipe";
@ -25,29 +28,37 @@ int pipe_fd;
namespace api
{
bool ready_state = false;
void intialize()
{
pipe_fd = open(drawex_pipe_name, O_WRONLY);
ready_state = true;
}
void draw_rect(float x, float y, float w, float h, const float* rgba = colors::white)
void draw_rect(float x, float y, float w, float h, const float* rgba)
{
cat_send_render_packet_rect(pipe_fd, x, y, w, h, rgba);
}
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba = colors::white, float thickness)
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba, float thickness)
{
cat_send_render_packet_rect_outline(pipe_fd, x, y, w, h, rgba, thickness);
}
void draw_line(float x, float y, float dx, float dy, const float* rgba = colors::white, float thickness)
void draw_line(float x, float y, float dx, float dy, const float* rgba, float thickness)
{
cat_send_render_packet_line(pipe_fd, x, y, dx, dy, rgba, thickness);
}
void draw_rect_textured(float x, float y, float w, float h, const float* rgba = colors::white, float u, float v, float s, float t)
void draw_rect_textured(float x, float y, float w, float h, const float* rgba, float u, float v, float s, float t)
{
static_assert(0, "draw_rect_textured is not implemented");
assert(0);
}
void draw_circle(float x, float y, float radius, const float *rgba, float thickness, int steps)
{
cat_send_render_packet_circle(pipe_fd, x, y, radius, rgba, thickness, steps);
}
void draw_begin()

View File

@ -17,12 +17,15 @@ extern int pipe_fd;
namespace api
{
extern bool ready_state;
void intialize();
void draw_rect(float x, float y, float w, float h, const float* rgba = colors::white);
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba = colors::white, float thickness);
void draw_line(float x, float y, float dx, float dy, const float* rgba = colors::white, float thickness);
void draw_rect_textured(float x, float y, float w, float h, const float* rgba = colors::white, float u, float v, float s, float t);
void draw_rect(float x, float y, float w, float h, const float* rgba);
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba, float thickness);
void draw_line(float x, float y, float dx, float dy, const float* rgba, float thickness);
void draw_rect_textured(float x, float y, float w, float h, const float* rgba, float u, float v, float s, float t);
void draw_circle(float x, float y, float radius, const float *rgba, float thickness, int steps);
void draw_begin();
void draw_end();

View File

@ -65,9 +65,9 @@ void intialize() {
textures::Init();
// Do not fucking ask. Without this, it crashes.
drawgl::draw_rect_outlined(0, 0, 0, 0);
drawgl::draw_rect(0, 0, 0, 0);
drawgl::draw_rect_textured(0, 0, 0, 0, 0, 0, 0, 0);
draw_api::draw_rect_outlined(0, 0, 0, 0, colors::white, 0.0f);
draw_api::draw_rect(0, 0, 0, 0, colors::white);
draw_api::draw_rect_textured(0, 0, 0, 0, colors::white, 0, 0, 0, 0);
ready_state = true;
draw_end();
}
@ -90,7 +90,7 @@ void draw_rect(float x, float y, float w, float h, const float* rgba) {
vertex_buffer_push_back_vertices(buffer_triangles_plain, vertices, 4);
}
void draw_line(float x, float y, float dx, float dy, const float* rgba) {
void draw_line(float x, float y, float dx, float dy, const float* rgba, float thickness) {
GLuint idx = buffer_lines->vertices->size;
GLuint indices[] = { idx, idx + 1 };
vertex_v2c4_t vertices[] = {
@ -101,7 +101,7 @@ void draw_line(float x, float y, float dx, float dy, const float* rgba) {
vertex_buffer_push_back_vertices(buffer_lines, vertices, 2);
}
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba) {
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba, float thickness) {
GLuint idx = buffer_lines->vertices->size;
GLuint indices[] = { idx, idx + 1, idx + 1, idx + 2, idx + 2, idx + 3, idx + 3, idx };
vertex_v2c4_t vertices[] = {
@ -114,7 +114,7 @@ void draw_rect_outlined(float x, float y, float w, float h, const float* rgba) {
vertex_buffer_push_back_vertices(buffer_lines, vertices, 4);
}
void draw_rect_textured(float x, float y, float w, float h, float u, float v, float u2, float v2, const float* rgba) {
void draw_rect_textured(float x, float y, float w, float h, const float* rgba, float u, float v, float u2, float v2) {
GLuint idx = buffer_triangles_textured->vertices->size;
GLuint indices[] = { idx, idx + 1, idx + 2, idx, idx + 2, idx + 3 };
vertex_v2t2c4_t vertices[] = {
@ -127,6 +127,25 @@ void draw_rect_textured(float x, float y, float w, float h, float u, float v, fl
vertex_buffer_push_back_vertices(buffer_triangles_textured, vertices, 4);
}
void draw_circle(float x, float y, float radius, const float *rgba, float thickness, int steps)
{
float px = 0;
float py = 0;
for (int i = 0; i < steps; i++) {
float ang = 2 * PI * (float(i) / steps);
float zx = x + radius * cos(ang);
float zy = y + radius * sin(ang);
if (!i) {
ang = 2 * PI * (float(steps - 1) / steps);
px = x + radius * cos(ang);
py = y + radius * sin(ang);
}
draw_api::draw_line(px, py, zx - px, zy - py, rgba, thickness);
px = x;
py = y;
}
}
void draw_begin() {
vertex_buffer_clear(buffer_triangles_plain);
vertex_buffer_clear(buffer_triangles_textured);

View File

@ -10,7 +10,7 @@
#include "drawing.h"
#define draw_api drawgl::api
#define draw_api drawgl
extern "C" {
#include "freetype-gl/vec234.h"
@ -38,10 +38,11 @@ extern const float white[4];
void intialize();
void draw_rect(float x, float y, float w, float h, const float* rgba = white);
void draw_line(float x, float y, float dx, float dy, const float* rgba = white);
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba = white);
void draw_rect_textured(float x, float y, float w, float h, float u, float v, float u2, float v2, const float* rgba = white);
void draw_rect(float x, float y, float w, float h, const float* rgba);
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba, float thickness);
void draw_line(float x, float y, float dx, float dy, const float* rgba, float thickness);
void draw_rect_textured(float x, float y, float w, float h, const float* rgba, float u, float v, float s, float t);
void draw_circle(float x, float y, float radius, const float *rgba, float thickness, int steps);
void draw_begin();
void draw_end();

View File

@ -74,13 +74,15 @@ void draw::Initialize() {
if (!draw::width || !draw::height) {
g_IEngine->GetScreenSize(draw::width, draw::height);
}
draw_api::intialize();
#ifdef RENDERING_ENGINE_OPENGL
FTGL_PreInit();
fonts::font_ftgl.InstallChangeCallback([](IConVar* var, const char* pOldValue, float flOldValue) {
FTGL_ChangeFont(&fonts::font_main, fonts::font_ftgl.GetString());
(void)flOldValue;
});
#endif
}
bool draw::EntityCenterToScreen(CachedEntity* entity, Vector& out) {
@ -95,7 +97,7 @@ bool draw::EntityCenterToScreen(CachedEntity* entity, Vector& out) {
return succ;
}
VMatrix wts {};
VMatrix draw::wts {};
void draw::UpdateWTS() {
memcpy(&wts, &g_IEngine->WorldToScreenMatrix(), sizeof(VMatrix));

View File

@ -8,6 +8,12 @@
#ifndef DRAWING_H_
#define DRAWING_H_
#if RENDERING_ENGINE_OPENGL
#define DRAW_API "drawgl.hpp"
#elif RENDERING_ENGINE_XOVERLAY
#define DRAW_API "drawex.hpp"
#endif
#include "common.h"
extern "C" {
@ -19,6 +25,7 @@ class Vector;
class CatVar;
class IClientEntity;
class CatEnum;
class VMatrix;
namespace fonts {

View File

@ -10,9 +10,9 @@
void BeginCheatVisuals() {
std::lock_guard<std::mutex> draw_lock(drawing_mutex);
if (drawgl::ready_state) {
if (draw_api::ready_state) {
FTGL_NewFrame();
drawgl::draw_begin();
draw_api::draw_begin();
ResetStrings();
}
}
@ -24,7 +24,7 @@ CatVar info_text_min(CV_SWITCH, "info_min", "0", "Show minimal info", "Only show
void DrawCheatVisuals() {
std::lock_guard<std::mutex> draw_lock(drawing_mutex);
if (drawgl::ready_state) {
if (draw_api::ready_state) {
{
PROF_SECTION(DRAW_misc);
SAFE_CALL(hacks::shared::misc::DrawText());
@ -69,10 +69,12 @@ void DrawCheatVisuals() {
PROF_SECTION(DRAW_skinchanger);
SAFE_CALL(hacks::tf2::skinchanger::DrawText());
}
#ifndef FEATURES_RADAR_DISABLED
IF_GAME(IsTF()) {
PROF_SECTION(DRAW_radar);
SAFE_CALL(hacks::tf::radar::Draw());
}
#endif
IF_GAME(IsTF2()) {
PROF_SECTION(DRAW_healarrows);
hacks::tf2::healarrow::Draw();
@ -96,7 +98,9 @@ void DrawCheatVisuals() {
PROF_SECTION(DRAW_esp);
hacks::shared::esp::Draw();
}
#ifndef FEATURE_FIDGET_SPINNER_DISABLED
DrawSpinner();
#endif
Prediction_PaintTraverse();
}
{
@ -108,7 +112,7 @@ void DrawCheatVisuals() {
}
void EndCheatVisuals() {
if (drawgl::ready_state) {
if (draw_api::ready_state) {
}
}

View File

@ -7,6 +7,8 @@
#include "fidgetspinner.hpp"
#ifndef FEATURE_FIDGET_SPINNER_DISABLED
CatVar enable_spinner(CV_SWITCH, "fidgetspinner", "0", "Fidget Spinner", "Part of Cathook Autism Awareness program");
std::vector<textures::AtlasTexture> spinner_states {};
@ -77,7 +79,7 @@ void DrawSpinner() {
}
int state = min(3, spinning_speed / 250.0f);
// Paste from drawgl::
// Paste from draw_api::
using namespace drawgl;
using namespace ftgl;
@ -96,3 +98,5 @@ void DrawSpinner() {
if (angle > PI * 4) angle -= PI * 4;
}
#endif

View File

@ -10,21 +10,8 @@
#include "common.h"
#define STRINGIFY(x) #x
#define TO_STRING(x) STRINGIFY(x)
/*
* make -j4 -e GAME=tf2
*/
// http://stackoverflow.com/questions/2335888/how-to-compare-string-in-c-conditional-preprocessor-directives
constexpr int c_strcmp( char const* lhs, char const* rhs ) {
return (('\0' == lhs[0]) && ('\0' == rhs[0])) ? 0
: (lhs[0] != rhs[0]) ? (lhs[0] - rhs[0])
: c_strcmp( lhs+1, rhs+1 );
}
#ifdef BUILD_GAME
constexpr bool IsTF2() { return !c_strcmp(TO_STRING(BUILD_GAME), "tf2"); }
constexpr bool IsTF2C() { return !c_strcmp(TO_STRING(BUILD_GAME), "tf2c"); }
constexpr bool IsHL2DM() { return !c_strcmp(TO_STRING(BUILD_GAME), "hl2dm"); }

View File

@ -328,8 +328,10 @@ void hack::Initialize() {
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow");
}
logging::Info("SSE enabled..");
#if RENDERING_ENGINE_OPENGL
DoSDLHooking();
logging::Info("SDL hooking done");
#endif
g_IGameEventManager->AddListener(&adv_event_listener, false);
#endif /* TEXTMODE */
@ -338,8 +340,10 @@ void hack::Initialize() {
hacks::tf2::healarrow::Init();
#if ENABLE_VISUALS == 1
#ifndef FEATURE_FIDGET_SPINNER_DISABLED
InitSpinner();
logging::Info("Initialized Fidget Spinner");
#endif
hacks::shared::spam::Init();
backpacktf::init();
logging::Info("Initialized Backpack.TF integration");

View File

@ -825,23 +825,7 @@ void DrawText() {
float fov_real = RAD2DEG(2 * atanf(mon_fov * tanf(DEG2RAD(draw::fov / 2))));
float radius = tan(DEG2RAD(float(fov)) / 2) / tan(DEG2RAD(fov_real) / 2) * (width);
// Draw a circle
float px = 0;
float py = 0;
constexpr float steps = 120;
for (int i = 0; i < steps; i++) {
float ang = 2 * PI * (float(i) / steps);
float x = width / 2 + radius * cos(ang);
float y = height / 2 + radius * sin(ang);
if (!i) {
ang = 2 * PI * (float(steps - 1) / steps);
px = width / 2 + radius * cos(ang);
py = height / 2 + radius * sin(ang);
}
drawgl::draw_line(px, py, x - px, y - py, color);
px = x;
py = y;
}
draw_api::draw_circle(width / 2, height / 2, radius, color, 1, 100);
}
}
}
@ -853,8 +837,8 @@ void DrawText() {
Vector screen;
Vector oscreen;
if (draw::WorldToScreen(calculated_data_array[i].aim_position, screen) && draw::WorldToScreen(ent->m_vecOrigin, oscreen)) {
drawgl::draw_rect(screen.x - 2, screen.y - 2, 4, 4);
drawgl::draw_line(oscreen.x, oscreen.y, screen.x - oscreen.x, screen.y - oscreen.y);
draw_api::draw_rect(screen.x - 2, screen.y - 2, 4, 4, colors::white);
draw_api::draw_line(oscreen.x, oscreen.y, screen.x - oscreen.x, screen.y - oscreen.y, colors::EntityF(ent), 0.5f);
}
}
}

View File

@ -22,11 +22,13 @@ CatVar box_corner_size(CV_INT, "esp_box_corner_size", "10", "Corner Size");
CatEnum tracers_enum({ "OFF", "CENTER", "BOTTOM" });
CatVar tracers(tracers_enum, "esp_tracers", "0", "Tracers", "SDraws a line from the player to a position on your screen");
// Emoji Esp
#ifndef FEATURES_EMOJI_ESP_DISABLED
CatEnum emoji_esp_enum({ "None", "Joy", "Thinking" });
CatVar emoji_esp(emoji_esp_enum, "esp_emoji", "0", "Emoji ESP", "Draw emoji on peopels head");
CatVar emoji_esp_size(CV_FLOAT, "esp_emoji_size", "32", "Emoji ESP Size");
CatVar emoji_esp_scaling(CV_SWITCH, "esp_emoji_scaling", "1", "Emoji ESP Scaling");
CatVar emoji_min_size(CV_INT, "esp_emoji_min_size", "20", "Emoji ESP min size", "Minimum size for an emoji when you use auto scaling");
#endif
// Other esp options
CatEnum show_health_enum({ "None", "Text", "Healthbar", "Both" });
CatVar show_health(show_health_enum, "esp_health", "3", "Health ESP", "Show enemy health");
@ -146,7 +148,7 @@ struct bonelist_s {
return;
}
if (i > 0) {
drawgl::draw_line(last_screen.x, last_screen.y, current_screen.x - last_screen.x, current_screen.y - last_screen.y, color);
draw_api::draw_line(last_screen.x, last_screen.y, current_screen.x - last_screen.x, current_screen.y - last_screen.y, color, 0.5f);
}
last_screen = current_screen;
}
@ -300,7 +302,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
draw::WorldToScreen(ent->m_vecOrigin, scn);
// Draw a line
drawgl::draw_line(scn.x, scn.y, width - scn.x, height - scn.y, fg);
draw_api::draw_line(scn.x, scn.y, width - scn.x, height - scn.y, fg, 0.5f);
}
// Sightline esp
@ -379,12 +381,12 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
}
// We have both vectors, draw
if (found_scn1) {
drawgl::draw_line(scn1.x, scn1.y, scn2.x - scn1.x, scn2.y - scn1.y, fg);
draw_api::draw_line(scn1.x, scn1.y, scn2.x - scn1.x, scn2.y - scn1.y, fg, 0.5f);
}
}
}
}
#ifndef FEATURE_EMOJI_ESP_DISABLED
// Emoji esp
if (emoji_esp) {
if (ent->m_Type == ENTITY_PLAYER) {
@ -405,12 +407,12 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
if (int(emoji_esp) == 1) tx = &joy_texture;
if (int(emoji_esp) == 2) tx = &thinking_texture;
if (tx)
tx->Draw(head_scr.x - size / 2, head_scr.y - size / 2, size, size);
tx->Draw(head_scr.x - size / 2, head_scr.y - size / 2, colors::white, size, size);
}
}
}
}
#endif
// Box esp
if (box_esp) {
switch (ent->m_Type) {
@ -466,8 +468,8 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
int hbh = (max_y - min_y - 2) * min((float)health / (float)healthmax, 1.0f);
// Draw
drawgl::draw_rect_outlined(min_x - 7, min_y, 7, max_y - min_y, border);
drawgl::draw_rect(min_x - 6, max_y - hbh - 1, 5, hbh, hp);
draw_api::draw_rect_outlined(min_x - 7, min_y, 7, max_y - min_y, border, 0.5f);
draw_api::draw_rect(min_x - 6, max_y - hbh - 1, 5, hbh, hp);
}
}
}
@ -583,7 +585,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
if (!draw::WorldToScreen(box_points[iii], scn2)) continue;
// Draw between points
drawgl::Line(scn1.x, scn1.y, scn2.x - scn1.x, scn2.y - scn1.y, fg);
draw_api::Line(scn1.x, scn1.y, scn2.x - scn1.x, scn2.y - scn1.y, fg);
}
}
}
@ -905,9 +907,9 @@ void _FASTCALL DrawBox(CachedEntity* ent, const rgba_t& clr) {
BoxCorners(min_x, min_y, max_x, max_y, clr, (clr.a != 1.0f));
// Otherwise, we just do simple draw funcs
else {
drawgl::draw_rect_outlined(min_x, min_y, max_x - min_x, max_y - min_y, border);
drawgl::draw_rect_outlined(min_x + 1, min_y + 1, max_x - min_x - 2, max_y - min_y - 2, clr);
drawgl::draw_rect_outlined(min_x + 2, min_y + 2, max_x - min_x - 4, max_y - min_y - 4, border);
draw_api::draw_rect_outlined(min_x, min_y, max_x - min_x, max_y - min_y, border, 0.5f);
draw_api::draw_rect_outlined(min_x + 1, min_y + 1, max_x - min_x - 2, max_y - min_y - 2, clr, 0.5f);
draw_api::draw_rect_outlined(min_x + 2, min_y + 2, max_x - min_x - 4, max_y - min_y - 4, border, 0.5f);
}
}
@ -918,31 +920,31 @@ void BoxCorners(int minx, int miny, int maxx, int maxy, const rgba_t& color, boo
// Black corners
// Top Left
drawgl::draw_rect(minx, miny, size, 3, black);
drawgl::draw_rect(minx, miny + 3, 3, size - 3, black);
draw_api::draw_rect(minx, miny, size, 3, black);
draw_api::draw_rect(minx, miny + 3, 3, size - 3, black);
// Top Right
drawgl::draw_rect(maxx - size + 1, miny, size, 3, black);
drawgl::draw_rect(maxx - 3 + 1, miny + 3, 3, size - 3, black);
draw_api::draw_rect(maxx - size + 1, miny, size, 3, black);
draw_api::draw_rect(maxx - 3 + 1, miny + 3, 3, size - 3, black);
// Bottom Left
drawgl::draw_rect(minx, maxy - 3, size, 3, black);
drawgl::draw_rect(minx, maxy - size, 3, size - 3, black);
draw_api::draw_rect(minx, maxy - 3, size, 3, black);
draw_api::draw_rect(minx, maxy - size, 3, size - 3, black);
// Bottom Right
drawgl::draw_rect(maxx - size + 1, maxy - 3, size, 3, black);
drawgl::draw_rect(maxx - 2, maxy - size, 3, size - 3, black);
draw_api::draw_rect(maxx - size + 1, maxy - 3, size, 3, black);
draw_api::draw_rect(maxx - 2, maxy - size, 3, size - 3, black);
// Colored corners
// Top Left
drawgl::draw_line(minx + 1, miny + 1, size - 2, 0, color);
drawgl::draw_line(minx + 1, miny + 1, 0, size - 2, color);
draw_api::draw_line(minx + 1, miny + 1, size - 2, 0, color, 0.5f);
draw_api::draw_line(minx + 1, miny + 1, 0, size - 2, color, 0.5f);
// Top Right
drawgl::draw_line(maxx - 1, miny + 1, -(size - 2), 0, color);
drawgl::draw_line(maxx - 1, miny + 1, 0, size - 2, color);
draw_api::draw_line(maxx - 1, miny + 1, -(size - 2), 0, color, 0.5f);
draw_api::draw_line(maxx - 1, miny + 1, 0, size - 2, color, 0.5f);
// Bottom Left
drawgl::draw_line(minx + 1, maxy - 2, size - 2, 0, color);
drawgl::draw_line(minx + 1, maxy - 2, 0, -(size - 2), color);
draw_api::draw_line(minx + 1, maxy - 2, size - 2, 0, color, 0.5f);
draw_api::draw_line(minx + 1, maxy - 2, 0, -(size - 2), color, 0.5f);
// Bottom Right
drawgl::draw_line(maxx - 1, maxy - 2, -(size - 2), 0, color);
drawgl::draw_line(maxx - 1, maxy - 2, 0, -(size - 2), color);
draw_api::draw_line(maxx - 1, maxy - 2, -(size - 2), 0, color, 0.5f);
draw_api::draw_line(maxx - 1, maxy - 2, 0, -(size - 2), color, 0.5f);
}
// Used for caching collidable bounds

View File

@ -727,7 +727,7 @@ void DrawFollowbot() {
// Create a vector for the screen, run world to screen to bring the world vector into the screen vector, then draw a rect at the point
Vector scn;
draw::WorldToScreen(destination_point, scn);
drawgl::FilledRect(scn.x - 3, scn.y - 3, 6, 6);
draw_api::FilledRect(scn.x - 3, scn.y - 3, 6, 6);
// Return as we are finished
break;
@ -742,7 +742,7 @@ void DrawFollowbot() {
// Get the entity vector to screen and draw a rect on it
Vector scn;
draw::WorldToScreen(breadcrumbs[crumbBottom], scn);
drawgl::FilledRect(scn.x - 3, scn.y - 3, 6, 6);
draw_api::FilledRect(scn.x - 3, scn.y - 3, 6, 6);
}
// Return as we have nothing else to do
@ -771,11 +771,11 @@ void DrawFollowbot() {
draw::WorldToScreen(breadcrumbs[tmpCrumb2], scnEnd);
// Draw a line from one crumb to the other
drawgl::Line(scnSrt.x, scnSrt.y, scnEnd.x - scnSrt.x, scnEnd.y - scnSrt.y, colors::white);
draw_api::Line(scnSrt.x, scnSrt.y, scnEnd.x - scnSrt.x, scnEnd.y - scnSrt.y, colors::white);
// If this is our first iteration, draw a box on 1
if (i == 1)
drawgl::FilledRect(scnSrt.x - 3, scnSrt.y - 3, 6, 6);
draw_api::FilledRect(scnSrt.x - 3, scnSrt.y - 3, 6, 6);
}
break;
}*/
@ -790,7 +790,7 @@ void DrawFollowbot() {
// Get the entity vector to screen and draw a rect on it
Vector scn;
draw::WorldToScreen(breadcrumbs[crumbBottom], scn);
drawgl::draw_rect(scn.x - 3, scn.y - 3, 6, 6);
draw_api::draw_rect(scn.x - 3, scn.y - 3, 6, 6, colors::white);
}
// Return as we have nothing else to do
@ -819,11 +819,11 @@ void DrawFollowbot() {
draw::WorldToScreen(breadcrumbs[tmpCrumb2], scnEnd);
// Draw a line from one crumb to the other
drawgl::draw_line(scnSrt.x, scnSrt.y, scnEnd.x - scnSrt.x, scnEnd.y - scnSrt.y, colors::white);
draw_api::draw_line(scnSrt.x, scnSrt.y, scnEnd.x - scnSrt.x, scnEnd.y - scnSrt.y, colors::white, 0.5f);
// If this is our first iteration, draw a box on 1
if (i == 0)
drawgl::draw_rect(scnSrt.x - 3, scnSrt.y - 3, 6, 6);
draw_api::draw_rect(scnSrt.x - 3, scnSrt.y - 3, 6, 6, colors::white);
}
return;
}

View File

@ -388,7 +388,7 @@ void DrawText() {
rgba_t gaybow = colors::FromHSL(fabs(sin((g_GlobalVars->curtime / 2.0f) + (i / 2))) * 360.0f, 0.85f, 0.9f);
gaybow.a = .5;
// Draw next step
drawgl::FilledRect(0, step * (i - 1), width, (step * i) - (step * (i - 1)), gaybow);
draw_api::FilledRect(0, step * (i - 1), width, (step * i) - (step * (i - 1)), gaybow);
}
//int size_x;

View File

@ -8,6 +8,8 @@
#include "Radar.hpp"
#include "../common.h"
#ifndef FEATURE_RADAR_DISABLED
namespace hacks { namespace tf { namespace radar {
std::unique_ptr<textures::AtlasTexture> tx_classes[3][9];
@ -86,19 +88,19 @@ void DrawEntity(int x, int y, CachedEntity* ent) {
const auto& wtr = WorldToRadar(ent->m_vecOrigin.x, ent->m_vecOrigin.y);
if (use_icons) {
tx_teams[idx].get()->Draw(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size);
tx_classes[2][clazz - 1].get()->Draw(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size);
tx_teams[idx].get()->Draw(x + wtr.first, y + wtr.second, colors::white, (int)icon_size, (int)icon_size);
tx_classes[2][clazz - 1].get()->Draw(x + wtr.first, y + wtr.second, colors::white, (int)icon_size, (int)icon_size);
} else {
tx_classes[idx][clazz - 1].get()->Draw(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size);
drawgl::draw_rect_outlined(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size, idx ? colors::blu_v : colors::red_v);
tx_classes[idx][clazz - 1].get()->Draw(x + wtr.first, y + wtr.second, colors::white, (int)icon_size, (int)icon_size);
draw_api::draw_rect_outlined(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size, idx ? colors::blu_v : colors::red_v, 0.5f);
}
if (ent->m_iMaxHealth && healthbar) {
healthp = (float)ent->m_iHealth / (float)ent->m_iMaxHealth;
clr = colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
if (healthp > 1.0f) healthp = 1.0f;
drawgl::draw_rect_outlined(x + wtr.first, y + wtr.second + (int)icon_size, (int)icon_size, 4, colors::black);
drawgl::draw_rect(x + wtr.first + 1, y + wtr.second + (int)icon_size + 1, ((float)icon_size - 2.0f) * healthp, 2, clr);
draw_api::draw_rect_outlined(x + wtr.first, y + wtr.second + (int)icon_size, (int)icon_size, 4, colors::black, 0.5f);
draw_api::draw_rect(x + wtr.first + 1, y + wtr.second + (int)icon_size + 1, ((float)icon_size - 2.0f) * healthp, 2, clr);
}
} else if (ent->m_Type == ENTITY_BUILDING) {
/*if (ent->m_iClassID == CL_CLASS(CObjectDispenser)) {
@ -121,12 +123,12 @@ void DrawEntity(int x, int y, CachedEntity* ent) {
const auto& wtr = WorldToRadar(ent->m_vecOrigin.x, ent->m_vecOrigin.y);
float sz = float(icon_size) * 0.15f * 0.5f;
float sz2 = float(icon_size) * 0.85;
tx_items[1].get()->Draw(x + wtr.first + sz, y + wtr.second + sz, sz2, sz2);
tx_items[1].get()->Draw(x + wtr.first + sz, y + wtr.second + sz, colors::white, sz2, sz2);
} else if (show_ammopacks && (ent->m_ItemType == ITEM_AMMO_LARGE || ent->m_ItemType == ITEM_AMMO_MEDIUM || ent->m_ItemType == ITEM_AMMO_SMALL)) {
const auto& wtr = WorldToRadar(ent->m_vecOrigin.x, ent->m_vecOrigin.y);
float sz = float(icon_size) * 0.15f * 0.5f;
float sz2 = float(icon_size) * 0.85;
tx_items[0].get()->Draw(x + wtr.first + sz, y + wtr.second + sz, sz2, sz2);
tx_items[0].get()->Draw(x + wtr.first + sz, y + wtr.second + sz, colors::white, sz2, sz2);
}
}
}
@ -147,8 +149,8 @@ void Draw() {
outlineclr = (hacks::shared::aimbot::foundTarget ? colors::pink : GUIColor());
drawgl::draw_rect(x, y, radar_size, radar_size, colors::Transparent(colors::black, 0.4f));
drawgl::draw_rect_outlined(x, y, radar_size, radar_size, outlineclr);
draw_api::draw_rect(x, y, radar_size, radar_size, colors::Transparent(colors::black, 0.4f));
draw_api::draw_rect_outlined(x, y, radar_size, radar_size, outlineclr, 0.5f);
if (enemies_over_teammates) enemies.clear();
for (int i = 1; i < HIGHEST_ENTITY; i++) {
@ -173,11 +175,13 @@ void Draw() {
DrawEntity(x, y, LOCAL_E);
const auto& wtr = WorldToRadar(g_pLocalPlayer->v_Origin.x, g_pLocalPlayer->v_Origin.y);
if (!use_icons)
drawgl::draw_rect_outlined(x + wtr.first, y + wtr.second, int(icon_size), int(icon_size), GUIColor());
draw_api::draw_rect_outlined(x + wtr.first, y + wtr.second, int(icon_size), int(icon_size), GUIColor(), 0.5f);
}
drawgl::draw_line(x + half_size, y + half_size / 2, 0, half_size, colors::Transparent(GUIColor(), 0.4f));
drawgl::draw_line(x + half_size / 2, y + half_size, half_size, 0, colors::Transparent(GUIColor(), 0.4f));
draw_api::draw_line(x + half_size, y + half_size / 2, 0, half_size, colors::Transparent(GUIColor(), 0.4f), 0.5f);
draw_api::draw_line(x + half_size / 2, y + half_size, half_size, 0, colors::Transparent(GUIColor(), 0.4f), 0.5f);
}
}}}
#endif

View File

@ -828,7 +828,7 @@ void DrawConnection(index_t a, connection_s& b) {
if ((a_.flags & b_.flags) & NF_JUMP) color = &colors::yellow;
else if ((a_.flags & b_.flags) & NF_DUCK) color = &colors::green;
drawgl::draw_line(wts_a.x, wts_a.y, wts_c.x - wts_a.x, wts_c.y - wts_a.y, color->rgba);
draw_api::draw_line(wts_a.x, wts_a.y, wts_c.x - wts_a.x, wts_c.y - wts_a.y, color->rgba, 0.5f);
if (draw_connection_flags && b.flags != CF_GOOD) {
std::string flags;
@ -868,7 +868,7 @@ void DrawNode(index_t node, bool draw_back) {
if (node == state::active_node)
color = &colors::red;
drawgl::draw_rect(wts.x - node_size, wts.y - node_size, 2 * node_size, 2 * node_size, color->rgba);
draw_api::draw_rect(wts.x - node_size, wts.y - node_size, 2 * node_size, 2 * node_size, color->rgba);
}
if (draw_indices) {

View File

@ -44,7 +44,9 @@ void PaintTraverse_hook(void* _this, unsigned int vp, bool fr, bool ar) {
#if ENABLE_VISUALS == 1
if (!textures_loaded) {
textures_loaded = true;
#ifndef FEATURES_RADAR_DISABLED
hacks::tf::radar::Init();
#endif
}
#endif
if (pure_bypass) {

View File

@ -37,16 +37,16 @@ int SDL_PollEvent_hook(SDL_Event* event) {
void SDL_GL_SwapWindow_hook(SDL_Window* window) {
static SDL_GLContext ctx_tf2 = SDL_GL_GetCurrentContext();
static SDL_GLContext ctx_imgui = nullptr;
static SDL_GLContext ctx_text = nullptr;
static SDL_GLContext ctx_opengl = nullptr;
if (!disable_visuals) {
PROF_SECTION(DRAW_cheat);
if (!ctx_imgui) {
ctx_imgui = SDL_GL_CreateContext(window);
ImGui_ImplSdl_Init(window);
ctx_text = SDL_GL_CreateContext(window);
ctx_opengl = SDL_GL_CreateContext(window);
FTGL_Init();
textures::Init();
drawgl::intialize();
draw_api::intialize();
}
if (!cathook) {
@ -55,10 +55,10 @@ void SDL_GL_SwapWindow_hook(SDL_Window* window) {
return;
}
SDL_GL_MakeCurrent(window, ctx_text);
SDL_GL_MakeCurrent(window, ctx_opengl);
{
std::lock_guard<std::mutex> draw_lock(drawing_mutex);
drawgl::render();
draw_api::render();
}
SDL_GL_MakeCurrent(window, ctx_imgui);
{

View File

@ -7,6 +7,28 @@
#pragma once
#define STRINGIFY(x) #x
#define TO_STRING(x) STRINGIFY(x)
/*
* make -j4 -e GAME=tf2
*/
// http://stackoverflow.com/questions/2335888/how-to-compare-string-in-c-conditional-preprocessor-directives
constexpr int c_strcmp( char const* lhs, char const* rhs ) {
return (('\0' == lhs[0]) && ('\0' == rhs[0])) ? 0
: (lhs[0] != rhs[0]) ? (lhs[0] - rhs[0])
: c_strcmp( lhs+1, rhs+1 );
}
#ifndef DATA_PATH
# define DATA_PATH "/opt/cathook"
#endif
#if RENDERING_ENGINE_XOVERLAY
#define FEATURE_EMOJI_ESP_DISABLED
#define FEATURE_RADAR_DISABLED
#define FEATURE_FIDGET_SPINNER_DISABLED
#endif

View File

@ -93,7 +93,7 @@ void Prediction_PaintTraverse() {
for (int j = 0; j < predicted_players[i].size(); j++) {
Vector screen;
if (draw::WorldToScreen(predicted_players[i][j], screen)) {
drawgl::draw_line(screen.x, screen.y, previous_screen.x - screen.x, previous_screen.y - screen.y, color);
draw_api::draw_line(screen.x, screen.y, previous_screen.x - screen.x, previous_screen.y - screen.y, color, 0.5f);
previous_screen = screen;
} else {
break;