summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 86d649cde..fb806cdd2 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -284,17 +284,19 @@ static int npc_event_export(struct npc_data *nd, int i)
CREATE(ev, struct event_data, 1);
ev->nd = nd;
ev->pos = pos;
- if (strdb_put(ev_db, buf, ev) != NULL) // There was already another event of the same name?
+ if (strdb_put(ev_db, buf, ev)) // There was already another event of the same name?
return 1;
}
return 0;
}
int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char* eventname); //[Lance]
-/*==========================================
+
+/**
* 全てのNPCのOn*イベント実行
- *------------------------------------------*/
-int npc_event_doall_sub(DBKey key, void* data, va_list ap)
+ * @see DBApply
+ */
+int npc_event_doall_sub(DBKey key, DBData *data, va_list ap)
{
const char* p = key.str;
struct event_data* ev;
@@ -302,7 +304,7 @@ int npc_event_doall_sub(DBKey key, void* data, va_list ap)
const char* name;
int rid;
- nullpo_ret(ev = (struct event_data *)data);
+ nullpo_ret(ev = db_data2ptr(data));
nullpo_ret(c = va_arg(ap, int *));
nullpo_ret(name = va_arg(ap, const char *));
rid = va_arg(ap, int);
@@ -320,14 +322,17 @@ int npc_event_doall_sub(DBKey key, void* data, va_list ap)
return 0;
}
-static int npc_event_do_sub(DBKey key, void* data, va_list ap)
+/**
+ * @see DBApply
+ */
+static int npc_event_do_sub(DBKey key, DBData *data, va_list ap)
{
const char* p = key.str;
struct event_data* ev;
int* c;
const char* name;
- nullpo_ret(ev = (struct event_data *)data);
+ nullpo_ret(ev = db_data2ptr(data));
nullpo_ret(c = va_arg(ap, int *));
nullpo_ret(name = va_arg(ap, const char *));
@@ -1675,9 +1680,12 @@ int npc_remove_map(struct npc_data* nd)
return 0;
}
-static int npc_unload_ev(DBKey key, void* data, va_list ap)
+/**
+ * @see DBApply
+ */
+static int npc_unload_ev(DBKey key, DBData *data, va_list ap)
{
- struct event_data* ev = (struct event_data *)data;
+ struct event_data* ev = db_data2ptr(data);
char* npcname = va_arg(ap, char *);
if(strcmp(ev->nd->exname,npcname)==0){
@@ -2133,13 +2141,14 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
return strchr(start,'\n');// continue
}
-/*==========================================
+/**
* NPCのラベルデータコンバート
- *------------------------------------------*/
-int npc_convertlabel_db(DBKey key, void* data, va_list ap)
+ * @see DBApply
+ */
+int npc_convertlabel_db(DBKey key, DBData *data, va_list ap)
{
const char* lname = (const char*)key.str;
- int lpos = (int)data;
+ int lpos = (int)db_data2ptr(data);
struct npc_label_list** label_list;
int* label_list_num;
const char* filepath;
@@ -2709,8 +2718,8 @@ void npc_setclass(struct npc_data* nd, short class_)
static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
{
DBMap* func_db;
+ DBData old_data;
struct script_code *script;
- struct script_code *oldscript;
const char* end;
const char* script_start;
@@ -2732,9 +2741,9 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co
return end;
func_db = script_get_userfunc_db();
- oldscript = (struct script_code*)strdb_put(func_db, w3, script);
- if( oldscript != NULL )
+ if (func_db->put(func_db, db_str2key(w3), db_ptr2data(script), &old_data))
{
+ struct script_code *oldscript = db_data2ptr(&old_data);
ShowInfo("npc_parse_function: Overwriting user function [%s] (%s:%d)\n", w3, filepath, strline(buffer,start-buffer));
script_free_vars(&oldscript->script_vars);
aFree(oldscript->script_buf);
@@ -3358,7 +3367,7 @@ void npc_read_event_script(void)
{
DBIterator* iter;
DBKey key;
- void* data;
+ DBData *data;
char name[64]="::";
strncpy(name+2,config[i].event_name,62);
@@ -3368,7 +3377,7 @@ void npc_read_event_script(void)
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) )
{
const char* p = key.str;
- struct event_data* ed = (struct event_data*) data;
+ struct event_data* ed = db_data2ptr(data);
unsigned char count = script_event[i].event_count;
if( count >= ARRAYLENGTH(script_event[i].event) )