mirror of
https://github.com/XLabsProject/s1x-client.git
synced 2023-08-02 15:02:12 +02:00
maint: xsk update
This commit is contained in:
parent
089f1ed002
commit
42b53a2962
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -48,6 +48,3 @@
|
|||||||
path = deps/gsc-tool
|
path = deps/gsc-tool
|
||||||
url = https://github.com/xensik/gsc-tool.git
|
url = https://github.com/xensik/gsc-tool.git
|
||||||
branch = dev
|
branch = dev
|
||||||
[submodule "deps/fmt"]
|
|
||||||
path = deps/fmt
|
|
||||||
url = https://github.com/fmtlib/fmt.git
|
|
||||||
|
6
deps/extra/gsc-tool/gsc_interface.cpp
vendored
6
deps/extra/gsc-tool/gsc_interface.cpp
vendored
@ -1,6 +0,0 @@
|
|||||||
#include "gsc_interface.hpp"
|
|
||||||
|
|
||||||
namespace gsc
|
|
||||||
{
|
|
||||||
std::unique_ptr<xsk::gsc::s1_pc::context> cxt;
|
|
||||||
}
|
|
15
deps/extra/gsc-tool/gsc_interface.hpp
vendored
15
deps/extra/gsc-tool/gsc_interface.hpp
vendored
@ -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
deps/fmt
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 98699719f85445e0ab4a962c0b1a2a0218289814
|
|
2
deps/gsc-tool
vendored
2
deps/gsc-tool
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 9318c6e0ae15b69fd02d192ff3148dd187352d5d
|
Subproject commit 30efba5424e89adc2133caf671c5c4e73208c3dd
|
34
deps/premake/fmt.lua
vendored
34
deps/premake/fmt.lua
vendored
@ -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)
|
|
14
deps/premake/gsc-tool.lua
vendored
14
deps/premake/gsc-tool.lua
vendored
@ -9,12 +9,7 @@ end
|
|||||||
|
|
||||||
function gsc_tool.includes()
|
function gsc_tool.includes()
|
||||||
includedirs {
|
includedirs {
|
||||||
path.join(gsc_tool.source, "s1"),
|
|
||||||
path.join(gsc_tool.source, "utils"),
|
|
||||||
path.join(gsc_tool.source, "gsc"),
|
|
||||||
gsc_tool.source,
|
gsc_tool.source,
|
||||||
|
|
||||||
path.join(dependencies.basePath, "extra/gsc-tool"),
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -34,7 +29,6 @@ function gsc_tool.project()
|
|||||||
}
|
}
|
||||||
|
|
||||||
zlib.includes()
|
zlib.includes()
|
||||||
fmt.includes()
|
|
||||||
|
|
||||||
project "xsk-gsc-s1"
|
project "xsk-gsc-s1"
|
||||||
kind "StaticLib"
|
kind "StaticLib"
|
||||||
@ -45,6 +39,8 @@ function gsc_tool.project()
|
|||||||
filter {}
|
filter {}
|
||||||
|
|
||||||
files {
|
files {
|
||||||
|
path.join(gsc_tool.source, "stdinc.hpp"),
|
||||||
|
|
||||||
path.join(gsc_tool.source, "s1/s1_pc.hpp"),
|
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.cpp"),
|
||||||
path.join(gsc_tool.source, "s1/s1_pc_code.cpp"),
|
path.join(gsc_tool.source, "s1/s1_pc_code.cpp"),
|
||||||
@ -56,17 +52,11 @@ function gsc_tool.project()
|
|||||||
path.join(gsc_tool.source, "gsc/misc/*.cpp"),
|
path.join(gsc_tool.source, "gsc/misc/*.cpp"),
|
||||||
path.join(gsc_tool.source, "gsc/*.hpp"),
|
path.join(gsc_tool.source, "gsc/*.hpp"),
|
||||||
path.join(gsc_tool.source, "gsc/*.cpp"),
|
path.join(gsc_tool.source, "gsc/*.cpp"),
|
||||||
|
|
||||||
path.join(dependencies.basePath, "extra/gsc-tool/gsc_interface.cpp"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
includedirs {
|
includedirs {
|
||||||
path.join(gsc_tool.source, "s1"),
|
|
||||||
gsc_tool.source,
|
gsc_tool.source,
|
||||||
path.join(dependencies.basePath, "extra/gsc-tool"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.includes()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(dependencies, gsc_tool)
|
table.insert(dependencies, gsc_tool)
|
||||||
|
@ -10,11 +10,10 @@
|
|||||||
|
|
||||||
#include "script_error.hpp"
|
#include "script_error.hpp"
|
||||||
#include "script_extension.hpp"
|
#include "script_extension.hpp"
|
||||||
|
#include "script_loading.hpp"
|
||||||
|
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
#include <gsc_interface.hpp>
|
|
||||||
|
|
||||||
namespace gsc
|
namespace gsc
|
||||||
{
|
{
|
||||||
std::uint16_t function_id_start = 0x2DF;
|
std::uint16_t function_id_start = 0x2DF;
|
||||||
@ -95,11 +94,11 @@ namespace gsc
|
|||||||
|
|
||||||
if (function_id > 0x1000)
|
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
|
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
|
try
|
||||||
{
|
{
|
||||||
const auto index = gsc::cxt->opcode_enum(opcode);
|
const auto index = gsc_ctx->opcode_enum(opcode);
|
||||||
return {gsc::cxt->opcode_name(index)};
|
return {gsc_ctx->opcode_name(index)};
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -232,7 +231,7 @@ namespace gsc
|
|||||||
|
|
||||||
void override_function(const std::string& name, game::BuiltinFunction func)
|
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);
|
builtin_funcs_overrides.emplace(id, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +239,7 @@ namespace gsc
|
|||||||
{
|
{
|
||||||
++function_id_start;
|
++function_id_start;
|
||||||
functions[function_id_start] = function;
|
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
|
class extension final : public component_interface
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
#include "script_loading.hpp"
|
#include "script_loading.hpp"
|
||||||
|
|
||||||
#include <gsc_interface.hpp>
|
|
||||||
|
|
||||||
namespace gsc
|
namespace gsc
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<xsk::gsc::s1_pc::context> gsc_ctx;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, unsigned int> main_handles;
|
std::unordered_map<std::string, unsigned int> main_handles;
|
||||||
@ -82,8 +82,8 @@ namespace gsc
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto& compiler = gsc::cxt->compiler();
|
auto& compiler = gsc_ctx->compiler();
|
||||||
auto& assembler = gsc::cxt->assembler();
|
auto& assembler = gsc_ctx->assembler();
|
||||||
|
|
||||||
std::string source_buffer{};
|
std::string source_buffer{};
|
||||||
if (!read_raw_script_file(real_name + ".gsc", &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)
|
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)
|
if (!id)
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
@ -177,8 +177,8 @@ namespace gsc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto main_handle = game::Scr_GetFunctionHandle(name.data(), gsc::cxt->token_id("main"));
|
const auto main_handle = game::Scr_GetFunctionHandle(name.data(), gsc_ctx->token_id("main"));
|
||||||
const auto init_handle = game::Scr_GetFunctionHandle(name.data(), gsc::cxt->token_id("init"));
|
const auto init_handle = game::Scr_GetFunctionHandle(name.data(), gsc_ctx->token_id("init"));
|
||||||
|
|
||||||
if (main_handle)
|
if (main_handle)
|
||||||
{
|
{
|
||||||
@ -306,7 +306,7 @@ namespace gsc
|
|||||||
xsk::gsc::build::dev :
|
xsk::gsc::build::dev :
|
||||||
xsk::gsc::build::prod;
|
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);
|
const auto real_name = get_raw_script_file_name(include_name);
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ namespace gsc
|
|||||||
void scr_end_load_scripts_stub()
|
void scr_end_load_scripts_stub()
|
||||||
{
|
{
|
||||||
// Cleanup the compiler
|
// Cleanup the compiler
|
||||||
gsc::cxt->cleanup();
|
gsc_ctx->cleanup();
|
||||||
|
|
||||||
utils::hook::invoke<void>(SELECT_VALUE(0x140243780, 0x1403EDF90));
|
utils::hook::invoke<void>(SELECT_VALUE(0x140243780, 0x1403EDF90));
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ namespace gsc
|
|||||||
const auto id = static_cast<std::uint16_t>(std::strtol(name, nullptr, 10));
|
const auto id = static_cast<std::uint16_t>(std::strtol(name, nullptr, 10));
|
||||||
if (id)
|
if (id)
|
||||||
{
|
{
|
||||||
real_name = gsc::cxt->token_name(id);
|
real_name = gsc_ctx->token_name(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* script = load_custom_script(name, real_name);
|
auto* script = load_custom_script(name, real_name);
|
||||||
@ -363,7 +363,7 @@ namespace gsc
|
|||||||
public:
|
public:
|
||||||
void post_load() override
|
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
|
void post_unpack() override
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <s1/s1_pc.hpp>
|
||||||
|
|
||||||
namespace gsc
|
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);
|
game::ScriptFile* find_script(game::XAssetType type, const char* name, int allow_create_default);
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
#include "component/gsc/script_extension.hpp"
|
#include "component/gsc/script_extension.hpp"
|
||||||
|
#include "component/gsc/script_loading.hpp"
|
||||||
#include <gsc_interface.hpp>
|
|
||||||
|
|
||||||
namespace scripting
|
namespace scripting
|
||||||
{
|
{
|
||||||
@ -14,8 +13,8 @@ namespace scripting
|
|||||||
int find_function_index(const std::string& name, [[maybe_unused]] const bool prefer_global)
|
int find_function_index(const std::string& name, [[maybe_unused]] const bool prefer_global)
|
||||||
{
|
{
|
||||||
const auto target = utils::string::to_lower(name);
|
const auto target = utils::string::to_lower(name);
|
||||||
auto const& first = gsc::cxt->func_map();
|
auto const& first = gsc::gsc_ctx->func_map();
|
||||||
auto const& second = gsc::cxt->meth_map();
|
auto const& second = gsc::gsc_ctx->meth_map();
|
||||||
|
|
||||||
if (const auto itr = first.find(name); itr != first.end())
|
if (const auto itr = first.find(name); itr != first.end())
|
||||||
{
|
{
|
||||||
@ -43,17 +42,17 @@ namespace scripting
|
|||||||
|
|
||||||
std::string find_token(std::uint32_t id)
|
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)
|
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)
|
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)
|
if (id)
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
|
|
||||||
#include "game/scripting/execution.hpp"
|
#include "game/scripting/execution.hpp"
|
||||||
|
|
||||||
|
#include "component/gsc/script_loading.hpp"
|
||||||
|
|
||||||
#include "component/command.hpp"
|
#include "component/command.hpp"
|
||||||
#include "component/notifies.hpp"
|
#include "component/notifies.hpp"
|
||||||
#include "component/scripting.hpp"
|
#include "component/scripting.hpp"
|
||||||
|
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
#include <gsc_interface.hpp>
|
|
||||||
|
|
||||||
namespace scripting::lua
|
namespace scripting::lua
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
@ -245,7 +245,7 @@ namespace scripting::lua
|
|||||||
|
|
||||||
auto entity_type = state.new_usertype<entity>("entity");
|
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);
|
const auto name = std::string(func.first);
|
||||||
entity_type[name] = [name](const entity& entity, const sol::this_state s, sol::variadic_args va)
|
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_");
|
auto game_type = state.new_usertype<game>("game_");
|
||||||
state["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);
|
const auto name = std::string(func.first);
|
||||||
game_type[name] = [name](const game&, const sol::this_state s, sol::variadic_args va)
|
game_type[name] = [name](const game&, const sol::this_state s, sol::variadic_args va)
|
||||||
|
Loading…
Reference in New Issue
Block a user