deps: remove fmt
This commit is contained in:
parent
63f34d76db
commit
b41011b5b7
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -37,6 +37,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
|
||||
|
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::iw5_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 <iw5/iw5_pc.hpp>
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
extern std::unique_ptr<xsk::gsc::iw5_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 b44a51d8ac9aa69eee360f96d619c460373bbbc2
|
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)
|
18
deps/premake/gsc-tool.lua
vendored
18
deps/premake/gsc-tool.lua
vendored
@ -9,12 +9,11 @@ end
|
||||
|
||||
function gsc_tool.includes()
|
||||
includedirs {
|
||||
gsc_tool.source,
|
||||
path.join(gsc_tool.source, "iw5"),
|
||||
path.join(gsc_tool.source, "utils"),
|
||||
path.join(gsc_tool.source, "gsc"),
|
||||
gsc_tool.source,
|
||||
|
||||
path.join(dependencies.basePath, "extra/gsc-tool"),
|
||||
path.join(dependencies.basePath, "gsc-tool/include"),
|
||||
}
|
||||
end
|
||||
|
||||
@ -29,12 +28,11 @@ function gsc_tool.project()
|
||||
}
|
||||
|
||||
includedirs {
|
||||
path.join(gsc_tool.source, "utils"),
|
||||
gsc_tool.source,
|
||||
path.join(gsc_tool.source, "utils"),
|
||||
}
|
||||
|
||||
zlib.includes()
|
||||
fmt.includes()
|
||||
|
||||
project "xsk-gsc-iw5"
|
||||
kind "StaticLib"
|
||||
@ -45,6 +43,9 @@ function gsc_tool.project()
|
||||
filter {}
|
||||
|
||||
files {
|
||||
path.join(gsc_tool.source, "stdinc.hpp"),
|
||||
path.join(gsc_tool.source, "stdinc.cpp"),
|
||||
|
||||
path.join(gsc_tool.source, "iw5/iw5_pc.hpp"),
|
||||
path.join(gsc_tool.source, "iw5/iw5_pc.cpp"),
|
||||
path.join(gsc_tool.source, "iw5/iw5_pc_code.cpp"),
|
||||
@ -56,17 +57,12 @@ function gsc_tool.project()
|
||||
path.join(gsc_tool.source, "gsc/misc/*.cpp"),
|
||||
path.join(gsc_tool.source, "gsc/*.hpp"),
|
||||
path.join(gsc_tool.source, "gsc/*.cpp"),
|
||||
|
||||
path.join(dependencies.basePath, "extra/gsc-tool/gsc_interface.cpp"),
|
||||
}
|
||||
|
||||
includedirs {
|
||||
path.join(gsc_tool.source, "iw5"),
|
||||
gsc_tool.source,
|
||||
path.join(dependencies.basePath, "extra/gsc-tool"),
|
||||
path.join(gsc_tool.source, "iw5"),
|
||||
}
|
||||
|
||||
fmt.includes()
|
||||
end
|
||||
|
||||
table.insert(dependencies, gsc_tool)
|
||||
|
@ -1,90 +0,0 @@
|
||||
#include <std_include.hpp>
|
||||
#include "game/game.hpp"
|
||||
|
||||
#include "module/gsc/script_extension.hpp"
|
||||
|
||||
#include "functions.hpp"
|
||||
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include <gsc_interface.hpp>
|
||||
|
||||
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();
|
||||
|
||||
if (const auto itr = first.find(name); itr != first.end())
|
||||
{
|
||||
return static_cast<int>(itr->second);
|
||||
}
|
||||
|
||||
if (const auto itr = second.find(name); itr != second.end())
|
||||
{
|
||||
return static_cast<int>(itr->second);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::uint32_t parse_token_id(const std::string& name)
|
||||
{
|
||||
if (name.starts_with("_ID"))
|
||||
{
|
||||
return static_cast<std::uint32_t>(std::strtol(name.substr(3).data(), nullptr, 10));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string find_token(std::uint32_t id)
|
||||
{
|
||||
return gsc::cxt->token_name(id);
|
||||
}
|
||||
|
||||
std::string find_token_single(std::uint32_t id)
|
||||
{
|
||||
return gsc::cxt->token_name(id);
|
||||
}
|
||||
|
||||
unsigned int find_token_id(const std::string& name)
|
||||
{
|
||||
const auto id = gsc::cxt->token_id(name);
|
||||
if (id)
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
const auto parsed_id = parse_token_id(name);
|
||||
if (parsed_id)
|
||||
{
|
||||
return parsed_id;
|
||||
}
|
||||
|
||||
return game::native::SL_GetCanonicalString(name.data());
|
||||
}
|
||||
|
||||
game::native::BuiltinFunction get_function_by_index(const std::uint32_t index)
|
||||
{
|
||||
auto** function_table = gsc::func_table;
|
||||
auto** method_table = gsc::meth_table;
|
||||
|
||||
if (index < gsc::scr_func_max_id)
|
||||
{
|
||||
return reinterpret_cast<game::native::BuiltinFunction*>(function_table)[index - 1];
|
||||
}
|
||||
|
||||
return reinterpret_cast<game::native::BuiltinFunction*>(method_table)[index];
|
||||
}
|
||||
|
||||
game::native::BuiltinFunction find_function(const std::string& name, const bool prefer_global)
|
||||
{
|
||||
const auto index = find_function_index(name, prefer_global);
|
||||
if (index < 0) return nullptr;
|
||||
|
||||
return get_function_by_index(index);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace scripting
|
||||
{
|
||||
std::string find_token(std::uint32_t id);
|
||||
std::string find_token_single(std::uint32_t id);
|
||||
unsigned int find_token_id(const std::string& name);
|
||||
|
||||
int find_function_index(const std::string& name, bool prefer_global);
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "script_error.hpp"
|
||||
#include "script_loading.hpp"
|
||||
#include "script_extension.hpp"
|
||||
|
||||
#include "module/console.hpp"
|
||||
#include "module/scripting.hpp"
|
||||
@ -11,8 +12,6 @@
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include <gsc_interface.hpp>
|
||||
|
||||
using namespace utils::string;
|
||||
|
||||
namespace gsc
|
||||
@ -124,8 +123,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 (...)
|
||||
{
|
||||
@ -140,11 +139,11 @@ namespace gsc
|
||||
|
||||
if (function_id > (scr_func_max_id - 1))
|
||||
{
|
||||
console::error("in call to builtin method \"%s\"%s\n", gsc::cxt->meth_name(function_id).data(), error.data());
|
||||
console::error("in call to builtin method \"%s\"%s\n", gsc_ctx->meth_name(function_id).data(), error.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
console::error("in call to builtin function \"%s\"%s\n", gsc::cxt->func_name(function_id).data(), error.data());
|
||||
console::error("in call to builtin function \"%s\"%s\n", gsc_ctx->func_name(function_id).data(), error.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "script_extension.hpp"
|
||||
#include "script_error.hpp"
|
||||
#include "script_loading.hpp"
|
||||
|
||||
#include "module/console.hpp"
|
||||
#include "module/scripting.hpp"
|
||||
@ -11,8 +12,6 @@
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include <gsc_interface.hpp>
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
std::uint16_t scr_func_max_id = 0x1C7;
|
||||
@ -173,7 +172,7 @@ namespace gsc
|
||||
|
||||
++scr_func_max_id;
|
||||
custom_functions.push_back({ lowered_name, scr_func_max_id, func });
|
||||
cxt->func_add(lowered_name, scr_func_max_id);
|
||||
gsc_ctx->func_add(lowered_name, scr_func_max_id);
|
||||
}
|
||||
|
||||
void register_method(const std::string& name, const game::native::BuiltinMethod& meth)
|
||||
@ -193,7 +192,7 @@ namespace gsc
|
||||
|
||||
++scr_meth_max_id;
|
||||
custom_methods.push_back({ lowered_name, scr_meth_max_id, meth });
|
||||
cxt->meth_add(lowered_name, scr_meth_max_id);
|
||||
gsc_ctx->meth_add(lowered_name, scr_meth_max_id);
|
||||
}
|
||||
|
||||
const char* get_code_pos(int index)
|
||||
|
@ -12,10 +12,10 @@
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/memory.hpp>
|
||||
|
||||
#include <gsc_interface.hpp>
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
std::unique_ptr<xsk::gsc::iw5_pc::context> gsc_ctx;
|
||||
|
||||
namespace
|
||||
{
|
||||
utils::memory::allocator script_file_allocator;
|
||||
@ -80,8 +80,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))
|
||||
@ -128,7 +128,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;
|
||||
@ -190,14 +190,14 @@ namespace gsc
|
||||
|
||||
console::info("Script %s.gsc loaded successfully\n", path);
|
||||
|
||||
const auto main_handle = game::native::Scr_GetFunctionHandle(path, static_cast<std::uint16_t>(gsc::cxt->token_id("main")));
|
||||
const auto main_handle = game::native::Scr_GetFunctionHandle(path, static_cast<std::uint16_t>(gsc_ctx->token_id("main")));
|
||||
if (main_handle)
|
||||
{
|
||||
console::info("Loaded '%s::main'\n", path);
|
||||
main_handles[path] = main_handle;
|
||||
}
|
||||
|
||||
const auto init_handle = game::native::Scr_GetFunctionHandle(path, static_cast<std::uint16_t>(gsc::cxt->token_id("init")));
|
||||
const auto init_handle = game::native::Scr_GetFunctionHandle(path, static_cast<std::uint16_t>(gsc_ctx->token_id("init")));
|
||||
if (init_handle)
|
||||
{
|
||||
console::info("Loaded '%s::init'\n", path);
|
||||
@ -265,7 +265,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);
|
||||
|
||||
@ -293,7 +293,7 @@ namespace gsc
|
||||
void scr_end_load_scripts_stub()
|
||||
{
|
||||
// Cleanup the compiler
|
||||
gsc::cxt->cleanup();
|
||||
gsc_ctx->cleanup();
|
||||
|
||||
utils::hook::invoke<void>(SELECT_VALUE(0x5DF010, 0x561D00));
|
||||
}
|
||||
@ -305,7 +305,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);
|
||||
@ -322,7 +322,7 @@ namespace gsc
|
||||
public:
|
||||
void post_start() override
|
||||
{
|
||||
gsc::cxt = std::make_unique<xsk::gsc::iw5_pc::context>();
|
||||
gsc_ctx = std::make_unique<xsk::gsc::iw5_pc::context>();
|
||||
}
|
||||
|
||||
void post_load() override
|
||||
|
@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
#define XSK_GSC_IW5_PC
|
||||
#include <gsc_api.hpp>
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
extern std::uint16_t scr_func_max_id;
|
||||
extern std::unique_ptr<xsk::gsc::iw5_pc::context> gsc_ctx;
|
||||
|
||||
game::native::ScriptFile* find_script(game::native::XAssetType type, const char* name, int allow_create_default);
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
#include <loader/module_loader.hpp>
|
||||
#include "game/game.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include "scripting.hpp"
|
||||
|
||||
#include "game/scripting/functions.hpp"
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "gsc/script_loading.hpp"
|
||||
|
||||
@ -23,11 +23,6 @@ namespace scripting
|
||||
|
||||
std::vector<std::function<void(int)>> shutdown_callbacks;
|
||||
|
||||
std::string get_token(unsigned int id)
|
||||
{
|
||||
return find_token(id);
|
||||
}
|
||||
|
||||
void add_function_sort(unsigned int id, const char* pos)
|
||||
{
|
||||
std::string filename = current_file;
|
||||
@ -111,6 +106,11 @@ namespace scripting
|
||||
}
|
||||
}
|
||||
|
||||
std::string find_token(std::uint32_t id)
|
||||
{
|
||||
return gsc::gsc_ctx->token_name(id);
|
||||
}
|
||||
|
||||
std::string get_token(unsigned int id)
|
||||
{
|
||||
return find_token(id);
|
||||
|
@ -8,6 +8,7 @@ namespace scripting
|
||||
|
||||
extern std::string current_file;
|
||||
|
||||
std::string find_token(std::uint32_t id);
|
||||
std::string get_token(unsigned int id);
|
||||
|
||||
void on_shutdown(const std::function<void(int)>& callback);
|
||||
|
Loading…
Reference in New Issue
Block a user