Merge branch 'develop' of https://github.com/fedddddd/h2-mod into develop

This commit is contained in:
fed 2022-10-22 00:38:19 +02:00
commit 7a2d345c1c
14 changed files with 33 additions and 66 deletions

2
deps/GSL vendored

@ -1 +1 @@
Subproject commit 1683d87a3f45dff1817e858dbaf006e5ff84e784
Subproject commit c52bad36aa9d5ececcdf6be2d5cd2dce9daa4194

2
deps/asmjit vendored

@ -1 +1 @@
Subproject commit 052b4430e93f021709d27d2b5d42694ce0c49ce6
Subproject commit 8f2c237b8315a7d662e0e67d06807296a7bbe5ab

2
deps/libtomcrypt vendored

@ -1 +1 @@
Subproject commit e6be20bfc7e92c91dc1ef9cb5cc11a326e41f706
Subproject commit 3474ca37124c6fe78f5461876542e226a25b5f1f

2
deps/minhook vendored

@ -1 +1 @@
Subproject commit 4a455528f61b5a375b1f9d44e7d296d47f18bb18
Subproject commit 426cb6880035ee3cceed05384bb3f2db01a20a15

2
deps/zlib vendored

@ -1 +1 @@
Subproject commit 21767c654d31d2dccdde4330529775c6c5fd5389
Subproject commit 04f42ceca40f73e2978b50e93806c2a18c1281fc

View File

@ -626,7 +626,6 @@ namespace gsc
utils::hook::set<uint32_t>(0x1405BC7BC, 0x1000); // change builtin func count
#define RVA(ptr) static_cast<uint32_t>(reinterpret_cast<size_t>(ptr) - 0x140000000)
std::memcpy(&func_table, reinterpret_cast<void*>(0x14B153F90), 0x1900);
utils::hook::set<uint32_t>(0x1405BC7C2 + 4, RVA(&func_table));
utils::hook::inject(0x1405BCB78 + 3, &func_table);
utils::hook::set<uint32_t>(0x1405CA678 + 4, RVA(&func_table));

View File

@ -4,10 +4,8 @@
#include "game/game.hpp"
#include "game/dvars.hpp"
#include "command.hpp"
#include "scheduler.hpp"
#include "scripting.hpp"
#include "console.hpp"
#include "gsc.hpp"
#include "game/scripting/event.hpp"
@ -17,7 +15,6 @@
#include <utils/hook.hpp>
#include <utils/concurrency.hpp>
#include <utils/string.hpp>
namespace scripting
{

View File

@ -39,16 +39,10 @@ namespace ui_scripting
utils::hook::detour hks_shutdown_hook;
utils::hook::detour hks_package_require_hook;
struct script
{
std::string name;
std::string root;
};
struct globals_t
{
std::string in_require_script;
std::vector<script> loaded_scripts;
std::unordered_map<std::string, std::string> loaded_scripts;
bool load_raw_script{};
std::string raw_script_name{};
};
@ -57,28 +51,13 @@ namespace ui_scripting
bool is_loaded_script(const std::string& name)
{
for (auto i = globals.loaded_scripts.begin(); i != globals.loaded_scripts.end(); ++i)
{
if (i->name == name)
{
return true;
}
}
return false;
return globals.loaded_scripts.contains(name);
}
std::string get_root_script(const std::string& name)
{
for (auto i = globals.loaded_scripts.begin(); i != globals.loaded_scripts.end(); ++i)
{
if (i->name == name)
{
return i->root;
}
}
return {};
const auto itr = globals.loaded_scripts.find(name);
return itr == globals.loaded_scripts.end() ? std::string() : itr->second;
}
table get_globals()
@ -124,7 +103,7 @@ namespace ui_scripting
void load_script(const std::string& name, const std::string& data)
{
globals.loaded_scripts.push_back({name, name});
globals.loaded_scripts[name] = name;
const auto lua = get_globals();
const auto load_results = lua["loadstring"](data, name);
@ -454,14 +433,11 @@ namespace ui_scripting
if (globals.load_raw_script)
{
globals.load_raw_script = false;
globals.loaded_scripts.push_back({globals.raw_script_name, globals.in_require_script});
globals.loaded_scripts[globals.raw_script_name] = globals.in_require_script;
return load_buffer(globals.raw_script_name, utils::io::read_file(globals.raw_script_name));
}
else
{
return utils::hook::invoke<int>(0x1402D9410, state, compiler_options, reader,
reader_data, chunk_name);
}
return utils::hook::invoke<int>(0x1402D9410, state, compiler_options, reader, reader_data, chunk_name);
}
std::string current_error;
@ -478,7 +454,7 @@ namespace ui_scripting
}
const auto closure = value.v.cClosure;
if (converted_functions.find(closure) == converted_functions.end())
if (!converted_functions.contains(closure))
{
return 0;
}

View File

@ -5,7 +5,6 @@
#include <xsk/gsc/types.hpp>
#include <xsk/resolver.hpp>
#include <xsk/utils/compression.hpp>
#include <utils/string.hpp>

View File

