Implement Error Handler

This commit is contained in:
GreenComfyTea
2023-08-05 16:30:15 +03:00
parent 4bdb4ee2e6
commit dfb7893c1a
59 changed files with 1079 additions and 402 deletions

View File

@@ -8,6 +8,7 @@ local ailments;
local singletons;
local non_players;
local utils;
local error_handler;
local sdk = sdk;
local tostring = tostring;
@@ -106,11 +107,13 @@ function this.update_damage(enemy, enemy_calc_damage_info)
local is_large_monster = is_boss_enemy_method:call(enemy);
if is_large_monster == nil then
error_handler.report("damage_hook.update_damage", "Failed to Access Data: is_large_monster");
return;
end
local dead_or_captured = check_die_method:call(enemy);
if dead_or_captured == nil then
error_handler.report("damage_hook.update_damage", "Failed to Access Data: dead_or_captured");
return;
end
@@ -263,6 +266,7 @@ function this.cart(dead_player_id, flag_cat_skill_insurance)
local player = players.list[dead_player_id];
if player == nil then
error_handler.report("damage_hook.cart", "No Dead Player Found");
return;
end
@@ -296,6 +300,7 @@ function this.on_stock_direct_marionette_finish_shoot_hit_parts_damage(enemy, da
end
if player == nil then
error_handler.report("damage_hook.on_stock_direct_marionette_finish_shoot_hit_parts_damage", "Failed to Create Player Entry");
return;
end
@@ -355,11 +360,13 @@ function this.on_anomaly_core_break(anomaly_core_part)
end
if anomaly_monster == nil then
error_handler.report("damage_hook.on_anomaly_core_break", "No Anomaly Monster Found");
return;
end
local anomaly_core_break_damage_rate = get_mystery_core_break_damage_rate_method:call(anomaly_monster.enemy);
if anomaly_core_break_damage_rate == nil then
error_handler.report("damage_hook.on_anomaly_core_break", "Failed to Access Data: anomaly_core_break_damage_rate");
return;
end
@@ -383,10 +390,10 @@ function this.init_dependencies()
singletons = require("MHR_Overlay.Game_Handler.singletons");
non_players = require("MHR_Overlay.Damage_Meter.non_players");
utils = require("MHR_Overlay.Misc.utils");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()
sdk.hook(stock_direct_marionette_finish_shoot_hit_parts_damage_method, function(args)
local enemy = sdk.to_managed_object(args[2]);
local damage_rate = sdk.to_float(args[3]);

View File

@@ -9,6 +9,7 @@ local quest_status;
local drawing;
local language;
local players;
local error_handler;
local sdk = sdk;
local tostring = tostring;
@@ -132,17 +133,19 @@ function this.update_servant_list()
local cached_config = config.current_config.damage_meter_UI;
if singletons.servant_manager == nil then
error_handler.report("non_players.update_servant_list", "Failed to Access Data: servant_manager");
return;
end
local quest_servant_id_list = get_quest_servant_id_list_method:call(singletons.servant_manager);
if quest_servant_id_list == nil then
error_handler.report("non_players.update_servant_list", "Failed to Access Data: quest_servant_id_list");
return;
end
local servant_count = servant_get_count_method:call(quest_servant_id_list);
if servant_count == nil then
customization_menu.status = "No quest servant id list count";
error_handler.report("non_players.update_servant_list", "Failed to Access Data: servant_count");
return;
end
@@ -150,19 +153,20 @@ function this.update_servant_list()
for i = 0, servant_count - 1 do
local servant_id = servant_get_item_method:call(quest_servant_id_list, i);
if servant_id == nil then
error_handler.report("non_players.update_servant_list", "Failed to Access Data: servant_id No." .. tostring(i));
goto continue;
end
local ai_control = get_ai_control_by_servant_id_method:call(singletons.servant_manager, servant_id);
if ai_control == nil then
customization_menu.status = "No quest servant ai control";
error_handler.report("non_players.update_servant_list", "Failed to Access Data: ai_control No." .. tostring(i));
goto continue;
end
local servant_info = get_servant_info_method:call(ai_control);
if servant_info == nil then
customization_menu.status = "No quest servant info";
error_handler.report("non_players.update_servant_list", "Failed to Access Data: servant_info No." .. tostring(i));
goto continue;
end
@@ -213,8 +217,14 @@ function this.update_my_otomos()
local cached_config = config.current_config.damage_meter_UI;
local first_otomo = get_master_otomo_info_method:call(singletons.otomo_manager, 0);
if first_otomo ~= nil then
if first_otomo == nil then
error_handler.report("non_players.update_my_otomos", "Failed to Access Data: first_otomo");
else
local name = otomo_create_data_name_field:get_data(first_otomo);
if name == nil then
error_handler.report("non_players.update_my_otomos", "Failed to Access Data: first_otomo -> name");
end
if name ~= nil and name ~= "" then
local level = otomo_create_data_level_field:get_data(first_otomo) or 0;
@@ -230,8 +240,14 @@ function this.update_my_otomos()
end
local second_otomo = get_master_otomo_info_method:call(singletons.otomo_manager, 1);
if second_otomo ~= nil then
if second_otomo == nil then
error_handler.report("non_players.update_my_otomos", "Failed to Access Data: second_otomo");
else
local name = otomo_create_data_name_field:get_data(second_otomo);
if name == nil then
error_handler.report("non_players.update_my_otomos", "Failed to Access Data: second_otomo -> name");
end
if name ~= nil and name ~= "" then
local level = otomo_create_data_level_field:get_data(second_otomo) or 0;
@@ -252,19 +268,20 @@ function this.update_servant_otomos()
local servant_otomo_list = get_servant_otomo_list_method:call(singletons.otomo_manager);
if servant_otomo_list == nil then
customization_menu.status = "No servant otomo list";
error_handler.report("non_players.update_servant_otomos", "Failed to Access Data: servant_otomo_list");
return;
end
local count = otomo_get_count_method:call(servant_otomo_list);
if count == nil then
customization_menu.status = "No servant otomo list count";
error_handler.report("non_players.update_servant_otomos", "Failed to Access Data: servant_otomo_list -> count");
return;
end
for i = 0, count - 1 do
local servant_otomo = otomo_get_item_method:call(servant_otomo_list, i);
if servant_otomo == nil then
error_handler.report("non_players.update_servant_otomos", "Failed to Access Data: servant_otomo No. " .. tostring(i));
goto continue
end
@@ -275,6 +292,7 @@ function this.update_servant_otomos()
local member_id = otomo_create_data:get_field("MemberID");
if name == nil then
error_handler.report("non_players.update_servant_otomos", string.format("Failed to Access Data: servant_otomo No. %d -> name", i));
goto continue;
end
@@ -296,30 +314,33 @@ function this.update_otomos(otomo_info_field_)
local cached_config = config.current_config.damage_meter_UI;
if singletons.lobby_manager == nil then
error_handler.report("non_players.update_otomos", "Failed to Access Data: lobby_manager");
return;
end
-- other players
local otomo_info_list = otomo_info_field_:get_data(singletons.lobby_manager);
if otomo_info_list == nil then
customization_menu.status = "No otomo info list";
error_handler.report("non_players.update_otomos", "Failed to Access Data: otomo_info_list");
return;
end
local count = otomo_info_get_count_method:call(otomo_info_list);
if count == nil then
customization_menu.status = "No otomo info list count";
error_handler.report("non_players.update_otomos", "Failed to Access Data: otomo_info_list -> count");
return;
end
for id = 0, count - 1 do
local otomo_info = otomo_info_get_item_method:call(otomo_info_list, id);
if otomo_info == nil then
error_handler.report("non_players.update_otomos", "Failed to Access Data: otomo_info No. " .. tostring(id));
goto continue;
end
local name = otomo_info_name_field:get_data(otomo_info);
if name == nil then
error_handler.report("non_players.update_otomos", string.format("Failed to Access Data: otomo_info No. %d -> name", id));
goto continue;
end
@@ -387,6 +408,7 @@ function this.init_dependencies()
drawing = require("MHR_Overlay.UI.drawing");
language = require("MHR_Overlay.Misc.language");
players = require("MHR_Overlay.Damage_Meter.players");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()

View File

@@ -10,6 +10,7 @@ local drawing;
local language;
local non_players;
local utils;
local error_handler;
local sdk = sdk;
local tostring = tostring;
@@ -137,6 +138,7 @@ end
function this.update_damage(player, damage_source_type, is_large_monster, damage_object)
if player == nil then
error_handler.report("players.update_damage", "Missing Parameter: player");
return;
end
@@ -155,6 +157,7 @@ end
function this.update_display(player)
if player == nil then
error_handler.report("players.update_display", "Missing Parameter: player");
return;
end
@@ -450,20 +453,22 @@ local get_pos_field = player_base_type_def:get_method("get_Pos");
function this.update_myself_position()
if singletons.player_manager == nil then
customization_menu.status = "No player manager";
error_handler.report("players.update_myself_position", "Failed to Access Data: player_manager");
return;
end
local master_player = find_master_player_method:call(singletons.player_manager);
if master_player == nil then
customization_menu.status = "No master player";
error_handler.report("players.update_myself_position", "Failed to Access Data: master_player");
return;
end
local position = get_pos_field:call(master_player);
if position ~= nil then
this.myself_position = position;
if position == nil then
error_handler.report("players.update_myself_position", "Failed to Access Data: position");
end
this.myself_position = position;
end
function this.init()
@@ -512,23 +517,25 @@ function this.update_player_list_(hunter_info_field_)
local cached_config = config.current_config.damage_meter_UI;
if singletons.lobby_manager == nil then
error_handler.report("players.update_player_list_", "Failed to Access Data: lobby_manager");
return;
end
if singletons.progress_manager == nil then
error_handler.report("players.update_player_list_", "Failed to Access Data: progress_manager");
return;
end
-- myself player
local myself_player_info = my_hunter_info_field:get_data(singletons.lobby_manager);
if myself_player_info == nil then
customization_menu.status = "No myself player info list";
error_handler.report("players.update_player_list_", "Failed to Access Data: myself_player_info");
return;
end
local myself_player_name = name_field:get_data(myself_player_info);
if myself_player_name == nil then
customization_menu.status = "No myself player name";
error_handler.report("players.update_player_list_", "Failed to Access Data: myself_player_name");
return;
end
@@ -538,7 +545,7 @@ function this.update_player_list_(hunter_info_field_)
local myself_id = get_master_player_id_method:call(singletons.player_manager);
if myself_id == nil then
customization_menu.status = "No myself player id";
error_handler.report("players.update_player_list_", "Failed to Access Data: myself_id");
return;
end
@@ -551,25 +558,26 @@ function this.update_player_list_(hunter_info_field_)
-- other players
local player_info_list = hunter_info_field_:get_data(singletons.lobby_manager);
if player_info_list == nil then
customization_menu.status = "No player info list";
error_handler.report("players.update_player_list_", "Failed to Access Data: player_info_list");
return;
end
local count = get_count_method:call(player_info_list);
if count == nil then
customization_menu.status = "No player info list count";
error_handler.report("players.update_player_list_", "Failed to Access Data: player_info_list -> count");
return;
end
for i = 0, count - 1 do
local player_info = get_item_method:call(player_info_list, i);
if player_info == nil then
error_handler.report("players.update_player_list_", "Failed to Access Data: player_info No. " .. tostring(i));
goto continue
end
local id = member_index_field:get_data(player_info);
if id == nil then
error_handler.report("players.update_player_list_", string.format("Failed to Access Data: player_info No. %d -> id", i));
goto continue
end
@@ -578,13 +586,13 @@ function this.update_player_list_(hunter_info_field_)
local name = name_field:get_data(player_info);
if name == nil then
error_handler.report("players.update_player_list_", string.format("Failed to Access Data: player_info No. %d -> name", i));
goto continue
end
local player = this.list[id];
if player == nil then
if name == this.myself.name then
player = this.new(id, name, master_rank, hunter_rank, this.types.myself);
this.myself = player;
@@ -647,7 +655,7 @@ function this.init_dependencies()
language = require("MHR_Overlay.Misc.language");
non_players = require("MHR_Overlay.Damage_Meter.non_players");
utils = require("MHR_Overlay.Misc.utils");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()