summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog.txt2
-rw-r--r--src/map/npc.c14
-rw-r--r--src/map/npc.h2
-rw-r--r--src/map/script.c5
4 files changed, 13 insertions, 10 deletions
diff --git a/Changelog.txt b/Changelog.txt
index bd0e191f9..b2bee6cfd 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,5 +1,7 @@
Date Added
01/11
+ * Added Shinomori's changes to npc event timers (I never realised it, thanks
+ ^^; ) [celest]
* Updated clif.c to be able to identify client versions based on the packet DB
[celest]
* Correct packet_db_ver to the maximum version allowed if it was set too high
diff --git a/src/map/npc.c b/src/map/npc.c
index ff752192a..0186fe6de 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -596,7 +596,7 @@ int npc_timerevent(int tid,unsigned int tick,int id,int data)
* タイマーイベント開始
*------------------------------------------
*/
-int npc_timerevent_start(struct npc_data *nd)
+int npc_timerevent_start(struct npc_data *nd, int rid)
{
int j,n, next;
@@ -610,12 +610,13 @@ int npc_timerevent_start(struct npc_data *nd)
if( nd->u.scr.timer_event[j].timer > nd->u.scr.timer )
break;
}
+ if(j>=n) // check if there is a timer to use !!BEFORE!! you write stuff to the structures [Shinomori]
+ return 0;
+
nd->u.scr.nexttimer=j;
nd->u.scr.timertick=gettick();
- nd->u.scr.rid=0; // reset attached player [celest]
-
- if(j>=n)
- return 0;
+ if (rid >= 0) nd->u.scr.rid=rid; // changed to: attaching to given rid by default [Shinomori]
+ // if rid is less than 0 leave it unchanged [celest]
next = nd->u.scr.timer_event[j].timer - nd->u.scr.timer;
nd->u.scr.timerid = add_timer(gettick()+next,npc_timerevent,nd->bl.id,next);
@@ -635,6 +636,7 @@ int npc_timerevent_stop(struct npc_data *nd)
if(nd->u.scr.timerid!=-1)
delete_timer(nd->u.scr.timerid,npc_timerevent);
nd->u.scr.timerid = -1;
+ nd->u.scr.rid = 0;
}
return 0;
}
@@ -669,7 +671,7 @@ int npc_settimerevent_tick(struct npc_data *nd,int newtimer)
npc_timerevent_stop(nd);
nd->u.scr.timer=newtimer;
if(flag>=0)
- npc_timerevent_start(nd);
+ npc_timerevent_start(nd, -1);
return 0;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index b3b38e5e0..a68cc8e54 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -42,7 +42,7 @@ int npc_do_ontimer(int,struct map_session_data *,int);
int npc_event_doall(const char *name);
int npc_event_do(const char *name);
-int npc_timerevent_start(struct npc_data *nd);
+int npc_timerevent_start(struct npc_data *nd, int rid);
int npc_timerevent_stop(struct npc_data *nd);
int npc_gettimerevent_tick(struct npc_data *nd);
int npc_settimerevent_tick(struct npc_data *nd,int newtimer);
diff --git a/src/map/script.c b/src/map/script.c
index 64e4a7692..a6b65e213 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3892,8 +3892,7 @@ int buildin_initnpctimer(struct script_state *st)
nd=(struct npc_data *)map_id2bl(st->oid);
npc_settimerevent_tick(nd,0);
- npc_timerevent_start(nd);
- nd->u.scr.rid=st->rid;
+ npc_timerevent_start(nd, st->rid);
return 0;
}
/*==========================================
@@ -3908,7 +3907,7 @@ int buildin_startnpctimer(struct script_state *st)
else
nd=(struct npc_data *)map_id2bl(st->oid);
- npc_timerevent_start(nd);
+ npc_timerevent_start(nd, st->rid);
return 0;
}
/*==========================================