From da2a116426e14182fcb571065d8b13d0cb1cf05c Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 19 Apr 2020 18:42:11 +0200 Subject: [PATCH] Convert saving learned spells and recipes to use paths aswell. --- entities/entity.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/entities/entity.cpp b/entities/entity.cpp index 23cf435..5871439 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -649,10 +649,10 @@ void Entity::_setup(Ref info) { Ref class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path()); if (class_profile.is_valid() && class_profile->has_custom_data("spells")) { - Vector spells = class_profile->get_custom_data("spells"); + Vector spells = class_profile->get_custom_data("spells"); for (int i = 0; i < spells.size(); ++i) { - adds_spell_id(spells.get(i)); + adds_spell_id(ESS::get_instance()->get_resource_db()->spell_path_to_id(spells.get(i))); } } } @@ -661,10 +661,10 @@ void Entity::_setup(Ref info) { Ref class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path()); if (class_profile.is_valid() && class_profile->has_custom_data("recipes")) { - Vector recipes = class_profile->get_custom_data("recipes"); + Vector recipes = class_profile->get_custom_data("recipes"); for (int i = 0; i < recipes.size(); ++i) { - adds_craft_recipe_id(recipes.get(i)); + adds_craft_recipe_id(ESS::get_instance()->get_resource_db()->craft_recipe_path_to_id(recipes.get(i))); } } } @@ -1555,24 +1555,24 @@ void Entity::adds_craft_recipe_id(int id) { Ref class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path()); if (class_profile->has_custom_data("recipes")) { - Vector recipes = class_profile->get_custom_data("recipes"); + Vector recipes = class_profile->get_custom_data("recipes"); bool found = false; for (int i = 0; i < recipes.size(); ++i) { - if (recipes[i] == id) { + if (recipes[i] == craft_recipe->get_path()) { found = true; break; } } if (!found) { - recipes.push_back(id); + recipes.push_back(craft_recipe->get_path()); class_profile->set_custom_data("recipes", recipes); } } else { - Vector recipes; - recipes.push_back(id); + Vector recipes; + recipes.push_back(craft_recipe->get_path()); class_profile->set_custom_data("recipes", recipes); } } @@ -4543,25 +4543,25 @@ void Entity::adds_spell(Ref spell) { Ref class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path()); if (class_profile->has_custom_data("spells")) { - Vector spells = class_profile->get_custom_data("spells"); + Vector spells = class_profile->get_custom_data("spells"); bool found = false; for (int i = 0; i < spells.size(); ++i) { - if (spells[i] == id) { + if (spells[i] == spell->get_path()) { found = true; break; } } if (!found) { - spells.push_back(id); + spells.push_back(spell->get_path()); class_profile->set_custom_data("spells", spells); } } else { - Vector spells; - spells.push_back(id); + Vector spells; + spells.push_back(spell->get_path()); class_profile->set_custom_data("spells", spells); } }