From 9fa7c234627cf60179626526d8ca774023aa65fa Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 9 Apr 2020 12:32:05 +0200 Subject: [PATCH] Fix build for 4.0. (When 4.0 becomes stable I'll create a branch for it) --- data/auras/aura.cpp | 24 +++ data/items/item_stat_modifier.h | 6 + data/items/item_template.cpp | 18 ++ data/items/item_template_stat_modifier.h | 6 + data/species/entity_species_data.cpp | 10 + data/species/species_model_data.cpp | 14 ++ data/spells/spell.cpp | 39 ++++ entities/ai/entity_ai.cpp | 18 ++ entities/auras/aura_data.cpp | 6 + entities/data/character_spec.cpp | 6 + entities/data/entity_class_data.cpp | 71 +++++++ entities/data/entity_data.cpp | 70 +++++++ entities/data/item_container_data.cpp | 6 + entities/data/vendor_item_data.cpp | 6 + entities/entity.cpp | 206 +++++++++++++++++++- entities/entity.h | 7 + entities/stats/stat.cpp | 6 + entities/stats/stat_data_entry.cpp | 6 + entities/stats/stat_modifier.cpp | 6 + formations/ai_formation.cpp | 7 + infos/spell_cast_info.cpp | 20 ++ pipelines/spell_damage_info.cpp | 14 ++ pipelines/spell_heal_info.cpp | 14 ++ profiles/actionbar/action_bar_entry.cpp | 6 + profiles/player_profile.cpp | 31 +++ projectiles/3d/spell_follow_projectile_3d.h | 8 + singletons/entity_data_manager.cpp | 46 ++++- singletons/profile_manager.cpp | 26 ++- skeleton/character_skeleton_3d.cpp | 19 ++ skeleton/character_skeleton_3d.h | 10 + utility/category_cooldown.cpp | 6 + utility/cooldown.cpp | 6 + 32 files changed, 733 insertions(+), 11 deletions(-) diff --git a/data/auras/aura.cpp b/data/auras/aura.cpp index ba30eac..97f8194 100644 --- a/data/auras/aura.cpp +++ b/data/auras/aura.cpp @@ -25,6 +25,8 @@ SOFTWARE. #include "../../entities/resources/entity_resource_cost_data.h" #include "../../singletons/entity_data_manager.h" +#include "core/version.h" + int Aura::get_id() const { return _id; } @@ -1255,7 +1257,12 @@ void Aura::_supdate(Ref aura, float delta) { } void Aura::_setup_aura_data(Ref data, Ref info) { + + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_caster())); + #else + ERR_FAIL_COND(info->get_caster() == NULL); + #endif data->set_aura(Ref(this)); data->set_aura_id(get_id()); @@ -1291,14 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); + #else + ERR_FAIL_COND(info->get_dealer() == NULL); + #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 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); + #else + ERR_FAIL_COND(info->get_dealer() == NULL); + #endif info->get_dealer()->sdeal_damage_to(info); } @@ -1316,14 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); + #else + ERR_FAIL_COND(info->get_dealer() == NULL); + #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 ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); + #else + ERR_FAIL_COND(info->get_dealer() == NULL); + #endif info->get_dealer()->sdeal_heal_to(info); } diff --git a/data/items/item_stat_modifier.h b/data/items/item_stat_modifier.h index 43903f7..b2056ae 100644 --- a/data/items/item_stat_modifier.h +++ b/data/items/item_stat_modifier.h @@ -26,6 +26,12 @@ SOFTWARE. #include "../../entities/stats/stat.h" #include "core/reference.h" +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#define REAL FLOAT +#endif + class ItemStatModifier : public Reference { GDCLASS(ItemStatModifier, Reference); diff --git a/data/items/item_template.cpp b/data/items/item_template.cpp index d9b794b..5f2aba0 100644 --- a/data/items/item_template.cpp +++ b/data/items/item_template.cpp @@ -27,6 +27,8 @@ SOFTWARE. #include "../spells/spell.h" #include "item_instance.h" +#include "core/version.h" + int ItemTemplate::get_id() const { return _id; } @@ -176,7 +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 r.push_back(_teaches_spells[i].get_ref_ptr()); + #else + r.push_back(_teaches_spells[i]); + #endif } return r; } @@ -212,7 +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 r.push_back(_grants_spells[i].get_ref_ptr()); + #else + r.push_back(_grants_spells[i]); + #endif } return r; } @@ -248,7 +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 r.push_back(_auras[i].get_ref_ptr()); + #else + r.push_back(_auras[i]); + #endif } return r; } @@ -280,7 +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 r.push_back(_required_skills[i].get_ref_ptr()); + #else + r.push_back(_required_skills[i]); + #endif } return r; } diff --git a/data/items/item_template_stat_modifier.h b/data/items/item_template_stat_modifier.h index 5ee606f..c42ff46 100644 --- a/data/items/item_template_stat_modifier.h +++ b/data/items/item_template_stat_modifier.h @@ -26,6 +26,12 @@ SOFTWARE. #include "../../entities/stats/stat.h" #include "core/reference.h" +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#define REAL FLOAT +#endif + class ItemTemplateStatModifier : public Reference { GDCLASS(ItemTemplateStatModifier, Reference); diff --git a/data/species/entity_species_data.cpp b/data/species/entity_species_data.cpp index b4078a2..444d19e 100644 --- a/data/species/entity_species_data.cpp +++ b/data/species/entity_species_data.cpp @@ -25,6 +25,8 @@ SOFTWARE. #include "../auras/aura.h" #include "../spells/spell.h" +#include "core/version.h" + int EntitySpeciesData::get_id() const { return _id; } @@ -81,7 +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 r.push_back(_spells[i].get_ref_ptr()); + #else + r.push_back(_spells[i]); + #endif } return r; } @@ -122,7 +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 r.push_back(_auras[i].get_ref_ptr()); + #else + r.push_back(_auras[i]); + #endif } return r; } diff --git a/data/species/species_model_data.cpp b/data/species/species_model_data.cpp index 5552e91..22e448c 100644 --- a/data/species/species_model_data.cpp +++ b/data/species/species_model_data.cpp @@ -22,6 +22,8 @@ SOFTWARE. #include "species_model_data.h" +#include "core/version.h" + int SpeciesModelData::get_id() { return _id; } @@ -73,7 +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 r.push_back(_visuals[bone_index][i].get_ref_ptr()); + #else + r.push_back(_visuals[bone_index][i]); + #endif } return r; } @@ -157,7 +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 r.push_back(_hair_styles[i].get_ref_ptr()); + #else + r.push_back(_hair_styles[i]); + #endif } return r; } @@ -239,7 +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 r.push_back(_heads[i].get_ref_ptr()); + #else + r.push_back(_heads[i]); + #endif } return r; } diff --git a/data/spells/spell.cpp b/data/spells/spell.cpp index 6066889..fbcb92a 100644 --- a/data/spells/spell.cpp +++ b/data/spells/spell.cpp @@ -34,6 +34,8 @@ SOFTWARE. #include "../../pipelines/spell_damage_info.h" #include "../../pipelines/spell_heal_info.h" +#include "core/version.h" + int Spell::get_id() const { return _id; } @@ -204,7 +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 r.push_back(_caster_aura_applys[i].get_ref_ptr()); + #else + r.push_back(_caster_aura_applys[i]); + #endif } return r; } @@ -240,7 +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 r.push_back(_target_aura_applys[i].get_ref_ptr()); + #else + r.push_back(_target_aura_applys[i]); + #endif } return r; } @@ -276,7 +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 r.push_back(_on_learn_auras[i].get_ref_ptr()); + #else + r.push_back(_on_learn_auras[i]); + #endif } return r; } @@ -560,7 +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 ERR_FAIL_COND(!caster || !ObjectDB::instance_validate(caster)); + #else + ERR_FAIL_COND(!caster || caster == NULL); + #endif Ref info = Ref(memnew(SpellCastInfo())); @@ -575,7 +593,11 @@ void Spell::sstart_casting_simple(Entity *caster, float spell_scale) { } void Spell::sinterrupt_cast_simple(Entity *caster) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!caster || !ObjectDB::instance_validate(caster)); + #else + ERR_FAIL_COND(!caster || caster == NULL); + #endif Ref info(memnew(SpellCastInfo())); @@ -586,7 +608,11 @@ void Spell::sinterrupt_cast_simple(Entity *caster) { } void Spell::sstart_casting_triggered_simple(Entity *caster) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!caster || !ObjectDB::instance_validate(caster)); + #else + ERR_FAIL_COND(!caster || caster == NULL); + #endif Ref info(memnew(SpellCastInfo())); @@ -950,7 +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 (ObjectDB::instance_validate(info->get_target())) { + #else + if (info->get_target() != NULL) { + #endif + info->get_target()->son_cast_finished_target(info); } @@ -1003,7 +1034,11 @@ void Spell::_handle_projectile(Ref info) { Node *p = info->get_caster()->get_parent(); + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(p)); + #else + ERR_FAIL_COND(p == NULL); + #endif p->add_child(projectile); @@ -1030,7 +1065,11 @@ void Spell::_handle_effect(Ref info) { # return */ + #if VERSION_MAJOR < 4 bool has_target = ObjectDB::instance_validate(info->get_target()); + #else + bool has_target = info->get_target() == NULL; + #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 84077df..0319ac9 100644 --- a/entities/ai/entity_ai.cpp +++ b/entities/ai/entity_ai.cpp @@ -24,6 +24,8 @@ SOFTWARE. #include "../entity.h" +#include "core/version.h" + bool EntityAI::get_enabled() { return _enabled; } @@ -98,26 +100,42 @@ String EntityAI::get_editor_description() const { } void EntityAI::update(float delta) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); + #else + ERR_FAIL_COND(_owner == NULL); + #endif if (has_method("_update")) call("_update", delta); } void EntityAI::pet_update(float delta) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); + #else + ERR_FAIL_COND(_owner == NULL); + #endif if (has_method("_pet_update")) call("_pet_update", delta); } void EntityAI::move(float delta) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); + #else + ERR_FAIL_COND(_owner == NULL); + #endif if (has_method("_move")) call("_move", delta); } void EntityAI::pet_move(float delta) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); + #else + ERR_FAIL_COND(_owner == NULL); + #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 a6cddca..f5e01bb 100644 --- a/entities/auras/aura_data.cpp +++ b/entities/auras/aura_data.cpp @@ -26,6 +26,8 @@ SOFTWARE. #include "../../singletons/entity_data_manager.h" #include "../entity.h" +#include "core/version.h" + float AuraData::get_damage_count() { return _damage_already_taken; } @@ -257,7 +259,11 @@ void AuraData::set_slow(float value) { } void AuraData::resolve_references(Node *owner) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(owner)); + #else + ERR_FAIL_COND(owner == NULL); + #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 4e5c942..860872e 100644 --- a/entities/data/character_spec.cpp +++ b/entities/data/character_spec.cpp @@ -24,6 +24,8 @@ SOFTWARE. #include "../../data/auras/aura.h" +#include "core/version.h" + int CharacterSpec::get_id() { return _id; } @@ -52,7 +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 r.push_back(_rows[i].get_ref_ptr()); + #else + r.push_back(_rows[i]); + #endif } return r; } diff --git a/entities/data/entity_class_data.cpp b/entities/data/entity_class_data.cpp index 7baab02..a3d8597 100644 --- a/entities/data/entity_class_data.cpp +++ b/entities/data/entity_class_data.cpp @@ -30,6 +30,8 @@ SOFTWARE. #include "../entity.h" #include "character_spec.h" +#include "core/version.h" + int EntityClassData::get_id() { return _id; } @@ -125,7 +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 r.push_back(_entity_resources[i].get_ref_ptr()); + #else + r.push_back(_entity_resources[i]); + #endif } return r; } @@ -169,7 +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 r.push_back(_specs[i].get_ref_ptr()); + #else + r.push_back(_specs[i]); + #endif } return r; } @@ -213,7 +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 r.push_back(_spells[i].get_ref_ptr()); + #else + r.push_back(_spells[i]); + #endif } return r; } @@ -257,7 +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 r.push_back(_start_spells[i].get_ref_ptr()); + #else + r.push_back(_start_spells[i]); + #endif } return r; } @@ -301,7 +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 r.push_back(_auras[i].get_ref_ptr()); + #else + r.push_back(_auras[i]); + #endif } return r; } @@ -345,7 +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 r.push_back(_ais[i].get_ref_ptr()); + #else + r.push_back(_ais[i]); + #endif } return r; } @@ -622,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -636,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -650,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -824,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -838,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -852,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -881,7 +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 ERR_FAIL_COND_V(!ObjectDB::instance_validate(entity), false); + #else + ERR_FAIL_COND_V(entity == NULL, false); + #endif Entity *e = Object::cast_to(entity); @@ -895,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -909,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -923,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -937,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); diff --git a/entities/data/entity_data.cpp b/entities/data/entity_data.cpp index 8850d83..37378d7 100644 --- a/entities/data/entity_data.cpp +++ b/entities/data/entity_data.cpp @@ -30,6 +30,8 @@ SOFTWARE. #include "character_spec.h" #include "vendor_item_data.h" +#include "core/version.h" + int EntityData::get_id() const { return _id; } @@ -213,7 +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 r.push_back(_craft_recipes[i].get_ref_ptr()); + #else + r.push_back(_craft_recipes[i]); + #endif } return r; } @@ -266,7 +272,11 @@ String EntityData::generate_name() { //// SETUP //// void EntityData::setup_resources(Entity *entity) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif if (_entity_class_data.is_valid()) _entity_class_data->setup_resources(entity); @@ -276,7 +286,11 @@ void EntityData::setup_resources(Entity *entity) { } bool EntityData::cans_interact(Entity *entity) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(entity), false); + #else + ERR_FAIL_COND_V(entity == NULL, false); + #endif if (has_method("_cans_interact")) return call("_cans_interact", entity); @@ -285,7 +299,11 @@ bool EntityData::cans_interact(Entity *entity) { } bool EntityData::cans_interact_bind(Node *entity) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(entity), false); + #else + ERR_FAIL_COND_V(entity == NULL, false); + #endif Entity *e = Object::cast_to(entity); @@ -295,14 +313,22 @@ bool EntityData::cans_interact_bind(Node *entity) { } void EntityData::sinteract(Entity *entity) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif if (has_method("_sinteract")) call("_sinteract", entity); } void EntityData::sinteract_bind(Node *entity) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -605,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -622,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -639,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -880,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -897,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -914,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -955,7 +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 ERR_FAIL_COND_V(!ObjectDB::instance_validate(entity), false); + #else + ERR_FAIL_COND_V(entity == NULL, false); + #endif Entity *e = Object::cast_to(entity); @@ -972,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -989,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -1006,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); @@ -1023,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif Entity *e = Object::cast_to(entity); diff --git a/entities/data/item_container_data.cpp b/entities/data/item_container_data.cpp index b627c65..d334b63 100644 --- a/entities/data/item_container_data.cpp +++ b/entities/data/item_container_data.cpp @@ -22,6 +22,8 @@ SOFTWARE. #include "item_container_data.h" +#include "core/version.h" + int ItemContainerData::get_num_container_datas() { return _container_datas.size(); } @@ -43,7 +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 r.push_back(_container_datas[i].get_ref_ptr()); + #else + r.push_back(_container_datas[i]); + #endif } return r; } diff --git a/entities/data/vendor_item_data.cpp b/entities/data/vendor_item_data.cpp index 7c81b9d..631e003 100644 --- a/entities/data/vendor_item_data.cpp +++ b/entities/data/vendor_item_data.cpp @@ -22,6 +22,8 @@ SOFTWARE. #include "vendor_item_data.h" +#include "core/version.h" + int VendorItemData::get_num_vendor_datas() { return _vendor_datas.size(); } @@ -40,7 +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 r.push_back(_vendor_datas[i].get_ref_ptr()); + #else + r.push_back(_vendor_datas[i]); + #endif } return r; } diff --git a/entities/entity.cpp b/entities/entity.cpp index 80400b4..464ff51 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -39,6 +39,8 @@ SOFTWARE. #include "core/script_language.h" +#include "core/version.h" + NodePath Entity::get_body_path() { return _body_path; } @@ -47,8 +49,13 @@ void Entity::set_body_path(NodePath value) { _body = get_node_or_null(_body_path); + #if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_body)) _body->set_owner(this); + #else + if (_body == NULL) + _body->set_owner(this); + #endif } Node *Entity::get_body() { return _body; @@ -123,12 +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 ERR_FAIL_COND_V(!ObjectDB::instance_validate(e), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); + #else + ERR_FAIL_COND_V(e == NULL, EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); + #endif return gets_relation_to(e); } EntityEnums::EntityRelationType Entity::gets_relation_to(Entity *to) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(to), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); + #else + ERR_FAIL_COND_V(to == NULL, EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); + #endif return static_cast(static_cast(call("_gets_relation_to", to))); } @@ -143,12 +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 ERR_FAIL_COND_V(!ObjectDB::instance_validate(e), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); + #else + ERR_FAIL_COND_V(e == NULL, EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); + #endif return getc_relation_to(e); } EntityEnums::EntityRelationType Entity::getc_relation_to(Entity *to) { + + #if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(to), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); + #else + ERR_FAIL_COND_V(to == NULL, EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); + #endif return static_cast(static_cast(call("_getc_relation_to", to))); } @@ -235,7 +259,12 @@ EntityEnums::EntityGender Entity::getc_gender() { void Entity::setc_gender(EntityEnums::EntityGender value) { _c_gender = value; + #if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_character_skeleton)) { + #else + if (_character_skeleton != NULL) { + #endif + if (_character_skeleton->has_method("set_gender")) _character_skeleton->call("set_gender", _c_gender); } @@ -642,7 +671,7 @@ void Entity::setup_actionbars() { return; } - ProfileManager *pm = ProfileManager::get_instance(); + //ProfileManager *pm = ProfileManager::get_instance(); //if (pm != NULL) { // Ref cp = pm->get_class_profile(gets_entity_data()->get_id()); @@ -744,7 +773,11 @@ void Entity::sets_ai(Ref value) { //// Pets //// void Entity::adds_pet(Entity *entity) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif //the owner always want to see his pet, and you pet will always want to see the owner adds_sees(entity); @@ -786,12 +819,20 @@ void Entity::removes_pet_index(int index) { for (int i = 0; i < _s_pets.size(); ++i) { Entity *pet = _s_pets.get(index); - ERR_CONTINUE(!ObjectDB::instance_validate(entity)); + #if VERSION_MAJOR < 4 + ERR_CONTINUE(!ObjectDB::instance_validate(pet)); + #else + ERR_CONTINUE(pet == NULL); + #endif _s_pets.get(i)->sets_pet_formation_index(i); } + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif entity->sets_pet_owner(NULL); @@ -824,13 +865,21 @@ void Entity::addc_pet_path(NodePath path) { Entity *entity = Object::cast_to(n); + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif addc_pet(entity); } void Entity::addc_pet(Entity *entity) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif _c_pets.push_back(entity); @@ -851,11 +900,15 @@ Entity *Entity::getc_pet(int index) { void Entity::removec_pet_index(int index) { ERR_FAIL_INDEX(index, _c_pets.size()); - Entity *entity = _c_pets.get(index); + //Entity *entity = _c_pets.get(index); _c_pets.remove(index); - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + //#if VERSION_MAJOR < 4 + //ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + //#else + //ERR_FAIL_COND(entity == NULL); + //#endif //full callback stack spet_added } @@ -1991,7 +2044,12 @@ void Entity::_capply_item(Ref item) { ERR_FAIL_COND(!it.is_valid()); + #if VERSION_MAJOR < 4 if (it->get_item_visual().is_valid() && ObjectDB::instance_validate(_character_skeleton)) { + #else + if (it->get_item_visual().is_valid() && _character_skeleton == NULL) { + #endif + if (_character_skeleton->has_method("add_item_visual")) _character_skeleton->call("add_item_visual", it->get_item_visual()); } @@ -2003,7 +2061,12 @@ void Entity::_cdeapply_item(Ref item) { ERR_FAIL_COND(!it.is_valid()); + #if VERSION_MAJOR < 4 if (it->get_item_visual().is_valid() && ObjectDB::instance_validate(_character_skeleton)) { + #else + if (it->get_item_visual().is_valid() && _character_skeleton == NULL) { + #endif + if (_character_skeleton->has_method("remove_item_visual")) _character_skeleton->call("remove_item_visual", it->get_item_visual()); } @@ -2382,7 +2445,12 @@ bool Entity::canc_interact() { return call("_canc_interact"); } + #if VERSION_MAJOR < 4 if (!ObjectDB::instance_validate(_c_target)) { + #else + if (_c_target == NULL) { + #endif + return false; } @@ -3500,7 +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 (!ObjectDB::instance_validate(caster)) { + #else + if (caster == NULL) { + #endif + return Ref(); } @@ -4605,8 +4678,13 @@ void Entity::adds_skill(Ref skill) { if (hass_skill(skill)) return; + #if VERSION_MAJOR < 4 skill->connect("current_changed", this, "sskill_current_changed"); skill->connect("max_changed", this, "sskill_max_changed"); + #else + skill->connect("current_changed", callable_mp(this, &Entity::sskill_current_changed)); + skill->connect("max_changed", callable_mp(this, &Entity::sskill_max_changed)); + #endif _s_skills.push_back(skill); @@ -4832,7 +4910,12 @@ Entity *Entity::gets_target() { void Entity::sets_target(Node *p_target) { Entity *original_target = _s_target; + #if VERSION_MAJOR < 4 if (!ObjectDB::instance_validate(original_target)) { + #else + if (original_target == NULL) { + #endif + original_target = NULL; _s_target = NULL; } @@ -4882,7 +4965,12 @@ Entity *Entity::getc_target() { void Entity::setc_target(Node *p_target) { Entity *original_target = _c_target; + #if VERSION_MAJOR < 4 if (!ObjectDB::instance_validate(original_target)) { + #else + if (original_target == NULL) { + #endif + original_target = NULL; _c_target = NULL; } @@ -5152,23 +5240,41 @@ Ref Entity::gets_bag() const { } void Entity::sets_bag(const Ref bag) { if (_s_bag.is_valid()) { + #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 + _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 } _s_bag = bag; if (_s_bag.is_valid()) { + #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 + _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 } emit_signal("sbag_changed", this, _s_bag); @@ -5194,19 +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 _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 + _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 } _s_target_bag = bag; if (_s_target_bag.is_valid()) { + #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 + _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 } emit_signal("starget_bag_changed", this, _s_target_bag); @@ -5602,7 +5722,12 @@ Entity *Entity::gets_sees(int index) { void Entity::removes_sees_index(int index) { Entity *e = _s_sees.get(index); + #if VERSION_MAJOR < 4 if (unlikely(!ObjectDB::instance_validate(e))) { + #else + if (e == NULL) { + #endif + _s_sees.remove(index); return; } @@ -5612,7 +5737,12 @@ void Entity::removes_sees_index(int index) { _s_sees.remove(index); } void Entity::removes_sees(Entity *entity) { + #if VERSION_MAJOR < 4 if (unlikely(!ObjectDB::instance_validate(entity))) { + #else + if (entity == NULL) { + #endif + _s_sees.erase(entity); return; } @@ -5629,7 +5759,11 @@ void Entity::removes_sees_bind(Node *entity) { removes_sees(e); } void Entity::adds_sees(Entity *entity) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif entity->adds_seen_by(this); @@ -5670,7 +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 ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); + #else + ERR_FAIL_COND(entity == NULL); + #endif for (int i = 0; i < _s_seen_by.size(); ++i) { if (_s_seen_by.get(i) == entity) @@ -5705,7 +5843,12 @@ 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 (unlikely(!ObjectDB::instance_validate(e))) { + #else + if (e == NULL) { + #endif + _s_seen_by.remove(i); --i; continue; @@ -5721,16 +5864,30 @@ void Entity::vrpc(const StringName &p_method, VARIANT_ARG_DECLARE) { rpcp(get_network_master(), false, p_method, argptr, argc); } +#if VERSION_MAJOR < 4 Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { +#else +Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { +#endif if (p_argcount < 1) { + #if VERSION_MAJOR < 4 r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; + #else + r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; + #endif + r_error.argument = 1; return Variant(); } if (p_args[0]->get_type() != Variant::STRING) { + #if VERSION_MAJOR < 4 r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + #else + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + #endif + r_error.argument = 0; r_error.expected = Variant::STRING; return Variant(); @@ -5741,7 +5898,12 @@ Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Variant::Call for (int i = 0; i < _s_seen_by.size(); ++i) { Entity *e = _s_seen_by.get(i); + #if VERSION_MAJOR < 4 if (unlikely(!ObjectDB::instance_validate(e))) { + #else + if (unlikely(e == NULL)) { + #endif + _s_seen_by.remove(i); --i; continue; @@ -5755,7 +5917,12 @@ Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Variant::Call //call(method, &p_args[1], p_argcount - 1); + #if VERSION_MAJOR < 4 r_error.error = Variant::CallError::CALL_OK; + #else + r_error.error = Callable::CallError::CALL_OK; + #endif + return Variant(); } @@ -6241,13 +6408,21 @@ void Entity::_moved() { } void Entity::_con_target_changed(Node *p_entity, Node *p_old_target) { - Entity *entity = Object::cast_to(p_entity); + //Entity *entity = Object::cast_to(p_entity); Entity *old_target = Object::cast_to(p_old_target); + #if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(old_target)) old_target->onc_untargeted(); if (ObjectDB::instance_validate(getc_target())) { + #else + if (old_target != NULL) + old_target->onc_untargeted(); + + if (getc_target() != NULL) { + #endif + getc_target()->onc_targeted(); if (canc_interact()) @@ -6297,8 +6472,9 @@ void Entity::_son_death() { } void Entity::_slearn_spell(int id) { - if (EntityDataManager::get_instance()->get_use_spell_points()) + if (EntityDataManager::get_instance()->get_use_spell_points()) { ERR_FAIL_COND(gets_free_spell_points() <= 0); + } ERR_FAIL_COND(!_s_entity_data.is_valid()); @@ -6334,8 +6510,13 @@ void Entity::_notification(int p_what) { case NOTIFICATION_INSTANCED: { _body = get_node_or_null(_body_path); + #if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_body)) _body->set_owner(this); + #else + if (_body != NULL) + _body->set_owner(this); + #endif _character_skeleton = get_node_or_null(_character_skeleton_path); @@ -6351,8 +6532,13 @@ void Entity::_notification(int p_what) { if (!_body) { _body = get_node_or_null(_body_path); + #if VERSION_MAJOR < 4 if (ObjectDB::instance_validate(_body)) _body->set_owner(this); + #else + if (_body != NULL) + _body->set_owner(this); + #endif } if (!_character_skeleton) { @@ -6375,9 +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 (ObjectDB::instance_validate(e)) { + #if VERSION_MAJOR < 4 + if (ObjectDB::instance_validate(e)) e->removes_sees(this); - } + #else + if (e != NULL) + e->removes_sees(this); + #endif } } break; } diff --git a/entities/entity.h b/entities/entity.h index f456951..c57c76d 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -56,6 +56,8 @@ SOFTWARE. #include "../data/auras/aura_group.h" +#include "core/version.h" + class EntityData; class AuraData; class Spell; @@ -970,7 +972,12 @@ public: int gets_seen_by_count(); void vrpc(const StringName &p_method, VARIANT_ARG_LIST); + #if VERSION_MAJOR < 4 Variant _vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error); + #else + Variant _vrpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error); + #endif + Dictionary data_as_dict(String &data); diff --git a/entities/stats/stat.cpp b/entities/stats/stat.cpp index e46ac05..aecf9cd 100644 --- a/entities/stats/stat.cpp +++ b/entities/stats/stat.cpp @@ -25,6 +25,8 @@ SOFTWARE. #include "../entity.h" #include "stat_data_entry.h" +#include "core/version.h" + const String Stat::STAT_BINDING_STRING = "Health,Speed,Mana,GCD,Haste,Agility,Strength,Stamina,Intellect,Spirit,Haste Rating,Resilience,Armor,Attack Power,Spell Power,Melee Crit,Melee Crit bonus,Spell Crit,Spell Crit Bonus,Block,Parry,Damage Reduction,Melee Damage Reduction,Spell Damage Reduction,Damage Taken,Heal Taken,Melee Damage,Spell Damage,Holy Resist,Shadow Resist,Nature Resist,Fire Resist,Frost Resist,Lightning Resist,Chaos Resist,Silence Resist,Fear Resist,Stun Resist,Energy,Rage,XP Rate,None"; const String Stat::MAIN_STAT_BINDING_STRING = "Agility,Strength,Stamina,Intellect,Spirit"; @@ -327,7 +329,11 @@ void Stat::remove_modifier_index(int index) { } void Stat::apply_modifiers() { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(_owner)); + #else + ERR_FAIL_COND(_owner == NULL); + #endif ERR_FAIL_COND(!_stat_data_entry.is_valid()); reset_values(); diff --git a/entities/stats/stat_data_entry.cpp b/entities/stats/stat_data_entry.cpp index 7e4cefb..9e1a304 100644 --- a/entities/stats/stat_data_entry.cpp +++ b/entities/stats/stat_data_entry.cpp @@ -22,6 +22,12 @@ SOFTWARE. #include "stat_data_entry.h" +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#define REAL FLOAT +#endif + Stat::StatId StatDataEntry::get_stat_id() { return _stat_id; } diff --git a/entities/stats/stat_modifier.cpp b/entities/stats/stat_modifier.cpp index dfe8897..f110937 100644 --- a/entities/stats/stat_modifier.cpp +++ b/entities/stats/stat_modifier.cpp @@ -24,6 +24,12 @@ SOFTWARE. #include "stat.h" +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#define REAL FLOAT +#endif + Ref StatModifier::get_owner() { return Ref(_owner); } diff --git a/formations/ai_formation.cpp b/formations/ai_formation.cpp index 0a050ad..40e6582 100644 --- a/formations/ai_formation.cpp +++ b/formations/ai_formation.cpp @@ -24,6 +24,8 @@ SOFTWARE. #include "../entities/entity.h" +#include "core/version.h" + void AIFormation::set_owner(Entity *entity) { _owner = entity; @@ -60,7 +62,12 @@ String AIFormation::get_editor_description() const { } Vector3 AIFormation::get_position(int slot_index) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(_owner), Vector3()); + #else + ERR_FAIL_COND_V(_owner == NULL, Vector3()); + #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 ee9d4a3..6816703 100644 --- a/infos/spell_cast_info.cpp +++ b/infos/spell_cast_info.cpp @@ -28,12 +28,16 @@ SOFTWARE. #include "../entities/entity.h" #include "../singletons/entity_data_manager.h" +#include "core/version.h" + //// SpellCastInfo //// Entity *SpellCastInfo::get_caster() { + #if VERSION_MAJOR < 4 if (_caster && !ObjectDB::instance_validate(_caster)) { _caster = NULL; } + #endif return _caster; } @@ -55,9 +59,12 @@ void SpellCastInfo::set_caster_bind(Node *caster) { } Entity *SpellCastInfo::get_target() { + #if VERSION_MAJOR < 4 if (_target && !ObjectDB::instance_validate(_target)) { _target = NULL; } + #endif + return _target; } @@ -160,7 +167,12 @@ void SpellCastInfo::physics_process(float delta) { } void SpellCastInfo::resolve_references(Node *owner) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(owner)); + #else + ERR_FAIL_COND(owner == NULL); + #endif + ERR_FAIL_COND(!owner->is_inside_tree()); _caster = Object::cast_to(owner); @@ -179,11 +191,19 @@ void SpellCastInfo::resolve_references(Node *owner) { Dictionary SpellCastInfo::to_dict() { Dictionary dict; + #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 + if (_caster == NULL) + dict["caster"] = _caster->get_path(); + + if (_target == NULL) + dict["target"] = _target->get_path(); + #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 38d0e93..0eaf4df 100644 --- a/pipelines/spell_damage_info.cpp +++ b/pipelines/spell_damage_info.cpp @@ -27,6 +27,8 @@ SOFTWARE. #include "../entities/entity.h" #include "../singletons/entity_data_manager.h" +#include "core/version.h" + bool SpellDamageInfo::get_immune() { return _crit; } @@ -162,7 +164,11 @@ void SpellDamageInfo::reset() { } void SpellDamageInfo::resolve_references(Node *owner) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(owner)); + #else + ERR_FAIL_COND(owner == NULL); + #endif ERR_FAIL_COND(!owner->is_inside_tree()); _dealer = Object::cast_to(owner->get_node_or_null(_dealer_path)); @@ -178,11 +184,19 @@ void SpellDamageInfo::resolve_references(Node *owner) { Dictionary SpellDamageInfo::to_dict() { Dictionary dict; + #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 + if (_dealer != NULL) + dict["dealer_path"] = _dealer->get_path(); + + if (_receiver != NULL) + dict["receiver_path"] = _receiver->get_path(); + #endif dict["immune"] = _immune; dict["damage"] = _damage; diff --git a/pipelines/spell_heal_info.cpp b/pipelines/spell_heal_info.cpp index 89854d8..26681df 100644 --- a/pipelines/spell_heal_info.cpp +++ b/pipelines/spell_heal_info.cpp @@ -27,6 +27,8 @@ SOFTWARE. #include "../entities/entity.h" #include "../singletons/entity_data_manager.h" +#include "core/version.h" + bool SpellHealInfo::get_immune() { return _immune; } @@ -158,7 +160,11 @@ void SpellHealInfo::reset() { } void SpellHealInfo::resolve_references(Node *owner) { + #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(owner)); + #else + ERR_FAIL_COND(owner == NULL); + #endif ERR_FAIL_COND(!owner->is_inside_tree()); _dealer = Object::cast_to(owner->get_node_or_null(_dealer_path)); @@ -174,11 +180,19 @@ void SpellHealInfo::resolve_references(Node *owner) { Dictionary SpellHealInfo::to_dict() { Dictionary dict; + #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 + if (_dealer == NULL) + dict["dealer_path"] = _dealer->get_path(); + + if (_receiver == NULL) + dict["receiver_path"] = _receiver->get_path(); + #endif dict["immune"] = _immune; dict["heal"] = _heal; diff --git a/profiles/actionbar/action_bar_entry.cpp b/profiles/actionbar/action_bar_entry.cpp index e1cb450..2c76198 100644 --- a/profiles/actionbar/action_bar_entry.cpp +++ b/profiles/actionbar/action_bar_entry.cpp @@ -24,6 +24,12 @@ SOFTWARE. #include "action_bar_profile.h" +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#define REAL FLOAT +#endif + Ref ActionBarEntry::get_owner() { return Ref(_owner); } diff --git a/profiles/player_profile.cpp b/profiles/player_profile.cpp index d0aaf6e..4e995c5 100644 --- a/profiles/player_profile.cpp +++ b/profiles/player_profile.cpp @@ -22,6 +22,8 @@ SOFTWARE. #include "player_profile.h" +#include "core/version.h" + const String PlayerProfile::DEFAULT_PROFILE_FILE_NAME = "default.profile"; int PlayerProfile::get_id() { @@ -59,7 +61,11 @@ Ref PlayerProfile::get_class_profile_index(const int index) { } void PlayerProfile::add_class_profile(Ref profile) { + #if VERSION_MAJOR < 4 profile->connect("changed", this, "_on_class_profile_changed"); + #else + profile->connect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); + #endif _class_profiles.push_back(profile); @@ -68,7 +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 _class_profiles.get(i)->disconnect("changed", this, "_on_class_profile_changed"); + #else + _class_profiles.get(i)->disconnect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); + #endif } _class_profiles.clear(); @@ -77,7 +87,13 @@ void PlayerProfile::clear_class_profiles() { } void PlayerProfile::remove_class_profile(const int index) { + + + #if VERSION_MAJOR < 4 _class_profiles.get(index)->disconnect("changed", this, "_on_class_profile_changed"); + #else + _class_profiles.get(index)->disconnect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); + #endif _class_profiles.remove(index); @@ -98,7 +114,12 @@ Ref PlayerProfile::get_class_profile(const int class_id) { Ref class_profile = Ref(memnew(ClassProfile(class_id))); class_profile->load_defaults(); + + #if VERSION_MAJOR < 4 class_profile->connect("changed", this, "_on_class_profile_changed"); + #else + class_profile->connect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); + #endif _class_profiles.push_back(Ref(class_profile)); @@ -155,7 +176,12 @@ void PlayerProfile::from_dict(const Dictionary &dict) { c.instance(); c->from_dict(arr.get(i)); + + #if VERSION_MAJOR < 4 c->connect("changed", this, "_on_class_profile_changed"); + #else + c->connect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); + #endif _class_profiles.push_back(c); } @@ -187,7 +213,12 @@ void PlayerProfile::load_defaults() { for (int i = 0; i < _class_profiles.size(); ++i) { _class_profiles.get(i)->load_defaults(); + + #if VERSION_MAJOR < 4 _class_profiles.get(i)->connect("changed", this, "_on_class_profile_changed"); + #else + _class_profiles.get(i)->connect("changed", callable_mp(this, &PlayerProfile::_on_class_profile_changed)); + #endif } emit_change(); diff --git a/projectiles/3d/spell_follow_projectile_3d.h b/projectiles/3d/spell_follow_projectile_3d.h index 8d580b1..4a0b1cb 100644 --- a/projectiles/3d/spell_follow_projectile_3d.h +++ b/projectiles/3d/spell_follow_projectile_3d.h @@ -23,7 +23,15 @@ SOFTWARE. #ifndef SPELL_PROJECTILE_3D #define SPELL_PROJECTILE_3D +#include "core/version.h" + +#if VERSION_MAJOR < 4 #include "scene/3d/spatial.h" +#else +#include "scene/3d/node_3d.h" + +typedef class Node3D Spatial; +#endif class SpellCastInfo; diff --git a/singletons/entity_data_manager.cpp b/singletons/entity_data_manager.cpp index 0161a40..ca50594 100644 --- a/singletons/entity_data_manager.cpp +++ b/singletons/entity_data_manager.cpp @@ -450,6 +450,7 @@ void EntityDataManager::load_xp_data() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(_xp_data_path, "XPData"); ERR_FAIL_COND(!resl.is_valid()); @@ -457,6 +458,9 @@ void EntityDataManager::load_xp_data() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(_xp_data_path, "XPData"); + #endif ERR_FAIL_COND(!s.is_valid()); @@ -489,6 +493,7 @@ void EntityDataManager::load_entity_resources() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntityResourceData"); ERR_CONTINUE(!resl.is_valid()); @@ -496,6 +501,9 @@ void EntityDataManager::load_entity_resources() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "EntityResourceData"); + #endif ERR_CONTINUE(!s.is_valid()); @@ -533,6 +541,7 @@ void EntityDataManager::load_entity_skills() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntitySkillData"); ERR_CONTINUE(!resl.is_valid()); @@ -540,6 +549,9 @@ void EntityDataManager::load_entity_skills() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "EntitySkillData"); + #endif ERR_CONTINUE(!s.is_valid()); @@ -577,6 +589,7 @@ void EntityDataManager::load_spells() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "Spell"); ERR_CONTINUE(!resl.is_valid()); @@ -584,6 +597,9 @@ void EntityDataManager::load_spells() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "Spell"); + #endif ERR_CONTINUE(!s.is_valid()); @@ -621,6 +637,7 @@ void EntityDataManager::load_auras() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "Aura"); ERR_CONTINUE(!resl.is_valid()); @@ -628,6 +645,9 @@ void EntityDataManager::load_auras() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "Aura"); + #endif ERR_CONTINUE(!s.is_valid()); @@ -665,6 +685,7 @@ void EntityDataManager::load_characters() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntityData"); ERR_CONTINUE(!resl.is_valid()); @@ -672,6 +693,9 @@ void EntityDataManager::load_characters() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "EntityData"); + #endif ERR_CONTINUE(!s.is_valid()); @@ -709,6 +733,7 @@ void EntityDataManager::load_craft_datas() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "CraftRecipe"); ERR_CONTINUE(!resl.is_valid()); @@ -716,6 +741,9 @@ void EntityDataManager::load_craft_datas() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "CraftRecipe"); + #endif ERR_CONTINUE(!s.is_valid()); @@ -753,6 +781,7 @@ void EntityDataManager::load_item_templates() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "ItemTemplate"); ERR_CONTINUE(!resl.is_valid()); @@ -760,6 +789,9 @@ void EntityDataManager::load_item_templates() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "ItemTemplate"); + #endif ERR_CONTINUE(!s.is_valid()); @@ -797,6 +829,7 @@ void EntityDataManager::load_mob_datas() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntityData"); ERR_CONTINUE(!resl.is_valid()); @@ -804,6 +837,9 @@ void EntityDataManager::load_mob_datas() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "EntityData"); + #endif ERR_CONTINUE(!s.is_valid()); @@ -841,6 +877,7 @@ void EntityDataManager::load_player_character_datas() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntityData"); ERR_CONTINUE(!resl.is_valid()); @@ -848,7 +885,10 @@ void EntityDataManager::load_player_character_datas() { resl->wait(); Ref s = resl->get_resource(); - + #else + Ref s = rl->load(path, "EntityData"); + #endif + ERR_CONTINUE(!s.is_valid()); Ref pcd = s; @@ -885,6 +925,7 @@ void EntityDataManager::load_entity_species_datas() { _ResourceLoader *rl = _ResourceLoader::get_singleton(); + #if VERSION_MAJOR < 4 Ref resl = rl->load_interactive(path, "EntitySpeciesData"); ERR_CONTINUE(!resl.is_valid()); @@ -892,6 +933,9 @@ void EntityDataManager::load_entity_species_datas() { resl->wait(); Ref s = resl->get_resource(); + #else + Ref s = rl->load(path, "EntitySpeciesData"); + #endif ERR_CONTINUE(!s.is_valid()); diff --git a/singletons/profile_manager.cpp b/singletons/profile_manager.cpp index b191c09..63f077b 100644 --- a/singletons/profile_manager.cpp +++ b/singletons/profile_manager.cpp @@ -25,6 +25,8 @@ SOFTWARE. #include "core/os/file_access.h" #include "core/project_settings.h" +#include "core/version.h" + ProfileManager *ProfileManager::_instance; ProfileManager *ProfileManager::get_instance() { @@ -164,9 +166,15 @@ void ProfileManager::from_dict(const Dictionary &dict) { clears_player_profiles(); + #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 + _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 Array arr = dict.get("splayer_profiles", Array()); @@ -175,7 +183,12 @@ void ProfileManager::from_dict(const Dictionary &dict) { c.instance(); c->from_dict(arr.get(i)); - c->connect("changed", this, "_on_class_profile_changed"); + + #if VERSION_MAJOR < 4 + c->connect("changed", this, "_on_player_profile_changed"); + #else + c->connect("changed", callable_mp(this, &ProfileManager::_on_player_profile_changed)); + #endif _s_player_profiles.push_back(c); } @@ -189,7 +202,12 @@ ProfileManager::ProfileManager() { _save_file = GLOBAL_DEF("ess/profiles/save_file", "user://profile.save"); _c_player_profile.instance(); + + #if VERSION_MAJOR < 4 _c_player_profile->connect("changed", this, "_on_player_profile_changed"); + #else + _c_player_profile->connect("changed", callable_mp(this, &ProfileManager::_on_player_profile_changed)); + #endif if (_automatic_load) call_deferred("load"); @@ -197,8 +215,12 @@ ProfileManager::ProfileManager() { ProfileManager::~ProfileManager() { _instance = NULL; - + + #if VERSION_MAJOR < 4 _c_player_profile->disconnect("changed", this, "_on_player_profile_changed"); + #else + _c_player_profile->disconnect("changed", callable_mp(this, &ProfileManager::_on_player_profile_changed)); + #endif _s_player_profiles.clear(); } diff --git a/skeleton/character_skeleton_3d.cpp b/skeleton/character_skeleton_3d.cpp index f329651..7ecdb14 100644 --- a/skeleton/character_skeleton_3d.cpp +++ b/skeleton/character_skeleton_3d.cpp @@ -24,6 +24,21 @@ SOFTWARE. #include "../data/items/item_visual.h" +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#include "servers/rendering_server.h" + +typedef class RenderingServer VisualServer; +typedef class RenderingServer VS; + +#define PoolVector3Array PackedVector3Array +#define PoolVector2Array PackedVector2Array +#define PoolColorArray PackedColorArray +#define PoolIntArray PackedInt32Array +#define PoolRealArray PackedFloat32Array +#endif + EntityEnums::EntityGender CharacterSkeleton3D::get_gender() { return _gender; } @@ -325,7 +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 img->lock(); + #endif for (int i = 0; i < uvs.size(); ++i) { Vector2 uv = uvs[i]; @@ -336,7 +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 img->unlock(); + #endif arr[VisualServer::ARRAY_COLOR] = colors; diff --git a/skeleton/character_skeleton_3d.h b/skeleton/character_skeleton_3d.h index b59b2d4..e0ee072 100644 --- a/skeleton/character_skeleton_3d.h +++ b/skeleton/character_skeleton_3d.h @@ -37,6 +37,16 @@ SOFTWARE. #include "../data/items/item_visual_entry.h" +#include "core/version.h" + +#if VERSION_MAJOR < 4 +#include "scene/3d/spatial.h" +#else +#include "scene/3d/node_3d.h" +#define Spatial Node3D +#define Texture Texture2D +#endif + class ItemVisual; //Rename to HumanoidCharSkeleton -> maybe make that a subclass? diff --git a/utility/category_cooldown.cpp b/utility/category_cooldown.cpp index a01f165..213e231 100644 --- a/utility/category_cooldown.cpp +++ b/utility/category_cooldown.cpp @@ -22,6 +22,12 @@ SOFTWARE. #include "category_cooldown.h" +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#define REAL FLOAT +#endif + int CategoryCooldown::get_category_id() const { return _category_id; } diff --git a/utility/cooldown.cpp b/utility/cooldown.cpp index 14ce58e..5f93376 100644 --- a/utility/cooldown.cpp +++ b/utility/cooldown.cpp @@ -22,6 +22,12 @@ SOFTWARE. #include "cooldown.h" +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#define REAL FLOAT +#endif + int Cooldown::get_spell_id() const { return _spell_id; }