diff options
author | shinomori <shinomori@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-02-14 20:50:40 +0000 |
---|---|---|
committer | shinomori <shinomori@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-02-14 20:50:40 +0000 |
commit | 8fa0cea72c24c464e4e43b081316af34dcf30af7 (patch) | |
tree | de29a771617152dcae91189222be42efd19a8ead /src/map/npc.c | |
parent | 61980833a1b7ffe229712f782f14425ab4fef90e (diff) | |
download | hercules-8fa0cea72c24c464e4e43b081316af34dcf30af7.tar.gz hercules-8fa0cea72c24c464e4e43b081316af34dcf30af7.tar.bz2 hercules-8fa0cea72c24c464e4e43b081316af34dcf30af7.tar.xz hercules-8fa0cea72c24c464e4e43b081316af34dcf30af7.zip |
fixed memory leak in guild_gvg_eliminate_timer and timer handling in npc_event_timer [Shinomori]
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1106 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r-- | src/map/npc.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index 12906a1fc..1ba55699f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -164,12 +164,31 @@ int npc_delete(struct npc_data *nd) */ int npc_event_timer(int tid,unsigned int tick,int id,int data) { + char *eventname = (char *)data; + struct event_data *ev = (struct event_data *)strdb_search(ev_db,eventname); + struct npc_data *nd; struct map_session_data *sd=map_id2sd(id); - if (sd==NULL) - return 0; + size_t i; - npc_event(sd,(const char *)data,0); - aFree((void*)data); + if((ev==NULL || (nd=ev->nd)==NULL)) + { + if(battle_config.error_log) + printf("npc_event: event not found [%s]\n",eventname); + } + else + { + for(i=0;i<MAX_EVENTTIMER;i++) { + if( nd->eventtimer[i]==tid ) { + nd->eventtimer[i]=-1; + npc_event(sd,eventname,0); // sd NULL check is within + break; + } + } + if(i==MAX_EVENTTIMER && battle_config.error_log) + printf("npc_event_timer: event timer not found [%s]!\n",eventname); + } + + aFree(eventname); return 0; } |