Merge pull request #661 from XLabsProject/develop

Release v2.1.3
This commit is contained in:
Maurice Heumann 2023-04-01 16:40:13 +02:00 committed by GitHub
commit ba28cac8be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 70 additions and 132 deletions

3
.gitmodules vendored
View File

@ -48,6 +48,3 @@
path = deps/gsc-tool
url = https://github.com/xensik/gsc-tool.git
branch = dev
[submodule "deps/fmt"]
path = deps/fmt
url = https://github.com/fmtlib/fmt.git

2
deps/GSL vendored

@ -1 +1 @@
Subproject commit 49c88f27bd642b8d80371cbd0b8cffbfe5367c44
Subproject commit 1d036585ccea8a57dc5fdc84406181db3d1f3205

2
deps/asmjit vendored

@ -1 +1 @@
Subproject commit e13642567393a4bfc8c5607b33337b2ed3b0d01e
Subproject commit 51b10b19b6631434d3f9ad536a6fb140944a36d2

View File

@ -1,6 +0,0 @@
#include "gsc_interface.hpp"
namespace gsc
{
std::unique_ptr<xsk::gsc::s1_pc::context> cxt;
}

View File

@ -1,15 +0,0 @@
#pragma once
#undef ERROR
#undef IN
#undef TRUE
#undef FALSE
#undef far
#include <stdinc.hpp>
#include <s1/s1_pc.hpp>
namespace gsc
{
extern std::unique_ptr<xsk::gsc::s1_pc::context> cxt;
}

1
deps/fmt vendored

@ -1 +0,0 @@
Subproject commit e03753c4ac04d80517ec5fa92e78b0dc1f896a70

2
deps/gsc-tool vendored

@ -1 +1 @@
Subproject commit adf88fc5c9e5f0ecf3a7743e82c95c4482822bf8
Subproject commit 15526ab79ad6e268452d2884013fc909cc9ded8e

2
deps/lua vendored

@ -1 +1 @@
Subproject commit cf08915d62e338c987b71c078b148490510e9fe7
Subproject commit 7ca8105a2ea7b6a0d7b55b59d273ccd271c35268

2
deps/minhook vendored

@ -1 +1 @@
Subproject commit 49d03ad118cf7f6768c79a8f187e14b8f2a07f94
Subproject commit 98b74f1fc12d00313d91f10450e5b3e0036175e3

34
deps/premake/fmt.lua vendored
View File

@ -1,34 +0,0 @@
fmt = {
source = path.join(dependencies.basePath, "fmt"),
}
function fmt.import()
links { "fmt" }
fmt.includes()
end
function fmt.includes()
includedirs {
path.join(fmt.source, "include"),
}
end
function fmt.project()
project "fmt"
kind "StaticLib"
language "C++"
fmt.includes()
files {
path.join(fmt.source, "include/fmt/*.h"),
path.join(fmt.source, "src/*.cc")
}
removefiles {
path.join(fmt.source, "src/fmt.cc")
}
end
table.insert(dependencies, fmt)

View File

