mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-18 04:08:27 +00:00
[Feature] Add RegisterBug LuaMod (#4209)
* Add RegisterBug LuaMod * Add missing header * Add missing header to lua_mod * Fix RegisterBug ignore_default * Fix ignore_default * Fix formatting
This commit is contained in:
@@ -37,6 +37,7 @@ void LuaMod::Init()
|
||||
m_has_get_experience_for_kill = parser_->HasFunction("GetExperienceForKill", package_name_);
|
||||
m_has_common_outgoing_hit_success = parser_->HasFunction("CommonOutgoingHitSuccess", package_name_);
|
||||
m_has_calc_spell_effect_value_formula = parser_->HasFunction("CalcSpellEffectValue_formula", package_name_);
|
||||
m_has_register_bug = parser_->HasFunction("RegisterBug", package_name_);
|
||||
}
|
||||
|
||||
void PutDamageHitInfo(lua_State *L, luabind::adl::object &e, DamageHitInfo &hit) {
|
||||
@@ -678,4 +679,74 @@ void LuaMod::CalcSpellEffectValue_formula(Mob *self, uint32 formula, int64 base_
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LuaMod::RegisterBug(Client *self, BaseBugReportsRepository::BugReports bug, bool &ignore_default)
|
||||
{
|
||||
int start = lua_gettop(L);
|
||||
|
||||
try {
|
||||
if (!m_has_register_bug) {
|
||||
return;
|
||||
}
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, package_name_.c_str());
|
||||
lua_getfield(L, -1, "RegisterBug");
|
||||
|
||||
Lua_Client l_self(self);
|
||||
luabind::adl::object e = luabind::newtable(L);
|
||||
e["self"] = l_self;
|
||||
e["zone"] = bug.zone;
|
||||
e["client_version_id"] = bug.client_version_id;
|
||||
e["client_version_name"] = bug.client_version_name;
|
||||
e["account_id"] = bug.account_id;
|
||||
e["character_id"] = bug.character_id;
|
||||
e["character_name"] = bug.character_name;
|
||||
e["reporter_spoof"] = bug.reporter_spoof;
|
||||
e["category_id"] = bug.category_id;
|
||||
e["category_name"] = bug.category_name;
|
||||
e["reporter_name"] = bug.reporter_name;
|
||||
e["ui_path"] = bug.ui_path;
|
||||
e["pos_x"] = bug.pos_x;
|
||||
e["pos_y"] = bug.pos_y;
|
||||
e["pos_z"] = bug.pos_z;
|
||||
e["heading"] = bug.heading;
|
||||
e["time_played"] = bug.time_played;
|
||||
e["target_id"] = bug.target_id;
|
||||
e["target_name"] = bug.target_name;
|
||||
e["optional_info_mask"] = bug.optional_info_mask;
|
||||
e["_can_duplicate"] = bug._can_duplicate;
|
||||
e["_crash_bug"] = bug._crash_bug;
|
||||
e["_target_info"] = bug._target_info;
|
||||
e["_character_flags"] = bug._character_flags;
|
||||
e["_unknown_value"] = bug._unknown_value;
|
||||
e["bug_report"] = bug.bug_report;
|
||||
e["system_info"] = bug.system_info;
|
||||
|
||||
e.push(L);
|
||||
|
||||
if (lua_pcall(L, 1, 1, 0)) {
|
||||
std::string error = lua_tostring(L, -1);
|
||||
parser_->AddError(error);
|
||||
lua_pop(L, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lua_type(L, -1) == LUA_TTABLE) {
|
||||
luabind::adl::object ret(luabind::from_stack(L, -1));
|
||||
auto ignore_default_obj = ret["ignore_default"];
|
||||
if (luabind::type(ignore_default_obj) == LUA_TBOOLEAN) {
|
||||
ignore_default = ignore_default || luabind::object_cast<bool>(ignore_default_obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
parser_->AddError(ex.what());
|
||||
}
|
||||
|
||||
int end = lua_gettop(L);
|
||||
int n = end - start;
|
||||
if (n > 0) {
|
||||
lua_pop(L, n);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user