summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorremoitnane <remoit(DOT)nane(AT)gmail(DOT)com>2010-07-23 12:16:14 -0700
committerChuck Miller <shadowmil@gmail.com>2010-07-23 22:36:41 -0400
commit1292f043398ec4aeae06da4d3652c94ac7708277 (patch)
tree63a7334baf434fff82e9e8778eafbdf67daa4c78 /src/map/npc.c
parent9e28e286682dc0c958de4db57483483a460e93de (diff)
downloadtmwa-1292f043398ec4aeae06da4d3652c94ac7708277.tar.gz
tmwa-1292f043398ec4aeae06da4d3652c94ac7708277.tar.bz2
tmwa-1292f043398ec4aeae06da4d3652c94ac7708277.tar.xz
tmwa-1292f043398ec4aeae06da4d3652c94ac7708277.zip
Clean up some memory handling
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index d302fe8..d3def90 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -138,16 +138,22 @@ int npc_event_dequeue (struct map_session_data *sd)
nullpo_retr (0, sd);
sd->npc_id = 0;
+
if (sd->eventqueue[0][0])
- { // �L���[�̃C�x���g����
- char *name = (char *) aCalloc (50, sizeof (char));
- int i;
+ {
+ if (!pc_addeventtimer(sd, 100, sd->eventqueue[0]))
+ {
+ printf ("npc_event_dequeue(): Event timer is full.\n");
+ return 0;
+ }
- memcpy (name, sd->eventqueue[0], 50);
- for (i = MAX_EVENTQUEUE - 2; i >= 0; i--)
- memcpy (sd->eventqueue[i], sd->eventqueue[i + 1], 50);
- add_timer (gettick () + 100, npc_event_timer, sd->bl.id, (int) name);
+ if (MAX_EVENTQUEUE > 1)
+ memmove (sd->eventqueue[0], sd->eventqueue[1],
+ (MAX_EVENTQUEUE - 1) * sizeof (sd->eventqueue[0]));
+ sd->eventqueue[MAX_EVENTQUEUE - 1][0] = '\0';
+ return 1;
}
+
return 0;
}
@@ -747,7 +753,8 @@ int npc_event (struct map_session_data *sd, const char *eventname,
{
// if (battle_config.etc_log)
// printf("npc_event: enqueue\n");
- memcpy (sd->eventqueue[i], eventname, 50);
+ strncpy (sd->eventqueue[i], eventname, 50);
+ sd->eventqueue[i][49] = '\0';
}
return 1;
}