10 Commits

Author SHA1 Message Date
705ad50d65 Fixes for pluto update 2021-11-07 02:33:16 +01:00
e8cad54293 Merge branch 'main' of https://github.com/fedddddd/iw5-gsc-utils 2021-11-07 02:06:05 +01:00
a548e9d04b Update dllmain.cpp 2021-11-07 02:06:03 +01:00
fed
d4c8a7ce2c Merge pull request #3 from diamante0018/main
Add unlimited sprint toggle via gsc
2021-11-07 01:22:05 +01:00
Edo
ba290e0f7c [GSC] VS Delete this space 2021-11-07 00:19:03 +00:00
234f510e98 [GSC] Add infinite sprint 2021-11-07 00:04:31 +00:00
8224ca3b57 Update pointers 2021-11-06 02:16:11 +01:00
a19c2761c8 Update pointers 2021-10-21 18:55:01 +02:00
739ea2a7f0 Update pointers 2021-10-01 03:04:08 +02:00
6c99991429 Typo 2021-08-31 21:06:18 +02:00
8 changed files with 49 additions and 85 deletions

2
deps/GSL vendored

Submodule deps/GSL updated: c1cbb41b42...c31a9ad5e8

View File

@ -14,8 +14,6 @@
namespace gsc namespace gsc
{ {
std::unordered_map<const char*, const char*> replaced_functions;
function_args::function_args(std::vector<scripting::script_value> values) function_args::function_args(std::vector<scripting::script_value> values)
: values_(values) : values_(values)
{ {
@ -109,7 +107,7 @@ namespace gsc
{ {
if (id < 0x200) if (id < 0x200)
{ {
return reinterpret_cast<builtin_function*>(0x1D6EB34)[id](); return reinterpret_cast<builtin_function*>(0x20689DD8)[id]();
} }
try try
@ -135,7 +133,7 @@ namespace gsc
{ {
if (id < 0x8400) if (id < 0x8400)
{ {
return reinterpret_cast<builtin_method*>(0x1D4F258)[id](ent); return reinterpret_cast<builtin_method*>(0x2068A5A8)[id - 0x8000](ent);
} }
try try
@ -201,62 +199,6 @@ namespace gsc
retn retn
} }
} }
const char* replaced_pos = 0;
void get_replaced_pos(const char* pos)
{
if (replaced_functions.find(pos) != replaced_functions.end())
{
replaced_pos = replaced_functions[pos];
}
}
__declspec(naked) void vm_execute_stub()
{
__asm
{
pushad
push esi
call get_replaced_pos
pop esi
popad
cmp replaced_pos, 0
jne set_pos
movzx eax, byte ptr[esi]
inc esi
jmp loc_1
loc_1:
mov [ebp - 0x18], eax
mov [ebp - 0x8], esi
push ecx
mov ecx, 0x20B8E28
mov [ecx], eax
mov ecx, 0x20B4A5C
mov[ecx], esi
pop ecx
cmp eax, 0x98
push 0x56B740
retn
set_pos:
mov esi, replaced_pos
mov replaced_pos, 0
movzx eax, byte ptr[esi]
inc esi
jmp loc_1
}
}
} }
namespace function namespace function
@ -292,16 +234,6 @@ namespace gsc
return {}; return {};
}); });
function::add("replacefunc", [](const function_args& args) -> scripting::script_value
{
const auto what = args[0].as<scripting::function>();
const auto with = args[1].as<scripting::function>();
replaced_functions[what.get_pos()] = with.get_pos();
return {};
});
function::add("addcommand", [](const function_args& args) -> scripting::script_value function::add("addcommand", [](const function_args& args) -> scripting::script_value
{ {
const auto name = args[0].as<std::string>(); const auto name = args[0].as<std::string>();
@ -343,9 +275,29 @@ namespace gsc
return {}; return {};
}); });
method::add("specialtymarathon", [](const game::scr_entref_t ent, const function_args& args) -> scripting::script_value
{
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
}
const auto num = ent.entnum;
const auto toggle = args[0].as<int>();
auto g_client = game::g_entities[num].client;
auto playerState = &g_client->ps;
auto flags = playerState->perks[0];
playerState->perks[0] = toggle
? flags | 0x4000u
: flags & ~0x4000u;
return {};
});
utils::hook::jump(0x56C8EB, call_builtin_stub); utils::hook::jump(0x56C8EB, call_builtin_stub);
utils::hook::jump(0x56CBDC, call_builtin_method_stub); utils::hook::jump(0x56CBDC, call_builtin_method_stub);
utils::hook::jump(0x56B726, vm_execute_stub);
} }
}; };
} }