@ -3,22 +3,20 @@
#include "error.hpp"
#include "value_conversion.hpp"
#include "../execution.hpp"
#include "../functions.hpp"
#include "game/scripting/execution.hpp"
#include "../../../component/notifies.hpp"
#include "../../../component/scripting.hpp"
#include "../../../component/command.hpp"
#include "../../../component/fastfiles.hpp"
#include "../../../component/mods.hpp"
#include "../../../component/localized_strings.hpp"
#include "../../../component/scheduler.hpp"
#include "component/notifies.hpp"
#include "component/scripting.hpp"
#include "component/command.hpp"
#include "component/fastfiles.hpp"
#include "component/mods.hpp"
#include "component/localized_strings.hpp"
#include "component/scheduler.hpp"
#include "game/ui_scripting/execution.hpp"
#include <xsk/gsc/types.hpp>
#include <xsk/resolver.hpp>
#include <xsk/utils/compression.hpp>
#include <utils/string.hpp>
#include <utils/io.hpp>
@ -342,8 +340,7 @@ namespace scripting::lua
for (const auto& func : xsk::gsc::h2::resolver::get_methods())
{
const auto func_name = std::string(func.first);
const auto name = utils::string::to_lower(func_name);
const auto name = std::string(func.first);
entity_type[name.data()] = [name](const entity& entity, const sol::this_state s, sol::variadic_args va)
{
std::vector<script_value> arguments{};
@ -476,8 +473,7 @@ namespace scripting::lua
for (const auto& func : xsk::gsc::h2::resolver::get_functions())
{
const auto func_name = std::string(func.first);
const auto name = utils::string::to_lower(func_name);
const auto name = std::string(func.first);
game_type[name] = [name](const game&, const sol::this_state s, sol::variadic_args va)
{
std::vector<script_value> arguments{};

View File

@ -91,7 +91,7 @@ namespace game
WEAK symbol<int(void* ps, unsigned int weapon, int a3, int a4, __int64 a5, int a6)>
G_GivePlayerWeapon{0x14051B660};
WEAK symbol<void(void* ps, const unsigned int weapon, int hadWeapon)> G_InitializeAmmo{0x1404C4110};
WEAK symbol<void(int clientNum, const unsigned int weapon)> G_SelectWeapon{0x14051C0D0};
WEAK symbol<void(int localClientNum, const unsigned int weapon)> G_SelectWeapon{0x14051C0D0};
WEAK symbol<bool(int localClientNum, ScreenPlacement* screenPlacement, const float* worldDir, float* outScreenPos)> WorldPosToScreenPos{0x14036F310};
WEAK symbol<char*(char* string)> I_CleanStr{0x140620660};
@ -101,15 +101,15 @@ namespace game
WEAK symbol<const char*(int, int, int)> Key_KeynumToString{0x1403D32D0};
WEAK symbol<void(int clientNum, const char* menu, int a3, int a4, unsigned int a5)> LUI_OpenMenu{0x1405F0EE0};
WEAK symbol<bool(int clientNum, const char* name, hks::lua_State* s)> LUI_BeginEvent{0x1403155E0};
WEAK symbol<bool(int clientNum, int lui_event_cache, hks::lua_State* s)> LUI_BeginCachedEvent{0x1403153E0};
WEAK symbol<void(int localClientNum, const char* menuName, int a3, int a4, unsigned int a5)> LUI_OpenMenu{0x1405F0EE0};
WEAK symbol<bool(int localClientNum, const char* name, hks::lua_State* s)> LUI_BeginEvent{0x1403155E0};
WEAK symbol<bool(int localClientNum, int lui_event_cache, hks::lua_State* s)> LUI_BeginCachedEvent{0x1403153E0};
WEAK symbol<void(const char* name, int value, hks::lua_State* s)> LUI_SetTableInt{0x140320060};
WEAK symbol<void(const char* name, const char* value, hks::lua_State* s)> LUI_SetTableString{0x1403201F0};
WEAK symbol<void(hks::lua_State* s)> LUI_EndEvent{0x140316890};
WEAK symbol<void()> LUI_EnterCriticalSection{0x140316980};
WEAK symbol<void()> LUI_LeaveCriticalSection{0x14031BC20};
WEAK symbol<bool(int clientNum, const char* menu)> Menu_IsMenuOpenAndVisible{0x1405EE1A0};
WEAK symbol<bool(int localClientNum, const char* menuName)> Menu_IsMenuOpenAndVisible{0x1405EE1A0};
WEAK symbol<Material*(const char* material)> Material_RegisterHandle{0x140759BA0};
@ -273,6 +273,6 @@ namespace game
WEAK symbol<int(lua_State* s, const char* what, lua_Debug* ar)> hksi_lua_getinfo{0x1402DD1F0};
WEAK symbol<int(lua_State* s, int level, lua_Debug* ar)> hksi_lua_getstack{0x1402DD4C0};
WEAK symbol<void(lua_State* s, const char* fmt, ...)> hksi_luaL_error{0x1402E3E40};
WEAK symbol<const char*> typenames{0x140BE9F50};
WEAK symbol<const char*> s_compilerTypeName{0x140BE9F50};
}
}

View File

@ -70,7 +70,7 @@ namespace ui_scripting
values.push_back(v);
}
if (values.size() == 0)
if (values.empty())
{
values.push_back({});
}
@ -90,7 +90,7 @@ namespace ui_scripting
values.push_back(v);
}
if (values.size() == 0)
if (values.empty())
{
values.push_back({});
}

View File

@ -167,7 +167,7 @@ namespace ui_scripting
{
if (!this->is<T>())
{
const auto hks_typename = game::hks::typenames[this->get_raw().t + 2];
const auto hks_typename = game::hks::s_compilerTypeName[this->get_raw().t + 2];
const auto typename_ = get_typename<T>();
throw std::runtime_error(utils::string::va("%s expected, got %s",