summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-07-23 19:26:50 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-07-23 19:26:50 +0000
commit98e833dc83ad9f0642bdbf6b90b239704292f15f (patch)
tree73194653b1a88d67d8608d9caaac7f5119a56c6d /src/map/npc.c
parent81bfbbfb9c0f5af32e55f66ccea2d444eb76cabc (diff)
downloadhercules-98e833dc83ad9f0642bdbf6b90b239704292f15f.tar.gz
hercules-98e833dc83ad9f0642bdbf6b90b239704292f15f.tar.bz2
hercules-98e833dc83ad9f0642bdbf6b90b239704292f15f.tar.xz
hercules-98e833dc83ad9f0642bdbf6b90b239704292f15f.zip
Follow up r16471 improved overall feature performance by making the bind list a pointer array, this also allows the system to have a unlimited amount of atcommand bind instances. also fixed a memory leak that'd be caused when npc_do_atcmd_event fails (e.g. when target npc is manually reloaded)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16485 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index d629ac1b3..4faa54e24 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2758,22 +2758,18 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
struct script_state *st;
int i = 0, j = 0, k = 0;
char *temp;
- temp = (char*)aMalloc(strlen(message) + 1);
nullpo_ret(sd);
- if( ev == NULL || (nd = ev->nd) == NULL )
- {
+ if( ev == NULL || (nd = ev->nd) == NULL ) {
ShowError("npc_event: event not found [%s]\n", eventname);
return 0;
}
- if( sd->npc_id != 0 )
- { // Enqueue the event trigger.
+ if( sd->npc_id != 0 ) { // Enqueue the event trigger.
int i;
ARR_FIND( 0, MAX_EVENTQUEUE, i, sd->eventqueue[i][0] == '\0' );
- if( i < MAX_EVENTQUEUE )
- {
+ if( i < MAX_EVENTQUEUE ) {
safestrncpy(sd->eventqueue[i],eventname,50); //Event enqueued.
return 0;
}
@@ -2782,8 +2778,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
return 1;
}
- if( ev->nd->sc.option&OPTION_INVISIBLE )
- { // Disabled npc, shouldn't trigger event.
+ if( ev->nd->sc.option&OPTION_INVISIBLE ) { // Disabled npc, shouldn't trigger event.
npc_event_dequeue(sd);
return 2;
}
@@ -2794,16 +2789,16 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
// split atcmd parameters based on spaces
i = 0;
j = 0;
- while( message[i] != '\0' )
- {
- if( message[i] == ' ' && k < 127 )
- {
+
+ temp = (char*)aMalloc(strlen(message) + 1);
+
+ while( message[i] != '\0' ) {
+ if( message[i] == ' ' && k < 127 ) {
temp[j] = '\0';
setd_sub(st, NULL, ".@atcmd_parameters$", k++, (void *)temp, NULL);
j = 0;
++i;
- }
- else
+ } else
temp[j++] = message[i++];
}