summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/Makefile4
-rw-r--r--src/char_sql/Makefile9
-rw-r--r--src/char_sql/char.c2
-rw-r--r--src/char_sql/int_guild.c2
-rw-r--r--src/char_sql/int_party.c2
-rw-r--r--src/char_sql/int_pet.c2
-rw-r--r--src/char_sql/inter.c2
-rw-r--r--src/char_sql/make.sh3
-rw-r--r--src/common/Makefile1
-rw-r--r--src/common/timer.c185
-rw-r--r--src/common/timer.h1
-rw-r--r--src/ladmin/Makefile4
-rw-r--r--src/login/Makefile4
-rw-r--r--src/login_sql/Makefile9
-rw-r--r--src/login_sql/login.c2
-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
-rw-r--r--src/txt-converter/char/Makefile8
-rw-r--r--src/txt-converter/char/char-converter.c2
-rw-r--r--src/txt-converter/login/Makefile8
25 files changed, 266 insertions, 130 deletions
diff --git a/src/char/Makefile b/src/char/Makefile
index 0a2009333..877f83c5a 100644
--- a/src/char/Makefile
+++ b/src/char/Makefile
@@ -1,8 +1,8 @@
all: char-server
txt: char-server
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/showmsg.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h ../common/showmsg.h
+COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o
+COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h
char-server: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(COMMON_OBJ)
$(CC) -o ../../$@ $>
diff --git a/src/char_sql/Makefile b/src/char_sql/Makefile
index faf2bbb64..c58e2d59d 100644
--- a/src/char_sql/Makefile
+++ b/src/char_sql/Makefile
@@ -1,20 +1,19 @@
all: char-server_sql
sql: char-server_sql
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o ../common/utils.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/utils.h
+COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o ../common/utils.o ../common/strlib.o
+COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h
-char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o strlib.o itemdb.o $(COMMON_OBJ)
+char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o itemdb.o $(COMMON_OBJ)
$(CC) -o ../../$@ $^ $(LIB_S)
-char.o: char.c char.h strlib.h itemdb.h ../common/showmsg.h
+char.o: char.c char.h ../common/strlib.h itemdb.h ../common/showmsg.h
inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h ../common/mmo.h char.h ../common/socket.h ../common/showmsg.h
int_party.o: int_party.c int_party.h inter.h ../common/mmo.h char.h ../common/socket.h ../common/timer.h ../common/db.h ../common/showmsg.h
int_guild.o: int_guild.c int_guild.h inter.h ../common/mmo.h char.h ../common/socket.h ../common/db.h ../common/showmsg.h
int_storage.o: int_storage.c int_storage.h char.h itemdb.h ../common/showmsg.h
int_pet.o: int_pet.c int_pet.h inter.h char.h ../common/mmo.h ../common/socket.h ../common/db.h ../common/showmsg.h
-strlib.o: strlib.c strlib.h ../common/showmsg.h
itemdb.o: itemdb.c itemdb.h ../common/db.h ../common/mmo.h ../common/showmsg.h
$(COMMON_OBJ): $(COMMON_H)
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 1083235cf..a1318bcc1 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -34,7 +34,7 @@
#include <stdarg.h>
#include "char.h"
-#include "strlib.h"
+#include "../common/strlib.h"
#include "itemdb.h"
#include "inter.h"
#include "db.h"
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index 85c301cd1..744465625 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -5,7 +5,7 @@
#include "char.h"
-#include "strlib.h"
+#include "../common/strlib.h"
#include "int_storage.h"
#include "inter.h"
#include "int_guild.h"
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index ecc252185..ddcc8bb8d 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -4,7 +4,7 @@
//
#include "char.h"
-#include "strlib.h"
+#include "../common/strlib.h"
#include "socket.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c
index 7f2ed2a7c..97548aeff 100644
--- a/src/char_sql/int_pet.c
+++ b/src/char_sql/int_pet.c
@@ -3,7 +3,7 @@
// SQL conversion by Jioh L. Jung
//
#include "char.h"
-#include "strlib.h"
+#include "../common/strlib.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c
index 52d688dce..7dc76e0f6 100644
--- a/src/char_sql/inter.c
+++ b/src/char_sql/inter.c
@@ -7,7 +7,7 @@
#include <stdlib.h>
#include "char.h"
-#include "strlib.h"
+#include "../common/strlib.h"
#include "inter.h"
#include "int_party.h"
#include "int_guild.h"
diff --git a/src/char_sql/make.sh b/src/char_sql/make.sh
index a4ca8b5e4..6ee175f73 100644
--- a/src/char_sql/make.sh
+++ b/src/char_sql/make.sh
@@ -6,6 +6,5 @@
gcc -c int_pet.c -I/usr/local/include/mysql/
gcc -c int_storage.c -I/usr/local/include/mysql/
gcc -c inter.c -I/usr/local/include/mysql/
- gcc -c strlib.c
gcc -c itemdb.c -I../common/
- gcc -o ../char-server inter.o char.o int_pet.o int_storage.o int_guild.o int_party.o strlib.o itemdb.o ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o -L/usr/local/lib/mysql -lmysqlclient -lz
+ gcc -o ../char-server inter.o char.o int_pet.o int_storage.o int_guild.o int_party.o ../common/strlib.o itemdb.o ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o -L/usr/local/lib/mysql -lmysqlclient -lz
diff --git a/src/common/Makefile b/src/common/Makefile
index b15d4d481..eaa7205d2 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -9,6 +9,7 @@ lock.o: lock.h showmsg.h
nullpo.o: nullpo.c nullpo.h showmsg.h
malloc.o: malloc.c malloc.h showmsg.h
showmsg.o: showmsg.c showmsg.h
+strlib.o: strlib.c strlib.h utils.h
clean:
rm -f *.o
diff --git a/src/common/timer.c b/src/common/timer.c
index 7781dbc9d..49d205619 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -15,11 +15,15 @@
#include "timer.h"
#include "utils.h"
+#include "../common/malloc.h"
#ifdef MEMWATCH
#include "memwatch.h"
#endif
+// タイマー間隔の最小値。モンスターの大量召還時、多数のクライアント接続時に
+// サーバーが反応しなくなる場合は、TIMER_MIN_INTERVEL を増やしてください。
+
// If the server shows no reaction when processing thousands of monsters
// or connected by many clients, please increase TIMER_MIN_INTERVEL.
@@ -37,9 +41,9 @@ static int* timer_heap = NULL;
struct timer_func_list {
int (*func)(int,unsigned int,int,int);
struct timer_func_list* next;
- char* name;
+ char name[40];
};
-static struct timer_func_list* tfl_root;
+static struct timer_func_list* tfl_root=NULL;
#if defined(_WIN32)
void gettimeofday(struct timeval *t, struct timezone *dummy)
@@ -59,11 +63,11 @@ int add_timer_func_list(int (*func)(int,unsigned int,int,int),char* name)
struct timer_func_list* tfl;
CREATE(tfl, struct timer_func_list, 1);
- CREATE(tfl->name, char, strlen(name) + 1);
+ //CREATE(tfl->name, char, strlen(name) + 1);
tfl->next = tfl_root;
tfl->func = func;
- strcpy(tfl->name,name);
+ strncpy(tfl->name, name, sizeof(tfl->name) - 1);
tfl_root = tfl;
return 0;
@@ -86,10 +90,14 @@ static unsigned int gettick_cache;
static int gettick_count;
unsigned int gettick_nocache(void)
{
+#ifdef _WIN32
+ return gettick_cache = GetTickCount();
+#else
struct timeval tval;
gettimeofday(&tval,NULL);
gettick_count = 256;
return gettick_cache = tval.tv_sec * 1000 + tval.tv_usec/1000;
+#endif
}
unsigned int gettick(void)
@@ -104,67 +112,135 @@ unsigned int gettick(void)
* CORE : Timer Heap
*--------------------------------------
*/
+
+// デバッグ用関数群
+static void dump_timer_heap(void) {
+ int j;
+ for(j = 1 ; j <= timer_heap[0] ; j++) {
+ if(j != timer_heap[0] && DIFF_TICK(
+ timer_data[timer_heap[j]].tick,
+ timer_data[timer_heap[j + 1]].tick
+ ) < 0) {
+ printf("*");
+ } else {
+ printf(" ");
+ }
+ printf("%d : %d %d\n",j,timer_heap[j],timer_data[timer_heap[j]].tick);
+ }
+}
+
static void push_timer_heap(int index)
{
- int i, h;
-
if (timer_heap == NULL || timer_heap[0] + 1 >= timer_heap_max) {
int first = timer_heap == NULL;
timer_heap_max += 256;
- RECREATE(timer_heap, int, timer_heap_max);
+ timer_heap = (int*)aRealloc(timer_heap, sizeof(int) * timer_heap_max);
memset(timer_heap + (timer_heap_max - 256), 0, sizeof(int) * 256);
if (first)
timer_heap[0] = 0;
}
- timer_heap[0]++;
-
- for (h = timer_heap[0]-1, i = (h - 1) / 2;
- h > 0 && DIFF_TICK(timer_data[index].tick,
- timer_data[timer_heap[i + 1]].tick) < 0;
- i = (h - 1) / 2) {
- timer_heap[h + 1] = timer_heap[i + 1];
- h = i;
+ // timer_heap[0] : タイマーヒープの数
+ // timer_heap[1..] : タイマーヒープ(大 → 小)
+ if(timer_heap[0] == 0) {
+ // データが無い : 先頭に追加
+ timer_heap[0]++;
+ timer_heap[1] = index;
+ } else if(DIFF_TICK(timer_data[timer_heap[timer_heap[0]]].tick,timer_data[index].tick) > 0) {
+ // 最後尾に追加
+ timer_heap[++timer_heap[0]] = index;
+ } else if(DIFF_TICK(timer_data[timer_heap[1]].tick,timer_data[index].tick) < 0) {
+ // 先頭に追加
+ memmove(&timer_heap[2],&timer_heap[1],timer_heap[0] * sizeof(int));
+ timer_heap[0]++;
+ timer_heap[1] = index;
+ } else {
+ int min = 1;
+ int max = timer_heap[0] + 1;
+ while(max != min + 1) {
+ int mid = (min + max)/2;
+ if(DIFF_TICK(timer_data[index].tick,timer_data[timer_heap[mid]].tick) > 0) {
+ max = mid;
+ } else {
+ min = mid;
+ }
+ }
+ memmove(&timer_heap[min+2],&timer_heap[min+1],(timer_heap[0] - min) * sizeof(int));
+ timer_heap[min+1] = index;
+ timer_heap[0]++;
}
- timer_heap[h + 1] = index;
+ // check_timer_heap();
}
-static int top_timer_heap()
+// 指定したindex を持つタイマーヒープを返す
+static int search_timer_heap(int index)
{
- if (timer_heap == NULL || timer_heap[0] <= 0)
+ if (timer_heap == NULL || timer_heap[0] <= 0) {
return -1;
+ } else {
+ int min = 1;
+ int max = timer_heap[0] + 1;
+ while(max != min + 1) {
+ int mid = (min + max)/2;
+ if(DIFF_TICK(timer_data[index].tick,timer_data[timer_heap[mid]].tick) > 0) {
+ max = mid;
+ } else {
+ min = mid;
+ }
+ }
+ if(timer_heap[min] == index) {
+ return min;
+ } else {
+ int pos = min - 1;
+ while(pos > 0 && timer_data[index].tick == timer_data[timer_heap[pos]].tick) {
+ if(timer_heap[pos] == index) {
+ return pos;
+ }
+ pos--;
+ }
+ pos = min + 1;
+ while(pos <= timer_heap[0] && timer_data[index].tick == timer_data[timer_heap[pos]].tick) {
+ if(timer_heap[pos] == index) {
+ return pos;
+ }
+ pos++;
+ }
+ printf("search_timer_heap : can't find tid:%d\n",index);
+ return -1;
+ }
+ }
+}
- return timer_heap[1];
+static void delete_timer_heap(int index) {
+ int pos = search_timer_heap(index);
+ if(pos != -1) {
+ memmove(&timer_heap[pos],&timer_heap[pos+1],(timer_heap[0] - pos) * sizeof(int));
+ timer_heap[0]--;
+ }
}
-static int pop_timer_heap()
+#ifdef _WIN32
+int top_timer_heap(void)
+#else
+static inline int top_timer_heap(void)
+#endif
{
- int i,h,k;
- int ret,last;
-
if (timer_heap == NULL || timer_heap[0] <= 0)
return -1;
- ret = timer_heap[1];
- last = timer_heap[timer_heap[0]];
- timer_heap[0]--;
-
- for(h = 0,k = 2;k<timer_heap[0];k = k * 2 + 2) {
- if (DIFF_TICK(timer_data[timer_heap[k + 1]].tick , timer_data[timer_heap[k]].tick)>0)
- k--;
- timer_heap[h + 1] = timer_heap[k + 1], h = k;
- }
- if (k == timer_heap[0])
- timer_heap[h + 1] = timer_heap[k], h = k-1;
- for(i = (h-1)/2;
- h>0 && DIFF_TICK(timer_data[timer_heap[i + 1]].tick , timer_data[last].tick)>0;
- i = (h-1)/2) {
- timer_heap[h + 1] = timer_heap[i + 1],h = i;
- }
- timer_heap[h + 1] = last;
+ return timer_heap[timer_heap[0]];
+}
- return ret;
+#ifdef _WIN32
+int pop_timer_heap(void)
+#else
+static inline int pop_timer_heap(void)
+#endif
+{
+ if (timer_heap == NULL || timer_heap[0] <= 0)
+ return -1;
+ return timer_heap[timer_heap[0]--];
}
int add_timer(unsigned int tick,int (*func)(int,unsigned int,int,int),int id,int data)
@@ -185,6 +261,7 @@ int add_timer(unsigned int tick,int (*func)(int,unsigned int,int,int),int id,int
if (timer_data_max == 0) {
timer_data_max = 256;
CREATE(timer_data, struct TimerData, timer_data_max);
+ //timer_data[0] = NULL;
} else {
timer_data_max += 256;
RECREATE(timer_data, struct TimerData, timer_data_max);
@@ -237,13 +314,16 @@ int delete_timer(int id,int (*func)(int,unsigned int,int,int))
// そのうち消えるにまかせる
timer_data[id].func = NULL;
timer_data[id].type = TIMER_ONCE_AUTODEL;
- timer_data[id].tick -= 60 * 60 * 1000;
+ // timer_data[id].tick -= 60 * 60 * 1000;
return 0;
}
int addtick_timer(int tid,unsigned int tick)
{
- return timer_data[tid].tick += tick;
+ delete_timer_heap(tid);
+ timer_data[tid].tick += tick;
+ push_timer_heap(tid);
+ return timer_data[tid].tick;
}
struct TimerData* get_timer(int tid)
{
@@ -264,6 +344,9 @@ int do_timer(unsigned int tick)
#endif
while((i = top_timer_heap()) >= 0) {
+ if(i == 2) {
+ i = 2;
+ }
if (DIFF_TICK(timer_data[i].tick , tick)>0) {
nextmin = DIFF_TICK(timer_data[i].tick , tick);
break;
@@ -312,7 +395,19 @@ int do_timer(unsigned int tick)
return nextmin;
}
-void timer_final()
+void timer_final(void)
{
- free(timer_data);
+ struct timer_func_list *tfl, *tfl_next;
+ for(tfl = tfl_root; tfl; tfl = tfl_next)
+ {
+ tfl_next = tfl->next;
+ free(tfl);
+ tfl = NULL;
+ }
+ if(timer_heap)
+ free(timer_heap);
+ if(free_timer_list)
+ free(free_timer_list);
+ if(timer_data)
+ free(timer_data);
}
diff --git a/src/common/timer.h b/src/common/timer.h
index f6fc5c84d..c43c0e6b0 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -38,6 +38,7 @@ struct TimerData *get_timer(int tid);
int do_timer(unsigned int tick);
int add_timer_func_list(int (*)(int,unsigned int,int,int),char*);
+void do_final_timer(void);
char* search_timer_func_list(int (*)(int,unsigned int,int,int));
extern void timer_final();
diff --git a/src/ladmin/Makefile b/src/ladmin/Makefile
index 879edaeea..1b5ed3d97 100644
--- a/src/ladmin/Makefile
+++ b/src/ladmin/Makefile
@@ -2,8 +2,8 @@ all: ladmin
txt: ladmin
sql: ladmin
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h
+COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o
+COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h
ladmin: ladmin.o md5calc.o $(COMMON_OBJ)
$(CC) -o ../../$@ ladmin.o md5calc.o $(COMMON_OBJ)
diff --git a/src/login/Makefile b/src/login/Makefile
index 300737cbf..f49aa4b4f 100644
--- a/src/login/Makefile
+++ b/src/login/Makefile
@@ -1,8 +1,8 @@
all: login-server
txt: login-server
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/showmsg.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/lock.h ../common/malloc.h ../common/showmsg.h
+COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o
+COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/lock.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h
login-server: login.o md5calc.o $(COMMON_OBJ)
$(CC) -o ../../$@ login.o md5calc.o $(COMMON_OBJ)
diff --git a/src/login_sql/Makefile b/src/login_sql/Makefile
index 6fbb30865..18b023fe6 100644
--- a/src/login_sql/Makefile
+++ b/src/login_sql/Makefile
@@ -2,15 +2,14 @@ all: login-server_sql
sql: login-server_sql
shared_libs=all
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h
+COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o
+COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h
-login-server_sql: login.o md5calc.o strlib.o $(COMMON_OBJ)
+login-server_sql: login.o md5calc.o $(COMMON_OBJ)
$(CC) -o ../../$@ $^ $(LIB_S)
-login.o: login.c login.h md5calc.h strlib.h $(COMMON_H)
+login.o: login.c login.h md5calc.h $(COMMON_H)
md5calc.o: md5calc.c md5calc.h
-strlib.o: strlib.c strlib.h
clean:
rm -f *.o ../../login-server_sql
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index a8f2720bd..687eb3b37 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -44,7 +44,7 @@ void Gettimeofday(struct timeval *timenow)
//add include for DBMS(mysql)
#include <mysql.h>
-#include "strlib.h"
+#include "../common/strlib.h"
#include "timer.h"
/*
#include "timer.h"
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する
diff --git a/src/txt-converter/char/Makefile b/src/txt-converter/char/Makefile
index 4dd3db689..a4cca87fd 100644
--- a/src/txt-converter/char/Makefile
+++ b/src/txt-converter/char/Makefile
@@ -1,13 +1,13 @@
all: char-converter
sql: char-converter
-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
-char-converter: char-converter.o strlib.o $(COMMON_OBJ)
+char-converter: char-converter.o $(COMMON_OBJ)
$(CC) -o ../../../$@ $^ $(LIB_S)
-char-converter.o: char-converter.c char.h strlib.h
-strlib.o: strlib.c strlib.h
+char-converter.o: char-converter.c char.h ../../common/strlib.h
+strlib.o: strlib.c ../../common/strlib.h
clean:
rm -f *.o ../../../char-converter
diff --git a/src/txt-converter/char/char-converter.c b/src/txt-converter/char/char-converter.c
index 8928e240f..7b35fda63 100644
--- a/src/txt-converter/char/char-converter.c
+++ b/src/txt-converter/char/char-converter.c
@@ -18,7 +18,7 @@
#define STORAGE_MEMINC 16
#include "char.h"
-#include "strlib.h"
+#include "../../common/strlib.h"
#ifdef MEMWATCH
#include "memwatch.h"
diff --git a/src/txt-converter/login/Makefile b/src/txt-converter/login/Makefile
index 125490479..56b97e772 100644
--- a/src/txt-converter/login/Makefile
+++ b/src/txt-converter/login/Makefile
@@ -1,12 +1,12 @@
all: login-converter
sql: login-converter
-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
-COMMON_H = ../../common/core.h ../../common/socket.h ../../common/timer.h ../../common/mmo.h ../../common/version.h ../../common/db.h ../../common/malloc.h
+COMMON_H = ../../common/core.h ../../common/socket.h ../../common/timer.h ../../common/mmo.h ../../common/version.h ../../common/db.h ../../common/malloc.h ../../common/strlib.h
-login-converter: login-converter.o ../../login_sql/md5calc.o ../../login_sql/strlib.o $(COMMON_OBJ)
+login-converter: login-converter.o ../../login_sql/md5calc.o $(COMMON_OBJ)
$(CC) -o ../../../$@ $^ $(LIB_S)
-login-converter.o: login-converter.c ../../login_sql/login.h ../../login_sql/md5calc.h ../../login_sql/strlib.h $(COMMON_H)
+login-converter.o: login-converter.c ../../login_sql/login.h ../../login_sql/md5calc.h $(COMMON_H)
clean:
rm -f *.o ../../../login-converter