View File

@ -2,8 +2,6 @@
namespace gsc namespace gsc
{ {
extern std::unordered_map<const char*, const char*> replaced_functions;
class function_args class function_args
{ {
public: public:

View File

@ -77,7 +77,6 @@ namespace scripting
{ {
userinfo::clear_overrides(); userinfo::clear_overrides();
command::clear_script_commands(); command::clear_script_commands();
gsc::replaced_functions.clear();
g_shutdown_game_hook.invoke<void>(free_scripts); g_shutdown_game_hook.invoke<void>(free_scripts);
} }

View File

@ -5,12 +5,12 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
{ {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{ {
const auto value = *reinterpret_cast<DWORD*>(0x20600000); const auto value = *reinterpret_cast<DWORD*>(0x20800000);
if (value != 0x77E0B164) if (value != 0xB9C9566)
{ {
printf("\x1b[31m\n**************************************************************************************\n\n"); printf("\x1b[31m\n**************************************************************************************\n\n");
printf("This version of \x1b[33miw5-gsc-utils\x1b[31m is outdated.\n"); printf("This version of \x1b[33miw5-gsc-utils\x1b[31m is outdated.\n");
printf("Download the latest dll from here:\x1b[34m https://github.com/fedddddd/iw5-gsc-utils/releases\ \x1b[31m\n"); printf("Download the latest dll from here:\x1b[34m https://github.com/fedddddd/iw5-gsc-utils/releases \x1b[31m\n");
printf("\n**************************************************************************************\n\n\x1b[37m"); printf("\n**************************************************************************************\n\n\x1b[37m");
return FALSE; return FALSE;
} }

View File

@ -59,15 +59,15 @@ namespace scripting
script_function get_function_by_index(const unsigned index) script_function get_function_by_index(const unsigned index)
{ {
static const auto function_table = 0x1D6EB34; static const auto function_table = 0x20689DD8;
static const auto method_table = 0x1D4F258; static const auto method_table = 0x2068A5A8;
if (index < 0x1C7) if (index < 0x1C7)
{ {
return reinterpret_cast<script_function*>(function_table)[index]; return reinterpret_cast<script_function*>(function_table)[index];
} }
return reinterpret_cast<script_function*>(method_table)[index]; return reinterpret_cast<script_function*>(method_table)[index - 0x8000];
} }
} }

View File

@ -303,8 +303,23 @@ namespace game
dvar_t* hashNext; dvar_t* hashNext;
}; };
struct playerState_s
{
char __pad0[1260];
unsigned int perks[2];
unsigned int perkSlots[9];
char __pad1[11752];
};
struct gclient_s
{
playerState_s ps;
};
struct gentity_s struct gentity_s
{ {
int entnum; int entnum;
char __pad0[340];
gclient_s* client;
}; };
} }

View File

@ -74,12 +74,12 @@ namespace game
WEAK symbol<scr_classStruct_t*> g_classMap{0x8B4300}; WEAK symbol<scr_classStruct_t*> g_classMap{0x8B4300};
WEAK symbol<gentity_s> g_entities{0x0}; WEAK symbol<gentity_s> g_entities{0x1A66E28};
WEAK symbol<unsigned int> levelEntityId{0x208E1A4}; WEAK symbol<unsigned int> levelEntityId{0x208E1A4};
namespace plutonium namespace plutonium
{ {
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> function_map_rev{0x2059A610}; WEAK symbol<std::unordered_map<std::string, std::uint16_t>> function_map_rev{0x20691228};
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> method_map_rev{0x2059A630}; WEAK symbol<std::unordered_map<std::string, std::uint16_t>> method_map_rev{0x20691248};
} }
} }