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.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 46e6d0fd2..d90f87f5d 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -610,18 +610,14 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
ShowError("npc_timerevent_start: Attached player not found!\n");
return 1;
}
-
// Check if timer is already started.
- if( sd )
- {
+ if( sd ) {
if( sd->npc_timer_id != INVALID_TIMER )
return 0;
- }
- else if( nd->u.scr.timerid != INVALID_TIMER || nd->u.scr.timertick )
+ } else if( nd->u.scr.timerid != INVALID_TIMER || nd->u.scr.timertick )
return 0;
- if (j < nd->u.scr.timeramount)
- {
+ if (j < nd->u.scr.timeramount) {
int next;
struct timer_event_data *ted;
// Arrange for the next event
@@ -640,10 +636,10 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
nd->u.scr.timertick = tick; // Set when timer is started
nd->u.scr.timerid = iTimer->add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted);
}
- }
- else if (!sd)
- {
+
+ } else if (!sd) {
nd->u.scr.timertick = tick;
+
}
return 0;
@@ -664,7 +660,6 @@ int npc_timerevent_stop(struct npc_data* nd)
ShowError("npc_timerevent_stop: Attached player not found!\n");
return 1;
}
-
tid = sd?&sd->npc_timer_id:&nd->u.scr.timerid;
if( *tid == INVALID_TIMER && (sd || !nd->u.scr.timertick) ) // Nothing to stop
return 0;
@@ -785,7 +780,7 @@ int npc_settimerevent_tick(struct npc_data* nd, int newtimer)
nd->u.scr.rid = 0;
// Check if timer is started
- flag = (nd->u.scr.timerid != INVALID_TIMER);
+ flag = (nd->u.scr.timerid != INVALID_TIMER || nd->u.scr.timertick);
if( flag ) npc_timerevent_stop(nd);
nd->u.scr.timer = newtimer;
@@ -1322,7 +1317,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
nameid = item_list[i*2+1];
amount = item_list[i*2+0];
- if( !itemdb_exists(nameid) || amount <= 0 )
+ if( !itemdb->exists(nameid) || amount <= 0 )
return 5;
ARR_FIND(0,nd->u.shop.count,j,nd->u.shop.shop_item[j].nameid == nameid);
@@ -1427,7 +1422,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
if( sd->state.trading )
return 4;
- if( (item = itemdb_exists(nameid)) == NULL )
+ if( (item = itemdb->exists(nameid)) == NULL )
return 5; // Invalid Item
ARR_FIND(0, nd->u.shop.count, i, nd->u.shop.shop_item[i].nameid == nameid);
@@ -1526,7 +1521,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
nameid = item_list[i*2+1] = nd->u.shop.shop_item[j].nameid; //item_avail replacement
value = nd->u.shop.shop_item[j].value;
- if( !itemdb_exists(nameid) )
+ if( !itemdb->exists(nameid) )
return 3; // item no longer in itemdb
if( !itemdb_isstackable(nameid) && amount > 1 ) {
@@ -2211,7 +2206,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
break;
}
- if( (id = itemdb_exists(nameid)) == NULL )
+ if( (id = itemdb->exists(nameid)) == NULL )
{
ShowWarning("npc_parse_shop: Invalid sell item in file '%s', line '%d' (id '%d').\n", filepath, strline(buffer,start-buffer), nameid);
p = strchr(p+1,',');
@@ -3230,7 +3225,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
int drop_id = 0, drop_type = 0;
if (!strcmpi(drop_arg1, "random"))
drop_id = -1;
- else if (itemdb_exists((drop_id = atoi(drop_arg1))) == NULL)
+ else if (itemdb->exists((drop_id = atoi(drop_arg1))) == NULL)
drop_id = 0;
if (!strcmpi(drop_arg2, "inventory"))
drop_type = 1;
@@ -3850,6 +3845,9 @@ int npc_reload(void) {
npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */
+ /* re-insert */
+ itemdb->name_constants();
+
//Re-read the NPC Script Events cache.
npc_read_event_script();