From 12276aa334739b0e6bbb87fe69b13e59e9593241 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 9 Jan 2023 01:15:48 +0100 Subject: [PATCH] Work on fixing compile. --- database/ess_resource_db_folders.cpp | 26 ++--- database/ess_resource_db_map.cpp | 14 +-- entities/entity.cpp | 133 +++++++++++----------- entities/resources/entity_resource.cpp | 4 +- material_cache/ess_material_cache.cpp | 3 +- material_cache/ess_material_cache.h | 3 +- material_cache/ess_material_cache_pcm.cpp | 8 +- material_cache/ess_material_cache_pcm.h | 4 +- singletons/ess.cpp | 35 ++---- singletons/profile_manager.cpp | 19 ++-- skeleton/character_skeleton_2d.cpp | 16 +-- skeleton/character_skeleton_3d.cpp | 16 +-- utility/entity_create_info.cpp | 2 +- utility/entity_create_info.h | 1 + 14 files changed, 129 insertions(+), 155 deletions(-) diff --git a/database/ess_resource_db_folders.cpp b/database/ess_resource_db_folders.cpp index 5b64109..84f2d95 100644 --- a/database/ess_resource_db_folders.cpp +++ b/database/ess_resource_db_folders.cpp @@ -28,6 +28,7 @@ SOFTWARE. #include "../entities/data/entity_data.h" #include "../entities/resources/entity_resource.h" #include "../entities/skills/entity_skill_data.h" +#include "core/io/dir_access.h" bool ESSResourceDBFolders::get_automatic_load() const { return _automatic_load; @@ -65,23 +66,22 @@ void ESSResourceDBFolders::load_folders() { } void ESSResourceDBFolders::load_folder(const String &folder) { - _Directory dir; + Ref dir = DirAccess::open(folder); bool ew = folder.ends_with("/"); - if (dir.open(folder) == OK) { - - dir.list_dir_begin(); + if (dir.is_valid()) { + dir->list_dir_begin(); String filename; while (true) { - filename = dir.get_next(); + filename = dir->get_next(); if (filename == "") break; - if (!dir.current_is_dir()) { + if (!dir->current_is_dir()) { String path; if (ew) @@ -122,19 +122,7 @@ void ESSResourceDBFolders::add_resource(const Ref &resource) { } Ref ESSResourceDBFolders::load_resource(const String &path, const String &type_hint) { - _ResourceLoader *rl = _ResourceLoader::get_singleton(); - -#if VERSION_MAJOR < 4 - Ref resl = rl->load_interactive(path, type_hint); - - ERR_FAIL_COND_V(!resl.is_valid(), Ref()); - - resl->wait(); - - return resl->get_resource(); -#else - return rl->load(path, type_hint); -#endif + return ResourceLoader::load(path, type_hint); } ESSResourceDBFolders::ESSResourceDBFolders() { diff --git a/database/ess_resource_db_map.cpp b/database/ess_resource_db_map.cpp index 9b39fd9..f0dc117 100644 --- a/database/ess_resource_db_map.cpp +++ b/database/ess_resource_db_map.cpp @@ -50,7 +50,7 @@ void ESSResourceDBMap::add_entity_resource(Ref cls) { ERR_FAIL_COND(!cls.is_valid()); _entity_resources.push_back(cls); - _entity_resource_map.set(cls->get_id(), cls); + _entity_resource_map[cls->get_id()] = cls; ESSResourceDB::add_entity_resource(cls); } @@ -86,7 +86,7 @@ void ESSResourceDBMap::add_entity_skill(Ref cls) { ERR_FAIL_COND(!cls.is_valid()); _entity_skills.push_back(cls); - _entity_skill_map.set(cls->get_id(), cls); + _entity_skill_map[cls->get_id()] = cls; ESSResourceDB::add_entity_skill(cls); } @@ -122,7 +122,7 @@ void ESSResourceDBMap::add_entity_data(Ref cls) { ERR_FAIL_COND(!cls.is_valid()); _entity_datas.push_back(cls); - _entity_data_map.set(cls->get_id(), cls); + _entity_data_map[cls->get_id()] = cls; ESSResourceDB::add_entity_data(cls); } @@ -159,7 +159,7 @@ void ESSResourceDBMap::add_spell(Ref spell) { ERR_FAIL_COND(!spell.is_valid()); _spells.push_back(spell); - _spell_map.set(spell->get_id(), spell); + _spell_map[spell->get_id()] = spell; ESSResourceDB::add_spell(spell); } @@ -183,7 +183,7 @@ void ESSResourceDBMap::add_craft_recipe(Ref cda) { ERR_FAIL_COND(!cda.is_valid()); _craft_recipes.push_back(cda); - _craft_recipe_map.set(cda->get_id(), cda); + _craft_recipe_map[cda->get_id()] = cda; ESSResourceDB::add_craft_recipe(cda); } @@ -223,7 +223,7 @@ void ESSResourceDBMap::add_item_template(Ref cda) { ERR_FAIL_COND(!cda.is_valid()); _item_templates.push_back(cda); - _item_template_map.set(cda->get_id(), cda); + _item_template_map[cda->get_id()] = cda; ESSResourceDB::add_item_template(cda); } @@ -262,7 +262,7 @@ void ESSResourceDBMap::add_entity_species_data(Ref cda) { ERR_FAIL_COND(!cda.is_valid()); _entity_species_datas.push_back(cda); - _entity_species_data_map.set(cda->get_id(), cda); + _entity_species_data_map[cda->get_id()] = cda; ESSResourceDB::add_entity_species_data(cda); } diff --git a/entities/entity.cpp b/entities/entity.cpp index 79a3e7d..ac2dcd4 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -632,8 +632,9 @@ void Entity::setup(Ref info) { sets_entity_player_type(info->get_entity_player_type()); - if (info->get_network_owner() != 0) - set_network_master(info->get_network_owner()); + if (info->get_network_owner() != 0) { + set_multiplayer_authority(info->get_network_owner()); + } sets_original_entity_controller(info->get_entity_controller()); sets_entity_controller(info->get_entity_controller()); @@ -677,7 +678,7 @@ void Entity::_setup() { Ref ad = _s_auras.get(i); if (!ad->get_aura()->aura_get_hide()) - VRPCOBJ(aura_addc_rpc, JSON::print(ad->to_dict()), aura_addc, ad); + VRPCOBJ(aura_addc_rpc, JSON::stringify(ad->to_dict()), aura_addc, ad); } if (gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY) { @@ -939,8 +940,9 @@ void Entity::setc_entity_controller(EntityEnums::EntityController value) { } bool Entity::getc_is_controlled() { - if (is_inside_tree() && get_tree()->has_network_peer()) { - return (_c_entity_controller == EntityEnums::ENITIY_CONTROLLER_PLAYER) && (get_network_master() == get_tree()->get_network_unique_id()); + Ref _multiplayer_api = get_multiplayer(); + if (_multiplayer_api.is_valid()) { + return (_c_entity_controller == EntityEnums::ENITIY_CONTROLLER_PLAYER) && (get_multiplayer_authority() == _multiplayer_api->get_unique_id()); } else { return _c_entity_controller == EntityEnums::ENITIY_CONTROLLER_PLAYER; } @@ -1577,8 +1579,8 @@ void Entity::_from_dict(const Dictionary &dict) { String class_name = dict.get("class_name", EntityDataContainer::get_class_static()); - if (ClassDB::can_instance(class_name) && ClassDB::is_parent_class(class_name, EntityDataContainer::get_class_static())) { - Ref data = Ref(ClassDB::instance(class_name)); + if (ClassDB::can_instantiate(class_name) && ClassDB::is_parent_class(class_name, EntityDataContainer::get_class_static())) { + Ref data = Ref(ClassDB::instantiate(class_name)); if (data.is_valid()) { data->from_dict(entry); @@ -1897,7 +1899,7 @@ void Entity::craft_adds_recipe_id(int id) { void Entity::craft_removes_recipe(Ref craft_recipe) { for (int i = 0; i < _s_craft_recipes.size(); ++i) { if (_s_craft_recipes.get(i) == craft_recipe) { - _s_craft_recipes.remove(i); + _s_craft_recipes.remove_at(i); break; } } @@ -1913,7 +1915,7 @@ void Entity::craft_removes_recipe_id(int id) { craft_recipe = _s_craft_recipes.get(i); if (craft_recipe->get_id() == id) { - _s_craft_recipes.remove(i); + _s_craft_recipes.remove_at(i); break; } } @@ -1989,7 +1991,7 @@ void Entity::craft_addc_recipe_id(int id) { void Entity::craft_removec_recipe(Ref craft_recipe) { for (int i = 0; i < _c_craft_recipes.size(); ++i) { if (_c_craft_recipes.get(i) == craft_recipe) { - _c_craft_recipes.remove(i); + _c_craft_recipes.remove_at(i); break; } } @@ -2003,7 +2005,7 @@ void Entity::craft_removec_recipe_id(int id) { craft_recipe = _c_craft_recipes.get(i); if (craft_recipe->get_id() == id) { - _c_craft_recipes.remove(i); + _c_craft_recipes.remove_at(i); break; } } @@ -2497,7 +2499,7 @@ void Entity::resource_adds(Ref resource) { notification_sentity_resource_added(resource); - VRPCOBJP(resource_addc_rpc, _s_resources.size() - 1, JSON::print(resource->to_dict()), resource_addc, _s_resources.size() - 1, resource); + VRPCOBJP(resource_addc_rpc, _s_resources.size() - 1, JSON::stringify(resource->to_dict()), resource_addc, _s_resources.size() - 1, resource); } int Entity::resource_gets_count() { return _s_resources.size(); @@ -2687,7 +2689,7 @@ void Entity::stake_damage(Ref info) { notification_sdamage(SpellEnums::NOTIFICATION_DAMAGE_BEFORE_HIT, info); if (info->get_immune()) { - VRPCOBJ12(cdamage_dealt_rpc, JSON::print(info->to_dict()), notification_cdamage, SpellEnums::NOTIFICATION_DAMAGE_DAMAGE_DEALT, info); + VRPCOBJ12(cdamage_dealt_rpc, JSON::stringify(info->to_dict()), notification_cdamage, SpellEnums::NOTIFICATION_DAMAGE_DAMAGE_DEALT, info); return; } @@ -2720,7 +2722,7 @@ void Entity::stake_damage(Ref info) { emit_signal("son_damage_received", this, info); //send an event to client - VRPCOBJ12(cdamage_dealt_rpc, JSON::print(info->to_dict()), notification_cdamage, SpellEnums::NOTIFICATION_DAMAGE_DAMAGE_DEALT, info); + VRPCOBJ12(cdamage_dealt_rpc, JSON::stringify(info->to_dict()), notification_cdamage, SpellEnums::NOTIFICATION_DAMAGE_DAMAGE_DEALT, info); if (hp->get_current_value() <= 0) { dies(); @@ -2741,7 +2743,7 @@ void Entity::sdeal_damage_to(Ref info) { notification_sdamage(SpellEnums::NOTIFICATION_DAMAGE_DEALT_DAMAGE, info); //send an event to client - VRPCOBJ12(cdealt_damage_rpc, JSON::print(info->to_dict()), notification_cdamage, SpellEnums::NOTIFICATION_DAMAGE_DEALT_DAMAGE, info); + VRPCOBJ12(cdealt_damage_rpc, JSON::stringify(info->to_dict()), notification_cdamage, SpellEnums::NOTIFICATION_DAMAGE_DEALT_DAMAGE, info); //signal emit_signal("son_dealt_damage", this, info); @@ -2759,7 +2761,7 @@ void Entity::stake_heal(Ref info) { notification_sheal(SpellEnums::NOTIFICATION_HEAL_BEFORE_HIT, info); if (info->get_immune()) { - VRPCOBJ12(cheal_dealt_rpc, JSON::print(info->to_dict()), notification_cheal, SpellEnums::NOTIFICATION_HEAL_HEAL_DEALT, info); + VRPCOBJ12(cheal_dealt_rpc, JSON::stringify(info->to_dict()), notification_cheal, SpellEnums::NOTIFICATION_HEAL_HEAL_DEALT, info); return; } @@ -2782,7 +2784,7 @@ void Entity::stake_heal(Ref info) { hp->set_current_value(h); //send an event to client - VRPCOBJ12(cheal_dealt_rpc, JSON::print(info->to_dict()), notification_cheal, SpellEnums::NOTIFICATION_HEAL_HEAL_DEALT, info); + VRPCOBJ12(cheal_dealt_rpc, JSON::stringify(info->to_dict()), notification_cheal, SpellEnums::NOTIFICATION_HEAL_HEAL_DEALT, info); //signal emit_signal("son_heal_received", this, info); @@ -2802,7 +2804,7 @@ void Entity::sdeal_heal_to(Ref info) { info->receiver_get()->stake_heal(info); notification_sheal(SpellEnums::NOTIFICATION_HEAL_HEAL_DEALT, info); - VRPCOBJ12(cdealt_heal_rpc, JSON::print(info->to_dict()), notification_cheal, SpellEnums::NOTIFICATION_HEAL_DEALT_HEAL, info); + VRPCOBJ12(cdealt_heal_rpc, JSON::stringify(info->to_dict()), notification_cheal, SpellEnums::NOTIFICATION_HEAL_DEALT_HEAL, info); emit_signal("son_heal_dealt", this, info); } @@ -2906,7 +2908,7 @@ bool Entity::isc_target_in_interact_range() { bool Entity::_iss_target_in_interact_range() { Entity *t = gets_target(); - if (!ObjectDB::instance_validate(t)) { + if (!INSTANCE_VALIDATE(t)) { return false; } @@ -2939,7 +2941,7 @@ bool Entity::_iss_target_in_interact_range() { bool Entity::_isc_target_in_interact_range() { Entity *t = getc_target(); - if (!ObjectDB::instance_validate(t)) { + if (!INSTANCE_VALIDATE(t)) { return false; } @@ -3284,7 +3286,7 @@ void Entity::aura_adds(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_ADDED, aura); if (!aura->get_aura()->aura_get_hide()) - VRPCOBJ(aura_addc_rpc, JSON::print(aura->to_dict()), aura_addc, aura); + VRPCOBJ(aura_addc_rpc, JSON::stringify(aura->to_dict()), aura_addc, aura); } void Entity::aura_removes(Ref aura) { @@ -3299,7 +3301,7 @@ void Entity::aura_removes(Ref aura) { a = _s_auras.get(i); if (a->get_aura_id() == aid && a->caster_get() == caster) { - _s_auras.remove(i); + _s_auras.remove_at(i); removed = true; break; } @@ -3309,7 +3311,7 @@ void Entity::aura_removes(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, a); if (!aura->get_aura()->aura_get_hide()) - VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura); + VRPCOBJ(aura_removec_rpc, JSON::stringify(aura->to_dict()), aura_removec, aura); } } @@ -3322,7 +3324,7 @@ void Entity::aura_removes_exact(Ref aura) { if (ad == aura) { ad->get_aura()->son_remove(ad); - _s_auras.remove(i); + _s_auras.remove_at(i); break; } @@ -3331,7 +3333,7 @@ void Entity::aura_removes_exact(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura); if (!aura->get_aura()->aura_get_hide()) - VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura); + VRPCOBJ(aura_removec_rpc, JSON::stringify(aura->to_dict()), aura_removec, aura); } void Entity::aura_removes_expired(Ref aura) { @@ -3343,7 +3345,7 @@ void Entity::aura_removes_expired(Ref aura) { if (ad == aura) { ad->get_aura()->son_remove(ad); - _s_auras.remove(i); + _s_auras.remove_at(i); break; } @@ -3352,7 +3354,7 @@ void Entity::aura_removes_expired(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura); if (!aura->get_aura()->aura_get_hide()) - VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura); + VRPCOBJ(aura_removec_rpc, JSON::stringify(aura->to_dict()), aura_removec, aura); } void Entity::aura_removes_dispelled(Ref aura) { @@ -3364,7 +3366,7 @@ void Entity::aura_removes_dispelled(Ref aura) { if (ad == aura) { ad->get_aura()->son_remove(ad); - _s_auras.remove(i); + _s_auras.remove_at(i); break; } @@ -3373,7 +3375,7 @@ void Entity::aura_removes_dispelled(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, aura); if (!aura->get_aura()->aura_get_hide()) - VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura); + VRPCOBJ(aura_removec_rpc, JSON::stringify(aura->to_dict()), aura_removec, aura); } void Entity::aura_refresheds(Ref aura) { @@ -3385,7 +3387,7 @@ void Entity::aura_refresheds(Ref aura) { notification_saura(SpellEnums::NOTIFICATION_AURA_REFRESHED, aura); if (!aura->get_aura()->aura_get_hide()) - VRPCOBJ(aura_refreshedc_rpc, JSON::print(aura->to_dict()), aura_refreshedc, aura); + VRPCOBJ(aura_refreshedc_rpc, JSON::stringify(aura->to_dict()), aura_refreshedc, aura); } void Entity::aura_addc_rpc(String data) { @@ -3468,7 +3470,7 @@ void Entity::aura_removec(Ref aura) { a = _c_auras.get(i); if (a->get_aura_id() == aid && a->caster_get() == caster) { - _c_auras.remove(i); + _c_auras.remove_at(i); removed = true; break; } @@ -3484,7 +3486,7 @@ void Entity::aura_removec_exact(Ref aura) { for (int i = 0; i < _c_auras.size(); i++) { if (_c_auras.get(i) == aura) { - _c_auras.remove(i); + _c_auras.remove_at(i); break; } } @@ -3497,7 +3499,7 @@ void Entity::aura_removec_dispelled(Ref aura) { for (int i = 0; i < _c_auras.size(); i++) { if (_c_auras.get(i) == aura) { - _c_auras.remove(i); + _c_auras.remove_at(i); break; } } @@ -3519,7 +3521,7 @@ void Entity::aura_removec_expired(Ref aura) { for (int i = 0; i < _c_auras.size(); i++) { if (_c_auras.get(i) == aura) { - _c_auras.remove(i); + _c_auras.remove_at(i); break; } } @@ -3746,7 +3748,7 @@ void Entity::cast_starts(Ref info) { notification_scast(SpellEnums::NOTIFICATION_CAST_STARTED, info); - VRPCOBJ(cast_startc_rpc, JSON::print(info->to_dict()), cast_startc, info); + VRPCOBJ(cast_startc_rpc, JSON::stringify(info->to_dict()), cast_startc, info); } void Entity::cast_fails() { @@ -3823,7 +3825,7 @@ void Entity::cast_interruptc() { void Entity::cast_spell_successs(Ref info) { notification_scast(SpellEnums::NOTIFICATION_CAST_SUCCESS, info); - VRPCOBJ(cast_spell_successc_rpc, JSON::print(info->to_dict()), cast_spell_successc, info); + VRPCOBJ(cast_spell_successc_rpc, JSON::stringify(info->to_dict()), cast_spell_successc, info); } void Entity::cast_spell_successc_rpc(String data) { @@ -3878,7 +3880,7 @@ void Entity::cooldown_removes(int spell_id) { if (_s_cooldowns[i].id == spell_id) { float cd = _s_cooldowns[i].cooldown; - _s_cooldowns.remove(i); + _s_cooldowns.remove_at(i); notification_scooldown_removed(spell_id, cd); @@ -3940,7 +3942,7 @@ void Entity::cooldown_removec(int spell_id) { if (_c_cooldowns[i].id == spell_id) { float cd = _c_cooldowns[i].cooldown; - _c_cooldowns.remove(i); + _c_cooldowns.remove_at(i); notification_ccooldown_removed(spell_id, cd); @@ -4032,7 +4034,7 @@ void Entity::category_cooldown_removes(int category_id) { for (int i = 0; i < _s_category_cooldowns.size(); ++i) { if (_s_category_cooldowns[i].id == category_id) { cc = _s_category_cooldowns.get(i); - _s_category_cooldowns.remove(i); + _s_category_cooldowns.remove_at(i); found = true; break; @@ -4100,7 +4102,7 @@ void Entity::category_cooldown_removec(int category_id) { for (int i = 0; i < _c_category_cooldowns.size(); ++i) { if (_c_category_cooldowns[i].id == category_id) { cc = _c_category_cooldowns.get(i); - _c_category_cooldowns.remove(i); + _c_category_cooldowns.remove_at(i); found = true; break; @@ -4266,7 +4268,7 @@ void Entity::spell_adds_id(int id) { void Entity::spell_removes(Ref spell) { for (int i = 0; i < _s_spells.size(); ++i) { if (_s_spells.get(i) == spell) { - _s_spells.remove(i); + _s_spells.remove_at(i); break; } } @@ -4318,7 +4320,7 @@ void Entity::spell_addc(Ref spell) { void Entity::spell_removec(Ref spell) { for (int i = 0; i < _c_spells.size(); ++i) { if (_c_spells.get(i) == spell) { - _c_spells.remove(i); + _c_spells.remove_at(i); break; } } @@ -4391,7 +4393,7 @@ void Entity::skill_adds(Ref skill) { void Entity::skill_removes(Ref skill) { for (int i = 0; i < _s_skills.size(); ++i) { if (_s_skills.get(i) == skill) { - _s_skills.remove(i); + _s_skills.remove_at(i); break; } } @@ -4442,7 +4444,7 @@ void Entity::skill_addc(Ref skill) { void Entity::skill_removec(Ref skill) { for (int i = 0; i < _c_skills.size(); ++i) { if (_c_skills.get(i) == skill) { - _c_skills.remove(i); + _c_skills.remove_at(i); break; } } @@ -4488,7 +4490,7 @@ void Entity::skill_removec_id(int skill_id) { ERR_CONTINUE(!skill.is_valid()); if (skill->get_skill_id() == skill_id) { - _c_skills.remove(i); + _c_skills.remove_at(i); emit_signal("cskill_removed", this, skill); @@ -4566,7 +4568,7 @@ void Entity::aura_removess_with_group(Ref aura_group) { if (ad->get_aura()->aura_get_aura_group() == aura_group) { aura_removec(ad); - _s_auras.remove(i); + _s_auras.remove_at(i); emit_signal("saura_removed", ad); @@ -4582,8 +4584,8 @@ void Entity::target_crequest_change(NodePath path) { } void Entity::target_net_sets(NodePath path) { - Ref _multiplayer_api = get_multiplayer(); - if (!_multiplayer_api.is_valid() && !_multiplayer_api->is_server()) { + Ref multiplayer_api = get_multiplayer(); + if (!multiplayer_api.is_valid() && !multiplayer_api->is_server()) { return; } @@ -4653,7 +4655,8 @@ void Entity::sets_target(Node *p_target) { emit_signal("starget_changed", this, original_target); - if (is_inside_tree() && !get_tree()->has_network_peer()) { + Ref multiplayer_api = get_multiplayer(); + if (multiplayer_api.is_valid()) { setc_target(p_target); } } @@ -4844,7 +4847,7 @@ void Entity::class_talent_adds(int class_talent) { void Entity::class_talent_removes(int class_talent) { for (int i = 0; i < _s_class_talents.size(); ++i) { if (_s_class_talents[i] == class_talent) { - _s_class_talents.remove(i); + _s_class_talents.remove_at(i); for (int j = 0; j < aura_gets_count(); ++j) { Ref ad = aura_gets(j); @@ -4899,7 +4902,7 @@ void Entity::class_talent_addc(int class_talent) { void Entity::class_talent_removec(int class_talent) { for (int i = 0; i < _c_class_talents.size(); ++i) { if (_c_class_talents[i] == class_talent) { - _c_class_talents.remove(i); + _c_class_talents.remove_at(i); return; } } @@ -5091,7 +5094,7 @@ void Entity::character_talent_adds(int character_talent) { void Entity::character_talent_removes(int character_talent) { for (int i = 0; i < _s_character_talents.size(); ++i) { if (_s_character_talents[i] == character_talent) { - _s_character_talents.remove(i); + _s_character_talents.remove_at(i); for (int j = 0; j < aura_gets_count(); ++j) { Ref ad = aura_gets(j); @@ -5146,7 +5149,7 @@ void Entity::character_talent_addc(int character_talent) { void Entity::character_talent_removec(int character_talent) { for (int i = 0; i < _c_character_talents.size(); ++i) { if (_c_character_talents[i] == character_talent) { - _c_character_talents.remove(i); + _c_character_talents.remove_at(i); return; } } @@ -5227,7 +5230,7 @@ void Entity::sets_bag(const Ref bag) { emit_signal("sbag_changed", this, _s_bag); if (_s_bag.is_valid()) { - ORPC(setc_bag_rpc, JSON::print(_s_bag->to_dict())); + ORPC(setc_bag_rpc, JSON::stringify(_s_bag->to_dict())); } else { ORPC(setc_bag_rpc, ""); } @@ -5265,7 +5268,7 @@ void Entity::sets_target_bag(const Ref bag) { emit_signal("starget_bag_changed", this, _s_target_bag); if (_s_target_bag.is_valid()) { - ORPC(setc_target_bag_rpc, JSON::print(_s_target_bag->to_dict())); + ORPC(setc_target_bag_rpc, JSON::stringify(_s_target_bag->to_dict())); } else { ORPC(setc_target_bag_rpc, ""); } @@ -5316,7 +5319,7 @@ void Entity::lootc(int index) { } void Entity::notification_item_sadded(Ref bag, Ref item, int slot_id) { - ORPCOBJP(item_addc_rpc, slot_id, JSON::print(item->to_dict()), item_addc, slot_id, item); + ORPCOBJP(item_addc_rpc, slot_id, JSON::stringify(item->to_dict()), item_addc, slot_id, item); } void Entity::item_addc_rpc(int slot_id, String item_data) { Ref ii; @@ -5387,7 +5390,7 @@ void Entity::notification_soverburden_removed(Ref bag) { //Target Bag void Entity::notification_target_item_sadded(Ref bag, Ref item, int slot_id) { - ORPCOBJP(target_item_addc_rpc, slot_id, JSON::print(item->to_dict()), target_item_addc, slot_id, item); + ORPCOBJP(target_item_addc_rpc, slot_id, JSON::stringify(item->to_dict()), target_item_addc, slot_id, item); } void Entity::target_item_addc_rpc(int slot_id, String item_data) { Ref ii; @@ -5829,15 +5832,15 @@ Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Callable::Cal if (unlikely(e == NULL)) { #endif - _s_seen_by.remove(i); + _s_seen_by.remove_at(i); --i; continue; } - int netm = e->get_network_master(); + int netm = e->get_multiplayer_authority(); if (netm != 1) - rpcp(netm, false, method, &p_args[1], p_argcount - 1); + rpcp(netm, method, &p_args[1], p_argcount - 1); } //call(method, &p_args[1], p_argcount - 1); @@ -5852,13 +5855,7 @@ Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Callable::Cal } Dictionary Entity::data_as_dict(String &data) { - Error err; - String err_txt; - int err_line; - Variant v; - err = JSON::parse(data, v, err_txt, err_line); - - ERR_FAIL_COND_V(err != OK, v); + Variant v = JSON::parse_string(data); Dictionary d = v; @@ -6549,7 +6546,7 @@ void Entity::_notification(int p_what) { case NOTIFICATION_POSTINITIALIZE: { call("_initialize"); } break; - case NOTIFICATION_INSTANCED: { + case NOTIFICATION_SCENE_INSTANTIATED: { set_body(get_node_or_null(_body_path)); if (INSTANCE_VALIDATE(_body)) diff --git a/entities/resources/entity_resource.cpp b/entities/resources/entity_resource.cpp index 16d4936..9f19e4a 100644 --- a/entities/resources/entity_resource.cpp +++ b/entities/resources/entity_resource.cpp @@ -174,7 +174,7 @@ void EntityResource::add_stacking_mod(const float value) { void EntityResource::remove_stacking_mod(const float value) { for (int i = 0; i < _stacking_mods.size(); ++i) { if (Math::is_equal_approx(_stacking_mods[i], value)) { - _stacking_mods.remove(i); + _stacking_mods.remove_at(i); call("_stacking_mod_removed", value); return; } @@ -189,7 +189,7 @@ void EntityResource::add_non_stacking_mod(const float value) { void EntityResource::remove_non_stacking_mod(const float value) { for (int i = 0; i < _non_stacking_mods.size(); ++i) { if (Math::is_equal_approx(_non_stacking_mods[i], value)) { - _non_stacking_mods.remove(i); + _non_stacking_mods.remove_at(i); call("_non_stacking_mod_removed", value); return; } diff --git a/material_cache/ess_material_cache.cpp b/material_cache/ess_material_cache.cpp index faa3dbb..c5a658c 100644 --- a/material_cache/ess_material_cache.cpp +++ b/material_cache/ess_material_cache.cpp @@ -37,6 +37,7 @@ SOFTWARE. #endif #include "../singletons/ess.h" +#include "../../texture_packer/texture_packer.h" #define VARIANT_ARRAY_GET(arr) \ @@ -143,7 +144,7 @@ void ESSMaterialCache::texture_add(const Ref &texture) { void ESSMaterialCache::texture_remove(const Ref &texture) { for (int i = 0; i < _textures.size(); ++i) { if (_textures[i] == texture) { - _textures.remove(i); + _textures.remove_at(i); return; } } diff --git a/material_cache/ess_material_cache.h b/material_cache/ess_material_cache.h index 6275cbd..cad186e 100644 --- a/material_cache/ess_material_cache.h +++ b/material_cache/ess_material_cache.h @@ -29,11 +29,12 @@ SOFTWARE. #include "core/math/color.h" #include "core/templates/vector.h" - #include "core/math/rect2.h" #include "scene/resources/material.h" #include "core/os/mutex.h" +#include "../../texture_packer/texture_packer.h" + class PropData; class ESSMaterialCache : public Resource { diff --git a/material_cache/ess_material_cache_pcm.cpp b/material_cache/ess_material_cache_pcm.cpp index 5ca0a95..d0743ce 100644 --- a/material_cache/ess_material_cache_pcm.cpp +++ b/material_cache/ess_material_cache_pcm.cpp @@ -87,7 +87,7 @@ Rect2 ESSMaterialCachePCM::texture_get_uv_rect(const Ref &texture) { return Rect2(0, 0, 1, 1); } - Ref image = tex->get_data(); + Ref image = tex->get_image(); if (!image.is_valid()) { return Rect2(0, 0, 1, 1); @@ -147,17 +147,17 @@ void ESSMaterialCachePCM::_setup_material_albedo(Ref texture) { for (int i = 0; i < count; ++i) { Ref m = material_get(i); - Ref spmat = m; + Ref spmat = m; if (spmat.is_valid()) { - spmat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); + spmat->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture); return; } Ref shmat = m; if (shmat.is_valid()) { - shmat->set_shader_param("texture_albedo", texture); + shmat->set_shader_parameter("texture_albedo", texture); } } } diff --git a/material_cache/ess_material_cache_pcm.h b/material_cache/ess_material_cache_pcm.h index e7705ef..f94c397 100644 --- a/material_cache/ess_material_cache_pcm.h +++ b/material_cache/ess_material_cache_pcm.h @@ -31,9 +31,11 @@ SOFTWARE. #include "core/math/color.h" #include "core/templates/vector.h" - #include "core/math/rect2.h" #include "scene/resources/material.h" +#include "scene/resources/texture.h" + +#include "../../texture_packer/texture_packer.h" class TexturePacker; class PropData; diff --git a/singletons/ess.cpp b/singletons/ess.cpp index 1eddb30..586d1a3 100644 --- a/singletons/ess.cpp +++ b/singletons/ess.cpp @@ -26,6 +26,7 @@ SOFTWARE. #include "../material_cache/ess_material_cache.h" #include "../spawners/ess_entity_spawner.h" #include "../utility/entity_create_info.h" +#include "core/config/project_settings.h" ESS *ESS::instance; @@ -117,8 +118,6 @@ void ESS::request_entity_spawn_deferred(Ref info) { } void ESS::load_resource_db() { - _Directory dir; - ERR_FAIL_COND(_ess_resource_db_path == ""); Ref d = load_resource(_ess_resource_db_path, "ESSResourceDB"); @@ -153,7 +152,7 @@ void ESS::stat_set_string(const String &stat_enum_string) { StringName s = StringName(slice); _stat_id_to_name.set(i, s); - _stat_name_to_id.set(s, i); + _stat_name_to_id[s] = i; String st = slice; st = st.to_lower(); @@ -161,7 +160,7 @@ void ESS::stat_set_string(const String &stat_enum_string) { StringName stp = StringName(st); _stat_id_to_property.set(i, stp); - _stat_property_to_id.set(stp, i); + _stat_property_to_id[stp] = i; } } String ESS::stat_get_string() const { @@ -227,7 +226,7 @@ void ESS::stats_set(const PoolStringArray &array) { StringName s = StringName(array[i]); _stat_id_to_name.set(i, s); - _stat_name_to_id.set(s, i); + _stat_name_to_id[s] = i; String st = array[i]; st = st.to_lower(); @@ -235,7 +234,7 @@ void ESS::stats_set(const PoolStringArray &array) { StringName stp = StringName(st); _stat_id_to_property.set(i, stp); - _stat_property_to_id.set(stp, i); + _stat_property_to_id[stp] = i; _stat_enum_string += ","; _stat_enum_string += array[i]; @@ -266,7 +265,7 @@ void ESS::equip_slot_set_string(const String &equip_slot_enum_string) { StringName s = StringName(slice); _equip_slot_id_to_name.set(i, s); - _equip_slot_name_to_id.set(s, i); + _equip_slot_name_to_id[s] = i; String st = slice; st = st.to_lower(); @@ -274,7 +273,7 @@ void ESS::equip_slot_set_string(const String &equip_slot_enum_string) { StringName stp = StringName(st); _equip_slot_id_to_property.set(i, stp); - _equip_slot_property_to_id.set(stp, i); + _equip_slot_property_to_id[stp] = i; } _equip_slot_enum_string = equip_slot_enum_string + ",None"; @@ -342,7 +341,7 @@ void ESS::equip_slots_set(const PoolStringArray &array) { StringName s = StringName(array[i]); _equip_slot_id_to_name.set(i, s); - _equip_slot_name_to_id.set(s, i); + _equip_slot_name_to_id[s] = i; String st = array[i]; st = st.to_lower(); @@ -350,7 +349,7 @@ void ESS::equip_slots_set(const PoolStringArray &array) { StringName stp = StringName(st); _equip_slot_id_to_property.set(i, stp); - _equip_slot_property_to_id.set(stp, i); + _equip_slot_property_to_id[stp] = i; _equip_slot_enum_string += ","; _equip_slot_enum_string += array[i]; @@ -624,7 +623,7 @@ Ref ESS::material_cache_get(const uint64_t key) { return m; } - ESSMaterialCache *p = Object::cast_to(ClassDB::instance(_default_ess_material_cache_class)); + ESSMaterialCache *p = Object::cast_to(ClassDB::instantiate(_default_ess_material_cache_class)); if (!p) { ERR_PRINT("Can't instance the given ESSMaterialCache! class_name: " + String(_default_ess_material_cache_class)); @@ -660,19 +659,7 @@ void ESS::material_cache_unref(const uint64_t key) { } Ref ESS::load_resource(const String &path, const String &type_hint) { - _ResourceLoader *rl = _ResourceLoader::get_singleton(); - -#if VERSION_MAJOR < 4 - Ref resl = rl->load_interactive(path, type_hint); - - ERR_FAIL_COND_V(!resl.is_valid(), Ref()); - - resl->wait(); - - return resl->get_resource(); -#else - return rl->load(path, type_hint); -#endif + return ResourceLoader::load(path, type_hint); } void ESS::_bind_methods() { diff --git a/singletons/profile_manager.cpp b/singletons/profile_manager.cpp index 91fe823..31cae21 100644 --- a/singletons/profile_manager.cpp +++ b/singletons/profile_manager.cpp @@ -22,7 +22,7 @@ SOFTWARE. #include "profile_manager.h" #include "core/io/json.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/version.h" @@ -98,14 +98,14 @@ void ProfileManager::load() { void ProfileManager::_save() { Error err; - FileAccess *f = FileAccess::open(_save_file, FileAccess::WRITE, &err); + Ref f = FileAccess::open(_save_file, FileAccess::WRITE, &err); - if (!f) { + if (!f.is_valid()) { ERR_FAIL_MSG("Couldn't open file: " + err); } - f->store_line(JSON::print(to_dict())); - f->close(); + f->store_line(JSON::stringify(to_dict())); + //f->close(); } void ProfileManager::_load() { @@ -120,14 +120,11 @@ void ProfileManager::_load() { ERR_FAIL_MSG("Couldn't open file: " + err); } - String err_txt; - int err_line; - Variant v; - err = JSON::parse(text, v, err_txt, err_line); + Variant v = JSON::parse_string(text); - if (err) { + if (v.get_type() == Variant::NIL) { load_defaults(); - ERR_FAIL_MSG("Error parsing profile: " + err); + ERR_FAIL_MSG("Error parsing profile"); } Dictionary d = v; diff --git a/skeleton/character_skeleton_2d.cpp b/skeleton/character_skeleton_2d.cpp index cd654ee..be31ec7 100644 --- a/skeleton/character_skeleton_2d.cpp +++ b/skeleton/character_skeleton_2d.cpp @@ -307,7 +307,7 @@ void CharacterSkeleton2D::remove_model_visual_entry(Ref vis, Refset_count(e->get_count() - 1); if (e->get_count() <= 0) { - entries.remove(i); + entries.remove_at(i); _model_dirty = true; set_process(true); @@ -373,15 +373,15 @@ Array CharacterSkeleton2D::merge_mesh_array(Array arr) const { int rem = equals[k]; int remk = rem - k; - verts.remove(remk); - normals.remove(remk); - uvs.remove(remk); - colors.remove(remk); + verts.remove_at(remk); + normals.remove_at(remk); + uvs.remove_at(remk); + colors.remove_at(remk); int bindex = remk * 4; for (int l = 0; l < 4; ++l) { - bones.remove(bindex); - weights.remove(bindex); + bones.remove_at(bindex); + weights.remove_at(bindex); } for (int j = 0; j < indices.size(); ++j) { @@ -411,7 +411,7 @@ Array CharacterSkeleton2D::bake_mesh_array_uv(Array arr, Ref tex, float ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); ERR_FAIL_COND_V(!tex.is_valid(), arr); - Ref img = tex->get_data(); + Ref img = tex->get_image(); ERR_FAIL_COND_V(!img.is_valid(), arr); diff --git a/skeleton/character_skeleton_3d.cpp b/skeleton/character_skeleton_3d.cpp index 9f8e083..c7e477c 100644 --- a/skeleton/character_skeleton_3d.cpp +++ b/skeleton/character_skeleton_3d.cpp @@ -347,7 +347,7 @@ void CharacterSkeleton3D::remove_model_visual_entry(Ref vis, Refset_count(e->get_count() - 1); if (e->get_count() <= 0) { - entries.remove(i); + entries.remove_at(i); _model_dirty = true; set_process(true); @@ -413,15 +413,15 @@ Array CharacterSkeleton3D::merge_mesh_array(Array arr) const { int rem = equals[k]; int remk = rem - k; - verts.remove(remk); - normals.remove(remk); - uvs.remove(remk); - colors.remove(remk); + verts.remove_at(remk); + normals.remove_at(remk); + uvs.remove_at(remk); + colors.remove_at(remk); int bindex = remk * 4; for (int l = 0; l < 4; ++l) { - bones.remove(bindex); - weights.remove(bindex); + bones.remove_at(bindex); + weights.remove_at(bindex); } for (int j = 0; j < indices.size(); ++j) { @@ -451,7 +451,7 @@ Array CharacterSkeleton3D::bake_mesh_array_uv(Array arr, Ref tex, float ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); ERR_FAIL_COND_V(!tex.is_valid(), arr); - Ref img = tex->get_data(); + Ref img = tex->get_image(); ERR_FAIL_COND_V(!img.is_valid(), arr); diff --git a/utility/entity_create_info.cpp b/utility/entity_create_info.cpp index 2a9b957..32f63eb 100644 --- a/utility/entity_create_info.cpp +++ b/utility/entity_create_info.cpp @@ -273,7 +273,7 @@ void EntityCreateInfo::_bind_methods() { ClassDB::bind_method(D_METHOD("get_transform2d"), &EntityCreateInfo::get_transform2d); ClassDB::bind_method(D_METHOD("set_transform2d", "value"), &EntityCreateInfo::set_transform2d); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D2D, "transform2d"), "set_transform2d", "get_transform2d"); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform2d"), "set_transform2d", "get_transform2d"); ClassDB::bind_method(D_METHOD("get_entity_data"), &EntityCreateInfo::get_entity_data); ClassDB::bind_method(D_METHOD("set_entity_data", "value"), &EntityCreateInfo::set_entity_data); diff --git a/utility/entity_create_info.h b/utility/entity_create_info.h index 0bfdde4..68068b7 100644 --- a/utility/entity_create_info.h +++ b/utility/entity_create_info.h @@ -34,6 +34,7 @@ SOFTWARE. class EntityData; class SpeciesInstance; class Entity; +class Node; class EntityCreateInfo : public RefCounted { GDCLASS(EntityCreateInfo, RefCounted);