mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-04-20 05:25:44 +00:00
use plugin gsc register
This commit is contained in:
parent
483c7126c8
commit
232ce3bcaa
@ -2011,14 +2011,6 @@ LABEL_17:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// our addition
|
|
||||||
auto f = gsc::function::get(pName, type);
|
|
||||||
if (f != nullptr)
|
|
||||||
{
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
|
|
||||||
// pluto
|
// pluto
|
||||||
if (game::plutonium::scr_get_function_hook != nullptr)
|
if (game::plutonium::scr_get_function_hook != nullptr)
|
||||||
{
|
{
|
||||||
@ -2154,14 +2146,6 @@ LABEL_17:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// our addition
|
|
||||||
auto f = gsc::method::get(pName, type);
|
|
||||||
if (f != nullptr)
|
|
||||||
{
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
|
|
||||||
// pluto
|
// pluto
|
||||||
if (game::plutonium::scr_get_method_hook != nullptr)
|
if (game::plutonium::scr_get_method_hook != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -2,124 +2,13 @@
|
|||||||
#include "loader/component_loader.hpp"
|
#include "loader/component_loader.hpp"
|
||||||
#include "gsc.hpp"
|
#include "gsc.hpp"
|
||||||
|
|
||||||
#include "scheduler.hpp"
|
|
||||||
|
|
||||||
#include <json.hpp>
|
|
||||||
#include <utils/io.hpp>
|
|
||||||
#include <utils/hook.hpp>
|
|
||||||
#include <utils/string.hpp>
|
|
||||||
|
|
||||||
namespace gsc
|
namespace gsc
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, game::BuiltinFunction> functions;
|
|
||||||
std::unordered_map<std::string, game::BuiltinMethod> methods;
|
|
||||||
|
|
||||||
utils::hook::detour scr_getmethod_hook;
|
|
||||||
void* scr_getfunction_stub_ret_loc;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
game::BuiltinFunction scr_getfunction_call(const char** pName, int* pType)
|
|
||||||
{
|
|
||||||
auto itr = functions.find(*pName);
|
|
||||||
|
|
||||||
if (itr == functions.end())
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pType = 0;
|
|
||||||
return itr->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
game::BuiltinFunction NAKED scr_getfunction_stub()
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
push eax;
|
|
||||||
pushad;
|
|
||||||
|
|
||||||
lea eax, [esp + 0x24 + 0x2C - 0x1C];
|
|
||||||
push eax;
|
|
||||||
push edx;
|
|
||||||
call scr_getfunction_call;
|
|
||||||
add esp, 8;
|
|
||||||
mov [esp + 0x20], eax;
|
|
||||||
|
|
||||||
popad;
|
|
||||||
pop eax;
|
|
||||||
|
|
||||||
test eax, eax;
|
|
||||||
jnz just_ret;
|
|
||||||
|
|
||||||
// go do original code
|
|
||||||
push scr_getfunction_stub_ret_loc;
|
|
||||||
ret;
|
|
||||||
|
|
||||||
just_ret:
|
|
||||||
add esp, 4;
|
|
||||||
push 0x682DC8;
|
|
||||||
ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
game::BuiltinMethod scr_getmethod_call(const char** pName, int* pType)
|
|
||||||
{
|
|
||||||
auto itr = methods.find(*pName);
|
|
||||||
|
|
||||||
if (itr == methods.end())
|
|
||||||
{
|
|
||||||
// call og
|
|
||||||
const auto og_addr = scr_getmethod_hook.get_original();
|
|
||||||
game::BuiltinMethod answer;
|
|
||||||
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
mov edi, pType;
|
|
||||||
mov esi, pName;
|
|
||||||
call og_addr;
|
|
||||||
mov answer, eax;
|
|
||||||
}
|
|
||||||
|
|
||||||
return answer;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pType = 0;
|
|
||||||
return itr->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
game::BuiltinMethod NAKED scr_getmethod_stub()
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
push edi;
|
|
||||||
push esi;
|
|
||||||
call scr_getmethod_call;
|
|
||||||
add esp, 8;
|
|
||||||
|
|
||||||
ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace function
|
namespace function
|
||||||
{
|
{
|
||||||
void add(const std::string& name, const game::BuiltinFunction function)
|
void add(const std::string& name, const game::BuiltinFunction function)
|
||||||
{
|
{
|
||||||
functions.insert_or_assign(name, function);
|
plugin::get()->get_interface()->gsc()->register_function(name, function);
|
||||||
}
|
|
||||||
|
|
||||||
game::BuiltinFunction get(const char** name, int* type)
|
|
||||||
{
|
|
||||||
auto got = functions.find(*name);
|
|
||||||
|
|
||||||
if (got == functions.end())
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
*type = 0;
|
|
||||||
return got->second;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,46 +16,8 @@ namespace gsc
|
|||||||
{
|
{
|
||||||
void add(const std::string& name, const game::BuiltinMethod method)
|
void add(const std::string& name, const game::BuiltinMethod method)
|
||||||
{
|
{
|
||||||
methods.insert_or_assign(name, method);
|
plugin::get()->get_interface()->gsc()->register_method(name, (plutonium::sdk::v1::interfaces::gsc::method_callback)method);
|
||||||
}
|
|
||||||
|
|
||||||
game::BuiltinMethod get(const char** name, int* type)
|
|
||||||
{
|
|
||||||
auto got = methods.find(*name);
|
|
||||||
|
|
||||||
if (got == methods.end())
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
*type = 0;
|
|
||||||
return got->second;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class component final : public component_interface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void post_unpack() override
|
|
||||||
{
|
|
||||||
// for when we dont use the decomp
|
|
||||||
// custom gsc methods
|
|
||||||
if (game::plutonium::scr_get_method_stub != nullptr)
|
|
||||||
{
|
|
||||||
scr_getmethod_hook.create(game::plutonium::scr_get_method_stub.get(), scr_getmethod_stub);
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom gsc funcs
|
|
||||||
if (game::plutonium::scr_get_function_stub != nullptr)
|
|
||||||
{
|
|
||||||
scr_getfunction_stub_ret_loc = game::plutonium::scr_get_function_stub.get();
|
|
||||||
utils::hook::jump(SELECT(0x0, 0x682D99), scr_getfunction_stub);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_COMPONENT(gsc::component)
|
|
||||||
|
|
||||||
|
@ -5,12 +5,10 @@ namespace gsc
|
|||||||
namespace function
|
namespace function
|
||||||
{
|
{
|
||||||
void add(const std::string& name, const game::BuiltinFunction function);
|
void add(const std::string& name, const game::BuiltinFunction function);
|
||||||
game::BuiltinFunction get(const char** name, int* type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace method
|
namespace method
|
||||||
{
|
{
|
||||||
void add(const std::string& name, const game::BuiltinMethod method);
|
void add(const std::string& name, const game::BuiltinMethod method);
|
||||||
game::BuiltinMethod get(const char** name, int* type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -216,8 +216,6 @@ namespace signatures
|
|||||||
SAFE_SET_PLUTO_SYMBOL_DOUBLE(store_func_codepos, 0x688909, 0x3);
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(store_func_codepos, 0x688909, 0x3);
|
||||||
|
|
||||||
SAFE_SET_PLUTO_SYMBOL(cscr_get_function_hook, 0x682DC0);
|
SAFE_SET_PLUTO_SYMBOL(cscr_get_function_hook, 0x682DC0);
|
||||||
SAFE_SET_PLUTO_SYMBOL(scr_get_function_stub, 0x682D99);
|
|
||||||
SAFE_SET_PLUTO_SYMBOL(scr_get_method_stub, 0x683043);
|
|
||||||
SAFE_SET_PLUTO_SYMBOL(cscr_get_method_hook, 0x68305C);
|
SAFE_SET_PLUTO_SYMBOL(cscr_get_method_hook, 0x68305C);
|
||||||
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_get_method_hook, 0x683043, 0x4);
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_get_method_hook, 0x683043, 0x4);
|
||||||
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_get_function_hook, 0x682D99, 0x8);
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_get_function_hook, 0x682D99, 0x8);
|
||||||
|
@ -107,9 +107,6 @@ namespace game
|
|||||||
|
|
||||||
WEAK symbol<const char*(game::scriptInstance_t, unsigned int)> at_codepose_va{ 0x0, 0x0 };
|
WEAK symbol<const char*(game::scriptInstance_t, unsigned int)> at_codepose_va{ 0x0, 0x0 };
|
||||||
|
|
||||||
WEAK symbol<void()> scr_get_method_stub{ 0x0, 0x0 };
|
|
||||||
WEAK symbol<void()> scr_get_function_stub{ 0x0, 0x0 };
|
|
||||||
|
|
||||||
WEAK symbol<game::BuiltinMethod(const char** name, int* type)> scr_get_method_hook{ 0x0, 0x0 };
|
WEAK symbol<game::BuiltinMethod(const char** name, int* type)> scr_get_method_hook{ 0x0, 0x0 };
|
||||||
WEAK symbol<game::BuiltinFunction(const char** name, int* type)> scr_get_function_hook{ 0x0, 0x0 };
|
WEAK symbol<game::BuiltinFunction(const char** name, int* type)> scr_get_function_hook{ 0x0, 0x0 };
|
||||||
WEAK symbol<game::BuiltinMethod(const char** name, int* type)> cscr_get_method_hook{ 0x0, 0x0 };
|
WEAK symbol<game::BuiltinMethod(const char** name, int* type)> cscr_get_method_hook{ 0x0, 0x0 };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user