From 52fe1a820582d490dac4b342e2680ff69d4fada4 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Mon, 31 Jul 2017 07:42:57 +0300 Subject: [PATCH] -e TEXTMODE_STDIN=1 --- makefile | 5 +++++ src/hooks/others.cpp | 8 ++++++++ src/ipc.cpp | 1 - src/textmode.cpp | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 36412de3..5ee76eac 100644 --- a/makefile +++ b/makefile @@ -13,6 +13,7 @@ DEFINES=_GLIBCXX_USE_CXX11_ABI=0 _POSIX=1 FREETYPE_GL_USE_VAO RAD_TELEMETRY_DISA 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 + ifdef CLANG COMMON_FLAGS+=-Wno-c++11-narrowing endif @@ -66,6 +67,10 @@ DEFINES += TEXTMODE=1 #OUT_NAME := libcathook-textmode.so endif +ifdef TEXTMODE_STDIN +DEFINES+=-DTEXTMODE_STDIN +endif + SRC_DIR = src RES_DIR = res TARGET_DIR = bin diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 8e15b48e..089d706a 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -401,6 +401,12 @@ void FrameStageNotify_hook(void* _this, int stage) { } if (stage == FRAME_START) { #if IPC_ENABLED + static Timer nametimer {}; + if (nametimer.test_and_set(1000 * 10)) { + if (ipc::peer) { + ipc::StoreClientData(); + } + } static Timer ipc_timer {}; if (ipc_timer.test_and_set(1000)) { if (ipc::peer) { @@ -419,12 +425,14 @@ void FrameStageNotify_hook(void* _this, int stage) { hack::command_stack().pop(); } } +#if defined(TEXTMODE) and defined(TEXTMODE_STDIN) static auto last_stdin = std::chrono::system_clock::from_time_t(0); auto ms = std::chrono::duration_cast(std::chrono::system_clock::now() - last_stdin).count(); if (ms > 500) { UpdateInput(); last_stdin = std::chrono::system_clock::now(); } +#endif } #ifndef TEXTMODE if (cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START) { diff --git a/src/ipc.cpp b/src/ipc.cpp index 532348e1..37380073 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -164,7 +164,6 @@ void UpdateTemporaryData() { void StoreClientData() { UpdateServerAddress(); - peer_t::MutexLock lock(peer); user_data_s& data = peer->memory->peer_user_data[peer->client_id]; data.friendid = g_ISteamUser->GetSteamID().GetAccountID(); strncpy(data.name, g_ISteamFriends->GetPersonaName(), sizeof(data.name)); diff --git a/src/textmode.cpp b/src/textmode.cpp index 789a429f..8c689c53 100644 --- a/src/textmode.cpp +++ b/src/textmode.cpp @@ -34,11 +34,13 @@ CatCommand fixvac("fixvac", "Lemme in to secure servers", []() { #ifdef TEXTMODE InitRoutine init([]() { +#ifdef TEXTMODE_STDIN logging::Info("[TEXTMODE] Setting up input handling"); int flags = fcntl(0, F_GETFL, 0); flags |= O_NONBLOCK; fcntl(0, F_SETFL, flags); logging::Info("[TEXTMODE] stdin is now non-blocking"); +#endif EXPOSED_Epic_VACBypass_1337_DoNotSteal_xXx_$1_xXx_MLG(); }); #endif