summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/Makefile4
-rw-r--r--src/map/Makefile.win324
-rw-r--r--src/map/atcommand.c8
-rw-r--r--src/map/atcommand.h2
-rw-r--r--src/map/mail.c7
-rw-r--r--src/map/map.c1
-rw-r--r--src/map/npc.c120
7 files changed, 94 insertions, 52 deletions
diff --git a/src/map/Makefile b/src/map/Makefile
index 4204cfaff..b12bcd5af 100644
--- a/src/map/Makefile
+++ b/src/map/Makefile
@@ -10,7 +10,7 @@ txtobj:
sqlobj:
mkdir sqlobj
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o ../common/utils.o
+COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o ../common/utils.o ../common/strlib.o
LIBS = -lz -lm
map-server: txtobj/map.o txtobj/chrif.o txtobj/clif.o txtobj/pc.o txtobj/npc.o txtobj/chat.o txtobj/path.o txtobj/itemdb.o txtobj/mob.o txtobj/script.o txtobj/storage.o txtobj/skill.o txtobj/atcommand.o txtobj/charcommand.o txtobj/battle.o txtobj/intif.o txtobj/trade.o txtobj/party.o txtobj/vending.o txtobj/guild.o txtobj/pet.o $(COMMON_OBJ)
@@ -67,7 +67,7 @@ sqlobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h ../common/db.
sqlobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h ../common/mmo.h ../common/showmsg.h
sqlobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
sqlobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
-sqlobj/mail.o: mail.c mail.h ../common/showmsg.h
+sqlobj/mail.o: mail.c mail.h ../common/showmsg.h ../common/strlib.h ../common/utils.h
sqlobj/log.o: log.c log.h map.h ../common/nullpo.h
sqlobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
diff --git a/src/map/Makefile.win32 b/src/map/Makefile.win32
index ed4b4e95a..9a0a0b174 100644
--- a/src/map/Makefile.win32
+++ b/src/map/Makefile.win32
@@ -23,7 +23,7 @@ LINKOPT = /debug /SUBSYSTEM:CONSOLE
# OPT = /O2
CFLAGS = $(OPT) /nologo /I../common /I$(ZLIBDIR) $(PACKETDEF) /D_WIN32
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o
+COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o
LIBS = "WSOCK32.LIB"
# "WSOCK32.LIB" "USER32.LIB" "ADVAPI32.LIB" "MSVCRT.LIB" "OLDNAMES.LIB" "KERNEL32.LIB"
@@ -86,7 +86,7 @@ sqlobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h ../common/db.
sqlobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h ../common/mmo.h ../common/showmsg.h
sqlobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
sqlobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
-sqlobj/mail.o: mail.c mail.h ../common/showmsg.h
+sqlobj/mail.o: mail.c mail.h ../common/showmsg.h ../common/strlib.h ../common/utils.h
sqlobj/log.o: log.c log.h map.h ../common/nullpo.h
clean:
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index a1b90a5c3..7948b3c27 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -163,7 +163,7 @@ ACMD_FUNC(partyspy); // [Syrus22]
ACMD_FUNC(repairall); // [Valaris]
ACMD_FUNC(guildrecall); // by Yor
ACMD_FUNC(partyrecall); // by Yor
-//ACMD_FUNC(nuke); // [Valaris]
+ACMD_FUNC(nuke); // [Valaris]
ACMD_FUNC(enablenpc);
ACMD_FUNC(disablenpc);
ACMD_FUNC(servertime); // by Yor
@@ -414,7 +414,7 @@ static AtCommandInfo atcommand_info[] = {
{ AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
{ AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
{ AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
-// { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
+ { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
{ AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc }, // []
{ AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // []
{ AtCommand_ServerTime, "@time", 0, atcommand_servertime }, // by Yor
@@ -6111,7 +6111,7 @@ int atcommand_repairall(
return 0;
}
-/* Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
+// Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
int atcommand_nuke(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
@@ -6142,7 +6142,7 @@ int atcommand_nuke(
return 0;
}
-*/
+
/*==========================================
*
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index d0aac3a49..a6c0a5e9e 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -143,7 +143,7 @@ enum AtCommandType {
AtCommand_RepairAll, // [Valaris]
AtCommand_GuildRecall, // by Yor
AtCommand_PartyRecall, // by Yor
-// AtCommand_Nuke, // [Valaris]
+ AtCommand_Nuke, // [Valaris]
AtCommand_Enablenpc,
AtCommand_Disablenpc,
AtCommand_ServerTime, // by Yor
diff --git a/src/map/mail.c b/src/map/mail.c
index 0aaff677a..5d63b6f80 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -6,9 +6,10 @@
#include <stdlib.h>
#include <string.h>
-#include "socket.h"
-#include "timer.h"
-#include "nullpo.h"
+#include "../common/strlib.h"
+#include "../common/socket.h"
+#include "../common/timer.h"
+#include "../common/nullpo.h"
#include "map.h"
#include "clif.h"
diff --git a/src/map/map.c b/src/map/map.c
index d709272be..2327ef7df 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2236,6 +2236,7 @@ void do_final(void) {
delete_session(i);
map_removenpc();
+ //do_final_timer(); (we used timer_final() instead)
timer_final();
numdb_final(id_db, id_db_final);
diff --git a/src/map/npc.c b/src/map/npc.c
index 7b616282f..0d3bcffd3 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1586,10 +1586,10 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
{
int x,y,dir=0,m,xs=0,ys=0,class=0; // [Valaris] thanks to fov
char mapname[24];
- unsigned char *srcbuf=NULL,*script;
+ char *srcbuf=NULL,*script;
int srcsize=65536;
int startline=0;
- unsigned char line[1024];
+ char line[1024];
int i;
struct npc_data *nd;
int evflag=0;
@@ -1602,51 +1602,91 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
if(strcmp(w1,"-")==0){
x=0;y=0;m=-1;
}else{
- // 引数の個数チェック
- if (sscanf(w1,"%[^,],%d,%d,%d",mapname,&x,&y,&dir) != 4 ||
+ // 引数の個数チェック
+ if (sscanf(w1,"%[^,],%d,%d,%d",mapname,&x,&y,&dir) != 4 ||
( strcmp(w2,"script")==0 && strchr(w4,',')==NULL) ) {
- printf("bad script line : %s\n",w3);
- return 1;
- }
- m = map_mapname2mapid(mapname);
+ printf("bad script line : %s\n",w3);
+ return 1;
+ }
+ m = map_mapname2mapid(mapname);
}
-
+
if(strcmp(w2,"script")==0){
// スクリプトの解析
+ // { , } の入れ子許したらこっちでも簡易解析しないといけなくなったりもする
+ int curly_count = 0;
+ int string_flag = 0;
+ int j;
srcbuf=(char *)aCalloc(srcsize,sizeof(char));
- if (strchr(first_line,'{')) {
- strcpy(srcbuf,strchr(first_line,'{'));
- startline=*lines;
- } else
- srcbuf[0]=0;
- while(1) {
- for(i=strlen(srcbuf)-1;i>=0 && isspace(srcbuf[i]);i--);
- if (i>=0 && srcbuf[i]=='}')
- break;
- fgets(line,1020,fp);
- (*lines)++;
- if (feof(fp))
- break;
- if (strlen(srcbuf)+strlen(line)+1>=srcsize) {
- srcsize += 65536;
- srcbuf = (char *)aRealloc(srcbuf, srcsize);
- memset(srcbuf + srcsize - 65536, '\0', 65536);
- }
- if (srcbuf[0]!='{') {
- if (strchr(line,'{')) {
- strcpy(srcbuf,strchr(line,'{'));
- startline=*lines;
- }
+ if (strchr(first_line,'{')) {
+ strcpy(srcbuf,strchr(first_line,'{'));
+ startline=*lines;
} else
- strcat(srcbuf,line);
- }
- script=parse_script(srcbuf,startline);
- if (script==NULL) {
- // script parse error?
- free(srcbuf);
- return 1;
- }
+ srcbuf[0]=0;
+ while(1) {
+ fgets(line,1020,fp);
+ (*lines)++;
+ if (feof(fp))
+ break;
+ // line の中に文字列 , {} が含まれているか調査
+ i = strlen(line);
+ for(j = 0; j < i ; j++) {
+ if(string_flag) {
+ if(line[j] == '\"' && (j <= 0 || line[j-1] != '\\')) {
+ string_flag = 0;
+ }
+ } else {
+ if(line[j] == '\"') {
+ string_flag = 1;
+ } else if(line[j] == '}') {
+ if(curly_count == 0) {
+ // 抜けるのはfor だけ
+ break;
+ } else {
+ curly_count--;
+ }
+ } else if(line[j] == '{') {
+ curly_count++;
+ } else if(line[j] == '/' && line[j+1] == '/') {
+ // コメント
+ break;
+ } else if(*(unsigned char*)(line + j) >= 0x80) {
+ // 全角文字
+ j++;
+ }
+ }
+ }
+ if (strlen(srcbuf)+strlen(line)+1>=srcsize) {
+ srcsize += 65536;
+ srcbuf = (char *)aRealloc(srcbuf, srcsize);
+ memset(srcbuf + srcsize - 65536, '\0', 65536);
+ }
+ if (srcbuf[0]!='{') {
+ if (strchr(line,'{')) {
+ strcpy(srcbuf,strchr(line,'{'));
+ startline=*lines;
+ }
+ } else
+ strcat(srcbuf,line);
+ if(!string_flag && line[j] == '}' && curly_count == 0) {
+ break;
+ }
+ }
+ if(curly_count > 0) {
+ printf("warning: Missing right curly at line %d\n",*lines);
+ script=NULL;
+ exit(1);
+ } else {
+ // printf("Ok line %d\n",*lines);
+ script=parse_script(srcbuf,startline);
+ }
+ if (script==NULL) {
+ // script parse error?
+ free(srcbuf);
+ return 1;
+ }
+
}else{
// duplicateする