@ -1,5 +1,5 @@
gsc_tool = {
source = path.join(dependencies.basePath, "gsc-tool/src"),
source = path.join(dependencies.basePath, "gsc-tool"),
}
function gsc_tool.import()
@ -9,12 +9,7 @@ end
function gsc_tool.includes()
includedirs {
path.join(gsc_tool.source, "s1"),
path.join(gsc_tool.source, "utils"),
path.join(gsc_tool.source, "gsc"),
gsc_tool.source,
path.join(dependencies.basePath, "extra/gsc-tool"),
path.join(gsc_tool.source, "include"),
}
end
@ -24,17 +19,15 @@ function gsc_tool.project()
language "C++"
files {
path.join(gsc_tool.source, "utils/**.hpp"),
path.join(gsc_tool.source, "utils/**.cpp"),
path.join(gsc_tool.source, "include/xsk/utils/*.hpp"),
path.join(gsc_tool.source, "src/utils/*.cpp"),
}
includedirs {
path.join(gsc_tool.source, "utils"),
gsc_tool.source,
path.join(gsc_tool.source, "include"),
}
zlib.includes()
fmt.includes()
project "xsk-gsc-s1"
kind "StaticLib"
@ -45,28 +38,25 @@ function gsc_tool.project()
filter {}
files {
path.join(gsc_tool.source, "s1/s1_pc.hpp"),
path.join(gsc_tool.source, "s1/s1_pc.cpp"),
path.join(gsc_tool.source, "s1/s1_pc_code.cpp"),
path.join(gsc_tool.source, "s1/s1_pc_func.cpp"),
path.join(gsc_tool.source, "s1/s1_pc_meth.cpp"),
path.join(gsc_tool.source, "s1/s1_pc_token.cpp"),
path.join(gsc_tool.source, "include/xsk/stdinc.hpp"),
path.join(gsc_tool.source, "gsc/misc/*.hpp"),
path.join(gsc_tool.source, "gsc/misc/*.cpp"),
path.join(gsc_tool.source, "gsc/*.hpp"),
path.join(gsc_tool.source, "gsc/*.cpp"),
path.join(gsc_tool.source, "include/xsk/gsc/engine/s1_pc.hpp"),
path.join(gsc_tool.source, "src/gsc/engine/s1_pc.cpp"),
path.join(dependencies.basePath, "extra/gsc-tool/gsc_interface.cpp"),
path.join(gsc_tool.source, "src/gsc/engine/s1_pc_code.cpp"),
path.join(gsc_tool.source, "src/gsc/engine/s1_pc_func.cpp"),
path.join(gsc_tool.source, "src/gsc/engine/s1_pc_meth.cpp"),
path.join(gsc_tool.source, "src/gsc/engine/s1_pc_token.cpp"),
path.join(gsc_tool.source, "src/gsc/*.cpp"),
path.join(gsc_tool.source, "src/gsc/common/*.cpp"),
path.join(gsc_tool.source, "include/xsk/gsc/common/*.hpp"),
}
includedirs {
path.join(gsc_tool.source, "s1"),
gsc_tool.source,
path.join(dependencies.basePath, "extra/gsc-tool"),
path.join(gsc_tool.source, "include"),
}
fmt.includes()
end
table.insert(dependencies, gsc_tool)

2
deps/protobuf vendored

@ -1 +1 @@
Subproject commit 8d5fdedd42ef361dcfc1531fba4f33470273f375
Subproject commit 53a1c5c1d8b61984899b6877e491e5117ad486ba

2
deps/sol2 vendored

@ -1 +1 @@
Subproject commit 19898d8d3e6c3def33625082343428be1bb9387b
Subproject commit eab1430ccdbf61a0d61d11bf86b4975838dcfb9a

2
deps/zlib vendored

@ -1 +1 @@
Subproject commit fa8cd50ada68b873c754766bc73b12080b7b309e
Subproject commit eb0e038b297f2c9877ed8b3515c6718a4b65d485

View File

@ -71,6 +71,11 @@ namespace arxan
return EXCEPTION_CONTINUE_EXECUTION;
}
if (info->ExceptionRecord->ExceptionCode == STATUS_SINGLE_STEP)
{
return EXCEPTION_CONTINUE_EXECUTION;
}
return EXCEPTION_CONTINUE_SEARCH;
}
@ -136,7 +141,7 @@ namespace arxan
nt_query_information_process_hook.create(ntdll.get_proc<void*>("NtQueryInformationProcess"),
nt_query_information_process_stub);
AddVectoredExceptionHandler(1, exception_filter);
AddVectoredExceptionHandler(0, exception_filter);
}
void post_unpack() override

View File

