From f29b01af8be1ac886e3b706981f9353e9109b566 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 10 Apr 2020 14:09:21 +0200 Subject: [PATCH] Clang format. --- data/auras/aura.cpp | 32 ++-- data/items/item_template.cpp | 24 +-- data/species/entity_species_data.cpp | 12 +- data/species/species_model_data.cpp | 18 +-- data/spells/spell.cpp | 56 +++---- entities/ai/entity_ai.cpp | 24 +-- entities/auras/aura_data.cpp | 6 +- entities/data/character_spec.cpp | 6 +- entities/data/entity_class_data.cpp | 104 ++++++------ entities/data/entity_data.cpp | 102 ++++++------ entities/data/item_container_data.cpp | 6 +- entities/data/vendor_item_data.cpp | 6 +- entities/entity.cpp | 218 +++++++++++++------------- entities/entity.h | 7 +- entities/stats/stat.cpp | 6 +- formations/ai_formation.cpp | 7 +- infos/spell_cast_info.cpp | 23 ++- pipelines/spell_damage_info.cpp | 12 +- pipelines/spell_heal_info.cpp | 12 +- profiles/player_profile.cpp | 41 +++-- singletons/entity_data_manager.cpp | 68 ++++---- singletons/profile_manager.cpp | 28 ++-- skeleton/character_skeleton_3d.cpp | 8 +- 23 files changed, 411 insertions(+), 415 deletions(-) diff --git a/data/auras/aura.cpp b/data/auras/aura.cpp index 97f8194..656ffe3 100644 --- a/data/auras/aura.cpp +++ b/data/auras/aura.cpp @@ -1258,11 +1258,11 @@ void Aura::_supdate(Ref aura, float delta) { void Aura::_setup_aura_data(Ref data, Ref info) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_caster())); - #else +#else ERR_FAIL_COND(info->get_caster() == NULL); - #endif +#endif data->set_aura(Ref(this)); data->set_aura_id(get_id()); @@ -1298,23 +1298,23 @@ void Aura::_calculate_initial_damage(Ref aura_data, Ref } void Aura::_handle_aura_damage(Ref aura_data, Ref info) { - - #if VERSION_MAJOR < 4 + +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); - #else +#else ERR_FAIL_COND(info->get_dealer() == NULL); - #endif +#endif Math::randomize(); info->set_damage(_damage_min + (Math::rand() % (_damage_max = _damage_min))); info->set_damage_source_type(SpellDamageInfo::DAMAGE_SOURCE_AURA); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); - #else +#else ERR_FAIL_COND(info->get_dealer() == NULL); - #endif +#endif info->get_dealer()->sdeal_damage_to(info); } @@ -1332,22 +1332,22 @@ void Aura::_calculate_initial_heal(Ref aura_data, Ref i } void Aura::_handle_aura_heal(Ref aura_data, Ref info) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); - #else +#else ERR_FAIL_COND(info->get_dealer() == NULL); - #endif +#endif Math::randomize(); info->set_heal(_heal_min + (Math::rand() % (_heal_max = _heal_min))); info->set_heal_source_type(SpellHealInfo::HEAL_SOURCE_AURA); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); - #else +#else ERR_FAIL_COND(info->get_dealer() == NULL); - #endif +#endif info->get_dealer()->sdeal_heal_to(info); } diff --git a/data/items/item_template.cpp b/data/items/item_template.cpp index 5f2aba0..92af697 100644 --- a/data/items/item_template.cpp +++ b/data/items/item_template.cpp @@ -178,11 +178,11 @@ void ItemTemplate::set_teaches_spell(const int index, const Ref &spell) { Vector ItemTemplate::get_teaches_spells() { Vector r; for (int i = 0; i < _teaches_spells.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_teaches_spells[i].get_ref_ptr()); - #else +#else r.push_back(_teaches_spells[i]); - #endif +#endif } return r; } @@ -218,11 +218,11 @@ void ItemTemplate::set_grants_spell(const int index, const Ref &spell) { Vector ItemTemplate::get_grants_spells() { Vector r; for (int i = 0; i < _grants_spells.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_grants_spells[i].get_ref_ptr()); - #else +#else r.push_back(_grants_spells[i]); - #endif +#endif } return r; } @@ -258,11 +258,11 @@ void ItemTemplate::set_aura(const int index, const Ref &aura) { Vector ItemTemplate::get_auras() { Vector r; for (int i = 0; i < _auras.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_auras[i].get_ref_ptr()); - #else +#else r.push_back(_auras[i]); - #endif +#endif } return r; } @@ -294,11 +294,11 @@ void ItemTemplate::set_required_skill(const int index, const Ref &aura) { Vector ItemTemplate::get_required_skills() { Vector r; for (int i = 0; i < _required_skills.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_required_skills[i].get_ref_ptr()); - #else +#else r.push_back(_required_skills[i]); - #endif +#endif } return r; } diff --git a/data/species/entity_species_data.cpp b/data/species/entity_species_data.cpp index 444d19e..dc62bf6 100644 --- a/data/species/entity_species_data.cpp +++ b/data/species/entity_species_data.cpp @@ -83,11 +83,11 @@ int EntitySpeciesData::get_spell_count() const { Vector EntitySpeciesData::get_spells() { Vector r; for (int i = 0; i < _spells.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_spells[i].get_ref_ptr()); - #else +#else r.push_back(_spells[i]); - #endif +#endif } return r; } @@ -128,11 +128,11 @@ int EntitySpeciesData::get_aura_count() const { Vector EntitySpeciesData::get_auras() { Vector r; for (int i = 0; i < _auras.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_auras[i].get_ref_ptr()); - #else +#else r.push_back(_auras[i]); - #endif +#endif } return r; } diff --git a/data/species/species_model_data.cpp b/data/species/species_model_data.cpp index 22e448c..b876860 100644 --- a/data/species/species_model_data.cpp +++ b/data/species/species_model_data.cpp @@ -75,11 +75,11 @@ Vector SpeciesModelData::get_visuals(const int bone_index) { Vector r; for (int i = 0; i < _visuals[bone_index].size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_visuals[bone_index][i].get_ref_ptr()); - #else +#else r.push_back(_visuals[bone_index][i]); - #endif +#endif } return r; } @@ -163,11 +163,11 @@ int SpeciesModelData::get_hair_style_count() const { Vector SpeciesModelData::get_hair_styles() { Vector r; for (int i = 0; i < _hair_styles.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_hair_styles[i].get_ref_ptr()); - #else +#else r.push_back(_hair_styles[i]); - #endif +#endif } return r; } @@ -249,11 +249,11 @@ int SpeciesModelData::get_head_count() const { Vector SpeciesModelData::get_heads() { Vector r; for (int i = 0; i < _heads.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_heads[i].get_ref_ptr()); - #else +#else r.push_back(_heads[i]); - #endif +#endif } return r; } diff --git a/data/spells/spell.cpp b/data/spells/spell.cpp index fbcb92a..5fc4b63 100644 --- a/data/spells/spell.cpp +++ b/data/spells/spell.cpp @@ -206,11 +206,11 @@ void Spell::set_caster_aura_apply(const int index, const Ref &caster_aura_ Vector Spell::get_caster_aura_applys() { Vector r; for (int i = 0; i < _caster_aura_applys.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_caster_aura_applys[i].get_ref_ptr()); - #else +#else r.push_back(_caster_aura_applys[i]); - #endif +#endif } return r; } @@ -246,11 +246,11 @@ void Spell::set_target_aura_apply(const int index, const Ref &target_aura_ Vector Spell::get_target_aura_applys() { Vector r; for (int i = 0; i < _target_aura_applys.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_target_aura_applys[i].get_ref_ptr()); - #else +#else r.push_back(_target_aura_applys[i]); - #endif +#endif } return r; } @@ -286,11 +286,11 @@ void Spell::set_on_learn_aura(const int index, const Ref &on_learn_aura_ap Vector Spell::get_on_learn_auras() { Vector r; for (int i = 0; i < _on_learn_auras.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_on_learn_auras[i].get_ref_ptr()); - #else +#else r.push_back(_on_learn_auras[i]); - #endif +#endif } return r; } @@ -574,11 +574,11 @@ void Spell::set_training_required_skill_level(const int value) { //// Spell System //// void Spell::sstart_casting_simple(Entity *caster, float spell_scale) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!caster || !ObjectDB::instance_validate(caster)); - #else +#else ERR_FAIL_COND(!caster || caster == NULL); - #endif +#endif Ref info = Ref(memnew(SpellCastInfo())); @@ -593,11 +593,11 @@ void Spell::sstart_casting_simple(Entity *caster, float spell_scale) { } void Spell::sinterrupt_cast_simple(Entity *caster) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!caster || !ObjectDB::instance_validate(caster)); - #else +#else ERR_FAIL_COND(!caster || caster == NULL); - #endif +#endif Ref info(memnew(SpellCastInfo())); @@ -608,11 +608,11 @@ void Spell::sinterrupt_cast_simple(Entity *caster) { } void Spell::sstart_casting_triggered_simple(Entity *caster) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!caster || !ObjectDB::instance_validate(caster)); - #else +#else ERR_FAIL_COND(!caster || caster == NULL); - #endif +#endif Ref info(memnew(SpellCastInfo())); @@ -976,12 +976,12 @@ void Spell::_sfinish_cast(Ref info) { info->get_caster()->son_cast_finished(info); info->get_caster()->sspell_cast_success(info); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(info->get_target())) { - #else +#else if (info->get_target() != NULL) { - #endif - +#endif + info->get_target()->son_cast_finished_target(info); } @@ -1034,11 +1034,11 @@ void Spell::_handle_projectile(Ref info) { Node *p = info->get_caster()->get_parent(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(p)); - #else +#else ERR_FAIL_COND(p == NULL); - #endif +#endif p->add_child(projectile); @@ -1065,11 +1065,11 @@ void Spell::_handle_effect(Ref info) { # return */ - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 bool has_target = ObjectDB::instance_validate(info->get_target()); - #else +#else bool has_target = info->get_target() == NULL; - #endif +#endif if (_target_type == SPELL_TARGET_TYPE_TARGET) { if (!has_target) diff --git a/entities/ai/entity_ai.cpp b/entities/ai/entity_ai.cpp index 0319ac9..ce017dd 100644 --- a/entities/ai/entity_ai.cpp +++ b/entities/ai/entity_ai.cpp @@ -100,42 +100,42 @@ String EntityAI::get_editor_description() const { } void EntityAI::update(float delta) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); - #else +#else ERR_FAIL_COND(_owner == NULL); - #endif +#endif if (has_method("_update")) call("_update", delta); } void EntityAI::pet_update(float delta) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); - #else +#else ERR_FAIL_COND(_owner == NULL); - #endif +#endif if (has_method("_pet_update")) call("_pet_update", delta); } void EntityAI::move(float delta) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); - #else +#else ERR_FAIL_COND(_owner == NULL); - #endif +#endif if (has_method("_move")) call("_move", delta); } void EntityAI::pet_move(float delta) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); - #else +#else ERR_FAIL_COND(_owner == NULL); - #endif +#endif if (has_method("_pet_move")) call("_pet_move", delta); diff --git a/entities/auras/aura_data.cpp b/entities/auras/aura_data.cpp index f5e01bb..f1d8667 100644 --- a/entities/auras/aura_data.cpp +++ b/entities/auras/aura_data.cpp @@ -259,11 +259,11 @@ void AuraData::set_slow(float value) { } void AuraData::resolve_references(Node *owner) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(owner)); - #else +#else ERR_FAIL_COND(owner == NULL); - #endif +#endif ERR_FAIL_COND(!owner->is_inside_tree()); _owner = Object::cast_to(owner); diff --git a/entities/data/character_spec.cpp b/entities/data/character_spec.cpp index 860872e..db7c4a8 100644 --- a/entities/data/character_spec.cpp +++ b/entities/data/character_spec.cpp @@ -54,11 +54,11 @@ void CharacterSpec::set_talent_row(const int index, const Ref row Vector CharacterSpec::get_talent_rows() { Vector r; for (int i = 0; i < _rows.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_rows[i].get_ref_ptr()); - #else +#else r.push_back(_rows[i]); - #endif +#endif } return r; } diff --git a/entities/data/entity_class_data.cpp b/entities/data/entity_class_data.cpp index a3d8597..39544c7 100644 --- a/entities/data/entity_class_data.cpp +++ b/entities/data/entity_class_data.cpp @@ -127,11 +127,11 @@ void EntityClassData::set_entity_resource(int index, Ref ent Vector EntityClassData::get_entity_resources() { Vector r; for (int i = 0; i < _entity_resources.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_entity_resources[i].get_ref_ptr()); - #else +#else r.push_back(_entity_resources[i]); - #endif +#endif } return r; } @@ -175,11 +175,11 @@ void EntityClassData::set_spec(int index, Ref spec) { Vector EntityClassData::get_specs() { Vector r; for (int i = 0; i < _specs.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_specs[i].get_ref_ptr()); - #else +#else r.push_back(_specs[i]); - #endif +#endif } return r; } @@ -223,11 +223,11 @@ void EntityClassData::set_spell(int index, Ref spell) { Vector EntityClassData::get_spells() { Vector r; for (int i = 0; i < _spells.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_spells[i].get_ref_ptr()); - #else +#else r.push_back(_spells[i]); - #endif +#endif } return r; } @@ -271,11 +271,11 @@ void EntityClassData::set_start_spell(int index, Ref spell) { Vector EntityClassData::get_start_spells() { Vector r; for (int i = 0; i < _start_spells.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_start_spells[i].get_ref_ptr()); - #else +#else r.push_back(_start_spells[i]); - #endif +#endif } return r; } @@ -319,11 +319,11 @@ void EntityClassData::set_aura(int index, Ref aura) { Vector EntityClassData::get_auras() { Vector r; for (int i = 0; i < _auras.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_auras[i].get_ref_ptr()); - #else +#else r.push_back(_auras[i]); - #endif +#endif } return r; } @@ -367,11 +367,11 @@ void EntityClassData::set_ai(int index, Ref ai) { Vector EntityClassData::get_ais() { Vector r; for (int i = 0; i < _ais.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_ais[i].get_ref_ptr()); - #else +#else r.push_back(_ais[i]); - #endif +#endif } return r; } @@ -648,12 +648,12 @@ void EntityClassData::son_xp_gained(Entity *entity, int value) { call("_son_xp_gained", entity, value); } void EntityClassData::son_xp_gained_bind(Node *entity, int value) { - - #if VERSION_MAJOR < 4 + +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -667,11 +667,11 @@ void EntityClassData::son_class_level_up(Entity *entity, int value) { call("_son_class_level_up", entity); } void EntityClassData::son_class_level_up_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -685,11 +685,11 @@ void EntityClassData::son_character_level_up(Entity *entity, int value) { call("_son_character_level_up", entity); } void EntityClassData::son_character_level_up_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -863,11 +863,11 @@ void EntityClassData::con_xp_gained(Entity *entity, int value) { call("_con_xp_gained", entity, value); } void EntityClassData::con_xp_gained_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -881,11 +881,11 @@ void EntityClassData::con_class_level_up(Entity *entity, int value) { call("_con_class_level_up", entity); } void EntityClassData::con_class_level_up_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -899,11 +899,11 @@ void EntityClassData::con_character_level_up(Entity *entity, int value) { call("_con_character_level_up", entity); } void EntityClassData::con_character_level_up_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -932,11 +932,11 @@ bool EntityClassData::should_deny_equip(Entity *entity, ItemEnums::EquipSlots eq return false; } bool EntityClassData::should_deny_equip_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(entity), false); - #else +#else ERR_FAIL_COND_V(entity == NULL, false); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -950,11 +950,11 @@ void EntityClassData::son_equip_success(Entity *entity, ItemEnums::EquipSlots eq call("_son_equip_success", entity, equip_slot, item, old_item, bag_slot); } void EntityClassData::son_equip_success_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item, Ref old_item, int bag_slot) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -968,11 +968,11 @@ void EntityClassData::son_equip_fail(Entity *entity, ItemEnums::EquipSlots equip call("_son_equip_fail", entity, equip_slot, item, old_item, bag_slot); } void EntityClassData::son_equip_fail_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item, Ref old_item, int bag_slot) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -986,11 +986,11 @@ void EntityClassData::con_equip_success(Entity *entity, ItemEnums::EquipSlots eq call("_con_equip_success", entity, equip_slot, item, old_item, bag_slot); } void EntityClassData::con_equip_success_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item, Ref old_item, int bag_slot) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -1004,11 +1004,11 @@ void EntityClassData::con_equip_fail(Entity *entity, ItemEnums::EquipSlots equip call("_con_equip_fail", entity, equip_slot, item, old_item, bag_slot); } void EntityClassData::con_equip_fail_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item, Ref old_item, int bag_slot) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); diff --git a/entities/data/entity_data.cpp b/entities/data/entity_data.cpp index 37378d7..d0565ed 100644 --- a/entities/data/entity_data.cpp +++ b/entities/data/entity_data.cpp @@ -215,11 +215,11 @@ void EntityData::set_craft_recipe(int index, const Ref &craft_data) Vector EntityData::get_craft_recipes() const { Vector r; for (int i = 0; i < _craft_recipes.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_craft_recipes[i].get_ref_ptr()); - #else +#else r.push_back(_craft_recipes[i]); - #endif +#endif } return r; } @@ -272,11 +272,11 @@ String EntityData::generate_name() { //// SETUP //// void EntityData::setup_resources(Entity *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif if (_entity_class_data.is_valid()) _entity_class_data->setup_resources(entity); @@ -286,11 +286,11 @@ void EntityData::setup_resources(Entity *entity) { } bool EntityData::cans_interact(Entity *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(entity), false); - #else +#else ERR_FAIL_COND_V(entity == NULL, false); - #endif +#endif if (has_method("_cans_interact")) return call("_cans_interact", entity); @@ -299,11 +299,11 @@ bool EntityData::cans_interact(Entity *entity) { } bool EntityData::cans_interact_bind(Node *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(entity), false); - #else +#else ERR_FAIL_COND_V(entity == NULL, false); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -313,22 +313,22 @@ bool EntityData::cans_interact_bind(Node *entity) { } void EntityData::sinteract(Entity *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif if (has_method("_sinteract")) call("_sinteract", entity); } void EntityData::sinteract_bind(Node *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -631,11 +631,11 @@ void EntityData::son_xp_gained(Entity *entity, int value) { call("_son_xp_gained", entity, value); } void EntityData::son_xp_gained_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -652,11 +652,11 @@ void EntityData::son_class_level_up(Entity *entity, int value) { call("_son_class_level_up", entity); } void EntityData::son_class_level_up_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -673,11 +673,11 @@ void EntityData::son_character_level_up(Entity *entity, int value) { call("_son_character_level_up", entity); } void EntityData::son_character_level_up_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -918,11 +918,11 @@ void EntityData::con_xp_gained(Entity *entity, int value) { call("_con_xp_gained", entity, value); } void EntityData::con_xp_gained_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -939,11 +939,11 @@ void EntityData::con_class_level_up(Entity *entity, int value) { call("_con_class_level_up", entity); } void EntityData::con_class_level_up_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -960,11 +960,11 @@ void EntityData::con_character_level_up(Entity *entity, int value) { call("_con_character_level_up", entity); } void EntityData::con_character_level_up_bind(Node *entity, int value) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -1005,11 +1005,11 @@ bool EntityData::should_deny_equip(Entity *entity, ItemEnums::EquipSlots equip_s return false; } bool EntityData::should_deny_equip_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(entity), false); - #else +#else ERR_FAIL_COND_V(entity == NULL, false); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -1026,11 +1026,11 @@ void EntityData::son_equip_success(Entity *entity, ItemEnums::EquipSlots equip_s call("_son_equip_success", entity, equip_slot, item, old_item, bag_slot); } void EntityData::son_equip_success_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item, Ref old_item, int bag_slot) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -1047,11 +1047,11 @@ void EntityData::son_equip_fail(Entity *entity, ItemEnums::EquipSlots equip_slot call("_son_equip_fail", entity, equip_slot, item, old_item, bag_slot); } void EntityData::son_equip_fail_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item, Ref old_item, int bag_slot) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -1068,11 +1068,11 @@ void EntityData::con_equip_success(Entity *entity, ItemEnums::EquipSlots equip_s call("_con_equip_success", entity, equip_slot, item, old_item, bag_slot); } void EntityData::con_equip_success_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item, Ref old_item, int bag_slot) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); @@ -1089,11 +1089,11 @@ void EntityData::con_equip_fail(Entity *entity, ItemEnums::EquipSlots equip_slot call("_con_equip_fail", entity, equip_slot, item, old_item, bag_slot); } void EntityData::con_equip_fail_bind(Node *entity, ItemEnums::EquipSlots equip_slot, Ref item, Ref old_item, int bag_slot) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif Entity *e = Object::cast_to(entity); diff --git a/entities/data/item_container_data.cpp b/entities/data/item_container_data.cpp index d334b63..043edc9 100644 --- a/entities/data/item_container_data.cpp +++ b/entities/data/item_container_data.cpp @@ -45,11 +45,11 @@ void ItemContainerData::set_container_data(int index, Ref ItemContainerData::get_container_datas() { Vector r; for (int i = 0; i < _container_datas.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_container_datas[i].get_ref_ptr()); - #else +#else r.push_back(_container_datas[i]); - #endif +#endif } return r; } diff --git a/entities/data/vendor_item_data.cpp b/entities/data/vendor_item_data.cpp index 631e003..d8841ae 100644 --- a/entities/data/vendor_item_data.cpp +++ b/entities/data/vendor_item_data.cpp @@ -42,11 +42,11 @@ void VendorItemData::set_vendor_data(int index, Ref vendor_ Vector VendorItemData::get_vendor_datas() { Vector r; for (int i = 0; i < _vendor_datas.size(); i++) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r.push_back(_vendor_datas[i].get_ref_ptr()); - #else +#else r.push_back(_vendor_datas[i]); - #endif +#endif } return r; } diff --git a/entities/entity.cpp b/entities/entity.cpp index 464ff51..1a9a922 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -49,13 +49,13 @@ void Entity::set_body_path(NodePath value) { _body = get_node_or_null(_body_path); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_body)) _body->set_owner(this); - #else +#else if (_body == NULL) _body->set_owner(this); - #endif +#endif } Node *Entity::get_body() { return _body; @@ -130,20 +130,20 @@ void Entity::setc_entity_type(EntityEnums::EntityType value) { EntityEnums::EntityRelationType Entity::gets_relation_to_bind(Node *to) { Entity *e = Object::cast_to(to); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(e), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); - #else +#else ERR_FAIL_COND_V(e == NULL, EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); - #endif +#endif return gets_relation_to(e); } EntityEnums::EntityRelationType Entity::gets_relation_to(Entity *to) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(to), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); - #else +#else ERR_FAIL_COND_V(to == NULL, EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); - #endif +#endif return static_cast(static_cast(call("_gets_relation_to", to))); } @@ -158,21 +158,21 @@ EntityEnums::EntityRelationType Entity::_gets_relation_to(Node *to) { EntityEnums::EntityRelationType Entity::getc_relation_to_bind(Node *to) { Entity *e = Object::cast_to(to); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(e), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); - #else +#else ERR_FAIL_COND_V(e == NULL, EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); - #endif +#endif return getc_relation_to(e); } EntityEnums::EntityRelationType Entity::getc_relation_to(Entity *to) { - - #if VERSION_MAJOR < 4 + +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(to), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); - #else +#else ERR_FAIL_COND_V(to == NULL, EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); - #endif +#endif return static_cast(static_cast(call("_getc_relation_to", to))); } @@ -259,11 +259,11 @@ EntityEnums::EntityGender Entity::getc_gender() { void Entity::setc_gender(EntityEnums::EntityGender value) { _c_gender = value; - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_character_skeleton)) { - #else +#else if (_character_skeleton != NULL) { - #endif +#endif if (_character_skeleton->has_method("set_gender")) _character_skeleton->call("set_gender", _c_gender); @@ -773,11 +773,11 @@ void Entity::sets_ai(Ref value) { //// Pets //// void Entity::adds_pet(Entity *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif //the owner always want to see his pet, and you pet will always want to see the owner adds_sees(entity); @@ -819,20 +819,20 @@ void Entity::removes_pet_index(int index) { for (int i = 0; i < _s_pets.size(); ++i) { Entity *pet = _s_pets.get(index); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_CONTINUE(!ObjectDB::instance_validate(pet)); - #else +#else ERR_CONTINUE(pet == NULL); - #endif +#endif _s_pets.get(i)->sets_pet_formation_index(i); } - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif entity->sets_pet_owner(NULL); @@ -865,21 +865,21 @@ void Entity::addc_pet_path(NodePath path) { Entity *entity = Object::cast_to(n); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif addc_pet(entity); } void Entity::addc_pet(Entity *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif _c_pets.push_back(entity); @@ -2044,11 +2044,11 @@ void Entity::_capply_item(Ref item) { ERR_FAIL_COND(!it.is_valid()); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (it->get_item_visual().is_valid() && ObjectDB::instance_validate(_character_skeleton)) { - #else +#else if (it->get_item_visual().is_valid() && _character_skeleton == NULL) { - #endif +#endif if (_character_skeleton->has_method("add_item_visual")) _character_skeleton->call("add_item_visual", it->get_item_visual()); @@ -2061,11 +2061,11 @@ void Entity::_cdeapply_item(Ref item) { ERR_FAIL_COND(!it.is_valid()); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (it->get_item_visual().is_valid() && ObjectDB::instance_validate(_character_skeleton)) { - #else +#else if (it->get_item_visual().is_valid() && _character_skeleton == NULL) { - #endif +#endif if (_character_skeleton->has_method("remove_item_visual")) _character_skeleton->call("remove_item_visual", it->get_item_visual()); @@ -2445,11 +2445,11 @@ bool Entity::canc_interact() { return call("_canc_interact"); } - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (!ObjectDB::instance_validate(_c_target)) { - #else +#else if (_c_target == NULL) { - #endif +#endif return false; } @@ -3568,12 +3568,12 @@ Ref Entity::gets_aura_with_group_by(Entity *caster, Ref aur return Ref(); } Ref Entity::gets_aura_with_group_by_bind(Node *caster, Ref aura_group) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (!ObjectDB::instance_validate(caster)) { - #else +#else if (caster == NULL) { - #endif - +#endif + return Ref(); } @@ -4678,13 +4678,13 @@ void Entity::adds_skill(Ref skill) { if (hass_skill(skill)) return; - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 skill->connect("current_changed", this, "sskill_current_changed"); skill->connect("max_changed", this, "sskill_max_changed"); - #else +#else skill->connect("current_changed", callable_mp(this, &Entity::sskill_current_changed)); skill->connect("max_changed", callable_mp(this, &Entity::sskill_max_changed)); - #endif +#endif _s_skills.push_back(skill); @@ -4910,11 +4910,11 @@ Entity *Entity::gets_target() { void Entity::sets_target(Node *p_target) { Entity *original_target = _s_target; - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (!ObjectDB::instance_validate(original_target)) { - #else +#else if (original_target == NULL) { - #endif +#endif original_target = NULL; _s_target = NULL; @@ -4965,11 +4965,11 @@ Entity *Entity::getc_target() { void Entity::setc_target(Node *p_target) { Entity *original_target = _c_target; - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (!ObjectDB::instance_validate(original_target)) { - #else +#else if (original_target == NULL) { - #endif +#endif original_target = NULL; _c_target = NULL; @@ -5240,41 +5240,41 @@ Ref Entity::gets_bag() const { } void Entity::sets_bag(const Ref bag) { if (_s_bag.is_valid()) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 _s_bag->disconnect("item_added", this, "ons_item_added"); _s_bag->disconnect("item_removed", this, "ons_item_removed"); _s_bag->disconnect("item_swapped", this, "ons_items_swapped"); _s_bag->disconnect("item_count_changed", this, "ons_item_count_changed"); _s_bag->disconnect("overburdened", this, "ons_overburdened"); _s_bag->disconnect("overburden_removed", this, "ons_overburden_removed"); - #else +#else _s_bag->disconnect("item_added", callable_mp(this, &Entity::ons_item_added)); _s_bag->disconnect("item_removed", callable_mp(this, &Entity::ons_item_removed)); _s_bag->disconnect("item_swapped", callable_mp(this, &Entity::ons_items_swapped)); _s_bag->disconnect("item_count_changed", callable_mp(this, &Entity::ons_item_count_changed)); _s_bag->disconnect("overburdened", callable_mp(this, &Entity::ons_overburdened)); _s_bag->disconnect("overburden_removed", callable_mp(this, &Entity::ons_overburden_removed)); - #endif +#endif } _s_bag = bag; if (_s_bag.is_valid()) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 _s_bag->connect("item_added", this, "ons_item_added"); _s_bag->connect("item_removed", this, "ons_item_removed"); _s_bag->connect("item_swapped", this, "ons_items_swapped"); _s_bag->connect("item_count_changed", this, "ons_item_count_changed"); _s_bag->connect("overburdened", this, "ons_overburdened"); _s_bag->connect("overburden_removed", this, "ons_overburden_removed"); - #else +#else _s_bag->connect("item_added", callable_mp(this, &Entity::ons_item_added)); _s_bag->connect("item_removed", callable_mp(this, &Entity::ons_item_removed)); _s_bag->connect("item_swapped", callable_mp(this, &Entity::ons_items_swapped)); _s_bag->connect("item_count_changed", callable_mp(this, &Entity::ons_item_count_changed)); _s_bag->connect("overburdened", callable_mp(this, &Entity::ons_overburdened)); _s_bag->connect("overburden_removed", callable_mp(this, &Entity::ons_overburden_removed)); - #endif +#endif } emit_signal("sbag_changed", this, _s_bag); @@ -5300,33 +5300,33 @@ Ref Entity::gets_target_bag() const { } void Entity::sets_target_bag(const Ref bag) { if (_s_target_bag.is_valid()) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 _s_target_bag->disconnect("item_added", this, "ons_target_item_added"); _s_target_bag->disconnect("item_removed", this, "ons_target_item_removed"); _s_target_bag->disconnect("item_swapped", this, "ons_target_items_swapped"); _s_target_bag->disconnect("item_count_changed", this, "ons_target_item_count_changed"); - #else +#else _s_target_bag->disconnect("item_added", callable_mp(this, &Entity::ons_target_item_added)); _s_target_bag->disconnect("item_removed", callable_mp(this, &Entity::ons_target_item_removed)); _s_target_bag->disconnect("item_swapped", callable_mp(this, &Entity::ons_target_items_swapped)); _s_target_bag->disconnect("item_count_changed", callable_mp(this, &Entity::ons_target_item_count_changed)); - #endif +#endif } _s_target_bag = bag; if (_s_target_bag.is_valid()) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 _s_target_bag->connect("item_added", this, "ons_target_item_added"); _s_target_bag->connect("item_removed", this, "ons_target_item_removed"); _s_target_bag->connect("item_swapped", this, "ons_target_items_swapped"); _s_target_bag->connect("item_count_changed", this, "ons_target_item_count_changed"); - #else +#else _s_target_bag->connect("item_added", callable_mp(this, &Entity::ons_target_item_added)); _s_target_bag->connect("item_removed", callable_mp(this, &Entity::ons_target_item_removed)); _s_target_bag->connect("item_swapped", callable_mp(this, &Entity::ons_target_items_swapped)); _s_target_bag->connect("item_count_changed", callable_mp(this, &Entity::ons_target_item_count_changed)); - #endif +#endif } emit_signal("starget_bag_changed", this, _s_target_bag); @@ -5722,11 +5722,11 @@ Entity *Entity::gets_sees(int index) { void Entity::removes_sees_index(int index) { Entity *e = _s_sees.get(index); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (unlikely(!ObjectDB::instance_validate(e))) { - #else +#else if (e == NULL) { - #endif +#endif _s_sees.remove(index); return; @@ -5737,11 +5737,11 @@ void Entity::removes_sees_index(int index) { _s_sees.remove(index); } void Entity::removes_sees(Entity *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (unlikely(!ObjectDB::instance_validate(entity))) { - #else +#else if (entity == NULL) { - #endif +#endif _s_sees.erase(entity); return; @@ -5759,11 +5759,11 @@ void Entity::removes_sees_bind(Node *entity) { removes_sees(e); } void Entity::adds_sees(Entity *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif entity->adds_seen_by(this); @@ -5804,11 +5804,11 @@ void Entity::removes_seen_by_bind(Node *entity) { removes_seen_by(e); } void Entity::adds_seen_by(Entity *entity) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); - #else +#else ERR_FAIL_COND(entity == NULL); - #endif +#endif for (int i = 0; i < _s_seen_by.size(); ++i) { if (_s_seen_by.get(i) == entity) @@ -5843,11 +5843,11 @@ void Entity::vrpc(const StringName &p_method, VARIANT_ARG_DECLARE) { for (int i = 0; i < _s_seen_by.size(); ++i) { Entity *e = _s_seen_by.get(i); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (unlikely(!ObjectDB::instance_validate(e))) { - #else +#else if (e == NULL) { - #endif +#endif _s_seen_by.remove(i); --i; @@ -5871,23 +5871,23 @@ Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Callable::Cal #endif if (p_argcount < 1) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - #else +#else r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - #endif +#endif r_error.argument = 1; return Variant(); } if (p_args[0]->get_type() != Variant::STRING) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; - #else +#else r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - #endif - +#endif + r_error.argument = 0; r_error.expected = Variant::STRING; return Variant(); @@ -5898,11 +5898,11 @@ Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Callable::Cal for (int i = 0; i < _s_seen_by.size(); ++i) { Entity *e = _s_seen_by.get(i); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (unlikely(!ObjectDB::instance_validate(e))) { - #else +#else if (unlikely(e == NULL)) { - #endif +#endif _s_seen_by.remove(i); --i; @@ -5917,12 +5917,12 @@ Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Callable::Cal //call(method, &p_args[1], p_argcount - 1); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 r_error.error = Variant::CallError::CALL_OK; - #else +#else r_error.error = Callable::CallError::CALL_OK; - #endif - +#endif + return Variant(); } @@ -6411,17 +6411,17 @@ void Entity::_con_target_changed(Node *p_entity, Node *p_old_target) { //Entity *entity = Object::cast_to(p_entity); Entity *old_target = Object::cast_to(p_old_target); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(old_target)) old_target->onc_untargeted(); if (ObjectDB::instance_validate(getc_target())) { - #else +#else if (old_target != NULL) old_target->onc_untargeted(); if (getc_target() != NULL) { - #endif +#endif getc_target()->onc_targeted(); @@ -6510,13 +6510,13 @@ void Entity::_notification(int p_what) { case NOTIFICATION_INSTANCED: { _body = get_node_or_null(_body_path); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_body)) _body->set_owner(this); - #else +#else if (_body != NULL) _body->set_owner(this); - #endif +#endif _character_skeleton = get_node_or_null(_character_skeleton_path); @@ -6532,13 +6532,13 @@ void Entity::_notification(int p_what) { if (!_body) { _body = get_node_or_null(_body_path); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_body)) _body->set_owner(this); - #else +#else if (_body != NULL) _body->set_owner(this); - #endif +#endif } if (!_character_skeleton) { @@ -6561,13 +6561,13 @@ void Entity::_notification(int p_what) { for (int i = 0; i < _s_seen_by.size(); ++i) { Entity *e = _s_seen_by.get(i); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(e)) e->removes_sees(this); - #else +#else if (e != NULL) e->removes_sees(this); - #endif +#endif } } break; } diff --git a/entities/entity.h b/entities/entity.h index c57c76d..0f1852a 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -972,12 +972,11 @@ public: int gets_seen_by_count(); void vrpc(const StringName &p_method, VARIANT_ARG_LIST); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Variant _vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error); - #else +#else Variant _vrpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error); - #endif - +#endif Dictionary data_as_dict(String &data); diff --git a/entities/stats/stat.cpp b/entities/stats/stat.cpp index aecf9cd..e85dfaa 100644 --- a/entities/stats/stat.cpp +++ b/entities/stats/stat.cpp @@ -329,11 +329,11 @@ void Stat::remove_modifier_index(int index) { } void Stat::apply_modifiers() { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); - #else +#else ERR_FAIL_COND(_owner == NULL); - #endif +#endif ERR_FAIL_COND(!_stat_data_entry.is_valid()); reset_values(); diff --git a/formations/ai_formation.cpp b/formations/ai_formation.cpp index 40e6582..2bf9317 100644 --- a/formations/ai_formation.cpp +++ b/formations/ai_formation.cpp @@ -62,12 +62,11 @@ String AIFormation::get_editor_description() const { } Vector3 AIFormation::get_position(int slot_index) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(_owner), Vector3()); - #else +#else ERR_FAIL_COND_V(_owner == NULL, Vector3()); - #endif - +#endif if (has_method("_get_position")) return call("_get_position", slot_index); diff --git a/infos/spell_cast_info.cpp b/infos/spell_cast_info.cpp index 6816703..c81061a 100644 --- a/infos/spell_cast_info.cpp +++ b/infos/spell_cast_info.cpp @@ -33,11 +33,11 @@ SOFTWARE. //// SpellCastInfo //// Entity *SpellCastInfo::get_caster() { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (_caster && !ObjectDB::instance_validate(_caster)) { _caster = NULL; } - #endif +#endif return _caster; } @@ -59,12 +59,11 @@ void SpellCastInfo::set_caster_bind(Node *caster) { } Entity *SpellCastInfo::get_target() { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (_target && !ObjectDB::instance_validate(_target)) { _target = NULL; } - #endif - +#endif return _target; } @@ -167,12 +166,12 @@ void SpellCastInfo::physics_process(float delta) { } void SpellCastInfo::resolve_references(Node *owner) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(owner)); - #else +#else ERR_FAIL_COND(owner == NULL); - #endif - +#endif + ERR_FAIL_COND(!owner->is_inside_tree()); _caster = Object::cast_to(owner); @@ -191,19 +190,19 @@ void SpellCastInfo::resolve_references(Node *owner) { Dictionary SpellCastInfo::to_dict() { Dictionary dict; - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_caster)) dict["caster"] = _caster->get_path(); if (ObjectDB::instance_validate(_target)) dict["target"] = _target->get_path(); - #else +#else if (_caster == NULL) dict["caster"] = _caster->get_path(); if (_target == NULL) dict["target"] = _target->get_path(); - #endif +#endif dict["has_cast_time"] = _has_cast_time; dict["cast_time"] = _cast_time; diff --git a/pipelines/spell_damage_info.cpp b/pipelines/spell_damage_info.cpp index 0eaf4df..91527ae 100644 --- a/pipelines/spell_damage_info.cpp +++ b/pipelines/spell_damage_info.cpp @@ -164,11 +164,11 @@ void SpellDamageInfo::reset() { } void SpellDamageInfo::resolve_references(Node *owner) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(owner)); - #else +#else ERR_FAIL_COND(owner == NULL); - #endif +#endif ERR_FAIL_COND(!owner->is_inside_tree()); _dealer = Object::cast_to(owner->get_node_or_null(_dealer_path)); @@ -184,19 +184,19 @@ void SpellDamageInfo::resolve_references(Node *owner) { Dictionary SpellDamageInfo::to_dict() { Dictionary dict; - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_dealer)) dict["dealer_path"] = _dealer->get_path(); if (ObjectDB::instance_validate(_receiver)) dict["receiver_path"] = _receiver->get_path(); - #else +#else if (_dealer != NULL) dict["dealer_path"] = _dealer->get_path(); if (_receiver != NULL) dict["receiver_path"] = _receiver->get_path(); - #endif +#endif dict["immune"] = _immune; dict["damage"] = _damage; diff --git a/pipelines/spell_heal_info.cpp b/pipelines/spell_heal_info.cpp index 26681df..a62c481 100644 --- a/pipelines/spell_heal_info.cpp +++ b/pipelines/spell_heal_info.cpp @@ -160,11 +160,11 @@ void SpellHealInfo::reset() { } void SpellHealInfo::resolve_references(Node *owner) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(owner)); - #else +#else ERR_FAIL_COND(owner == NULL); - #endif +#endif ERR_FAIL_COND(!owner->is_inside_tree()); _dealer = Object::cast_to(owner->get_node_or_null(_dealer_path)); @@ -180,19 +180,19 @@ void SpellHealInfo::resolve_references(Node *owner) { Dictionary SpellHealInfo::to_dict() { Dictionary dict; - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_dealer)) dict["dealer_path"] = _dealer->get_path(); if (ObjectDB::instance_validate(_receiver)) dict["receiver_path"] = _receiver->get_path(); - #else +#else if (_dealer == NULL) dict["dealer_path"] = _dealer->get_path(); if (_receiver == NULL) dict["receiver_path"] = _receiver->get_path(); - #endif +#endif dict["immune"] = _immune; dict["heal"] = _heal; diff --git a/profiles/player_profile.cpp b/profiles/player_profile.cpp index 4e995c5..7f11c8e 100644 --- a/profiles/player_profile.cpp +++ b/profiles/player_profile.cpp @@ -61,11 +61,11 @@ Ref PlayerProfile::get_class_profile_index(const int index) { } void PlayerProfile::add_class_profile(Ref profile) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 profile->connect("changed", this, "_on_class_profile_changed"); - #else +#else profile->connect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); - #endif +#endif _class_profiles.push_back(profile); @@ -74,11 +74,11 @@ void PlayerProfile::add_class_profile(Ref profile) { void PlayerProfile::clear_class_profiles() { for (int i = 0; i < _class_profiles.size(); ++i) { - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 _class_profiles.get(i)->disconnect("changed", this, "_on_class_profile_changed"); - #else +#else _class_profiles.get(i)->disconnect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); - #endif +#endif } _class_profiles.clear(); @@ -87,13 +87,12 @@ void PlayerProfile::clear_class_profiles() { } void PlayerProfile::remove_class_profile(const int index) { - - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 _class_profiles.get(index)->disconnect("changed", this, "_on_class_profile_changed"); - #else +#else _class_profiles.get(index)->disconnect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); - #endif +#endif _class_profiles.remove(index); @@ -115,11 +114,11 @@ Ref PlayerProfile::get_class_profile(const int class_id) { class_profile->load_defaults(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 class_profile->connect("changed", this, "_on_class_profile_changed"); - #else +#else class_profile->connect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); - #endif +#endif _class_profiles.push_back(Ref(class_profile)); @@ -176,12 +175,12 @@ void PlayerProfile::from_dict(const Dictionary &dict) { c.instance(); c->from_dict(arr.get(i)); - - #if VERSION_MAJOR < 4 + +#if VERSION_MAJOR < 4 c->connect("changed", this, "_on_class_profile_changed"); - #else +#else c->connect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); - #endif +#endif _class_profiles.push_back(c); } @@ -213,12 +212,12 @@ void PlayerProfile::load_defaults() { for (int i = 0; i < _class_profiles.size(); ++i) { _class_profiles.get(i)->load_defaults(); - - #if VERSION_MAJOR < 4 + +#if VERSION_MAJOR < 4 _class_profiles.get(i)->connect("changed", this, "_on_class_profile_changed"); - #else +#else _class_profiles.get(i)->connect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); - #endif +#endif } emit_change(); diff --git a/singletons/entity_data_manager.cpp b/singletons/entity_data_manager.cpp index ca50594..438a103 100644 --- a/singletons/entity_data_manager.cpp +++ b/singletons/entity_data_manager.cpp @@ -450,7 +450,7 @@ void EntityDataManager::load_xp_data() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(_xp_data_path, "XPData"); ERR_FAIL_COND(!resl.is_valid()); @@ -458,9 +458,9 @@ void EntityDataManager::load_xp_data() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(_xp_data_path, "XPData"); - #endif +#endif ERR_FAIL_COND(!s.is_valid()); @@ -493,7 +493,7 @@ void EntityDataManager::load_entity_resources() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntityResourceData"); ERR_CONTINUE(!resl.is_valid()); @@ -501,9 +501,9 @@ void EntityDataManager::load_entity_resources() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "EntityResourceData"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); @@ -541,7 +541,7 @@ void EntityDataManager::load_entity_skills() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntitySkillData"); ERR_CONTINUE(!resl.is_valid()); @@ -549,9 +549,9 @@ void EntityDataManager::load_entity_skills() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "EntitySkillData"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); @@ -589,7 +589,7 @@ void EntityDataManager::load_spells() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "Spell"); ERR_CONTINUE(!resl.is_valid()); @@ -597,9 +597,9 @@ void EntityDataManager::load_spells() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "Spell"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); @@ -637,7 +637,7 @@ void EntityDataManager::load_auras() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "Aura"); ERR_CONTINUE(!resl.is_valid()); @@ -645,9 +645,9 @@ void EntityDataManager::load_auras() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "Aura"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); @@ -685,7 +685,7 @@ void EntityDataManager::load_characters() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntityData"); ERR_CONTINUE(!resl.is_valid()); @@ -693,9 +693,9 @@ void EntityDataManager::load_characters() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "EntityData"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); @@ -733,7 +733,7 @@ void EntityDataManager::load_craft_datas() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "CraftRecipe"); ERR_CONTINUE(!resl.is_valid()); @@ -741,9 +741,9 @@ void EntityDataManager::load_craft_datas() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "CraftRecipe"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); @@ -781,7 +781,7 @@ void EntityDataManager::load_item_templates() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "ItemTemplate"); ERR_CONTINUE(!resl.is_valid()); @@ -789,9 +789,9 @@ void EntityDataManager::load_item_templates() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "ItemTemplate"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); @@ -829,7 +829,7 @@ void EntityDataManager::load_mob_datas() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntityData"); ERR_CONTINUE(!resl.is_valid()); @@ -837,9 +837,9 @@ void EntityDataManager::load_mob_datas() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "EntityData"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); @@ -877,7 +877,7 @@ void EntityDataManager::load_player_character_datas() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntityData"); ERR_CONTINUE(!resl.is_valid()); @@ -885,10 +885,10 @@ void EntityDataManager::load_player_character_datas() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "EntityData"); - #endif - +#endif + ERR_CONTINUE(!s.is_valid()); Ref pcd = s; @@ -925,7 +925,7 @@ void EntityDataManager::load_entity_species_datas() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntitySpeciesData"); ERR_CONTINUE(!resl.is_valid()); @@ -933,9 +933,9 @@ void EntityDataManager::load_entity_species_datas() { resl->wait(); Ref s = resl->get_resource(); - #else +#else Ref s = rl->load(path, "EntitySpeciesData"); - #endif +#endif ERR_CONTINUE(!s.is_valid()); diff --git a/singletons/profile_manager.cpp b/singletons/profile_manager.cpp index 63f077b..ab34d74 100644 --- a/singletons/profile_manager.cpp +++ b/singletons/profile_manager.cpp @@ -166,15 +166,15 @@ void ProfileManager::from_dict(const Dictionary &dict) { clears_player_profiles(); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 _c_player_profile->disconnect("changed", this, "_on_player_profile_changed"); _c_player_profile->from_dict(dict.get("cplayer_profile", Dictionary())); _c_player_profile->connect("changed", this, "_on_player_profile_changed"); - #else +#else _c_player_profile->disconnect("changed", callable_mp(this, &ProfileManager::_on_player_profile_changed)); _c_player_profile->from_dict(dict.get("cplayer_profile", Dictionary())); _c_player_profile->connect("changed", callable_mp(this, &ProfileManager::_on_player_profile_changed)); - #endif +#endif Array arr = dict.get("splayer_profiles", Array()); @@ -184,11 +184,11 @@ void ProfileManager::from_dict(const Dictionary &dict) { c->from_dict(arr.get(i)); - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 c->connect("changed", this, "_on_player_profile_changed"); - #else +#else c->connect("changed", callable_mp(this, &ProfileManager::_on_player_profile_changed)); - #endif +#endif _s_player_profiles.push_back(c); } @@ -202,12 +202,12 @@ ProfileManager::ProfileManager() { _save_file = GLOBAL_DEF("ess/profiles/save_file", "user://profile.save"); _c_player_profile.instance(); - - #if VERSION_MAJOR < 4 + +#if VERSION_MAJOR < 4 _c_player_profile->connect("changed", this, "_on_player_profile_changed"); - #else +#else _c_player_profile->connect("changed", callable_mp(this, &ProfileManager::_on_player_profile_changed)); - #endif +#endif if (_automatic_load) call_deferred("load"); @@ -215,12 +215,12 @@ ProfileManager::ProfileManager() { ProfileManager::~ProfileManager() { _instance = NULL; - - #if VERSION_MAJOR < 4 + +#if VERSION_MAJOR < 4 _c_player_profile->disconnect("changed", this, "_on_player_profile_changed"); - #else +#else _c_player_profile->disconnect("changed", callable_mp(this, &ProfileManager::_on_player_profile_changed)); - #endif +#endif _s_player_profiles.clear(); } diff --git a/skeleton/character_skeleton_3d.cpp b/skeleton/character_skeleton_3d.cpp index 7ecdb14..35abb0a 100644 --- a/skeleton/character_skeleton_3d.cpp +++ b/skeleton/character_skeleton_3d.cpp @@ -340,9 +340,9 @@ Array CharacterSkeleton3D::bake_mesh_array_uv(Array arr, Ref tex, float PoolVector2Array uvs = arr[VisualServer::ARRAY_TEX_UV]; PoolColorArray colors = arr[VisualServer::ARRAY_COLOR]; - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 img->lock(); - #endif +#endif for (int i = 0; i < uvs.size(); ++i) { Vector2 uv = uvs[i]; @@ -353,9 +353,9 @@ Array CharacterSkeleton3D::bake_mesh_array_uv(Array arr, Ref tex, float colors.set(i, colors[i] * c * mul_color); } - #if VERSION_MAJOR < 4 +#if VERSION_MAJOR < 4 img->unlock(); - #endif +#endif arr[VisualServer::ARRAY_COLOR] = colors;