Compare commits

..

2 Commits

Author SHA1 Message Date
Wizzard c7ee48dfa6 Added game by game detection to help fix certain issues with specific games 2023-09-19 13:16:13 -04:00
Wizzard a7b30ca7f8 Note about watermark 2023-09-19 11:54:58 -04:00
5 changed files with 118 additions and 1 deletions

View File

@ -5,7 +5,7 @@ INCLUDES=-Isrc/include/sdk/common -Isrc/include/sdk/public -Isrc/include/sdk/pm_
CFLAGS=-Wall -Wextra -Wno-write-strings -m32 -fPIC $(INCLUDES) CFLAGS=-Wall -Wextra -Wno-write-strings -m32 -fPIC $(INCLUDES)
LDFLAGS=-lm LDFLAGS=-lm
OBJS=obj/main.c.o obj/globals.c.o obj/cvars.c.o obj/hooks.c.o obj/detour.c.o obj/util.c.o obj/features/movement.c.o obj/features/esp.c.o obj/features/chams.c.o obj/features/aim.c.o obj/features/misc.c.o OBJS=obj/main.c.o obj/globals.c.o obj/cvars.c.o obj/hooks.c.o obj/detour.c.o obj/util.c.o obj/features/movement.c.o obj/features/esp.c.o obj/features/chams.c.o obj/features/aim.c.o obj/features/misc.c.o obj/game_detection.c.o
BIN=libhlcheat.so BIN=libhlcheat.so
.PHONY: clean all inject .PHONY: clean all inject

View File

@ -55,6 +55,10 @@ console variables than more customization at runtime.
=bullet_tracers()= function inside [[https://git.deadzone.lol/Wizzard/goldsource-cheat/src/branch/main/src/features/misc.c][src/features/misc.c]]. See previous chams note. =bullet_tracers()= function inside [[https://git.deadzone.lol/Wizzard/goldsource-cheat/src/branch/main/src/features/misc.c][src/features/misc.c]]. See previous chams note.
#+end_quote #+end_quote
#+begin_quote
*Note:* You can disable the watermark with dz_watermark 0
#+end_quote
* Building * Building
#+begin_src console #+begin_src console
$ git clone --recurse-submodules https://git.deadzone.lol/Wizzard/goldsource-cheat $ git clone --recurse-submodules https://git.deadzone.lol/Wizzard/goldsource-cheat

68
src/game_detection.c Normal file
View File

@ -0,0 +1,68 @@
#include "include/game_detection.h"
#include <string.h>
#include <stdio.h>
static GameType current_game = GAME_UNKNOWN;
GameType get_current_game(void) {
if (current_game != GAME_UNKNOWN) {
return current_game;
}
FILE *fp = fopen("/proc/self/cmdline", "r");
if (fp) {
char buf[1024];
size_t size = fread(buf, sizeof(char), sizeof(buf) - 1, fp);
fclose(fp);
if (size > 0) {
buf[size] = '\0';
char *gameTypeToken = NULL;
char *steamToken = NULL;
int tokensFound = 0;
for (char *token = buf; token < buf + size; token += strlen(token) + 1) {
tokensFound++;
if (strcmp(token, "-game") == 0) {
gameTypeToken = token + strlen(token) + 1;
} else if (strcmp(token, "-steam") == 0) {
steamToken = token;
}
}
if (gameTypeToken) {
if (strcmp(gameTypeToken, "cstrike") == 0) {
current_game = GAME_CS16;
} else if (strcmp(gameTypeToken, "dod") == 0) {
current_game = GAME_DAY_OF_DEFEAT;
} else if (strcmp(gameTypeToken, "tfc") == 0) {
current_game = GAME_TFC;
}
} else if (steamToken && tokensFound == 2) {
// If only `-steam` is found and no `-game`, with only two tokens, assume it's Half-Life 1
current_game = GAME_HALFLIFE;
}
}
}
return current_game;
}
int IsCS16(void) {
return get_current_game() == GAME_CS16;
}
int IsHalfLife(void) {
return get_current_game() == GAME_HALFLIFE;
}
int IsDayOfDefeat(void) {
return get_current_game() == GAME_DAY_OF_DEFEAT;
}
int IsTFC(void) {
return get_current_game() == GAME_TFC;
}

View File

@ -0,0 +1,17 @@
#ifndef _GAME_DETECT_H_
#define _GAME_DETECT_H_
typedef enum {
GAME_UNKNOWN = 0,
GAME_HALFLIFE,
GAME_CS16,
GAME_TFC,
GAME_DAY_OF_DEFEAT
} GameType;
GameType get_current_game(void);
int IsCS16(void);
int IsHalfLife(void);
int IsDayOfDefeat(void);
#endif

View File

@ -8,6 +8,7 @@
#include "include/cvars.h" #include "include/cvars.h"
#include "include/hooks.h" #include "include/hooks.h"
#include "include/util.h" #include "include/util.h"
#include "include/game_detection.h"
static bool loaded = false; static bool loaded = false;
@ -40,6 +41,33 @@ void load(void) {
this_game_id = get_cur_game(); this_game_id = get_cur_game();
i_engine->pfnClientCmd("echo \"goldsource-cheat loaded successfully!\""); i_engine->pfnClientCmd("echo \"goldsource-cheat loaded successfully!\"");
i_engine->pfnClientCmd("echo \"Deadzone rulez!\"");
i_engine->pfnClientCmd("echo \"https://git.deadzone.lol/Wizzard/goldsource-cheat\"");
GameType game = get_current_game();
switch(game) {
case GAME_HALFLIFE:
i_engine->pfnClientCmd("echo \"Detected Game: Half-Life 1\"");
break;
case GAME_CS16:
i_engine->pfnClientCmd("echo \"Detected Game: Counter-Strike 1.6\"");
break;
case GAME_DAY_OF_DEFEAT:
i_engine->pfnClientCmd("echo \"Detected Game: Day of Defeat\"");
break;
case GAME_TFC:
i_engine->pfnClientCmd("echo \"Detected Game: Team Fortress Classic\"");
break;
default:
i_engine->pfnClientCmd("echo \"Detected Game: Unknown Game\"");
break;
}
return;
loaded = true; loaded = true;
} }