diff --git a/src/common/database.cpp b/src/common/database.cpp index 0174b5cab9..535e65811e 100644 --- a/src/common/database.cpp +++ b/src/common/database.cpp @@ -84,7 +84,11 @@ bool YamlDatabase::verifyCompatibility( const YAML::Node& rootNode ){ } bool YamlDatabase::load(){ - return this->load( this->getDefaultLocation() ); + bool ret = this->load( this->getDefaultLocation() ); + + this->loadingFinished(); + + return ret; } bool YamlDatabase::reload(){ @@ -128,8 +132,6 @@ bool YamlDatabase::load(const std::string& path) { this->parseImports( rootNode ); - this->loadingFinished(); - return true; } diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 108c7a1045..18e6d4d24e 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -1019,6 +1019,23 @@ uint64 ItemDatabase::parseBodyNode(const YAML::Node &node) { return 1; } +void ItemDatabase::loadingFinished(){ + if( !this->exists( ITEMID_DUMMY ) ){ + // Create dummy item + std::shared_ptr dummy_item = std::make_shared(); + + dummy_item->nameid = ITEMID_DUMMY; + dummy_item->weight = 1; + dummy_item->value_sell = 1; + dummy_item->type = IT_ETC; + dummy_item->name = "UNKNOWN_ITEM"; + dummy_item->ename = "Unknown Item"; + dummy_item->view_id = UNKNOWN_ITEM_ID; + + item_db.put( ITEMID_DUMMY, dummy_item ); + } +} + ItemDatabase item_db; /** @@ -1364,23 +1381,6 @@ static void itemdb_jobid2mapid(uint64 bclass[3], e_mapid jobmask, bool active) } } -/** - * Create dummy item_data - */ -static void itemdb_create_dummy(void) { - std::shared_ptr dummy_item; - - dummy_item = std::make_shared(); - dummy_item->nameid = ITEMID_DUMMY; - dummy_item->weight = 1; - dummy_item->value_sell = 1; - dummy_item->type = IT_ETC; - dummy_item->name = "UNKNOWN_ITEM"; - dummy_item->ename = "Unknown Item"; - dummy_item->view_id = UNKNOWN_ITEM_ID; - item_db.put(ITEMID_DUMMY, dummy_item); -} - /*========================================== * Loads an item from the db. If not found, it will return the dummy item. * @param nameid @@ -2758,7 +2758,6 @@ void do_final_itemdb(void) { */ void do_init_itemdb(void) { itemdb_group = uidb_alloc(DB_OPT_BASE); - itemdb_create_dummy(); itemdb_read(); if (battle_config.feature_roulette) diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp index bfbd29d773..22750d5a2e 100644 --- a/src/map/itemdb.hpp +++ b/src/map/itemdb.hpp @@ -989,6 +989,7 @@ public: const std::string getDefaultLocation(); uint64 parseBodyNode(const YAML::Node& node); + void loadingFinished(); }; extern ItemDatabase item_db; diff --git a/src/tool/csv2yaml.cpp b/src/tool/csv2yaml.cpp index c41685c0b8..fd9dd116ea 100644 --- a/src/tool/csv2yaml.cpp +++ b/src/tool/csv2yaml.cpp @@ -763,6 +763,9 @@ uint64 ItemDatabase::parseBodyNode(const YAML::Node& node) { return 1; } +void ItemDatabase::loadingFinished(){ +} + ItemDatabase item_db; static bool parse_mob_constants( char* split[], int columns, int current ){