From 02720aae3af5cc563a8b6dd374b5aebd5a0da074 Mon Sep 17 00:00:00 2001 From: amber Date: Mon, 29 Nov 2004 05:19:01 +0000 Subject: A few bug fixes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@412 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/common/socket.c') diff --git a/src/common/socket.c b/src/common/socket.c index 4afcf50d4..703361627 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -121,8 +121,10 @@ static int send_from_fifo(int fd) int len; //printf("send_from_fifo : %d\n",fd); - if(session[fd]->eof) + if(session[fd]->eof || session[fd]->wdata == 0) return -1; + if (session[fd]->wdata_size == 0) + return 0; #ifdef _WIN32 len=send(fd, session[fd]->wdata,session[fd]->wdata_size, 0); @@ -148,6 +150,15 @@ static int send_from_fifo(int fd) return 0; } +void flush_fifos_for_final() +{ + int i; + for(i=0;ifunc_send == send_from_fifo) + send_from_fifo(i); +} + static int null_parse(int fd) { printf("null_parse : %d\n",fd); -- cgit v1.2.3-70-g09d2 From d943834522d8eda49664927b11806e53c1ecb1f3 Mon Sep 17 00:00:00 2001 From: amber Date: Sun, 5 Dec 2004 03:50:24 +0000 Subject: oops.. missed some git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@448 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 2 +- src/common/socket.h | 2 +- src/common/timer.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/common/socket.c') diff --git a/src/common/socket.c b/src/common/socket.c index 703361627..d93e77294 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -150,7 +150,7 @@ static int send_from_fifo(int fd) return 0; } -void flush_fifos_for_final() +void flush_fifos() { int i; for(i=0;i Date: Sun, 5 Dec 2004 04:01:38 +0000 Subject: enable NSOCKET for twilight git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@451 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/common/socket.c') diff --git a/src/common/socket.c b/src/common/socket.c index d93e77294..701d4e0de 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -35,6 +35,10 @@ int fd_max; int rfifo_size = 65536; int wfifo_size = 65536; +#ifdef TWILIGHT +#define NSOCKET +#endif + #ifndef TCP_FRAME_LEN #define TCP_FRAME_LEN 1053 #endif -- cgit v1.2.3-70-g09d2 From 33042f4f96ba34e518d600921f4f88b7b697e16d Mon Sep 17 00:00:00 2001 From: amber Date: Mon, 13 Dec 2004 16:15:45 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@555 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 3 +++ src/common/socket.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index 414f3c095..856e519df 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,7 @@ Date Added +12/14 + * Fixed how socket handles EAGIN errors (retry instead of + disconnecting) [MouseJstr] 12/13 * Skill Updates [celest] - Added the new 'Throw Tomahawk' skill (Requires Sakexe1129 or newer) diff --git a/src/common/socket.c b/src/common/socket.c index 701d4e0de..415a011a4 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -16,6 +16,7 @@ #include #include #include +#include #endif #include @@ -147,7 +148,7 @@ static int send_from_fifo(int fd) } else { session[fd]->wdata_size=0; } - } else { + } else if (errno != EAGAIN) { printf("set eof :%d\n",fd); session[fd]->eof=1; } -- cgit v1.2.3-70-g09d2 From db4d0797f6bb0a54e0955b330a3ccd7675b7b95c Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Wed, 15 Dec 2004 00:06:02 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@569 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 ++ src/common/core.c | 2 +- src/common/socket.c | 4 ++-- src/map/chrif.c | 20 +++++++++++++++----- src/map/chrif.h | 2 ++ src/map/map.c | 10 +++++++--- src/map/npc.c | 4 ++-- 7 files changed, 31 insertions(+), 13 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index 2143dd182..6d354f0ea 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,7 @@ Date Added 12/14 + * Changed "Map-server can't connect to char-server" message to reduce output spamming and set it to + display only once [MC Cameri] * Added a busy animation for npc loading [MC Cameri] * Replaced the way map loading was displayed into a progress-like way [MC Cameri] * Fixed some typos in _ShowMessage() [MC Cameri] diff --git a/src/common/core.c b/src/common/core.c index 167b38efb..2e0029ea1 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -104,7 +104,7 @@ static void display_title(void) printf("\033[37;44m (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)\033[K\033[0m\n\n"); // reset color if ((revision = get_svn_revision(".svn\\entries"))>0) { - snprintf(tmp_output,sizeof(tmp_output),"SVN Revision: %d.\n",revision); + snprintf(tmp_output,sizeof(tmp_output),"SVN Revision: '"CL_WHITE"%d"CL_RESET"'.\n",revision); ShowInfo(tmp_output); } } diff --git a/src/common/socket.c b/src/common/socket.c index 415a011a4..611d73902 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -115,7 +115,7 @@ static int recv_to_fifo(int fd) // printf("%s has logged off your server.\n",RFIFOP(fd,6)); // Removed [Valaris] // else if (fd != 8) // [Valaris] - printf("set eof : connection #%d\n", fd); +// printf("set eof : connection #%d\n", fd); session[fd]->eof=1; } return 0; @@ -149,7 +149,7 @@ static int send_from_fifo(int fd) session[fd]->wdata_size=0; } } else if (errno != EAGAIN) { - printf("set eof :%d\n",fd); +// printf("set eof :%d\n",fd); session[fd]->eof=1; } return 0; diff --git a/src/map/chrif.c b/src/map/chrif.c index 81c6744c2..236590ff3 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -245,9 +245,10 @@ int chrif_connectack(int fd) printf("Connected to char-server failed %d.\n", RFIFOB(fd,2)); exit(1); } - sprintf(tmp_output,"Successfully connected to Char-Server (Connection #%d).\n",fd); + sprintf(tmp_output,"Successfully connected to Char Server (Connection: '"CL_WHITE"%d"CL_RESET"').\n",fd); ShowStatus(tmp_output); chrif_state = 1; + chrif_connected=1; chrif_sendmap(fd); @@ -862,6 +863,7 @@ int chrif_recvgmaccounts(int fd) { sprintf(tmp_output,"From login-server: receiving information of '"CL_WHITE"%d"CL_RESET"' GM accounts.\n", pc_read_gm_account(fd)); ShowInfo(tmp_output); + memset(tmp_output,'\0',sizeof(tmp_output)); return 0; } @@ -977,12 +979,15 @@ int chrif_char_online(struct map_session_data *sd) int chrif_parse(int fd) { int packet_len, cmd; - // only char-server can have an access to here. // so, if it isn't the char-server, we disconnect the session (fd != char_fd). if (fd != char_fd || session[fd]->eof) { if (fd == char_fd) { - printf("Map-server can't connect to char-server (connection #%d).\n", fd); + if (chrif_connected == 1) { + sprintf(tmp_output,"Map Server disconnected from Char Server.\n\n"); + ShowWarning(tmp_output); + chrif_connected=0; + } char_fd = -1; // check_connect_char_server(0, 0, 0, 0); } @@ -1077,14 +1082,19 @@ int send_users_tochar(int tid, unsigned int tick, int id, int data) { *------------------------------------------ */ int check_connect_char_server(int tid, unsigned int tick, int id, int data) { + static int displayed = 0; if (char_fd <= 0 || session[char_fd] == NULL) { - printf("Attempt to connect to char-server...\n"); + if (!displayed) { + ShowStatus("Attempting to connect to Char Server. Please wait.\n"); + displayed = 1; + } chrif_state = 0; char_fd = make_connection(char_ip, char_port); session[char_fd]->func_parse = chrif_parse; realloc_fifo(char_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); chrif_connect(char_fd); + chrif_connected = chrif_isconnect(); #ifndef TXT_ONLY srvinfo = 0; } else { @@ -1094,7 +1104,7 @@ int check_connect_char_server(int tid, unsigned int tick, int id, int data) { } #endif /* not TXT_ONLY */ } - + if (chrif_isconnect()) displayed = 0; return 0; } diff --git a/src/map/chrif.h b/src/map/chrif.h index 5f43120cc..d53631e25 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -9,6 +9,8 @@ void chrif_setport(int); int chrif_isconnect(void); +int chrif_connected; + int chrif_authreq(struct map_session_data *); int chrif_save(struct map_session_data*); int chrif_charselectreq(struct map_session_data *); diff --git a/src/map/map.c b/src/map/map.c index 6013f5751..84164ff95 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1880,7 +1880,7 @@ int map_config_read(char *cfgName) { char_ip_set_ = 1; h = gethostbyname (w2); if(h != NULL) { - snprintf(tmp_output,sizeof(tmp_output),"Character server IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + snprintf(tmp_output,sizeof(tmp_output),"Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); ShowInfo(tmp_output); sprintf(w2,"%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); } @@ -1891,7 +1891,8 @@ int map_config_read(char *cfgName) { map_ip_set_ = 1; h = gethostbyname (w2); if (h != NULL) { - printf("Map server IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + snprintf(tmp_output,sizeof(tmp_output),"Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + ShowInfo(tmp_output); sprintf(w2, "%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); } clif_setip(w2); @@ -1927,8 +1928,10 @@ int map_config_read(char *cfgName) { } else if (strcmpi(w1, "import") == 0) { map_config_read(w2); } else if (strcmpi(w1, "console") == 0) { - if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 ) + if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 ) { console = 1; + ShowNotice("Console Commands is enabled.\n"); + } } else if(strcmpi(w1,"imalive_on")==0){ //Added by Mugendai for I'm Alive mod imalive_on = atoi(w2); //Added by Mugendai for I'm Alive mod } else if(strcmpi(w1,"imalive_time")==0){ //Added by Mugendai for I'm Alive mod @@ -2286,6 +2289,7 @@ void map_versionscreen(int flag) { *------------------------------------------------------ */ int do_init(int argc, char *argv[]) { + chrif_connected = 0; int i; FILE *data_conf; char line[1024], w1[1024], w2[1024]; diff --git a/src/map/npc.c b/src/map/npc.c index d760099ef..70bb4aa12 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2314,12 +2314,12 @@ int do_init_npc(void) // fflush(stdout); } printf("\r"); - sprintf(tmp_output,"Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:\n\t-'" + sprintf(tmp_output,"Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:%30s\n\t-'" CL_WHITE"%d"CL_RESET"' Warps\n\t-'" CL_WHITE"%d"CL_RESET"' Shops\n\t-'" CL_WHITE"%d"CL_RESET"' Scripts\n\t-'" CL_WHITE"%d"CL_RESET"' Mobs\n", - npc_id-START_NPC_NUM,npc_warp,npc_shop,npc_script,npc_mob); + npc_id-START_NPC_NUM,"",npc_warp,npc_shop,npc_script,npc_mob); ShowInfo(tmp_output); add_timer_func_list(npc_walktimer,"npc_walktimer"); // [Valaris] -- cgit v1.2.3-70-g09d2 From 4e003aea5ffaa764bf0e40a63ea314c56903fda0 Mon Sep 17 00:00:00 2001 From: amber Date: Wed, 15 Dec 2004 16:19:07 +0000 Subject: More compile cleanups git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@574 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 1 + src/char/GNUmakefile | 17 --------- src/char_sql/GNUmakefile | 20 ---------- src/common/GNUmakefile | 14 ------- src/common/socket.c | 10 ----- src/ladmin/GNUmakefile | 14 ------- src/login/GNUmakefile | 13 ------- src/login_sql/GNUmakefile | 17 --------- src/map/GNUmakefile | 75 ------------------------------------- src/map/battle.c | 3 +- src/map/map.c | 7 +++- src/txt-converter/char/GNUmakefile | 13 ------- src/txt-converter/char/Makefile | 2 +- src/txt-converter/login/GNUmakefile | 11 ------ src/txt-converter/login/Makefile | 2 +- 15 files changed, 10 insertions(+), 209 deletions(-) delete mode 100644 src/char/GNUmakefile delete mode 100644 src/char_sql/GNUmakefile delete mode 100644 src/common/GNUmakefile delete mode 100644 src/ladmin/GNUmakefile delete mode 100644 src/login/GNUmakefile delete mode 100644 src/login_sql/GNUmakefile delete mode 100644 src/map/GNUmakefile delete mode 100644 src/txt-converter/char/GNUmakefile delete mode 100644 src/txt-converter/login/GNUmakefile (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index b8af157fe..9a048ad7e 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Date Added 12/15 + * Fixed more compile errors gcc 2.95 [MouseJstr] * Removed log files from svn... they will be created when needed [MouseJstr] * Removed unused var in src/map/map.c:107 [MouseJstr] diff --git a/src/char/GNUmakefile b/src/char/GNUmakefile deleted file mode 100644 index f3164e0ec..000000000 --- a/src/char/GNUmakefile +++ /dev/null @@ -1,17 +0,0 @@ -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 -char-server: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ - -char.o: char.c char.h inter.h int_pet.h $(COMMON_H) ../common/version.h -inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H) -int_party.o: int_party.c int_party.h inter.h char.h $(COMMON_H) -int_guild.o: int_guild.c int_guild.h int_storage.h inter.h char.h $(COMMON_H) -int_storage.o: int_storage.c int_storage.h int_guild.h inter.h char.h $(COMMON_H) -int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H) - -clean: - rm -f *.o ../../char-server diff --git a/src/char_sql/GNUmakefile b/src/char_sql/GNUmakefile deleted file mode 100644 index c2e8afe35..000000000 --- a/src/char_sql/GNUmakefile +++ /dev/null @@ -1,20 +0,0 @@ -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_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h ../common/malloc.h ../common/showmsg.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) - $(CC) -o ../../$@ $^ $(LIB_S) - -char.o: char.c char.h 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 - -clean: - rm -f *.o ../../char-server_sql diff --git a/src/common/GNUmakefile b/src/common/GNUmakefile deleted file mode 100644 index b15d4d481..000000000 --- a/src/common/GNUmakefile +++ /dev/null @@ -1,14 +0,0 @@ -txt sql all: core.o socket.o timer.o grfio.o db.o lock.o nullpo.o malloc.o showmsg.o - -core.o: core.c core.h showmsg.h -socket.o: socket.c socket.h mmo.h showmsg.h -timer.o: timer.c timer.h showmsg.h -grfio.o: grfio.c grfio.h showmsg.h -db.o: db.c db.h showmsg.h -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 - -clean: - rm -f *.o diff --git a/src/common/socket.c b/src/common/socket.c index 611d73902..497564298 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -105,16 +105,6 @@ static int recv_to_fifo(int fd) session[fd]->rdata_size+=len; } else if(len<=0){ // value of connection is not necessary the same -// if (fd == 4) // Removed [Yor] -// printf("Char-Server Has Disconnected.\n"); -// else if (fd == 5) // Removed [Yor] -// printf("Attempt To Log In Successful.\n"); -// else if (fd == 7) // Removed [Yor] -// printf("Char-Server Has Disconnected.\n"); -// else if (fd == 8) // Removed [Valaris] -// printf("%s has logged off your server.\n",RFIFOP(fd,6)); // Removed [Valaris] - -// else if (fd != 8) // [Valaris] // printf("set eof : connection #%d\n", fd); session[fd]->eof=1; } diff --git a/src/ladmin/GNUmakefile b/src/ladmin/GNUmakefile deleted file mode 100644 index 879edaeea..000000000 --- a/src/ladmin/GNUmakefile +++ /dev/null @@ -1,14 +0,0 @@ -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 - -ladmin: ladmin.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ ladmin.o md5calc.o $(COMMON_OBJ) -ladmin.o: ladmin.c ladmin.h md5calc.h $(COMMON_H) -md5calc.o: md5calc.c md5calc.h - -clean: - rm -f *.o ../../ladmin diff --git a/src/login/GNUmakefile b/src/login/GNUmakefile deleted file mode 100644 index 300737cbf..000000000 --- a/src/login/GNUmakefile +++ /dev/null @@ -1,13 +0,0 @@ -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 - -login-server: login.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ login.o md5calc.o $(COMMON_OBJ) -login.o: login.c login.h md5calc.h $(COMMON_H) -md5calc.o: md5calc.c md5calc.h - -clean: - rm -f *.o ../../login-server diff --git a/src/login_sql/GNUmakefile b/src/login_sql/GNUmakefile deleted file mode 100644 index 6fbb30865..000000000 --- a/src/login_sql/GNUmakefile +++ /dev/null @@ -1,17 +0,0 @@ -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 - -login-server_sql: login.o md5calc.o strlib.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ $(LIB_S) - -login.o: login.c login.h md5calc.h strlib.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/map/GNUmakefile b/src/map/GNUmakefile deleted file mode 100644 index 03f520f37..000000000 --- a/src/map/GNUmakefile +++ /dev/null @@ -1,75 +0,0 @@ -all: txt sql - -txt: txtobj map-server - -sql: sqlobj map-server_sql - -txtobj: - mkdir 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 -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) - $(CC) -o ../../$@ $^ $(LIBS) - -map-server_sql: sqlobj/map.o sqlobj/chrif.o sqlobj/clif.o sqlobj/pc.o sqlobj/npc.o sqlobj/chat.o sqlobj/path.o sqlobj/itemdb.o sqlobj/mob.o sqlobj/script.o sqlobj/storage.o sqlobj/skill.o sqlobj/atcommand.o sqlobj/charcommand.o sqlobj/battle.o sqlobj/intif.o sqlobj/trade.o sqlobj/party.o sqlobj/vending.o sqlobj/guild.o sqlobj/pet.o sqlobj/mail.o sqlobj/log.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ $(LIB_S) - -txtobj/%.o: %.c - $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< - -sqlobj/%.o: %.c - $(COMPILE.c) $(OUTPUT_OPTION) $< - -txtobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h ../common/core.h ../common/timer.h ../common/db.h ../common/grfio.h ../common/mmo.h ../common/showmsg.h -txtobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/showmsg.h -txtobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/showmsg.h -txtobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h ../common/db.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/chat.o: chat.c map.h clif.h pc.h chat.h ../common/db.h ../common/mmo.h ../common/showmsg.h -txtobj/path.o: path.c map.h battle.h ../common/mmo.h ../common/showmsg.h -txtobj/itemdb.o: itemdb.c map.h battle.h itemdb.h ../common/db.h ../common/grfio.h ../common/mmo.h ../common/showmsg.h -txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h ../common/timer.h ../common/socket.h ../common/mmo.h ../common/showmsg.h -txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h -txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h -txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/atcommand.o: atcommand.c atcommand.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 -txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h -txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h ../common/mmo.h ../common/showmsg.h -txtobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h ../common/mmo.h ../common/showmsg.h -txtobj/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 -txtobj/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 -txtobj/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 - -sqlobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h log.h ../common/core.h ../common/timer.h ../common/db.h ../common/grfio.h ../common/mmo.h ../common/showmsg.h -sqlobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/showmsg.h -sqlobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h log.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/showmsg.h -sqlobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h ../common/db.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/chat.o: chat.c map.h clif.h pc.h chat.h ../common/db.h ../common/mmo.h ../common/showmsg.h -sqlobj/path.o: path.c map.h battle.h ../common/mmo.h ../common/showmsg.h -sqlobj/itemdb.o: itemdb.c map.h battle.h itemdb.h ../common/db.h ../common/grfio.h ../common/mmo.h ../common/showmsg.h -sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h log.h ../common/timer.h ../common/socket.h ../common/mmo.h ../common/showmsg.h -sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h -sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h -sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/atcommand.o: atcommand.c atcommand.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 -sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h -sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h ../common/mmo.h ../common/showmsg.h -sqlobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -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/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 - -clean: - rm -rf *.o ../../map-server ../../map-server_sql sqlobj txtobj diff --git a/src/map/battle.c b/src/map/battle.c index 8892104b9..34c9d5ebb 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1578,10 +1578,11 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i if(sc_data[SC_AUTOGUARD].timer != -1 && damage > 0 && flag&BF_WEAPON) { if(rand()%100 < sc_data[SC_AUTOGUARD].val2) { + int delay; + damage = 0; clif_skill_nodamage(bl,bl,CR_AUTOGUARD,sc_data[SC_AUTOGUARD].val1,1); // different delay depending on skill level [celest] - int delay; if (sc_data[SC_AUTOGUARD].val1 <= 5) delay = 300; else if (sc_data[SC_AUTOGUARD].val1 > 5 && sc_data[SC_AUTOGUARD].val1 <= 9) diff --git a/src/map/map.c b/src/map/map.c index 83c99ed5c..9e50b2f01 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1655,7 +1655,6 @@ static int map_readmap(int m,char *fn, char *alias) { *------------------------------------------ */ int map_readallmap(void) { - ShowStatus("Loading Maps...\n"); int i,maps_removed=0; char fn[256]; char c = '-'; @@ -1665,6 +1664,8 @@ int map_readallmap(void) { FILE *afm_file; #endif + ShowStatus("Loading Maps...\n"); + // 先に全部のャbプの存在を確認 for(i=0;i Date: Mon, 20 Dec 2004 20:03:39 +0000 Subject: gcc 2.95 compile fixes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@678 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 44 -------------------------------------------- src/map/pc.c | 4 ++-- src/map/skill.c | 3 ++- 3 files changed, 4 insertions(+), 47 deletions(-) (limited to 'src/common/socket.c') diff --git a/src/common/socket.c b/src/common/socket.c index 497564298..dfeebf03a 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -36,10 +36,6 @@ int fd_max; int rfifo_size = 65536; int wfifo_size = 65536; -#ifdef TWILIGHT -#define NSOCKET -#endif - #ifndef TCP_FRAME_LEN #define TCP_FRAME_LEN 1053 #endif @@ -61,7 +57,6 @@ void set_defaultparse(int (*defaultparse)(int)) default_func_parse = defaultparse; } -#ifdef NSOCKET static void setsocketopts(int fd) { int yes = 1; // reuse fix @@ -76,7 +71,6 @@ static void setsocketopts(int fd) setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *) &rfifo_size , sizeof(rfifo_size )); } -#endif /* NSOCKET */ /*====================================== * CORE : Socket Sub Function *-------------------------------------- @@ -172,9 +166,6 @@ static int connect_client(int listen_fd) struct sockaddr_in client_address; int len; int result; -#ifndef NSOCKET - int yes = 1; // reuse fix -#endif /* not NSOCKET */ //printf("connect_client : %d\n",listen_fd); @@ -183,15 +174,7 @@ static int connect_client(int listen_fd) fd=accept(listen_fd,(struct sockaddr*)&client_address,&len); if(fd_max<=fd) fd_max=fd+1; -#ifndef NSOCKET - setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char *)&yes,sizeof yes); -#ifdef SO_REUSEPORT - setsockopt(fd,SOL_SOCKET,SO_REUSEPORT,(char *)&yes,sizeof yes); -#endif - setsockopt(fd,IPPROTO_TCP,TCP_NODELAY,(char *)&yes,sizeof yes); -#else /* NSOCKET */ setsocketopts(fd); -#endif /* NSOCKET */ if(fd==-1) perror("accept"); @@ -227,9 +210,6 @@ int make_listen_port(int port) struct sockaddr_in server_address; int fd; int result; -#ifndef NSOCKET - int yes = 1; // reuse fix -#endif /* not NSOCKET */ fd = socket( AF_INET, SOCK_STREAM, 0 ); if(fd_max<=fd) fd_max=fd+1; @@ -243,15 +223,7 @@ int make_listen_port(int port) result = fcntl(fd, F_SETFL, O_NONBLOCK); #endif -#ifndef NSOCKET - setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char *)&yes,sizeof yes); -#ifdef SO_REUSEPORT - setsockopt(fd,SOL_SOCKET,SO_REUSEPORT,(char *)&yes,sizeof yes); -#endif - setsockopt(fd,IPPROTO_TCP,TCP_NODELAY,(char *)&yes,sizeof yes); -#else /* NSOCKET */ setsocketopts(fd); -#endif /* NSOCKET */ server_address.sin_family = AF_INET; server_address.sin_addr.s_addr = htonl( INADDR_ANY ); @@ -333,24 +305,12 @@ int make_connection(long ip,int port) struct sockaddr_in server_address; int fd; int result; -#ifndef NSOCKET - int yes = 1; // reuse fix -#endif /* not NSOCKET */ fd = socket( AF_INET, SOCK_STREAM, 0 ); -#ifndef NSOCKET - if(fd_max<=fd) fd_max=fd+1; - setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char *)&yes,sizeof yes); -#ifdef SO_REUSEPORT - setsockopt(fd,SOL_SOCKET,SO_REUSEPORT,(char *)&yes,sizeof yes); -#endif - setsockopt(fd,IPPROTO_TCP,TCP_NODELAY,(char *)&yes,sizeof yes); -#else /* NSOCKET */ if(fd_max<=fd) fd_max=fd+1; setsocketopts(fd); -#endif /* NSOCKET */ server_address.sin_family = AF_INET; server_address.sin_addr.s_addr = ip; @@ -418,10 +378,8 @@ int realloc_fifo(int fd,int rfifo_size,int wfifo_size) int WFIFOSET(int fd,int len) { struct socket_data *s=session[fd]; -#ifdef NSOCKET if (s == NULL || s->wdata == NULL) return 0; -#endif /* NSOCKET */ if( s->wdata_size+len+16384 > s->max_wdata ){ unsigned char *sin_addr = (unsigned char *)&s->client_addr.sin_addr; realloc_fifo(fd,s->max_rdata, s->max_wdata <<1 ); @@ -429,10 +387,8 @@ int WFIFOSET(int fd,int len) } s->wdata_size=(s->wdata_size+(len)+2048 < s->max_wdata) ? s->wdata_size+len : (printf("socket: %d wdata lost !!\n",fd),s->wdata_size); -#ifdef NSOCKET if (s->wdata_size > (TCP_FRAME_LEN)) send_from_fifo(fd); -#endif /* NSOCKET */ return 0; } diff --git a/src/map/pc.c b/src/map/pc.c index 0e749ead2..09b8b8c4d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -963,9 +963,9 @@ int pc_calc_skilltree(struct map_session_data *sd) do { flag=0; for(i=0;(id=skill_tree[s][c][i].id)>0;i++){ + int j,f=1; if(skill_get_inf2(id)) continue; - int j,f=1; if(!battle_config.skillfree) { for(j=0;j<5;j++) { if( skill_tree[s][c][i].need[j].id && @@ -980,9 +980,9 @@ int pc_calc_skilltree(struct map_session_data *sd) } } for(i=0;(id=skill_tree[s][s_class.job][i].id)>0;i++){ + int j,f=1; if(!skill_get_inf2(id)) continue; - int j,f=1; if(!battle_config.skillfree) { for(j=0;j<5;j++) { if( skill_tree[s][s_class.job][i].need[j].id && diff --git a/src/map/skill.c b/src/map/skill.c index f74409caf..dacd08e88 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -5228,10 +5228,11 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, int i,count=1,limit=10000,val1=0,val2=0; int target=BCT_ENEMY,interval=1000,range=0; int dir=0,aoe_diameter=0; // -- aoe_diameter (moonsoul) added for sage Area Of Effect skills + struct status_change *sc_data; nullpo_retr(0, src); - struct status_change *sc_data = battle_get_sc_data(src); // for firewall and fogwall - celest + sc_data = battle_get_sc_data(src); // for firewall and fogwall - celest switch(skillid){ /* 設定 */ -- cgit v1.2.3-70-g09d2 From 593b12ed67cf27b69563afd2d12752c7ebfee683 Mon Sep 17 00:00:00 2001 From: celest Date: Thu, 23 Dec 2004 13:08:54 +0000 Subject: * Added some of Shinomori's fixes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@751 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 4 +++- src/common/grfio.c | 20 +++++++++++++++----- src/common/mmo.h | 4 ---- src/common/socket.c | 5 +++++ src/login/login.h | 6 +++--- src/map/intif.c | 18 +++++++++++++++--- src/map/npc.c | 25 ++++++++++++++++++++----- src/map/pc.c | 12 +++++------- src/map/pc.h | 7 ++++--- 9 files changed, 70 insertions(+), 31 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index babbcc122..6bc8be064 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,9 +1,11 @@ Date Added 12/23 * Updated mapflags (added missing payon_in03,ayo_in01,ayo_in02, que_god01, que_god02) [Lupus] - * Updated Sacrifice [celest] + * Updated Sacrifice : it's now self-activating, and lasts for 5 attacks [celest] * Fixed compile errors in party.c [celest] * Moved SC_EDP back to 114 [celest] + * Added some of Shinomori's fixes [celest] + * Added optimisation in intif_parse_WisMessage from Freya [celest] 12/22 * Eliminated skill tree mapping since we have entries diff --git a/src/common/grfio.c b/src/common/grfio.c index d27636d33..c8c021b8d 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -140,7 +140,11 @@ static unsigned char NibbleData[4][64]={ */ static unsigned int getlong(unsigned char *p) { - return *p+p[1]*256+(p[2]+p[3]*256)*65536; +// return *p+p[1]*256+(p[2]+p[3]*256)*65536; + return p[0] + | p[1] << 0x08 + | p[2] << 0x10 + | p[3] << 0x18; // Shinomori } /*========================================== @@ -158,15 +162,17 @@ static void BitConvert(BYTE *Src,char *BitSwapTable) { int lop,prm; BYTE tmp[8]; - *(DWORD*)tmp=*(DWORD*)(tmp+4)=0; +// *(DWORD*)tmp=*(DWORD*)(tmp+4)=0; + memset(tmp,0,8); for(lop=0;lop!=64;lop++) { prm = BitSwapTable[lop]-1; if (Src[(prm >> 3) & 7] & BitMaskTable[prm & 7]) { tmp[(lop >> 3) & 7] |= BitMaskTable[lop & 7]; } } - *(DWORD*)Src = *(DWORD*)tmp; - *(DWORD*)(Src+4) = *(DWORD*)(tmp+4); +// *(DWORD*)Src = *(DWORD*)tmp; +// *(DWORD*)(Src+4) = *(DWORD*)(tmp+4); + memcpy(Src,tmp,8); } static void BitConvert4(BYTE *Src) @@ -194,7 +200,11 @@ static void BitConvert4(BYTE *Src) tmp[(lop >> 3) + 4] |= BitMaskTable[lop & 7]; } } - *(DWORD*)Src ^= *(DWORD*)(tmp+4); +// *(DWORD*)Src ^= *(DWORD*)(tmp+4); + Src[0] ^= tmp[4]; + Src[1] ^= tmp[5]; + Src[2] ^= tmp[6]; + Src[3] ^= tmp[7]; } static void decode_des_etc(BYTE *buf,int len,int type,int cycle) diff --git a/src/common/mmo.h b/src/common/mmo.h index 5ee6bf602..44069b85f 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -325,10 +325,6 @@ enum { #ifndef strnicmp #define strnicmp strncasecmp #endif -#ifndef strrchr -#define strrchr rindex -#endif - #endif #endif // _MMO_H_ diff --git a/src/common/socket.c b/src/common/socket.c index dfeebf03a..0f5b53550 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -17,6 +17,11 @@ #include #include #include + +#ifndef SIOCGIFCONF +#include // SIOCGIFCONF on Solaris, maybe others? [Shinomori] +#endif + #endif #include diff --git a/src/login/login.h b/src/login/login.h index 9ae4734fe..7370f5238 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -13,7 +13,7 @@ #define START_ACCOUNT_NUM 2000000 #define END_ACCOUNT_NUM 100000000 -int login_port; +extern int login_port; struct mmo_account { char* userid; char passwd[33]; @@ -36,6 +36,6 @@ struct mmo_char_server { int new; }; -struct mmo_char_server server[MAX_SERVERS]; -int server_fd[MAX_SERVERS]; +extern struct mmo_char_server server[MAX_SERVERS]; +extern int server_fd[MAX_SERVERS]; #endif diff --git a/src/map/intif.c b/src/map/intif.c index fd79acc0c..28f1b65a2 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -627,6 +627,7 @@ int intif_guild_castle_datasave(int castle_id,int index, int value) // Wisp/Page reception int intif_parse_WisMessage(int fd) { // rewritten by [Yor] struct map_session_data* sd; + char *wisp_source; int id=RFIFOL(fd,4); int i=0; //,j=0; @@ -651,9 +652,20 @@ int intif_parse_WisMessage(int fd) { // rewritten by [Yor] else{ */ - if(i == MAX_IGNORE_LIST) { - clif_wis_message(sd->fd,RFIFOP(fd,8),RFIFOP(fd,56),RFIFOW(fd,2)-56); - intif_wis_replay(RFIFOL(fd,4),0); // 送信成功 + else { + wisp_source = RFIFOP(fd,8); // speed up [Yor] + for(i=0;iignore[i].name, wisp_source)==0){ + break; + } + } + if(i==MAX_IGNORE_LIST) // run out of list, so we are not ignored + { + clif_wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56); + intif_wis_replay(id,0); // 送信成功 + } + else + intif_wis_replay(id, 2); // 受信拒否 } }else intif_wis_replay(id,1); // そんな人いません diff --git a/src/map/npc.c b/src/map/npc.c index 7b616282f..728e76a9c 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -32,13 +32,17 @@ struct npc_src_list { struct npc_src_list * next; - struct npc_src_list * prev; +// struct npc_src_list * prev; //[Shinomori] char name[4]; } ; -static struct npc_src_list *npc_src_first,*npc_src_last; +static struct npc_src_list *npc_src_first=NULL; +static struct npc_src_list *npc_src_last=NULL; static int npc_id=START_NPC_NUM; -static int npc_warp,npc_shop,npc_script,npc_mob; +static int npc_warp=0; +static int npc_shop=0; +static int npc_script=0; +static int npc_mob=0; int npc_get_new_npc_id(void){ return npc_id++; } @@ -1366,6 +1370,17 @@ void npc_addsrcfile(char *name) return; } + { + // prevent multiple insert of source files + struct npc_src_list *p=npc_src_first; + while( p ) + { // found the file, no need to insert it again + if( 0==strcmp(name,p->name) ) + return; + p=p->next; + } + } + len = sizeof(*new) + strlen(name); new=(struct npc_src_list *)aCalloc(1,len); new->next = NULL; @@ -2273,10 +2288,10 @@ int do_init_npc(void) memset(&ev_tm_b,-1,sizeof(ev_tm_b)); for(nsl=npc_src_first;nsl;nsl=nsl->next) { - if(nsl->prev){ + /*if(nsl->prev){ // [Shinomori] free(nsl->prev); nsl->prev = NULL; - } + }*/ fp=fopen(nsl->name,"r"); if (fp==NULL) { printf("file not found : %s\n",nsl->name); diff --git a/src/map/pc.c b/src/map/pc.c index 3cd14fcef..09ff43733 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -55,13 +55,11 @@ static char job_bonus[3][MAX_PC_CLASS][MAX_LEVEL]; static int exp_table[14][MAX_LEVEL]; static char statp[255][7]; -/*static struct { - int id; - int max; - struct { - short id,lv; - } need[6]; -} skill_tree[3][MAX_PC_CLASS][100];*/ // moved to pc.h - celest +// h-files are for declarations, not for implementations... [Shinomori] +struct skill_tree_entry skill_tree[3][MAX_PC_CLASS][100]; +// timer for night.day implementation +int day_timer_tid; +int night_timer_tid; static int atkmods[3][20]; // 武器ATKサイズ修正(size_fix.txt) static int refinebonus[5][3]; // 精?ボ?ナステ?ブル(refine_db.txt) diff --git a/src/map/pc.h b/src/map/pc.h index 1f294ce92..a32926886 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -181,7 +181,8 @@ struct skill_tree_entry { struct { short id,lv; } need[6]; -} skill_tree[3][MAX_PC_CLASS][100]; // Celest +}; // Celest +extern struct skill_tree_entry skill_tree[3][MAX_PC_CLASS][100]; int pc_read_gm_account(int fd); int pc_setinvincibletimer(struct map_session_data *sd,int); @@ -194,8 +195,8 @@ int do_init_pc(void); enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT}; // timer for night.day -int day_timer_tid; -int night_timer_tid; +extern int day_timer_tid; +extern int night_timer_tid; int map_day_timer(int,unsigned int,int,int); // by [yor] int map_night_timer(int,unsigned int,int,int); // by [yor] -- cgit v1.2.3-70-g09d2 From d73cbd4c778f408ce3e06c57ad6418b99e2b9c51 Mon Sep 17 00:00:00 2001 From: amber Date: Sun, 26 Dec 2004 19:44:00 +0000 Subject: updates git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@793 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 21 +++++++++++++++++++ src/char_sql/char.c | 2 +- src/char_sql/int_guild.c | 54 ++++++++++++++++++++++++++++++++++-------------- src/common/socket.c | 6 +++++- src/common/socket.h | 1 + src/map/chrif.c | 15 ++++++++++++++ src/map/chrif.h | 2 ++ src/map/map.c | 6 +++++- src/map/pc.c | 31 ++++++++++++--------------- 9 files changed, 101 insertions(+), 37 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index 9c70a25f2..bffbac0f2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,26 @@ Date Added 12/26 + * @mapexit (and do_final) now persist all data to the + char server before exiting to eliminate storage/inventory + inconsistancies.. [MouseJstr] (SVN 793) + * Some cleanup of spiritball memory management [MouseJstr] + * Dramatic performance work for exp updates to sql. Previously, [MouseJstr] + when u killed a mob (in party share), it would cause the char_server to + + 1) Delete all guilds for all members of your party + 2) Re-create all guilds for all members of your party with the new exp + values. + + Now it just generates 2 sql statements per party member, + + 1) update the guild exp, + 2) update the guild_member exp. + + + src/common/socket.c src/common/socket.h src/char_sql/char.c + src/char_sql/int_guild.c src/map/chrif.h src/map/pc.c + src/map/map.c src/map/chrif.c + * Disabled import charcommand_conf.txt by default [celest] * Added Bitmap File system from jA 1086 - automatically generates a cache from maps in the GRF to speed up loading. You can enable/disable it with diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 7eb9a1929..82c8e2a34 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -3338,7 +3338,7 @@ int do_init(int argc, char **argv){ #undef mysql_query int debug_mysql_query(char *file, int line, void *mysql, const char *q) { - // printf("sql: %s:%d# %s\n", file, line, q); + printf("sql: %s:%d# %s\n", file, line, q); return mysql_query((MYSQL *) mysql, q); } diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index df3ec4d81..dedabfab7 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -1235,12 +1235,14 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, { // Could speed up by manipulating only guild_member struct guild * g= inter_guild_fromsql(guild_id); - int i,alv,c; + int i,alv,c, idx; if(g==NULL||g->guild_id<=0) return 0; g->connect_member=0; + + idx = -1; for(i=0,alv=0,c=0;imax_member;i++){ if( g->member[i].account_id==account_id && @@ -1250,6 +1252,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, g->member[i].lv=lv; g->member[i].class=class; mapif_guild_memberinfoshort(g,i); + idx = i; } if( g->member[i].account_id>0 ){ alv+=g->member[i].lv; @@ -1260,8 +1263,14 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, } // 平均レベル g->average_lv=alv/c; - - inter_guild_tosql(g,3); // Change guild & guild_member + + sprintf(tmp_sql, "UPDATE `%s` SET `connect_member`=%d,`average_lv`=%d WHERE `guild_id`='%d'", guild_db, g->connect_member, g->average_lv, g->guild_id); + if(mysql_query(&mysql_handle, tmp_sql) ) + printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); + + sprintf(tmp_sql, "UPDATE `%s` SET `online`=%d,`lv`=%d,`class`=%d WHERE `char_id`=%d", guild_member_db, g->member[idx].online, g->member[idx].lv, g->member[idx].class, g->member[idx].char_id); + if(mysql_query(&mysql_handle, tmp_sql) ) + printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); return 0; } @@ -1385,21 +1394,34 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha } switch(type){ case GMI_POSITION: // 役職 - g->member[i].position=*((int *)data); - break; - case GMI_EXP: { // EXP - int exp,oldexp=g->member[i].exp; - exp=g->member[i].exp=*((unsigned int *)data); - g->exp+=(exp-oldexp); - guild_calcinfo(g); // Lvアップ判断 - mapif_guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,4); - }break; + { + g->member[i].position=*((int *)data); + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + inter_guild_tosql(g,3); // Change guild & guild_member + break; + } + case GMI_EXP: + { // EXP + int exp,oldexp=g->member[i].exp; + exp=g->member[i].exp=*((unsigned int *)data); + g->exp+=(exp-oldexp); + guild_calcinfo(g); // Lvアップ判断 + mapif_guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,4); + mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); + + sprintf(tmp_sql, "UPDATE `%s` SET `guild_lv`=%d,`connect_member`=%d,`max_member`=%d,`average_lv`=%d,`exp`=%d,`next_exp`=%d,`skill_point`=%d WHERE `guild_id`='%d'", guild_db, g->guild_lv, g->connect_member, g->max_member, g->average_lv, g->exp, g->next_exp, g->skill_point, g->guild_id); + if(mysql_query(&mysql_handle, tmp_sql) ) + printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); + + sprintf(tmp_sql, "UPDATE `%s` SET `exp`=%d WHERE `char_id`=%d", guild_member_db, g->member[i].exp, g->member[i].char_id); + if(mysql_query(&mysql_handle, tmp_sql) ) + printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); + break; + } default: - printf("int_guild: GuildMemberInfoChange: Unknown type %d\n",type); - break; + printf("int_guild: GuildMemberInfoChange: Unknown type %d\n",type); + break; } - mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); - inter_guild_tosql(g,3); // Change guild & guild_member return 0; } diff --git a/src/common/socket.c b/src/common/socket.c index 0f5b53550..729f2fdfe 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -62,6 +62,10 @@ void set_defaultparse(int (*defaultparse)(int)) default_func_parse = defaultparse; } +void set_nonblocking(int fd, int yes) { + setsockopt(fd,IPPROTO_TCP,TCP_NODELAY,(char *)&yes,sizeof yes); +} + static void setsocketopts(int fd) { int yes = 1; // reuse fix @@ -70,7 +74,7 @@ static void setsocketopts(int fd) #ifdef SO_REUSEPORT setsockopt(fd,SOL_SOCKET,SO_REUSEPORT,(char *)&yes,sizeof yes); #endif - setsockopt(fd,IPPROTO_TCP,TCP_NODELAY,(char *)&yes,sizeof yes); + set_nonblocking(fd, yes); setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *) &wfifo_size , sizeof(rfifo_size )); setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *) &rfifo_size , sizeof(rfifo_size )); diff --git a/src/common/socket.h b/src/common/socket.h index 43acd6941..9b0c05013 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -91,6 +91,7 @@ int do_parsepacket(void); void do_socket(void); extern void flush_fifos(); +extern void set_nonblocking(int fd, int yes); int start_console(void); diff --git a/src/map/chrif.c b/src/map/chrif.c index 236590ff3..353533561 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -939,6 +939,21 @@ int chrif_char_offline(struct map_session_data *sd) return 0; } +/*========================================= + * Tell char-server to reset all chars offline [Wizputer] + *----------------------------------------- + */ +int chrif_flush_fifo(void) { + if (char_fd < 1) + return -1; + + set_nonblocking(char_fd, 0); + flush_fifos(); + set_nonblocking(char_fd, 1); + + return 0; +} + /*========================================= * Tell char-server to reset all chars offline [Wizputer] *----------------------------------------- diff --git a/src/map/chrif.h b/src/map/chrif.h index d53631e25..7f55d23d6 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -33,4 +33,6 @@ int check_connect_char_server(int tid, unsigned int tick, int id, int data); int do_init_chrif(void); +int chrif_flush_fifo(void); + #endif diff --git a/src/map/map.c b/src/map/map.c index 46705dc8d..4e7223d11 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2489,7 +2489,7 @@ static int cleanup_sub(struct block_list *bl, va_list ap) { switch(bl->type) { case BL_PC: - map_delblock(bl); // There is something better... + map_quit((struct map_session_data *) bl); break; case BL_NPC: npc_delete((struct npc_data *)bl); @@ -2522,9 +2522,13 @@ void do_final(void) { if(map[map_id].m) map_foreachinarea(cleanup_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, 0, 0); } + #ifndef TXT_ONLY chrif_char_reset_offline(); #endif + + chrif_flush_fifo(); + for (i = 0; i < fd_max; i++) delete_session(i); diff --git a/src/map/pc.c b/src/map/pc.c index d314d2e30..881d302c5 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -183,7 +183,6 @@ int pc_delinvincibletimer(struct map_session_data *sd) { static int pc_spiritball_timer(int tid,unsigned int tick,int id,int data) { struct map_session_data *sd; - int i; if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; @@ -193,22 +192,24 @@ static int pc_spiritball_timer(int tid,unsigned int tick,int id,int data) { printf("spirit_timer %d != %d\n",sd->spirit_timer[0],tid); return 0; } - sd->spirit_timer[0]=-1; - for(i=1;ispiritball;i++) { - sd->spirit_timer[i-1] = sd->spirit_timer[i]; - sd->spirit_timer[i] = -1; + + if(sd->spiritball <= 0) { + if(battle_config.error_log) + printf("Spiritballs are already 0 when pc_spiritball_timer gets called"); + sd->spiritball = 0; + return 0; } + sd->spiritball--; - if(sd->spiritball < 0) - sd->spiritball = 0; + memcpy( &sd->spirit_timer[0], &sd->spirit_timer[1], sizeof(sd->spirit_timer[0]) * sd->spiritball ); + sd->spirit_timer[sd->spiritball]=-1; + clif_spiritball(sd); return 0; } int pc_addspiritball(struct map_session_data *sd,int interval,int max) { - int i; - nullpo_retr(0, sd); if(max > MAX_SKILL_LEVEL) @@ -217,16 +218,10 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) { sd->spiritball = 0; if(sd->spiritball >= max) { - if(sd->spirit_timer[0] != -1) { + if(sd->spirit_timer[0] != -1) delete_timer(sd->spirit_timer[0],pc_spiritball_timer); - sd->spirit_timer[0] = -1; - } - for(i=1;ispirit_timer[i-1] = sd->spirit_timer[i]; - sd->spirit_timer[i] = -1; - } - } - else + memcpy( &sd->spirit_timer[0], &sd->spirit_timer[1], sizeof(sd->spirit_timer[0]) * (sd->spiritball - 1)); + } else sd->spiritball++; sd->spirit_timer[sd->spiritball-1] = add_timer(gettick()+interval,pc_spiritball_timer,sd->bl.id,0); -- cgit v1.2.3-70-g09d2 From ab0a9edc2f5754c4f778c008caff1682d43d65eb Mon Sep 17 00:00:00 2001 From: amber Date: Wed, 29 Dec 2004 19:18:18 +0000 Subject: cxx updates git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@861 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 1 + Makefile | 1 + src/char/char.c | 26 +++---- src/char/int_guild.c | 8 +- src/char/int_pet.c | 6 +- src/char_sql/char.c | 10 +-- src/char_sql/int_guild.c | 10 +-- src/char_sql/int_pet.c | 8 +- src/common/db.c | 1 + src/common/grfio.c | 36 ++++----- src/common/grfio.h | 4 +- src/common/mmo.h | 6 +- src/common/socket.c | 12 +-- src/common/socket.h | 1 + src/common/strlib.c | 1 + src/common/utils.h | 4 +- src/map/atcommand.c | 162 +++++++++++++++++++-------------------- src/map/battle.c | 126 +++++++++++++++--------------- src/map/charcommand.c | 58 +++++++------- src/map/chrif.c | 6 +- src/map/clif.c | 194 +++++++++++++++++++++++------------------------ src/map/guild.c | 6 +- src/map/itemdb.c | 6 +- src/map/itemdb.h | 2 +- src/map/map.h | 6 +- src/map/mob.c | 166 ++++++++++++++++++++-------------------- src/map/npc.c | 18 ++--- src/map/pc.c | 162 +++++++++++++++++++-------------------- src/map/pet.c | 46 +++++------ src/map/pet.h | 2 +- src/map/script.c | 14 ++-- src/map/skill.c | 30 ++++---- 32 files changed, 572 insertions(+), 567 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index 6441040a4..f7f3dddd7 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Date Added 12/29 + * Some code cleanup in prep for new debugging malloc (SVN 861) [MouseJstr] * Updated Soul Breaker's damage calculation [celest] * Updated Meteor Assault's cast delay to be not affected by dex [celest] * Changed int_guild.c so it will calculate average guild level only if > 0 diff --git a/Makefile b/Makefile index d9258179c..527693e4e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ # $Id: Makefile 158 2004-10-01 03:45:15Z PoW $ CC = gcc -pipe +# CC = gcc -pipe -x c++ # CC = gcc -pipe -DGCOLLECT # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK diff --git a/src/char/char.c b/src/char/char.c index 72d461865..e812e1de1 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -269,7 +269,7 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p) { "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%s,%d,%d\t%s,%d,%d,%d\t", p->char_id, p->account_id, p->char_num, p->name, // - p->class, p->base_level, p->job_level, + p->class_, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, p->hp, p->max_hp, p->sp, p->max_sp, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, @@ -397,7 +397,7 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) { p->char_id = tmp_int[0]; p->account_id = tmp_int[1]; p->char_num = tmp_int[2]; - p->class = tmp_int[3]; + p->class_ = tmp_int[3]; p->base_level = tmp_int[4]; p->job_level = tmp_int[5]; p->base_exp = tmp_int[6]; @@ -947,7 +947,7 @@ int make_new_char(int fd, unsigned char *dat) { char_dat[i].account_id = sd->account_id; char_dat[i].char_num = dat[30]; strcpy(char_dat[i].name, dat); - char_dat[i].class = 0; + char_dat[i].class_ = 0; char_dat[i].base_level = 1; char_dat[i].job_level = 1; char_dat[i].base_exp = 0; @@ -1156,12 +1156,12 @@ void create_online_files(void) { break; case 4: // by job (and job level) for(k = 0; k < players; k++) - if (char_dat[j].class < char_dat[id[k]].class || + if (char_dat[j].class_ < char_dat[id[k]].class_ || // if same job, we sort by job level. - (char_dat[j].class == char_dat[id[k]].class && + (char_dat[j].class_ == char_dat[id[k]].class_ && char_dat[j].job_level < char_dat[id[k]].job_level) || // if same job and job level, we sort by job exp. - (char_dat[j].class == char_dat[id[k]].class && + (char_dat[j].class_ == char_dat[id[k]].class_ && char_dat[j].job_level == char_dat[id[k]].job_level && char_dat[j].job_exp < char_dat[id[k]].job_exp)) { for(l = players; l > k; l--) @@ -1302,7 +1302,7 @@ void create_online_files(void) { } // displaying of the job if (online_display_option & 6) { - char * jobname = job_name(char_dat[j].class); + char * jobname = job_name(char_dat[j].class_); if ((online_display_option & 6) == 6) { fprintf(fp2, " %s %d/%d\n", jobname, char_dat[j].base_level, char_dat[j].job_level); fprintf(fp, "%-18s %3d/%3d ", jobname, char_dat[j].base_level, char_dat[j].job_level); @@ -1436,7 +1436,7 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { WFIFOW(fd,j+46) = (p->sp > 0x7fff) ? 0x7fff : p->sp; WFIFOW(fd,j+48) = (p->max_sp > 0x7fff) ? 0x7fff : p->max_sp; WFIFOW(fd,j+50) = DEFAULT_WALK_SPEED; // p->speed; - WFIFOW(fd,j+52) = p->class; + WFIFOW(fd,j+52) = p->class_; WFIFOW(fd,j+54) = p->hair; WFIFOW(fd,j+56) = p->weapon; WFIFOW(fd,j+58) = p->base_level; @@ -1717,7 +1717,7 @@ int parse_tologin(int fd) { if (acc > 0) { for (i = 0; i < char_num; i++) { if (char_dat[i].account_id == acc) { - int jobclass = char_dat[i].class; + int jobclass = char_dat[i].class_; char_dat[i].sex = sex; auth_fifo[i].sex = sex; if (jobclass == 19 || jobclass == 20 || @@ -1725,11 +1725,11 @@ int parse_tologin(int fd) { jobclass == 4042 || jobclass == 4043) { // job modification if (jobclass == 19 || jobclass == 20) { - char_dat[i].class = (sex) ? 19 : 20; + char_dat[i].class_ = (sex) ? 19 : 20; } else if (jobclass == 4020 || jobclass == 4021) { - char_dat[i].class = (sex) ? 4020 : 4021; + char_dat[i].class_ = (sex) ? 4020 : 4021; } else if (jobclass == 4042 || jobclass == 4043) { - char_dat[i].class = (sex) ? 4042 : 4043; + char_dat[i].class_ = (sex) ? 4042 : 4043; } // remove specifical skills of classes 19, 4020 and 4042 for(j = 315; j <= 322; j++) { @@ -2730,7 +2730,7 @@ int parse_char(int fd) { WFIFOW(fd,2+46) = (char_dat[i].sp > 0x7fff) ? 0x7fff : char_dat[i].sp; WFIFOW(fd,2+48) = (char_dat[i].max_sp > 0x7fff) ? 0x7fff : char_dat[i].max_sp; WFIFOW(fd,2+50) = DEFAULT_WALK_SPEED; // char_dat[i].speed; - WFIFOW(fd,2+52) = char_dat[i].class; + WFIFOW(fd,2+52) = char_dat[i].class_; WFIFOW(fd,2+54) = char_dat[i].hair; WFIFOW(fd,2+58) = char_dat[i].base_level; diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 8577b2a66..0ee4476fc 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -45,7 +45,7 @@ int inter_guild_tostr(char *str, struct guild *g) { len += sprintf(str + len, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\t%s\t", m->account_id, m->char_id, m->hair, m->hair_color, m->gender, - m->class, m->lv, m->exp, m->exp_payper, m->position, + m->class_, m->lv, m->exp, m->exp_payper, m->position, ((m->account_id > 0) ? m->name : "-")); } // 役職 @@ -138,7 +138,7 @@ int inter_guild_fromstr(char *str, struct guild *g) { m->hair = tmp_int[2]; m->hair_color = tmp_int[3]; m->gender = tmp_int[4]; - m->class = tmp_int[5]; + m->class_ = tmp_int[5]; m->lv = tmp_int[6]; m->exp = tmp_int[7]; m->exp_payper = tmp_int[8]; @@ -767,7 +767,7 @@ int mapif_guild_memberinfoshort(struct guild *g, int idx) { WBUFL(buf,10) = g->member[idx].char_id; WBUFB(buf,14) = g->member[idx].online; WBUFW(buf,15) = g->member[idx].lv; - WBUFW(buf,17) = g->member[idx].class; + WBUFW(buf,17) = g->member[idx].class_; mapif_sendall(buf, 19); return 0; } @@ -1101,7 +1101,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, if (g->member[i].account_id == account_id && g->member[i].char_id == char_id) { g->member[i].online = online; g->member[i].lv = lv; - g->member[i].class = class; + g->member[i].class_ = class; mapif_guild_memberinfoshort(g, i); } if (g->member[i].account_id > 0) { diff --git a/src/char/int_pet.c b/src/char/int_pet.c index cff1e434f..c08c4ccf3 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -30,7 +30,7 @@ int inter_pet_tostr(char *str,struct s_pet *p) p->intimate = 1000; len=sprintf(str,"%d,%d,%s\t%d,%d,%d,%d,%d,%d,%d,%d,%d", - p->pet_id,p->class,p->name,p->account_id,p->char_id,p->level,p->egg_id, + p->pet_id,p->class_,p->name,p->account_id,p->char_id,p->level,p->egg_id, p->equip,p->intimate,p->hungry,p->rename_flag,p->incuvate); return 0; @@ -52,7 +52,7 @@ int inter_pet_fromstr(char *str,struct s_pet *p) return 1; p->pet_id = tmp_int[0]; - p->class = tmp_int[1]; + p->class_ = tmp_int[1]; memcpy(p->name,tmp_str,24); p->account_id = tmp_int[2]; p->char_id = tmp_int[3]; @@ -225,7 +225,7 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet p->account_id = account_id; p->char_id = char_id; } - p->class = pet_class; + p->class_ = pet_class; p->level = pet_lv; p->egg_id = pet_egg_id; p->equip = pet_equip; diff --git a/src/char_sql/char.c b/src/char_sql/char.c index be8611889..6e982ac67 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -440,7 +440,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ //===================================================================================================== - if ((p->base_exp != cp->base_exp) || (p->class != cp->class) || + if ((p->base_exp != cp->base_exp) || (p->class_ != cp->class_) || (p->base_level != cp->base_level) || (p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) || (p->zeny != cp->zeny) || (p->last_point.x != cp->last_point.x) || (p->last_point.y != cp->last_point.y) || @@ -498,7 +498,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ "`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d'," "`hair`='%d',`hair_color`='%d',`clothes_color`='%d',`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d',`partner_id`='%d' WHERE `account_id`='%d' AND `char_id` = '%d'", - char_db, p->class, p->base_level, p->job_level, + char_db, p->class_, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, @@ -913,7 +913,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ p->account_id = atoi(sql_row[1]); p->char_num = atoi(sql_row[2]); strcpy(p->name, sql_row[3]); - p->class = atoi(sql_row[4]); + p->class_ = atoi(sql_row[4]); p->base_level = atoi(sql_row[5]); p->job_level = atoi(sql_row[6]); p->base_exp = atoi(sql_row[7]); @@ -1429,7 +1429,7 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { WFIFOW(fd,j+46) = (p->sp > 0x7fff) ? 0x7fff : p->sp; WFIFOW(fd,j+48) = (p->max_sp > 0x7fff) ? 0x7fff : p->max_sp; WFIFOW(fd,j+50) = DEFAULT_WALK_SPEED; // p->speed; - WFIFOW(fd,j+52) = p->class; + WFIFOW(fd,j+52) = p->class_; WFIFOW(fd,j+54) = p->hair; WFIFOW(fd,j+56) = p->weapon; WFIFOW(fd,j+58) = p->base_level; @@ -2539,7 +2539,7 @@ int parse_char(int fd) { WFIFOW(fd,2+46) = (char_dat[i].sp > 0x7fff) ? 0x7fff : char_dat[i].sp; WFIFOW(fd,2+48) = (char_dat[i].max_sp > 0x7fff) ? 0x7fff : char_dat[i].max_sp; WFIFOW(fd,2+50) = DEFAULT_WALK_SPEED; // char_dat[i].speed; - WFIFOW(fd,2+52) = char_dat[i].class; + WFIFOW(fd,2+52) = char_dat[i].class_; WFIFOW(fd,2+54) = char_dat[i].hair; WFIFOW(fd,2+58) = char_dat[i].base_level; diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 5fee88511..258c173cf 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -229,7 +229,7 @@ int inter_guild_tosql(struct guild *g,int flag) g->guild_id, m->account_id,m->char_id, m->hair,m->hair_color,m->gender, - m->class,m->lv,m->exp,m->exp_payper,m->online,m->position, + m->class_,m->lv,m->exp,m->exp_payper,m->online,m->position, 0,0, jstrescapecpy(t_member,m->name)); @@ -405,7 +405,7 @@ struct guild * inter_guild_fromsql(int guild_id) m->hair=atoi(sql_row[3]); m->hair_color=atoi(sql_row[4]); m->gender=atoi(sql_row[5]); - m->class=atoi(sql_row[6]); + m->class_=atoi(sql_row[6]); m->lv=atoi(sql_row[7]); m->exp=atoi(sql_row[8]); m->exp_payper=atoi(sql_row[9]); @@ -908,7 +908,7 @@ int mapif_guild_memberinfoshort(struct guild *g,int idx) WBUFL(buf,10)=g->member[idx].char_id; WBUFB(buf,14)=g->member[idx].online; WBUFW(buf,15)=g->member[idx].lv; - WBUFW(buf,17)=g->member[idx].class; + WBUFW(buf,17)=g->member[idx].class_; mapif_sendall(buf,19); return 0; } @@ -1283,7 +1283,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, g->member[i].online=online; g->member[i].lv=lv; - g->member[i].class=class; + g->member[i].class_=class; mapif_guild_memberinfoshort(g,i); idx = i; } @@ -1303,7 +1303,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); - sprintf(tmp_sql, "UPDATE `%s` SET `online`=%d,`lv`=%d,`class`=%d WHERE `char_id`=%d", guild_member_db, g->member[idx].online, g->member[idx].lv, g->member[idx].class, g->member[idx].char_id); + sprintf(tmp_sql, "UPDATE `%s` SET `online`=%d,`lv`=%d,`class`=%d WHERE `char_id`=%d", guild_member_db, g->member[idx].online, g->member[idx].lv, g->member[idx].class_, g->member[idx].char_id); if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 97548aeff..edad95f84 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -39,11 +39,11 @@ int inter_pet_tosql(int pet_id, struct s_pet *p) { if (sql_res!=NULL && mysql_num_rows(sql_res)>0) //row reside -> updating sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'", - pet_db, p->class, t_name, p->account_id, p->char_id, p->level, p->egg_id, + pet_db, p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id); else //no row -> insert sprintf(tmp_sql,"INSERT INTO `%s` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) VALUES ('%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - pet_db, pet_id, p->class, t_name, p->account_id, p->char_id, p->level, p->egg_id, + pet_db, pet_id, p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate); mysql_free_result(sql_res) ; //resource free if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -72,7 +72,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet *p){ sql_row = mysql_fetch_row(sql_res); p->pet_id = pet_id; - p->class = atoi(sql_row[1]); + p->class_ = atoi(sql_row[1]); memcpy(p->name, sql_row[2],24); p->account_id = atoi(sql_row[3]); p->char_id = atoi(sql_row[4]); @@ -215,7 +215,7 @@ int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_pt->account_id = account_id; pet_pt->char_id = char_id; } - pet_pt->class = pet_class; + pet_pt->class_ = pet_class; pet_pt->level = pet_lv; pet_pt->egg_id = pet_egg_id; pet_pt->equip = pet_equip; diff --git a/src/common/db.c b/src/common/db.c index 8996dda80..bc4e8451b 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -6,6 +6,7 @@ #include "db.h" #include "mmo.h" #include "utils.h" +#include "malloc.h" #ifdef MEMWATCH #include "memwatch.h" diff --git a/src/common/grfio.c b/src/common/grfio.c index 37cf2b9ee..440c3b2a3 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -284,7 +284,7 @@ static void decode_des_etc(BYTE *buf,int len,int type,int cycle) * Grf data decode sub : zip *------------------------------------------ */ -int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) +int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -294,7 +294,7 @@ int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - stream.next_out = dest; + stream.next_out = (Bytef*) dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; @@ -315,7 +315,7 @@ int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned return err; } -int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { +int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -324,7 +324,7 @@ int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - stream.next_out = dest; + stream.next_out = (Bytef*) dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; @@ -382,7 +382,7 @@ FILELIST *filelist_find(char *fname) { int hash; - for(hash=filelist_hash[filehash(fname)];hash>=0;hash=filelist[hash].next) { + for(hash=filelist_hash[filehash((unsigned char *) fname)];hash>=0;hash=filelist[hash].next) { if(strcmpi(filelist[hash].fn,fname)==0) break; } @@ -421,7 +421,7 @@ static FILELIST* filelist_add(FILELIST *entry) memcpy( &filelist[filelist_entrys], entry, sizeof(FILELIST) ); - hash = filehash(entry->fn); + hash = filehash((unsigned char *) entry->fn); filelist[filelist_entrys].next = filelist_hash[hash]; filelist_hash[hash] = filelist_entrys; @@ -576,7 +576,7 @@ void* grfio_reads(char *fname, int *size) lentry.declen = ftell(in); } fseek(in,0,0); // SEEK_SET - buf2 = calloc(lentry.declen+1024, 1); + buf2 = (unsigned char *) aCalloc(lentry.declen+1024, 1); if (buf2==NULL) { printf("file read memory allocate error : declen\n"); goto errret; @@ -598,7 +598,7 @@ void* grfio_reads(char *fname, int *size) } } if (entry!=NULL && entry->gentry>0) { // Archive[GRF] File Read - buf = calloc(entry->srclen_aligned+1024, 1); + buf = (unsigned char *) aCalloc(entry->srclen_aligned+1024, 1); if (buf==NULL) { printf("file read memory allocate error : srclen_aligned\n"); goto errret; @@ -614,7 +614,7 @@ void* grfio_reads(char *fname, int *size) fseek(in,entry->srcpos,0); fread(buf,1,entry->srclen_aligned,in); fclose(in); - buf2=calloc(entry->declen+1024, 1); + buf2 = (unsigned char *) aCalloc(entry->declen+1024, 1); if (buf2==NULL) { printf("file decode memory allocate error\n"); goto errret; @@ -694,7 +694,7 @@ static int grfio_entryread(char *gfname,int gentry) grf_size = ftell(fp); fseek(fp,0,0); // SEEK_SET fread(grf_header,1,0x2e,fp); - if(strcmp(grf_header,"Master of Magic") || fseek(fp,getlong(grf_header+0x1e),1)){ // SEEK_CUR + if(strcmp((const char *) grf_header,"Master of Magic") || fseek(fp,getlong(grf_header+0x1e),1)){ // SEEK_CUR fclose(fp); printf("%s read error\n",gfname); return 2; // 2:file format error @@ -704,7 +704,7 @@ static int grfio_entryread(char *gfname,int gentry) if (grf_version==0x01) { //****** Grf version 01xx ****** list_size = grf_size-ftell(fp); - grf_filelist = calloc(list_size, 1); + grf_filelist = (unsigned char *) aCalloc(list_size, 1); if(grf_filelist==NULL){ fclose(fp); printf("out of memory : grf_filelist\n"); @@ -725,13 +725,13 @@ static int grfio_entryread(char *gfname,int gentry) type = grf_filelist[ofs2+12]; if( type!=0 ){ // Directory Index ... skip fname = decode_filename(grf_filelist+ofs+6,grf_filelist[ofs]-6); - if(strlen(fname)>sizeof(aentry.fn)-1){ + if(strlen((const char *) fname)>sizeof(aentry.fn)-1){ printf("file name too long : %s\n",fname); free(grf_filelist); exit(1); } srclen=0; - if((period_ptr=strrchr(fname,'.'))!=NULL){ + if((period_ptr=strrchr((const char *) fname,'.'))!=NULL){ for(lop=0;lop<4;lop++) { if(strcmpi(period_ptr,".gnd\0.gat\0.act\0.str"+lop*5)==0) break; @@ -752,7 +752,7 @@ static int grfio_entryread(char *gfname,int gentry) aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e; aentry.cycle = srccount; aentry.type = type; - strncpy(aentry.fn,fname,sizeof(aentry.fn)-1); + strncpy(aentry.fn, (const char *) fname,sizeof(aentry.fn)-1); #ifdef GRFIO_LOCAL aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck #else @@ -779,13 +779,13 @@ static int grfio_entryread(char *gfname,int gentry) return 4; } - rBuf = calloc( rSize , 1); // Get a Read Size + rBuf = (unsigned char *) aCalloc( rSize , 1); // Get a Read Size if (rBuf==NULL) { fclose(fp); printf("out of memory : grf compress entry table buffer\n"); return 3; } - grf_filelist = calloc( eSize , 1); // Get a Extend Size + grf_filelist = (unsigned char *) aCalloc( eSize , 1); // Get a Extend Size if (grf_filelist==NULL) { free(rBuf); fclose(fp); @@ -806,7 +806,7 @@ static int grfio_entryread(char *gfname,int gentry) FILELIST aentry; fname = grf_filelist+ofs; - if (strlen(fname)>sizeof(aentry.fn)-1) { + if (strlen((const char *) fname)>sizeof(aentry.fn)-1) { printf("grf : file name too long : %s\n",fname); free(grf_filelist); exit(1); @@ -927,7 +927,7 @@ int grfio_add(char *fname) } } len = strlen( fname ); - buf = calloc(len+1, 1); + buf = aCalloc(len+1, 1); if (buf==NULL) { printf("out of memory : gentry\n"); exit(1); diff --git a/src/common/grfio.h b/src/common/grfio.h index f39e9af1b..3fa257e2f 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -8,8 +8,8 @@ void* grfio_read(char*); // GRFIO data file read void* grfio_reads(char*,int*); // GRFIO data file read & size get int grfio_size(char*); // GRFIO data file size get -int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen); -int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen); +int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); +int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); // Accessor to GRF filenames char *grfio_setdatafile(const char *str); diff --git a/src/common/mmo.h b/src/common/mmo.h index 617a870e9..41598509e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -114,7 +114,7 @@ struct s_pet { int account_id; int char_id; int pet_id; - short class; + short class_; short level; short egg_id;//pet egg id short equip;//pet equip name_id @@ -132,7 +132,7 @@ struct mmo_charstatus { int base_exp,job_exp,zeny; - short class; + short class_; short status_point,skill_point; int hp,max_hp,sp,max_sp; short option,karma,manner; @@ -204,7 +204,7 @@ struct party { struct guild_member { int account_id, char_id; - short hair,hair_color,gender,class,lv; + short hair,hair_color,gender,class_,lv; int exp,exp_payper; short online,position; int rsv1,rsv2; diff --git a/src/common/socket.c b/src/common/socket.c index 729f2fdfe..5d7d0775e 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -200,8 +200,8 @@ static int connect_client(int listen_fd) #endif CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, char, rfifo_size); - CREATE(session[fd]->wdata, char, wfifo_size); + CREATE(session[fd]->rdata, unsigned char, rfifo_size); + CREATE(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -339,8 +339,8 @@ int make_connection(long ip,int port) FD_SET(fd,&readfds); CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, char, rfifo_size); - CREATE(session[fd]->wdata, char, wfifo_size); + CREATE(session[fd]->rdata, unsigned char, rfifo_size); + CREATE(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -374,11 +374,11 @@ int realloc_fifo(int fd,int rfifo_size,int wfifo_size) { struct socket_data *s=session[fd]; if( s->max_rdata != rfifo_size && s->rdata_size < rfifo_size){ - RECREATE(s->rdata, char, rfifo_size); + RECREATE(s->rdata, unsigned char, rfifo_size); s->max_rdata = rfifo_size; } if( s->max_wdata != wfifo_size && s->wdata_size < wfifo_size){ - RECREATE(s->wdata, char, wfifo_size); + RECREATE(s->wdata, unsigned char, wfifo_size); s->max_wdata = wfifo_size; } return 0; diff --git a/src/common/socket.h b/src/common/socket.h index 9b0c05013..e5e065f33 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -12,6 +12,7 @@ #include #include #endif +#include "malloc.h" // define declaration diff --git a/src/common/strlib.c b/src/common/strlib.c index b113d96f5..9114c3d03 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -4,6 +4,7 @@ #include "strlib.h" #include "utils.h" +#include "malloc.h" //----------------------------------------------- // string lib. diff --git a/src/common/utils.h b/src/common/utils.h index d234e9351..0ac880a50 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -27,11 +27,11 @@ #define CREATE(result, type, number) do {\ if ((number) * sizeof(type) <= 0) \ printf("SYSERR: Zero bytes or less requested at %s:%d.\n", __FILE__, __LINE__); \ - if (!((result) = (type *) calloc ((number), sizeof(type)))) \ + if (!((result) = (type *) aCalloc ((number), sizeof(type)))) \ { perror("SYSERR: malloc failure"); abort(); } } while(0) #define RECREATE(result,type,number) do {\ - if (!((result) = (type *) realloc ((result), sizeof(type) * (number))))\ + if (!((result) = (type *) aRealloc ((result), sizeof(type) * (number))))\ { printf("SYSERR: realloc failure"); abort(); } } while(0) struct StringBuf { diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 45b87a2f3..dc6c55777 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -831,7 +831,7 @@ static int atmobsearch_sub(struct block_list *bl,va_list ap) md = (struct mob_data *)bl; - if(md && fd && (mob_id==-1 || (md->class==mob_id))){ + if(md && fd && (mob_id==-1 || (md->class_==mob_id))){ snprintf(output, sizeof output, "%2d[%3d:%3d] %s", ++number,bl->x, bl->y,md->name); clif_displaymessage(fd, output); @@ -1285,9 +1285,9 @@ int atcommand_who2( player_name[j] = tolower(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive if (pl_GM_level > 0) - sprintf(output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); else - sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); clif_displaymessage(fd, output); count++; } @@ -1478,9 +1478,9 @@ int atcommand_whomap2( if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level if (pl_sd->bl.m == map_id) { if (pl_GM_level > 0) - sprintf(output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); else - sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); clif_displaymessage(fd, output); count++; } @@ -1621,7 +1621,7 @@ int atcommand_whogm( if (strstr(player_name, match_text) != NULL) { // search with no case sensitive sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, output); - sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); clif_displaymessage(fd, output); g = guild_search(pl_sd->status.guild_id); if (g == NULL) @@ -1884,30 +1884,30 @@ int atcommand_option( } sd->status.option = param3; // fix pecopeco display - if (sd->status.class == 13 || sd->status.class == 21 || sd->status.class == 4014 || sd->status.class == 4022) { + if (sd->status.class_ == 13 || sd->status.class_ == 21 || sd->status.class_ == 4014 || sd->status.class_ == 4022) { if (!pc_isriding(sd)) { // sd have the new value... - if (sd->status.class == 13) - sd->status.class = sd->view_class = 7; - else if (sd->status.class == 21) - sd->status.class = sd->view_class = 14; - else if (sd->status.class == 4014) - sd->status.class = sd->view_class = 4008; - else if (sd->status.class == 4022) - sd->status.class = sd->view_class = 4015; + if (sd->status.class_ == 13) + sd->status.class_ = sd->view_class = 7; + else if (sd->status.class_ == 21) + sd->status.class_ = sd->view_class = 14; + else if (sd->status.class_ == 4014) + sd->status.class_ = sd->view_class = 4008; + else if (sd->status.class_ == 4022) + sd->status.class_ = sd->view_class = 4015; } } else { if (pc_isriding(sd)) { // sd have the new value... if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor]) sd->status.option &= ~0x0020; } else { - if (sd->status.class == 7) - sd->status.class = sd->view_class = 13; - else if (sd->status.class == 14) - sd->status.class = sd->view_class = 21; - else if (sd->status.class == 4008) - sd->status.class = sd->view_class = 4014; - else if (sd->status.class == 4015) - sd->status.class = sd->view_class = 4022; + if (sd->status.class_ == 7) + sd->status.class_ = sd->view_class = 13; + else if (sd->status.class_ == 14) + sd->status.class_ = sd->view_class = 21; + else if (sd->status.class_ == 4008) + sd->status.class_ = sd->view_class = 4014; + else if (sd->status.class_ == 4015) + sd->status.class_ = sd->view_class = 4022; else sd->status.option &= ~0x0020; } @@ -2049,14 +2049,14 @@ int atcommand_jobchange( // fix pecopeco display if ((job != 13 && job != 21 && job != 4014 && job != 4022)) { if (pc_isriding(sd)) { - if (sd->status.class == 13) - sd->status.class = sd->view_class = 7; - if (sd->status.class == 21) - sd->status.class = sd->view_class = 14; - if (sd->status.class == 4014) - sd->status.class = sd->view_class = 4008; - if (sd->status.class == 4022) - sd->status.class = sd->view_class = 4015; + if (sd->status.class_ == 13) + sd->status.class_ = sd->view_class = 7; + if (sd->status.class_ == 21) + sd->status.class_ = sd->view_class = 14; + if (sd->status.class_ == 4014) + sd->status.class_ = sd->view_class = 4008; + if (sd->status.class_ == 4022) + sd->status.class_ = sd->view_class = 4015; sd->status.option &= ~0x0020; clif_changeoption(&sd->bl); pc_calcstatus(sd, 0); @@ -2280,9 +2280,9 @@ int atcommand_item( for (i = 0; i < number; i += get_count) { // if pet egg if (pet_id >= 0) { - sd->catch_target_class = pet_db[pet_id].class; + sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet(sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv, + pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); // if not pet egg @@ -2480,7 +2480,7 @@ int atcommand_joblevelup( int up_level = 50, level; struct pc_base_job s_class; nullpo_retr(-1, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); if (!message || !*message || (level = atoi(message)) == 0) { clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup )."); @@ -2492,7 +2492,7 @@ int atcommand_joblevelup( // super novices can go up to 99 [celest] else if (s_class.job == 23) up_level += 49; - else if (sd->status.class > 4007 && sd->status.class < 4023) + else if (sd->status.class_ > 4007 && sd->status.class_ < 4023) up_level += 20; if (level > 0) { @@ -2748,7 +2748,7 @@ int atcommand_model( hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR && cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) { //服の色変更 - if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) { + if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) { //服の色未実装職の判定 clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class. return -1; @@ -2814,7 +2814,7 @@ int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* } if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) { - if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) { + if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) { clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class. return -1; } else { @@ -2860,7 +2860,7 @@ int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* } if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) { - if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) { + if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) { clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class. return -1; } else { @@ -3976,10 +3976,10 @@ int atcommand_makeegg( if (pet_id < 0) pet_id = search_petDB_index(id, PET_EGG); if (pet_id >= 0) { - sd->catch_target_class = pet_db[pet_id].class; + sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet( sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv, + pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } else { @@ -4711,14 +4711,14 @@ int atcommand_character_joblevel( } if ((pl_sd = map_nick2sd(character)) != NULL) { - pl_s_class = pc_calc_base_job(pl_sd->status.class); + pl_s_class = pc_calc_base_job(pl_sd->status.class_); if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level if (pl_s_class.job == 0) max_level -= 40; // super novices can go up to 99 [celest] else if (pl_s_class.job == 23) max_level += 49; - else if (pl_sd->status.class > 4007 && pl_sd->status.class < 4023) + else if (pl_sd->status.class_ > 4007 && pl_sd->status.class_ < 4023) max_level += 20; if (level > 0) { @@ -5316,7 +5316,7 @@ int atcommand_charmodel( if (cloth_color != 0 && pl_sd->status.sex == 1 && - (pl_sd->status.class == 12 || pl_sd->status.class == 17)) { + (pl_sd->status.class_ == 12 || pl_sd->status.class_ == 17)) { clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class. return -1; } else { @@ -5782,7 +5782,7 @@ int atcommand_mapinfo( default: strcpy(direction, "Unknown"); break; } sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d", - ++i, nd->name, direction, nd->class, nd->bl.x, nd->bl.y); + ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y); clif_displaymessage(fd, output); } break; @@ -5826,15 +5826,15 @@ int atcommand_mount_peco( } if (!pc_isriding(sd)) { // if actually no peco - if (sd->status.class == 7 || sd->status.class == 14 || sd->status.class == 4008 || sd->status.class == 4015) { - if (sd->status.class == 7) - sd->status.class = sd->view_class = 13; - else if (sd->status.class == 14) - sd->status.class = sd->view_class = 21; - else if (sd->status.class == 4008) - sd->status.class = sd->view_class = 4014; - else if (sd->status.class == 4015) - sd->status.class = sd->view_class = 4022; + if (sd->status.class_ == 7 || sd->status.class_ == 14 || sd->status.class_ == 4008 || sd->status.class_ == 4015) { + if (sd->status.class_ == 7) + sd->status.class_ = sd->view_class = 13; + else if (sd->status.class_ == 14) + sd->status.class_ = sd->view_class = 21; + else if (sd->status.class_ == 4008) + sd->status.class_ = sd->view_class = 4014; + else if (sd->status.class_ == 4015) + sd->status.class_ = sd->view_class = 4022; pc_setoption(sd, sd->status.option | 0x0020); clif_displaymessage(fd, msg_table[102]); // Mounted Peco. } else { @@ -5842,14 +5842,14 @@ int atcommand_mount_peco( return -1; } } else { - if (sd->status.class == 13) - sd->status.class = sd->view_class = 7; - else if (sd->status.class == 21) - sd->status.class = sd->view_class = 14; - else if (sd->status.class == 4014) - sd->status.class = sd->view_class = 4008; - else if (sd->status.class == 4022) - sd->status.class = sd->view_class = 4015; + if (sd->status.class_ == 13) + sd->status.class_ = sd->view_class = 7; + else if (sd->status.class_ == 21) + sd->status.class_ = sd->view_class = 14; + else if (sd->status.class_ == 4014) + sd->status.class_ = sd->view_class = 4008; + else if (sd->status.class_ == 4022) + sd->status.class_ = sd->view_class = 4015; pc_setoption(sd, sd->status.option & ~0x0020); clif_displaymessage(fd, msg_table[214]); // Unmounted Peco. } @@ -5883,15 +5883,15 @@ int atcommand_char_mount_peco( } if (!pc_isriding(pl_sd)) { // if actually no peco - if (pl_sd->status.class == 7 || pl_sd->status.class == 14 || pl_sd->status.class == 4008 || pl_sd->status.class == 4015) { - if (pl_sd->status.class == 7) - pl_sd->status.class = pl_sd->view_class = 13; - else if (pl_sd->status.class == 14) - pl_sd->status.class = pl_sd->view_class = 21; - else if (pl_sd->status.class == 4008) - pl_sd->status.class = pl_sd->view_class = 4014; - else if (pl_sd->status.class == 4015) - pl_sd->status.class = pl_sd->view_class = 4022; + if (pl_sd->status.class_ == 7 || pl_sd->status.class_ == 14 || pl_sd->status.class_ == 4008 || pl_sd->status.class_ == 4015) { + if (pl_sd->status.class_ == 7) + pl_sd->status.class_ = pl_sd->view_class = 13; + else if (pl_sd->status.class_ == 14) + pl_sd->status.class_ = pl_sd->view_class = 21; + else if (pl_sd->status.class_ == 4008) + pl_sd->status.class_ = pl_sd->view_class = 4014; + else if (pl_sd->status.class_ == 4015) + pl_sd->status.class_ = pl_sd->view_class = 4022; pc_setoption(pl_sd, pl_sd->status.option | 0x0020); clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco. } else { @@ -5899,14 +5899,14 @@ int atcommand_char_mount_peco( return -1; } } else { - if (pl_sd->status.class == 13) - pl_sd->status.class = pl_sd->view_class = 7; - else if (pl_sd->status.class == 21) - pl_sd->status.class = pl_sd->view_class = 14; - else if (pl_sd->status.class == 4014) - pl_sd->status.class = pl_sd->view_class = 4008; - else if (pl_sd->status.class == 4022) - pl_sd->status.class = pl_sd->view_class = 4015; + if (pl_sd->status.class_ == 13) + pl_sd->status.class_ = pl_sd->view_class = 7; + else if (pl_sd->status.class_ == 21) + pl_sd->status.class_ = pl_sd->view_class = 14; + else if (pl_sd->status.class_ == 4014) + pl_sd->status.class_ = pl_sd->view_class = 4008; + else if (pl_sd->status.class_ == 4022) + pl_sd->status.class_ = pl_sd->view_class = 4015; pc_setoption(pl_sd, pl_sd->status.option & ~0x0020); clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco. } @@ -7175,7 +7175,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, if((pl_sd=map_nick2sd(target)) == NULL) return -1; - s_class = pc_calc_base_job(pl_sd->status.class); + s_class = pc_calc_base_job(pl_sd->status.class_); c = s_class.job; s = s_class.upper; @@ -7620,7 +7620,7 @@ atcommand_summon( if((md=(struct mob_data *)map_id2bl(id))){ md->master_id=sd->bl.id; md->state.special_mob_ai=1; - md->mode=mob_db[md->class].mode|0x04; + md->mode=mob_db[md->class_].mode|0x04; md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0); clif_misceffect2(&md->bl,344); } @@ -7894,7 +7894,7 @@ atcommand_petid(const int fd, struct map_session_data* sd, strcpy(temp0,pet_db[i].jname); strcpy(temp0, estr_lower(temp1)); if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) { - snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class, + snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_, pet_db[i].jname); if (cnt >= 100) { // Only if there are custom pets clif_displaymessage(fd, "Be more specific, can't send more than" diff --git a/src/map/battle.c b/src/map/battle.c index 1d699bd10..f59c179b5 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -64,11 +64,11 @@ int battle_get_class(struct block_list *bl) { nullpo_retr(0, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return ((struct mob_data *)bl)->class; + return ((struct mob_data *)bl)->class_; else if(bl->type==BL_PC && (struct map_session_data *)bl) - return ((struct map_session_data *)bl)->status.class; + return ((struct map_session_data *)bl)->status.class_; else if(bl->type==BL_PET && (struct pet_data *)bl) - return ((struct pet_data *)bl)->class; + return ((struct pet_data *)bl)->class_; else return 0; } @@ -115,11 +115,11 @@ int battle_get_range(struct block_list *bl) { nullpo_retr(0, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].range; + return mob_db[((struct mob_data *)bl)->class_].range; else if(bl->type==BL_PC && (struct map_session_data *)bl) return ((struct map_session_data *)bl)->attackrange; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].range; + return mob_db[((struct pet_data *)bl)->class_].range; else return 0; } @@ -152,10 +152,10 @@ int battle_get_max_hp(struct block_list *bl) struct status_change *sc_data=battle_get_sc_data(bl); int max_hp=1; if(bl->type==BL_MOB && ((struct mob_data*)bl)) { - max_hp = mob_db[((struct mob_data*)bl)->class].max_hp; + max_hp = mob_db[((struct mob_data*)bl)->class_].max_hp; if(battle_config.mobs_level_up) // mobs leveling up increase [Valaris] - max_hp+=(((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv)*battle_get_vit(bl); - if(mob_db[((struct mob_data*)bl)->class].mexp > 0) { + max_hp+=(((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv)*battle_get_vit(bl); + if(mob_db[((struct mob_data*)bl)->class_].mexp > 0) { if(battle_config.mvp_hp_rate != 100) max_hp = (max_hp * battle_config.mvp_hp_rate)/100; } @@ -165,8 +165,8 @@ int battle_get_max_hp(struct block_list *bl) } } else if(bl->type==BL_PET && ((struct pet_data*)bl)) { - max_hp = mob_db[((struct pet_data*)bl)->class].max_hp; - if(mob_db[((struct pet_data*)bl)->class].mexp > 0) { + max_hp = mob_db[((struct pet_data*)bl)->class_].max_hp; + if(mob_db[((struct pet_data*)bl)->class_].mexp > 0) { if(battle_config.mvp_hp_rate != 100) max_hp = (max_hp * battle_config.mvp_hp_rate)/100; } @@ -198,14 +198,14 @@ int battle_get_str(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && ((struct mob_data *)bl)) { - str = mob_db[((struct mob_data *)bl)->class].str; + str = mob_db[((struct mob_data *)bl)->class_].str; if(battle_config.mobs_level_up) // mobs leveling up increase [Valaris] - str+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + str+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && ((struct map_session_data *)bl)) return ((struct map_session_data *)bl)->paramc[0]; else if(bl->type==BL_PET && ((struct pet_data *)bl)) - str = mob_db[((struct pet_data *)bl)->class].str; + str = mob_db[((struct pet_data *)bl)->class_].str; if(sc_data) { if(sc_data[SC_LOUD].timer!=-1 && sc_data[SC_QUAGMIRE].timer == -1 && bl->type != BL_PC) @@ -235,14 +235,14 @@ int battle_get_agi(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl) { - agi=mob_db[((struct mob_data *)bl)->class].agi; + agi=mob_db[((struct mob_data *)bl)->class_].agi; if(battle_config.mobs_level_up) // increase of mobs leveling up [Valaris] - agi+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + agi+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) agi=((struct map_session_data *)bl)->paramc[1]; else if(bl->type==BL_PET && (struct pet_data *)bl) - agi=mob_db[((struct pet_data *)bl)->class].agi; + agi=mob_db[((struct pet_data *)bl)->class_].agi; if(sc_data) { if( sc_data[SC_INCREASEAGI].timer!=-1 && sc_data[SC_QUAGMIRE].timer == -1 && sc_data[SC_DONTFORGETME].timer == -1 && @@ -280,14 +280,14 @@ int battle_get_vit(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl) { - vit=mob_db[((struct mob_data *)bl)->class].vit; + vit=mob_db[((struct mob_data *)bl)->class_].vit; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - vit+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + vit+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) vit=((struct map_session_data *)bl)->paramc[2]; else if(bl->type==BL_PET && (struct pet_data *)bl) - vit=mob_db[((struct pet_data *)bl)->class].vit; + vit=mob_db[((struct pet_data *)bl)->class_].vit; if(sc_data) { if(sc_data[SC_STRIPARMOR].timer != -1 && bl->type!=BL_PC) vit = vit*60/100; @@ -311,14 +311,14 @@ int battle_get_int(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl){ - int_=mob_db[((struct mob_data *)bl)->class].int_; + int_=mob_db[((struct mob_data *)bl)->class_].int_; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - int_+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + int_+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) int_=((struct map_session_data *)bl)->paramc[3]; else if(bl->type==BL_PET && (struct pet_data *)bl) - int_=mob_db[((struct pet_data *)bl)->class].int_; + int_=mob_db[((struct pet_data *)bl)->class_].int_; if(sc_data) { if( sc_data[SC_BLESSING].timer != -1 && bl->type != BL_PC){ // ブレッシング @@ -347,14 +347,14 @@ int battle_get_dex(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl) { - dex=mob_db[((struct mob_data *)bl)->class].dex; + dex=mob_db[((struct mob_data *)bl)->class_].dex; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - dex+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + dex+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) dex=((struct map_session_data *)bl)->paramc[4]; else if(bl->type==BL_PET && (struct pet_data *)bl) - dex=mob_db[((struct pet_data *)bl)->class].dex; + dex=mob_db[((struct pet_data *)bl)->class_].dex; if(sc_data) { if(sc_data[SC_CONCENTRATE].timer!=-1 && sc_data[SC_QUAGMIRE].timer == -1 && bl->type != BL_PC) @@ -391,14 +391,14 @@ int battle_get_luk(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl) { - luk=mob_db[((struct mob_data *)bl)->class].luk; + luk=mob_db[((struct mob_data *)bl)->class_].luk; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - luk+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + luk+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) luk=((struct map_session_data *)bl)->paramc[5]; else if(bl->type==BL_PET && (struct pet_data *)bl) - luk=mob_db[((struct pet_data *)bl)->class].luk; + luk=mob_db[((struct pet_data *)bl)->class_].luk; if(sc_data) { if(sc_data[SC_GLORIA].timer!=-1 && bl->type != BL_PC) // グロリア(PCはpc.cで) @@ -580,9 +580,9 @@ int battle_get_atk(struct block_list *bl) if(bl->type==BL_PC && (struct map_session_data *)bl) atk = ((struct map_session_data*)bl)->watk; else if(bl->type==BL_MOB && (struct mob_data *)bl) - atk = mob_db[((struct mob_data*)bl)->class].atk1; + atk = mob_db[((struct mob_data*)bl)->class_].atk1; else if(bl->type==BL_PET && (struct pet_data *)bl) - atk = mob_db[((struct pet_data*)bl)->class].atk1; + atk = mob_db[((struct pet_data*)bl)->class_].atk1; if(sc_data) { if(sc_data[SC_PROVOKE].timer!=-1 && bl->type != BL_PC) @@ -627,9 +627,9 @@ int battle_get_atk2(struct block_list *bl) struct status_change *sc_data=battle_get_sc_data(bl); int atk2=0; if(bl->type==BL_MOB && (struct mob_data *)bl) - atk2 = mob_db[((struct mob_data*)bl)->class].atk2; + atk2 = mob_db[((struct mob_data*)bl)->class_].atk2; else if(bl->type==BL_PET && (struct pet_data *)bl) - atk2 = mob_db[((struct pet_data*)bl)->class].atk2; + atk2 = mob_db[((struct pet_data*)bl)->class_].atk2; if(sc_data) { if( sc_data[SC_IMPOSITIO].timer!=-1) atk2 += sc_data[SC_IMPOSITIO].val1*5; @@ -746,12 +746,12 @@ int battle_get_def(struct block_list *bl) skillid = ((struct map_session_data *)bl)->skillid; } else if(bl->type==BL_MOB && (struct mob_data *)bl) { - def = mob_db[((struct mob_data *)bl)->class].def; + def = mob_db[((struct mob_data *)bl)->class_].def; skilltimer = ((struct mob_data *)bl)->skilltimer; skillid = ((struct mob_data *)bl)->skillid; } else if(bl->type==BL_PET && (struct pet_data *)bl) - def = mob_db[((struct pet_data *)bl)->class].def; + def = mob_db[((struct pet_data *)bl)->class_].def; if(def < 1000000) { if(sc_data) { @@ -808,9 +808,9 @@ int battle_get_mdef(struct block_list *bl) if(bl->type==BL_PC && (struct map_session_data *)bl) mdef = ((struct map_session_data *)bl)->mdef; else if(bl->type==BL_MOB && (struct mob_data *)bl) - mdef = mob_db[((struct mob_data *)bl)->class].mdef; + mdef = mob_db[((struct mob_data *)bl)->class_].mdef; else if(bl->type==BL_PET && (struct pet_data *)bl) - mdef = mob_db[((struct pet_data *)bl)->class].mdef; + mdef = mob_db[((struct pet_data *)bl)->class_].mdef; if(mdef < 1000000) { if(sc_data) { @@ -842,9 +842,9 @@ int battle_get_def2(struct block_list *bl) if(bl->type==BL_PC) def2 = ((struct map_session_data *)bl)->def2; else if(bl->type==BL_MOB) - def2 = mob_db[((struct mob_data *)bl)->class].vit; + def2 = mob_db[((struct mob_data *)bl)->class_].vit; else if(bl->type==BL_PET) - def2 = mob_db[((struct pet_data *)bl)->class].vit; + def2 = mob_db[((struct pet_data *)bl)->class_].vit; if(sc_data) { if( sc_data[SC_ANGELUS].timer!=-1 && bl->type != BL_PC) @@ -872,11 +872,11 @@ int battle_get_mdef2(struct block_list *bl) nullpo_retr(0, bl); if(bl->type==BL_MOB) - mdef2 = mob_db[((struct mob_data *)bl)->class].int_ + (mob_db[((struct mob_data *)bl)->class].vit>>1); + mdef2 = mob_db[((struct mob_data *)bl)->class_].int_ + (mob_db[((struct mob_data *)bl)->class_].vit>>1); else if(bl->type==BL_PC) mdef2 = ((struct map_session_data *)bl)->mdef2 + (((struct map_session_data *)bl)->paramc[2]>>1); else if(bl->type==BL_PET) - mdef2 = mob_db[((struct pet_data *)bl)->class].int_ + (mob_db[((struct pet_data *)bl)->class].vit>>1); + mdef2 = mob_db[((struct pet_data *)bl)->class_].int_ + (mob_db[((struct pet_data *)bl)->class_].vit>>1); if(sc_data) { if( sc_data[SC_MINDBREAKER].timer!=-1 && bl->type != BL_PC) mdef2 -= (mdef2*6*sc_data[SC_MINDBREAKER].val1)/100; @@ -901,7 +901,7 @@ int battle_get_speed(struct block_list *bl) if(bl->type==BL_MOB && (struct mob_data *)bl) { speed = ((struct mob_data *)bl)->speed; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - speed-=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + speed-=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PET && (struct pet_data *)bl) speed = ((struct pet_data *)bl)->msd->petDB->speed; @@ -960,9 +960,9 @@ int battle_get_adelay(struct block_list *bl) struct status_change *sc_data=battle_get_sc_data(bl); int adelay=4000,aspd_rate = 100,i; if(bl->type==BL_MOB && (struct mob_data *)bl) - adelay = mob_db[((struct mob_data *)bl)->class].adelay; + adelay = mob_db[((struct mob_data *)bl)->class_].adelay; else if(bl->type==BL_PET && (struct pet_data *)bl) - adelay = mob_db[((struct pet_data *)bl)->class].adelay; + adelay = mob_db[((struct pet_data *)bl)->class_].adelay; if(sc_data) { //ツーハンドクイッケン使用時でクァグマイアでも私を忘れないで…でもない時は3割減算 @@ -1016,9 +1016,9 @@ int battle_get_amotion(struct block_list *bl) struct status_change *sc_data=battle_get_sc_data(bl); int amotion=2000,aspd_rate = 100,i; if(bl->type==BL_MOB && (struct mob_data *)bl) - amotion = mob_db[((struct mob_data *)bl)->class].amotion; + amotion = mob_db[((struct mob_data *)bl)->class_].amotion; else if(bl->type==BL_PET && (struct pet_data *)bl) - amotion = mob_db[((struct pet_data *)bl)->class].amotion; + amotion = mob_db[((struct pet_data *)bl)->class_].amotion; if(sc_data) { if(sc_data[SC_TWOHANDQUICKEN].timer != -1 && sc_data[SC_QUAGMIRE].timer == -1 && sc_data[SC_DONTFORGETME].timer == -1) // 2HQ @@ -1061,7 +1061,7 @@ int battle_get_dmotion(struct block_list *bl) nullpo_retr(0, bl); sc_data = battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl){ - ret=mob_db[((struct mob_data *)bl)->class].dmotion; + ret=mob_db[((struct mob_data *)bl)->class_].dmotion; if(battle_config.monster_damage_delay_rate != 100) ret = ret*battle_config.monster_damage_delay_rate/400; } @@ -1071,7 +1071,7 @@ int battle_get_dmotion(struct block_list *bl) ret = ret*battle_config.pc_damage_delay_rate/400; } else if(bl->type==BL_PET && (struct pet_data *)bl) - ret=mob_db[((struct pet_data *)bl)->class].dmotion; + ret=mob_db[((struct pet_data *)bl)->class_].dmotion; else return 2000; @@ -1093,7 +1093,7 @@ int battle_get_element(struct block_list *bl) else if(bl->type==BL_PC && (struct map_session_data *)bl) ret=20+((struct map_session_data *)bl)->def_ele; // 防御属性Lv1 else if(bl->type==BL_PET && (struct pet_data *)bl) - ret = mob_db[((struct pet_data *)bl)->class].element; + ret = mob_db[((struct pet_data *)bl)->class_].element; if(sc_data) { if( sc_data[SC_BENEDICTIO].timer!=-1 ) // 聖体降福 @@ -1183,7 +1183,7 @@ int battle_get_guild_id(struct block_list *bl) if(bl->type==BL_PC && (struct map_session_data *)bl) return ((struct map_session_data *)bl)->status.guild_id; else if(bl->type==BL_MOB && (struct mob_data *)bl) - return ((struct mob_data *)bl)->class; + return ((struct mob_data *)bl)->class_; else if(bl->type==BL_SKILL && (struct skill_unit *)bl) return ((struct skill_unit *)bl)->group->guild_id; else @@ -1193,11 +1193,11 @@ int battle_get_race(struct block_list *bl) { nullpo_retr(0, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].race; + return mob_db[((struct mob_data *)bl)->class_].race; else if(bl->type==BL_PC && (struct map_session_data *)bl) return 7; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].race; + return mob_db[((struct pet_data *)bl)->class_].race; else return 0; } @@ -1205,11 +1205,11 @@ int battle_get_size(struct block_list *bl) { nullpo_retr(1, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].size; + return mob_db[((struct mob_data *)bl)->class_].size; else if(bl->type==BL_PC && (struct map_session_data *)bl) return 1; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].size; + return mob_db[((struct pet_data *)bl)->class_].size; else return 1; } @@ -1217,9 +1217,9 @@ int battle_get_mode(struct block_list *bl) { nullpo_retr(0x01, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].mode; + return mob_db[((struct mob_data *)bl)->class_].mode; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].mode; + return mob_db[((struct pet_data *)bl)->class_].mode; else return 0x01; // とりあえず動くということで1 } @@ -1228,9 +1228,9 @@ int battle_get_mexp(struct block_list *bl) { nullpo_retr(0, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].mexp; + return mob_db[((struct mob_data *)bl)->class_].mexp; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].mexp; + return mob_db[((struct pet_data *)bl)->class_].mexp; else return 0; } @@ -1914,7 +1914,7 @@ static struct Damage battle_calc_pet_weapon_attack( atkmin = battle_get_atk(src); atkmax = battle_get_atk2(src); } - if(mob_db[pd->class].range>3 ) + if(mob_db[pd->class_].range>3 ) flag=(flag&~BF_RANGEMASK)|BF_LONG; if(atkmin > atkmax) atkmin = atkmax; @@ -2375,7 +2375,7 @@ static struct Damage battle_calc_mob_weapon_attack( atkmin = battle_get_atk(src); atkmax = battle_get_atk2(src); } - if(mob_db[md->class].range>3 ) + if(mob_db[md->class_].range>3 ) flag=(flag&~BF_RANGEMASK)|BF_LONG; if(atkmin > atkmax) atkmin = atkmax; @@ -2722,12 +2722,12 @@ static struct Damage battle_calc_mob_weapon_attack( int cardfix=100,i; cardfix=cardfix*(100-tsd->subele[s_ele])/100; // 属 性によるダメージ耐性 cardfix=cardfix*(100-tsd->subrace[s_race])/100; // 種族によるダメージ耐性 - if(mob_db[md->class].mode & 0x20) + if(mob_db[md->class_].mode & 0x20) cardfix=cardfix*(100-tsd->subrace[10])/100; else cardfix=cardfix*(100-tsd->subrace[11])/100; for(i=0;iadd_def_class_count;i++) { - if(tsd->add_def_classid[i] == md->class) { + if(tsd->add_def_classid[i] == md->class_) { cardfix=cardfix*(100-tsd->add_def_classrate[i])/100; break; } @@ -3798,7 +3798,7 @@ static struct Damage battle_calc_pc_weapon_attack( cardfix=cardfix*(100-tsd->subrace[11])/100; //ボス以外からの攻撃はダメージ減少 //特定Class用補正処理左手(少女の日記→ボンゴン用?) for(i=0;iadd_def_class_count;i++) { - if(tsd->add_def_classid[i] == sd->status.class) { + if(tsd->add_def_classid[i] == sd->status.class_) { cardfix=cardfix*(100-tsd->add_def_classrate[i])/100; break; } @@ -4984,7 +4984,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if(su && su->group->target_flag==BCT_NOENEMY) return 1; else if (battle_config.pk_mode && - (((struct map_session_data*)ss)->status.class==0 || ((struct map_session_data*)target)->status.class==0 || + (((struct map_session_data*)ss)->status.class_==0 || ((struct map_session_data*)target)->status.class_==0 || ((struct map_session_data*)ss)->status.base_level < battle_config.pk_min_level || ((struct map_session_data*)target)->status.base_level < battle_config.pk_min_level)) return 1; // prevent novice engagement in pk_mode [Valaris] diff --git a/src/map/charcommand.c b/src/map/charcommand.c index f8e3be983..1ced08777 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -309,14 +309,14 @@ int charcommand_jobchange( // fix pecopeco display if ((job != 13 && job != 21 && job != 4014 && job != 4022)) { if (pc_isriding(sd)) { - if (pl_sd->status.class == 13) - pl_sd->status.class = pl_sd->view_class = 7; - if (pl_sd->status.class == 21) - pl_sd->status.class = pl_sd->view_class = 14; - if (pl_sd->status.class == 4014) - pl_sd->status.class = pl_sd->view_class = 4008; - if (pl_sd->status.class == 4022) - pl_sd->status.class = pl_sd->view_class = 4015; + if (pl_sd->status.class_ == 13) + pl_sd->status.class_ = pl_sd->view_class = 7; + if (pl_sd->status.class_ == 21) + pl_sd->status.class_ = pl_sd->view_class = 14; + if (pl_sd->status.class_ == 4014) + pl_sd->status.class_ = pl_sd->view_class = 4008; + if (pl_sd->status.class_ == 4022) + pl_sd->status.class_ = pl_sd->view_class = 4015; pl_sd->status.option &= ~0x0020; clif_changeoption(&pl_sd->bl); pc_calcstatus(pl_sd, 0); @@ -502,7 +502,7 @@ int charcommand_stats( { "Zeny - %d", pl_sd->status.zeny }, { NULL, 0 } }; - sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class), "(level %d)"); + sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class_), "(level %d)"); sprintf(output, msg_table[53], pl_sd->status.name); // '%s' stats: clif_displaymessage(fd, output); for (i = 0; output_table[i].format != NULL; i++) { @@ -582,30 +582,30 @@ int charcommand_option( pl_sd->opt2 = opt2; pl_sd->status.option = opt3; // fix pecopeco display - if (pl_sd->status.class == 13 || pl_sd->status.class == 21 || pl_sd->status.class == 4014 || pl_sd->status.class == 4022) { + if (pl_sd->status.class_ == 13 || pl_sd->status.class_ == 21 || pl_sd->status.class_ == 4014 || pl_sd->status.class_ == 4022) { if (!pc_isriding(pl_sd)) { // pl_sd have the new value... - if (pl_sd->status.class == 13) - pl_sd->status.class = pl_sd->view_class = 7; - else if (pl_sd->status.class == 21) - pl_sd->status.class = pl_sd->view_class = 14; - else if (pl_sd->status.class == 4014) - pl_sd->status.class = pl_sd->view_class = 4008; - else if (pl_sd->status.class == 4022) - pl_sd->status.class = pl_sd->view_class = 4015; + if (pl_sd->status.class_ == 13) + pl_sd->status.class_ = pl_sd->view_class = 7; + else if (pl_sd->status.class_ == 21) + pl_sd->status.class_ = pl_sd->view_class = 14; + else if (pl_sd->status.class_ == 4014) + pl_sd->status.class_ = pl_sd->view_class = 4008; + else if (pl_sd->status.class_ == 4022) + pl_sd->status.class_ = pl_sd->view_class = 4015; } } else { if (pc_isriding(pl_sd)) { // pl_sd have the new value... if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor]) pl_sd->status.option &= ~0x0020; } else { - if (pl_sd->status.class == 7) - pl_sd->status.class = pl_sd->view_class = 13; - else if (pl_sd->status.class == 14) - pl_sd->status.class = pl_sd->view_class = 21; - else if (pl_sd->status.class == 4008) - pl_sd->status.class = pl_sd->view_class = 4014; - else if (pl_sd->status.class == 4015) - pl_sd->status.class = pl_sd->view_class = 4022; + if (pl_sd->status.class_ == 7) + pl_sd->status.class_ = pl_sd->view_class = 13; + else if (pl_sd->status.class_ == 14) + pl_sd->status.class_ = pl_sd->view_class = 21; + else if (pl_sd->status.class_ == 4008) + pl_sd->status.class_ = pl_sd->view_class = 4014; + else if (pl_sd->status.class_ == 4015) + pl_sd->status.class_ = pl_sd->view_class = 4022; else pl_sd->status.option &= ~0x0020; } @@ -701,7 +701,7 @@ int charcommand_stats_all(const int fd, struct map_session_data* sd, const char* else sprintf(gmlevel, " "); - sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp); + sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp); clif_displaymessage(fd, output); sprintf(output, "STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s", pl_sd->status.str, pl_sd->status.agi, pl_sd->status.vit, pl_sd->status.int_, pl_sd->status.dex, pl_sd->status.luk, pl_sd->status.zeny, gmlevel); clif_displaymessage(fd, output); @@ -1061,9 +1061,9 @@ int charcommand_item( for (i = 0; i < number; i += get_count) { // if pet egg if (pet_id >= 0) { - sd->catch_target_class = pet_db[pet_id].class; + sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet(sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv, + pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); // if not pet egg diff --git a/src/map/chrif.c b/src/map/chrif.c index 353533561..c04630300 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -606,7 +606,7 @@ int chrif_changedsex(int fd) sd = map_id2sd(acc); if (acc > 0) { if (sd != NULL && sd->status.sex != sex) { - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); if (sd->status.sex == 0) { sd->status.sex = 1; sd->sex = 1; @@ -641,9 +641,9 @@ int chrif_changedsex(int fd) clif_updatestatus(sd, SP_SKILLPOINT); // change job if necessary if (s_class.job == 20 || s_class.job == 4021 || s_class.job == 4043) - sd->status.class -= 1; + sd->status.class_ -= 1; else if (s_class.job == 19 || s_class.job == 4020 || s_class.job == 4042) - sd->status.class += 1; + sd->status.class_ += 1; } // save character chrif_save(sd); diff --git a/src/map/clif.c b/src/map/clif.c index 28cc58fcf..0f4746251 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -973,21 +973,21 @@ static int clif_mob0078(struct mob_data *md, unsigned char *buf) WBUFW(buf,8)=md->opt1; WBUFW(buf,10)=md->opt2; WBUFW(buf,12)=md->option; - WBUFW(buf,14)=mob_get_viewclass(md->class); - if((mob_get_viewclass(md->class) <= 23) || (mob_get_viewclass(md->class) == 812) || (mob_get_viewclass(md->class) >= 4001)) { - WBUFW(buf,12)|=mob_db[md->class].option; - WBUFW(buf,16)=mob_get_hair(md->class); - WBUFW(buf,18)=mob_get_weapon(md->class); - WBUFW(buf,20)=mob_get_head_buttom(md->class); - WBUFW(buf,22)=mob_get_shield(md->class); - WBUFW(buf,24)=mob_get_head_top(md->class); - WBUFW(buf,26)=mob_get_head_mid(md->class); - WBUFW(buf,28)=mob_get_hair_color(md->class); - WBUFW(buf,30)=mob_get_clothes_color(md->class); //Add for player monster dye - Valaris - WBUFB(buf,45)=mob_get_sex(md->class); - } - - if (md->class >= 1285 && md->class <= 1287 && md->guild_id) { // Added guardian emblems [Valaris] + WBUFW(buf,14)=mob_get_viewclass(md->class_); + if((mob_get_viewclass(md->class_) <= 23) || (mob_get_viewclass(md->class_) == 812) || (mob_get_viewclass(md->class_) >= 4001)) { + WBUFW(buf,12)|=mob_db[md->class_].option; + WBUFW(buf,16)=mob_get_hair(md->class_); + WBUFW(buf,18)=mob_get_weapon(md->class_); + WBUFW(buf,20)=mob_get_head_buttom(md->class_); + WBUFW(buf,22)=mob_get_shield(md->class_); + WBUFW(buf,24)=mob_get_head_top(md->class_); + WBUFW(buf,26)=mob_get_head_mid(md->class_); + WBUFW(buf,28)=mob_get_hair_color(md->class_); + WBUFW(buf,30)=mob_get_clothes_color(md->class_); //Add for player monster dye - Valaris + WBUFB(buf,45)=mob_get_sex(md->class_); + } + + if (md->class_ >= 1285 && md->class_ <= 1287 && md->guild_id) { // Added guardian emblems [Valaris] struct guild *g; struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if (gc && gc->guild_id > 0) { @@ -1025,23 +1025,23 @@ static int clif_mob007b(struct mob_data *md, unsigned char *buf) { WBUFW(buf,8)=md->opt1; WBUFW(buf,10)=md->opt2; WBUFW(buf,12)=md->option; - WBUFW(buf,14)=mob_get_viewclass(md->class); - if ((mob_get_viewclass(md->class) < 24) || (mob_get_viewclass(md->class) > 4000)) { - WBUFW(buf,12)|=mob_db[md->class].option; - WBUFW(buf,16)=mob_get_hair(md->class); - WBUFW(buf,18)=mob_get_weapon(md->class); - WBUFW(buf,20)=mob_get_head_buttom(md->class); + WBUFW(buf,14)=mob_get_viewclass(md->class_); + if ((mob_get_viewclass(md->class_) < 24) || (mob_get_viewclass(md->class_) > 4000)) { + WBUFW(buf,12)|=mob_db[md->class_].option; + WBUFW(buf,16)=mob_get_hair(md->class_); + WBUFW(buf,18)=mob_get_weapon(md->class_); + WBUFW(buf,20)=mob_get_head_buttom(md->class_); WBUFL(buf,22)=gettick(); - WBUFW(buf,26)=mob_get_shield(md->class); - WBUFW(buf,28)=mob_get_head_top(md->class); - WBUFW(buf,30)=mob_get_head_mid(md->class); - WBUFW(buf,32)=mob_get_hair_color(md->class); - WBUFW(buf,34)=mob_get_clothes_color(md->class); //Add for player monster dye - Valaris - WBUFB(buf,49)=mob_get_sex(md->class); + WBUFW(buf,26)=mob_get_shield(md->class_); + WBUFW(buf,28)=mob_get_head_top(md->class_); + WBUFW(buf,30)=mob_get_head_mid(md->class_); + WBUFW(buf,32)=mob_get_hair_color(md->class_); + WBUFW(buf,34)=mob_get_clothes_color(md->class_); //Add for player monster dye - Valaris + WBUFB(buf,49)=mob_get_sex(md->class_); } else WBUFL(buf,22)=gettick(); - if(md->class >= 1285 && md->class <= 1287 && md->guild_id) { // Added guardian emblems [Valaris] + if(md->class_ >= 1285 && md->class_ <= 1287 && md->guild_id) { // Added guardian emblems [Valaris] struct guild *g; struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc && gc->guild_id > 0){ @@ -1075,8 +1075,8 @@ static int clif_npc0078(struct npc_data *nd, unsigned char *buf) { WBUFW(buf,0)=0x78; WBUFL(buf,2)=nd->bl.id; WBUFW(buf,6)=nd->speed; - WBUFW(buf,14)=nd->class; - if ((nd->class == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) { + WBUFW(buf,14)=nd->class_; + if ((nd->class_ == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) { WBUFL(buf,22)=g->emblem_id; WBUFL(buf,26)=g->guild_id; } @@ -1099,8 +1099,8 @@ static int clif_npc007b(struct npc_data *nd, unsigned char *buf) { WBUFW(buf,0)=0x7b; WBUFL(buf,2)=nd->bl.id; WBUFW(buf,6)=nd->speed; - WBUFW(buf,14)=nd->class; - if ((nd->class == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) { + WBUFW(buf,14)=nd->class_; + if ((nd->class_ == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) { WBUFL(buf,22)=g->emblem_id; WBUFL(buf,26)=g->guild_id; } @@ -1127,18 +1127,18 @@ static int clif_pet0078(struct pet_data *pd, unsigned char *buf) { WBUFW(buf,0)=0x78; WBUFL(buf,2)=pd->bl.id; WBUFW(buf,6)=pd->speed; - WBUFW(buf,14)=mob_get_viewclass(pd->class); - if((mob_get_viewclass(pd->class) < 24) || (mob_get_viewclass(pd->class) > 4000)) { - WBUFW(buf,12)=mob_db[pd->class].option; - WBUFW(buf,16)=mob_get_hair(pd->class); - WBUFW(buf,18)=mob_get_weapon(pd->class); - WBUFW(buf,20)=mob_get_head_buttom(pd->class); - WBUFW(buf,22)=mob_get_shield(pd->class); - WBUFW(buf,24)=mob_get_head_top(pd->class); - WBUFW(buf,26)=mob_get_head_mid(pd->class); - WBUFW(buf,28)=mob_get_hair_color(pd->class); - WBUFW(buf,30)=mob_get_clothes_color(pd->class); //Add for player pet dye - Valaris - WBUFB(buf,45)=mob_get_sex(pd->class); + WBUFW(buf,14)=mob_get_viewclass(pd->class_); + if((mob_get_viewclass(pd->class_) < 24) || (mob_get_viewclass(pd->class_) > 4000)) { + WBUFW(buf,12)=mob_db[pd->class_].option; + WBUFW(buf,16)=mob_get_hair(pd->class_); + WBUFW(buf,18)=mob_get_weapon(pd->class_); + WBUFW(buf,20)=mob_get_head_buttom(pd->class_); + WBUFW(buf,22)=mob_get_shield(pd->class_); + WBUFW(buf,24)=mob_get_head_top(pd->class_); + WBUFW(buf,26)=mob_get_head_mid(pd->class_); + WBUFW(buf,28)=mob_get_hair_color(pd->class_); + WBUFW(buf,30)=mob_get_clothes_color(pd->class_); //Add for player pet dye - Valaris + WBUFB(buf,45)=mob_get_sex(pd->class_); } else { WBUFW(buf,16)=0x14; if((view = itemdb_viewid(pd->equip)) > 0) @@ -1169,19 +1169,19 @@ static int clif_pet007b(struct pet_data *pd, unsigned char *buf) { WBUFW(buf,0)=0x7b; WBUFL(buf,2)=pd->bl.id; WBUFW(buf,6)=pd->speed; - WBUFW(buf,14)=mob_get_viewclass(pd->class); - if((mob_get_viewclass(pd->class) < 24) || (mob_get_viewclass(pd->class) > 4000)) { - WBUFW(buf,12)=mob_db[pd->class].option; - WBUFW(buf,16)=mob_get_hair(pd->class); - WBUFW(buf,18)=mob_get_weapon(pd->class); - WBUFW(buf,20)=mob_get_head_buttom(pd->class); + WBUFW(buf,14)=mob_get_viewclass(pd->class_); + if((mob_get_viewclass(pd->class_) < 24) || (mob_get_viewclass(pd->class_) > 4000)) { + WBUFW(buf,12)=mob_db[pd->class_].option; + WBUFW(buf,16)=mob_get_hair(pd->class_); + WBUFW(buf,18)=mob_get_weapon(pd->class_); + WBUFW(buf,20)=mob_get_head_buttom(pd->class_); WBUFL(buf,22)=gettick(); - WBUFW(buf,26)=mob_get_shield(pd->class); - WBUFW(buf,28)=mob_get_head_top(pd->class); - WBUFW(buf,30)=mob_get_head_mid(pd->class); - WBUFW(buf,32)=mob_get_hair_color(pd->class); - WBUFW(buf,34)=mob_get_clothes_color(pd->class); //Add for player pet dye - Valaris - WBUFB(buf,49)=mob_get_sex(pd->class); + WBUFW(buf,26)=mob_get_shield(pd->class_); + WBUFW(buf,28)=mob_get_head_top(pd->class_); + WBUFW(buf,30)=mob_get_head_mid(pd->class_); + WBUFW(buf,32)=mob_get_hair_color(pd->class_); + WBUFW(buf,34)=mob_get_clothes_color(pd->class_); //Add for player pet dye - Valaris + WBUFB(buf,49)=mob_get_sex(pd->class_); } else { WBUFW(buf,16)=0x14; if ((view = itemdb_viewid(pd->equip)) > 0) @@ -1285,11 +1285,11 @@ int clif_spawnpc(struct map_session_data *sd) { clif_guild_emblem(sd,g); } // end addition [Valaris] - if (sd->status.class==13 || sd->status.class==21 || sd->status.class==4014 || sd->status.class==4022) + if (sd->status.class_==13 || sd->status.class_==21 || sd->status.class_==4014 || sd->status.class_==4022) pc_setoption(sd,sd->status.option|0x0020); // [Valaris] - if ((pc_isriding(sd) && pc_checkskill(sd,KN_RIDING)>0) && (sd->status.class==7 || - sd->status.class==14 || sd->status.class==4008 || sd->status.class==4015)) + if ((pc_isriding(sd) && pc_checkskill(sd,KN_RIDING)>0) && (sd->status.class_==7 || + sd->status.class_==14 || sd->status.class_==4008 || sd->status.class_==4015)) pc_setriding(sd); // update peco riders for people upgrading athena [Valaris] @@ -1318,7 +1318,7 @@ int clif_spawnnpc(struct npc_data *nd) nullpo_retr(0, nd); - if(nd->class < 0 || nd->flag&1 || nd->class == INVISIBLE_CLASS) + if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS) return 0; memset(buf,0,packet_len_table[0x7c]); @@ -1326,7 +1326,7 @@ int clif_spawnnpc(struct npc_data *nd) WBUFW(buf,0)=0x7c; WBUFL(buf,2)=nd->bl.id; WBUFW(buf,6)=nd->speed; - WBUFW(buf,20)=nd->class; + WBUFW(buf,20)=nd->class_; WBUFPOS(buf,36,nd->bl.x,nd->bl.y); clif_send(buf,packet_len_table[0x7c],&nd->bl,AREA); @@ -1348,7 +1348,7 @@ int clif_spawnmob(struct mob_data *md) nullpo_retr(0, md); - if (mob_get_viewclass(md->class) > 23 ) { + if (mob_get_viewclass(md->class_) > 23 ) { memset(buf,0,packet_len_table[0x7c]); WBUFW(buf,0)=0x7c; @@ -1357,7 +1357,7 @@ int clif_spawnmob(struct mob_data *md) WBUFW(buf,8)=md->opt1; WBUFW(buf,10)=md->opt2; WBUFW(buf,12)=md->option; - WBUFW(buf,20)=mob_get_viewclass(md->class); + WBUFW(buf,20)=mob_get_viewclass(md->class_); WBUFPOS(buf,36,md->bl.x,md->bl.y); clif_send(buf,packet_len_table[0x7c],&md->bl,AREA); } @@ -1365,8 +1365,8 @@ int clif_spawnmob(struct mob_data *md) len = clif_mob0078(md,buf); clif_send(buf,len,&md->bl,AREA); - if (mob_get_equip(md->class) > 0) // mob equipment [Valaris] - clif_mob_equip(md,mob_get_equip(md->class)); + if (mob_get_equip(md->class_) > 0) // mob equipment [Valaris] + clif_mob_equip(md,mob_get_equip(md->class_)); if(md->size==2) // tiny/big mobs [Valaris] clif_specialeffect(&md->bl,423,0); @@ -1389,13 +1389,13 @@ int clif_spawnpet(struct pet_data *pd) nullpo_retr(0, pd); - if (mob_get_viewclass(pd->class) >= MAX_PC_CLASS) { + if (mob_get_viewclass(pd->class_) >= MAX_PC_CLASS) { memset(buf,0,packet_len_table[0x7c]); WBUFW(buf,0)=0x7c; WBUFL(buf,2)=pd->bl.id; WBUFW(buf,6)=pd->speed; - WBUFW(buf,20)=mob_get_viewclass(pd->class); + WBUFW(buf,20)=mob_get_viewclass(pd->class_); WBUFPOS(buf,36,pd->bl.x,pd->bl.y); clif_send(buf,packet_len_table[0x7c],&pd->bl,AREA); @@ -3552,7 +3552,7 @@ void clif_getareachar_npc(struct map_session_data* sd,struct npc_data* nd) int len; nullpo_retv(sd); nullpo_retv(nd); - if(nd->class < 0 || nd->flag&1 || nd->class == INVISIBLE_CLASS) + if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS) return; if(nd->state.state == MS_WALK){ len = clif_npc007b(nd,WFIFOP(sd->fd,0)); @@ -3580,8 +3580,8 @@ int clif_movemob(struct mob_data *md) len = clif_mob007b(md,buf); clif_send(buf,len,&md->bl,AREA); - if(mob_get_equip(md->class) > 0) // mob equipment [Valaris] - clif_mob_equip(md,mob_get_equip(md->class)); + if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris] + clif_mob_equip(md,mob_get_equip(md->class_)); if(md->size==2) // tiny/big mobs [Valaris] clif_specialeffect(&md->bl,423,0); @@ -3739,8 +3739,8 @@ void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md) WFIFOSET(sd->fd,len); } - if(mob_get_equip(md->class) > 0) // mob equipment [Valaris] - clif_mob_equip(md,mob_get_equip(md->class)); + if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris] + clif_mob_equip(md,mob_get_equip(md->class_)); if(md->size==2) // tiny/big mobs [Valaris] clif_specialeffect(&md->bl,423,0); @@ -3976,7 +3976,7 @@ int clif_pcoutsight(struct block_list *bl,va_list ap) } break; case BL_NPC: - if( ((struct npc_data *)bl)->class != INVISIBLE_CLASS ) + if( ((struct npc_data *)bl)->class_ != INVISIBLE_CLASS ) clif_clearchar_id(bl->id,0,sd->fd); break; case BL_MOB: @@ -4191,7 +4191,7 @@ int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range) memset(WFIFOP(fd,14),0,24); if(!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn == 1 || (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) ) //WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_get_max(id) && sd->status.skill[skillid].flag ==0 )? 1:0; - WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class) && sd->status.skill[skillid].flag ==0 )? 1:0; + WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[skillid].flag ==0 )? 1:0; else WFIFOB(fd,38) = 0; WFIFOSET(fd,packet_len_table[0x147]); @@ -4226,7 +4226,7 @@ int clif_skillinfoblock(struct map_session_data *sd) memset(WFIFOP(fd,len+12),0,24); if(!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn == 1 || (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) ) //WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_get_max(id) && sd->status.skill[i].flag ==0 )? 1:0; - WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class) && sd->status.skill[i].flag ==0 )? 1:0; + WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[i].flag ==0 )? 1:0; else WFIFOB(fd,len+36) = 0; len+=37; @@ -4259,7 +4259,7 @@ int clif_skillup(struct map_session_data *sd,int skill_num) range = battle_get_range(&sd->bl) - (range + 1); WFIFOW(fd,8) = range; //WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_get_max(sd->status.skill[skill_num].id)) ? 1 : 0; - WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class)) ? 1 : 0; + WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0; WFIFOSET(fd,packet_len_table[0x10e]); return 0; @@ -4623,13 +4623,13 @@ int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) return 0; WBUFW(buf, 0)=0x18c; - WBUFW(buf, 2)=mob_get_viewclass(md->class); + WBUFW(buf, 2)=mob_get_viewclass(md->class_); WBUFW(buf, 4)=md->level; - WBUFW(buf, 6)=mob_db[md->class].size; + WBUFW(buf, 6)=mob_db[md->class_].size; WBUFL(buf, 8)=md->hp; WBUFW(buf,12)=battle_get_def2(&md->bl); - WBUFW(buf,14)=mob_db[md->class].race; - WBUFW(buf,16)=battle_get_mdef2(&md->bl) - (mob_db[md->class].vit>>1); + WBUFW(buf,14)=mob_db[md->class_].race; + WBUFW(buf,16)=battle_get_mdef2(&md->bl) - (mob_db[md->class_].vit>>1); WBUFW(buf,18)=battle_get_elem_type(&md->bl); for(i=0;i<9;i++) WBUFB(buf,20+i)= battle_attr_fix(100,i+1,md->def_ele); @@ -5831,7 +5831,7 @@ int clif_update_mobhp(struct mob_data *md) WBUFL(buf,2) = md->bl.id; memcpy(WBUFP(buf,6), md->name, 24); - sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class].max_hp); + sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class_].max_hp); WBUFW(buf, 0) = 0x195; memcpy(WBUFP(buf,30), mobhp, 24); WBUFL(buf,54) = 0; @@ -6023,7 +6023,7 @@ int clif_pet_emotion(struct pet_data *pd,int param) if(sd->petDB->talk_convert_class < 0) return 0; else if(sd->petDB->talk_convert_class > 0) { - param -= (pd->class - 100)*100; + param -= (pd->class_ - 100)*100; param += (sd->petDB->talk_convert_class - 100)*100; } } @@ -6501,7 +6501,7 @@ int clif_guild_memberlist(struct map_session_data *sd) WFIFOW(fd,c*104+12)=m->hair; WFIFOW(fd,c*104+14)=m->hair_color; WFIFOW(fd,c*104+16)=m->gender; - WFIFOW(fd,c*104+18)=m->class; + WFIFOW(fd,c*104+18)=m->class_; WFIFOW(fd,c*104+20)=m->lv; WFIFOL(fd,c*104+22)=m->exp; WFIFOL(fd,c*104+26)=m->online; @@ -7439,10 +7439,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if(sd->state.connect_new) { sd->state.connect_new = 0; - if(sd->status.class != sd->view_class) + if(sd->status.class_ != sd->view_class) clif_changelook(&sd->bl,LOOK_BASE,sd->view_class); if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 900) - clif_pet_emotion(sd->pd,(sd->pd->class - 100)*100 + 50 + pet_hungry_val(sd)); + clif_pet_emotion(sd->pd,(sd->pd->class_ - 100)*100 + 50 + pet_hungry_val(sd)); /* Stop players from spawning inside castles [Valaris] */ @@ -7753,7 +7753,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { nullpo_retv(md); memcpy(WFIFOP(fd,6), md->name, 24); - if (md->class >= 1285 && md->class <= 1288 && md->guild_id) { + if (md->class_ >= 1285 && md->class_ <= 1288 && md->guild_id) { struct guild *g; struct guild_castle *gc = guild_mapname2gc(map[md->bl.m].name); if (gc && gc->guild_id > 0 && (g = guild_search(gc->guild_id)) != NULL) { @@ -7767,7 +7767,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { } } else if (battle_config.show_mob_hp == 1) { char mobhp[50]; - sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class].max_hp); + sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class_].max_hp); WFIFOW(fd, 0) = 0x195; memcpy(WFIFOP(fd,30), mobhp, 24); WFIFOB(fd,54) = 0; @@ -7849,7 +7849,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < WFIFOSET(fd, WFIFOW(fd,2)); // Celest - if (pc_calc_base_job2 (sd->status.class) == 23 ) { + if (pc_calc_base_job2 (sd->status.class_) == 23 ) { int next = pc_nextbaseexp(sd)>0 ? pc_nextbaseexp(sd) : sd->status.base_exp; if ((sd->status.base_exp*100/next)%10 == 0) { estr_lower(RFIFOP(fd,4)); @@ -8680,17 +8680,17 @@ void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd) void clif_parse_RemoveOption(int fd,struct map_session_data *sd) { if(pc_isriding(sd)) { // jobchange when removing peco [Valaris] - if(sd->status.class==13) - sd->status.class=sd->view_class=7; + if(sd->status.class_==13) + sd->status.class_=sd->view_class=7; - if(sd->status.class==21) - sd->status.class=sd->view_class=14; + if(sd->status.class_==21) + sd->status.class_=sd->view_class=14; - if(sd->status.class==4014) - sd->status.class=sd->view_class=4008; + if(sd->status.class_==4014) + sd->status.class_=sd->view_class=4008; - if(sd->status.class==4022) - sd->status.class=sd->view_class=4015; + if(sd->status.class_==4022) + sd->status.class_=sd->view_class=4015; } pc_setoption(sd,0); @@ -10011,7 +10011,7 @@ void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd) { if(sd){ int nextbaseexp=pc_nextbaseexp(sd); - struct pc_base_job s_class = pc_calc_base_job(sd->status.class); + struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); if (battle_config.etc_log){ if(nextbaseexp != 0) printf("SuperNovice explosionspirits!! %d %d %d %d\n",sd->bl.id,s_class.job,sd->status.base_exp,(int)((double)1000*sd->status.base_exp/nextbaseexp)); diff --git a/src/map/guild.c b/src/map/guild.c index 7369757a7..ddaa05999 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -242,7 +242,7 @@ void guild_makemember(struct guild_member *m,struct map_session_data *sd) m->hair =sd->status.hair; m->hair_color =sd->status.hair_color; m->gender =sd->sex; - m->class =sd->status.class; + m->class_ =sd->status.class_; m->lv =sd->status.base_level; m->exp =0; m->exp_payper =0; @@ -722,7 +722,7 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online) return 0; intif_guild_memberinfoshort(g->guild_id, - sd->status.account_id,sd->status.char_id,online,sd->status.base_level,sd->status.class); + sd->status.account_id,sd->status.char_id,online,sd->status.base_level,sd->status.class_); if( !online ){ // ログアウトするならsdをクリアして終了 int i=guild_getindex(g,sd->status.account_id,sd->status.char_id); @@ -762,7 +762,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin oldonline=m->online; m->online=online; m->lv=lv; - m->class=class; + m->class_=class; idx=i; } if(m->account_id>0){ diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 815034d8c..e6a997976 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -158,7 +158,7 @@ struct item_data* itemdb_search(int nameid) id->weight=10; id->sex=2; id->elv=0; - id->class=0xffffffff; + id->class_=0xffffffff; id->flag.available=0; id->flag.value_notdc=0; //一応・・・ id->flag.value_notoc=0; @@ -339,7 +339,7 @@ static int itemdb_readdb(void) id->def=atoi(str[8]); id->range=atoi(str[9]); id->slot=atoi(str[10]); - id->class=atoi(str[11]); + id->class_=atoi(str[11]); id->sex=atoi(str[12]); if(id->equip != atoi(str[13])){ id->equip=atoi(str[13]); @@ -814,7 +814,7 @@ static int itemdb_read_sqldb(void) id->def = (sql_row[8] != NULL) ? atoi(sql_row[8]) : 0; id->range = (sql_row[9] != NULL) ? atoi(sql_row[9]) : 0; id->slot = (sql_row[10] != NULL) ? atoi(sql_row[10]) : 0; - id->class = (sql_row[11] != NULL) ? atoi(sql_row[11]) : 0; + id->class_ = (sql_row[11] != NULL) ? atoi(sql_row[11]) : 0; id->sex = (sql_row[12] != NULL) ? atoi(sql_row[12]) : 0; id->equip = (sql_row[13] != NULL) ? atoi(sql_row[13]) : 0; id->wlv = (sql_row[14] != NULL) ? atoi(sql_row[14]) : 0; diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 9ff3981a2..2ba6ae7f6 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -12,7 +12,7 @@ struct item_data { int value_buy; int value_sell; int type; - int class; + int class_; int sex; int equip; int weight; diff --git a/src/map/map.h b/src/map/map.h index ccedaacaf..405c34d65 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -348,7 +348,7 @@ struct npc_item_list { struct npc_data { struct block_list bl; short n; - short class,dir; + short class_,dir; short speed; char name[24]; char exname[24]; @@ -395,7 +395,7 @@ struct npc_data { struct mob_data { struct block_list bl; short n; - short base_class,class,dir,mode,level; + short base_class,class_,dir,mode,level; short m,x0,y0,xs,ys; char name[24]; int spawndelay1,spawndelay2; @@ -457,7 +457,7 @@ struct mob_data { struct pet_data { struct block_list bl; short n; - short class,dir; + short class_,dir; short speed; char name[24]; struct { diff --git a/src/map/mob.c b/src/map/mob.c index c6b772209..539a10c1a 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -99,7 +99,7 @@ int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class) memcpy(md->name,mobname,24); md->n = 0; - md->base_class = md->class = class; + md->base_class = md->class_ = class; md->bl.id= npc_get_new_npc_id(); memset(&md->state,0,sizeof(md->state)); @@ -600,11 +600,11 @@ static int mob_attack(struct mob_data *md,unsigned int tick,int data) if(!md->mode) - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; else mode=md->mode; - race=mob_db[md->class].race; + race=mob_db[md->class_].race; if(!(mode&0x80)){ md->target_id=0; md->state.targettype = NONE_ATTACKABLE; @@ -617,7 +617,7 @@ static int mob_attack(struct mob_data *md,unsigned int tick,int data) return 0; } - range = mob_db[md->class].range; + range = mob_db[md->class_].range; if(mode&1) range++; if(distance(md->bl.x,md->bl.y,tbl->x,tbl->y) > range) @@ -912,7 +912,7 @@ int mob_spawn(int id) map_delblock(&md->bl); } else - md->class = md->base_class; + md->class_ = md->base_class; md->bl.m =md->m; do { @@ -946,11 +946,11 @@ int mob_spawn(int id) md->move_fail_count = 0; if(!md->speed) - md->speed = mob_db[md->class].speed; - md->def_ele = mob_db[md->class].element; + md->speed = mob_db[md->class_].speed; + md->def_ele = mob_db[md->class_].element; if(!md->level) // [Valaris] - md->level=mob_db[md->class].lv; + md->level=mob_db[md->class_].lv; md->master_id=0; md->master_dist=0; @@ -964,7 +964,7 @@ int mob_spawn(int id) md->canmove_tick = tick; md->guild_id = 0; - if (md->class >= 1285 && md->class <= 1288) { + if (md->class_ >= 1285 && md->class_ <= 1288) { struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) md->guild_id = gc->guild_id; @@ -998,7 +998,7 @@ int mob_spawn(int id) md->hp = battle_get_max_hp(&md->bl); if(md->hp<=0){ - mob_makedummymobdb(md->class); + mob_makedummymobdb(md->class_); md->hp = battle_get_max_hp(&md->bl); } @@ -1094,7 +1094,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range) //=========== guildcastle guardian no search start=========== //when players are the guild castle member not attack them ! - if(md->class >= 1285 && md->class <= 1287){ + if(md->class_ >= 1285 && md->class_ <= 1287){ struct map_session_data *sd; struct guild *g=NULL; struct guild_castle *gc=guild_mapname2gc(map[bl->m].name); @@ -1171,10 +1171,10 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) sc_data = battle_get_sc_data(bl); option = battle_get_option(bl); - race=mob_db[md->class].race; + race=mob_db[md->class_].race; if(!md->mode) - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; else mode=md->mode; @@ -1236,13 +1236,13 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) return 0; if(!smd->mode) - mode=mob_db[smd->class].mode; + mode=mob_db[smd->class_].mode; else mode=smd->mode; // アクティブでターゲット射程内にいるなら、ロックする if( mode&0x04 ){ - race=mob_db[smd->class].race; + race=mob_db[smd->class_].race; //対象がPCの場合 if(tsd && !pc_isdead(tsd) && @@ -1295,7 +1295,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) nullpo_retr(0, itc=va_arg(ap,int *)); if(!md->mode) - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; else mode=md->mode; @@ -1332,8 +1332,8 @@ static int mob_ai_sub_hard_linksearch(struct block_list *bl,va_list ap) nullpo_retr(0, target=va_arg(ap,struct block_list *)); // same family free in a range at a link monster -- it will be made to lock if MOB is -/* if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && mob_db[md->class].mode&0x08){ - if( tmd->class==md->class && (!tmd->target_id || md->state.targettype == NONE_ATTACKABLE) && tmd->bl.m == md->bl.m){ +/* if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && mob_db[md->class_].mode&0x08){ + if( tmd->class_==md->class_ && (!tmd->target_id || md->state.targettype == NONE_ATTACKABLE) && tmd->bl.m == md->bl.m){ if( mob_can_reach(tmd,target,12) ){ // Reachability judging tmd->target_id=md->target_id; tmd->state.targettype = ATTACKABLE; @@ -1341,8 +1341,8 @@ static int mob_ai_sub_hard_linksearch(struct block_list *bl,va_list ap) } } }*/ - if( md->attacked_id > 0 && mob_db[md->class].mode&0x08){ - if( tmd->class==md->class && tmd->bl.m == md->bl.m && (!tmd->target_id || md->state.targettype == NONE_ATTACKABLE)){ + if( md->attacked_id > 0 && mob_db[md->class_].mode&0x08){ + if( tmd->class_==md->class_ && tmd->bl.m == md->bl.m && (!tmd->target_id || md->state.targettype == NONE_ATTACKABLE)){ if( mob_can_reach(tmd,target,12) ){ // Reachability judging tmd->target_id=md->attacked_id; tmd->state.targettype = ATTACKABLE; @@ -1368,7 +1368,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) if((bl=map_id2bl(md->master_id)) != NULL ) mmd=(struct mob_data *)bl; - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; // It is not main monster/leader. if(!mmd || mmd->bl.type!=BL_MOB || mmd->bl.id!=md->master_id) @@ -1439,7 +1439,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) struct map_session_data *sd=map_id2sd(mmd->target_id); if(sd!=NULL && !pc_isdead(sd) && sd->invincible_timer == -1 && !pc_isinvisible(sd)){ - race=mob_db[md->class].race; + race=mob_db[md->class_].race; if(mode&0x20 || (sd->sc_data[SC_TRICKDEAD].timer == -1 && sd->sc_data[SC_BASILICA].timer == -1 && ( (!pc_ishiding(sd) && !sd->state.gangsterparadise) || ((race == 4 || race == 6) && !sd->perfect_hiding) ) ) ){ // 妨害がないか判定 @@ -1457,7 +1457,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) struct map_session_data *sd=map_id2sd(md->target_id); if(sd!=NULL && !pc_isdead(sd) && sd->invincible_timer == -1 && !pc_isinvisible(sd)){ - race=mob_db[mmd->class].race; + race=mob_db[mmd->class_].race; if(mode&0x20 || (sd->sc_data[SC_TRICKDEAD].timer == -1 && (!(sd->status.option&0x06) || race==4 || race==6) @@ -1525,7 +1525,7 @@ static int mob_randomwalk(struct mob_data *md,int tick) md->target_dir = 0; if(md->move_fail_count>1000){ if(battle_config.error_log) - printf("MOB cant move. random spawn %d, class = %d\n",md->bl.id,md->class); + printf("MOB cant move. random spawn %d, class = %d\n",md->bl.id,md->class_); md->move_fail_count=0; mob_spawn(md->bl.id); } @@ -1577,11 +1577,11 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) } if(!md->mode) - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; else mode=md->mode; - race=mob_db[md->class].race; + race=mob_db[md->class_].race; // Abnormalities if((md->opt1 > 0 && md->opt1 != 6) || md->state.state==MS_DELAY || md->sc_data[SC_BLADESTOP].timer != -1) @@ -1674,7 +1674,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) ((pc_ishiding(tsd) || tsd->state.gangsterparadise) && !((race == 4 || race == 6) && !tsd->perfect_hiding) )) ) mob_unlocktarget(md,tick); // スキルなどによる策敵妨害 - else if(!battle_check_range(&md->bl,tbl,mob_db[md->class].range)){ + else if(!battle_check_range(&md->bl,tbl,mob_db[md->class_].range)){ // 攻撃範囲外なので移動 if(!(mode&1)){ // 移動しないモード mob_unlocktarget(md,tick); @@ -1889,7 +1889,7 @@ static int mob_ai_sub_lazy(void * key,void * data,va_list app) } if(DIFF_TICK(md->next_walktime,tick)<0 && - (mob_db[md->class].mode&1) && mob_can_move(md) ){ + (mob_db[md->class_].mode&1) && mob_can_move(md) ){ if( map[md->bl.m].users>0 ){ // Since PC is in the same map, somewhat better negligent processing is carried out. @@ -1900,7 +1900,7 @@ static int mob_ai_sub_lazy(void * key,void * data,va_list app) // MOB which is not not the summons MOB but BOSS, either sometimes reboils. else if( rand()%1000x0<=0 && md->master_id!=0 && - mob_db[md->class].mexp <= 0 && !(mob_db[md->class].mode & 0x20)) + mob_db[md->class_].mexp <= 0 && !(mob_db[md->class_].mode & 0x20)) mob_spawn(md->bl.id); }else{ @@ -1908,7 +1908,7 @@ static int mob_ai_sub_lazy(void * key,void * data,va_list app) // MOB which is not BOSS which is not Summons MOB, either -- a case -- sometimes -- leaping if( rand()%1000x0<=0 && md->master_id!=0 && - mob_db[md->class].mexp <= 0 && !(mob_db[md->class].mode & 0x20)) + mob_db[md->class_].mexp <= 0 && !(mob_db[md->class_].mode & 0x20)) mob_warp(md,-1,-1,-1,-1); } @@ -2018,7 +2018,7 @@ int mob_delete(struct mob_data *md) mob_changestate(md,MS_DEAD,0); clif_clearchar_area(&md->bl,1); map_delblock(&md->bl); - if(mob_get_viewclass(md->class) <= 1000) + if(mob_get_viewclass(md->class_) <= 1000) clif_clearchar_delay(gettick()+3000,&md->bl,0); mob_deleteslave(md); mob_setdelayspawn(md->bl.id); @@ -2220,7 +2220,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) md->hp-=damage; - if(md->class >= 1285 && md->class <=1287) { // guardian hp update [Valaris] + if(md->class_ >= 1285 && md->class_ <=1287) { // guardian hp update [Valaris] struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { @@ -2292,7 +2292,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(md->state.special_mob_ai == 2){//スフィアーマイン int skillidx=0; - if((skillidx=mob_skillid2skillidx(md->class,NPC_SELFDESTRUCTION2))>=0){ + if((skillidx=mob_skillid2skillidx(md->class_,NPC_SELFDESTRUCTION2))>=0){ md->mode |= 0x1; md->next_walktime=tick; mobskill_use_id(md,&md->bl,skillidx);//自爆詠唱開始 @@ -2374,13 +2374,13 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) // jAthena's exp formula // per = ((double)md->dmglog[i].dmg)*(9.+(double)((count > 6)? 6:count))/10./((double)max_hp) * dmg_rate; per = ((double)md->dmglog[i].dmg)*(9.+(double)((count > 6)? 6:count))/10./tdmg; - temp = (double)mob_db[md->class].base_exp * per; + temp = (double)mob_db[md->class_].base_exp * per; base_exp = (temp > 2147483647.)? 0x7fffffff:(int)temp; - if(mob_db[md->class].base_exp > 0 && base_exp < 1) base_exp = 1; + if(mob_db[md->class_].base_exp > 0 && base_exp < 1) base_exp = 1; if(base_exp < 0) base_exp = 0; - temp = (double)mob_db[md->class].job_exp * per; + temp = (double)mob_db[md->class_].job_exp * per; job_exp = (temp > 2147483647.)? 0x7fffffff:(int)temp; - if(mob_db[md->class].job_exp > 0 && job_exp < 1) job_exp = 1; + if(mob_db[md->class_].job_exp > 0 && job_exp < 1) job_exp = 1; if(job_exp < 0) job_exp = 0; } else if (battle_config.exp_calc_type == 1) { @@ -2388,9 +2388,9 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) per=(double)md->dmglog[i].dmg*256*(9+(double)((count > 6)? 6:count))/10/(double)max_hp; if(per>512) per=512; if(per<1) per=1; - base_exp=mob_db[md->class].base_exp*per/256; + base_exp=mob_db[md->class_].base_exp*per/256; if(base_exp < 1) base_exp = 1; - job_exp=mob_db[md->class].job_exp*per/256; + job_exp=mob_db[md->class_].job_exp*per/256; if(job_exp < 1) job_exp = 1; } else { @@ -2398,16 +2398,16 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) per=(double)md->dmglog[i].dmg*256*(9+(double)((count > 6)? 6:count))/10/tdmg; if(per>512) per=512; if(per<1) per=1; - base_exp=mob_db[md->class].base_exp*per/256; + base_exp=mob_db[md->class_].base_exp*per/256; if(base_exp < 1) base_exp = 1; - job_exp=mob_db[md->class].job_exp*per/256; + job_exp=mob_db[md->class_].job_exp*per/256; if(job_exp < 1) job_exp = 1; } - if(sd && battle_config.pk_mode && (mob_db[md->class].lv - sd->status.base_level >= 20)) { + if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { base_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] } - if(sd && battle_config.pk_mode && (mob_db[md->class].lv - sd->status.base_level >= 20)) { + if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { job_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] } if(md->master_id || (md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1)) { // for summoned creatures [Valaris] @@ -2417,12 +2417,12 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) else { if(battle_config.zeny_from_mobs) { if(md->level > 0) zeny=(md->level+rand()%md->level)*per/256; // zeny calculation moblv + random moblv [Valaris] - if(mob_db[md->class].mexp > 0) + if(mob_db[md->class_].mexp > 0) zeny*=rand()%250; } - if(battle_config.mobs_level_up && md->level > mob_db[md->class].lv) { // [Valaris] - job_exp+=((md->level-mob_db[md->class].lv)*mob_db[md->class].job_exp*.03)*per/256; - base_exp+=((md->level-mob_db[md->class].lv)*mob_db[md->class].base_exp*.03)*per/256; + if(battle_config.mobs_level_up && md->level > mob_db[md->class_].lv) { // [Valaris] + job_exp+=((md->level-mob_db[md->class_].lv)*mob_db[md->class_].job_exp*.03)*per/256; + base_exp+=((md->level-mob_db[md->class_].lv)*mob_db[md->class_].base_exp*.03)*per/256; } } @@ -2473,18 +2473,18 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(md->master_id || (md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1)) // Added [Valaris] break; // End - if(mob_db[md->class].dropitem[i].nameid <= 0) + if(mob_db[md->class_].dropitem[i].nameid <= 0) continue; - drop_rate = mob_db[md->class].dropitem[i].p; + drop_rate = mob_db[md->class_].dropitem[i].p; if(drop_rate <= 0 && battle_config.drop_rate0item) drop_rate = 1; if(battle_config.drops_by_luk>0 && sd && md) drop_rate+=(sd->status.luk*battle_config.drops_by_luk)/100; // drops affected by luk [Valaris] - if(sd && md && battle_config.pk_mode==1 && (mob_db[md->class].lv - sd->status.base_level >= 20)) drop_rate*=1.25; // pk_mode increase drops if 20 level difference [Valaris] + if(sd && md && battle_config.pk_mode==1 && (mob_db[md->class_].lv - sd->status.base_level >= 20)) drop_rate*=1.25; // pk_mode increase drops if 20 level difference [Valaris] if(drop_rate <= rand()%10000) continue; ditem=(struct delay_item_drop *)aCalloc(1,sizeof(struct delay_item_drop)); - ditem->nameid = mob_db[md->class].dropitem[i].nameid; + ditem->nameid = mob_db[md->class_].dropitem[i].nameid; log_item[i] = ditem->nameid; ditem->amount = 1; ditem->m = md->bl.m; @@ -2498,7 +2498,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) #ifndef TXT_ONLY if(log_config.drop > 0) - log_drop(mvp_sd, md->class, log_item); + log_drop(mvp_sd, md->class_, log_item); #endif // Ore Discovery [Celest] @@ -2520,7 +2520,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) #ifndef TXT_ONLY if(log_config.drop > 0) - log_drop(mvp_sd, md->class, log_item); + log_drop(mvp_sd, md->class_, log_item); #endif if(sd && sd->state.attack_type == BF_WEAPON) { @@ -2530,8 +2530,8 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(sd->monster_drop_itemid[i] <= 0) continue; if(sd->monster_drop_race[i] & (1<class].mode & 0x20 && sd->monster_drop_race[i] & 1<<10) || - (!(mob_db[md->class].mode & 0x20) && sd->monster_drop_race[i] & 1<<11) ) { + (mob_db[md->class_].mode & 0x20 && sd->monster_drop_race[i] & 1<<10) || + (!(mob_db[md->class_].mode & 0x20) && sd->monster_drop_race[i] & 1<<11) ) { if(sd->monster_drop_itemrate[i] <= rand()%10000) continue; @@ -2548,7 +2548,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) } } if(sd->get_zeny_num > 0) - pc_getzeny(sd,mob_db[md->class].lv*10 + rand()%(sd->get_zeny_num+1)); + pc_getzeny(sd,mob_db[md->class_].lv*10 + rand()%(sd->get_zeny_num+1)); } if(md->lootitem) { for(i=0;ilootitem_count;i++) { @@ -2568,11 +2568,11 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) } // mvp処理 - if(mvp_sd && mob_db[md->class].mexp > 0 ){ + if(mvp_sd && mob_db[md->class_].mexp > 0 ){ int log_mvp[2] = {0}; int j; int mexp; - temp = ((double)mob_db[md->class].mexp * (9.+(double)count)/10.); //[Gengar] + temp = ((double)mob_db[md->class_].mexp * (9.+(double)count)/10.); //[Gengar] mexp = (temp > 2147483647.)? 0x7fffffff:(int)temp; if(mexp < 1) mexp = 1; clif_mvp_effect(mvp_sd); // エフェクト @@ -2581,9 +2581,9 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) log_mvp[1] = mexp; for(j=0;j<3;j++){ i = rand() % 3; - if(mob_db[md->class].mvpitem[i].nameid <= 0) + if(mob_db[md->class_].mvpitem[i].nameid <= 0) continue; - drop_rate = mob_db[md->class].mvpitem[i].p; + drop_rate = mob_db[md->class_].mvpitem[i].p; if(drop_rate <= 0 && battle_config.drop_rate0item) drop_rate = 1; if(drop_rate < battle_config.item_drop_mvp_min) @@ -2593,7 +2593,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(drop_rate <= rand()%10000) continue; memset(&item,0,sizeof(item)); - item.nameid=mob_db[md->class].mvpitem[i].nameid; + item.nameid=mob_db[md->class_].mvpitem[i].nameid; item.identify=!itemdb_isequip3(item.nameid); clif_mvp_item(mvp_sd,item.nameid); log_mvp[0] = item.nameid; @@ -2607,7 +2607,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) } #ifndef TXT_ONLY if(log_config.mvpdrop > 0) - log_mvpdrop(mvp_sd, md->class, log_mvp); + log_mvpdrop(mvp_sd, md->class_, log_mvp); #endif } @@ -2649,7 +2649,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) clif_clearchar_area(&md->bl,1); if(md->level) md->level=0; map_delblock(&md->bl); - if(mob_get_viewclass(md->class) <= 1000) + if(mob_get_viewclass(md->class_) <= 1000) clif_clearchar_delay(tick+3000,&md->bl,0); mob_deleteslave(md); mob_setdelayspawn(md->bl.id); @@ -2683,7 +2683,7 @@ int mob_class_change(struct mob_data *md,int *value) max_hp = battle_get_max_hp(&md->bl); hp_rate = md->hp*100/max_hp; clif_mob_class_change(md,class); - md->class = class; + md->class_ = class; max_hp = battle_get_max_hp(&md->bl); if(battle_config.monster_class_change_full_recover==1) { md->hp = max_hp; @@ -2700,8 +2700,8 @@ int mob_class_change(struct mob_data *md,int *value) md->target_id = 0; md->move_fail_count = 0; - md->speed = mob_db[md->class].speed; - md->def_ele = mob_db[md->class].element; + md->speed = mob_db[md->class_].speed; + md->def_ele = mob_db[md->class_].element; mob_changestate(md,MS_IDLE,0); skill_castcancel(&md->bl,0); @@ -2742,7 +2742,7 @@ int mob_heal(struct mob_data *md,int heal) if( max_hp < md->hp ) md->hp = max_hp; - if(md->class >= 1285 && md->class <=1287) { // guardian hp update [Valaris] + if(md->class_ >= 1285 && md->class_ <=1287) { // guardian hp update [Valaris] struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { if(md->bl.id==gc->GID0) gc->Ghp0=md->hp; @@ -2835,7 +2835,7 @@ int mob_warp(struct mob_data *md,int m,int x,int y,int type) }else { m=md->bl.m; if(battle_config.error_log==1) - printf("MOB %d warp failed, class = %d\n",md->bl.id,md->class); + printf("MOB %d warp failed, class = %d\n",md->bl.id,md->class_); } md->target_id=0; // タゲを解除する @@ -2846,7 +2846,7 @@ int mob_warp(struct mob_data *md,int m,int x,int y,int type) if(type>0 && i==1000) { if(battle_config.battle_log) - printf("MOB %d warp to (%d,%d), class = %d\n",md->bl.id,x,y,md->class); + printf("MOB %d warp to (%d,%d), class = %d\n",md->bl.id,x,y,md->class_); } map_addblock(&md->bl); @@ -3107,7 +3107,7 @@ int mobskill_castend_id( int tid, unsigned int tick, int id,int data ) md->skilldelay[md->skillidx]=tick; if(battle_config.mob_skill_log) - printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class); + printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class_); // mob_stop_walking(md,0); switch( skill_get_nk(md->skillid) ) @@ -3117,7 +3117,7 @@ int mobskill_castend_id( int tid, unsigned int tick, int id,int data ) skill_castend_damage_id(&md->bl,bl,md->skillid,md->skilllv,tick,0); break; case 1:// 支援系 - if(!mob_db[md->class].skill[md->skillidx].val[0] && + if(!mob_db[md->class_].skill[md->skillidx].val[0] && (md->skillid==AL_HEAL || (md->skillid==ALL_RESURRECTION && bl->type != BL_PC)) && battle_check_undead(battle_get_race(bl),battle_get_elem_type(bl)) ) skill_castend_damage_id(&md->bl,bl,md->skillid,md->skilllv,tick,0); else @@ -3238,7 +3238,7 @@ int mobskill_castend_pos( int tid, unsigned int tick, int id,int data ) md->skilldelay[md->skillidx]=tick; if(battle_config.mob_skill_log) - printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class); + printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class_); // mob_stop_walking(md,0); skill_castend_pos2(&md->bl,md->skillx,md->skilly,md->skillid,md->skilllv,tick,0); @@ -3258,7 +3258,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx) int skill_id, skill_lv, forcecast = 0; nullpo_retr(0, md); - nullpo_retr(0, ms=&mob_db[md->class].skill[skill_idx]); + nullpo_retr(0, ms=&mob_db[md->class_].skill[skill_idx]); if( target==NULL && (target=map_id2bl(md->target_id))==NULL ) return 0; @@ -3326,7 +3326,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx) } if(battle_config.mob_skill_log) - printf("MOB skill use target_id=%d skill=%d lv=%d cast=%d, class = %d\n",target->id,skill_id,skill_lv,casttime,md->class); + printf("MOB skill use target_id=%d skill=%d lv=%d cast=%d, class = %d\n",target->id,skill_id,skill_lv,casttime,md->class_); if(casttime>0 || forcecast){ // 詠唱が必要 // struct mob_data *md2; @@ -3335,7 +3335,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx) md->bl.id, target->id, 0,0, skill_id,casttime); // 詠唱反応モンスター -/* if( target->type==BL_MOB && mob_db[(md2=(struct mob_data *)target)->class].mode&0x10 && +/* if( target->type==BL_MOB && mob_db[(md2=(struct mob_data *)target)->class_].mode&0x10 && md2->state.state!=MS_ATTACK){ md2->target_id=md->bl.id; md->state.targettype = ATTACKABLE; @@ -3379,7 +3379,7 @@ int mobskill_use_pos( struct mob_data *md, int skill_id, skill_lv; nullpo_retr(0, md); - nullpo_retr(0, ms=&mob_db[md->class].skill[skill_idx]); + nullpo_retr(0, ms=&mob_db[md->class_].skill[skill_idx]); if( md->bl.prev==NULL ) return 0; @@ -3424,7 +3424,7 @@ int mobskill_use_pos( struct mob_data *md, if(battle_config.mob_skill_log) printf("MOB skill use target_pos=(%d,%d) skill=%d lv=%d cast=%d, class = %d\n", - skill_x,skill_y,skill_id,skill_lv,casttime,md->class); + skill_x,skill_y,skill_id,skill_lv,casttime,md->class_); if( casttime>0 ) { // A cast time is required. mob_stop_walking(md,0); // 歩行停止 @@ -3475,7 +3475,7 @@ int mob_getfriendhpltmaxrate_sub(struct block_list *bl,va_list ap) return 0; rate=va_arg(ap,int); fr=va_arg(ap,struct mob_data **); - if( md->hp < mob_db[md->class].max_hp*rate/100 ) + if( md->hp < mob_db[md->class_].max_hp*rate/100 ) (*fr)=md; return 0; } @@ -3547,7 +3547,7 @@ int mobskill_use(struct mob_data *md,unsigned int tick,int event) int i,max_hp; nullpo_retr(0, md); - nullpo_retr(0, ms = mob_db[md->class].skill); + nullpo_retr(0, ms = mob_db[md->class_].skill); max_hp = battle_get_max_hp(&md->bl); @@ -3560,7 +3560,7 @@ int mobskill_use(struct mob_data *md,unsigned int tick,int event) if(md->sc_data[SC_SELFDESTRUCTION].timer!=-1) //自爆中はスキルを使わない return 0; - for(i=0;iclass].maxskill;i++){ + for(i=0;iclass_].maxskill;i++){ int c2=ms[i].cond2,flag=0; struct mob_data *fmd=NULL; @@ -3697,18 +3697,18 @@ int mob_gvmobcheck(struct map_session_data *sd, struct block_list *bl) nullpo_retr(0,bl); if(bl->type==BL_MOB && (md=(struct mob_data *)bl) && - (md->class == 1288 || md->class == 1287 || md->class == 1286 || md->class == 1285)) + (md->class_ == 1288 || md->class_ == 1287 || md->class_ == 1286 || md->class_ == 1285)) { struct guild_castle *gc=guild_mapname2gc(map[sd->bl.m].name); struct guild *g=guild_search(sd->status.guild_id); - if(g == NULL && md->class == 1288) + if(g == NULL && md->class_ == 1288) return 0;//ギルド未加入ならダメージ無し else if(gc != NULL && !map[sd->bl.m].flag.gvg) return 0;//砦内でGvじゃないときはダメージなし else if(g && gc != NULL && g->guild_id == gc->guild_id) return 0;//自占領ギルドのエンペならダメージ無し - else if(g && guild_checkskill(g,GD_APPROVAL) <= 0 && md->class == 1288) + else if(g && guild_checkskill(g,GD_APPROVAL) <= 0 && md->class_ == 1288) return 0;//正規ギルド承認がないとダメージ無し } diff --git a/src/map/npc.c b/src/map/npc.c index 4f6fa42ad..4ef38ff52 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -853,7 +853,7 @@ int npc_checknear(struct map_session_data *sd,int id) return 1; } - if (nd->class<0) // イベント系は常にOK + if (nd->class_<0) // イベント系は常にOK return 0; // エリア判定 @@ -1022,7 +1022,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) } //商人経験値 -/* if ((sd->status.class == 5) || (sd->status.class == 10) || (sd->status.class == 18)) { +/* if ((sd->status.class_ == 5) || (sd->status.class_ == 10) || (sd->status.class_ == 18)) { z = z * pc_checkskill(sd,MC_DISCOUNT) / ((1 + 300 / itemamount) * 4000) * battle_config.shop_exp; pc_gainexp(sd,0,z); }*/ @@ -1082,7 +1082,7 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list) } //商人経験値 -/* if ((sd->status.class == 5) || (sd->status.class == 10) || (sd->status.class == 18)) { +/* if ((sd->status.class_ == 5) || (sd->status.class_ == 10) || (sd->status.class_ == 18)) { z = z * pc_checkskill(sd,MC_OVERCHARGE) / ((1 + 500 / itemamount) * 4000) * battle_config.shop_exp ; pc_gainexp(sd,0,z); }*/ @@ -1449,9 +1449,9 @@ int npc_parse_warp(char *w1,char *w2,char *w3,char *w4) nd->chat_id=0; if (!battle_config.warp_point_debug) - nd->class=WARP_CLASS; + nd->class_=WARP_CLASS; else - nd->class=WARP_DEBUG_CLASS; + nd->class_=WARP_DEBUG_CLASS; nd->speed=200; nd->option = 0; nd->opt1 = 0; @@ -1535,7 +1535,7 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4) nd->dir = dir; nd->flag = 0; memcpy(nd->name, w3, 24); - nd->class = atoi(w4); + nd->class_ = atoi(w4); nd->speed = 200; nd->chat_id = 0; nd->option = 0; @@ -1732,7 +1732,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line nd->bl.id=npc_get_new_npc_id(); nd->dir = dir; nd->flag=0; - nd->class=class; + nd->class_=class; nd->speed=200; nd->u.scr.script=script; nd->u.scr.src_id=src_id; @@ -1743,7 +1743,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line nd->opt3 = 0; nd->walktimer=-1; - //printf("script npc %s %d %d read done\n",mapname,nd->bl.id,nd->class); + //printf("script npc %s %d %d read done\n",mapname,nd->bl.id,nd->class_); npc_script++; nd->bl.type=BL_NPC; nd->bl.subtype=SCRIPT; @@ -1965,7 +1965,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) memcpy(md->name,w3,24); md->n = i; - md->base_class = md->class = class; + md->base_class = md->class_ = class; md->bl.id=npc_get_new_npc_id(); md->m =m; md->x0=x; diff --git a/src/map/pc.c b/src/map/pc.c index e42122665..3288dd1bc 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -269,7 +269,7 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); //----------------------- // 死亡した @@ -308,7 +308,7 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { /* removed exp penalty on spawn [Valaris] */ - if(type&2 && sd->status.class != 0 && battle_config.zeny_penalty > 0 && !map[sd->bl.m].flag.nozenypenalty) { + if(type&2 && sd->status.class_ != 0 && battle_config.zeny_penalty > 0 && !map[sd->bl.m].flag.nozenypenalty) { int zeny = (int)((double)sd->status.zeny * (double)battle_config.zeny_penalty / 10000.); if(zeny < 1) zeny = 1; sd->status.zeny -= zeny; @@ -447,7 +447,7 @@ int pc_equippoint(struct map_session_data *sd,int n) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); if(sd->inventory_data[n]) { ep = sd->inventory_data[n]->equip; @@ -569,14 +569,14 @@ int pc_isequip(struct map_session_data *sd,int n) // as it allows all advanced classes to equip items their normal versions // could equip) // - if(((sd->status.class==13 || sd->status.class==4014) && ((1<<7)&item->class) == 0) || // have mounted classes use unmounted equipment [Valaris] - ((sd->status.class==21 || sd->status.class==4022) && ((1<<14)&item->class) == 0)) + if(((sd->status.class_==13 || sd->status.class_==4014) && ((1<<7)&item->class_) == 0) || // have mounted classes use unmounted equipment [Valaris] + ((sd->status.class_==21 || sd->status.class_==4022) && ((1<<14)&item->class_) == 0)) return 0; - if(sd->status.class!=13 && sd->status.class!=4014 && sd->status.class!=21 && sd->status.class!=4022) - if((sd->status.class<=4000 && ((1<status.class)&item->class) == 0) || (sd->status.class>4000 && sd->status.class<4023 && ((1<<(sd->status.class-4001))&item->class) == 0) || - (sd->status.class>=4023 && ((1<<(sd->status.class-4023))&item->class) == 0)) + if(sd->status.class_!=13 && sd->status.class_!=4014 && sd->status.class_!=21 && sd->status.class_!=4022) + if((sd->status.class_<=4000 && ((1<status.class_)&item->class_) == 0) || (sd->status.class_>4000 && sd->status.class_<4023 && ((1<<(sd->status.class_-4001))&item->class_) == 0) || + (sd->status.class_>=4023 && ((1<<(sd->status.class_-4023))&item->class_) == 0)) return 0; -// if(((1<status.class)&item->class) == 0) +// if(((1<status.class_)&item->class_) == 0) // return 0; if(map[sd->bl.m].flag.pvp && (item->flag.no_equip==1 || item->flag.no_equip==3)) return 0; @@ -735,7 +735,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->bl.prev = sd->bl.next = NULL; sd->weapontype1 = sd->weapontype2 = 0; - sd->view_class = sd->status.class; + sd->view_class = sd->status.class_; sd->speed = DEFAULT_WALK_SPEED; sd->state.dead_sit = 0; sd->dir = 0; @@ -984,7 +984,7 @@ int pc_calc_skilltree(struct map_session_data *sd) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); c = s_class.job; //s = (s_class.upper==1) ? 1 : 0 ; //?生以外は通常のスキル? s = s_class.upper; @@ -1193,7 +1193,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) nullpo_retr(0, sd); //?生や養子の場合の元の職業を算出する - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); b_speed = sd->speed; b_max_hp = sd->status.max_hp; @@ -1220,7 +1220,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) b_mdef = sd->mdef; b_mdef2 = sd->mdef2; b_class = sd->view_class; - sd->view_class = sd->status.class; + sd->view_class = sd->status.class_; b_base_atk = sd->base_atk; pc_calc_skilltree(sd); // スキルツリ?の計算 @@ -1847,12 +1847,12 @@ int pc_calcstatus(struct map_session_data* sd,int first) //Flee上昇 if( (skill=pc_checkskill(sd,TF_MISS))>0 ){ // 回避率?加 - if(sd->status.class==6||sd->status.class==4007 || sd->status.class==23){ + if(sd->status.class_==6||sd->status.class_==4007 || sd->status.class_==23){ sd->flee += skill*3; } - if(sd->status.class==12||sd->status.class==17||sd->status.class==4013||sd->status.class==4018) + if(sd->status.class_==12||sd->status.class_==17||sd->status.class_==4013||sd->status.class_==4018) sd->flee += skill*4; - if(sd->status.class==12||sd->status.class==4013) + if(sd->status.class_==12||sd->status.class_==4013) sd->speed -= sd->speed *(skill*1.5)/100; } if( (skill=pc_checkskill(sd,MO_DODGE))>0 ) // 見切り @@ -2211,7 +2211,7 @@ int pc_calcspeed (struct map_session_data *sd) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); b_speed = sd->speed; sd->speed = DEFAULT_WALK_SPEED ; @@ -3371,12 +3371,12 @@ int pc_isUseitem(struct map_session_data *sd,int n) return 0; if(item->elv > 0 && sd->status.base_level < item->elv) return 0; - if(((sd->status.class==13 || sd->status.class==4014) && ((1<<7)&item->class) == 0) || // have mounted classes use unmounted items [Valaris] - ((sd->status.class==21 || sd->status.class==4022) && ((1<<14)&item->class) == 0)) + if(((sd->status.class_==13 || sd->status.class_==4014) && ((1<<7)&item->class_) == 0) || // have mounted classes use unmounted items [Valaris] + ((sd->status.class_==21 || sd->status.class_==4022) && ((1<<14)&item->class_) == 0)) return 0; - if(sd->status.class!=13 && sd->status.class!=4014 && sd->status.class!=21 && sd->status.class!=4022) - if((sd->status.class<=4000 && ((1<status.class)&item->class) == 0) || (sd->status.class>4000 && sd->status.class<4023 && ((1<<(sd->status.class-4001))&item->class) == 0) || - (sd->status.class>=4023 && ((1<<(sd->status.class-4023))&item->class) == 0)) + if(sd->status.class_!=13 && sd->status.class_!=4014 && sd->status.class_!=21 && sd->status.class_!=4022) + if((sd->status.class_<=4000 && ((1<status.class_)&item->class_) == 0) || (sd->status.class_>4000 && sd->status.class_<4023 && ((1<<(sd->status.class_-4001))&item->class_) == 0) || + (sd->status.class_>=4023 && ((1<<(sd->status.class_-4023))&item->class_) == 0)) return 0; #ifndef TXT_ONLY @@ -3730,25 +3730,25 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl) int i,skill,rate,itemid,flag, count; struct mob_data *md; md=(struct mob_data *)bl; - if(!md->state.steal_flag && mob_db[md->class].mexp <= 0 && !(mob_db[md->class].mode&0x20) && - (!(md->class>1324 && md->class<1364))) // prevent stealing from treasure boxes [Valaris] + if(!md->state.steal_flag && mob_db[md->class_].mexp <= 0 && !(mob_db[md->class_].mode&0x20) && + (!(md->class_>1324 && md->class_<1364))) // prevent stealing from treasure boxes [Valaris] { if (md->sc_data && (md->sc_data[SC_STONE].timer != -1 || md->sc_data[SC_FREEZE].timer != -1)) return 0; skill = battle_config.skill_steal_type == 1 - ? (sd->paramc[4] - mob_db[md->class].dex)/2 + pc_checkskill(sd,TF_STEAL)*6 + 10 - : sd->paramc[4] - mob_db[md->class].dex + pc_checkskill(sd,TF_STEAL)*3 + 10; + ? (sd->paramc[4] - mob_db[md->class_].dex)/2 + pc_checkskill(sd,TF_STEAL)*6 + 10 + : sd->paramc[4] - mob_db[md->class_].dex + pc_checkskill(sd,TF_STEAL)*3 + 10; if(0 < skill) { for(count = 8; count <= 8 && count != 0; count--) { i = rand()%8; - itemid = mob_db[md->class].dropitem[i].nameid; + itemid = mob_db[md->class_].dropitem[i].nameid; if(itemid > 0 && itemdb_type(itemid) != 6) { - rate = (mob_db[md->class].dropitem[i].p / battle_config.item_rate_common * 100 * skill)/100; + rate = (mob_db[md->class_].dropitem[i].p / battle_config.item_rate_common * 100 * skill)/100; if(rand()%10000 < rate) { @@ -3796,9 +3796,9 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *bl) if (md->sc_data && (md->sc_data[SC_STONE].timer != -1 || md->sc_data[SC_FREEZE].timer != -1)) return 0; skill = pc_checkskill(sd,RG_STEALCOIN)*10; - rate = skill + (sd->status.base_level - mob_db[md->class].lv)*3 + sd->paramc[4]*2 + sd->paramc[5]*2; + rate = skill + (sd->status.base_level - mob_db[md->class_].lv)*3 + sd->paramc[4]*2 + sd->paramc[5]*2; if(rand()%1000 < rate) { - pc_getzeny(sd,mob_db[md->class].lv*10 + rand()%100); + pc_getzeny(sd,mob_db[md->class_].lv*10 + rand()%100); md->state.steal_coin_flag = 1; return 1; } @@ -4859,7 +4859,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) nullpo_retr(0, sd); if(sd->status.base_exp >= next && next > 0){ - struct pc_base_job s_class = pc_calc_base_job(sd->status.class); + struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); // base側レベルアップ?理 sd->status.base_exp -= next; @@ -4989,12 +4989,12 @@ int pc_nextbaseexp(struct map_session_data *sd) if(sd->status.base_level>=MAX_LEVEL || sd->status.base_level<=0) return 0; - if(sd->status.class==0) i=0; - else if(sd->status.class<=6) i=1; - else if(sd->status.class<=22) i=2; - else if(sd->status.class==23) i=3; - else if(sd->status.class==4001) i=4; - else if(sd->status.class<=4007) i=5; + if(sd->status.class_==0) i=0; + else if(sd->status.class_<=6) i=1; + else if(sd->status.class_<=22) i=2; + else if(sd->status.class_==23) i=3; + else if(sd->status.class_==4001) i=4; + else if(sd->status.class_<=4007) i=5; else i=6; return exp_table[i][sd->status.base_level-1]; @@ -5013,12 +5013,12 @@ int pc_nextjobexp(struct map_session_data *sd) if(sd->status.job_level>=MAX_LEVEL || sd->status.job_level<=0) return 0; - if(sd->status.class==0) i=7; - else if(sd->status.class<=6) i=8; - else if(sd->status.class<=22) i=9; - else if(sd->status.class==23) i=10; - else if(sd->status.class==4001) i=11; - else if(sd->status.class<=4007) i=12; + if(sd->status.class_==0) i=7; + else if(sd->status.class_<=6) i=8; + else if(sd->status.class_<=22) i=9; + else if(sd->status.class_==23) i=10; + else if(sd->status.class_==4001) i=11; + else if(sd->status.class_<=4007) i=12; else i=13; return exp_table[i][sd->status.job_level-1]; @@ -5037,12 +5037,12 @@ int pc_nextbaseafter(struct map_session_data *sd) if(sd->status.base_level>=MAX_LEVEL || sd->status.base_level<=0) return 0; - if(sd->status.class==0) i=0; - else if(sd->status.class<=6) i=1; - else if(sd->status.class<=22) i=2; - else if(sd->status.class==23) i=3; - else if(sd->status.class==4001) i=4; - else if(sd->status.class<=4007) i=5; + if(sd->status.class_==0) i=0; + else if(sd->status.class_<=6) i=1; + else if(sd->status.class_<=22) i=2; + else if(sd->status.class_==23) i=3; + else if(sd->status.class_==4001) i=4; + else if(sd->status.class_<=4007) i=5; else i=6; return exp_table[i][sd->status.base_level]; @@ -5061,12 +5061,12 @@ int pc_nextjobafter(struct map_session_data *sd) if(sd->status.job_level>=MAX_LEVEL || sd->status.job_level<=0) return 0; - if(sd->status.class==0) i=7; - else if(sd->status.class<=6) i=8; - else if(sd->status.class<=22) i=9; - else if(sd->status.class==23) i=10; - else if(sd->status.class==4001) i=11; - else if(sd->status.class<=4007) i=12; + if(sd->status.class_==0) i=7; + else if(sd->status.class_<=6) i=8; + else if(sd->status.class_<=22) i=9; + else if(sd->status.class_==23) i=10; + else if(sd->status.class_==4001) i=11; + else if(sd->status.class_<=4007) i=12; else i=13; return exp_table[i][sd->status.job_level]; @@ -5104,7 +5104,7 @@ int pc_statusup(struct map_session_data *sd,int type) nullpo_retr(0, sd); - max = (pc_calc_upper(sd->status.class)==2) ? 80 : battle_config.max_parameter; + max = (pc_calc_upper(sd->status.class_)==2) ? 80 : battle_config.max_parameter; need=pc_need_status_point(sd,type); if(typeSP_LUK || need<0 || need>sd->status.status_point){ @@ -5259,7 +5259,7 @@ int pc_skillup(struct map_session_data *sd,int skill_num) if( sd->status.skill_point>0 && sd->status.skill[skill_num].id!=0 && //sd->status.skill[skill_num].lv < skill_get_max(skill_num) ) - celest - sd->status.skill[skill_num].lv < skill_tree_get_max(skill_num, sd->status.class) ) + sd->status.skill[skill_num].lv < skill_tree_get_max(skill_num, sd->status.class_) ) { sd->status.skill[skill_num].lv++; sd->status.skill_point--; @@ -5285,7 +5285,7 @@ int pc_allskillup(struct map_session_data *sd) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); c = s_class.job; s = (s_class.upper==1) ? 1 : 0 ; //?生以外は通常のスキル? @@ -5313,7 +5313,7 @@ int pc_allskillup(struct map_session_data *sd) if(sd->status.skill[id].id==0 && (!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn) ) { sd->status.skill[id].id = id; // celest // sd->status.skill[id].lv=skill_get_max(id); - sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class); // celest + sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); // celest } } } @@ -5351,7 +5351,7 @@ int pc_resetlvl(struct map_session_data* sd,int type) sd->status.int_=1; sd->status.dex=1; sd->status.luk=1; - if(sd->status.class == 4001) + if(sd->status.class_ == 4001) sd->status.status_point=88; } @@ -5416,7 +5416,7 @@ int pc_resetstate(struct map_session_data* sd) // New statpoint table used here - Dexity sd->status.status_point = atoi (statp[sd->status.base_level - 1]); - if(sd->status.class >= 4001 && sd->status.class <= 4024) + if(sd->status.class_ >= 4001 && sd->status.class_ <= 4024) sd->status.status_point+=40; // End addition @@ -5504,7 +5504,7 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage) nullpo_retr(0, sd); //?生や養子の場合の元の職業を算出する - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); // ?に死んでいたら無? if(pc_isdead(sd)) return 0; @@ -5612,7 +5612,7 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage) } if(battle_config.death_penalty_type>0) { // changed penalty options, added death by player if pk_mode [Valaris] - if(sd->status.class != 0 && !map[sd->bl.m].flag.nopenalty && !map[sd->bl.m].flag.gvg){ // only novices will recieve no penalty + if(sd->status.class_ != 0 && !map[sd->bl.m].flag.nopenalty && !map[sd->bl.m].flag.gvg){ // only novices will recieve no penalty if(battle_config.death_penalty_type==1 && battle_config.death_penalty_base > 0) sd->status.base_exp -= (double)pc_nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000; if(battle_config.pk_mode && src && src->type==BL_PC) @@ -5748,7 +5748,7 @@ int pc_readparam(struct map_session_data *sd,int type) int val=0; struct pc_base_job s_class; - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); nullpo_retr(0, sd); @@ -5772,7 +5772,7 @@ int pc_readparam(struct map_session_data *sd,int type) if(val>=24 && val < 45) val+=3978; else - val= sd->status.class; + val= sd->status.class_; break; case SP_BASEJOB: val= s_class.job; @@ -5850,7 +5850,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); switch(type){ case SP_BASELEVEL: @@ -5873,7 +5873,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) // super novices can go up to 99 [celest] else if (s_class.job == 23) up_level += 49; - else if (sd->status.class >= 4008 && sd->status.class <= 4022) + else if (sd->status.class_ >= 4008 && sd->status.class_ <= 4022) up_level += 20; if (val >= sd->status.job_level) { if (val > up_level)val = up_level; @@ -6160,7 +6160,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) int i; int b_class = 0; //?生や養子の場合の元の職業を算出する - struct pc_base_job s_class = pc_calc_base_job(sd->status.class); + struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); nullpo_retr(0, sd); @@ -6188,7 +6188,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if((sd->status.sex == 0 && job == 19) || (sd->status.sex == 1 && job == 20) || // not needed [celest] //(sd->status.sex == 0 && job == 4020) || (sd->status.sex == 1 && job == 4021) || - job == 22 || sd->status.class == b_class) //♀はバ?ドになれない、♂はダンサ?になれない、結婚衣裳もお?り + job == 22 || sd->status.class_ == b_class) //♀はバ?ドになれない、♂はダンサ?になれない、結婚衣裳もお?り return 1; // check if we are changing from 1st to 2nd job @@ -6203,7 +6203,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) pc_setglobalreg (sd, "jobchange_level", sd->change_level); - sd->status.class = sd->view_class = b_class; + sd->status.class_ = sd->view_class = b_class; sd->status.job_level=1; sd->status.job_exp=0; @@ -6369,17 +6369,17 @@ int pc_setriding(struct map_session_data *sd) if((pc_checkskill(sd,KN_RIDING)>0)){ // ライディングスキル所持 pc_setoption(sd,sd->status.option|0x0020); - if(sd->status.class==7) - sd->status.class=sd->view_class=13; + if(sd->status.class_==7) + sd->status.class_=sd->view_class=13; - if(sd->status.class==14) - sd->status.class=sd->view_class=21; + if(sd->status.class_==14) + sd->status.class_=sd->view_class=21; - if(sd->status.class==4008) - sd->status.class=sd->view_class=4014; + if(sd->status.class_==4008) + sd->status.class_=sd->view_class=4014; - if(sd->status.class==4015) - sd->status.class=sd->view_class=4022; + if(sd->status.class_==4015) + sd->status.class_=sd->view_class=4022; } return 0; @@ -6857,7 +6857,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos) // 二刀流?理 if ((pos==0x22) // 一?、?備要求箇所が二刀流武器かチェックする && (id->equip==2) // ? 手武器 - && (pc_checkskill(sd, AS_LEFT) > 0 || pc_calc_base_job2(sd->status.class) == 12) ) // 左手修?有 + && (pc_checkskill(sd, AS_LEFT) > 0 || pc_calc_base_job2(sd->status.class_) == 12) ) // 左手修?有 { int tpos=0; if(sd->equip_index[8] >= 0) @@ -7234,7 +7234,7 @@ int pc_ismarried(struct map_session_data *sd) */ int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd) { - if(sd == NULL || dstsd == NULL || sd->status.partner_id > 0 || dstsd->status.partner_id > 0 || pc_calc_upper(sd->status.class)==2) + if(sd == NULL || dstsd == NULL || sd->status.partner_id > 0 || dstsd->status.partner_id > 0 || pc_calc_upper(sd->status.class_)==2) return -1; sd->status.partner_id=dstsd->status.char_id; dstsd->status.partner_id=sd->status.char_id; @@ -7503,7 +7503,7 @@ static int pc_natural_heal_sp(struct map_session_data *sd) if(sd->nshealsp > 0) { if(sd->inchealsptick >= battle_config.natural_heal_skill_interval && sd->status.sp < sd->status.max_sp) { - struct pc_base_job s_class = pc_calc_base_job(sd->status.class); + struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); if(sd->doridori_counter && s_class.job == 23) bonus = sd->nshealsp*2; else diff --git a/src/map/pet.c b/src/map/pet.c index 80331bd0f..3c87a91e5 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -183,14 +183,14 @@ static int pet_attack(struct pet_data *pd,unsigned int tick,int data) return 0; } - mode=mob_db[pd->class].mode; - race=mob_db[pd->class].race; - if(mob_db[pd->class].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race != 4 && race != 6) ) { + mode=mob_db[pd->class_].mode; + race=mob_db[pd->class_].race; + if(mob_db[pd->class_].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race != 4 && race != 6) ) { pd->target_id=0; return 0; } - range = mob_db[pd->class].range + 1; + range = mob_db[pd->class_].range + 1; if(distance(pd->bl.x,pd->bl.y,md->bl.x,md->bl.y) > range) return 0; if(battle_config.monster_attack_direction_change) @@ -308,15 +308,15 @@ int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type) Assert((pd->msd == 0) || (pd->msd->pd == pd)); - if(bl && pd && bl->type == BL_MOB && sd->pet.intimate > 900 && sd->pet.hungry > 0 && pd->class != battle_get_class(bl) + if(bl && pd && bl->type == BL_MOB && sd->pet.intimate > 900 && sd->pet.hungry > 0 && pd->class_ != battle_get_class(bl) && pd->state.state != MS_DELAY) { - mode=mob_db[pd->class].mode; - race=mob_db[pd->class].race; + mode=mob_db[pd->class_].mode; + race=mob_db[pd->class_].race; md=(struct mob_data *)bl; if(md->bl.type != BL_MOB || pd->bl.m != md->bl.m || md->bl.prev == NULL || distance(pd->bl.x,pd->bl.y,md->bl.x,md->bl.y) > 13) return 0; - if(mob_db[pd->class].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race!=4 && race!=6) ) + if(mob_db[pd->class_].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race!=4 && race!=6) ) return 0; if(!type) { rate = sd->petDB->attack_rate; @@ -541,11 +541,11 @@ int search_petDB_index(int key,int type) int i; for(i=0;ipet.class,PET_CLASS); + i = search_petDB_index(sd->pet.class_,PET_CLASS); if(i < 0) { sd->status.pet_id = 0; return 1; @@ -720,7 +720,7 @@ int pet_data_init(struct map_session_data *sd) pd->bl.y = pd->to_y; pd->bl.id = npc_get_new_npc_id(); memcpy(pd->name,sd->pet.name,24); - pd->class = sd->pet.class; + pd->class_ = sd->pet.class_; pd->equip = sd->pet.equip; pd->dir = sd->dir; pd->speed = sd->petDB->speed; @@ -865,17 +865,17 @@ int pet_catch_process2(struct map_session_data *sd,int target_id) return 1; } - i = search_petDB_index(md->class,PET_CLASS); - if(md == NULL || md->bl.type != BL_MOB || md->bl.prev == NULL || i < 0 || sd->catch_target_class != md->class) { + i = search_petDB_index(md->class_,PET_CLASS); + if(md == NULL || md->bl.type != BL_MOB || md->bl.prev == NULL || i < 0 || sd->catch_target_class != md->class_) { clif_pet_rulet(sd,0); return 1; } //target_idによる敵→卵判定 // if(battle_config.etc_log) -// printf("mob_id = %d, mob_class = %d\n",md->bl.id,md->class); +// printf("mob_id = %d, mob_class = %d\n",md->bl.id,md->class_); //成功の場合 - pet_catch_rate = (pet_db[i].capture + (sd->status.base_level - mob_db[md->class].lv)*30 + sd->paramc[5]*20)*(200 - md->hp*100/mob_db[md->class].max_hp)/100; + pet_catch_rate = (pet_db[i].capture + (sd->status.base_level - mob_db[md->class_].lv)*30 + sd->paramc[5]*20)*(200 - md->hp*100/mob_db[md->class_].max_hp)/100; if(pet_catch_rate < 1) pet_catch_rate = 1; if(battle_config.pet_catch_rate != 100) pet_catch_rate = (pet_catch_rate*battle_config.pet_catch_rate)/100; @@ -885,7 +885,7 @@ int pet_catch_process2(struct map_session_data *sd,int target_id) clif_pet_rulet(sd,1); // if(battle_config.etc_log) // printf("rulet success %d\n",target_id); - intif_create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class,mob_db[pet_db[i].class].lv, + intif_create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class_,mob_db[pet_db[i].class_].lv, pet_db[i].EggID,0,pet_db[i].intimate,100,0,1,pet_db[i].jname); } else @@ -1111,7 +1111,7 @@ static int pet_randomwalk(struct pet_data *pd,int tick) pd->move_fail_count++; if(pd->move_fail_count>1000){ if(battle_config.error_log) - printf("PET cant move. hold position %d, class = %d\n",pd->bl.id,pd->class); + printf("PET cant move. hold position %d, class = %d\n",pd->bl.id,pd->class_); pd->move_fail_count=0; pet_changestate(pd,MS_DELAY,60000); return 0; @@ -1184,15 +1184,15 @@ static int pet_ai_sub_hard(struct pet_data *pd,unsigned int tick) pet_randomwalk(pd,tick); } else if(pd->target_id - MAX_FLOORITEM > 0) { - mode=mob_db[pd->class].mode; - race=mob_db[pd->class].race; + mode=mob_db[pd->class_].mode; + race=mob_db[pd->class_].race; md=(struct mob_data *)map_id2bl(pd->target_id); if(md == NULL || md->bl.type != BL_MOB || pd->bl.m != md->bl.m || md->bl.prev == NULL || distance(pd->bl.x,pd->bl.y,md->bl.x,md->bl.y) > 13) pet_unlocktarget(pd); - else if(mob_db[pd->class].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race!=4 && race!=6) ) + else if(mob_db[pd->class_].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race!=4 && race!=6) ) pet_unlocktarget(pd); - else if(!battle_check_range(&pd->bl,&md->bl,mob_db[pd->class].range)){ + else if(!battle_check_range(&pd->bl,&md->bl,mob_db[pd->class_].range)){ if(pd->timer != -1 && pd->state.state == MS_WALK && distance(pd->to_x,pd->to_y,md->bl.x,md->bl.y) < 2) return 0; if( !pet_can_reach(pd,md->bl.x,md->bl.y)) @@ -1641,7 +1641,7 @@ int read_petdb() continue; //MobID,Name,JName,ItemID,EggID,AcceID,FoodID,"Fullness (1回の餌での満腹度増加率%)","HungryDeray (/min)","R_Hungry (空腹時餌やり親密度増加率%)","R_Full (とても満腹時餌やり親密度減少率%)","Intimate (捕獲時親密度%)","Die (死亡時親密度減少率%)","Capture (捕獲率%)",(Name) - pet_db[j].class = nameid; + pet_db[j].class_ = nameid; memcpy(pet_db[j].name,str[1],24); memcpy(pet_db[j].jname,str[2],24); pet_db[j].itemID=atoi(str[3]); diff --git a/src/map/pet.h b/src/map/pet.h index b811735b1..1664f42d5 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -6,7 +6,7 @@ #define PETLOOT_SIZE 20 // [Valaris] struct pet_db { - int class; + int class_; char name[24],jname[24]; int itemID; int EggID; diff --git a/src/map/script.c b/src/map/script.c index 788c755e5..7730c2ed9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3666,10 +3666,10 @@ int buildin_makepet(struct script_state *st) if (pet_id < 0) pet_id = search_petDB_index(id, PET_EGG); if (pet_id >= 0 && sd) { - sd->catch_target_class = pet_db[pet_id].class; + sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet( sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv, + pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } @@ -4426,13 +4426,13 @@ int buildin_changesex(struct script_state *st) { if (sd->status.sex == 0) { sd->status.sex = 1; sd->sex = 1; - if (sd->status.class == 20 || sd->status.class == 4021) - sd->status.class -= 1; + if (sd->status.class_ == 20 || sd->status.class_ == 4021) + sd->status.class_ -= 1; } else if (sd->status.sex == 1) { sd->status.sex = 0; sd->sex = 0; - if(sd->status.class == 19 || sd->status.class == 4020) - sd->status.class += 1; + if(sd->status.class_ == 19 || sd->status.class_ == 4020) + sd->status.class_ += 1; } chrif_char_ask_name(-1, sd->status.name, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex chrif_save(sd); @@ -4978,7 +4978,7 @@ int buildin_maprespawnguildid_sub(struct block_list *bl,va_list ap) pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,3); // end addition [Valaris] } if(md && flag&4){ - if(md->class < 1285 || md->class > 1288) + if(md->class_ < 1285 || md->class_ > 1288) mob_delete(md); } return 0; diff --git a/src/map/skill.c b/src/map/skill.c index af8db17cc..55b531fd7 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2969,7 +2969,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if( dstsd && dstsd->special_state.no_magic_damage ) heal=0; /* ?金蟲カ?ド(ヒ?ル量0) */ if (sd){ - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); if((skill=pc_checkskill(sd,HP_MEDITATIO))>0) // メディテイティオ heal += heal*skill*2/100; if(sd && dstsd && sd->status.partner_id == dstsd->status.char_id && s_class.job == 23 && sd->status.sex == 0) //自分も?象もPC、?象が自分のパ?トナ?、自分がスパノビ、自分が♀なら @@ -3157,8 +3157,8 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int clif_skill_nodamage(src,bl,skillid,skilllv,1); if (dstmd){ for(i=0;iclass == pet_db[i].class){ - pet_catch_process1(sd,dstmd->class); + if(dstmd->class_ == pet_db[i].class_){ + pet_catch_process1(sd,dstmd->class_); break; } } @@ -3391,7 +3391,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case CR_DEVOTION: /* ディボ?ション */ if(sd && dstsd){ //?生や養子の場合の元の職業を算出する - struct pc_base_job dst_s_class = pc_calc_base_job(dstsd->status.class); + struct pc_base_job dst_s_class = pc_calc_base_job(dstsd->status.class_); int lv = sd->status.base_level-dstsd->status.base_level; lv = (lv<0)?-lv:lv; @@ -3457,7 +3457,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int }else if(sd && dstmd){ //?象がモンスタ?の場合 //20%の確率で?象のLv*2のSPを回復する。成功したときはタ?ゲット(σ?Д?)σ????!! if(rand()%100<20){ - i=2*mob_db[dstmd->class].lv; + i=2*mob_db[dstmd->class_].lv; mob_target(dstmd,src,0); } } @@ -4303,7 +4303,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case NPC_PROVOCATION: clif_skill_nodamage(src,bl,skillid,skilllv,1); if(md) - clif_pet_performance(src,mob_db[md->class].skill[md->skillidx].val[0]); + clif_pet_performance(src,mob_db[md->class_].skill[md->skillidx].val[0]); break; case NPC_HALLUCINATION: @@ -4372,18 +4372,18 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case NPC_SUMMONSLAVE: /* 手下召喚 */ case NPC_SUMMONMONSTER: /* MOB召喚 */ if(md) - mob_summonslave(md,mob_db[md->class].skill[md->skillidx].val,skilllv,(skillid==NPC_SUMMONSLAVE)?1:0); + mob_summonslave(md,mob_db[md->class_].skill[md->skillidx].val,skilllv,(skillid==NPC_SUMMONSLAVE)?1:0); break; case NPC_TRANSFORMATION: case NPC_METAMORPHOSIS: if(md) - mob_class_change(md,mob_db[md->class].skill[md->skillidx].val); + mob_class_change(md,mob_db[md->class_].skill[md->skillidx].val); break; case NPC_EMOTION: /* エモ?ション */ if(md) - clif_emotion(&md->bl,mob_db[md->class].skill[md->skillidx].val[0]); + clif_emotion(&md->bl,mob_db[md->class_].skill[md->skillidx].val[0]); break; case NPC_DEFENDER: @@ -6837,14 +6837,14 @@ static int skill_check_condition_char_sub(struct block_list *bl,va_list ap) nullpo_retr(0, c=va_arg(ap,int *)); nullpo_retr(0, ssd=(struct map_session_data*)src); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); //チェックしない設定ならcにありえない大きな?字を返して終了 if(!battle_config.player_skill_partner_check){ //本?はforeachの前にやりたいけど設定適用箇所をまとめるためにここへ (*c)=99; return 0; } - ss_class = pc_calc_base_job(ssd->status.class); + ss_class = pc_calc_base_job(ssd->status.class_); switch(ssd->skillid){ case PR_BENEDICTIO: /* 聖?降福 */ @@ -6898,7 +6898,7 @@ static int skill_check_condition_use_sub(struct block_list *bl,va_list ap) nullpo_retr(0, c=va_arg(ap,int *)); nullpo_retr(0, ssd=(struct map_session_data*)src); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); //チェックしない設定ならcにありえない大きな?字を返して終了 if(!battle_config.player_skill_partner_check){ //本?はforeachの前にやりたいけど設定適用箇所をまとめるためにここへ @@ -6906,7 +6906,7 @@ static int skill_check_condition_use_sub(struct block_list *bl,va_list ap) return 0; } - ss_class = pc_calc_base_job(ssd->status.class); + ss_class = pc_calc_base_job(ssd->status.class_); skillid=ssd->skillid; skilllv=ssd->skilllv; //if(skilllv <= 0) return 0; @@ -6967,7 +6967,7 @@ static int skill_check_condition_mob_master_sub(struct block_list *bl,va_list ap nullpo_retr(0, mob_class=va_arg(ap,int)); nullpo_retr(0, c=va_arg(ap,int *)); - if(md->class==mob_class && md->master_id==src_id) + if(md->class_==mob_class && md->master_id==src_id) (*c)++; return 0; } @@ -7782,7 +7782,7 @@ int skill_use_id( struct map_session_data *sd, int target_id, clif_skillcasting( &sd->bl, sd->bl.id, target_id, 0,0, skill_num,casttime); /* 詠唱反?モンスタ? */ - if( bl->type==BL_MOB && (md=(struct mob_data *)bl) && mob_db[md->class].mode&0x10 && + if( bl->type==BL_MOB && (md=(struct mob_data *)bl) && mob_db[md->class_].mode&0x10 && md->state.state!=MS_ATTACK && sd->invincible_timer == -1){ md->target_id=sd->bl.id; md->state.targettype = ATTACKABLE; -- cgit v1.2.3-70-g09d2 From 28cb9b9d074dbefa1e5de9805ff172f7dbd39da4 Mon Sep 17 00:00:00 2001 From: amber Date: Thu, 6 Jan 2005 15:02:42 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@924 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 15 +++++++++++++++ conf-tmpl/login_athena.conf | 3 +++ src/common/core.c | 2 ++ src/common/socket.c | 14 +++++++++++--- src/common/socket.h | 6 ++++++ src/map/clif.c | 5 ----- src/map/map.c | 8 ++------ src/map/map.h | 1 - src/map/party.c | 2 +- src/map/pc.c | 30 +++--------------------------- src/map/pc.h | 3 --- 11 files changed, 43 insertions(+), 46 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index de35e52a4..e947ea7b2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,19 @@ Date Added +01/06 + * Fixed typo in src/map/map.c causing compile + errors (SVN 924) [MouseJstr] + * Removed the alive_timer mechanism entirly replaced with + a stall detection mechanism that will disconnect a player + who has not sent any data for a configurable + (conf/login_athena.conf:stall_time) amount of time. The default + is currently 60 seconds. + + The root cause of the disconnect error is that some NAT based + routers are not dropping the TCP connection when the aliased + machine goes offline abnormally. This means that we are seeing + a stalled but perfectly valid TCP connection. + + (SVN 924) [MouseJstr] 01/05 * Fixed some typos in map_versionscreen() [MC Cameri] * Removed loop freeing in map-server's do_final(), it was causing seg faults [MC Cameri] diff --git a/conf-tmpl/login_athena.conf b/conf-tmpl/login_athena.conf index d58e8e09c..4758f7dc0 100644 --- a/conf-tmpl/login_athena.conf +++ b/conf-tmpl/login_athena.conf @@ -151,4 +151,7 @@ flush_on: 0 // How often to flush the buffer in Mugendai's GUI flush_time: 60 +// How long can a socket stall before closing the connection +stall_time: 60 + import: conf/import/login_conf.txt diff --git a/src/common/core.c b/src/common/core.c index 2e0029ea1..493aab850 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -169,6 +169,8 @@ int main(int argc,char **argv) display_title(); + tick_ = time(0); + do_init(argc,argv); while(runflag){ next=do_timer(gettick_nocache()); diff --git a/src/common/socket.c b/src/common/socket.c index 5d7d0775e..764d4d821 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -37,6 +37,8 @@ fd_set readfds; int fd_max; +time_t tick_; +time_t stall_time_ = 60; int rfifo_size = 65536; int wfifo_size = 65536; @@ -106,6 +108,7 @@ static int recv_to_fifo(int fd) //{ int i; printf("recv %d : ",fd); for(i=0;irdata_size+i)); } printf("\n");} if(len>0){ session[fd]->rdata_size+=len; + session[fd]->rdata_tick = tick_; } else if(len<=0){ // value of connection is not necessary the same // printf("set eof : connection #%d\n", fd); @@ -209,6 +212,7 @@ static int connect_client(int listen_fd) session[fd]->func_send = send_from_fifo; session[fd]->func_parse = default_func_parse; session[fd]->client_addr = client_address; + session[fd]->rdata_tick = tick_; //printf("new_session : %d %d\n",fd,session[fd]->eof); return fd; @@ -347,6 +351,7 @@ int make_connection(long ip,int port) session[fd]->func_recv = recv_to_fifo; session[fd]->func_send = send_from_fifo; session[fd]->func_parse = default_func_parse; + session[fd]->rdata_tick = tick_; return fd; } @@ -407,7 +412,10 @@ int do_sendrecv(int next) struct timeval timeout; int ret,i; - rfd=readfds; + tick_ = time(0); + + memcpy(&rfd, &readfds, sizeof(rfd)); + FD_ZERO(&wfd); for(i=0;ifunc_send) - //send_from_fifo(i); session[i]->func_send(i); } if(FD_ISSET(i,&rfd)){ //printf("read:%d\n",i); if(session[i]->func_recv) - //recv_to_fifo(i); session[i]->func_recv(i); } } @@ -450,6 +456,8 @@ int do_parsepacket(void) for(i=0;irdata_tick != 0) && ((tick_ - session[i]->rdata_tick) > stall_time_)) + session[i]->eof = 1; if(session[i]->rdata_size==0 && session[i]->eof==0) continue; if(session[i]->func_parse){ diff --git a/src/common/socket.h b/src/common/socket.h index e5e065f33..172712d26 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -12,8 +12,13 @@ #include #include #endif +#include + #include "malloc.h" +extern time_t tick_; +extern time_t stall_time_; + // define declaration #define RFIFOP(fd,pos) (session[fd]->rdata+session[fd]->rdata_pos+(pos)) @@ -55,6 +60,7 @@ struct socket_data{ unsigned char *rdata,*wdata; int max_rdata,max_wdata; int rdata_size,wdata_size; + time_t rdata_tick; int rdata_pos; struct sockaddr_in client_addr; int (*func_recv)(int); diff --git a/src/map/clif.c b/src/map/clif.c index af89df654..0412192e1 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7545,11 +7545,6 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { break; } - //double connection bug fix by Valaris - if(sd->alive_timer > 0) - delete_timer(sd->alive_timer,pc_alive_timer); - sd->alive_timer=add_timer(gettick()+60*1000,pc_alive_timer,sd->bl.id,0); - sd->server_tick = gettick(); clif_servertick(sd); } diff --git a/src/map/map.c b/src/map/map.c index 6c028628d..039bdc5f2 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1051,12 +1051,6 @@ int map_quit(struct map_session_data *sd) { storage_storage_dirty(sd); storage_storage_save(sd); - //double connect bug fix by Valaris - if(sd->alive_timer > 0) { - delete_timer(sd->alive_timer,pc_alive_timer); - sd->alive_timer = -1; // not 0, the server will assume it's still active - } - if( sd->npc_stackbuf && sd->npc_stackbuf != NULL) { free( sd->npc_stackbuf ); sd->npc_stackbuf = NULL; @@ -2440,6 +2434,8 @@ int sql_config_read(char *cfgName) strcpy(login_server_pw, w2); } else if(strcmpi(w1,"login_server_db")==0){ strcpy(login_server_db, w2); + } else if(strcmpi(w1,"stall_time")==0){ + stall_time_ = atoi(w2); } else if(strcmpi(w1,"lowest_gm_level")==0){ lowest_gm_level = atoi(w2); } else if(strcmpi(w1,"read_gm_interval")==0){ diff --git a/src/map/map.h b/src/map/map.h index 289e8338b..f25ebba30 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -332,7 +332,6 @@ struct map_session_data { int last_skillid,last_skilllv; // Added by RoVeRT unsigned char change_level; // [celest] - int alive_timer; //[Valaris] #ifndef TXT_ONLY int mail_counter; // mail counter for mail system [Valaris] diff --git a/src/map/party.c b/src/map/party.c index ddaed7fc7..28f05bab9 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -591,7 +591,7 @@ int party_exp_share(struct party *p,int map,int base_exp,int job_exp,int zeny) return 0; for(i=0;imember[i].sd)!=NULL && sd->bl.m==map && session[sd->fd] != NULL) { - if (/* pc_issit(sd) || */ sd->chatID || (sd->idletime < (time(0) - 120))) + if (/* pc_issit(sd) || */ sd->chatID || (sd->idletime < (tick_ - 120))) continue; #ifdef TWILIGHT pc_gainexp(sd,base_exp,job_exp); diff --git a/src/map/pc.c b/src/map/pc.c index 14ee9b097..3dbfc4e88 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4016,11 +4016,6 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt // map_addblock(&sd->bl); /// ブロック登?とspawnは // clif_spawnpc(sd); - //double connection bug fix by Valaris - if(sd->alive_timer > 0) - delete_timer(sd->alive_timer,pc_alive_timer); - sd->alive_timer=add_timer(gettick()+60*1000,pc_alive_timer,sd->bl.id,0); - return 0; } @@ -4323,7 +4318,7 @@ int pc_walktoxy(struct map_session_data *sd,int x,int y) sd->to_x=x; sd->to_y=y; - sd->idletime = time(0); + sd->idletime = tick_; if(sd->walktimer != -1 && sd->state.change_walk_target==0){ // 現在?いている最中の目的地?更なのでマス目の中心に?た暫ノ @@ -4652,7 +4647,7 @@ int pc_attack_timer(int tid,unsigned int tick,int id,int data) if(sd == NULL) return 0; - sd->idletime = time(0); + sd->idletime = tick_; if(sd->attacktimer != tid){ if(battle_config.error_log) @@ -4773,7 +4768,7 @@ int pc_attack(struct map_session_data *sd,int target_id,int type) if(bl==NULL) return 1; - sd->idletime = time(0); + sd->idletime = tick_; if(bl->type==BL_NPC) { // monster npcs [Valaris] //npc_click(sd,RFIFOL(sd->fd,2)); @@ -7894,24 +7889,6 @@ int map_night_timer(int tid, unsigned int tick, int id, int data) { // by [yor] return 0; } -/*========================================== - * I'm alive timer (to prevent double connect bug) by Valaris - *------------------------------------------ - */ -int pc_alive_timer(int tid,unsigned int tick,int id,int data) -{ - //struct map_session_data *sd=(struct map_session_data*)map_id2bl(id); - struct map_session_data *sd=map_id2sd(id); // more accurate [celest] - nullpo_retr(0, sd); - if(sd->alive_timer != tid) - return 0; - sd->alive_timer = -1; -// map_quit(sd); - clif_timedout (sd); - - return 0; -} - void pc_setstand(struct map_session_data *sd){ nullpo_retv(sd); @@ -8308,7 +8285,6 @@ int do_init_pc(void) { // add night/day timer (by [yor]) add_timer_func_list(map_day_timer, "map_day_timer"); // by [yor] add_timer_func_list(map_night_timer, "map_night_timer"); // by [yor] - add_timer_func_list(pc_alive_timer, "pc_alive_timer"); //by Valaris { int day_duration = battle_config.day_duration; int night_duration = battle_config.night_duration; diff --git a/src/map/pc.h b/src/map/pc.h index a32926886..02dfcb74a 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -200,8 +200,5 @@ extern int night_timer_tid; int map_day_timer(int,unsigned int,int,int); // by [yor] int map_night_timer(int,unsigned int,int,int); // by [yor] -//double connect bug fix -int pc_alive_timer(int tid,unsigned int tick,int,int); - #endif -- cgit v1.2.3-70-g09d2 From 2c5fabbc0b492cb5456e670ce9eb2352a11d5e3b Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Sun, 23 Jan 2005 20:38:44 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@968 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 138 +++++++ Dev/bugs.txt | 8 +- conf-tmpl/battle_athena.conf | 4 + db/packet_db.txt | 318 ++++++++------- db/skill_cast_db.txt | 2 +- npc/mobs/fields/yuno.txt | 170 +++++--- sql-files/database.sql | 3 - sql-files/mail.sql | 2 - src/char/char.c | 120 +++--- src/char/char.h | 6 +- src/char/int_guild.c | 24 +- src/char/int_party.c | 8 +- src/char/int_pet.c | 8 +- src/char/int_storage.c | 16 +- src/char/inter.c | 12 +- src/char_sql/char.c | 96 ++--- src/char_sql/char.h | 6 +- src/char_sql/int_guild.c | 196 ++++----- src/char_sql/int_party.c | 2 +- src/char_sql/int_pet.c | 2 +- src/char_sql/int_storage.c | 4 +- src/char_sql/inter.c | 4 +- src/char_sql/itemdb.c | 8 +- src/char_sql/itemdb.h | 2 +- src/common/core.c | 1 + src/common/db.c | 6 +- src/common/grfio.c | 68 ++-- src/common/grfio.h | 4 +- src/common/malloc.c | 23 +- src/common/malloc.h | 20 + src/common/mmo.h | 32 +- src/common/showmsg.c | 5 +- src/common/socket.c | 64 +-- src/common/socket.h | 3 +- src/common/strlib.c | 22 +- src/common/strlib.h | 6 +- src/common/timer.c | 10 +- src/common/utils.c | 9 +- src/common/utils.h | 6 + src/ladmin/ladmin.c | 10 +- src/login/login.c | 90 +++-- src/login/login.h | 2 +- src/login_sql/login.c | 26 +- src/login_sql/login.h | 2 +- src/map/atcommand.c | 164 ++++---- src/map/atcommand.h | 10 +- src/map/battle.c | 169 +++++--- src/map/battle.h | 7 +- src/map/charcommand.c | 4 +- src/map/chat.c | 6 +- src/map/clif.c | 388 ++++++++++-------- src/map/clif.h | 14 +- src/map/guild.c | 36 +- src/map/guild.h | 2 +- src/map/intif.c | 10 +- src/map/intif.h | 2 +- src/map/itemdb.c | 14 +- src/map/mail.c | 56 +-- src/map/map.c | 195 ++++----- src/map/map.h | 11 +- src/map/mob.c | 636 +++++++++++++++--------------- src/map/mob.h | 6 +- src/map/npc.c | 226 +++++------ src/map/party.c | 2 +- src/map/pc.c | 246 ++++++++---- src/map/pet.c | 4 +- src/map/script.c | 240 +++++------ src/map/skill.c | 536 ++++++++++++++++++------- src/map/skill.h | 15 +- src/map/storage.c | 12 +- src/map/vending.c | 6 +- src/txt-converter/char/char-converter.c | 106 ++--- src/txt-converter/char/char.h | 6 +- src/txt-converter/common/mmo.h | 10 +- src/txt-converter/login/login-converter.c | 8 +- 75 files changed, 2740 insertions(+), 1975 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index 6c019b932..4defcf648 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,142 @@ Date Added + +01/23 + * Forgot a couple small changes [SVN 35] [Ajarn] + * Changed map_data.gat and map_data_other_server.gat from unsigned char* + to char* (this might be needed, because of unicode or something, please + correct me if I'm wrong) [SVN 34] [Ajarn] + * Converted decode_zip, enconde_zip, remove_control_chars, mapif_sendall*, + and e_mail_check to use char* instead of unsigned char* (again, please test) + [SVN 34] [Ajarn] + * Modified skill unit group checking in skill_unit_onplace that might have + been causing crashes [celest] + * Updated packet 0x143 length's for version 14 (2004-11-01Sakexe) and version + 16 (2005-01-10Sakexe), thanks to jathena and ice2big [celest] + * Fixed login-server compile error with the "new" -> "new_" changes [celest] + +01/22 + * Fixed an error that was in my last commit (optimising g++ build) [SVN 29] + [Ajarn] + * Made strlib functions char*, instead of unsigned char*. Strings are meant + to be char. (Shouldn't break anyhting, but might, please test this for me) + [SVN 26] [Ajarn] + * Added cast for TXT version [SVN 25] [Ajarn] + * Added cast from allocation calls, from void* to intended type [SVN 24] [Ajarn] + * Changed bool -> bool_. Still need to make convertions between + char* and unsigned char* valid, and some other convertions too. + Also, sizeof is being used wierd in map.c, at least g++ + complains [SVN 22] [Ajarn] + * Changed the rest of the class variable names to class_ and all the new + variable names to new_, for futher g++ support [SVN 21] [Ajarn] + * Update both caster and target's SP after using Soul Change -- thanks to Aalye + / Freya [celest] + * Force a monster to switch attack target when being casted Provoke [celest] + * Corrected description for @enablenpc -- "@npcon" -> "@enablenpc" [celest] + * Since job normalising is still buggy require all 1st class skills to check + for Basic Skill level when calculating the skill tree [celest] + +01/21 + * Updated packet DB configurations : enable_packet_db, packet_db_ver, + -- check the .txt for description [celest] + + Note: For people having connection problems try setting 'enable_packet_db' + to 'no'... and use the latest client (01-10Sakexe) + + * Fixed a small typo in 12-06's packets -- 21b => 21d [celest] + * Updated packet_db.txt to only contain the latest version, like jAthena, + since there's not much point to re-read packets eA already supports + (although if you remove all the //'s it can still read multiple versions) + [celest] + * Added clif_config in clif.c - for keeping packet/client connections related + stuff [celest] + * Send 'Game Exe not latest version' to a client if it hasn't been authentified + yet, but is sending a non-connection-related packet to prevent crashing + -- assume the client is using an unknown exe [celest] + +01/20 + * Fixed compile time problems with the non-GC case [MouseJstr] + * Introduced aMallocA and aCallocA + + These two functions allocate "atomic" memory which means + "memory that does not contain references to other memory". + + This lets the garbage collector ignore these objects when searching + memory for references to other objects dramatically increasing + performance of the GC. + + When in doubt, use aMalloc and aCalloc. It is better to add + a tiny bit of work to the GC then do cause a crash due to memory + being cleaned up when it shouldn't. + [MouseJstr] + * Modified all calls to aMalloc and aCalloc that reference + atomic memory to use aMallocA and aCallocA + [MouseJstr] + * Modified the socket buffer allocator to use "atomic" memory + for the fifo data buffers [MouseJstr] +01/19 + * added support for the Hans-J. Boehm libC garbage collector + (A copy is in http://amber.stormbirds.org/~joshs/gc6.3.tar). + + It is ABSOLUTELY critical for people to use + aFree/aMalloc/aCalloc/aStrdup for this to work. If somebody + has just used free or malloc, this will crash when used with + the garbage collector. + + A amusing environmental variable to set is GC_PRINT_STATS (to 1) + so that you see real time statistics of leaked data being + recovered. + + grab a copy of the gc6.3.tar.. build it .. install it.. + modify the Makefile to have the + + CC = gcc -pipe -DGCOLLECT + GCLIB = -lgc + + lines... and make the sql servers (the txt server doesn't + build using this right now due to stupid Makefile issues) + + [MouseJstr] + * SVN 3 on http://svn.stormbirds.org/svn/eathena will be what + I diff against when I merge back into delta.. if we ever merge + back into delta [MouseJstr] + * Removed 12-06 Sakexe detection, since it doesn't seem to work, and + might be conflicting with 10-25 clients [celest] + * Update the Soul Burn target's SP when it has been successfully reduced to 0, + thanks to Aalye / Freya [celest] + * Moved SC_PRESERVE and SC_BATTLEORDERS's id so they'll display a status icon + when cast, thanks XiaoLin of cAthena [celest] + * Added missing code for Preserve -- i totally forgot to add it ^^; [celest] + +01/18 + * Added some skill bug fixes, thanks to Aalye / Freya [celest] + - stop player attacking if the target goes into hiding + - fixed Sword Reject not working against swords, only daggers + - additional check in case Marionette Control doesn't end properly even + when one of the partners has logged off + * Added stun, bleeding and SP loss effect for Pressure, thanks to DracoRpg + [celest] + * TEST: Fixed more compile warnings in MSVC [celest] + * TEST: Fixed some compile errors in MS Visual C++, thanks to Ser [celest] + +01/17 + * Some rewrites in skill_delayfix [celest] + - If the delay is < 0, add the weapon aspd delay to it + - If the skill is not weapon type, and has 0 delay, add 300ms as default + * Added min_skill_delay_limit as the minimum allowed delay for any skills + [celest] + * Some tidying up in battle_get_ functions [celest] + * Set exp table and job bonus table to 0 before reading - might solve some + memory bugs [celest] + * Updated skill range leniency code - If possible try and move towards the + skill target so that when casting it no longer falls out of range [celest] + +01/15 + * Added effects to enemies for Gospel [celest] + * Added mobs spawn to all Yuno fields (according to 4th Jan patch) [Lupus] + +01/14 + * Added party supporting effects for Gospel [celest] + 01/13 * Added and testing support for 2004-12-06Sakexe [celest] * Removed emblem changing requiring Glory of Guild limited to TXT only [celest] diff --git a/Dev/bugs.txt b/Dev/bugs.txt index bc85d6272..a1108f3a3 100644 --- a/Dev/bugs.txt +++ b/Dev/bugs.txt @@ -221,9 +221,7 @@ Problem: Berzebub, etc cards don't decrease aftercast delays Assigned: N/A Progress: 0% -Problem: Some clients that are able to log into eAthena servers properly are not able to when custom items are used. - I believe Celest may have accidentially "broken" a few things when she was attempting to create new packet - compatibility and removed old ones. +Problem: Older Clients are unable to log into the server, period. + Even if the packet_db is set to use the older clients, they still are unable to connect. Assigned: Celest -Progress: 0% - Celest: What version was the client using? \ No newline at end of file +Progress: 0% \ No newline at end of file diff --git a/conf-tmpl/battle_athena.conf b/conf-tmpl/battle_athena.conf index 9f7bd11a8..35b20f7d9 100644 --- a/conf-tmpl/battle_athena.conf +++ b/conf-tmpl/battle_athena.conf @@ -46,6 +46,10 @@ delay_rate: 100 // Note: On Official servers Dex does NOT affect delay time delay_dependon_dex: no +// Minimum allowed delay for ANY skills after casting (in miliseconds) (Note 1) +// Note: Setting this to anything above 0 can stop speedhacks. +min_skill_delay_limit: 100 + // At what dex does the cast time become zero (instacast) castrate_dex_scale: 150 diff --git a/db/packet_db.txt b/db/packet_db.txt index 28ae52fee..95591eacf 100644 --- a/db/packet_db.txt +++ b/db/packet_db.txt @@ -1,11 +1,23 @@ // The packet database allows you to add support for new clients, -// because packets change every release. -// This only allows 1 type of client at a time, make sure your +// because packets change every release. +// By default this only allows 1 type of client at a time, make sure your // client is the last one in the list // EX: You have client 628 and it goes up to 1021, // delete or comment (use //) till your client is last. -packet_ver: 5 + +// Whether to allow identifying clients via the packet DB +enable_packet_db: yes + +// Main packet version of the DB (default = Auto Detect) +packet_db_ver: default + +// Whether the packet DB takes higher precedence over the hardcoded packet +// length and functions, and whether to overwrite them when reading +prefer_packet_db: yes + + +// packet_ver: 5 0x0064,55 0x0065,17 0x0066,3 @@ -438,182 +450,182 @@ packet_ver: 5 //jROはここまで //2004-07-06kRO -packet_ver: 6 -0x0072,22,wanttoconnection,5:9:13:17:21 -0x0085,8,walktoxy,5 -0x00a7,13,useitem,5:9 -0x0113,15,useskilltoid,4:9:11 -0x0116,15,useskilltopos,4:9:11:13 -0x0190,95,useskilltopos,4:9:11:13:15 +// packet_ver: 6 +// 0x0072,22,wanttoconnection,5:9:13:17:21 +// 0x0085,8,walktoxy,5 +// 0x00a7,13,useitem,5:9 +// 0x0113,15,useskilltoid,4:9:11 +// 0x0116,15,useskilltopos,4:9:11:13 +// 0x0190,95,useskilltopos,4:9:11:13:15 //2004-07-13kRO -packet_ver: 7 -0x0072,39,wanttoconnection,12:22:30:34:38 -0x0085,9,walktoxy,6 -0x009b,13,changedir,5:12 -0x009f,10,takeitem,6 -0x00a7,17,useitem,6:13 -0x0113,19,useskilltoid,7:9:15 -0x0116,19,useskilltopos,7:9:15:17 -0x0190,99,useskilltopos,7:9:15:17:19 +// packet_ver: 7 +// 0x0072,39,wanttoconnection,12:22:30:34:38 +// 0x0085,9,walktoxy,6 +// 0x009b,13,changedir,5:12 +// 0x009f,10,takeitem,6 +// 0x00a7,17,useitem,6:13 +// 0x0113,19,useskilltoid,7:9:15 +// 0x0116,19,useskilltopos,7:9:15:17 +// 0x0190,99,useskilltopos,7:9:15:17:19 //2004-07-26kRO -packet_ver: 8 -0x0072,14,dropitem,5:12 -0x007e,33,wanttoconnection,12:18:24:28:32 -0x0085,20,useskilltoid,7:12:16 -0x0089,15,getcharnamerequest,11 -0x008c,23,useskilltopos,3:6:17:21 -0x0094,10,takeitem,6 -0x009b,6,walktoxy,3 -0x009f,13,changedir,5:12 -0x00a2,103,useskilltopos,3:6:17:21:23 -0x00a7,12,solvecharname,8 -0x00f3,-1,globalmessage,2:4 -0x00f5,17,useitem,6:12 -0x00f7,10,ticksend,6 -0x0113,16,movetokafra,5:12 -0x0116,2,closekafra,0 -0x0190,26,movefromkafra,10:22 -0x0193,9,actionrequest,3:8 +// packet_ver: 8 +// 0x0072,14,dropitem,5:12 +// 0x007e,33,wanttoconnection,12:18:24:28:32 +// 0x0085,20,useskilltoid,7:12:16 +// 0x0089,15,getcharnamerequest,11 +// 0x008c,23,useskilltopos,3:6:17:21 +// 0x0094,10,takeitem,6 +// 0x009b,6,walktoxy,3 +// 0x009f,13,changedir,5:12 +// 0x00a2,103,useskilltopos,3:6:17:21:23 +// 0x00a7,12,solvecharname,8 +// 0x00f3,-1,globalmessage,2:4 +// 0x00f5,17,useitem,6:12 +// 0x00f7,10,ticksend,6 +// 0x0113,16,movetokafra,5:12 +// 0x0116,2,closekafra,0 +// 0x0190,26,movefromkafra,10:22 +// 0x0193,9,actionrequest,3:8 //2004-08-09kRO -packet_ver: 9 -0x0072,17,dropitem,8:15 +// packet_ver: 9 +// 0x0072,17,dropitem,8:15 //9, +12, +7, +4, +4 -0x007e,37,wanttoconnection,9:21:28:32:36 -0x0085,26,useskilltoid,11:18:22 -0x0089,12,getcharnamerequest,8 -0x008c,40,useskilltopos,5:15:29:38 -0x0094,13,takeitem,9 -0x009b,15,walktoxy,12 -0x009f,12,changedir,7:11 -0x00a2,120,useskilltopos,5:15:29:38:40 -0x00a7,11,solvecharname,7 -0x00f5,24,useitem,9:20 -0x00f7,13,ticksend,9 -0x0113,23,movetokafra,5:19 -0x0190,26,movefromkafra,11:22 -0x0193,18,actionrequest,7:17 +// 0x007e,37,wanttoconnection,9:21:28:32:36 +// 0x0085,26,useskilltoid,11:18:22 +// 0x0089,12,getcharnamerequest,8 +// 0x008c,40,useskilltopos,5:15:29:38 +// 0x0094,13,takeitem,9 +// 0x009b,15,walktoxy,12 +// 0x009f,12,changedir,7:11 +// 0x00a2,120,useskilltopos,5:15:29:38:40 +// 0x00a7,11,solvecharname,7 +// 0x00f5,24,useitem,9:20 +// 0x00f7,13,ticksend,9 +// 0x0113,23,movetokafra,5:19 +// 0x0190,26,movefromkafra,11:22 +// 0x0193,18,actionrequest,7:17 //2004-08-16aSakexe -0x020f,0 -0x0210,0 -0x0211,0 -0x0212,26 -0x0213,26 -0x0214,42 +// 0x020f,0 +// 0x0210,0 +// 0x0211,0 +// 0x0212,26 +// 0x0213,26 +// 0x0214,42 //2004-08-17aSakexe -0x020f,10 -0x0210,22 +// 0x020f,10 +// 0x0210,22 //2004-09-06aSakexe -packet_ver: 10 +// packet_ver: 10 //0x0072,20,useitem,9:20 -0x007e,19,movetokafra,3:15 -0x0085,23,actionrequest,9:22 -0x0089,9,walktoxy,6 -0x008c,105,useskilltopos,10:14:18:23:25 -0x0094,17,dropitem,6:15 -0x009b,14,getcharnamerequest,10 -0x009f,-1,globalmessage,2:4 -0x00a2,14,solvecharname,10 -0x00a7,25,useskilltopos,10:14:18:23 -0x00f3,10,changedir,4:9 +// 0x007e,19,movetokafra,3:15 +// 0x0085,23,actionrequest,9:22 +// 0x0089,9,walktoxy,6 +// 0x008c,105,useskilltopos,10:14:18:23:25 +// 0x0094,17,dropitem,6:15 +// 0x009b,14,getcharnamerequest,10 +// 0x009f,-1,globalmessage,2:4 +// 0x00a2,14,solvecharname,10 +// 0x00a7,25,useskilltopos,10:14:18:23 +// 0x00f3,10,changedir,4:9 //7, +7, +10, +4, +6 -0x00f5,34,wanttoconnection,7:15:25:29:33 -0x00f7,2,closekafra,0 -0x0113,11,takeitem,7 -0x0116,11,ticksend,7 -0x0190,22,useskilltoid,9:15:18 -0x0193,17,movefromkafra,3:13 +// 0x00f5,34,wanttoconnection,7:15:25:29:33 +// 0x00f7,2,closekafra,0 +// 0x0113,11,takeitem,7 +// 0x0116,11,ticksend,7 +// 0x0190,22,useskilltoid,9:15:18 +// 0x0193,17,movefromkafra,3:13 //2004-09-21aSakexe by Sara -packet_ver: 11 -0x0072,18,useitem,10:14 -0x007e,25,movetokafra,6:21 -0x0085,9,actionrequest,3:8 -0x0089,14,walktoxy,11 -0x008c,109,useskilltopos,16:20:23:27:29 -0x0094,19,dropitem,12:17 -0x00a2,10,solvecharname,6 -0x00a7,29,useskilltopos,6:20:23:27 -0x00f3,18,changedir,8:17 -0x00f5,32,wanttoconnection,10:17:23:27:31 -0x009b,10,getcharnamerequest,6 -0x0113,14,takeitem,10 -0x0116,14,ticksend,10 -0x0190,14,useskilltoid,4:7:10 -0x0193,12,movefromkafra,4:8 +// packet_ver: 11 +// 0x0072,18,useitem,10:14 +// 0x007e,25,movetokafra,6:21 +// 0x0085,9,actionrequest,3:8 +// 0x0089,14,walktoxy,11 +// 0x008c,109,useskilltopos,16:20:23:27:29 +// 0x0094,19,dropitem,12:17 +// 0x00a2,10,solvecharname,6 +// 0x00a7,29,useskilltopos,6:20:23:27 +// 0x00f3,18,changedir,8:17 +// 0x00f5,32,wanttoconnection,10:17:23:27:31 +// 0x009b,10,getcharnamerequest,6 +// 0x0113,14,takeitem,10 +// 0x0116,14,ticksend,10 +// 0x0190,14,useskilltoid,4:7:10 +// 0x0193,12,movefromkafra,4:8 //2004-10-11aSakexe by Sara -packet_ver: 12 -0x0072,17,useitem,6:13 -0x007e,16,movetokafra,5:12 -0x0089,6,walktoxy,3 -0x008c,103,useskilltopos,2:6:17:21:23 -0x0094,14,dropitem,5:12 -0x009b,15,getcharnamerequest,11 -0x00a2,12,solvecharname,8 -0x00a7,23,useskilltopos,3:6:17:21 -0x00f3,13,changedir,5:12 -0x00f5,33,wanttoconnection,12:18:24:28:32 -0x0113,10,takeitem,6 -0x0116,10,ticksend,6 -0x0190,20,useskilltoid,7:12:16 -0x0193,26,movefromkafra,10:22 +// packet_ver: 12 +// 0x0072,17,useitem,6:13 +// 0x007e,16,movetokafra,5:12 +// 0x0089,6,walktoxy,3 +// 0x008c,103,useskilltopos,2:6:17:21:23 +// 0x0094,14,dropitem,5:12 +// 0x009b,15,getcharnamerequest,11 +// 0x00a2,12,solvecharname,8 +// 0x00a7,23,useskilltopos,3:6:17:21 +// 0x00f3,13,changedir,5:12 +// 0x00f5,33,wanttoconnection,12:18:24:28:32 +// 0x0113,10,takeitem,6 +// 0x0116,10,ticksend,6 +// 0x0190,20,useskilltoid,7:12:16 +// 0x0193,26,movefromkafra,10:22 //2004-10-25aSakexe by Sara -packet_ver: 13 -0x0072,13,useitem,5:9 -0x007e,13,movetokafra,6:9 -0x0085,15,actionrequest,4:14 -0x008c,108,useskilltopos,6:9:23:26:28 -0x0094,12,dropitem,6:10 -0x009b,10,getcharnamerequest,6 -0x00a2,16,solvecharname,12 -0x00a7,28,useskilltopos,6:9:23:26 -0x00f3,15,changedir,6:14 -0x00f5,29,wanttoconnection,5:14:20:24:28 -0x0113,9,takeitem,5 -0x0116,9,ticksend,5 -0x0190,26,useskilltoid,4:10:22 -0x0193,22,movefromkafra,12:18 +// packet_ver: 13 +// 0x0072,13,useitem,5:9 +// 0x007e,13,movetokafra,6:9 +// 0x0085,15,actionrequest,4:14 +// 0x008c,108,useskilltopos,6:9:23:26:28 +// 0x0094,12,dropitem,6:10 +// 0x009b,10,getcharnamerequest,6 +// 0x00a2,16,solvecharname,12 +// 0x00a7,28,useskilltopos,6:9:23:26 +// 0x00f3,15,changedir,6:14 +// 0x00f5,29,wanttoconnection,5:14:20:24:28 +// 0x0113,9,takeitem,5 +// 0x0116,9,ticksend,5 +// 0x0190,26,useskilltoid,4:10:22 +// 0x0193,22,movefromkafra,12:18 //2004-11-01aSakexe by Sara -packet_ver: 14 -0x0215,6 -0x0143,23,npcamountinput,2:6 -0x0145,19 +// packet_ver: 14 +// 0x0215,6 +// 0x0143,23,npcamountinput,2:6 +// 0x0145,19 //0x01f9,6,adopt,5 //2004-12-06aSakexe -packet_ver: 15 -0x0190,15,useitem,3:11 -0x0094,14,movetokafra,4:10 -0x009f,18,actionrequest,6:17 -0x00a7,7,walktoxy,4 -0x007e,30,useskilltopos,4:9:22:28 -0x0116,12,dropitem,4:10 -0x008c,13,getcharnamerequest,9 -0x0085,-1,globalmessage,2:4 -0x00f7,14,solvecharname,10 -0x0113,110,useskilltopos,4:9:22:28:30 -0x00f3,8,changedir,3:7 -0x00f5,29,wanttoconnection,3:10:20:24:28 -0x00a2,7,takeitem,3 -0x0089,7,ticksend,3 -0x0072,22,useskilltoid,8:12:18 -0x0193,21,movefromkafra,4:17 -0x009b,2,closekafra,0 -0x0222,6 -0x0221,-1 -0x021d,6 -0x0223,8 +// packet_ver: 15 +// 0x0190,15,useitem,3:11 +// 0x0094,14,movetokafra,4:10 +// 0x009f,18,actionrequest,6:17 +// 0x00a7,7,walktoxy,4 +// 0x007e,30,useskilltopos,4:9:22:28 +// 0x0116,12,dropitem,4:10 +// 0x008c,13,getcharnamerequest,9 +// 0x0085,-1,globalmessage,2:4 +// 0x00f7,14,solvecharname,10 +// 0x0113,110,useskilltopos,4:9:22:28:30 +// 0x00f3,8,changedir,3:7 +// 0x00f5,29,wanttoconnection,3:10:20:24:28 +// 0x00a2,7,takeitem,3 +// 0x0089,7,ticksend,3 +// 0x0072,22,useskilltoid,8:12:18 +// 0x0193,21,movefromkafra,4:17 +// 0x009b,2,closekafra,0 +// 0x0222,6 +// 0x0221,-1 +// 0x021d,6 +// 0x0223,8 //2005-01-10bSakexe by Sara -packet_ver: 16 +// packet_ver: 16 0x009b,32,wanttoconnection,3:12:23:27:31 0x0089,9,ticksend,5 0x00a7,13,walktoxy,10 @@ -631,5 +643,7 @@ packet_ver: 16 0x0072,26,useskilltoid,8:16:22 0x007e,114,useskilltopos,9:18:22:32:34 0x00a2,11,solvecharname,7 +0x0143,10,npcamountinput,2:6 -packet_ver: 17 \ No newline at end of file +// packet_ver: 17 +// Add new packets here \ No newline at end of file diff --git a/db/skill_cast_db.txt b/db/skill_cast_db.txt index af93d845d..774ca5aa0 100644 --- a/db/skill_cast_db.txt +++ b/db/skill_cast_db.txt @@ -32,7 +32,7 @@ 35,0,1000,0,0 //AL_CURE#キュアー# 45,0,0,60000:80000:100000:120000:140000:160000:180000:200000:220000:240000,0 //AC_CONCENTRATION#集中力向上# -46,0,1500,100,0 //AC_DOUBLE +46,0,-300,100,0 //AC_DOUBLE 47,0,1500,100,0 //AC_SHOWER 51,0,0,30000:60000:90000:120000:150000:180000:210000:240000:270000:300000,0 //TF_HIDING#ハイディング# diff --git a/npc/mobs/fields/yuno.txt b/npc/mobs/fields/yuno.txt index 7b0cbbb27..dd0f67335 100644 --- a/npc/mobs/fields/yuno.txt +++ b/npc/mobs/fields/yuno.txt @@ -3,58 +3,136 @@ //===== By: ================================================== //= Athena (1.0) //===== Current Version: ===================================== -//= 1.1 +//= 1.3 //===== Compatible With: ===================================== //= Any Athena Version //===== Additional Comments: ================================= //= 1.1 fixed tabs, names [Lupus] +//= 1.2 New/Better Spawn [Muad_Dib] +//= 1.3 Fix Up [Darkchild] //============================================================ -//(yuno_fild04.gat)* -yuno_fild04.gat,0,0,0,0 monster Goat 1372,40,0,0,0 -yuno_fild04.gat,0,0,0,0 monster Sleeper 1386,5,0,0,0 -yuno_fild04.gat,0,0,0,0 monster The Paper 1375,3,0,0,0 -yuno_fild04.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 -yuno_fild04.gat,0,0,0,0 monster Driller 1380,10,0,0,0 -yuno_fild04.gat,0,0,0,0 monster Poring 1002,20,0,0,0 +//======================================================================================== +// - Yuno Field 01 +//======================================================================================== + +yuno_fild01.gat,0,0,0,0 monster Poring 1002,55,0,0,0 +yuno_fild01.gat,0,0,0,0 monster Poporing 1031,35,0,0,0 +yuno_fild01.gat,0,0,0,0 monster Dustiness 1114,25,0,0,0 +yuno_fild01.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 +yuno_fild01.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 +yuno_fild01.gat,0,0,0,0 monster Shining Plant 1083,5,1800000,900000,1 +yuno_fild01.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 + +//======================================================================================== +// - Yuno Field 02 +//======================================================================================== + +yuno_fild02.gat,0,0,0,0 monster Sageworm 1281,5,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Dustiness 1114,15,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Kind of Beetle 1494,15,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Horn 1128,35,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Stainer 1174,25,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Wild Rose 1261,15,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 +yuno_fild02.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 +yuno_fild02.gat,0,0,0,0 monster Green Plant 1080,15,180000,90000,1 + +//======================================================================================== +// - Yuno Field 03 +//======================================================================================== + +yuno_fild03.gat,0,0,0,0 monster Drops 1113,30,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Poring 1002,40,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Sidewinder 1037,5,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Poporing 1031,20,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Marin 1242,20,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Geographer 1368,15,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Archangeling 1388,1,3600000,1800000,1 +yuno_fild03.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 +yuno_fild03.gat,0,0,0,0 monster Green Plant 1080,50,180000,90000,1 +yuno_fild03.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 + +//======================================================================================== +// - Yuno Field 04 +//======================================================================================== + +yuno_fild04.gat,0,0,0,0 monster Poring 1002,50,0,0,0 +yuno_fild04.gat,0,0,0,0 monster Pupa 1008,15,0,0,0 +yuno_fild04.gat,0,0,0,0 monster Drops 1113,30,0,0,0 +yuno_fild04.gat,0,0,0,0 monster Condor 1009,15,0,0,0 +yuno_fild04.gat,0,0,0,0 monster Creamy 1018,10,0,0,0 yuno_fild04.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 yuno_fild04.gat,0,0,0,0 monster Red Plant 1078,10,180000,90000,1 yuno_fild04.gat,0,0,0,0 monster Yellow Plant 1081,10,360000,180000,1 -yuno_fild04.gat,0,0,0,0 monster Harpy 1376,1,0,0,0 - -//(yuno_fild03.gat)* -yuno_fild03.gat,0,0,0,0 monster Goat 1372,60,0,0,0 -yuno_fild03.gat,0,0,0,0 monster Sleeper 1386,30,0,0,0 -yuno_fild03.gat,0,0,0,0 monster The Paper 1375,3,0,0,0 -yuno_fild03.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 -yuno_fild03.gat,0,0,0,0 monster Demon Pungus 1378,30,0,0,0 -yuno_fild03.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 -yuno_fild03.gat,0,0,0,0 monster Shining Plant 1083,2,1800000,900000,1 -yuno_fild03.gat,0,0,0,0 monster Blue Plant 1079,4,360000,180000,1 -yuno_fild03.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 -yuno_fild03.gat,0,0,0,0 monster Harpy 1376,2,0,0,0 - -//(yuno_fild02.gat)* -yuno_fild02.gat,0,0,0,0 monster Sleeper 1386,10,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Grand Peco 1369,70,0,0,0 -yuno_fild02.gat,0,0,0,0 monster The Paper 1375,1,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Driller 1380,30,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Dustiness 1114,20,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Poring 1002,20,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Red Plant 1078,20,180000,90000,1 -yuno_fild02.gat,0,0,0,0 monster Shining Plant 1083,1,1800000,900000,1 -yuno_fild02.gat,0,0,0,0 monster Blue Plant 1079,3,360000,180000,1 -yuno_fild02.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 -yuno_fild02.gat,0,0,0,0 monster Archangeling 1388,1,3600000,1800000,1 - -//(yuno_fild01.gat)* -yuno_fild01.gat,0,0,0,0 monster Grand Peco 1369,3,0,0,0 -yuno_fild01.gat,0,0,0,0 monster Dustiness 1114,50,0,0,0 -yuno_fild01.gat,0,0,0,0 monster Poporing 1031,20,0,0,0 -yuno_fild01.gat,0,0,0,0 monster Poring 1002,20,0,0,0 -yuno_fild01.gat,0,0,0,0 monster Green Plant 1080,20,180000,90000,1 -yuno_fild01.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 -yuno_fild01.gat,0,0,0,0 monster Shining Plant 1083,3,1800000,900000,1 -yuno_fild01.gat,0,0,0,0 monster Blue Plant 1079,2,360000,180000,1 -yuno_fild01.gat,0,0,0,0 monster Yellow Plant 1081,23,360000,180000,1 + +//======================================================================================== +// - Yuno Field 05 +//======================================================================================== + +yuno_fild05.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 +yuno_fild05.gat,0,0,0,0 monster Goat 1372,5,0,0,0 +yuno_fild05.gat,0,0,0,0 monster Demon Pungus 1378,20,0,0,0 +yuno_fild05.gat,0,0,0,0 monster Sleeper 1386,45,0,0,0 +yuno_fild05.gat,0,0,0,0 monster The Paper 1375,15,0,0,0 +yuno_fild05.gat,0,0,0,0 monster Green Plant 1080,5,180000,90000,1 +yuno_fild05.gat,0,0,0,0 monster Yellow Plant 1081,10,360000,180000,1 +yuno_fild05.gat,0,0,0,0 monster Red Plant 1078,5,180000,90000,1 + +//======================================================================================== +// - Yuno Field 07 +//======================================================================================== + +yuno_fild07.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 +yuno_fild07.gat,0,0,0,0 monster Goat 1372,60,0,0,0 +yuno_fild07.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 +yuno_fild07.gat,0,0,0,0 monster Red Plant 1078,10,180000,90000,1 +yuno_fild07.gat,0,0,0,0 monster Yellow Plant 1081,15,360000,180000,1 + +//======================================================================================== +// - Yuno Field 08 +//======================================================================================== + +yuno_fild08.gat,0,0,0,0 monster Grand Peco 1369,20,0,0,0 +yuno_fild08.gat,0,0,0,0 monster Dustiness 1114,30,0,0,0 +yuno_fild08.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 +yuno_fild08.gat,0,0,0,0 monster Wild Rose 1261,15,0,0,0 +yuno_fild08.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 +yuno_fild08.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 +yuno_fild08.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 + +//======================================================================================== +// - Yuno Field 09 +//======================================================================================== + +yuno_fild09.gat,0,0,0,0 monster Gargoyle 1253,10,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Dustiness 1114,20,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1122,10,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1123,5,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1124,10,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1125,5,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1126,5,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Horn 1128,25,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Red Plant 1078,10,180000,90000,1 +yuno_fild09.gat,0,0,0,0 monster Yellow Plant 1081,15,360000,180000,1 +yuno_fild09.gat,0,0,0,0 monster Green Plant 1080,15,180000,90000,1 + +//======================================================================================== +// - Yuno Field 11 +//======================================================================================== + +yuno_fild11.gat,0,0,0,0 monster Sleeper 1386,55,0,0,0 +yuno_fild11.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 +yuno_fild11.gat,0,0,0,0 monster Red Plant 1078,10,180000,90000,1 +yuno_fild11.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 +yuno_fild11.gat,0,0,0,0 monster Yellow Plant 1081,15,360000,180000,1 + +//======================================================================================== +// - Yuno Field 12 +//======================================================================================== + +yuno_fild12.gat,0,0,0,0 monster Dustiness 1114,35,0,0,0 +yuno_fild12.gat,0,0,0,0 monster Demon Pungus 1378,20,0,0,0 +yuno_fild12.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 +yuno_fild12.gat,0,0,0,0 monster Red Plant 1078,5,180000,90000,1 +yuno_fild12.gat,0,0,0,0 monster Yellow Plant 1081,10,360000,180000,1 diff --git a/sql-files/database.sql b/sql-files/database.sql index 9700ddb3a..1c379859f 100644 --- a/sql-files/database.sql +++ b/sql-files/database.sql @@ -1,6 +1,3 @@ -DROP DATABASE erag; -CREATE DATABASE erag; -USE erag; CREATE TABLE `item_db` ( `id` smallint(5) unsigned NOT NULL default '0', `name_english` varchar(24) NOT NULL default '', diff --git a/sql-files/mail.sql b/sql-files/mail.sql index 201142d59..62cc9d65d 100644 --- a/sql-files/mail.sql +++ b/sql-files/mail.sql @@ -1,5 +1,3 @@ -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `ragnarok`; -USE `ragnarok`; CREATE TABLE `mail` ( `message_id` int(11) NOT NULL auto_increment, `to_account_id` int(11) NOT NULL default '0', diff --git a/src/char/char.c b/src/char/char.c index 6aaae27b0..56d070e5d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -166,7 +166,7 @@ int char_log(char *fmt, ...) { //----------------------------------------------------- // Function to suppress control characters in a string. //----------------------------------------------------- -int remove_control_chars(unsigned char *str) { +int remove_control_chars(char *str) { int i; int change = 0; @@ -244,7 +244,7 @@ int mmo_friends_list_data_str(char *str, struct mmo_charstatus *p) { int i; char *str_p = str; str_p += sprintf(str_p, "%d", p->char_id); - + for (i=0;i<20;i++) { str_p += sprintf(str_p, ",%d,%s", p->friend_id[i],p->friend_name[i]); @@ -575,16 +575,16 @@ int parse_friend_txt(struct mmo_charstatus *p) char line[1024]; int i,cid=0,temp[20]; FILE *fp; - + // Open the file and look for the ID fp = fopen(friends_txt, "r"); if(fp == NULL) return 1; - + while(fgets(line, sizeof(line)-1, fp)) { - + if(line[0] == '/' && line[1] == '/') continue; @@ -612,7 +612,7 @@ int parse_friend_txt(struct mmo_charstatus *p) if (cid == p->char_id) break; } - + // No register of friends list if (cid == 0) { fclose(fp); @@ -638,12 +638,12 @@ int mmo_char_init(void) { FILE *fp; char_max = 256; - char_dat = calloc(sizeof(struct mmo_charstatus) * 256, 1); + char_dat = (struct mmo_charstatus*)aCalloc(sizeof(struct mmo_charstatus) * 256, 1); if (!char_dat) { printf("out of memory: mmo_char_init (calloc of char_dat).\n"); exit(1); } - online_chars = calloc(sizeof(struct online_chars) * 256, 1); + online_chars = (struct online_chars*)aCalloc(sizeof(struct online_chars) * 256, 1); if (!online_chars) { printf("out of memory: mmo_char_init (calloc of online_chars).\n"); exit(1); @@ -683,13 +683,13 @@ int mmo_char_init(void) { if (char_num >= char_max) { char_max += 256; - char_dat = realloc(char_dat, sizeof(struct mmo_charstatus) * char_max); + char_dat = (struct mmo_charstatus*)aRealloc(char_dat, sizeof(struct mmo_charstatus) * char_max); if (!char_dat) { printf("Out of memory: mmo_char_init (realloc of char_dat).\n"); char_log("Out of memory: mmo_char_init (realloc of char_dat)." RETCODE); exit(1); } - online_chars = realloc(online_chars, sizeof(struct online_chars) * char_max); + online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * char_max); if (!online_chars) { printf("Out of memory: mmo_char_init (realloc of online_chars).\n"); char_log("Out of memory: mmo_char_init (realloc of online_chars)." RETCODE); @@ -703,10 +703,10 @@ int mmo_char_init(void) { } ret = mmo_char_fromstr(line, &char_dat[char_num]); - + // Initialize friends list parse_friend_txt(&char_dat[char_num]); // Grab friends for the character - + if (ret > 0) { // negative value or zero for errors if (char_dat[char_num].char_id >= char_id_count) char_id_count = char_dat[char_num].char_id + 1; @@ -769,7 +769,7 @@ void mmo_char_sync(void) { int i, j, k; int lock; FILE *fp,*f_fp; - int id[char_num]; + int *id = (int *) aMalloc(sizeof(int) * char_num); // Sorting before save (by [Yor]) for(i = 0; i < char_num; i++) { @@ -825,9 +825,11 @@ void mmo_char_sync(void) { mmo_friends_list_data_str(f_line, &char_dat[id[i]]); fprintf(f_fp, "%s" RETCODE, f_line); } - + lock_fclose(f_fp, friends_txt, &lock); - + + aFree(id); + return; } @@ -847,7 +849,7 @@ int make_new_char(int fd, unsigned char *dat) { int i, j; struct char_session_data *sd; - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; // remove control characters from the name dat[23] = '\0'; @@ -921,13 +923,13 @@ int make_new_char(int fd, unsigned char *dat) { if (char_num >= char_max) { char_max += 256; - char_dat = realloc(char_dat, sizeof(struct mmo_charstatus) * char_max); + char_dat = (struct mmo_charstatus*)aRealloc(char_dat, sizeof(struct mmo_charstatus) * char_max); if (!char_dat) { printf("Out of memory: make_new_char (realloc of char_dat).\n"); char_log("Out of memory: make_new_char (realloc of char_dat)." RETCODE); exit(1); } - online_chars = realloc(online_chars, sizeof(struct online_chars) * char_max); + online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * char_max); if (!online_chars) { printf("Out of memory: make_new_char (realloc of online_chars).\n"); char_log("Out of memory: make_new_char (realloc of online_chars)." RETCODE); @@ -998,8 +1000,8 @@ int make_new_char(int fd, unsigned char *dat) { //---------------------------------------------------- // This function return the name of the job (by [Yor]) //---------------------------------------------------- -char * job_name(int class) { - switch (class) { +char * job_name(int class_) { + switch (class_) { case 0: return "Novice"; case 1: return "Swordsman"; case 2: return "Mage"; @@ -1550,7 +1552,7 @@ int disconnect_player(int accound_id) { // disconnect player if online on char-server for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == accound_id) { session[i]->eof = 1; return 1; @@ -1612,7 +1614,7 @@ int parse_tologin(int fd) { return 0; } - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; while(RFIFOREST(fd) >= 2) { // printf("parse_tologin: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd)); @@ -1645,7 +1647,7 @@ int parse_tologin(int fd) { return 0; // printf("parse_tologin 2713 : %d\n", RFIFOB(fd,6)); for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) { if (RFIFOB(fd,6) != 0) { WFIFOW(i,0) = 0x6c; WFIFOB(i,2) = 0x42; @@ -1683,7 +1685,7 @@ int parse_tologin(int fd) { if (RFIFOREST(fd) < 50) return 0; for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == RFIFOL(fd,2)) { memcpy(sd->email, RFIFOP(fd,6), 40); if (e_mail_check(sd->email) == 0) @@ -1891,7 +1893,7 @@ int parse_tologin(int fd) { int j, k; struct char_session_data *sd2; for (j = 0; j < fd_max; j++) { - if (session[j] && (sd2 = session[j]->session_data) && + if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) && sd2->account_id == char_dat[char_num-1].account_id) { for (k = 0; k < 9; k++) { if (sd2->found_char[k] == char_num-1) { @@ -1946,8 +1948,8 @@ int parse_tologin(int fd) { { char buf[32000]; if (gm_account != NULL) - free(gm_account); - gm_account = calloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); + aFree(gm_account); + gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); GM_num = 0; for (i = 4; i < RFIFOW(fd,2); i = i + 5) { gm_account[GM_num].account_id = RFIFOL(fd,i); @@ -2158,7 +2160,7 @@ int parse_frommap(int fd) { if (j == online_players_max) { // create 256 new slots online_players_max += 256; - online_chars = realloc(online_chars, sizeof(struct online_chars) * online_players_max); + online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * online_players_max); if (!online_chars) { printf("out of memory: parse_frommap - online_chars (realloc).\n"); exit(1); @@ -2515,7 +2517,7 @@ int parse_char(int fd) { return 0; } - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; while (RFIFOREST(fd) >= 2) { cmd = RFIFOW(fd,0); @@ -2539,7 +2541,7 @@ int parse_char(int fd) { // if (sd == NULL && cmd != 0x65 && cmd != 0x20b && cmd != 0x187 && // cmd != 0x2af8 && cmd != 0x7530 && cmd != 0x7532) // cmd = 0xffff; // パケットダンプを表示させる - + switch(cmd){ case 0x20b: //20040622暗号化ragexe対応 if (RFIFOREST(fd) < 19) @@ -2557,7 +2559,7 @@ int parse_char(int fd) { else printf("Account Logged On; Account ID: %d.\n", RFIFOL(fd,2)); if (sd == NULL) { - sd = session[fd]->session_data = calloc(sizeof(struct char_session_data), 1); + sd = session[fd]->session_data = (struct char_session_data*)aCalloc(sizeof(struct char_session_data), 1); memset(sd, 0, sizeof(struct char_session_data)); memcpy(sd->email, "no mail", 40); // put here a mail without '@' to refuse deletion if we don't receive the e-mail sd->connect_until_time = 0; // unknow or illimited (not displaying on map-server) @@ -2837,7 +2839,7 @@ int parse_char(int fd) { int j, k; struct char_session_data *sd2; for (j = 0; j < fd_max; j++) { - if (session[j] && (sd2 = session[j]->session_data) && + if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) && sd2->account_id == char_dat[char_num-1].account_id) { for (k = 0; k < 9; k++) { if (sd2->found_char[k] == char_num-1) { @@ -2947,29 +2949,29 @@ int parse_char(int fd) { // Console Command Parser [Wizputer] int parse_console(char *buf) { char *type,*command; - - type = (char *)malloc(64); - command = (char *)malloc(64); - + + type = (char *)aMalloc(64); + command = (char *)aMalloc(64); + memset(type,0,64); memset(command,0,64); - + printf("Console: %s\n",buf); - + if ( sscanf(buf, "%[^:]:%[^\n]", type , command ) < 2 ) sscanf(buf,"%[^\n]",type); - + printf("Type of command: %s || Command: %s \n",type,command); - - if(buf) free(buf); - if(type) free(type); - if(command) free(command); - + + if(buf) aFree(buf); + if(type) aFree(type); + if(command) aFree(command); + return 0; } // 全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) -int mapif_sendall(unsigned char *buf, unsigned int len) { +int mapif_sendall(char *buf, unsigned int len) { int i, c; c = 0; @@ -2985,7 +2987,7 @@ int mapif_sendall(unsigned char *buf, unsigned int len) { } // 自分以外の全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) -int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { +int mapif_sendallwos(int sfd, char *buf, unsigned int len) { int i, c; c = 0; @@ -3000,7 +3002,7 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { return c; } // MAPサーバーにデータ送信(map鯖生存確認有り) -int mapif_send(int fd, unsigned char *buf, unsigned int len) { +int mapif_send(int fd, char *buf, unsigned int len) { int i; if (fd >= 0) { @@ -3349,19 +3351,19 @@ void do_final(void) { } create_online_files(); - if(online_chars) free(online_chars); + if(online_chars) aFree(online_chars); mmo_char_sync(); inter_save(); - if(gm_account) free(gm_account); - if(char_dat) free(char_dat); + if(gm_account) aFree(gm_account); + if(char_dat) aFree(char_dat); delete_session(login_fd); delete_session(char_fd); for(i = 0; i < fd_max; i++) - if(session[i] != NULL) free(session[i]); + if(session[i] != NULL) aFree(session[i]); char_log("----End of char-server (normal end with closing of all files)." RETCODE); } @@ -3377,14 +3379,14 @@ int do_init(int argc, char **argv) { // moved behind char_config_read in case we changed the filename [celest] char_log("The char-server starting..." RETCODE); - if ((naddr_ != 0) && (login_ip_set_ == 0 || char_ip_set_ == 0)) { + if ((naddr_ != 0) && (login_ip_set_ == 0 || char_ip_set_ == 0)) { // The char server should know what IP address it is running on // - MouseJstr int localaddr = ntohl(addr_[0]); unsigned char *ptr = (unsigned char *) &localaddr; char buf[16]; sprintf(buf, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);; - if (naddr_ != 1) + if (naddr_ != 1) printf("Multiple interfaces detected.. using %s as our IP address\n", buf); else printf("Defaulting to %s as our IP address\n", buf); @@ -3393,9 +3395,9 @@ int do_init(int argc, char **argv) { if (char_ip_set_ == 0) strcpy(char_ip_str, buf); - if (ptr[0] == 192 && ptr[1] == 168) + if (ptr[0] == 192 && ptr[1] == 168) printf("Firewall detected.. edit lan_support.conf and char_athena.conf\n"); - } + } login_ip = inet_addr(login_ip_str); char_ip = inet_addr(char_ip_str); @@ -3406,7 +3408,7 @@ int do_init(int argc, char **argv) { } online_players_max = 256; - online_chars = calloc(sizeof(struct online_chars) * 256, 1); + online_chars = (struct online_chars*)aCalloc(sizeof(struct online_chars) * 256, 1); if (!online_chars) { printf("out of memory: do_init (calloc).\n"); exit(1); @@ -3432,7 +3434,7 @@ int do_init(int argc, char **argv) { add_timer_func_list(check_connect_login_server, "check_connect_login_server"); add_timer_func_list(send_users_tologin, "send_users_tologin"); add_timer_func_list(mmo_char_sync_timer, "mmo_char_sync_timer"); - + i = add_timer_interval(gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000); i = add_timer_interval(gettick() + 1000, send_users_tologin, 0, 0, 5 * 1000); i = add_timer_interval(gettick() + autosave_interval, mmo_char_sync_timer, 0, 0, autosave_interval); @@ -3446,12 +3448,12 @@ int do_init(int argc, char **argv) { add_timer_interval(gettick()+10, flush_timer,0,0,flush_time); - + if(anti_freeze_enable > 0) { add_timer_func_list(map_anti_freeze_system, "map_anti_freeze_system"); i = add_timer_interval(gettick() + 1000, map_anti_freeze_system, 0, 0, ANTI_FREEZE_INTERVAL * 1000); // checks every X seconds user specifies } - + if(console) { set_defaultconsoleparse(parse_console); start_console(); diff --git a/src/char/char.h b/src/char/char.h index 3ee2f9f6d..c70facba1 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -20,9 +20,9 @@ struct mmo_map_server{ int search_character_index(char* character_name); char * search_character_name(int index); -int mapif_sendall(unsigned char *buf, unsigned int len); -int mapif_sendallwos(int fd,unsigned char *buf, unsigned int len); -int mapif_send(int fd,unsigned char *buf, unsigned int len); +int mapif_sendall(char *buf, unsigned int len); +int mapif_sendallwos(int fd,char *buf, unsigned int len); +int mapif_send(int fd,char *buf, unsigned int len); int char_log(char *fmt, ...); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 0ee4476fc..348008e1d 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -398,7 +398,7 @@ int inter_guild_init() { continue; } - g = calloc(sizeof(struct guild), 1); + g = aCalloc(sizeof(struct guild), 1); if(g == NULL){ printf("int_guild: out of memory!\n"); exit(0); @@ -412,7 +412,7 @@ int inter_guild_init() { guild_calcinfo(g); } else { printf("int_guild: broken data [%s] line %d\n", guild_txt, c); - free(g); + aFree(g); } c++; } @@ -426,7 +426,7 @@ int inter_guild_init() { } while(fgets(line, sizeof(line)-1, fp)) { - gc = calloc(sizeof(struct guild_castle), 1); + gc = aCalloc(sizeof(struct guild_castle), 1); if(gc == NULL){ printf("int_guild: out of memory!\n"); exit(0); @@ -436,7 +436,7 @@ int inter_guild_init() { numdb_insert(castle_db, gc->castle_id, gc); } else { printf("int_guild: broken data [%s] line %d\n", castle_txt, c); - free(gc); + aFree(gc); } c++; } @@ -445,7 +445,7 @@ int inter_guild_init() { printf(" %s - making Default Data...\n", castle_txt); //デフォルトデータを作成 for(i = 0; i < MAX_GUILDCASTLE; i++) { - gc = calloc(sizeof(struct guild_castle), 1); + gc = aCalloc(sizeof(struct guild_castle), 1); if (gc == NULL) { printf("int_guild: out of memory!\n"); exit(0); @@ -577,7 +577,7 @@ int guild_check_empty(struct guild *g) { numdb_erase(guild_db, g->guild_id); inter_guild_storage_delete(g->guild_id); mapif_guild_broken(g->guild_id, 0); - free(g); + aFree(g); return 1; } @@ -765,7 +765,7 @@ int mapif_guild_memberinfoshort(struct guild *g, int idx) { WBUFL(buf, 2) = g->guild_id; WBUFL(buf, 6) = g->member[idx].account_id; WBUFL(buf,10) = g->member[idx].char_id; - WBUFB(buf,14) = g->member[idx].online; + WBUFB(buf,14) = (unsigned char)g->member[idx].online; WBUFW(buf,15) = g->member[idx].lv; WBUFW(buf,17) = g->member[idx].class_; mapif_sendall(buf, 19); @@ -965,7 +965,7 @@ int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_mem mapif_guild_created(fd, account_id, NULL); return 0; } - g = calloc(sizeof(struct guild), 1); + g = aCalloc(sizeof(struct guild), 1); if (g == NULL) { printf("int_guild: CreateGuild: out of memory !\n"); mapif_guild_created(fd, account_id, NULL); @@ -1085,7 +1085,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in } // オンライン/Lv更新 -int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class) { +int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class_) { struct guild *g; int i, alv, c; @@ -1101,7 +1101,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, if (g->member[i].account_id == account_id && g->member[i].char_id == char_id) { g->member[i].online = online; g->member[i].lv = lv; - g->member[i].class_ = class; + g->member[i].class_ = class_; mapif_guild_memberinfoshort(g, i); } if (g->member[i].account_id > 0) { @@ -1111,7 +1111,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, if (g->member[i].online) g->connect_member++; } - + if (c) // 平均レベル g->average_lv = alv / c; @@ -1147,7 +1147,7 @@ int mapif_parse_BreakGuild(int fd, int guild_id) { if(log_inter) inter_log("guild %s (id=%d) broken" RETCODE, g->name, guild_id); - free(g); + aFree(g); return 0; } diff --git a/src/char/int_party.c b/src/char/int_party.c index 194e96707..6b7f4361e 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -94,7 +94,7 @@ int inter_party_init() { continue; } - p = calloc(sizeof(struct party), 1); + p = aCalloc(sizeof(struct party), 1); if (p == NULL){ printf("int_party: out of memory!\n"); exit(0); @@ -107,7 +107,7 @@ int inter_party_init() { party_check_empty(p); } else { printf("int_party: broken data [%s] line %d\n", party_txt, c + 1); - free(p); + aFree(p); } c++; } @@ -199,7 +199,7 @@ int party_check_empty(struct party *p) { // 誰もいないので解散 mapif_party_broken(p->party_id, 0); numdb_erase(party_db, p->party_id); - free(p); + aFree(p); return 1; } @@ -391,7 +391,7 @@ int mapif_parse_CreateParty(int fd, int account_id, char *name, char *nick, char mapif_party_created(fd, account_id, NULL); return 0; } - p = calloc(sizeof(struct party), 1); + p = aCalloc(sizeof(struct party), 1); if (p == NULL) { printf("int_party: out of memory !\n"); mapif_party_created(fd,account_id,NULL); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index c08c4ccf3..0dd334514 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -88,7 +88,7 @@ int inter_pet_init() if( (fp=fopen(pet_txt,"r"))==NULL ) return 1; while(fgets(line,sizeof(line),fp)){ - p=calloc(sizeof(struct s_pet), 1); + p=aCalloc(sizeof(struct s_pet), 1); if(p==NULL){ printf("int_pet: out of memory!\n"); exit(0); @@ -100,7 +100,7 @@ int inter_pet_init() numdb_insert(pet_db,p->pet_id,p); }else{ printf("int_pet: broken data [%s] line %d\n",pet_txt,c); - free(p); + aFree(p); } c++; } @@ -210,7 +210,7 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name) { struct s_pet *p; - p=malloc(sizeof(struct s_pet)); + p=aMalloc(sizeof(struct s_pet)); if(p==NULL){ printf("int_pet: out of memory !\n"); mapif_pet_created(fd,account_id,NULL); @@ -282,7 +282,7 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data) pet_id = data->pet_id; p=numdb_search(pet_db,pet_id); if(p == NULL) { - p=malloc(sizeof(struct s_pet)); + p=aMalloc(sizeof(struct s_pet)); if(p==NULL){ printf("int_pet: out of memory !\n"); mapif_save_pet_ack(fd,account_id,1); diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 7a4022a55..73d50f323 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -192,7 +192,7 @@ struct storage *account2storage(int account_id) struct storage *s; s=numdb_search(storage_db,account_id); if(s == NULL) { - s = calloc(sizeof(struct storage), 1); + s = aCalloc(sizeof(struct storage), 1); if(s==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -210,7 +210,7 @@ struct guild_storage *guild2storage(int guild_id) if(inter_guild_search(guild_id) != NULL) { gs=numdb_search(guild_storage_db,guild_id); if(gs == NULL) { - gs = calloc(sizeof(struct guild_storage), 1); + gs = aCalloc(sizeof(struct guild_storage), 1); if(gs==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -242,7 +242,7 @@ int inter_storage_init() } while(fgets(line,65535,fp)){ sscanf(line,"%d",&tmp_int); - s=calloc(sizeof(struct storage), 1); + s=aCalloc(sizeof(struct storage), 1); if(s==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -254,7 +254,7 @@ int inter_storage_init() } else{ printf("int_storage: broken data [%s] line %d\n",storage_txt,c); - free(s); + aFree(s); } c++; } @@ -270,7 +270,7 @@ int inter_storage_init() } while(fgets(line,65535,fp)){ sscanf(line,"%d",&tmp_int); - gs=calloc(sizeof(struct guild_storage), 1); + gs=aCalloc(sizeof(struct guild_storage), 1); if(gs==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -282,7 +282,7 @@ int inter_storage_init() } else{ printf("int_storage: broken data [%s] line %d\n",guild_storage_txt,c); - free(gs); + aFree(gs); } c++; } @@ -356,7 +356,7 @@ int inter_storage_delete(int account_id) inter_pet_delete(*((long *)(&s->storage[i].card[2]))); } numdb_erase(storage_db,account_id); - free(s); + aFree(s); } return 0; } @@ -372,7 +372,7 @@ int inter_guild_storage_delete(int guild_id) inter_pet_delete(*((long *)(&gs->storage[i].card[2]))); } numdb_erase(guild_storage_db,guild_id); - free(gs); + aFree(gs); } return 0; } diff --git a/src/char/inter.c b/src/char/inter.c index a6e2a4199..f0fe38f60 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -114,7 +114,7 @@ int inter_accreg_init() { while(fgets(line, sizeof(line)-1, fp)){ line[sizeof(line)-1] = '\0'; - reg = calloc(sizeof(struct accreg), 1); + reg = aCalloc(sizeof(struct accreg), 1); if (reg == NULL) { printf("inter: accreg: out of memory!\n"); exit(0); @@ -123,7 +123,7 @@ int inter_accreg_init() { numdb_insert(accreg_db, reg->account_id, reg); } else { printf("inter: accreg: broken data [%s] line %d\n", accreg_txt, c); - free(reg); + aFree(reg); } c++; } @@ -371,7 +371,7 @@ int check_ttl_wisdata() { // removed. not send information after a timeout. Just no answer for the player //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target numdb_erase(wis_db, wd->id); - free(wd); + aFree(wd); } } while(wis_delnum >= WISDELLIST_MAX); @@ -423,7 +423,7 @@ int mapif_parse_WisRequest(int fd) { mapif_send(fd, buf, 27); } else { - wd = (struct WisData *)calloc(sizeof(struct WisData), 1); + wd = (struct WisData *)aCalloc(sizeof(struct WisData), 1); if (wd == NULL){ printf("inter: WisRequest: out of memory !\n"); return 0; @@ -458,7 +458,7 @@ int mapif_parse_WisReply(int fd) { if ((--wd->count) <= 0 || flag != 1) { mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target numdb_erase(wis_db, id); - free(wd); + aFree(wd); } return 0; @@ -481,7 +481,7 @@ int mapif_parse_AccReg(int fd) { struct accreg *reg = numdb_search(accreg_db, RFIFOL(fd,4)); if (reg == NULL) { - if ((reg = calloc(sizeof(struct accreg), 1)) == NULL) { + if ((reg = aCalloc(sizeof(struct accreg), 1)) == NULL) { printf("inter: accreg: out of memory !\n"); exit(0); } diff --git a/src/char_sql/char.c b/src/char_sql/char.c index d7f17515b..876ea991d 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -73,7 +73,7 @@ char login_db_level[32] = "level"; int lowest_gm_level = 1; -unsigned char *SQL_CONF_NAME = "conf/inter_athena.conf"; +char *SQL_CONF_NAME = "conf/inter_athena.conf"; struct mmo_map_server server[MAX_MAP_SERVERS]; int server_fd[MAX_MAP_SERVERS]; @@ -206,9 +206,9 @@ void set_char_offline(int char_id, int account_id) { if ( char_id == 99 ) sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id); else { - cp = numdb_search(char_db_,char_id); + cp = (struct mmo_charstatus*)numdb_search(char_db_,char_id); if (cp != NULL) { - free(cp); + aFree(cp); numdb_erase(char_db_,char_id); } @@ -229,7 +229,7 @@ void set_char_offline(int char_id, int account_id) { //----------------------------------------------------- // Function to suppress control characters in a string. //----------------------------------------------------- -int remove_control_chars(unsigned char *str) { +int remove_control_chars(char *str) { int i; int change = 0; @@ -259,7 +259,7 @@ int isGM(int account_id) { void read_gm_account(void) { if (gm_account != NULL) - free(gm_account); + aFree(gm_account); GM_num = 0; sprintf(tmp_lsql, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`>='%d'",login_db_account_id,login_db_level,login_db,login_db_level,lowest_gm_level); @@ -268,7 +268,7 @@ void read_gm_account(void) { } lsql_res = mysql_store_result(&lmysql_handle); if (lsql_res) { - gm_account = aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); + gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); while ((lsql_row = mysql_fetch_row(lsql_res))) { gm_account[GM_num].account_id = atoi(lsql_row[0]); gm_account[GM_num].level = atoi(lsql_row[1]); @@ -329,7 +329,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if (char_id!=p->char_id) return 0; - cp = numdb_search(char_db_,char_id); + cp = (struct mmo_charstatus*)numdb_search(char_db_,char_id); if (cp == NULL) { cp = (struct mmo_charstatus *) aMalloc(sizeof(struct mmo_charstatus)); @@ -441,7 +441,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ //===================================================================================================== - if ((p->base_exp != cp->base_exp) || (p->class_ != cp->class_) || + if ((p->base_exp != cp->base_exp) || (p->class_ != cp->class_) || (p->base_level != cp->base_level) || (p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) || (p->zeny != cp->zeny) || (p->last_point.x != cp->last_point.x) || (p->last_point.y != cp->last_point.y) || @@ -457,7 +457,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ (p->shield != cp->shield) || (p->head_top != cp->head_top) || (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->partner_id != cp->partner_id)) { - + //}//---------------------------test count------------------------------ //check party_exist party_exist=0; @@ -546,7 +546,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ diff = 0; for(i=0;iskill[i].lv != 0) && (p->skill[i].id == 0)) + if ((p->skill[i].lv != 0) && (p->skill[i].id == 0)) p->skill[i].id = i; // Fix skill tree if((p->skill[i].id != cp->skill[i].id) || (p->skill[i].lv != cp->skill[i].lv) || @@ -589,7 +589,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ break; } } - + if (diff) { //printf("- Save global_reg_value data to MySQL!\n"); //`global_reg_value` (`char_id`, `str`, `value`) @@ -603,7 +603,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if (p->global_reg[i].str) { if(p->global_reg[i].value !=0){ sprintf(tmp_sql,"INSERT INTO `%s` (`char_id`, `str`, `value`) VALUES ('%d', '%s','%d')", - reg_db, char_id, jstrescapecpy(temp_str,(unsigned char*)p->global_reg[i].str), p->global_reg[i].value); + reg_db, char_id, jstrescapecpy(temp_str,p->global_reg[i].str), p->global_reg[i].value); if(mysql_query(&mysql_handle, tmp_sql)) { printf("DB server Error (insert `global_reg_value`)- %s\n", mysql_error(&mysql_handle)); } @@ -612,9 +612,9 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } - // Friends list + // Friends list // account_id, friend_id0, name0, ... - + tmp_p += sprintf(tmp_p, "REPLACE INTO `%s` (`id`, `account_id`",friend_db); diff = 0; @@ -623,7 +623,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ tmp_p += sprintf(tmp_p, ", `friend_id%d`, `name%d`", i, i); tmp_p += sprintf(tmp_p, ") VALUES (NULL, '%d'", char_id); - + for (i=0;i<20;i++) { tmp_p += sprintf(tmp_p, ", '%d', '%s'", p->friend_id[i], p->friend_name[i]); if ((p->friend_id[i] != cp->friend_id[i]) || @@ -633,7 +633,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ tmp_p += sprintf(tmp_p, ")"); - if (diff) + if (diff) mysql_query(&mysql_handle, tmp_sql); printf("saving char is done.\n"); @@ -882,9 +882,9 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ char *tmp_p = tmp_sql; struct mmo_charstatus *cp; - cp = numdb_search(char_db_,char_id); + cp = (struct mmo_charstatus*)numdb_search(char_db_,char_id); if (cp != NULL) - free(cp); + aFree(cp); memset(p, 0, sizeof(struct mmo_charstatus)); @@ -966,10 +966,10 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ } else printf("char2 - failed\n"); //Error?! ERRRRRR WHAT THAT SAY!? - if (p->last_point.x == 0 || p->last_point.y == 0 || p->last_point.map[0] == '\0') + if (p->last_point.x == 0 || p->last_point.y == 0 || p->last_point.map[0] == '\0') memcpy(&p->last_point, &start_point, sizeof(start_point)); - if (p->save_point.x == 0 || p->save_point.y == 0 || p->save_point.map[0] == '\0') + if (p->save_point.x == 0 || p->save_point.y == 0 || p->save_point.map[0] == '\0') memcpy(&p->save_point, &start_point, sizeof(start_point)); printf("char2 "); @@ -1102,10 +1102,10 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ sql_row = mysql_fetch_row(sql_res); i=mysql_num_rows(sql_res); - + // debugg //printf("mysql: %d\n",i); - + // Create an entry for the character if it doesnt already have one if(!i) { @@ -1188,15 +1188,15 @@ int mmo_char_sql_init(void) { printf("set char_id_count: %d.......\n",char_id_count); sprintf(tmp_sql , "REPLACE INTO `%s` SET `online`=0", char_db); - if (mysql_query(&mysql_handle, tmp_sql)) + if (mysql_query(&mysql_handle, tmp_sql)) printf("DB server Error - %s\n", mysql_error(&mysql_handle)); sprintf(tmp_sql , "REPLACE INTO `%s` SET `online`=0", guild_member_db); - if (mysql_query(&mysql_handle, tmp_sql)) + if (mysql_query(&mysql_handle, tmp_sql)) printf("DB server Error - %s\n", mysql_error(&mysql_handle)); sprintf(tmp_sql , "REPLACE INTO `%s` SET `connect_member`=0", guild_db); - if (mysql_query(&mysql_handle, tmp_sql)) + if (mysql_query(&mysql_handle, tmp_sql)) printf("DB server Error - %s\n", mysql_error(&mysql_handle)); printf("init end.......\n"); @@ -1212,10 +1212,10 @@ int make_new_char_sql(int fd, unsigned char *dat) { int i; //aphostropy error check! - fixed! - jstrescapecpy(t_name, dat); + jstrescapecpy(t_name, (char*)dat); printf("making new char -"); - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; // Check Authorised letters/symbols in the name of the character if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised @@ -1477,7 +1477,7 @@ int parse_tologin(int fd) { return 0; } - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; // hehe. no need to set user limite on SQL version. :P // but char limitation is good way to maintain server. :D @@ -1513,7 +1513,7 @@ int parse_tologin(int fd) { if(RFIFOREST(fd)<51) return 0; for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) { if (RFIFOB(fd,6) != 0) { WFIFOW(i,0) = 0x6c; WFIFOB(i,2) = 0x42; @@ -1546,7 +1546,7 @@ int parse_tologin(int fd) { if (RFIFOREST(fd) < 50) return 0; for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == RFIFOL(fd,2)) { sd->connect_until_time = (time_t)RFIFOL(fd,46); break; @@ -1606,22 +1606,22 @@ int parse_tologin(int fd) { sql_res = mysql_store_result(&mysql_handle); if (sql_res) { - int char_id, jobclass, skill_point, class; + int char_id, jobclass, skill_point, class_; sql_row = mysql_fetch_row(sql_res); char_id = atoi(sql_row[0]); jobclass = atoi(sql_row[1]); skill_point = atoi(sql_row[2]); - class = jobclass; + class_ = jobclass; if (jobclass == 19 || jobclass == 20 || jobclass == 4020 || jobclass == 4021 || jobclass == 4042 || jobclass == 4043) { // job modification if (jobclass == 19 || jobclass == 20) { - class = (sex) ? 19 : 20; + class_ = (sex) ? 19 : 20; } else if (jobclass == 4020 || jobclass == 4021) { - class = (sex) ? 4020 : 4021; + class_ = (sex) ? 4020 : 4021; } else if (jobclass == 4042 || jobclass == 4043) { - class = (sex) ? 4042 : 4043; + class_ = (sex) ? 4042 : 4043; } // remove specifical skills of classes 19,20 4020,4021 and 4042,4043 sprintf(tmp_sql, "SELECT `lv` FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id); @@ -1644,7 +1644,7 @@ int parse_tologin(int fd) { if (mysql_query(&mysql_handle, tmp_sql)) { printf("DB server Error (select `char`)- %s\n", mysql_error(&mysql_handle)); } - sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d' , `skill_point`='%d' , `weapon`='0' , `shield='0' , `head_top`='0' , `head_mid`='0' , `head_bottom`='0' WHERE `char_id` = '%d'",char_db, class, skill_point, char_id); + sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d' , `skill_point`='%d' , `weapon`='0' , `shield='0' , `head_top`='0' , `head_mid`='0' , `head_bottom`='0' WHERE `char_id` = '%d'",char_db, class_, skill_point, char_id); if (mysql_query(&mysql_handle, tmp_sql)) { printf("DB server Error (select `char`)- %s\n", mysql_error(&mysql_handle)); } @@ -1652,7 +1652,7 @@ int parse_tologin(int fd) { } // disconnect player if online on char-server for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == acc) { session[i]->eof = 1; break; @@ -1706,7 +1706,7 @@ int parse_tologin(int fd) { } // disconnect player if online on char-server for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == RFIFOL(fd,2)) { session[i]->eof = 1; break; @@ -2296,7 +2296,7 @@ int parse_char(int fd) { struct char_session_data *sd; unsigned char *p = (unsigned char *) &session[fd]->client_addr.sin_addr; - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; if(login_fd < 0) session[fd]->eof = 1; @@ -2353,7 +2353,7 @@ int parse_char(int fd) { */ if (sd == NULL) { CREATE(session[fd]->session_data, struct char_session_data, 1); - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; sd->connect_until_time = 0; // unknow or illimited (not displaying on map-server) } sd->account_id = RFIFOL(fd, 2); @@ -2843,15 +2843,15 @@ int parse_console(char *buf) { printf("Type of command: %s || Command: %s \n",type,command); - if(buf) free(buf); - if(type) free(type); - if(command) free(command); + if(buf) aFree(buf); + if(type) aFree(type); + if(command) aFree(command); return 0; } // MAP send all -int mapif_sendall(unsigned char *buf, unsigned int len) { +int mapif_sendall(char *buf, unsigned int len) { int i, c; int fd; @@ -2867,7 +2867,7 @@ int mapif_sendall(unsigned char *buf, unsigned int len) { return c; } -int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { +int mapif_sendallwos(int sfd, char *buf, unsigned int len) { int i, c; int fd; @@ -2883,7 +2883,7 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { return c; } -int mapif_send(int fd, unsigned char *buf, unsigned int len) { +int mapif_send(int fd, char *buf, unsigned int len) { int i; if (fd >= 0) { @@ -3016,12 +3016,12 @@ void do_final(void) { printf("DB server Error (insert `char`)- %s\n", mysql_error(&mysql_handle)); if(gm_account) { - free(gm_account); + aFree(gm_account); gm_account = 0; } if(char_dat) { - free(char_dat); + aFree(char_dat); char_dat = 0; } diff --git a/src/char_sql/char.h b/src/char_sql/char.h index c7261650b..17a938780 100644 --- a/src/char_sql/char.h +++ b/src/char_sql/char.h @@ -41,9 +41,9 @@ struct itemtemp{ struct itemtmp equip[MAX_GUILD_STORAGE],notequip[MAX_GUILD_STORAGE]; }; int memitemdata_to_sql(struct itemtemp mapitem, int eqcount, int noteqcount, int char_id,int tableswitch); -int mapif_sendall(unsigned char *buf,unsigned int len); -int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len); -int mapif_send(int fd,unsigned char *buf,unsigned int len); +int mapif_sendall(char *buf,unsigned int len); +int mapif_sendallwos(int fd,char *buf,unsigned int len); +int mapif_send(int fd,char *buf,unsigned int len); extern int autosave_interval; extern char db_path[]; diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 3f9243bfe..e3b8d30a8 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -46,7 +46,7 @@ static int _erase_guild(void *key, void *data, va_list ap) { int guild = va_arg(ap, int); struct guild_castle * castle = (struct guild_castle *) data; if (castle->guild_id == guild) { - free(castle); + aFree(castle); db_erase(castle_db_, key); } @@ -60,21 +60,21 @@ int inter_guild_tosql(struct guild *g,int flag) // 2 `guild_member` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`rsv1`,`rsv2`,`name`) // 4 `guild_position` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) // 8 `guild_alliance` (`guild_id`,`opposition`,`alliance_id`,`name`) - // 16 `guild_expulsion` (`guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3`) + // 16 `guild_expulsion` (`guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3`) // 32 `guild_skill` (`guild_id`,`id`,`lv`) - + char t_name[100],t_master[24],t_mes1[60],t_mes2[240],t_member[24],t_position[24],t_alliance[24]; // temporay storage for str convertion; char t_ename[24],t_emes[40]; char emblem_data[4096]; int i=0; int guild_exist=0,guild_member=0,guild_online_member=0; - + if (g->guild_id<=0) return -1; - + printf("(\033[1;35m%d\033[0m) Request save guild -(flag 0x%x) ",g->guild_id, flag); - + jstrescapecpy(t_name, g->name); - + //printf("- Check if guild %d exists\n",g->guild_id); sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_db,g->guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -87,7 +87,7 @@ int inter_guild_tosql(struct guild *g,int flag) //printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes")); } mysql_free_result(sql_res) ; //resource free - + if (guild_exist >0){ // Check members in party sprintf(tmp_sql,"SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_member_db, g->guild_id); @@ -98,13 +98,13 @@ int inter_guild_tosql(struct guild *g,int flag) sql_res = mysql_store_result(&mysql_handle) ; if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { sql_row = mysql_fetch_row(sql_res); - + guild_member = atoi (sql_row[0]); // printf("- Check members in guild %d : %d \n",g->guild_id,guild_member); } mysql_free_result(sql_res) ; //resource free - + // Delete old guild from sql if (flag&1||guild_member==0){ // printf("- Delete guild %d from guild\n",g->guild_id); @@ -164,7 +164,7 @@ int inter_guild_tosql(struct guild *g,int flag) sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_castle_db, g->guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `guild_castle`)- %s\n", mysql_error(&mysql_handle) ); - } + } db_foreach(castle_db_, _erase_guild, g->guild_id); } } @@ -175,14 +175,14 @@ int inter_guild_tosql(struct guild *g,int flag) if (g->member[i].account_id>0) guild_online_member++; i++; } - + // No member in guild , no need to create it in sql if (guild_member <= 0 && guild_online_member <=0) { inter_guild_storage_delete(g->guild_id); printf("No member in guild %d , break it! \n",g->guild_id); return -2; } - + // Insert new guild to sqlserver if (flag&1||guild_member==0){ int len=0; @@ -190,7 +190,7 @@ int inter_guild_tosql(struct guild *g,int flag) for(i=0;iemblem_len;i++){ len+=sprintf(emblem_data+len,"%02x",(unsigned char)(g->emblem_data[i])); //printf("%02x",(unsigned char)(g->emblem_data[i])); - } + } emblem_data[len] = '\0'; //printf("- emblem_len = %d \n",g->emblem_len); sprintf(tmp_sql,"INSERT INTO `%s` " @@ -204,7 +204,7 @@ int inter_guild_tosql(struct guild *g,int flag) printf("DB server Error (insert `guild`)- %s\n", mysql_error(&mysql_handle) ); } } - + if (flag&2||guild_member==0){ struct StringBuf sbuf; struct StringBuf sbuf2; @@ -238,16 +238,16 @@ int inter_guild_tosql(struct guild *g,int flag) } StringBuf_Printf(&sbuf2,")"); - if(mysql_query(&mysql_handle, StringBuf_Value(&sbuf))) + if(mysql_query(&mysql_handle, StringBuf_Value(&sbuf))) printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); - if(mysql_query(&mysql_handle, StringBuf_Value(&sbuf2))) + if(mysql_query(&mysql_handle, StringBuf_Value(&sbuf2))) printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); StringBuf_Destroy(&sbuf2); StringBuf_Destroy(&sbuf); } - + if (flag&4||guild_member==0){ //printf("- Insert guild %d to guild_position\n",g->guild_id); for(i=0;i0) { sql_row = mysql_fetch_row(sql_res); if (sql_row==NULL) { mysql_free_result(sql_res); - free(g); + aFree(g); return 0; } - + g->guild_id=atoi(sql_row[0]); strncpy(g->name,sql_row[1],24); strncpy(g->master,sql_row[2],24); @@ -382,7 +382,7 @@ struct guild * inter_guild_fromsql(int guild_id) if(c2>='a' && c2<='f')x2=c2-'a'+10; if(c2>='A' && c2<='F')x2=c2-'A'+10; g->emblem_data[i]=(x1<<4)|x2; - } + } } mysql_free_result(sql_res); @@ -392,7 +392,7 @@ struct guild * inter_guild_fromsql(int guild_id) //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_member`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -415,33 +415,33 @@ struct guild * inter_guild_fromsql(int guild_id) } } mysql_free_result(sql_res); - + //printf("- Read guild_position %d from sql \n",guild_id); sprintf(tmp_sql,"SELECT `guild_id`,`position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'",guild_position_db, guild_id); //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_position`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { int i; for(i=0;((sql_row = mysql_fetch_row(sql_res))&&iposition[position]; - strncpy(p->name,sql_row[2],24); + strncpy(p->name,sql_row[2],24); p->mode=atoi(sql_row[3]); - p->exp_mode=atoi(sql_row[4]); + p->exp_mode=atoi(sql_row[4]); } } - mysql_free_result(sql_res); + mysql_free_result(sql_res); //printf("- Read guild_alliance %d from sql \n",guild_id); sprintf(tmp_sql,"SELECT `guild_id`,`opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'",guild_alliance_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_alliance`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -455,12 +455,12 @@ struct guild * inter_guild_fromsql(int guild_id) } } mysql_free_result(sql_res); - + //printf("- Read guild_expulsion %d from sql \n",guild_id); sprintf(tmp_sql,"SELECT `guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3` FROM `%s` WHERE `guild_id`='%d'",guild_expulsion_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_expulsion`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -476,16 +476,16 @@ struct guild * inter_guild_fromsql(int guild_id) e->rsv1=atoi(sql_row[5]); e->rsv2=atoi(sql_row[6]); e->rsv3=atoi(sql_row[7]); - + } } mysql_free_result(sql_res); - + //printf("- Read guild_skill %d from sql \n",guild_id); sprintf(tmp_sql,"SELECT `guild_id`,`id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`",guild_skill_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_skill`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -497,7 +497,7 @@ struct guild * inter_guild_fromsql(int guild_id) } } mysql_free_result(sql_res); - + // printf("Successfully retrieve guild information from sql!\n"); numdb_insert(guild_db_, guild_id,g); @@ -542,8 +542,8 @@ int inter_guildcastle_tosql(struct guild_castle *gc) "(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`," "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`)" - "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')", - guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, + "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')", + guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC, gc->visibleG0, gc->visibleG1, gc->visibleG2, gc->visibleG3, gc->visibleG4, gc->visibleG5, gc->visibleG6, gc->visibleG7, gc->Ghp0, gc->Ghp1, gc->Ghp2, gc->Ghp3, gc->Ghp4, gc->Ghp5, gc->Ghp6, gc->Ghp7); //printf(" %s\n",tmp_sql); @@ -558,7 +558,7 @@ int inter_guildcastle_tosql(struct guild_castle *gc) printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); return 0; } - + sprintf(tmp_sql,"UPDATE `%s` SET `castle_id`='%d' WHERE `guild_id`='%d'",guild_db, gc->castle_id,gc->guild_id); //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -567,7 +567,7 @@ int inter_guildcastle_tosql(struct guild_castle *gc) } db_foreach(guild_db_, _set_guild_castle, gc->castle_id,gc->guild_id); - + return 0; } // Read guild_castle from sql @@ -603,7 +603,7 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) mysql_free_result(sql_res); return 0; } - + gc->guild_id = atoi (sql_row[1]); gc->economy = atoi (sql_row[2]); gc->defense = atoi (sql_row[3]); @@ -629,7 +629,7 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) gc->Ghp5 = atoi (sql_row[23]); gc->Ghp6 = atoi (sql_row[24]); gc->Ghp7 = atoi (sql_row[25]); - + //printf("Read Castle %d of guild %d from sql \n",castle_id,gc->guild_id); } @@ -647,7 +647,7 @@ int inter_guild_readdb() FILE *fp; char line[1024]; for (i=0;i<100;i++) guild_exp[i]=0; - + fp=fopen("db/exp_guild.txt","r"); if(fp==NULL){ printf("can't read db/exp_guild.txt\n"); @@ -676,14 +676,14 @@ int inter_guild_sql_init() guild_expcache_db_=numdb_init(); guild_infoevent_db_=numdb_init(); guild_castleinfoevent_db_=numdb_init(); - + printf("interserver guild memory initialize.... (%d byte)\n",sizeof(struct guild)); guild_pt = aCalloc(sizeof(struct guild), 1); guild_pt2= aCalloc(sizeof(struct guild), 1); guildcastle_pt=aCalloc(sizeof(struct guild_castle), 1); - + inter_guild_readdb(); // Read exp - + sprintf (tmp_sql , "SELECT count(*) FROM `%s`",guild_db); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); @@ -702,13 +702,13 @@ int inter_guild_sql_init() printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); exit(0); } - + sql_res = mysql_store_result(&mysql_handle) ; sql_row = mysql_fetch_row(sql_res); guild_newid = atoi(sql_row[0])+1; mysql_free_result(sql_res); } - + printf("set guild_newid: %d.......\n",guild_newid); return 0; @@ -743,7 +743,7 @@ int guild_check_empty(struct guild *g) return 0; } } - + // 誰もいないので解散 mapif_guild_broken(g->guild_id,0); inter_guild_storage_delete(g->guild_id); @@ -795,7 +795,7 @@ int guild_calcinfo(struct guild *g) nextexp = guild_nextexp(g->guild_lv); } } - + // ギルドの次の経験値 g->next_exp = guild_nextexp(g->guild_lv); @@ -809,13 +809,13 @@ int guild_calcinfo(struct guild *g) if(g->member[i].account_id>0){ g->average_lv+=g->member[i].lv; c++; - + if(g->member[i].online>0) g->connect_member++; } } if(c) g->average_lv/=c; - + // 全データを送る必要がありそう if( g->max_member!=before.max_member || g->guild_lv!=before.guild_lv || @@ -823,7 +823,7 @@ int guild_calcinfo(struct guild *g) mapif_guild_info(-1,g); return 1; } - + return 0; } @@ -906,7 +906,7 @@ int mapif_guild_memberinfoshort(struct guild *g,int idx) WBUFL(buf, 2)=g->guild_id; WBUFL(buf, 6)=g->member[idx].account_id; WBUFL(buf,10)=g->member[idx].char_id; - WBUFB(buf,14)=g->member[idx].online; + WBUFB(buf,14)=(unsigned char)g->member[idx].online; WBUFW(buf,15)=g->member[idx].lv; WBUFW(buf,17)=g->member[idx].class_; mapif_sendall(buf,19); @@ -1121,7 +1121,7 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member { struct guild *g; int i; - + printf("CreateGuild\n"); g=search_guildname(name); if(g!=NULL&&g->guild_id>0){ @@ -1135,38 +1135,38 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member memcpy(g->name,name,24); memcpy(g->master,master->name,24); memcpy(&g->member[0],master,sizeof(struct guild_member)); - + g->position[0].mode=0x11; strcpy(g->position[ 0].name,"GuildMaster"); strcpy(g->position[MAX_GUILDPOSITION-1].name,"Newbie"); for(i=1;iposition[i].name,"Position %d",i+1); - + // Initialize guild property g->max_member=16; g->average_lv=master->lv; g->castle_id=-1; for(i=0;iskill[i].id=i + GD_SKILLBASE; - + // Save to sql printf("Create initialize OK!\n"); i=inter_guild_tosql(g,255); - + if (i<0) { mapif_guild_created(fd,account_id,NULL); return 0; } - + // Report to client mapif_guild_created(fd,account_id,g); mapif_guild_info(fd,g); - + if(log_inter) inter_log("guild %s (id=%d) created by master %s (id=%d)" RETCODE, name, g->guild_id, master->name, master->account_id ); - - + + return 0; } // Return guild info to client @@ -1191,10 +1191,10 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); return 0; } - + for(i=0;imax_member;i++){ if(g->member[i].account_id==0){ - + memcpy(&g->member[i],m,sizeof(struct guild_member)); mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,0); guild_calcinfo(g); @@ -1211,7 +1211,7 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int flag,const char *mes) { struct guild *g= inter_guild_fromsql(guild_id); - + if(g!=NULL&&g->guild_id>0){ int i; for(i=0;imax_member;i++){ @@ -1219,7 +1219,7 @@ int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int fl g->member[i].char_id==char_id){ printf("%d %d\n",i, (int)(&g->member[i])); printf("%d %s\n",i, g->member[i].name); - + if(flag){ // 追放の場合追放リストに入れる int j; for(j=0;jexplusion[j].name,g->member[i].name,24); memcpy(g->explusion[j].mes,mes,40); } - + mapif_guild_leaved(guild_id,account_id,char_id,flag,g->member[i].name,mes); printf("%d %d\n",i, (int)(&g->member[i])); printf("%d %s\n",i, (&g->member[i])->name); memset(&g->member[i],0,sizeof(struct guild_member)); - + if( guild_check_empty(g)==0 ) mapif_guild_info(-1,g);// まだ人がいるのでデータ送信 /* @@ -1259,12 +1259,12 @@ int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int fl } /* mapif_guild_leaved(guild_id,account_id,char_id,flag,g->member[i].name,mes); */ } - + return 0; } // Change member info int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, - int account_id,int char_id,int online,int lv,int class) + int account_id,int char_id,int online,int lv,int class_) { // Could speed up by manipulating only guild_member struct guild * g= inter_guild_fromsql(guild_id); @@ -1272,18 +1272,18 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, if(g==NULL||g->guild_id<=0) return 0; - + g->connect_member=0; idx = -1; - + for(i=0,alv=0,c=0;imax_member;i++){ if( g->member[i].account_id==account_id && g->member[i].char_id==char_id){ - + g->member[i].online=online; g->member[i].lv=lv; - g->member[i].class_=class; + g->member[i].class_=class_; mapif_guild_memberinfoshort(g,i); idx = i; } @@ -1300,13 +1300,13 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, g->average_lv=alv/c; sprintf(tmp_sql, "UPDATE `%s` SET `connect_member`=%d,`average_lv`=%d WHERE `guild_id`='%d'", guild_db, g->connect_member, g->average_lv, g->guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); sprintf(tmp_sql, "UPDATE `%s` SET `online`=%d,`lv`=%d,`class`=%d WHERE `char_id`=%d", guild_member_db, g->member[idx].online, g->member[idx].lv, g->member[idx].class_, g->member[idx].char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); - + return 0; } @@ -1316,7 +1316,7 @@ int mapif_parse_BreakGuild(int fd,int guild_id) struct guild *g= inter_guild_fromsql(guild_id); if(g==NULL) return 0; - + // Delete guild from sql //printf("- Delete guild %d from guild\n",guild_id); sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id); @@ -1348,7 +1348,7 @@ int mapif_parse_BreakGuild(int fd,int guild_id) if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `guild_position`)- %s\n", mysql_error(&mysql_handle) ); } - + //printf("- Delete guild %d from guild_castle\n",guild_id); sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_castle_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -1356,19 +1356,19 @@ int mapif_parse_BreakGuild(int fd,int guild_id) } db_foreach(castle_db_, _erase_guild, guild_id); - + //printf("- Update guild %d of char\n",guild_id); sprintf(tmp_sql, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'",char_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `guild_position`)- %s\n", mysql_error(&mysql_handle) ); } - + inter_guild_storage_delete(guild_id); mapif_guild_broken(guild_id,0); - + if(log_inter) inter_log("guild %s (id=%d) broken" RETCODE,g->name,guild_id); - + return 0; } @@ -1416,7 +1416,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha struct guild * g = inter_guild_fromsql(guild_id); //printf("GuildMemberInfoChange %s \n",(type==GMI_EXP)?"GMI_EXP":"OTHER"); - + if(g==NULL){ return 0; } @@ -1437,7 +1437,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha inter_guild_tosql(g,3); // Change guild & guild_member break; } - case GMI_EXP: + case GMI_EXP: { // EXP int exp,oldexp=g->member[i].exp; exp=g->member[i].exp=*((unsigned int *)data); @@ -1447,11 +1447,11 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); sprintf(tmp_sql, "UPDATE `%s` SET `guild_lv`=%d,`connect_member`=%d,`max_member`=%d,`average_lv`=%d,`exp`=%d,`next_exp`=%d,`skill_point`=%d WHERE `guild_id`='%d'", guild_db, g->guild_lv, g->connect_member, g->max_member, g->average_lv, g->exp, g->next_exp, g->skill_point, g->guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); sprintf(tmp_sql, "UPDATE `%s` SET `exp`=%d WHERE `char_id`=%d", guild_member_db, g->member[i].exp, g->member[i].char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); break; } @@ -1488,7 +1488,7 @@ int mapif_parse_GuildSkillUp(int fd,int guild_id,int skill_num,int account_id) if(g == NULL || idx < 0 || idx >= MAX_GUILDSKILL) return 0; //printf("GuildSkillUp\n"); - + if( g->skill_point>0 && g->skill[idx].id>0 && g->skill[idx].lv<10 ){ g->skill[idx].lv++; @@ -1511,10 +1511,10 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2, int j,i; g[0]= inter_guild_fromsql(guild_id1); g[1]= inter_guild_fromsql(guild_id2); - + if(g[0]==NULL || g[1]==NULL || g[0]->guild_id ==0 || g[1]->guild_id==0) return 0; - + if(!(flag&0x8)){ for(i=0;i<2-(flag&1);i++){ for(j=0;jguild_id<=0) return 0; memcpy(g->mes1,mes1,60); @@ -1557,7 +1557,7 @@ int mapif_parse_GuildNotice(int fd,int guild_id,const char *mes1,const char *mes int mapif_parse_GuildEmblem(int fd,int len,int guild_id,int dummy,const char *data) { struct guild * g= inter_guild_fromsql(guild_id); - + if(g==NULL||g->guild_id<=0) return 0; memcpy(g->emblem_data,data,len); diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index af3ad7dc3..9ea3a5635 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -207,7 +207,7 @@ int inter_party_sql_init(){ //memory alloc printf("interserver party memory initialize.... (%d byte)\n",sizeof(struct party)); - party_pt = calloc(sizeof(struct party), 1); + party_pt = aCalloc(sizeof(struct party), 1); sprintf (tmp_sql , "SELECT count(*) FROM `%s`",party_db); if(mysql_query(&mysql_handle, tmp_sql) ) { diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 44151c8e4..18172b066 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -105,7 +105,7 @@ int inter_pet_sql_init(){ //memory alloc printf("interserver pet memory initialize.... (%d byte)\n",sizeof(struct s_pet)); - pet_pt = calloc(sizeof(struct s_pet), 1); + pet_pt = aCalloc(sizeof(struct s_pet), 1); sprintf (tmp_sql , "SELECT count(*) FROM `%s`", pet_db); if(mysql_query(&mysql_handle, tmp_sql) ) { diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index 69eaf2469..e2d4010a1 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -191,8 +191,8 @@ int inter_storage_sql_init(){ //memory alloc printf("interserver storage memory initialize....(%d byte)\n",sizeof(struct storage)); - storage_pt=calloc(sizeof(struct storage), 1); - guild_storage_pt=calloc(sizeof(struct guild_storage), 1); + storage_pt=aCalloc(sizeof(struct storage), 1); + guild_storage_pt=aCalloc(sizeof(struct guild_storage), 1); memset(storage_pt,0,sizeof(struct storage)); memset(guild_storage_pt,0,sizeof(struct guild_storage)); diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 52a53f702..92a002898 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -402,7 +402,7 @@ int check_ttl_wisdata() { // removed. not send information after a timeout. Just no answer for the player //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target numdb_erase(wis_db, wd->id); - free(wd); + aFree(wd); } } while(wis_delnum >= WISDELLIST_MAX); @@ -490,7 +490,7 @@ int mapif_parse_WisReply(int fd) { if ((--wd->count) <= 0 || flag != 1) { mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target numdb_erase(wis_db, id); - free(wd); + aFree(wd); } return 0; diff --git a/src/char_sql/itemdb.c b/src/char_sql/itemdb.c index 0bed07c23..efd3df84b 100644 --- a/src/char_sql/itemdb.c +++ b/src/char_sql/itemdb.c @@ -172,7 +172,7 @@ static int itemdb_read_sqldb(void) // sql item_db read, shortened version of map // Insert a new row into the item database /* - id = calloc(sizeof(struct item_data), 1); + id = aCalloc(sizeof(struct item_data), 1); if (id == NULL) { printf("out of memory : itemdb_read_sqldb\n"); @@ -214,10 +214,10 @@ static int itemdb_final(void *key,void *data,va_list ap) id=data; if(id->use_script) - free(id->use_script); + aFree(id->use_script); if(id->equip_script) - free(id->equip_script); - free(id); + aFree(id->equip_script); + aFree(id); return 0; } diff --git a/src/char_sql/itemdb.h b/src/char_sql/itemdb.h index dea835e78..762873c8e 100644 --- a/src/char_sql/itemdb.h +++ b/src/char_sql/itemdb.h @@ -6,7 +6,7 @@ struct item_data { char name[24],jname[24]; int value_buy,value_sell,value_notdc,value_notoc; int type; - int class; + int class_; int sex; int equip; int weight; diff --git a/src/common/core.c b/src/common/core.c index 493aab850..a8c922fc3 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -9,6 +9,7 @@ #include #include +#include "../common/mmo.h" #include "core.h" #include "socket.h" #include "timer.h" diff --git a/src/common/db.c b/src/common/db.c index bc4e8451b..d76b7a44c 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -424,7 +424,7 @@ void* db_erase(struct dbt *table,void* key) #ifdef MALLOC_DBN free_dbn(p); #else - free(p); + aFree(p); #endif return data; } @@ -497,11 +497,11 @@ void db_final(struct dbt *table,int (*func)(void*,void*,va_list),...) #ifdef MALLOC_DBN free_dbn(p); #else - free(p); + aFree(p); #endif p=pn; } } - free(table); + aFree(table); va_end(ap); } diff --git a/src/common/grfio.c b/src/common/grfio.c index 440c3b2a3..6afd1d668 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -25,8 +25,6 @@ #include #include -#include - #include "utils.h" #include "grfio.h" #include "mmo.h" @@ -284,7 +282,7 @@ static void decode_des_etc(BYTE *buf,int len,int type,int cycle) * Grf data decode sub : zip *------------------------------------------ */ -int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) +int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -301,21 +299,21 @@ int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; - err = inflateInit(&stream); + err = zlib_inflateInit(&stream); if (err != Z_OK) return err; - err = inflate(&stream, Z_FINISH); + err = zlib_inflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { - inflateEnd(&stream); + zlib_inflateEnd(&stream); return err == Z_OK ? Z_BUF_ERROR : err; } *destLen = stream.total_out; - err = inflateEnd(&stream); + err = zlib_inflateEnd(&stream); return err; } -int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { +int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -513,14 +511,14 @@ int grfio_size(char *fname) char lfname[256],*rname,*p; FILELIST lentry; struct stat st; - + if(strcmp(data_dir, "") != 0 && (rname=grfio_resnametable(fname,lfname))!=NULL) { //printf("%s\t",fname); //sprintf(rname,"%s",grfio_resnametable(fname,lfname)); //printf("%s\n",rname); sprintf(lfname,"%s%s",data_dir,rname); //printf("%s\n",lfname); - } + } for(p=&lfname[0];*p!=0;p++) if (*p=='\\') *p = '/'; // * At the time of Unix @@ -557,7 +555,7 @@ void* grfio_reads(char *fname, int *size) strncpy(lfname,fname,255); // i hope this is the correct way =p [celest] - if ((rname=grfio_resnametable(fname,lfname))!=NULL) { + if ((rname=grfio_resnametable(fname,lfname))!=NULL) { char tbuf[255]; //sprintf(rname,"%s",grfio_resnametable(fname,lfname)); sprintf(tbuf,"%s%s",data_dir,rname); @@ -576,7 +574,7 @@ void* grfio_reads(char *fname, int *size) lentry.declen = ftell(in); } fseek(in,0,0); // SEEK_SET - buf2 = (unsigned char *) aCalloc(lentry.declen+1024, 1); + buf2 = (unsigned char *) aCallocA(lentry.declen+1024, 1); if (buf2==NULL) { printf("file read memory allocate error : declen\n"); goto errret; @@ -592,13 +590,13 @@ void* grfio_reads(char *fname, int *size) } else { printf("%s not found (grfio_reads)\n", fname); //goto errret; - free(buf2); + aFree(buf2); return NULL; } } } if (entry!=NULL && entry->gentry>0) { // Archive[GRF] File Read - buf = (unsigned char *) aCalloc(entry->srclen_aligned+1024, 1); + buf = (unsigned char *) aCallocA(entry->srclen_aligned+1024, 1); if (buf==NULL) { printf("file read memory allocate error : srclen_aligned\n"); goto errret; @@ -608,13 +606,13 @@ void* grfio_reads(char *fname, int *size) if(in==NULL) { printf("%s not found (grfio_reads)\n",gfname); //goto errret; - free(buf); + aFree(buf); return NULL; } fseek(in,entry->srcpos,0); fread(buf,1,entry->srclen_aligned,in); fclose(in); - buf2 = (unsigned char *) aCalloc(entry->declen+1024, 1); + buf2 = (unsigned char *) aCallocA(entry->declen+1024, 1); if (buf2==NULL) { printf("file decode memory allocate error\n"); goto errret; @@ -633,14 +631,14 @@ void* grfio_reads(char *fname, int *size) } else { memcpy(buf2,buf,entry->declen); } - free(buf); + aFree(buf); } if (size!=NULL && entry!=NULL) *size = entry->declen; return buf2; errret: - if (buf!=NULL) free(buf); - if (buf2!=NULL) free(buf2); + if (buf!=NULL) aFree(buf); + if (buf2!=NULL) aFree(buf2); if (in!=NULL) fclose(in); return NULL; } @@ -704,7 +702,7 @@ static int grfio_entryread(char *gfname,int gentry) if (grf_version==0x01) { //****** Grf version 01xx ****** list_size = grf_size-ftell(fp); - grf_filelist = (unsigned char *) aCalloc(list_size, 1); + grf_filelist = (unsigned char *) aCallocA(list_size, 1); if(grf_filelist==NULL){ fclose(fp); printf("out of memory : grf_filelist\n"); @@ -727,7 +725,7 @@ static int grfio_entryread(char *gfname,int gentry) fname = decode_filename(grf_filelist+ofs+6,grf_filelist[ofs]-6); if(strlen((const char *) fname)>sizeof(aentry.fn)-1){ printf("file name too long : %s\n",fname); - free(grf_filelist); + aFree(grf_filelist); exit(1); } srclen=0; @@ -762,7 +760,7 @@ static int grfio_entryread(char *gfname,int gentry) } ofs = ofs2 + 17; } - free(grf_filelist); + aFree(grf_filelist); } else if (grf_version==0x02) { //****** Grf version 02xx ****** unsigned char eheader[8]; @@ -779,15 +777,15 @@ static int grfio_entryread(char *gfname,int gentry) return 4; } - rBuf = (unsigned char *) aCalloc( rSize , 1); // Get a Read Size + rBuf = (unsigned char *) aCallocA( rSize , 1); // Get a Read Size if (rBuf==NULL) { fclose(fp); printf("out of memory : grf compress entry table buffer\n"); return 3; } - grf_filelist = (unsigned char *) aCalloc( eSize , 1); // Get a Extend Size + grf_filelist = (unsigned char *) aCallocA( eSize , 1); // Get a Extend Size if (grf_filelist==NULL) { - free(rBuf); + aFree(rBuf); fclose(fp); printf("out of memory : grf extract entry table buffer\n"); return 3; @@ -796,7 +794,7 @@ static int grfio_entryread(char *gfname,int gentry) fclose(fp); decode_zip(grf_filelist,&eSize,rBuf,rSize); // Decode function list_size = eSize; - free(rBuf); + aFree(rBuf); entrys = getlong(grf_header+0x26) - 7; @@ -808,7 +806,7 @@ static int grfio_entryread(char *gfname,int gentry) fname = grf_filelist+ofs; if (strlen((const char *) fname)>sizeof(aentry.fn)-1) { printf("grf : file name too long : %s\n",fname); - free(grf_filelist); + aFree(grf_filelist); exit(1); } ofs2 = ofs+strlen(grf_filelist+ofs)+1; @@ -839,7 +837,7 @@ static int grfio_entryread(char *gfname,int gentry) } ofs = ofs2 + 17; } - free(grf_filelist); + aFree(grf_filelist); } else { //****** Grf Other version ****** fclose(fp); @@ -859,11 +857,11 @@ static int grfio_entryread(char *gfname,int gentry) static void grfio_resourcecheck() { int size; - unsigned char *buf,*ptr; + char *buf,*ptr; char w1[256],w2[256],src[256],dst[256]; FILELIST *entry; - buf=grfio_reads("data\\resnametable.txt",&size); + buf = (char*)grfio_reads("data\\resnametable.txt",&size); buf[size] = 0; for(ptr=buf;ptr-buf #include #include #include "malloc.h" +#if !defined(DMALLOC) && !defined(GCOLLECT) && !defined(BCHECK) + void* aMalloc_( size_t size, const char *file, int line, const char *func ) { void *ret; @@ -45,9 +46,27 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f return ret; } +#endif + + +#if defined(GCOLLECT) + +void * _bcallocA(size_t size, size_t cnt) { + void *ret = aMallocA(size * cnt); + memset(ret, 0, size * cnt); + return ret; +} + void * _bcalloc(size_t size, size_t cnt) { - void *ret = malloc(size * cnt); + void *ret = aMalloc(size * cnt); memset(ret, 0, size * cnt); return ret; } #endif + +char * _bstrdup(const char *chr) { + int len = strlen(chr); + char *ret = aMalloc(len + 1); + strcpy(ret, chr); + return ret; +} diff --git a/src/common/malloc.h b/src/common/malloc.h index 860f8dd7b..b37c3b799 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -9,23 +9,39 @@ #define aMalloc(size) \ dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 0) +#define aMallocA(size) \ + dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 0) +#define aCallocA(count,size) \ + dmalloc_malloc(__FILE__, __LINE__, (count)*(size), DMALLOC_FUNC_CALLOC, 0, 0) #define aCalloc(count,size) \ dmalloc_malloc(__FILE__, __LINE__, (count)*(size), DMALLOC_FUNC_CALLOC, 0, 0) #define aRealloc(ptr,size) \ dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 0) +#define aFree(ptr) free(ptr) +#define aStrdup(ptr) strdup(ptr) #elif defined(GCOLLECT) #include "gc.h" #define aMalloc(n) GC_MALLOC(n) +#define aMallocA(n) GC_MALLOC_ATOMIC(n) +#define aCallocA(m,n) _bcallocA(m,n) #define aCalloc(m,n) _bcalloc(m,n) #define aRealloc(p,n) GC_REALLOC(p,n) +#define aFree(n) GC_FREE(n) +#define aStrdup(n) _bstrdup(n) extern void * _bcalloc(size_t, size_t); +extern void * _bcallocA(size_t, size_t); +extern char * _bstrdup(const char *); #elif defined(BCHECK) #define aMalloc(n) malloc(n) +#define aMallocA(n) malloc(n) #define aCalloc(m,n) calloc(m,n) +#define aCallocA(m,n) calloc(m,n) #define aRealloc(p,n) realloc(p,n) +#define aFree(n) free(n) +#define aStrdup(n) strdup(n) #else #if __STDC_VERSION__ < 199901L @@ -43,8 +59,12 @@ void* aCalloc_( size_t num, size_t size, const char *file, int line, const char void* aRealloc_( void *p, size_t size, const char *file, int line, const char *func ); #define aMalloc(n) aMalloc_(n,ALC_MARK) +#define aMallocA(n) aMalloc_(n,ALC_MARK) #define aCalloc(m,n) aCalloc_(m,n,ALC_MARK) +#define aCallocA(m,n) aCalloc_(m,n,ALC_MARK) #define aRealloc(p,n) aRealloc_(p,n,ALC_MARK) +#define aFree(ptr) free(ptr) +#define aStrdup(ptr) strdup(ptr) #endif diff --git a/src/common/mmo.h b/src/common/mmo.h index 41598509e..a8722e53e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -326,19 +326,25 @@ enum { GD_DEVELOPMENT=10014, }; -#ifndef _WIN32 -#ifndef strcmpi -#define strcmpi strcasecmp -#endif -#ifndef stricmp -#define stricmp strcasecmp -#endif -#ifndef strncmpi -#define strncmpi strncasecmp -#endif -#ifndef strnicmp -#define strnicmp strncasecmp -#endif +#ifndef __WIN32 + #ifndef strcmpi + #define strcmpi strcasecmp + #endif + #ifndef stricmp + #define stricmp strcasecmp + #endif + #ifndef strncmpi + #define strncmpi strncasecmp + #endif + #ifndef strnicmp + #define strnicmp strncasecmp + #endif +#else + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #ifndef strncmpi + #define strncmpi strnicmp + #endif #endif #endif // _MMO_H_ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 857a819bb..ddaae3a52 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,6 +2,7 @@ #include #include #include "showmsg.h" +#include "malloc.h" char tmp_output[1024] = {"\0"}; @@ -47,7 +48,7 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri return 1; } if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { - output = (char*)malloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) + output = (char*)aMalloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) if (output == NULL) { return 1; // exit(1); // Kill server? Deadly @@ -58,7 +59,7 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri strcat(output,string); printf(output); fflush(stdout); - free(output); + aFree(output); } /* if ((core_config.debug_output_level > -1) && (flag >= core_config.debug_output_level)) { diff --git a/src/common/socket.c b/src/common/socket.c index 764d4d821..72e7e3f22 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -3,11 +3,13 @@ #include #include #include +#include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include +#include #else #include #include @@ -16,7 +18,6 @@ #include #include #include -#include #ifndef SIOCGIFCONF #include // SIOCGIFCONF on Solaris, maybe others? [Shinomori] @@ -151,11 +152,11 @@ static int send_from_fifo(int fd) return 0; } -void flush_fifos() +void flush_fifos() { int i; for(i=0;ifunc_send == send_from_fifo) send_from_fifo(i); } @@ -177,20 +178,22 @@ static int connect_client(int listen_fd) int fd; struct sockaddr_in client_address; int len; +#ifndef _WIN32 int result; +#endif //printf("connect_client : %d\n",listen_fd); len=sizeof(client_address); - fd=accept(listen_fd,(struct sockaddr*)&client_address,&len); + fd = accept(listen_fd,(struct sockaddr*)&client_address,(socklen_t*)&len); if(fd_max<=fd) fd_max=fd+1; setsocketopts(fd); if(fd==-1) perror("accept"); - else + else FD_SET(fd,&readfds); #ifdef _WIN32 @@ -203,8 +206,8 @@ static int connect_client(int listen_fd) #endif CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, unsigned char, rfifo_size); - CREATE(session[fd]->wdata, unsigned char, wfifo_size); + CREATE_A(session[fd]->rdata, unsigned char, rfifo_size); + CREATE_A(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -240,7 +243,7 @@ int make_listen_port(int port) server_address.sin_family = AF_INET; server_address.sin_addr.s_addr = htonl( INADDR_ANY ); - server_address.sin_port = htons(port); + server_address.sin_port = htons((unsigned short)port); result = bind(fd, (struct sockaddr*)&server_address, sizeof(server_address)); if( result == -1 ) { @@ -271,12 +274,13 @@ int make_listen_port(int port) int console_recieve(int i) { int n; char *buf; - - CREATE(buf, char , 64); - + + CREATE_A(buf, char , 64); + memset(buf,0,sizeof(64)); n = read(0, buf , 64); + if ( n < 0 ) printf("Console input read error\n"); else @@ -298,21 +302,21 @@ static int null_console_parse(char *buf) // Console Input [Wizputer] int start_console(void) { FD_SET(0,&readfds); - + CREATE(session[0], struct socket_data, 1); if(session[0]==NULL){ printf("out of memory : start_console\n"); exit(1); } - + memset(session[0],0,sizeof(*session[0])); - + session[0]->func_recv = console_recieve; session[0]->func_console = default_console_parse; - + return 0; -} - +} + int make_connection(long ip,int port) { struct sockaddr_in server_address; @@ -320,14 +324,14 @@ int make_connection(long ip,int port) int result; fd = socket( AF_INET, SOCK_STREAM, 0 ); - if(fd_max<=fd) + if(fd_max<=fd) fd_max=fd+1; setsocketopts(fd); server_address.sin_family = AF_INET; server_address.sin_addr.s_addr = ip; - server_address.sin_port = htons(port); + server_address.sin_port = htons((unsigned short)port); #ifdef _WIN32 { @@ -343,8 +347,8 @@ int make_connection(long ip,int port) FD_SET(fd,&readfds); CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, unsigned char, rfifo_size); - CREATE(session[fd]->wdata, unsigned char, wfifo_size); + CREATE_A(session[fd]->rdata, unsigned char, rfifo_size); + CREATE_A(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -363,12 +367,12 @@ int delete_session(int fd) FD_CLR(fd,&readfds); if(session[fd]){ if(session[fd]->rdata) - free(session[fd]->rdata); + aFree(session[fd]->rdata); if(session[fd]->wdata) - free(session[fd]->wdata); + aFree(session[fd]->wdata); if(session[fd]->session_data) - free(session[fd]->session_data); - free(session[fd]); + aFree(session[fd]->session_data); + aFree(session[fd]); } session[fd]=NULL; //printf("delete_session:%d\n",fd); @@ -401,7 +405,7 @@ int WFIFOSET(int fd,int len) } s->wdata_size=(s->wdata_size+(len)+2048 < s->max_wdata) ? s->wdata_size+len : (printf("socket: %d wdata lost !!\n",fd),s->wdata_size); - if (s->wdata_size > (TCP_FRAME_LEN)) + if (s->wdata_size > (TCP_FRAME_LEN)) send_from_fifo(fd); return 0; } @@ -456,7 +460,7 @@ int do_parsepacket(void) for(i=0;irdata_tick != 0) && ((tick_ - session[i]->rdata_tick) > stall_time_)) + if ((session[i]->rdata_tick != 0) && ((tick_ - session[i]->rdata_tick) > stall_time_)) session[i]->eof = 1; if(session[i]->rdata_size==0 && session[i]->eof==0) continue; @@ -500,7 +504,7 @@ int Net_Init(void) unsigned int i; char fullhost[255]; struct hostent* hent; - + /* Start up the windows networking */ WSADATA wsaData; @@ -512,7 +516,7 @@ int Net_Init(void) if(gethostname(fullhost, sizeof(fullhost)) == SOCKET_ERROR) { printf("Ugg.. no hostname defined!\n"); return 0; - } + } // XXX This should look up the local IP addresses in the registry // instead of calling gethostbyname. However, the way IP addresses @@ -545,7 +549,7 @@ int Net_Init(void) return 0; } - for(pos = 0; pos < ic.ifc_len;) + for(pos = 0; pos < ic.ifc_len;) { struct ifreq * ir = (struct ifreq *) (ic.ifc_buf + pos); diff --git a/src/common/socket.h b/src/common/socket.h index 172712d26..68b204862 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,8 +5,9 @@ #include -#ifdef _WIN32 +#ifdef __WIN32 #include +#define close(fd) closesocket(fd) #else #include #include diff --git a/src/common/strlib.c b/src/common/strlib.c index 9114c3d03..ca6e38761 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -8,15 +8,15 @@ //----------------------------------------------- // string lib. -unsigned char* jstrescape (unsigned char* pt) { +char* jstrescape (char* pt) { //copy from here unsigned char * ptr; int i =0, j=0; - + //copy string to temporary - CREATE(ptr, char, J_MAX_MALLOC_SIZE); + CREATE_A(ptr, char, J_MAX_MALLOC_SIZE); strcpy (ptr,pt); - + while (ptr[i] != '\0') { switch (ptr[i]) { case '\'': @@ -32,14 +32,14 @@ unsigned char* jstrescape (unsigned char* pt) { } } pt[j++] = '\0'; - free (ptr); - return (unsigned char*) &pt[0]; + aFree (ptr); + return &pt[0]; } -unsigned char* jstrescapecpy (unsigned char* pt,unsigned char* spt) { +char* jstrescapecpy (char* pt,char* spt) { //copy from here int i =0, j=0; - + while (spt[i] != '\0') { switch (spt[i]) { case '\'': @@ -55,12 +55,12 @@ unsigned char* jstrescapecpy (unsigned char* pt,unsigned char* spt) { } } pt[j++] = '\0'; - return (unsigned char*) &pt[0]; + return &pt[0]; } -int jmemescapecpy (unsigned char* pt,unsigned char* spt, int size) { +int jmemescapecpy (char* pt,char* spt, int size) { //copy from here int i =0, j=0; - + while (i < size) { switch (spt[i]) { case '\'': diff --git a/src/common/strlib.h b/src/common/strlib.h index 6b6169083..54c52cf94 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -4,7 +4,7 @@ // String function library. // code by Jioh L. Jung (ziozzang@4wish.net) // This code is under license "BSD" -unsigned char* jstrescape (unsigned char* pt); -unsigned char* jstrescapecpy (unsigned char* pt,unsigned char* spt); -int jmemescapecpy (unsigned char* pt,unsigned char* spt, int size); +char* jstrescape (char* pt); +char* jstrescapecpy (char* pt,char* spt); +int jmemescapecpy (char* pt,char* spt, int size); #endif diff --git a/src/common/timer.c b/src/common/timer.c index 4c602b51e..8b52811b8 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -262,7 +262,7 @@ int add_timer(unsigned int tick,int (*func)(int,unsigned int,int,int),int id,int int j; if (timer_data_max == 0) { timer_data_max = 256; - CREATE(timer_data, struct TimerData, timer_data_max); + CREATE_A(timer_data, struct TimerData, timer_data_max); //timer_data[0] = NULL; } else { timer_data_max += 256; @@ -403,13 +403,13 @@ void timer_final(void) for(tfl = tfl_root; tfl; tfl = tfl_next) { tfl_next = tfl->next; - free(tfl); + aFree(tfl); tfl = NULL; } if(timer_heap) - free(timer_heap); + aFree(timer_heap); if(free_timer_list) - free(free_timer_list); + aFree(free_timer_list); if(timer_data) - free(timer_data); + aFree(timer_data); } diff --git a/src/common/utils.c b/src/common/utils.c index 9a7722478..732b1d366 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -4,6 +4,7 @@ #include #include #include "malloc.h" +#include "mmo.h" void dump(unsigned char *buffer, int num) { @@ -112,7 +113,7 @@ void str_lower(char *name) // Allocate a StringBuf [MouseJstr] struct StringBuf * StringBuf_Malloc() { - struct StringBuf * ret = (struct StringBuf *) malloc(sizeof(struct StringBuf)); + struct StringBuf * ret = (struct StringBuf *) aMallocA(sizeof(struct StringBuf)); StringBuf_Init(ret); return ret; } @@ -120,7 +121,7 @@ struct StringBuf * StringBuf_Malloc() // Initialize a previously allocated StringBuf [MouseJstr] void StringBuf_Init(struct StringBuf * sbuf) { sbuf->max_ = 1024; - sbuf->ptr_ = sbuf->buf_ = (char *) malloc(sbuf->max_ + 1); + sbuf->ptr_ = sbuf->buf_ = (char *) aMallocA(sbuf->max_ + 1); } // printf into a StringBuf, moving the pointer [MouseJstr] @@ -169,7 +170,7 @@ int StringBuf_Append(struct StringBuf *buf1,const struct StringBuf *buf2) // Destroy a StringBuf [MouseJstr] void StringBuf_Destroy(struct StringBuf *sbuf) { - free(sbuf->buf_); + aFree(sbuf->buf_); sbuf->ptr_ = sbuf->buf_ = 0; } @@ -177,7 +178,7 @@ void StringBuf_Destroy(struct StringBuf *sbuf) void StringBuf_Free(struct StringBuf *sbuf) { StringBuf_Destroy(sbuf); - free(sbuf); + aFree(sbuf); } // Return the built string from the StringBuf [MouseJstr] diff --git a/src/common/utils.h b/src/common/utils.h index 0ac880a50..63c3f21ec 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -30,6 +30,12 @@ if (!((result) = (type *) aCalloc ((number), sizeof(type)))) \ { perror("SYSERR: malloc failure"); abort(); } } while(0) +#define CREATE_A(result, type, number) do {\ + if ((number) * sizeof(type) <= 0) \ + printf("SYSERR: Zero bytes or less requested at %s:%d.\n", __FILE__, __LINE__); \ + if (!((result) = (type *) aCallocA ((number), sizeof(type)))) \ + { perror("SYSERR: malloc failure"); abort(); } } while(0) + #define RECREATE(result,type,number) do {\ if (!((result) = (type *) aRealloc ((result), sizeof(type) * (number))))\ { printf("SYSERR: realloc failure"); abort(); } } while(0) diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index c8b0d60f0..66f5b837f 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -280,7 +280,7 @@ int ladmin_log(char *fmt, ...) { fprintf(logfp, RETCODE); else { gettimeofday(&tv, NULL); - strftime(tmpstr, 24, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 24, date_format, localtime((const time_t*)&(tv.tv_sec))); sprintf(tmpstr + strlen(tmpstr), ".%03d: %s", (int)tv.tv_usec / 1000, fmt); vfprintf(logfp, tmpstr, ap); } @@ -294,7 +294,7 @@ int ladmin_log(char *fmt, ...) { //----------------------------------------------------- // Function to suppress control characters in a string. //----------------------------------------------------- -int remove_control_chars(unsigned char *str) { +int remove_control_chars(char *str) { int i; int change = 0; @@ -381,9 +381,9 @@ int verify_accountname(char* account_name) { //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- -int e_mail_check(unsigned char *email) { +int e_mail_check(char *email) { char ch; - unsigned char* last_arobas; + char* last_arobas; // athena limits if (strlen(email) < 3 || strlen(email) > 39) @@ -3266,7 +3266,7 @@ int parse_fromlogin(int fd) { } // printf("parse_fromlogin : %d %d %d\n", fd, RFIFOREST(fd), RFIFOW(fd,0)); - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; while(RFIFOREST(fd) >= 2) { switch(RFIFOW(fd,0)) { diff --git a/src/login/login.c b/src/login/login.c index 5f8bde598..11c970aca 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,7 +2,7 @@ // new version of the login-server by [Yor] #include -#ifdef WIN32 +#ifdef __WIN32 #define WIN32_LEAN_AND_MEAN #include #include @@ -232,12 +232,12 @@ void addGM(int account_id, int level) { } return; } - + // if new account if (i == GM_num && do_add) { if (GM_num >= GM_max) { GM_max += 256; - gm_account_db = realloc(gm_account_db, sizeof(struct gm_account) * GM_max); + gm_account_db = (struct gm_account*)aRealloc(gm_account_db, sizeof(struct gm_account) * GM_max); memset(gm_account_db + (GM_max - 256), 0, sizeof(struct gm_account) * 256); } gm_account_db[GM_num].account_id = account_id; @@ -261,7 +261,7 @@ int read_gm_account() { struct stat file_stat; int start_range = 0, end_range = 0, is_range = 0, current_id = 0; - if(gm_account_db) free(gm_account_db); + if(gm_account_db) aFree(gm_account_db); GM_num = 0; if(GM_max < 0) GM_max = 256; gm_account_db = (struct gm_account*)aCalloc(GM_max, sizeof(struct gm_account)); @@ -302,7 +302,7 @@ int read_gm_account() { printf("read_gm_account: file [%s] invalid range, beginning of range is equal to end of range (line #%d).\n", GM_account_filename, line_counter); else if (start_range>end_range) printf("read_gm_account: file [%s] invalid range, beginning of range must be lower than end of range (line #%d).\n", GM_account_filename, line_counter); - else + else for (current_id = start_range;current_id<=end_range;current_id++) addGM(current_id,level); } else { @@ -620,7 +620,7 @@ int mmo_auth_init(void) { if (auth_num >= auth_max) { auth_max += 256; - auth_dat = realloc(auth_dat, sizeof(struct auth_dat) * auth_max); + auth_dat = (struct auth_dat*)aRealloc(auth_dat, sizeof(struct auth_dat) * auth_max); } memset(&auth_dat[auth_num], '\0', sizeof(struct auth_dat)); @@ -745,7 +745,7 @@ int mmo_auth_init(void) { if (auth_num >= auth_max) { auth_max += 256; - auth_dat = realloc(auth_dat, sizeof(struct auth_dat) * auth_max); + auth_dat = (struct auth_dat*)aRealloc(auth_dat, sizeof(struct auth_dat) * auth_max); } memset(&auth_dat[auth_num], '\0', sizeof(struct auth_dat)); @@ -871,7 +871,8 @@ void mmo_auth_sync(void) { FILE *fp; int i, j, k, lock; int account_id; - int id[auth_num]; + //int id[auth_num]; + int *id = (int *)aCalloc(auth_num, sizeof(int)); char line[65536]; // Sorting before save @@ -889,8 +890,10 @@ void mmo_auth_sync(void) { } // Data save - if ((fp = lock_fopen(account_filename, &lock)) == NULL) + if ((fp = lock_fopen(account_filename, &lock)) == NULL) { + if (id) free(id); return; + } fprintf(fp, "// Accounts file: here are saved all information about the accounts.\n"); fprintf(fp, "// Structure: ID, account name, password, last login time, sex, # of logins, state, email, error message for state 7, validity time, last (accepted) login ip, memo field, ban timestamp, repeated(register text, register value)\n"); @@ -921,6 +924,8 @@ void mmo_auth_sync(void) { if (auth_before_save_file < AUTH_BEFORE_SAVE_FILE) auth_before_save_file = AUTH_BEFORE_SAVE_FILE; + if (id) aFree(id); + return; } @@ -1019,7 +1024,7 @@ int mmo_auth_new(struct mmo_account* account, char sex, char* email) { if (auth_num >= auth_max) { auth_max += 256; - auth_dat = realloc(auth_dat, sizeof(struct auth_dat) * auth_max); + auth_dat = (struct auth_dat*)aRealloc(auth_dat, sizeof(struct auth_dat) * auth_max); memset(auth_dat, 0, sizeof(struct auth_dat) * auth_max); } @@ -1132,7 +1137,7 @@ int mmo_auth(struct mmo_account* account, int fd) { memcpy(user_password, account->passwd, 25); encpasswdok = 0; #ifdef PASSWORDENC - ld = session[fd]->session_data; + ld = (struct login_session_data*)session[fd]->session_data; if (account->passwdenc > 0) { int j = account->passwdenc; if (!ld) { @@ -1392,7 +1397,7 @@ int parse_fromchar(int fd) { break; // we receive a e-mail creation of an account with a default e-mail (no answer) - case 0x2715: + case 0x2715: if (RFIFOREST(fd) < 46) return 0; { @@ -1701,7 +1706,9 @@ int parse_fromchar(int fd) { acc = RFIFOL(fd,4); for(i = 0; i < auth_num; i++) { if (auth_dat[i].account_id == acc) { - unsigned char buf[RFIFOW(fd,2)+1]; + //unsigned char buf[RFIFOW(fd,2)+1]; + unsigned char *buf; + buf = (unsigned char*)aCalloc(RFIFOW(fd,2)+1, sizeof(unsigned char)); login_log("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s)." RETCODE, server[id].name, acc, ip); for(p = 8, j = 0; p < RFIFOW(fd,2) && j < ACCOUNT_REG2_NUM; p += 36, j++) { @@ -1718,6 +1725,7 @@ int parse_fromchar(int fd) { // Save mmo_auth_sync(); // printf("parse_fromchar: receiving (from the char-server) of account_reg2 (account id: %d).\n", acc); + if (buf) free(buf); break; } } @@ -1883,7 +1891,8 @@ int parse_admin(int fd) { return 0; { int st, ed, len; - int id[auth_num]; + //int id[auth_num]; + int *id=(int *)aCalloc(auth_num, sizeof(int)); st = RFIFOL(fd,2); ed = RFIFOL(fd,6); RFIFOSKIP(fd,10); @@ -1927,6 +1936,7 @@ int parse_admin(int fd) { } WFIFOW(fd,2) = len; WFIFOSET(fd,len); + if (id) free(id); } break; @@ -2114,7 +2124,7 @@ int parse_admin(int fd) { memcpy(WFIFOP(fd,4+server_num*32+6), server[i].name, 20); WFIFOW(fd,4+server_num*32+26) = server[i].users; WFIFOW(fd,4+server_num*32+28) = server[i].maintenance; - WFIFOW(fd,4+server_num*32+30) = server[i].new; + WFIFOW(fd,4+server_num*32+30) = server[i].new_; server_num++; } } @@ -2845,7 +2855,7 @@ int parse_login(int fd) { } else printf("parse_login: connection #%d, packet: 0x%x (with being read: %d).\n", fd, RFIFOW(fd,0), RFIFOREST(fd)); } - + switch(RFIFOW(fd,0)) { case 0x200: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. if (RFIFOREST(fd) < 26) @@ -2920,7 +2930,7 @@ int parse_login(int fd) { memcpy(WFIFOP(fd,47+server_num*32+6), server[i].name, 20); WFIFOW(fd,47+server_num*32+26) = server[i].users; WFIFOW(fd,47+server_num*32+28) = server[i].maintenance; - WFIFOW(fd,47+server_num*32+30) = server[i].new; + WFIFOW(fd,47+server_num*32+30) = server[i].new_; server_num++; } } @@ -2984,7 +2994,7 @@ int parse_login(int fd) { session[fd]->eof = 1; return 0; } - ld = session[fd]->session_data = (struct login_session_data*)aCalloc(1, sizeof(struct login_session_data)); + ld = (struct login_session_data*)session[fd]->session_data = (struct login_session_data*)aCalloc(1, sizeof(struct login_session_data)); if (!ld) { printf("login: Request for md5 key: memory allocation failure (malloc)!\n"); session[fd]->eof = 1; @@ -3036,7 +3046,7 @@ int parse_login(int fd) { memcpy(server[account.account_id].name, server_name, 20); server[account.account_id].users = 0; server[account.account_id].maintenance = RFIFOW(fd,82); - server[account.account_id].new = RFIFOW(fd,84); + server[account.account_id].new_ = RFIFOW(fd,84); server_fd[account.account_id] = fd; if(anti_freeze_enable) server_freezeflag[account.account_id] = 5; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed @@ -3105,7 +3115,7 @@ int parse_login(int fd) { if (!check_ladminip(session[fd]->client_addr.sin_addr.s_addr)) { login_log("'ladmin'-login: Connection in administration mode refused: IP isn't authorised (ladmin_allow, ip: %s)." RETCODE, ip); } else { - struct login_session_data *ld = session[fd]->session_data; + struct login_session_data *ld = (struct login_session_data*)session[fd]->session_data; if (RFIFOW(fd,2) == 0) { // non encrypted password unsigned char* password=""; memcpy(password, RFIFOP(fd,4), 24); @@ -3205,9 +3215,9 @@ int parse_console(char *buf) { char command[256]; memset(command,0,sizeof(command)); - + sscanf(buf, "%[^\n]", command); - + login_log("Console command :%s" RETCODE, command); if(strcmpi("shutdown", command) == 0 || @@ -3372,22 +3382,22 @@ int login_config_read(const char *cfgName) { admin_pass[sizeof(admin_pass)-1] = '\0'; } else if (strcmpi(w1, "ladminallowip") == 0) { if (strcmpi(w2, "clear") == 0) { - if (access_ladmin_allow) - free(access_ladmin_allow); + if (access_ladmin_allow) + aFree(access_ladmin_allow); access_ladmin_allow = NULL; access_ladmin_allownum = 0; } else { if (strcmpi(w2, "all") == 0) { // reset all previous values if (access_ladmin_allow) - free(access_ladmin_allow); + aFree(access_ladmin_allow); // set to all access_ladmin_allow = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); access_ladmin_allownum = 1; access_ladmin_allow[0] = '\0'; } else if (w2[0] && !(access_ladmin_allownum == 1 && access_ladmin_allow[0] == '\0')) { // don't add IP if already 'all' if (access_ladmin_allow) - access_ladmin_allow = realloc(access_ladmin_allow, (access_ladmin_allownum+1) * ACO_STRSIZE); + access_ladmin_allow = (char*)aRealloc(access_ladmin_allow, (access_ladmin_allownum+1) * ACO_STRSIZE); else access_ladmin_allow = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); strncpy(access_ladmin_allow + (access_ladmin_allownum++) * ACO_STRSIZE, w2, ACO_STRSIZE); @@ -3469,21 +3479,21 @@ int login_config_read(const char *cfgName) { } else if (strcmpi(w1, "allow") == 0) { if (strcmpi(w2, "clear") == 0) { if (access_allow) - free(access_allow); + aFree(access_allow); access_allow = NULL; access_allownum = 0; } else { if (strcmpi(w2, "all") == 0) { // reset all previous values if (access_allow) - free(access_allow); + aFree(access_allow); // set to all access_allow = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); access_allownum = 1; access_allow[0] = '\0'; } else if (w2[0] && !(access_allownum == 1 && access_allow[0] == '\0')) { // don't add IP if already 'all' if (access_allow) - access_allow = realloc(access_allow, (access_allownum+1) * ACO_STRSIZE); + access_allow = (char*)aRealloc(access_allow, (access_allownum+1) * ACO_STRSIZE); else access_allow = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); strncpy(access_allow + (access_allownum++) * ACO_STRSIZE, w2, ACO_STRSIZE); @@ -3493,21 +3503,21 @@ int login_config_read(const char *cfgName) { } else if (strcmpi(w1, "deny") == 0) { if (strcmpi(w2, "clear") == 0) { if (access_deny) - free(access_deny); + aFree(access_deny); access_deny = NULL; access_denynum = 0; } else { if (strcmpi(w2, "all") == 0) { // reset all previous values if (access_deny) - free(access_deny); + aFree(access_deny); // set to all access_deny = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); access_denynum = 1; access_deny[0] = '\0'; } else if (w2[0] && !(access_denynum == 1 && access_deny[0] == '\0')) { // don't add IP if already 'all' if (access_deny) - access_deny = realloc(access_deny, (access_denynum+1) * ACO_STRSIZE); + access_deny = (char*)aRealloc(access_deny, (access_denynum+1) * ACO_STRSIZE); else access_deny = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); strncpy(access_deny + (access_denynum++) * ACO_STRSIZE, w2, ACO_STRSIZE); @@ -3877,18 +3887,18 @@ void do_final(void) { fflush(stdout); mmo_auth_sync(); - if(auth_dat) free(auth_dat); - if(gm_account_db) free(gm_account_db); - if(access_ladmin_allow) free(access_ladmin_allow); - if(access_allow) free(access_allow); - if(access_deny) free(access_deny); + if(auth_dat) aFree(auth_dat); + if(gm_account_db) aFree(gm_account_db); + if(access_ladmin_allow) aFree(access_ladmin_allow); + if(access_allow) aFree(access_allow); + if(access_deny) aFree(access_deny); for (i = 0; i < MAX_SERVERS; i++) { if ((fd = server_fd[i]) >= 0) { server_fd[i] = -1; memset(&server[i], 0, sizeof(struct mmo_char_server)); close(fd); delete_session(fd); - if(session[fd]) free(session[fd]); + if(session[fd]) aFree(session[fd]); } } close(login_fd); @@ -3929,7 +3939,7 @@ int do_init(int argc, char **argv) { // set_termfunc(mmo_auth_sync); set_defaultparse(parse_login); login_fd = make_listen_port(login_port); - + if(anti_freeze_enable > 0) { add_timer_func_list(char_anti_freeze_system, "char_anti_freeze_system"); i = add_timer_interval(gettick() + 1000, char_anti_freeze_system, 0, 0, ANTI_FREEZE_INTERVAL * 1000); @@ -3957,7 +3967,7 @@ int do_init(int argc, char **argv) { set_defaultconsoleparse(parse_console); start_console(); } - + login_log("The login-server is ready (Server is listening on the port %d)." RETCODE, login_port); printf("The login-server is \033[1;32mready\033[0m (Server is listening on the port %d).\n\n", login_port); diff --git a/src/login/login.h b/src/login/login.h index 7370f5238..4a5b5be0c 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -33,7 +33,7 @@ struct mmo_char_server { short port; int users; int maintenance; - int new; + int new_; }; extern struct mmo_char_server server[MAX_SERVERS]; diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 25df5310d..302e78b9e 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -161,7 +161,7 @@ struct dbt *online_db; void add_online_user(int account_id) { int *p; - p = aMalloc(sizeof(int)); + p = (int*)aMalloc(sizeof(int)); if (p == NULL) { printf("add_online_user: memory allocation failure (malloc)!\n"); exit(0); @@ -173,7 +173,7 @@ void add_online_user(int account_id) { int is_user_online(int account_id) { int *p; - p = numdb_search(online_db, account_id); + p = (int*)numdb_search(online_db, account_id); if (p == NULL) return 0; printf("Acccount %d\n",*p); @@ -182,8 +182,8 @@ int is_user_online(int account_id) { void remove_online_user(int account_id) { int *p; - p = numdb_erase(online_db,account_id); - free(p); + p = (int*)numdb_erase(online_db,account_id); + aFree(p); } //----------------------------------------------------- @@ -238,9 +238,9 @@ int remove_control_chars(unsigned char *str) { //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- -int e_mail_check(unsigned char *email) { +int e_mail_check(char *email) { char ch; - unsigned char* last_arobas; + char* last_arobas; // athena limits if (strlen(email) < 3 || strlen(email) > 39) @@ -394,7 +394,7 @@ int mmo_auth( struct mmo_account* account , int fd){ // auth start : time seed gettimeofday(&tv, NULL); - strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",localtime(&(tv.tv_sec))); + strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",localtime((const time_t*)&(tv.tv_sec))); sprintf(tmpstr+19, ".%03d", (int)tv.tv_usec/1000); jstrescapecpy(t_uid,account->userid); @@ -1217,7 +1217,7 @@ int parse_login(int fd) { memcpy(WFIFOP(fd,47+server_num*32+6), server[i].name, 20); WFIFOW(fd,47+server_num*32+26) = server[i].users; WFIFOW(fd,47+server_num*32+28) = server[i].maintenance; - WFIFOW(fd,47+server_num*32+30) = server[i].new; + WFIFOW(fd,47+server_num*32+30) = server[i].new_; server_num++; } } @@ -1407,7 +1407,7 @@ int parse_login(int fd) { memcpy(server[account.account_id].name,RFIFOP(fd,60),20); server[account.account_id].users=0; server[account.account_id].maintenance=RFIFOW(fd,82); - server[account.account_id].new=RFIFOW(fd,84); + server[account.account_id].new_=RFIFOW(fd,84); server_fd[account.account_id]=fd; if(anti_freeze_enable) server_freezeflag[account.account_id] = 5; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed @@ -1480,9 +1480,9 @@ int parse_console(char *buf) { printf("Type of command: %s || Command: %s \n",type,command); - if(buf) free(buf); - if(type) free(type); - if(command) free(command); + if(buf) aFree(buf); + if(type) aFree(type); + if(command) aFree(command); return 0; } @@ -1841,7 +1841,7 @@ int do_init(int argc,char **argv){ } // Online user database init - free(online_db); + aFree(online_db); online_db = numdb_init(); printf("The login-server is \033[1;32mready\033[0m (Server is listening on the port %d).\n\n", login_port); diff --git a/src/login_sql/login.h b/src/login_sql/login.h index 6335168d7..73892f4ef 100644 --- a/src/login_sql/login.h +++ b/src/login_sql/login.h @@ -34,7 +34,7 @@ struct mmo_char_server { short port; int users; int maintenance; - int new; + int new_; }; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4b245fd0b..c1f491910 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8,6 +8,7 @@ #include "../common/socket.h" #include "../common/timer.h" #include "../common/nullpo.h" +#include "../common/mmo.h" #include "log.h" #include "clif.h" @@ -465,7 +466,7 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_Send, "@send", 60, atcommand_send }, { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag }, { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris] - { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity + { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest] @@ -531,8 +532,8 @@ static AtCommandInfo atcommand_info[] = { * This function return the name of the job (by [Yor]) *---------------------------------------------------- */ -char * job_name(int class) { - switch (class) { +char * job_name(int class_) { + switch (class_) { case 0: return "Novice"; case 1: return "Swordsman"; case 2: return "Mage"; @@ -833,18 +834,18 @@ static int atmobsearch_sub(struct block_list *bl,va_list ap) static int number=0; struct mob_data *md; char output[128]; - + nullpo_retr(0, bl); - + if(!ap){ number=0; return 0; } mob_id = va_arg(ap,int); fd = va_arg(ap,int); - + md = (struct mob_data *)bl; - + if(md && fd && (mob_id==-1 || (md->class_==mob_id))){ snprintf(output, sizeof output, "%2d[%3d:%3d] %s", ++number,bl->x, bl->y,md->name); @@ -894,7 +895,7 @@ void rehash( const int fd, struct map_session_data* sd ) int map_id = 0; int LOADED_MAPS = map_num; - + for (map_id = 0; map_id < LOADED_MAPS;map_id++) { if (map_id > LOADED_MAPS) @@ -1023,7 +1024,7 @@ int atcommand_send( WBUFW(buf,0)=0x18f; case 4: WBUFW(buf,0)=0x190; - } + } } return 0; } @@ -1113,7 +1114,7 @@ int atcommand_where( snprintf(output, sizeof output, "%s %s %d %d", character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, output); - + return 0; } @@ -1135,7 +1136,7 @@ int atcommand_jumpto( clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto )."); return -1; } - + memset(character, '\0', sizeof character); if (sscanf(message, "%99[^\n]", character) < 1) return -1; @@ -1677,8 +1678,10 @@ int atcommand_whozeny( int i, j, count,c; char match_text[100]; char player_name[24]; - int zeny[clif_countusers()]; - int counted[clif_countusers()]; + //int zeny[clif_countusers()]; + //int counted[clif_countusers()]; + int *zeny = (int *)aCallocA(clif_countusers(), sizeof(int)); + int *counted = (int *)aCallocA(clif_countusers(), sizeof(int)); nullpo_retr(-1, sd); @@ -1732,6 +1735,9 @@ int atcommand_whozeny( clif_displaymessage(fd, output); } + free(zeny); + free(counted); + return 0; } @@ -1749,7 +1755,7 @@ int atcommand_happyhappyjoyjoy( for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) { e=rand()%40; - if(e==34) + if(e==34) e = 0; clif_emotion(&pl_sd->bl,e); } @@ -2177,7 +2183,7 @@ int atcommand_alive( clif_resurrection(&sd->bl, 1); clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle! return 0; - } + } return -1; } @@ -2296,8 +2302,8 @@ int atcommand_item( if (pet_id >= 0) { sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet(sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, - pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, + (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv, + (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); // if not pet egg } else { @@ -2447,7 +2453,7 @@ int atcommand_baselevelup( clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher. return -1; } // End Addition - if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow + if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow level = battle_config.maximum_level - sd->status.base_level; for (i = 1; i <= level; i++) sd->status.status_point += (sd->status.base_level + i + 14) / 5; @@ -2464,7 +2470,7 @@ int atcommand_baselevelup( clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower. return -1; } - if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow + if (level < -(int)battle_config.maximum_level || level < (1 - (int)sd->status.base_level)) // fix negativ overflow level = 1 - sd->status.base_level; if (sd->status.status_point > 0) { for (i = 0; i > level; i--) @@ -2491,7 +2497,8 @@ int atcommand_joblevelup( const int fd, struct map_session_data* sd, const char* command, const char* message) { - int up_level = 50, level; + unsigned int up_level = 50; + int level; struct pc_base_job s_class; nullpo_retr(-1, sd); s_class = pc_calc_base_job(sd->status.class_); @@ -2514,7 +2521,7 @@ int atcommand_joblevelup( clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher. return -1; } - if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow + if ((unsigned int)level > up_level || (unsigned int)level > (up_level - sd->status.job_level)) // fix positiv overflow level = up_level - sd->status.job_level; sd->status.job_level += level; clif_updatestatus(sd, SP_JOBLEVEL); @@ -2529,7 +2536,7 @@ int atcommand_joblevelup( clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower. return -1; } - if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow + if (level < -(int)up_level || level < (1 - (int)sd->status.job_level)) // fix negativ overflow level = 1 - sd->status.job_level; sd->status.job_level += level; clif_updatestatus(sd, SP_JOBLEVEL); @@ -3117,7 +3124,7 @@ int atcommand_monster( printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y); count = 0; - range = sqrt(number) / 2; + range = (int)sqrt(number) / 2; range = range * 2 + 5; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { j = 0; @@ -3209,7 +3216,7 @@ int atcommand_spawn( printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y); count = 0; - range = sqrt(number) / 2; + range = (int)sqrt(number) / 2; range = range * 2 + 5; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { j = 0; @@ -3848,9 +3855,9 @@ int atcommand_param( } new_value = (int)*status[index] + value; - if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow + if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow new_value = battle_config.max_parameter; - else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow + else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow new_value = 1; if (new_value != (int)*status[index]) { @@ -3893,9 +3900,9 @@ int atcommand_stat_all( for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) { new_value = (int)*status[index] + value; - if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow + if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow new_value = battle_config.max_parameter; - else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow + else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow new_value = 1; if (new_value != (int)*status[index]) { @@ -3993,8 +4000,8 @@ int atcommand_makeegg( sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet( sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, - pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, + (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv, + (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } else { clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist. @@ -4149,14 +4156,14 @@ atcommand_recall( char character[100]; char output[200]; struct map_session_data *pl_sd = NULL; - + nullpo_retr(-1, sd); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @recall )."); return -1; } - + memset(character, '\0', sizeof character); if(sscanf(message, "%99[^\n]", character) < 1) return -1; @@ -4658,7 +4665,7 @@ int atcommand_character_baselevel( clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher. return 0; } // End Addition - if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow + if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow level = battle_config.maximum_level - pl_sd->status.base_level; for (i = 1; i <= level; i++) pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5; @@ -4675,7 +4682,7 @@ int atcommand_character_baselevel( clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower. return -1; } - if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) // fix negativ overflow + if (level < -(int)battle_config.maximum_level || level < (1 - (int)pl_sd->status.base_level)) // fix negativ overflow level = 1 - pl_sd->status.base_level; if (pl_sd->status.status_point > 0) { for (i = 0; i > level; i--) @@ -4712,7 +4719,8 @@ int atcommand_character_joblevel( { struct map_session_data *pl_sd; char character[100]; - int max_level = 50, level = 0; + unsigned int max_level = 50; + int level = 0; //転生や養子の場合の元の職業を算出する struct pc_base_job pl_s_class; nullpo_retr(-1, sd); @@ -5195,7 +5203,7 @@ int atcommand_idsearch( { char item_name[100]; char output[200]; - int i, match; + unsigned int i, match; struct item_data *item; nullpo_retr(-1, sd); @@ -5652,7 +5660,7 @@ int atcommand_reloadscript( nullpo_retr(-1, sd); atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." ); atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" ); - + rehash( fd, sd ); atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." ); @@ -6090,7 +6098,7 @@ int atcommand_enablenpc(const int fd, struct map_session_data* sd, memset(NPCname, '\0', sizeof(NPCname)); if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) { - clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcon )."); + clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc )."); return -1; } @@ -6961,7 +6969,7 @@ atcommand_npcmove(const int fd, struct map_session_data* sd, int x = 0, y = 0; struct npc_data *nd = 0; nullpo_retr(-1, sd); - + if (!message || !*message) return -1; @@ -7010,7 +7018,7 @@ atcommand_addwarp(const int fd, struct map_session_data* sd, ret = npc_parse_warp(w1, "warp", w3, w4); - sprintf(output, "New warp NPC => %s",w3); + sprintf(output, "New warp NPC => %s",w3); clif_displaymessage(fd, output); @@ -7063,7 +7071,7 @@ atcommand_dropall(const int fd, struct map_session_data* sd, } /*========================================== * @chardropall by [MouseJstr] - * + * * Throw all the characters possessions on the ground. Normally * done in response to them being disrespectful of a GM *------------------------------------------ @@ -7139,7 +7147,7 @@ atcommand_charstoreall(const int fd, struct map_session_data* sd, if (!message || !*message) return -1; - if((pl_sd=map_nick2sd((char *) message)) == NULL) + if((pl_sd=map_nick2sd((char *) message)) == NULL) return -1; if (storage_storageopen(pl_sd) == 1) { @@ -7254,7 +7262,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, clif_displaymessage(fd, "Usage: @skilltree "); return -1; } - if((pl_sd=map_nick2sd(target)) == NULL) + if((pl_sd=map_nick2sd(target)) == NULL) return -1; s_class = pc_calc_base_job(pl_sd->status.class_); @@ -7265,8 +7273,8 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, tbl = job_name(c); - sprintf(output, "Player is using %s %s skill tree (%d basic points)", - s_class.upper ? "upper" : "lower", + sprintf(output, "Player is using %s %s skill tree (%d basic points)", + s_class.upper ? "upper" : "lower", tbl, pc_checkskill(pl_sd, 1)); clif_displaymessage(fd, output); @@ -7276,7 +7284,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, break; } } - + if (skillidx == -1) { sprintf(output, "I do not believe the player can use that skill"); clif_displaymessage(fd, output); @@ -7285,19 +7293,19 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, ent = &skill_tree[s][c][skillidx]; - for(j=0;j<5;j++) + for(j=0;j<5;j++) if( ent->need[j].id && - pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv) + pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv) { int idx = 0; char *desc; - while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id) + while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id) idx++; if (skill_names[idx].id == 0) desc = "Unknown skill"; else desc = skill_names[idx].desc; - sprintf(output, "player requires level %d of skill %s", + sprintf(output, "player requires level %d of skill %s", ent->need[j].lv, desc); clif_displaymessage(fd, output); meets = 0; @@ -7307,7 +7315,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, sprintf(output, "I believe the player meets all the requirements for that skill"); clif_displaymessage(fd, output); } - + return 0; } @@ -7392,7 +7400,7 @@ atcommand_rings(const int fd, struct map_session_data* sd, { struct item item_tmp; int flag; - + memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = 2634; @@ -7456,7 +7464,7 @@ atcommand_grind(const int fd, struct map_session_data* sd, clif_displaymessage(fd, "Usage: @grind "); return -1; } - if((pl_sd=map_nick2sd(target)) == NULL) + if((pl_sd=map_nick2sd(target)) == NULL) return -1; for (skillnum = 1; skillnum < 500; skillnum++) { @@ -7512,7 +7520,7 @@ atcommand_rain( } else { map[sd->bl.m].flag.rain=1; clif_specialeffect(&sd->bl,effno,2); - clif_displaymessage(fd, "It is made to rain."); + clif_displaymessage(fd, "It is made to rain."); } return 0; } @@ -7536,7 +7544,7 @@ atcommand_snow( clif_specialeffect(&sd->bl,effno,2); clif_displaymessage(fd, "It is made to snow."); } - + return 0; } @@ -7629,7 +7637,7 @@ atcommand_clearweather( map[sd->bl.m].flag.leaves=0; //clif_specialeffect(&sd->bl,effno,2); // not required. [celest] return 0; -} +} /*=============================================================== * Sound Command - plays a sound for everyone! [Codemaster] @@ -7720,7 +7728,7 @@ atcommand_cleanmap( } /*========================================== - * + * *------------------------------------------ */ int @@ -7735,14 +7743,14 @@ atcommand_summon( int id = 0; struct mob_data *md; unsigned int tick=gettick(); - + nullpo_retr(-1, sd); if (!message || !*message) return -1; if (sscanf(message, "%99s", name) < 1) return -1; - + if ((mob_id = atoi(name)) == 0) mob_id = mobdb_searchname(name); if(mob_id == 0) @@ -7823,7 +7831,7 @@ atcommand_adjgmlvl( return -1; } - if((pl_sd=map_nick2sd((char *) user)) == NULL) + if((pl_sd=map_nick2sd((char *) user)) == NULL) return -1; pc_set_gm_level(pl_sd->status.account_id, newlev); @@ -7837,7 +7845,7 @@ atcommand_adjgmlvl( * * Open a trade window with a remote player * - * If I have to jump to a remote player one more time, I am + * If I have to jump to a remote player one more time, I am * gonna scream! *------------------------------------------ */ @@ -7876,7 +7884,7 @@ atcommand_setbattleflag( return -1; } - if (battle_set_value(flag, value) == 0) + if (battle_set_value(flag, value) == 0) clif_displaymessage(fd, "unknown battle_config flag"); else clif_displaymessage(fd, "battle_config set as requested"); @@ -7901,7 +7909,7 @@ int atcommand_unmute( if((pl_sd=map_nick2sd((char *) message)) != NULL) { if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) { pl_sd->status.manner = 0; // have to set to 0 first [celest] - skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1); + skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1); clif_displaymessage(sd->fd,"Player unmuted"); } else @@ -7932,7 +7940,7 @@ atcommand_uptime( seconds -= (seconds/hour>0)?(seconds/hour)*hour:0; minutes = seconds/minute; seconds -= (seconds/minute>0)?(seconds/minute)*minute:0; - + snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds); clif_displaymessage(fd,output); @@ -8013,7 +8021,7 @@ atcommand_petid(const int fd, struct map_session_data* sd, char temp0[100]; char temp1[100]; int cnt = 0, i = 0; - + nullpo_retr(-1, sd); if (!message || !*message) @@ -8066,7 +8074,7 @@ atcommand_identify( } } if (num > 0) { - clif_item_identify_list(sd); + clif_item_identify_list(sd); } else { clif_displaymessage(fd,"There are no items to appraise."); } @@ -8074,7 +8082,7 @@ atcommand_identify( } /*========================================== - * @gmotd (Global MOTD) + * @gmotd (Global MOTD) * by davidsiaw :P *------------------------------------------ */ @@ -8113,7 +8121,7 @@ int atcommand_misceffect( if (sscanf(message, "%d", &effect) < 1) return -1; clif_misceffect(&sd->bl,effect); - + return 0; } @@ -8128,7 +8136,7 @@ int charid2sessionid(int charid) if (pl_sd->status.char_id==charid) { session_id = i; break; } } } - + return session_id; } @@ -8143,7 +8151,7 @@ int accountid2sessionid(int accountid) if (pl_sd->status.account_id==accountid) { session_id = i; break; } } } - + return session_id; } @@ -8696,9 +8704,9 @@ atcommand_charkillableid( { if((pl_sd=session[session_id]->session_data) == NULL) return -1; - + pl_sd->special_state.killable = !pl_sd->special_state.killable; - + if(pl_sd->special_state.killable) clif_displaymessage(fd, "The player is now killable"); else @@ -8737,9 +8745,9 @@ atcommand_charkillableid2( { if((pl_sd=session[session_id]->session_data) == NULL) return -1; - + pl_sd->special_state.killable = !pl_sd->special_state.killable; - + if(pl_sd->special_state.killable) clif_displaymessage(fd, "The player is now killable"); else @@ -8762,7 +8770,7 @@ atcommand_charkillableid2( int atcommand_listmail( const int fd, struct map_session_data* sd, const char* command, const char* message) -{ +{ if(!battle_config.mail_system) return 0; @@ -8772,7 +8780,7 @@ int atcommand_listmail( mail_check(sd,3); else if(strlen(command)==9) mail_check(sd,2); - else + else mail_check(sd,1); return 0; } @@ -8823,7 +8831,7 @@ int atcommand_sendmail( if(strlen(command)==17) mail_send(sd,name,text,1); - else + else mail_send(sd,name,text,0); return 0; @@ -8842,7 +8850,7 @@ int atcommand_refreshonline( nullpo_retr(-1, sd); char_online_check(); - + return 0; } diff --git a/src/map/atcommand.h b/src/map/atcommand.h index f639d8c33..754a741b7 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -112,9 +112,9 @@ enum AtCommandType { AtCommand_CharSkReset, AtCommand_CharStReset, //by chbrules - AtCommand_CharModel, + AtCommand_CharModel, AtCommand_CharSKPoint, - AtCommand_CharSTPoint, + AtCommand_CharSTPoint, // AtCommand_CharZeny, //now #zeny AtCommand_RecallAll, AtCommand_ReloadItemDB, @@ -198,7 +198,7 @@ enum AtCommandType { AtCommand_CleanMap, // SQL-only commands start -#ifndef TXT_ONLY +#ifndef TXT_ONLY AtCommand_CheckMail, // [Valaris] AtCommand_ListMail, // [Valaris] AtCommand_ListNewMail, // [Valaris] @@ -206,7 +206,7 @@ enum AtCommandType { AtCommand_SendMail, // [Valaris] AtCommand_DeleteMail, // [Valaris] AtCommand_SendPriorityMail, // [Valaris] -// AtCommand_Sound, // [Valaris] +// AtCommand_Sound, // [Valaris] AtCommand_RefreshOnline, // [Valaris] // SQL-only commands end #endif @@ -272,7 +272,7 @@ int msg_config_read(const char *cfgName); char *estr_lower(char *str); -char * job_name(int class); +char * job_name(int class_); int e_mail_check(unsigned char *email); #endif diff --git a/src/map/battle.c b/src/map/battle.c index 3cff73a18..ce691158c 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -179,6 +179,10 @@ int battle_get_max_hp(struct block_list *bl) if(sc_data[SC_APPLEIDUN].timer!=-1) max_hp += ((5+sc_data[SC_APPLEIDUN].val1*2+((sc_data[SC_APPLEIDUN].val2+1)>>1) +sc_data[SC_APPLEIDUN].val3/10) * max_hp)/100; + if(sc_data[SC_GOSPEL].timer!=-1 && + sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 4) + max_hp += max_hp * 25 / 100; } if(max_hp < 1) max_hp = 1; return max_hp; @@ -429,16 +433,24 @@ int battle_get_flee(struct block_list *bl) else flee=battle_get_agi(bl) + battle_get_lv(bl); - if(sc_data) { - if(sc_data[SC_WHISTLE].timer!=-1 && bl->type != BL_PC) + if(bl->type != BL_PC && sc_data){ + if(sc_data[SC_WHISTLE].timer!=-1) flee += flee*(sc_data[SC_WHISTLE].val1+sc_data[SC_WHISTLE].val2 +(sc_data[SC_WHISTLE].val3>>16))/100; - if(sc_data[SC_BLIND].timer!=-1 && bl->type != BL_PC) + if(sc_data[SC_BLIND].timer!=-1) flee -= flee*25/100; - if(sc_data[SC_WINDWALK].timer!=-1 && bl->type != BL_PC) // ウィンドウォーク + if(sc_data[SC_WINDWALK].timer!=-1) // ウィンドウォーク flee += flee*(sc_data[SC_WINDWALK].val2)/100; - if(sc_data[SC_SPIDERWEB].timer!=-1 && bl->type != BL_PC) //スパイダーウェブ + if(sc_data[SC_SPIDERWEB].timer!=-1) //スパイダーウェブ flee -= flee*50/100; + if(sc_data[SC_GOSPEL].timer!=-1) { + if (sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 13) + flee += flee*5/100; + else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 7) + flee = 0; + } } if(flee < 1) flee = 1; return flee; @@ -460,16 +472,20 @@ int battle_get_hit(struct block_list *bl) else hit=battle_get_dex(bl) + battle_get_lv(bl); - if(sc_data) { - if(sc_data[SC_HUMMING].timer!=-1 && bl->type != BL_PC) // + if(bl->type != BL_PC && sc_data) { + if(sc_data[SC_HUMMING].timer!=-1) // hit += hit*(sc_data[SC_HUMMING].val1*2+sc_data[SC_HUMMING].val2 +sc_data[SC_HUMMING].val3)/100; - if(sc_data[SC_BLIND].timer!=-1 && bl->type != BL_PC) // 呪い + if(sc_data[SC_BLIND].timer!=-1) // 呪い hit -= hit*25/100; - if(sc_data[SC_TRUESIGHT].timer!=-1 && bl->type != BL_PC) // トゥルーサイト + if(sc_data[SC_TRUESIGHT].timer!=-1) // トゥルーサイト hit += 3*(sc_data[SC_TRUESIGHT].val1); - if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション + if(sc_data[SC_CONCENTRATION].timer!=-1) //コンセントレーション hit += (hit*(10*(sc_data[SC_CONCENTRATION].val1)))/100; + if(sc_data[SC_GOSPEL].timer!=-1 && + sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 14) + hit += hit*5/100; } if(hit < 1) hit = 1; return hit; @@ -560,7 +576,7 @@ int battle_get_baseatk(struct block_list *bl) if(sc_data[SC_CURSE].timer!=-1 ) //呪われていたら batk -= batk*25/100; //base_atkが25%減少 if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション - batk += batk*(5*sc_data[SC_CONCENTRATION].val1)/100; + batk += batk*(5*sc_data[SC_CONCENTRATION].val1)/100; } if(batk < 1) batk = 1; //base_atkは最低でも1 return batk; @@ -584,13 +600,22 @@ int battle_get_atk(struct block_list *bl) else if(bl->type==BL_PET && (struct pet_data *)bl) atk = mob_db[((struct pet_data*)bl)->class_].atk1; - if(sc_data) { - if(sc_data[SC_PROVOKE].timer!=-1 && bl->type != BL_PC) + if(bl->type != BL_PC && sc_data) { + if(sc_data[SC_PROVOKE].timer!=-1) atk = atk*(100+2*sc_data[SC_PROVOKE].val1)/100; - if(sc_data[SC_CURSE].timer!=-1 ) + if(sc_data[SC_CURSE].timer!=-1) atk -= atk*25/100; - if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション + if(sc_data[SC_CONCENTRATION].timer!=-1) //コンセントレーション atk += atk*(5*sc_data[SC_CONCENTRATION].val1)/100; + + if(sc_data[SC_GOSPEL].timer!=-1) { + if (sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 12) + atk += atk*8/100; + else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 6) + atk = 0; + } } if(atk < 0) atk = 0; return atk; @@ -605,9 +630,6 @@ int battle_get_atk_(struct block_list *bl) nullpo_retr(0, bl); if(bl->type==BL_PC && (struct map_session_data *)bl){ int atk=((struct map_session_data*)bl)->watk_; - - if(((struct map_session_data *)bl)->sc_data[SC_CURSE].timer!=-1 ) - atk -= atk*25/100; return atk; } else @@ -780,10 +802,19 @@ int battle_get_def(struct block_list *bl) def = def * (100 - sc_data[SC_SIGNUMCRUCIS].val2)/100; //永遠の混沌時はDEF0になる if(sc_data[SC_ETERNALCHAOS].timer!=-1) - def = 0; + def = 0; //コンセントレーション時は減算 if( sc_data[SC_CONCENTRATION].timer!=-1) def = (def*(100 - 5*sc_data[SC_CONCENTRATION].val1))/100; + + if(sc_data[SC_GOSPEL].timer!=-1) { + if (sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 11) + def += def*25/100; + else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 5) + def = 0; + } } } //詠唱中は詠唱時減算率に基づいて減算 @@ -859,6 +890,15 @@ int battle_get_def2(struct block_list *bl) //コンセントレーション時は減算 if( sc_data[SC_CONCENTRATION].timer!=-1) def2 = def2*(100 - 5*sc_data[SC_CONCENTRATION].val1)/100; + + if(sc_data[SC_GOSPEL].timer!=-1) { + if (sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 11) + def2 += def2*25/100; + else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 5) + def2 = 0; + } } if(def2 < 1) def2 = 1; return def2; @@ -942,6 +982,10 @@ int battle_get_speed(struct block_list *bl) speed = speed*150/100; if(sc_data[SC_SPEEDUP0].timer!=-1) speed -= speed*25/100; + if(sc_data[SC_GOSPEL].timer!=-1 && + sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 8) + speed = speed*125/100; } if(speed < 1) speed = 1; return speed; @@ -1002,6 +1046,10 @@ int battle_get_adelay(struct block_list *bl) //ディフェンダー時は加算 if(sc_data[SC_DEFENDER].timer != -1) adelay += (1100 - sc_data[SC_DEFENDER].val1*100); + if(sc_data[SC_GOSPEL].timer!=-1 && + sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 8) + aspd_rate = aspd_rate*125/100; } if(aspd_rate != 100) adelay = adelay*aspd_rate/100; @@ -1315,7 +1363,7 @@ int battle_delay_damage_sub(int tid,unsigned int tick,int id,int data) struct battle_delay_damage_ *dat=(struct battle_delay_damage_ *)data; if( dat && map_id2bl(id)==dat->src && dat->target->prev!=NULL) battle_damage(dat->src,dat->target,dat->damage,dat->flag); - free(dat); + aFree(dat); return 0; } int battle_delay_damage(unsigned int tick,struct block_list *src,struct block_list *target,int damage,int flag) @@ -1487,11 +1535,11 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i struct mob_data *md=NULL; struct status_change *sc_data,*sc; short *sc_count; - int class; + int class_; nullpo_retr(0, bl); - class = battle_get_class(bl); + class_ = battle_get_class(bl); if(bl->type==BL_MOB) md=(struct mob_data *)bl; else sd=(struct map_session_data *)bl; @@ -1612,7 +1660,10 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i } // リジェクトソード if(sc_data[SC_REJECTSWORD].timer!=-1 && damage > 0 && flag&BF_WEAPON && - ((src->type==BL_PC && ((struct map_session_data *)src)->status.weapon == (1 || 2 || 3)) || src->type==BL_MOB )){ + // Fixed the condition check [Aalye] + (src->type==BL_MOB || (src->type==BL_PC && (((struct map_session_data *)src)->status.weapon == 1 || + ((struct map_session_data *)src)->status.weapon == 2 || + ((struct map_session_data *)src)->status.weapon == 3)))){ if(rand()%100 < (15*sc_data[SC_REJECTSWORD].val1)){ //反射確率は15*Lv damage = damage*50/100; clif_damage(bl,src,gettick(),0,0,damage,0,0,0); @@ -1630,22 +1681,22 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i damage<<=1; skill_status_change_end(bl, SC_SPIDERWEB, -1); } - + if(sc_data[SC_FOGWALL].timer != -1 && flag&BF_MAGIC) if(rand()%100 < sc_data[SC_FOGWALL].val2) damage = 0; } - if(class == 1288 || class == 1287 || class == 1286 || class == 1285) { -// if(class == 1288) { - if(class == 1288 && flag&BF_SKILL) + if(class_ == 1288 || class_ == 1287 || class_ == 1286 || class_ == 1285) { +// if(class_ == 1288) { + if(class_ == 1288 && flag&BF_SKILL) damage=0; if(src->type == BL_PC) { struct guild *g=guild_search(((struct map_session_data *)src)->status.guild_id); struct guild_castle *gc=guild_mapname2gc(map[bl->m].name); if(!((struct map_session_data *)src)->status.guild_id) damage=0; - if(gc && agit_flag==0 && class != 1288) // guardians cannot be damaged during non-woe [Valaris] + if(gc && agit_flag==0 && class_ != 1288) // guardians cannot be damaged during non-woe [Valaris] damage=0; // end woe check [Valaris] if(g == NULL) damage=0;//ギルド未加入ならダメージ無し @@ -2010,7 +2061,7 @@ static struct Damage battle_calc_pet_weapon_attack( blewcount=0; break; case AS_GRIMTOOTH: - damage = damage*(100+ 20*skill_lv)/100; + damage = damage*(100+ 20*skill_lv)/100; break; case AS_POISONREACT: // celest s_ele = 0; @@ -2208,7 +2259,7 @@ static struct Damage battle_calc_pet_weapon_attack( hitrate -= 50; if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中 t_sc_data[SC_STAN].timer!=-1 || // スタンは必中 - t_sc_data[SC_FREEZE].timer!=-1 || + t_sc_data[SC_FREEZE].timer!=-1 || (t_sc_data[SC_STONE].timer!=-1 && t_sc_data[SC_STONE].val2==0)) // 凍結は必中 hitrate = 1000000; } @@ -2221,7 +2272,7 @@ static struct Damage battle_calc_pet_weapon_attack( dmg_lv = ATK_DEF; } - + if(t_sc_data) { int cardfix=100; if(t_sc_data[SC_DEFENDER].timer != -1 && flag&BF_LONG) @@ -2507,7 +2558,7 @@ static struct Damage battle_calc_mob_weapon_attack( flag=(flag&~BF_SKILLMASK)|BF_NORMAL; break; case AS_GRIMTOOTH: - damage = damage*(100+ 20*skill_lv)/100; + damage = damage*(100+ 20*skill_lv)/100; break; case AS_POISONREACT: // celest s_ele = 0; @@ -2710,7 +2761,7 @@ static struct Damage battle_calc_mob_weapon_attack( hitrate -= 50; if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中 t_sc_data[SC_STAN].timer!=-1 || // スタンは必中 - t_sc_data[SC_FREEZE].timer!=-1 || + t_sc_data[SC_FREEZE].timer!=-1 || (t_sc_data[SC_STONE].timer!=-1 && t_sc_data[SC_STONE].val2==0)) // 凍結は必中 hitrate = 1000000; } @@ -2762,8 +2813,8 @@ static struct Damage battle_calc_mob_weapon_attack( if(damage < 0) damage = 0; // 属 性の適用 - if (!((battle_config.mob_ghostring_fix == 1) && - (battle_get_elem_type(target) == 8) && + if (!((battle_config.mob_ghostring_fix == 1) && + (battle_get_elem_type(target) == 8) && (target->type==BL_PC))) // [MouseJstr] if(skill_num != 0 || s_ele != 0 || !battle_config.mob_attack_attr_none) damage=battle_attr_fix(damage, s_ele, battle_get_element(target) ); @@ -3506,7 +3557,7 @@ static struct Damage battle_calc_pc_weapon_attack( /* int mdef1=battle_get_mdef(target); int mdef2=battle_get_mdef2(target); int imdef_flag=0; - + damage = ((damage * 5) + (skill_lv * battle_get_int(src) * 5) + rand()%500 + 500) /2; damage2 = ((damage2 * 5) + (skill_lv * battle_get_int(src) * 5) + rand()%500 + 500) /2; damage3 = damage; @@ -3520,7 +3571,7 @@ static struct Damage battle_calc_pc_weapon_attack( // calculate magic part of damage damage3 = skill_lv * battle_get_int(src) * 5; - + // ignores magic defense now [Celest] /*if(sd->ignore_mdef_ele & (1<ignore_mdef_race & (1<status.weapon > 16) {// 二刀流か? int dmg = damage, dmg2 = damage2; @@ -4258,7 +4309,7 @@ struct Damage battle_calc_magic_attack( } else if (target->type == BL_PC) { damage = ((struct map_session_data *)target)->status.sp * 2; matk_flag = 0; // don't consider matk and matk2 - } + } break; } } @@ -4554,6 +4605,7 @@ struct Damage battle_calc_attack( int attack_type, default: if(battle_config.error_log) printf("battle_calc_attack: unknwon attack type ! %d\n",attack_type); + memset(&d,0,sizeof(d)); break; } return d; @@ -4596,7 +4648,7 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target, } if(battle_check_target(src,target,BCT_ENEMY) <= 0 && - !battle_check_range(src,target,0)) + !battle_check_range(src,target,0)) return 0; // 攻撃対象外 race = battle_get_race(target); @@ -4810,8 +4862,8 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target, --t_sc_data[SC_POISONREACT].val2; } if (t_sc_data[SC_POISONREACT].val2<=0) - skill_status_change_end(target,SC_POISONREACT,-1); - } + skill_status_change_end(target,SC_POISONREACT,-1); + } } if (t_sc_data && t_sc_data[SC_BLADESTOP_WAIT].timer != -1 && !(battle_get_mode(src)&0x20)) { // ボスには無効 @@ -4911,7 +4963,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f return -1; if(ss->prev == NULL) return -1; - if(inf2&0x80 && + if(inf2&0x80 && (map[src->m].flag.pvp || pc_iskiller((struct map_session_data *)src, (struct map_session_data *)target)) && // [MouseJstr] !(target->type == BL_PC && pc_isinvisible((struct map_session_data *)target))) return 0; @@ -5037,7 +5089,7 @@ int battle_check_range(struct block_list *src,struct block_list *bl,int range) int dx,dy; struct walkpath_data wpd; int arange; - + nullpo_retr(0, src); nullpo_retr(0, bl); @@ -5182,7 +5234,7 @@ static const struct { { "item_slots_override_grffile", &battle_config.item_slots_override_grffile}, // [Celest] { "indoors_override_grffile", &battle_config.indoors_override_grffile}, // [Celest] { "skill_sp_override_grffile", &battle_config.skill_sp_override_grffile}, // [Celest] - { "cardillust_read_grffile", &battle_config.cardillust_read_grffile}, // [Celest] + { "cardillust_read_grffile", &battle_config.cardillust_read_grffile}, // [Celest] { "arrow_decrement", &battle_config.arrow_decrement }, { "max_aspd", &battle_config.max_aspd }, { "max_hp", &battle_config.max_hp }, @@ -5329,10 +5381,10 @@ static const struct { { "allow_atcommand_when_mute", &battle_config.allow_atcommand_when_mute}, // [celest] { "finding_ore_rate", &battle_config.finding_ore_rate}, // [celest] { "exp_calc_type", &battle_config.exp_calc_type}, // [celest] - { "double_login_system", &battle_config.double_login_system}, // [celest] + { "min_skill_delay_limit", &battle_config.min_skill_delay_limit}, // [celest] //SQL-only options start -#ifndef TXT_ONLY +#ifndef TXT_ONLY { "mail_system", &battle_config.mail_system }, // added by [Valaris] //SQL-only options end #endif @@ -5442,7 +5494,7 @@ void battle_set_defaults() { battle_config.item_slots_override_grffile=0; // [Celest] battle_config.indoors_override_grffile=0; // [Celest] battle_config.skill_sp_override_grffile=0; // [Celest] - battle_config.cardillust_read_grffile=0; // [Celest] + battle_config.cardillust_read_grffile=0; // [Celest] battle_config.arrow_decrement=1; battle_config.max_aspd = 199; battle_config.max_hp = 32500; @@ -5590,10 +5642,10 @@ void battle_set_defaults() { battle_config.castrate_dex_scale = 150; battle_config.area_size = 14; battle_config.exp_calc_type = 1; - battle_config.double_login_system = 0; + battle_config.min_skill_delay_limit = 100; //SQL-only options start -#ifndef TXT_ONLY +#ifndef TXT_ONLY battle_config.mail_system = 0; //SQL-only options end #endif @@ -5710,13 +5762,13 @@ void battle_validate_conf() { // at least 1 client must be accepted if ((battle_config.packet_ver_flag & 127) == 0) // added by [Yor] battle_config.packet_ver_flag = 127; // accept all clients - + if (battle_config.night_darkness_level > 10) // Celest battle_config.night_darkness_level = 10; if (battle_config.skill_range_leniency < 0) // Celest battle_config.skill_range_leniency = 0; - + if (battle_config.motd_type < 0) battle_config.motd_type = 0; else if (battle_config.motd_type > 1) @@ -5728,22 +5780,21 @@ void battle_validate_conf() { if (battle_config.vending_max_value > 10000000 || battle_config.vending_max_value<=0) // Lupus & Kobra_k88 battle_config.vending_max_value = 10000000; - if (battle_config.double_login_system < 0) - battle_config.double_login_system = 0; - + if (battle_config.min_skill_delay_limit < 10) + battle_config.min_skill_delay_limit = 10; // minimum delay of 10ms } /*========================================== * 設定ファイルを読み込む *------------------------------------------ */ -int battle_config_read(const char *cfgName) +int battle_config_read(const char *cfgName) { char line[1024], w1[1024], w2[1024]; FILE *fp; static int count = 0; - if ((count++) == 0) + if ((count++) == 0) battle_set_defaults(); fp = fopen(cfgName,"r"); diff --git a/src/map/battle.h b/src/map/battle.h index 29b537080..d88ea54c1 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -115,6 +115,7 @@ enum { BCT_NOPARTY =0x50000, BCT_ALL =0x20000, BCT_NOONE =0x60000, + BCT_SELF =0x60000, }; int battle_check_undead(int race,int element); @@ -291,7 +292,7 @@ extern struct Battle_Config { int prevent_logout; // Added by RoVeRT int alchemist_summon_reward; // [Valaris] - int maximum_level; + unsigned int maximum_level; int drops_by_luk; int monsters_ignore_gm; int equipment_breaking; @@ -348,7 +349,7 @@ extern struct Battle_Config { int zeny_from_mobs; // [Valaris] int mobs_level_up; // [Valaris] - int pk_min_level; // [celest] + unsigned int pk_min_level; // [celest] int skill_steal_type; // [celest] int skill_steal_rate; // [celest] int night_darkness_level; // [celest] @@ -357,7 +358,7 @@ extern struct Battle_Config { int allow_atcommand_when_mute; // [celest] int finding_ore_rate; // orn int exp_calc_type; - int double_login_system; + int min_skill_delay_limit; #ifndef TXT_ONLY /* SQL-only options */ int mail_system; // [Valaris] diff --git a/src/map/charcommand.c b/src/map/charcommand.c index 1ced08777..5d65c8f01 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -1063,8 +1063,8 @@ int charcommand_item( if (pet_id >= 0) { sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet(sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, - pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, + (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv, + (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); // if not pet egg } else { diff --git a/src/map/chat.c b/src/map/chat.c index c7ec13a5f..cfd2660e0 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -49,7 +49,7 @@ int chat_createchat(struct map_session_data *sd,int limit,int pub,char* pass,cha cd->bl.id = map_addobject(&cd->bl); if(cd->bl.id==0){ clif_createchat(sd,1); - free(cd); + aFree(cd); return 0; } pc_setchatid(sd,cd->bl.id); @@ -82,7 +82,7 @@ int chat_joinchat(struct map_session_data *sd,int chatid,char* pass) clif_joinchatfail(sd,1); return 0; } - if(chatid == sd->chatID) //Double Chat fix by Alex14, thx CHaNGeTe + if(chatid == (int)sd->chatID) //Double Chat fix by Alex14, thx CHaNGeTe { clif_joinchatfail(sd,1); return 0; @@ -290,7 +290,7 @@ int chat_createnpcchat(struct npc_data *nd,int limit,int pub,int trigger,char* t cd->bl.id = map_addobject(&cd->bl); if(cd->bl.id==0){ - free(cd); + aFree(cd); return 0; } nd->chat_id=cd->bl.id; diff --git a/src/map/clif.c b/src/map/clif.c index b72192690..38aa8ab26 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -53,11 +53,15 @@ #define STATE_BLIND 0x10 -int packet_db_ver = -1; // the packet version used by packet_db -int packet_db_connect_cmd = 0xF5; // the default packet used for connecting to the server - +struct Clif_Config clif_config; struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB]; +#define USE_PACKET_DB(sd) \ + clif_config.enable_packet_db && sd->packet_ver == clif_config.packet_db_ver + +#define IS_PACKET_DB_VER(cmd) \ + cmd == clif_config.connect_cmd + static const int packet_len_table[MAX_PACKET_DB] = { 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -66,7 +70,7 @@ static const int packet_len_table[MAX_PACKET_DB] = { //#0x0040 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2, + 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2, #if PACKETVER < 2 3, 28, 19, 11, 3, -1, 9, 5, 52, 51, 56, 58, 41, 2, 6, 6, #else // 78-7b 亀島以降 lv99エフェクト用 @@ -155,7 +159,7 @@ char talkie_mes[80]; * map鯖のip設定 *------------------------------------------ */ -void clif_setip(char *ip) +void clif_setip(char *ip) { memcpy(map_ip_str, ip, 16); map_ip = inet_addr(map_ip_str); @@ -165,7 +169,7 @@ void clif_setip(char *ip) * map鯖のport設定 *------------------------------------------ */ -void clif_setport(int port) +void clif_setport(int port) { map_port = port; } @@ -174,7 +178,7 @@ void clif_setport(int port) * map鯖のip読み出し *------------------------------------------ */ -in_addr_t clif_getip(void) +in_addr_t clif_getip(void) { return map_ip; } @@ -183,7 +187,7 @@ in_addr_t clif_getip(void) * map鯖のport読み出し *------------------------------------------ */ -int clif_getport(void) +int clif_getport(void) { return map_port; } @@ -192,7 +196,7 @@ int clif_getport(void) * *------------------------------------------ */ -int clif_countusers(void) +int clif_countusers(void) { int users = 0, i; struct map_session_data *sd; @@ -209,7 +213,7 @@ int clif_countusers(void) * 全てのclientに対してfunc()実行 *------------------------------------------ */ -int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) +int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) { int i; va_list ap; @@ -228,7 +232,7 @@ int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) * clif_sendでAREA*指定時用 *------------------------------------------ */ -int clif_send_sub(struct block_list *bl, va_list ap) +int clif_send_sub(struct block_list *bl, va_list ap) { unsigned char *buf; int len; @@ -902,17 +906,17 @@ static int clif_set007b(struct map_session_data *sd,unsigned char *buf) { * クラスチェンジ typeはMobの場合は1で他は0? *------------------------------------------ */ -int clif_class_change(struct block_list *bl,int class,int type) +int clif_class_change(struct block_list *bl,int class_,int type) { char buf[16]; nullpo_retr(0, bl); - if(class >= MAX_PC_CLASS) { + if(class_ >= MAX_PC_CLASS) { WBUFW(buf,0)=0x1b0; WBUFL(buf,2)=bl->id; WBUFB(buf,6)=type; - WBUFL(buf,7)=class; + WBUFL(buf,7)=class_; clif_send(buf,packet_len_table[0x1b0],bl,AREA); } @@ -922,9 +926,9 @@ int clif_class_change(struct block_list *bl,int class,int type) * *------------------------------------------ */ -int clif_mob_class_change(struct mob_data *md, int class) { +int clif_mob_class_change(struct mob_data *md, int class_) { char buf[16]; - int view = mob_get_viewclass(class); + int view = mob_get_viewclass(class_); nullpo_retr(0, md); @@ -961,7 +965,7 @@ int clif_mob_equip(struct mob_data *md, int nameid) { * MOB表示1 *------------------------------------------ */ -static int clif_mob0078(struct mob_data *md, unsigned char *buf) +static int clif_mob0078(struct mob_data *md, unsigned char *buf) { int level; @@ -3730,7 +3734,7 @@ void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md) int len; nullpo_retv(sd); nullpo_retv(md); - + if (session[sd->fd] == NULL) return; @@ -3749,7 +3753,7 @@ void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md) clif_specialeffect(&md->bl,423,0); else if(md->size==1) clif_specialeffect(&md->bl,421,0); - + } @@ -4049,8 +4053,8 @@ int clif_moboutsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); nullpo_retr(0, md=va_arg(ap,struct mob_data*)); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_clearchar_id(md->bl.id,0,sd->fd); } @@ -4071,8 +4075,8 @@ int clif_mobinsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); md=va_arg(ap,struct mob_data*); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_getareachar_mob(sd,md); } @@ -4093,8 +4097,8 @@ int clif_petoutsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); nullpo_retr(0, pd=va_arg(ap,struct pet_data*)); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_clearchar_id(pd->bl.id,0,sd->fd); } @@ -4112,8 +4116,8 @@ int clif_npcoutsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); nullpo_retr(0, nd=va_arg(ap,struct npc_data*)); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_clearchar_id(nd->bl.id,0,sd->fd); } @@ -4134,8 +4138,8 @@ int clif_petinsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); pd=va_arg(ap,struct pet_data*); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_getareachar_pet(sd,pd); } @@ -4153,8 +4157,8 @@ int clif_npcinsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); nd=va_arg(ap,struct npc_data*); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_getareachar_npc(sd,nd); } @@ -4701,7 +4705,7 @@ int clif_status_change(struct block_list *bl,int type,int flag) * Send message (modified by [Yor]) *------------------------------------------ */ -int clif_displaymessage(const int fd, char* mes) +int clif_displaymessage(const int fd, char* mes) { //Console [Wizputer] if (fd == 0) @@ -4724,13 +4728,13 @@ int clif_displaymessage(const int fd, char* mes) * 天の声を送信する *------------------------------------------ */ -int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag) +int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag) { unsigned char *buf; int lp; lp = (flag & 0x10) ? 8 : 4; - buf = (unsigned char*)aCalloc(len + lp, sizeof(unsigned char)); + buf = (unsigned char*)aCallocA(len + lp, sizeof(unsigned char)); WBUFW(buf,0) = 0x9a; WBUFW(buf,2) = len + lp; @@ -4743,7 +4747,7 @@ int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag) (flag == 3) ? SELF : ALL_CLIENT); - if(buf) free(buf); + if(buf) aFree(buf); return 0; } @@ -4893,7 +4897,7 @@ int clif_wis_message(int fd, char *nick, char *mes, int mes_len) // R 0097 *------------------------------------------ */ int clif_wis_end(int fd, int flag) // R 0098 .B: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target -{ +{ WFIFOW(fd,0) = 0x98; WFIFOW(fd,2) = flag; WFIFOSET(fd,packet_len_table[0x98]); @@ -5794,7 +5798,7 @@ int clif_hpmeter(struct map_session_data *sd) unsigned char buf[16]; unsigned char buf2[16]; int i; - + nullpo_retr(0, sd); WBUFW(buf,0)=0x107; @@ -5809,7 +5813,7 @@ int clif_hpmeter(struct map_session_data *sd) WFIFOSET(i,packet_len_table[0x107]); } } - + WBUFW(buf2,0)=0x106; WBUFL(buf2,2)=sd->status.account_id; WBUFW(buf2,6)=(sd->status.hp > 0x7fff)? 0x7fff:sd->status.hp; @@ -5821,7 +5825,7 @@ int clif_hpmeter(struct map_session_data *sd) WFIFOSET(i,packet_len_table[0x106]); } } - + return 0; } /*================================================== @@ -5834,7 +5838,7 @@ int clif_update_mobhp(struct mob_data *md) char mobhp[50]; nullpo_retr(0, md); - + WBUFW(buf,0) = 0x95; WBUFL(buf,2) = md->bl.id; @@ -5845,7 +5849,7 @@ int clif_update_mobhp(struct mob_data *md) WBUFL(buf,54) = 0; WBUFL(buf,78) = 0; clif_send(buf,packet_len_table[0x195],&md->bl,AREA); - + return 0; } /*========================================== @@ -6206,7 +6210,7 @@ int clif_combo_delay(struct block_list *bl,int wait) *------------------------------------------ */ int clif_bladestop(struct block_list *src,struct block_list *dst, - int bool) + int _bool) { unsigned char buf[32]; @@ -6216,7 +6220,7 @@ int clif_bladestop(struct block_list *src,struct block_list *dst, WBUFW(buf,0)=0x1d1; WBUFL(buf,2)=src->id; WBUFL(buf,6)=dst->id; - WBUFL(buf,10)=bool; + WBUFL(buf,10)=_bool; clif_send(buf,packet_len_table[0x1d1],src,AREA); @@ -6837,7 +6841,7 @@ int clif_guild_message(struct guild *g,int account_id,const char *mes,int len) struct map_session_data *sd; unsigned char *buf; - buf = (unsigned char*)aCalloc(len + 4, sizeof(unsigned char)); + buf = (unsigned char*)aCallocA(len + 4, sizeof(unsigned char)); WBUFW(buf, 0) = 0x17f; WBUFW(buf, 2) = len + 4; @@ -6846,7 +6850,7 @@ int clif_guild_message(struct guild *g,int account_id,const char *mes,int len) if ((sd = guild_getavailablesd(g)) != NULL) clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD); - if(buf) free(buf); + if(buf) aFree(buf); return 0; } @@ -7043,7 +7047,7 @@ void clif_callpartner(struct map_session_data *sd) * Adopt baby [Celest] *------------------------------------------ */ -void clif_adopt_process(struct map_session_data *sd) +void clif_adopt_process(struct map_session_data *sd) { int fd; nullpo_retv(sd); @@ -7054,7 +7058,7 @@ void clif_adopt_process(struct map_session_data *sd) } /*========================================== - * + * *------------------------------------------ */ void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) { @@ -7067,7 +7071,7 @@ void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) { * 座る *------------------------------------------ */ -void clif_sitting(struct map_session_data *sd) +void clif_sitting(struct map_session_data *sd) { unsigned char buf[64]; @@ -7083,13 +7087,13 @@ void clif_sitting(struct map_session_data *sd) * *------------------------------------------ */ -int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len) +int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len) { unsigned char *buf; nullpo_retr(0, sd); - buf = (unsigned char*)aCalloc(len + 8, sizeof(unsigned char)); + buf = (unsigned char*)aCallocA(len + 8, sizeof(unsigned char)); WBUFW(buf, 0) = 0x17f; WBUFW(buf, 2) = len + 8; @@ -7097,7 +7101,7 @@ int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len) clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); - if(buf) free(buf); + if(buf) aFree(buf); return 0; } @@ -7107,7 +7111,7 @@ int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len) *------------------------------------------ */ -int clif_GM_kickack(struct map_session_data *sd, int id) +int clif_GM_kickack(struct map_session_data *sd, int id) { int fd; @@ -7142,7 +7146,7 @@ int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int ty *------------------------------------------ */ -int clif_timedout(struct map_session_data *sd) +int clif_timedout(struct map_session_data *sd) { nullpo_retr(0, sd); @@ -7247,8 +7251,8 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) { struct map_session_data *pl_sd; int i; for(i = 0; i < fd_max; i++) { - if (session[i] && (pl_sd = session[i]->session_data) != NULL && - pl_sd->state.auth && + if (session[i] && (pl_sd = session[i]->session_data) != NULL && + pl_sd->state.auth && (pc_isGM((struct map_session_data *)&bl) > pc_isGM((struct map_session_data *)&pl_sd->bl))) clif_specialeffect(&pl_sd->bl, type, 1); } @@ -7278,10 +7282,10 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) { * *------------------------------------------ */ -void clif_parse_WantToConnection(int fd, struct map_session_data *sd) +void clif_parse_WantToConnection(int fd, struct map_session_data *sd) { struct map_session_data *old_sd; - int account_id; // account_id in the packet 0x72 or 0x7E + int cmd, account_id; // account_id in the packet 0x72 or 0x7E if (sd) { if (battle_config.error_log) @@ -7289,12 +7293,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) return; } + cmd = RFIFOW(fd,0); + // packet DB - if (RFIFOW(fd,0) == packet_db_connect_cmd) { + if (IS_PACKET_DB_VER(cmd)) { //printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd)); - account_id = RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[0]); + account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[0]); // 0x72 - } else if (RFIFOW(fd,0) == 0x72) { + } else if (cmd == 0x72) { //printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd)); if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) // 00 = Female, 01 = Male account_id = RFIFOL(fd,12); @@ -7303,14 +7309,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) else // old packet version account_id = RFIFOL(fd,2); // 0x7E - } else if (RFIFOW(fd,0) == 0x7E) { + } else if (cmd == 0x7E) { //printf("Received bytes %d with packet 0x7E.\n", RFIFOREST(fd)); if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) // 00 = Female, 01 = Male account_id = RFIFOL(fd,9); else account_id = RFIFOL(fd,12); // 0xF5 - } else if (RFIFOW(fd,0) == 0xF5) { + } else if (cmd == 0xF5) { //printf("Received bytes %d with packet 0xF5.\n", RFIFOREST(fd)); if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) // 00 = Female, 01 = Male account_id = RFIFOL(fd,7); @@ -7319,9 +7325,9 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male account_id = RFIFOL(fd,10); else { // 29 28 28 - if (RFIFOW(fd,1) == 0) // testing ^^; + /*if (RFIFOW(fd,1) == 0) // testing ^^; account_id = RFIFOL(fd,3); - else + else*/ account_id = RFIFOL(fd,5); } // 0x9B @@ -7339,14 +7345,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) sd = session[fd]->session_data = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data)); sd->fd = fd; + if (IS_PACKET_DB_VER(cmd)) { + sd->packet_ver = clif_config.packet_db_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) + pc_setnewpc(sd, account_id, RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[1]), + RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[2]), + RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[3]), + RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[4]), fd); // 0x72 - if (RFIFOW(fd,0) == packet_db_connect_cmd) { - sd->packet_ver = packet_db_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) - pc_setnewpc(sd, account_id, RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[1]), - RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[2]), - RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[3]), - RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[4]), fd); - } else if (RFIFOW(fd,0) == 0x72) { + } else if (cmd == 0x72) { if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) { // 00 = Female, 01 = Male sd->packet_ver = 7; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) pc_setnewpc(sd, account_id, RFIFOL(fd,22), RFIFOL(fd,30), RFIFOL(fd,34), RFIFOB(fd,38), fd); @@ -7358,7 +7364,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) pc_setnewpc(sd, account_id, RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18), fd); } // 0x7E - } else if (RFIFOW(fd,0) == 0x7E) { + } else if (cmd == 0x7E) { if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) { // 00 = Female, 01 = Male sd->packet_ver = 9; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) pc_setnewpc(sd, account_id, RFIFOL(fd,21), RFIFOL(fd,28), RFIFOL(fd,32), RFIFOB(fd,36), fd); @@ -7367,7 +7373,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) pc_setnewpc(sd, account_id, RFIFOL(fd,18), RFIFOL(fd,24), RFIFOL(fd,28), RFIFOB(fd,32), fd); } // 0xF5 - } else if (RFIFOW(fd,0) == 0xF5) { + } else if (cmd == 0xF5) { if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) { // 00 = Female, 01 = Male sd->packet_ver = 10; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) pc_setnewpc(sd, account_id, RFIFOL(fd,15), RFIFOL(fd,25), RFIFOL(fd,29), RFIFOB(fd,33), fd); @@ -7522,7 +7528,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) (sd->sc_data[SC_PROVOKE].timer==-1 || sd->sc_data[SC_PROVOKE].val2==0 )) // オートバーサーク発動 skill_status_change_start(&sd->bl,SC_PROVOKE,10,1,0,0,0,0); - + // if(time(&timer) < ((weddingtime=pc_readglobalreg(sd,"PC_WEDDING_TIME")) + 3600)) // skill_status_change_start(&sd->bl,SC_WEDDING,0,weddingtime,0,0,36000,0); @@ -7568,9 +7574,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) void clif_parse_TickSend(int fd, struct map_session_data *sd) { nullpo_retv(sd); - if (sd->packet_ver == packet_db_ver) { - sd->client_tick=RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - } else { + if (USE_PACKET_DB(sd)) { + sd->client_tick=RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: sd->client_tick = RFIFOL(fd,6); @@ -7597,7 +7603,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { case 16: sd->client_tick = RFIFOL(fd,5); break; - + default: // old version by default (and version 6 + 7) sd->client_tick = RFIFOL(fd,2); break; @@ -7614,7 +7620,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { */ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) { int x, y; - + nullpo_retv(sd); if (pc_isdead(sd)) { @@ -7642,6 +7648,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) { sd->sc_data[SC_BLADESTOP].timer !=-1 || //白刃取り sd->sc_data[SC_SPIDERWEB].timer !=-1 || //スパイダーウェッブ (sd->sc_data[SC_DANCING].timer !=-1 && sd->sc_data[SC_DANCING].val4) || //合奏スキル演奏中は動けない + (sd->sc_data[SC_GOSPEL].timer !=-1 && sd->sc_data[SC_GOSPEL].val4 == BCT_SELF) || // cannot move while gospel is in effect sd->sc_data[SC_CONFUSION].timer !=-1) return; if ((sd->status.option & 2) && pc_checkskill(sd, RG_TUNNELDRIVE) <= 0) @@ -7652,10 +7659,12 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) { pc_stopattack(sd); - if (sd->packet_ver == packet_db_ver) { + if (USE_PACKET_DB(sd)) { int cmd = RFIFOW(fd,0); - x = RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0]) * 4 + (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0] + 1) >> 6); - y = ((RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0]+1) & 0x3f) << 4) + (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0] + 2) >> 4); + x = RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]) * 4 + + (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 1) >> 6); + y = ((RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]+1) & 0x3f) << 4) + + (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 2) >> 4); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 6: @@ -7748,8 +7757,8 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { struct block_list *bl; int account_id; - if (sd->packet_ver == packet_db_ver) { - account_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); + if (USE_PACKET_DB(sd)) { + account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -7785,7 +7794,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { bl = map_id2bl(account_id); if (bl == NULL) return; - + WFIFOW(fd,0) = 0x95; WFIFOL(fd,2) = account_id; @@ -7881,13 +7890,13 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < nullpo_retv(sd); if ((is_atcommand(fd, sd, RFIFOP(fd,4), 0) != AtCommand_None) || (is_charcommand(fd, sd, RFIFOP(fd,4),0)!= CharCommand_None) || - (sd->sc_data && + (sd->sc_data && (sd->sc_data[SC_BERSERK].timer != -1 || //バーサーク時は会話も不可 sd->sc_data[SC_NOCHAT].timer != -1 ))) //チャット禁止 return; - message = (char*)aCalloc(RFIFOW(fd,2) + 128, sizeof(char)); - buf = (char*)aCalloc(RFIFOW(fd,2) + 4, sizeof(char)); + message = (char*)aCallocA(RFIFOW(fd,2) + 128, sizeof(char)); + buf = (char*)aCallocA(RFIFOW(fd,2) + 4, sizeof(char)); //printf("clif_parse_GlobalMessage: message: '%s'.\n", RFIFOP(fd,4)); if (strncmp(RFIFOP(fd,4), sd->status.name, strlen(sd->status.name)) != 0) { @@ -7912,9 +7921,9 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < if (battle_config.ban_spoof_namer > 0) { chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_spoof_namer, 0); // type: 2 - ban (year, month, day, hour, minute, second) clif_setwaitclose(fd); // forced to disconnect because of the hack - - if(message) free(message); - if(buf) free(buf); + + if(message) aFree(message); + if(buf) aFree(buf); return; } @@ -7958,8 +7967,8 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < } } - if(message) free(message); - if(buf) free(buf); + if(message) aFree(message); + if(buf) aFree(buf); return; } @@ -8038,9 +8047,9 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd) { nullpo_retv(sd); - if (sd->packet_ver == packet_db_ver) { - headdir = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - dir = RFIFOB(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + headdir = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + dir = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 7: @@ -8152,9 +8161,9 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { pc_stop_walking(sd, 0); pc_stopattack(sd); - if (sd->packet_ver == packet_db_ver) { - target_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - action_type = RFIFOB(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + action_type = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -8283,20 +8292,20 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 .w status.name, RFIFOP(fd,28)); if ((is_charcommand(fd, sd, gm_command, 0) != CharCommand_None) || (is_atcommand(fd, sd, gm_command, 0) != AtCommand_None) || - (sd && sd->sc_data && + (sd && sd->sc_data && (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可 sd->sc_data[SC_NOCHAT].timer != -1))) //チャット禁止 { - if(gm_command) free(gm_command); + if(gm_command) aFree(gm_command); return; } - if(gm_command) free(gm_command); + if(gm_command) aFree(gm_command); // searching destination character dstsd = map_nick2sd(RFIFOP(fd,4)); @@ -8360,8 +8369,8 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd) { nullpo_retv(sd); - if (sd->packet_ver == packet_db_ver) { - map_object_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); + if (USE_PACKET_DB(sd)) { + map_object_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 7: @@ -8436,9 +8445,9 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd) { sd->sc_data[SC_BERSERK].timer != -1)) ) //バーサーク return; - if (sd->packet_ver == packet_db_ver) { - item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2; - item_amount = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2; + item_amount = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -8505,8 +8514,8 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd) { if (sd->invincible_timer != -1) pc_delinvincibletimer(sd); - if (sd->packet_ver == packet_db_ver) { - pc_useitem(sd,RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2); + if (USE_PACKET_DB(sd)) { + pc_useitem(sd,RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 6: @@ -8888,10 +8897,10 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) { if (sd->chatID || sd->npc_id != 0 || sd->vender_id != 0) return; - if (sd->packet_ver == packet_db_ver) { - skilllv = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - skillnum = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); - target_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[2]); + if (USE_PACKET_DB(sd)) { + skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); + target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 6: @@ -8972,7 +8981,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) { return; } - if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) || + if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) || sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 || sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22) return; @@ -9021,11 +9030,11 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) { if(sd->chatID) return; skillmoreinfo = -1; - if (sd->packet_ver == packet_db_ver) { - skilllv = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - skillnum = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); - x = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[2]); - y = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[3]); + if (USE_PACKET_DB(sd)) { + skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); + x = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]); + y = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[3]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 6: @@ -9146,7 +9155,7 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) { return; } - if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) || + if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) || sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 || sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22) return; @@ -9176,7 +9185,7 @@ void clif_parse_UseSkillMap(int fd,struct map_session_data *sd) if(sd->chatID) return; - if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->sc_data && + if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->sc_data && (sd->sc_data[SC_TRICKDEAD].timer != -1 || sd->sc_data[SC_BERSERK].timer!=-1 || sd->sc_data[SC_NOCHAT].timer!=-1 || @@ -9324,8 +9333,8 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd) void clif_parse_SolveCharName(int fd, struct map_session_data *sd) { int char_id; - if (sd->packet_ver == packet_db_ver) { - char_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); + if (USE_PACKET_DB(sd)) { + char_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -9412,9 +9421,9 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) { if (sd->npc_id != 0 || sd->vender_id != 0) return; - if (sd->packet_ver == packet_db_ver) { - item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2; - item_amount = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2; + item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -9478,9 +9487,9 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) { nullpo_retv(sd); - if (sd->packet_ver == packet_db_ver) { - item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-1; - item_amount = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-1; + item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -9649,7 +9658,7 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) { void clif_parse_PartyMessage(int fd, struct map_session_data *sd) { nullpo_retv(sd); if (is_charcommand(fd, sd, RFIFOP(fd,4), 0) != CharCommand_None) - return; + return; if (is_atcommand(fd, sd, RFIFOP(fd,4), 0) != AtCommand_None) return; if(sd->sc_data && @@ -10093,7 +10102,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by WFIFOW(fd,0) = 0x0d1; // R 00d1 .B .B: type: 0: deny, 1: allow, fail: 0: success, 1: fail WFIFOB(fd,2) = RFIFOB(fd,26); // do nothing only if nick can not exist - if (strlen(nick) < 4) { + if (strlen(nick) < 4) { WFIFOB(fd,3) = 1; // fail WFIFOSET(fd, packet_len_table[0x0d1]); if (RFIFOB(fd,26) == 0) // type @@ -10239,7 +10248,7 @@ void clif_parse_sn_doridori(int fd, struct map_session_data *sd) { * スパノビの爆裂波動 *------------------------------------------ */ -void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd) +void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd) { if(sd){ int nextbaseexp=pc_nextbaseexp(sd); @@ -10369,9 +10378,6 @@ void clif_parse_debug(int fd,struct map_session_data *sd) { int i, cmd; - if (packet_db_ver < 0) - return; - cmd = RFIFOW(fd,0); printf("packet debug 0x%4X\n",cmd); @@ -10562,11 +10568,12 @@ static int clif_parse(int fd) { packet_ver = sd->packet_ver; // check authentification packet to know packet version else { - // packet DB - if (cmd == packet_db_connect_cmd) { - if (RFIFOREST(fd) >= packet_db[packet_db_ver][cmd].len && - (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[4]) == 0 || RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[4]) == 1)) {// 00 = Female, 01 = Male - packet_ver = packet_db_ver; + // packet DB + if (IS_PACKET_DB_VER (cmd)) { + if (RFIFOREST(fd) >= packet_db[clif_config.packet_db_ver][cmd].len && + (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 0 || + RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 1)) {// 00 = Female, 01 = Male + packet_ver = clif_config.packet_db_ver; } // 0x72 } else if (cmd == 0x72) { @@ -10597,9 +10604,9 @@ static int clif_parse(int fd) { else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male packet_ver = 11; // 11: 21sept04 else if (RFIFOREST(fd) >= 29 && (RFIFOB(fd,28) == 0 || RFIFOB(fd,28) == 1)) { // 00 = Female, 01 = Male - if (RFIFOW(fd,1) == 0) // testing ^^; + /*if (RFIFOW(fd,1) == 0) // testing ^^; packet_ver = 15; - else + else*/ packet_ver = 13; // 13: 25oct04 (by [Yor]) } // -- some way to identify version 14 and 15? -- @@ -10625,7 +10632,9 @@ static int clif_parse(int fd) { (packet_ver == 14 && (battle_config.packet_ver_flag & 16) == 0) || (packet_ver == 15 && (battle_config.packet_ver_flag & 32) == 0) || (packet_ver == 16 && (battle_config.packet_ver_flag & 64) == 0) || - packet_ver > MAX_PACKET_VER) { // no support yet + packet_ver > MAX_PACKET_VER || // no packet version support yet + // identified version, but unknown client? + (!sd && packet_db[packet_ver][cmd].func != clif_parse_WantToConnection)) { WFIFOW(fd,0) = 0x6a; WFIFOB(fd,2) = 5; // 05 = Game's EXE is not the latest version WFIFOSET(fd,23); @@ -10731,8 +10740,8 @@ static int packetdb_readdb(void) FILE *fp; char line[1024]; int ln=0; - int cmd,j,packet_ver = 0; - char *str[32],*p,*str2[32],*p2; + int cmd,j,k,packet_ver; + char *str[32],*p,*str2[32],*p2,w1[24],w2[24]; struct { void (*func)(); @@ -10861,18 +10870,51 @@ static int packetdb_readdb(void) return 1; } - packet_db_ver = MAX_PACKET_VER; - + clif_config.packet_db_ver = MAX_PACKET_VER; + packet_ver = MAX_PACKET_VER; // read into packet_db's version by default + while(fgets(line,1020,fp)){ if(line[0]=='/' && line[1]=='/') continue; - if (sscanf(line,"packet_ver: %d",&packet_ver) == 1) { - memcpy(&packet_db[packet_ver], &packet_db[packet_ver - 1], sizeof(packet_db[0])); // copy into new version and continue - // i hope this isn't the wrong way to do things ^^; - continue; + if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) { + if(strcmpi(w1,"packet_ver")==0) { + packet_ver = atoi(w2); + // copy from previous version into new version and continue + // - indicating all following packets should be read into the newer version + // -- on 2nd thought, rereading everything isn't the best thing to do... + // memcpy(&packet_db[packet_ver], &packet_db[packet_ver - 1], sizeof(packet_db[0])); + continue; + } else if(strcmpi(w1,"packet_db_ver")==0) { + // optional: if you do not wish to read multiple versions from the packet_db, + // remove all "packet_ver: ##" lines, and define the packet DB version with this + if(strcmpi(w2,"default")==0) + clif_config.packet_db_ver = MAX_PACKET_VER; + else { + // to manually set the packet DB version + clif_config.packet_db_ver = atoi(w2); + // check for invalid version + if (clif_config.packet_db_ver > MAX_PACKET_VER || + clif_config.packet_db_ver < 0) + clif_config.packet_db_ver = MAX_PACKET_VER; + } + continue; + } else if(strcmpi(w1,"enable_packet_db")==0) { + // whether we want to allow identifying clients via the packet DB + clif_config.enable_packet_db = battle_config_switch(w2); + // if we don't want to read the packet DB, and use hardcoded values only + if (!clif_config.enable_packet_db) + return 0; + continue; + } else if(strcmpi(w1,"prefer_packet_db")==0) { + // whether the packet DB takes higher precedence over the hardcoded one (type 1) + // and whether to overwrite predefined packet length and functions when reading + // from the DB (type 2) + clif_config.prefer_packet_db = battle_config_switch(w2); // not used for now + continue; + } } - memset(str,0,sizeof(str)); + memset(str,0,sizeof(str)); for(j=0,p=line;j<4 && p;j++){ str[j]=p; p=strchr(p,','); @@ -10888,7 +10930,9 @@ static int packetdb_readdb(void) ShowError(tmp_output); continue; } - packet_db[packet_ver][cmd].len = atoi(str[1]); + k = atoi(str[1]); + // if (packet_db[packet_ver][cmd].len != k && clif_config.prefer_packet_db) // not used for now + packet_db[packet_ver][cmd].len = k; if(str[2]==NULL){ ln++; @@ -10897,13 +10941,15 @@ static int packetdb_readdb(void) for(j=0;j 2 /* && packet_db[cmd].pos[0] == 0 */) +// if(packet_db[clif_config.packet_db_ver][cmd].len > 2 /* && packet_db[cmd].pos[0] == 0 */) // printf("packet_db ver %d: %d 0x%x %d %s %p\n",packet_ver,ln,cmd,packet_db[packet_ver][cmd].len,str[2],packet_db[packet_ver][cmd].func); } - + fclose(fp); - sprintf(tmp_output,"Done reading packet version '"CL_WHITE"%d"CL_RESET"' in '"CL_WHITE"%s"CL_RESET"'.\n", packet_db_ver, "db/packet_db.txt"); + sprintf(tmp_output,"Done reading packet version '"CL_WHITE"%d"CL_RESET"' in '"CL_WHITE"%s"CL_RESET"'.\n", clif_config.packet_db_ver, "db/packet_db.txt"); ShowStatus(tmp_output); return 0; @@ -10936,6 +10984,11 @@ static int packetdb_readdb(void) int do_init_clif(void) { int i; + clif_config.enable_packet_db = 1; // whether to use the packet DB for client connection + clif_config.packet_db_ver = -1; // the main packet version of the DB + clif_config.prefer_packet_db = 1; // whether the packet version takes precedence + clif_config.connect_cmd = 0xF5; // the default packet used for connecting to the server + memset(packet_db,0,sizeof(packet_db)); // size of packet version 5 (old) @@ -11163,6 +11216,7 @@ int do_init_clif(void) { packet_db[14][0x21a].len = 282; packet_db[14][0x21b].len = 10; packet_db[14][0x21c].len = 10; +// packet_db[14][0x143].len = 23; // is this required? uncomment if it is // Init packet function calls for packet ver 15 memcpy(packet_db[15], packet_db[14], sizeof(packet_db[0])); packet_db[15][0x072].func = clif_parse_UseSkillToId; @@ -11200,7 +11254,7 @@ int do_init_clif(void) { packet_db[15][0x116].len = 12; packet_db[15][0x190].len = 15; packet_db[15][0x193].len = 21; - packet_db[15][0x21b].len = 6; + packet_db[15][0x21d].len = 6; packet_db[15][0x222].len = 6; packet_db[15][0x221].len = -1; packet_db[15][0x223].len = 8; @@ -11241,12 +11295,14 @@ int do_init_clif(void) { packet_db[16][0x116].len = 20; packet_db[16][0x09f].len = 17; packet_db[16][0x0f7].len = 21; - // Init packet function calls for packet ver 17 (packet db) - memcpy(packet_db[17], packet_db[16], sizeof(packet_db[0])); + packet_db[16][0x143].len = 10; + // Init packet function calls for the packet_db.txt (17) + memcpy(packet_db[MAX_PACKET_VER], packet_db[MAX_PACKET_VER - 1], sizeof(packet_db[0])); #endif - packetdb_readdb(); - + if (clif_config.enable_packet_db) + packetdb_readdb(); + set_defaultparse(clif_parse); #ifdef __WIN32 if (!make_listen_port(map_port)) { diff --git a/src/map/clif.h b/src/map/clif.h index d0cd2e86e..99e0752d1 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -16,7 +16,6 @@ typedef unsigned int in_addr_t; #define MAX_PACKET_DB 0x224 #define MAX_PACKET_VER 17 -extern int packet_db_ver; struct packet_db { short len; void (*func)(); @@ -24,6 +23,13 @@ struct packet_db { }; extern struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB]; +extern struct Clif_Config { + int enable_packet_db; + int packet_db_ver; + int prefer_packet_db; + int connect_cmd; +} clif_config; + void clif_setip(char*); void clif_setport(int); @@ -137,8 +143,8 @@ int clif_petinsight(struct block_list *bl,va_list ap); int clif_npcoutsight(struct block_list *bl,va_list ap); int clif_npcinsight(struct block_list *bl,va_list ap); -int clif_class_change(struct block_list *bl,int class,int type); -int clif_mob_class_change(struct mob_data *md,int class); +int clif_class_change(struct block_list *bl,int class_,int type); +int clif_mob_class_change(struct mob_data *md,int class_); int clif_mob_equip(struct mob_data *md,int nameid); // [Valaris] int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range); @@ -177,7 +183,7 @@ int clif_autospell(struct map_session_data *sd,int skilllv); int clif_devotion(struct map_session_data *sd,int target); int clif_spiritball(struct map_session_data *sd); int clif_combo_delay(struct block_list *src,int wait); -int clif_bladestop(struct block_list *src,struct block_list *dst,int bool); +int clif_bladestop(struct block_list *src,struct block_list *dst,int bool_); int clif_changemapcell(int m,int x,int y,int cell_type,int type); int clif_status_change(struct block_list *bl,int type,int flag); diff --git a/src/map/guild.c b/src/map/guild.c index 5f9e31794..8099ac934 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -284,7 +284,7 @@ int guild_payexp_timer_sub(void *key,void *data,va_list ap) c->exp=0; dellist[(*delp)++]=dataid; - free(c); + aFree(c); return 0; } int guild_payexp_timer(int tid,unsigned int tick,int id,int data) @@ -476,7 +476,7 @@ int guild_recv_info(struct guild *sg) // イベントの発生 if( (ev=numdb_search(guild_infoevent_db,sg->guild_id))!=NULL ){ numdb_erase(guild_infoevent_db,sg->guild_id); - for(;ev;ev2=ev->next,free(ev),ev=ev2){ + for(;ev;ev2=ev->next,aFree(ev),ev=ev2){ npc_event_do(ev->name); } } @@ -750,7 +750,7 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online) return 0; } // ギルドメンバのオンライン状態/Lv更新通知 -int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class) +int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_) { int i,alv,c,idx=0,om=0,oldonline=-1; struct guild *g=guild_search(guild_id); @@ -762,7 +762,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin oldonline=m->online; m->online=online; m->lv=lv; - m->class_=class; + m->class_=class_; idx=i; } if(m->account_id>0){ @@ -938,7 +938,7 @@ int guild_payexp(struct map_session_data *sd,int exp) return 0; if( (c=numdb_search(guild_expcache_db,sd->status.char_id))==NULL ){ - c=(struct guild_expcache *)aCalloc(1,sizeof(struct guild_expcache)); + c=(struct guild_expcache *)aCallocA(1,sizeof(struct guild_expcache)); c->guild_id=sd->status.guild_id; c->account_id=sd->status.account_id; c->char_id=sd->status.char_id; @@ -960,9 +960,9 @@ int guild_getexp(struct map_session_data *sd,int exp) if(sd->status.guild_id==0 || (g=guild_search(sd->status.guild_id))==NULL ) return 0; - + if( (c=numdb_search(guild_expcache_db,sd->status.char_id))==NULL ){ - c=(struct guild_expcache *)aCalloc(1,sizeof(struct guild_expcache)); + c=(struct guild_expcache *)aCallocA(1,sizeof(struct guild_expcache)); c->guild_id=sd->status.guild_id; c->account_id=sd->status.account_id; c->char_id=sd->status.char_id; @@ -1191,7 +1191,7 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id const char *guild_name[2]; struct map_session_data *sd[2]; int j,i; - + guild_id[0] = guild_id1; guild_id[1] = guild_id2; guild_name[0] = name1; @@ -1300,7 +1300,7 @@ int guild_broken(int guild_id,int flag) numdb_foreach(guild_db,guild_broken_sub,guild_id); numdb_erase(guild_db,guild_id); guild_storage_delete(guild_id); - free(g); + aFree(g); return 0; } @@ -1396,7 +1396,7 @@ int guild_castledataloadack(int castle_id,int index,int value) } if( (ev=numdb_search(guild_castleinfoevent_db,code))!=NULL ){ numdb_erase(guild_castleinfoevent_db,code); - for(;ev;ev2=ev->next,free(ev),ev=ev2){ + for(;ev;ev2=ev->next,aFree(ev),ev=ev2){ npc_event_do(ev->name); } } @@ -1500,7 +1500,7 @@ int guild_agit_end(void) int guild_gvg_eliminate_timer(int tid,unsigned int tick,int id,int data) { // Run One NPC_Event[OnAgitEliminate] size_t len = strlen((const char*)data); - char *evname=(char*)aCalloc(len + 4,sizeof(char)); + char *evname=(char*)aCallocA(len + 4,sizeof(char)); int c=0; if(!agit_flag) return 0; // Agit already End @@ -1517,7 +1517,7 @@ int guild_agit_break(struct mob_data *md) nullpo_retr(0, md); - evname=(char *)aCalloc(strlen(md->npc_event) + 1, sizeof(char)); + evname=(char *)aCallocA(strlen(md->npc_event) + 1, sizeof(char)); strcpy(evname,md->npc_event); // Now By User to Run [OnAgitBreak] NPC Event... @@ -1539,7 +1539,7 @@ int guild_checkcastles(struct guild *g) { for(i=0;iguild_id; - if(g->guild_id==cas_id) + if(g->guild_id==cas_id) nb_cas=nb_cas+1; } //end for return nb_cas; @@ -1570,12 +1570,12 @@ int guild_isallied(struct guild *g, struct guild_castle *gc) return 0; } - + static int guild_db_final(void *key,void *data,va_list ap) { struct guild *g=data; - free(g); + aFree(g); return 0; } @@ -1583,7 +1583,7 @@ static int castle_db_final(void *key,void *data,va_list ap) { struct guild_castle *gc=data; - free(gc); + aFree(gc); return 0; } @@ -1591,7 +1591,7 @@ static int guild_expcache_db_final(void *key,void *data,va_list ap) { struct guild_expcache *c=data; - free(c); + aFree(c); return 0; } @@ -1599,7 +1599,7 @@ static int guild_infoevent_db_final(void *key,void *data,va_list ap) { struct eventlist *ev=data; - free(ev); + aFree(ev); return 0; } diff --git a/src/map/guild.h b/src/map/guild.h index eefdcb04e..8f5243a8c 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -56,7 +56,7 @@ int guild_delalliance(struct map_session_data *sd,int guild_id,int flag); int guild_opposition(struct map_session_data *sd,int char_id); int guild_send_memberinfoshort(struct map_session_data *sd,int online); -int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class); +int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_); int guild_change_memberposition(int guild_id,int account_id,int char_id,int idx); int guild_memberposition_changed(struct guild *g,int idx,int pos); int guild_change_position(struct map_session_data *sd,int idx, diff --git a/src/map/intif.c b/src/map/intif.c index 9ba9b1ebb..3f1bbfe88 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -457,7 +457,7 @@ int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const cha } // ギルドメンバのオンライン状況/Lv更新要求 int intif_guild_memberinfoshort(int guild_id, - int account_id,int char_id,int online,int lv,int class) + int account_id,int char_id,int online,int lv,int class_) { if (CheckForCharServer()) return 0; @@ -467,7 +467,7 @@ int intif_guild_memberinfoshort(int guild_id, WFIFOL(inter_fd,10) = char_id; WFIFOB(inter_fd,14) = online; WFIFOW(inter_fd,15) = lv; - WFIFOW(inter_fd,17) = class; + WFIFOW(inter_fd,17) = class_; WFIFOSET(inter_fd,19); return 0; } @@ -640,7 +640,7 @@ int intif_parse_WisMessage(int fd) { // rewritten by [Yor] // if(battle_config.etc_log) // printf("intif_parse_wismessage: %d %s %s %s\n",id,RFIFOP(fd,6),RFIFOP(fd,30),RFIFOP(fd,54) ); - + sd=map_nick2sd(RFIFOP(fd,32)); // 送信先を探す if(sd!=NULL && strcmp(sd->status.name, RFIFOP(fd,32)) == 0){ /* @@ -698,7 +698,7 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 .w .24B struct map_session_data *pl_sd; char Wisp_name[24]; char mbuf[255]; - char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) aMalloc((RFIFOW(fd,2) - 30)) : mbuf; + char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) aMallocA((RFIFOW(fd,2) - 30)) : mbuf; min_gm_level = (int)RFIFOW(fd,28); memcpy(Wisp_name, RFIFOP(fd,4), 24); @@ -712,7 +712,7 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 .w .24B clif_wis_message(i, Wisp_name, message, strlen(message) + 1); if (message != mbuf) - free(message); + aFree(message); return 0; } diff --git a/src/map/intif.h b/src/map/intif.h index 5077dbe18..761c1ea63 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -33,7 +33,7 @@ int intif_guild_create(const char *name, const struct guild_member *master); int intif_guild_request_info(int guild_id); int intif_guild_addmember(int guild_id, struct guild_member *m); int intif_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes); -int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class); +int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class_); int intif_guild_break(int guild_id); int intif_guild_message(int guild_id, int account_id, char *mes, int len); int intif_guild_checkconflict(int guild_id, int account_id, int char_id); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index e6a997976..dd8de15d4 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -530,7 +530,7 @@ static int itemdb_read_itemnametable(void) if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\idnum2itemdisplaynametable.txt"); ShowStatus(tmp_output); @@ -566,7 +566,7 @@ static int itemdb_read_cardillustnametable(void) if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\num2cardillustnametable.txt"); ShowStatus(tmp_output); @@ -604,7 +604,7 @@ static int itemdb_read_itemslottable(void) if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\itemslottable.txt"); ShowStatus(tmp_output); @@ -636,7 +636,7 @@ static int itemdb_read_itemslotcounttable(void) if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\itemslotcounttable.txt"); ShowStatus(tmp_output); @@ -896,10 +896,10 @@ static int itemdb_final(void *key,void *data,va_list ap) nullpo_retr(0, id=data); if(id->use_script) - free(id->use_script); + aFree(id->use_script); if(id->equip_script) - free(id->equip_script); - free(id); + aFree(id->equip_script); + aFree(id); return 0; } diff --git a/src/map/mail.c b/src/map/mail.c index 5d63b6f80..74d2bf7c0 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -30,12 +30,12 @@ extern char msg_table[1000][256]; // Server messages (0-499 reserved for GM comm int mail_check(struct map_session_data *sd,int type) { - int i=0,new=0,priority=0; + int i=0,new_=0,priority=0; char message[50]; if(sd==NULL) return 0; - + sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`from_char_name`,`read_flag`,`priority`,`check_flag` FROM `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id`", mail_db, sd->status.account_id); if (mysql_query(&mail_handle, tmp_msql)) { @@ -64,7 +64,7 @@ int mail_check(struct map_session_data *sd,int type) } if(!atoi(mail_row[3])) { - new++; + new_++; if(atoi(mail_row[4])) priority++; if(type==2 || type==3) { @@ -88,28 +88,28 @@ int mail_check(struct map_session_data *sd,int type) sprintf(message, msg_table[513], i, mail_row[2]); clif_displaymessage(sd->fd, jstrescape(message)); } - + } - + mysql_free_result(mail_res); - + } else { printf("MySQL error (storing query result for %s): %s\n", mail_db, mysql_error(&mail_handle)); return 0; } - if(i>0 && new>0 && type==1) { - //sprintf(message, "You have %d new messages.", new); - sprintf(message, msg_table[514], new); + if(i>0 && new_>0 && type==1) { + //sprintf(message, "You have %d new messages.", new_); + sprintf(message, msg_table[514], new_); clif_displaymessage(sd->fd, jstrescape(message)); } - if(i>0 && new>0 && priority>0 && type==1) { + if(i>0 && new_>0 && priority>0 && type==1) { //sprintf(message, "You have %d unread priority messages.", priority); sprintf(message, msg_table[515], priority); clif_displaymessage(sd->fd, jstrescape(message)); } - if(!new) { + if(!new_) { //clif_displaymessage(sd->fd, "You have no new messages."); clif_displaymessage(sd->fd, msg_table[516]); } @@ -124,7 +124,7 @@ int mail_read(struct map_session_data *sd, int message_id) if(sd==NULL) return 0; - + sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`from_char_name`,`message`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id` LIMIT %d, 1",mail_db,sd->status.account_id,message_id-1); if (mysql_query(&mail_handle, tmp_msql)) { @@ -162,9 +162,9 @@ int mail_read(struct map_session_data *sd, int message_id) printf("DB server Error (update Read `%s`)- %s\n", mail_db, mysql_error(&mail_handle) ); } } - + mysql_free_result(mail_res); - + } else { printf("MySQL error (storing query result for %s): %s\n", mail_db, mysql_error(&mail_handle)); return 0; @@ -177,7 +177,7 @@ int mail_delete(struct map_session_data *sd, int message_id) { if(sd==NULL) return 0; - + sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id` LIMIT %d, 1",mail_db,sd->status.account_id,message_id-1); if (mysql_query(&mail_handle, tmp_msql)) { @@ -217,9 +217,9 @@ int mail_delete(struct map_session_data *sd, int message_id) //else clif_displaymessage(sd->fd,"Message deleted."); else clif_displaymessage(sd->fd,msg_table[521]); } - + mysql_free_result(mail_res); - + } else { printf("MySQL error (delete query result for %s): %s\n", mail_db, mysql_error(&mail_handle)); return 0; @@ -232,7 +232,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) { if(sd==NULL) return 0; - + if(pc_isGM(sd) < 80 && sd->mail_counter > 0) { //clif_displaymessage(sd->fd,"You must wait 10 minutes before sending another message"); clif_displaymessage(sd->fd,msg_table[522]); @@ -254,8 +254,8 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) if (mysql_query(&mail_handle, tmp_msql)) { printf("Database server error (executing query for %s): %s\n", char_db, mysql_error(&mail_handle)); return 0; - } - + } + mail_res = mysql_store_result(&mail_handle); if(mail_res) { if (mysql_num_rows(mail_res) == 0) { @@ -268,7 +268,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) while ((mail_row = mysql_fetch_row(mail_res))) { if(strcmp(name,"*")==0) { sprintf(tmp_msql, "INSERT DELAYED INTO `%s` (`to_account_id`,`from_account_id`,`from_char_name`,`message`,`priority`)" - " VALUES ('%d', '%d', '%s', '%s', '%d')",mail_db, atoi(mail_row[0]), sd->status.account_id, sd->status.name, jstrescape(message), flag); + " VALUES ('%d', '%d', '%s', '%s', '%d')",mail_db, atoi(mail_row[0]), sd->status.account_id, sd->status.name, jstrescape(message), flag); } else { sprintf(tmp_msql, "INSERT DELAYED INTO `%s` (`to_account_id`,`to_char_name`,`from_account_id`,`from_char_name`,`message`,`priority`)" @@ -276,7 +276,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) if(pc_isGM(sd) < 80) sd->mail_counter=5; } - + if(mysql_query(&mail_handle, tmp_msql) ) { mysql_free_result(mail_res); printf("DB server Error (insert `mail_db`)- %s\n", mysql_error(&mail_handle) ); @@ -295,18 +295,18 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) int mail_check_timer(int tid,unsigned int tick,int id,int data) { struct map_session_data *sd = NULL; - int i; + int i; if(mail_timer != tid) return 0; sprintf(tmp_msql,"SELECT DISTINCT `to_account_id` FROM `%s` WHERE `read_flag` = '0' AND `check_flag` = '0'", mail_db); - + if (mysql_query(&mail_handle, tmp_msql)) { printf("Database server error (executing query for %s): %s\n", char_db, mysql_error(&mail_handle)); mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0); return 0; - } + } mail_res = mysql_store_result(&mail_handle); @@ -324,8 +324,8 @@ int mail_check_timer(int tid,unsigned int tick,int id,int data) if(pc_isGM(sd) < 80 && sd->mail_counter > 0) sd->mail_counter--; if(sd->status.account_id==atoi(mail_row[0])) - //clif_displaymessage(sd->fd, "You have new mail."); - clif_displaymessage(sd->fd, msg_table[526]); + //clif_displaymessage(sd->fd, "You have new mail."); + clif_displaymessage(sd->fd, msg_table[526]); } } } @@ -341,7 +341,7 @@ int mail_check_timer(int tid,unsigned int tick,int id,int data) } int do_init_mail(void) -{ +{ add_timer_func_list(mail_check_timer,"mail_check_timer"); mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0); return 0; diff --git a/src/map/map.c b/src/map/map.c index a591c97a2..55d571767 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -193,7 +193,7 @@ int map_getusers(void) { int map_freeblock( void *bl ) { if(block_free_lock==0){ - free(bl); + aFree(bl); bl = NULL; } else{ @@ -229,7 +229,7 @@ int map_freeblock_unlock(void) { // printf("map_freeblock_unlock: free %d object\n",block_free_count); // } for(i=0;ibl.id = map_addobject(&fitem->bl); if(fitem->bl.id==0){ - free(fitem); + aFree(fitem); return 0; } @@ -894,9 +894,9 @@ void map_addchariddb(int charid, char *name) { struct charid2nick *p=NULL; int req=0; - p=numdb_search(charid_db,charid); + p = (struct charid2nick*)numdb_search(charid_db,charid); if(p==NULL){ // デ?タベ?スにない - p = (struct charid2nick *)aCalloc(1,sizeof(struct charid2nick)); + p = (struct charid2nick *)aCallocA(1,sizeof(struct charid2nick)); p->req_id=0; }else numdb_erase(charid_db,charid); @@ -921,7 +921,7 @@ int map_reqchariddb(struct map_session_data * sd,int charid) { nullpo_retr(0, sd); - p=numdb_search(charid_db,charid); + p = (struct charid2nick*)numdb_search(charid_db,charid); if(p!=NULL) // デ?タベ?スにすでにある return 0; p = (struct charid2nick *)aCalloc(1,sizeof(struct charid2nick)); @@ -1005,7 +1005,7 @@ int map_quit(struct map_session_data *sd) { // check if we've been authenticated [celest] if (sd->state.auth) skill_castcancel(&sd->bl,0); // 詠唱を中?する - + skill_stop_dancing(&sd->bl,1);// ダンス/演奏中? if(sd->sc_data && sd->sc_data[SC_BERSERK].timer!=-1) //バ?サ?ク中の終了はHPを100に @@ -1052,7 +1052,7 @@ int map_quit(struct map_session_data *sd) { storage_storage_save(sd); if( sd->npc_stackbuf && sd->npc_stackbuf != NULL) { - free( sd->npc_stackbuf ); + aFree( sd->npc_stackbuf ); sd->npc_stackbuf = NULL; } @@ -1092,7 +1092,7 @@ struct map_session_data * map_id2sd(int id) { struct map_session_data *sd=NULL; for(i = 0; i < fd_max; i++) - if (session[i] && (sd = session[i]->session_data) && sd->bl.id == id) + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd->bl.id == id) return sd; return NULL; @@ -1103,7 +1103,7 @@ struct map_session_data * map_id2sd(int id) { *------------------------------------------ */ char * map_charid2nick(int id) { - struct charid2nick *p=numdb_search(charid_db,id); + struct charid2nick *p = (struct charid2nick*)numdb_search(charid_db,id); if(p==NULL) return NULL; @@ -1130,7 +1130,7 @@ struct map_session_data * map_nick2sd(char *nick) { nicklen = strlen(nick); for (i = 0; i < fd_max; i++) { - if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) + if (session[i] && (pl_sd = (struct map_session_data*)session[i]->session_data) && pl_sd->state.auth) // Without case sensitive check (increase the number of similar character names found) if (strnicmp(pl_sd->status.name, nick, nicklen) == 0) { // Strict comparison (if found, we finish the function immediatly with correct value) @@ -1160,7 +1160,7 @@ struct block_list * map_id2bl(int id) if(idbl); numdb_erase(id_db,map[m].npc[i]->bl.id); if(map[m].npc[i]->bl.subtype==SCRIPT) { -// free(map[m].npc[i]->u.scr.script); -// free(map[m].npc[i]->u.scr.label_list); +// aFree(map[m].npc[i]->u.scr.script); +// aFree(map[m].npc[i]->u.scr.label_list); } - free(map[m].npc[i]); + aFree(map[m].npc[i]); map[m].npc[i] = NULL; n++; } @@ -1238,7 +1238,7 @@ void map_removenpc(void) { int map_mapname2mapid(char *name) { struct map_data *md=NULL; - md=strdb_search(map_db,name); + md = (struct map_data*)strdb_search(map_db,name); #ifdef USE_AFM // If we can't find the .gat map try .afm instead [celest] @@ -1246,7 +1246,7 @@ int map_mapname2mapid(char *name) { char afm_name[16] = ""; strncpy(afm_name, name, strlen(name) - 4); strcat(afm_name, ".afm"); - md = strdb_search(map_db,afm_name); + md = (struct map_data*)strdb_search(map_db,afm_name); } #endif @@ -1262,7 +1262,7 @@ int map_mapname2mapid(char *name) { int map_mapname2ipport(char *name,int *ip,int *port) { struct map_data_other_server *mdos=NULL; - mdos=strdb_search(map_db,name); + mdos = (struct map_data_other_server*)strdb_search(map_db,name); if(mdos==NULL || mdos->gat) return -1; *ip=mdos->ip; @@ -1385,7 +1385,7 @@ int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk) case CELL_CHKTYPE: return m->gat[j]; default: return 0; - } + } return 0; } @@ -1396,7 +1396,7 @@ int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk) int map_setcell(int m,int x,int y,CELL_SET cellset) { int i,j; - + if(x<0 || x>=map[m].xs || y<0 || y>=map[m].ys) return 0; j=x+y*map[m].xs; @@ -1431,7 +1431,7 @@ int map_setipport(char *name,unsigned long ip,int port) { struct map_data *md=NULL; struct map_data_other_server *mdos=NULL; - md=strdb_search(map_db,name); + md = (struct map_data*)strdb_search(map_db,name); if(md==NULL){ // not exist -> add new data mdos=(struct map_data_other_server *)aCalloc(1,sizeof(struct map_data_other_server)); memcpy(mdos->name,name,24); @@ -1459,7 +1459,7 @@ int map_setipport(char *name,unsigned long ip,int port) { * 水場高さ設定 *------------------------------------------ */ -static struct { +static struct waterlist_ { char mapname[24]; int waterheight; } *waterlist=NULL; @@ -1487,7 +1487,7 @@ static void map_readwater(char *watertxt) { return; } if(waterlist==NULL) - waterlist=aCalloc(MAX_MAP_PER_SERVER,sizeof(*waterlist)); + waterlist = (struct waterlist_*)aCallocA(MAX_MAP_PER_SERVER,sizeof(*waterlist)); while(fgets(line,1020,fp) && n < MAX_MAP_PER_SERVER){ int wh,count; if(line[0] == '/' && line[1] == '/') @@ -1554,7 +1554,7 @@ static int map_cache_open(char *fn) { map_cache.head.filesize == ftell(map_cache.fp) ) { // キャッシュ読み込み成功 - map_cache.map = aMalloc(sizeof(struct MAP_CACHE_INFO) * map_cache.head.nmaps); + map_cache.map = (struct MAP_CACHE_INFO*)aMallocA(sizeof(struct MAP_CACHE_INFO) * map_cache.head.nmaps); fseek(map_cache.fp,sizeof(struct MAP_CACHE_HEAD),SEEK_SET); fread(map_cache.map,sizeof(struct MAP_CACHE_INFO),map_cache.head.nmaps,map_cache.fp); return 1; @@ -1567,7 +1567,7 @@ static int map_cache_open(char *fn) { map_cache.fp = fopen(fn,"wb"); if(map_cache.fp) { memset(&map_cache.head,0,sizeof(struct MAP_CACHE_HEAD)); - map_cache.map = aCalloc(sizeof(struct MAP_CACHE_INFO),MAX_CAHCE_MAX); + map_cache.map = (struct MAP_CACHE_INFO*)aCallocA(sizeof(struct MAP_CACHE_INFO),MAX_CAHCE_MAX); map_cache.head.nmaps = MAX_CAHCE_MAX; map_cache.head.sizeof_header = sizeof(struct MAP_CACHE_HEAD); map_cache.head.sizeof_map = sizeof(struct MAP_CACHE_INFO); @@ -1589,7 +1589,7 @@ static void map_cache_close(void) { fwrite(map_cache.map,map_cache.head.nmaps,sizeof(struct MAP_CACHE_INFO),map_cache.fp); } fclose(map_cache.fp); - free(map_cache.map); + aFree(map_cache.map); map_cache.fp = NULL; return; } @@ -1607,14 +1607,14 @@ int map_cache_read(struct map_data *m) { int size = map_cache.map[i].xs * map_cache.map[i].ys; m->xs = map_cache.map[i].xs; m->ys = map_cache.map[i].ys; - m->gat = (unsigned char *)aCalloc(m->xs * m->ys,sizeof(unsigned char)); + m->gat = (unsigned char *)aCallocA(m->xs * m->ys,sizeof(unsigned char)); fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET); if(fread(m->gat,1,size,map_cache.fp) == size) { // 成功 return 1; } else { // なぜかファイル後半が欠けてるので読み直し - m->xs = 0; m->ys = 0; m->gat = NULL; free(m->gat); + m->xs = 0; m->ys = 0; m->gat = NULL; aFree(m->gat); return 0; } } else if(map_cache.map[i].compressed == 1) { @@ -1624,14 +1624,14 @@ int map_cache_read(struct map_data *m) { int size_compress = map_cache.map[i].compressed_len; m->xs = map_cache.map[i].xs; m->ys = map_cache.map[i].ys; - m->gat = (unsigned char *)aMalloc(m->xs * m->ys * sizeof(unsigned char)); - buf = (unsigned char*)aMalloc(size_compress); + m->gat = (unsigned char *)aMallocA(m->xs * m->ys * sizeof(unsigned char)); + buf = (unsigned char*)aMallocA(size_compress); fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET); if(fread(buf,1,size_compress,map_cache.fp) != size_compress) { // なぜかファイル後半が欠けてるので読み直し printf("fread error\n"); m->xs = 0; m->ys = 0; m->gat = NULL; - free(m->gat); free(buf); + aFree(m->gat); aFree(buf); return 0; } dest_len = m->xs * m->ys; @@ -1639,10 +1639,10 @@ int map_cache_read(struct map_data *m) { if(dest_len != map_cache.map[i].xs * map_cache.map[i].ys) { // 正常に解凍が出来てない m->xs = 0; m->ys = 0; m->gat = NULL; - free(m->gat); free(buf); + aFree(m->gat); aFree(buf); return 0; } - free(buf); + aFree(buf); return 1; } } @@ -1669,7 +1669,7 @@ static int map_cache_write(struct map_data *m) { if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { // 圧縮保存 // さすがに2倍に膨れる事はないという事で - write_buf = aMalloc(m->xs * m->ys * 2); + write_buf = (char*)aMallocA(m->xs * m->ys * 2); len_new = m->xs * m->ys * 2; encode_zip(write_buf,&len_new,m->gat,m->xs * m->ys); map_cache.map[i].compressed = 1; @@ -1678,7 +1678,7 @@ static int map_cache_write(struct map_data *m) { len_new = m->xs * m->ys; write_buf = m->gat; map_cache.map[i].compressed = 0; - map_cache.map[i].compressed_len = 0; + map_cache.map[i].compressed_len = 0; } if(len_new <= len_old) { // サイズが同じか小さくなったので場所は変わらない @@ -1696,7 +1696,7 @@ static int map_cache_write(struct map_data *m) { map_cache.map[i].water_height = map_waterheight(m->name); map_cache.dirty = 1; if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { - free(write_buf); + aFree(write_buf); } return 0; } @@ -1706,7 +1706,7 @@ static int map_cache_write(struct map_data *m) { if(map_cache.map[i].fn[0] == 0) { // 新しい場所に登録 if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { - write_buf = aMalloc(m->xs * m->ys * 2); + write_buf = (char*)aMallocA(m->xs * m->ys * 2); len_new = m->xs * m->ys * 2; encode_zip(write_buf,&len_new,m->gat,m->xs * m->ys); map_cache.map[i].compressed = 1; @@ -1727,7 +1727,7 @@ static int map_cache_write(struct map_data *m) { map_cache.head.filesize += len_new; map_cache.dirty = 1; if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { - free(write_buf); + aFree(write_buf); } return 0; } @@ -1819,7 +1819,8 @@ static int map_readafm(int m,char *fn) { map[m].m = m; xs = map[m].xs = afm_size[0]; ys = map[m].ys = afm_size[1]; - map[m].gat = aCalloc(s = map[m].xs * map[m].ys, 1); + // check this, unsigned where it might not need to be + map[m].gat = (unsigned char*)aCallocA(s = map[m].xs * map[m].ys, 1); if(map[m].gat==NULL){ printf("out of memory : map_readmap gat\n"); @@ -1842,14 +1843,14 @@ static int map_readafm(int m,char *fn) { map[m].bxs=(xs+BLOCK_SIZE-1)/BLOCK_SIZE; map[m].bys=(ys+BLOCK_SIZE-1)/BLOCK_SIZE; size = map[m].bxs * map[m].bys * sizeof(struct block_list*); - map[m].block = aCalloc(size, 1); + map[m].block = (struct block_list**)aCalloc(size, 1); if(map[m].block == NULL){ printf("out of memory : map_readmap block\n"); exit(1); } - map[m].block_mob = aCalloc(size, 1); + map[m].block_mob = (struct block_list**)aCalloc(size, 1); if (map[m].block_mob == NULL) { printf("out of memory : map_readmap block_mob\n"); exit(1); @@ -1857,14 +1858,14 @@ static int map_readafm(int m,char *fn) { size = map[m].bxs*map[m].bys*sizeof(int); - map[m].block_count = aCalloc(size, 1); + map[m].block_count = (int*)aCallocA(size, 1); if(map[m].block_count==NULL){ printf("out of memory : map_readmap block\n"); exit(1); } memset(map[m].block_count,0,size); - map[m].block_mob_count=aCalloc(size, 1); + map[m].block_mob_count = (int*)aCallocA(size, 1); if(map[m].block_mob_count==NULL){ printf("out of memory : map_readmap block_mob\n"); exit(1); @@ -1885,9 +1886,9 @@ static int map_readafm(int m,char *fn) { * マップ1枚読み込み * ===================================================*/ static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap) { - unsigned char *gat=""; + char *gat=""; size_t size; - + int i = 0; int e = 0; char progress[21] = " "; @@ -1925,19 +1926,20 @@ static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap) int s; int wh; int x,y,xs,ys; - struct gat_1cell {float high[4]; int type;} *p=NULL; + struct gat_1cell {float high[4]; int type;} *p=NULL; // read & convert fn - gat=grfio_read(fn); + // again, might not need to be unsigned char + gat = grfio_read(fn); if(gat==NULL) { return -1; // さすがにマップが読めないのはまずいので終了する //printf("Can't load map %s\n",fn); //exit(1); } - + xs=map[m].xs=*(int*)(gat+6); ys=map[m].ys=*(int*)(gat+10); - map[m].gat = (unsigned char *)aCalloc(s = map[m].xs * map[m].ys,sizeof(unsigned char)); + map[m].gat = (char *)aCallocA(s = map[m].xs * map[m].ys,sizeof(char)); wh=map_waterheight(map[m].name); for(y=0;y= READ_FROM_BITMAP) { map_cache_open(map_bitmap_filename); @@ -2032,7 +2034,7 @@ int map_readallmap(void) { char buf[64]; *p++ = '\0'; sprintf(buf,"data\\%s", p); - map[i].alias = strdup(buf); + map[i].alias = aStrdup(buf); } else map[i].alias = NULL; @@ -2041,20 +2043,20 @@ int map_readallmap(void) { map_delmap(map[i].name); maps_removed++; i--; - } + } } } - free(waterlist); + aFree(waterlist); printf("\r"); snprintf(tmp_output,sizeof(tmp_output),"Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps.%30s\n",map_num,""); ShowInfo(tmp_output); - + map_cache_close(); if(map_read_flag == CREATE_BITMAP || map_read_flag == CREATE_BITMAP_COMPRESSED) { --map_read_flag; } - + if (maps_removed) { snprintf(tmp_output,sizeof(tmp_output),"Maps Removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed); ShowNotice(tmp_output); @@ -2119,15 +2121,15 @@ int parse_console(char *buf) { int m, n; struct map_session_data *sd; - sd = aCalloc(sizeof(*sd), 1); + sd = (struct map_session_data*)aCalloc(sizeof(*sd), 1); sd->fd = 0; strcpy( sd->status.name , "console"); - type = (char *)aMalloc(64); - command = (char *)aMalloc(64); - map = (char *)aMalloc(64); - buf2 = (char *)aMalloc(72); + type = (char *)aMallocA(64); + command = (char *)aMallocA(64); + map = (char *)aMallocA(64); + buf2 = (char *)aMallocA(72); memset(type,0,64); memset(command,0,64); @@ -2184,12 +2186,12 @@ int parse_console(char *buf) { } end: - free(buf); - free(type); - free(command); - free(map); - free(buf2); - free(sd); + aFree(buf); + aFree(type); + aFree(command); + aFree(map); + aFree(buf2); + aFree(sd); return 0; } @@ -2317,7 +2319,7 @@ int inter_config_read(char *cfgName) if(i!=2) continue; if(strcmpi(w1,"stall_time")==0){ - stall_time_ = atoi(w2); + stall_time_ = atoi(w2); #ifndef TXT_ONLY } else if(strcmpi(w1,"item_db_db")==0){ strcpy(item_db_db,w2); @@ -2484,7 +2486,7 @@ void char_online_check(void) chrif_char_reset_offline(); for(i=0;isession_data) && sd && sd->state.auth && + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd))) if(sd->status.char_id) { chrif_char_online(sd); @@ -2523,21 +2525,22 @@ int flush_timer(int tid, unsigned int tick, int id, int data){ int id_db_final(void *k,void *d,va_list ap) { struct mob_data *id; - nullpo_retr(0, id=d); + nullpo_retr(0, id = (struct mob_data*)d); if(id->lootitem) - free(id->lootitem); + aFree(id->lootitem); if(id) - free(id); + aFree(id); return 0; } + int map_db_final(void *k,void *d,va_list ap) { struct map_data *id; - nullpo_retr(0, id=d); + nullpo_retr(0, id = (struct map_data*)d); if(id->gat) - free(id->gat); + aFree(id->gat); if(id) - free(id); + aFree(id); return 0; } int nick_db_final(void *k,void *d,va_list ap){ return 0; } @@ -2607,14 +2610,14 @@ void do_final(void) { do_final_guild(); /* for(i=0;i= (sizeof(mob_db) / sizeof(mob_db[0])) || mob_db[id].name[0] == '\0') return 0; @@ -85,28 +85,28 @@ int mobdb_checkid(const int id) * The minimum data set for MOB spawning *------------------------------------------ */ -int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class) +int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class_) { nullpo_retr(0, md); md->bl.prev=NULL; md->bl.next=NULL; if(strcmp(mobname,"--en--")==0) - memcpy(md->name,mob_db[class].name,24); + memcpy(md->name,mob_db[class_].name,24); else if(strcmp(mobname,"--ja--")==0) - memcpy(md->name,mob_db[class].jname,24); + memcpy(md->name,mob_db[class_].jname,24); else memcpy(md->name,mobname,24); md->n = 0; - md->base_class = md->class_ = class; + md->base_class = md->class_ = class_; md->bl.id= npc_get_new_npc_id(); memset(&md->state,0,sizeof(md->state)); md->timer = -1; md->target_id=0; md->attacked_id=0; - md->speed=mob_db[class].speed; + md->speed=mob_db[class_].speed; return 0; } @@ -117,10 +117,10 @@ int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class) *------------------------------------------ */ int mob_once_spawn(struct map_session_data *sd,char *mapname, - int x,int y,const char *mobname,int class,int amount,const char *event) + int x,int y,const char *mobname,int class_,int amount,const char *event) { struct mob_data *md=NULL; - int m,count,lv=255,r=class; + int m,count,lv=255,r=class_; if( sd ) lv=sd->status.base_level; @@ -130,27 +130,27 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname, else m=map_mapname2mapid(mapname); - if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>6000) // 値が異常なら召喚を止める + if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // 値が異常なら召喚を止める return 0; - if(class<0){ // ランダムに召喚 + if(class_<0){ // ランダムに召喚 int i=0; - int j=-class-1; + int j=-class_-1; int k; if(j>=0 && j=2000){ - class=mob_db[0].summonper[j]; + class_=mob_db[0].summonper[j]; } }else{ return 0; } // if(battle_config.etc_log) -// printf("mobclass=%d try=%d\n",class,i); +// printf("mobclass=%d try=%d\n",class_,i); } if(sd){ if(x<=0) x=sd->bl.x; @@ -163,21 +163,21 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname, md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data)); memset(md, '\0', sizeof *md); - if(class>4000) { // large/tiny mobs [Valaris] + if(class_>4000) { // large/tiny mobs [Valaris] md->size=2; - class-=4000; + class_-=4000; } - else if(class>MAX_MOB_DB) { + else if(class_>MAX_MOB_DB) { md->size=1; - class-=MAX_MOB_DB; + class_-=MAX_MOB_DB; } - if(mob_db[class].mode&0x02) + if(mob_db[class_].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); else md->lootitem=NULL; - mob_spawn_dataset(md,mobname,class); + mob_spawn_dataset(md,mobname,class_); md->bl.m=m; md->bl.x=x; md->bl.y=y; @@ -195,15 +195,15 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname, md->bl.type=BL_MOB; map_addiddb(&md->bl); mob_spawn(md->bl.id); - - if(class==1288) { // emperium hp based on defense level [Valaris] + + if(class_==1288) { // emperium hp based on defense level [Valaris] struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { - mob_db[class].max_hp+=2000*gc->defense; - md->hp=mob_db[class].max_hp; + mob_db[class_].max_hp+=2000*gc->defense; + md->hp=mob_db[class_].max_hp; } } // end addition [Valaris] - + } return (amount>0)?md->bl.id:0; @@ -214,7 +214,7 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname, */ int mob_once_spawn_area(struct map_session_data *sd,char *mapname, int x0,int y0,int x1,int y1, - const char *mobname,int class,int amount,const char *event) + const char *mobname,int class_,int amount,const char *event) { int x,y,i,max,lx=-1,ly=-1,id=0; int m; @@ -227,7 +227,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname, max=(y1-y0+1)*(x1-x0+1)*3; if(max>1000)max=1000; - if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>6000) // A summon is stopped if a value is unusual + if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // A summon is stopped if a value is unusual return 0; for(i=0;i=0 && class<=1000) || class>MAX_MOB_DB) // Invalid monster classes + if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // Invalid monster classes return 0; - if(class<0) + if(class_<0) return 0; - + if(sd){ if(x<=0) x=sd->bl.x; if(y<=0) y=sd->bl.y; } - + else if(x<=0 || y<=0) printf("mob_spawn_guardian: ??\n"); - + for(count=0;countbl.m=m; md->bl.x=x; md->bl.y=y; @@ -315,7 +315,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname, gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { - mob_db[class].max_hp+=2000*gc->defense; + mob_db[class_].max_hp+=2000*gc->defense; if(guardian==0) { md->hp=gc->Ghp0; gc->GID0=md->bl.id; } if(guardian==1) { md->hp=gc->Ghp1; gc->GID1=md->bl.id; } if(guardian==2) { md->hp=gc->Ghp2; gc->GID2=md->bl.id; } @@ -324,7 +324,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname, if(guardian==5) { md->hp=gc->Ghp5; gc->GID5=md->bl.id; } if(guardian==6) { md->hp=gc->Ghp6; gc->GID6=md->bl.id; } if(guardian==7) { md->hp=gc->Ghp7; gc->GID7=md->bl.id; } - + } } @@ -373,49 +373,49 @@ int mob_exclusion_check(struct mob_data *md,struct map_session_data *sd) * Appearance income of mob *------------------------------------------ */ -int mob_get_viewclass(int class) +int mob_get_viewclass(int class_) { - return mob_db[class].view_class; + return mob_db[class_].view_class; } -int mob_get_sex(int class) +int mob_get_sex(int class_) { - return mob_db[class].sex; + return mob_db[class_].sex; } -short mob_get_hair(int class) +short mob_get_hair(int class_) { - return mob_db[class].hair; + return mob_db[class_].hair; } -short mob_get_hair_color(int class) +short mob_get_hair_color(int class_) { - return mob_db[class].hair_color; + return mob_db[class_].hair_color; } -short mob_get_weapon(int class) +short mob_get_weapon(int class_) { - return mob_db[class].weapon; + return mob_db[class_].weapon; } -short mob_get_shield(int class) +short mob_get_shield(int class_) { - return mob_db[class].shield; + return mob_db[class_].shield; } -short mob_get_head_top(int class) +short mob_get_head_top(int class_) { - return mob_db[class].head_top; + return mob_db[class_].head_top; } -short mob_get_head_mid(int class) +short mob_get_head_mid(int class_) { - return mob_db[class].head_mid; + return mob_db[class_].head_mid; } -short mob_get_head_buttom(int class) +short mob_get_head_buttom(int class_) { - return mob_db[class].head_buttom; + return mob_db[class_].head_buttom; } -short mob_get_clothes_color(int class) // Add for player monster dye - Valaris +short mob_get_clothes_color(int class_) // Add for player monster dye - Valaris { - return mob_db[class].clothes_color; // End + return mob_db[class_].clothes_color; // End } -int mob_get_equip(int class) // mob equip [Valaris] +int mob_get_equip(int class_) // mob equip [Valaris] { - return mob_db[class].equip; + return mob_db[class_].equip; } /*========================================== * Is MOB in the state in which the present movement is possible or not? @@ -432,7 +432,7 @@ int mob_can_move(struct mob_data *md) md->sc_data[SC_AUTOCOUNTER].timer != -1 || //オートカウンター md->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り md->sc_data[SC_SPIDERWEB].timer != -1 //スパイダーウェッブ - ) + ) return 0; return 1; @@ -536,7 +536,7 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data) if(md->walkpath.path_pos>=md->walkpath.path_len) clif_fixmobpos(md); // とまったときに位置の再送信 - } + } return 0; } @@ -613,7 +613,7 @@ static int mob_attack(struct mob_data *md,unsigned int tick,int data) if(tsd && !(mode&0x20) && (tsd->sc_data[SC_TRICKDEAD].timer != -1 || tsd->sc_data[SC_BASILICA].timer != -1 || ((pc_ishiding(tsd) || tsd->state.gangsterparadise) && !((race == 4 || race == 6) && !tsd->perfect_hiding) ) ) ) { md->target_id=0; - md->state.targettype = NONE_ATTACKABLE; + md->state.targettype = NONE_ATTACKABLE; return 0; } @@ -739,7 +739,7 @@ static int mob_timer(int tid,unsigned int tick,int id,int data) if( (bl=map_id2bl(id)) == NULL ){ //攻撃してきた敵がもういないのは正常のようだ return 1; } - + if(!bl || !bl->type || bl->type!=BL_MOB) return 1; @@ -904,7 +904,7 @@ int mob_spawn(int id) if(!md || !md->bl.type || md->bl.type!=BL_MOB) return -1; - + md->last_spawntime=tick; if( md->bl.prev!=NULL ){ // clif_clearchar_area(&md->bl,3); @@ -969,7 +969,7 @@ int mob_spawn(int id) if(gc) md->guild_id = gc->guild_id; } - + md->deletetimer=-1; md->skilltimer=-1; @@ -1042,7 +1042,7 @@ int mob_stop_walking(struct mob_data *md,int type) if(md->state.state == MS_WALK || md->state.state == MS_IDLE) { int dx=0,dy=0; - + md->walkpath.path_len=0; if(type&4){ dx=md->to_x-md->bl.x; @@ -1101,7 +1101,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range) if(gc && agit_flag==0) // Guardians will not attack during non-woe time [Valaris] return 0; // end addition [Valaris] - + if(bl && bl->type == BL_PC){ nullpo_retr(0, sd=(struct map_session_data *)bl); if(!gc) @@ -1183,7 +1183,9 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) return 0; } // Nothing will be carried out if there is no mind of changing TAGE by TAGE ending. - if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && ( !(mode&0x04) || rand()%100>25) ) + if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && (!(mode&0x04) || rand()%100>25) && + // if the monster was provoked ignore the above rule [celest] + !(md->state.provoke_flag && md->state.provoke_flag == bl->id)) return 0; if(mode&0x20 || // Coercion is exerted if it is MVPMOB. @@ -1197,11 +1199,13 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) return 0; } - md->target_id=bl->id; // Since there was no disturbance, it locks on to target. + md->target_id = bl->id; // Since there was no disturbance, it locks on to target. if(bl->type == BL_PC || bl->type == BL_MOB) md->state.targettype = ATTACKABLE; else md->state.targettype = NONE_ATTACKABLE; + if (md->state.provoke_flag) + md->state.provoke_flag = 0; md->min_chase=dist+13; if(md->min_chase>26) md->min_chase=26; @@ -1245,9 +1249,9 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) race=mob_db[smd->class_].race; //対象がPCの場合 if(tsd && - !pc_isdead(tsd) && - tsd->bl.m == smd->bl.m && - tsd->invincible_timer == -1 && + !pc_isdead(tsd) && + tsd->bl.m == smd->bl.m && + tsd->invincible_timer == -1 && !pc_isinvisible(tsd) && (dist=distance(smd->bl.x,smd->bl.y,tsd->bl.x,tsd->bl.y))<9 ) @@ -1259,7 +1263,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) rand()%1000<1000/(++(*pcc)) ){ // 範囲内PCで等確率にする smd->target_id=tsd->bl.id; smd->state.targettype = ATTACKABLE; - smd->min_chase=13; + smd->min_chase=13; } } } @@ -1298,7 +1302,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) mode=mob_db[md->class_].mode; else mode=md->mode; - + if( !md->target_id && mode&0x02){ if(!md->lootitem || (battle_config.monster_loot_type == 1 && md->lootitem_count >= LOOTITEM_SIZE) ) @@ -1393,7 +1397,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) } // Although there is the master, since it is somewhat far, it approaches. - if((!md->target_id || md->state.targettype == NONE_ATTACKABLE) && mob_can_move(md) && + if((!md->target_id || md->state.targettype == NONE_ATTACKABLE) && mob_can_move(md) && (md->walkpath.path_pos>=md->walkpath.path_len || md->walkpath.path_len==0) && md->master_dist<15){ int i=0,dx,dy,ret; if(md->master_dist>4) { @@ -1716,7 +1720,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) ret=mob_walktoxy(md,md->bl.x+dx,md->bl.y+dy,0); i++; } while(ret && i<5); - + if(ret){ // 移動不可能な所からの攻撃なら2歩下る if(dx<0) dx=2; else if(dx>0) dx=-2; @@ -1969,13 +1973,13 @@ static int mob_delay_item_drop(int tid,unsigned int tick,int id,int data) clif_additem(ditem->first_sd,0,0,flag); map_addflooritem(&temp_item,1,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); } - free(ditem); + aFree(ditem); return 0; } map_addflooritem(&temp_item,1,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); - free(ditem); + aFree(ditem); return 0; } @@ -1995,13 +1999,13 @@ static int mob_delay_item_drop2(int tid,unsigned int tick,int id,int data) clif_additem(ditem->first_sd,0,0,flag); map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); } - free(ditem); + aFree(ditem); return 0; } map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); - free(ditem); + aFree(ditem); return 0; } @@ -2219,71 +2223,71 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) } md->hp-=damage; - + if(md->class_ >= 1285 && md->class_ <=1287) { // guardian hp update [Valaris] struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { - if(md->bl.id==gc->GID0) { + if(md->bl.id==gc->GID0) { gc->Ghp0=md->hp; if(gc->Ghp0<=0) { guild_castledatasave(gc->castle_id,10,0); guild_castledatasave(gc->castle_id,18,0); } - } - if(md->bl.id==gc->GID1) { + } + if(md->bl.id==gc->GID1) { gc->Ghp1=md->hp; if(gc->Ghp1<=0) { guild_castledatasave(gc->castle_id,11,0); guild_castledatasave(gc->castle_id,19,0); } } - if(md->bl.id==gc->GID2) { + if(md->bl.id==gc->GID2) { gc->Ghp2=md->hp; if(gc->Ghp2<=0) { guild_castledatasave(gc->castle_id,12,0); guild_castledatasave(gc->castle_id,20,0); } } - if(md->bl.id==gc->GID3) { + if(md->bl.id==gc->GID3) { gc->Ghp3=md->hp; if(gc->Ghp3<=0) { guild_castledatasave(gc->castle_id,13,0); guild_castledatasave(gc->castle_id,21,0); } } - if(md->bl.id==gc->GID4) { + if(md->bl.id==gc->GID4) { gc->Ghp4=md->hp; if(gc->Ghp4<=0) { guild_castledatasave(gc->castle_id,14,0); guild_castledatasave(gc->castle_id,22,0); } } - if(md->bl.id==gc->GID5) { + if(md->bl.id==gc->GID5) { gc->Ghp5=md->hp; if(gc->Ghp5<=0) { guild_castledatasave(gc->castle_id,15,0); guild_castledatasave(gc->castle_id,23,0); } } - if(md->bl.id==gc->GID6) { + if(md->bl.id==gc->GID6) { gc->Ghp6=md->hp; if(gc->Ghp6<=0) { guild_castledatasave(gc->castle_id,16,0); guild_castledatasave(gc->castle_id,24,0); } } - if(md->bl.id==gc->GID7) { + if(md->bl.id==gc->GID7) { gc->Ghp7=md->hp; if(gc->Ghp7<=0) { guild_castledatasave(gc->castle_id,17,0); guild_castledatasave(gc->castle_id,25,0); - + } } } } // end addition [Valaris] - + if(md->option&2 ) skill_status_change_end(&md->bl, SC_HIDING, -1); if(md->option&4 ) @@ -2291,7 +2295,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(md->state.special_mob_ai == 2){//スフィアーマイン int skillidx=0; - + if((skillidx=mob_skillid2skillidx(md->class_,NPC_SELFDESTRUCTION2))>=0){ md->mode |= 0x1; md->next_walktime=tick; @@ -2403,10 +2407,10 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) job_exp=mob_db[md->class_].job_exp*per/256; if(job_exp < 1) job_exp = 1; } - + if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { base_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] - } + } if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { job_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] } @@ -2415,7 +2419,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) job_exp = 0; } else { - if(battle_config.zeny_from_mobs) { + if(battle_config.zeny_from_mobs) { if(md->level > 0) zeny=(md->level+rand()%md->level)*per/256; // zeny calculation moblv + random moblv [Valaris] if(mob_db[md->class_].mexp > 0) zeny*=rand()%250; @@ -2425,7 +2429,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) base_exp+=((md->level-mob_db[md->class_].lv)*mob_db[md->class_].base_exp*.03)*per/256; } } - + if((pid=tmpsd[i]->status.party_id)>0){ // パーティに入っている int j=0; for(j=0;jbl); if(sd->monster_drop_itemid[i] <= 0) continue; - if(sd->monster_drop_race[i] & (1<monster_drop_race[i] & (1<class_].mode & 0x20 && sd->monster_drop_race[i] & 1<<10) || (!(mob_db[md->class_].mode & 0x20) && sd->monster_drop_race[i] & 1<<11) ) { if(sd->monster_drop_itemrate[i] <= rand()%10000) @@ -2572,7 +2576,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) int log_mvp[2] = {0}; int j; int mexp; - temp = ((double)mob_db[md->class_].mexp * (9.+(double)count)/10.); //[Gengar] + temp = ((double)mob_db[md->class_].mexp * (9.+(double)count)/10.); //[Gengar] mexp = (temp > 2147483647.)? 0x7fffffff:(int)temp; if(mexp < 1) mexp = 1; clif_mvp_effect(mvp_sd); // エフェクト @@ -2617,7 +2621,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(md->npc_event[0] && strcmp(((md->npc_event)+strlen(md->npc_event)-13),"::OnAgitBreak") == 0) { printf("MOB.C: Run NPC_Event[OnAgitBreak].\n"); if (agit_flag == 1) //Call to Run NPC_Event[OnAgitBreak] - guild_agit_break(md); + guild_agit_break(md); } // SCRIPT実行 @@ -2665,7 +2669,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) int mob_class_change(struct mob_data *md,int *value) { unsigned int tick = gettick(); - int i,c,hp_rate,max_hp,class,count = 0; + int i,c,hp_rate,max_hp,class_,count = 0; nullpo_retr(0, md); nullpo_retr(0, value); @@ -2677,13 +2681,13 @@ int mob_class_change(struct mob_data *md,int *value) while(count < 5 && value[count] > 1000 && value[count] <= MAX_MOB_DB) count++; if(count < 1) return 0; - class = value[rand()%count]; - if(class<=1000 || class>MAX_MOB_DB) return 0; + class_ = value[rand()%count]; + if(class_<=1000 || class_>MAX_MOB_DB) return 0; max_hp = battle_get_max_hp(&md->bl); hp_rate = md->hp*100/max_hp; - clif_mob_class_change(md,class); - md->class_ = class; + clif_mob_class_change(md,class_); + md->class_ = class_; max_hp = battle_get_max_hp(&md->bl); if(battle_config.monster_class_change_full_recover==1) { md->hp = max_hp; @@ -2694,7 +2698,7 @@ int mob_class_change(struct mob_data *md,int *value) if(md->hp > max_hp) md->hp = max_hp; else if(md->hp < 1) md->hp = 1; - memcpy(md->name,mob_db[class].jname,24); + memcpy(md->name,mob_db[class_].jname,24); memset(&md->state,0,sizeof(md->state)); md->attacked_id = 0; md->target_id = 0; @@ -2710,13 +2714,13 @@ int mob_class_change(struct mob_data *md,int *value) md->next_walktime = tick+rand()%50+5000; md->attackabletime = tick; md->canmove_tick = tick; - + for(i=0,c=tick-1000*3600*10;iskilldelay[i] = c; md->skillid=0; md->skilllv=0; - if(md->lootitem == NULL && mob_db[class].mode&0x02) + if(md->lootitem == NULL && mob_db[class_].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); skill_clear_unitgroup(&md->bl); @@ -2902,7 +2906,7 @@ int mob_countslave(struct mob_data *md) int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag) { struct mob_data *md; - int bx,by,m,count = 0,class,k,a = amount; + int bx,by,m,count = 0,class_,k,a = amount; nullpo_retr(0, md2); nullpo_retr(0, value); @@ -2918,12 +2922,12 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag) for(k=0;kMAX_MOB_DB) continue; + class_ = value[k]; + if(class_<=1000 || class_>MAX_MOB_DB) continue; for(;amount>0;amount--){ int x=0,y=0,i=0; md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data)); - if(mob_db[class].mode&0x02) + if(mob_db[class_].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); else md->lootitem=NULL; @@ -2937,7 +2941,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag) y=by; } - mob_spawn_dataset(md,"--ja--",class); + mob_spawn_dataset(md,"--ja--",class_); md->bl.m=m; md->bl.x=x; md->bl.y=y; @@ -3018,15 +3022,15 @@ int mob_counttargeted(struct mob_data *md,struct block_list *src,int target_lv) *MOBskillから該当skillidのskillidxを返す *------------------------------------------ */ -int mob_skillid2skillidx(int class,int skillid) +int mob_skillid2skillidx(int class_,int skillid) { int i; - struct mob_skill *ms=mob_db[class].skill; - + struct mob_skill *ms=mob_db[class_].skill; + if(ms==NULL) return -1; - for(i=0;ibl.type!=BL_MOB || md->bl.prev==NULL ) return 0; @@ -3259,7 +3263,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx) nullpo_retr(0, md); nullpo_retr(0, ms=&mob_db[md->class_].skill[skill_idx]); - + if( target==NULL && (target=map_id2bl(md->target_id))==NULL ) return 0; @@ -3692,10 +3696,10 @@ int mobskill_event(struct mob_data *md,int flag) int mob_gvmobcheck(struct map_session_data *sd, struct block_list *bl) { struct mob_data *md=NULL; - + nullpo_retr(0,sd); nullpo_retr(0,bl); - + if(bl->type==BL_MOB && (md=(struct mob_data *)bl) && (md->class_ == 1288 || md->class_ == 1287 || md->class_ == 1286 || md->class_ == 1285)) { @@ -3712,7 +3716,7 @@ int mob_gvmobcheck(struct map_session_data *sd, struct block_list *bl) return 0;//正規ギルド承認がないとダメージ無し } - + return 1; } /*========================================== @@ -3739,53 +3743,53 @@ int mobskill_deltimer(struct mob_data *md ) * Since un-setting [ mob ] up was used, it is an initial provisional value setup. *------------------------------------------ */ -static int mob_makedummymobdb(int class) +static int mob_makedummymobdb(int class_) { int i; - sprintf(mob_db[class].name,"mob%d",class); - sprintf(mob_db[class].jname,"mob%d",class); - mob_db[class].lv=1; - mob_db[class].max_hp=1000; - mob_db[class].max_sp=1; - mob_db[class].base_exp=2; - mob_db[class].job_exp=1; - mob_db[class].range=1; - mob_db[class].atk1=7; - mob_db[class].atk2=10; - mob_db[class].def=0; - mob_db[class].mdef=0; - mob_db[class].str=1; - mob_db[class].agi=1; - mob_db[class].vit=1; - mob_db[class].int_=1; - mob_db[class].dex=6; - mob_db[class].luk=2; - mob_db[class].range2=10; - mob_db[class].range3=10; - mob_db[class].size=0; - mob_db[class].race=0; - mob_db[class].element=0; - mob_db[class].mode=0; - mob_db[class].speed=300; - mob_db[class].adelay=1000; - mob_db[class].amotion=500; - mob_db[class].dmotion=500; - mob_db[class].dropitem[0].nameid=909; // Jellopy - mob_db[class].dropitem[0].p=1000; + sprintf(mob_db[class_].name,"mob%d",class_); + sprintf(mob_db[class_].jname,"mob%d",class_); + mob_db[class_].lv=1; + mob_db[class_].max_hp=1000; + mob_db[class_].max_sp=1; + mob_db[class_].base_exp=2; + mob_db[class_].job_exp=1; + mob_db[class_].range=1; + mob_db[class_].atk1=7; + mob_db[class_].atk2=10; + mob_db[class_].def=0; + mob_db[class_].mdef=0; + mob_db[class_].str=1; + mob_db[class_].agi=1; + mob_db[class_].vit=1; + mob_db[class_].int_=1; + mob_db[class_].dex=6; + mob_db[class_].luk=2; + mob_db[class_].range2=10; + mob_db[class_].range3=10; + mob_db[class_].size=0; + mob_db[class_].race=0; + mob_db[class_].element=0; + mob_db[class_].mode=0; + mob_db[class_].speed=300; + mob_db[class_].adelay=1000; + mob_db[class_].amotion=500; + mob_db[class_].dmotion=500; + mob_db[class_].dropitem[0].nameid=909; // Jellopy + mob_db[class_].dropitem[0].p=1000; for(i=1;i<8;i++){ - mob_db[class].dropitem[i].nameid=0; - mob_db[class].dropitem[i].p=0; + mob_db[class_].dropitem[i].nameid=0; + mob_db[class_].dropitem[i].p=0; } // Item1,Item2 - mob_db[class].mexp=0; - mob_db[class].mexpper=0; + mob_db[class_].mexp=0; + mob_db[class_].mexpper=0; for(i=0;i<3;i++){ - mob_db[class].mvpitem[i].nameid=0; - mob_db[class].mvpitem[i].p=0; + mob_db[class_].mvpitem[i].nameid=0; + mob_db[class_].mvpitem[i].p=0; } for(i=0;iMAX_MOB_DB) + class_=atoi(str[0]); + if(class_<=1000 || class_>MAX_MOB_DB) continue; - mob_db[class].view_class=class; - memcpy(mob_db[class].name,str[1],24); - memcpy(mob_db[class].jname,str[2],24); - mob_db[class].lv=atoi(str[3]); - mob_db[class].max_hp=atoi(str[4]); - mob_db[class].max_sp=atoi(str[5]); - - mob_db[class].base_exp=atoi(str[6]); - if(mob_db[class].base_exp < 0) - mob_db[class].base_exp = 0; - else if(mob_db[class].base_exp > 0 && (mob_db[class].base_exp*battle_config.base_exp_rate/100 > 1000000000 || - mob_db[class].base_exp*battle_config.base_exp_rate/100 < 0)) - mob_db[class].base_exp=1000000000; - else - mob_db[class].base_exp*= battle_config.base_exp_rate/100; - - mob_db[class].job_exp=atoi(str[7]); - if(mob_db[class].job_exp < 0) - mob_db[class].job_exp = 0; - else if(mob_db[class].job_exp > 0 && (mob_db[class].job_exp*battle_config.job_exp_rate/100 > 1000000000 || - mob_db[class].job_exp*battle_config.job_exp_rate/100 < 0)) - mob_db[class].job_exp=1000000000; - else - mob_db[class].job_exp*=battle_config.job_exp_rate/100; - - mob_db[class].range=atoi(str[8]); - mob_db[class].atk1=atoi(str[9]); - mob_db[class].atk2=atoi(str[10]); - mob_db[class].def=atoi(str[11]); - mob_db[class].mdef=atoi(str[12]); - mob_db[class].str=atoi(str[13]); - mob_db[class].agi=atoi(str[14]); - mob_db[class].vit=atoi(str[15]); - mob_db[class].int_=atoi(str[16]); - mob_db[class].dex=atoi(str[17]); - mob_db[class].luk=atoi(str[18]); - mob_db[class].range2=atoi(str[19]); - mob_db[class].range3=atoi(str[20]); - mob_db[class].size=atoi(str[21]); - mob_db[class].race=atoi(str[22]); - mob_db[class].element=atoi(str[23]); - mob_db[class].mode=atoi(str[24]); - mob_db[class].speed=atoi(str[25]); - mob_db[class].adelay=atoi(str[26]); - mob_db[class].amotion=atoi(str[27]); - mob_db[class].dmotion=atoi(str[28]); + mob_db[class_].view_class=class_; + memcpy(mob_db[class_].name,str[1],24); + memcpy(mob_db[class_].jname,str[2],24); + mob_db[class_].lv=atoi(str[3]); + mob_db[class_].max_hp=atoi(str[4]); + mob_db[class_].max_sp=atoi(str[5]); + + mob_db[class_].base_exp=atoi(str[6]); + if(mob_db[class_].base_exp < 0) + mob_db[class_].base_exp = 0; + else if(mob_db[class_].base_exp > 0 && (mob_db[class_].base_exp*battle_config.base_exp_rate/100 > 1000000000 || + mob_db[class_].base_exp*battle_config.base_exp_rate/100 < 0)) + mob_db[class_].base_exp=1000000000; + else + mob_db[class_].base_exp*= battle_config.base_exp_rate/100; + + mob_db[class_].job_exp=atoi(str[7]); + if(mob_db[class_].job_exp < 0) + mob_db[class_].job_exp = 0; + else if(mob_db[class_].job_exp > 0 && (mob_db[class_].job_exp*battle_config.job_exp_rate/100 > 1000000000 || + mob_db[class_].job_exp*battle_config.job_exp_rate/100 < 0)) + mob_db[class_].job_exp=1000000000; + else + mob_db[class_].job_exp*=battle_config.job_exp_rate/100; + + mob_db[class_].range=atoi(str[8]); + mob_db[class_].atk1=atoi(str[9]); + mob_db[class_].atk2=atoi(str[10]); + mob_db[class_].def=atoi(str[11]); + mob_db[class_].mdef=atoi(str[12]); + mob_db[class_].str=atoi(str[13]); + mob_db[class_].agi=atoi(str[14]); + mob_db[class_].vit=atoi(str[15]); + mob_db[class_].int_=atoi(str[16]); + mob_db[class_].dex=atoi(str[17]); + mob_db[class_].luk=atoi(str[18]); + mob_db[class_].range2=atoi(str[19]); + mob_db[class_].range3=atoi(str[20]); + mob_db[class_].size=atoi(str[21]); + mob_db[class_].race=atoi(str[22]); + mob_db[class_].element=atoi(str[23]); + mob_db[class_].mode=atoi(str[24]); + mob_db[class_].speed=atoi(str[25]); + mob_db[class_].adelay=atoi(str[26]); + mob_db[class_].amotion=atoi(str[27]); + mob_db[class_].dmotion=atoi(str[28]); for(i=0;i<8;i++){ int rate = 0,type,ratemin,ratemax; - mob_db[class].dropitem[i].nameid=atoi(str[29+i*2]); - type = itemdb_type(mob_db[class].dropitem[i].nameid); + mob_db[class_].dropitem[i].nameid=atoi(str[29+i*2]); + type = itemdb_type(mob_db[class_].dropitem[i].nameid); if (type == 0) { // Added [Valaris] rate = battle_config.item_rate_heal; ratemin = battle_config.item_drop_heal_min; @@ -3947,28 +3951,28 @@ static int mob_readdb(void) } rate = rate * atoi(str[30+i*2])/100; rate = (rate < ratemin)? ratemin: (rate > ratemax)? ratemax: rate; - mob_db[class].dropitem[i].p = rate; + mob_db[class_].dropitem[i].p = rate; } // Item1,Item2 - mob_db[class].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100; - mob_db[class].mexpper=atoi(str[46]); + mob_db[class_].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100; + mob_db[class_].mexpper=atoi(str[46]); for(i=0;i<3;i++){ - mob_db[class].mvpitem[i].nameid=atoi(str[47+i*2]); - mob_db[class].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100; + mob_db[class_].mvpitem[i].nameid=atoi(str[47+i*2]); + mob_db[class_].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100; } for(i=0;iMAX_MOB_DB) // 値が異常なら処理しない。 + if(class_<=1000 || class_>MAX_MOB_DB) // 値が異常なら処理しない。 continue; k=atoi(str[1]); if(k >= 0) - mob_db[class].view_class=k; - - if((mob_db[class].view_class < 24) || (mob_db[class].view_class > 4000)) { - mob_db[class].sex=atoi(str[2]); - mob_db[class].hair=atoi(str[3]); - mob_db[class].hair_color=atoi(str[4]); - mob_db[class].weapon=atoi(str[5]); - mob_db[class].shield=atoi(str[6]); - mob_db[class].head_top=atoi(str[7]); - mob_db[class].head_mid=atoi(str[8]); - mob_db[class].head_buttom=atoi(str[9]); - mob_db[class].option=atoi(str[10])&~0x46; - mob_db[class].clothes_color=atoi(str[11]); // Monster player dye option - Valaris + mob_db[class_].view_class=k; + + if((mob_db[class_].view_class < 24) || (mob_db[class_].view_class > 4000)) { + mob_db[class_].sex=atoi(str[2]); + mob_db[class_].hair=atoi(str[3]); + mob_db[class_].hair_color=atoi(str[4]); + mob_db[class_].weapon=atoi(str[5]); + mob_db[class_].shield=atoi(str[6]); + mob_db[class_].head_top=atoi(str[7]); + mob_db[class_].head_mid=atoi(str[8]); + mob_db[class_].head_buttom=atoi(str[9]); + mob_db[class_].option=atoi(str[10])&~0x46; + mob_db[class_].clothes_color=atoi(str[11]); // Monster player dye option - Valaris } - else if(atoi(str[2]) > 0) mob_db[class].equip=atoi(str[2]); // mob equipment [Valaris] + else if(atoi(str[2]) > 0) mob_db[class_].equip=atoi(str[2]); // mob equipment [Valaris] ln++; } @@ -4066,7 +4070,7 @@ static int mob_read_randommonster(void) return -1; } while(fgets(line,1020,fp)){ - int class,per; + int class_,per; if(line[0] == '/' && line[1] == '/') continue; memset(str,0,sizeof(str)); @@ -4079,10 +4083,10 @@ static int mob_read_randommonster(void) if(str[0]==NULL || str[2]==NULL) continue; - class = atoi(str[0]); + class_ = atoi(str[0]); per=atoi(str[2]); - if((class>1000 && class<=MAX_MOB_DB) || class==0) - mob_db[class].summonper[i]=per; + if((class_>1000 && class_<=MAX_MOB_DB) || class_==0) + mob_db[class_].summonper[i]=per; } fclose(fp); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n",mobfile[i]); @@ -4267,12 +4271,12 @@ void mob_reload(void) static int mob_read_sqldb(void) { char line[1024]; - int i,class; + int i,class_; long unsigned int ln=0; char *str[55],*p,*np; - + memset(mob_db,0,sizeof(mob_db)); - + sprintf (tmp_sql, "SELECT * FROM `%s`",mob_db_db); if(mysql_query(&mmysql_handle, tmp_sql) ) { printf("DB server Error (select %s to Memory)- %s\n",mob_db_db,mysql_error(&mmysql_handle) ); @@ -4301,53 +4305,53 @@ static int mob_read_sqldb(void) } else str[i]=p; } - - class=atoi(str[0]); - if(class<=1000 || class>MAX_MOB_DB) + + class_=atoi(str[0]); + if(class_<=1000 || class_>MAX_MOB_DB) continue; - + ln++; - - mob_db[class].view_class=class; - memcpy(mob_db[class].name,str[1],24); - memcpy(mob_db[class].jname,str[2],24); - mob_db[class].lv=atoi(str[3]); - mob_db[class].max_hp=atoi(str[4]); - mob_db[class].max_sp=atoi(str[5]); - mob_db[class].base_exp=atoi(str[6])* + + mob_db[class_].view_class=class_; + memcpy(mob_db[class_].name,str[1],24); + memcpy(mob_db[class_].jname,str[2],24); + mob_db[class_].lv=atoi(str[3]); + mob_db[class_].max_hp=atoi(str[4]); + mob_db[class_].max_sp=atoi(str[5]); + mob_db[class_].base_exp=atoi(str[6])* battle_config.base_exp_rate/100; - if(mob_db[class].base_exp <= 0) - mob_db[class].base_exp = 1; - mob_db[class].job_exp=atoi(str[7])* + if(mob_db[class_].base_exp <= 0) + mob_db[class_].base_exp = 1; + mob_db[class_].job_exp=atoi(str[7])* battle_config.job_exp_rate/100; - if(mob_db[class].job_exp <= 0) - mob_db[class].job_exp = 1; - mob_db[class].range=atoi(str[8]); - mob_db[class].atk1=atoi(str[9]); - mob_db[class].atk2=atoi(str[10]); - mob_db[class].def=atoi(str[11]); - mob_db[class].mdef=atoi(str[12]); - mob_db[class].str=atoi(str[13]); - mob_db[class].agi=atoi(str[14]); - mob_db[class].vit=atoi(str[15]); - mob_db[class].int_=atoi(str[16]); - mob_db[class].dex=atoi(str[17]); - mob_db[class].luk=atoi(str[18]); - mob_db[class].range2=atoi(str[19]); - mob_db[class].range3=atoi(str[20]); - mob_db[class].size=atoi(str[21]); - mob_db[class].race=atoi(str[22]); - mob_db[class].element=atoi(str[23]); - mob_db[class].mode=atoi(str[24]); - mob_db[class].speed=atoi(str[25]); - mob_db[class].adelay=atoi(str[26]); - mob_db[class].amotion=atoi(str[27]); - mob_db[class].dmotion=atoi(str[28]); + if(mob_db[class_].job_exp <= 0) + mob_db[class_].job_exp = 1; + mob_db[class_].range=atoi(str[8]); + mob_db[class_].atk1=atoi(str[9]); + mob_db[class_].atk2=atoi(str[10]); + mob_db[class_].def=atoi(str[11]); + mob_db[class_].mdef=atoi(str[12]); + mob_db[class_].str=atoi(str[13]); + mob_db[class_].agi=atoi(str[14]); + mob_db[class_].vit=atoi(str[15]); + mob_db[class_].int_=atoi(str[16]); + mob_db[class_].dex=atoi(str[17]); + mob_db[class_].luk=atoi(str[18]); + mob_db[class_].range2=atoi(str[19]); + mob_db[class_].range3=atoi(str[20]); + mob_db[class_].size=atoi(str[21]); + mob_db[class_].race=atoi(str[22]); + mob_db[class_].element=atoi(str[23]); + mob_db[class_].mode=atoi(str[24]); + mob_db[class_].speed=atoi(str[25]); + mob_db[class_].adelay=atoi(str[26]); + mob_db[class_].amotion=atoi(str[27]); + mob_db[class_].dmotion=atoi(str[28]); for(i=0;i<8;i++){ int rate = 0,type,ratemin,ratemax; - mob_db[class].dropitem[i].nameid=atoi(str[29+i*2]); - type = itemdb_type(mob_db[class].dropitem[i].nameid); + mob_db[class_].dropitem[i].nameid=atoi(str[29+i*2]); + type = itemdb_type(mob_db[class_].dropitem[i].nameid); if (type == 0) { // Added by Valaris rate = battle_config.item_rate_heal; ratemin = battle_config.item_drop_heal_min; @@ -4375,27 +4379,27 @@ static int mob_read_sqldb(void) } rate = (rate / 100) * atoi(str[30+i*2]); rate = (rate < ratemin)? ratemin: (rate > ratemax)? ratemax: rate; - mob_db[class].dropitem[i].p = rate; + mob_db[class_].dropitem[i].p = rate; } - - mob_db[class].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100; - mob_db[class].mexpper=atoi(str[46]); + + mob_db[class_].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100; + mob_db[class_].mexpper=atoi(str[46]); for(i=0;i<3;i++){ - mob_db[class].mvpitem[i].nameid=atoi(str[47+i*2]); - mob_db[class].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100; + mob_db[class_].mvpitem[i].nameid=atoi(str[47+i*2]); + mob_db[class_].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100; } for(i=0;iareanpc_id=nd->bl.id; npc_event(sd,strcat(name,"::OnTouch"),0); } - free(name); + aFree(name); return 0; } int npc_enable(const char *name,int flag) @@ -92,7 +92,7 @@ int npc_enable(const char *name,int flag) struct npc_data *nd=strdb_search(npcname_db,name); if (nd==NULL) return 0; - + if (flag&1) { // 有効化 nd->flag&=~1; clif_spawnnpc(nd); @@ -132,7 +132,7 @@ int npc_event_dequeue(struct map_session_data *sd) sd->npc_id=0; if (sd->eventqueue[0][0]) { // キューのイベント処理 - char *name=(char *)aCalloc(50,sizeof(char)); + char *name=(char *)aCallocA(50,sizeof(char)); int i; memcpy(name,sd->eventqueue[0],50); @@ -164,9 +164,9 @@ int npc_event_timer(int tid,unsigned int tick,int id,int data) struct map_session_data *sd=map_id2sd(id); if (sd==NULL) return 0; - + npc_event(sd,(const char *)data,0); - free((void*)data); + aFree((void*)data); return 0; } @@ -226,7 +226,7 @@ int npc_timer(int tid,unsigned int tick,int id,int data) // Added by RoVeRT { strdb_foreach(npcname_db,npc_timer_sub); - free((void*)data); + aFree((void*)data); return 0; }*/ /*========================================== @@ -239,14 +239,14 @@ int npc_event_export(void *key,void *data,va_list ap) char *lname=(char *)key; int pos=(int)data; struct npc_data *nd=va_arg(ap,struct npc_data *); - + if ((lname[0]=='O' || lname[0]=='o')&&(lname[1]=='N' || lname[1]=='n')) { struct event_data *ev; char *buf; char *p=strchr(lname,':'); // エクスポートされる ev=aCalloc(sizeof(struct event_data), 1); - buf=aCalloc(50, 1); + buf=aCallocA(50, 1); if (ev==NULL || buf==NULL) { printf("npc_event_export: out of memory !\n"); exit(1); @@ -344,17 +344,17 @@ int npc_event_doall_sub(void *key,void *data,va_list ap) run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id); (*c)++; } - + return 0; } int npc_event_doall(const char *name) { int c=0; char buf[64]="::"; - + strncpy(buf+2,name,62); strdb_foreach(ev_db,npc_event_doall_sub,&c,buf); - return c; + return c; } int npc_event_do_sub(void *key,void *data,va_list ap) @@ -380,7 +380,7 @@ int npc_event_do_sub(void *key,void *data,va_list ap) int npc_event_do(const char *name) { int c=0; - + if (*name==':' && name[1]==':') { return npc_event_doall(name+2); } @@ -400,7 +400,7 @@ int npc_event_do_clock(int tid,unsigned int tick,int id,int data) char buf[64]; char *day=""; int c=0; - + time(&timer); t=localtime(&timer); @@ -413,7 +413,7 @@ int npc_event_do_clock(int tid,unsigned int tick,int id,int data) case 5: day = "Fri"; break; case 6: day = "Sat"; break; } - + if (t->tm_min != ev_tm_b.tm_min ) { sprintf(buf,"OnMinute%02d",t->tm_min); c+=npc_event_doall(buf); @@ -460,7 +460,7 @@ int npc_addeventtimer(struct npc_data *nd,int tick,const char *name) if( nd->eventtimer[i]==-1 ) break; if(iu.scr.timer_event; int j,i=nd->u.scr.timeramount; - if(te==NULL) te=aMalloc(sizeof(struct npc_timerevent_list)); + if(te==NULL) te=aMallocA(sizeof(struct npc_timerevent_list)); else te=aRealloc( te, sizeof(struct npc_timerevent_list) * (i+1) ); if(te==NULL){ printf("npc_timerevent_import: out of memory !\n"); @@ -581,7 +581,7 @@ int npc_timerevent(int tid,unsigned int tick,int id,int data) nd->u.scr.timertick=tick; te=nd->u.scr.timer_event+ nd->u.scr.nexttimer; nd->u.scr.timerid = -1; - + t = nd->u.scr.timer+=data; nd->u.scr.nexttimer++; if( nd->u.scr.timeramount>nd->u.scr.nexttimer ){ @@ -605,7 +605,7 @@ int npc_timerevent_start(struct npc_data *nd, int rid) n=nd->u.scr.timeramount; if( nd->u.scr.nexttimer>=0 || n==0 ) return 0; - + for(j=0;ju.scr.timer_event[j].timer > nd->u.scr.timer ) break; @@ -617,7 +617,7 @@ int npc_timerevent_start(struct npc_data *nd, int rid) nd->u.scr.timertick=gettick(); if (rid >= 0) nd->u.scr.rid=rid; // changed to: attaching to given rid by default [Shinomori] // if rid is less than 0 leave it unchanged [celest] - + next = nd->u.scr.timer_event[j].timer - nd->u.scr.timer; nd->u.scr.timerid = add_timer(gettick()+next,npc_timerevent,nd->bl.id,next); return 0; @@ -743,7 +743,7 @@ int npc_event(struct map_session_data *sd,const char *eventname,int mob_kill) npc_event_dequeue(sd); return 0; } - + sd->npc_id=nd->bl.id; sd->npc_pos=run_script(nd->u.scr.script,ev->pos,sd->bl.id,nd->bl.id); return 0; @@ -764,7 +764,7 @@ int npc_command_sub(void *key,void *data,va_list ap) if (strcmp(command,temp)==0) run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id); } - + return 0; } @@ -793,7 +793,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y) f=0; continue; } - + switch(map[m].npc[i]->bl.subtype) { case WARP: xs=map[m].npc[i]->u.warp.xs; @@ -824,7 +824,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y) break; case SCRIPT: { - char *name=(char *)aCalloc(50,sizeof(char)); + char *name=(char *)aCallocA(50,sizeof(char)); memcpy(name,map[m].npc[i]->name,50); if(sd->areanpc_id==map[m].npc[i]->bl.id) @@ -832,7 +832,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y) sd->areanpc_id=map[m].npc[i]->bl.id; if(npc_event(sd,strcat(name,"::OnTouch"),0)>0) npc_click(sd,map[m].npc[i]->bl.id); - free(name); + aFree(name); break; } } @@ -855,7 +855,7 @@ int npc_checknear(struct map_session_data *sd,int id) printf("no such npc : %d\n",id); return 1; } - + if (nd->class_<0) // イベント系は常にOK return 0; @@ -968,7 +968,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) { struct npc_data *nd; double z; - int i,j,w,skill,itemamount=0,new=0; + int i,j,w,skill,itemamount=0,new_=0; nullpo_retr(3, sd); nullpo_retr(3, item_list); @@ -998,7 +998,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) case ADDITEM_EXIST: break; case ADDITEM_NEW: - new++; + new_++; break; case ADDITEM_OVERAMOUNT: return 2; @@ -1010,7 +1010,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) return 1; // zeny不足 if (w+sd->weight > sd->max_weight) return 2; // 重量超過 - if (pc_inventoryblank(sd)walkpath.path_pos>=nd->walkpath.path_len) clif_fixnpcpos(nd); // When npc stops, retransmission current of a position. - + } return 0; } @@ -1237,7 +1237,7 @@ static int npc_walktimer(int tid,unsigned int tick,int id,int data) if(nd->walktimer != tid){ return 0; } - + nd->walktimer=-1; if(nd->bl.prev == NULL) @@ -1302,7 +1302,7 @@ int npc_stop_walking(struct npc_data *nd,int type) if(nd->state.state == MS_WALK || nd->state.state == MS_IDLE) { int dx=0,dy=0; - + nd->walkpath.path_len=0; if(type&4){ dx=nd->to_x-nd->bl.x; @@ -1352,7 +1352,7 @@ void npc_clearsrcfile() while( p ) { struct npc_src_list *p2=p; p=p->next; - free(p2); + aFree(p2); } npc_src_first=NULL; npc_src_last=NULL; @@ -1363,7 +1363,7 @@ void npc_clearsrcfile() */ void npc_addsrcfile(char *name) { - struct npc_src_list *new; + struct npc_src_list *new_; size_t len; if ( strcmpi(name,"clear")==0 ) { @@ -1382,16 +1382,16 @@ void npc_addsrcfile(char *name) } } - len = sizeof(*new) + strlen(name); - new=(struct npc_src_list *)aCalloc(1,len); - new->next = NULL; - strncpy(new->name,name,strlen(name)+1); + len = sizeof(*new_) + strlen(name); + new_=(struct npc_src_list *)aCalloc(1,len); + new_->next = NULL; + strncpy(new_->name,name,strlen(name)+1); if (npc_src_first==NULL) - npc_src_first = new; + npc_src_first = new_; if (npc_src_last) - npc_src_last->next = new; + npc_src_last->next = new_; - npc_src_last=new; + npc_src_last=new_; } /*========================================== * 読み込むnpcファイルの削除 @@ -1411,7 +1411,7 @@ void npc_delsrcfile(char *name) *lp=p->next; if ( npc_src_last==p ) npc_src_last=pp; - free(p); + aFree(p); break; } } @@ -1525,7 +1525,7 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4) p=strchr(p,','); } if (pos == 0) { - free(nd); + aFree(nd); return 1; } nd->u.shop_item[pos++].nameid = 0; @@ -1545,7 +1545,7 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4) nd->opt1 = 0; nd->opt2 = 0; nd->opt3 = 0; - + nd = (struct npc_data *)aRealloc(nd, sizeof(struct npc_data) + sizeof(nd->u.shop_item[0]) * pos); @@ -1572,14 +1572,14 @@ int npc_convertlabel_db(void *key,void *data,va_list ap) struct npc_label_list *lst; int num; char *p=strchr(lname,':'); - + nullpo_retr(0, ap); nullpo_retr(0, nd=va_arg(ap,struct npc_data *)); lst=nd->u.scr.label_list; num=nd->u.scr.label_list_num; if(!lst){ - lst=(struct npc_label_list *)aCalloc(1,sizeof(struct npc_label_list)); + lst=(struct npc_label_list *)aCallocA(1,sizeof(struct npc_label_list)); num=0; }else lst=(struct npc_label_list *)aRealloc(lst,sizeof(struct npc_label_list)*(num+1)); @@ -1598,7 +1598,7 @@ int npc_convertlabel_db(void *key,void *data,va_list ap) */ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line,FILE *fp,int *lines) { - int x,y,dir=0,m,xs=0,ys=0,class=0; // [Valaris] thanks to fov + int x,y,dir=0,m,xs=0,ys=0,class_=0; // [Valaris] thanks to fov char mapname[24]; unsigned char *srcbuf=NULL,*script; int srcsize=65536; @@ -1627,7 +1627,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line if(strcmp(w2,"script")==0){ // スクリプトの解析 - srcbuf=(char *)aCalloc(srcsize,sizeof(char)); + srcbuf=(char *)aCallocA(srcsize,sizeof(char)); if (strchr(first_line,'{')) { strcpy(srcbuf,strchr(first_line,'{')); startline=*lines; @@ -1657,13 +1657,13 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line script=parse_script(srcbuf,startline); if (script==NULL) { // script parse error? - free(srcbuf); + aFree(srcbuf); return 1; } }else{ // duplicateする - + char srcname[128]; struct npc_data *nd2; if( sscanf(w2,"duplicate(%[^)])",srcname)!=1 ){ @@ -1678,22 +1678,22 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line label_dup=nd2->u.scr.label_list; label_dupnum=nd2->u.scr.label_list_num; src_id=nd2->bl.id; - + }// end of スクリプト解析 nd=(struct npc_data *)aCalloc(1,sizeof(struct npc_data)); if(m==-1){ // スクリプトコピー用のダミーNPC - - }else if( sscanf(w4,"%d,%d,%d",&class,&xs,&ys)==3) { + + }else if( sscanf(w4,"%d,%d,%d",&class_,&xs,&ys)==3) { // 接触型NPC int i,j; - + if (xs>=0)xs=xs*2+1; if (ys>=0)ys=ys*2+1; - - if (class>=0) { + + if (class_>=0) { for(i=0;iu.scr.xs=xs; nd->u.scr.ys=ys; } else { // クリック型NPC - class=atoi(w4); + class_=atoi(w4); nd->u.scr.xs=0; nd->u.scr.ys=0; } - - if (class<0 && m>=0) { // イベント型NPC + + if (class_<0 && m>=0) { // イベント型NPC evflag=1; } @@ -1735,7 +1735,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line nd->bl.id=npc_get_new_npc_id(); nd->dir = dir; nd->flag=0; - nd->class_=class; + nd->class_=class_; nd->speed=200; nd->u.scr.script=script; nd->u.scr.src_id=src_id; @@ -1766,21 +1766,21 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line //----------------------------------------- - // ラベルデータの準備 + // ラベルデータの準備 if(srcbuf){ // script本体がある場合の処理 - + // ラベルデータのコンバート label_db=script_get_label_db(); strdb_foreach(label_db,npc_convertlabel_db,nd); - + // もう使わないのでバッファ解放 - free(srcbuf); + aFree(srcbuf); }else{ // duplicate -// nd->u.scr.label_list=aMalloc(sizeof(struct npc_label_list)*label_dupnum); +// nd->u.scr.label_list=aMallocA(sizeof(struct npc_label_list)*label_dupnum); // memcpy(nd->u.scr.label_list,label_dup,sizeof(struct npc_label_list)*label_dupnum); nd->u.scr.label_list=label_dup; // ラベルデータ共有 @@ -1792,13 +1792,13 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line for(i=0;iu.scr.label_list_num;i++){ char *lname=nd->u.scr.label_list[i].name; int pos=nd->u.scr.label_list[i].pos; - + if ((lname[0]=='O' || lname[0]=='o')&&(lname[1]=='N' || lname[1]=='n')) { struct event_data *ev; char *buf; // エクスポートされる ev=(struct event_data *)aCalloc(1,sizeof(struct event_data)); - buf=(char *)aCalloc(50,sizeof(char)); + buf=(char *)aCallocA(50,sizeof(char)); if (strlen(lname)>24) { printf("npc_parse_script: label name error !\n"); exit(1); @@ -1810,7 +1810,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line } } } - + //----------------------------------------- // ラベルデータからタイマーイベント取り込み for(i=0;iu.scr.label_list_num;i++){ @@ -1822,7 +1822,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line struct npc_timerevent_list *te=nd->u.scr.timer_event; int j,k=nd->u.scr.timeramount; if(te==NULL) - te=(struct npc_timerevent_list *)aCalloc(1,sizeof(struct npc_timerevent_list)); + te=(struct npc_timerevent_list *)aCallocA(1,sizeof(struct npc_timerevent_list)); else te=(struct npc_timerevent_list *)aRealloc( te, sizeof(struct npc_timerevent_list) * (k+1) ); for(j=0;ju.scr.nexttimer=-1; nd->u.scr.timerid=-1; - + return 0; } @@ -1859,7 +1859,7 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li char *p; // スクリプトの解析 - srcbuf=(char *)aCalloc(srcsize,sizeof(char)); + srcbuf=(char *)aCallocA(srcsize,sizeof(char)); if (strchr(first_line,'{')) { strcpy(srcbuf,strchr(first_line,'{')); startline=*lines; @@ -1889,11 +1889,11 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li script=parse_script(srcbuf,startline); if (script==NULL) { // script parse error? - free(srcbuf); + aFree(srcbuf); return 1; } - p=(char *)aCalloc(50,sizeof(char)); + p=(char *)aCallocA(50,sizeof(char)); strncpy(p,w3,50); strdb_insert(script_get_userfunc_db(),p,script); @@ -1901,10 +1901,10 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li // label_db=script_get_label_db(); // もう使わないのでバッファ解放 - free(srcbuf); - + aFree(srcbuf); + // printf("function %s => %p\n",p,script); - + return 0; } @@ -1915,7 +1915,7 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li */ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) { - int m,x,y,xs,ys,class,num,delay1,delay2,level; + int m,x,y,xs,ys,class_,num,delay1,delay2,level; int i; char mapname[24]; char mobname[24]; @@ -1926,7 +1926,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) delay1=delay2=0; // 引数の個数チェック if (sscanf(w1,"%[^,],%d,%d,%d,%d",mapname,&x,&y,&xs,&ys) < 3 || - sscanf(w4,"%d,%d,%d,%d,%s",&class,&num,&delay1,&delay2,eventname) < 2 ) { + sscanf(w4,"%d,%d,%d,%d,%s",&class_,&num,&delay1,&delay2,eventname) < 2 ) { printf("bad monster line : %s\n",w3); return 1; } @@ -1941,13 +1941,13 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) for(i=0;i4000) { // large/tiny mobs [Valaris] + if(class_>4000) { // large/tiny mobs [Valaris] md->size=2; - class-=4000; + class_-=4000; } - else if(class>2000) { + else if(class_>2000) { md->size=1; - class-=2000; + class_-=2000; } md->bl.prev=NULL; @@ -1958,9 +1958,9 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) if(sscanf(w3,"%[^,],%d",mobname,&level) > 1) { if(strcmp(mobname,"--en--")==0) - memcpy(md->name,mob_db[class].name,24); + memcpy(md->name,mob_db[class_].name,24); else if(strcmp(mobname,"--ja--")==0) - memcpy(md->name,mob_db[class].jname,24); + memcpy(md->name,mob_db[class_].jname,24); md->level=level; } @@ -1968,7 +1968,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) memcpy(md->name,w3,24); md->n = i; - md->base_class = md->class_ = class; + md->base_class = md->class_ = class_; md->bl.id=npc_get_new_npc_id(); md->m =m; md->x0=x; @@ -1982,9 +1982,9 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) md->timer = -1; md->target_id=0; md->attacked_id=0; - md->speed=mob_db[class].speed; + md->speed=mob_db[class_].speed; - if (mob_db[class].mode&0x02) + if (mob_db[class_].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); else md->lootitem=NULL; @@ -2122,19 +2122,19 @@ static int npc_parse_mapflag(char *w1,char *w2,char *w3,char *w4) } else if (strcmpi(w3,"noicewall")==0) { // noicewall [Valaris] map[m].flag.noicewall=1; - } + } else if (strcmpi(w3,"snow")==0) { // snow [Valaris] map[m].flag.snow=1; - } + } else if (strcmpi(w3,"fog")==0) { // fog [Valaris] map[m].flag.fog=1; - } + } else if (strcmpi(w3,"sakura")==0) { // sakura [Valaris] map[m].flag.sakura=1; - } + } else if (strcmpi(w3,"leaves")==0) { // leaves [Valaris] map[m].flag.leaves=1; - } + } else if (strcmpi(w3,"rain")==0) { // rain [Valaris] map[m].flag.rain=1; } @@ -2144,7 +2144,7 @@ static int npc_parse_mapflag(char *w1,char *w2,char *w3,char *w4) else if (strcmpi(w3,"nogo")==0) { // celest map[m].flag.nogo=1; } - + return 0; } @@ -2169,12 +2169,12 @@ static int npc_read_indoors(void) if ((m = map_mapname2mapid(map_name)) >= 0) map[m].flag.indoors=1; } - + p=strchr(p,10); if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\indoorrswtable.txt"); ShowStatus(tmp_output); @@ -2183,9 +2183,9 @@ static int npc_read_indoors(void) static int ev_db_final(void *key,void *data,va_list ap) { - free(data); + aFree(data); if(strstr(key,"::")!=NULL) - free(key); + aFree(key); return 0; } static int npcname_db_final(void *key,void *data,va_list ap) @@ -2214,49 +2214,49 @@ int do_final_npc(void) if((bl=map_id2bl(i))){ if(bl->type == BL_NPC && (nd = (struct npc_data *)bl)){ if(nd->chat_id && (cd=(struct chat_data*)map_id2bl(nd->chat_id))){ - free(cd); + aFree(cd); cd = NULL; } if(nd->bl.subtype == SCRIPT){ if(nd->u.scr.timer_event) - free(nd->u.scr.timer_event); + aFree(nd->u.scr.timer_event); if(nd->u.scr.src_id==0){ if(nd->u.scr.script){ - free(nd->u.scr.script); + aFree(nd->u.scr.script); nd->u.scr.script=NULL; } if(nd->u.scr.label_list){ - free(nd->u.scr.label_list); + aFree(nd->u.scr.label_list); nd->u.scr.label_list = NULL; } } } - free(nd); + aFree(nd); nd = NULL; }else if(bl->type == BL_MOB && (md = (struct mob_data *)bl)){ if(md->lootitem){ - free(md->lootitem); + aFree(md->lootitem); md->lootitem = NULL; } - free(md); + aFree(md); md = NULL; }else if(bl->type == BL_PET && (pd = (struct pet_data *)bl)){ - free(pd); + aFree(pd); pd = NULL; } } } - + return 0; } -void ev_release(struct dbn *db, int which) +void ev_release(struct dbn *db, int which) { if (which & 0x1) - free(db->key); + aFree(db->key); if (which & 0x2) - free(db->data); + aFree(db->data); } /*========================================== @@ -2281,12 +2281,12 @@ int do_init_npc(void) npcname_db=strdb_init(24); ev_db->release = ev_release; - + memset(&ev_tm_b,-1,sizeof(ev_tm_b)); for(nsl=npc_src_first;nsl;nsl=nsl->next) { /*if(nsl->prev){ // [Shinomori] - free(nsl->prev); + aFree(nsl->prev); nsl->prev = NULL; }*/ fp=fopen(nsl->name,"r"); diff --git a/src/map/party.c b/src/map/party.c index 28f05bab9..3c3c12886 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -30,7 +30,7 @@ int party_send_xyhp_timer(int tid,unsigned int tick,int id,int data); */ static int party_db_final(void *key,void *data,va_list ap) { - free(data); + aFree(data); return 0; } void do_final_party(void) diff --git a/src/map/pc.c b/src/map/pc.c index 2954dfddf..c17e8677b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -87,11 +87,11 @@ int pc_isGM(struct map_session_data *sd) { if (p == NULL) return 0; return p->level;*/ - + //For console [Wizputer] if ( sd->fd == 0 ) return 99; - + for(i = 0; i < GM_num; i++) if (gm_account[i].account_id == sd->status.account_id) return gm_account[i].level; @@ -218,7 +218,7 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) { sd->spiritball = 0; if(sd->spiritball >= max) { - if(sd->spirit_timer[0] != -1) + if(sd->spirit_timer[0] != -1) delete_timer(sd->spirit_timer[0],pc_spiritball_timer); memcpy( &sd->spirit_timer[0], &sd->spirit_timer[1], sizeof(sd->spirit_timer[0]) * (sd->spiritball - 1)); } else @@ -554,7 +554,7 @@ int pc_isequip(struct map_session_data *sd,int n) item = sd->inventory_data[n]; sc_data = battle_get_sc_data(&sd->bl); - //s_class = pc_calc_base_job(sd->status.class); + //s_class = pc_calc_base_job(sd->status.class_); if( battle_config.gm_allequip>0 && pc_isGM(sd)>=battle_config.gm_allequip ) return 1; @@ -599,7 +599,7 @@ int pc_break_equip(struct map_session_data *sd, unsigned short where) struct item_data* item; int i; int sc; - char output[255]; + char output[255]; if(sd == NULL) return -1; @@ -669,7 +669,7 @@ int pc_breakweapon(struct map_session_data *sd) return 1; } } - + return 0; } /*========================================== @@ -755,7 +755,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->skillitem = -1; sd->skillitemlv = -1; sd->invincible_timer = -1; - + sd->deal_locked = 0; sd->trade_partner = 0; @@ -772,7 +772,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->doridori_counter = 0; - sd->change_level = pc_readglobalreg(sd,"jobchange_level"); + sd->change_level = pc_readglobalreg(sd,"jobchange_level"); #ifndef TXT_ONLY // mail system [Valaris] if(battle_config.mail_system) @@ -790,7 +790,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->dev.val1[i] = 0; sd->dev.val2[i] = 0; } - + // アカウント??の送信要求 intif_request_accountreg(sd); @@ -876,7 +876,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->state.event_death = pc_readglobalreg(sd,"PCDieEvent"); sd->state.event_kill = pc_readglobalreg(sd,"PCKillEvent"); sd->state.event_disconnect = pc_readglobalreg(sd,"PCLogoffEvent"); - + if (night_flag == 1 && !map[sd->bl.m].flag.indoors) { char tmpstr[1024]; strcpy(tmpstr, msg_txt(500)); // Actually, it's the night... @@ -1016,7 +1016,7 @@ int pc_calc_skilltree(struct map_session_data *sd) for(i=0;istatus.skill[i].flag != 13) + if (sd->status.skill[i].flag != 13) sd->status.skill[i].id=0; if (sd->status.skill[i].flag && sd->status.skill[i].flag != 13){ // cardスキルなら、 sd->status.skill[i].lv=(sd->status.skill[i].flag==1)?0:sd->status.skill[i].flag-2; // 本?のlvに @@ -1030,13 +1030,13 @@ int pc_calc_skilltree(struct map_session_data *sd) sd->status.skill[i].id=i; for(i=210;i<291;i++) sd->status.skill[i].id=i; - for(i=304;i<337;i++){ + for(i=304;i<338;i++){ if(i==331) continue; sd->status.skill[i].id=i; } if(battle_config.enable_upper_class){ //confで無?でなければ?み?む - for(i=355;istatus.skill[i].id=i; + for(i=355;i<411;i++) + sd->status.skill[i].id=i; } }else{ do { @@ -1052,6 +1052,8 @@ int pc_calc_skilltree(struct map_session_data *sd) break; } } + if (id >= 2 && id <= 53 && pc_checkskill(sd, NV_BASIC) < 9) + f=0; } if(f && sd->status.skill[id].id==0 ){ sd->status.skill[id].id=id; @@ -1073,7 +1075,7 @@ int pc_calc_skilltree_normalize_job(int c, struct map_session_data *sd) { c = 0; //else if((sd->status.skill_point >= sd->status.job_level && skill_point < 58) && ((c > 6 && c < 23) || (c > 4007 && c < 4023) || (c > 4029 && c < 4045))) { //else if ((sd->status.skill_point >= sd->status.job_level && skill_point < 58) && (c > 6 && c < 23)) { - else if ((sd->status.skill_point >= sd->status.job_level && skill_point < sd->change_level+8) && (c > 6 && c < 23)) { + else if (sd->status.skill_point >= sd->status.job_level && ((sd->change_level > 0 && skill_point < sd->change_level+8) || skill_point < 58) && (c > 6 && c < 23)) { switch(c) { case 7: case 13: @@ -1178,7 +1180,7 @@ int pc_checkweighticon(struct map_session_data *sd) flag=1; if(sd->weight*10 >= sd->max_weight*9) flag=2; - + if(flag==1){ if(sd->sc_data[SC_WEIGHT50].timer==-1) skill_status_change_start(&sd->bl,SC_WEIGHT50,0,0,0,0,0,0); @@ -1670,6 +1672,16 @@ int pc_calcstatus(struct map_session_data* sd,int first) sd->paramb[5] += sd->status.luk+psd->status.luk/2 > 99 ? 99-sd->status.luk : psd->status.luk/2; } } + if(sd->sc_data[SC_GOSPEL].timer!=-1 && sd->sc_data[SC_GOSPEL].val4 == BCT_PARTY){ + if (sd->sc_data[SC_GOSPEL].val3 == 6) { + sd->paramb[0]+= 2; + sd->paramb[1]+= 2; + sd->paramb[2]+= 2; + sd->paramb[3]+= 2; + sd->paramb[4]+= 2; + sd->paramb[5]+= 2; + } + } } //1度も死んでないJob70スパノビに+10 @@ -1769,7 +1781,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) else if (pc_isriding(sd)) { // ペコペコ?りによる速度?加 sd->speed -= (0.25 * DEFAULT_WALK_SPEED); sd->max_weight += 10000; - } + } if((skill=pc_checkskill(sd,CR_TRUST))>0) { // フェイス sd->status.max_hp += skill*200; sd->subele[6] += skill*5; @@ -1788,7 +1800,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) sd->status.max_hp = sd->status.max_hp * 130/100; else if (s_class.upper==2) sd->status.max_hp = sd->status.max_hp * 70/100; - + if(sd->hprate!=100) sd->status.max_hp = sd->status.max_hp*sd->hprate/100; @@ -1910,6 +1922,13 @@ int pc_calcstatus(struct map_session_data* sd,int first) } if(sd->sc_data[SC_POISON].timer!=-1) // 毒?態 sd->def2 = sd->def2*75/100; + if(sd->sc_data[SC_CURSE].timer!=-1){ + sd->base_atk = sd->base_atk*75/100; + sd->watk = sd->watk*75/100; + index = sd->equip_index[8]; + if(index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == 4) + sd->watk_ = sd->watk_*75/100; + } if(sd->sc_data[SC_DRUMBATTLE].timer!=-1){ // ?太鼓の響き sd->watk += sd->sc_data[SC_DRUMBATTLE].val2; sd->def += sd->sc_data[SC_DRUMBATTLE].val3; @@ -2113,8 +2132,62 @@ int pc_calcstatus(struct map_session_data* sd,int first) sd->def = 100; if(sd->sc_data[SC_BARRIER].timer!=-1) sd->mdef = 100; + + if(sd->sc_data[SC_GOSPEL].timer!=-1) { + if (sd->sc_data[SC_GOSPEL].val4 == BCT_PARTY){ + switch (sd->sc_data[SC_GOSPEL].val3) + { + case 4: + sd->status.max_hp += sd->status.max_hp * 25 / 100; + if(sd->status.max_hp > battle_config.max_hp) + sd->status.max_hp = battle_config.max_hp; + break; + case 5: + sd->status.max_sp += sd->status.max_sp * 25 / 100; + if(sd->status.max_sp > battle_config.max_sp) + sd->status.max_sp = battle_config.max_sp; + break; + case 11: + sd->def += sd->def * 25 / 100; + sd->def2 += sd->def2 * 25 / 100; + break; + case 12: + sd->base_atk += sd->base_atk * 8 / 100; + break; + case 13: + sd->flee += sd->flee * 5 / 100; + break; + case 14: + sd->hit += sd->hit * 5 / 100; + break; + } + } else if (sd->sc_data[SC_GOSPEL].val4 == BCT_ENEMY){ + switch (sd->sc_data[SC_GOSPEL].val3) + { + case 5: + sd->def = 0; + sd->def2 = 0; + break; + case 6: + sd->base_atk = 0; + sd->watk = 0; + sd->watk2 = 0; + break; + case 7: + sd->flee = 0; + break; + case 8: + sd->speed_rate += 75; + aspd_rate += 75; + break; + } + } + } } + if (sd->speed_rate <= 0) + sd->speed_rate = 1; + if(sd->speed_rate != 100) sd->speed = sd->speed*sd->speed_rate/100; if(sd->speed < 1) sd->speed = 1; @@ -2216,7 +2289,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) clif_updatestatus(sd,SP_CARTINFO);*/ //if(sd->status.hpstatus.max_hp>>2 && pc_checkskill(sd,SM_AUTOBERSERK)>0 && - if(sd->status.hpstatus.max_hp>>2 && sd->sc_data[SC_AUTOBERSERK].timer != -1 && + if(sd->status.hpstatus.max_hp>>2 && sd->sc_data[SC_AUTOBERSERK].timer != -1 && (sd->sc_data[SC_PROVOKE].timer==-1 || sd->sc_data[SC_PROVOKE].val2==0 ) && !pc_isdead(sd)) // オ?トバ?サ?ク?動 skill_status_change_start(&sd->bl,SC_PROVOKE,10,1,0,0,0,0); @@ -2239,7 +2312,7 @@ int pc_calcspeed (struct map_session_data *sd) b_speed = sd->speed; sd->speed = DEFAULT_WALK_SPEED ; - + if(sd->sc_count){ if(sd->sc_data[SC_INCREASEAGI].timer!=-1 && sd->sc_data[SC_QUAGMIRE].timer == -1 && sd->sc_data[SC_DONTFORGETME].timer == -1){ // 速度?加 sd->speed -= sd->speed *25/100; @@ -2303,7 +2376,7 @@ int pc_calcspeed (struct map_session_data *sd) if(sd->speed_rate != 100) sd->speed = sd->speed*sd->speed_rate/100; if(sd->speed < 1) sd->speed = 1; - + if(sd->skilltimer != -1 && (skill = pc_checkskill(sd,SA_FREECAST)) > 0) { sd->prev_speed = sd->speed; sd->speed = sd->speed*(175 - skill*5)/100; @@ -2932,7 +3005,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag !=2){ sd->random_attack_increase_add = type2; sd->random_attack_increase_per += val; - } + } break; case SP_WEAPON_ATK: if(sd->state.lr_flag != 2) @@ -3662,7 +3735,7 @@ int pc_item_refine(struct map_session_data *sd,int idx) int flag = 1, i = 0, ep = 0, per; int material[5] = { 0, 1010, 1011, 984, 984 }; struct item *item; - + nullpo_retr(0, sd); item = &sd->status.inventory[idx]; @@ -3681,7 +3754,7 @@ int pc_item_refine(struct map_session_data *sd,int idx) per = percentrefinery [itemdb_wlv (item->nameid)][(int)item->refine]; //per += pc_checkskill(sd,BS_WEAPONRESEARCH); per *= (75 + sd->status.job_level/2)/100; - + if (per > rand() % 100) { flag = 0; item->refine++; @@ -3691,7 +3764,7 @@ int pc_item_refine(struct map_session_data *sd,int idx) pc_unequipitem(sd,idx,3); } clif_refine(sd->fd,sd,0,idx,item->refine); - clif_delitem(sd,idx,1); + clif_delitem(sd,idx,1); clif_additem(sd,idx,1,0); if (ep) pc_equipitem(sd,idx,ep); @@ -3777,7 +3850,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl) if(itemid > 0 && itemdb_type(itemid) != 6) { rate = (mob_db[md->class_].dropitem[i].p / battle_config.item_rate_common * 100 * skill)/100; - + if(rand()%10000 < rate) { struct item tmp_item; @@ -3882,7 +3955,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt if(sd->sc_data[SC_DANCING].timer!=-1) // clear dance effect when warping [Valaris] skill_stop_dancing(&sd->bl,0); } - + if(sd->status.option&2) skill_status_change_end(&sd->bl, SC_HIDING, -1); if(sd->status.option&4) @@ -3894,7 +3967,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt pet_stopattack(sd->pd); pet_changestate(sd->pd,MS_IDLE,0); } - + if(sd->disguise) { // clear disguises when warping [Valaris] clif_clearchar(&sd->bl, 9); disguise=sd->disguise; @@ -4000,13 +4073,13 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt if(disguise) // disguise teleport fix [Valaris] sd->disguise=disguise; - + memcpy(sd->mapname,mapname,24); sd->bl.m = m; sd->to_x = x; sd->to_y = y; - // moved and changed dance effect stopping + // moved and changed dance effect stopping sd->bl.x = x; sd->bl.y = y; @@ -4336,19 +4409,19 @@ int pc_walktoxy(struct map_session_data *sd,int x,int y) if (sd->sc_data && sd->status.guild_id > 0) { struct skill_unit *su; struct skill_unit_group *sg; - if (sd->state.leadership_flag && (su=(struct skill_unit *)sd->state.leadership_flag) && + if (sd->state.leadership_flag && (su=(struct skill_unit *)sd->state.leadership_flag) && (sg=su->group) && sg->src_id == sd->bl.id) { skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y)); } - if (sd->state.glorywounds_flag && (su=(struct skill_unit *)sd->state.glorywounds_flag) && + if (sd->state.glorywounds_flag && (su=(struct skill_unit *)sd->state.glorywounds_flag) && (sg=su->group) && sg->src_id == sd->bl.id) { skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y)); } - if (sd->state.soulcold_flag && (su=(struct skill_unit *)sd->state.soulcold_flag) && + if (sd->state.soulcold_flag && (su=(struct skill_unit *)sd->state.soulcold_flag) && (sg=su->group) && sg->src_id == sd->bl.id) { skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y)); } - if (sd->state.hawkeyes_flag && (su=(struct skill_unit *)sd->state.hawkeyes_flag) && + if (sd->state.hawkeyes_flag && (su=(struct skill_unit *)sd->state.hawkeyes_flag) && (sg=su->group) && sg->src_id == sd->bl.id) { skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y)); } @@ -4392,7 +4465,7 @@ int pc_randomwalk(struct map_session_data *sd,int tick) { const int retrycount = 20; nullpo_retr(0, sd); - + if(DIFF_TICK(sd->next_walktime,tick)<0){ int i,x,y,d; d = rand()%7+5; @@ -4608,7 +4681,7 @@ struct pc_base_job pc_calc_base_job(int b_class) }else{ bj.type = 2; } - + return bj; } @@ -4624,7 +4697,7 @@ int pc_calc_base_job2 (int b_class) return b_class - 4001; else if(b_class == 4045) return 23; - return b_class - 4023; + return b_class - 4023; } int pc_calc_upper(int b_class) @@ -4668,8 +4741,12 @@ int pc_attack_timer(int tid,unsigned int tick,int id,int data) if(bl==NULL || bl->prev == NULL) return 0; - if(bl->type == BL_PC && pc_isdead((struct map_session_data *)bl)) - return 0; + if(bl->type == BL_PC) { + if (pc_isdead((struct map_session_data *)bl)) + return 0; + else if (pc_ishiding((struct map_session_data *)bl)) + return 0; + } // 同じmapでないなら攻?しない // PCが死んでても攻?しない @@ -4685,7 +4762,7 @@ int pc_attack_timer(int tid,unsigned int tick,int id,int data) return 0; if(sd->sc_data[SC_BLADESTOP].timer != -1) return 0; - } + } //if((opt = battle_get_option(bl)) != NULL && *opt&0x46) if((opt = battle_get_option(bl)) != NULL && *opt&0x42) @@ -4774,13 +4851,13 @@ int pc_attack(struct map_session_data *sd,int target_id,int type) return 1; sd->idletime = tick_; - + if(bl->type==BL_NPC) { // monster npcs [Valaris] //npc_click(sd,RFIFOL(sd->fd,2)); npc_click(sd,target_id); // submitted by leinsirk10 [Celest] return 0; } - + if(!battle_check_target(&sd->bl,bl,BCT_ENEMY)) return 1; if(sd->attacktimer != -1) @@ -4972,7 +5049,7 @@ int pc_gainexp(struct map_session_data *sd,int base_exp,int job_exp) sd->status.base_exp += base_exp; if(sd->status.base_exp < 0) sd->status.base_exp = 0; - + while(pc_checkbaselevelup(sd)) ; clif_updatestatus(sd,SP_BASEEXP); @@ -4985,13 +5062,13 @@ int pc_gainexp(struct map_session_data *sd,int base_exp,int job_exp) sd->status.job_exp += job_exp; if(sd->status.job_exp < 0) sd->status.job_exp = 0; - + while(pc_checkjoblevelup(sd)) ; clif_updatestatus(sd,SP_JOBEXP); if(battle_config.disp_experience){ - sprintf(output, + sprintf(output, "Experienced Gained Base:%d Job:%d",base_exp,job_exp); clif_disp_onlyself(sd,output,strlen(output)); } @@ -5124,7 +5201,7 @@ int pc_need_status_point(struct map_session_data *sd,int type) int pc_statusup(struct map_session_data *sd,int type) { int max, need,val = 0; - + nullpo_retr(0, sd); max = (pc_calc_upper(sd->status.class_)==2) ? 80 : battle_config.max_parameter; @@ -5326,17 +5403,21 @@ int pc_allskillup(struct map_session_data *sd) sd->status.skill[i].lv=skill_get_max(i); for(i=210;i<291;i++) sd->status.skill[i].lv=skill_get_max(i); - for(i=304;istatus.skill[i].lv=skill_get_max(i); } + if(battle_config.enable_upper_class){ //confで無?でなければ?み?む + for(i=355;i<411;i++) + sd->status.skill[i].id=i; + } } else { for(i=0;(id=skill_tree[s][c][i].id)>0;i++){ if(sd->status.skill[id].id==0 && (!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn) ) { sd->status.skill[id].id = id; // celest // sd->status.skill[id].lv=skill_get_max(id); - sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); // celest + sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); // celest } } } @@ -5352,9 +5433,9 @@ int pc_allskillup(struct map_session_data *sd) int pc_resetlvl(struct map_session_data* sd,int type) { int i; - + nullpo_retr(0, sd); - + for(i=1;istatus.skill[i].lv = 0; } @@ -5395,7 +5476,7 @@ int pc_resetlvl(struct map_session_data* sd,int type) if(type == 4){ sd->status.job_level=1; sd->status.job_exp=0; - } + } clif_updatestatus(sd,SP_STATUSPOINT); clif_updatestatus(sd,SP_STR); @@ -5444,7 +5525,7 @@ int pc_resetstate(struct map_session_data* sd) sd->status.status_point = atoi (statp[sd->status.base_level - 1]); if(sd->status.class_ >= 4001 && sd->status.class_ <= 4024) sd->status.status_point+=52; // extra 52+48=100 stat points -// End addition +// End addition // Removed by Dexity - old count // add += sumsp(sd->status.str); @@ -5794,7 +5875,7 @@ int pc_readparam(struct map_session_data *sd,int type) { int val=0; struct pc_base_job s_class; - + s_class = pc_calc_base_job(sd->status.class_); nullpo_retr(0, sd); @@ -6208,12 +6289,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) int b_class = 0; //?生や養子の場合の元の職業を算出する struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); - + nullpo_retr(0, sd); if (upper < 0 || upper > 2) //現在?生かどうかを判?する upper = s_class.upper; - + b_class = job; //通常職ならjobそのまんま if (job < 23) { if (upper == 1) @@ -6248,8 +6329,8 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) else sd->change_level = 0; - pc_setglobalreg (sd, "jobchange_level", sd->change_level); - + pc_setglobalreg (sd, "jobchange_level", sd->change_level); + sd->status.class_ = sd->view_class = b_class; sd->status.job_level=1; @@ -6276,12 +6357,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) clif_equiplist(sd); if(pc_isriding(sd)) { // remove peco status if changing into invalid class [Valaris] - if(!(pc_checkskill(sd,KN_RIDING))) + if(!(pc_checkskill(sd,KN_RIDING))) pc_setoption(sd,sd->status.option|-0x0000); if(pc_checkskill(sd,KN_RIDING)>0) pc_setriding(sd); } - + return 0; } @@ -6418,13 +6499,13 @@ int pc_setriding(struct map_session_data *sd) if(sd->status.class_==7) sd->status.class_=sd->view_class=13; - + if(sd->status.class_==14) sd->status.class_=sd->view_class=21; - + if(sd->status.class_==4008) sd->status.class_=sd->view_class=4014; - + if(sd->status.class_==4015) sd->status.class_=sd->view_class=4022; } @@ -6772,7 +6853,7 @@ int pc_eventtimer(int tid,unsigned int tick,int id,int data) break; } } - free((void *)data); + aFree((void *)data); if(i==MAX_EVENTTIMER) { if(battle_config.error_log) printf("pc_eventtimer: no such event timer\n"); @@ -6795,7 +6876,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) if( sd->eventtimer[i]==-1 ) break; if(ieventtimer[i]=add_timer(gettick()+tick, pc_eventtimer,sd->bl.id,(int)evname); @@ -7035,7 +7116,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos) */ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { - nullpo_retr(0, sd); + nullpo_retr(0, sd); // -- moonsoul (if player is berserk then cannot unequip) // @@ -7243,7 +7324,7 @@ int pc_calc_pvprank(struct map_session_data *sd) nullpo_retr(0, sd); nullpo_retr(0, m=&map[sd->bl.m]); - + old=sd->pvp_rank; if( !(m->flag.pvp) ) @@ -7385,8 +7466,8 @@ static int pc_spheal(struct map_session_data *sd) if(gc) { struct guild *g; g=guild_search(sd->status.guild_id); - if(g && g->guild_id == gc->guild_id) - a += a; + if(g && g->guild_id == gc->guild_id) + a += a; } // end addition [Valaris] return a; @@ -7415,8 +7496,8 @@ static int pc_hpheal(struct map_session_data *sd) if(gc) { struct guild *g; g=guild_search(sd->status.guild_id); - if(g && g->guild_id == gc->guild_id) - a += a; + if(g && g->guild_id == gc->guild_id) + a += a; } // end addition [Valaris] return a; @@ -7680,8 +7761,8 @@ static int pc_natural_heal_sub(struct map_session_data *sd,va_list ap) { // -- moonsoul (if conditions below altered to disallow natural healing if under berserk status) if ((battle_config.natural_heal_weight_rate > 100 || sd->weight*100/sd->max_weight < battle_config.natural_heal_weight_rate) && - !pc_isdead(sd) && - !pc_ishiding(sd) && + !pc_isdead(sd) && + !pc_ishiding(sd) && //-- cannot regen for 5 minutes after using Berserk --- [Celest] DIFF_TICK (gettick(), sd->canregen_tick)>=0 && (sd->sc_data && !(sd->sc_data[SC_POISON].timer != -1 && sd->sc_data[SC_SLOWPOISON].timer == -1) && @@ -7746,7 +7827,7 @@ static int pc_autosave_sub(struct map_session_data *sd,va_list ap) { nullpo_retr(0, sd); - Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); + Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); if(save_flag==0 && sd->fd>last_save_fd){ struct guild_castle *gc=NULL; @@ -7807,10 +7888,10 @@ int pc_read_gm_account(int fd) int i = 0; #endif if (gm_account != NULL) - free(gm_account); + aFree(gm_account); GM_num = 0; #ifdef TXT_ONLY - gm_account = aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); + gm_account = aCallocA(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); for (i = 4; i < RFIFOW(fd,2); i = i + 5) { gm_account[GM_num].account_id = RFIFOL(fd,i); gm_account[GM_num].level = (int)RFIFOB(fd,i+4); @@ -7824,7 +7905,7 @@ int pc_read_gm_account(int fd) } lsql_res = mysql_store_result(&lmysql_handle); if (lsql_res) { - gm_account = aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); + gm_account = aCallocA(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); while ((lsql_row = mysql_fetch_row(lsql_res))) { gm_account[GM_num].account_id = atoi(lsql_row[0]); gm_account[GM_num].level = atoi(lsql_row[1]); @@ -7832,7 +7913,7 @@ int pc_read_gm_account(int fd) GM_num++; } } - + mysql_free_result(lsql_res); #endif /* TXT_ONLY */ return GM_num; @@ -7926,7 +8007,7 @@ int pc_readdb(void) char line[1024],*p; // 必要??値?み?み - + memset(exp_table,0,sizeof(exp_table)); fp=fopen("db/exp.txt","r"); if(fp==NULL){ printf("can't read db/exp.txt\n"); @@ -7997,6 +8078,7 @@ int pc_readdb(void) ShowStatus(tmp_output); // JOBボ?ナス + memset(job_bonus,0,sizeof(job_bonus)); fp=fopen("db/job_db2.txt","r"); if(fp==NULL){ printf("can't read db/job_db2.txt\n"); @@ -8076,7 +8158,7 @@ int pc_readdb(void) for(j=0;skill_tree[u][i][j].id;j++); skill_tree[u][i][j].id=atoi(split[1]); skill_tree[u][i][j].max=atoi(split[2]); - + //not required - Celest //skill_tree[2][i][j].id=atoi(split[1]); //養子職は良く分からないので暫定 //skill_tree[2][i][j].max=atoi(split[2]); //養子職は良く分からないので暫定 @@ -8242,7 +8324,7 @@ static void pc_statpointdb(void) end = ftell(stp); rewind(stp); - buf_stat = (char *) malloc (end + 1); + buf_stat = (char *) aMallocA (end + 1); l = fread(buf_stat,1,end,stp); fclose(stp); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/statpoint.txt"); @@ -8251,7 +8333,7 @@ static void pc_statpointdb(void) for(i=0;i<255;i++) { j=0; - while (*(buf_stat+k)!='\n') { + while (*(buf_stat+k)!='\n') { statp[i][j]=*(buf_stat+k); j++;k++; } @@ -8259,7 +8341,7 @@ static void pc_statpointdb(void) k++; } - free(buf_stat); + aFree(buf_stat); } /*========================================== diff --git a/src/map/pet.c b/src/map/pet.c index c198c1fb5..99f2a4d95 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1376,7 +1376,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) clif_additem(sd,0,0,flag); map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); } - free(ditem); + aFree(ditem); } else add_timer(gettick()+540+i,pet_delay_item_drop2,(int)ditem,0); @@ -1399,7 +1399,7 @@ int pet_delay_item_drop2(int tid,unsigned int tick,int id,int data) map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); - free(ditem); + aFree(ditem); return 0; } diff --git a/src/map/script.c b/src/map/script.c index a6b65e213..35645eaab 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -507,7 +507,7 @@ struct { {buildin_npctalk,"npctalk","*"}, // [Valaris] {buildin_hasitems,"hasitems","*"}, // [Valaris] {buildin_mobcount,"mobcount","ss"}, - {buildin_getlook,"getlook","i"}, + {buildin_getlook,"getlook","i"}, {buildin_getsavepoint,"getsavepoint","i"}, {buildin_npcspeed,"npcspeed","i"}, // [Valaris] {buildin_npcwalkto,"npcwalkto","ii"}, // [Valaris] @@ -576,14 +576,14 @@ static int add_str(const unsigned char *p) int i; char *lowcase; - lowcase=strdup(p); + lowcase=aStrdup(p); for(i=0;lowcase[i];i++) lowcase[i]=tolower(lowcase[i]); if((i=search_str(lowcase))>=0){ - free(lowcase); + aFree(lowcase); return i; } - free(lowcase); + aFree(lowcase); i=calc_hash(p); if(str_hash[i]==0){ @@ -605,7 +605,7 @@ static int add_str(const unsigned char *p) str_data=aRealloc(str_data,sizeof(str_data[0])*str_data_size); memset(str_data + (str_data_size - 128), '\0', 128); } - while(str_pos+strlen(p)+1>=str_size){ + while(str_pos+(int)strlen(p)+1>=str_size){ str_size+=256; str_buf=(char *)aRealloc(str_buf,str_size); memset(str_buf + (str_size - 256), '\0', 256); @@ -1159,7 +1159,7 @@ unsigned char* parse_script(unsigned char *src,int line) read_constdb(); } first=0; - script_buf=(unsigned char *)aCalloc(SCRIPT_BLOCK_SIZE,sizeof(unsigned char)); + script_buf=(unsigned char *)aCallocA(SCRIPT_BLOCK_SIZE,sizeof(unsigned char)); script_pos=0; script_size=SCRIPT_BLOCK_SIZE; str_data[LABEL_NEXTLINE].type=C_NOP; @@ -1395,7 +1395,7 @@ char* conv_str(struct script_state *st,struct script_data *data) get_val(st,data); if(data->type==C_INT){ char *buf; - buf=(char *)aCalloc(16,sizeof(char)); + buf=(char *)aCallocA(16,sizeof(char)); sprintf(buf,"%d",data->u.num); data->type=C_STR; data->u.str=buf; @@ -1421,7 +1421,7 @@ int conv_num(struct script_state *st,struct script_data *data) p=data->u.str; data->u.num = atoi(p); if(data->type==C_STR) - free(p); + aFree(p); data->type=C_INT; } return data->u.num; @@ -1478,7 +1478,7 @@ void push_copy(struct script_stack *stack,int pos) push_str(stack,C_CONSTSTR,stack->stack_data[pos].u.str); break; case C_STR: - push_str(stack,C_STR,strdup(stack->stack_data[pos].u.str)); + push_str(stack,C_STR,aStrdup(stack->stack_data[pos].u.str)); break; default: push_val(stack,stack->stack_data[pos].type,stack->stack_data[pos].u.num); @@ -1495,7 +1495,7 @@ void pop_stack(struct script_stack* stack,int start,int end) int i; for(i=start;istack_data[i].type==C_STR){ - free(stack->stack_data[i].u.str); + aFree(stack->stack_data[i].u.str); } } if(stack->sp>end){ @@ -1663,7 +1663,7 @@ int buildin_menu(struct script_state *st) char *buf; int len,i; struct map_session_data *sd; - + sd=script_rid2sd(st); if(sd->state.menu_or_input==0){ @@ -1673,14 +1673,14 @@ int buildin_menu(struct script_state *st) conv_str(st,& (st->stack->stack_data[i])); len+=strlen(st->stack->stack_data[i].u.str)+1; } - buf=(char *)aCalloc(len,sizeof(char)); + buf=(char *)aCallocA(len,sizeof(char)); buf[0]=0; for(i=st->start+2,len=0;iend;i+=2){ strcat(buf,st->stack->stack_data[i].u.str); strcat(buf,":"); } clif_scriptmenu(script_rid2sd(st),st->oid,buf); - free(buf); + aFree(buf); } else if(sd->npc_menu==0xff){ // cansel sd->state.menu_or_input=0; st->state=END; @@ -2522,7 +2522,7 @@ int buildin_delitem(struct script_state *st) if(sd->inventory_data[i]->type==7 && sd->status.inventory[i].card[0] == (short)0xff00 && search_petDB_index(nameid, PET_EGG) >= 0 ){ intif_delete_petdata(*((long *)(&sd->status.inventory[i].card[1]))); //clear egg flag. so it won't be put in IMPORTANT items (eggs look like item with 2 cards ^_^) - sd->status.inventory[i].card[1] = sd->status.inventory[i].card[0] = 0; + sd->status.inventory[i].card[1] = sd->status.inventory[i].card[0] = 0; //now this egg'll be deleted as a common unimportant item } //is this item important? does it have cards? or Player's name? or Refined/Upgraded @@ -2551,7 +2551,7 @@ int buildin_delitem(struct script_state *st) continue; if(sd->status.inventory[i].amount>=amount){ - pc_delitem(sd,i,amount,0); + pc_delitem(sd,i,amount,0); return 0; //we deleted exact amount of items. now exit } else { amount-=sd->status.inventory[i].amount; @@ -2627,7 +2627,7 @@ char *buildin_getpartyname_sub(int party_id) if(p!=NULL){ char *buf; - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strcpy(buf,p->name); return buf; } @@ -2684,7 +2684,7 @@ char *buildin_getguildname_sub(int guild_id) if(g!=NULL){ char *buf; - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strcpy(buf,g->name); return buf; } @@ -2713,7 +2713,7 @@ char *buildin_getguildmaster_sub(int guild_id) if(g!=NULL){ char *buf; - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strncpy(buf,g->master, 23); return buf; } @@ -2763,7 +2763,7 @@ int buildin_strcharinfo(struct script_state *st) num=conv_num(st,& (st->stack->stack_data[st->start+2])); if(num==0){ char *buf; - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strncpy(buf,sd->status.name, 23); push_str(st->stack,C_STR,buf); } @@ -2830,7 +2830,7 @@ int buildin_getequipname(struct script_state *st) struct item_data* item; char *buf; - buf=(char *)aCalloc(64,sizeof(char)); + buf=(char *)aCallocA(64,sizeof(char)); sd=script_rid2sd(st); num=conv_num(st,& (st->stack->stack_data[st->start+2])); i=pc_checkequip(sd,equip[num-1]); @@ -2856,9 +2856,9 @@ int buildin_getbrokenid(struct script_state *st) { int i,num,id=0,brokencounter=0; struct map_session_data *sd; - + sd=script_rid2sd(st); - + num=conv_num(st,& (st->stack->stack_data[st->start+2])); for(i=0; istatus.inventory[i].attribute==1){ @@ -2869,7 +2869,7 @@ int buildin_getbrokenid(struct script_state *st) } } } - + push_val(st->stack,C_INT,id); return 0; @@ -2887,7 +2887,7 @@ int buildin_repair(struct script_state *st) sd=script_rid2sd(st); - + num=conv_num(st,& (st->stack->stack_data[st->start+2])); for(i=0; istatus.inventory[i].attribute==1){ @@ -2941,7 +2941,7 @@ int buildin_getequipisenableref(struct script_state *st) i=pc_checkequip(sd,equip[num-1]); if(i >= 0 && num<7 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_refine) // replaced by Celest - /*(num!=1 + /*(num!=1 || sd->inventory_data[i]->def > 1 || (sd->inventory_data[i]->def==1 && sd->inventory_data[i]->equip_script==NULL) || (sd->inventory_data[i]->def<=0 && sd->inventory_data[i]->equip_script!=NULL)))*/ @@ -3245,15 +3245,15 @@ int buildin_getskilllv(struct script_state *st) return 0; } /*========================================== - * getgdskilllv(Guild_ID, Skill_ID); - * skill_id = 10000 : GD_APPROVAL - * 10001 : GD_KAFRACONTACT - * 10002 : GD_GUARDIANRESEARCH - * 10003 : GD_GUARDUP - * 10004 : GD_EXTENSION + * getgdskilllv(Guild_ID, Skill_ID); + * skill_id = 10000 : GD_APPROVAL + * 10001 : GD_KAFRACONTACT + * 10002 : GD_GUARDIANRESEARCH + * 10003 : GD_GUARDUP + * 10004 : GD_EXTENSION *------------------------------------------ */ -int buildin_getgdskilllv(struct script_state *st) +int buildin_getgdskilllv(struct script_state *st) { int guild_id=conv_num(st,& (st->stack->stack_data[st->start+2])); int skill_id=conv_num(st,& (st->stack->stack_data[st->start+3])); @@ -3590,7 +3590,7 @@ int buildin_gettimestr(struct script_state *st) fmtstr=conv_str(st,& (st->stack->stack_data[st->start+2])); maxlen=conv_num(st,& (st->stack->stack_data[st->start+3])); - tmpstr=(char *)aCalloc(maxlen+1,sizeof(char)); + tmpstr=(char *)aCallocA(maxlen+1,sizeof(char)); strftime(tmpstr,maxlen,fmtstr,localtime(&now)); tmpstr[maxlen]='\0'; @@ -3677,8 +3677,8 @@ int buildin_makepet(struct script_state *st) sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet( sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, - pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, + (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv, + (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } @@ -3727,19 +3727,19 @@ int buildin_guildgetexp(struct script_state *st) */ int buildin_monster(struct script_state *st) { - int class,amount,x,y; + int class_,amount,x,y; char *str,*map,*event=""; map =conv_str(st,& (st->stack->stack_data[st->start+2])); x =conv_num(st,& (st->stack->stack_data[st->start+3])); y =conv_num(st,& (st->stack->stack_data[st->start+4])); str =conv_str(st,& (st->stack->stack_data[st->start+5])); - class=conv_num(st,& (st->stack->stack_data[st->start+6])); + class_=conv_num(st,& (st->stack->stack_data[st->start+6])); amount=conv_num(st,& (st->stack->stack_data[st->start+7])); if( st->end>st->start+8 ) event=conv_str(st,& (st->stack->stack_data[st->start+8])); - mob_once_spawn(map_id2sd(st->rid),map,x,y,str,class,amount,event); + mob_once_spawn(map_id2sd(st->rid),map,x,y,str,class_,amount,event); return 0; } /*========================================== @@ -3748,7 +3748,7 @@ int buildin_monster(struct script_state *st) */ int buildin_areamonster(struct script_state *st) { - int class,amount,x0,y0,x1,y1; + int class_,amount,x0,y0,x1,y1; char *str,*map,*event=""; map =conv_str(st,& (st->stack->stack_data[st->start+2])); @@ -3757,12 +3757,12 @@ int buildin_areamonster(struct script_state *st) x1 =conv_num(st,& (st->stack->stack_data[st->start+5])); y1 =conv_num(st,& (st->stack->stack_data[st->start+6])); str =conv_str(st,& (st->stack->stack_data[st->start+7])); - class=conv_num(st,& (st->stack->stack_data[st->start+8])); + class_=conv_num(st,& (st->stack->stack_data[st->start+8])); amount=conv_num(st,& (st->stack->stack_data[st->start+9])); if( st->end>st->start+10 ) event=conv_str(st,& (st->stack->stack_data[st->start+10])); - mob_once_spawn_area(map_id2sd(st->rid),map,x0,y0,x1,y1,str,class,amount,event); + mob_once_spawn_area(map_id2sd(st->rid),map,x0,y0,x1,y1,str,class_,amount,event); return 0; } /*========================================== @@ -3974,7 +3974,7 @@ int buildin_attachnpctimer(struct script_state *st) struct map_session_data *sd; struct npc_data *nd; - nd=(struct npc_data *)map_id2bl(st->oid); + nd=(struct npc_data *)map_id2bl(st->oid); if( st->end > st->start+2 ) { char *name = conv_str(st,& (st->stack->stack_data[st->start+2])); sd=map_nick2sd(name); @@ -4270,7 +4270,7 @@ int buildin_sc_start(struct script_state *st) bl = map_id2bl(conv_num(st,& (st->stack->stack_data[st->start+5]))); else bl = map_id2bl(st->rid); - + if (bl != 0) { if(bl->type == BL_PC && ((struct map_session_data *)bl)->state.potionpitcher_flag) bl = map_id2bl(((struct map_session_data *)bl)->skilltarget); @@ -5101,7 +5101,7 @@ int buildin_getcastlename(struct script_state *st) for(i=0;imap_name)==0){ - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strncpy(buf,gc->castle_name,24); break; } @@ -5343,8 +5343,8 @@ int buildin_failedremovecards(struct script_state *st) if( (sd->status.inventory[i].card[c-1] > 4000 && sd->status.inventory[i].card[c-1] < 5000) || itemdb_type(sd->status.inventory[i].card[c-1]) == 6){ // [Celest] - - cardflag = 1; + + cardflag = 1; if(typefail == 2){ // 武具のみ損失なら、カードは受け取らせる item_tmp.id=0,item_tmp.nameid=sd->status.inventory[i].card[c-1]; @@ -5561,39 +5561,39 @@ int buildin_strmobinfo(struct script_state *st) { int num=conv_num(st,& (st->stack->stack_data[st->start+2])); - int class=conv_num(st,& (st->stack->stack_data[st->start+3])); + int class_=conv_num(st,& (st->stack->stack_data[st->start+3])); - if(num<=0 || num>=8 || (class>=0 && class<=1000) || class >2000) + if(num<=0 || num>=8 || (class_>=0 && class_<=1000) || class_ >2000) return 0; if(num==1) { char *buf; - buf=aCalloc(24, 1); -// buf=mob_db[class].name; + buf=aCallocA(24, 1); +// buf=mob_db[class_].name; // for string assignments you would need to go for c++ [Shinomori] - strcpy(buf,mob_db[class].name); + strcpy(buf,mob_db[class_].name); push_str(st->stack,C_STR,buf); return 0; } else if(num==2) { char *buf; - buf=aCalloc(24, 1); -// buf=mob_db[class].jname; + buf=aCallocA(24, 1); +// buf=mob_db[class_].jname; // for string assignments you would need to go for c++ [Shinomori] - strcpy(buf,mob_db[class].jname); + strcpy(buf,mob_db[class_].jname); push_str(st->stack,C_STR,buf); return 0; } else if(num==3) - push_val(st->stack,C_INT,mob_db[class].lv); + push_val(st->stack,C_INT,mob_db[class_].lv); else if(num==4) - push_val(st->stack,C_INT,mob_db[class].max_hp); + push_val(st->stack,C_INT,mob_db[class_].max_hp); else if(num==5) - push_val(st->stack,C_INT,mob_db[class].max_sp); + push_val(st->stack,C_INT,mob_db[class_].max_sp); else if(num==6) - push_val(st->stack,C_INT,mob_db[class].base_exp); + push_val(st->stack,C_INT,mob_db[class_].base_exp); else if(num==7) - push_val(st->stack,C_INT,mob_db[class].job_exp); + push_val(st->stack,C_INT,mob_db[class_].job_exp); return 0; } @@ -5603,20 +5603,20 @@ int buildin_strmobinfo(struct script_state *st) */ int buildin_guardian(struct script_state *st) { - int class=0,amount=1,x=0,y=0,guardian=0; + int class_=0,amount=1,x=0,y=0,guardian=0; char *str,*map,*event=""; map =conv_str(st,& (st->stack->stack_data[st->start+2])); x =conv_num(st,& (st->stack->stack_data[st->start+3])); y =conv_num(st,& (st->stack->stack_data[st->start+4])); str =conv_str(st,& (st->stack->stack_data[st->start+5])); - class=conv_num(st,& (st->stack->stack_data[st->start+6])); + class_=conv_num(st,& (st->stack->stack_data[st->start+6])); amount=conv_num(st,& (st->stack->stack_data[st->start+7])); event=conv_str(st,& (st->stack->stack_data[st->start+8])); if( st->end>st->start+9 ) guardian=conv_num(st,& (st->stack->stack_data[st->start+9])); - mob_spawn_guardian(map_id2sd(st->rid),map,x,y,str,class,amount,event,guardian); + mob_spawn_guardian(map_id2sd(st->rid),map,x,y,str,class_,amount,event,guardian); return 0; } @@ -5657,7 +5657,7 @@ int buildin_getitemname(struct script_state *st) i_data = NULL; i_data = itemdb_search(item_id); - item_name=(char *)aCalloc(24,sizeof(char)); + item_name=(char *)aCallocA(24,sizeof(char)); strncpy(item_name,i_data->jname,23); push_str(st->stack,C_STR,item_name); @@ -5671,12 +5671,12 @@ int buildin_getitemname(struct script_state *st) int buildin_petskillbonus(struct script_state *st) { - int type,val,duration,timer; + int type,val,duration,timer; struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5691,7 +5691,7 @@ int buildin_petskillbonus(struct script_state *st) pd->skillbonusduration=-1; pd->skillbonustimer=-1; - + pet_skill_bonus(sd,pd,type,val,duration,timer,0); return 0; @@ -5719,7 +5719,7 @@ int buildin_petloot(struct script_state *st) if(!max) return 0; - + pd->loot=1; pd->lootmax=max; @@ -5790,14 +5790,14 @@ int buildin_clearitem(struct script_state *st) */ int buildin_classchange(struct script_state *st) { - int class,type; + int _class,type; struct block_list *bl=map_id2bl(st->oid); - + if(bl==NULL) return 0; - class=conv_num(st,& (st->stack->stack_data[st->start+2])); + _class=conv_num(st,& (st->stack->stack_data[st->start+2])); type=conv_num(st,& (st->stack->stack_data[st->start+3])); - clif_class_change(bl,class,type); + clif_class_change(bl,_class,type); return 0; } @@ -5867,9 +5867,9 @@ int buildin_petrecovery(struct script_state *st) { struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5893,9 +5893,9 @@ int buildin_petheal(struct script_state *st) { struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5911,7 +5911,7 @@ int buildin_petheal(struct script_state *st) return 0; } - + /*========================================== * pet magnificat [Valaris] *------------------------------------------ @@ -5919,9 +5919,9 @@ int buildin_petheal(struct script_state *st) int buildin_petmag(struct script_state *st) { struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5946,9 +5946,9 @@ int buildin_petmag(struct script_state *st) int buildin_petskillattack(struct script_state *st) { struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5957,7 +5957,7 @@ int buildin_petskillattack(struct script_state *st) return 0; pd->skilltype=conv_num(st,& (st->stack->stack_data[st->start+2])); - pd->skillval=conv_num(st,& (st->stack->stack_data[st->start+3])); + pd->skillval=conv_num(st,& (st->stack->stack_data[st->start+3])); pd->skillduration=conv_num(st,& (st->stack->stack_data[st->start+4])); pd->skilltimer=conv_num(st,& (st->stack->stack_data[st->start+5])); @@ -5973,11 +5973,11 @@ int buildin_petskillattack(struct script_state *st) int buildin_skilleffect(struct script_state *st) { struct map_session_data *sd; - + int skillid=conv_num(st,& (st->stack->stack_data[st->start+2])); int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3])); sd=script_rid2sd(st); - + clif_skill_nodamage(&sd->bl,&sd->bl,skillid,skilllv,1); return 0; @@ -5990,9 +5990,9 @@ int buildin_skilleffect(struct script_state *st) int buildin_npcskilleffect(struct script_state *st) { struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid); - + int skillid=conv_num(st,& (st->stack->stack_data[st->start+2])); - int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3])); + int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3])); int x=conv_num(st,& (st->stack->stack_data[st->start+4])); int y=conv_num(st,& (st->stack->stack_data[st->start+5])); @@ -6036,13 +6036,13 @@ int buildin_specialeffect2(struct script_state *st) int buildin_nude(struct script_state *st) { - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); int i; if(sd==NULL) return 0; - - for(i=0;i<11;i++) + + for(i=0;i<11;i++) if(sd->equip_index[i] >= 0) pc_unequipitem(sd,sd->equip_index[i],2); @@ -6118,7 +6118,7 @@ int buildin_message(struct script_state *st) * area) [Valaris] *------------------------------------------ */ - + int buildin_npctalk(struct script_state *st) { char *str; @@ -6148,16 +6148,16 @@ int buildin_hasitems(struct script_state *st) { int i; struct map_session_data *sd; - + sd=script_rid2sd(st); - + for(i=0; istatus.inventory[i].amount) { push_val(st->stack,C_INT,1); return 0; } } - + push_val(st->stack,C_INT,0); return 0; @@ -6262,7 +6262,7 @@ int buildin_getsavepoint(struct script_state *st) sd=script_rid2sd(st); type=conv_num(st,& (st->stack->stack_data[st->start+2])); - mapname=aCalloc(24, 1); + mapname=aCallocA(24, 1); x=sd->status.save_point.x; y=sd->status.save_point.y; @@ -6331,7 +6331,7 @@ int buildin_getmapxy(struct script_state *st){ //??????????? >>> Possible needly check function parameters on C_STR,C_INT,C_INT <<< ???????????// type=conv_num(st,& (st->stack->stack_data[st->start+5])); - mapname=aCalloc(24, 1); + mapname=aCallocA(24, 1); switch (type){ case 0: //Get Character Position @@ -6363,7 +6363,7 @@ int buildin_getmapxy(struct script_state *st){ } x=nd->bl.x; - y=nd->bl.y; + y=nd->bl.y; strncpy(mapname,map[nd->bl.m].name,24); printf(">>>>%s %d %d\n",mapname,x,y); break; @@ -6385,7 +6385,7 @@ int buildin_getmapxy(struct script_state *st){ return 0; } x=pd->bl.x; - y=pd->bl.y; + y=pd->bl.y; strncpy(mapname,map[pd->bl.m].name,24); printf(">>>>%s %d %d\n",mapname,x,y); @@ -6491,7 +6491,7 @@ int buildin_logmes(struct script_state *st) int buildin_summon(struct script_state *st) { - int class, id; + int _class, id; char *str,*event=""; struct map_session_data *sd; struct mob_data *md; @@ -6500,11 +6500,11 @@ int buildin_summon(struct script_state *st) if (sd) { int tick = gettick(); str =conv_str(st,& (st->stack->stack_data[st->start+2])); - class=conv_num(st,& (st->stack->stack_data[st->start+3])); + _class=conv_num(st,& (st->stack->stack_data[st->start+3])); if( st->end>st->start+4 ) event=conv_str(st,& (st->stack->stack_data[st->start+4])); - id=mob_once_spawn(sd, "this", 0, 0, str,class,1,event); + id=mob_once_spawn(sd, "this", 0, 0, str,_class,1,event); if((md=(struct mob_data *)map_id2bl(id))){ md->master_id=sd->bl.id; md->state.special_mob_ai=1; @@ -6608,14 +6608,14 @@ void op_add(struct script_state* st) st->stack->stack_data[st->stack->sp-1].u.num += st->stack->stack_data[st->stack->sp].u.num; } else { // ssの予定 char *buf; - buf=(char *)aCalloc(strlen(st->stack->stack_data[st->stack->sp-1].u.str)+ + buf=(char *)aCallocA(strlen(st->stack->stack_data[st->stack->sp-1].u.str)+ strlen(st->stack->stack_data[st->stack->sp].u.str)+1,sizeof(char)); strcpy(buf,st->stack->stack_data[st->stack->sp-1].u.str); strcat(buf,st->stack->stack_data[st->stack->sp].u.str); if(st->stack->stack_data[st->stack->sp-1].type==C_STR) - free(st->stack->stack_data[st->stack->sp-1].u.str); + aFree(st->stack->stack_data[st->stack->sp-1].u.str); if(st->stack->stack_data[st->stack->sp].type==C_STR) - free(st->stack->stack_data[st->stack->sp].u.str); + aFree(st->stack->stack_data[st->stack->sp].u.str); st->stack->stack_data[st->stack->sp-1].type=C_STR; st->stack->stack_data[st->stack->sp-1].u.str=buf; } @@ -6657,8 +6657,8 @@ void op_2str(struct script_state *st,int op,int sp1,int sp2) push_val(st->stack,C_INT,a); - if(st->stack->stack_data[sp1].type==C_STR) free(s1); - if(st->stack->stack_data[sp2].type==C_STR) free(s2); + if(st->stack->stack_data[sp1].type==C_STR) aFree(s1); + if(st->stack->stack_data[sp2].type==C_STR) aFree(s2); } /*========================================== * 二項演算子(数値) @@ -6672,7 +6672,11 @@ void op_2num(struct script_state *st,int op,int i1,int i2) break; case C_MUL: { + #ifndef _MSC_VER long long res = i1 * i2; + #else + __int64 res = i1 * i2; + #endif if (res > 2147483647 ) i1 = 2147483647; else @@ -6988,7 +6992,7 @@ int run_script_main(unsigned char *script,int pos,int rid,int oid,struct script_ struct map_session_data *sd=map_id2sd(st->rid); if(sd/* && sd->npc_stackbuf==NULL*/){ if( sd->npc_stackbuf ) - free( sd->npc_stackbuf ); + aFree( sd->npc_stackbuf ); sd->npc_stackbuf = (char *)aCalloc(sizeof(stack->stack_data[0])*stack->sp_max,sizeof(char)); memcpy(sd->npc_stackbuf, stack->stack_data, sizeof(stack->stack_data[0]) * stack->sp_max); sd->npc_stack = stack->sp; @@ -7022,7 +7026,7 @@ int run_script(unsigned char *script,int pos,int rid,int oid) stack.sp_max=sd->npc_stackmax; stack.stack_data=(struct script_data *)aCalloc(stack.sp_max,sizeof(stack.stack_data[0])); memcpy(stack.stack_data,sd->npc_stackbuf,sizeof(stack.stack_data[0])*stack.sp_max); - free(sd->npc_stackbuf); + aFree(sd->npc_stackbuf); sd->npc_stackbuf=NULL; }else{ // スタック初期化 @@ -7036,7 +7040,7 @@ int run_script(unsigned char *script,int pos,int rid,int oid) st.oid=oid; run_script_main(script,pos,rid,oid,&st,rootscript); - free(stack.stack_data); + aFree(stack.stack_data); stack.stack_data=NULL; return st.pos; } @@ -7065,14 +7069,14 @@ int mapreg_setregstr(int num,const char *str) char *p; if( (p=numdb_search(mapregstr_db,num))!=NULL ) - free(p); + aFree(p); if( str==NULL || *str==0 ){ numdb_erase(mapregstr_db,num); mapreg_dirty=1; return 0; } - p=(char *)aCalloc(strlen(str)+1, sizeof(char)); + p=(char *)aCallocA(strlen(str)+1, sizeof(char)); strcpy(p,str); numdb_insert(mapregstr_db,num,p); mapreg_dirty=1; @@ -7102,7 +7106,7 @@ static int script_load_mapreg() printf("%s: %s broken data !\n",mapreg_txt,buf1); continue; } - p=(char *)aCalloc(strlen(buf2) + 1,sizeof(char)); + p=(char *)aCallocA(strlen(buf2) + 1,sizeof(char)); strcpy(p,buf2); s=add_str(buf1); numdb_insert(mapregstr_db,(i<<24)|s,p); @@ -7170,7 +7174,7 @@ static int script_autosave_mapreg(int tid,unsigned int tick,int id,int data) } /*========================================== - * + * *------------------------------------------ */ static int set_posword(char *p) @@ -7256,7 +7260,7 @@ static int mapreg_db_final(void *key,void *data,va_list ap) } static int mapregstr_db_final(void *key,void *data,va_list ap) { - free(data); + aFree(data); return 0; } static int scriptlabel_db_final(void *key,void *data,va_list ap) @@ -7265,8 +7269,8 @@ static int scriptlabel_db_final(void *key,void *data,va_list ap) } static int userfunc_db_final(void *key,void *data,va_list ap) { - free(key); - free(data); + aFree(key); + aFree(data); return 0; } int do_final_script() @@ -7274,7 +7278,7 @@ int do_final_script() if(mapreg_dirty>=0) script_save_mapreg(); if(script_buf) - free(script_buf); + aFree(script_buf); if(mapreg_db) numdb_final(mapreg_db,mapreg_db_final); @@ -7286,9 +7290,9 @@ int do_final_script() strdb_final(userfunc_db,userfunc_db_final); if (str_data) - free(str_data); + aFree(str_data); if (str_buf) - free(str_buf); + aFree(str_buf); return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index 8ede774e3..16cb26c06 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -730,7 +730,7 @@ const struct skill_name_db skill_names[] = { { WZ_STORMGUST, "STORMGUST", "Storm_Gust" } , { WZ_VERMILION, "VERMILION", "Lord_of_Vermilion" } , { WZ_WATERBALL, "WATERBALL", "Water_Ball" } , - { 0, 0, 0 } + { 0, 0, 0 } }; static const int dirx[8]={0,-1,-1,-1,0,1,1,1}; @@ -890,8 +890,8 @@ int skillnotok(int skillid, struct map_session_data *sd) { if (sd == 0) return 0; - if (!(skillid >= 10000 && skillid < 10015)) - if ((skillid > MAX_SKILL) || (skillid < 0)) + if (!(skillid >= 10000 && skillid < 10015)) + if ((skillid > MAX_SKILL) || (skillid < 0)) return 1; if (pc_isGM(sd) >= 20) @@ -1055,12 +1055,12 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s //if(skilllv <= 0) return 0; if(skillid > 0 && skilllv <= 0) return 0; // don't forget auto attacks! - celest - if(src->type==BL_PC){ - nullpo_retr(0, sd=(struct map_session_data *)src); - }else if(src->type==BL_MOB){ - nullpo_retr(0, md=(struct mob_data *)src); //未使用? - }else if(src->type==BL_PET){ - nullpo_retr(0, pd=(struct pet_data *)src); // [Valaris] + if (src->type == BL_PC){ + nullpo_retr(0, sd = (struct map_session_data *)src); + } else if (src->type == BL_MOB){ + nullpo_retr(0, md = (struct mob_data *)src); //未使用? + } else if (src->type == BL_PET){ + nullpo_retr(0, pd = (struct pet_data *)src); // [Valaris] } //?象の耐性 @@ -1088,6 +1088,13 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s if(sc_def_luk<50) sc_def_luk=50; } + if (dstsd && dstsd->sc_count && dstsd->sc_data[SC_GOSPEL].timer != -1 && + dstsd->sc_data[SC_GOSPEL].val4 == BCT_PARTY && + dstsd->sc_data[SC_GOSPEL].val3 == 3) { + sc_def_mdef -= 25; + sc_def_vit -= 25; + sc_def_int -= 25; + } if(sc_def_mdef<0) sc_def_mdef=0; if(sc_def_vit<0) @@ -1291,18 +1298,18 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s // case WZ_METEOR: if(rand()%100 < sc_def_vit) - skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); + skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); break; case WZ_VERMILION: if(rand()%100 < sc_def_int) - skill_status_change_start(bl,SC_BLIND,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); + skill_status_change_start(bl,SC_BLIND,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); break; // -- moonsoul (stun ability of new champion skill tigerfist) // case CH_TIGERFIST: if( rand()%100 < (10 + skilllv*10)*sc_def_vit/100 ) { - int sec = skill_get_time2 (skillid,skilllv) - (double)battle_get_agi(bl)*0.1; + int sec = skill_get_time2 (skillid,skilllv) - battle_get_agi(bl)/10; skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,sec,0); } break; @@ -1577,7 +1584,7 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds return 0; if(bl->type == BL_PC && pc_isdead((struct map_session_data *)bl)) //?象がPCですでに死んでいたら何もしない return 0; - if(bl->type == BL_PC && skillnotok(skillid, (struct map_session_data *) bl)) + if(bl->type == BL_PC && skillnotok(skillid, (struct map_session_data *) bl)) return 0; // [MouseJstr] if(sc_data && sc_data[SC_HIDING].timer != -1) { //ハイディング?態で if(skill_get_pl(skillid) != 2) //スキルの?性が地?性でなければ何もしない @@ -2297,7 +2304,7 @@ int skill_cleartimerskill(struct block_list *src) */ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int skillid,int skilllv,unsigned int tick,int flag ) { - struct map_session_data *sd=NULL; + struct map_session_data *sd = NULL; struct status_change *sc_data = battle_get_sc_data(src); int i; @@ -2374,7 +2381,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case LK_SPIRALPIERCE: /* スパイラルピア?ス */ case LK_HEADCRUSH: /* ヘッドクラッシュ */ case LK_JOINTBEAT: /* ジョイントビ?ト */ - case PA_PRESSURE: /* プレッシャ? */ +// case PA_PRESSURE: /* プレッシャ? */ // case PA_SACRIFICE: /* サクリファイス */ case SN_SHARPSHOOTING: /* シャ?プシュ?ティング */ case CG_ARROWVULCAN: /* アロ?バルカン */ @@ -2383,6 +2390,22 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case ITM_TOMAHAWK: skill_attack(BF_WEAPON,src,src,bl,skillid,skilllv,tick,flag); break; + case PA_PRESSURE: /* プレッシャ? */ + skill_attack(BF_WEAPON,src,src,bl,skillid,skilllv,tick,flag); + if (rand()%100 < 50) + skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(PA_PRESSURE,skilllv),0); + else + skill_status_change_start(bl,SC_BLEEDING,skilllv,0,0,0,skill_get_time2(PA_PRESSURE,skilllv),0); + if (bl->type == BL_PC) { + int sp; + struct map_session_data *tsd = (struct map_session_data *)bl; + nullpo_retb (tsd); + sp = tsd->status.max_sp * 10 * skilllv / 100; + if (sp > tsd->status.sp) sp = tsd->status.sp; + tsd->status.sp -= sp; + pc_heal(sd,0,-sp); + } + break; case NPC_DARKBREATH: clif_emotion(src,7); skill_attack(BF_MISC,src,src,bl,skillid,skilllv,tick,flag); @@ -2429,7 +2452,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s else if (bl->type == BL_MOB) ((struct mob_data *)bl)->dir=dir; clif_changed_dir(bl); - //skill_blown(src,bl,skill_get_blewcount(skillid,skilllv)); + //skill_blown(src,bl,skill_get_blewcount(skillid,skilllv)); } else if(src->type == BL_PC) clif_skill_fail(sd,sd->skillid,0,0); @@ -2558,7 +2581,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s if (skillid == ASC_METEORASSAULT) clif_skill_nodamage(src,bl,skillid,skilllv,1); - + skill_area_temp[1]=bl->id; skill_area_temp[2]=x; skill_area_temp[3]=y; @@ -2752,7 +2775,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case WZ_FROSTNOVA: /* フロストノヴァ */ skill_castend_pos2(src,bl->x,bl->y,skillid,skilllv,tick,0); //skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,flag); - map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); + map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); break; case WZ_SIGHTRASHER: @@ -2806,8 +2829,10 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s clif_skill_nodamage(src,bl,skillid,skilllv,1); if (skilllv == 5) skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,0 ); - if (bl->type == BL_PC) + if (bl->type == BL_PC) { ((struct map_session_data *)bl)->status.sp = 0; + clif_updatestatus((struct map_session_data *)bl,SP_SP); + } } else { clif_skill_nodamage(src,src,skillid,skilllv,1); if (skilllv == 5) @@ -2961,7 +2986,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int return 1; if (skillnotok(skillid, (struct map_session_data *)bl)) // [MouseJstr] return 0; - + map_freeblock_lock(); switch(skillid) { @@ -2971,7 +2996,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int int heal_get_jobexp; int skill; struct pc_base_job s_class; - + if( dstsd && dstsd->special_state.no_magic_damage ) heal=0; /* ?金蟲カ?ド(ヒ?ル量0) */ if (sd){ @@ -2981,7 +3006,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if(sd && dstsd && sd->status.partner_id == dstsd->status.char_id && s_class.job == 23 && sd->status.sex == 0) //自分も?象もPC、?象が自分のパ?トナ?、自分がスパノビ、自分が♀なら heal = heal*2; //スパノビの嫁が旦那にヒ?ルすると2倍になる } - + clif_skill_nodamage(src,bl,skillid,heal,1); heal_get_jobexp = battle_heal(NULL,bl,heal,0,0); @@ -3192,11 +3217,11 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int struct status_change *tsc_data = battle_get_sc_data(bl); int sc = SkillStatusChangeTable[skillid]; int sc2 = SC_MARIONETTE2; - + if((dstsd->bl.type!=BL_PC) || (sd->bl.id == dstsd->bl.id) || (!sd->status.party_id) - || (sd->status.party_id != dstsd->status.party_id)) { + || (sd->status.party_id != dstsd->status.party_id)) { clif_skill_fail(sd,skillid,0,0); map_freeblock_unlock(); return 1; @@ -3218,7 +3243,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } clif_skill_nodamage(src,bl,skillid,skilllv,1); } - } + } break; case SA_FLAMELAUNCHER: // added failure chance and chance to break weapon if turned on [Valaris] @@ -3303,7 +3328,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int skill_status_change_start(bl,SkillStatusChangeTable[skillid],skilllv,0,0,0,skill_get_time(skillid,skilllv),0 ); skill_status_change_start(src,SC_BLOCKSKILL,skilllv,0,skillid,0,10000,0 ); break; - + case SM_AUTOBERSERK: // Celest { struct status_change *tsc_data = battle_get_sc_data(bl); @@ -3317,7 +3342,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } } break; - + case AS_ENCHANTPOISON: // Prevent spamming [Valaris] if(bl->type==BL_PC) { struct map_session_data *sd2=(struct map_session_data *)bl; @@ -3385,11 +3410,12 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int skill_status_change_end(bl,SC_SLEEP,-1); } - if(bl->type==BL_MOB) { + if(dstmd) { int range = skill_get_range(skillid,skilllv); if(range < 0) range = battle_get_range(src) - (range + 1); - mob_target((struct mob_data *)bl,src,range); + md->state.provoke_flag = src->id; + mob_target(dstmd,src,range); } } break; @@ -3506,7 +3532,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int clif_skill_produce_mix_list(sd,256); clif_skill_nodamage(src,bl,skillid,skilllv,1); } - break; + break; case BS_HAMMERFALL: /* ハンマ?フォ?ル */ clif_skill_nodamage(src,bl,skillid,skilllv,1); if( bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_weapon_damage ) @@ -3733,6 +3759,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int skill_clear_unitgroup(src); clif_skill_nodamage(src,bl,skillid,skilllv,1); skill_unitsetting(src,skillid,skilllv,src->x,src->y,0); + skill_status_change_start(src,SkillStatusChangeTable[skillid],skilllv,0,0,BCT_SELF,skill_get_time(skillid,skilllv),0); break; case BD_ADAPTATION: /* アドリブ */ @@ -4402,20 +4429,20 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking) pc_breakweapon((struct map_session_data *)bl); break; - + case NPC_BREAKARMOR: clif_skill_nodamage(src,bl,skillid,skilllv,1); if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking) pc_breakarmor((struct map_session_data *)bl); break; - + case NPC_BREAKHELM: clif_skill_nodamage(src,bl,skillid,skilllv,1); if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking) // since we don't have any code for helm breaking yet... pc_breakweapon((struct map_session_data *)bl); break; - + case NPC_BREAKSHIELD: clif_skill_nodamage(src,bl,skillid,skilllv,1); if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking) @@ -4449,7 +4476,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if(map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto || map[dstsd->bl.m].flag.nowarp){ clif_skill_teleportmessage(sd,1); return 0; - } + } skill_unitsetting(src,skillid,skilllv,sd->bl.x,sd->bl.y,0); } break; @@ -4500,7 +4527,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); } } - + } if(su->group->unit_id == 0x91 && su->group->val2){ struct block_list *target=map_id2bl(su->group->val2); @@ -4595,7 +4622,9 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int sd->status.sp = sp2; dstsd->status.sp = sp1; clif_heal(sd->fd,SP_SP,sp2); + clif_updatestatus(sd,SP_SP); clif_heal(dstsd->fd,SP_SP,sp1); + clif_updatestatus(dstsd,SP_SP); } else if (dstmd) { if (dstmd->state.soul_change_flag) { clif_skill_fail(sd,skillid,0,0); @@ -4607,6 +4636,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int sp2 = sd->status.max_sp - sd->status.sp; sd->status.sp += sp2; clif_heal(sd->fd,SP_SP,sp2); + clif_updatestatus(sd,SP_SP); dstmd->state.soul_change_flag = 1; } } @@ -4661,6 +4691,15 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } } break; + case ST_PRESERVE: + if (sd){ + if (sd->sc_count && sd->sc_data[SC_PRESERVE].timer != -1) + skill_status_change_end(src, SC_PRESERVE, -1 ); + else + skill_status_change_start(src,SC_PRESERVE,skilllv,0,0,0,skill_get_time(skillid, skilllv),0 ); + clif_skill_nodamage(src,src,skillid,skilllv,1); + } + break; // New guild skills [Celest] case GD_BATTLEORDER: @@ -4713,7 +4752,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } } break; - case GD_RESTORE: + case GD_RESTORE: { struct guild *g = NULL; // Only usable during WoE @@ -4725,8 +4764,8 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if(flag&1) { if (dstsd && dstsd->status.guild_id == sd->status.guild_id) { int hp, sp; - hp = dstsd->status.max_hp*0.9; - sp = dstsd->status.max_sp*0.9; + hp = dstsd->status.max_hp*9/10; + sp = dstsd->status.max_sp*9/10; sp = dstsd->status.sp + sp <= dstsd->status.max_sp ? sp : dstsd->status.max_sp - dstsd->status.sp; clif_skill_nodamage(src,bl,AL_HEAL,hp,1); battle_heal(NULL,bl,hp,sp,0); @@ -4937,8 +4976,8 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil if(src->type==BL_PC){ nullpo_retr(0, sd=(struct map_session_data *)src); } - if( skillid != WZ_METEOR && - skillid != WZ_SIGHTRASHER && + if( skillid != WZ_METEOR && + skillid != WZ_SIGHTRASHER && skillid != AM_CANNIBALIZE && skillid != AM_SPHEREMINE) clif_skill_poseffect(src,skillid,skilllv,x,y,tick); @@ -5015,7 +5054,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil case HT_TALKIEBOX: /* ト?キ?ボックス */ skill_unitsetting(src,skillid,skilllv,x,y,0); break; - + case RG_GRAFFITI: /* Graffiti [Valaris] */ skill_clear_unitgroup(src); skill_unitsetting(src,skillid,skilllv,x,y,0); @@ -5088,7 +5127,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil mx = x;// + (rand()%10 - 5); my = y;// + (rand()%10 - 5); - + id=mob_once_spawn(sd,"this",mx,my,"--ja--", summons[skilllv-1] ,1,""); if( (md=(struct mob_data *)map_id2bl(id)) !=NULL ){ md->master_id=sd->bl.id; @@ -5138,7 +5177,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil map_foreachinarea(skill_area_sub, src->m,x-3,y-3,x+3,y+3,0, src,skillid,skilllv,tick,flag|BCT_ALL|1, - skill_castend_nodamage_id); + skill_castend_nodamage_id); } } } @@ -5175,7 +5214,7 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_MARIONETTE].timer != -1) return 0; - + if (sd->sc_data[SC_BLOCKSKILL].timer!=-1) if (skill_num == sd->sc_data[SC_BLOCKSKILL].val3) return 0; @@ -5243,7 +5282,7 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma return 0; if((group=skill_unitsetting(&sd->bl,sd->skillid,sd->skilllv,sd->skillx,sd->skilly,0))==NULL) return 0; - group->valstr=(char *)aCalloc(24,sizeof(char)); + group->valstr=(char *)aCallocA(24,sizeof(char)); memcpy(group->valstr,map,24); group->val2=(x<<16)|y; } @@ -5287,7 +5326,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, else count=3; limit=skill_get_time(skillid,skilllv); if(sc_data) { - if (sc_data[SC_VIOLENTGALE].timer!=-1) limit *= 1.5; + if (sc_data[SC_VIOLENTGALE].timer!=-1) limit = limit*3/2; } // check for sc_data first - Celest // if (((struct map_session_data *)src)->sc_data[SC_VIOLENTGALE].timer!=-1) @@ -5337,7 +5376,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, if(skilllv < 6) range=1; else - range=2; + range=2; break; case MG_THUNDERSTORM: /* サンダ?スト?ム */ @@ -5629,7 +5668,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, group->range=range; if(skillid==HT_TALKIEBOX || skillid==RG_GRAFFITI){ - group->valstr=aCalloc(80, 1); + group->valstr=aCallocA(80, 1); if(group->valstr==NULL){ printf("skill_castend_map: out of memory !\n"); exit(1); @@ -6079,13 +6118,13 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int { struct status_change *sc_data=battle_get_sc_data(bl); if(sg->val2==0 && sc_data && sc_data[SC_ANKLE].timer==-1){ - int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE); - int sec=skill_get_time2(sg->skill_id,sg->skill_lv) - (double)battle_get_agi(bl)*0.1; + int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE); + int sec = skill_get_time2(sg->skill_id,sg->skill_lv) - battle_get_agi(bl)/10; if(battle_get_mode(bl)&0x20) sec = sec/5; battle_stopwalking(bl,1); skill_status_change_start(bl,SC_ANKLE,sg->skill_lv,0,0,0,sec,0); - + if(moveblock) map_delblock(bl); bl->x = src->bl.x; bl->y = src->bl.y; @@ -6127,7 +6166,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int case 0x8e: /* クァグマイア */ { struct status_change *sc_data=battle_get_sc_data(bl); - int type=SkillStatusChangeTable[sg->skill_id]; + int type=SkillStatusChangeTable[sg->skill_id]; if( bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_magic_damage ) break; if(sc_data && sc_data[type].timer==-1) @@ -6153,7 +6192,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int if (sc_data[type].timer==-1) skill_status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); else if((unit2=(struct skill_unit *)sc_data[type].val2) && unit2 != src ){ - if( unit2->group != 0 && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) + if( unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) skill_status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); ts->tick-=sg->interval; } @@ -6210,7 +6249,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int skill_status_change_start(bl,type,sg->skill_lv,(sg->val1)>>16,(sg->val1)&0xffff, (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); else if((unit2=(struct skill_unit *)sc_data[type].val4) && unit2 != src ){ - if( unit2->group != 0 && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) + if( unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) skill_status_change_start(bl,type,sg->skill_lv,(sg->val1)>>16,(sg->val1)&0xffff, (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); ts->tick-=sg->interval; @@ -6489,7 +6528,7 @@ int skill_unit_onout(struct skill_unit *src,struct block_list *bl,unsigned int t { struct map_session_data *sd; if (bl->type == BL_PC && (sd=(struct map_session_data *)bl) && sd->state.hawkeyes_flag > 0) - sd->state.hawkeyes_flag = 0; + sd->state.hawkeyes_flag = 0; } break; @@ -6578,7 +6617,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick) src->bl.x,src->bl.y,1); if(group == NULL) return 0; - group->valstr=aCalloc(24, 1); + group->valstr=aCallocA(24, 1); if(group->valstr==NULL){ printf("skill_unit_onlimit: out of memory !\n"); exit(1); @@ -6619,7 +6658,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick) struct map_session_data *sd; if ((sd = (struct map_session_data *)(map_id2bl(sg->src_id)))!= NULL) { sd->state.glorywounds_flag = 0; - } + } } break; case 0xc3: // GD_SOULCOLD @@ -6627,7 +6666,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick) struct map_session_data *sd; if ((sd = (struct map_session_data *)(map_id2bl(sg->src_id)))!= NULL) { sd->state.soulcold_flag = 0; - } + } } break; case 0xc4: // GD_HAWKEYES @@ -6905,7 +6944,7 @@ static int skill_check_condition_use_sub(struct block_list *bl,va_list ap) nullpo_retr(0, ssd=(struct map_session_data*)src); s_class = pc_calc_base_job(sd->status.class_); - + //チェックしない設定ならcにありえない大きな?字を返して終了 if(!battle_config.player_skill_partner_check){ //本?はforeachの前にやりたいけど設定適用箇所をまとめるためにここへ (*c)=99; @@ -7034,7 +7073,7 @@ int skill_check_condition(struct map_session_data *sd,int type) (sd->sc_data[SC_MARIONETTE].timer != -1 && sd->skillid != CG_MARIONETTE)){ clif_skill_fail(sd,sd->skillid,0,0); return 0; /* ?態異常や沈?など */ - } + } } skill = sd->skillid; lv = sd->skilllv; @@ -7192,7 +7231,7 @@ int skill_check_condition(struct map_session_data *sd,int type) break; case MG_FIREWALL: /* ファイア?ウォ?ル */ case WZ_QUAGMIRE: - case WZ_FIREPILLAR: // celest + case WZ_FIREPILLAR: // celest case PF_FOGWALL: /* ?制限 */ if(battle_config.pc_land_skill_limit) { @@ -7340,7 +7379,7 @@ int skill_check_condition(struct map_session_data *sd,int type) if(((itemid[i] >= 715 && itemid[i] <= 717) || itemid[i] == 1065) && sd->sc_data[SC_INTOABYSS].timer != -1) continue; if(skill == WZ_FIREPILLAR && lv<=5) - continue; // no gemstones for 1-5 [Celest] + continue; // no gemstones for 1-5 [Celest] if(skill == AM_POTIONPITCHER && i != x) continue; @@ -7357,7 +7396,7 @@ int skill_check_condition(struct map_session_data *sd,int type) if(!(type&1)) return 1; - if(skill != AM_POTIONPITCHER && + if(skill != AM_POTIONPITCHER && skill != CR_SLIMPITCHER && skill != MG_STONECURSE) { if(skill == AL_WARP && !(type&2)) @@ -7408,7 +7447,7 @@ int skill_castfix( struct block_list *bl, int time ) nullpo_retr(0, md=(struct mob_data*)bl); skill = md->skillid; lv = md->skilllv; - } else { + } else { nullpo_retr(0, sd=(struct map_session_data*)bl); skill = sd->skillid; lv = sd->skilllv; @@ -7451,13 +7490,13 @@ int skill_delayfix( struct block_list *bl, int time ) { struct status_change *sc_data; struct map_session_data *sd = NULL; - int skill,lv = 0; - int delayrate=100; - + int skill = 0,lv = 0; + int delayrate = 100; + nullpo_retr(0, bl); - if(bl->type==BL_PC){ - nullpo_retr(0, sd=(struct map_session_data*)bl); + if(bl->type == BL_PC){ + nullpo_retr(0, sd = (struct map_session_data*)bl); skill = sd->skillid; lv = sd->skilllv; } @@ -7466,24 +7505,32 @@ int skill_delayfix( struct block_list *bl, int time ) sc_data = battle_get_sc_data(bl); - // instant cast attack skills depend on aspd as delay [celest] - if (time <= 0 && skill_db[skill].skill_type == BF_WEAPON) - time = battle_get_adelay (bl)/2; - if(sd) { delayrate=((struct map_session_data *)bl)->delayrate; + // instant cast attack skills depend on aspd as delay [celest] + if (time == 0) { + if (skill_db[skill].skill_type == BF_WEAPON) + time = battle_get_adelay (bl)/2; + else + time = 300; // default delay, according to official servers + } else if (time < 0) + time = abs(time) + battle_get_adelay (bl)/2; // if set to <0, the aspd delay will be added + if(battle_config.delay_dependon_dex && /* dexの影響を計算する */ !skill_get_delaynodex(skill, lv)) // if skill casttime is allowed to be reduced by dex - time=time*(battle_config.castrate_dex_scale - battle_get_dex(bl))/(battle_config.castrate_dex_scale); + time = time * (battle_config.castrate_dex_scale - battle_get_dex(bl)) / (battle_config.castrate_dex_scale); - time=time*delayrate*battle_config.delay_rate/10000; + time = time * delayrate * battle_config.delay_rate / 10000; + + if (time < battle_config.min_skill_delay_limit) // check minimum skill delay + time = battle_config.min_skill_delay_limit; } /* ブラギの詩 */ - if(sc_data && sc_data[SC_POEMBRAGI].timer!=-1 ) - time=time*(100-(sc_data[SC_POEMBRAGI].val1*3+sc_data[SC_POEMBRAGI].val2 - +(sc_data[SC_POEMBRAGI].val3&0xffff)))/100; + if(sc_data && sc_data[SC_POEMBRAGI].timer != -1 ) + time = time * (100 - (sc_data[SC_POEMBRAGI].val1 * 3 + sc_data[SC_POEMBRAGI].val2 + + (sc_data[SC_POEMBRAGI].val3 & 0xffff))) / 100; return (time>0)?time:0; } @@ -7512,10 +7559,10 @@ int skill_use_id( struct map_session_data *sd, int target_id, } if(sd->bl.m != bl->m || pc_isdead(sd)) return 0; - + if(skillnotok(skill_num, sd)) // [MouseJstr] return 0; - + sc_data=sd->sc_data; /* 沈?や異常(ただし、グリムなどの判定をする) */ @@ -7598,7 +7645,7 @@ int skill_use_id( struct map_session_data *sd, int target_id, case ST_CHASEWALK: return 0; } - }*/ + }*/ if(skill_get_inf2(skill_num)&0x200 && sd->bl.id == target_id) return 0; @@ -7671,15 +7718,27 @@ int skill_use_id( struct map_session_data *sd, int target_id, if(!skill_check_condition(sd,0)) return 0; - /* 射程と障害物チェック */ - range = skill_get_range(skill_num,skill_lv); - if(range < 0) - range = battle_get_range(&sd->bl) - (range + 1); - // be lenient if the skill was cast before we have moved to the correct position [Celest] - if (sd->walktimer != -1) - range += battle_config.skill_range_leniency; - if(!battle_check_range(&sd->bl,bl,range) ) - return 0; + { + int check_range_flag = 0; + + /* 射程と障害物チェック */ + range = skill_get_range(skill_num,skill_lv); + if(range < 0) + range = battle_get_range(&sd->bl) - (range + 1); + // be lenient if the skill was cast before we have moved to the correct position [Celest] + if (sd->walktimer != -1) + range += battle_config.skill_range_leniency; + else check_range_flag = 1; + if(!battle_check_range(&sd->bl,bl,range)) { + if (check_range_flag && battle_check_range(&sd->bl,bl,range + battle_config.skill_range_leniency)) { + int dir, mask[8][2] = {{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}}; + dir = map_calc_dir(&sd->bl,bl->x,bl->y); + pc_walktoxy (sd, sd->bl.x + mask[dir][0] * battle_config.skill_range_leniency, + sd->bl.y + mask[dir][1] * battle_config.skill_range_leniency); + } else + return 0; + } + } if(bl->type==BL_PC) { target_sd=(struct map_session_data*)bl; @@ -7745,13 +7804,12 @@ int skill_use_id( struct map_session_data *sd, int target_id, case WE_MALE: case WE_FEMALE: { + struct map_session_data *p_sd = pc_get_partner(sd); + nullpo_retr (0, p_sd) if(skill_num == WE_MALE && sd->status.hp <= ((15*sd->status.max_hp)/100)) // Requires more than 15% of Max HP for WE_MALE return 0; if(skill_num == WE_FEMALE && sd->status.sp <= ((15*sd->status.max_sp)/100)) // Requires more than 15% of Max SP for WE_FEMALE return 0; - struct map_session_data *p_sd = NULL; - if((p_sd = pc_get_partner(sd)) == NULL) - return 0; target_id = p_sd->bl.id; //rangeをもう1回?査 range = skill_get_range(skill_num,skill_lv); @@ -7905,7 +7963,7 @@ int skill_use_pos( struct map_session_data *sd, /* if(map[sd->bl.m].flag.gvg && (skill_num == SM_ENDURE || skill_num == AL_TELEPORT || - skill_num == AL_WARP || skill_num == WZ_ICEWALL || + skill_num == AL_WARP || skill_num == WZ_ICEWALL || skill_num == TF_BACKSLIDING)) return 0;*/ @@ -8023,7 +8081,7 @@ int skill_castcancel(struct block_list *bl,int type) } sd->skilltimer=-1; clif_skillcastcancel(bl); - } + } return 0; }else if(bl->type==BL_MOB){ @@ -8695,12 +8753,14 @@ int skill_status_change_timer_sub(struct block_list *bl, va_list ap ) break; case SC_RUWACH: /* ルアフ */ if( (*battle_get_option(bl))&6 ){ - skill_status_change_end( bl, SC_HIDING, -1); - skill_status_change_end( bl, SC_CLOAKING, -1); if(battle_check_target( src,bl, BCT_ENEMY ) > 0) { - struct status_change *sc_data = battle_get_sc_data(bl); - if (sc_data) + struct status_change *sc_data = battle_get_sc_data(bl); // check whether the target is hiding/cloaking [celest] + if (sc_data && (sc_data[SC_HIDING].timer != -1 || // if the target is using a special hiding, i.e not using normal hiding/cloaking, don't bother + sc_data[SC_CLOAKING].timer != -1)) { + skill_status_change_end( bl, SC_HIDING, -1); + skill_status_change_end( bl, SC_CLOAKING, -1); skill_attack(BF_MAGIC,src,src,bl,AL_RUWACH,sc_data[type].val1,tick,0); + } } } break; @@ -8712,7 +8772,7 @@ int skill_status_change_timer_sub(struct block_list *bl, va_list ap ) * ステ?タス異常終了 *------------------------------------------ */ -int skill_status_change_end(struct block_list* bl, int type, int tid) +int skill_status_change_end(struct block_list* bl, int type, int tid) { struct status_change* sc_data; int opt_flag=0, calc_flag = 0; @@ -8798,8 +8858,6 @@ int skill_status_change_end(struct block_list* bl, int type, int tid) case SC_MELTDOWN: /* メルトダウン */ // Celest case SC_EDP: - case SC_MARIONETTE: - case SC_MARIONETTE2: case SC_SLOWDOWN: case SC_SPEEDUP0: /* case SC_LEADERSHIP: @@ -8816,7 +8874,7 @@ int skill_status_change_end(struct block_list* bl, int type, int tid) break; case SC_BERSERK: /* バ?サ?ク */ calc_flag = 1; - clif_status_change(bl,SC_INCREASEAGI,0); /* アイコン消去 */ + clif_status_change(bl,SC_INCREASEAGI,0); /* アイコン消去 */ break; case SC_DEVOTION: /* ディボ?ション */ { @@ -8900,14 +8958,32 @@ int skill_status_change_end(struct block_list* bl, int type, int tid) case SC_CONFUSION: { struct map_session_data *sd=NULL; - if(bl->type == BL_PC && (sd=(struct map_session_data *)bl)){ + if(bl->type == BL_PC && (sd=(struct map_session_data *)bl)){ sd->next_walktime = -1; } } break; - } - if(bl->type==BL_PC && type 0 && + (sc_data = battle_get_sc_data(pbl)) && + sc_data[type2].timer != -1) + skill_status_change_end(pbl, type2, -1); + } + calc_flag = 1; + } + break; + } + + if(bl->type==BL_PC && + (type 0) { sc_data[type].timer = add_timer( 500 + tick, skill_status_change_timer, @@ -9437,7 +9513,7 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data) 1000 + tick, skill_status_change_timer, bl->id, data); return 0; - } + } } break; @@ -9451,7 +9527,7 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data) bl->id, data); } break;*/ - + // Celest case SC_CONFUSION: { @@ -9475,7 +9551,159 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data) } } break; - } + + case SC_GOSPEL: + { + int calc_flag = 0; + if (sc_data[type].val3 > 0) { + sc_data[type].val3 = 0; + calc_flag = 1; + } + if(sd && sc_data[type].val4 == BCT_SELF){ + int hp, sp; + hp = (sc_data[type].val1 > 5) ? 45 : 30; + sp = (sc_data[type].val1 > 5) ? 35 : 20; + if(sd->status.hp - hp > 0 && + sd->status.sp - sp > 0){ + sd->status.hp -= hp; + sd->status.sp -= sp; + clif_updatestatus(sd,SP_HP); + clif_updatestatus(sd,SP_SP); + if ((sc_data[type].val2 -= 10000) > 0) { + sc_data[type].timer = add_timer( + 10000+tick, skill_status_change_timer, + bl->id, data); + return 0; + } + } + } else if (sd && sc_data[type].val4 == BCT_PARTY) { + int i; + switch ((i = rand() % 12)) { + case 1: // heal between 100-1000 + { + struct block_list tbl; + int heal = rand() % 900 + 100; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,AL_HEAL,heal,1); + battle_heal(NULL,bl,heal,0,0); + } + break; + case 2: // end negative status + { + int j; + for (j=0; j<4; j++) + if(sc_data[i + SC_POISON].timer!=-1) { + skill_status_change_end(bl,j,-1); + break; + } + } + break; + case 3: // +25% resistance to negative status + case 4: // +25% max hp + case 5: // +25% max sp + case 6: // +2 to all stats + case 11: // +25% armor and vit def + case 12: // +8% atk + case 13: // +5% flee + case 14: // +5% hit + sc_data[type].val3 = i; + if (i == 6 || + (i >= 11 && i <= 14)) + calc_flag = 1; + break; + case 7: // level 5 bless + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,AL_BLESSING,5,1); + skill_status_change_start(bl,SkillStatusChangeTable[AL_BLESSING],5,0,0,0,10000,0 ); + } + break; + case 8: // level 5 increase agility + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,AL_INCAGI,5,1); + skill_status_change_start(bl,SkillStatusChangeTable[AL_INCAGI],5,0,0,0,10000,0 ); + } + break; + case 9: // holy element to weapon + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,PR_ASPERSIO,1,1); + skill_status_change_start(bl,SkillStatusChangeTable[PR_ASPERSIO],1,0,0,0,10000,0 ); + } + break; + case 10: // holy element to armour + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,PR_BENEDICTIO,1,1); + skill_status_change_start(bl,SkillStatusChangeTable[PR_BENEDICTIO],1,0,0,0,10000,0 ); + } + break; + default: + break; + } + } else if (sc_data[type].val4 == BCT_ENEMY) { + int i; + switch ((i = rand() % 8)) { + case 1: // damage between 300-800 + case 2: // damage between 150-550 (ignore def) + battle_damage(NULL, bl, rand() % 500,0); // temporary damage + break; + case 3: // random status effect + { + int effect[3] = { + SC_CURSE, + SC_BLIND, + SC_POISON }; + skill_status_change_start(bl,effect[rand()%3],1,0,0,0,10000,0 ); + } + break; + case 4: // level 10 provoke + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,SM_PROVOKE,1,1); + skill_status_change_start(bl,SkillStatusChangeTable[SM_PROVOKE],10,0,0,0,10000,0 ); + } + break; + case 5: // 0 def + case 6: // 0 atk + case 7: // 0 flee + case 8: // -75% move speed and aspd + sc_data[type].val3 = i; + calc_flag = 1; + break; + default: + break; + } + } + if (sd && calc_flag) + pc_calcstatus (sd, 0); + } + break; + } return skill_status_change_end( bl,type,tid ); } @@ -9510,7 +9738,7 @@ int skill_encchant_eremental_end(struct block_list *bl,int type) * ステ?タス異常開始 *------------------------------------------ */ -int skill_status_change_start(struct block_list *bl, int type, int val1, int val2, int val3, int val4, int tick, int flag) +int skill_status_change_start(struct block_list *bl, int type, int val1, int val2, int val3, int val4, int tick, int flag) { struct map_session_data *sd = NULL; struct status_change* sc_data; @@ -9660,7 +9888,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val break; case SC_DECREASEAGI: /* 速度減少 */ if (bl->type == BL_PC) // Celest - tick>>=1; + tick>>=1; calc_flag = 1; if(sc_data[SC_INCREASEAGI].timer!=-1 ) skill_status_change_end(bl,SC_INCREASEAGI,-1); @@ -9718,7 +9946,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val calc_flag = 1; break; case SC_POISONREACT: /* ポイズンリアクト */ - val2=val1/2 + val1%2; // [Celest] + val2=val1/2 + val1%2; // [Celest] break; case SC_IMPOSITIO: /* インポシティオマヌス */ calc_flag = 1; @@ -9756,7 +9984,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val case SC_TRICKDEAD: /* 死んだふり */ if (bl->type == BL_PC) { pc_stopattack((struct map_session_data *)sd); - } + } break; case SC_QUAGMIRE: /* クァグマイア */ calc_flag = 1; @@ -9814,7 +10042,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val case SC_STRIPSHIELD: if (val2==0) val2=85; break; - case SC_STRIPARMOR: + case SC_STRIPARMOR: case SC_STRIPHELM: case SC_CP_WEAPON: case SC_CP_SHIELD: @@ -9970,7 +10198,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val case SC_WEDDING: //結婚用(結婚衣裳になって?くのが?いとか) { time_t timer; - + calc_flag = 1; tick = 10000; if(!val2) @@ -9983,7 +10211,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val if(!battle_config.muting_players) break; - + tick = 60000; if(!val2) val2 = time(&timer); @@ -10243,6 +10471,30 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val case SC_BASILICA: // [celest] break; + case SC_GOSPEL: + if (val4 == BCT_SELF) { // self effect + int i; + if (sd) { + sd->canact_tick += tick; + sd->canmove_tick += tick; + } + val2 = tick; + tick = 1000; + for (i=0; i<=26; i++) { + if(sc_data[i].timer!=-1) + skill_status_change_end(bl,i,-1); + } + for (i=58; i<=62; i++) { + if(sc_data[i].timer!=-1) + skill_status_change_end(bl,i,-1); + } + for (i=132; i<=136; i++) { + if(sc_data[i].timer!=-1) + skill_status_change_end(bl,i,-1); + } + } + break; + case SC_MARIONETTE: /* マリオネットコントロ?ル */ case SC_MARIONETTE2: val2 = tick; @@ -10284,6 +10536,9 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val // calc_flag = 1; // not sure of effects yet [celest] break; + case SC_PRESERVE: + break; + case SC_BLOCKSKILL: if (!tick) tick = 60000; if (!val3) val3 = -1; @@ -10307,7 +10562,8 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val return 0; } - if(bl->type==BL_PC && typetype==BL_PC && + (typevalstr=NULL; } - map_freeblock(group->unit); /* free()の替わり */ + map_freeblock(group->unit); /* aFree()の替わり */ group->unit=NULL; group->src_id=0; group->group_id=0; @@ -11243,9 +11491,9 @@ int skill_unit_move_unit_group( struct skill_unit_group *group, int m,int dx,int int i,j, *r_flag, *s_flag, *m_flag; struct skill_unit *unit1; struct skill_unit *unit2; - r_flag = (int *) aMalloc(sizeof(int) * group->unit_count); - s_flag = (int *) aMalloc(sizeof(int) * group->unit_count); - m_flag = (int *) aMalloc(sizeof(int) * group->unit_count); + r_flag = (int *) aMallocA(sizeof(int) * group->unit_count); + s_flag = (int *) aMallocA(sizeof(int) * group->unit_count); + m_flag = (int *) aMallocA(sizeof(int) * group->unit_count); memset(r_flag,0, sizeof(int) * group->unit_count);// ?承フラグ memset(s_flag,0, sizeof(int) * group->unit_count);// ?承フラグ memset(m_flag,0, sizeof(int) * group->unit_count);// ?承フラグ @@ -11316,9 +11564,9 @@ int skill_unit_move_unit_group( struct skill_unit_group *group, int m,int dx,int } } } - free(r_flag); - free(s_flag); - free(m_flag); + aFree(r_flag); + aFree(s_flag); + aFree(m_flag); } } return 0; @@ -11470,7 +11718,7 @@ int skill_produce_mix( struct map_session_data *sd, else make_per = 1000 + sd->status.base_level*30 + sd->paramc[3]*20 + sd->paramc[4]*15 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300; } else if (skill_produce_db[idx].req_skill == ASC_CDP) { - make_per = 2000 + 40*sd->paramc[4] + 20*sd->paramc[5]; + make_per = 2000 + 40*sd->paramc[4] + 20*sd->paramc[5]; //make_per = 20 + (20*sd->paramc[4])/50 + (20*sd->paramc[5])/100; } else { if(nameid == 998) @@ -11493,7 +11741,7 @@ int skill_produce_mix( struct map_session_data *sd, if(make_per < 1) make_per = 1; - if(skill_produce_db[idx].req_skill==AM_PHARMACY || + if(skill_produce_db[idx].req_skill==AM_PHARMACY || skill_produce_db[idx].req_skill==ASC_CDP) { if( battle_config.pp_rate!=100 ) make_per=make_per*battle_config.pp_rate/100; @@ -12059,7 +12307,7 @@ int skill_readdb(void) i -= 9500; else if(i<=0 || i>MAX_SKILL_DB) continue; - + memset(split2,0,sizeof(split2)); for(j=0,p=split[1];j blank) + new_++; + if (new_ > blank) return; // 種類数超過 break; case ADDITEM_OVERAMOUNT: diff --git a/src/txt-converter/char/char-converter.c b/src/txt-converter/char/char-converter.c index 7b35fda63..1c5028d7e 100644 --- a/src/txt-converter/char/char-converter.c +++ b/src/txt-converter/char/char-converter.c @@ -16,16 +16,16 @@ #define STORAGE_MEMINC 16 - + #include "char.h" #include "../../common/strlib.h" #ifdef MEMWATCH #include "memwatch.h" #endif - + char pet_txt[256]="save/pet.txt"; -char storage_txt[256]="save/storage.txt"; +char storage_txt[256]="save/storage.txt"; MYSQL mysql_handle; MYSQL_RES* sql_res ; @@ -89,18 +89,18 @@ int inter_pet_fromstr(char *str, struct s_pet *p) int s; int tmp_int[16]; char tmp_str[256]; - + memset(p, 0, sizeof(struct s_pet)); - + // printf("sscanf pet main info\n"); s=sscanf(str,"%d, %d,%[^\t]\t%d, %d, %d, %d, %d, %d, %d, %d, %d", &tmp_int[0], &tmp_int[1], tmp_str, &tmp_int[2], &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10]); if(s!=12) return 1; - + p->pet_id = tmp_int[0]; - p->class = tmp_int[1]; + p->class_ = tmp_int[1]; memcpy(p->name, tmp_str, 24); p->account_id = tmp_int[2]; p->char_id = tmp_int[3]; @@ -126,11 +126,11 @@ int inter_pet_fromstr(char *str, struct s_pet *p) //--------------------------------------------------------- int inter_pet_tosql(int pet_id, struct s_pet *p) { //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) - + char tmp_sql[65535]; MYSQL_RES* sql_res ; MYSQL_ROW sql_row ; - + jstrescapecpy (t_name, p->name); if(p->hungry < 0) p->hungry = 0; @@ -148,19 +148,19 @@ int inter_pet_tosql(int pet_id, struct s_pet *p) { sql_row = mysql_fetch_row(sql_res); //row fetching if (!sql_row) //no row -> insert sprintf(tmp_sql,"INSERT INTO `pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) VALUES ('%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - p->pet_id, p->class, t_name, p->account_id, p->char_id, p->level, p->egg_id, + p->pet_id, p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate); else //row reside -> updating sprintf(tmp_sql, "UPDATE `pet` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'", - p->class, t_name, p->account_id, p->char_id, p->level, p->egg_id, + p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id); mysql_free_result(sql_res) ; //resource free if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } - + printf ("pet dump success! - %d:%s\n", pet_id, p->name); - + return 0; } @@ -168,22 +168,22 @@ int storage_tosql(int account_id,struct storage *p){ // id -> DB dump // storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} int i,j; - + j=0; - + //printf ("starting storage dump to DB - id: %d\n", account_id); - + //delete old data. sprintf(tmp_sql,"DELETE FROM `storage` WHERE `account_id`='%d'",account_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } - + //printf ("all storage item was deleted ok\n"); - + for(i=0;istorage[i].nameid , p->storage[i].amount); - + if( (p->storage[i].nameid) && (p->storage[i].amount) ){ sprintf(tmp_sql,"INSERT INTO `storage` (`account_id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`card0`,`card1`,`card2`,`card3`,`broken`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", p->account_id, p->storage[i].nameid, p->storage[i].amount, p->storage[i].equip, @@ -212,7 +212,7 @@ int storage_fromstr(char *str, struct storage *p) if(set!=2) return 0; if(str[next]=='\n' || str[next]=='\r') - return 1; + return 1; next++; for(i=0;str[next] && str[next]!='\t';i++){ if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", @@ -233,7 +233,7 @@ int storage_fromstr(char *str, struct storage *p) p->storage[i].broken = tmp_int[11]; next += len; if (str[next] == ' ') - next++; + next++; } else if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", @@ -251,12 +251,12 @@ int storage_fromstr(char *str, struct storage *p) p->storage[i].card[1] = tmp_int[8]; p->storage[i].card[2] = tmp_int[9]; p->storage[i].card[3] = tmp_int[10]; - p->storage[i].broken = 0; + p->storage[i].broken = 0; next += len; if (str[next] == ' ') - next++; + next++; } - + else return 0; } return 1; @@ -337,7 +337,7 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) { p->char_id = tmp_int[0]; p->account_id = tmp_int[1]; p->char_num = tmp_int[2]; - p->class = tmp_int[3]; + p->class_ = tmp_int[3]; p->base_level = tmp_int[4]; p->job_level = tmp_int[5]; p->base_exp = tmp_int[6]; @@ -508,10 +508,10 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) { //========================================================================================================== int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ int i,save_flag; - + save_flag = char_id; printf("request save char data... (%d)\n",char_id); - + //`char`( `char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`, //9 //`str`,`agi`,`vit`,`int`,`dex`,`luk`, //15 //`max_hp`,`hp`,`max_sp`,`sp`,`status_point`,`skill_point`, //21 @@ -525,7 +525,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ "`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d'," "`hair`='%d',`hair_color`='%d',`clothes_color`='%d',`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `partner_id` = '%d'", - char_id,p->account_id,p->char_num,p->name,p->class, p->base_level, p->job_level, + char_id,p->account_id,p->char_num,p->name,p->class_, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, @@ -535,17 +535,17 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ p->last_point.map, p->last_point.x, p->last_point.y, p->save_point.map, p->save_point.x, p->save_point.y, p->partner_id ); - + if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) ); } - + //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) sprintf(tmp_sql,"DELETE FROM `memo` WHERE `char_id`='%d'",char_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `memo`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;i<10;i++){ if(p->memo_point[i].map[0]){ @@ -560,7 +560,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `inventory`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;iinventory[i].nameid){ @@ -579,7 +579,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `cart_inventory`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;icart[i].nameid){ @@ -593,14 +593,14 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } } - - + + //`skill` (`char_id`, `id`, `lv`) sprintf(tmp_sql,"DELETE FROM `skill` WHERE `char_id`='%d'",char_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `skill`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;iskill[i].id){ @@ -618,7 +618,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `global_reg_value`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;iglobal_reg_num;i++){ if(p->global_reg[i].value !=0){ @@ -629,10 +629,10 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } } - + printf("saving char is done... (%d)\n",char_id); save_flag = 0; - + return 0; } //========================================================================================================== @@ -645,7 +645,7 @@ int mmo_char_init(void){ char input; FILE *fp; - + //DB connection initialized mysql_init(&mysql_handle); printf("Connect DB server.... (inter server)\n"); @@ -658,7 +658,7 @@ int mmo_char_init(void){ else { printf ("connect success! (inter server)\n"); } - + printf("Warning : Make sure you backup your databases before continuing!\n"); @@ -667,14 +667,14 @@ int mmo_char_init(void){ if(input == 'y' || input == 'Y'){ printf("\nConverting Character Database...\n"); fp=fopen("save/athena.txt","r"); - char_dat=malloc(sizeof(char_dat[0])*256); + char_dat = (struct mmo_charstatus*)malloc(sizeof(char_dat[0])*256); char_max=256; if(fp==NULL) return 0; while(fgets(line, 65535, fp)){ if(char_num>=char_max){ char_max+=256; - char_dat=realloc(char_dat, sizeof(char_dat[0]) *char_max); + char_dat = (struct mmo_charstatus*)realloc(char_dat, sizeof(char_dat[0]) *char_max); } memset(&char_dat[char_num], 0, sizeof(char_dat[0])); ret=mmo_char_fromstr(line, &char_dat[char_num]); @@ -689,8 +689,8 @@ int mmo_char_init(void){ printf("char data convert end\n"); fclose(fp); } - - while(getchar() != '\n'); + + while(getchar() != '\n'); printf("\nDo you wish to convert your Storage Database to SQL? (y/n) : "); input=getchar(); if(input == 'y' || input == 'Y') { @@ -700,14 +700,14 @@ int mmo_char_init(void){ printf("cant't read : %s\n",storage_txt); return 0; } - + while(fgets(line,65535,fp)){ set=sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]); if(set==2) { if(i==0){ - storage=malloc(sizeof(struct storage)); + storage = (struct storage*)malloc(sizeof(struct storage)); }else{ - storage=realloc(storage,sizeof(struct storage)*(i+1)); + storage = (struct storage*)realloc(storage,sizeof(struct storage)*(i+1)); } memset(&storage[i],0,sizeof(struct storage)); storage[i].account_id=tmp_int[0]; @@ -718,7 +718,7 @@ int mmo_char_init(void){ } fclose(fp); } - + while(getchar() != '\n'); printf("\nDo you wish to convert your Pet Database to SQL? (y/n) : "); input=getchar(); @@ -726,8 +726,8 @@ int mmo_char_init(void){ printf("\nConverting Pet Database...\n"); if( (fp=fopen(pet_txt,"r")) ==NULL ) return 1; - - p=malloc(sizeof(struct s_pet)); + + p = (struct s_pet*)malloc(sizeof(struct s_pet)); while(fgets(line, sizeof(line), fp)){ if(p==NULL){ printf("int_pet: out of memory!\n"); @@ -792,7 +792,7 @@ int inter_config_read(const char *cfgName) { } } fclose(fp); - + printf("Reading interserver configuration: Done\n"); return 0; @@ -825,7 +825,7 @@ int char_config_read(const char *cfgName) { } fclose(fp); printf("Reading configuration: Done\n"); - + return 0; } diff --git a/src/txt-converter/char/char.h b/src/txt-converter/char/char.h index b5864b31c..e1d5c90dc 100644 --- a/src/txt-converter/char/char.h +++ b/src/txt-converter/char/char.h @@ -24,9 +24,9 @@ struct mmo_map_server{ char map[MAX_MAP_PER_SERVER][16]; }; -int mapif_sendall(unsigned char *buf,unsigned int len); -int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len); -int mapif_send(int fd,unsigned char *buf,unsigned int len); +int mapif_sendall(char *buf,unsigned int len); +int mapif_sendallwos(int fd,char *buf,unsigned int len); +int mapif_send(int fd,char *buf,unsigned int len); extern int autosave_interval; diff --git a/src/txt-converter/common/mmo.h b/src/txt-converter/common/mmo.h index eb02b6879..e8ef2b987 100644 --- a/src/txt-converter/common/mmo.h +++ b/src/txt-converter/common/mmo.h @@ -87,7 +87,7 @@ struct s_pet { int account_id; int char_id; int pet_id; - short class; + short class_; short level; short egg_id;//pet egg id short equip;//pet equip name_id @@ -105,7 +105,7 @@ struct mmo_charstatus { int base_exp,job_exp,zeny; - short class; + short class_; short status_point,skill_point; int hp,max_hp,sp,max_sp; short option,karma,manner; @@ -168,7 +168,7 @@ struct party { struct guild_member { int account_id, char_id; - short hair,hair_color,gender,class,lv; + short hair,hair_color,gender,class_,lv; int exp,exp_payper; short online,position; int rsv1,rsv2; @@ -237,8 +237,8 @@ struct guild_castle { int Ghp4; int Ghp5; int Ghp6; - int Ghp7; - int GID0; + int Ghp7; + int GID0; int GID1; int GID2; int GID3; diff --git a/src/txt-converter/login/login-converter.c b/src/txt-converter/login/login-converter.c index a277ca949..f452d70aa 100644 --- a/src/txt-converter/login/login-converter.c +++ b/src/txt-converter/login/login-converter.c @@ -40,7 +40,7 @@ struct { int sex,delflag; } auth_fifo[AUTH_FIFO_SIZE]; int auth_fifo_pos=0; -struct { +struct auth_dat_ { int account_id, sex; char userid[24], pass[24], lastlogin[24]; int logincount; @@ -72,7 +72,7 @@ char db_server_logindb[32] = "ragnarok"; int isGM(int account_id) { struct gm_account *p; - p = numdb_search(gm_account_db,account_id); + p = (struct gm_account*)numdb_search(gm_account_db,account_id); if( p == NULL) return 0; return p->level; @@ -95,7 +95,7 @@ int read_gm_account() if(line[0] == '/' || line[1] == '/' || line[2] == '/') continue; - p=malloc(sizeof(struct gm_account)); + p = (struct gm_account*)malloc(sizeof(struct gm_account)); if(p==NULL){ printf("gm_account: out of memory!\n"); exit(0); @@ -145,7 +145,7 @@ int mmo_auth_init(void) fp=fopen("save/account.txt","r"); - auth_dat=malloc(sizeof(auth_dat[0])*256); + auth_dat = (struct auth_dat_*)malloc(sizeof(auth_dat[0])*256); auth_max=256; if(fp==NULL) return 0; -- cgit v1.2.3-70-g09d2 From d8776648ff6e6b3cb4922025b12c9cc42974b4db Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Sat, 5 Feb 2005 02:07:30 +0000 Subject: Servers can bind to single IP addresses now, and added buffer.(c/h) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1033 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 4 ++++ conf-tmpl/login_athena.conf | 10 ++++++++- src/char/char.c | 15 +++++++++----- src/char_sql/char.c | 13 ++++++------ src/common/buffer.h | 18 +++++++++++++++++ src/common/socket.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ src/common/socket.h | 1 + src/login/login.c | 29 +++++++++++++++++++++------ src/login_sql/login.c | 17 ++++++++++++++-- src/map/clif.c | 8 +++++--- 10 files changed, 141 insertions(+), 23 deletions(-) create mode 100644 src/common/buffer.h (limited to 'src/common/socket.c') diff --git a/Changelog.txt b/Changelog.txt index 2a8469119..5dbab7aa2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,10 @@ Date Added 02/04 + * Added common/buffer.(c/h) [SVN 1033: Ajarn] + * Login server can now set it's ip address in the config [SVN 1033: Ajarn] + * Servers now bind to a single ip address, thus allowing multiple servers to + a single port [SVN 1033: Ajarn] * Added experimental code to generate a stack dump when it segfaults, thanks to Ser [celest] - does not work with Cygwin, as it does not have glibc diff --git a/conf-tmpl/login_athena.conf b/conf-tmpl/login_athena.conf index 1c915dbbe..2cabd0953 100644 --- a/conf-tmpl/login_athena.conf +++ b/conf-tmpl/login_athena.conf @@ -1,7 +1,15 @@ // Athena Login Server configuration file. // Translated by Peter Kieser + +// Login Server IP +// +// You should only need to set this if you are running behind a +// firewall or on a machine with multiple interfaces. In that case, +// you need to specify the IP address you wish to export to the entire world. +// +//login_ip:127.0.0.1 -// Port to bind Login Server to (always binds to all IP addresses) +// Login Server Port login_port: 6900 // Whether remote administration is enabled or disabled (1 for enabled, 0 for disabled) diff --git a/src/char/char.c b/src/char/char.c index 45eb48389..caae3c143 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -49,11 +49,11 @@ char server_name[20]; char wisp_server_name[24] = "Server"; int login_ip_set_ = 0; char login_ip_str[16]; -int login_ip; +in_addr_t login_ip; int login_port = 6900; int char_ip_set_ = 0; char char_ip_str[16]; -int char_ip; +in_addr_t char_ip; int char_port = 6121; int char_maintenance; int char_new; @@ -769,7 +769,8 @@ void mmo_char_sync(void) { int i, j, k; int lock; FILE *fp,*f_fp; - int *id = (int *) aMalloc(sizeof(int) * char_num); + //int *id = (int *) aMalloc(sizeof(int) * char_num); + CREATE_BUFFER(id, int, char_num); // Sorting before save (by [Yor]) for(i = 0; i < char_num; i++) { @@ -808,6 +809,8 @@ void mmo_char_sync(void) { if (fp == NULL) { printf("WARNING: Server can't not create backup of characters file.\n"); char_log("WARNING: Server can't not create backup of characters file." RETCODE); + //aFree(id); // free up the memory before leaving -.- [Ajarn] + DELETE_BUFFER(id); return; } for(i = 0; i < char_num; i++) { @@ -828,7 +831,8 @@ void mmo_char_sync(void) { lock_fclose(f_fp, friends_txt, &lock); - aFree(id); + //aFree(id); + DELETE_BUFFER(id); return; } @@ -3431,7 +3435,8 @@ int do_init(int argc, char **argv) { set_termfunc(do_final); set_defaultparse(parse_char); - char_fd = make_listen_port(char_port); + //char_fd = make_listen_port(char_port); + char_fd = make_listen_bind(char_ip,char_port); add_timer_func_list(check_connect_login_server, "check_connect_login_server"); add_timer_func_list(send_users_tologin, "send_users_tologin"); diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 4c8d7e29f..22e1f78e1 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -89,11 +89,11 @@ char server_name[20]; char wisp_server_name[24] = "Server"; int login_ip_set_ = 0; char login_ip_str[128]; -int login_ip; +in_addr_t login_ip; int login_port = 6900; int char_ip_set_ = 0; char char_ip_str[128]; -int char_ip; +in_addr_t char_ip; int char_port = 6121; int char_maintenance; int char_new; @@ -3305,16 +3305,13 @@ int do_init(int argc, char **argv){ printf("set terminate function -> do_final().....\n"); set_termfunc(do_final); - printf("open port %d.....\n",char_port); - char_fd = make_listen_port(char_port); - if ((naddr_ != 0) && (login_ip_set_ == 0 || char_ip_set_ == 0)) { // The char server should know what IP address it is running on // - MouseJstr int localaddr = ntohl(addr_[0]); unsigned char *ptr = (unsigned char *) &localaddr; char buf[16]; - sprintf(buf, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);; + sprintf(buf, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]); if (naddr_ != 1) printf("Multiple interfaces detected.. using %s as our IP address\n", buf); else @@ -3331,6 +3328,10 @@ int do_init(int argc, char **argv){ login_ip = inet_addr(login_ip_str); char_ip = inet_addr(char_ip_str); + printf("open port %d.....\n",char_port); + //char_fd = make_listen_port(char_port); + char_fd = make_listen_bind(char_ip,char_port); + // send ALIVE PING to login server. printf("add interval tic (check_connect_login_server)....\n"); i = add_timer_interval(gettick() + 10, check_connect_login_server, 0, 0, 10 * 1000); diff --git a/src/common/buffer.h b/src/common/buffer.h new file mode 100644 index 000000000..294233595 --- /dev/null +++ b/src/common/buffer.h @@ -0,0 +1,18 @@ +#ifndef _BUFFER_H_ +#define _BUFFER_H_ + +// Full credit for this goes to Shinomori [Ajarn] + +#ifdef __GNUC__ // GCC has variable length arrays + +#define CREATE_BUFFER(name, type, size) type name[size] +#define DELETE_BUFFER(name) + +#else // others don't, so we emulate them + +#define CREATE_BUFFER(name, type, size) type *name=(type*)aCalloc(size,sizeof(type)) +#define DELETE_BUFFER(name) aFree(name);name=NULL + +#endif + +#endif \ No newline at end of file diff --git a/src/common/socket.c b/src/common/socket.c index 72e7e3f22..f43ca108c 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -270,6 +270,55 @@ int make_listen_port(int port) return fd; } +int make_listen_bind(long ip,int port) +{ + struct sockaddr_in server_address; + int fd; + int result; + + fd = socket( AF_INET, SOCK_STREAM, 0 ); + if(fd_max<=fd) fd_max=fd+1; + +#ifdef _WIN32 + { + unsigned long val = 1; + ioctlsocket(fd, FIONBIO, &val); + } +#else + result = fcntl(fd, F_SETFL, O_NONBLOCK); +#endif + + setsocketopts(fd); + + server_address.sin_family = AF_INET; + server_address.sin_addr.s_addr = ip; + server_address.sin_port = htons((unsigned short)port); + + result = bind(fd, (struct sockaddr*)&server_address, sizeof(server_address)); + if( result == -1 ) { + perror("bind"); + exit(1); + } + result = listen( fd, 5 ); + if( result == -1 ) { /* error */ + perror("listen"); + exit(1); + } + + FD_SET(fd, &readfds ); + + CREATE(session[fd], struct socket_data, 1); + + if(session[fd]==NULL){ + printf("out of memory : make_listen_bind\n"); + exit(1); + } + memset(session[fd],0,sizeof(*session[fd])); + session[fd]->func_recv = connect_client; + + return fd; +} + // Console Reciever [Wizputer] int console_recieve(int i) { int n; diff --git a/src/common/socket.h b/src/common/socket.h index 68b204862..7ee7b7689 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -88,6 +88,7 @@ extern int fd_max; // Function prototype declaration int make_listen_port(int); +int make_listen_bind(long,int); int make_connection(long,int); int delete_session(int); int realloc_fifo(int fd,int rfifo_size,int wfifo_size); diff --git a/src/login/login.c b/src/login/login.c index c7440dd4b..672e56b72 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -54,6 +54,8 @@ void Gettimeofday(struct timeval *timenow) int account_id_count = START_ACCOUNT_NUM; int server_num; int new_account_flag = 0; +char login_ip_str[16]; +in_addr_t login_ip; int login_port = 6900; char lan_char_ip[16]; int subneti[4]; @@ -872,7 +874,8 @@ void mmo_auth_sync(void) { int i, j, k, lock; int account_id; //int id[auth_num]; - int *id = (int *)aCalloc(auth_num, sizeof(int)); + //int *id = (int *)aCalloc(auth_num, sizeof(int)); + CREATE_BUFFER(id, int, auth_num); char line[65536]; // Sorting before save @@ -891,7 +894,8 @@ void mmo_auth_sync(void) { // Data save if ((fp = lock_fopen(account_filename, &lock)) == NULL) { - if (id) free(id); + //if (id) aFree(id); // aFree, right? + DELETE_BUFFER(id); return; } @@ -924,7 +928,8 @@ void mmo_auth_sync(void) { if (auth_before_save_file < AUTH_BEFORE_SAVE_FILE) auth_before_save_file = AUTH_BEFORE_SAVE_FILE; - if (id) aFree(id); + //if (id) aFree(id); + DELETE_BUFFER(id); return; } @@ -1891,7 +1896,8 @@ int parse_admin(int fd) { { int st, ed, len; //int id[auth_num]; - int *id=(int *)aCalloc(auth_num, sizeof(int)); + //int *id=(int *)aCalloc(auth_num, sizeof(int)); + CREATE_BUFFER(id, int, auth_num); st = RFIFOL(fd,2); ed = RFIFOL(fd,6); RFIFOSKIP(fd,10); @@ -1935,7 +1941,8 @@ int parse_admin(int fd) { } WFIFOW(fd,2) = len; WFIFOSET(fd,len); - if (id) free(id); + //if (id) free(id); + DELETE_BUFFER(id); } break; @@ -3412,6 +3419,14 @@ int login_config_read(const char *cfgName) { level_new_gm = atoi(w2); } else if (strcmpi(w1, "new_account") == 0) { new_account_flag = config_switch(w2); + } else if (strcmpi(w1, "login_ip") == 0) { + //login_ip_set_ = 1; + h = gethostbyname (w2); + if (h != NULL) { + printf("Login server IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + sprintf(login_ip_str, "%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + } else + memcpy(login_ip_str,w2,16); } else if (strcmpi(w1, "login_port") == 0) { login_port = atoi(w2); } else if (strcmpi(w1, "account_filename") == 0) { @@ -3938,7 +3953,9 @@ int do_init(int argc, char **argv) { read_gm_account(); // set_termfunc(mmo_auth_sync); set_defaultparse(parse_login); - login_fd = make_listen_port(login_port); + login_ip = inet_addr(login_ip_str); + //login_fd = make_listen_port(login_port); + login_fd = make_listen_bind(login_ip,login_port); if(anti_freeze_enable > 0) { add_timer_func_list(char_anti_freeze_system, "char_anti_freeze_system"); diff --git a/src/login_sql/login.c b/src/login_sql/login.c index c4c8bdafc..e11138c30 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -81,6 +81,8 @@ void Gettimeofday(struct timeval *timenow) int account_id_count = START_ACCOUNT_NUM; int server_num; int new_account_flag = 0; +char login_ip_str[16]; +in_addr_t login_ip; int login_port = 6900; char lan_char_ip[128]; // Lan char ip added by kashy int subnetmaski[4]; // Subnetmask added by kashy @@ -1591,7 +1593,15 @@ int login_config_read(const char *cfgName){ if(i!=2) continue; - else if(strcmpi(w1,"login_port")==0){ + } else if (strcmpi(w1, "login_ip") == 0) { + //login_ip_set_ = 1; + h = gethostbyname (w2); + if (h != NULL) { + printf("Login server IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + sprintf(login_ip_str, "%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + } else + memcpy(login_ip_str,w2,16); + } else if(strcmpi(w1,"login_port")==0){ login_port=atoi(w2); printf ("set login_port : %s\n",w2); } @@ -1804,7 +1814,10 @@ int do_init(int argc,char **argv){ printf ("set max servers complete\n"); //server port open & binding - login_fd=make_listen_port(login_port); + login_ip = inet_addr(login_ip_str); + + //login_fd=make_listen_port(login_port); + login_fd=make_listen_bind(login_ip,login_port); //Auth start printf ("Running mmo_auth_sqldb_init()\n"); diff --git a/src/map/clif.c b/src/map/clif.c index 87aa1ff5e..6ce1fc9c6 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10907,7 +10907,7 @@ static int packetdb_readdb(void) {clif_parse_PMIgnoreList,"wisexlist"}, {clif_parse_PMIgnoreAll,"wisall"}, {clif_parse_friends_list_add,"friendslistadd"}, - {clif_parse_friends_list_remove,"friendslistremove"}, + {clif_parse_friends_list_remove,"friendslistremove"}, {clif_parse_GMkillall,"killall"}, {clif_parse_GM_Monster_Item,"summon"}, {clif_parse_Shift,"shift"}, @@ -11356,13 +11356,15 @@ int do_init_clif(void) { set_defaultparse(clif_parse); #ifdef __WIN32 - if (!make_listen_port(map_port)) { + //if (!make_listen_port(map_port)) { + if (!make_listen_bind(map_ip,map_port)) { printf("cant bind game port\n"); exit(1); } #else for(i = 0; i < 10; i++) { - if (make_listen_port(map_port)) + //if (make_listen_port(map_port)) + if (make_listen_bind(map_ip,map_port)) break; sleep(20); } -- cgit v1.2.3-70-g09d2 From ff8a0342bc95eb2064ed7c620a0c410a92fde310 Mon Sep 17 00:00:00 2001 From: celest Date: Thu, 17 Feb 2005 16:28:36 +0000 Subject: * Readded Chemical Protection * Removed some old eA code that was causing Frost Nova to do an extra hit * Corrected Vulcan Arrow's hits in skill_db * Readded zlib and zconf .h files to under /lib * Fixed some compile errors in Windows * Changed remove_control_characters back to supporting korean chars * Moved some other code around git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1125 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 12 + db/skill_db.txt | 2 +- src/char/char.c | 18 +- src/char_sql/char.c | 19 +- src/common/grfio.c | 2 +- src/common/socket.c | 1 + src/common/strlib.c | 18 + src/common/strlib.h | 3 + src/ladmin/ladmin.c | 18 +- src/lib/zconf_win32.h | 279 ++++++++++++++++ src/lib/zlib_win32.h | 893 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/login/login.c | 19 +- src/login_sql/login.c | 17 - src/map/skill.c | 253 +------------- src/map/skill.h | 201 ------------ src/map/status.c | 231 +++++++++++++ src/map/status.h | 201 ++++++++++++ 17 files changed, 1658 insertions(+), 529 deletions(-) create mode 100644 src/lib/zconf_win32.h create mode 100644 src/lib/zlib_win32.h (limited to 'src/common/socket.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 743da2c3f..3a4d1a239 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,6 +1,18 @@ Date Added 02/17 + * Readded Chemical Protection -- i forgot to check for it when changing some + jA stuff earlier, sorry ^^; [celest] + * Removed some old eA code that was causing Frost Nova to do an extra hit + [celest] + * Corrected Vulcan Arrow's hits in skill_db -- the bug appeared when the + correct numbers hardcoded were removed [celest] + * Readded zlib and zconf .h files to under /lib for compiling in Windows, + thanks to Ser [celest] + * Fixed some compile errors in Windows, thanks to Ser [celest] + * Changed remove_control_characters back to supporting korean chars [celest] + * Moved some other code around [celest] + * Added Shinomori's changes to Dissonance -- don't increment the timer again if the target has died [celest] * Changed some nullpo checks back to normal null checks -- in some situations diff --git a/db/skill_db.txt b/db/skill_db.txt index f9b2b234f..d7b4fd9d0 100644 --- a/db/skill_db.txt +++ b/db/skill_db.txt @@ -451,7 +451,7 @@ //391,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //ST_STEALBACKPACK#スティ?ルバックパック# 392,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //CR_ALCHEMY#アルケ??# 393,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //CR_SYNTHESISPOTION#??ションシンセシス# -394,8,8,1,0,0,10,2,no,0,0,0,weapon,0 //CG_ARROWVULCAN#アロ?バルカン# +394,8,8,1,0,0,10,9,no,0,0,0,weapon,0 //CG_ARROWVULCAN#アロ?バルカン# 395,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //CG_MOONLIT#月明りの泉に落ちる花びら# 396,0,6,16,0,1,1,1,yes,0,0,0,magic,1 //CG_MARIONETTE#?リオネットコントロ?ル# 397,4,8,1,0,0,5,1,no,0,0,0,weapon,0 //LK_SPIRALPIERCE#スパイラルピア?ス# diff --git a/src/char/char.c b/src/char/char.c index 038000aab..72de37e03 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -17,6 +17,7 @@ #include #include +#include "../common/strlib.h" #include "core.h" #include "socket.h" #include "timer.h" @@ -166,23 +167,6 @@ int char_log(char *fmt, ...) { return 0; } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char *str) { - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //---------------------------------------------------------------------- // Determine if an account (id) is a GM account // and returns its level (or 0 if it isn't a GM account or if not found) diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 133d78296..db62d05cf 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -18,7 +18,6 @@ #include #endif -#include "../common/utils.h" #include #include #include @@ -34,6 +33,7 @@ #include #include "char.h" +#include "../common/utils.h" #include "../common/strlib.h" #include "itemdb.h" #include "inter.h" @@ -232,23 +232,6 @@ void set_char_offline(int char_id, int account_id) { WFIFOSET(login_fd,6); } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char *str) { - int i; - int change = 0; - - for(i = 0; i < strlen(str); i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //---------------------------------------------------------------------- // Determine if an account (id) is a GM account // and returns its level (or 0 if it isn't a GM account or if not found) diff --git a/src/common/grfio.c b/src/common/grfio.c index 2d47ff4e4..0c628d163 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -33,7 +33,7 @@ #ifdef _WIN32 #include - #include "zlib_win32.h" + #include "../lib/zlib_win32.h" HINSTANCE zlib_dll; #define zlib_inflateInit(strm) zlib_inflateInit_((strm),ZLIB_VERSION, sizeof(z_stream)) #define zlib_deflateInit(strm, level) zlib_deflateInit_((strm),(level),ZLIB_VERSION,sizeof(z_stream)) diff --git a/src/common/socket.c b/src/common/socket.c index f43ca108c..02ba49cb9 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -10,6 +10,7 @@ #include #include #include +typedef int socklen_t; #else #include #include diff --git a/src/common/strlib.c b/src/common/strlib.c index 64c8e154f..2b130e76d 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -78,3 +78,21 @@ int jmemescapecpy (char* pt,char* spt, int size) { // copy size is 0 ~ (j-1) return j; } + +//----------------------------------------------------- +// Function to suppress control characters in a string. +//----------------------------------------------------- +//int remove_control_chars(char *str) { +int remove_control_chars(unsigned char *str) { + int i; + int change = 0; + + for(i = 0; str[i]; i++) { + if (str[i] < 32) { + str[i] = '_'; + change = 1; + } + } + + return change; +} diff --git a/src/common/strlib.h b/src/common/strlib.h index 54c52cf94..55920f823 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -7,4 +7,7 @@ char* jstrescape (char* pt); char* jstrescapecpy (char* pt,char* spt); int jmemescapecpy (char* pt,char* spt, int size); + +// custom functions +int remove_control_chars(unsigned char *); #endif diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index de177ba8a..0453efa1d 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -36,6 +36,7 @@ void Gettimeofday(struct timeval *timenow) #include // valist #include // tolower +#include "../common/strlib.h" #include "../common/core.h" #include "../common/socket.h" #include "ladmin.h" @@ -291,23 +292,6 @@ int ladmin_log(char *fmt, ...) { return 0; } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char *str) { - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //--------------------------------------------- // Function to return ordonal text of a number. //--------------------------------------------- diff --git a/src/lib/zconf_win32.h b/src/lib/zconf_win32.h new file mode 100644 index 000000000..c5048fe91 --- /dev/null +++ b/src/lib/zconf_win32.h @@ -0,0 +1,279 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTRVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/src/lib/zlib_win32.h b/src/lib/zlib_win32.h new file mode 100644 index 000000000..aa4b49250 --- /dev/null +++ b/src/lib/zlib_win32.h @@ -0,0 +1,893 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.3, July 9th, 1998 + + Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "zconf_win32.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.3" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/src/login/login.c b/src/login/login.c index f925f5e2a..221913b5b 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -15,6 +15,7 @@ void Gettimeofday(struct timeval *timenow) return; } #define gettimeofday(timenow, dummy) Gettimeofday(timenow) +#define in_addr_t unsigned long #else #include #include @@ -43,6 +44,7 @@ void Gettimeofday(struct timeval *timenow) #include "../common/lock.h" #include "../common/malloc.h" #include "../common/buffer.h" +#include "../common/strlib.h" #ifdef PASSWORDENC #include "md5calc.h" @@ -436,23 +438,6 @@ int check_ladminip(unsigned int ip) { return 0; } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char *str) { - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- diff --git a/src/login_sql/login.c b/src/login_sql/login.c index f387e32c1..c7c4cd9d1 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -223,23 +223,6 @@ int isGM(int account_id) { return level; } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(unsigned char *str) { - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- diff --git a/src/map/skill.c b/src/map/skill.c index 61cd89ebd..240ad284e 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -36,237 +36,6 @@ #define STATE_BLIND 0x10 #define swap(x,y) { int t; t = x; x = y; y = t; } -/* スキル番?=>ステ?タス異常番??換テ?ブル */ -int SkillStatusChangeTable[]={ /* skill.hのenumのSC_***とあわせること */ -/* 0- */ - -1,-1,-1,-1,-1,-1, - SC_PROVOKE, /* プロボック */ - -1, 1,-1, -/* 10- */ - SC_SIGHT, /* サイト */ - -1,-1,-1,-1, - SC_FREEZE, /* フロストダイバ? */ - SC_STONE, /* スト?ンカ?ス */ - -1,-1,-1, -/* 20- */ - -1,-1,-1,-1, - SC_RUWACH, /* ルアフ */ - -1,-1,-1,-1, - SC_INCREASEAGI, /* 速度?加 */ -/* 30- */ - SC_DECREASEAGI, /* 速度減少 */ - -1, - SC_SIGNUMCRUCIS, /* シグナムクルシス */ - SC_ANGELUS, /* エンジェラス */ - SC_BLESSING, /* ブレッシング */ - -1,-1,-1,-1,-1, -/* 40- */ - -1,-1,-1,-1,-1, - SC_CONCENTRATE, /* 集中力向上 */ - -1,-1,-1,-1, -/* 50- */ - -1, - SC_HIDING, /* ハイディング */ - -1,-1,-1,-1,-1,-1,-1,-1, -/* 60- */ - SC_TWOHANDQUICKEN, /* 2HQ */ - SC_AUTOCOUNTER, - -1,-1,-1,-1, - SC_IMPOSITIO, /* インポシティオマヌス */ - SC_SUFFRAGIUM, /* サフラギウム */ - SC_ASPERSIO, /* アスペルシオ */ - SC_BENEDICTIO, /* 聖?降福 */ -/* 70- */ - -1, - SC_SLOWPOISON, - -1, - SC_KYRIE, /* キリエエレイソン */ - SC_MAGNIFICAT, /* マグニフィカ?ト */ - SC_GLORIA, /* グロリア */ - SC_DIVINA, /* レックスディビ?ナ */ - -1, - SC_AETERNA, /* レックスエ?テルナ */ - -1, -/* 80- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 90- */ - -1,-1, - SC_QUAGMIRE, /* クァグマイア */ - -1,-1,-1,-1,-1,-1,-1, -/* 100- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 110- */ - -1, - SC_ADRENALINE, /* アドレナリンラッシュ */ - SC_WEAPONPERFECTION,/* ウェポンパ?フェクション */ - SC_OVERTHRUST, /* オ?バ?トラスト */ - SC_MAXIMIZEPOWER, /* マキシマイズパワ? */ - -1,-1,-1,-1,-1, -/* 120- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 130- */ - -1,-1,-1,-1,-1, - SC_CLOAKING, /* クロ?キング */ - SC_STAN, /* ソニックブロ? */ - -1, - SC_ENCPOISON, /* エンチャントポイズン */ - SC_POISONREACT, /* ポイズンリアクト */ -/* 140- */ - SC_POISON, /* ベノムダスト */ - SC_SPLASHER, /* ベナムスプラッシャ? */ - -1, - SC_TRICKDEAD, /* 死んだふり */ - -1,-1,SC_AUTOBERSERK,-1,-1,-1, -/* 150- */ - -1,-1,-1,-1,-1, - SC_LOUD, /* ラウドボイス */ - -1, - SC_ENERGYCOAT, /* エナジ?コ?ト */ - -1,-1, -/* 160- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1, - SC_SELFDESTRUCTION, - -1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1, - SC_KEEPING, - -1,-1, - SC_BARRIER, - -1,-1, - SC_HALLUCINATION, - -1,-1, -/* 210- */ - -1,-1,-1,-1,-1, - SC_STRIPWEAPON, - SC_STRIPSHIELD, - SC_STRIPARMOR, - SC_STRIPHELM, - -1, -/* 220- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 230- */ - -1,-1,-1,-1, - SC_CP_WEAPON, - SC_CP_SHIELD, - SC_CP_ARMOR, - SC_CP_HELM, - -1,-1, -/* 240- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1, - SC_AUTOGUARD, -/* 250- */ - -1,-1, - SC_REFLECTSHIELD, - -1,-1, - SC_DEVOTION, - SC_PROVIDENCE, - SC_DEFENDER, - SC_SPEARSQUICKEN, - -1, -/* 260- */ - -1,-1,-1,-1,-1,-1,-1,-1, - SC_STEELBODY, - SC_BLADESTOP_WAIT, -/* 270- */ - SC_EXPLOSIONSPIRITS, - SC_EXTREMITYFIST, - -1,-1,-1,-1, - SC_MAGICROD, - -1,-1,-1, -/* 280- */ - SC_FLAMELAUNCHER, - SC_FROSTWEAPON, - SC_LIGHTNINGLOADER, - SC_SEISMICWEAPON, - -1, - SC_VOLCANO, - SC_DELUGE, - SC_VIOLENTGALE, - SC_LANDPROTECTOR, - -1, -/* 290- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 300- */ - -1,-1,-1,-1,-1,-1, - SC_LULLABY, - SC_RICHMANKIM, - SC_ETERNALCHAOS, - SC_DRUMBATTLE, -/* 310- */ - SC_NIBELUNGEN, - SC_ROKISWEIL, - SC_INTOABYSS, - SC_SIEGFRIED, - -1,-1,-1, - SC_DISSONANCE, - -1, - SC_WHISTLE, -/* 320- */ - SC_ASSNCROS, - SC_POEMBRAGI, - SC_APPLEIDUN, - -1,-1, - SC_UGLYDANCE, - -1, - SC_HUMMING, - SC_DONTFORGETME, - SC_FORTUNE, -/* 330- */ - SC_SERVICE4U, - SC_SELFDESTRUCTION, - -1,-1,-1,-1,-1,-1,-1,-1, -/* 340- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 350- */ - -1,-1,-1,-1,-1, - SC_AURABLADE, - SC_PARRYING, - SC_CONCENTRATION, - SC_TENSIONRELAX, - SC_BERSERK, -/* 360- */ - SC_BERSERK, - SC_ASSUMPTIO, - SC_BASILICA, - -1,-1,-1, - SC_MAGICPOWER, - -1, - SC_SACRIFICE, - SC_GOSPEL, -/* 370- */ - -1,-1,-1,-1,-1,-1,-1,-1, - SC_EDP, - -1, -/* 380- */ - SC_TRUESIGHT, - -1,-1, - SC_WINDWALK, - SC_MELTDOWN, - -1,-1, - SC_CARTBOOST, - -1, - SC_CHASEWALK, -/* 390- */ - SC_REJECTSWORD, - -1,-1,-1,-1, - SC_MOONLIT, - SC_MARIONETTE, - -1, - SC_HEADCRUSH, - SC_JOINTBEAT, -/* 400 */ - -1,-1, - SC_MINDBREAKER, - SC_MEMORIZE, - SC_FOGWALL, - SC_SPIDERWEB, - -1,-1,-1,-1, -/* 410- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -}; - const struct skill_name_db skill_names[] = { { AC_CHARGEARROW, "CHARGEARROW", "Charge_Arrow" } , { AC_CONCENTRATION, "CONCENTRATION", "Improve_Concentration" } , @@ -883,7 +652,7 @@ int skill_get_unit_id(int id,int flag) case WZ_SIGHTRASHER: return 0x86; /* サイトラッシャ? */ case WZ_METEOR: return 0x86; /* メテオスト?ム */ case WZ_VERMILION: return 0x86; /* ロ?ドオブヴァ?ミリオン */ - case WZ_FROSTNOVA: return 0x86; /* フロストノヴァ */ + //case WZ_FROSTNOVA: return 0x86; /* フロストノヴァ */ case WZ_STORMGUST: return 0x86; /* スト?ムガスト(とりあえずLoVと同じで?理) */ case CR_GRANDCROSS: return 0x86; /* グランドクロス */ case NPC_DARKGRANDCROSS: return 0x86; /*闇グランドクロス*/ @@ -2751,7 +2520,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s break; case WZ_FROSTNOVA: /* フロストノヴァ */ - skill_castend_pos2(src,bl->x,bl->y,skillid,skilllv,tick,0); + //skill_castend_pos2(src,bl->x,bl->y,skillid,skilllv,tick,0); //skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,flag); map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); break; @@ -3982,8 +3751,12 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int return 1; } - if (tsc_data && tsc_data[scid].timer != -1) - break; + if (tsc_data) { + if (tsc_data[scid].timer != -1) + break; + if (tsc_data[skillid - RG_STRIPWEAPON + SC_CP_WEAPON].timer != -1) + break; + } if (dstsd && dstsd->unstripable_equip & equip) break; @@ -4956,7 +4729,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil case WZ_SIGHTRASHER: case WZ_QUAGMIRE: /* クァグマイア */ case WZ_VERMILION: /* ロ?ドオブヴァ?ミリオン */ - case WZ_FROSTNOVA: /* フロストノヴァ */ + //case WZ_FROSTNOVA: /* フロストノヴァ */ case WZ_STORMGUST: /* スト?ムガスト */ case WZ_HEAVENDRIVE: /* ヘヴンズドライブ */ case PR_SANCTUARY: /* サンクチュアリ */ @@ -5306,10 +5079,10 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, range=1; break; - case WZ_FROSTNOVA: /* フロストノヴァ */ - limit=500; - range=5; - break; + //case WZ_FROSTNOVA: /* フロストノヴァ */ + // limit=500; + // range=5; + // break; case WZ_HEAVENDRIVE: /* ヘヴンズドライブ */ limit=500; diff --git a/src/map/skill.h b/src/map/skill.h index af2d79f59..c06ab270f 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -180,207 +180,6 @@ enum { ST_RECOV_WEIGHT_RATE,ST_MOVE_ENABLE,ST_WATER, }; -enum { // struct map_session_data の status_changeの番?テ?ブル -// SC_SENDMAX未?はクライアントへの通知あり。 -// 2-2次職の値はなんかめちゃくちゃっぽいので暫定。たぶん?更されます。 - SC_SENDMAX = 128, // note: max is now 182, but we'll need to do alot of moving around - SC_PROVOKE = 0, - SC_ENDURE = 1, - SC_TWOHANDQUICKEN = 2, - SC_CONCENTRATE = 3, - SC_HIDING = 4, - SC_CLOAKING = 5, - SC_ENCPOISON = 6, - SC_POISONREACT = 7, - SC_QUAGMIRE = 8, - SC_ANGELUS = 9, - SC_BLESSING = 10, - SC_SIGNUMCRUCIS = 11, - SC_INCREASEAGI = 12, - SC_DECREASEAGI = 13, - SC_SLOWPOISON = 14, - SC_IMPOSITIO = 15, - SC_SUFFRAGIUM = 16, - SC_ASPERSIO = 17, - SC_BENEDICTIO = 18, - SC_KYRIE = 19, - SC_MAGNIFICAT = 20, - SC_GLORIA = 21, - SC_AETERNA = 22, - SC_ADRENALINE = 23, - SC_WEAPONPERFECTION = 24, - SC_OVERTHRUST = 25, - SC_MAXIMIZEPOWER = 26, - SC_RIDING = 27, - SC_FALCON = 28, - SC_TRICKDEAD = 29, - SC_LOUD = 30, - SC_ENERGYCOAT = 31, - SC_HALLUCINATION = 34, - SC_WEIGHT50 = 35, - SC_WEIGHT90 = 36, - SC_SPEEDPOTION0 = 37, - SC_SPEEDPOTION1 = 38, - SC_SPEEDPOTION2 = 39, - SC_SPEEDPOTION3 = 40, -//-- 40-50 - SC_STRIPWEAPON = 50, - SC_STRIPSHIELD = 51, - SC_STRIPARMOR = 52, - SC_STRIPHELM = 53, - SC_CP_WEAPON = 54, - SC_CP_SHIELD = 55, - SC_CP_ARMOR = 56, - SC_CP_HELM = 57, - SC_AUTOGUARD = 58, - SC_REFLECTSHIELD = 59, - SC_DEVOTION = 60, - SC_PROVIDENCE = 61, - SC_DEFENDER = 62, - SC_AUTOSPELL = 65, - SC_SPEARSQUICKEN = 68, -//-- 69-85 - SC_EXPLOSIONSPIRITS = 86, - SC_STEELBODY = 87, - SC_COMBO = 89, - SC_FLAMELAUNCHER = 90, - SC_FROSTWEAPON = 91, - SC_LIGHTNINGLOADER = 92, - SC_SEISMICWEAPON = 93, -//-- 94-102 - SC_AURABLADE = 103, /* オ?ラブレ?ド */ - SC_PARRYING = 104, /* パリイング */ - SC_CONCENTRATION = 105, /* コンセントレ?ション */ - SC_TENSIONRELAX = 106, /* テンションリラックス */ - SC_BERSERK = 107, /* バ?サ?ク */ -//-- 108, 109 - SC_ASSUMPTIO = 110, /* アシャンプティオ */ -//-- 111, 112 - SC_MAGICPOWER = 113, /* 魔法力?幅 */ -//-- 114 - SC_TRUESIGHT = 115, /* トゥル?サイト */ - SC_WINDWALK = 116, /* ウインドウォ?ク */ - SC_MELTDOWN = 117, /* メルトダウン */ - SC_CARTBOOST = 118, /* カ?トブ?スト */ -//-- 119 - SC_REJECTSWORD = 120, /* リジェクトソ?ド */ - SC_MARIONETTE = 121, /* マリオネットコントロ?ル */ -//-- 122, 123 - SC_HEADCRUSH = 124, /* ヘッドクラッシュ */ - SC_JOINTBEAT = 125, /* ジョイントビ?ト */ -//-- 126, 127 - - SC_STONE = 128, - SC_FREEZE = 129, -// <-- 130 = a baby skill status? - SC_STAN = 130, - SC_SLEEP = 131, -// <-- 132 = another baby skill? - SC_POISON = 132, - SC_CURSE = 133, - SC_SILENCE = 134, - SC_CONFUSION = 135, - SC_BLIND = 136, - SC_DIVINA = SC_SILENCE, - - SC_SAFETYWALL = 140, - SC_PNEUMA = 141, - SC_WATERBALL = 142, - SC_ANKLE = 143, - SC_DANCING = 144, - SC_KEEPING = 145, - SC_BARRIER = 146, - - SC_MAGICROD = 149, - SC_SIGHT = 150, - SC_RUWACH = 151, - SC_AUTOCOUNTER = 152, - SC_VOLCANO = 153, - SC_DELUGE = 154, - SC_VIOLENTGALE = 155, - SC_BLADESTOP_WAIT = 156, - SC_BLADESTOP = 157, - SC_EXTREMITYFIST = 158, - SC_GRAFFITI = 159, - - SC_LULLABY =160, - SC_RICHMANKIM =161, - SC_ETERNALCHAOS =162, - SC_DRUMBATTLE =163, - SC_NIBELUNGEN =164, - SC_ROKISWEIL =165, - SC_INTOABYSS =166, - SC_SIEGFRIED =167, - SC_DISSONANCE =168, - SC_WHISTLE =169, - SC_ASSNCROS =170, - SC_POEMBRAGI =171, - SC_APPLEIDUN =172, - SC_UGLYDANCE =173, - SC_HUMMING =174, - SC_DONTFORGETME =175, - SC_FORTUNE =176, - SC_SERVICE4U =177, - SC_SPIDERWEB =180, /* スパイダ?ウェッブ */ -// SC_EDP // moved - SC_SACRIFICE =184, /* サクリファイス */ - SC_WEDDING =187, //結婚用(結婚衣裳になって?くのが?いとか) - SC_NOCHAT =188, //赤エモ?態 - SC_SPLASHER =189, /* ベナムスプラッシャ? */ - SC_SELFDESTRUCTION =190, /* 自爆 */ - SC_MEMORIZE =197, /* メモライズ */ // changed from 181 to 192 - SC_DPOISON =198, /* 猛毒 */ - -// Used by English Team - SC_BROKNARMOR =32, - SC_BROKNWEAPON =33, - SC_SPEEDUP0 =41, // for skill speedup - SC_SPEEDUP1 =42, // for skill speedup - SC_SLOWDOWN =45, // for skill slowdown - SC_AUTOBERSERK =46, - SC_SIGHTTRASHER =73, - SC_BASILICA =102, // temporarily use this before an actual id is found [celest] - SC_EDP =114, /* エフェクトが判明したら移動 */ - SC_MARIONETTE2 =122, // Marionette target - SC_ENSEMBLE =159, - SC_FOGWALL =178, - SC_GOSPEL =179, - SC_PRESERVE =181, - SC_BATTLEORDERS =182, - SC_MOONLIT =183, - SC_ATKPOT =185, // [Valaris] - SC_MATKPOT =186, // [Valaris] - SC_MINDBREAKER =191, - SC_SPELLBREAKER =192, - SC_LANDPROTECTOR =193, - SC_ADAPTATION =194, - SC_CHASEWALK =195, - SC_REGENERATION =196, - - -// [Celest] - SC_BLEEDING = 124, // Temporarily same id as headcrush - -// -- testing various SC effects -// SC_AURABLADE =81, -// SC_CONCENTRATION =83, -// SC_TENSIONRELAX =84, -// SC_BERSERK =85, -// SC_CALLSPIRITS =100, -// SC_PARRYING =100, -// SC_FREECAST =101, -// SC_ABSORBSPIRIT =102, -// SC_ASSUMPTIO =114, -// SC_SHARPSHOOT =127, -// SC_GANGSTER =184, -// SC_CANNIBALIZE =186, -// SC_SPHEREMINE =187, -// SC_METEOSTORM =189, -// SC_CASTCANCEL =190, -// SC_SPIDERWEB =191, -}; -extern int SkillStatusChangeTable[]; - enum { NV_BASIC = 1, diff --git a/src/map/status.c b/src/map/status.c index 412308f59..6c2300dca 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -23,6 +23,237 @@ #include "script.h" #include "showmsg.h" +/* スキル番?=>ステ?タス異常番??換テ?ブル */ +int SkillStatusChangeTable[]={ /* status.hのenumのSC_***とあわせること */ +/* 0- */ + -1,-1,-1,-1,-1,-1, + SC_PROVOKE, /* プロボック */ + -1, 1,-1, +/* 10- */ + SC_SIGHT, /* サイト */ + -1,-1,-1,-1, + SC_FREEZE, /* フロストダイバ? */ + SC_STONE, /* スト?ンカ?ス */ + -1,-1,-1, +/* 20- */ + -1,-1,-1,-1, + SC_RUWACH, /* ルアフ */ + -1,-1,-1,-1, + SC_INCREASEAGI, /* 速度?加 */ +/* 30- */ + SC_DECREASEAGI, /* 速度減少 */ + -1, + SC_SIGNUMCRUCIS, /* シグナムクルシス */ + SC_ANGELUS, /* エンジェラス */ + SC_BLESSING, /* ブレッシング */ + -1,-1,-1,-1,-1, +/* 40- */ + -1,-1,-1,-1,-1, + SC_CONCENTRATE, /* 集中力向上 */ + -1,-1,-1,-1, +/* 50- */ + -1, + SC_HIDING, /* ハイディング */ + -1,-1,-1,-1,-1,-1,-1,-1, +/* 60- */ + SC_TWOHANDQUICKEN, /* 2HQ */ + SC_AUTOCOUNTER, + -1,-1,-1,-1, + SC_IMPOSITIO, /* インポシティオマヌス */ + SC_SUFFRAGIUM, /* サフラギウム */ + SC_ASPERSIO, /* アスペルシオ */ + SC_BENEDICTIO, /* 聖?降福 */ +/* 70- */ + -1, + SC_SLOWPOISON, + -1, + SC_KYRIE, /* キリエエレイソン */ + SC_MAGNIFICAT, /* マグニフィカ?ト */ + SC_GLORIA, /* グロリア */ + SC_DIVINA, /* レックスディビ?ナ */ + -1, + SC_AETERNA, /* レックスエ?テルナ */ + -1, +/* 80- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 90- */ + -1,-1, + SC_QUAGMIRE, /* クァグマイア */ + -1,-1,-1,-1,-1,-1,-1, +/* 100- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 110- */ + -1, + SC_ADRENALINE, /* アドレナリンラッシュ */ + SC_WEAPONPERFECTION,/* ウェポンパ?フェクション */ + SC_OVERTHRUST, /* オ?バ?トラスト */ + SC_MAXIMIZEPOWER, /* マキシマイズパワ? */ + -1,-1,-1,-1,-1, +/* 120- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 130- */ + -1,-1,-1,-1,-1, + SC_CLOAKING, /* クロ?キング */ + SC_STAN, /* ソニックブロ? */ + -1, + SC_ENCPOISON, /* エンチャントポイズン */ + SC_POISONREACT, /* ポイズンリアクト */ +/* 140- */ + SC_POISON, /* ベノムダスト */ + SC_SPLASHER, /* ベナムスプラッシャ? */ + -1, + SC_TRICKDEAD, /* 死んだふり */ + -1,-1,SC_AUTOBERSERK,-1,-1,-1, +/* 150- */ + -1,-1,-1,-1,-1, + SC_LOUD, /* ラウドボイス */ + -1, + SC_ENERGYCOAT, /* エナジ?コ?ト */ + -1,-1, +/* 160- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1, + SC_SELFDESTRUCTION, + -1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1, + SC_KEEPING, + -1,-1, + SC_BARRIER, + -1,-1, + SC_HALLUCINATION, + -1,-1, +/* 210- */ + -1,-1,-1,-1,-1, + SC_STRIPWEAPON, + SC_STRIPSHIELD, + SC_STRIPARMOR, + SC_STRIPHELM, + -1, +/* 220- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 230- */ + -1,-1,-1,-1, + SC_CP_WEAPON, + SC_CP_SHIELD, + SC_CP_ARMOR, + SC_CP_HELM, + -1,-1, +/* 240- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1, + SC_AUTOGUARD, +/* 250- */ + -1,-1, + SC_REFLECTSHIELD, + -1,-1, + SC_DEVOTION, + SC_PROVIDENCE, + SC_DEFENDER, + SC_SPEARSQUICKEN, + -1, +/* 260- */ + -1,-1,-1,-1,-1,-1,-1,-1, + SC_STEELBODY, + SC_BLADESTOP_WAIT, +/* 270- */ + SC_EXPLOSIONSPIRITS, + SC_EXTREMITYFIST, + -1,-1,-1,-1, + SC_MAGICROD, + -1,-1,-1, +/* 280- */ + SC_FLAMELAUNCHER, + SC_FROSTWEAPON, + SC_LIGHTNINGLOADER, + SC_SEISMICWEAPON, + -1, + SC_VOLCANO, + SC_DELUGE, + SC_VIOLENTGALE, + SC_LANDPROTECTOR, + -1, +/* 290- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 300- */ + -1,-1,-1,-1,-1,-1, + SC_LULLABY, + SC_RICHMANKIM, + SC_ETERNALCHAOS, + SC_DRUMBATTLE, +/* 310- */ + SC_NIBELUNGEN, + SC_ROKISWEIL, + SC_INTOABYSS, + SC_SIEGFRIED, + -1,-1,-1, + SC_DISSONANCE, + -1, + SC_WHISTLE, +/* 320- */ + SC_ASSNCROS, + SC_POEMBRAGI, + SC_APPLEIDUN, + -1,-1, + SC_UGLYDANCE, + -1, + SC_HUMMING, + SC_DONTFORGETME, + SC_FORTUNE, +/* 330- */ + SC_SERVICE4U, + SC_SELFDESTRUCTION, + -1,-1,-1,-1,-1,-1,-1,-1, +/* 340- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 350- */ + -1,-1,-1,-1,-1, + SC_AURABLADE, + SC_PARRYING, + SC_CONCENTRATION, + SC_TENSIONRELAX, + SC_BERSERK, +/* 360- */ + SC_BERSERK, + SC_ASSUMPTIO, + SC_BASILICA, + -1,-1,-1, + SC_MAGICPOWER, + -1, + SC_SACRIFICE, + SC_GOSPEL, +/* 370- */ + -1,-1,-1,-1,-1,-1,-1,-1, + SC_EDP, + -1, +/* 380- */ + SC_TRUESIGHT, + -1,-1, + SC_WINDWALK, + SC_MELTDOWN, + -1,-1, + SC_CARTBOOST, + -1, + SC_CHASEWALK, +/* 390- */ + SC_REJECTSWORD, + -1,-1,-1,-1, + SC_MOONLIT, + SC_MARIONETTE, + -1, + SC_HEADCRUSH, + SC_JOINTBEAT, +/* 400 */ + -1,-1, + SC_MINDBREAKER, + SC_MEMORIZE, + SC_FOGWALL, + SC_SPIDERWEB, + -1,-1,-1,-1, +/* 410- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +}; + static int max_weight_base[MAX_PC_CLASS]; static int hp_coefficient[MAX_PC_CLASS]; static int hp_coefficient2[MAX_PC_CLASS]; diff --git a/src/map/status.h b/src/map/status.h index 0a7dda382..dbb4ec21c 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1,6 +1,207 @@ #ifndef _STATUS_H_ #define _STATUS_H_ +enum { // struct map_session_data の status_changeの番?テ?ブル +// SC_SENDMAX未?はクライアントへの通知あり。 +// 2-2次職の値はなんかめちゃくちゃっぽいので暫定。たぶん?更されます。 + SC_SENDMAX = 128, // note: max is now 182, but we'll need to do alot of moving around + SC_PROVOKE = 0, + SC_ENDURE = 1, + SC_TWOHANDQUICKEN = 2, + SC_CONCENTRATE = 3, + SC_HIDING = 4, + SC_CLOAKING = 5, + SC_ENCPOISON = 6, + SC_POISONREACT = 7, + SC_QUAGMIRE = 8, + SC_ANGELUS = 9, + SC_BLESSING = 10, + SC_SIGNUMCRUCIS = 11, + SC_INCREASEAGI = 12, + SC_DECREASEAGI = 13, + SC_SLOWPOISON = 14, + SC_IMPOSITIO = 15, + SC_SUFFRAGIUM = 16, + SC_ASPERSIO = 17, + SC_BENEDICTIO = 18, + SC_KYRIE = 19, + SC_MAGNIFICAT = 20, + SC_GLORIA = 21, + SC_AETERNA = 22, + SC_ADRENALINE = 23, + SC_WEAPONPERFECTION = 24, + SC_OVERTHRUST = 25, + SC_MAXIMIZEPOWER = 26, + SC_RIDING = 27, + SC_FALCON = 28, + SC_TRICKDEAD = 29, + SC_LOUD = 30, + SC_ENERGYCOAT = 31, + SC_HALLUCINATION = 34, + SC_WEIGHT50 = 35, + SC_WEIGHT90 = 36, + SC_SPEEDPOTION0 = 37, + SC_SPEEDPOTION1 = 38, + SC_SPEEDPOTION2 = 39, + SC_SPEEDPOTION3 = 40, +//-- 40-50 + SC_STRIPWEAPON = 50, + SC_STRIPSHIELD = 51, + SC_STRIPARMOR = 52, + SC_STRIPHELM = 53, + SC_CP_WEAPON = 54, + SC_CP_SHIELD = 55, + SC_CP_ARMOR = 56, + SC_CP_HELM = 57, + SC_AUTOGUARD = 58, + SC_REFLECTSHIELD = 59, + SC_DEVOTION = 60, + SC_PROVIDENCE = 61, + SC_DEFENDER = 62, + SC_AUTOSPELL = 65, + SC_SPEARSQUICKEN = 68, +//-- 69-85 + SC_EXPLOSIONSPIRITS = 86, + SC_STEELBODY = 87, + SC_COMBO = 89, + SC_FLAMELAUNCHER = 90, + SC_FROSTWEAPON = 91, + SC_LIGHTNINGLOADER = 92, + SC_SEISMICWEAPON = 93, +//-- 94-102 + SC_AURABLADE = 103, /* オ?ラブレ?ド */ + SC_PARRYING = 104, /* パリイング */ + SC_CONCENTRATION = 105, /* コンセントレ?ション */ + SC_TENSIONRELAX = 106, /* テンションリラックス */ + SC_BERSERK = 107, /* バ?サ?ク */ +//-- 108, 109 + SC_ASSUMPTIO = 110, /* アシャンプティオ */ +//-- 111, 112 + SC_MAGICPOWER = 113, /* 魔法力?幅 */ +//-- 114 + SC_TRUESIGHT = 115, /* トゥル?サイト */ + SC_WINDWALK = 116, /* ウインドウォ?ク */ + SC_MELTDOWN = 117, /* メルトダウン */ + SC_CARTBOOST = 118, /* カ?トブ?スト */ +//-- 119 + SC_REJECTSWORD = 120, /* リジェクトソ?ド */ + SC_MARIONETTE = 121, /* マリオネットコントロ?ル */ +//-- 122, 123 + SC_HEADCRUSH = 124, /* ヘッドクラッシュ */ + SC_JOINTBEAT = 125, /* ジョイントビ?ト */ +//-- 126, 127 + + SC_STONE = 128, + SC_FREEZE = 129, +// <-- 130 = a baby skill status? + SC_STAN = 130, + SC_SLEEP = 131, +// <-- 132 = another baby skill? + SC_POISON = 132, + SC_CURSE = 133, + SC_SILENCE = 134, + SC_CONFUSION = 135, + SC_BLIND = 136, + SC_DIVINA = SC_SILENCE, + + SC_SAFETYWALL = 140, + SC_PNEUMA = 141, + SC_WATERBALL = 142, + SC_ANKLE = 143, + SC_DANCING = 144, + SC_KEEPING = 145, + SC_BARRIER = 146, + + SC_MAGICROD = 149, + SC_SIGHT = 150, + SC_RUWACH = 151, + SC_AUTOCOUNTER = 152, + SC_VOLCANO = 153, + SC_DELUGE = 154, + SC_VIOLENTGALE = 155, + SC_BLADESTOP_WAIT = 156, + SC_BLADESTOP = 157, + SC_EXTREMITYFIST = 158, + SC_GRAFFITI = 159, + + SC_LULLABY =160, + SC_RICHMANKIM =161, + SC_ETERNALCHAOS =162, + SC_DRUMBATTLE =163, + SC_NIBELUNGEN =164, + SC_ROKISWEIL =165, + SC_INTOABYSS =166, + SC_SIEGFRIED =167, + SC_DISSONANCE =168, + SC_WHISTLE =169, + SC_ASSNCROS =170, + SC_POEMBRAGI =171, + SC_APPLEIDUN =172, + SC_UGLYDANCE =173, + SC_HUMMING =174, + SC_DONTFORGETME =175, + SC_FORTUNE =176, + SC_SERVICE4U =177, + SC_SPIDERWEB =180, /* スパイダ?ウェッブ */ +// SC_EDP // moved + SC_SACRIFICE =184, /* サクリファイス */ + SC_WEDDING =187, //結婚用(結婚衣裳になって?くのが?いとか) + SC_NOCHAT =188, //赤エモ?態 + SC_SPLASHER =189, /* ベナムスプラッシャ? */ + SC_SELFDESTRUCTION =190, /* 自爆 */ + SC_MEMORIZE =197, /* メモライズ */ // changed from 181 to 192 + SC_DPOISON =198, /* 猛毒 */ + +// Used by English Team + SC_BROKNARMOR =32, + SC_BROKNWEAPON =33, + SC_SPEEDUP0 =41, // for skill speedup + SC_SPEEDUP1 =42, // for skill speedup + SC_SLOWDOWN =45, // for skill slowdown + SC_AUTOBERSERK =46, + SC_SIGHTTRASHER =73, + SC_BASILICA =102, // temporarily use this before an actual id is found [celest] + SC_EDP =114, /* エフェクトが判明したら移動 */ + SC_MARIONETTE2 =122, // Marionette target + SC_ENSEMBLE =159, + SC_FOGWALL =178, + SC_GOSPEL =179, + SC_PRESERVE =181, + SC_BATTLEORDERS =182, + SC_MOONLIT =183, + SC_ATKPOT =185, // [Valaris] + SC_MATKPOT =186, // [Valaris] + SC_MINDBREAKER =191, + SC_SPELLBREAKER =192, + SC_LANDPROTECTOR =193, + SC_ADAPTATION =194, + SC_CHASEWALK =195, + SC_REGENERATION =196, + + +// [Celest] + SC_BLEEDING = 124, // Temporarily same id as headcrush + +// -- testing various SC effects +// SC_AURABLADE =81, +// SC_CONCENTRATION =83, +// SC_TENSIONRELAX =84, +// SC_BERSERK =85, +// SC_CALLSPIRITS =100, +// SC_PARRYING =100, +// SC_FREECAST =101, +// SC_ABSORBSPIRIT =102, +// SC_ASSUMPTIO =114, +// SC_SHARPSHOOT =127, +// SC_GANGSTER =184, +// SC_CANNIBALIZE =186, +// SC_SPHEREMINE =187, +// SC_METEOSTORM =189, +// SC_CASTCANCEL =190, +// SC_SPIDERWEB =191, +}; +extern int SkillStatusChangeTable[]; + // パラメータ所得系 battle.c より移動 int status_get_class(struct block_list *bl); int status_get_dir(struct block_list *bl); -- cgit v1.2.3-70-g09d2 From 8d96e1c00a9d7dd4562ec525e40384be0bf726e1 Mon Sep 17 00:00:00 2001 From: celest Date: Sat, 26 Feb 2005 08:38:22 +0000 Subject: * Added jA's dummy socket to prevent fd crashes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1183 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 1 + src/common/socket.c | 18 +++++++++++++++--- src/common/socket.h | 30 ++++++++++++++++++------------ 3 files changed, 34 insertions(+), 15 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index fa165d791..ce9043300 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,6 +1,7 @@ Date Added 02/26 + * Added jA's dummy socket to prevent fd crashes [celest] * Added some jA script commands: [Lupus] (first steps to add ELSE, FOR, WHILE, etc) - getusersname (works like @WHO ATCommand, outputs by 10 names in the Pop-up window) - dispbottom (print message in the common chat window) diff --git a/src/common/socket.c b/src/common/socket.c index 02ba49cb9..ad4e7d2e2 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -54,6 +54,9 @@ struct socket_data *session[FD_SETSIZE]; static int null_parse(int fd); static int (*default_func_parse)(int) = null_parse; +// fdが不正な時に代わりに読み書きするバッファ +unsigned char socket_dummy[SOCKET_DUMMY_SIZE]; + static int null_console_parse(char *buf); static int (*default_console_parse)(char*) = null_console_parse; @@ -431,7 +434,10 @@ int delete_session(int fd) int realloc_fifo(int fd,int rfifo_size,int wfifo_size) { - struct socket_data *s=session[fd]; + struct socket_data *s; + + if (fd <= 0) return 0; + s = session[fd]; if( s->max_rdata != rfifo_size && s->rdata_size < rfifo_size){ RECREATE(s->rdata, unsigned char, rfifo_size); s->max_rdata = rfifo_size; @@ -445,7 +451,10 @@ int realloc_fifo(int fd,int rfifo_size,int wfifo_size) int WFIFOSET(int fd,int len) { - struct socket_data *s=session[fd]; + struct socket_data *s; + + if (fd <= 0) return 0; + s = session[fd]; if (s == NULL || s->wdata == NULL) return 0; if( s->wdata_size+len+16384 > s->max_wdata ){ @@ -531,7 +540,10 @@ void do_socket(void) int RFIFOSKIP(int fd,int len) { - struct socket_data *s=session[fd]; + struct socket_data *s; + + if (fd <= 0) return 0; + s = session[fd]; if (s->rdata_size-s->rdata_pos-len<0) { fprintf(stderr,"too many skip\n"); diff --git a/src/common/socket.h b/src/common/socket.h index 7ee7b7689..52581faf7 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -22,24 +22,30 @@ extern time_t stall_time_; // define declaration -#define RFIFOP(fd,pos) (session[fd]->rdata+session[fd]->rdata_pos+(pos)) -#define RFIFOB(fd,pos) (*(unsigned char*)(session[fd]->rdata+session[fd]->rdata_pos+(pos))) -#define RFIFOW(fd,pos) (*(unsigned short*)(session[fd]->rdata+session[fd]->rdata_pos+(pos))) -#define RFIFOL(fd,pos) (*(unsigned int*)(session[fd]->rdata+session[fd]->rdata_pos+(pos))) +// fdが不正な時に代わりに読み書きするバッファ +#define SOCKET_DUMMY_SIZE 32768 +extern unsigned char socket_dummy[SOCKET_DUMMY_SIZE]; + +#define RFIFOSPACE(fd) (fd <= 0 ? SOCKET_DUMMY_SIZE : session[fd]->max_rdata-session[fd]->rdata_size) +#define RFIFOP(fd,pos) (fd <= 0 ? socket_dummy : session[fd]->rdata+session[fd]->rdata_pos+(pos)) +// use function instead of macro. +#define RFIFOB(fd,pos) (*(unsigned char*)RFIFOP(fd,pos)) +#define RFIFOW(fd,pos) (*(unsigned short*)RFIFOP(fd,pos)) +#define RFIFOL(fd,pos) (*(unsigned int*)RFIFOP(fd,pos)) +#define RFIFOREST(fd) (fd <= 0 ? 0 : session[fd]->rdata_size-session[fd]->rdata_pos) +#define RFIFOFLUSH(fd) (fd <= 0 ? 0 : memmove(session[fd]->rdata,RFIFOP(fd,0),RFIFOREST(fd)),session[fd]->rdata_size=RFIFOREST(fd),session[fd]->rdata_pos=0) //#define RFIFOSKIP(fd,len) ((session[fd]->rdata_size-session[fd]->rdata_pos-(len)<0) ? (fprintf(stderr,"too many skip\n"),exit(1)) : (session[fd]->rdata_pos+=(len))) -#define RFIFOREST(fd) (session[fd]->rdata_size-session[fd]->rdata_pos) -#define RFIFOFLUSH(fd) (memmove(session[fd]->rdata,RFIFOP(fd,0),RFIFOREST(fd)),session[fd]->rdata_size=RFIFOREST(fd),session[fd]->rdata_pos=0) -#define RFIFOSPACE(fd) (session[fd]->max_rdata-session[fd]->rdata_size) + #define RBUFP(p,pos) (((unsigned char*)(p))+(pos)) #define RBUFB(p,pos) (*(unsigned char*)RBUFP((p),(pos))) #define RBUFW(p,pos) (*(unsigned short*)RBUFP((p),(pos))) #define RBUFL(p,pos) (*(unsigned int*)RBUFP((p),(pos))) -#define WFIFOSPACE(fd) (session[fd]->max_wdata-session[fd]->wdata_size) -#define WFIFOP(fd,pos) (session[fd]->wdata+session[fd]->wdata_size+(pos)) -#define WFIFOB(fd,pos) (*(unsigned char*)(session[fd]->wdata+session[fd]->wdata_size+(pos))) -#define WFIFOW(fd,pos) (*(unsigned short*)(session[fd]->wdata+session[fd]->wdata_size+(pos))) -#define WFIFOL(fd,pos) (*(unsigned int*)(session[fd]->wdata+session[fd]->wdata_size+(pos))) +#define WFIFOSPACE(fd) (fd <= 0 ? SOCKET_DUMMY_SIZE : session[fd]->max_wdata-session[fd]->wdata_size) +#define WFIFOP(fd,pos) (fd <= 0 ? socket_dummy : session[fd]->wdata+session[fd]->wdata_size+(pos)) +#define WFIFOB(fd,pos) (*(unsigned char*)WFIFOP(fd,pos)) +#define WFIFOW(fd,pos) (*(unsigned short*)WFIFOP(fd,pos)) +#define WFIFOL(fd,pos) (*(unsigned int*)WFIFOP(fd,pos)) // use function instead of macro. //#define WFIFOSET(fd,len) (session[fd]->wdata_size = (session[fd]->wdata_size+(len)+2048 < session[fd]->max_wdata) ? session[fd]->wdata_size+len : session[fd]->wdata_size) #define WBUFP(p,pos) (((unsigned char*)(p))+(pos)) -- cgit v1.2.3-70-g09d2 From 236f3f46336cf648284b28a6b4bf7ffcec27fbd4 Mon Sep 17 00:00:00 2001 From: celest Date: Wed, 16 Mar 2005 12:21:26 +0000 Subject: * Updated jA's dummy socket to mod1137 * Added jA's ddos protection system * Moved stall_time's reading to packet_athena.conf git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1237 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 5 + conf-tmpl/inter_athena.conf | 3 - conf-tmpl/packet_athena.conf | 46 ++++++ src/common/socket.c | 341 +++++++++++++++++++++++++++++++++++++++++-- src/common/socket.h | 16 +- src/map/clif.c | 6 +- src/map/map.c | 9 +- 7 files changed, 391 insertions(+), 35 deletions(-) create mode 100644 conf-tmpl/packet_athena.conf (limited to 'src/common/socket.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index b6b7e0867..4647f89d5 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,5 +1,10 @@ Date Added +03/16 + * Updated jA's dummy socket to mod1137 [celest] + * Added jA's ddos protection system -- check packet_athena.conf [celest] + * Moved stall_time's reading from inter_athena.conf to packet_athena.conf + 03/15 * Fixed a compile warning in pc.c [celest] * Updated Soul Breaker's damage display, by DracoRPG [celest] diff --git a/conf-tmpl/inter_athena.conf b/conf-tmpl/inter_athena.conf index b73865f8f..a2155a5ac 100644 --- a/conf-tmpl/inter_athena.conf +++ b/conf-tmpl/inter_athena.conf @@ -32,9 +32,6 @@ inter_log_filename: log/inter.log // Level range for sharing within a party party_share_level: 10 -// How long can a socket stall before closing the connection -stall_time: 60 - // SQL version options only diff --git a/conf-tmpl/packet_athena.conf b/conf-tmpl/packet_athena.conf new file mode 100644 index 000000000..b8e1f31f7 --- /dev/null +++ b/conf-tmpl/packet_athena.conf @@ -0,0 +1,46 @@ +// ソケット関連の設定です。 (Untranslated yet) + + +// How long can a socket stall before closing the connection (in seconds) +stall_time: 60 + +//---- Ddos Protection Settings ---- + +// デバッグ情報の表示(バグ報告の際にコピペして頂けると助かります) +// debug: 1 + +// ddos攻撃と判断する為のルール設定 +// ddos_interval msec以内の接続要求がddos_count回続いた場合に、 +// ddos攻撃されたと判定します。 + +// 接続間隔(msec) +ddos_interval: 3000 + +// 接続回数 +ddos_count: 5 + +// ddos制限を解除する間隔(msec) +// この時間経過すると、接続制限が解除されます。 +ddos_autoreset: 600000 + +// アクセス制限の判定順序(Apacheと同じ) +// deny,allow が標準になっています。 + +order: deny,allow +// order: allow,deny +// order: mutual-failture + +// アクセスコントロールするIPリスト +// allow : ddosチェックの結果に関係なく許可 +// deny : 不許可 +// 指定無し : ddosチェックの結果で許可 / 不許可を決定 +// ただし、mutual-failture の場合は不許可になります。 + +// allow: 127.0.0.1 +// allow: 192.168.0.0/16 +// allow: 10.0.0.0/255.0.0.0 +allow: all + +// deny: 127.0.0.1 + +import: conf/import/packet_conf.txt \ No newline at end of file diff --git a/src/common/socket.c b/src/common/socket.c index ad4e7d2e2..19e4275a8 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -29,9 +29,10 @@ typedef int socklen_t; #include #include -#include "mmo.h" // [Valaris] thanks to fov #include "socket.h" -#include "utils.h" +#include "../common/mmo.h" // [Valaris] thanks to fov +#include "../common/timer.h" +#include "../common/utils.h" #ifdef MEMWATCH #include "memwatch.h" @@ -54,11 +55,9 @@ struct socket_data *session[FD_SETSIZE]; static int null_parse(int fd); static int (*default_func_parse)(int) = null_parse; -// fdが不正な時に代わりに読み書きするバッファ -unsigned char socket_dummy[SOCKET_DUMMY_SIZE]; - static int null_console_parse(char *buf); static int (*default_console_parse)(char*) = null_console_parse; +static int connect_check(unsigned int ip); /*====================================== * CORE : Set function @@ -195,16 +194,20 @@ static int connect_client(int listen_fd) setsocketopts(fd); - if(fd==-1) + if(fd==-1) { perror("accept"); - else + return -1; + } else if (!connect_check(*(unsigned int*)(&client_address.sin_addr))) { + close(fd); + return -1; + } else FD_SET(fd,&readfds); #ifdef _WIN32 - { - unsigned long val = 1; - ioctlsocket(fd, FIONBIO, &val); - } + { + unsigned long val = 1; + ioctlsocket(fd, FIONBIO, &val); + } #else result = fcntl(fd, F_SETFL, O_NONBLOCK); #endif @@ -415,7 +418,7 @@ int make_connection(long ip,int port) int delete_session(int fd) { - if(fd<0 || fd>=FD_SETSIZE) + if(fd<=0 || fd>=FD_SETSIZE) return -1; FD_CLR(fd,&readfds); if(session[fd]){ @@ -533,9 +536,269 @@ int do_parsepacket(void) return 0; } -void do_socket(void) +/* DDoS 攻撃対策 */ + +enum { + ACO_DENY_ALLOW=0, + ACO_ALLOW_DENY, + ACO_MUTUAL_FAILTURE, +}; + +struct _access_control { + unsigned int ip; + unsigned int mask; +}; + +static struct _access_control *access_allow; +static struct _access_control *access_deny; +static int access_order=ACO_DENY_ALLOW; +static int access_allownum=0; +static int access_denynum=0; +static int access_debug; +static int ddos_count = 10; +static int ddos_interval = 3000; +static int ddos_autoreset = 600*1000; + +struct _connect_history { + struct _connect_history *next; + struct _connect_history *prev; + int status; + int count; + unsigned int ip; + unsigned int tick; +}; +static struct _connect_history *connect_history[0x10000]; +static int connect_check_(unsigned int ip); + +// 接続できるかどうかの確認 +// false : 接続OK +// true : 接続NG +static int connect_check(unsigned int ip) { + int result = connect_check_(ip); + if(access_debug) { + printf("connect_check: connection from %08x %s\n", + ip,result ? "allowed" : "denied"); + } + return result; +} + +static int connect_check_(unsigned int ip) { + struct _connect_history *hist = connect_history[ip & 0xFFFF]; + struct _connect_history *hist_new; + int i,is_allowip = 0,is_denyip = 0,connect_ok = 0; + + // allow , deny リストに入っているか確認 + for(i = 0;i < access_allownum; i++) { + if((ip & access_allow[i].mask) == (access_allow[i].ip & access_allow[i].mask)) { + if(access_debug) { + printf("connect_check: match allow list from:%08x ip:%08x mask:%08x\n", + ip,access_allow[i].ip,access_allow[i].mask); + } + is_allowip = 1; + break; + } + } + for(i = 0;i < access_denynum; i++) { + if((ip & access_deny[i].mask) == (access_deny[i].ip & access_deny[i].mask)) { + if(access_debug) { + printf("connect_check: match deny list from:%08x ip:%08x mask:%08x\n", + ip,access_deny[i].ip,access_deny[i].mask); + } + is_denyip = 1; + break; + } + } + // コネクト出来るかどうか確認 + // connect_ok + // 0 : 無条件に拒否 + // 1 : 田代砲チェックの結果次第 + // 2 : 無条件に許可 + switch(access_order) { + case ACO_DENY_ALLOW: + default: + if(is_allowip) { + connect_ok = 2; + } else if(is_denyip) { + connect_ok = 0; + } else { + connect_ok = 1; + } + break; + case ACO_ALLOW_DENY: + if(is_denyip) { + connect_ok = 0; + } else if(is_allowip) { + connect_ok = 2; + } else { + connect_ok = 1; + } + break; + case ACO_MUTUAL_FAILTURE: + if(is_allowip) { + connect_ok = 2; + } else { + connect_ok = 0; + } + break; + } + + // 接続履歴を調べる + while(hist) { + if(ip == hist->ip) { + // 同じIP発見 + if(hist->status) { + // ban フラグが立ってる + return (connect_ok == 2 ? 1 : 0); + } else if(DIFF_TICK(gettick(),hist->tick) < ddos_interval) { + // ddos_interval秒以内にリクエスト有り + hist->tick = gettick(); + if(hist->count++ >= ddos_count) { + // ddos 攻撃を検出 + hist->status = 1; + printf("connect_check: ddos attack detected (%d.%d.%d.%d)\n", + ip & 0xFF,(ip >> 8) & 0xFF,(ip >> 16) & 0xFF,ip >> 24); + return (connect_ok == 2 ? 1 : 0); + } else { + return connect_ok; + } + } else { + // ddos_interval秒以内にリクエスト無いのでタイマークリア + hist->tick = gettick(); + hist->count = 0; + return connect_ok; + } + } + hist = hist->next; + } + // IPリストに無いので新規作成 + hist_new = aCalloc(1,sizeof(struct _connect_history)); + hist_new->ip = ip; + hist_new->tick = gettick(); + if(connect_history[ip & 0xFFFF] != NULL) { + hist = connect_history[ip & 0xFFFF]; + hist->prev = hist_new; + hist_new->next = hist; + } + connect_history[ip & 0xFFFF] = hist_new; + return connect_ok; +} + +static int connect_check_clear(int tid,unsigned int tick,int id,int data) { + int i; + int clear = 0; + int list = 0; + struct _connect_history *hist , *hist2; + for(i = 0;i < 0x10000 ; i++) { + hist = connect_history[i]; + while(hist) { + if( + (DIFF_TICK(tick,hist->tick) > ddos_interval * 3 && !hist->status) || + (DIFF_TICK(tick,hist->tick) > ddos_autoreset && hist->status) + ) { + // clear data + hist2 = hist->next; + if(hist->prev) { + hist->prev->next = hist->next; + } else { + connect_history[i] = hist->next; + } + if(hist->next) { + hist->next->prev = hist->prev; + } + aFree(hist); + hist = hist2; + clear++; + } else { + hist = hist->next; + list++; + } + } + } + if(access_debug) { + printf("connect_check_clear: clear = %d list = %d\n",clear,list); + } + return list; +} + +// IPマスクチェック +int access_ipmask(const char *str,struct _access_control* acc) { - FD_ZERO(&readfds); + unsigned int mask=0,i=0,m,ip, a0,a1,a2,a3; + if( !strcmp(str,"all") ) { + ip = 0; + mask = 0; + } else { + if( sscanf(str,"%d.%d.%d.%d%n",&a0,&a1,&a2,&a3,&i)!=4 || i==0) { + printf("access_ipmask: unknown format %s\n",str); + return 0; + } + ip = (a3 << 24) | (a2 << 16) | (a1 << 8) | a0; + + if(sscanf(str+i,"/%d.%d.%d.%d",&a0,&a1,&a2,&a3)==4 ){ + mask = (a3 << 24) | (a2 << 16) | (a1 << 8) | a0; + } else if(sscanf(str+i,"/%d",&m) == 1) { + for(i=0;i> 1) | 0x80000000; + } + mask = ntohl(mask); + } else { + mask = 0xFFFFFFFF; + } + } + if(access_debug) { + printf("access_ipmask: ip:%08x mask:%08x %s\n",ip,mask,str); + } + acc->ip = ip; + acc->mask = mask; + return 1; +} + +int socket_config_read(const char *cfgName) { + int i; + char line[1024],w1[1024],w2[1024]; + FILE *fp; + + fp=fopen(cfgName, "r"); + if(fp==NULL){ + printf("File not found: %s\n", cfgName); + return 1; + } + while(fgets(line,1020,fp)){ + if(line[0] == '/' && line[1] == '/') + continue; + i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2); + if(i!=2) + continue; + if(strcmpi(w1,"stall_time")==0){ + stall_time_ = atoi(w2); + } else if(strcmpi(w1,"order")==0){ + access_order=atoi(w2); + if(strcmpi(w2,"deny,allow")==0) access_order=ACO_DENY_ALLOW; + if(strcmpi(w2,"allow,deny")==0) access_order=ACO_ALLOW_DENY; + if(strcmpi(w2,"mutual-failture")==0) access_order=ACO_MUTUAL_FAILTURE; + } else if(strcmpi(w1,"allow")==0){ + access_allow = aRealloc(access_allow,(access_allownum+1)*sizeof(struct _access_control)); + if(access_ipmask(w2,&access_allow[access_allownum])) { + access_allownum++; + } + } else if(strcmpi(w1,"deny")==0){ + access_deny = aRealloc(access_deny,(access_denynum+1)*sizeof(struct _access_control)); + if(access_ipmask(w2,&access_deny[access_denynum])) { + access_denynum++; + } + } else if(!strcmpi(w1,"ddos_interval")){ + ddos_interval = atoi(w2); + } else if(!strcmpi(w1,"ddos_count")){ + ddos_count = atoi(w2); + } else if(!strcmpi(w1,"ddos_autoreset")){ + ddos_autoreset = atoi(w2); + } else if(!strcmpi(w1,"debug")){ + access_debug = atoi(w2); + } else if (strcmpi(w1, "import") == 0) + socket_config_read(w2); + } + fclose(fp); + return 0; } int RFIFOSKIP(int fd,int len) @@ -638,3 +901,53 @@ int Net_Init(void) return(0); } + +void do_final_socket(void) +{ + int i; + struct _connect_history *hist , *hist2; + for(i=0; inext; + aFree(hist); + hist = hist2; + } + } + if (access_allow) + aFree(access_allow); + if (access_deny) + aFree(access_deny); + + // session[0] のダミーデータを削除 + if (session[0]) { + aFree(session[0]->rdata); + aFree(session[0]->wdata); + aFree(session[0]); + } +} + +void do_socket(void) +{ + char *SOCKET_CONF_FILENAME = "conf/packet_athena.conf"; + + FD_ZERO(&readfds); + + atexit(do_final_socket); + socket_config_read(SOCKET_CONF_FILENAME); + + // session[0] にダミーデータを確保する + CREATE(session[0], struct socket_data, 1); + CREATE_A(session[0]->rdata, unsigned char, rfifo_size); + CREATE_A(session[0]->wdata, unsigned char, wfifo_size); + session[0]->max_rdata = rfifo_size; + session[0]->max_wdata = wfifo_size; + + // とりあえず5分ごとに不要なデータを削除する + add_timer_interval(gettick()+1000,connect_check_clear,0,0,300*1000); +} diff --git a/src/common/socket.h b/src/common/socket.h index 52581faf7..130c33d0c 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -22,18 +22,14 @@ extern time_t stall_time_; // define declaration -// fdが不正な時に代わりに読み書きするバッファ -#define SOCKET_DUMMY_SIZE 32768 -extern unsigned char socket_dummy[SOCKET_DUMMY_SIZE]; - -#define RFIFOSPACE(fd) (fd <= 0 ? SOCKET_DUMMY_SIZE : session[fd]->max_rdata-session[fd]->rdata_size) -#define RFIFOP(fd,pos) (fd <= 0 ? socket_dummy : session[fd]->rdata+session[fd]->rdata_pos+(pos)) +#define RFIFOSPACE(fd) (session[fd]->max_rdata-session[fd]->rdata_size) +#define RFIFOP(fd,pos) (session[fd]->rdata+session[fd]->rdata_pos+(pos)) // use function instead of macro. #define RFIFOB(fd,pos) (*(unsigned char*)RFIFOP(fd,pos)) #define RFIFOW(fd,pos) (*(unsigned short*)RFIFOP(fd,pos)) #define RFIFOL(fd,pos) (*(unsigned int*)RFIFOP(fd,pos)) -#define RFIFOREST(fd) (fd <= 0 ? 0 : session[fd]->rdata_size-session[fd]->rdata_pos) -#define RFIFOFLUSH(fd) (fd <= 0 ? 0 : memmove(session[fd]->rdata,RFIFOP(fd,0),RFIFOREST(fd)),session[fd]->rdata_size=RFIFOREST(fd),session[fd]->rdata_pos=0) +#define RFIFOREST(fd) (session[fd]->rdata_size-session[fd]->rdata_pos) +#define RFIFOFLUSH(fd) (memmove(session[fd]->rdata,RFIFOP(fd,0),RFIFOREST(fd)),session[fd]->rdata_size=RFIFOREST(fd),session[fd]->rdata_pos=0) //#define RFIFOSKIP(fd,len) ((session[fd]->rdata_size-session[fd]->rdata_pos-(len)<0) ? (fprintf(stderr,"too many skip\n"),exit(1)) : (session[fd]->rdata_pos+=(len))) #define RBUFP(p,pos) (((unsigned char*)(p))+(pos)) @@ -41,8 +37,8 @@ extern unsigned char socket_dummy[SOCKET_DUMMY_SIZE]; #define RBUFW(p,pos) (*(unsigned short*)RBUFP((p),(pos))) #define RBUFL(p,pos) (*(unsigned int*)RBUFP((p),(pos))) -#define WFIFOSPACE(fd) (fd <= 0 ? SOCKET_DUMMY_SIZE : session[fd]->max_wdata-session[fd]->wdata_size) -#define WFIFOP(fd,pos) (fd <= 0 ? socket_dummy : session[fd]->wdata+session[fd]->wdata_size+(pos)) +#define WFIFOSPACE(fd) (session[fd]->max_wdata-session[fd]->wdata_size) +#define WFIFOP(fd,pos) (session[fd]->wdata+session[fd]->wdata_size+(pos)) #define WFIFOB(fd,pos) (*(unsigned char*)WFIFOP(fd,pos)) #define WFIFOW(fd,pos) (*(unsigned short*)WFIFOP(fd,pos)) #define WFIFOL(fd,pos) (*(unsigned int*)WFIFOP(fd,pos)) diff --git a/src/map/clif.c b/src/map/clif.c index a44979ff4..2e1a7e1e7 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -973,7 +973,7 @@ int clif_mob_equip(struct mob_data *md, int nameid) { */ static int clif_mob0078(struct mob_data *md, unsigned char *buf) { - int level; + int level, i; memset(buf,0,packet_len_table[0x78]); @@ -986,7 +986,7 @@ static int clif_mob0078(struct mob_data *md, unsigned char *buf) WBUFW(buf,10)=md->opt2; WBUFW(buf,12)=md->option; WBUFW(buf,14)=mob_get_viewclass(md->class_); - if((mob_get_viewclass(md->class_) <= 23) || (mob_get_viewclass(md->class_) == 812) || (mob_get_viewclass(md->class_) >= 4001)) { + if((i=mob_get_viewclass(md->class_)) <= 23 || i == 812 || i >= 4001) { WBUFW(buf,12)|=mob_db[md->class_].option; WBUFW(buf,16)=mob_get_hair(md->class_); WBUFW(buf,18)=mob_get_weapon(md->class_); @@ -1360,7 +1360,7 @@ int clif_spawnmob(struct mob_data *md) nullpo_retr(0, md); - if (mob_get_viewclass(md->class_) > 23 ) { + if (mob_get_viewclass(md->class_) > 23) { memset(buf,0,packet_len_table[0x7c]); WBUFW(buf,0)=0x7c; diff --git a/src/map/map.c b/src/map/map.c index 7c8275cf9..3a6a29fde 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2896,8 +2896,10 @@ int inter_config_read(char *cfgName) i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2); if(i!=2) continue; - if(strcmpi(w1,"stall_time")==0){ - stall_time_ = atoi(w2); + //support the import command, just like any other config + if(strcmpi(w1,"import")==0){ + inter_config_read(w2); + } #ifndef TXT_ONLY } else if(strcmpi(w1,"item_db_db")==0){ strcpy(item_db_db,w2); @@ -2959,9 +2961,6 @@ int inter_config_read(char *cfgName) } else if(strcmpi(w1,"log_db_port")==0) { log_db_port = atoi(w2); #endif - //support the import command, just like any other config - } else if(strcmpi(w1,"import")==0){ - inter_config_read(w2); } } fclose(fp); -- cgit v1.2.3-70-g09d2 From 257a41619254ceb14b6e0867a20449248b540d41 Mon Sep 17 00:00:00 2001 From: celest Date: Sun, 20 Mar 2005 12:07:52 +0000 Subject: * Added 4 new card effects from 3/15's patch * Added 'enable_ip_rules' to packet_athena.conf * Updated socket debug messages to be more readable git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1257 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 4 ++++ conf-tmpl/packet_athena.conf | 45 ++++++++++++++++++++++++----------------- db/const.txt | 4 ++++ doc/item_bonus.txt | 10 +++++++++ src/common/socket.c | 48 ++++++++++++++++++++++++++++++-------------- src/map/battle.c | 12 ++++++++--- src/map/map.h | 10 +++++++-- src/map/mob.c | 33 +++++++++++++++++------------- src/map/pc.c | 47 ++++++++++++++++++++++++++++++++++--------- src/map/status.c | 6 +++++- 10 files changed, 157 insertions(+), 62 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index bbbf13d6a..c05c01b98 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,8 +2,12 @@ Date Added 03/20 * Fixed @storage / @gstorage ATcommands thanks2 Yor/Freya [Lupus] + * Added 4 new card effects from 3/15's patch -- check item_bonus.txt [celest] + * Added 'enable_ip_rules' to packet_athena.conf [celest] + * Updated socket debug messages to be more readable [celest] * Added a sql upgrader to handle the mob_db changes to assist in migrating to the newer SVN servers [MouseJstr] + 03/19 * Added getrefine() for 3/15's card patch -- returns the refined number of the current item [celest] diff --git a/conf-tmpl/packet_athena.conf b/conf-tmpl/packet_athena.conf index b8e1f31f7..b11baa429 100644 --- a/conf-tmpl/packet_athena.conf +++ b/conf-tmpl/packet_athena.conf @@ -1,27 +1,18 @@ -// ソケット関連の設定です。 (Untranslated yet) +// Athena sockets Configuration file +// (Untranslated yet) -// How long can a socket stall before closing the connection (in seconds) -stall_time: 60 - -//---- Ddos Protection Settings ---- - // デバッグ情報の表示(バグ報告の際にコピペして頂けると助かります) -// debug: 1 +debug: no -// ddos攻撃と判断する為のルール設定 -// ddos_interval msec以内の接続要求がddos_count回続いた場合に、 -// ddos攻撃されたと判定します。 +// How long can a socket stall before closing the connection (in seconds) +stall_time: 60 -// 接続間隔(msec) -ddos_interval: 3000 -// 接続回数 -ddos_count: 5 +//----- IP Rules Settings ----- -// ddos制限を解除する間隔(msec) -// この時間経過すると、接続制限が解除されます。 -ddos_autoreset: 600000 +// Do we check IP's before allowing incoming connections? +enable_ip_rules: yes // アクセス制限の判定順序(Apacheと同じ) // deny,allow が標準になっています。 @@ -43,4 +34,22 @@ allow: all // deny: 127.0.0.1 -import: conf/import/packet_conf.txt \ No newline at end of file + +//---- Ddos Protection Settings ---- + +// ddos攻撃と判断する為のルール設定 +// ddos_interval msec以内の接続要求がddos_count回続いた場合に、 +// ddos攻撃されたと判定します。 + +// 接続間隔(msec) +ddos_interval: 3000 + +// 接続回数 +ddos_count: 5 + +// ddos制限を解除する間隔(msec) +// この時間経過すると、接続制限が解除されます。 +ddos_autoreset: 600000 + + +//import: conf/import/packet_conf.txt \ No newline at end of file diff --git a/db/const.txt b/db/const.txt index 6c3ec6b8b..329c3530f 100644 --- a/db/const.txt +++ b/db/const.txt @@ -250,6 +250,10 @@ bHPGainValue 2025 bSubSize 2026 bDamageWhenUnequip 2027 bAddItemHealRate 2028 +bLoseSPWhenUnequip 2029 +bExpAddRace 2030 +bSPGainRace 2031 +bSPSubRace2 2032 Eff_Stone 0 diff --git a/doc/item_bonus.txt b/doc/item_bonus.txt index 039a84bd7..fbc613893 100644 --- a/doc/item_bonus.txt +++ b/doc/item_bonus.txt @@ -192,3 +192,13 @@ bonus4 bAutoSpellWhenHit,x,y,n,i; n% chance to cast skill x of level y when bonus2 bAddItemHealRate,n,x; Increases HP recovered by n type items by x% n:1=potions 2=herbs 3=fruits 4=meat 5=candy 6=juice 7=sashimi + +//---- 3/15 new card effects ---- + +bonus bLoseSPWhenUnequip.n; Lose n SP when the item is unequipped + +bonus2 bExpAddRace,n,x; Increase exp gained by n% vs. enemies of type x +bonus2 bSPGainRace,n,x; When killing a monster of type x by physical + attack gain n amount of sp +bonus2 bSPSubRace2,n,x; Damage x% reduction from enemies of race n + (Check db/mob_race2_db.txt) diff --git a/src/common/socket.c b/src/common/socket.c index 19e4275a8..f49d4c0ca 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -42,6 +42,7 @@ fd_set readfds; int fd_max; time_t tick_; time_t stall_time_ = 60; +int ip_rules = 1; int rfifo_size = 65536; int wfifo_size = 65536; @@ -50,6 +51,8 @@ int wfifo_size = 65536; #define TCP_FRAME_LEN 1053 #endif +#define CONVIP(ip) ip&0xFF,(ip>>8)&0xFF,(ip>>16)&0xFF,ip>>24 + struct socket_data *session[FD_SETSIZE]; static int null_parse(int fd); @@ -197,7 +200,7 @@ static int connect_client(int listen_fd) if(fd==-1) { perror("accept"); return -1; - } else if (!connect_check(*(unsigned int*)(&client_address.sin_addr))) { + } else if (ip_rules && !connect_check(*(unsigned int*)(&client_address.sin_addr))) { close(fd); return -1; } else @@ -554,7 +557,7 @@ static struct _access_control *access_deny; static int access_order=ACO_DENY_ALLOW; static int access_allownum=0; static int access_denynum=0; -static int access_debug; +static int access_debug=0; static int ddos_count = 10; static int ddos_interval = 3000; static int ddos_autoreset = 600*1000; @@ -576,8 +579,8 @@ static int connect_check_(unsigned int ip); static int connect_check(unsigned int ip) { int result = connect_check_(ip); if(access_debug) { - printf("connect_check: connection from %08x %s\n", - ip,result ? "allowed" : "denied"); + printf("connect_check: Connection from %d.%d.%d.%d %s\n", + CONVIP(ip),result ? "allowed." : "denied!"); } return result; } @@ -591,8 +594,10 @@ static int connect_check_(unsigned int ip) { for(i = 0;i < access_allownum; i++) { if((ip & access_allow[i].mask) == (access_allow[i].ip & access_allow[i].mask)) { if(access_debug) { - printf("connect_check: match allow list from:%08x ip:%08x mask:%08x\n", - ip,access_allow[i].ip,access_allow[i].mask); + printf("connect_check: Found match from allow list:%d.%d.%d.%d IP:%d.%d.%d.%d Mask:%d.%d.%d.%d\n", + CONVIP(ip), + CONVIP(access_allow[i].ip), + CONVIP(access_allow[i].mask)); } is_allowip = 1; break; @@ -601,8 +606,10 @@ static int connect_check_(unsigned int ip) { for(i = 0;i < access_denynum; i++) { if((ip & access_deny[i].mask) == (access_deny[i].ip & access_deny[i].mask)) { if(access_debug) { - printf("connect_check: match deny list from:%08x ip:%08x mask:%08x\n", - ip,access_deny[i].ip,access_deny[i].mask); + printf("connect_check: Found match from deny list:%d.%d.%d.%d IP:%d.%d.%d.%d Mask:%d.%d.%d.%d\n", + CONVIP(ip), + CONVIP(access_deny[i].ip), + CONVIP(access_deny[i].mask)); } is_denyip = 1; break; @@ -655,8 +662,8 @@ static int connect_check_(unsigned int ip) { if(hist->count++ >= ddos_count) { // ddos 攻撃を検出 hist->status = 1; - printf("connect_check: ddos attack detected (%d.%d.%d.%d)\n", - ip & 0xFF,(ip >> 8) & 0xFF,(ip >> 16) & 0xFF,ip >> 24); + printf("connect_check: DDOS Attack detected from %d.%d.%d.%d!\n", + CONVIP(ip)); return (connect_ok == 2 ? 1 : 0); } else { return connect_ok; @@ -715,7 +722,7 @@ static int connect_check_clear(int tid,unsigned int tick,int id,int data) { } } if(access_debug) { - printf("connect_check_clear: clear = %d list = %d\n",clear,list); + printf("connect_check_clear: Cleared %d of %d from IP list.\n", clear, clear+list); } return list; } @@ -729,7 +736,7 @@ int access_ipmask(const char *str,struct _access_control* acc) mask = 0; } else { if( sscanf(str,"%d.%d.%d.%d%n",&a0,&a1,&a2,&a3,&i)!=4 || i==0) { - printf("access_ipmask: unknown format %s\n",str); + printf("access_ipmask: Unknown format %s!\n",str); return 0; } ip = (a3 << 24) | (a2 << 16) | (a1 << 8) | a0; @@ -746,7 +753,8 @@ int access_ipmask(const char *str,struct _access_control* acc) } } if(access_debug) { - printf("access_ipmask: ip:%08x mask:%08x %s\n",ip,mask,str); + printf("access_ipmask: Loaded IP:%d.%d.%d.%d mask:%d.%d.%d.%d\n", + CONVIP(ip), CONVIP(mask)); } acc->ip = ip; acc->mask = mask; @@ -771,11 +779,17 @@ int socket_config_read(const char *cfgName) { continue; if(strcmpi(w1,"stall_time")==0){ stall_time_ = atoi(w2); + } else if(strcmpi(w1,"enable_ip_rules")==0){ + if(strcmpi(w2,"yes")==0) + ip_rules = 1; + else if(strcmpi(w2,"no")==0) + ip_rules = 0; + else ip_rules = atoi(w2); } else if(strcmpi(w1,"order")==0){ access_order=atoi(w2); if(strcmpi(w2,"deny,allow")==0) access_order=ACO_DENY_ALLOW; if(strcmpi(w2,"allow,deny")==0) access_order=ACO_ALLOW_DENY; - if(strcmpi(w2,"mutual-failture")==0) access_order=ACO_MUTUAL_FAILTURE; + if(strcmpi(w2,"mutual-failure")==0) access_order=ACO_MUTUAL_FAILTURE; } else if(strcmpi(w1,"allow")==0){ access_allow = aRealloc(access_allow,(access_allownum+1)*sizeof(struct _access_control)); if(access_ipmask(w2,&access_allow[access_allownum])) { @@ -793,7 +807,11 @@ int socket_config_read(const char *cfgName) { } else if(!strcmpi(w1,"ddos_autoreset")){ ddos_autoreset = atoi(w2); } else if(!strcmpi(w1,"debug")){ - access_debug = atoi(w2); + if(strcmpi(w2,"yes")==0) + access_debug = 1; + else if(strcmpi(w2,"no")==0) + access_debug = 0; + else access_debug = atoi(w2); } else if (strcmpi(w1, "import") == 0) socket_config_read(w2); } diff --git a/src/map/battle.c b/src/map/battle.c index 483ddffb7..81b2c3189 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1063,7 +1063,7 @@ static struct Damage battle_calc_mob_weapon_attack( struct Damage wd; int damage,damage2=0,type,div_,blewcount=skill_get_blewcount(skill_num,skill_lv); int flag,skill,ac_flag = 0,dmg_lv = 0; - int t_mode=0,t_race=0,t_size=1,s_race=0,s_ele=0,s_size=0; + int t_mode=0,t_race=0,t_size=1,s_race=0,s_ele=0,s_size=0,s_race2=0; struct status_change *sc_data,*t_sc_data; short *sc_count; short *option, *opt1, *opt2; @@ -1085,6 +1085,7 @@ static struct Damage battle_calc_mob_weapon_attack( option = status_get_option(src); opt1 = status_get_opt1(src); opt2 = status_get_opt2(src); + s_race2 = status_get_race2(src); // ターゲット if(target->type == BL_PC) @@ -1504,6 +1505,7 @@ static struct Damage battle_calc_mob_weapon_attack( cardfix=cardfix*(100-tsd->subele[s_ele])/100; // 属 性によるダメージ耐性 cardfix=cardfix*(100-tsd->subrace[s_race])/100; // 種族によるダメージ耐性 cardfix=cardfix*(100-tsd->subsize[s_size])/100; + cardfix=cardfix*(100-tsd->subrace2[s_race2])/100; // 種族によるダメージ耐性 if(mob_db[md->class_].mode & 0x20) cardfix=cardfix*(100-tsd->subrace[10])/100; else @@ -2857,7 +2859,7 @@ struct Damage battle_calc_magic_attack( int aflag; int normalmagic_flag=1; int matk_flag = 1; - int ele=0,race=7,size=1,t_ele=0,t_race=7,t_mode = 0,cardfix,t_class,i; + int ele=0,race=7,size=1,race2=7,t_ele=0,t_race=7,t_mode = 0,cardfix,t_class,i; struct map_session_data *sd=NULL,*tsd=NULL; struct mob_data *tmd = NULL; @@ -2879,6 +2881,7 @@ struct Damage battle_calc_magic_attack( ele = skill_get_pl(skill_num); race = status_get_race(bl); size = status_get_size(bl); + race2 = status_get_race2(bl); t_ele = status_get_elem_type(target); t_race = status_get_race(target); t_mode = status_get_mode(target); @@ -3091,6 +3094,7 @@ struct Damage battle_calc_magic_attack( cardfix=cardfix*(100-tsd->subrace[race])/100; // 種族によるダメージ耐性 cardfix=cardfix*(100-tsd->subsize[size])/100; cardfix=cardfix*(100-tsd->magic_subrace[race])/100; + cardfix=cardfix*(100-tsd->subrace2[race2])/100; // 種族によるダメージ耐性 if(status_get_mode(bl) & 0x20) cardfix=cardfix*(100-tsd->magic_subrace[10])/100; else @@ -3166,7 +3170,7 @@ struct Damage battle_calc_misc_attack( int int_=status_get_int(bl); // int luk=status_get_luk(bl); int dex=status_get_dex(bl); - int skill,ele,race,size,cardfix; + int skill,ele,race,size,cardfix,race2; struct map_session_data *sd=NULL,*tsd=NULL; int damage=0,div_=1,blewcount=skill_get_blewcount(skill_num,skill_lv); struct Damage md; @@ -3270,6 +3274,7 @@ struct Damage battle_calc_misc_attack( ele = skill_get_pl(skill_num); race = status_get_race(bl); size = status_get_size(bl); + race2 = status_get_race(bl); if(damagefix){ if(damage<1 && skill_num != NPC_DARKBREATH) @@ -3281,6 +3286,7 @@ struct Damage battle_calc_misc_attack( cardfix=cardfix*(100-tsd->subrace[race])/100; // 種族によるダメージ耐性 cardfix=cardfix*(100-tsd->subsize[size])/100; cardfix=cardfix*(100-tsd->misc_def_rate)/100; + cardfix=cardfix*(100-tsd->subrace2[race2])/100; damage=damage*cardfix/100; } if (sd && skill_num > 0 && sd->skillatk[0] == skill_num) diff --git a/src/map/map.h b/src/map/map.h index a83f810b9..8039615f7 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -297,9 +297,14 @@ struct map_session_data { short hp_loss_value, hp_loss_type; int addrace2[6],addrace2_[6]; int subsize[3]; - short unequip_damage[11]; + short unequip_losehp[11]; + short unequip_losesp[11]; int itemid; int itemhealrate[6]; + //--- 03/15's new card effects + int expaddrace[6]; + int subrace2[6]; + short sp_gain_race[6]; short spiritball, spiritball_old; int spirit_timer[MAX_SKILL_LEVEL]; @@ -647,7 +652,8 @@ enum { SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017 SP_SKILL_ATK, SP_UNSTRIPABLE, SP_ADD_DAMAGE_BY_CLASS, // 2018-2020 SP_SP_GAIN_VALUE, SP_IGNORE_DEF_MOB, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025 - SP_SUBSIZE, SP_DAMAGE_WHEN_UNEQUIP, SP_ADD_ITEM_HEAL_RATE // 2026-2028 + SP_SUBSIZE, SP_DAMAGE_WHEN_UNEQUIP, SP_ADD_ITEM_HEAL_RATE, SP_LOSESP_WHEN_UNEQUIP, SP_EXP_ADDRACE, // 2026-2030 + SP_SP_GAIN_RACE, SP_SUBRACE2, }; enum { diff --git a/src/map/mob.c b/src/map/mob.c index 584d9de2e..3cfb4e6d5 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2198,10 +2198,12 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) struct item item; int ret; int drop_rate; + int race; nullpo_retr(0, md); //srcはNULLで呼ばれる場合もあるので、他でチェック max_hp = status_get_max_hp(&md->bl); + race = status_get_race(&md->bl); if(src && src->type == BL_PC) { sd = (struct map_session_data *)src; @@ -2425,6 +2427,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) sp += (status_get_lv(&md->bl))*(65+15*i)/100; } sp += sd->sp_gain_value; + sp += sd->sp_gain_race[race]; hp += sd->hp_gain_value; if (sp > 0) { if(sd->status.sp + sp > sd->status.max_sp) @@ -2512,21 +2515,24 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(job_exp < 1) job_exp = 1; } - if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { - base_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] - } - if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { - job_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] + if(sd) { + int rate; + if ((rate = sd->expaddrace[race]) > 0) { + base_exp = (100+rate)*base_exp/100; + job_exp = (100+rate)*job_exp/100; + } + if (battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { + base_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] + job_exp*=1.15; + } } if(md->master_id) { - master = map_id2bl(md->master_id); - } - if((master && status_get_mode(master)&0x20) || // check if its master is a boss (MVP's and minibosses) - (md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1)) { // for summoned creatures [Valaris] - base_exp = 0; - job_exp = 0; - } - else { + if(((master = map_id2bl(md->master_id)) && status_get_mode(master)&0x20) || // check if its master is a boss (MVP's and minibosses) + (md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1)) { // for summoned creatures [Valaris] + base_exp = 0; + job_exp = 0; + } + } else { if(battle_config.zeny_from_mobs) { if(md->level > 0) zeny=(md->level+rand()%md->level)*per/256; // zeny calculation moblv + random moblv [Valaris] if(mob_db[md->class_].mexp > 0) @@ -2639,7 +2645,6 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(sd && sd->state.attack_type == BF_WEAPON) { for(i=0;imonster_drop_item_count;i++) { struct delay_item_drop *ditem; - int race = status_get_race(&md->bl); if(sd->monster_drop_itemid[i] <= 0) continue; if(sd->monster_drop_race[i] & (1<inventory_data[current_equip_item_index]->equip & equip_pos[i]) { - sd->unequip_damage[i] += val; + sd->unequip_losehp[i] += val; + break; + } + } + } + break; + case SP_LOSESP_WHEN_UNEQUIP: + if(!sd->state.lr_flag) { + int i; + for (i=0; i<11; i++) { + if (sd->inventory_data[current_equip_item_index]->equip & equip_pos[i]) { + sd->unequip_losesp[i] += val; break; } } @@ -1861,10 +1872,22 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag != 2) sd->subsize[type2]+=val; break; + case SP_SUBRACE2: + if(sd->state.lr_flag != 2) + sd->subrace2[type2]+=val; + break; case SP_ADD_ITEM_HEAL_RATE: if(sd->state.lr_flag != 2) sd->itemhealrate[type2 - 1] += val; break; + case SP_EXP_ADDRACE: + if(sd->state.lr_flag != 2) + sd->expaddrace[type2]+=val; + break; + case SP_SP_GAIN_RACE: + if(sd->state.lr_flag != 2) + sd->sp_gain_race[type2]+=val; + break; default: if(battle_config.error_log) @@ -6076,7 +6099,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos) */ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { - short dmg = 0; + short hp = 0, sp = 0; nullpo_retr(0, sd); // -- moonsoul (if player is berserk then cannot unequip) @@ -6093,9 +6116,13 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) for(i=0;i<11;i++) { if(sd->status.inventory[n].equip & equip_pos[i]) { sd->equip_index[i] = -1; - if(sd->unequip_damage[i] > 0) { - dmg += sd->unequip_damage[i]; - sd->unequip_damage[i] = 0; + if(sd->unequip_losehp[i] > 0) { + hp += sd->unequip_losehp[i]; + sd->unequip_losehp[i] = 0; + } + if(sd->unequip_losesp[i] > 0) { + sp += sd->unequip_losesp[i]; + sd->unequip_losesp[i] = 0; } } } @@ -6150,10 +6177,12 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) status_change_end(&sd->bl,SC_SIGNUMCRUCIS,-1); } - if (dmg > 0) { - if (dmg > sd->status.hp) - dmg = sd->status.hp; - pc_heal(sd,-dmg,0); + if (hp > 0 || sp > 0) { + if (hp > sd->status.hp) + hp = sd->status.hp; + if (sp > sd->status.sp) + sp = sd->status.sp; + pc_heal(sd,-hp,-sp); } return 0; diff --git a/src/map/status.c b/src/map/status.c index b0c90d520..e05d33909 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -521,7 +521,11 @@ int status_calc_pc(struct map_session_data* sd,int first) memset(sd->addrace2_,0,sizeof(sd->addrace2_)); sd->hp_gain_value = sd->sp_drain_type = 0; memset(sd->subsize,0,sizeof(sd->subsize)); - memset(sd->unequip_damage,0,sizeof(sd->unequip_damage)); + memset(sd->unequip_losehp,0,sizeof(sd->unequip_losehp)); + memset(sd->unequip_losesp,0,sizeof(sd->unequip_losesp)); + memset(sd->subrace2,0,sizeof(sd->subrace2)); + memset(sd->expaddrace,0,sizeof(sd->expaddrace)); + memset(sd->sp_gain_race,0,sizeof(sd->sp_gain_race)); if(!sd->disguiseflag && sd->disguise) { sd->disguise=0; -- cgit v1.2.3-70-g09d2 From 33b8fd47955eeab26cede233b14d683b8e0491b8 Mon Sep 17 00:00:00 2001 From: celest Date: Wed, 23 Mar 2005 15:26:52 +0000 Subject: * Fixed alot of memory leaks * Added stray memory cleaning routine to db.c git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1275 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 2 + src/char/char.c | 12 ++--- src/char/int_guild.c | 20 ++++++++- src/char/int_guild.h | 1 + src/char/int_party.c | 11 +++++ src/char/int_party.h | 1 + src/char/int_pet.c | 11 +++++ src/char/int_pet.h | 1 + src/char/int_storage.c | 16 +++++++ src/char/int_storage.h | 1 + src/char/inter.c | 23 ++++++++++ src/char/inter.h | 1 + src/char_sql/char.c | 9 ++++ src/char_sql/int_guild.c | 29 ++++++++++++ src/char_sql/int_guild.h | 1 + src/char_sql/int_party.c | 4 ++ src/char_sql/int_party.h | 1 + src/char_sql/int_pet.c | 4 ++ src/char_sql/int_pet.h | 1 + src/char_sql/int_storage.c | 7 +++ src/char_sql/int_storage.h | 1 + src/char_sql/inter.c | 20 +++++++++ src/char_sql/inter.h | 2 +- src/common/core.c | 12 ++--- src/common/malloc.c | 4 +- src/common/malloc.h | 3 ++ src/common/socket.c | 8 ++-- src/common/timer.h | 4 +- src/login/login.c | 3 +- src/login_sql/login.c | 43 ++++++++++-------- src/map/map.c | 108 ++++++++++++++++++++------------------------- src/map/npc.c | 92 ++++++++++++++++++++++++++------------ src/map/pc.c | 5 +++ src/map/pc.h | 1 + 34 files changed, 327 insertions(+), 135 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 7d4f3d92a..047c96b99 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,6 +1,8 @@ Date Added 03/23 + * Fixed alot of memory leaks [celest] + * Added stray memory cleaning routine to db.c [celest] * Fixed some compile errors, sorry xP [celest] * Corrected potion creation success chances, thanks to Avaj and DracoRPG * Removed some unused potion creation code, thanks to DracoRPG diff --git a/src/char/char.c b/src/char/char.c index 1a2b61389..78f4bd3ae 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -22,6 +22,7 @@ #include "socket.h" #include "timer.h" #include "mmo.h" +#include "db.h" #include "version.h" #include "lock.h" #include "char.h" @@ -630,11 +631,6 @@ int mmo_char_init(void) { printf("out of memory: mmo_char_init (calloc of char_dat).\n"); exit(1); } - online_chars = (struct online_chars*)aCalloc(sizeof(struct online_chars) * 256, 1); - if (!online_chars) { - printf("out of memory: mmo_char_init (calloc of online_chars).\n"); - exit(1); - } for(i = 0; i < char_max; i++) { online_chars[i].char_id = -1; @@ -3456,8 +3452,9 @@ void do_final(void) { delete_session(login_fd); delete_session(char_fd); - for(i = 0; i < fd_max; i++) - if(session[i] != NULL) aFree(session[i]); + inter_final(); + exit_dbn(); + timer_final(); char_log("----End of char-server (normal end with closing of all files)." RETCODE); } @@ -3512,7 +3509,6 @@ int do_init(int argc, char **argv) { online_chars[i].server = -1; } - mmo_char_init(); update_online = time(NULL); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 267b66f0f..78e6b476f 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -488,10 +488,28 @@ int inter_guild_init() { return 0; } +int castle_db_final (void *k, void *data, va_list ap) +{ + struct guild_castle *gc = data; + if (gc) aFree(gc); + return 0; +} +int guild_db_final (void *k, void *data, va_list ap) +{ + struct guild *g = data; + if (g) aFree(g); + return 0; +} +void inter_guild_final() { + numdb_final(castle_db, castle_db_final); + numdb_final(guild_db, guild_db_final); + return; +} + struct guild *inter_guild_search(int guild_id) { struct guild *g; - g= (struct guild *) numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); return g; } diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 555f5e123..3eeb1b3db 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -3,6 +3,7 @@ #define _INT_GUILD_H_ int inter_guild_init(); +void inter_guild_final(); int inter_guild_save(); int inter_guild_parse_frommap(int fd); struct guild *inter_guild_search(int guild_id); diff --git a/src/char/int_party.c b/src/char/int_party.c index 3298587f1..5ee48fc70 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -117,6 +117,17 @@ int inter_party_init() { return 0; } +int party_db_final (void *k, void *data, va_list ap) { + struct party *p = data; + if (p) aFree(p); + return 0; +} +void inter_party_final() +{ + numdb_final(party_db, party_db_final); + return; +} + // パ?ティ?デ?タのセ?ブ用 int inter_party_save_sub(void *key, void *data, va_list ap) { char line[8192]; diff --git a/src/char/int_party.h b/src/char/int_party.h index b265b4c2e..e3180f3b7 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -3,6 +3,7 @@ #define _INT_PARTY_H_ int inter_party_init(); +void inter_party_final(); int inter_party_save(); int inter_party_parse_frommap(int fd); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 8682860c0..342854f8b 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -109,6 +109,17 @@ int inter_pet_init() return 0; } +int pet_db_final (void *k, void *data, va_list ap) { + struct s_pet *p = data; + if (p) aFree(p); + return 0; +} +void inter_pet_final() +{ + numdb_final(pet_db, pet_db_final); + return; +} + int inter_pet_save_sub(void *key,void *data,va_list ap) { char line[8192]; diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 993f913ab..3a48ada3b 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -3,6 +3,7 @@ #define _INT_PET_H_ int inter_pet_init(); +void inter_pet_final(); int inter_pet_save(); int inter_pet_delete(int pet_id); diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 3c5695c90..67b25909b 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -291,6 +291,22 @@ int inter_storage_init() return 0; } +int storage_db_final (void *k, void *data, va_list ap) { + struct storage *p = data; + if (p) aFree(p); + return 0; +} +int guild_storage_db_final (void *k, void *data, va_list ap) { + struct guild_storage *p = data; + if (p) aFree(p); + return 0; +} +void inter_storage_final() { + numdb_final(storage_db, storage_db_final); + numdb_final(guild_storage_db, guild_storage_db_final); + return; +} + int inter_storage_save_sub(void *key,void *data,va_list ap) { char line[65536]; diff --git a/src/char/int_storage.h b/src/char/int_storage.h index d918f5fe3..f228be53d 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -3,6 +3,7 @@ #define _INT_STORAGE_H_ int inter_storage_init(); +void inter_storage_final(); int inter_storage_save(); int inter_guild_storage_save(); int inter_storage_delete(int account_id); diff --git a/src/char/inter.c b/src/char/inter.c index f368a48b6..3a388ea82 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -261,6 +261,29 @@ int inter_init(const char *file) { return 0; } +// finalize +int accreg_db_final (void *k, void *data, va_list ap) { + struct accreg *p = data; + if (p) aFree(p); + return 0; +} +int wis_db_final (void *k, void *data, va_list ap) { + struct WisData *p = data; + if (p) aFree(p); + return 0; +} +void inter_final() { + numdb_final(accreg_db, accreg_db_final); + numdb_final(wis_db, wis_db_final); + + inter_party_final(); + inter_guild_final(); + inter_storage_final(); + inter_pet_final(); + + return; +} + // マップサーバー接続 int inter_mapif_init(int fd) { inter_guild_mapif_init(fd); diff --git a/src/char/inter.h b/src/char/inter.h index 0b6f809d7..636ce31d8 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -3,6 +3,7 @@ #define _INTER_H_ int inter_init(const char *file); +void inter_final(); int inter_save(); int inter_parse_frommap(int fd); int inter_mapif_init(int fd); diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 78467b579..6b122974f 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -3134,6 +3134,12 @@ int char_lan_config_read(const char *lancfgName){ return 0; } +static int char_db_final(void *key,void *data,va_list ap) +{ + struct mmo_charstatus *p = data; + if (p) aFree(p); + return 0; +} void do_final(void) { printf("Doing final stage...\n"); //mmo_char_sync(); @@ -3162,9 +3168,12 @@ void do_final(void) { delete_session(login_fd); delete_session(char_fd); + numdb_final(char_db_, char_db_final); + exit_dbn(); mysql_close(&mysql_handle); mysql_close(&lmysql_handle); + timer_final(); printf("ok! all done...\n"); } diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 2f294bade..4961fd933 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -709,6 +709,35 @@ int inter_guild_sql_init() return 0; } +int guild_expcache_db_final (void *k, void *data, va_list ap) { return 0; } +int guild_infoevent_db_final (void *k, void *data, va_list ap) { return 0; } +int guild_castleinfoevent_db_final (void *k, void *data, va_list ap) { return 0; } +int guild_db_final (void *k, void *data, va_list ap) +{ + struct guild *g = data; + if (g) aFree(g); + return 0; +} +int castle_db_final (void *k, void *data, va_list ap) +{ + struct guild_castle *gc = data; + if (gc) aFree(gc); + return 0; +} +void inter_guild_sql_final() +{ + if (guild_pt) aFree(guild_pt); + if (guild_pt2) aFree(guild_pt2); + if (guildcastle_pt) aFree(guildcastle_pt); + + numdb_final(guild_db_, guild_db_); + numdb_final(castle_db_, castle_db_final); + numdb_final(guild_expcache_db_, guild_expcache_db_final); + numdb_final(guild_infoevent_db_, guild_infoevent_db_final); + numdb_final(guild_castleinfoevent_db_, guild_castleinfoevent_db_final); + + return; +} // Get guild by its name struct guild* search_guildname(char *str) diff --git a/src/char_sql/int_guild.h b/src/char_sql/int_guild.h index 8f4203d7c..8257cf8f6 100644 --- a/src/char_sql/int_guild.h +++ b/src/char_sql/int_guild.h @@ -3,6 +3,7 @@ int inter_guild_parse_frommap(int fd); int inter_guild_sql_init(); +void inter_guild_sql_final(); int inter_guild_mapif_init(int fd); int inter_guild_leave(int guild_id,int account_id,int char_id); diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index 4cafa9f4d..03392feb6 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -237,6 +237,10 @@ int inter_party_sql_init(){ return 0; } +void inter_party_sql_final(){ + if (party_pt) aFree(party_pt); + return; +} // Search for the party according to its name diff --git a/src/char_sql/int_party.h b/src/char_sql/int_party.h index 04f71c881..686d70b04 100644 --- a/src/char_sql/int_party.h +++ b/src/char_sql/int_party.h @@ -3,6 +3,7 @@ int inter_party_parse_frommap(int fd); int inter_party_sql_init(); +void inter_party_sql_final(); int inter_party_leave(int party_id,int account_id); #endif diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 35a7710a7..ea1fed67d 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -136,6 +136,10 @@ int inter_pet_sql_init(){ return 0; } +void inter_pet_sql_final(){ + if (pet_pt) aFree(pet_pt); + return; +} //---------------------------------- int inter_pet_delete(int pet_id){ printf("request delete pet: %d.......\n",pet_id); diff --git a/src/char_sql/int_pet.h b/src/char_sql/int_pet.h index b6e3f1bbf..39f127262 100644 --- a/src/char_sql/int_pet.h +++ b/src/char_sql/int_pet.h @@ -2,6 +2,7 @@ #define _INT_PET_H_ int inter_pet_init(); +void inter_pet_sql_final(); int inter_pet_save(); int inter_pet_delete(int pet_id); diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index 48f5e04a1..9bb5318c6 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -166,6 +166,13 @@ int inter_storage_sql_init(){ return 1; } +// storage data finalize +void inter_storage_sql_final() +{ + if (storage_pt) aFree(storage_pt); + if (guild_storage_pt) aFree(guild_storage_pt); + return; +} // q?f[^? int inter_storage_delete(int account_id) { diff --git a/src/char_sql/int_storage.h b/src/char_sql/int_storage.h index f9f37db3e..5541d1ed7 100644 --- a/src/char_sql/int_storage.h +++ b/src/char_sql/int_storage.h @@ -2,6 +2,7 @@ #define _INT_STORAGE_H_ int inter_storage_sql_init(); +void inter_storage_sql_final(); int inter_storage_delete(int account_id); int inter_guild_storage_delete(int guild_id); diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index a8e0d4f44..13ce0acbe 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -290,12 +290,32 @@ int inter_init(const char *file) inter_pet_sql_init(); inter_accreg_sql_init(); + atexit(inter_final); + //printf ("interserver timer initializing : %d sec...\n",autosave_interval); //i=add_timer_interval(gettick()+autosave_interval,inter_save_timer,0,0,autosave_interval); return 0; } +// finalize +int wis_db_final (void *k, void *data, va_list ap) { + struct WisData *p = data; + if (p) aFree(p); + return 0; +} +void inter_final() { + numdb_final(wis_db, wis_db_final); + + inter_guild_sql_final(); + inter_storage_sql_final(); + inter_party_sql_final(); + inter_pet_sql_final(); + + if (accreg_pt) aFree(accreg_pt); + return; +} + int inter_mapif_init(int fd) { inter_guild_mapif_init(fd); diff --git a/src/char_sql/inter.h b/src/char_sql/inter.h index 4b61b69c5..1e6a26dce 100644 --- a/src/char_sql/inter.h +++ b/src/char_sql/inter.h @@ -2,10 +2,10 @@ #define _INTER_H_ int inter_init(const char *file); +void inter_final(); int inter_parse_frommap(int fd); int inter_mapif_init(int fd); - int inter_check_length(int fd,int length); int inter_log(char *fmt,...); diff --git a/src/common/core.c b/src/common/core.c index 96d2c872b..03945040a 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -285,6 +285,12 @@ int main(int argc,char **argv) { int next; + display_title(); +#ifdef USE_MEMMGR + // call this first so it'll be finalised last + do_init_memmgr(argv[0]); // 一番最初に実行する必要がある +#endif + sscanf(argv[0], "./%24[^\n]", server_type); // map/char/login? atexit(log_uptime); pid_create(argv[0]); @@ -305,12 +311,6 @@ int main(int argc,char **argv) compat_signal(SIGTRAP, SIG_DFL); #endif - display_title(); - -#ifdef USE_MEMMGR - do_init_memmgr(argv[0]); // 一番最初に実行する必要がある -#endif - tick_ = time(0); ticks = gettick(); diff --git a/src/common/malloc.c b/src/common/malloc.c index 40c9f34bf..703933d01 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -7,9 +7,6 @@ #include "memwatch.h" #endif -// 独自メモリマネージャを使用する場合、次のコメントを外してください。 -// #define USE_MEMMGR - #if !defined(DMALLOC) && !defined(GCOLLECT) && !defined(BCHECK) && !defined(USE_MEMMGR) void* aMalloc_( size_t size, const char *file, int line, const char *func ) @@ -537,6 +534,7 @@ static void memmer_exit(void) { printf("memmgr: no memory leaks found.\n"); } else { printf("memmgr: memory leaks found.\n"); + fclose(fp); } } diff --git a/src/common/malloc.h b/src/common/malloc.h index 45451c9e0..eec138cdd 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -3,6 +3,9 @@ #include +// 独自メモリマネージャを使用する場合、次のコメントを外してください。 +// #define USE_MEMMGR + #if defined(DMALLOC) # include "dmalloc.h" diff --git a/src/common/socket.c b/src/common/socket.c index f49d4c0ca..1c4d5931a 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -943,11 +943,9 @@ void do_final_socket(void) aFree(access_deny); // session[0] のダミーデータを削除 - if (session[0]) { - aFree(session[0]->rdata); - aFree(session[0]->wdata); - aFree(session[0]); - } + aFree(session[0]->rdata); + aFree(session[0]->wdata); + aFree(session[0]); } void do_socket(void) diff --git a/src/common/timer.h b/src/common/timer.h index c43c0e6b0..57036ae01 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -36,11 +36,9 @@ int addtick_timer(int tid,unsigned int tick); struct TimerData *get_timer(int tid); int do_timer(unsigned int tick); +void timer_final(); 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(); - #endif // _TIMER_H_ diff --git a/src/login/login.c b/src/login/login.c index a54aca410..27f7c12ce 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -3923,11 +3923,12 @@ void do_final(void) { memset(&server[i], 0, sizeof(struct mmo_char_server)); close(fd); delete_session(fd); - if(session[fd]) aFree(session[fd]); } } close(login_fd); delete_session(login_fd); + exit_dbn(); + timer_final(); login_log("----End of login-server (normal end with closing of all files)." RETCODE); diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 91fc9ccb8..071b6d32c 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -41,30 +41,19 @@ void Gettimeofday(struct timeval *timenow) #include #include #include -#include "malloc.h" //add include for DBMS(mysql) #include -#include "../common/strlib.h" -#include "timer.h" -/* -#include "timer.h" -#include "core.h" -#include "socket.h" -#include "login.h" -#include "mmo.h" -#include "version.h" -#include "db.h" -*/ - #include "../common/core.h" #include "../common/socket.h" -#include "login.h" -#include "../common/mmo.h" -#include "../common/version.h" +#include "../common/malloc.h" #include "../common/db.h" #include "../common/timer.h" +#include "../common/strlib.h" +#include "../common/mmo.h" +#include "../common/version.h" +#include "login.h" #ifdef PASSWORDENC #include "md5calc.h" @@ -1835,6 +1824,24 @@ int flush_timer(int tid, unsigned int tick, int id, int data){ return 0; } +//-------------------------------------- +// Function called at exit of the server +//-------------------------------------- +static int online_db_final(void *key,void *data,va_list ap) +{ + int *p = data; + if (p) aFree(p); + return 0; +} +void do_final(void) { + //sync account when terminating. + //but no need when you using DBMS (mysql) + mmo_db_close(); + numdb_final(online_db, online_db_final); + exit_dbn(); + timer_final(); +} + int do_init(int argc,char **argv){ //initialize login server int i; @@ -1876,9 +1883,7 @@ int do_init(int argc,char **argv){ printf ("Running mmo_auth_sqldb_init()\n"); mmo_auth_sqldb_init(); printf ("finished mmo_auth_sqldb_init()\n"); - //sync account when terminating. - //but no need when you using DBMS (mysql) - set_termfunc(mmo_db_close); + set_termfunc(do_final); //set default parser as parse_login function set_defaultparse(parse_login); diff --git a/src/map/map.c b/src/map/map.c index 60d41b84e..9dcf541c1 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1697,24 +1697,24 @@ int map_addnpc(int m,struct npc_data *nd) { } void map_removenpc(void) { - int i,m,n=0; - - for(m=0;mbl,2); - map_delblock(&map[m].npc[i]->bl); - numdb_erase(id_db,map[m].npc[i]->bl.id); - if(map[m].npc[i]->bl.subtype==SCRIPT) { -// aFree(map[m].npc[i]->u.scr.script); -// aFree(map[m].npc[i]->u.scr.label_list); - } - aFree(map[m].npc[i]); - map[m].npc[i] = NULL; - n++; - } - } - } + int i,m,n=0; + + for(m=0;mbl,2); + map_delblock(&map[m].npc[i]->bl); + numdb_erase(id_db,map[m].npc[i]->bl.id); + if(map[m].npc[i]->bl.subtype==SCRIPT) { + aFree(map[m].npc[i]->u.scr.script); + aFree(map[m].npc[i]->u.scr.label_list); + } + aFree(map[m].npc[i]); + map[m].npc[i] = NULL; + n++; + } + } + } sprintf(tmp_output,"Successfully removed and freed from memory '"CL_WHITE"%d"CL_RESET"' NPCs.\n",n); ShowStatus(tmp_output); @@ -3097,29 +3097,20 @@ int flush_timer(int tid, unsigned int tick, int id, int data){ return 0; } -int id_db_final(void *k,void *d,va_list ap) +int id_db_final(void *k,void *d,va_list ap) { return 0; } +int map_db_final(void *k,void *d,va_list ap) { return 0; } +int nick_db_final(void *k,void *d,va_list ap) { - struct mob_data *id; - nullpo_retr(0, id = (struct mob_data*)d); - if(id->lootitem) - aFree(id->lootitem); - if(id) - aFree(id); + char *p = d; + if (p) aFree(p); return 0; } - -int map_db_final(void *k,void *d,va_list ap) +int charid_db_final(void *k,void *d,va_list ap) { - struct map_data *id; - nullpo_retr(0, id = (struct map_data*)d); - if(id->gat) - aFree(id->gat); - if(id) - aFree(id); + struct charid2nick *p = d; + if (p) aFree(p); return 0; } -int nick_db_final(void *k,void *d,va_list ap){ return 0; } -int charid_db_final(void *k,void *d,va_list ap){ return 0; } int cleanup_sub(struct block_list *bl, va_list ap) { nullpo_retr(0, bl); @@ -3152,12 +3143,12 @@ int cleanup_sub(struct block_list *bl, va_list ap) { *------------------------------------------ */ void do_final(void) { - int map_id, i; + int i; ShowStatus("Terminating...\n"); - for (map_id = 0; map_id < map_num;map_id++) - if(map[map_id].m) - map_foreachinarea(cleanup_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, 0, 0); + for (i = 0; i < map_num; i++) + if(map[i].m) + map_foreachinarea(cleanup_sub, i, 0, 0, map[i].xs, map[i].ys, 0, 0); #ifndef TXT_ONLY chrif_char_reset_offline(); @@ -3165,38 +3156,35 @@ void do_final(void) { chrif_flush_fifo(); - for (i = 0; i < fd_max; i++) - delete_session(i); - -#if 0 - map_removenpc(); - -// do_final_timer(); (we used timer_final() instead) - timer_final(); -// numdb_final(id_db, id_db_final); - strdb_final(map_db, map_db_final); - strdb_final(nick_db, nick_db_final); - numdb_final(charid_db, charid_db_final); - +//#if 0 // why is this here? >_> do_final_chrif(); // この内部でキャラを全て切断する + do_final_npc(); +// map_removenpc(); do_final_script(); do_final_itemdb(); do_final_storage(); do_final_guild(); + do_final_party(); + do_final_pc(); do_final_pet(); -/* - for(i=0;ichat_id && (cd=(struct chat_data*)map_id2bl(nd->chat_id))){ + aFree (cd); + cd = NULL; + } + if (nd->bl.subtype == SCRIPT) { + if (nd->u.scr.timer_event) + aFree(nd->u.scr.timer_event); + if (nd->u.scr.src_id==0) { + if(nd->u.scr.script) { + aFree(nd->u.scr.script); + nd->u.scr.script=NULL; + } + if (nd->u.scr.label_list) { + aFree(nd->u.scr.label_list); + nd->u.scr.label_list = NULL; + } + } + } + clif_clearchar_area(&nd->bl, 2); + map_delblock(&nd->bl); + map_deliddb(&nd->bl); + aFree(nd); + nd = NULL; + return 0; +} static int ev_db_final(void *key,void *data,va_list ap) { aFree(data); @@ -2326,6 +2356,30 @@ static int ev_db_final(void *key,void *data,va_list ap) static int npcname_db_final(void *key,void *data,va_list ap) { return 0; +} +/*========================================== + * + *------------------------------------------ + */ +int npc_reload(void) +{ + struct npc_data *nd; + struct block_list *bl; + int i; + + if(ev_db) + strdb_final(ev_db,ev_db_final); + if(npcname_db) + strdb_final(npcname_db,npcname_db_final); + + for (i = START_NPC_NUM; i < npc_id; i++) { + if((bl = map_id2bl(i)) && bl->type == BL_NPC && (nd = (struct npc_data *)bl)) + npc_unload(nd); + } + + return 0; + + } /*========================================== * 終了 @@ -2337,7 +2391,6 @@ int do_final_npc(void) struct block_list *bl; struct npc_data *nd; struct mob_data *md; - struct chat_data *cd; struct pet_data *pd; if(ev_db) @@ -2345,31 +2398,14 @@ int do_final_npc(void) if(npcname_db) strdb_final(npcname_db,npcname_db_final); - for(i=START_NPC_NUM;itype == BL_NPC && (nd = (struct npc_data *)bl)){ - if(nd->chat_id && (cd=(struct chat_data*)map_id2bl(nd->chat_id))){ - aFree(cd); - cd = NULL; - } - if(nd->bl.subtype == SCRIPT){ - if(nd->u.scr.timer_event) - aFree(nd->u.scr.timer_event); - if(nd->u.scr.src_id==0){ - if(nd->u.scr.script){ - aFree(nd->u.scr.script); - nd->u.scr.script=NULL; - } - if(nd->u.scr.label_list){ - aFree(nd->u.scr.label_list); - nd->u.scr.label_list = NULL; - } - } - } - aFree(nd); - nd = NULL; - }else if(bl->type == BL_MOB && (md = (struct mob_data *)bl)){ - if(md->lootitem){ + npc_unload(nd); + }else if (bl->type == BL_MOB && (md = (struct mob_data *)bl)){ + if (md->lootitem){ aFree(md->lootitem); md->lootitem = NULL; } @@ -2415,10 +2451,10 @@ int do_init_npc(void) // 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... //ev_db=strdb_init(24); - ev_db=strdb_init(51); - npcname_db=strdb_init(24); + ev_db = strdb_init(51); + npcname_db = strdb_init(24); - ev_db->release = ev_release; + ev_db->release = ev_release; memset(&ev_tm_b,-1,sizeof(ev_tm_b)); diff --git a/src/map/pc.c b/src/map/pc.c index 07e712dbe..8c0857d4b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -7234,6 +7234,11 @@ int pc_readdb(void) * pc? 係初期化 *------------------------------------------ */ +void do_final_pc(void) { + if (gm_account) + aFree(gm_account); + return; +} int do_init_pc(void) { pc_readdb(); diff --git a/src/map/pc.h b/src/map/pc.h index 242ae3147..8c4f96529 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -202,6 +202,7 @@ int pc_delspiritball(struct map_session_data *sd,int,int); int pc_eventtimer(int tid,unsigned int tick,int id,int data); // for npc_dequeue int do_init_pc(void); +void do_final_pc(void); enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT}; -- cgit v1.2.3-70-g09d2 From c1a8f6f0ac98a694e670bae4c8f74db126e0e8e8 Mon Sep 17 00:00:00 2001 From: amber Date: Tue, 29 Mar 2005 06:18:21 +0000 Subject: Fixe compile time problems with our mixed C++/C conformance git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1328 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 2 + src/char_sql/char.c | 7 ++-- src/char_sql/char.h | 2 +- src/char_sql/int_guild.c | 6 +-- src/char_sql/inter.c | 2 +- src/common/db.h | 10 +++-- src/common/malloc.c | 6 +-- src/common/malloc.h | 2 +- src/common/socket.c | 6 +-- src/common/timer.c | 14 +++---- src/login_sql/login.c | 2 +- src/map/clif.c | 4 +- src/map/itemdb.c | 8 ++-- src/map/map.c | 6 +-- src/map/npc.c | 2 +- src/map/pc.c | 2 +- src/map/script.c | 54 ++++++++++++------------- src/txt-converter/char/char-converter.c | 72 ++++++++++++++++----------------- src/txt-converter/common/mmo.h | 4 +- 19 files changed, 108 insertions(+), 103 deletions(-) (limited to 'src/common/socket.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 7f32d47cb..d20b19142 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,6 +1,8 @@ Date Added 03/29 + * Fixed a lot of compile time problems with our mixed C++/C + conformance [1328: MouseJstr] * Fixed use of storage variable to conform to ANSI C spec [1327: MouseJstr] * Added CIA-bot to the #athena channel [MouseJstr] diff --git a/src/char_sql/char.c b/src/char_sql/char.c index ab20b893b..75bf663d0 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -67,6 +67,7 @@ char party_db[256] = "party"; char pet_db[256] = "pet"; char login_db[256] = "login"; char friend_db[256] = "friends"; +int db_use_sqldbs; char login_db_account_id[32] = "account_id"; char login_db_level[32] = "level"; @@ -3138,7 +3139,7 @@ int char_lan_config_read(const char *lancfgName){ static int char_db_final(void *key,void *data,va_list ap) { - struct mmo_charstatus *p = data; + struct mmo_charstatus *p = (struct mmo_charstatus *) data; if (p) aFree(p); return 0; } @@ -3280,8 +3281,8 @@ int char_config_read(const char *cfgName) { if (sscanf(line,"%[^:]: %[^\r\n]", w1, w2) != 2) continue; - remove_control_chars(w1); - remove_control_chars(w2); + remove_control_chars((unsigned char *) w1); + remove_control_chars((unsigned char *) w2); if (strcmpi(w1, "userid") == 0) { memcpy(userid, w2, 24); } else if (strcmpi(w1, "passwd") == 0) { diff --git a/src/char_sql/char.h b/src/char_sql/char.h index 74bb28cf1..ddd873374 100644 --- a/src/char_sql/char.h +++ b/src/char_sql/char.h @@ -71,7 +71,7 @@ extern char guild_storage_db[256]; extern char party_db[256]; extern char pet_db[256]; -int db_use_sqldbs; // added for sql item_db read for char server [Valaris] +extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris] extern char login_db_level[32]; extern char login_db_account_id[32]; diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index b5d20590a..5ec700a54 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -532,7 +532,7 @@ int inter_guildcastle_tosql(struct guild_castle *gc) return 0; } //printf("[Guild Castle %02i]: Save...\n",gc->castle_id); - gcopy = numdb_search(castle_db_,gc->castle_id); + gcopy = (struct guild_castle *) numdb_search(castle_db_,gc->castle_id); if (gcopy == NULL) { gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); numdb_insert(castle_db_, gc->castle_id, gcopy); @@ -714,13 +714,13 @@ int guild_infoevent_db_final (void *k, void *data, va_list ap) { return 0; } int guild_castleinfoevent_db_final (void *k, void *data, va_list ap) { return 0; } int guild_db_final (void *k, void *data, va_list ap) { - struct guild *g = data; + struct guild *g = (struct guild *) data; if (g) aFree(g); return 0; } int castle_db_final (void *k, void *data, va_list ap) { - struct guild_castle *gc = data; + struct guild_castle *gc = (struct guild_castle *) data; if (gc) aFree(gc); return 0; } diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 13ce0acbe..1a2a2d751 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -300,7 +300,7 @@ int inter_init(const char *file) // finalize int wis_db_final (void *k, void *data, va_list ap) { - struct WisData *p = data; + struct WisData *p = (struct WisData *) data; if (p) aFree(p); return 0; } diff --git a/src/common/db.h b/src/common/db.h index 8b37e15ad..6980099cf 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -18,6 +18,11 @@ struct dbn { struct dbn *prev; }; +struct db_free { + struct dbn *z; + struct dbn **root; +}; + struct dbt { int (*cmp)(struct dbt*,void*,void*); unsigned int (*hash)(struct dbt*,void*); @@ -30,10 +35,7 @@ struct dbt { int alloc_line; // DB?s // db_foreach 内部でdb_erase される対策として、 // db_foreach が終わるまでロックすることにする - struct db_free { - struct dbn *z; - struct dbn **root; - } *free_list; + struct db_free *free_list; int free_count; int free_max; int free_lock; diff --git a/src/common/malloc.c b/src/common/malloc.c index 747423b47..b562ca3c0 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -65,15 +65,15 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f return ret; } -void* aStrdup_( const void *p, const char *file, int line, const char *func ) +char* aStrdup_( const void *p, const char *file, int line, const char *func ) { - void *ret; + char *ret; // printf("%s:%d: in func %s: strdup %p\n",file,line,func,p); #ifdef MEMWATCH ret=mwStrdup(p,file,line); #else - ret=strdup(p); + ret= strdup((char *) p); #endif if(ret==NULL){ printf("%s:%d: in func %s: strdup error out of memory!\n",file,line,func); diff --git a/src/common/malloc.h b/src/common/malloc.h index c59c08a4e..1bc0eb292 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -63,7 +63,7 @@ void* aCalloc_( size_t num, size_t size, const char *file, int line, const char *func ); void* aRealloc_( void *p, size_t size, const char *file, int line, const char *func ); void aFree_( void *p, const char *file, int line, const char *func ); - void* aStrdup_( const void *p, const char *file, int line, const char *func ); + char* aStrdup_( const void *p, const char *file, int line, const char *func ); # define aMalloc(n) aMalloc_(n,ALC_MARK) # define aMallocA(n) aMalloc_(n,ALC_MARK) diff --git a/src/common/socket.c b/src/common/socket.c index 1c4d5931a..70432eddf 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -678,7 +678,7 @@ static int connect_check_(unsigned int ip) { hist = hist->next; } // IPリストに無いので新規作成 - hist_new = aCalloc(1,sizeof(struct _connect_history)); + hist_new = (struct _connect_history *) aCalloc(1,sizeof(struct _connect_history)); hist_new->ip = ip; hist_new->tick = gettick(); if(connect_history[ip & 0xFFFF] != NULL) { @@ -791,12 +791,12 @@ int socket_config_read(const char *cfgName) { if(strcmpi(w2,"allow,deny")==0) access_order=ACO_ALLOW_DENY; if(strcmpi(w2,"mutual-failure")==0) access_order=ACO_MUTUAL_FAILTURE; } else if(strcmpi(w1,"allow")==0){ - access_allow = aRealloc(access_allow,(access_allownum+1)*sizeof(struct _access_control)); + access_allow = (struct _access_control *) aRealloc(access_allow,(access_allownum+1)*sizeof(struct _access_control)); if(access_ipmask(w2,&access_allow[access_allownum])) { access_allownum++; } } else if(strcmpi(w1,"deny")==0){ - access_deny = aRealloc(access_deny,(access_denynum+1)*sizeof(struct _access_control)); + access_deny = (struct _access_control *) aRealloc(access_deny,(access_denynum+1)*sizeof(struct _access_control)); if(access_ipmask(w2,&access_deny[access_denynum])) { access_denynum++; } diff --git a/src/common/timer.c b/src/common/timer.c index 6bf5cdbda..6a740d47a 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -54,9 +54,9 @@ int add_timer_func_list(int (*func)(int,unsigned int,int,int), char* name) { struct timer_func_list* tfl; //CALLOC(tfl, struct timer_func_list, 1); - tfl = aCalloc( sizeof(struct timer_func_list) , 1); + tfl = (struct timer_func_list*) aCalloc( sizeof(struct timer_func_list) , 1); //MALLOC(tfl->name, char, strlen(name) + 1); - tfl->name = aMalloc( strlen(name) + 1 ); + tfl->name = (char *) aMalloc( strlen(name) + 1 ); tfl->next = tfl_root; tfl->func = func; @@ -112,11 +112,11 @@ static void push_timer_heap(int index) { if (timer_heap_max == 0) { timer_heap_max = 256; //CALLOC(timer_heap, int, 256); - timer_heap = aCalloc( sizeof(int) , 256); + timer_heap = (int *) aCalloc( sizeof(int) , 256); } else { timer_heap_max += 256; //REALLOC(timer_heap, int, timer_heap_max); - timer_heap = aRealloc( timer_heap, sizeof(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); } } @@ -178,11 +178,11 @@ 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; //CALLOC(timer_data, struct TimerData, timer_data_max); - timer_data = aCalloc( sizeof(struct TimerData) , timer_data_max); + timer_data = (struct TimerData*) aCalloc( sizeof(struct TimerData) , timer_data_max); } else { timer_data_max += 256; //REALLOC(timer_data, struct TimerData, timer_data_max); - timer_data = aRealloc( timer_data, sizeof(struct TimerData) * timer_data_max); + timer_data = (struct TimerData *) aRealloc( timer_data, sizeof(struct TimerData) * timer_data_max); memset(timer_data + (timer_data_max - 256), 0, sizeof(struct TimerData) * 256); } } @@ -267,7 +267,7 @@ int do_timer(unsigned int tick) { if (free_timer_list_pos >= free_timer_list_max) { free_timer_list_max += 256; //REALLOC(free_timer_list, int, free_timer_list_max); - free_timer_list = aRealloc(free_timer_list, sizeof(int) * free_timer_list_max); + free_timer_list = (int *) aRealloc(free_timer_list, sizeof(int) * free_timer_list_max); memset(free_timer_list + (free_timer_list_max - 256), 0, 256 * sizeof(int)); } free_timer_list[free_timer_list_pos++] = i; diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 071b6d32c..85f08391d 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -1829,7 +1829,7 @@ int flush_timer(int tid, unsigned int tick, int id, int data){ //-------------------------------------- static int online_db_final(void *key,void *data,va_list ap) { - int *p = data; + int *p = (int *) data; if (p) aFree(p); return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index 9e649df40..7ebf11b8a 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4778,8 +4778,8 @@ void clif_GlobalMessage(struct block_list *bl,char *message) WBUFW(buf,0)=cmd; WBUFW(buf,2)=len+8; WBUFL(buf,4)=bl->id; - strncpy(WBUFP(buf,8),message,len); - clif_send(buf,WBUFW(buf,2),bl,AREA_CHAT_WOC); + strncpy((char *) WBUFP(buf,8),message,len); + clif_send((unsigned char *) buf,WBUFW(buf,2),bl,AREA_CHAT_WOC); } /*========================================== diff --git a/src/map/itemdb.c b/src/map/itemdb.c index c37274cb9..d575e8a77 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -851,10 +851,10 @@ static int itemdb_read_sqldb(void) if (sql_row[17] != NULL) { if (sql_row[17][0] == '{') - id->use_script = parse_script(sql_row[17], 0); + id->use_script = parse_script((unsigned char *) sql_row[17], 0); else { sprintf(script, "{%s}", sql_row[17]); - id->use_script = parse_script(script, 0); + id->use_script = parse_script((unsigned char *) script, 0); } } else @@ -865,10 +865,10 @@ static int itemdb_read_sqldb(void) if (sql_row[18] != NULL) { if (sql_row[18][0] == '{') - id->equip_script = parse_script(sql_row[18], 0); + id->equip_script = parse_script((unsigned char *) sql_row[18], 0); else { sprintf(script, "{%s}", sql_row[18]); - id->equip_script = parse_script(script, 0); + id->equip_script = parse_script((unsigned char *) script, 0); } } else diff --git a/src/map/map.c b/src/map/map.c index db2831cf5..19edfd08b 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2012,7 +2012,7 @@ int map_eraseipport(char *name,unsigned long ip,int port) struct map_data_other_server *mdos; // unsigned char *p=(unsigned char *)&ip; - md=strdb_search(map_db,name); + md=(struct map_data *) strdb_search(map_db,name); if(md){ if(md->gat) // local -> check data return 0; @@ -3119,13 +3119,13 @@ int id_db_final(void *k,void *d,va_list ap) { return 0; } int map_db_final(void *k,void *d,va_list ap) { return 0; } int nick_db_final(void *k,void *d,va_list ap) { - char *p = d; + char *p = (char *) d; if (p) aFree(p); return 0; } int charid_db_final(void *k,void *d,va_list ap) { - struct charid2nick *p = d; + struct charid2nick *p = (struct charid2nick *) d; if (p) aFree(p); return 0; } diff --git a/src/map/npc.c b/src/map/npc.c index 6e22c69b3..95893ad11 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -875,7 +875,7 @@ int npc_checknear(struct map_session_data *sd,int id) */ int npc_globalmessage(const char *name,char *mes) { - struct npc_data *nd=strdb_search(npcname_db,name); + struct npc_data *nd=(struct npc_data *) strdb_search(npcname_db,name); char temp[100]; char ntemp[50]; char *ltemp; diff --git a/src/map/pc.c b/src/map/pc.c index c9b8755de..8b3a32c6f 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6994,7 +6994,7 @@ int pc_read_gm_account(int fd) } lsql_res = mysql_store_result(&lmysql_handle); if (lsql_res) { - gm_account = aCallocA(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); + gm_account = (struct gm_account *) aCallocA(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); while ((lsql_row = mysql_fetch_row(lsql_res))) { gm_account[GM_num].account_id = atoi(lsql_row[0]); gm_account[GM_num].level = atoi(lsql_row[1]); diff --git a/src/map/script.c b/src/map/script.c index d7d5f433e..c39afc8f6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -62,7 +62,7 @@ static struct str_data_struct { int str; int backpatch; int label; - int (*func)(); + int (*func)(script_state *); int val; int next; } *str_data; @@ -1190,7 +1190,7 @@ static void read_constdb(void) sscanf(line,"%[A-Za-z0-9_] %d %d",name,&val,&type)>=2){ for(i=0;name[i];i++) name[i]=tolower(name[i]); - n=add_str(name); + n=add_str((const unsigned char *) name); if(type==0) str_data[n].type=C_INT; else @@ -1281,7 +1281,7 @@ char* parse_script(unsigned char *src,int line) add_scriptc(C_NOP); script_size = script_pos; - script_buf=(char *)aRealloc(script_buf,script_pos + 1); + script_buf=(unsigned char *)aRealloc(script_buf,script_pos + 1); // 未解決のラベルを解決 for(i=LABEL_START;i %d\n",type,str,stack->sp); stack->stack_data[stack->sp].type=type; - stack->stack_data[stack->sp].u.str=str; + stack->stack_data[stack->sp].u.str=(char *) str; stack->sp++; } @@ -1537,10 +1537,10 @@ void push_copy(struct script_stack *stack,int pos) { switch(stack->stack_data[pos].type){ case C_CONSTSTR: - push_str(stack,C_CONSTSTR,stack->stack_data[pos].u.str); + push_str(stack,C_CONSTSTR,(unsigned char *) stack->stack_data[pos].u.str); break; case C_STR: - push_str(stack,C_STR,aStrdup(stack->stack_data[pos].u.str)); + push_str(stack,C_STR,(unsigned char *) aStrdup(stack->stack_data[pos].u.str)); break; default: push_val(stack,stack->stack_data[pos].type,stack->stack_data[pos].u.num); @@ -1609,7 +1609,7 @@ int buildin_callfunc(struct script_state *st) char *scr; char *str=conv_str(st,& (st->stack->stack_data[st->start+2])); - if( (scr=strdb_search(script_get_userfunc_db(),str)) ){ + if( (scr=(char *) strdb_search(script_get_userfunc_db(),str)) ){ int i,j; for(i=st->start+3,j=0;iend;i++,j++) push_copy(st->stack,i); @@ -1748,8 +1748,8 @@ int buildin_menu(struct script_state *st) st->state=END; } else { // goto動作 // ragemu互換のため - pc_setreg(sd,add_str("l15"),sd->npc_menu); - pc_setreg(sd,add_str("@menu"),sd->npc_menu); + pc_setreg(sd,add_str((unsigned char *) "l15"),sd->npc_menu); + pc_setreg(sd,add_str((unsigned char *) "@menu"),sd->npc_menu); sd->state.menu_or_input=0; if(sd->npc_menu>0 && sd->npc_menu<(st->end-st->start)/2){ int pos; @@ -1930,7 +1930,7 @@ int buildin_input(struct script_state *st) { struct map_session_data *sd=NULL; int num=(st->end>st->start+2)?st->stack->stack_data[st->start+2].u.num:0; - char *name=(st->end>st->start+2)?str_buf+str_data[num&0x00ffffff].str:""; + char *name=(char *) ((st->end>st->start+2)?str_buf+str_data[num&0x00ffffff].str:""); // char prefix=*name; char postfix=name[strlen(name)-1]; @@ -1961,7 +1961,7 @@ int buildin_input(struct script_state *st) set_reg(sd,num,name,(void*)sd->npc_amount); } else { // ragemu互換のため - pc_setreg(sd,add_str("l14"),sd->npc_amount); + pc_setreg(sd,add_str((unsigned char *) "l14"),sd->npc_amount); } } } else { @@ -2186,7 +2186,7 @@ int buildin_deletearray(struct script_state *st) } for(;i<(128-(num>>24));i++){ if( postfix!='$' ) set_reg(sd,num+(i<<24),name, 0); - if( postfix=='$' ) set_reg(sd,num+(i<<24),name, ""); + if( postfix=='$' ) set_reg(sd,num+(i<<24),name, (void *) ""); } return 0; } @@ -2704,9 +2704,9 @@ int buildin_getpartyname(struct script_state *st) party_id=conv_num(st,& (st->stack->stack_data[st->start+2])); name=buildin_getpartyname_sub(party_id); if(name!=0) - push_str(st->stack,C_STR,name); + push_str(st->stack,C_STR,(unsigned char *)name); else - push_str(st->stack,C_CONSTSTR,"null"); + push_str(st->stack,C_CONSTSTR, (unsigned char *) "null"); return 0; } @@ -2726,12 +2726,12 @@ int buildin_getpartymember(struct script_state *st) for(i=0;imember[i].account_id){ // printf("name:%s %d\n",p->member[i].name,i); - mapreg_setregstr(add_str("$@partymembername$")+(i<<24),p->member[i].name); + mapreg_setregstr(add_str((unsigned char *) "$@partymembername$")+(i<<24),p->member[i].name); j++; } } } - mapreg_setreg(add_str("$@partymembercount"),j); + mapreg_setreg(add_str((unsigned char *) "$@partymembercount"),j); return 0; } @@ -2758,9 +2758,9 @@ int buildin_getguildname(struct script_state *st) int guild_id=conv_num(st,& (st->stack->stack_data[st->start+2])); name=buildin_getguildname_sub(guild_id); if(name!=0) - push_str(st->stack,C_STR,name); + push_str(st->stack,C_STR,(unsigned char *) name); else - push_str(st->stack,C_CONSTSTR,"null"); + push_str(st->stack,C_CONSTSTR,(unsigned char *) "null"); return 0; } @@ -2788,9 +2788,9 @@ int buildin_getguildmaster(struct script_state *st) int guild_id=conv_num(st,& (st->stack->stack_data[st->start+2])); master=buildin_getguildmaster_sub(guild_id); if(master!=0) - push_str(st->stack,C_STR,master); + push_str(st->stack,C_STR,(unsigned char *) master); else - push_str(st->stack,C_CONSTSTR,"null"); + push_str(st->stack,C_CONSTSTR,(unsigned char *) "null"); return 0; } @@ -2827,23 +2827,23 @@ int buildin_strcharinfo(struct script_state *st) char *buf; buf=(char *)aCallocA(24,sizeof(char)); strncpy(buf,sd->status.name, 23); - push_str(st->stack,C_STR,buf); + push_str(st->stack,C_STR,(unsigned char *) buf); } if(num==1){ char *buf; buf=buildin_getpartyname_sub(sd->status.party_id); if(buf!=0) - push_str(st->stack,C_STR,buf); + push_str(st->stack,C_STR,(unsigned char *) buf); else - push_str(st->stack,C_CONSTSTR,""); + push_str(st->stack,C_CONSTSTR,(unsigned char *) ""); } if(num==2){ char *buf; buf=buildin_getguildname_sub(sd->status.guild_id); if(buf!=0) - push_str(st->stack,C_STR,buf); + push_str(st->stack,C_STR,(unsigned char *) buf); else - push_str(st->stack,C_CONSTSTR,""); + push_str(st->stack,C_CONSTSTR,(unsigned char *) ""); } return 0; diff --git a/src/txt-converter/char/char-converter.c b/src/txt-converter/char/char-converter.c index 30782412c..217bf2b15 100644 --- a/src/txt-converter/char/char-converter.c +++ b/src/txt-converter/char/char-converter.c @@ -39,7 +39,7 @@ char db_server_id[32] = "ragnarok"; char db_server_pw[32] = "ragnarok"; char db_server_logindb[32] = "ragnarok"; -struct storage *storage=NULL; +struct storage *storage_=NULL; struct mmo_map_server server[MAX_MAP_SERVERS]; int server_fd[MAX_MAP_SERVERS]; @@ -182,13 +182,13 @@ int storage_tosql(int account_id,struct storage *p){ //printf ("all storage item was deleted ok\n"); for(i=0;istorage[i].nameid , p->storage[i].amount); + //printf ("save storage num: %d (%d:%d)\n",i, p->storage_[i].nameid , p->storage_[i].amount); - if( (p->storage[i].nameid) && (p->storage[i].amount) ){ + if( (p->storage_[i].nameid) && (p->storage_[i].amount) ){ sprintf(tmp_sql,"INSERT INTO `storage` (`account_id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`card0`,`card1`,`card2`,`card3`,`broken`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - p->account_id, p->storage[i].nameid, p->storage[i].amount, p->storage[i].equip, - p->storage[i].identify, p->storage[i].refine, p->storage[i].attribute, - p->storage[i].card[0], p->storage[i].card[1], p->storage[i].card[2], p->storage[i].card[3], p->storage[i].broken ); + p->account_id, p->storage_[i].nameid, p->storage_[i].amount, p->storage_[i].equip, + p->storage_[i].identify, p->storage_[i].refine, p->storage_[i].attribute, + p->storage_[i].card[0], p->storage_[i].card[1], p->storage_[i].card[2], p->storage_[i].card[3], p->storage_[i].broken ); //printf ("%s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); @@ -219,18 +219,18 @@ int storage_fromstr(char *str, struct storage *p) &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &len) == 12) { - p->storage[i].id = tmp_int[0]; - p->storage[i].nameid = tmp_int[1]; - p->storage[i].amount = tmp_int[2]; - p->storage[i].equip = tmp_int[3]; - p->storage[i].identify = tmp_int[4]; - p->storage[i].refine = tmp_int[5]; - p->storage[i].attribute = tmp_int[6]; - p->storage[i].card[0] = tmp_int[7]; - p->storage[i].card[1] = tmp_int[8]; - p->storage[i].card[2] = tmp_int[9]; - p->storage[i].card[3] = tmp_int[10]; - p->storage[i].broken = tmp_int[11]; + p->storage_[i].id = tmp_int[0]; + p->storage_[i].nameid = tmp_int[1]; + p->storage_[i].amount = tmp_int[2]; + p->storage_[i].equip = tmp_int[3]; + p->storage_[i].identify = tmp_int[4]; + p->storage_[i].refine = tmp_int[5]; + p->storage_[i].attribute = tmp_int[6]; + p->storage_[i].card[0] = tmp_int[7]; + p->storage_[i].card[1] = tmp_int[8]; + p->storage_[i].card[2] = tmp_int[9]; + p->storage_[i].card[3] = tmp_int[10]; + p->storage_[i].broken = tmp_int[11]; next += len; if (str[next] == ' ') next++; @@ -240,18 +240,18 @@ int storage_fromstr(char *str, struct storage *p) &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &len) == 11) { - p->storage[i].id = tmp_int[0]; - p->storage[i].nameid = tmp_int[1]; - p->storage[i].amount = tmp_int[2]; - p->storage[i].equip = tmp_int[3]; - p->storage[i].identify = tmp_int[4]; - p->storage[i].refine = tmp_int[5]; - p->storage[i].attribute = tmp_int[6]; - p->storage[i].card[0] = tmp_int[7]; - p->storage[i].card[1] = tmp_int[8]; - p->storage[i].card[2] = tmp_int[9]; - p->storage[i].card[3] = tmp_int[10]; - p->storage[i].broken = 0; + p->storage_[i].id = tmp_int[0]; + p->storage_[i].nameid = tmp_int[1]; + p->storage_[i].amount = tmp_int[2]; + p->storage_[i].equip = tmp_int[3]; + p->storage_[i].identify = tmp_int[4]; + p->storage_[i].refine = tmp_int[5]; + p->storage_[i].attribute = tmp_int[6]; + p->storage_[i].card[0] = tmp_int[7]; + p->storage_[i].card[1] = tmp_int[8]; + p->storage_[i].card[2] = tmp_int[9]; + p->storage_[i].card[3] = tmp_int[10]; + p->storage_[i].broken = 0; next += len; if (str[next] == ' ') next++; @@ -705,14 +705,14 @@ int mmo_char_init(void){ set=sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]); if(set==2) { if(i==0){ - storage = (struct storage*)malloc(sizeof(struct storage)); + storage_ = (struct storage*)malloc(sizeof(struct storage)); }else{ - storage = (struct storage*)realloc(storage,sizeof(struct storage)*(i+1)); + storage_ = (struct storage*)realloc(storage_,sizeof(struct storage)*(i+1)); } - memset(&storage[i],0,sizeof(struct storage)); - storage[i].account_id=tmp_int[0]; - storage_fromstr(line,&storage[i]); - storage_tosql(tmp_int[0],&storage[i]); //to sql. (dump) + memset(&storage_[i],0,sizeof(struct storage)); + storage_[i].account_id=tmp_int[0]; + storage_fromstr(line,&storage_[i]); + storage_tosql(tmp_int[0],&storage_[i]); //to sql. (dump) i++; } } diff --git a/src/txt-converter/common/mmo.h b/src/txt-converter/common/mmo.h index e8ef2b987..28462e99d 100644 --- a/src/txt-converter/common/mmo.h +++ b/src/txt-converter/common/mmo.h @@ -135,14 +135,14 @@ struct storage { int account_id; short storage_status; short storage_amount; - struct item storage[MAX_STORAGE]; + struct item storage_[MAX_STORAGE]; }; struct guild_storage { int guild_id; short storage_status; short storage_amount; - struct item storage[MAX_GUILD_STORAGE]; + struct item storage_[MAX_GUILD_STORAGE]; }; struct map_session_data; -- cgit v1.2.3-70-g09d2 From 56f8c49f065831c21156dd88bd5397b6ba355813 Mon Sep 17 00:00:00 2001 From: celest Date: Wed, 30 Mar 2005 17:10:03 +0000 Subject: * Added base code for loading Ser's UPNP plugin * Added 'idle_no_share' to battle_athena.conf * Added item_findingore.txt git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1343 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 3 +++ conf-tmpl/battle_athena.conf | 3 +++ db/item_findingore.txt | 24 ++++++++++++++++++++ src/common/socket.c | 48 ++++++++++++++++++++++++++++++++++++++- src/map/battle.c | 2 ++ src/map/battle.h | 1 + src/map/itemdb.c | 16 +++++++------ src/map/mob.c | 5 ++-- src/map/party.c | 26 ++++++++++----------- src/map/skill.c | 54 ++++++++++++++++++++------------------------ 10 files changed, 129 insertions(+), 53 deletions(-) create mode 100644 db/item_findingore.txt (limited to 'src/common/socket.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 316f0d8c3..28da82c4b 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,6 +2,8 @@ Date Added 03/30 + * Added base code for loading Ser's UPNP plugin [celest] + * Added 'idle_no_share' to battle_athena.conf [celest] * updated map server to jA1137~1159 - Added @reloadatcommand, @reloadbattleconf, @reloadstatusdb, @reloadpcdb @@ -16,6 +18,7 @@ Date Added - Updated Hammerfall, Meteor Shower and Lord of Vermillion -- when MvP's cast them they should have much more range - Some other skill tweaks + - Added item_findingore.txt * Some tidying up in mob.c and skill.c [celest] 03/29 diff --git a/conf-tmpl/battle_athena.conf b/conf-tmpl/battle_athena.conf index 5663bc4e6..a92f27c4e 100644 --- a/conf-tmpl/battle_athena.conf +++ b/conf-tmpl/battle_athena.conf @@ -823,5 +823,8 @@ exp_calc_type: 1 // P.S 2: This skill is not implemented on official servers, so its only optional require_glory_guild: no +// Is exp sharing disabled for idle members in the party? +idle_no_share: no + import: conf/import/battle_conf.txt diff --git a/db/item_findingore.txt b/db/item_findingore.txt new file mode 100644 index 000000000..d14d14f29 --- /dev/null +++ b/db/item_findingore.txt @@ -0,0 +1,24 @@ +// 鉱石発見スキルでドロップされる鉱石 +// item ID, Jname (dummy), 確率を 1 万倍 (100% なら 1000000) +// 0 はデフォルト項目 +0,Iron Ore,1002 +714,Emperium,30000 +756,Rough Oridecon,200000 +757,Rough Elunium,200000 +969,Gold,20000 +984,Oridecon,100000 +985,Elunium,100000 +990,Red Blood,300000 +991,Crystal Blue,300000 +992,Wind of Verdure,300000 +993,Green Live,300000 +994,Flame Heart,150000 +995,Mystic Frozen,150000 +996,Rough Wind,150000 +997,Great Nature,150000 +998,Iron,800000 +999,Steel,500000 +1002,Iron Ore,1000000 +1003,Coal,600000 +1010,Phracon,950000 +1011,Emveretarcon,550000 \ No newline at end of file diff --git a/src/common/socket.c b/src/common/socket.c index 70432eddf..5dd2e38f9 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -38,6 +38,20 @@ typedef int socklen_t; #include "memwatch.h" #endif +#ifdef UPNP + #if defined(CYGWIN) + #include + #elif _WIN32 + // windows.h already included + #else + #error This doesnt work with non-Windows yet + #endif + + void *upnp_dll; + void (*upnp_init)(); + void (*upnp_final)(); +#endif + fd_set readfds; int fd_max; time_t tick_; @@ -920,6 +934,27 @@ int Net_Init(void) return(0); } +#ifdef UPNP +// not implemented yet ^^; +void do_init_upnp(void) +{ + upnp_dll = dlopen("upnp.dll", RTLD_NOW); + if (!upnp_dll) { + printf ("Cannot open upnp.dll: %s\n", dlerror()); + return; + } + upnp_init = (void *)dlsym(upnp_dll, "do_init"); + upnp_final = (void *)dlsym(upnp_dll, "do_final"); + if (!upnp_init || !upnp_final) { + printf ("Cannot load symbol: %s\n", dlerror()); + dlclose (upnp_dll); + return; + } + upnp_init(); + return; +} +#endif + void do_final_socket(void) { int i; @@ -945,7 +980,14 @@ void do_final_socket(void) // session[0] のダミーデータを削除 aFree(session[0]->rdata); aFree(session[0]->wdata); - aFree(session[0]); + aFree(session[0]); + +#ifdef UPNP + if (upnp_final) + upnp_final(); + if (upnp_dll) + dlclose(upnp_dll); +#endif } void do_socket(void) @@ -966,4 +1008,8 @@ void do_socket(void) // とりあえず5分ごとに不要なデータを削除する add_timer_interval(gettick()+1000,connect_check_clear,0,0,300*1000); + +#ifdef UPNP + do_init_upnp(); +#endif } diff --git a/src/map/battle.c b/src/map/battle.c index aa30ef0a9..421f85ec3 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -4202,6 +4202,7 @@ static const struct { { "exp_calc_type", &battle_config.exp_calc_type}, // [celest] { "min_skill_delay_limit", &battle_config.min_skill_delay_limit}, // [celest] { "require_glory_guild", &battle_config.require_glory_guild}, // [celest] + { "idle_no_share", &battle_config.idle_no_share}, // [celest], for a feature by [MouseJstr] //SQL-only options start #ifndef TXT_ONLY @@ -4450,6 +4451,7 @@ void battle_set_defaults() { battle_config.exp_calc_type = 1; battle_config.min_skill_delay_limit = 100; battle_config.require_glory_guild = 0; + battle_config.idle_no_share = 0; //SQL-only options start #ifndef TXT_ONLY diff --git a/src/map/battle.h b/src/map/battle.h index 3bb9068bf..393cc58b4 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -312,6 +312,7 @@ extern struct Battle_Config { int exp_calc_type; int min_skill_delay_limit; int require_glory_guild; + int idle_no_share; #ifndef TXT_ONLY /* SQL-only options */ int mail_system; // [Valaris] diff --git a/src/map/itemdb.c b/src/map/itemdb.c index d575e8a77..91ec58c81 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -26,9 +26,9 @@ static struct dbt* item_db; -static struct random_item_data blue_box[MAX_RANDITEM],violet_box[MAX_RANDITEM],card_album[MAX_RANDITEM],gift_box[MAX_RANDITEM],scroll[MAX_RANDITEM]; -static int blue_box_count=0,violet_box_count=0,card_album_count=0,gift_box_count=0,scroll_count=0; -static int blue_box_default=0,violet_box_default=0,card_album_default=0,gift_box_default=0,scroll_default=0; +static struct random_item_data blue_box[MAX_RANDITEM], violet_box[MAX_RANDITEM], card_album[MAX_RANDITEM], gift_box[MAX_RANDITEM], scroll[MAX_RANDITEM], finding_ore[MAX_RANDITEM]; +static int blue_box_count=0, violet_box_count=0, card_album_count=0, gift_box_count=0, scroll_count=0, finding_ore_count = 0; +static int blue_box_default=0, violet_box_default=0, card_album_default=0, gift_box_default=0, scroll_default=0, finding_ore_default = 0; // Function declarations @@ -102,7 +102,7 @@ int itemdb_searchrandomid(int flags) struct { int nameid,count; struct random_item_data *list; - } data[6]; + } data[7]; // for BCC32 compile error data[0].nameid = 0; data[0].count = 0; data[0].list = NULL; @@ -111,8 +111,9 @@ int itemdb_searchrandomid(int flags) data[3].nameid = card_album_default; data[3].count = card_album_count; data[3].list = card_album; data[4].nameid = gift_box_default; data[4].count = gift_box_count; data[4].list = gift_box; data[5].nameid = scroll_default; data[5].count = scroll_count; data[5].list = scroll; + data[6].nameid = finding_ore_default; data[6].count = finding_ore_count; data[6].list = finding_ore; - if(flags>=1 && flags<=5){ + if(flags>=1 && flags<=6){ nameid=data[flags].nameid; count=data[flags].count; list=data[flags].list; @@ -410,8 +411,9 @@ static int itemdb_read_randomitem() {"db/item_bluebox.txt", blue_box, &blue_box_count, &blue_box_default }, {"db/item_violetbox.txt", violet_box, &violet_box_count, &violet_box_default }, {"db/item_cardalbum.txt", card_album, &card_album_count, &card_album_default }, - {"db/item_giftbox.txt", gift_box, &gift_box_count, &gift_box_default }, - {"db/item_scroll.txt", scroll, &scroll_count, &scroll_default }, + {"db/item_giftbox.txt", gift_box, &gift_box_count, &gift_box_default }, + {"db/item_scroll.txt", scroll, &scroll_count, &scroll_default }, + {"db/item_findingore.txt", finding_ore,&finding_ore_count, &finding_ore_default }, }; for(i=0;i0 && battle_config.finding_ore_rate/100 >= rand()%1000) { + if (sd == mvp_sd && pc_checkskill(sd,BS_FINDINGORE)>0 && battle_config.finding_ore_rate/100 >= rand()%1000) { struct delay_item_drop *ditem; - int itemid[17] = { 714, 756, 757, 969, 984, 985, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1002 }; ditem=(struct delay_item_drop *)aCalloc(1,sizeof(struct delay_item_drop)); - ditem->nameid = itemid[rand()%17]; //should return from 0 to 16 + ditem->nameid = itemdb_searchrandomid(6); if (drop_ore<0) i=8; //we have only 10 slots in LOG, there's a check to not overflow (9th item usually a card, so we use 8th slot) log_item[i] = ditem->nameid; //it's for logging only drop_items++; //we cound if there were any drops diff --git a/src/map/party.c b/src/map/party.c index 17f0cf5eb..7eb3f02dc 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -586,23 +586,23 @@ int party_exp_share(struct party *p,int map,int base_exp,int job_exp,int zeny) nullpo_retr(0, p); - for(i=c=0;imember[i].sd)!=NULL && p->member[i].online && sd->bl.m==map && session[sd->fd] != NULL) + for (i=c=0; i < MAX_PARTY; i++) + if ((sd = p->member[i].sd) != NULL && p->member[i].online && sd->bl.m == map /*&& session[sd->fd] != NULL*/) // should be done in socket.c c++; - - if(c==0) + + if(c == 0) return 0; - for(i=0;imember[i].sd)!=NULL && p->member[i].online && sd->bl.m==map && session[sd->fd] != NULL) { - if (/* pc_issit(sd) || */ sd->chatID || (sd->idletime < (tick_ - 120))) + for (i = 0; i < MAX_PARTY; i++) + if ((sd = p->member[i].sd) != NULL && p->member[i].online && sd->bl.m == map /*&& session[sd->fd] != NULL*/) { + if (battle_config.idle_no_share && (/* pc_issit(sd) || */ sd->chatID || (sd->idletime < (tick_ - 120)))) continue; -#ifdef TWILIGHT + #ifdef TWILIGHT pc_gainexp(sd,base_exp,job_exp); -#else - pc_gainexp(sd,base_exp/c+1,job_exp/c+1); -#endif - if(battle_config.zeny_from_mobs) // zeny from mobs [Valaris] - pc_getzeny(sd,zeny/c+1); + #else + pc_gainexp(sd,(base_exp/c)+1,(job_exp/c)+1); + #endif + if (battle_config.zeny_from_mobs) // zeny from mobs [Valaris] + pc_getzeny(sd,(zeny/c)+1); } return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index 40626fa57..b6010f151 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -608,8 +608,8 @@ int skillnotok(int skillid, struct map_session_data *sd) return 1; } - if (pc_isGM(sd) >= 20) - return 0; // gm's can do anything damn thing they want + if (pc_isGM(sd) >= 20) + return 0; // gm's can do anything damn thing they want // Check skill restrictions [Celest] if(!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.gvg && skill_get_nocast (skillid) & 1) @@ -630,7 +630,7 @@ int skillnotok(int skillid, struct map_session_data *sd) case MC_IDENTIFY: return 0; // always allowed default: - return(map[sd->bl.m].flag.noskill); + return (map[sd->bl.m].flag.noskill); } } @@ -639,9 +639,9 @@ static int distance(int x0,int y0,int x1,int y1) { int dx,dy; - dx=abs(x0-x1); - dy=abs(y0-y1); - return dx>dy ? dx : dy; + dx = abs(x0 - x1); + dy = abs(y0 - y1); + return dx > dy ? dx : dy; } /* スキルユニットの配置情報を返す */ @@ -649,26 +649,25 @@ struct skill_unit_layout skill_unit_layout[MAX_SKILL_UNIT_LAYOUT]; int firewall_unit_pos; int icewall_unit_pos; -struct skill_unit_layout *skill_get_unit_layout(int skillid,int skilllv,struct block_list *src,int x,int y) -{ - +struct skill_unit_layout *skill_get_unit_layout (int skillid, int skilllv, struct block_list *src, int x, int y) +{ int pos = skill_get_unit_layout_type(skillid,skilllv); int dir; - if (pos!=-1) + if (pos != -1) return &skill_unit_layout[pos]; - if (src->x==x && src->y==y) + if (src->x == x && src->y == y) dir = 2; else dir = map_calc_dir(src,x,y); - if (skillid==MG_FIREWALL) - return &skill_unit_layout[firewall_unit_pos+dir]; - else if (skillid==WZ_ICEWALL) - return &skill_unit_layout[icewall_unit_pos+dir]; + if (skillid == MG_FIREWALL) + return &skill_unit_layout [firewall_unit_pos + dir]; + else if (skillid == WZ_ICEWALL) + return &skill_unit_layout [icewall_unit_pos + dir]; - printf("unknown unit layout for skill %d, %d\n",skillid,skilllv); + printf("Unknown unit layout for skill %d, %d\n",skillid,skilllv); return &skill_unit_layout[0]; } @@ -691,7 +690,7 @@ struct skill_unit_layout *skill_get_unit_layout(int skillid,int skilllv,struct b * スキル追加?果 *------------------------------------------ */ -int skill_additional_effect( struct block_list* src, struct block_list *bl,int skillid,int skilllv,int attack_type,unsigned int tick) +int skill_additional_effect (struct block_list* src, struct block_list *bl, int skillid, int skilllv, int attack_type, unsigned int tick) { /* MOB追加?果スキル用 */ const int sc[]={ @@ -825,8 +824,9 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s case WZ_FROSTNOVA: /* フロストノヴァ */ { struct status_change *sc_data = status_get_sc_data(bl); - rate=(skilllv*3+35)*sc_def_mdef/100-(status_get_int(bl)+status_get_luk(bl))/15; - rate=rate<=5?5:rate; + rate = (skilllv*3+35)*sc_def_mdef/100-(status_get_int(bl)+status_get_luk(bl))/15; + if (rate <= 5) + rate = 5; if(sc_data && sc_data[SC_FREEZE].timer == -1 && rand()%100 < rate) status_change_start(bl,SC_FREEZE,skilllv,0,0,0,skill_get_time2(skillid,skilllv)*(1-sc_def_mdef/100),0); else if (sd && skillid == MG_FROSTDIVER) @@ -2384,9 +2384,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case SM_MAGNUM: /* マグナムブレイク [celest] */ if(flag&1 && bl->id != skill_area_temp[1]){ - int dx = abs( bl->x - skill_area_temp[2] ); - int dy = abs( bl->y - skill_area_temp[3] ); - int dist = ((dx>dy)?dx:dy); + int dist = distance (bl->x, bl->y, skill_area_temp[2], skill_area_temp[3]); skill_attack(BF_WEAPON,src,src,bl,skillid,skilllv,tick, 0x0500|dist); } else { @@ -2514,18 +2512,16 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case MG_NAPALMBEAT: /* ナパ?ムビ?ト */ case MG_FIREBALL: /* ファイヤ?ボ?ル */ case WZ_SIGHTRASHER: /* サイトラッシャー */ - if(flag&1){ + if (flag & 1) { /* 個別にダメ?ジを?える */ - if(bl->id!=skill_area_temp[1]){ - if(skillid==MG_FIREBALL){ /* ファイヤ?ボ?ルなら中心からの距離を計算 */ - int dx=abs( bl->x - skill_area_temp[2] ); - int dy=abs( bl->y - skill_area_temp[3] ); - skill_area_temp[0]=((dx>dy)?dx:dy); + if (bl->id != skill_area_temp[1]){ + if(skillid == MG_FIREBALL){ /* ファイヤ?ボ?ルなら中心からの距離を計算 */ + skill_area_temp[0] = distance(bl->x, bl->y, skill_area_temp[2], skill_area_temp[3]); } skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick, skill_area_temp[0]| 0x0500); } - }else{ + } else { int ar; skill_area_temp[0]=0; skill_area_temp[1]=bl->id; -- cgit v1.2.3-70-g09d2 From 177e5a3af1b7b421c027dfc06abc6e6b8ca10e28 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 4 Apr 2005 14:24:07 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1397 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 79 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 18 deletions(-) (limited to 'src/common/socket.c') diff --git a/src/common/socket.c b/src/common/socket.c index 5dd2e38f9..7178c95e2 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -38,26 +38,45 @@ typedef int socklen_t; #include "memwatch.h" #endif +fd_set readfds; +int fd_max; +time_t tick_; +time_t stall_time_ = 60; +int ip_rules = 1; + +#define UPNP #ifdef UPNP #if defined(CYGWIN) + #include + void *upnp_dll; + int (*upnp_init)(); + int (*upnp_final)(); + int (*firewall_addport)(char *desc, int port); + int (*upnp_addport)(char *desc, char *ip, int port); + #define DLL_OPEN(x) dlopen(x,RTLD_NOW) + #define DLL_SYM(x,y,z) x=(void *)dlsym(y,z) + #define DLL_CLOSE(x) dlclose(x) + #elif _WIN32 + // windows.h already included + HINSTANCE upnp_dll; + int (WINAPI* upnp_init)(); + int (WINAPI* upnp_final)(); + int (WINAPI* firewall_addport)(char *desc, int port); + int (WINAPI* upnp_addport)(char *desc, char *ip, int port); + #define DLL_OPEN(x) LoadLibrary(x) + #define DLL_SYM(x,y,z) (FARPROC)x=GetProcAddress(y,z) + #define DLL_CLOSE(x) FreeLibrary(x) + #else #error This doesnt work with non-Windows yet #endif - void *upnp_dll; - void (*upnp_init)(); - void (*upnp_final)(); + extern char server_type[24]; #endif -fd_set readfds; -int fd_max; -time_t tick_; -time_t stall_time_ = 60; -int ip_rules = 1; - int rfifo_size = 65536; int wfifo_size = 65536; @@ -318,6 +337,23 @@ int make_listen_bind(long ip,int port) server_address.sin_addr.s_addr = ip; server_address.sin_port = htons((unsigned short)port); +#ifdef UPNP + if (upnp_dll) { + int localaddr = ntohl(addr_[0]); + unsigned char *natip = (unsigned char *)&localaddr; + char buf[16]; + sprintf(buf, "%d.%d.%d.%d", natip[0], natip[1], natip[2], natip[3]); + //printf("natip=%d.%d.%d.%d\n", natip[0], natip[1], natip[2], natip[3]); + if (firewall_addport(server_type, port)) + printf ("Firewall port %d successfully opened\n", port); + if (natip[0] == 192 && natip[1] == 168) { + if (upnp_addport(server_type, natip, port)) + printf ("Upnp mappings successfull\n"); + else printf ("Upnp mapping failed\n"); + } + } +#endif + result = bind(fd, (struct sockaddr*)&server_address, sizeof(server_address)); if( result == -1 ) { perror("bind"); @@ -938,19 +974,26 @@ int Net_Init(void) // not implemented yet ^^; void do_init_upnp(void) { - upnp_dll = dlopen("upnp.dll", RTLD_NOW); + upnp_dll = DLL_OPEN ("upnp.dll"); if (!upnp_dll) { printf ("Cannot open upnp.dll: %s\n", dlerror()); return; } - upnp_init = (void *)dlsym(upnp_dll, "do_init"); - upnp_final = (void *)dlsym(upnp_dll, "do_final"); - if (!upnp_init || !upnp_final) { + DLL_SYM (upnp_init, upnp_dll, "do_init"); + DLL_SYM (upnp_final, upnp_dll, "do_final"); + DLL_SYM (firewall_addport, upnp_dll, "Firewall_AddPort"); + DLL_SYM (upnp_addport, upnp_dll, "UPNP_AddPort"); + if (!upnp_init || !upnp_final || !firewall_addport || !upnp_addport) { printf ("Cannot load symbol: %s\n", dlerror()); - dlclose (upnp_dll); + DLL_CLOSE (upnp_dll); + upnp_dll = NULL; return; } - upnp_init(); + if (upnp_init() == 0) { + printf ("Error initialising upnp.dll, unloading...\n"); + DLL_CLOSE (upnp_dll); + upnp_dll = NULL; + } return; } #endif @@ -983,10 +1026,10 @@ void do_final_socket(void) aFree(session[0]); #ifdef UPNP - if (upnp_final) + if (upnp_dll) { upnp_final(); - if (upnp_dll) - dlclose(upnp_dll); + DLL_CLOSE(upnp_dll); + } #endif } -- cgit v1.2.3-70-g09d2 From 7b57637c32ea9c179c4fa694a98afc64e4922e56 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 4 Apr 2005 14:48:14 +0000 Subject: * Added dll.h * Update base code for the UPNP plugin loading git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1398 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 1 + src/common/Makefile | 2 +- src/common/dll.h | 25 +++++++++++++++++++++++++ src/common/socket.c | 26 ++++---------------------- 4 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 src/common/dll.h (limited to 'src/common/socket.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 3ce650e1b..de6743659 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,6 +2,7 @@ Date Added 04/04 + * Update base code for the UPNP plugin loading [celest] * Removed anti-freeze system for login and char -- Shinomori's update would be enough to keep inter connections alive [celest] diff --git a/src/common/Makefile b/src/common/Makefile index c90940b94..7a00c5a3c 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -9,7 +9,7 @@ obj/%.o: %.c $(COMPILE.c) $(OUTPUT_OPTION) $< obj/core.o: core.c core.h showmsg.h -obj/socket.o: socket.c socket.h mmo.h showmsg.h +obj/socket.o: socket.c socket.h mmo.h showmsg.h dll.h obj/timer.o: timer.c timer.h showmsg.h obj/grfio.o: grfio.c grfio.h showmsg.h obj/db.o: db.c db.h showmsg.h diff --git a/src/common/dll.h b/src/common/dll.h new file mode 100644 index 000000000..ec6f8cbed --- /dev/null +++ b/src/common/dll.h @@ -0,0 +1,25 @@ + +#ifndef _DLL_H_ +#define _DLL_H_ + +#ifdef _WIN32 + + #include + #define DLL_OPEN(x) LoadLibrary(x) + #define DLL_SYM(x,y,z) (FARPROC)x=GetProcAddress(y,z) + #define DLL_CLOSE(x) FreeLibrary(x) + #define DLL HINSTANCE + +#else + + #include + #define DLL_OPEN(x) dlopen(x,RTLD_NOW) + #define DLL_SYM(x,y,z) x=(void *)dlsym(y,z) + #define DLL_CLOSE(x) dlclose(x) + #define DLL void* + +#endif + +#endif // _DLL_H_ + + diff --git a/src/common/socket.c b/src/common/socket.c index 7178c95e2..6c7d873e0 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -30,6 +30,7 @@ typedef int socklen_t; #include #include "socket.h" +#include "../common/dll.h" #include "../common/mmo.h" // [Valaris] thanks to fov #include "../common/timer.h" #include "../common/utils.h" @@ -46,35 +47,16 @@ int ip_rules = 1; #define UPNP #ifdef UPNP - #if defined(CYGWIN) - - #include - void *upnp_dll; + #if defined(CYGWIN) || defined(_WIN32) + DLL upnp_dll; int (*upnp_init)(); int (*upnp_final)(); int (*firewall_addport)(char *desc, int port); int (*upnp_addport)(char *desc, char *ip, int port); - #define DLL_OPEN(x) dlopen(x,RTLD_NOW) - #define DLL_SYM(x,y,z) x=(void *)dlsym(y,z) - #define DLL_CLOSE(x) dlclose(x) - - #elif _WIN32 - - // windows.h already included - HINSTANCE upnp_dll; - int (WINAPI* upnp_init)(); - int (WINAPI* upnp_final)(); - int (WINAPI* firewall_addport)(char *desc, int port); - int (WINAPI* upnp_addport)(char *desc, char *ip, int port); - #define DLL_OPEN(x) LoadLibrary(x) - #define DLL_SYM(x,y,z) (FARPROC)x=GetProcAddress(y,z) - #define DLL_CLOSE(x) FreeLibrary(x) - + extern char server_type[24]; #else #error This doesnt work with non-Windows yet #endif - - extern char server_type[24]; #endif int rfifo_size = 65536; -- cgit v1.2.3-70-g09d2 From af1ad6e424c5b9c0aefd402e276a9743174028a2 Mon Sep 17 00:00:00 2001 From: amber Date: Mon, 4 Apr 2005 17:52:53 +0000 Subject: pull out upnp as default git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1402 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/common/socket.c') diff --git a/src/common/socket.c b/src/common/socket.c index 6c7d873e0..2daf00764 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -45,18 +45,19 @@ time_t tick_; time_t stall_time_ = 60; int ip_rules = 1; -#define UPNP +// #define UPNP + #ifdef UPNP - #if defined(CYGWIN) || defined(_WIN32) - DLL upnp_dll; - int (*upnp_init)(); - int (*upnp_final)(); - int (*firewall_addport)(char *desc, int port); - int (*upnp_addport)(char *desc, char *ip, int port); - extern char server_type[24]; - #else - #error This doesnt work with non-Windows yet - #endif +#if defined(CYGWIN) || defined(_WIN32) +DLL upnp_dll; +int (*upnp_init)(); +int (*upnp_final)(); +int (*firewall_addport)(char *desc, int port); +int (*upnp_addport)(char *desc, char *ip, int port); +extern char server_type[24]; +#else +#error This doesnt work with non-Windows yet +#endif #endif int rfifo_size = 65536; -- cgit v1.2.3-70-g09d2 From 573c40f53e1d0fe29c72117fc4ca2d931b274d8c Mon Sep 17 00:00:00 2001 From: celest Date: Tue, 5 Apr 2005 14:32:04 +0000 Subject: * Added SERVER_TYPE to core for future plugins support * Added support for the UPNP plugin to release port mappings and re-close firewall ports on shutdown * Updated showmsg git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1409 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/core.c | 42 ++++++++++++++++++---------------- src/common/core.h | 10 +++++++- src/common/showmsg.c | 64 ++++++++++++++++++++++++---------------------------- src/common/showmsg.h | 13 ++++++++++- src/common/socket.c | 34 +++++++++++++++++++++++++--- 5 files changed, 104 insertions(+), 59 deletions(-) (limited to 'src/common/socket.c') diff --git a/src/common/core.c b/src/common/core.c index b325b96e4..0a9e76120 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -14,20 +14,21 @@ #endif #endif -#include "../common/mmo.h" -#include "malloc.h" #include "core.h" -#include "socket.h" -#include "timer.h" -#include "version.h" -#include "showmsg.h" +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/version.h" +#include "../common/showmsg.h" #ifdef MEMWATCH #include "memwatch.h" #endif -char server_type[24]; +char *argp; int runflag = 1; +char SERVER_TYPE = SERVER_NONE; unsigned long ticks = 0; // by MC Cameri char pid_file[256]; static void (*term_func)(void)=NULL; @@ -132,7 +133,7 @@ void sig_dump(int sn) // search for a usable filename do { - sprintf (file, "log/%s%04d.stackdump", server_type, ++no); + sprintf (file, "log/%s%04d.stackdump", argp, ++no); } while((fp = fopen(file,"r")) && (fclose(fp), no < 9999)); // dump the trace into the file @@ -171,12 +172,13 @@ int get_svn_revision(char *svnentry) { // Warning: minor syntax checking if ((fp = fopen(svnentry, "r")) == NULL) { return 0; } else { - while (fgets(line,1023,fp)) if (strstr(line,"revision=")) break; + while (fgets(line,1023,fp)) + if (strstr(line,"revision=")) break; fclose(fp); - if (sscanf(line," %*[^\"]\"%d%*[^\n]",&rev)==1) - return rev; + if (sscanf(line," %*[^\"]\"%d%*[^\n]",&rev) == 1) + return rev; else - return 0; + return 0; } // return 0; } @@ -273,7 +275,7 @@ void log_uptime(void) seconds -= (seconds/minute>0)?(seconds/minute)*minute:0; fprintf(fp, "%s: %s uptime - %ld days, %ld hours, %ld minutes, %ld seconds.\n", - curtime2, server_type, days, hours, minutes, seconds); + curtime2, argp, days, hours, minutes, seconds); fclose(fp); } @@ -285,14 +287,15 @@ int main(int argc,char **argv) { int next; - display_title(); - // call this first so it'll be finalised last - do_init_memmgr(argv[0]); // 一番最初に実行する必要がある + if ((argp = strstr(argv[0], "./")) != NULL) + argp+=2; + else argp = argv[0]; - sscanf(argv[0], "./%24[^\n]", server_type); // map/char/login? - atexit(log_uptime); - pid_create(argv[0]); + display_title(); + do_init_memmgr(argp); // 一番最初に実行する必要がある + atexit(log_uptime); + pid_create(argp); Net_Init(); do_socket(); @@ -313,6 +316,7 @@ int main(int argc,char **argv) ticks = gettick(); do_init(argc,argv); + while(runflag){ next=do_timer(gettick_nocache()); do_sendrecv(next); diff --git a/src/common/core.h b/src/common/core.h index 23431f297..e9b5c8227 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -3,11 +3,19 @@ #ifndef _CORE_H_ #define _CORE_H_ +extern char *argp; extern int runflag; extern unsigned long ticks; +extern char SERVER_TYPE; -int do_init(int,char**); +enum { + SERVER_NONE, + SERVER_LOGIN, + SERVER_CHAR, + SERVER_MAP, +}; +int do_init(int,char**); void set_termfunc(void (*termfunc)(void)); #endif // _CORE_H_ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 9901af81b..24d51d2dc 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -5,15 +5,12 @@ char tmp_output[1024] = {"\0"}; -#undef ShowMessage - // by MC Cameri int _vShowMessage(enum msg_type flag, const char *string, va_list ap) { // _ShowMessage MUST be used instead of printf as of 10/24/2004. // Return: 0 = Successful, 1 = Failed. // int ret = 0; -// char *output; char prefix[40]; if (!string || strlen(string) <= 0) { @@ -21,6 +18,8 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) return 1; } switch (flag) { + case MSG_NONE: // direct printf replacement + break; case MSG_STATUS: //Bright Green (To inform about good things) strcpy(prefix,CL_GREEN"[Status]"CL_RESET":"); break; @@ -49,22 +48,10 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) printf("In function _ShowMessage() -> Invalid flag passed.\n"); return 1; } - if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { - -/* output = (char*)aMalloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) - if (output == NULL) { - return 1; -// exit(1); // Kill server? Deadly - } - strcpy(output,prefix); - strcat(output," "); - strcat(output,string); - vprintf(output, ap); - fflush(stdout); - aFree(output);*/ - - printf ("%s ", prefix); + if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { + if (flag != MSG_NONE) + printf ("%s ", prefix); vprintf (string, ap); fflush (stdout); } @@ -96,51 +83,58 @@ int _ShowMessage(enum msg_type flag, const char *string, ...) return _vShowMessage(flag, string, ap); } +// direct printf replacement +int ShowMessage(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_NONE, string, ap); +} int ShowStatus(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_STATUS, string, ap); + return _vShowMessage(MSG_STATUS, string, ap); } int ShowSQL(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_SQL, string, ap); + return _vShowMessage(MSG_SQL, string, ap); } int ShowInfo(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_INFORMATION, string, ap); + return _vShowMessage(MSG_INFORMATION, string, ap); } int ShowNotice(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_NOTICE, string, ap); + return _vShowMessage(MSG_NOTICE, string, ap); } int ShowWarning(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_WARNING, string, ap); + return _vShowMessage(MSG_WARNING, string, ap); } int ShowDebug(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_DEBUG, string, ap); + return _vShowMessage(MSG_DEBUG, string, ap); } int ShowError(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_ERROR, string, ap); + return _vShowMessage(MSG_ERROR, string, ap); } int ShowFatalError(const char *string, ...) { - va_list ap; - + va_list ap; + va_start(ap, string); - return _vShowMessage(MSG_FATALERROR, string, ap); + return _vShowMessage(MSG_FATALERROR, string, ap); } diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 3461369c3..b5f4d4bfd 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -32,8 +32,19 @@ extern char tmp_output[1024]; -enum msg_type {MSG_STATUS, MSG_SQL, MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_DEBUG,MSG_ERROR,MSG_FATALERROR}; +enum msg_type { + MSG_NONE, + MSG_STATUS, + MSG_SQL, + MSG_INFORMATION, + MSG_NOTICE, + MSG_WARNING, + MSG_DEBUG, + MSG_ERROR, + MSG_FATALERROR +}; +extern int ShowMessage(const char *, ...); extern int ShowStatus(const char *, ...); extern int ShowSQL(const char *, ...); extern int ShowInfo(const char *, ...); diff --git a/src/common/socket.c b/src/common/socket.c index 2daf00764..64f660a11 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -54,7 +54,10 @@ int (*upnp_init)(); int (*upnp_final)(); int (*firewall_addport)(char *desc, int port); int (*upnp_addport)(char *desc, char *ip, int port); -extern char server_type[24]; +extern char *argp; + +int release_mappings = 1; +int close_ports = 1; #else #error This doesnt work with non-Windows yet #endif @@ -327,10 +330,10 @@ int make_listen_bind(long ip,int port) char buf[16]; sprintf(buf, "%d.%d.%d.%d", natip[0], natip[1], natip[2], natip[3]); //printf("natip=%d.%d.%d.%d\n", natip[0], natip[1], natip[2], natip[3]); - if (firewall_addport(server_type, port)) + if (firewall_addport(argp, port)) printf ("Firewall port %d successfully opened\n", port); if (natip[0] == 192 && natip[1] == 168) { - if (upnp_addport(server_type, natip, port)) + if (upnp_addport(argp, natip, port)) printf ("Upnp mappings successfull\n"); else printf ("Upnp mapping failed\n"); } @@ -845,6 +848,20 @@ int socket_config_read(const char *cfgName) { else if(strcmpi(w2,"no")==0) access_debug = 0; else access_debug = atoi(w2); + #ifdef UPNP + } else if(!strcmpi(w1,"release_mappings")){ + if(strcmpi(w2,"yes")==0) + release_mappings = 1; + else if(strcmpi(w2,"no")==0) + release_mappings = 0; + else release_mappings = atoi(w2); + } else if(!strcmpi(w1,"close_ports")){ + if(strcmpi(w2,"yes")==0) + close_ports = 1; + else if(strcmpi(w2,"no")==0) + close_ports = 0; + else close_ports = atoi(w2); + #endif } else if (strcmpi(w1, "import") == 0) socket_config_read(w2); } @@ -957,6 +974,9 @@ int Net_Init(void) // not implemented yet ^^; void do_init_upnp(void) { + int *_release_mappings; + int *_close_ports; + upnp_dll = DLL_OPEN ("upnp.dll"); if (!upnp_dll) { printf ("Cannot open upnp.dll: %s\n", dlerror()); @@ -972,6 +992,14 @@ void do_init_upnp(void) upnp_dll = NULL; return; } + + DLL_SYM (_release_mappings, upnp_dll, "release_mappings"); + DLL_SYM (_close_ports, upnp_dll, "close_ports"); + if (release_mappings && _release_mappings) + *_release_mappings = release_mappings; + if (close_ports && _close_ports) + *_close_ports = close_ports; + if (upnp_init() == 0) { printf ("Error initialising upnp.dll, unloading...\n"); DLL_CLOSE (upnp_dll); -- cgit v1.2.3-70-g09d2