Bladeren bron

- One closer inspection, removed that clear in itemdb_reload for a foreach call again. And modified itemdb_load to scrap the dummy item entry from the item_db and replace it with proper data for the item.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7597 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 jaren geleden
bovenliggende
commit
7040dc1031
2 gewijzigde bestanden met toevoegingen van 14 en 2 verwijderingen
  1. 3 0
      Changelog-Trunk.txt
  2. 11 2
      src/map/itemdb.c

+ 3 - 0
Changelog-Trunk.txt

@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/07/10
+	* One closer inspection, removed that clear in itemdb_reload for a foreach
+	  call again. And modified itemdb_load to scrap the dummy item entry from the
+	  item_db and replace it with proper data for the item. [Skotlex]
 	* itemdb_reload will clear the itemdb before reloading info instead of only
 	  clearing the scripts now. [Skotlex]
 	* Some cleaning of skill_castend_pos2, fixed Gospel, and a

+ 11 - 2
src/map/itemdb.c

@@ -228,7 +228,16 @@ static void* create_item_data(DBKey key, va_list args) {
  */
 struct item_data* itemdb_load(int nameid)
 {
-	return idb_ensure(item_db,nameid,create_item_data);
+	struct item_data *id = idb_ensure(item_db,nameid,create_item_data);
+	if (id == &dummy_item)
+  	{	//Remove dummy_item, replace by real data.
+		DBKey key;
+		key.i = nameid;
+		idb_remove(item_db,nameid);
+		id = create_item_data(key, NULL);
+		idb_put(item_db,nameid,id);
+	}
+	return id;
 }
 
 static void* return_dummy_data(DBKey key, va_list args) {
@@ -1193,7 +1202,7 @@ static int itemdb_final_sub (DBKey key,void *data,va_list ap)
 void itemdb_reload(void)
 {
 	// free up all item scripts first
-	item_db->clear(item_db, itemdb_final_sub, 0);
+	item_db->foreach(item_db, itemdb_final_sub, 0);
 	itemdb_read();
 }