Skip to content

Commit

Permalink
cvar check before replacing deny with replace (untested)
Browse files Browse the repository at this point in the history
added support for 1.0 and 1.3 (untested)
  • Loading branch information
M-itch committed Jan 9, 2014
1 parent 6eb982c commit 2d12fd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 14 additions & 4 deletions functions.hpp
Expand Up @@ -48,16 +48,26 @@ typedef int (*ClientCommand_t)(int clientNum);
static int hook_ClientCommand_call = (int)NULL;
#endif

typedef float (*Cvar_VariableValue_t)(const char *var_name);
#if COD2_VERSION == COD2_VERSION_1_0
static Cvar_VariableValue_t CvarVariableValue = (Cvar_VariableValue_t)0x080B0BB6;
#elif COD2_VERSION == COD2_VERSION_1_2
static Cvar_VariableValue_t CvarVariableValue = (Cvar_VariableValue_t)0x080B2E66;
#elif COD2_VERSION == COD2_VERSION_1_3
static Cvar_VariableValue_t CvarVariableValue = (Cvar_VariableValue_t)0x080B2FAA;
#else
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
static Cvar_VariableValue_t CvarVariableValue = (Cvar_VariableValue_t)NULL;
#endif

#if COD2_VERSION == COD2_VERSION_1_0
static int hook_ServerCommand_call = 0x080941F2;
static int hook_ConnectionlessPacket = 0x08093F1E;
#warning static int fsrestrict_ServerCommand = NULL;
static int fsrestrict_ServerCommand = (int)NULL;
static int fsrestrict_ServerCommand = 0x0808C8F2;
#elif COD2_VERSION == COD2_VERSION_1_2
static int hook_ServerCommand_call = 0x0809606C;
static int hook_ConnectionlessPacket = 0x08095894;
#warning static int fsrestrict_ServerCommand = NULL;
static int fsrestrict_ServerCommand = (int)NULL;
static int fsrestrict_ServerCommand = 0x0808DAAF;
#elif COD2_VERSION == COD2_VERSION_1_3
static int hook_ServerCommand_call = 0x08096126;
static int hook_ConnectionlessPacket = 0x0809594E;
Expand Down
6 changes: 5 additions & 1 deletion libcod.cpp
Expand Up @@ -1481,7 +1481,7 @@ typedef struct {

void hook_ServerCommand( netadr_t from, msg_t *msg )
{
if (strncmp (msg->data,"\xff\xff\xff\xffipAuthorize", 15) == 0)
if ((CvarVariableValue == NULL || CvarVariableValue("sv_cracked")) && strncmp (msg->data,"\xff\xff\xff\xffipAuthorize", 15) == 0)
{
char * pch = strstr (msg->data, "deny");

Expand Down Expand Up @@ -1791,6 +1791,8 @@ class cCallOfDuty2Pro
cracking_hook_function((int)gametype_scripts, (int)hook_codscript_gametype_scripts);
cracking_hook_call(hook_ClientCommand_call, (int)hook_ClientCommand);
cracking_hook_call(hook_ServerCommand_call, (int)hook_ServerCommand);
char * cracked = (char *)"sv_cracked"; // to do clean up on unload
memcpy((void *)(fsrestrict_ServerCommand+3), &cracked, 4);
#elif COD_VERSION == COD2_1_2
if (0)
cracking_hook_function(0x08094698, (int)SV_AddServerCommand);
Expand All @@ -1801,6 +1803,8 @@ class cCallOfDuty2Pro
cracking_hook_function((int)gametype_scripts, (int)hook_codscript_gametype_scripts);
cracking_hook_call(hook_ClientCommand_call, (int)hook_ClientCommand);
cracking_hook_call(hook_ServerCommand_call, (int)hook_ServerCommand);
char * cracked = (char *)"sv_cracked"; // to do clean up on unload
memcpy((void *)(fsrestrict_ServerCommand+3), &cracked, 4);
#endif

#if COD_VERSION == COD2_1_3
Expand Down

0 comments on commit 2d12fd4

Please sign in to comment.