summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-11-22 23:54:34 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-11-22 23:54:34 +0000
commit1bb03e1549a9050049bc027566a448a530298b64 (patch)
tree608261af5fedb40990629bf14a434b918afe470b /src/map/itemdb.c
parent69fc1bcd69e4094d5e232acabf2a19376395d501 (diff)
downloadhercules-1bb03e1549a9050049bc027566a448a530298b64.tar.gz
hercules-1bb03e1549a9050049bc027566a448a530298b64.tar.bz2
hercules-1bb03e1549a9050049bc027566a448a530298b64.tar.xz
hercules-1bb03e1549a9050049bc027566a448a530298b64.zip
* Hunted down improper uses of va_list variables.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13383 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 3bcd07cf1..1cc7a5cb4 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -255,13 +255,13 @@ static void create_dummy_data(void)
dummy_item.view_id=UNKNOWN_ITEM_ID;
}
-static void* create_item_data(DBKey key, va_list args)
+static struct item_data* create_item_data(int nameid)
{
struct item_data *id;
CREATE(id, struct item_data, 1);
- id->nameid=key.i;
- id->weight=1;
- id->type=IT_ETC;
+ id->nameid = nameid;
+ id->weight = 1;
+ id->type = IT_ETC;
return id;
}
@@ -271,50 +271,42 @@ static void* create_item_data(DBKey key, va_list args)
struct item_data* itemdb_load(int nameid)
{
struct item_data *id;
- DBKey key;
if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) )
{
id = itemdb_array[nameid];
- if( id == NULL )
- {
- key.i = nameid;
- id = itemdb_array[nameid] = (struct item_data*)create_item_data(key, NULL);
- }
+ if( id == NULL || id == &dummy_item )
+ id = itemdb_array[nameid] = create_item_data(nameid);
return id;
}
- id = (struct item_data*)idb_ensure(itemdb_other, nameid, create_item_data);
- if( id == &dummy_item )
- {// Remove dummy_item, replace by real data.
- key.i = nameid;
- id = (struct item_data*)create_item_data(key, NULL);
+ id = (struct item_data*)idb_get(itemdb_other, nameid);
+ if( id == NULL || id == &dummy_item )
+ {
+ id = create_item_data(nameid);
idb_put(itemdb_other, nameid, id);
}
return id;
}
-static void* return_dummy_data(DBKey key, va_list args)
-{
- ShowWarning("itemdb_search: Item ID %d does not exists in the item_db. Using dummy data.\n", key.i);
- dummy_item.nameid = key.i;
- return &dummy_item;
-}
-
/*==========================================
* Loads an item from the db. If not found, it will return the dummy item.
*------------------------------------------*/
struct item_data* itemdb_search(int nameid)
{
+ struct item_data* id;
if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) )
+ id = itemdb_array[nameid];
+ else
+ id = (struct item_data*)idb_get(itemdb_other, nameid);
+
+ if( id == NULL )
{
- DBKey key;
- if( itemdb_array[nameid] )
- return itemdb_array[nameid];
- key.i = nameid;
- return (struct item_data*)return_dummy_data(key, NULL);
+ ShowWarning("itemdb_search: Item ID %d does not exists in the item_db. Using dummy data.\n", nameid);
+ id = &dummy_item;
+ dummy_item.nameid = nameid;
}
- return (struct item_data*)idb_ensure(itemdb_other,nameid,return_dummy_data);
+ return id;
}
/*==========================================