Cleanup notifies component
This commit is contained in:
parent
14679bbb8f
commit
3004006783
30
deps/extra/gsc-tool/interface.cpp
vendored
30
deps/extra/gsc-tool/interface.cpp
vendored
@ -1,30 +0,0 @@
|
|||||||
#include "stdafx.hpp"
|
|
||||||
|
|
||||||
#include <xsk/h2.hpp>
|
|
||||||
|
|
||||||
#include "interface.hpp"
|
|
||||||
|
|
||||||
namespace gsc
|
|
||||||
{
|
|
||||||
std::unique_ptr<xsk::gsc::compiler> compiler()
|
|
||||||
{
|
|
||||||
auto compiler = std::make_unique<xsk::gsc::h2::compiler>();
|
|
||||||
compiler->mode(xsk::gsc::build::prod);
|
|
||||||
return compiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<xsk::gsc::decompiler> decompiler()
|
|
||||||
{
|
|
||||||
return std::make_unique<xsk::gsc::h2::decompiler>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<xsk::gsc::assembler> assembler()
|
|
||||||
{
|
|
||||||
return std::make_unique<xsk::gsc::h2::assembler>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<xsk::gsc::disassembler> disassembler()
|
|
||||||
{
|
|
||||||
return std::make_unique<xsk::gsc::h2::disassembler>();
|
|
||||||
}
|
|
||||||
}
|
|
9
deps/extra/gsc-tool/interface.hpp
vendored
9
deps/extra/gsc-tool/interface.hpp
vendored
@ -1,9 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
namespace gsc
|
|
||||||
{
|
|
||||||
std::unique_ptr<xsk::gsc::compiler> compiler();
|
|
||||||
std::unique_ptr<xsk::gsc::decompiler> decompiler();
|
|
||||||
std::unique_ptr<xsk::gsc::assembler> assembler();
|
|
||||||
std::unique_ptr<xsk::gsc::disassembler> disassembler();
|
|
||||||
}
|
|
@ -268,6 +268,7 @@ namespace gsc
|
|||||||
{
|
{
|
||||||
utils::hook::set<uint32_t>(0x1405BC7BC, FUNC_TABLE_SIZE); // change builtin func count
|
utils::hook::set<uint32_t>(0x1405BC7BC, FUNC_TABLE_SIZE); // change builtin func count
|
||||||
|
|
||||||
|
utils::hook::set<uint32_t>(0x1405BCB6C + 2, sizeof(func_table));
|
||||||
utils::hook::set<uint32_t>(0x1405BC7C2 + 4, RVA(&func_table));
|
utils::hook::set<uint32_t>(0x1405BC7C2 + 4, RVA(&func_table));
|
||||||
utils::hook::inject(0x1405BCB78 + 3, &func_table);
|
utils::hook::inject(0x1405BCB78 + 3, &func_table);
|
||||||
utils::hook::set<uint32_t>(0x1405CA678 + 4, RVA(&func_table));
|
utils::hook::set<uint32_t>(0x1405CA678 + 4, RVA(&func_table));
|
||||||
|
@ -31,15 +31,16 @@ namespace notifies
|
|||||||
char empty_function[2] = {0x32, 0x34}; // CHECK_CLEAR_PARAMS, END
|
char empty_function[2] = {0x32, 0x34}; // CHECK_CLEAR_PARAMS, END
|
||||||
const char* target_function = nullptr;
|
const char* target_function = nullptr;
|
||||||
|
|
||||||
unsigned int local_id_to_entity(unsigned int local_id)
|
scripting::entity local_id_to_entity(unsigned int local_id)
|
||||||
{
|
{
|
||||||
const auto variable = game::scr_VarGlob->objectVariableValue[local_id];
|
return game::scr_VarGlob->objectVariableValue[local_id].u.f.next;
|
||||||
return variable.u.f.next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool execute_vm_hook(const char* pos)
|
bool execute_vm_hook(const char* pos)
|
||||||
{
|
{
|
||||||
if (vm_execute_hooks.find(pos) == vm_execute_hooks.end())
|
const auto start = std::chrono::high_resolution_clock::now();
|
||||||
|
const auto iter = vm_execute_hooks.find(pos);
|
||||||
|
if (iter == vm_execute_hooks.end())
|
||||||
{
|
{
|
||||||
hook_enabled = true;
|
hook_enabled = true;
|
||||||
return false;
|
return false;
|
||||||
@ -51,18 +52,16 @@ namespace notifies
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& hook = vm_execute_hooks[pos];
|
const auto& hook = iter->second;
|
||||||
if (hook.is_lua_hook)
|
if (hook.is_lua_hook)
|
||||||
{
|
{
|
||||||
const auto& function = hook.lua_function;
|
const auto& function = hook.lua_function;
|
||||||
const auto state = function.lua_state();
|
const auto state = function.lua_state();
|
||||||
|
|
||||||
const scripting::entity self = local_id_to_entity(game::scr_VmPub->function_frame->fs.localId);
|
const auto self = local_id_to_entity(game::scr_VmPub->function_frame->fs.localId);
|
||||||
|
|
||||||
std::vector<sol::lua_value> args;
|
std::vector<sol::lua_value> args;
|
||||||
|
|
||||||
const auto top = game::scr_function_stack->top;
|
const auto top = game::scr_function_stack->top;
|
||||||
|
|
||||||
for (auto* value = top; value->type != game::SCRIPT_END; --value)
|
for (auto* value = top; value->type != game::SCRIPT_END; --value)
|
||||||
{
|
{
|
||||||
args.push_back(scripting::lua::convert(state, *value));
|
args.push_back(scripting::lua::convert(state, *value));
|
||||||
@ -119,16 +118,14 @@ namespace notifies
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto player = scripting::call("getentbynum", {ent->s.entityNum});
|
const scripting::entity entity{game::scr_entref_t(ent->s.entityNum, 0)};
|
||||||
|
return scripting::lua::convert(state, entity);
|
||||||
return scripting::lua::convert(state, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_weapon_name(unsigned int weapon, bool isAlternate)
|
std::string get_weapon_name(unsigned int weapon, bool isAlternate)
|
||||||
{
|
{
|
||||||
char output[1024] = {0};
|
char output[1024] = {0};
|
||||||
game::BG_GetWeaponNameComplete(weapon, isAlternate, output, 1024);
|
game::BG_GetWeaponNameComplete(weapon, isAlternate, output, 1024);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,37 +136,34 @@ namespace notifies
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto _vec = scripting::vector(vec);
|
return scripting::lua::convert(state, scripting::vector(vec));
|
||||||
|
|
||||||
return scripting::lua::convert(state, _vec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string convert_mod(const int meansOfDeath)
|
std::string convert_mod(const int meansOfDeath)
|
||||||
{
|
{
|
||||||
const auto value = reinterpret_cast<game::scr_string_t**>(0x140BF49B0)[meansOfDeath];
|
const auto value = reinterpret_cast<game::scr_string_t**>(0x140BF49B0)[meansOfDeath];
|
||||||
const auto string = game::SL_ConvertToString(*value);
|
return game::SL_ConvertToString(*value);
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void scr_entity_damage_stub(game::gentity_s* self, game::gentity_s* inflictor, game::gentity_s* attacker, const float* vDir, const float* vPoint,
|
void scr_entity_damage_stub(game::gentity_s* self, game::gentity_s* inflictor, game::gentity_s* attacker, const float* v_dir, const float* v_point,
|
||||||
int damage, int dflags, const unsigned int meansOfDeath, const unsigned int weapon, bool isAlternate, unsigned int a11, const int hitLoc, unsigned int a13, unsigned int a14)
|
int damage, int dflags, const unsigned int means_of_death, const unsigned int weapon, bool is_alternate,
|
||||||
|
unsigned int a11, const int hit_loc, unsigned int a13, unsigned int a14)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
const std::string _hitLoc = reinterpret_cast<const char**>(0x140BF4AA0)[hitLoc];
|
const std::string hit_loc_str = reinterpret_cast<const char**>(0x140BF4AA0)[hit_loc];
|
||||||
const auto _mod = convert_mod(meansOfDeath);
|
const auto mod_str = convert_mod(means_of_death);
|
||||||
const auto _weapon = get_weapon_name(weapon, isAlternate);
|
const auto weapon_str = get_weapon_name(weapon, is_alternate);
|
||||||
|
|
||||||
for (const auto& callback : entity_damage_callbacks)
|
for (const auto& callback : entity_damage_callbacks)
|
||||||
{
|
{
|
||||||
const auto state = callback.lua_state();
|
const auto state = callback.lua_state();
|
||||||
|
|
||||||
const auto _self = convert_entity(state, self);
|
const auto self_ent = convert_entity(state, self);
|
||||||
const auto _inflictor = convert_entity(state, inflictor);
|
const auto inflictor_ent = convert_entity(state, inflictor);
|
||||||
const auto _attacker = convert_entity(state, attacker);
|
const auto attacker_ent = convert_entity(state, attacker);
|
||||||
const auto _vDir = convert_vector(state, vDir);
|
const auto v_dir_vec = convert_vector(state, v_dir);
|
||||||
|
|
||||||
const auto result = callback(_self, _inflictor, _attacker, damage, _mod, _weapon, _vDir, _hitLoc);
|
const auto result = callback(self_ent, inflictor_ent, attacker_ent, damage, mod_str, weapon_str, v_dir_vec, hit_loc_str);
|
||||||
scripting::lua::handle_error(result);
|
scripting::lua::handle_error(result);
|
||||||
|
|
||||||
if (result.valid())
|
if (result.valid())
|
||||||
@ -188,8 +182,8 @@ namespace notifies
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scr_entity_damage_hook.invoke<void>(self,inflictor, attacker, vDir, vPoint, damage, dflags,
|
scr_entity_damage_hook.invoke<void>(self, inflictor, attacker, v_dir, v_point, damage, dflags,
|
||||||
meansOfDeath, weapon, isAlternate, a11, hitLoc, a13, a14);
|
means_of_death, weapon, is_alternate, a11, hit_loc, a13, a14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,4 +255,4 @@ namespace notifies
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_COMPONENT(notifies::component)
|
REGISTER_COMPONENT(notifies::component)
|
||||||
|
Loading…
Reference in New Issue
Block a user