summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 95cb4b177..4118b79ea 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1725,13 +1725,13 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4)
*/
int npc_convertlabel_db (DBKey key, void *data, va_list ap)
{
- unsigned char *lname = key.str;
+ const char *lname = (const char*)key.str;
int pos = (int)data;
struct npc_data *nd;
struct npc_label_list *lst;
int num;
- char *p;
- char c;
+ const char *p;
+ int len;
nullpo_retr(0, ap);
nullpo_retr(0, nd = va_arg(ap,struct npc_data *));
@@ -1746,18 +1746,17 @@ int npc_convertlabel_db (DBKey key, void *data, va_list ap)
// In case of labels not terminated with ':', for user defined function support
p = lname;
- while(isalnum(*(unsigned char*)p) || *p == '_') { p++; }
- c = *p;
- *p='\0';
+ while( ISALNUM(*p) || *p == '_' )
+ p++;
+ len = p-lname;
// here we check if the label fit into the buffer
- if (strlen(lname) > 23) {
+ if (len > 23) {
ShowError("npc_parse_script: label name longer than 23 chars! '%s'\n (%s)", lname, current_file);
exit(1);
}
- memcpy(lst[num].name, lname, strlen(lname)+1); //including EOS
-
- *p = c;
+ memcpy(lst[num].name, lname, len);
+ lst[num].name[len]=0;
lst[num].pos = pos;
nd->u.scr.label_list = lst;
nd->u.scr.label_list_num = num+1;
@@ -1868,7 +1867,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
unsigned char line[1024];
int i;
struct npc_data *nd, *dnd;
- struct dbt *label_db;
+ DB label_db;
char *p;
struct npc_label_list *label_dup = NULL;
int label_dupnum = 0;
@@ -1920,7 +1919,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
script = NULL;
} else {
// printf("Ok line %d\n",*lines);
- script = parse_script((unsigned char *) srcbuf, file, startline);
+ script = parse_script(srcbuf, file, startline, SCRIPT_USE_LABEL_DB);
}
if (script == NULL) {
// script parse error?
@@ -2039,6 +2038,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
// ラベルデータのコンバート
label_db = script_get_label_db();
label_db->foreach(label_db, npc_convertlabel_db, nd);
+ label_db->clear(label_db,NULL); // not needed anymore, so clear the db
// もう使わないのでバッファ解放
aFree(srcbuf);
@@ -2156,7 +2156,7 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
ShowError("Missing right curly at file %s, line %d\n",file, *lines);
script = NULL;
} else {
- script = parse_script(srcbuf, file, startline);
+ script = parse_script(srcbuf, file, startline,0);
}
if (script == NULL) {
// script parse error?