mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-07-03 09:41:51 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
705ad50d65 | |||
e8cad54293 | |||
a548e9d04b | |||
d4c8a7ce2c | |||
ba290e0f7c | |||
234f510e98 | |||
8224ca3b57 | |||
a19c2761c8 | |||
739ea2a7f0 | |||
6c99991429 |
2
deps/GSL
vendored
2
deps/GSL
vendored
Submodule deps/GSL updated: c1cbb41b42...c31a9ad5e8
@ -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);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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:
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -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};
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user