From 1eacc72295735847bd5f35819affcd5f094a6e3b Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 29 May 2021 22:12:43 +0200 Subject: [PATCH] Cleanup --- src/component/gsc.cpp | 41 ++--------------------------------------- src/component/gsc.hpp | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 39 deletions(-) create mode 100644 src/component/gsc.hpp diff --git a/src/component/gsc.cpp b/src/component/gsc.cpp index 2f1cb44..350b10f 100644 --- a/src/component/gsc.cpp +++ b/src/component/gsc.cpp @@ -6,52 +6,15 @@ #include "game/scripting/execution.hpp" #include "game/scripting/functions.hpp" +#include "gsc.hpp" + namespace gsc { - using function_args = std::vector; - - using builtin_function = void(*)(); - using builtin_method = void(*)(game::scr_entref_t); - - using script_function = std::function; - using script_method = std::function; - std::unordered_map functions; std::unordered_map methods; namespace { - void gsc_function_stub(game::scr_entref_t ent) - { - /*const auto function = scripting::script_value(*game::scr_VmPub->top); - - if (!function.is()) - { - return; - } - - const auto function_str = function.as(); - - if (gsc_functions.find(function_str) != gsc_functions.end()) - { - std::vector arguments; - - for (auto i = 1; i < game::scr_VmPub->outparamcount; i++) - { - const auto value = game::scr_VmPub->top[-i]; - - arguments.emplace_back(value); - } - - const auto value = gsc_functions[function_str](ent, arguments); - if (*reinterpret_cast(&value)) - { - game::Scr_ClearOutParams(); - scripting::push_value(value); - } - }*/ - } - std::string method_name(unsigned int id) { const auto map = *game::plutonium::method_map_rev; diff --git a/src/component/gsc.hpp b/src/component/gsc.hpp new file mode 100644 index 0000000..d44a32e --- /dev/null +++ b/src/component/gsc.hpp @@ -0,0 +1,22 @@ +#pragma once + +namespace gsc +{ + using function_args = std::vector; + + using builtin_function = void(*)(); + using builtin_method = void(*)(game::scr_entref_t); + + using script_function = std::function; + using script_method = std::function; + + namespace function + { + void add(const std::string& name, const script_function& func); + } + + namespace method + { + void add(const std::string& name, const script_method& func); + } +} \ No newline at end of file