summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-09 20:21:17 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-09 20:21:17 +0000
commite0a18f0853dd7a0cf0533ae0d10da9d19b116767 (patch)
tree2f0adc6661ce4597106033a18e33d8e774a76459 /src/map/npc.c
parentfaf6d705ec5b1f8a95a06d31635704adefcca99b (diff)
downloadhercules-e0a18f0853dd7a0cf0533ae0d10da9d19b116767.tar.gz
hercules-e0a18f0853dd7a0cf0533ae0d10da9d19b116767.tar.bz2
hercules-e0a18f0853dd7a0cf0533ae0d10da9d19b116767.tar.xz
hercules-e0a18f0853dd7a0cf0533ae0d10da9d19b116767.zip
* Recoded and renamed the trim function in strlib to normalize_name. (didn't behave like a standard trim function, see function comment for what it does)
* Added a proper trim function to strlib. * Other minor cleanups. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10199 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 20b7206d4..16152ecfa 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -46,7 +46,7 @@ static int npc_script=0;
static int npc_mob=0;
static int npc_delay_mob=0;
static int npc_cache_mob=0;
-char *current_file = NULL;
+const char *current_file = NULL;
int npc_get_new_npc_id(void){ return npc_id++; }
static struct dbt *ev_db;
@@ -63,7 +63,7 @@ static struct eri *timer_event_ers; //For the npc timer data. [Skotlex]
//For holding the view data of npc classes. [Skotlex]
static struct view_data npc_viewdb[MAX_NPC_CLASS];
-static struct
+static struct script_event_s
{ //Holds pointers to the commonly executed scripts for speedup. [Skotlex]
struct npc_data *nd;
struct event_data *event[UCHAR_MAX];
@@ -2795,7 +2795,7 @@ static int npc_parse_mapcell (char *w1, char *w2, char *w3, char *w4)
return 0;
}
-void npc_parsesrcfile (char *name)
+void npc_parsesrcfile(const char* name)
{
int m, lines = 0;
char line[2048];
@@ -2876,6 +2876,7 @@ void npc_parsesrcfile (char *name)
}
}
fclose(fp);
+ current_file = NULL;
return;
}
@@ -3135,17 +3136,17 @@ static void npc_debug_warps(void)
*/
int do_init_npc(void)
{
- struct npc_src_list *nsl;
- time_t last_time = time(0);
- int busy, i;
+ struct npc_src_list *file;
+ time_t last_time = time(NULL);
+ int busy = 0;
+ int i;
char c = '-';
//Stock view data for normal npcs.
memset(&npc_viewdb, 0, sizeof(npc_viewdb));
npc_viewdb[0].class_ = INVISIBLE_CLASS; //Invisible class is stored here.
- for (busy = 1; busy < MAX_NPC_CLASS; busy++)
- npc_viewdb[busy].class_ = busy;
- busy = 0;
+ for( i = 1; i < MAX_NPC_CLASS; i++ )
+ npc_viewdb[i].class_ = i;
// comparing only the first 24 chars of labels that are 50 chars long isn't that nice
// will cause "duplicated" labels where actually no dup is...
@@ -3155,16 +3156,17 @@ int do_init_npc(void)
memset(&ev_tm_b, -1, sizeof(ev_tm_b));
timer_event_ers = ers_new(sizeof(struct timer_event_data));
- for (nsl = npc_src_files; nsl; nsl = nsl->next) {
- npc_parsesrcfile(nsl->name);
- current_file = NULL;
+ for( file = npc_src_files; file != NULL; file = file->next) {
+ npc_parsesrcfile(file->name);
printf("\r");
if (script_config.verbose_mode)
- ShowStatus ("Loading NPCs... %-53s", nsl->name);
- else {
+ ShowStatus("Loading NPCs... %-53s", file->name);
+ else
+ {
ShowStatus("Loading NPCs... Working: ");
- if (last_time != time(0)) {
- last_time = time(0);
+ if (last_time != time(NULL))
+ {// change character at least every second
+ last_time = time(NULL);
switch(busy) {
case 0: c='\\'; busy++; break;
case 1: c='|'; busy++; break;
@@ -3197,7 +3199,7 @@ int do_init_npc(void)
add_timer_func_list(npc_timerevent,"npc_timerevent");
// Init dummy NPC
- fake_nd = (struct npc_data *)aCalloc(sizeof(struct npc_data),1);
+ fake_nd = (struct npc_data *)aMalloc(sizeof(struct npc_data));
fake_nd->bl.prev = fake_nd->bl.next = NULL;
fake_nd->bl.m = -1;
fake_nd->bl.x = 0;