rename "tf-settings" folder to data, use /opt/cathook/data folder for

data files now, "make data"
This commit is contained in:
nullifiedcat 2017-08-16 11:20:08 +03:00
parent 6555ed90f2
commit 88915b54db
17 changed files with 44 additions and 20 deletions

9
check-data Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
if ! [ -d "$1" ]; then
echo "Creating cathook data directory at $1"
sudo mkdir -p "$1"
sudo chown -R $USER "$1"
sudo chmod -R 777 "$1"
rsync -avh --progress "data/" "$1"
fi

View File

@ -22,7 +22,7 @@ ENABLE_IPC=1
ENABLE_NULL_GRAPHICS=0 ENABLE_NULL_GRAPHICS=0
TEXTMODE_STDIN=0 TEXTMODE_STDIN=0
TEXTMODE_VAC=0 TEXTMODE_VAC=0
DATA_PATH="/opt/cathook-data" DATA_PATH="/opt/cathook/data"
NO_LTO=0 NO_LTO=0
ifdef CLANG ifdef CLANG
override NO_LTO=1 override NO_LTO=1
@ -137,15 +137,19 @@ OBJECTS = $(patsubst %.c,%.o, $(patsubst %.cpp,%.o, $(SOURCES)))
OBJECTS += $(shell find $(RES_DIR) -name "*.o" -print) OBJECTS += $(shell find $(RES_DIR) -name "*.o" -print)
DEPENDS = $(patsubst %.c,%.d, $(patsubst %.cpp,%.d, $(SOURCES))) DEPENDS = $(patsubst %.c,%.d, $(patsubst %.cpp,%.d, $(SOURCES)))
.PHONY: clean directories echo .PHONY: clean directories echo data
all: all:
mkdir -p $(OUT_DIR) mkdir -p $(OUT_DIR)
$(MAKE) data
$(MAKE) $(TARGET) $(MAKE) $(TARGET)
echo: echo:
echo $(OBJECTS) echo $(OBJECTS)
data:
./check-data "$(DATA_PATH)"
# 3rd party source files, we don't need warnings there # 3rd party source files, we don't need warnings there
# c++ # c++

View File

@ -9,6 +9,7 @@
#include "sdk.h" #include "sdk.h"
#include "copypasted/CSignature.h" #include "copypasted/CSignature.h"
time_t time_injected { 0 };
int g_AppID = 0; int g_AppID = 0;

View File

@ -8,6 +8,8 @@
#ifndef GLOBALS_H_ #ifndef GLOBALS_H_
#define GLOBALS_H_ #define GLOBALS_H_
#include <time.h>
class Vector; class Vector;
class ConVar; class ConVar;
class CatVar; class CatVar;
@ -37,6 +39,8 @@ extern int last_cmd_number;
extern char* disconnect_reason_newlined; extern char* disconnect_reason_newlined;
extern CatVar disconnect_reason; extern CatVar disconnect_reason;
extern time_t time_injected;
class GlobalSettings { class GlobalSettings {
public: public:
void Init(); void Init();

View File

@ -162,6 +162,7 @@ void hack::CC_Cat(const CCommand& args) {
} }
void hack::Initialize() { void hack::Initialize() {
time_injected = time(nullptr);
// Essential files must always exist, except when the game is running in text mode. // Essential files must always exist, except when the game is running in text mode.
#if ENABLE_VISUALS == 1 #if ENABLE_VISUALS == 1

View File

@ -531,6 +531,11 @@ void LevelInit_hook(void* _this, const char* newmap) {
hacks::shared::anticheat::ResetEverything(); hacks::shared::anticheat::ResetEverything();
original(_this, newmap); original(_this, newmap);
hacks::shared::walkbot::OnLevelInit(); hacks::shared::walkbot::OnLevelInit();
#if IPC_ENABLED
if (ipc::peer) {
ipc::peer->memory->peer_user_data[ipc::peer->client_id].ts_connected = time(nullptr);
}
#endif
} }
void LevelShutdown_hook(void* _this) { void LevelShutdown_hook(void* _this) {
@ -542,5 +547,10 @@ void LevelShutdown_hook(void* _this) {
chat_stack::Reset(); chat_stack::Reset();
hacks::shared::anticheat::ResetEverything(); hacks::shared::anticheat::ResetEverything();
original(_this); original(_this);
#if IPC_ENABLED
if (ipc::peer) {
ipc::peer->memory->peer_user_data[ipc::peer->client_id].ts_disconnected = time(nullptr);
}
#endif
} }

View File

@ -52,7 +52,10 @@ CatCommand connect("ipc_connect", "Connect to IPC server", []() {
hack::command_stack().push(std::string((const char*)payload)); hack::command_stack().push(std::string((const char*)payload));
}); });
hacks::shared::followbot::AddMessageHandlers(peer); hacks::shared::followbot::AddMessageHandlers(peer);
user_data_s& data = peer->memory->peer_user_data[peer->client_id];
memset(&data, 0, sizeof(data));
StoreClientData(); StoreClientData();
Heartbeat();
thread_running = true; thread_running = true;
pthread_create(&listener_thread, nullptr, listen, nullptr); pthread_create(&listener_thread, nullptr, listen, nullptr);
} catch (std::exception& error) { } catch (std::exception& error) {
@ -183,6 +186,9 @@ void UpdateTemporaryData() {
data.last_score = data.score; data.last_score = data.score;
} }
data.team = g_pPlayerResource->GetTeam(g_IEngine->GetLocalPlayer()); data.team = g_pPlayerResource->GetTeam(g_IEngine->GetLocalPlayer());
data.x = g_pLocalPlayer->v_Origin.x;
data.y = g_pLocalPlayer->v_Origin.y;
data.z = g_pLocalPlayer->v_Origin.z;
} else { } else {
data.good = false; data.good = false;
} }
@ -193,6 +199,7 @@ void StoreClientData() {
UpdateServerAddress(); UpdateServerAddress();
user_data_s& data = peer->memory->peer_user_data[peer->client_id]; user_data_s& data = peer->memory->peer_user_data[peer->client_id];
data.friendid = g_ISteamUser->GetSteamID().GetAccountID(); data.friendid = g_ISteamUser->GetSteamID().GetAccountID();
data.ts_injected = time_injected;
strncpy(data.name, GetFriendPersonaName_hook(g_ISteamFriends, g_ISteamUser->GetSteamID()), sizeof(data.name)); strncpy(data.name, GetFriendPersonaName_hook(g_ISteamFriends, g_ISteamUser->GetSteamID()), sizeof(data.name));
} }

View File

@ -61,6 +61,12 @@ struct user_data_s {
int last_score; int last_score;
int total_score; int total_score;
time_t heartbeat; time_t heartbeat;
float x;
float y;
float z;
time_t ts_injected;
time_t ts_connected;
time_t ts_disconnected;
}; };
using peer_t = cat_ipc::Peer<server_data_s, user_data_s>; using peer_t = cat_ipc::Peer<server_data_s, user_data_s>;

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
echo "Searching for Team Fortress 2"
echo "Please wait..."
find / -type d -name "Team Fortress 2" 2>/dev/null | while read path; do
if [ -e "$path/tf/gameinfo.txt" ]; then
if grep -q 440 "$path/tf/gameinfo.txt"; then
echo "Found Team Fortress 2 installation at $path"
mkdir -p "$path/cathook"
ln -s "$path/cathook" "Data Folder"
rsync -avh --progress tf-settings/ "$path/cathook"
echo "Symbolic link created (Data Folder)"
echo "You can close this window"
read -p "Press ENTER to continue"
fi
fi
done