summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/npc.c36
-rw-r--r--src/map/npc.h4
-rw-r--r--src/map/script.c4
4 files changed, 23 insertions, 23 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 148cd5673..df10655f7 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -5898,7 +5898,7 @@ int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* com
// add to list of script sources and run it
npc_addsrcfile(message);
- npc_parsesrcfile((char *)message);
+ npc_parsesrcfile(message);
npc_read_event_script();
clif_displaymessage(fd, msg_txt(262));
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;
diff --git a/src/map/npc.h b/src/map/npc.h
index accfc13e2..0ef12de7f 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -65,7 +65,7 @@ int npc_get_new_npc_id(void);
void npc_addsrcfile(const char* name);
void npc_delsrcfile(const char* name);
-void npc_parsesrcfile(char *);
+void npc_parsesrcfile(const char* name);
int do_final_npc(void);
int do_init_npc(void);
int npc_event_do_oninit(void);
@@ -87,8 +87,6 @@ int npc_reload(void);
void npc_read_event_script(void);
int npc_script_event(TBL_PC* sd, int type);
-extern char *current_file;
-
struct npc_data *fake_nd;
#endif /* _NPC_H_ */
diff --git a/src/map/script.c b/src/map/script.c
index afa7146b0..f0d491176 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -22,7 +22,6 @@
#include "itemdb.h"
#include "pc.h"
#include "status.h"
-#include "script.h"
#include "storage.h"
#include "mob.h"
#include "npc.h"
@@ -40,6 +39,7 @@
#include "unit.h"
#include "irc.h"
#include "pet.h"
+#include "script.h"
#include <stdio.h>
#include <stdlib.h>
@@ -346,7 +346,7 @@ static void check_event(struct script_state *st, const char *evt)
* 文字列のハッシュを計算
*------------------------------------------
*/
-#define calc_hash(x) calc_hash2(x)%SCRIPT_HASH_SIZE
+#define calc_hash(x) (calc_hash2(x)%SCRIPT_HASH_SIZE)
static unsigned int calc_hash2(const unsigned char *p)
{
#if defined(SCRIPT_HASH_DJB2)