diff --git a/data/auras/aura.cpp b/data/auras/aura.cpp index 73d722e..c941098 100644 --- a/data/auras/aura.cpp +++ b/data/auras/aura.cpp @@ -25,13 +25,7 @@ SOFTWARE. #include "../../entities/resources/entity_resource_cost_data.h" #include "../../singletons/ess.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define PoolStringArray PackedStringArray - -#define POOL_STRING_ARRAY PACKED_STRING_ARRAY -#endif +#include "../../defines.h" int Aura::get_id() const { return _id; @@ -1094,11 +1088,7 @@ 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(info->get_caster())); data->set_aura(Ref(this)); data->set_aura_id(get_id()); @@ -1134,22 +1124,14 @@ 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(info->get_dealer())); 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(info->get_dealer())); info->get_dealer()->sdeal_damage_to(info); } @@ -1167,22 +1149,14 @@ 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(info->get_dealer())); 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(info->get_dealer())); info->get_dealer()->sdeal_heal_to(info); } diff --git a/data/items/item_stat_modifier.h b/data/items/item_stat_modifier.h index fe32e23..150c486 100644 --- a/data/items/item_stat_modifier.h +++ b/data/items/item_stat_modifier.h @@ -25,11 +25,7 @@ SOFTWARE. #include "core/reference.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define REAL FLOAT -#endif +#include "../../defines.h" class ItemStatModifier : public Reference { GDCLASS(ItemStatModifier, Reference); diff --git a/data/items/item_template.cpp b/data/items/item_template.cpp index bc80af2..ae30ef8 100644 --- a/data/items/item_template.cpp +++ b/data/items/item_template.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "../../singletons/ess.h" -#include "core/version.h" +#include "../../defines.h" int ItemTemplate::get_id() const { return _id; @@ -178,23 +178,10 @@ 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; + VARIANT_ARRAY_GET(_teaches_spells); } void ItemTemplate::set_teaches_spells(const Vector &spells) { - _teaches_spells.clear(); - for (int i = 0; i < spells.size(); i++) { - Ref spell = Ref(spells[i]); - - _teaches_spells.push_back(spell); - } + VARIANT_ARRAY_SET(spells, _teaches_spells, Spell); } //// GRANTS SPELLS //// @@ -218,23 +205,10 @@ 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; + VARIANT_ARRAY_GET(_grants_spells); } void ItemTemplate::set_grants_spells(const Vector &spells) { - _grants_spells.clear(); - for (int i = 0; i < spells.size(); i++) { - Ref spell = Ref(spells[i]); - - _grants_spells.push_back(spell); - } + VARIANT_ARRAY_SET(spells, _grants_spells, Spell); } //// AURAS //// @@ -258,23 +232,10 @@ 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; + VARIANT_ARRAY_GET(_auras); } void ItemTemplate::set_auras(const Vector &auras) { - _auras.clear(); - for (int i = 0; i < auras.size(); i++) { - Ref spell = Ref(auras[i]); - - _auras.push_back(spell); - } + VARIANT_ARRAY_SET(auras, _auras, Aura); } //Required Skills @@ -294,23 +255,10 @@ 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; + VARIANT_ARRAY_GET(_required_skills); } void ItemTemplate::set_required_skills(const Vector &skills) { - _required_skills.clear(); - for (int i = 0; i < skills.size(); i++) { - Ref skill = Ref(skills[i]); - - _required_skills.push_back(skill); - } + VARIANT_ARRAY_SET(skills, _required_skills, Aura); } //use spell diff --git a/data/items/item_template_stat_modifier.h b/data/items/item_template_stat_modifier.h index fc07bde..62402cd 100644 --- a/data/items/item_template_stat_modifier.h +++ b/data/items/item_template_stat_modifier.h @@ -25,11 +25,7 @@ SOFTWARE. #include "core/reference.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define REAL FLOAT -#endif +#include "../../defines.h" class ItemTemplateStatModifier : public Reference { GDCLASS(ItemTemplateStatModifier, Reference); diff --git a/data/items/model_visual.cpp b/data/items/model_visual.cpp index e931f9a..98bddb1 100644 --- a/data/items/model_visual.cpp +++ b/data/items/model_visual.cpp @@ -24,6 +24,8 @@ SOFTWARE. #include "../../singletons/ess.h" +#include "../../defines.h" + int ModelVisual::get_layer() { return _layer; } @@ -57,23 +59,10 @@ int ModelVisual::get_visual_entry_count() const { } Vector ModelVisual::get_visual_entries() { - Vector r; - for (int i = 0; i < _visual_entries.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_visual_entries[i].get_ref_ptr()); -#else - r.push_back(_visual_entries[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_visual_entries); } void ModelVisual::set_visual_entries(const Vector &visual_entries) { - _visual_entries.clear(); - for (int i = 0; i < visual_entries.size(); i++) { - Ref visual_entry = Ref(visual_entries[i]); - - _visual_entries.push_back(visual_entry); - } + VARIANT_ARRAY_SET(visual_entries, _visual_entries, ModelVisualEntry); } ModelVisual::ModelVisual() { diff --git a/data/species/entity_species_data.cpp b/data/species/entity_species_data.cpp index 80bebcc..73401aa 100644 --- a/data/species/entity_species_data.cpp +++ b/data/species/entity_species_data.cpp @@ -74,23 +74,10 @@ int EntitySpeciesData::get_model_data_count() const { } Vector EntitySpeciesData::get_model_datas() { - Vector r; - for (int i = 0; i < _model_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_model_datas[i].get_ref_ptr()); -#else - r.push_back(_model_datas[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_model_datas); } void EntitySpeciesData::set_model_datas(const Vector &model_datas) { - _model_datas.clear(); - for (int i = 0; i < model_datas.size(); i++) { - Ref model_data = Ref(model_datas[i]); - - _model_datas.push_back(model_data); - } + VARIANT_ARRAY_SET(model_datas, _model_datas, SpeciesModelData); } //Spells @@ -119,23 +106,10 @@ 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; + VARIANT_ARRAY_GET(_spells); } void EntitySpeciesData::set_spells(const Vector &spells) { - _spells.clear(); - for (int i = 0; i < spells.size(); i++) { - Ref spell = Ref(spells[i]); - - _spells.push_back(spell); - } + VARIANT_ARRAY_SET(spells, _spells, Spell); } //Auras @@ -164,15 +138,7 @@ 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; + VARIANT_ARRAY_GET(_auras); } void EntitySpeciesData::set_auras(const Vector &auras) { _auras.clear(); diff --git a/data/species/species_model_data.cpp b/data/species/species_model_data.cpp index fd3f665..0a91681 100644 --- a/data/species/species_model_data.cpp +++ b/data/species/species_model_data.cpp @@ -26,6 +26,8 @@ SOFTWARE. #include "../../singletons/ess.h" +#include "../../defines.h" + int SpeciesModelData::get_id() { return _id; } @@ -75,15 +77,7 @@ int SpeciesModelData::get_visual_count(const int bone_index) const { Vector SpeciesModelData::get_visuals(const int bone_index) { ERR_FAIL_INDEX_V(bone_index, EntityEnums::SKELETON_POINTS_MAX, Vector()); - 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; + VARIANT_ARRAY_GET(_visuals[bone_index]); } void SpeciesModelData::set_visuals(const int bone_index, const Vector &visuals) { ERR_FAIL_INDEX(bone_index, EntityEnums::SKELETON_POINTS_MAX); @@ -204,23 +198,10 @@ 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; + VARIANT_ARRAY_GET(_hair_styles); } void SpeciesModelData::set_hair_styles(const Vector &hair_styles) { - _hair_styles.clear(); - for (int i = 0; i < hair_styles.size(); i++) { - Ref hair_style = Ref(hair_styles[i]); - - _hair_styles.push_back(hair_style); - } + VARIANT_ARRAY_SET(hair_styles, _hair_styles, ModelVisualEntry); } //HairColors @@ -290,23 +271,10 @@ 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; + VARIANT_ARRAY_GET(_heads); } void SpeciesModelData::set_heads(const Vector &heads) { - _heads.clear(); - for (int i = 0; i < heads.size(); i++) { - Ref head = Ref(heads[i]); - - _heads.push_back(head); - } + VARIANT_ARRAY_SET(heads, _heads, ModelVisualEntry); } SpeciesModelData::SpeciesModelData() { diff --git a/data/spells/spell.cpp b/data/spells/spell.cpp index b5bbad8..4d2079f 100644 --- a/data/spells/spell.cpp +++ b/data/spells/spell.cpp @@ -34,7 +34,7 @@ SOFTWARE. #include "../../pipelines/spell_damage_info.h" #include "../../pipelines/spell_heal_info.h" -#include "core/version.h" +#include "../../defines.h" int Spell::get_id() const { return _id; @@ -204,23 +204,10 @@ 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; + VARIANT_ARRAY_GET(_caster_aura_applys); } void Spell::set_caster_aura_applys(const Vector &caster_aura_applys) { - _caster_aura_applys.clear(); - for (int i = 0; i < caster_aura_applys.size(); i++) { - Ref aura = Ref(caster_aura_applys[i]); - - _caster_aura_applys.push_back(aura); - } + VARIANT_ARRAY_SET(caster_aura_applys, _caster_aura_applys, Aura); } //// Target Aura Apply //// @@ -244,23 +231,10 @@ 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; + VARIANT_ARRAY_GET(_target_aura_applys); } void Spell::set_target_aura_applys(const Vector &target_aura_applys) { - _target_aura_applys.clear(); - for (int i = 0; i < target_aura_applys.size(); i++) { - Ref aura = Ref(target_aura_applys[i]); - - _target_aura_applys.push_back(aura); - } + VARIANT_ARRAY_SET(target_aura_applys, _target_aura_applys, Aura); } //// Apply Auras On Learn //// @@ -284,23 +258,10 @@ 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; + VARIANT_ARRAY_GET(_on_learn_auras); } void Spell::set_on_learn_auras(const Vector &on_learn_aura_applys) { - _on_learn_auras.clear(); - for (int i = 0; i < on_learn_aura_applys.size(); i++) { - Ref aura = Ref(on_learn_aura_applys[i]); - - _on_learn_auras.push_back(aura); - } + VARIANT_ARRAY_SET(on_learn_aura_applys, _on_learn_auras, Aura); } //// Range //// @@ -574,11 +535,7 @@ void Spell::set_training_required_skill_level(const int value) { //// Spell System //// void Spell::cast_starts_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 + ERR_FAIL_COND(!caster || !INSTANCE_VALIDATE(caster)); Ref info = Ref(memnew(SpellCastInfo())); @@ -593,11 +550,7 @@ void Spell::cast_starts_simple(Entity *caster, float spell_scale) { } void Spell::cast_interrupts_simple(Entity *caster) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!caster || !ObjectDB::instance_validate(caster)); -#else - ERR_FAIL_COND(!caster || caster == NULL); -#endif + ERR_FAIL_COND(!caster || !INSTANCE_VALIDATE(caster)); Ref info(memnew(SpellCastInfo())); @@ -608,11 +561,7 @@ void Spell::cast_interrupts_simple(Entity *caster) { } void Spell::cast_starts_triggered_simple(Entity *caster) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!caster || !ObjectDB::instance_validate(caster)); -#else - ERR_FAIL_COND(!caster || caster == NULL); -#endif + ERR_FAIL_COND(!caster || !INSTANCE_VALIDATE(caster)); Ref info(memnew(SpellCastInfo())); @@ -954,11 +903,7 @@ void Spell::_cast_finishs(Ref info) { info->get_caster()->notification_scast(SpellEnums::NOTIFICATION_CAST_FINISHED, info); info->get_caster()->cast_spell_successs(info); -#if VERSION_MAJOR < 4 - if (ObjectDB::instance_validate(info->get_target())) { -#else - if (info->get_target() != NULL) { -#endif + if (INSTANCE_VALIDATE(info->get_target())) { info->get_target()->notification_scast(SpellEnums::NOTIFICATION_CAST_FINISHED_TARGET, info); } @@ -1011,11 +956,7 @@ 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(p)); p->add_child(projectile); @@ -1025,7 +966,6 @@ void Spell::_handle_projectile(Ref info) { } void Spell::_handle_effect(Ref info) { - /* # var ok : bool = false @@ -1042,11 +982,7 @@ 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 + bool has_target = INSTANCE_VALIDATE(info->get_target()); if (_target_type == SPELL_TARGET_TYPE_TARGET) { if (!has_target) diff --git a/database/ess_resource_db_folders.h b/database/ess_resource_db_folders.h index 367e2f1..da19dd2 100644 --- a/database/ess_resource_db_folders.h +++ b/database/ess_resource_db_folders.h @@ -41,13 +41,7 @@ SOFTWARE. #include "../data/entities/xp_data.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define PoolStringArray PackedStringArray - -#define POOL_STRING_ARRAY PACKED_STRING_ARRAY -#endif +#include "../defines.h" class Aura; class Spell; diff --git a/database/ess_resource_db_map.cpp b/database/ess_resource_db_map.cpp index 76b9abd..48ed3bf 100644 --- a/database/ess_resource_db_map.cpp +++ b/database/ess_resource_db_map.cpp @@ -56,15 +56,7 @@ void ESSResourceDBMap::add_entity_resource(Ref cls) { ESSResourceDB::add_entity_resource(cls); } Vector ESSResourceDBMap::get_entity_resources() const { - 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; + VARIANT_ARRAY_GET(_entity_resources); } void ESSResourceDBMap::set_entity_resources(const Vector &data) { _entity_resources.clear(); @@ -100,15 +92,7 @@ void ESSResourceDBMap::add_entity_skill(Ref cls) { ESSResourceDB::add_entity_skill(cls); } Vector ESSResourceDBMap::get_entity_skills() const { - Vector r; - for (int i = 0; i < _entity_skills.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_entity_skills[i].get_ref_ptr()); -#else - r.push_back(_entity_skills[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_entity_skills); } void ESSResourceDBMap::set_entity_skills(const Vector &data) { _entity_skills.clear(); @@ -144,15 +128,7 @@ void ESSResourceDBMap::add_entity_data(Ref cls) { ESSResourceDB::add_entity_data(cls); } Vector ESSResourceDBMap::get_entity_datas() const { - Vector r; - for (int i = 0; i < _entity_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_entity_datas[i].get_ref_ptr()); -#else - r.push_back(_entity_datas[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_entity_datas); } void ESSResourceDBMap::set_entity_datas(const Vector &data) { _craft_recipes.clear(); @@ -189,15 +165,7 @@ void ESSResourceDBMap::add_spell(Ref spell) { ESSResourceDB::add_spell(spell); } Vector ESSResourceDBMap::get_spells() const { - 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; + VARIANT_ARRAY_GET(_spells); } void ESSResourceDBMap::set_spells(const Vector &data) { _spells.clear(); @@ -237,15 +205,7 @@ int ESSResourceDBMap::get_aura_count() { } Vector ESSResourceDBMap::get_auras() const { - 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; + VARIANT_ARRAY_GET(_auras); } void ESSResourceDBMap::set_auras(const Vector &data) { _auras.clear(); @@ -286,15 +246,7 @@ int ESSResourceDBMap::get_craft_recipe_count() { } Vector ESSResourceDBMap::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; + VARIANT_ARRAY_GET(_craft_recipes); } void ESSResourceDBMap::set_craft_recipes(const Vector &data) { _craft_recipes.clear(); @@ -333,15 +285,7 @@ int ESSResourceDBMap::get_item_template_count() { return _item_templates.size(); } Vector ESSResourceDBMap::get_item_templates() const { - Vector r; - for (int i = 0; i < _item_templates.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_item_templates[i].get_ref_ptr()); -#else - r.push_back(_item_templates[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_item_templates); } void ESSResourceDBMap::set_item_templates(const Vector &data) { _item_templates.clear(); @@ -378,15 +322,7 @@ int ESSResourceDBMap::get_entity_species_data_count() { return _entity_species_datas.size(); } Vector ESSResourceDBMap::get_entity_species_datas() const { - Vector r; - for (int i = 0; i < _entity_species_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_entity_species_datas[i].get_ref_ptr()); -#else - r.push_back(_entity_species_datas[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_entity_species_datas); } void ESSResourceDBMap::set_entity_species_datas(const Vector &data) { _entity_species_datas.clear(); diff --git a/database/ess_resource_db_map.h b/database/ess_resource_db_map.h index dd875f7..07dc706 100644 --- a/database/ess_resource_db_map.h +++ b/database/ess_resource_db_map.h @@ -41,13 +41,7 @@ SOFTWARE. #include "../data/entities/xp_data.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define PoolStringArray PackedStringArray - -#define POOL_STRING_ARRAY PACKED_STRING_ARRAY -#endif +#include "../defines.h" class Aura; class Spell; @@ -127,29 +121,29 @@ protected: static void _bind_methods(); private: - Vector > _entity_resources; - HashMap > _entity_resource_map; + Vector> _entity_resources; + HashMap> _entity_resource_map; - Vector > _entity_skills; - HashMap > _entity_skill_map; + Vector> _entity_skills; + HashMap> _entity_skill_map; - Vector > _entity_datas; - HashMap > _entity_data_map; + Vector> _entity_datas; + HashMap> _entity_data_map; - Vector > _spells; - HashMap > _spell_map; + Vector> _spells; + HashMap> _spell_map; - Vector > _auras; - HashMap > _aura_map; + Vector> _auras; + HashMap> _aura_map; - Vector > _craft_recipes; - HashMap > _craft_recipe_map; + Vector> _craft_recipes; + HashMap> _craft_recipe_map; - Vector > _item_templates; - HashMap > _item_template_map; + Vector> _item_templates; + HashMap> _item_template_map; - Vector > _entity_species_datas; - HashMap > _entity_species_data_map; + Vector> _entity_species_datas; + HashMap> _entity_species_data_map; }; #endif diff --git a/database/ess_resource_db_static.cpp b/database/ess_resource_db_static.cpp index 9497b36..865a187 100644 --- a/database/ess_resource_db_static.cpp +++ b/database/ess_resource_db_static.cpp @@ -60,15 +60,7 @@ void ESSResourceDBStatic::add_entity_resource(Ref cls) { ESSResourceDB::add_entity_resource(cls); } Vector ESSResourceDBStatic::get_entity_resources() const { - 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; + VARIANT_ARRAY_GET(_entity_resources); } void ESSResourceDBStatic::set_entity_resources(const Vector &data) { _entity_resources.clear(); @@ -102,15 +94,7 @@ void ESSResourceDBStatic::add_entity_skill(Ref cls) { ESSResourceDB::add_entity_skill(cls); } Vector ESSResourceDBStatic::get_entity_skills() const { - Vector r; - for (int i = 0; i < _entity_skills.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_entity_skills[i].get_ref_ptr()); -#else - r.push_back(_entity_skills[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_entity_skills); } void ESSResourceDBStatic::set_entity_skills(const Vector &data) { _entity_skills.clear(); @@ -144,15 +128,7 @@ void ESSResourceDBStatic::add_entity_data(Ref cls) { ESSResourceDB::add_entity_data(cls); } Vector ESSResourceDBStatic::get_entity_datas() const { - Vector r; - for (int i = 0; i < _entity_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_entity_datas[i].get_ref_ptr()); -#else - r.push_back(_entity_datas[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_entity_datas); } void ESSResourceDBStatic::set_entity_datas(const Vector &data) { _entity_datas.clear(); @@ -187,15 +163,7 @@ void ESSResourceDBStatic::add_spell(Ref spell) { ESSResourceDB::add_spell(spell); } Vector ESSResourceDBStatic::get_spells() const { - 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; + VARIANT_ARRAY_GET(_spells); } void ESSResourceDBStatic::set_spells(const Vector &data) { _spells.clear(); @@ -233,15 +201,7 @@ int ESSResourceDBStatic::get_aura_count() { } Vector ESSResourceDBStatic::get_auras() const { - 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; + VARIANT_ARRAY_GET(_auras); } void ESSResourceDBStatic::set_auras(const Vector &data) { _auras.clear(); @@ -280,15 +240,7 @@ int ESSResourceDBStatic::get_craft_recipe_count() { } Vector ESSResourceDBStatic::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; + VARIANT_ARRAY_GET(_craft_recipes); } void ESSResourceDBStatic::set_craft_recipes(const Vector &data) { _craft_recipes.clear(); @@ -325,15 +277,7 @@ int ESSResourceDBStatic::get_item_template_count() { return _item_templates.size(); } Vector ESSResourceDBStatic::get_item_templates() const { - Vector r; - for (int i = 0; i < _item_templates.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_item_templates[i].get_ref_ptr()); -#else - r.push_back(_item_templates[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_item_templates); } void ESSResourceDBStatic::set_item_templates(const Vector &data) { _item_templates.clear(); @@ -367,15 +311,7 @@ int ESSResourceDBStatic::get_entity_species_data_count() { return _entity_species_datas.size(); } Vector ESSResourceDBStatic::get_entity_species_datas() const { - Vector r; - for (int i = 0; i < _entity_species_datas.size(); i++) { -#if VERSION_MAJOR < 4 - r.push_back(_entity_species_datas[i].get_ref_ptr()); -#else - r.push_back(_entity_species_datas[i]); -#endif - } - return r; + VARIANT_ARRAY_GET(_entity_species_datas); } void ESSResourceDBStatic::set_entity_species_datas(const Vector &data) { _entity_species_datas.clear(); diff --git a/database/ess_resource_db_static.h b/database/ess_resource_db_static.h index 5cbc62b..ad28d92 100644 --- a/database/ess_resource_db_static.h +++ b/database/ess_resource_db_static.h @@ -31,13 +31,7 @@ SOFTWARE. #include "../data/entities/xp_data.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define PoolStringArray PackedStringArray - -#define POOL_STRING_ARRAY PACKED_STRING_ARRAY -#endif +#include "../defines.h" class Aura; class Spell; @@ -130,14 +124,14 @@ protected: private: bool _remap_ids; - Vector > _entity_resources; - Vector > _entity_skills; - Vector > _entity_datas; - Vector > _spells; - Vector > _auras; - Vector > _craft_recipes; - Vector > _item_templates; - Vector > _entity_species_datas; + Vector> _entity_resources; + Vector> _entity_skills; + Vector> _entity_datas; + Vector> _spells; + Vector> _auras; + Vector> _craft_recipes; + Vector> _item_templates; + Vector> _entity_species_datas; }; #endif diff --git a/defines.h b/defines.h new file mode 100644 index 0000000..6cff52d --- /dev/null +++ b/defines.h @@ -0,0 +1,91 @@ + +#ifndef ESS_DEFINES_H +#define ESS_DEFINES_H + +#include "core/version.h" + +#if VERSION_MAJOR >= 4 +#define GODOT4 true +#endif + +//includes +#if GODOT4 +#define spatial_h_path "scene/3d/node_3d.h" +#define visual_server_h_path include "servers/rendering_server.h" + +//#include "core/input/input_event.h" +//#include "editor/plugins/node_3d_editor_plugin.h" +//#include "scene/3d/camera_3d.h" +#else +#define spatial_h_path "scene/3d/spatial.h" +#define visual_server_h_path include "servers/visual_server.h" + +//#include "core/os/input.h" +//#include "editor/plugins/spatial_editor_plugin.h" +//#include "scene/3d/camera.h" + +#endif + +//Type Defines +#if GODOT4 +#define PhysicsDirectSpaceState PhysicsDirectSpaceState3D +#define SpatialEditor Node3DEditor +#define SpatialEditorPlugin Node3DEditorPlugin +#define SpatialEditorViewport Node3DEditorViewport +#define PoolStringArray PackedStringArray +#define REAL FLOAT +#define POOL_STRING_ARRAY PACKED_STRING_ARRAY +#define Spatial Node3D + +typedef class RenderingServer VisualServer; +typedef class RenderingServer VS; + +#define PoolVector3Array PackedVector3Array +#define PoolVector2Array PackedVector2Array +#define PoolColorArray PackedColorArray +#define PoolIntArray PackedInt64Array +#define PoolRealArray PackedFloat32Array + +//toodo figure out a way to have this +//#define Variant::CallError Callable::CallError +#endif + +#if GODOT4 + +#define VARIANT_ARRAY_GET(arr) \ + Vector r; \ + for (int i = 0; i < arr.size(); i++) { \ + r.push_back(arr[i]); \ + } \ + return r; + +#else + +#define VARIANT_ARRAY_GET(arr) \ + Vector r; \ + for (int i = 0; i < arr.size(); i++) { \ + r.push_back(arr[i].get_ref_ptr()); \ + } \ + return r; + +#endif + +#define VARIANT_ARRAY_SET(arr, arr_into, type) \ + arr_into.clear(); \ + for (int i = 0; i < arr.size(); i++) { \ + Ref e = Ref(arr[i]); \ + arr_into.push_back(e); \ + } + +#if GODOT4 +//TODO do this properly +#define INSTANCE_VALIDATE(var) var +#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method)) +#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method)) +#else +#define INSTANCE_VALIDATE(var) ObjectDB::instance_validate(var) +#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method) +#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method) +#endif + +#endif \ No newline at end of file diff --git a/entities/ai/entity_ai.cpp b/entities/ai/entity_ai.cpp index ce017dd..1552420 100644 --- a/entities/ai/entity_ai.cpp +++ b/entities/ai/entity_ai.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "../entity.h" -#include "core/version.h" +#include "../../defines.h" bool EntityAI::get_enabled() { return _enabled; @@ -100,42 +100,26 @@ 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(_owner)); 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(_owner)); 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(_owner)); 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(_owner)); if (has_method("_pet_move")) call("_pet_move", delta); diff --git a/entities/auras/aura_data.cpp b/entities/auras/aura_data.cpp index c060efe..cbc259c 100644 --- a/entities/auras/aura_data.cpp +++ b/entities/auras/aura_data.cpp @@ -27,7 +27,7 @@ SOFTWARE. #include "../../singletons/ess.h" #include "../entity.h" -#include "core/version.h" +#include "../../defines.h" float AuraData::get_damage_count() { return _damage_already_taken; @@ -265,11 +265,8 @@ 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(!INSTANCE_VALIDATE(owner)); + 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 db7c4a8..b59b467 100644 --- a/entities/data/character_spec.cpp +++ b/entities/data/character_spec.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "../../data/auras/aura.h" -#include "core/version.h" +#include "../../defines.h" int CharacterSpec::get_id() { return _id; @@ -52,23 +52,10 @@ 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; + VARIANT_ARRAY_GET(_rows); } void CharacterSpec::set_talent_rows(const Vector &talent_rows) { - _rows.clear(); - for (int i = 0; i < talent_rows.size(); i++) { - Ref talent_row = Ref(talent_rows[i]); - - _rows.push_back(talent_row); - } + VARIANT_ARRAY_SET(talent_rows, _rows, TalentRowData); } Ref CharacterSpec::get_talent(const int row_index, const int culomn, const int rank) const { diff --git a/entities/data/entity_class_data.cpp b/entities/data/entity_class_data.cpp index 9dcd9a7..951df5f 100644 --- a/entities/data/entity_class_data.cpp +++ b/entities/data/entity_class_data.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include "../entity.h" #include "character_spec.h" -#include "core/version.h" +#include "../../defines.h" int EntityClassData::get_id() { return _id; @@ -103,15 +103,7 @@ 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; + VARIANT_ARRAY_GET(_entity_resources); } void EntityClassData::set_entity_resources(const Vector &entity_resources) { _entity_resources.clear(); @@ -151,15 +143,7 @@ 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; + VARIANT_ARRAY_GET(_specs); } void EntityClassData::set_specs(const Vector &specs) { _specs.clear(); @@ -199,15 +183,7 @@ 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; + VARIANT_ARRAY_GET(_spells); } void EntityClassData::set_spells(const Vector &spells) { _spells.clear(); @@ -247,15 +223,7 @@ 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; + VARIANT_ARRAY_GET(_start_spells); } void EntityClassData::set_start_spells(const Vector &spells) { _start_spells.clear(); @@ -295,15 +263,7 @@ 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; + VARIANT_ARRAY_GET(_auras); } void EntityClassData::set_auras(const Vector &auras) { _auras.clear(); @@ -343,15 +303,7 @@ 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; + VARIANT_ARRAY_GET(_ais); } void EntityClassData::set_ais(const Vector &ais) { _ais.clear(); @@ -511,12 +463,7 @@ void EntityClassData::notification_sxp_gained(Entity *entity, int value) { call("_notification_sxp_gained", entity, value); } void EntityClassData::notification_sxp_gained_bind(Node *entity, int value) { - -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -530,11 +477,7 @@ void EntityClassData::notification_sclass_level_up(Entity *entity, int value) { call("_notification_sclass_level_up", entity); } void EntityClassData::notification_sclass_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -548,11 +491,7 @@ void EntityClassData::notification_scharacter_level_up(Entity *entity, int value call("_notification_scharacter_level_up", entity); } void EntityClassData::notification_scharacter_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -671,11 +610,7 @@ void EntityClassData::notification_cxp_gained(Entity *entity, int value) { call("_notification_cxp_gained", entity, value); } void EntityClassData::notification_cxp_gained_bind(Node *entity, int value) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -689,11 +624,7 @@ void EntityClassData::notification_cclass_level_up(Entity *entity, int value) { call("_notification_cclass_level_up", entity); } void EntityClassData::notification_cclass_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -707,11 +638,7 @@ void EntityClassData::notification_ccharacter_level_up(Entity *entity, int value call("_notification_ccharacter_level_up", entity); } void EntityClassData::notification_ccharacter_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -740,11 +667,7 @@ bool EntityClassData::equip_should_deny(Entity *entity, int 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(entity), false); Entity *e = Object::cast_to(entity); @@ -758,11 +681,7 @@ void EntityClassData::equip_son_success(Entity *entity, int 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -776,11 +695,7 @@ void EntityClassData::equip_son_fail(Entity *entity, int 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -794,11 +709,7 @@ void EntityClassData::equip_con_success(Entity *entity, int 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -812,11 +723,7 @@ void EntityClassData::equip_con_fail(Entity *entity, int 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); diff --git a/entities/data/entity_data.cpp b/entities/data/entity_data.cpp index 2196b0c..1337960 100644 --- a/entities/data/entity_data.cpp +++ b/entities/data/entity_data.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include "character_spec.h" #include "vendor_item_data.h" -#include "core/version.h" +#include "../../defines.h" int EntityData::get_id() const { return _id; @@ -232,15 +232,7 @@ 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; + VARIANT_ARRAY_GET(_craft_recipes); } void EntityData::set_craft_recipes(const Vector &craft_datas) { _craft_recipes.clear(); @@ -291,11 +283,7 @@ 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); if (_entity_class_data.is_valid()) _entity_class_data->setup_resources(entity); @@ -305,11 +293,7 @@ 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(entity), false); if (has_method("_cans_interact")) return call("_cans_interact", entity); @@ -318,11 +302,7 @@ 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(entity), false); Entity *e = Object::cast_to(entity); @@ -332,22 +312,14 @@ 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -487,11 +459,7 @@ void EntityData::notification_sxp_gained(Entity *entity, int value) { call("_notification_sxp_gained", entity, value); } void EntityData::notification_sxp_gained_bind(Node *entity, int value) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -508,11 +476,7 @@ void EntityData::notification_sclass_level_up(Entity *entity, int value) { call("_notification_sclass_level_up", entity); } void EntityData::notification_sclass_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -529,11 +493,7 @@ void EntityData::notification_scharacter_level_up(Entity *entity, int value) { call("_notification_scharacter_level_up", entity); } void EntityData::notification_scharacter_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -695,11 +655,7 @@ void EntityData::notification_cxp_gained(Entity *entity, int value) { call("_notification_cxp_gained", entity, value); } void EntityData::notification_cxp_gained_bind(Node *entity, int value) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -716,11 +672,7 @@ void EntityData::notification_cclass_level_up(Entity *entity, int value) { call("_notification_cclass_level_up", entity); } void EntityData::notification_cclass_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -737,11 +689,7 @@ void EntityData::notification_ccharacter_level_up(Entity *entity, int value) { call("_notification_ccharacter_level_up", entity); } void EntityData::notification_ccharacter_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -782,11 +730,7 @@ bool EntityData::equip_should_deny(Entity *entity, int 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(entity), false); Entity *e = Object::cast_to(entity); @@ -803,11 +747,7 @@ void EntityData::equip_son_success(Entity *entity, int 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -824,11 +764,7 @@ void EntityData::equip_son_fail(Entity *entity, int 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -845,11 +781,7 @@ void EntityData::equip_con_success(Entity *entity, int 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); @@ -866,11 +798,7 @@ void EntityData::equip_con_fail(Entity *entity, int 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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); Entity *e = Object::cast_to(entity); diff --git a/entities/data/item_container_data.cpp b/entities/data/item_container_data.cpp index 043edc9..9318f49 100644 --- a/entities/data/item_container_data.cpp +++ b/entities/data/item_container_data.cpp @@ -22,7 +22,7 @@ SOFTWARE. #include "item_container_data.h" -#include "core/version.h" +#include "../../defines.h" int ItemContainerData::get_num_container_datas() { return _container_datas.size(); @@ -43,15 +43,7 @@ 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; + VARIANT_ARRAY_GET(_container_datas); } void ItemContainerData::set_container_datas(const Vector &container_datas) { _container_datas.clear(); diff --git a/entities/data/vendor_item_data.cpp b/entities/data/vendor_item_data.cpp index d8841ae..e30eed2 100644 --- a/entities/data/vendor_item_data.cpp +++ b/entities/data/vendor_item_data.cpp @@ -22,7 +22,7 @@ SOFTWARE. #include "vendor_item_data.h" -#include "core/version.h" +#include "../../defines.h" int VendorItemData::get_num_vendor_datas() { return _vendor_datas.size(); @@ -40,15 +40,7 @@ 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; + VARIANT_ARRAY_GET(_vendor_datas); } void VendorItemData::set_vendor_datas(const Vector &vendor_datas) { _vendor_datas.clear(); diff --git a/entities/entity.cpp b/entities/entity.cpp index 9228c7e..0fff8dd 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -45,6 +45,8 @@ SOFTWARE. #include "core/version.h" +#include "../defines.h" + NodePath Entity::get_body_path() { return _body_path; } @@ -53,13 +55,8 @@ void Entity::set_body_path(NodePath value) { set_body(get_node_or_null(_body_path)); -#if VERSION_MAJOR < 4 - if (ObjectDB::instance_validate(_body)) + if (INSTANCE_VALIDATE(_body)) _body->set_owner(this); -#else - if (_body == NULL) - _body->set_owner(this); -#endif } Node *Entity::get_body() { return _body; @@ -113,11 +110,7 @@ void Entity::setc_guid(int value) { //Transforms Transform Entity::get_transform_3d(bool only_stored) const { if (!only_stored && _body_3d) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND_V(!ObjectDB::instance_validate(_body_3d), _transform); -#else - ERR_FAIL_COND_V(!_body_3d, _transform); -#endif + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(_body_3d), _transform); return _body_3d->get_transform(); } @@ -126,11 +119,7 @@ Transform Entity::get_transform_3d(bool only_stored) const { } void Entity::set_transform_3d(const Transform &transform, bool only_stored) { if (!only_stored && _body_3d) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(_body_3d)); -#else - ERR_FAIL_COND(!_body_3d); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(_body_3d)); return _body_3d->set_transform(transform); } @@ -140,11 +129,7 @@ void Entity::set_transform_3d(const Transform &transform, bool only_stored) { Transform2D Entity::get_transform_2d(bool only_stored) const { if (!only_stored && _body_2d) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND_V(!ObjectDB::instance_validate(_body_2d), _transform_2d); -#else - ERR_FAIL_COND_V(!_body_2d, _transform_2d); -#endif + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(_body_2d), _transform_2d); return _body_2d->get_transform(); } @@ -153,11 +138,7 @@ Transform2D Entity::get_transform_2d(bool only_stored) const { } void Entity::set_transform_2d(const Transform2D &transform, bool only_stored) { if (!only_stored && _body_2d) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(_body_2d)); -#else - ERR_FAIL_COND(!_body_2d); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(_body_2d)); return _body_2d->set_transform(_transform_2d); } @@ -203,20 +184,12 @@ void Entity::setc_entity_type(int 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(e), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(to), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); return static_cast(static_cast(call("_gets_relation_to", to))); } @@ -231,20 +204,12 @@ 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(e), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(to), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); return static_cast(static_cast(call("_getc_relation_to", to))); } @@ -331,12 +296,7 @@ int Entity::getc_model_index() { void Entity::setc_model_index(int value) { _c_model_index = value; -#if VERSION_MAJOR < 4 - if (ObjectDB::instance_validate(_character_skeleton)) { -#else - if (_character_skeleton != NULL) { -#endif - + if (INSTANCE_VALIDATE(_character_skeleton)) { if (_character_skeleton->has_method("set_model_index")) _character_skeleton->call("set_model_index", _c_model_index); } @@ -898,11 +858,7 @@ void Entity::sets_ai(Ref value) { //// Pets //// void Entity::pet_adds(Entity *entity) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); //the owner always want to see his pet, and you pet will always want to see the owner sees_adds(entity); @@ -944,20 +900,12 @@ void Entity::pet_removes_index(int index) { for (int i = 0; i < _s_pets.size(); ++i) { Entity *pet = _s_pets.get(index); -#if VERSION_MAJOR < 4 - ERR_CONTINUE(!ObjectDB::instance_validate(pet)); -#else - ERR_CONTINUE(pet == NULL); -#endif + ERR_CONTINUE(!INSTANCE_VALIDATE(pet)); _s_pets.get(i)->pet_sets_formation_index(i); } -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); entity->pet_sets_owner(NULL); @@ -990,21 +938,13 @@ void Entity::pet_addc_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 + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); pet_addc(entity); } void Entity::pet_addc(Entity *entity) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); _c_pets.push_back(entity); @@ -2284,12 +2224,7 @@ void Entity::_equip_applyc_item(Ref item) { ERR_FAIL_COND(!it.is_valid()); -#if VERSION_MAJOR < 4 - if (it->get_model_visual().is_valid() && ObjectDB::instance_validate(_character_skeleton)) { -#else - if (it->get_model_visual().is_valid() && _character_skeleton == NULL) { -#endif - + if (it->get_model_visual().is_valid() && INSTANCE_VALIDATE(_character_skeleton)) { if (_character_skeleton->has_method("add_model_visual")) _character_skeleton->call("add_model_visual", it->get_model_visual()); } @@ -2301,12 +2236,7 @@ void Entity::_equip_deapplyc_item(Ref item) { ERR_FAIL_COND(!it.is_valid()); -#if VERSION_MAJOR < 4 - if (it->get_model_visual().is_valid() && ObjectDB::instance_validate(_character_skeleton)) { -#else - if (it->get_model_visual().is_valid() && _character_skeleton == NULL) { -#endif - + if (it->get_model_visual().is_valid() && INSTANCE_VALIDATE(_character_skeleton)) { if (_character_skeleton->has_method("remove_model_visual")) _character_skeleton->call("remove_model_visual", it->get_model_visual()); } @@ -2707,12 +2637,7 @@ bool Entity::canc_interact() { return call("_canc_interact"); } -#if VERSION_MAJOR < 4 - if (!ObjectDB::instance_validate(_c_target)) { -#else - if (_c_target == NULL) { -#endif - + if (!INSTANCE_VALIDATE(_c_target)) { return false; } @@ -3541,12 +3466,7 @@ Ref Entity::aura_gets_with_group_by(Entity *caster, Ref aur return Ref(); } Ref Entity::aura_gets_with_group_by_bind(Node *caster, Ref aura_group) { -#if VERSION_MAJOR < 4 - if (!ObjectDB::instance_validate(caster)) { -#else - if (caster == NULL) { -#endif - + if (!INSTANCE_VALIDATE(caster)) { return Ref(); } @@ -3951,17 +3871,17 @@ void Entity::cast_spell_successc(Ref info) { } //// Cooldowns //// -Vector > *Entity::cooldowns_gets() { +Vector> *Entity::cooldowns_gets() { return &_s_cooldowns; } -Vector > *Entity::cooldowns_getc() { +Vector> *Entity::cooldowns_getc() { return &_c_cooldowns; } -HashMap > *Entity::cooldown_get_maps() { +HashMap> *Entity::cooldown_get_maps() { return &_s_cooldown_map; } -HashMap > *Entity::cooldown_get_mapc() { +HashMap> *Entity::cooldown_get_mapc() { return &_c_cooldown_map; } @@ -4105,10 +4025,10 @@ int Entity::cooldown_getc_count() { } //Category Cooldowns -Vector > Entity::category_cooldowns_gets() { +Vector> Entity::category_cooldowns_gets() { return _s_category_cooldowns; } -Vector > Entity::category_cooldowns_getc() { +Vector> Entity::category_cooldowns_getc() { return _c_category_cooldowns; } @@ -4485,13 +4405,8 @@ void Entity::skill_adds(Ref skill) { if (skill_hass(skill)) return; -#if VERSION_MAJOR < 4 - skill->connect("current_changed", this, "skill_scurrent_changed"); - skill->connect("max_changed", this, "skill_smax_changed"); -#else - skill->connect("current_changed", callable_mp(this, &Entity::skill_scurrent_changed)); - skill->connect("max_changed", callable_mp(this, &Entity::skill_smax_changed)); -#endif + skill->CONNECT("current_changed", this, Entity, skill_scurrent_changed); + skill->CONNECT("max_changed", this, Entity, skill_smax_changed); _s_skills.push_back(skill); @@ -4716,12 +4631,7 @@ 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 - + if (!INSTANCE_VALIDATE(original_target)) { original_target = NULL; _s_target = NULL; } @@ -4771,12 +4681,7 @@ 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 - + if (!INSTANCE_VALIDATE(original_target)) { original_target = NULL; _c_target = NULL; } @@ -5046,41 +4951,23 @@ 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, "notification_item_sadded"); - _s_bag->disconnect("item_removed", this, "notification_item_sremoved"); - _s_bag->disconnect("item_swapped", this, "notification_items_sswapped"); - _s_bag->disconnect("item_count_changed", this, "notification_item_sscount_changed"); - _s_bag->disconnect("overburdened", this, "notification_soverburdened"); - _s_bag->disconnect("overburden_removed", this, "notification_soverburden_removed"); -#else - _s_bag->disconnect("item_added", callable_mp(this, &Entity::notification_item_sadded)); - _s_bag->disconnect("item_removed", callable_mp(this, &Entity::notification_item_sremoved)); - _s_bag->disconnect("item_swapped", callable_mp(this, &Entity::notification_items_sswapped)); - _s_bag->disconnect("item_count_changed", callable_mp(this, &Entity::notification_item_sscount_changed)); - _s_bag->disconnect("overburdened", callable_mp(this, &Entity::notification_soverburdened)); - _s_bag->disconnect("overburden_removed", callable_mp(this, &Entity::notification_soverburden_removed)); -#endif + _s_bag->DISCONNECT("item_added", this, Entity, notification_item_sadded); + _s_bag->DISCONNECT("item_removed", this, Entity, notification_item_sremoved); + _s_bag->DISCONNECT("item_swapped", this, Entity, notification_items_sswapped); + _s_bag->DISCONNECT("item_count_changed", this, Entity, notification_item_sscount_changed); + _s_bag->DISCONNECT("overburdened", this, Entity, notification_soverburdened); + _s_bag->DISCONNECT("overburden_removed", this, Entity, notification_soverburden_removed); } _s_bag = bag; if (_s_bag.is_valid()) { -#if VERSION_MAJOR < 4 - _s_bag->connect("item_added", this, "notification_item_sadded"); - _s_bag->connect("item_removed", this, "notification_item_sremoved"); - _s_bag->connect("item_swapped", this, "notification_items_sswapped"); - _s_bag->connect("item_count_changed", this, "notification_item_sscount_changed"); - _s_bag->connect("overburdened", this, "notification_soverburdened"); - _s_bag->connect("overburden_removed", this, "notification_soverburden_removed"); -#else - _s_bag->connect("item_added", callable_mp(this, &Entity::notification_item_sadded)); - _s_bag->connect("item_removed", callable_mp(this, &Entity::notification_item_sremoved)); - _s_bag->connect("item_swapped", callable_mp(this, &Entity::notification_items_sswapped)); - _s_bag->connect("item_count_changed", callable_mp(this, &Entity::notification_item_sscount_changed)); - _s_bag->connect("overburdened", callable_mp(this, &Entity::notification_soverburdened)); - _s_bag->connect("overburden_removed", callable_mp(this, &Entity::notification_soverburden_removed)); -#endif + _s_bag->CONNECT("item_added", this, Entity, notification_item_sadded); + _s_bag->CONNECT("item_removed", this, Entity, notification_item_sremoved); + _s_bag->CONNECT("item_swapped", this, Entity, notification_items_sswapped); + _s_bag->CONNECT("item_count_changed", this, Entity, notification_item_sscount_changed); + _s_bag->CONNECT("overburdened", this, Entity, notification_soverburdened); + _s_bag->CONNECT("overburden_removed", this, Entity, notification_soverburden_removed); } emit_signal("sbag_changed", this, _s_bag); @@ -5106,33 +4993,19 @@ 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, "notification_target_item_sadded"); - _s_target_bag->disconnect("item_removed", this, "notification_target_item_sremoved"); - _s_target_bag->disconnect("item_swapped", this, "notification_target_items_sswapped"); - _s_target_bag->disconnect("item_count_changed", this, "notification_target_item_sscount_changed"); -#else - _s_target_bag->disconnect("item_added", callable_mp(this, &Entity::notification_target_item_sadded)); - _s_target_bag->disconnect("item_removed", callable_mp(this, &Entity::notification_target_item_sremoved)); - _s_target_bag->disconnect("item_swapped", callable_mp(this, &Entity::notification_target_items_sswapped)); - _s_target_bag->disconnect("item_count_changed", callable_mp(this, &Entity::notification_target_item_sscount_changed)); -#endif + _s_target_bag->DISCONNECT("item_added", this, Entity, notification_target_item_sadded); + _s_target_bag->DISCONNECT("item_removed", this, Entity, notification_target_item_sremoved); + _s_target_bag->DISCONNECT("item_swapped", this, Entity, notification_target_items_sswapped); + _s_target_bag->DISCONNECT("item_count_changed", this, Entity, notification_target_item_sscount_changed); } _s_target_bag = bag; if (_s_target_bag.is_valid()) { -#if VERSION_MAJOR < 4 - _s_target_bag->connect("item_added", this, "notification_target_item_sadded"); - _s_target_bag->connect("item_removed", this, "notification_target_item_sremoved"); - _s_target_bag->connect("item_swapped", this, "notification_target_items_sswapped"); - _s_target_bag->connect("item_count_changed", this, "notification_target_item_sscount_changed"); -#else - _s_target_bag->connect("item_added", callable_mp(this, &Entity::notification_target_item_sadded)); - _s_target_bag->connect("item_removed", callable_mp(this, &Entity::notification_target_item_sremoved)); - _s_target_bag->connect("item_swapped", callable_mp(this, &Entity::notification_target_items_sswapped)); - _s_target_bag->connect("item_count_changed", callable_mp(this, &Entity::notification_target_item_sscount_changed)); -#endif + _s_target_bag->CONNECT("item_added", this, Entity, notification_target_item_sadded); + _s_target_bag->CONNECT("item_removed", this, Entity, notification_target_item_sremoved); + _s_target_bag->CONNECT("item_swapped", this, Entity, notification_target_items_sswapped); + _s_target_bag->CONNECT("item_count_changed", this, Entity, notification_target_item_sscount_changed); } emit_signal("starget_bag_changed", this, _s_target_bag); @@ -5523,12 +5396,7 @@ Entity *Entity::sees_gets(int index) { void Entity::sees_removes_index(int index) { Entity *e = _s_sees.get(index); -#if VERSION_MAJOR < 4 - if (unlikely(!ObjectDB::instance_validate(e))) { -#else - if (e == NULL) { -#endif - + if (unlikely(!INSTANCE_VALIDATE(e))) { _s_sees.remove(index); return; } @@ -5538,12 +5406,7 @@ void Entity::sees_removes_index(int index) { _s_sees.remove(index); } void Entity::sees_removes(Entity *entity) { -#if VERSION_MAJOR < 4 - if (unlikely(!ObjectDB::instance_validate(entity))) { -#else - if (entity == NULL) { -#endif - + if (unlikely(!INSTANCE_VALIDATE(entity))) { _s_sees.erase(entity); return; } @@ -5560,11 +5423,7 @@ void Entity::sees_removes_bind(Node *entity) { sees_removes(e); } void Entity::sees_adds(Entity *entity) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); entity->seen_by_adds(this); @@ -5605,11 +5464,7 @@ void Entity::seen_by_removes_bind(Node *entity) { seen_by_removes(e); } void Entity::seen_by_adds(Entity *entity) { -#if VERSION_MAJOR < 4 - ERR_FAIL_COND(!ObjectDB::instance_validate(entity)); -#else - ERR_FAIL_COND(entity == NULL); -#endif + ERR_FAIL_COND(!INSTANCE_VALIDATE(entity)); for (int i = 0; i < _s_seen_by.size(); ++i) { if (_s_seen_by.get(i) == entity) @@ -5643,12 +5498,7 @@ 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 - + if (unlikely(!INSTANCE_VALIDATE(e))) { _s_seen_by.remove(i); --i; continue; @@ -6206,18 +6056,10 @@ 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 (ObjectDB::instance_validate(old_target)) + if (INSTANCE_VALIDATE(old_target)) old_target->notification_cuntargeted(); - if (ObjectDB::instance_validate(getc_target())) { -#else - if (old_target != NULL) - old_target->notification_cuntargeted(); - - if (getc_target() != NULL) { -#endif - + if (INSTANCE_VALIDATE(getc_target())) { getc_target()->notification_ctargeted(); if (canc_interact()) @@ -6307,13 +6149,8 @@ void Entity::_notification(int p_what) { case NOTIFICATION_INSTANCED: { set_body(get_node_or_null(_body_path)); -#if VERSION_MAJOR < 4 - if (ObjectDB::instance_validate(_body)) + if (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); @@ -6329,13 +6166,8 @@ void Entity::_notification(int p_what) { if (!_body) { set_body(get_node_or_null(_body_path)); -#if VERSION_MAJOR < 4 - if (ObjectDB::instance_validate(_body)) + if (INSTANCE_VALIDATE(_body)) _body->set_owner(this); -#else - if (_body != NULL) - _body->set_owner(this); -#endif } if (!_character_skeleton) { @@ -6358,13 +6190,8 @@ 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 (ObjectDB::instance_validate(e)) + if (INSTANCE_VALIDATE(e)) e->sees_removes(this); -#else - if (e != NULL) - e->sees_removes(this); -#endif } } break; } diff --git a/entities/entity.h b/entities/entity.h index 4fe6f4d..de3a7cd 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -60,12 +60,9 @@ SOFTWARE. #include "core/version.h" -#if VERSION_MAJOR < 4 -#include "scene/3d/spatial.h" -#else -#include "scene/3d/node_3d.h" -#define Spatial Node3D -#endif +#include "../defines.h" + +#include spatial_h_path class EntityData; class AuraData; @@ -702,11 +699,11 @@ public: //// Cooldowns //// - Vector > *cooldowns_gets(); - Vector > *cooldowns_getc(); + Vector> *cooldowns_gets(); + Vector> *cooldowns_getc(); - HashMap > *cooldown_get_maps(); - HashMap > *cooldown_get_mapc(); + HashMap> *cooldown_get_maps(); + HashMap> *cooldown_get_mapc(); bool cooldown_hass(int spell_id); void cooldown_adds(int spell_id, float value); @@ -724,8 +721,8 @@ public: //Category Cooldowns - Vector > category_cooldowns_gets(); - Vector > category_cooldowns_getc(); + Vector> category_cooldowns_gets(); + Vector> category_cooldowns_getc(); bool category_cooldown_hass(int category_id); void category_cooldown_adds(int category_id, float value); @@ -1129,13 +1126,13 @@ private: //// Equipment //// - Vector > _s_equipment; - Vector > _c_equipment; + Vector> _s_equipment; + Vector> _c_equipment; //// Resources //// - Vector > _s_resources; - Vector > _c_resources; + Vector> _s_resources; + Vector> _c_resources; //// GCD //// @@ -1156,8 +1153,8 @@ private: //// AuraComponent //// - Vector > _s_auras; - Vector > _c_auras; + Vector> _s_auras; + Vector> _c_auras; int _s_entity_type; int _c_entity_type; @@ -1168,14 +1165,14 @@ private: int _c_entity_flags; //// Cooldowns //// - Vector > _s_cooldowns; - Vector > _c_cooldowns; + Vector> _s_cooldowns; + Vector> _c_cooldowns; - HashMap > _s_cooldown_map; - HashMap > _c_cooldown_map; + HashMap> _s_cooldown_map; + HashMap> _c_cooldown_map; - Vector > _s_category_cooldowns; - Vector > _c_category_cooldowns; + Vector> _s_category_cooldowns; + Vector> _c_category_cooldowns; int _s_active_category_cooldowns; int _c_active_category_cooldowns; @@ -1195,8 +1192,8 @@ private: //// Data //// - Vector > _s_data; - Vector > _c_data; + Vector> _s_data; + Vector> _c_data; //// Actionbars //// @@ -1205,21 +1202,21 @@ private: //// Crafting System //// - Vector > _s_craft_recipes; - Vector > _c_craft_recipes; + Vector> _s_craft_recipes; + Vector> _c_craft_recipes; //// Known Spells //// int _s_free_spell_points; int _c_free_spell_points; - Vector > _s_spells; - Vector > _c_spells; + Vector> _s_spells; + Vector> _c_spells; //// Skills //// - Vector > _s_skills; - Vector > _c_skills; + Vector> _s_skills; + Vector> _c_skills; //// Stat Allocations //// @@ -1263,7 +1260,7 @@ private: // Callbacks - Vector > _physics_process_scis; + Vector> _physics_process_scis; }; #endif diff --git a/entities/stats/stat_data.h b/entities/stats/stat_data.h index a740986..3688962 100644 --- a/entities/stats/stat_data.h +++ b/entities/stats/stat_data.h @@ -28,12 +28,6 @@ SOFTWARE. #include "level_stat_data.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define REAL FLOAT -#endif - class StatData : public Resource { GDCLASS(StatData, Resource); diff --git a/formations/ai_formation.cpp b/formations/ai_formation.cpp index 2bf9317..bb56050 100644 --- a/formations/ai_formation.cpp +++ b/formations/ai_formation.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "../entities/entity.h" -#include "core/version.h" +#include "../defines.h" void AIFormation::set_owner(Entity *entity) { _owner = entity; @@ -62,11 +62,7 @@ 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 + ERR_FAIL_COND_V(!INSTANCE_VALIDATE(_owner), Vector3()); 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 ff5df7d..34769dd 100644 --- a/infos/spell_cast_info.cpp +++ b/infos/spell_cast_info.cpp @@ -29,16 +29,14 @@ SOFTWARE. #include "../entities/entity.h" #include "../singletons/ess.h" -#include "core/version.h" +#include "../defines.h" //// SpellCastInfo //// Entity *SpellCastInfo::get_caster() { -#if VERSION_MAJOR < 4 - if (_caster && !ObjectDB::instance_validate(_caster)) { + if (_caster && !INSTANCE_VALIDATE(_caster)) { _caster = NULL; } -#endif return _caster; } @@ -60,11 +58,9 @@ void SpellCastInfo::set_caster_bind(Node *caster) { } Entity *SpellCastInfo::get_target() { -#if VERSION_MAJOR < 4 - if (_target && !ObjectDB::instance_validate(_target)) { + if (_target && !INSTANCE_VALIDATE(_target)) { _target = NULL; } -#endif return _target; } @@ -167,11 +163,7 @@ 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(!INSTANCE_VALIDATE(owner)); ERR_FAIL_COND(!owner->is_inside_tree()); @@ -191,19 +183,11 @@ void SpellCastInfo::resolve_references(Node *owner) { Dictionary SpellCastInfo::to_dict() { Dictionary dict; -#if VERSION_MAJOR < 4 - if (ObjectDB::instance_validate(_caster)) + if (INSTANCE_VALIDATE(_caster)) dict["caster"] = _caster->get_path(); - if (ObjectDB::instance_validate(_target)) + if (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 b1588b0..a7f76d7 100644 --- a/pipelines/spell_damage_info.cpp +++ b/pipelines/spell_damage_info.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "../entities/entity.h" #include "../singletons/ess.h" -#include "core/version.h" +#include "../defines.h" bool SpellDamageInfo::get_immune() { return _crit; @@ -165,11 +165,7 @@ 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(!INSTANCE_VALIDATE(owner)); ERR_FAIL_COND(!owner->is_inside_tree()); _dealer = Object::cast_to(owner->get_node_or_null(_dealer_path)); @@ -185,19 +181,11 @@ void SpellDamageInfo::resolve_references(Node *owner) { Dictionary SpellDamageInfo::to_dict() { Dictionary dict; -#if VERSION_MAJOR < 4 - if (ObjectDB::instance_validate(_dealer)) + if (INSTANCE_VALIDATE(_dealer)) dict["dealer_path"] = _dealer->get_path(); - if (ObjectDB::instance_validate(_receiver)) + if (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 180bdb9..a64fc04 100644 --- a/pipelines/spell_heal_info.cpp +++ b/pipelines/spell_heal_info.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "../entities/entity.h" #include "../singletons/ess.h" -#include "core/version.h" +#include "../defines.h" bool SpellHealInfo::get_immune() { return _immune; @@ -161,11 +161,7 @@ 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(!INSTANCE_VALIDATE(owner)); ERR_FAIL_COND(!owner->is_inside_tree()); _dealer = Object::cast_to(owner->get_node_or_null(_dealer_path)); @@ -181,19 +177,11 @@ void SpellHealInfo::resolve_references(Node *owner) { Dictionary SpellHealInfo::to_dict() { Dictionary dict; -#if VERSION_MAJOR < 4 - if (ObjectDB::instance_validate(_dealer)) + if (INSTANCE_VALIDATE(_dealer)) dict["dealer_path"] = _dealer->get_path(); - if (ObjectDB::instance_validate(_receiver)) + if (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 da28ed7..dcbac32 100644 --- a/profiles/actionbar/action_bar_entry.cpp +++ b/profiles/actionbar/action_bar_entry.cpp @@ -24,11 +24,7 @@ SOFTWARE. #include "action_bar_profile.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define REAL FLOAT -#endif +#include "../../defines.h" Ref ActionBarEntry::get_owner() { return Ref(_owner); diff --git a/profiles/player_profile.cpp b/profiles/player_profile.cpp index 7df4810..ce316f2 100644 --- a/profiles/player_profile.cpp +++ b/profiles/player_profile.cpp @@ -22,7 +22,7 @@ SOFTWARE. #include "player_profile.h" -#include "core/version.h" +#include "../defines.h" const String PlayerProfile::DEFAULT_PROFILE_FILE_NAME = "default.profile"; @@ -61,11 +61,7 @@ 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 + profile->CONNECT("changed", this, PlayerProfile, _on_class_profile_changed); _class_profiles.push_back(profile); @@ -74,11 +70,7 @@ 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.get(i)->DISCONNECT("changed", this, PlayerProfile, _on_class_profile_changed); } _class_profiles.clear(); @@ -87,19 +79,14 @@ 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.get(index)->DISCONNECT("changed", this, PlayerProfile, _on_class_profile_changed); _class_profiles.remove(index); emit_change(); } -Vector > &PlayerProfile::get_class_profiles() { +Vector> &PlayerProfile::get_class_profiles() { return _class_profiles; } @@ -114,11 +101,7 @@ Ref PlayerProfile::get_class_profile(const StringName &class_path) 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_profile->CONNECT("changed", this, PlayerProfile, _on_class_profile_changed); _class_profiles.push_back(Ref(class_profile)); @@ -176,11 +159,7 @@ void PlayerProfile::from_dict(const Dictionary &dict) { 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 + c->CONNECT("changed", this, PlayerProfile, _on_class_profile_changed); _class_profiles.push_back(c); } @@ -208,11 +187,7 @@ 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 + _class_profiles.get(i)->CONNECT("changed", this, PlayerProfile, _on_class_profile_changed); } emit_change(); diff --git a/projectiles/3d/spell_follow_projectile_3d.h b/projectiles/3d/spell_follow_projectile_3d.h index 4a0b1cb..e07004e 100644 --- a/projectiles/3d/spell_follow_projectile_3d.h +++ b/projectiles/3d/spell_follow_projectile_3d.h @@ -23,15 +23,9 @@ SOFTWARE. #ifndef SPELL_PROJECTILE_3D #define SPELL_PROJECTILE_3D -#include "core/version.h" +#include "../../defines.h" -#if VERSION_MAJOR < 4 -#include "scene/3d/spatial.h" -#else -#include "scene/3d/node_3d.h" - -typedef class Node3D Spatial; -#endif +#include spatial_h_path class SpellCastInfo; diff --git a/singletons/ess.h b/singletons/ess.h index 64e3eda..aa0d7b6 100644 --- a/singletons/ess.h +++ b/singletons/ess.h @@ -33,13 +33,7 @@ SOFTWARE. #include "core/bind/core_bind.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define PoolStringArray PackedStringArray - -#define POOL_STRING_ARRAY PACKED_STRING_ARRAY -#endif +#include "../defines.h" class ESSResourceDB; class ESSEntitySpawner; diff --git a/singletons/profile_manager.cpp b/singletons/profile_manager.cpp index 94e6f07..5485fa4 100644 --- a/singletons/profile_manager.cpp +++ b/singletons/profile_manager.cpp @@ -27,7 +27,7 @@ SOFTWARE. #include "core/engine.h" -#include "core/version.h" +#include "../defines.h" ProfileManager *ProfileManager::_instance; @@ -63,7 +63,6 @@ int ProfileManager::gets_player_profile_count() const { return _s_player_profiles.size(); } Ref ProfileManager::gets_player_profile_index(const int index) { - return _s_player_profiles.get(index); } void ProfileManager::adds_player_profile(const Ref &profile) { @@ -168,15 +167,9 @@ 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->DISCONNECT("changed", this, ProfileManager, _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 + _c_player_profile->CONNECT("changed", this, ProfileManager, _on_player_profile_changed); Array arr = dict.get("splayer_profiles", Array()); @@ -186,11 +179,7 @@ void ProfileManager::from_dict(const Dictionary &dict) { c->from_dict(arr.get(i)); -#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 + c->CONNECT("changed", this, ProfileManager, _on_player_profile_changed); _s_player_profiles.push_back(c); } @@ -205,11 +194,7 @@ ProfileManager::ProfileManager() { _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 + _c_player_profile->CONNECT("changed", this, ProfileManager, _on_player_profile_changed); if (!Engine::get_singleton()->is_editor_hint() && _automatic_load) call_deferred("load"); @@ -218,11 +203,7 @@ 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 + _c_player_profile->DISCONNECT("changed", this, ProfileManager, _on_player_profile_changed); _s_player_profiles.clear(); } diff --git a/skeleton/character_skeleton_3d.cpp b/skeleton/character_skeleton_3d.cpp index 7109f13..3cd9927 100644 --- a/skeleton/character_skeleton_3d.cpp +++ b/skeleton/character_skeleton_3d.cpp @@ -24,20 +24,7 @@ SOFTWARE. #include "../data/items/model_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 +#include "../defines.h" int CharacterSkeleton3D::get_model_index() { return _model_index; @@ -190,7 +177,7 @@ void CharacterSkeleton3D::add_model_visual_entry(Ref vis, Ref > &entries = _entries[target_bone_idx]; + Vector> &entries = _entries[target_bone_idx]; for (int i = 0; i < entries.size(); ++i) { Ref e = entries.get(i); @@ -218,7 +205,7 @@ void CharacterSkeleton3D::remove_model_visual_entry(Ref vis, Ref > &entries = _entries[target_bone_idx]; + Vector> &entries = _entries[target_bone_idx]; for (int i = 0; i < entries.size(); ++i) { Ref e = entries.get(i); @@ -252,7 +239,7 @@ int CharacterSkeleton3D::get_model_entry_count(const int bone_index) { void CharacterSkeleton3D::sort_layers() { for (int i = 0; i < EntityEnums::SKELETON_POINTS_MAX; ++i) { - Vector > &entries = _entries[i]; + Vector> &entries = _entries[i]; entries.sort_custom<_ModelEntryComparator>(); } @@ -340,7 +327,7 @@ 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 !GODOT4 img->lock(); #endif @@ -353,7 +340,7 @@ Array CharacterSkeleton3D::bake_mesh_array_uv(Array arr, Ref tex, float colors.set(i, colors[i] * c * mul_color); } -#if VERSION_MAJOR < 4 +#if !GODOT4 img->unlock(); #endif @@ -391,7 +378,6 @@ void CharacterSkeleton3D::_notification(int p_what) { build_model(); } break; case NOTIFICATION_EXIT_TREE: { - } break; } } diff --git a/skeleton/character_skeleton_3d.h b/skeleton/character_skeleton_3d.h index 3ecef28..87651e2 100644 --- a/skeleton/character_skeleton_3d.h +++ b/skeleton/character_skeleton_3d.h @@ -37,13 +37,11 @@ SOFTWARE. #include "../data/items/model_visual_entry.h" -#include "core/version.h" +#include "../defines.h" -#if VERSION_MAJOR < 4 -#include "scene/3d/spatial.h" -#else -#include "scene/3d/node_3d.h" -#define Spatial Node3D +#include spatial_h_path + +#if GODOT4 #define Texture Texture2D #endif @@ -129,8 +127,8 @@ private: Node *_bone_nodes[EntityEnums::SKELETON_POINTS_MAX]; bool _model_dirty; - Vector > _model_visuals; - Vector > _entries[EntityEnums::SKELETON_POINTS_MAX]; + Vector> _model_visuals; + Vector> _entries[EntityEnums::SKELETON_POINTS_MAX]; }; #endif diff --git a/utility/category_cooldown.cpp b/utility/category_cooldown.cpp index 213e231..4213239 100644 --- a/utility/category_cooldown.cpp +++ b/utility/category_cooldown.cpp @@ -22,11 +22,7 @@ SOFTWARE. #include "category_cooldown.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define REAL FLOAT -#endif +#include "../defines.h" int CategoryCooldown::get_category_id() const { return _category_id; diff --git a/utility/cooldown.cpp b/utility/cooldown.cpp index 238a844..49f86a8 100644 --- a/utility/cooldown.cpp +++ b/utility/cooldown.cpp @@ -25,11 +25,7 @@ SOFTWARE. #include "../database/ess_resource_db.h" #include "../singletons/ess.h" -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define REAL FLOAT -#endif +#include "../defines.h" int Cooldown::get_spell_id() const { return _spell_id;