From 0a5ed34bb7c8ae6f73e7a1b149677aa1898be4bc Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 19 Mar 2022 13:52:08 +0100 Subject: [PATCH] Fixed lots of crashes found by godot's regression test tool throwing improper parameters at methods. --- .../data/items/craft_recipe.cpp | 8 + .../data/items/equipment_data.cpp | 12 +- .../data/items/item_instance.cpp | 4 +- .../data/items/item_template.cpp | 32 +++ .../entity_spell_system/entities/entity.cpp | 193 ++++++++++++------ .../entities/resources/entity_resource.cpp | 2 + .../resources/entity_resource_health.cpp | 2 + .../resources/entity_resource_speed.cpp | 2 + .../stats/complex_level_stat_data.cpp | 12 +- .../material_cache/ess_material_cache.cpp | 2 + .../profiles/input/input_profile.cpp | 3 + .../profiles/input/input_profile_modifier.cpp | 12 ++ .../profiles/player_profile.cpp | 4 + .../skeleton/character_skeleton_2d.cpp | 2 + .../skeleton/character_skeleton_3d.cpp | 2 + modules/mesh_utils/mesh_merger.cpp | 20 ++ .../props_2d/prop_2d_instance_prop_job.cpp | 5 +- modules/props_2d/props/prop_2d_data_entry.cpp | 2 + 18 files changed, 253 insertions(+), 66 deletions(-) diff --git a/modules/entity_spell_system/data/items/craft_recipe.cpp b/modules/entity_spell_system/data/items/craft_recipe.cpp index f301de174..70c37574b 100644 --- a/modules/entity_spell_system/data/items/craft_recipe.cpp +++ b/modules/entity_spell_system/data/items/craft_recipe.cpp @@ -48,10 +48,14 @@ void CraftRecipe::set_sub_category(const CraftSubCategories value) { } Ref CraftRecipe::get_required_tool(const int index) { + ERR_FAIL_INDEX_V(index, MAX_REQUIRED_TOOLS, Ref()); + return _required_tools[index]; } void CraftRecipe::set_required_tool(const int index, const Ref &value) { + ERR_FAIL_INDEX(index, MAX_REQUIRED_TOOLS); + _required_tools[index] = value; } @@ -64,10 +68,14 @@ void CraftRecipe::set_required_tools_count(const int value) { } void CraftRecipe::set_required_material(const int index, const Ref &value) { + ERR_FAIL_INDEX(index, MAX_REQUIRED_MATERIALS); + _required_materials[index] = value; } Ref CraftRecipe::get_required_material(int index) { + ERR_FAIL_INDEX_V(index, MAX_REQUIRED_MATERIALS, Ref()); + return _required_materials[index]; } diff --git a/modules/entity_spell_system/data/items/equipment_data.cpp b/modules/entity_spell_system/data/items/equipment_data.cpp index d3bf228e3..80b145411 100644 --- a/modules/entity_spell_system/data/items/equipment_data.cpp +++ b/modules/entity_spell_system/data/items/equipment_data.cpp @@ -28,18 +28,18 @@ SOFTWARE. #include "../../singletons/ess.h" Ref EquipmentData::get_slot(int index) { - ERR_FAIL_INDEX_V(index, ESS::get_singleton()->equip_slot_get_count(), Ref()); + ERR_FAIL_INDEX_V(index, _entries.size(), Ref()); return _entries[index]; } void EquipmentData::set_slot(int index, Ref entry) { - ERR_FAIL_INDEX(index, ESS::get_singleton()->equip_slot_get_count()); + ERR_FAIL_INDEX(index, _entries.size()); _entries.write[index] = entry; } Ref EquipmentData::get_item(int index) { - ERR_FAIL_INDEX_V(index, ESS::get_singleton()->equip_slot_get_count(), Ref()); + ERR_FAIL_INDEX_V(index, _entries.size(), Ref()); Ref ede = _entries[index]; @@ -60,6 +60,8 @@ EquipmentData::~EquipmentData() { } bool EquipmentData::_set(const StringName &p_name, const Variant &p_value) { + ERR_FAIL_COND_V(!ESS::get_singleton(), false); + String name = p_name; if (name.get_slicec('/', 0) == "slot") { @@ -86,6 +88,8 @@ bool EquipmentData::_set(const StringName &p_name, const Variant &p_value) { } bool EquipmentData::_get(const StringName &p_name, Variant &r_ret) const { + ERR_FAIL_COND_V(!ESS::get_singleton(), false); + String name = p_name; if (name.get_slicec('/', 0) == "slot") { @@ -112,6 +116,8 @@ bool EquipmentData::_get(const StringName &p_name, Variant &r_ret) const { } void EquipmentData::_get_property_list(List *p_list) const { + ERR_FAIL_COND(!ESS::get_singleton()); + for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) { p_list->push_back(PropertyInfo(Variant::OBJECT, "slot/" + ESS::get_singleton()->equip_slot_get_property_name(i), PROPERTY_HINT_RESOURCE_TYPE, "ItemTemplate")); } diff --git a/modules/entity_spell_system/data/items/item_instance.cpp b/modules/entity_spell_system/data/items/item_instance.cpp index a5faca46d..04847b9bb 100644 --- a/modules/entity_spell_system/data/items/item_instance.cpp +++ b/modules/entity_spell_system/data/items/item_instance.cpp @@ -172,7 +172,9 @@ void ItemInstance::from_dict(const Dictionary &dict) { Dictionary ItemInstance::_to_dict() { Dictionary dict; - dict["item_path"] = _item_template->get_path(); + if (_item_template.is_valid()) { + dict["item_path"] = _item_template->get_path(); + } dict["stack_size"] = _stack_size; diff --git a/modules/entity_spell_system/data/items/item_template.cpp b/modules/entity_spell_system/data/items/item_template.cpp index eb187b1d9..5577fdd45 100644 --- a/modules/entity_spell_system/data/items/item_template.cpp +++ b/modules/entity_spell_system/data/items/item_template.cpp @@ -291,66 +291,98 @@ void ItemTemplate::stat_modifier_set_count(int value) { } int ItemTemplate::stat_modifier_get_stat_id(const int index) const { + ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0); + return _modifiers[index].stat_id; } void ItemTemplate::stat_modifier_set_stat_id(const int index, const int value) { + ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD); + _modifiers[index].stat_id = value; } float ItemTemplate::stat_modifier_get_min_base_mod(const int index) const { + ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0); + return _modifiers[index].min_base_mod; } void ItemTemplate::stat_modifier_set_min_base_mod(const int index, const float value) { + ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD); + _modifiers[index].min_base_mod = value; } float ItemTemplate::stat_modifier_get_max_base_mod(const int index) const { + ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0); + return _modifiers[index].max_base_mod; } void ItemTemplate::stat_modifier_set_max_base_mod(const int index, const float value) { + ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD); + _modifiers[index].max_base_mod = value; } float ItemTemplate::stat_modifier_get_min_bonus_mod(const int index) const { + ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0); + return _modifiers[index].min_bonus_mod; } void ItemTemplate::stat_modifier_set_min_bonus_mod(const int index, const float value) { + ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD); + _modifiers[index].min_bonus_mod = value; } float ItemTemplate::stat_modifier_get_max_bonus_mod(const int index) const { + ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0); + return _modifiers[index].max_bonus_mod; } void ItemTemplate::stat_modifier_set_max_bonus_mod(const int index, const float value) { + ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD); + _modifiers[index].max_bonus_mod = value; } float ItemTemplate::stat_modifier_get_min_percent_mod(const int index) const { + ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0); + return _modifiers[index].min_percent_mod; } void ItemTemplate::stat_modifier_set_min_percent_mod(const int index, const float value) { + ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD); + _modifiers[index].min_percent_mod = value; } float ItemTemplate::stat_modifier_get_max_percent_mod(const int index) const { + ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0); + return _modifiers[index].max_percent_mod; } void ItemTemplate::stat_modifier_set_max_percent_mod(const int index, const float value) { + ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD); + _modifiers[index].max_percent_mod = value; } float ItemTemplate::stat_modifier_get_scaling_factor(const int index) const { + ERR_FAIL_INDEX_V(index, MAX_ITEM_STAT_MOD, 0); + return _modifiers[index].scaling_factor; } void ItemTemplate::stat_modifier_set_scaling_factor(const int index, const float value) { + ERR_FAIL_INDEX(index, MAX_ITEM_STAT_MOD); + _modifiers[index].scaling_factor = value; } diff --git a/modules/entity_spell_system/entities/entity.cpp b/modules/entity_spell_system/entities/entity.cpp index 272882a2c..f223d43e1 100644 --- a/modules/entity_spell_system/entities/entity.cpp +++ b/modules/entity_spell_system/entities/entity.cpp @@ -656,6 +656,8 @@ void Entity::setup(Ref info) { } void Entity::_setup() { + ERR_FAIL_COND(!ESS::get_singleton()); + if (!_s_entity_data.is_valid()) return; @@ -712,11 +714,11 @@ void Entity::_setup() { ERR_FAIL_COND(!stat_data.is_valid()); - for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) { + for (int i = 0; i < _stats.size(); ++i) { stat_set_base(i, stat_data->get_base(i)); } - for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) { + for (int i = 0; i < _stats.size(); ++i) { stat_setc_current(i, stat_gets_current(i)); stat_set_dirty(i, false); } @@ -768,7 +770,7 @@ void Entity::_setup() { if (_s_entity_data->get_equipment_data().is_valid()) { Ref eqd = _s_entity_data->get_equipment_data(); - for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) { + for (int i = 0; i < _s_equipment.size(); ++i) { Ref ii = eqd->get_item(i); if (ii.is_valid()) @@ -1093,6 +1095,8 @@ int Entity::pet_getc_count() { //// Profiles //// Ref Entity::get_class_profile() { + ERR_FAIL_COND_V(!ProfileManager::get_singleton(), Ref()); + return ProfileManager::get_singleton()->getc_player_profile()->get_class_profile(_s_entity_data->get_path()); } @@ -1159,7 +1163,7 @@ Dictionary Entity::_to_dict() { Dictionary sd; - for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) { + for (int i = 0; i < _stats.size(); ++i) { Dictionary sdict; sdict["base"] = stat_get_base(i); @@ -1177,7 +1181,7 @@ Dictionary Entity::_to_dict() { Dictionary equipment; - for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) { + for (int i = 0; i < _s_equipment.size(); ++i) { Ref ii = _s_equipment[i]; if (ii.is_valid()) @@ -1292,7 +1296,7 @@ Dictionary Entity::_to_dict() { //// Known Spells //// - if (ESS::get_singleton()->get_use_spell_points()) + if (ESS::get_singleton() && ESS::get_singleton()->get_use_spell_points()) dict["free_spell_points"] = _s_free_spell_points; Dictionary known_spells; @@ -1341,8 +1345,6 @@ Dictionary Entity::_to_dict() { return dict; } void Entity::_from_dict(const Dictionary &dict) { - ERR_FAIL_COND(dict.empty()); - //// Transforms //// //Not needed for now @@ -1392,7 +1394,7 @@ void Entity::_from_dict(const Dictionary &dict) { Dictionary stats = dict.get("stats", Dictionary()); - for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) { + for (int i = 0; i < _stats.size(); ++i) { Dictionary sd = stats.get(String::num(i), Dictionary()); stat_set_base(i, sd.get("base", 0)); @@ -1411,7 +1413,7 @@ void Entity::_from_dict(const Dictionary &dict) { Dictionary equipment = dict.get("equipment", Dictionary()); - for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) { + for (int i = 0; i < _s_equipment.size(); ++i) { if (equipment.has(String::num(i))) { Ref ii = _s_equipment[i]; @@ -1600,8 +1602,9 @@ void Entity::_from_dict(const Dictionary &dict) { //// Known Spells //// - if (ESS::get_singleton()->get_use_spell_points()) + if (ESS::get_singleton() && ESS::get_singleton()->get_use_spell_points()) { sets_free_spell_points(dict.get("free_spell_points", 0)); + } Dictionary known_spells = dict.get("known_spells", Dictionary()); @@ -2013,42 +2016,42 @@ void Entity::scraft_recipes_set(const Vector &resources) { //// Stat System //// EntityStat Entity::get_stat(const int stat_id) const { - ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), EntityStat()); + ERR_FAIL_INDEX_V(stat_id, _stats.size(), EntityStat()); return _stats[stat_id]; } void Entity::set_stat(const int stat_id, const EntityStat &entry) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.set(stat_id, entry); } bool Entity::stat_get_dirty(const int stat_id) const { - ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), false); + ERR_FAIL_INDEX_V(stat_id, _stats.size(), false); return _stats[stat_id].dirty; } void Entity::stat_set_dirty(const int stat_id, const bool value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].dirty = value; } float Entity::stat_get_base(const int stat_id) const { - ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0); + ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0); return _stats[stat_id].base; } void Entity::stat_set_base(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].base = value; stat_recalculate(stat_id); } void Entity::stat_mod_base(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].base += value; @@ -2056,12 +2059,12 @@ void Entity::stat_mod_base(const int stat_id, const float value) { } float Entity::stat_get_base_calculated(const int stat_id) const { - ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0); + ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0); return _stats[stat_id].base_calculated; } void Entity::stat_set_base_calculated(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].base_calculated = value; @@ -2069,19 +2072,19 @@ void Entity::stat_set_base_calculated(const int stat_id, const float value) { } float Entity::stat_get_bonus(const int stat_id) const { - ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0); + ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0); return _stats[stat_id].bonus; } void Entity::stat_set_bonus(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].bonus = value; stat_recalculate(stat_id); } void Entity::stat_mod_bonus(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].bonus += value; @@ -2089,19 +2092,19 @@ void Entity::stat_mod_bonus(const int stat_id, const float value) { } float Entity::stat_get_percent(const int stat_id) const { - ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0); + ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0); return _stats[stat_id].percent; } void Entity::stat_set_percent(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].percent = value; stat_recalculate(stat_id); } void Entity::stat_mod_percent(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].percent += value; @@ -2109,7 +2112,7 @@ void Entity::stat_mod_percent(const int stat_id, const float value) { } void Entity::stat_mod(const int stat_id, const float base, const float bonus, const float percent) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].base += base; _stats.write[stat_id].bonus += bonus; @@ -2119,23 +2122,23 @@ void Entity::stat_mod(const int stat_id, const float base, const float bonus, co } float Entity::stat_gets_current(const int stat_id) const { - ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0); + ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0); return _stats[stat_id].scurrent; } void Entity::stat_sets_current(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].scurrent = value; } float Entity::stat_getc_current(const int stat_id) const { - ERR_FAIL_INDEX_V(stat_id, ESS::get_singleton()->stat_get_count(), 0); + ERR_FAIL_INDEX_V(stat_id, _stats.size(), 0); return _stats[stat_id].ccurrent; } void Entity::stat_setc_current(const int stat_id, const float value) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); _stats.write[stat_id].ccurrent = value; @@ -2143,7 +2146,7 @@ void Entity::stat_setc_current(const int stat_id, const float value) { } void Entity::stat_recalculate(const int stat_id) { - ERR_FAIL_INDEX(stat_id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(stat_id, _stats.size()); stat_sets_current(stat_id, (stat_get_base(stat_id) + stat_get_base_calculated(stat_id) + stat_get_bonus(stat_id)) * (stat_get_percent(stat_id) / 100.0)); @@ -2180,14 +2183,14 @@ void Entity::notification_cstat_changed(const int statid, const float current) { } void Entity::ssend_stat(int id, int ccurrent) { - ERR_FAIL_INDEX(id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(id, _stats.size()); //Only the owner needs access to stats ORPC(creceive_stat, id, ccurrent); } void Entity::creceive_stat(int id, int ccurrent) { - ERR_FAIL_INDEX(id, ESS::get_singleton()->stat_get_count()); + ERR_FAIL_INDEX(id, _stats.size()); stat_setc_current(id, ccurrent); } @@ -2289,7 +2292,7 @@ void Entity::equips(int equip_slot, int bag_slot) { call("_equips", equip_slot, bag_slot); } void Entity::_equips(int equip_slot, int bag_slot) { - ERR_FAIL_INDEX(equip_slot, ESS::get_singleton()->equip_slot_get_count()); + ERR_FAIL_INDEX(equip_slot, _s_equipment.size()); ERR_FAIL_COND(!_s_bag.is_valid()); Ref bag_item = _s_bag->get_item(bag_slot); @@ -2320,7 +2323,7 @@ void Entity::_equips(int equip_slot, int bag_slot) { ORPC(equip_csuccess, equip_slot, bag_slot); } void Entity::equip_csuccess(int equip_slot, int bag_slot) { - ERR_FAIL_INDEX(equip_slot, ESS::get_singleton()->equip_slot_get_count()); + ERR_FAIL_INDEX(equip_slot, _c_equipment.size()); ERR_FAIL_COND(!_c_bag.is_valid()); Ref old_bag_item = _c_bag->get_item(bag_slot); @@ -2338,7 +2341,7 @@ void Entity::equip_csuccess(int equip_slot, int bag_slot) { equip_con_success(equip_slot, old_bag_item, old_equipped_item, bag_slot); } void Entity::equip_cfail(int equip_slot, int bag_slot) { - ERR_FAIL_INDEX(equip_slot, ESS::get_singleton()->equip_slot_get_count()); + ERR_FAIL_INDEX(equip_slot, _c_equipment.size()); ERR_FAIL_COND(!_c_bag.is_valid()); Ref bag_item = _c_bag->get_item(bag_slot); @@ -2348,23 +2351,23 @@ void Entity::equip_cfail(int equip_slot, int bag_slot) { } Ref Entity::equip_gets_slot(int index) { - ERR_FAIL_INDEX_V(index, ESS::get_singleton()->equip_slot_get_count(), Ref()); + ERR_FAIL_INDEX_V(index, _s_equipment.size(), Ref()); return _s_equipment[index]; } void Entity::equip_sets_slot(int index, Ref item) { - ERR_FAIL_INDEX(index, ESS::get_singleton()->equip_slot_get_count()); + ERR_FAIL_INDEX(index, _s_equipment.size()); _s_equipment.write[index] = item; } Ref Entity::equip_getc_slot(int index) { - ERR_FAIL_INDEX_V(index, ESS::get_singleton()->equip_slot_get_count(), Ref()); + ERR_FAIL_INDEX_V(index, _c_equipment.size(), Ref()); return _c_equipment[index]; } void Entity::equip_setc_slot(int index, Ref item) { - ERR_FAIL_INDEX(index, ESS::get_singleton()->equip_slot_get_count()); + ERR_FAIL_INDEX(index, _c_equipment.size()); _c_equipment.write[index] = item; } @@ -2503,6 +2506,8 @@ void Entity::resource_clears() { } void Entity::resource_addc_rpc(int index, String data) { + ERR_FAIL_COND(!ESS::get_singleton()); + //Ref res; Dictionary dict = data_as_dict(data); @@ -2713,6 +2718,7 @@ void Entity::stake_damage(Ref info) { void Entity::sdeal_damage_to(Ref info) { ERR_FAIL_COND(!info.is_valid()); + ERR_FAIL_COND(!info->receiver_get()); //serverside @@ -2733,6 +2739,7 @@ void Entity::sdeal_damage_to(Ref info) { void Entity::stake_heal(Ref info) { ERR_FAIL_COND(!info.is_valid()); + ERR_FAIL_COND(!info->receiver_get()); //serverside @@ -2774,7 +2781,7 @@ void Entity::stake_heal(Ref info) { void Entity::sdeal_heal_to(Ref info) { ERR_FAIL_COND(!info.is_valid()); - ERR_FAIL_COND(info->receiver_get() == NULL); + ERR_FAIL_COND(!info->receiver_get()); //serverside @@ -2972,6 +2979,8 @@ void Entity::levelups(int value) { if (value <= 0) return; + ERR_FAIL_COND(!ESS::get_singleton()); + if (_s_level == ESS::get_singleton()->get_max_character_level()) return; @@ -3017,6 +3026,8 @@ void Entity::item_crequest_use(int item_id) { RPCS(item_uses, item_id); } void Entity::_item_uses(int item_id) { + ERR_FAIL_COND(!ESS::get_singleton()); + Ref it = ESS::get_singleton()->get_resource_db()->get_item_template(item_id); ERR_FAIL_COND(!it.is_valid()); @@ -3133,6 +3144,9 @@ void Entity::notification_saura(int what, Ref data) { for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); + ERR_CONTINUE(!ad.is_valid()); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_saura(what, data); } @@ -3151,6 +3165,9 @@ void Entity::notification_sheal(int what, Ref info) { for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); + ERR_CONTINUE(!ad.is_valid()); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_sheal(what, ad, info); } } @@ -3172,6 +3189,9 @@ void Entity::notification_sdamage(int what, Ref info) { for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); + ERR_CONTINUE(!ad.is_valid()); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_sdamage(what, ad, info); } } @@ -3184,6 +3204,9 @@ void Entity::notification_sdeath() { for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); + ERR_CONTINUE(!ad.is_valid()); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_sdeath(ad); } @@ -3267,8 +3290,10 @@ void Entity::aura_adds(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_ADDED, aura); - if (!aura->get_aura()->aura_get_hide()) + ERR_FAIL_COND(!aura->get_aura().is_valid()); + if (!aura->get_aura()->aura_get_hide()) { VRPCOBJ(aura_addc_rpc, JSON::print(aura->to_dict()), aura_addc, aura); + } } void Entity::aura_removes(Ref aura) { @@ -3291,9 +3316,11 @@ void Entity::aura_removes(Ref aura) { if (removed) { notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, a); - - if (!aura->get_aura()->aura_get_hide()) + + ERR_FAIL_COND(!aura->get_aura().is_valid()); + if (!aura->get_aura()->aura_get_hide()) { VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura); + } } } @@ -3314,8 +3341,10 @@ void Entity::aura_removes_exact(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura); - if (!aura->get_aura()->aura_get_hide()) + ERR_FAIL_COND(!aura->get_aura().is_valid()); + if (!aura->get_aura()->aura_get_hide()) { VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura); + } } void Entity::aura_removes_expired(Ref aura) { @@ -3335,8 +3364,10 @@ void Entity::aura_removes_expired(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura); - if (!aura->get_aura()->aura_get_hide()) + ERR_FAIL_COND(!aura->get_aura().is_valid()); + if (!aura->get_aura()->aura_get_hide()) { VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura); + } } void Entity::aura_removes_dispelled(Ref aura) { @@ -3356,8 +3387,10 @@ void Entity::aura_removes_dispelled(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura); - if (!aura->get_aura()->aura_get_hide()) + ERR_FAIL_COND(!aura->get_aura().is_valid()); + if (!aura->get_aura()->aura_get_hide()) { VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura); + } } void Entity::aura_refresheds(Ref aura) { @@ -3368,8 +3401,10 @@ void Entity::aura_refresheds(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REFRESHED, aura); - if (!aura->get_aura()->aura_get_hide()) + ERR_FAIL_COND(!aura->get_aura().is_valid()); + if (!aura->get_aura()->aura_get_hide()) { VRPCOBJ(aura_refreshedc_rpc, JSON::print(aura->to_dict()), aura_refreshedc, aura); + } } void Entity::aura_addc_rpc(String data) { @@ -3627,6 +3662,8 @@ void Entity::notification_caura(int what, Ref data) { for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_caura(what, data); } @@ -3641,6 +3678,8 @@ void Entity::notification_cheal(int what, Ref info) { for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_cheal(what, ad, info); } @@ -3652,12 +3691,15 @@ void Entity::notification_cheal(int what, Ref info) { } void Entity::notification_ccast(int what, Ref info) { ERR_FAIL_COND(!info.is_valid()); + ERR_FAIL_COND(!info->get_spell().is_valid()); info->get_spell()->notification_ccast(what, info); for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_aura_ccast(what, ad, info); } @@ -3672,6 +3714,8 @@ void Entity::notification_cdamage(int what, Ref info) { for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_cdamage(what, ad, info); } @@ -3723,6 +3767,8 @@ void Entity::cast_starts(Ref info) { for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); + ERR_CONTINUE(!ad->get_aura().is_valid()); + ad->get_aura()->notification_aura_scast(SpellEnums::NOTIFICATION_CAST_STARTED, ad, info); } @@ -3748,6 +3794,9 @@ void Entity::cast_delays() { } void Entity::cast_finishs() { + ERR_FAIL_COND(!_s_spell_cast_info.is_valid()); + ERR_FAIL_COND(!_s_spell_cast_info->get_spell().is_valid()); + _s_spell_cast_info->get_spell()->cast_finishs(_s_spell_cast_info); notification_scast(SpellEnums::NOTIFICATION_CAST_FINISHED, _s_spell_cast_info); @@ -3758,6 +3807,8 @@ void Entity::cast_finishs() { } void Entity::cast_interrupts() { + ERR_FAIL_COND(!_s_spell_cast_info.is_valid()); + notification_scast(SpellEnums::NOTIFICATION_CAST_INTERRUPTED, _s_spell_cast_info); _s_spell_cast_info.unref(); @@ -3781,24 +3832,31 @@ void Entity::cast_startc(Ref info) { } void Entity::cast_failc() { + ERR_FAIL_COND(!_c_spell_cast_info.is_valid()); + notification_ccast(SpellEnums::NOTIFICATION_CAST_FAILED, _c_spell_cast_info); _c_spell_cast_info.unref(); } void Entity::cast_delayc() { + ERR_FAIL_COND(!_c_spell_cast_info.is_valid()); //c_on_cast_ notification_scast(SpellEnums::NOTIFICATION_CAST_DELAYED, _c_spell_cast_info); } void Entity::cast_finishc() { + ERR_FAIL_COND(!_c_spell_cast_info.is_valid()); + notification_ccast(SpellEnums::NOTIFICATION_CAST_FINISHED, _c_spell_cast_info); _c_spell_cast_info.unref(); } void Entity::cast_interruptc() { + ERR_FAIL_COND(!_c_spell_cast_info.is_valid()); + notification_ccast(SpellEnums::NOTIFICATION_CAST_INTERRUPTED, _c_spell_cast_info); _c_spell_cast_info.unref(); @@ -4202,6 +4260,8 @@ bool Entity::spell_hass_id(int id) { return false; } void Entity::spell_adds(Ref spell) { + ERR_FAIL_COND(!ESS::get_singleton()); + if (spell_hass(spell)) return; @@ -4241,6 +4301,8 @@ void Entity::spell_adds(Ref spell) { ORPCOBJ(spell_addc_rpc, spell->get_id(), spell_addc, spell); } void Entity::spell_adds_id(int id) { + ERR_FAIL_COND(!ESS::get_singleton()); + Ref spell = ESS::get_singleton()->get_resource_db()->get_spell(id); ERR_FAIL_COND(!spell.is_valid()); @@ -5491,6 +5553,8 @@ void Entity::set_actionbar_locked(bool value) { } Ref Entity::get_action_bar_profile() { + ERR_FAIL_COND_V(!ProfileManager::get_singleton(), Ref()); + if (_action_bar_profile.is_valid()) return _action_bar_profile; @@ -5586,13 +5650,11 @@ void Entity::update(float delta) { } } - if (ESS::get_singleton()) { - for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) { - if (stat_get_dirty(i)) { - ssend_stat(i, stat_gets_current(i)); + for (int i = 0; i < _stats.size(); ++i) { + if (stat_get_dirty(i)) { + ssend_stat(i, stat_gets_current(i)); - stat_set_dirty(i, false); - } + stat_set_dirty(i, false); } } @@ -5646,6 +5708,8 @@ Entity *Entity::sees_gets(int index) { return _s_sees.get(index); } void Entity::sees_removes_index(int index) { + ERR_FAIL_INDEX(index, _s_sees.size()); + Entity *e = _s_sees.get(index); if (unlikely(!ObjectDB::instance_validate(e))) { @@ -5703,6 +5767,8 @@ Entity *Entity::seen_by_gets(int index) { return _s_seen_by.get(index); } void Entity::seen_by_removes_index(int index) { + ERR_FAIL_INDEX(index, _s_sees.size()); + _s_seen_by.remove(index); } void Entity::seen_by_removes(Entity *entity) { @@ -5828,9 +5894,10 @@ Entity::Entity() { _maunal_process = false; _deserialized = false; - _body = NULL; - _body_3d = NULL; - _body_2d = NULL; + _character_skeleton = nullptr; + _body = nullptr; + _body_3d = nullptr; + _body_2d = nullptr; _s_guid = 0; _c_guid = 0; @@ -6219,6 +6286,8 @@ void Entity::_crafts(int id) { } void Entity::_notification_sxp_gained(int value) { + ERR_FAIL_COND(!ESS::get_singleton()); + /* if (ESS::get_singleton()->get_use_class_xp() && ESS::get_singleton()->get_automatic_class_levelups()) { if (ESS::get_singleton()->get_resource_db()->get_xp_data()->can_class_level_up(gets_class_level())) { @@ -6243,6 +6312,8 @@ void Entity::_notification_sxp_gained(int value) { } void Entity::_notification_slevel_up(int level) { + ERR_FAIL_COND(!ESS::get_singleton()); + if (!gets_entity_data().is_valid()) return; @@ -6350,6 +6421,8 @@ void Entity::_notification_sdeath() { } void Entity::_spell_learns(int id) { + ERR_FAIL_COND(!ESS::get_singleton()); + if (ESS::get_singleton()->get_use_spell_points()) { ERR_FAIL_COND(gets_free_spell_points() <= 0); } @@ -6654,13 +6727,13 @@ void Entity::_get_property_list(List *p_list) const { int property_usange = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL; #endif - for (int i = 0; i < ESS::get_singleton()->stat_get_count(); ++i) { + for (int i = 0; i < _stats.size(); ++i) { p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/base", PROPERTY_HINT_NONE, "", property_usange)); p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/percent", PROPERTY_HINT_NONE, "", property_usange)); p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/scurrent", PROPERTY_HINT_NONE, "", property_usange)); } - for (int i = 0; i < ESS::get_singleton()->equip_slot_get_count(); ++i) { + for (int i = 0; i < _s_equipment.size(); ++i) { p_list->push_back(PropertyInfo(Variant::OBJECT, "sequipment/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance", property_usange)); } } diff --git a/modules/entity_spell_system/entities/resources/entity_resource.cpp b/modules/entity_spell_system/entities/resources/entity_resource.cpp index d271bfc2e..014bf222f 100644 --- a/modules/entity_spell_system/entities/resources/entity_resource.cpp +++ b/modules/entity_spell_system/entities/resources/entity_resource.cpp @@ -253,6 +253,8 @@ void EntityResource::from_dict(const Dictionary &dict) { Dictionary EntityResource::_to_dict() { Dictionary dict; + ERR_FAIL_COND_V(!ESS::get_singleton(), dict); + dict["data_path"] = ESS::get_singleton()->get_resource_db()->get_entity_resource(_id)->get_path(); dict["dirty"] = _dirty; diff --git a/modules/entity_spell_system/entities/resources/entity_resource_health.cpp b/modules/entity_spell_system/entities/resources/entity_resource_health.cpp index 78c872ba9..347386c31 100644 --- a/modules/entity_spell_system/entities/resources/entity_resource_health.cpp +++ b/modules/entity_spell_system/entities/resources/entity_resource_health.cpp @@ -32,6 +32,8 @@ void EntityResourceHealth::_init() { stamina_stat_id = 0; health_stat_id = 0; + ERR_FAIL_COND(!ESS::get_singleton()); + if (ESS::get_singleton()->stat_is_property("Stamina")) { stamina_stat_id = ESS::get_singleton()->stat_get_id("Stamina"); } diff --git a/modules/entity_spell_system/entities/resources/entity_resource_speed.cpp b/modules/entity_spell_system/entities/resources/entity_resource_speed.cpp index 154349690..91a7bb19b 100644 --- a/modules/entity_spell_system/entities/resources/entity_resource_speed.cpp +++ b/modules/entity_spell_system/entities/resources/entity_resource_speed.cpp @@ -32,6 +32,8 @@ void EntityResourceSpeed::_init() { speed_stat_id = 0; + ERR_FAIL_COND(!ESS::get_singleton()); + if (ESS::get_singleton()->stat_is_property("Speed")) speed_stat_id = ESS::get_singleton()->stat_get_id("Speed"); } diff --git a/modules/entity_spell_system/entities/stats/complex_level_stat_data.cpp b/modules/entity_spell_system/entities/stats/complex_level_stat_data.cpp index d6b87dc94..e48939e80 100644 --- a/modules/entity_spell_system/entities/stats/complex_level_stat_data.cpp +++ b/modules/entity_spell_system/entities/stats/complex_level_stat_data.cpp @@ -25,12 +25,14 @@ SOFTWARE. #include "../../singletons/ess.h" int ComplexLevelStatData::get_stat_for_level(int main_stat, int level) { + ERR_FAIL_COND_V(!ESS::get_singleton(), 0); ERR_FAIL_INDEX_V(level, ESS::get_singleton()->get_max_character_level(), 0); ERR_FAIL_INDEX_V(main_stat, ESS::get_singleton()->stat_get_main_stat_count(), 0); return _stat_per_level[level][main_stat]; } void ComplexLevelStatData::set_stat_for_level(int main_stat, int level, int value) { + ERR_FAIL_COND(!ESS::get_singleton()); ERR_FAIL_INDEX(level, ESS::get_singleton()->get_max_character_level()); ERR_FAIL_INDEX(main_stat, ESS::get_singleton()->stat_get_main_stat_count()); @@ -48,6 +50,8 @@ int ComplexLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_l } ComplexLevelStatData::ComplexLevelStatData() { + ERR_FAIL_COND(!ESS::get_singleton()); + if (ESS::get_singleton()->get_max_character_level()) { _stat_per_level.resize(ESS::get_singleton()->get_max_character_level()); @@ -64,12 +68,14 @@ ComplexLevelStatData::ComplexLevelStatData() { } ComplexLevelStatData::~ComplexLevelStatData() { - for (int i = 0; i < ESS::get_singleton()->get_max_character_level(); ++i) { + for (int i = 0; i < _stat_per_level.size(); ++i) { _stat_per_level.write[i].clear(); } } bool ComplexLevelStatData::_set(const StringName &p_name, const Variant &p_value) { + ERR_FAIL_COND_V(!ESS::get_singleton(), false); + String prop_name = p_name; if (prop_name.begins_with("level_")) { @@ -100,6 +106,8 @@ bool ComplexLevelStatData::_set(const StringName &p_name, const Variant &p_value } bool ComplexLevelStatData::_get(const StringName &p_name, Variant &r_ret) const { + ERR_FAIL_COND_V(!ESS::get_singleton(), false); + String prop_name = p_name; if (prop_name.begins_with("level_")) { @@ -130,6 +138,8 @@ bool ComplexLevelStatData::_get(const StringName &p_name, Variant &r_ret) const } void ComplexLevelStatData::_get_property_list(List *p_list) const { + ERR_FAIL_COND(!ESS::get_singleton()); + //int property_usange = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL; int property_usange = PROPERTY_USAGE_DEFAULT; diff --git a/modules/entity_spell_system/material_cache/ess_material_cache.cpp b/modules/entity_spell_system/material_cache/ess_material_cache.cpp index 0ad92b003..7072d54d8 100644 --- a/modules/entity_spell_system/material_cache/ess_material_cache.cpp +++ b/modules/entity_spell_system/material_cache/ess_material_cache.cpp @@ -279,6 +279,8 @@ void ESSMaterialCache::initial_setup_default() { ESS *ess = ESS::get_singleton(); + ERR_FAIL_COND(!ess); + ess->ensure_materials_loaded(); int matc = ess->material_get_num(); diff --git a/modules/entity_spell_system/profiles/input/input_profile.cpp b/modules/entity_spell_system/profiles/input/input_profile.cpp index 068347268..7d57e7b49 100644 --- a/modules/entity_spell_system/profiles/input/input_profile.cpp +++ b/modules/entity_spell_system/profiles/input/input_profile.cpp @@ -42,6 +42,8 @@ void InputProfile::set_data(const Array &data) { } void InputProfile::load_to_projectsettings() { + ERR_FAIL_COND(!ProjectSettings::get_singleton()); + for (int i = 0; i < _data.size(); ++i) { Array arr = _data[i]; @@ -98,6 +100,7 @@ void InputProfile::from_dict(const Dictionary &dict) { } InputProfile::InputProfile() { + _owner = nullptr; } void InputProfile::_bind_methods() { diff --git a/modules/entity_spell_system/profiles/input/input_profile_modifier.cpp b/modules/entity_spell_system/profiles/input/input_profile_modifier.cpp index da85afd45..39d849f85 100644 --- a/modules/entity_spell_system/profiles/input/input_profile_modifier.cpp +++ b/modules/entity_spell_system/profiles/input/input_profile_modifier.cpp @@ -35,14 +35,20 @@ void InputProfileModifier::add_modifier(String modifier) { } String InputProfileModifier::get_modifier(int index) { + ERR_FAIL_INDEX_V(index, _modifier_actions->size(), ""); + return _modifier_actions->get(index); } void InputProfileModifier::set_modifier(int index, String value) { + ERR_FAIL_INDEX(index, _modifier_actions->size()); + _modifier_actions->set(index, value); } void InputProfileModifier::remove_modifier(int index) { + ERR_FAIL_INDEX(index, _modifier_actions->size()); + _modifier_actions->remove(index); } @@ -59,14 +65,20 @@ void InputProfileModifier::add_entry(Ref modifier) { } Ref InputProfileModifier::get_entry(int index) { + ERR_FAIL_INDEX_V(index, _entries->size(), Ref()); + return _entries->get(index); } void InputProfileModifier::set_entry(int index, Ref value) { + ERR_FAIL_INDEX(index, _entries->size()); + _entries->set(index, Ref(value)); } void InputProfileModifier::remove_entry(int index) { + ERR_FAIL_INDEX(index, _entries->size()); + _entries->remove(index); } diff --git a/modules/entity_spell_system/profiles/player_profile.cpp b/modules/entity_spell_system/profiles/player_profile.cpp index 5a669f15a..711e8d658 100644 --- a/modules/entity_spell_system/profiles/player_profile.cpp +++ b/modules/entity_spell_system/profiles/player_profile.cpp @@ -57,6 +57,8 @@ int PlayerProfile::get_class_profile_count() const { } Ref PlayerProfile::get_class_profile_index(const int index) { + ERR_FAIL_INDEX_V(index, _class_profiles.size(), Ref()); + return _class_profiles.get(index); } @@ -79,6 +81,8 @@ void PlayerProfile::clear_class_profiles() { } void PlayerProfile::remove_class_profile(const int index) { + ERR_FAIL_INDEX(index, _class_profiles.size()); + _class_profiles.get(index)->disconnect("changed", this, "_on_class_profile_changed"); _class_profiles.remove(index); diff --git a/modules/entity_spell_system/skeleton/character_skeleton_2d.cpp b/modules/entity_spell_system/skeleton/character_skeleton_2d.cpp index 5d979078e..9103fccb8 100644 --- a/modules/entity_spell_system/skeleton/character_skeleton_2d.cpp +++ b/modules/entity_spell_system/skeleton/character_skeleton_2d.cpp @@ -302,6 +302,8 @@ void CharacterSkeleton2D::remove_model_visual_entry(Ref vis, Refget_bone(); + ERR_FAIL_INDEX(target_bone_idx, _entries.size()); + Vector> &entries = _entries.write[target_bone_idx]; for (int i = 0; i < entries.size(); ++i) { diff --git a/modules/entity_spell_system/skeleton/character_skeleton_3d.cpp b/modules/entity_spell_system/skeleton/character_skeleton_3d.cpp index c5b5e77f9..21f723b51 100644 --- a/modules/entity_spell_system/skeleton/character_skeleton_3d.cpp +++ b/modules/entity_spell_system/skeleton/character_skeleton_3d.cpp @@ -342,6 +342,8 @@ void CharacterSkeleton3D::remove_model_visual_entry(Ref vis, Refget_bone(); + ERR_FAIL_INDEX(target_bone_idx, _entries.size()); + Vector> &entries = _entries.write[target_bone_idx]; for (int i = 0; i < entries.size(); ++i) { diff --git a/modules/mesh_utils/mesh_merger.cpp b/modules/mesh_utils/mesh_merger.cpp index 4bf0b659b..50bdca894 100644 --- a/modules/mesh_utils/mesh_merger.cpp +++ b/modules/mesh_utils/mesh_merger.cpp @@ -695,10 +695,14 @@ void MeshMerger::add_vertex(const Vector3 &vertex) { } Vector3 MeshMerger::get_vertex(const int idx) const { + ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector3()); + return _vertices.get(idx).vertex; } void MeshMerger::remove_vertex(const int idx) { + ERR_FAIL_INDEX(idx, _vertices.size()); + _vertices.remove(idx); } @@ -730,6 +734,8 @@ void MeshMerger::add_normal(const Vector3 &normal) { } Vector3 MeshMerger::get_normal(int idx) const { + ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector3()); + return _vertices.get(idx).normal; } @@ -761,6 +767,8 @@ void MeshMerger::add_color(const Color &color) { } Color MeshMerger::get_color(const int idx) const { + ERR_FAIL_INDEX_V(idx, _vertices.size(), Color()); + return _vertices.get(idx).color; } @@ -792,6 +800,8 @@ void MeshMerger::add_uv(const Vector2 &uv) { } Vector2 MeshMerger::get_uv(const int idx) const { + ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector2()); + return _vertices.get(idx).uv; } @@ -823,10 +833,14 @@ void MeshMerger::add_uv2(const Vector2 &uv) { } Vector2 MeshMerger::get_uv2(const int idx) const { + ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector2()); + return _vertices.get(idx).uv2; } Vector MeshMerger::get_bones(const int idx) const { + ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector()); + return _vertices[idx].bones; } void MeshMerger::add_bones(const Vector &vector) { @@ -834,6 +848,8 @@ void MeshMerger::add_bones(const Vector &vector) { } Vector MeshMerger::get_bone_weights(const int idx) const { + ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector()); + return _vertices[idx].weights; } void MeshMerger::add_bone_weights(const Vector &arr) { @@ -857,10 +873,14 @@ void MeshMerger::add_indices(const int index) { } int MeshMerger::get_index(const int idx) const { + ERR_FAIL_INDEX_V(idx, _indices.size(), 0); + return _indices.get(idx); } void MeshMerger::remove_index(const int idx) { + ERR_FAIL_INDEX(idx, _indices.size()); + _indices.remove(idx); } diff --git a/modules/props_2d/prop_2d_instance_prop_job.cpp b/modules/props_2d/prop_2d_instance_prop_job.cpp index ac7a1421a..2ded4d9ad 100644 --- a/modules/props_2d/prop_2d_instance_prop_job.cpp +++ b/modules/props_2d/prop_2d_instance_prop_job.cpp @@ -124,8 +124,9 @@ void Prop2DInstanceProp2DJob::clear_lights() { } void Prop2DInstanceProp2DJob::_physics_process(float delta) { - if (_phase == 0) + if (_phase == 0) { phase_physics_process(); + } } void Prop2DInstanceProp2DJob::_execute_phase() { @@ -179,6 +180,8 @@ void Prop2DInstanceProp2DJob::_reset() { } void Prop2DInstanceProp2DJob::phase_physics_process() { + ERR_FAIL_COND(!_prop_instace); + //TODO this should only update the differences //for (int i = 0; i < _prop_instace->collider_get_num(); ++i) { // PhysicsServer::get_singleton()->free(_prop_instace->collider_body_get(i)); diff --git a/modules/props_2d/props/prop_2d_data_entry.cpp b/modules/props_2d/props/prop_2d_data_entry.cpp index c75a78070..811f5161b 100644 --- a/modules/props_2d/props/prop_2d_data_entry.cpp +++ b/modules/props_2d/props/prop_2d_data_entry.cpp @@ -166,6 +166,8 @@ Node *Prop2DDataEntry::_processor_get_node_for(const Transform2D &transform, Nod n = memnew(Node2D()); } + ERR_FAIL_COND_V(!n, nullptr); + n->set_transform(transform * get_transform_2d()); n->set_z_index(get_z_index());