@ -10,11 +10,10 @@
#include "script_error.hpp"
#include "script_extension.hpp"
#include "script_loading.hpp"
#include <utils/string.hpp>
#include <gsc_interface.hpp>
namespace gsc
{
std::uint16_t function_id_start = 0x2DF;
@ -95,11 +94,11 @@ namespace gsc
if (function_id > 0x1000)
{
console::warn("in call to builtin method \"%s\"%s", gsc::cxt->meth_name(function_id).data(), error.data());
console::warn("in call to builtin method \"%s\"%s", gsc_ctx->meth_name(function_id).data(), error.data());
}
else
{
console::warn("in call to builtin function \"%s\"%s", gsc::cxt->func_name(function_id).data(), error.data());
console::warn("in call to builtin function \"%s\"%s", gsc_ctx->func_name(function_id).data(), error.data());
}
}
@ -107,8 +106,8 @@ namespace gsc
{
try
{
const auto index = gsc::cxt->opcode_enum(opcode);
return {gsc::cxt->opcode_name(index)};
const auto index = gsc_ctx->opcode_enum(opcode);
return {gsc_ctx->opcode_name(index)};
}
catch (...)
{
@ -232,7 +231,7 @@ namespace gsc
void override_function(const std::string& name, game::BuiltinFunction func)
{
const auto id = gsc::cxt->func_id(name);
const auto id = gsc_ctx->func_id(name);
builtin_funcs_overrides.emplace(id, func);
}
@ -240,7 +239,7 @@ namespace gsc
{
++function_id_start;
functions[function_id_start] = function;
gsc::cxt->func_add(name, function_id_start);
gsc_ctx->func_add(name, function_id_start);
}
class extension final : public component_interface

View File

@ -14,10 +14,10 @@
#include "script_loading.hpp"
#include <gsc_interface.hpp>
namespace gsc
{
std::unique_ptr<xsk::gsc::s1_pc::context> gsc_ctx;
namespace
{
std::unordered_map<std::string, unsigned int> main_handles;
@ -82,8 +82,8 @@ namespace gsc
try
{
auto& compiler = gsc::cxt->compiler();
auto& assembler = gsc::cxt->assembler();
auto& compiler = gsc_ctx->compiler();
auto& assembler = gsc_ctx->assembler();
std::string source_buffer{};
if (!read_raw_script_file(real_name + ".gsc", &source_buffer))
@ -140,7 +140,7 @@ namespace gsc
std::string get_script_file_name(const std::string& name)
{
const auto id = gsc::cxt->token_id(name);
const auto id = gsc_ctx->token_id(name);
if (!id)
{
return name;
@ -159,7 +159,8 @@ namespace gsc
console::info("Decompiling scriptfile '%s'\n", real_name.data());
const std::string stack{script_file->buffer, static_cast<std::uint32_t>(script_file->len)};
const auto len = script_file->compressedLen;
const std::string stack{script_file->buffer, static_cast<std::uint32_t>(len)};
const auto decompressed_stack = utils::compression::zlib::decompress(stack);
@ -176,8 +177,8 @@ namespace gsc
return;
}
const auto main_handle = game::Scr_GetFunctionHandle(name.data(), gsc::cxt->token_id("main"));
const auto init_handle = game::Scr_GetFunctionHandle(name.data(), gsc::cxt->token_id("init"));
const auto main_handle = game::Scr_GetFunctionHandle(name.data(), gsc_ctx->token_id("main"));
const auto init_handle = game::Scr_GetFunctionHandle(name.data(), gsc_ctx->token_id("init"));
if (main_handle)
{
@ -305,7 +306,7 @@ namespace gsc
xsk::gsc::build::dev :
xsk::gsc::build::prod;
gsc::cxt->init(comp_mode, [](const std::string& include_name) -> std::pair<xsk::gsc::buffer, std::vector<std::uint8_t>>
gsc_ctx->init(comp_mode, [](const std::string& include_name) -> std::pair<xsk::gsc::buffer, std::vector<std::uint8_t>>
{
const auto real_name = get_raw_script_file_name(include_name);
@ -333,7 +334,7 @@ namespace gsc
void scr_end_load_scripts_stub()
{
// Cleanup the compiler
gsc::cxt->cleanup();
gsc_ctx->cleanup();
utils::hook::invoke<void>(SELECT_VALUE(0x140243780, 0x1403EDF90));
}
@ -345,7 +346,7 @@ namespace gsc
const auto id = static_cast<std::uint16_t>(std::strtol(name, nullptr, 10));
if (id)
{
real_name = gsc::cxt->token_name(id);
real_name = gsc_ctx->token_name(id);
}
auto* script = load_custom_script(name, real_name);
@ -362,7 +363,7 @@ namespace gsc
public:
void post_load() override
{
gsc::cxt = std::make_unique<xsk::gsc::s1_pc::context>();
gsc_ctx = std::make_unique<xsk::gsc::s1_pc::context>();
}
void post_unpack() override

View File

@ -1,6 +1,9 @@
#pragma once
#include <xsk/gsc/engine/s1_pc.hpp>
namespace gsc
{
extern std::unique_ptr<xsk::gsc::s1_pc::context> gsc_ctx;
game::ScriptFile* find_script(game::XAssetType type, const char* name, int allow_create_default);
}

View File

@ -4,8 +4,7 @@
#include <utils/string.hpp>
#include "component/gsc/script_extension.hpp"
#include <gsc_interface.hpp>
#include "component/gsc/script_loading.hpp"
namespace scripting
{
@ -14,8 +13,8 @@ namespace scripting
int find_function_index(const std::string& name, [[maybe_unused]] const bool prefer_global)
{
const auto target = utils::string::to_lower(name);
auto const& first = gsc::cxt->func_map();
auto const& second = gsc::cxt->meth_map();
auto const& first = gsc::gsc_ctx->func_map();
auto const& second = gsc::gsc_ctx->meth_map();
if (const auto itr = first.find(name); itr != first.end())
{
@ -43,17 +42,17 @@ namespace scripting
std::string find_token(std::uint32_t id)
{
return gsc::cxt->token_name(id);
return gsc::gsc_ctx->token_name(id);
}
std::string find_token_single(std::uint32_t id)
{
return gsc::cxt->token_name(id);
return gsc::gsc_ctx->token_name(id);
}
unsigned int find_token_id(const std::string& name)
{
const auto id = gsc::cxt->token_id(name);
const auto id = gsc::gsc_ctx->token_id(name);
if (id)
{
return id;

View File

@ -5,14 +5,14 @@
#include "game/scripting/execution.hpp"
#include "component/gsc/script_loading.hpp"
#include "component/command.hpp"
#include "component/notifies.hpp"
#include "component/scripting.hpp"
#include <utils/string.hpp>
#include <gsc_interface.hpp>
namespace scripting::lua
{
namespace
@ -245,7 +245,7 @@ namespace scripting::lua
auto entity_type = state.new_usertype<entity>("entity");
for (auto const& func : gsc::cxt->meth_map())
for (auto const& func : gsc::gsc_ctx->meth_map())
{
const auto name = std::string(func.first);
entity_type[name] = [name](const entity& entity, const sol::this_state s, sol::variadic_args va)
@ -377,7 +377,7 @@ namespace scripting::lua
auto game_type = state.new_usertype<game>("game_");
state["game"] = game();
for (auto const& func : gsc::cxt->func_map())
for (auto const& func : gsc::gsc_ctx->func_map())
{
const auto name = std::string(func.first);
game_type[name] = [name](const game&, const sol::this_state s, sol::variadic_args va)

View File

@ -162,11 +162,11 @@ void limit_parallel_dll_loading()
void apply_environment()
{
wchar_t* buffer{};
char* buffer{};
std::size_t size{};
if (_wdupenv_s(&buffer, &size, L"XLABS_AW_INSTALL") != 0 || buffer == nullptr)
if (_dupenv_s(&buffer, &size, "XLABS_AW_INSTALL") != 0 || buffer == nullptr)
{
throw std::runtime_error("Please use the X Labs launcher to run the game!");
return;
}
const auto _ = gsl::finally([&]
@ -174,8 +174,8 @@ void apply_environment()
std::free(buffer);
});
SetCurrentDirectoryW(buffer);
SetDllDirectoryW(buffer);
SetCurrentDirectoryA(buffer);
SetDllDirectoryA(buffer);
}
int main()