From e4e674473518ab7e513639f19963174b7697dade Mon Sep 17 00:00:00 2001 From: amber Date: Sun, 5 Dec 2004 16:57:37 +0000 Subject: Updates git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@468 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9317bdcf8..dc27eed45 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ OS_TYPE = -DCYGWIN CFLAGS = $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) else OS_TYPE = -CFLAGS = $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = -DTWILIGHT $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) endif MYSQLFLAG_INCLUDE_DEFAULT = /usr/local/include/mysql -- cgit v1.2.3-70-g09d2 From d5fb1ce08e0d2c57b952416ac71d0badef16adc0 Mon Sep 17 00:00:00 2001 From: amber Date: Thu, 16 Dec 2004 03:39:48 +0000 Subject: oops git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@579 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index dc27eed45..9317bdcf8 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ OS_TYPE = -DCYGWIN CFLAGS = $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) else OS_TYPE = -CFLAGS = -DTWILIGHT $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) endif MYSQLFLAG_INCLUDE_DEFAULT = /usr/local/include/mysql -- cgit v1.2.3-70-g09d2 From 52d4357afb7fcf69e7163b4d2b8dd368c30c6656 Mon Sep 17 00:00:00 2001 From: amber Date: Thu, 16 Dec 2004 03:55:53 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@580 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 ++ Makefile | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index e5b404038..78d61bc53 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,7 @@ Date Added 12/16 + * Fixed a misuse of mysql_config (thanks Daegalus for + creating a reproducable environment for me) [MouseJstr] * Fixed compile time errors for gcc 2.95 [MouseJstr] * Added #itemlist, removed @charitemlist [MC Cameri] * Changed @job and #job so that when it's used it unequips all the items, to prevent sprite errors [MC Cameri] diff --git a/Makefile b/Makefile index 9317bdcf8..e6b79229e 100644 --- a/Makefile +++ b/Makefile @@ -34,10 +34,10 @@ ifeq ($(findstring /,$(MYSQLFLAG_CONFIG)), /) MYSQLFLAG_VERSION = $(shell $(MYSQLFLAG_CONFIG) --version | sed s:\\..*::) endif -ifeq ($(findstring 5,$(MYSQLFLAG_VERSION)), 5) -MYSQLFLAG_CONFIG_ARGUMENT = --include -endif ifeq ($(findstring 4,$(MYSQLFLAG_VERSION)), 4) +MYSQLFLAG_CONFIG_ARGUMENT = --cflags +endif +ifeq ($(findstring 5,$(MYSQLFLAG_VERSION)), 5) MYSQLFLAG_CONFIG_ARGUMENT = --include endif ifndef MYSQLFLAG_CONFIG_ARGUMENT -- cgit v1.2.3-70-g09d2 From 5a00db39c2eaf410292ae86d8b4f356ffa81e5dd Mon Sep 17 00:00:00 2001 From: amber Date: Fri, 17 Dec 2004 04:42:48 +0000 Subject: more updates git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@590 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 3 +++ Makefile | 1 + conf-tmpl/battle_athena.conf | 3 ++- src/map/atcommand.c | 42 +++++++++++++++++++++++++++++++++++++++++- src/map/atcommand.h | 1 + src/map/pc.c | 2 +- 6 files changed, 49 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index 0c8782821..893d11747 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,8 @@ Date Added 12/17 + * Fixed skill #301 causing crashes [MouseJstr] + * Fixed documentation error on gm_skills_unconditionl [MouseJstr] + * added @grind test command.. only for testing [MouseJstr] * Added clearweather to the atcommand configuration file. [nsstrunks] 12/16 * Added a fix for AFM loading, thanks to Pete [celest] diff --git a/Makefile b/Makefile index e6b79229e..0cd7f2c31 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ # $Id: Makefile 158 2004-10-01 03:45:15Z PoW $ +# CC = /usr/local/bin/gcc -fbounds-checking -pipe CC = gcc -pipe PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT #PACKETDEF = -DPACKETVER=5 -DNEW_006b diff --git a/conf-tmpl/battle_athena.conf b/conf-tmpl/battle_athena.conf index f0ae5e9b1..74672d35d 100644 --- a/conf-tmpl/battle_athena.conf +++ b/conf-tmpl/battle_athena.conf @@ -208,7 +208,8 @@ gm_all_skill_add_abra: no // [GM] Can equip anything? (No or minimum GM level, can cause client errors.) gm_all_equipment: no -// [GM] Raise skills unconditionally, that is, put points in to a skill not in thier jobs skill tree? (no or minimum gm level) +// [GM] Can use skills without meeting the required conditions (no +// blue gems? no problem gm_skill_unconditional: no // Can a normal player by-pass the skill tree? (Note 1) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index aea1f145b..d1f645d9c 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -233,6 +233,8 @@ ACMD_FUNC(marry); // by MouseJstr ACMD_FUNC(divorce); // by MouseJstr ACMD_FUNC(rings); // by MouseJstr +ACMD_FUNC(grind); // by MouseJstr + /*========================================== *AtCommandInfo atcommand_info[]構造体の定義 *------------------------------------------ @@ -483,6 +485,7 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr] { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr] { AtCommand_Rings, "@rings", 40, atcommand_rings }, // [MouseJstr] + { AtCommand_Grind, "@grind", 40, atcommand_grind }, // [MouseJstr] // add new commands before this line { AtCommand_Unknown, NULL, 1, NULL } @@ -2160,7 +2163,6 @@ int atcommand_alive( return 0; } return -1; - } /*========================================== @@ -7494,6 +7496,44 @@ atcommand_rings(const int fd, struct map_session_data* sd, return 0; } +/*========================================== + * @grind by [MouseJstr] + *------------------------------------------ + */ +int +atcommand_grind(const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + struct map_session_data *pl_sd = NULL; + int skillnum; + int inf; + char target[255]; + nullpo_retr(-1, sd); + + if (!message || !*message) + return -1; + if(sscanf(message, "%s", target) != 1) { + clif_displaymessage(fd, "Usage: @grind "); + return -1; + } + if((pl_sd=map_nick2sd(target)) == NULL) + return -1; + + for (skillnum = 1; skillnum < 500; skillnum++) { + sd->status.sp = sd->status.max_sp; + atcommand_alive(fd, sd, command, message); + + inf = skill_get_inf(skillnum); + + if ((inf == 2) || (inf == 1)) + skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1); + else + skill_use_id(sd, pl_sd->bl.id, skillnum, 1); + } + + return 0; +} + /*========================================== * It is made to rain. *------------------------------------------ diff --git a/src/map/atcommand.h b/src/map/atcommand.h index d3fa22a07..96838b7ae 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -216,6 +216,7 @@ enum AtCommandType { AtCommand_Marry, // by MouseJstr AtCommand_Divorce, // by MouseJstr AtCommand_Rings, // by MouseJstr + AtCommand_Grind, // by MouseJstr // end AtCommand_Unknown, diff --git a/src/map/pc.c b/src/map/pc.c index d975deaf5..3c37f7ce1 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5408,7 +5408,7 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage) if (sd->sc_data) { if (sd->sc_data[SC_ENDURE].timer == -1 && sd->sc_data[SC_BERSERK].timer == -1 && !sd->special_state.infinite_endure) pc_stop_walking(sd,3); - else if(sd->sc_data[SC_ENDURE].timer != -1 && src->type==BL_MOB && (--sd->sc_data[SC_ENDURE].val2) <= 0) + else if(sd->sc_data[SC_ENDURE].timer != -1 && (src != NULL && src->type==BL_MOB) && (--sd->sc_data[SC_ENDURE].val2) <= 0) skill_status_change_end(&sd->bl, SC_ENDURE, -1); } else pc_stop_walking(sd,3); -- cgit v1.2.3-70-g09d2 From 349cf47fcf2b8f6fded1df4a52249df93f07fbad Mon Sep 17 00:00:00 2001 From: amber Date: Fri, 24 Dec 2004 04:27:49 +0000 Subject: packet changes went back into stable git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@769 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0cd7f2c31..45f9d325f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ # $Id: Makefile 158 2004-10-01 03:45:15Z PoW $ -# CC = /usr/local/bin/gcc -fbounds-checking -pipe -CC = gcc -pipe +CC = /usr/local/bin/gcc -fbounds-checking -pipe +# CC = /usr/local/bin/gcc +#CC = gcc -pipe PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT #PACKETDEF = -DPACKETVER=5 -DNEW_006b #PACKETDEF = -DPACKETVER=4 -DNEW_006b @@ -24,7 +25,7 @@ OS_TYPE = -DCYGWIN CFLAGS = $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) else OS_TYPE = -CFLAGS = $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = $(OPT) -DTWILIGHT -Wall -I../common $(PACKETDEF) $(OS_TYPE) endif MYSQLFLAG_INCLUDE_DEFAULT = /usr/local/include/mysql -- cgit v1.2.3-70-g09d2 From a1af8c0b9887f9fb621e0f6ad5f39fd0f6734e78 Mon Sep 17 00:00:00 2001 From: amber Date: Fri, 24 Dec 2004 04:30:59 +0000 Subject: quick git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@770 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 45f9d325f..219dfd07a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # $Id: Makefile 158 2004-10-01 03:45:15Z PoW $ -CC = /usr/local/bin/gcc -fbounds-checking -pipe +# CC = /usr/local/bin/gcc -fbounds-checking -pipe # CC = /usr/local/bin/gcc -#CC = gcc -pipe +CC = gcc -pipe PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT #PACKETDEF = -DPACKETVER=5 -DNEW_006b #PACKETDEF = -DPACKETVER=4 -DNEW_006b -- cgit v1.2.3-70-g09d2 From b85345109d1b5388e4aaccfdfc7a534d26e8d484 Mon Sep 17 00:00:00 2001 From: amber Date: Sat, 25 Dec 2004 02:50:53 +0000 Subject: foo git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@783 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 219dfd07a..40dcc7dc3 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ OS_TYPE = -DCYGWIN CFLAGS = $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) else OS_TYPE = -CFLAGS = $(OPT) -DTWILIGHT -Wall -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) endif MYSQLFLAG_INCLUDE_DEFAULT = /usr/local/include/mysql -- cgit v1.2.3-70-g09d2 From 7206810cc58a01e9d87a02920b0e6771c9864b8a Mon Sep 17 00:00:00 2001 From: amber Date: Mon, 27 Dec 2004 16:30:02 +0000 Subject: foo git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@822 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 40dcc7dc3..d9258179c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ # $Id: Makefile 158 2004-10-01 03:45:15Z PoW $ -# CC = /usr/local/bin/gcc -fbounds-checking -pipe -# CC = /usr/local/bin/gcc CC = gcc -pipe +# CC = gcc -pipe -DGCOLLECT +# CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK + +# GCLIB = -lgc +GCLIB = + PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT #PACKETDEF = -DPACKETVER=5 -DNEW_006b #PACKETDEF = -DPACKETVER=4 -DNEW_006b @@ -26,6 +30,7 @@ CFLAGS = $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) else OS_TYPE = CFLAGS = $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) +# CFLAGS = $(OPT) -DTWILIGHT -Wall -I../common $(PACKETDEF) $(OS_TYPE) endif MYSQLFLAG_INCLUDE_DEFAULT = /usr/local/include/mysql @@ -60,11 +65,11 @@ else LIB_S = $(LIB_S_DEFAULT) endif -MYLIB = CC="$(CC)" CFLAGS="$(CFLAGS) $(MYSQLFLAG_INCLUDE)" LIB_S="$(LIB_S)" +MYLIB = CC="$(CC)" CFLAGS="$(CFLAGS) $(MYSQLFLAG_INCLUDE)" LIB_S="$(LIB_S) $(GCLIB)" endif -MKDEF = CC="$(CC)" CFLAGS="$(CFLAGS)" +MKDEF = CC="$(CC)" CFLAGS="$(CFLAGS)" LIB_S="$(GCLIB)" all: conf txt -- 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 'Makefile') 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 e76aeff95c38966a2402fc1d6cbe975f2ec535c2 Mon Sep 17 00:00:00 2001 From: amber Date: Wed, 29 Dec 2004 21:16:45 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@864 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 +- Makefile | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index 61404e627..222c6a9aa 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,6 @@ Date Added 12/29 - * Fixing a crash if you change the name of a pet you don't have (SVN 862) [MouseJstr] + * Fixing a crash if you change the name of a pet you don't have (SVN 863) [MouseJstr] * Eliminated src/common/malloc.c when not needed [MouseJstr] * Some code cleanup in prep for new debugging malloc (SVN 861) [MouseJstr] * Updated Soul Breaker's damage calculation [celest] diff --git a/Makefile b/Makefile index 527693e4e..e8f251ad4 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,12 @@ CC = gcc -pipe # CC = gcc -pipe -x c++ # CC = gcc -pipe -DGCOLLECT +# CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK # GCLIB = -lgc GCLIB = +# GCLIB = -ldmalloc PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT #PACKETDEF = -DPACKETVER=5 -DNEW_006b -- cgit v1.2.3-70-g09d2 From f29b1bc83edac7b0f153b98bb64ac79d29b633a0 Mon Sep 17 00:00:00 2001 From: amber Date: Thu, 30 Dec 2004 03:47:18 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@866 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 3 +++ Makefile | 1 - src/char_sql/int_guild.c | 8 ++++---- src/char_sql/int_party.c | 6 +++--- src/char_sql/int_pet.c | 6 +++--- src/char_sql/int_storage.c | 5 +++-- src/map/atcommand.c | 35 +++++++++++++++++++++++++++++++++++ src/map/atcommand.h | 3 +++ src/map/map.h | 2 +- 9 files changed, 55 insertions(+), 14 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index 222c6a9aa..0b77a3a4b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,8 @@ Date Added 12/29 + * Another -1 alive_timer fix (SVN 866) [MouseJstr] + * Added @dmstart and @dmtick for debugging malloc tests [MouseJstr] + * Fix some more compile errors on different platforms [MouseJstr] * Fixing a crash if you change the name of a pet you don't have (SVN 863) [MouseJstr] * Eliminated src/common/malloc.c when not needed [MouseJstr] * Some code cleanup in prep for new debugging malloc (SVN 861) [MouseJstr] diff --git a/Makefile b/Makefile index e8f251ad4..254ac58c1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -# $Id: Makefile 158 2004-10-01 03:45:15Z PoW $ CC = gcc -pipe # CC = gcc -pipe -x c++ diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 258c173cf..3f9243bfe 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -4,6 +4,10 @@ // +#include +#include +#include + #include "char.h" #include "../common/strlib.h" #include "int_storage.h" @@ -15,10 +19,6 @@ #include "db.h" #include "malloc.h" -#include -#include -#include - static struct dbt *guild_db_; static struct dbt *castle_db_; static struct dbt *guild_expcache_db_; diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index 05a607a15..af3ad7dc3 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -3,12 +3,12 @@ // SQL conversion by hack // -#include "char.h" -#include "../common/strlib.h" -#include "socket.h" #include #include #include +#include "char.h" +#include "../common/strlib.h" +#include "socket.h" static struct party *party_pt; static int party_newid=100; diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index edad95f84..44151c8e4 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -2,13 +2,13 @@ // original code from athena // SQL conversion by Jioh L. Jung // -#include "char.h" -#include "../common/strlib.h" - #include #include #include +#include "char.h" +#include "../common/strlib.h" + struct s_pet *pet_pt; static int pet_newid = 100; diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index a6ad01eea..69eaf2469 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -2,11 +2,12 @@ // original code from athena // SQL conversion by Jioh L. Jung // -#include "char.h" -#include "itemdb.h" #include #include +#include "char.h" +#include "itemdb.h" + #define STORAGE_MEMINC 16 // reset by inter_config_read() diff --git a/src/map/atcommand.c b/src/map/atcommand.c index dc6c55777..2f7cdd995 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -230,6 +230,11 @@ ACMD_FUNC(rings); // by MouseJstr ACMD_FUNC(grind); // by MouseJstr ACMD_FUNC(grind2); // by MouseJstr +#ifdef DMALLOC +ACMD_FUNC(dmstart); // by MouseJstr +ACMD_FUNC(dmtick); // by MouseJstr +#endif + ACMD_FUNC(jumptoid); // by Dino9021 ACMD_FUNC(jumptoid2); // by Dino9021 ACMD_FUNC(recallid); // by Dino9021 @@ -490,6 +495,11 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr] { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr] +#ifdef DMALLOC + { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr] + { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr] +#endif + { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021] { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021] { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021] @@ -7329,6 +7339,31 @@ atcommand_rings(const int fd, struct map_session_data* sd, return 0; } +#ifdef DMALLOC +unsigned long dmark_; +int +atcommand_dmstart(const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + dmark_ = dmalloc_mark(); + + clif_displaymessage(fd, "debug mark set"); + + return 0; +} + +int +atcommand_dmtick(const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + dmalloc_log_changed ( dmark_, 1, 0, 1 ) ; + dmark_ = dmalloc_mark(); + clif_displaymessage(fd, "malloc changes logged"); + + return 0; +} +#endif + /*========================================== * @grind by [MouseJstr] *------------------------------------------ diff --git a/src/map/atcommand.h b/src/map/atcommand.h index d53be174d..4dba383e3 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -217,6 +217,9 @@ enum AtCommandType { AtCommand_Grind, // by MouseJstr AtCommand_Grind2, // by MouseJstr + AtCommand_DMStart, // by MouseJstr + AtCommand_DMTick, // by MouseJstr + AtCommand_JumpToId, // by Dino9021 AtCommand_JumpToId2, // by Dino9021 AtCommand_RecallId, // by Dino9021 diff --git a/src/map/map.h b/src/map/map.h index 405c34d65..eecb35afc 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -327,7 +327,7 @@ struct map_session_data { int last_skillid,last_skilllv; // Added by RoVeRT unsigned char change_level; // [celest] - unsigned int alive_timer; //[Valaris] + int alive_timer; //[Valaris] #ifndef TXT_ONLY int mail_counter; // mail counter for mail system [Valaris] -- cgit v1.2.3-70-g09d2 From aa6510ad1ed20dd163d946d858a401a9fd2d1941 Mon Sep 17 00:00:00 2001 From: amber Date: Thu, 30 Dec 2004 05:51:53 +0000 Subject: svn prop changes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@871 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 ++ Makefile | 12 +++++++----- src/char/Makefile | 4 +++- src/char_sql/Makefile | 4 ++-- src/login/Makefile | 4 +++- src/login_sql/Makefile | 3 ++- src/map/Makefile | 6 ++++-- 7 files changed, 23 insertions(+), 12 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index fe9f243f2..a19c569b6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4,6 +4,8 @@ SVN: $Rev$ Date Added 12/29 + * Modified the build system to include SVN revision as a #define + as well as in the executable name (SVN 871) [MouseJstr] * Fix account register wipe issue (SVN 868) [MouseJstr] * Double storage/lag exploit fixed (SVN 867) [MouseJstr] * Another -1 alive_timer fix (SVN 866) [MouseJstr] diff --git a/Makefile b/Makefile index 254ac58c1..16058c68b 100644 --- a/Makefile +++ b/Makefile @@ -26,13 +26,15 @@ endif OPT = -g -O2 -ffast-math +SVN_VERSION = $(shell echo " $Rev$ " | sed -e 's/^.* \(.*\) .*/\1/') + ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) OS_TYPE = -DCYGWIN -CFLAGS = $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = -DSVN_VERSION=$(SVN_VERSION) $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) else OS_TYPE = -CFLAGS = $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) -# CFLAGS = $(OPT) -DTWILIGHT -Wall -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = -DSVN_VERSION=$(SVN_VERSION) $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) +# CFLAGS = -DTWILIGHT -DSVN_VERSION=$(SVN_VERSION) $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) endif MYSQLFLAG_INCLUDE_DEFAULT = /usr/local/include/mysql @@ -67,11 +69,11 @@ else LIB_S = $(LIB_S_DEFAULT) endif -MYLIB = CC="$(CC)" CFLAGS="$(CFLAGS) $(MYSQLFLAG_INCLUDE)" LIB_S="$(LIB_S) $(GCLIB)" +MYLIB = SVN_VERSION="$(SVN_VERSION)" CC="$(CC)" CFLAGS="$(CFLAGS) $(MYSQLFLAG_INCLUDE)" LIB_S="$(LIB_S) $(GCLIB)" endif -MKDEF = CC="$(CC)" CFLAGS="$(CFLAGS)" LIB_S="$(GCLIB)" +MKDEF = SVN_VERSION="$(SVN_VERSION)" CC="$(CC)" CFLAGS="$(CFLAGS)" LIB_S="$(GCLIB)" all: conf txt diff --git a/src/char/Makefile b/src/char/Makefile index 877f83c5a..740d2608f 100644 --- a/src/char/Makefile +++ b/src/char/Makefile @@ -4,7 +4,9 @@ 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/strlib.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h char-server: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(COMMON_OBJ) - $(CC) -o ../../$@ $> + $(CC) -o ../../$@-$(SVN_VERSION) $> + cp ../../$@-$(SVN_VERSION) ../../$@ + 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) diff --git a/src/char_sql/Makefile b/src/char_sql/Makefile index c58e2d59d..10d08e2a9 100644 --- a/src/char_sql/Makefile +++ b/src/char_sql/Makefile @@ -5,8 +5,8 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db. COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o itemdb.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ $(LIB_S) - + $(CC) -o ../../$@-$(SVN_VERSION) $^ $(LIB_S) + cp ../../$@-$(SVN_VERSION) ../../$@ char.o: char.c char.h ../common/strlib.h itemdb.h ../common/showmsg.h inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h ../common/mmo.h char.h ../common/socket.h ../common/showmsg.h diff --git a/src/login/Makefile b/src/login/Makefile index f49aa4b4f..ef3907161 100644 --- a/src/login/Makefile +++ b/src/login/Makefile @@ -5,7 +5,9 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db. COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/lock.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h login-server: login.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ login.o md5calc.o $(COMMON_OBJ) + $(CC) -o ../../$@-$(SVN_VERSION) login.o md5calc.o $(COMMON_OBJ) + cp ../../$@-$(SVN_VERSION) ../../$@ + login.o: login.c login.h md5calc.h $(COMMON_H) md5calc.o: md5calc.c md5calc.h diff --git a/src/login_sql/Makefile b/src/login_sql/Makefile index 18b023fe6..933acc0ee 100644 --- a/src/login_sql/Makefile +++ b/src/login_sql/Makefile @@ -6,7 +6,8 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db. COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h login-server_sql: login.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ $(LIB_S) + $(CC) -o ../../$@-$(SVN_VERSION) $^ $(LIB_S) + cp ../../$@-$(SVN_VERSION) ../../$@ login.o: login.c login.h md5calc.h $(COMMON_H) md5calc.o: md5calc.c md5calc.h diff --git a/src/map/Makefile b/src/map/Makefile index 0dddf6132..6ac47838c 100644 --- a/src/map/Makefile +++ b/src/map/Makefile @@ -14,10 +14,12 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grf 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 txtobj/log.o $(COMMON_OBJ) - $(CC) -o ../../$@ $> $(LIBS) + $(CC) -o ../../$@-$(SVN_VERSION) $> $(LIBS) + cp ../../$@-$(SVN_VERSION) ../../$@ 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) + $(CC) -o ../../$@-$(SVN_VERSION) $> $(LIB_S) + cp ../../$@-$(SVN_VERSION) ../../$@ txtobj/%.o: %.c $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< -- cgit v1.2.3-70-g09d2 From 9c6bcfc755263b24a31c5f63e0b0dab2d9a460e0 Mon Sep 17 00:00:00 2001 From: amber Date: Thu, 30 Dec 2004 06:09:45 +0000 Subject: remove SVN_VERSION git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@873 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 -- Makefile | 12 +++++------- src/char/Makefile | 4 +--- src/char_sql/Makefile | 3 +-- src/login/Makefile | 3 +-- src/login_sql/Makefile | 3 +-- src/map/Makefile | 6 ++---- 7 files changed, 11 insertions(+), 22 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index a19c569b6..fe9f243f2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4,8 +4,6 @@ SVN: $Rev$ Date Added 12/29 - * Modified the build system to include SVN revision as a #define - as well as in the executable name (SVN 871) [MouseJstr] * Fix account register wipe issue (SVN 868) [MouseJstr] * Double storage/lag exploit fixed (SVN 867) [MouseJstr] * Another -1 alive_timer fix (SVN 866) [MouseJstr] diff --git a/Makefile b/Makefile index 16058c68b..bfd8774d9 100644 --- a/Makefile +++ b/Makefile @@ -26,15 +26,13 @@ endif OPT = -g -O2 -ffast-math -SVN_VERSION = $(shell echo " $Rev$ " | sed -e 's/^.* \(.*\) .*/\1/') - ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) OS_TYPE = -DCYGWIN -CFLAGS = -DSVN_VERSION=$(SVN_VERSION) $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) else OS_TYPE = -CFLAGS = -DSVN_VERSION=$(SVN_VERSION) $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) -# CFLAGS = -DTWILIGHT -DSVN_VERSION=$(SVN_VERSION) $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) +# CFLAGS = -DTWILIGHT $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) endif MYSQLFLAG_INCLUDE_DEFAULT = /usr/local/include/mysql @@ -69,11 +67,11 @@ else LIB_S = $(LIB_S_DEFAULT) endif -MYLIB = SVN_VERSION="$(SVN_VERSION)" CC="$(CC)" CFLAGS="$(CFLAGS) $(MYSQLFLAG_INCLUDE)" LIB_S="$(LIB_S) $(GCLIB)" +MYLIB = CC="$(CC)" CFLAGS="$(CFLAGS) $(MYSQLFLAG_INCLUDE)" LIB_S="$(LIB_S) $(GCLIB)" endif -MKDEF = SVN_VERSION="$(SVN_VERSION)" CC="$(CC)" CFLAGS="$(CFLAGS)" LIB_S="$(GCLIB)" +MKDEF = CC="$(CC)" CFLAGS="$(CFLAGS)" LIB_S="$(GCLIB)" all: conf txt diff --git a/src/char/Makefile b/src/char/Makefile index 740d2608f..877f83c5a 100644 --- a/src/char/Makefile +++ b/src/char/Makefile @@ -4,9 +4,7 @@ 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/strlib.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h char-server: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(COMMON_OBJ) - $(CC) -o ../../$@-$(SVN_VERSION) $> - cp ../../$@-$(SVN_VERSION) ../../$@ - + $(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) diff --git a/src/char_sql/Makefile b/src/char_sql/Makefile index 10d08e2a9..e206dd211 100644 --- a/src/char_sql/Makefile +++ b/src/char_sql/Makefile @@ -5,8 +5,7 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db. COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o itemdb.o $(COMMON_OBJ) - $(CC) -o ../../$@-$(SVN_VERSION) $^ $(LIB_S) - cp ../../$@-$(SVN_VERSION) ../../$@ + $(CC) -o ../../$@ $^ $(LIB_S) char.o: char.c char.h ../common/strlib.h itemdb.h ../common/showmsg.h inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h ../common/mmo.h char.h ../common/socket.h ../common/showmsg.h diff --git a/src/login/Makefile b/src/login/Makefile index ef3907161..191a015cb 100644 --- a/src/login/Makefile +++ b/src/login/Makefile @@ -5,8 +5,7 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db. COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/lock.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h login-server: login.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@-$(SVN_VERSION) login.o md5calc.o $(COMMON_OBJ) - cp ../../$@-$(SVN_VERSION) ../../$@ + $(CC) -o ../../$@ login.o md5calc.o $(COMMON_OBJ) login.o: login.c login.h md5calc.h $(COMMON_H) md5calc.o: md5calc.c md5calc.h diff --git a/src/login_sql/Makefile b/src/login_sql/Makefile index 933acc0ee..18b023fe6 100644 --- a/src/login_sql/Makefile +++ b/src/login_sql/Makefile @@ -6,8 +6,7 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db. COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h login-server_sql: login.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@-$(SVN_VERSION) $^ $(LIB_S) - cp ../../$@-$(SVN_VERSION) ../../$@ + $(CC) -o ../../$@ $^ $(LIB_S) login.o: login.c login.h md5calc.h $(COMMON_H) md5calc.o: md5calc.c md5calc.h diff --git a/src/map/Makefile b/src/map/Makefile index 6ac47838c..0dddf6132 100644 --- a/src/map/Makefile +++ b/src/map/Makefile @@ -14,12 +14,10 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grf 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 txtobj/log.o $(COMMON_OBJ) - $(CC) -o ../../$@-$(SVN_VERSION) $> $(LIBS) - cp ../../$@-$(SVN_VERSION) ../../$@ + $(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 ../../$@-$(SVN_VERSION) $> $(LIB_S) - cp ../../$@-$(SVN_VERSION) ../../$@ + $(CC) -o ../../$@ $> $(LIB_S) txtobj/%.o: %.c $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< -- cgit v1.2.3-70-g09d2 From e38158dfce4969609ab4957446d1d9a631abbfb5 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Mon, 24 Jan 2005 16:55:10 +0000 Subject: More G++ work git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@976 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 2 +- src/char/int_guild.c | 42 +++++++++++++++++++++--------------------- src/char/int_party.c | 14 +++++++------- src/char/int_pet.c | 10 +++++----- src/char/int_storage.c | 12 ++++++------ src/login/login.c | 3 ++- src/map/clif.c | 7 ++++--- src/map/clif.h | 2 +- src/map/npc.c | 22 +++++++++++----------- src/map/pc.c | 12 ++++++------ 10 files changed, 64 insertions(+), 62 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index bfd8774d9..fe096d619 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc -pipe -# CC = gcc -pipe -x c++ +# CC = g++ # CC = gcc -pipe -DGCOLLECT # CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK diff --git a/src/char/int_guild.c b/src/char/int_guild.c index b95817599..267b66f0f 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -398,7 +398,7 @@ int inter_guild_init() { continue; } - g = aCalloc(sizeof(struct guild), 1); + g = (struct guild *) aCalloc(sizeof(struct guild), 1); if(g == NULL){ printf("int_guild: out of memory!\n"); exit(0); @@ -426,7 +426,7 @@ int inter_guild_init() { } while(fgets(line, sizeof(line)-1, fp)) { - gc = aCalloc(sizeof(struct guild_castle), 1); + gc = (struct guild_castle *) aCalloc(sizeof(struct guild_castle), 1); if(gc == NULL){ printf("int_guild: out of memory!\n"); exit(0); @@ -445,7 +445,7 @@ int inter_guild_init() { printf(" %s - making Default Data...\n", castle_txt); //デフォルトデータを作成 for(i = 0; i < MAX_GUILDCASTLE; i++) { - gc = aCalloc(sizeof(struct guild_castle), 1); + gc = (struct guild_castle *) aCalloc(sizeof(struct guild_castle), 1); if (gc == NULL) { printf("int_guild: out of memory!\n"); exit(0); @@ -491,7 +491,7 @@ int inter_guild_init() { struct guild *inter_guild_search(int guild_id) { struct guild *g; - g=numdb_search(guild_db, guild_id); + g= (struct guild *) numdb_search(guild_db, guild_id); return g; } @@ -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 = aCalloc(sizeof(struct guild), 1); + g = (struct guild *) aCalloc(sizeof(struct guild), 1); if (g == NULL) { printf("int_guild: CreateGuild: out of memory !\n"); mapif_guild_created(fd, account_id, NULL); @@ -1005,7 +1005,7 @@ int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_mem int mapif_parse_GuildInfo(int fd, int guild_id) { struct guild *g; - g = numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); if (g != NULL){ guild_calcinfo(g); mapif_guild_info(fd, g); @@ -1020,7 +1020,7 @@ int mapif_parse_GuildAddMember(int fd, int guild_id, struct guild_member *m) { struct guild *g; int i; - g = numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); if (g == NULL) { mapif_guild_memberadded(fd, guild_id, m->account_id, m->char_id, 1); return 0; @@ -1046,7 +1046,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in struct guild *g = NULL; int i, j; - g = numdb_search(guild_db, guild_id); + g = (struct guild *)numdb_search(guild_db, guild_id); if (g != NULL) { for(i = 0; i < MAX_GUILD; i++) { if (g->member[i].account_id == account_id && g->member[i].char_id == char_id) { @@ -1089,7 +1089,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, struct guild *g; int i, alv, c; - g = numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); if (g == NULL) return 0; @@ -1136,7 +1136,7 @@ int guild_break_sub(void *key, void *data, va_list ap) { int mapif_parse_BreakGuild(int fd, int guild_id) { struct guild *g; - g = numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); if(g == NULL) return 0; @@ -1162,7 +1162,7 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const char struct guild *g; short dw = *((short *)data); - g = numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); if (g == NULL) return 0; @@ -1189,7 +1189,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int int i; struct guild *g; - g = numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); if(g == NULL) return 0; @@ -1224,7 +1224,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int // ギルド役職名変更要求 int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_position *p) { - struct guild *g = numdb_search(guild_db, guild_id); + struct guild *g = (struct guild *) numdb_search(guild_db, guild_id); if (g == NULL || idx < 0 || idx >= MAX_GUILDPOSITION) { return 0; @@ -1238,7 +1238,7 @@ int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_positi // ギルドスキルアップ要求 int mapif_parse_GuildSkillUp(int fd, int guild_id, int skill_num, int account_id) { - struct guild *g = numdb_search(guild_db, guild_id); + struct guild *g = (struct guild *) numdb_search(guild_db, guild_id); int idx = skill_num - GD_SKILLBASE; if (g == NULL || idx < 0 || idx >= MAX_GUILDSKILL) @@ -1261,8 +1261,8 @@ int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_ struct guild *g[2]; int j, i; - g[0] = numdb_search(guild_db, guild_id1); - g[1] = numdb_search(guild_db, guild_id2); + g[0] = (struct guild *) numdb_search(guild_db, guild_id1); + g[1] = (struct guild *) numdb_search(guild_db, guild_id2); if (g[0] == NULL || g[1] == NULL) return 0; @@ -1294,7 +1294,7 @@ int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_ int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2) { struct guild *g; - g = numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); if (g == NULL) return 0; memcpy(g->mes1, mes1, 60); @@ -1307,7 +1307,7 @@ int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char * int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data) { struct guild *g; - g = numdb_search(guild_db, guild_id); + g = (struct guild *) numdb_search(guild_db, guild_id); if (g == NULL) return 0; memcpy(g->emblem_data, data, len); @@ -1318,7 +1318,7 @@ int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char } int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index) { - struct guild_castle *gc = numdb_search(castle_db, castle_id); + struct guild_castle *gc = (struct guild_castle *) numdb_search(castle_db, castle_id); if (gc == NULL) { return mapif_guild_castle_dataload(castle_id, 0, 0); @@ -1359,7 +1359,7 @@ int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index) { } int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) { - struct guild_castle *gc=numdb_search(castle_db, castle_id); + struct guild_castle *gc= (struct guild_castle *) numdb_search(castle_db, castle_id); if (gc == NULL) { return mapif_guild_castle_datasave(castle_id, index, value); @@ -1368,7 +1368,7 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) case 1: if (gc->guild_id != value) { int gid = (value) ? value : gc->guild_id; - struct guild *g = numdb_search(guild_db, gid); + struct guild *g = (struct guild *) numdb_search(guild_db, gid); if(log_inter) inter_log("guild %s (id=%d) %s castle id=%d" RETCODE, (g) ? g->name : "??", gid, (value) ? "occupy" : "abandon", castle_id); diff --git a/src/char/int_party.c b/src/char/int_party.c index c95d13620..02e4a5210 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -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 = aCalloc(sizeof(struct party), 1); + p = (struct party *) aCalloc(sizeof(struct party), 1); if (p == NULL) { printf("int_party: out of memory !\n"); mapif_party_created(fd,account_id,NULL); @@ -421,7 +421,7 @@ int mapif_parse_CreateParty(int fd, int account_id, char *name, char *nick, char int mapif_parse_PartyInfo(int fd, int party_id) { struct party *p; - p = numdb_search(party_db, party_id); + p = (struct party *) numdb_search(party_db, party_id); if (p != NULL) mapif_party_info(fd, p); else @@ -435,7 +435,7 @@ int mapif_parse_PartyAddMember(int fd, int party_id, int account_id, char *nick, struct party *p; int i; - p = numdb_search(party_db, party_id); + p = (struct party *) numdb_search(party_db, party_id); if (p == NULL) { mapif_party_memberadded(fd, party_id, account_id, 1); return 0; @@ -473,7 +473,7 @@ int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, struct party *p; int flag = 0; - p = numdb_search(party_db, party_id); + p = (struct party *) numdb_search(party_db, party_id); if (p == NULL) return 0; @@ -494,7 +494,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id) { struct party *p; int i; - p = numdb_search(party_db, party_id); + p = (struct party *) numdb_search(party_db, party_id); if (p != NULL) { for(i = 0; i < MAX_PARTY; i++) { if (p->member[i].account_id == account_id) { @@ -516,7 +516,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, char *map, struct party *p; int i; - p = numdb_search(party_db, party_id); + p = (struct party *) numdb_search(party_db, party_id); if (p == NULL) return 0; @@ -546,7 +546,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, char *map, int mapif_parse_BreakParty(int fd, int party_id) { struct party *p; - p = numdb_search(party_db, party_id); + p = (struct party *) numdb_search(party_db, party_id); if (p == NULL) return 0; diff --git a/src/char/int_pet.c b/src/char/int_pet.c index f690e554e..8682860c0 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -136,7 +136,7 @@ int inter_pet_save() int inter_pet_delete(int pet_id) { struct s_pet *p; - p = numdb_search(pet_db,pet_id); + p = (struct s_pet *) numdb_search(pet_db,pet_id); if( p == NULL) return 1; else { @@ -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=aMalloc(sizeof(struct s_pet)); + p= (struct s_pet *) aMalloc(sizeof(struct s_pet)); if(p==NULL){ printf("int_pet: out of memory !\n"); mapif_pet_created(fd,account_id,NULL); @@ -253,7 +253,7 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet int mapif_load_pet(int fd,int account_id,int char_id,int pet_id) { struct s_pet *p; - p=numdb_search(pet_db,pet_id); + p=(struct s_pet *)numdb_search(pet_db,pet_id); if(p!=NULL) { if(p->incuvate == 1) { p->account_id = p->char_id = 0; @@ -280,9 +280,9 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data) } else{ pet_id = data->pet_id; - p=numdb_search(pet_db,pet_id); + p=(struct s_pet *)numdb_search(pet_db,pet_id); if(p == NULL) { - p=aMalloc(sizeof(struct s_pet)); + p=(struct s_pet *)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 8e4711cec..3c5695c90 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -190,9 +190,9 @@ int guild_storage_fromstr(char *str,struct guild_storage *p) struct storage *account2storage(int account_id) { struct storage *s; - s=numdb_search(storage_db,account_id); + s= (struct storage *) numdb_search(storage_db,account_id); if(s == NULL) { - s = aCalloc(sizeof(struct storage), 1); + s = (struct storage *) aCalloc(sizeof(struct storage), 1); if(s==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -208,9 +208,9 @@ struct guild_storage *guild2storage(int guild_id) { struct guild_storage *gs = NULL; if(inter_guild_search(guild_id) != NULL) { - gs=numdb_search(guild_storage_db,guild_id); + gs= (struct guild_storage *) numdb_search(guild_storage_db,guild_id); if(gs == NULL) { - gs = aCalloc(sizeof(struct guild_storage), 1); + gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1); if(gs==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -348,7 +348,7 @@ int inter_guild_storage_save() // 倉庫データ削除 int inter_storage_delete(int account_id) { - struct storage *s = numdb_search(storage_db,account_id); + struct storage *s = (struct storage *) numdb_search(storage_db,account_id); if(s) { int i; for(i=0;istorage_amount;i++){ @@ -364,7 +364,7 @@ int inter_storage_delete(int account_id) // ギルド倉庫データ削除 int inter_guild_storage_delete(int guild_id) { - struct guild_storage *gs = numdb_search(guild_storage_db,guild_id); + struct guild_storage *gs = (struct guild_storage *) numdb_search(guild_storage_db,guild_id); if(gs) { int i; for(i=0;istorage_amount;i++){ diff --git a/src/login/login.c b/src/login/login.c index 5736963d3..4e1870163 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2994,7 +2994,8 @@ int parse_login(int fd) { session[fd]->eof = 1; return 0; } - ld = (struct login_session_data*)session[fd]->session_data = (struct login_session_data*)aCalloc(1, sizeof(struct login_session_data)); + ld = (struct login_session_data*)aCalloc(1, sizeof(struct login_session_data)); + session[fd]->session_data = ld; if (!ld) { printf("login: Request for md5 key: memory allocation failure (malloc)!\n"); session[fd]->eof = 1; diff --git a/src/map/clif.c b/src/map/clif.c index 7b088068f..d15fdf3a1 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7343,7 +7343,8 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) if (sd != 0) clif_setwaitclose(sd->fd); // Set session to EOF } else { - sd = (struct map_session_data*)session[fd]->session_data = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data)); + sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data)); + session[fd]->session_data = sd; sd->fd = fd; if (IS_PACKET_DB_VER(cmd)) { @@ -10392,7 +10393,7 @@ void clif_parse_debug(int fd,struct map_session_data *sd) } // functions list -static void (*clif_parse_func_table[MAX_PACKET_DB])() = { +static void (*clif_parse_func_table[MAX_PACKET_DB])(int, struct map_session_data *) = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -10745,7 +10746,7 @@ static int packetdb_readdb(void) char *str[32],*p,*str2[32],*p2,w1[24],w2[24]; struct { - void (*func)(); + void (*func)(int, struct map_session_data *); char *name; } clif_parse_func[]={ {clif_parse_WantToConnection,"wanttoconnection"}, diff --git a/src/map/clif.h b/src/map/clif.h index 99e0752d1..17fcfb446 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -18,7 +18,7 @@ typedef unsigned int in_addr_t; struct packet_db { short len; - void (*func)(); + void (*func)(int, struct map_session_data *); short pos[20]; }; extern struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB]; diff --git a/src/map/npc.c b/src/map/npc.c index 6fd630fd5..349514e3b 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -89,7 +89,7 @@ int npc_enable_sub( struct block_list *bl, va_list ap ) } int npc_enable(const char *name,int flag) { - struct npc_data *nd=strdb_search(npcname_db,name); + struct npc_data *nd= (struct npc_data *) strdb_search(npcname_db,name); if (nd==NULL) return 0; @@ -120,7 +120,7 @@ int npc_enable(const char *name,int flag) */ struct npc_data* npc_name2id(const char *name) { - return strdb_search(npcname_db,name); + return (struct npc_data *) strdb_search(npcname_db,name); } /*========================================== * イベントキューのイベント処理 @@ -172,7 +172,7 @@ int npc_event_timer(int tid,unsigned int tick,int id,int data) int npc_timer_event(const char *eventname) // Added by RoVeRT { - struct event_data *ev=strdb_search(ev_db,eventname); + struct event_data *ev=(struct event_data *) strdb_search(ev_db,eventname); struct npc_data *nd; // int xs,ys; @@ -245,8 +245,8 @@ int npc_event_export(void *key,void *data,va_list ap) char *buf; char *p=strchr(lname,':'); // エクスポートされる - ev=aCalloc(sizeof(struct event_data), 1); - buf=aCallocA(50, 1); + ev=(struct event_data *) aCalloc(sizeof(struct event_data), 1); + buf=(char *) aCallocA(50, 1); if (ev==NULL || buf==NULL) { printf("npc_event_export: out of memory !\n"); exit(1); @@ -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=aMallocA(sizeof(struct npc_timerevent_list)); - else te=aRealloc( te, sizeof(struct npc_timerevent_list) * (i+1) ); + if(te==NULL) te=(struct npc_timerevent_list*)aMallocA(sizeof(struct npc_timerevent_list)); + else te= (struct npc_timerevent_list*)aRealloc( te, sizeof(struct npc_timerevent_list) * (i+1) ); if(te==NULL){ printf("npc_timerevent_import: out of memory !\n"); exit(1); @@ -681,7 +681,7 @@ int npc_settimerevent_tick(struct npc_data *nd,int newtimer) */ int npc_event(struct map_session_data *sd,const char *eventname,int mob_kill) { - struct event_data *ev=strdb_search(ev_db,eventname); + struct event_data *ev=(struct event_data *) strdb_search(ev_db,eventname); struct npc_data *nd; int xs,ys; char mobevent[100]; @@ -697,7 +697,7 @@ int npc_event(struct map_session_data *sd,const char *eventname,int mob_kill) if(mob_kill && (ev==NULL || (nd=ev->nd)==NULL)){ strcpy( mobevent, eventname); strcat( mobevent, "::OnMyMobDead"); - ev=strdb_search(ev_db,mobevent); + ev= (struct event_data *) strdb_search(ev_db,mobevent); if (ev==NULL || (nd=ev->nd)==NULL) { if (strnicmp(eventname,"GM_MONSTER",10)!=0) printf("npc_event: event not found [%s]\n",mobevent); @@ -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 *)aCallocA(srcsize,sizeof(char)); + srcbuf=(unsigned char *)aCallocA(srcsize,sizeof(char)); if (strchr(first_line,'{')) { strcpy(srcbuf,strchr(first_line,'{')); startline=*lines; diff --git a/src/map/pc.c b/src/map/pc.c index c17e8677b..3713b4409 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -126,7 +126,7 @@ int pc_set_gm_level(int account_id, int level) { } GM_num++; - gm_account = aRealloc(gm_account, sizeof(struct gm_account) * GM_num); + gm_account = (struct gm_account *) aRealloc(gm_account, sizeof(struct gm_account) * GM_num); gm_account[GM_num - 1].account_id = account_id; gm_account[GM_num - 1].level = level; return 0; @@ -6558,7 +6558,7 @@ int pc_setreg(struct map_session_data *sd,int reg,int val) } } sd->reg_num++; - sd->reg = aRealloc(sd->reg, sizeof(*(sd->reg)) * sd->reg_num); + sd->reg = (struct script_reg *) aRealloc(sd->reg, sizeof(*(sd->reg)) * sd->reg_num); if (sd->reg == NULL){ printf("out of memory : pc_setreg\n"); exit(1); @@ -6609,7 +6609,7 @@ int pc_setregstr(struct map_session_data *sd,int reg,char *str) return 0; } sd->regstr_num++; - sd->regstr = aRealloc(sd->regstr, sizeof(sd->regstr[0]) * sd->regstr_num); + sd->regstr = (struct script_regstr *) aRealloc(sd->regstr, sizeof(sd->regstr[0]) * sd->regstr_num); if(sd->regstr==NULL){ printf("out of memory : pc_setreg\n"); exit(1); @@ -7891,7 +7891,7 @@ int pc_read_gm_account(int fd) aFree(gm_account); GM_num = 0; #ifdef TXT_ONLY - gm_account = aCallocA(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); + gm_account = (struct 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); @@ -7933,7 +7933,7 @@ int map_day_timer(int tid, unsigned int tick, int id, int data) { // by [yor] strcpy(tmpstr, msg_txt(502)); // The day has arrived! night_flag = 0; // 0=day, 1=night [Yor] 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) { pl_sd->opt2 &= ~STATE_BLIND; clif_changeoption(&pl_sd->bl); clif_wis_message(pl_sd->fd, wisp_server_name, tmpstr, strlen(tmpstr)+1); @@ -7959,7 +7959,7 @@ int map_night_timer(int tid, unsigned int tick, int id, int data) { // by [yor] strcpy(tmpstr, msg_txt(503)); // The night has fallen... night_flag = 1; // 0=day, 1=night [Yor] for(i = 0; i < fd_max; i++) { - if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !map[pl_sd->bl.m].flag.indoors) { + if (session[i] && (pl_sd = (struct map_session_data *) session[i]->session_data) && pl_sd->state.auth && !map[pl_sd->bl.m].flag.indoors) { if (battle_config.night_darkness_level > 0) clif_specialeffect(&pl_sd->bl, 474 + battle_config.night_darkness_level, 0); else { -- cgit v1.2.3-70-g09d2 From 6bd2b81c4f1b71fcbc7d0a34d0c617b5251a4f04 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Tue, 25 Jan 2005 15:43:48 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@991 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 13 +++++ Makefile | 8 +-- conf-tmpl/battle_athena.conf | 19 +++---- src/char/Makefile | 2 +- src/login/Makefile | 2 +- src/map/Makefile | 2 +- src/map/battle.c | 6 +-- src/map/clif.c | 17 ++++--- src/map/skill.c | 115 ++++++++++++------------------------------- 9 files changed, 73 insertions(+), 111 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index 81b9d5db2..9bff594ee 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,18 @@ Date Added +01/25 + * Fixed TXT compile problems with libGC [celest] + * Added "Clients older than 2004-09-06aSakray" option to packet_ver_flag in + battle_athena, just in case server owners still prefer the older clients. + With so many changes to Sakray over the past months its much better upgrading + to the newer clients (November or higher recommended) available ;P [celest] + * Merged Full Strip into jA's tidier stripping skills code -- also fixes + a typo that was causing Full Strip to do the reverse effect instead, + and the skill not updating the target's status after successfully unequipping + items [celest] + * Tidy up the 4 chemical protection skills into one code block [celest] + * Corrected Slim Pitcher's code -- sorry, i missed a few things ^^; [celest] + 01/24 * Fixed a typo in Provoke that was causing crashes [celest] * Fixed another compile warning in src/char/char.c diff --git a/Makefile b/Makefile index fe096d619..292c3ff2c 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -CC = gcc -pipe +# CC = gcc -pipe # CC = g++ -# CC = gcc -pipe -DGCOLLECT +CC = gcc -pipe -DGCOLLECT # CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK -# GCLIB = -lgc -GCLIB = +GCLIB = -L/usr/local/lib -lgc +# GCLIB = # GCLIB = -ldmalloc PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT diff --git a/conf-tmpl/battle_athena.conf b/conf-tmpl/battle_athena.conf index 35b20f7d9..3b2b93c94 100644 --- a/conf-tmpl/battle_athena.conf +++ b/conf-tmpl/battle_athena.conf @@ -772,15 +772,16 @@ any_warp_GM_min_level: 20 // Set here which client version do you accept. Add all values of clients: // Clients older than accepted versions, and versions not set to 'accepted' // here will be rejected when logging in -// 1: 2004-09-06aSakray client -// 2: 2004-09-21aSakray Client -// 4: 2004-10-18bSakexe Client -// 8: 2004-10-25aSakexe Client -// 16: 2004-11-01aSakexe Client -// 32: 2004-12-06aSakexe Client -// 64: 2005-01-10aSakexe Client -// default value: 127 (all clients) -packet_ver_flag: 127 +// 1: Clients older than 2004-09-06aSakray +// 2: 2004-09-06aSakray client +// 4: 2004-09-21aSakray Client +// 8: 2004-10-18bSakexe Client +// 16: 2004-10-25aSakexe Client +// 32: 2004-11-01aSakexe Client +// 64: 2004-12-06aSakexe Client +// 128: 2005-01-10aSakexe Client +// default value: 255 (all clients) +packet_ver_flag: 255 // Allow GMs to mute players or not? muting_players: no diff --git a/src/char/Makefile b/src/char/Makefile index 877f83c5a..3c09db92c 100644 --- a/src/char/Makefile +++ b/src/char/Makefile @@ -4,7 +4,7 @@ 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/strlib.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h char-server: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(COMMON_OBJ) - $(CC) -o ../../$@ $> + $(CC) -o ../../$@ $> $(LIB_S) 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) diff --git a/src/login/Makefile b/src/login/Makefile index 191a015cb..482503969 100644 --- a/src/login/Makefile +++ b/src/login/Makefile @@ -5,7 +5,7 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db. COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/lock.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h login-server: login.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ login.o md5calc.o $(COMMON_OBJ) + $(CC) -o ../../$@ login.o md5calc.o $(COMMON_OBJ) $(LIB_S) login.o: login.c login.h md5calc.h $(COMMON_H) md5calc.o: md5calc.c md5calc.h diff --git a/src/map/Makefile b/src/map/Makefile index 0dddf6132..ac9ba9bf7 100644 --- a/src/map/Makefile +++ b/src/map/Makefile @@ -14,7 +14,7 @@ COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grf 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 txtobj/log.o $(COMMON_OBJ) - $(CC) -o ../../$@ $> $(LIBS) + $(CC) -o ../../$@ $> $(LIBS) $(LIB_S) 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) diff --git a/src/map/battle.c b/src/map/battle.c index ce691158c..a11facfc9 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -5622,7 +5622,7 @@ void battle_set_defaults() { battle_config.ban_spoof_namer = 5; // added by [Yor] (default: 5 minutes) battle_config.hack_info_GM_level = 60; // added by [Yor] (default: 60, GM level) battle_config.any_warp_GM_min_level = 20; // added by [Yor] - battle_config.packet_ver_flag = 127; // added by [Yor] + battle_config.packet_ver_flag = 255; // added by [Yor] battle_config.min_hair_style = 0; battle_config.max_hair_style = 20; battle_config.min_hair_color = 0; @@ -5760,8 +5760,8 @@ void battle_validate_conf() { battle_config.any_warp_GM_min_level = 100; // 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.packet_ver_flag & 255) == 0) // added by [Yor] + battle_config.packet_ver_flag = 255; // accept all clients if (battle_config.night_darkness_level > 10) // Celest battle_config.night_darkness_level = 10; diff --git a/src/map/clif.c b/src/map/clif.c index d15fdf3a1..eeae87439 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10626,14 +10626,15 @@ static int clif_parse(int fd) { } // check if version is accepted - if (packet_ver <= 9 || // reject any client versions older than 6sept04 - (packet_ver == 10 && (battle_config.packet_ver_flag & 1) == 0) || - (packet_ver == 11 && (battle_config.packet_ver_flag & 2) == 0) || - (packet_ver == 12 && (battle_config.packet_ver_flag & 4) == 0) || - (packet_ver == 13 && (battle_config.packet_ver_flag & 8) == 0) || - (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) || + if (packet_ver <= 5 || // reject really old client versions + (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04 + (packet_ver == 10 && (battle_config.packet_ver_flag & 2) == 0) || + (packet_ver == 11 && (battle_config.packet_ver_flag & 4) == 0) || + (packet_ver == 12 && (battle_config.packet_ver_flag & 8) == 0) || + (packet_ver == 13 && (battle_config.packet_ver_flag & 16) == 0) || + (packet_ver == 14 && (battle_config.packet_ver_flag & 32) == 0) || + (packet_ver == 15 && (battle_config.packet_ver_flag & 64) == 0) || + (packet_ver == 16 && (battle_config.packet_ver_flag & 128) == 0) || 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)) { diff --git a/src/map/skill.c b/src/map/skill.c index 964354c53..55d3ce175 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -3975,9 +3975,10 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case RG_STRIPSHIELD: /* ストリップシールド */ case RG_STRIPARMOR: /* ストリップアーマー */ case RG_STRIPHELM: /* ストリップヘルム */ + case ST_FULLSTRIP: // Celest { struct status_change *tsc_data = battle_get_sc_data(bl); - int scid, equip, strip_fix; + int scid, equip, strip_fix, strip_num = 0; scid = SkillStatusChangeTable[skillid]; switch (skillid) { case RG_STRIPWEAPON: @@ -3992,6 +3993,10 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case RG_STRIPHELM: equip = EQP_HELM; break; + case ST_FULLSTRIP: + equip = EQP_WEAPON | EQP_SHIELD | EQP_ARMOR | EQP_HELM; + strip_num = 3; + break; default: return 1; } @@ -4009,8 +4014,9 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if (dstsd) { for (i=0;istatus.inventory[i].equip && dstsd->status.inventory[i].equip & equip){ - pc_unequipitem(dstsd,i,0); - break; + pc_unequipitem(dstsd,i,3); + if ((--strip_num) <= 0) + break; } } if (i == MAX_INVENTORY) @@ -4022,49 +4028,6 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int break; } - // Full Strip [Celest] - case ST_FULLSTRIP: - { - struct status_change *tsc_data = battle_get_sc_data(bl); - int c=0, i, j, strip_fix; - int striplist[2][4] = { { 0, 0, 0, 0 }, - { 0x0002, 0x0020, 0x0010, 0x0100 } }; - - strip_fix = battle_get_dex(src) - battle_get_dex(bl); - if(strip_fix < 0) - strip_fix=0; - strip_per = 5+2*skilllv+strip_fix/5; - strip_time = skill_get_time(skillid,skilllv)+strip_fix/2; - for (i=0; i<4; i++) { - if(tsc_data && tsc_data[SC_CP_WEAPON + i].timer != -1) - break; - if(rand()%100 < strip_per) { - striplist[0][i] = 1; - c++; - } - } - - if (c > 0) { - clif_skill_nodamage(src,bl,skillid,skilllv,1); - for (j=0; j<4 && c > 0; j++) { - if (striplist[0][j]) { - skill_status_change_start(bl,SC_STRIPWEAPON + i,skilllv,0,0,0,strip_time,0 ); - if(dstsd){ - for(i=0;istatus.inventory[i].equip && dstsd->status.inventory[i].equip & striplist[1][j]){ - pc_unequipitem(dstsd,i,3); - --c; - break; - } - } - } - } - } - } - } - break; - - /* PotionPitcher */ case AM_POTIONPITCHER: /* ポ?ションピッチャ? */ { @@ -4135,38 +4098,15 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } break; case AM_CP_WEAPON: - { - struct status_change *tsc_data = battle_get_sc_data(bl); - clif_skill_nodamage(src,bl,skillid,skilllv,1); - if(tsc_data && tsc_data[SC_STRIPWEAPON].timer != -1) - skill_status_change_end(bl, SC_STRIPWEAPON, -1 ); - skill_status_change_start(bl,SkillStatusChangeTable[skillid],skilllv,0,0,0,skill_get_time(skillid,skilllv),0 ); - } - break; case AM_CP_SHIELD: - { - struct status_change *tsc_data = battle_get_sc_data(bl); - clif_skill_nodamage(src,bl,skillid,skilllv,1); - if(tsc_data && tsc_data[SC_STRIPSHIELD].timer != -1) - skill_status_change_end(bl, SC_STRIPSHIELD, -1 ); - skill_status_change_start(bl,SkillStatusChangeTable[skillid],skilllv,0,0,0,skill_get_time(skillid,skilllv),0 ); - } - break; case AM_CP_ARMOR: - { - struct status_change *tsc_data = battle_get_sc_data(bl); - clif_skill_nodamage(src,bl,skillid,skilllv,1); - if(tsc_data && tsc_data[SC_STRIPARMOR].timer != -1) - skill_status_change_end(bl, SC_STRIPARMOR, -1 ); - skill_status_change_start(bl,SkillStatusChangeTable[skillid],skilllv,0,0,0,skill_get_time(skillid,skilllv),0 ); - } - break; case AM_CP_HELM: { + int scid = SC_STRIPWEAPON + (skillid - AM_CP_WEAPON); struct status_change *tsc_data = battle_get_sc_data(bl); clif_skill_nodamage(src,bl,skillid,skilllv,1); - if(tsc_data && tsc_data[SC_STRIPHELM].timer != -1) - skill_status_change_end(bl, SC_STRIPHELM, -1 ); + if(tsc_data && tsc_data[scid].timer != -1) + skill_status_change_end(bl, SC_STRIPWEAPON, -1 ); skill_status_change_start(bl,SkillStatusChangeTable[skillid],skilllv,0,0,0,skill_get_time(skillid,skilllv),0 ); } break; @@ -4654,12 +4594,18 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case CR_SLIMPITCHER: { if (sd && flag&1) { + struct block_list tbl; int hp = sd->potion_hp * (100 + pc_checkskill(sd,CR_SLIMPITCHER)*10 + pc_checkskill(sd,AM_POTIONPITCHER)*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*5)/100; hp = hp * (100 + (battle_get_vit(bl)<<1))/100; - if (dstsd) + if (dstsd) { hp = hp * (100 + pc_checkskill(dstsd,SM_RECOVERY)*10)/100; - clif_skill_nodamage(src,bl,skillid,skilllv,1); - battle_heal(src,bl,hp,0,0); + } + tbl.id = 0; + tbl.m = src->m; + tbl.x = src->x; + tbl.y = src->y; + clif_skill_nodamage(&tbl,bl,AL_HEAL,hp,1); + battle_heal(NULL,bl,hp,0,0); } } break; @@ -5160,23 +5106,23 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil case CR_SLIMPITCHER: { if (sd) { - int x = skilllv%11 - 1; - int i = pc_search_inventory(sd,skill_db[skillid].itemid[x]); - if(i < 0 || skill_db[skillid].itemid[x] <= 0 || sd->inventory_data[i] == NULL || - sd->status.inventory[i].amount < skill_db[skillid].amount[x]) { + int i = skilllv%11 - 1; + int j = pc_search_inventory(sd,skill_db[skillid].itemid[i]); + if(j < 0 || skill_db[skillid].itemid[i] <= 0 || sd->inventory_data[j] == NULL || + sd->status.inventory[j].amount < skill_db[skillid].amount[i]) { clif_skill_fail(sd,skillid,0,0); - map_freeblock_unlock(); return 1; } sd->state.potionpitcher_flag = 1; sd->potion_hp = 0; - run_script(sd->inventory_data[i]->use_script,0,sd->bl.id,0); - pc_delitem(sd,i,skill_db[skillid].amount[x],0); + run_script(sd->inventory_data[j]->use_script,0,sd->bl.id,0); + pc_delitem(sd,j,skill_db[skillid].amount[i],0); sd->state.potionpitcher_flag = 0; + clif_skill_poseffect(src,skillid,skilllv,x,y,tick); if(sd->potion_hp > 0) { map_foreachinarea(skill_area_sub, src->m,x-3,y-3,x+3,y+3,0, - src,skillid,skilllv,tick,flag|BCT_ALL|1, + src,skillid,skilllv,tick,flag|BCT_PARTY|1, skill_castend_nodamage_id); } } @@ -7380,7 +7326,8 @@ int skill_check_condition(struct map_session_data *sd,int type) continue; if(skill == WZ_FIREPILLAR && lv<=5) continue; // no gemstones for 1-5 [Celest] - if(skill == AM_POTIONPITCHER && i != x) + if((skill == AM_POTIONPITCHER || + skill == CR_SLIMPITCHER) && i != x) continue; index[i] = pc_search_inventory(sd,itemid[i]); -- cgit v1.2.3-70-g09d2 From 2143a2dcf2af305c7248711275a31f63b17431f4 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Tue, 25 Jan 2005 18:14:14 +0000 Subject: Removed libGC git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@992 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 ++ Makefile | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index 9bff594ee..ebb5efb8f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,7 @@ Date Added +01/26 + * libGC isn't ready to be the default quite yet... [MouseJstr] 01/25 * Fixed TXT compile problems with libGC [celest] * Added "Clients older than 2004-09-06aSakray" option to packet_ver_flag in diff --git a/Makefile b/Makefile index 292c3ff2c..d47568419 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -# CC = gcc -pipe +CC = gcc -pipe # CC = g++ -CC = gcc -pipe -DGCOLLECT +# CC = gcc -pipe -DGCOLLECT # CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK -GCLIB = -L/usr/local/lib -lgc -# GCLIB = +# GCLIB = -L/usr/local/lib -lgc +GCLIB = # GCLIB = -ldmalloc PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT -- cgit v1.2.3-70-g09d2 From 3f38fcaeaf61cf293c5392a67d85cfd5465d9585 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Wed, 26 Jan 2005 02:03:07 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@995 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 3 +++ Makefile | 2 +- conf-tmpl/mapflag/nomemo.txt | 1 + db/Changelog.txt | 4 ++++ db/item_db.txt | 2 +- src/map/map.h | 2 +- src/map/skill.c | 4 +--- 7 files changed, 12 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index accf32895..8f8394b29 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,9 @@ Date Added 01/26 + * Removed my changes to /stable/Makefile that i've accidentally commited, sorry + ^^; [celest] + * Removed an unnecessary "cloneskill_lv" from map_session_data [celest] * Removed WATER.TXT (this file wasn't used at all. There's no such mapflag as WATER even). [Lupus] * Added Water Height of New Yuno Fileds 9 and 11. Now Water Ball works there as should. Wizards could levelup on sleepers, too. [Lupus] diff --git a/Makefile b/Makefile index d47568419..fe096d619 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ CC = gcc -pipe # CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK -# GCLIB = -L/usr/local/lib -lgc +# GCLIB = -lgc GCLIB = # GCLIB = -ldmalloc diff --git a/conf-tmpl/mapflag/nomemo.txt b/conf-tmpl/mapflag/nomemo.txt index e28d7aa69..0566ec0e2 100644 --- a/conf-tmpl/mapflag/nomemo.txt +++ b/conf-tmpl/mapflag/nomemo.txt @@ -9,6 +9,7 @@ // Towns ==================== ayo_in01.gat mapflag nomemo ayo_in02.gat mapflag nomemo +ayo_fild02.gat mapflag nomemo alb2trea.gat mapflag nomemo alb_ship.gat mapflag nomemo alberta_in.gat mapflag nomemo diff --git a/db/Changelog.txt b/db/Changelog.txt index e3384763b..e6f60e31a 100644 --- a/db/Changelog.txt +++ b/db/Changelog.txt @@ -5,6 +5,10 @@ Ayathoya items == Added but no effect ( all are "ect" itens) Skill databases == celest working on them i believe. +01/26 + * Updated Counter dagger's attack, thanks to Poki#3 + * Added ayo_fild02 to nomemo mapflag list + 01/13 * Fixed drops of Taoist Hermit, added drops rates to JOKER (all rates were 0%) Removed 0.01% Chances of all Apple drops plugs diff --git a/db/item_db.txt b/db/item_db.txt index 4c3bcecdf..d7440724e 100644 --- a/db/item_db.txt +++ b/db/item_db.txt @@ -538,7 +538,7 @@ 1239,Poison_Knife,Poison Knife,4,20,0,800,64,,1,0,2055918,2,2,3,65,1,{},{ bonus bAtkEle,5; bonus2 bAddEff,Eff_Poison,3000; } 1240,Princess_Knife,Princess Knife,4,20,0,400,84,,1,0,2055918,2,2,4,1,1,{},{ bonus bAllStats,1; } 1241,Cursed_Dagger,Cursed Dagger,4,20,0,400,55,,1,0,66052,2,2,4,85,1,{},{ bonus2 bAddEff,Eff_Curse,500; } -1242,Counter_Dagger,Counter Dagger,4,20,0,550,75,,1,0,66052,2,2,4,55,1,{},{ bonus bCritical,90; bonus3 bAutoSpell,61,1,25; } +1242,Counter_Dagger,Counter Dagger,4,20,0,550,140,,1,0,66052,2,2,4,55,1,{},{ bonus bCritical,90; bonus3 bAutoSpell,61,1,25; } 1243,Main_Gauche_For_Novice,Novice Main Gauche,4,20,0,1,45,,1,0,8388609,2,2,1,1,1,{},{} // Katars 1250,Jur,Jur,4,19500,0,800,125,,1,2,4096,2,34,2,18,16,{},{} diff --git a/src/map/map.h b/src/map/map.h index d4f673d6a..ed66e5669 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -217,7 +217,7 @@ struct map_session_data { struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET]; struct skill_timerskill skilltimerskill[MAX_SKILLTIMERSKILL]; unsigned short timerskill_count; // [celest] - int cloneskill_id,cloneskill_lv; + int cloneskill_id; int potion_hp,potion_sp,potion_per_hp,potion_per_sp; int invincible_timer; diff --git a/src/map/skill.c b/src/map/skill.c index 55d3ce175..b42d3d898 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1804,13 +1804,11 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds && !(skillid > NPC_PIERCINGATT && skillid < NPC_SUMMONMONSTER) && !(skillid > NPC_SELFDESTRUCTION2 && skillid < NPC_UNDEADATTACK)){ //?に?んでいるスキルがあれば該?スキルを消す - if (tsd->cloneskill_id && tsd->cloneskill_lv && tsd->status.skill[tsd->cloneskill_id].flag==13){ + if (tsd->cloneskill_id && tsd->status.skill[tsd->cloneskill_id].flag==13){ tsd->status.skill[tsd->cloneskill_id].id=0; - tsd->status.skill[tsd->cloneskill_id].lv=0; tsd->status.skill[tsd->cloneskill_id].flag=0; } tsd->cloneskill_id=skillid; - tsd->cloneskill_lv=skilllv; tsd->status.skill[skillid].id=skillid; tsd->status.skill[skillid].lv=(pc_checkskill(tsd,RG_PLAGIARISM) > skill_get_max(skillid))? skill_get_max(skillid):pc_checkskill(tsd,RG_PLAGIARISM); -- cgit v1.2.3-70-g09d2 From 414864ad8b4237cc31d03b020119a8cf978c30bc Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Fri, 4 Feb 2005 12:12:48 +0000 Subject: * Added experimental code to generate a stack dump when it segfaults git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1027 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 11 +++++++++++ Makefile | 1 + 2 files changed, 12 insertions(+) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index 28dab9917..2a8469119 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,17 @@ Date Added 02/04 + * 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 + - to enable, edit the Makefile and remove the # on the line: + + # OPT += -DDUMPSTACK -rdynamic + + - What it does: everytime eA crashes it'll generate a file "stackdump_ + .txt" in your save folder with a backtrace, which you can + examine and send to a dev to be fixed. + * Some more tidying up in status_get_ functions [celest] 02/03 diff --git a/Makefile b/Makefile index fe096d619..26d07fbcc 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ MAKE = make endif OPT = -g -O2 -ffast-math +# OPT += -DDUMPSTACK -rdynamic ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) OS_TYPE = -DCYGWIN -- cgit v1.2.3-70-g09d2 From eedd229519169dee4733be16f9e842fc29ae7110 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Sat, 5 Feb 2005 06:02:39 +0000 Subject: more compile errors git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1040 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 1 + Makefile | 4 ++-- src/map/chat.c | 6 +++--- src/map/itemdb.c | 20 +++++++++---------- src/map/mob.c | 6 +++--- src/map/npc.c | 16 +++++++-------- src/map/script.c | 61 ++++++++++++++++++++++++++++---------------------------- 7 files changed, 58 insertions(+), 56 deletions(-) (limited to 'Makefile') diff --git a/Changelog.txt b/Changelog.txt index 95319d2bd..596c713e5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,7 @@ Date Added 02/04 + * Fixed more compile signed/unsigned errors [SVN 1040: MouseJstr] * TXT convertors now read the import command in inter_athena.conf [SVN 1038: Ajarn] * Fixed some compile errors [SVN 1037: MouseJstr] diff --git a/Makefile b/Makefile index 26d07fbcc..3b25b5e59 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -CC = gcc -pipe -# CC = g++ +# CC = gcc -pipe +CC = g++ # CC = gcc -pipe -DGCOLLECT # CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK diff --git a/src/map/chat.c b/src/map/chat.c index cfd2660e0..3bd29fec3 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -29,7 +29,7 @@ int chat_createchat(struct map_session_data *sd,int limit,int pub,char* pass,cha nullpo_retr(0, sd); - cd = aCalloc(1,sizeof(struct chat_data)); + cd = (struct chat_data *) aCalloc(1,sizeof(struct chat_data)); cd->limit = limit; cd->pub = pub; @@ -78,7 +78,7 @@ int chat_joinchat(struct map_session_data *sd,int chatid,char* pass) clif_joinchatfail(sd,0); return 0; } - if(cd->pub==0 && strncmp(pass,cd->pass,8)){ + if(cd->pub==0 && strncmp(pass,(char *) cd->pass,8)){ clif_joinchatfail(sd,1); return 0; } @@ -268,7 +268,7 @@ int chat_createnpcchat(struct npc_data *nd,int limit,int pub,int trigger,char* t nullpo_retr(1, nd); - cd = aCalloc(1,sizeof(struct chat_data)); + cd = (struct chat_data *) aCalloc(1,sizeof(struct chat_data)); cd->limit = cd->trigger = limit; if(trigger>0) diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 971f6cacf..5e19b1aca 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -136,7 +136,7 @@ int itemdb_searchrandomid(int flags) */ struct item_data* itemdb_exists(int nameid) { - return numdb_search(item_db,nameid); + return (struct item_data *) numdb_search(item_db,nameid); } /*========================================== * DBの検索 @@ -146,7 +146,7 @@ struct item_data* itemdb_search(int nameid) { struct item_data *id; - id=numdb_search(item_db,nameid); + id=(struct item_data *) numdb_search(item_db,nameid); if(id) return id; id=(struct item_data *)aCalloc(1,sizeof(struct item_data)); @@ -373,10 +373,10 @@ static int itemdb_readdb(void) if((p=strchr(np,'{'))==NULL) continue; - id->use_script = parse_script(p,lines); + id->use_script = parse_script((unsigned char *) p,lines); if((p=strchr(p+1,'{'))==NULL) continue; - id->equip_script = parse_script(p,lines); + id->equip_script = parse_script((unsigned char *) p,lines); } fclose(fp); sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,filename[i]); @@ -415,7 +415,7 @@ static int itemdb_read_randomitem() struct random_item_data *pd=data[i].pdata; int *pc=data[i].pcount; int *pdefault=data[i].pdefault; - char *fn=data[i].filename; + char *fn=(char *) data[i].filename; *pdefault = 0; if( (fp=fopen(fn,"r"))==NULL ){ @@ -519,7 +519,7 @@ static int itemdb_read_itemnametable(void) char *buf,*p; int s; - buf=grfio_reads("data\\idnum2itemdisplaynametable.txt",&s); + buf=(char *) grfio_reads("data\\idnum2itemdisplaynametable.txt",&s); if(buf==NULL) return -1; @@ -562,7 +562,7 @@ static int itemdb_read_cardillustnametable(void) char *buf,*p; int s; - buf=grfio_reads("data\\num2cardillustnametable.txt",&s); + buf=(char *) grfio_reads("data\\num2cardillustnametable.txt",&s); if(buf==NULL) return -1; @@ -601,7 +601,7 @@ static int itemdb_read_itemslottable(void) char *buf,*p; int s; - buf=grfio_read("data\\itemslottable.txt"); + buf=(char *) grfio_read("data\\itemslottable.txt"); if(buf==NULL) return -1; s=grfio_size("data\\itemslottable.txt"); @@ -636,7 +636,7 @@ static int itemdb_read_itemslotcounttable(void) char *buf,*p; int s; - buf=grfio_read("data\\itemslotcounttable.txt"); + buf=(char *) grfio_read("data\\itemslotcounttable.txt"); if(buf==NULL) return -1; s=grfio_size("data\\itemslotcounttable.txt"); @@ -909,7 +909,7 @@ static int itemdb_final(void *key,void *data,va_list ap) { struct item_data *id; - nullpo_retr(0, id=data); + nullpo_retr(0, id= (struct item_data *) data); if(id->use_script) aFree(id->use_script); diff --git a/src/map/mob.c b/src/map/mob.c index b8eac5d67..1068b515a 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -288,7 +288,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname, for(count=0;countsession_data) && tmpsd->state.auth) { + if(session[i] && (tmpsd= (struct map_session_data *) session[i]->session_data) && tmpsd->state.auth) { if(md->bl.m == tmpsd->bl.m) { sd = tmpsd; break; diff --git a/src/map/npc.c b/src/map/npc.c index 0519b9925..95788a2cd 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1655,13 +1655,13 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line } if (srcbuf[0]!='{') { if (strchr((char *) line,'{')) { - strcpy(srcbuf,strchr((const char *) line,'{')); + strcpy((char *) srcbuf,strchr((const char *) line,'{')); startline=*lines; } } else - strcat(srcbuf,line); + strcat((char *) srcbuf,(const char *) line); } - script=parse_script(srcbuf,startline); + script=(unsigned char *) parse_script((unsigned char *) srcbuf,startline); if (script==NULL) { // script parse error? aFree(srcbuf); @@ -1681,7 +1681,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line printf("bad duplicate name! (not exist) : %s\n",srcname); return 0; } - script=nd2->u.scr.script; + script=(unsigned char *)nd2->u.scr.script; label_dup=nd2->u.scr.label_list; label_dupnum=nd2->u.scr.label_list_num; src_id=nd2->bl.id; @@ -1744,7 +1744,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line nd->flag=0; nd->class_=class_; nd->speed=200; - nd->u.scr.script=script; + nd->u.scr.script=(char *) script; nd->u.scr.src_id=src_id; nd->chat_id=0; nd->option = 0; @@ -1893,7 +1893,7 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li } else strcat(srcbuf,line); } - script=parse_script(srcbuf,startline); + script= parse_script((unsigned char *) srcbuf,startline); if (script==NULL) { // script parse error? aFree(srcbuf); @@ -2160,7 +2160,7 @@ static int npc_read_indoors(void) char *buf,*p; int s, m; - buf=grfio_reads("data\\indoorrswtable.txt",&s); + buf=(char *) grfio_reads("data\\indoorrswtable.txt",&s); if(buf==NULL) return -1; @@ -2191,7 +2191,7 @@ static int npc_read_indoors(void) static int ev_db_final(void *key,void *data,va_list ap) { aFree(data); - if(strstr(key,"::")!=NULL) + if(strstr((const char *) key,"::")!=NULL) aFree(key); return 0; } diff --git a/src/map/script.c b/src/map/script.c index 0b4374887..07f642dc6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -52,7 +52,7 @@ static int script_pos,script_size; char *str_buf; int str_pos,str_size; -static struct { +static struct str_data_struct { int type; int str; int backpatch; @@ -306,7 +306,7 @@ int mapreg_setreg(int num,int val); int mapreg_setregstr(int num,const char *str); struct { - int (*func)(); + int (*func)(struct script_state *); char *name; char *arg; } buildin_func[]={ @@ -559,7 +559,7 @@ static int search_str(const unsigned char *p) int i; i=str_hash[calc_hash(p)]; while(i){ - if(strcmp(str_buf+str_data[i].str,p)==0){ + if(strcmp(str_buf+str_data[i].str,(char *) p)==0){ return i; } i=str_data[i].next; @@ -577,10 +577,10 @@ static int add_str(const unsigned char *p) int i; char *lowcase; - lowcase=aStrdup(p); + lowcase=aStrdup((char *) p); for(i=0;lowcase[i];i++) lowcase[i]=tolower(lowcase[i]); - if((i=search_str(lowcase))>=0){ + if((i=search_str((unsigned char *) lowcase))>=0){ aFree(lowcase); return i; } @@ -592,7 +592,7 @@ static int add_str(const unsigned char *p) } else { i=str_hash[i]; for(;;){ - if(strcmp(str_buf+str_data[i].str,p)==0){ + if(strcmp(str_buf+str_data[i].str,(char *) p)==0){ return i; } if(str_data[i].next==0) @@ -603,22 +603,22 @@ static int add_str(const unsigned char *p) } if(str_num>=str_data_size){ str_data_size+=128; - str_data=aRealloc(str_data,sizeof(str_data[0])*str_data_size); + str_data=(struct str_data_struct *) aRealloc(str_data,sizeof(str_data[0])*str_data_size); memset(str_data + (str_data_size - 128), '\0', 128); } - while(str_pos+(int)strlen(p)+1>=str_size){ + while(str_pos+(int)strlen((char *) p)+1>=str_size){ str_size+=256; str_buf=(char *)aRealloc(str_buf,str_size); memset(str_buf + (str_size - 256), '\0', 256); } - strcpy(str_buf+str_pos,p); + strcpy(str_buf+str_pos, (char *) p); str_data[str_num].type=C_NOP; str_data[str_num].str=str_pos; str_data[str_num].next=0; str_data[str_num].func=NULL; str_data[str_num].backpatch=-1; str_data[str_num].label=-1; - str_pos+=strlen(p)+1; + str_pos+=strlen( (char *) p)+1; return str_num++; } @@ -631,7 +631,7 @@ static void check_script_buf(int size) { if(script_pos+size>=script_size){ script_size+=SCRIPT_BLOCK_SIZE; - script_buf=(char *)aRealloc(script_buf,script_size); + script_buf=(unsigned char *)aRealloc(script_buf,script_size); memset(script_buf + script_size - SCRIPT_BLOCK_SIZE, '\0', SCRIPT_BLOCK_SIZE); } @@ -792,7 +792,7 @@ static void disp_error_message(const char *mes,const unsigned char *pos) for(line=startline,p=startptr;p && *p;line++){ linestart=p; - lineend=strchr(p,'\n'); + lineend=(unsigned char *) strchr((char *) p,'\n'); if(lineend){ c=*lineend; *lineend=0; @@ -842,9 +842,9 @@ unsigned char* parse_simpleexpr(unsigned char *p) } } else if(isdigit(*p) || ((*p=='-' || *p=='+') && isdigit(p[1]))){ char *np; - i=strtoul(p,&np,0); + i=strtoul((char *) p,&np,0); add_scripti(i); - p=np; + p=(unsigned char *) np; } else if(*p=='"'){ add_scriptc(C_STR); p++; @@ -871,12 +871,12 @@ unsigned char* parse_simpleexpr(unsigned char *p) disp_error_message("unexpected character",p); exit(1); } - p2=skip_word(p); + p2=(char *) skip_word(p); c=*p2; *p2=0; // 名前をadd_strする l=add_str(p); parse_cmd=l; // warn_*_mismatch_paramnumのために必要 - if(l==search_str("if")) // warn_cmd_no_commaのために必要 + if(l== search_str((unsigned char *) "if")) // warn_cmd_no_commaのために必要 parse_cmd_if++; /* // 廃止予定のl14/l15,およびプレフィックスlの警告 @@ -887,11 +887,12 @@ unsigned char* parse_simpleexpr(unsigned char *p) disp_error_message("prefix 'l' is DEPRECATED. use prefix '@' instead.",p2); } */ - *p2=c; p=p2; + *p2=c; + p=(unsigned char *) p2; if(str_data[l].type!=C_FUNC && c=='['){ // array(name[i] => getelementofarray(name,i) ) - add_scriptl(search_str("getelementofarray")); + add_scriptl(search_str((unsigned char *) "getelementofarray")); add_scriptc(C_ARG); add_scriptl(l); p=parse_subexpr(p+1,-1); @@ -929,14 +930,14 @@ unsigned char* parse_subexpr(unsigned char *p,int limit) p=skip_space(p); if(*p=='-'){ - tmpp=skip_space(p+1); + tmpp=(char *) skip_space((unsigned char *) (p+1)); if(*tmpp==';' || *tmpp==','){ add_scriptl(LABEL_NEXTLINE); p++; return p; } } - tmpp=p; + tmpp=(char *) p; if((op=C_NEG,*p=='-') || (op=C_LNOT,*p=='!') || (op=C_NOT,*p=='~')){ p=parse_subexpr(p+1,100); add_scriptc(op); @@ -968,13 +969,13 @@ unsigned char* parse_subexpr(unsigned char *p,int limit) const char *plist[128]; if( str_data[func].type!=C_FUNC ){ - disp_error_message("expect function",tmpp); + disp_error_message("expect function",(unsigned char *) tmpp); exit(0); } add_scriptc(C_ARG); do { - plist[i]=p; + plist[i]=(char *) p; p=parse_subexpr(p,-1); p=skip_space(p); if(*p==',') p++; @@ -984,7 +985,7 @@ unsigned char* parse_subexpr(unsigned char *p,int limit) p=skip_space(p); i++; } while(*p && *p!=')' && i<128); - plist[i]=p; + plist[i]=(char *) p; if(*(p++)!=')'){ disp_error_message("func request '(' ')'",p); exit(1); @@ -995,7 +996,7 @@ unsigned char* parse_subexpr(unsigned char *p,int limit) int j=0; for(j=0;arg[j];j++) if(arg[j]=='*')break; if( (arg[j]==0 && i!=j) || (arg[j]=='*' && i Date: Sat, 5 Feb 2005 06:10:58 +0000 Subject: oops git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1041 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3b25b5e59..26d07fbcc 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -# CC = gcc -pipe -CC = g++ +CC = gcc -pipe +# CC = g++ # CC = gcc -pipe -DGCOLLECT # CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK -- cgit v1.2.3-70-g09d2 From b292e29e093cb3b1cba367e6b4644abe68108ae0 Mon Sep 17 00:00:00 2001 From: amber Date: Tue, 22 Feb 2005 05:01:20 +0000 Subject: PCRE updates git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1157 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 7 +- Makefile | 2 + npc/other/eliza.txt | 702 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/map/Makefile | 6 +- src/map/clif.c | 4 + src/map/map.h | 2 + src/map/npc.c | 4 + src/map/npc.h | 2 + src/map/npc_chat.c | 502 +++++++++++++++++++++++++++++++++++++ src/map/script.c | 26 +- src/map/script.h | 4 + 11 files changed, 1253 insertions(+), 8 deletions(-) create mode 100644 npc/other/eliza.txt create mode 100644 src/map/npc_chat.c (limited to 'Makefile') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 84b0bb6fb..7e5d7258d 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,5 +1,10 @@ Date Added +02/22 + * Added perl regular expression support.. look at src/map/npc_chat.c + for all the dirt on the new features. To build it, you have + to enable the PCRE_SUPPORT #define and you also have to + build/install the pcre library. [SVN 1157: MouseJstr] 02/21 * Added actual item_db.sql into sql-files. [Lupus] * Added actual mob_db.sql into sql-files. If you use SQL Mob DB then update it [Lupus] @@ -2000,4 +2005,4 @@ Date Added router or a firewall since there is no way of determining the external IP address. On the other hand, we should be able to eliminate the lan_conf file since we know our IP addresses as well - as our netmask. \ No newline at end of file + as our netmask. diff --git a/Makefile b/Makefile index 26d07fbcc..cc95d3800 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,13 @@ CC = gcc -pipe +# CC = gcc -pipe -DPCRE_SUPPORT # CC = g++ # CC = gcc -pipe -DGCOLLECT # CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK # GCLIB = -lgc +# GCLIB = -L/usr/local/lib -lpcre GCLIB = # GCLIB = -ldmalloc diff --git a/npc/other/eliza.txt b/npc/other/eliza.txt new file mode 100644 index 000000000..d5c3c0765 --- /dev/null +++ b/npc/other/eliza.txt @@ -0,0 +1,702 @@ +prontera.gat,152,181,5 script MouseJstr 763,{ + +// hello +Lquote0: + npctalk "How do you do. Please state your problem."; + break; +// computer +Lquote1: + set $foo,rand(4); + if($foo == 0) goto Lquote1a; + if($foo == 1) goto Lquote1b; + if($foo == 2) goto Lquote1c; + if($foo == 3) goto Lquote1d; +Lquote1a: + npctalk "Do computers worry you?"; + break; +Lquote1b: + npctalk "What do you think about machines?"; + break; +Lquote1c: + npctalk "Why do you mention computers?"; + break; +Lquote1d: + npctalk "What do you think machines have to do with your problem?"; + break; +// name +Lquote2: + npctalk "I am not interested in names"; + break; +// sorry +Lquote3: + set $foo,rand(3); + if($foo == 0) goto Lquote3a; + if($foo == 1) goto Lquote3b; + if($foo == 2) goto Lquote3c; + +Lquote3a: + npctalk "Please don't apologize"; + break; + +Lquote3b: + npctalk "Apologies are not necessary"; + break; + +Lquote3c: + npctalk "What feelings do you have when you apologize"; + break; + +// I remember $p2$ +Lquote4: + set $foo,rand(6); + if($foo == 0) goto Lquote4a; + if($foo == 1) goto Lquote4b; + if($foo == 2) goto Lquote4c; + if($foo == 3) goto Lquote4d; + if($foo == 4) goto Lquote4e; + if($foo == 5) goto Lquote4f; + +Lquote4a: + npctalk "Do you often think of "+$p2$+"?"; + break; + +Lquote4b: + npctalk "Does thinking of "+$p2$+" bring anything else to mind?"; + break; + +Lquote4c: + npctalk "What else do you remember?"; + break; + +Lquote4d: + npctalk "Why do you recall "+$p2$+" right now?"; + break; + +Lquote4e: + npctalk "What in the present situation reminds you of "+$p2$+"?"; + break; + +Lquote4f: + npctalk "What is the connection between me and "+$p2$+"?"; + break; + +// do you remember +Lquote5: + set $foo,rand(4); + if($foo == 0) goto Lquote5a; + if($foo == 1) goto Lquote5b; + if($foo == 2) goto Lquote5c; + if($foo == 3) goto Lquote5d; +Lquote5a: + npctalk "Did you think I would forget "+$p2$+" ?"; + break; + +Lquote5b: + npctalk "Why do you think I should recall "+$p2$+" now"; + break; + +Lquote5c: + npctalk "What about "+$p2$+""; + break; + +Lquote5d: + npctalk "You mentioned "+$p2$+""; + break; + +// if +Lquote6: + set $foo,rand(4); + if($foo == 0) goto Lquote6a; + if($foo == 1) goto Lquote6b; + if($foo == 2) goto Lquote6c; + if($foo == 3) goto Lquote6d; +Lquote6a: + npctalk "Do you really think its likely that "+$p2$+""; + break; + +Lquote6b: + npctalk "Do you wish that "+$p2$+"?"; + break; + +Lquote6c: + npctalk "What do you think about "+$p2$+"?"; + break; + +Lquote6d: + npctalk "Really-- if "+$p2$+"?"; + break; + +// i dreamt +Lquote7: + set $foo,rand(3); + if($foo == 0) goto Lquote7a; + if($foo == 1) goto Lquote7b; + if($foo == 2) goto Lquote7c; +Lquote7a: + npctalk "Really-- "+$p2$+""; + break; + +Lquote7b: + npctalk "Have you ever fantasized "+$p2$+" while you were awake?"; + break; + +Lquote7c: + npctalk "Have you dreamt "+$p2$+" before?"; + break; + +// dream about + +Lquote8: + npctalk "How do you feel about "+$p2$+" in reality?"; + break; + +// dream +Lquote9: + set $foo,rand(4); + if($foo == 0) goto Lquote9a; + if($foo == 1) goto Lquote9b; + if($foo == 2) goto Lquote9c; + if($foo == 3) goto Lquote9d; +Lquote9a: + npctalk "What does this dream suggest to you?"; + break; + +Lquote9b: + npctalk "Do you dream often?"; + break; + +Lquote9c: + npctalk "What persons appear in your dreams?"; + break; + +Lquote9d: + npctalk "Don't you believe that dream has to do with your problem?"; + break; + +// my mother +Lquote10: + set $foo,rand(2); + if($foo == 0) goto Lquote10a; + if($foo == 1) goto Lquote10b; +Lquote10a: + npctalk "Who else in your family "+$p2$+""; + break; + +Lquote10b: + npctalk "Tell me more about your family"; + break; + +// my father +Lquote11: + set $foo,rand(3); + if($foo == 0) goto Lquote11a; + if($foo == 1) goto Lquote11b; + if($foo == 2) goto Lquote11c; +Lquote11a: + npctalk "Your father"; + break; + +Lquote11b: + npctalk "Does he influence you strongly?"; + break; + +Lquote11c: + npctalk "What else comes to mind when you think of your father?"; + break; + +// I want +Lquote12: + set $foo,rand(3); + if($foo == 0) goto Lquote12a; + if($foo == 1) goto Lquote12b; + if($foo == 2) goto Lquote12c; +Lquote12a: + npctalk "What would it mean if you got "+$p2$+""; + break; + +Lquote12b: + npctalk "Why do you want "+$p2$+""; + break; + +Lquote12c: + npctalk "Suppose you got "+$p2$+" soon"; + break; + +// I am glad +Lquote13: + set $foo,rand(3); + if($foo == 0) goto Lquote13a; + if($foo == 1) goto Lquote13b; + if($foo == 2) goto Lquote13c; +Lquote13a: + npctalk "How have I helped you to be "+$p2$+""; + break; + +Lquote13b: + npctalk "What makes you happy just now"; + break; + +Lquote13c: + npctalk "Can you explain why you are suddenly "+$p2$+""; + break; + +// I am sad +Lquote14: + set $foo,rand(2); + if($foo == 0) goto Lquote14a; + if($foo == 1) goto Lquote14b; +Lquote14a: + npctalk "I am sorry to hear you are depressed"; + break; + +Lquote14b: + npctalk "I'm sure its not pleasant to be sad"; + break; + +// $p2 are like "+$p3$+" +Lquote15: + npctalk "What resemblance do you see between "+$p2$+" and "+$p3$+""; + break; + +// "+$p2$+" is like "+$p3$+" +Lquote16: + set $foo,rand(4); + if($foo == 0) goto Lquote16a; + if($foo == 1) goto Lquote16b; + if($foo == 2) goto Lquote16c; + if($foo == 3) goto Lquote16d; +Lquote16a: + npctalk "In what way is it that "+$p2$+" is like "+$p3$+""; + break; + +Lquote16b: + npctalk "What resemblance do you see?"; + break; + +Lquote16c: + npctalk "Could there really be some connection?"; + break; + +Lquote16d: + npctalk "How?"; + break; +// alike +Lquote17: + set $foo,rand(2); + if($foo == 0) goto Lquote17a; + if($foo == 1) goto Lquote17b; +Lquote17a: + npctalk "In what way?"; + break; + +Lquote17b: + npctalk "What similarities are there?"; + break; +// same +Lquote18: + npctalk "What other connections do you see?"; + break; + +// I was "+$p2$+" +Lquote19: + set $foo,rand(3); + if($foo == 0) goto Lquote19a; + if($foo == 1) goto Lquote19b; + if($foo == 2) goto Lquote19c; +Lquote19a: + npctalk "Were you really?"; + break; + +Lquote19b: + npctalk "Perhaps I already knew you were "+$p2$+""; + break; + +Lquote19c: + npctalk "Why do you tell me you were "+$p2$+" now?"; + break; + +// was I +Lquote20: + set $foo,rand(3); + if($foo == 0) goto Lquote20a; + if($foo == 1) goto Lquote20b; + if($foo == 2) goto Lquote20c; +Lquote20a: + npctalk "What if you were "+$p2$+" ?"; + break; + +Lquote20b: + npctalk "Do you thin you were "+$p2$+""; + break; + +Lquote20c: + npctalk "What would it mean if you were "+$p2$+""; + break; + +// I am +Lquote21: + set $foo,rand(2); + if($foo == 0) goto Lquote21a; + if($foo == 1) goto Lquote21b; +Lquote21a: + npctalk "In what way are you "+$p2$+""; + break; + +Lquote21b: + npctalk "Do you want to be "+$p2$+" ?"; + break; + +// am I +Lquote22: + set $foo,rand(4); + if($foo == 0) goto Lquote22a; + if($foo == 1) goto Lquote22b; + if($foo == 2) goto Lquote22c; + if($foo == 3) goto Lquote22d; +Lquote22a: + npctalk "Do you believe you are "+$p2$+""; + break; + +Lquote22b: + npctalk "Would you want to be "+$p2$+""; + break; + +Lquote22c: + npctalk "You wish I would tell you you are "+$p2$+""; + break; + +Lquote22d: + npctalk "What would it mean if you were "+$p2$+""; + break; + +// am +Lquote23: + set $foo,rand(2); + if($foo == 0) goto Lquote23a; + if($foo == 1) goto Lquote23b; + +Lquote23a: + npctalk "Why do you say AM?"; + break; + +Lquote23b: + npctalk "I don't understand that"; + break; + +// are you +Lquote24: + set $foo,rand(3); + if($foo == 0) goto Lquote24a; + if($foo == 1) goto Lquote24b; + if($foo == 2) goto Lquote24c; +Lquote24a: + npctalk "Why are you interested in whether I am "+$p2$+" or not?"; + break; + +Lquote24b: + npctalk "Would you prefer if I weren't "+$p2$+""; + break; + +Lquote24c: + npctalk "Perhaps I am "+$p2$+" in your fantasies"; + break; + +// you are +Lquote25: + npctalk "What makes you think I am "+$p2$+" ?"; + break; + +// because +Lquote26: + set $foo,rand(3); + if($foo == 0) goto Lquote26a; + if($foo == 1) goto Lquote26b; + if($foo == 2) goto Lquote26c; +Lquote26a: + npctalk "Is that the real reason?"; + break; + +Lquote26b: + npctalk "What other reasons might there be?"; + break; + +Lquote26c: + npctalk "Does that reason seem to explain anything else?"; + break; + +// were you +Lquote27: + set $foo,rand(3); + if($foo == 0) goto Lquote27a; + if($foo == 1) goto Lquote27b; + if($foo == 2) goto Lquote27c; +Lquote27a: + npctalk "Perhaps I was "+$p2$+""; + break; + +Lquote27b: + npctalk "What do you think?"; + break; + +Lquote27c: + npctalk "What if I had been "+$p2$+""; + break; + +// I can't +Lquote28: + set $foo,rand(2); + if($foo == 0) goto Lquote28a; + if($foo == 1) goto Lquote28b; +Lquote28a: + npctalk "Maybe you could "+$p2$+" now"; + break; + +Lquote28b: + npctalk "What if you could "+$p2$+" ?"; + break; + +// I feel +Lquote29: + npctalk "Do you often feel "+$p2$+" ?"; + break; + +// I felt +Lquote30: + npctalk "What other feelings do you have?"; + break; + +// $p1$ I $p2$ you $p3$ +Lquote31: + npctalk "Perhaps in your fantasy we "+$p3$+" each other?"; + break; + +// why don't you +Lquote32: + set $foo,rand(3); + if($foo == 0) goto Lquote32a; + if($foo == 1) goto Lquote32b; + if($foo == 2) goto Lquote32c; +Lquote32a: + npctalk "Should you "+$p2$+" yourself?"; + break; + +Lquote32b: + npctalk "Do you believe I don't "+$p2$+""; + break; + +Lquote32c: + npctalk "Perhaps I will "+$p2$+" in good time"; + break; + +// yes +Lquote33: + set $foo,rand(3); + if($foo == 0) goto Lquote33a; + if($foo == 1) goto Lquote33b; + if($foo == 2) goto Lquote33c; +Lquote33a: + npctalk "You seem quite positive"; + break; + +Lquote33b: + npctalk "You are sure?"; + break; + +Lquote33c: + npctalk "I understand"; + break; + +// no +Lquote34: + set $foo,rand(3); + if($foo == 0) goto Lquote34a; + if($foo == 1) goto Lquote34b; + if($foo == 2) goto Lquote34c; +Lquote34a: + npctalk "Why not?"; + break; + +Lquote34b: + npctalk "You are being a bit negative"; + break; + +Lquote34c: + npctalk "Are you saying NO just to be negative?"; + break; + +// someone +Lquote35: + npctalk "Can you be more specific?"; + break; + +// everyone +Lquote36: + set $foo,rand(4); + if($foo == 0) goto Lquote36a; + if($foo == 1) goto Lquote36b; + if($foo == 2) goto Lquote36c; + if($foo == 3) goto Lquote36d; +Lquote36a: + npctalk "surely not everyone"; + break; + +Lquote36b: + npctalk "Can you think of anyone in particular?"; + break; + +Lquote36c: + npctalk "Who for example?"; + break; + +Lquote36d: + npctalk "You are thinking of a special person?"; + break; + +// always +Lquote37: + set $foo,rand(4); + if($foo == 0) goto Lquote37a; + if($foo == 1) goto Lquote37b; + if($foo == 2) goto Lquote37c; + if($foo == 3) goto Lquote37d; +Lquote37a: + npctalk "Can you think of a specific example?"; + break; + +Lquote37b: + npctalk "When?"; + break; + +Lquote37c: + npctalk "What incident are you thinking of?"; + break; + +Lquote37d: + npctalk "Really-- always?"; + break; + +// what +Lquote38: + set $foo,rand(5); + if($foo == 0) goto Lquote38a; + if($foo == 1) goto Lquote38b; + if($foo == 2) goto Lquote38c; + if($foo == 3) goto Lquote38d; + if($foo == 4) goto Lquote38e; +Lquote38a: + npctalk "Why do you ask?"; + break; + +Lquote38b: + npctalk "Does that question interest you?"; + break; + +Lquote38c: + npctalk "What is it you really want to know?"; + break; + +Lquote38d: + npctalk "What do you think?"; + break; + +Lquote38e: + npctalk "What comes to your mind when you ask that?"; + break; + +// perhaps +Lquote39: + npctalk "You do not seem quite certain"; + break; + +// are +Lquote40: + set $foo,rand(2); + if($foo == 0) goto Lquote40a; + if($foo == 1) goto Lquote40b; +Lquote40a: + npctalk "Did you think they might not be "+$p2$+""; + break; + +Lquote40b: + npctalk "Possibly they are "+$p2$; + break; + +// default +Lquote41: + set $foo,rand(6); + if($foo == 0) goto Lquote41a; + if($foo == 1) goto Lquote41b; + if($foo == 2) goto Lquote41c; + if($foo == 3) goto Lquote41d; + if($foo == 4) goto Lquote41e; + if($foo == 5) goto Lquote41f; +Lquote41a: + npctalk "Very interesting"; + break; + +Lquote41b: + npctalk "I am not sure I understand you fully"; + break; + +Lquote41c: + npctalk "What does that suggest to you?"; + break; + +Lquote41d: + npctalk "Please continue"; + break; + +Lquote41e: + npctalk "Go on"; + break; + +Lquote41f: + npctalk "Do you feel strongly about discussing such things?"; + break; +OnInit: + defpattern 1, "([^:]+):.*\\shello.*", "Lquote0"; + defpattern 1, "([^:]+):.*\\scomputer.*", "Lquote1"; + defpattern 1, "([^:]+):.*\\sname.*", "Lquote2"; + defpattern 1, "([^:]+):.*\\ssorry.*", "Lquote3"; + defpattern 1, "([^:]+):.*\\si\\s+remember\\s+(.*)", "Lquote4"; + defpattern 1, "([^:]+):.*\\sdo\\s+you\\s+remember\\s+(.*)", "Lquote5"; + defpattern 1, "([^:]+):.*\\sif\\s+(.*)", "Lquote6"; + defpattern 1, "([^:]+):.*\\si\\s+dreamt\\s+(.*)", "Lquote7"; + defpattern 1, "([^:]+):.*\\sdream\\s+about\\s+(.*)", "Lquote8"; + defpattern 1, "([^:]+):.*\\sdream\\s+(.*)", "Lquote9"; + defpattern 1, "([^:]+):.*\\smy\\s+mother\\s+(.*)", "Lquote10"; + defpattern 1, "([^:]+):.*\\smy\\s+father\\s+(.*)", "Lquote11"; + defpattern 1, "([^:]+):.*\\si\\s+want\\s+(.*)", "Lquote12"; + defpattern 1, "([^:]+):.*\\si\\s+am\\s+glad\\s+(.*)", "Lquote13"; + defpattern 1, "([^:]+):\\s+(.*)\\s+i\\s+am\\s+sad\\s+(.*)", "Lquote14"; + defpattern 1, "([^:]+):\\s+(.*)\\s+are\\s+like\\s+(.*)", "Lquote15"; + defpattern 1, "([^:]+):\\s+(.*)\\s+is\\s+like\\s+(.*)", "Lquote16"; + defpattern 1, "([^:]+):.*\\salike\\s+(.*)", "Lquote17"; + defpattern 1, "([^:]+):.*\\ssame\\s+(.*)", "Lquote18"; + defpattern 1, "([^:]+):.*\\si\\s+was\\s+(.*)", "Lquote19"; + defpattern 1, "([^:]+):.*\\swas\\s+i\\s+(.*)", "Lquote20"; + defpattern 1, "([^:]+):.*\\si\\s+am\\s+(.*)", "Lquote21"; + defpattern 1, "([^:]+):.*\\sam\\s+i\\s+(.*)", "Lquote22"; + defpattern 1, "([^:]+):.*\\sam\\s+(.*)", "Lquote23"; + defpattern 1, "([^:]+):.*\\sare\\s+you\\s+(.*)", "Lquote24"; + defpattern 1, "([^:]+):.*\\syou\\s+are\\s+(.*)", "Lquote25"; + defpattern 1, "([^:]+):.*\\sbecause\\s+(.*)", "Lquote26"; + defpattern 1, "([^:]+):.*\\swere\\s+you\\s+(.*)", "Lquote27"; + defpattern 1, "([^:]+):.*\\si\\s+(cant|can't|cannot)\\s+(.*)", "Lquote28"; + defpattern 1, "([^:]+):.*\\si\\s+feel\\s+(.*)", "Lquote29"; + defpattern 1, "([^:]+):.*\\si\\s+felt\\s+(.*)", "Lquote30"; + defpattern 1, "([^:]+):.*\\si\\s+(.*)\\s+you\\s+(.*)", "Lquote31"; + defpattern 1, "([^:]+):.*\\swhy\\s+(don't|dont)\\s+you\\s+(.*)", "Lquote32"; + defpattern 1, "([^:]+):.*\\syes\\s+(.*)", "Lquote33"; + defpattern 1, "([^:]+):.*\\sno\\s+(.*)", "Lquote34"; + defpattern 1, "([^:]+):.*\\ssomeone\\s+(.*)", "Lquote35"; + defpattern 1, "([^:]+):.*\\severyone\\s+(.*)", "Lquote36"; + defpattern 1, "([^:]+):.*\\salways\\s+(.*)", "Lquote37"; + defpattern 1, "([^:]+):.*\\swhat\\s+(.*)", "Lquote38"; + defpattern 1, "([^:]+):.*\\sperhaps\\s+(.*)", "Lquote39"; + defpattern 1, "([^:]+):.*\\sare\\s+(.*)", "Lquote40"; + defpattern 1, "([^:]+):(.*)", "Lquote41"; + + activatepset 1; + break; +} diff --git a/src/map/Makefile b/src/map/Makefile index 3a05cd7a8..884e8b902 100644 --- a/src/map/Makefile +++ b/src/map/Makefile @@ -13,10 +13,10 @@ sqlobj: COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o ../common/utils.o ../common/strlib.o LIBS = -lz -lm -map-server: txtobj/map.o txtobj/chrif.o txtobj/clif.o txtobj/pc.o txtobj/status.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 txtobj/log.o $(COMMON_OBJ) +map-server: txtobj/map.o txtobj/chrif.o txtobj/clif.o txtobj/pc.o txtobj/status.o txtobj/npc.o txtobj/npc_chat.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 txtobj/log.o $(COMMON_OBJ) $(CC) -o ../../$@ $> $(LIBS) $(LIB_S) -map-server_sql: sqlobj/map.o sqlobj/chrif.o sqlobj/clif.o sqlobj/pc.o sqlobj/status.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) +map-server_sql: sqlobj/map.o sqlobj/chrif.o sqlobj/clif.o sqlobj/pc.o sqlobj/status.o sqlobj/npc.o sqlobj/npc_chat.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 @@ -31,6 +31,7 @@ txtobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h cha 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/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.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/npc_chat.o: npc_chat.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 @@ -55,6 +56,7 @@ sqlobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h cha 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/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.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/npc_chat.o: npc_chat.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 diff --git a/src/map/clif.c b/src/map/clif.c index 0a0db934a..67c925f75 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7964,6 +7964,10 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < WFIFOW(fd,0) = 0x8e; WFIFOSET(fd, WFIFOW(fd,2)); +#ifdef PCRE_SUPPORT + map_foreachinarea(npc_chat_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_NPC, RFIFOP(fd,4), strlen(RFIFOP(fd,4)), &sd->bl); +#endif + // Celest if (pc_calc_base_job2 (sd->status.class_) == 23 ) { int next = pc_nextbaseexp(sd)>0 ? pc_nextbaseexp(sd) : sd->status.base_exp; diff --git a/src/map/map.h b/src/map/map.h index 92c334806..2963a316e 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -411,6 +411,8 @@ struct npc_data { char eventqueue[MAX_EVENTQUEUE][50]; int eventtimer[MAX_EVENTTIMER]; short arenaflag; + + void *chatdb; }; struct mob_data { struct block_list bl; diff --git a/src/map/npc.c b/src/map/npc.c index 1ba55699f..54a35c51c 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -153,6 +153,10 @@ int npc_delete(struct npc_data *nd) if(nd->bl.prev == NULL) return 1; +#ifdef PCRE_SUPPORT + npc_chat_finalize(nd); +#endif + clif_clearchar_area(&nd->bl,1); map_delblock(&nd->bl); return 0; diff --git a/src/map/npc.h b/src/map/npc.h index a68cc8e54..dbb351fa0 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,6 +8,8 @@ #define WARP_DEBUG_CLASS 722 #define INVISIBLE_CLASS 32767 +void npc_chat_finalize(struct npc_data *nd); +int npc_chat_sub(struct block_list *bl, va_list ap); int npc_event_dequeue(struct map_session_data *sd); int npc_event_timer(int tid,unsigned int tick,int id,int data); int npc_event(struct map_session_data *sd,const char *npcname,int); diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c new file mode 100644 index 000000000..5ec8540ae --- /dev/null +++ b/src/map/npc_chat.c @@ -0,0 +1,502 @@ +#ifdef PCRE_SUPPORT + +#include +#include +#include +#include +#include +#ifdef __WIN32 +#define __USE_W32_SOCKETS +#include +#else +#include +#include +#include +#include +#include +#endif +#include + +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/version.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + +#include "map.h" +#include "status.h" +#include "npc.h" +#include "chat.h" +#include "script.h" +#include "battle.h" + +#include "pcre.h" + +/** + * Written by MouseJstr in a vision... (2/21/2005) + * + * This allows you to make npc listen for spoken text (global + * messages) and pattern match against that spoken text using perl + * regular expressions. + * + * Please feel free to copy this code into your own personal ragnarok + * servers or distributions but please leave my name. Also, please + * wait until I've put it into the main eA branch which means I + * believe it is ready for distribution. + * + * So, how do people use this? + * + * The first and most important function is defpattern + * + * defpattern 1, "[^:]+: (.*) loves (.*)", "label"; + * + * this defines a new pattern in set 1 using perl syntax + * (http://www.troubleshooters.com/codecorn/littperl/perlreg.htm) + * and tells it to jump to the supplied label when the pattern + * is matched. + * + * each of the matched Groups will result in a variable being + * set ($p1$ through $p9$ with $p0$ being the entire string) + * before the script gets executed. + * + * activatepset 1; + * + * This activates a set of patterns.. You can have many pattern + * sets defined and many active all at once. This feature allows + * you to set up "conversations" and ever changing expectations of + * the pattern matcher + * + * deactivatepset 1; + * + * turns off a pattern set; + * + * deactivatepset -1; + * + * turns off ALL pattern sets; + * + * deletepset 1; + * + * deletes a pset + */ + +/* Structure containing all info associated with a single pattern + block */ + +struct pcrematch_entry { + struct pcrematch_entry *next_; + char *pattern_; + pcre *pcre_; + pcre_extra *pcre_extra_; + char *label_; +}; + +/* A set of patterns that can be activated and deactived with a single + command */ + +struct pcrematch_set { + struct pcrematch_set *next_, *prev_; + struct pcrematch_entry *head_; + int setid_; +}; + +/* + * Entire data structure hung off a NPC + * + * The reason I have done it this way (a void * in npc_data and then + * this) was to reduce the number of patches that needed to be applied + * to a ragnarok distribution to bring this code online. I + * also wanted people to be able to grab this one file to get updates + * without having to do a large number of changes. + */ + +struct npc_parse { + struct pcrematch_set *active_; + struct pcrematch_set *inactive_; +}; + + +/** + * delete everythign associated with a entry + * + * This does NOT do the list management + */ + +void finalize_pcrematch_entry(struct pcrematch_entry *e) { + free(e->pcre_); + free(e->pcre_extra_); + aFree(e->pattern_); + aFree(e->label_); +} + +/** + * Lookup (and possibly create) a new set of patterns by the set id + */ +static struct pcrematch_set * lookup_pcreset(struct npc_data *nd,int setid) +{ + struct pcrematch_set *pcreset; + struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb; + if (npcParse == NULL) + nd->chatdb = npcParse = (struct npc_parse *) + aCalloc(sizeof(struct npc_parse), 1); + + pcreset = npcParse->active_; + + while (pcreset != NULL) { + if (pcreset->setid_ == setid) + break; + pcreset = pcreset->next_; + } + if (pcreset == NULL) + pcreset = npcParse->inactive_; + + while (pcreset != NULL) { + if (pcreset->setid_ == setid) + break; + pcreset = pcreset->next_; + } + + if (pcreset == NULL) { + pcreset = (struct pcrematch_set *) + aCalloc(sizeof(struct pcrematch_set), 1); + pcreset->next_ = npcParse->inactive_; + if (pcreset->next_ != NULL) + pcreset->next_->prev_ = pcreset; + pcreset->prev_ = 0; + npcParse->inactive_ = pcreset; + pcreset->setid_ = setid; + } + + return pcreset; +} + +/** + * activate a set of patterns. + * + * if the setid does not exist, this will silently return + */ + +static void activate_pcreset(struct npc_data *nd,int setid) { + struct pcrematch_set *pcreset; + struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb; + if (npcParse == NULL) + return; // Nothing to activate... + pcreset = npcParse->inactive_; + while (pcreset != NULL) { + if (pcreset->setid_ == setid) + break; + pcreset = pcreset->next_; + } + if (pcreset == NULL) + return; // not in inactive list + if (pcreset->next_ != NULL) + pcreset->next_->prev_ = pcreset->prev_; + if (pcreset->prev_ != NULL) + pcreset->prev_->next_ = pcreset->next_; + else + npcParse->inactive_ = pcreset->next_; + + pcreset->prev_ = NULL; + pcreset->next_ = npcParse->active_; + if (pcreset->next_ != NULL) + pcreset->next_->prev_ = pcreset; + npcParse->active_ = pcreset; +} + +/** + * deactivate a set of patterns. + * + * if the setid does not exist, this will silently return + */ + +static void deactivate_pcreset(struct npc_data *nd,int setid) { + struct pcrematch_set *pcreset; + struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb; + if (npcParse == NULL) + return; // Nothing to deactivate... + if (setid == -1) { + while(npcParse->active_ != NULL) + deactivate_pcreset(nd, npcParse->active_->setid_); + return; + } + pcreset = npcParse->active_; + while (pcreset != NULL) { + if (pcreset->setid_ == setid) + break; + pcreset = pcreset->next_; + } + if (pcreset == NULL) + return; // not in active list + if (pcreset->next_ != NULL) + pcreset->next_->prev_ = pcreset->prev_; + if (pcreset->prev_ != NULL) + pcreset->prev_->next_ = pcreset->next_; + else + npcParse->active_ = pcreset->next_; + + pcreset->prev_ = NULL; + pcreset->next_ = npcParse->inactive_; + if (pcreset->next_ != NULL) + pcreset->next_->prev_ = pcreset; + npcParse->inactive_ = pcreset; +} + +/** + * delete a set of patterns. + */ +static void delete_pcreset(struct npc_data *nd,int setid) { + int active = 1; + struct pcrematch_set *pcreset; + struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb; + if (npcParse == NULL) + return; // Nothing to deactivate... + pcreset = npcParse->active_; + while (pcreset != NULL) { + if (pcreset->setid_ == setid) + break; + pcreset = pcreset->next_; + } + if (pcreset == NULL) { + active = 0; + pcreset = npcParse->inactive_; + while (pcreset != NULL) { + if (pcreset->setid_ == setid) + break; + pcreset = pcreset->next_; + } + } + if (pcreset == NULL) + return; + + if (pcreset->next_ != NULL) + pcreset->next_->prev_ = pcreset->prev_; + if (pcreset->prev_ != NULL) + pcreset->prev_->next_ = pcreset->next_; + else if(active == 1) + npcParse->active_ = pcreset->next_; + else + npcParse->inactive_ = pcreset->next_; + + pcreset->prev_ = NULL; + pcreset->next_ = NULL; + + while (pcreset->head_) { + struct pcrematch_entry *n = pcreset->head_->next_;; + finalize_pcrematch_entry(pcreset->head_); + pcreset->head_ = n; + } + + aFree(pcreset); +} + +/** + * create a new pattern entry + */ +static struct pcrematch_entry *create_pcrematch_entry(struct pcrematch_set * set) { + struct pcrematch_entry * e = (struct pcrematch_entry *) + aCalloc(sizeof(struct pcrematch_entry), 1); + struct pcrematch_entry * last = set->head_; + + // Normally we would have just stuck it at the end of the list but + // this doesn't sink up with peoples usage pattern. They wanted + // the items defined first to have a higher priority then the + // items defined later.. as a result, we have to do some work up + // front.. + + /* if we are the first pattern, stick us at the end */ + if (last == NULL) { + set->head_ = e; + return e; + } + + /* Look for the last entry */ + while (last->next_ != NULL) + last = last->next_; + + last->next_ = e; + e->next_ = NULL; + + return e; +} + +/** + * define/compile a new pattern + */ + +void npc_chat_def_pattern(struct npc_data *nd, int setid, + const char *pattern, const char *label) +{ + const char *err; + int erroff; + + struct pcrematch_set * s = lookup_pcreset(nd, setid); + struct pcrematch_entry *e = create_pcrematch_entry(s); + e->pattern_ = aStrdup(pattern); + e->label_ = aStrdup(label); + e->pcre_ = pcre_compile(pattern, PCRE_CASELESS, &err, &erroff, NULL); + e->pcre_extra_ = pcre_study(e->pcre_, 0, &err); +} + +/** + * Delete everything associated with a NPC concerning the pattern + * matching code + * + * this could be more efficent but.. how often do you do this? + */ +void npc_chat_finalize(struct npc_data *nd) +{ + struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb; + if (npcParse == NULL) + return; + + while(npcParse->active_) + delete_pcreset(nd, npcParse->active_->setid_); + + while(npcParse->inactive_) + delete_pcreset(nd, npcParse->inactive_->setid_); +} + +/** + * Handler called whenever a global message is spoken in a NPC's area + */ +int npc_chat_sub(struct block_list *bl, va_list ap) +{ + struct npc_data *nd = (struct npc_data *)bl; + struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb; + unsigned char *msg; + int len, pos, i; + struct map_session_data *sd; + struct npc_label_list *lst; + struct pcrematch_set *pcreset; + + // Not interested in anything you might have to say... + if (npcParse == NULL || npcParse->active_ == NULL) + return 0; + + msg = va_arg(ap,unsigned char*); + len = va_arg(ap,int); + sd = va_arg(ap,struct map_session_data *); + + // grab the active list + pcreset = npcParse->active_; + + // interate across all active sets + while (pcreset != NULL) { + struct pcrematch_entry *e = pcreset->head_; + // interate across all patterns in that set + while (e != NULL) { + int offsets[20]; + char buf[255]; + // perform pattern match + int r = pcre_exec(e->pcre_, e->pcre_extra_, msg, len, 0, + 0, offsets, sizeof(offsets) / sizeof(offsets[0])); + if (r >= 0) { + // save out the matched strings + switch (r) { + case 10: + memcpy(buf, &msg[offsets[18]], offsets[19]); + buf[offsets[19]] = '\0'; + set_var(sd, "$p9$", buf); + case 9: + memcpy(buf, &msg[offsets[16]], offsets[17]); + buf[offsets[17]] = '\0'; + set_var(sd, "$p8$", buf); + case 8: + memcpy(buf, &msg[offsets[14]], offsets[15]); + buf[offsets[15]] = '\0'; + set_var(sd, "$p7$", buf); + case 7: + memcpy(buf, &msg[offsets[12]], offsets[13]); + buf[offsets[13]] = '\0'; + set_var(sd, "$p6$", buf); + case 6: + memcpy(buf, &msg[offsets[10]], offsets[11]); + buf[offsets[11]] = '\0'; + set_var(sd, "$p5$", buf); + case 5: + memcpy(buf, &msg[offsets[8]], offsets[9]); + buf[offsets[9]] = '\0'; + set_var(sd, "$p4$", buf); + case 4: + memcpy(buf, &msg[offsets[6]], offsets[7]); + buf[offsets[7]] = '\0'; + set_var(sd, "$p3$", buf); + case 3: + memcpy(buf, &msg[offsets[4]], offsets[5]); + buf[offsets[5]] = '\0'; + set_var(sd, "$p2$", buf); + case 2: + memcpy(buf, &msg[offsets[2]], offsets[3]); + buf[offsets[3]] = '\0'; + set_var(sd, "$p1$", buf); + case 1: + memcpy(buf, &msg[offsets[0]], offsets[1]); + buf[offsets[1]] = '\0'; + set_var(sd, "$p0$", buf); + } + + // find the target label.. this sucks.. + lst=nd->u.scr.label_list; + pos = -1; + for (i = 0; i < nd->u.scr.label_list_num; i++) { + if (strncmp(lst[i].name, e->label_, sizeof(lst[i].name)) == 0) { + pos = lst[i].pos; + break; + } + } + if (pos == -1) { + printf("Unable to find label: %s", e->label_); + // unable to find label... do something.. + return 0; + } + // run the npc script + run_script(nd->u.scr.script,pos,sd->bl.id,nd->bl.id); + return 0; + } + e = e->next_; + } + pcreset = pcreset->next_; + } + + return 0; +} + +// Various script builtins used to support these functions + +int buildin_defpattern(struct script_state *st) { + int setid=conv_num(st,& (st->stack->stack_data[st->start+2])); + char *pattern=conv_str(st,& (st->stack->stack_data[st->start+3])); + char *label=conv_str(st,& (st->stack->stack_data[st->start+4])); + struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid); + + npc_chat_def_pattern(nd, setid, pattern, label); + + return 0; +} + +int buildin_activatepset(struct script_state *st) { + int setid=conv_num(st,& (st->stack->stack_data[st->start+2])); + struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid); + + activate_pcreset(nd, setid); + + return 0; +} +int buildin_deactivatepset(struct script_state *st) { + int setid=conv_num(st,& (st->stack->stack_data[st->start+2])); + struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid); + + deactivate_pcreset(nd, setid); + + return 0; +} +int buildin_deletepset(struct script_state *st) { + int setid=conv_num(st,& (st->stack->stack_data[st->start+2])); + struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid); + + delete_pcreset(nd, setid); + + return 0; +} + + +#endif diff --git a/src/map/script.c b/src/map/script.c index 92ecd8690..24195b698 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -253,9 +253,9 @@ int buildin_failedremovecards(struct script_state *st); int buildin_marriage(struct script_state *st); int buildin_wedding_effect(struct script_state *st); int buildin_divorce(struct script_state *st); -int buildin_ispartneron(struct script_state *st); -int buildin_getpartnerid(struct script_state *st); -int buildin_warppartner(struct script_state *st); +int buildin_ispartneron(struct script_state *st); // MouseJstr +int buildin_getpartnerid(struct script_state *st); // MouseJstr +int buildin_warppartner(struct script_state *st); // MouseJstr int buildin_getitemname(struct script_state *st); int buildin_makepet(struct script_state *st); int buildin_getexp(struct script_state *st); @@ -315,6 +315,13 @@ int run_func(struct script_state *st); int mapreg_setreg(int num,int val); int mapreg_setregstr(int num,const char *str); +#ifdef PCRE_SUPPORT +int buildin_defpattern(struct script_state *st); // MouseJstr +int buildin_activatepset(struct script_state *st); // MouseJstr +int buildin_deactivatepset(struct script_state *st); // MouseJstr +int buildin_deletepset(struct script_state *st); // MouseJstr +#endif + struct { int (*func)(struct script_state *); char *name; @@ -537,10 +544,14 @@ struct { {buildin_isday,"isday",""}, // check whether it is day time [Celest] {buildin_isequipped,"isequipped","i*"}, // check whether another item/card has been equipped [Celest] {buildin_isequippedcnt,"isequippedcnt","i*"}, // check how many items/cards are being equipped [Celest] +#ifdef PCRE_SUPPORT + {buildin_defpattern, "defpattern", "iss"}, // Define pattern to listen for [MouseJstr] + {buildin_activatepset, "activatepset", "i"}, // Activate a pattern set [MouseJstr] + {buildin_deactivatepset, "deactivatepset", "i"}, // Deactive a pattern set [MouseJstr] + {buildin_deletepset, "deletepset", "i"}, // Delete a pattern set [MouseJstr] +#endif {NULL,NULL,NULL}, }; -int buildin_message(struct script_state *st); // [MouseJstr] - enum { C_NOP,C_POS,C_INT,C_PARAM,C_FUNC,C_STR,C_CONSTSTR,C_ARG, @@ -1403,6 +1414,11 @@ static int set_reg(struct map_session_data *sd,int num,char *name,void *v) return 0; } +int set_var(struct map_session_data *sd, char *name, void *val) +{ + return set_reg(sd, add_str(name), name, val); +} + /*========================================== * 文字列への変換 *------------------------------------------ diff --git a/src/map/script.h b/src/map/script.h index 759013e95..b30201a67 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -42,6 +42,10 @@ struct script_state { char * parse_script(unsigned char *,int); int run_script(char *,int,int,int); +int set_var(struct map_session_data *sd, char *name, void *val); +int conv_num(struct script_state *st,struct script_data *data); +char* conv_str(struct script_state *st,struct script_data *data); + struct dbt* script_get_label_db(); struct dbt* script_get_userfunc_db(); -- cgit v1.2.3-70-g09d2 From 126ce626c0e0ef900a19c1643efe884f95938892 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 21 Mar 2005 06:06:21 +0000 Subject: * Moved /tool and /webserver to under /src and added 'make tools' and 'make web-server' * Removed ladmin compiling from 'make sql' git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1261 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 5 + Makefile | 19 +- src/tool/Makefile | 6 + src/tool/adduser.c | 96 ++ src/tool/backup | 100 ++ src/tool/cgi/addaccount.cgi | 204 +++ src/tool/checkversion | 85 + src/tool/convert.c | 296 ++++ src/tool/getlogincount | 122 ++ src/tool/ladmin | 3793 +++++++++++++++++++++++++++++++++++++++++ src/tool/mapcheck.sh | 34 + src/tool/mapchecker.sh | 56 + src/webserver/Makefile | 20 + src/webserver/doc/API.txt | 50 + src/webserver/doc/README | 11 + src/webserver/generate.c | 38 + src/webserver/htmlstyle.c | 51 + src/webserver/logs.c | 8 + src/webserver/main.c | 142 ++ src/webserver/pages/about.c | 6 + src/webserver/pages/notdone.c | 5 + src/webserver/pages/sample.c | 24 + src/webserver/parse.c | 135 ++ 23 files changed, 5298 insertions(+), 8 deletions(-) create mode 100644 src/tool/Makefile create mode 100644 src/tool/adduser.c create mode 100644 src/tool/backup create mode 100644 src/tool/cgi/addaccount.cgi create mode 100644 src/tool/checkversion create mode 100644 src/tool/convert.c create mode 100644 src/tool/getlogincount create mode 100644 src/tool/ladmin create mode 100644 src/tool/mapcheck.sh create mode 100644 src/tool/mapchecker.sh create mode 100644 src/webserver/Makefile create mode 100644 src/webserver/doc/API.txt create mode 100644 src/webserver/doc/README create mode 100644 src/webserver/generate.c create mode 100644 src/webserver/htmlstyle.c create mode 100644 src/webserver/logs.c create mode 100644 src/webserver/main.c create mode 100644 src/webserver/pages/about.c create mode 100644 src/webserver/pages/notdone.c create mode 100644 src/webserver/pages/sample.c create mode 100644 src/webserver/parse.c (limited to 'Makefile') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 908e35f6c..a1ae1576a 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,5 +1,10 @@ Date Added +03/21 + * Moved /tool and /webserver to under /src and added 'make tools' and 'make + web-server' [celest] + * Removed ladmin compiling from 'make sql' [celest] + 03/20 * Don't register the day/night timers if any one is set to 0 [celest] * Fixed @storage / @gstorage ATcommands thanks2 Yor/Freya [Lupus] diff --git a/Makefile b/Makefile index cc95d3800..5bbe28131 100644 --- a/Makefile +++ b/Makefile @@ -91,19 +91,26 @@ txt : src/common/GNUmakefile src/login/GNUmakefile src/char/GNUmakefile src/map/ ifdef SQLFLAG -sql: src/common/GNUmakefile src/login_sql/GNUmakefile src/char_sql/GNUmakefile src/map/GNUmakefile src/ladmin/GNUmakefile src/txt-converter/login/GNUmakefile src/txt-converter/char/GNUmakefile conf +sql: src/common/GNUmakefile src/login_sql/GNUmakefile src/char_sql/GNUmakefile src/map/GNUmakefile src/txt-converter/login/GNUmakefile src/txt-converter/char/GNUmakefile conf cd src ; cd common ; $(MAKE) $(MKDEF) $@ ; cd .. cd src ; cd login_sql ; $(MAKE) $(MYLIB) $@ ; cd .. cd src ; cd char_sql ; $(MAKE) $(MYLIB) $@ ; cd .. cd src ; cd map ; $(MAKE) $(MYLIB) $@ ; cd .. - cd src ; cd ladmin ; $(MAKE) $(MKDEF) $@ ; cd .. - cd src ; cd txt-converter ; cd login ; $(MAKE) $(MYLIB) $@ ; cd .. - cd src ; cd txt-converter ; cd char ; $(MAKE) $(MYLIB) $@ ; cd .. + cd src ; cd txt-converter ; cd login ; $(MAKE) $(MYLIB) ; cd .. + cd src ; cd txt-converter ; cd char ; $(MAKE) $(MYLIB) ; cd .. else sql: $(MAKE) CC="$(CC)" OPT="$(OPT)" SQLFLAG=1 $@ endif + +tools: + cd src ; cd tool && $(MAKE) $(MKDEF) && cd .. + +webserver: + cd src ; cd webserver && $(MAKE) $(MKDEF) && cd .. + + clean: src/common/GNUmakefile src/login/GNUmakefile src/char/GNUmakefile src/map/GNUmakefile src/ladmin/GNUmakefile src/txt-converter/login/GNUmakefile src/txt-converter/char/GNUmakefile cd src ; cd common ; $(MAKE) $(MKDEF) $@ ; cd .. cd src ; cd login ; $(MAKE) $(MKDEF) $@ ; cd .. @@ -115,10 +122,6 @@ clean: src/common/GNUmakefile src/login/GNUmakefile src/char/GNUmakefile src/map cd src ; cd txt-converter ; cd login ; $(MAKE) $(MKLIB) $@ ; cd .. cd src ; cd txt-converter ; cd char ; $(MAKE) $(MKLIB) $@ ; cd .. -tools: - cd tool && $(MAKE) $(MKDEF) && cd .. - $(CC) -o setupwizard setupwizard.c - src/common/GNUmakefile: src/common/Makefile sed -e 's/$$>/$$^/' src/common/Makefile > src/common/GNUmakefile src/login/GNUmakefile: src/login/Makefile diff --git a/src/tool/Makefile b/src/tool/Makefile new file mode 100644 index 000000000..873404113 --- /dev/null +++ b/src/tool/Makefile @@ -0,0 +1,6 @@ +all: + $(CC) -o adduser adduser.c + +clean: + rm -f adduser + rm -f *.exe diff --git a/src/tool/adduser.c b/src/tool/adduser.c new file mode 100644 index 000000000..96b9fc3df --- /dev/null +++ b/src/tool/adduser.c @@ -0,0 +1,96 @@ +/* + This program adds an user to account.txt + Don't usr it When login-sever is working. +*/ + +#include +#include +#include + +char *account_txt = "../save/account.txt"; + +//----------------------------------------------------- +// 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; +} + +int main(int argc, char *argv[]) { + + char username[24]; + char password[24]; + char sex[2]; + + int next_id, id; + char line[1024]; + + // Check to see if account.txt exists. + printf("Checking if '%s' file exists...\n", account_txt); + FILE *FPaccin = fopen(account_txt, "r"); + if (FPaccin == NULL) { + printf("'%s' file not found!\n", account_txt); + printf("Run the setup wizard please.\n"); + exit(0); + } + + next_id = 2000000; + while(fgets(line, sizeof(line)-1, FPaccin)) { + if (line[0] == '/' && line[1] == '/') { continue; } + if (sscanf(line, "%d\t%%newid%%\n", &id) == 1) { + if (next_id < id) { + next_id = id; + } + } else { + sscanf(line,"%i%[^ ]", &id); + if (next_id <= id) { + next_id = id +1; + } + } + } + close(FPaccin); + printf("File exists.\n"); + + printf("Don't create an account if the login-server is online!!!\n"); + printf("If the login-server is online, press ctrl+C now to stop this software.\n"); + printf("\n"); + + strcpy(username, ""); + while (strlen(username) < 4 || strlen(username) > 23) { + printf("Enter an username (4-23 characters): "); + scanf("%s", &username); + username[23] = 0; + remove_control_chars(username); + } + + strcpy(password, ""); + while (strlen(password) < 4 || strlen(password) > 23) { + printf("Enter a password (4-23 characters): "); + scanf("%s", &password); + password[23] = 0; + remove_control_chars(password); + } + + strcpy(sex, ""); + while (strcmp(sex, "F") != 0 && strcmp(sex, "M") != 0) { + printf("Enter a gender (M for male, F for female): "); + scanf("%s", &sex); + } + + FILE *FPaccout = fopen(account_txt, "r+"); + fseek(FPaccout, 0, SEEK_END); + fprintf(FPaccout, "%i %s %s - %s -\r\n", next_id, username, password, sex); + close(FPaccout); + + printf("Account added.\n"); +} diff --git a/src/tool/backup b/src/tool/backup new file mode 100644 index 000000000..2b5a95814 --- /dev/null +++ b/src/tool/backup @@ -0,0 +1,100 @@ +#!/usr/bin/perl + +########################################################################## +# Athena用データバックアップツール +# +#  Athenaの各種データファイル*.txtをバックアップするツール +# +#------------------------------------------------------------------------- +# 設定方法 +#  実行する時のカレントフォルダからのデータへのパス、ファイルのリストを +#  正しく設定します。バックアップ先のフォルダは自動作成されないので、 +#  自分で作成しておく必要があります。 +#  フォルダの最後の「/」は省略できません。 +# +#  フォルダは引数でも指定できます。例>./backup ../save/ ./backup_data/ +#  フォルダの最後の「/」は省略できません。 +# +#  実行するとバックアップ先のフォルダへ、ファイル名に現在の日付と時刻を +#  つけてファイルをコピーします。 +# +# * toolフォルダ内にbackup_dataフォルダを作成し、 +#   athena.shの中に「./tool/backup ./save/ ./tool/backup_data/」 +# という行を追加すると、athenaを起動するたびにバックアップが取れます +# +# 復元するときは引数に「-r 日付と時刻」を指定します。 +#  またその後ろにフォルダを指定することも出来ます +#  例1> ./backup -r 200309191607 +#  例2> ./backup -r 200309191607 ../save ./backup_data/ +#  この例では2003/09/19の16:07分にバックアップしたデータを復元しています +# +#  復元するとき、Athenaディレクトリにあるデータは *.bak に名前を変更して +#  残しているので、いらない場合は rm *.bak などで消してください。 +# +########################################################################## + +$sdir="../save/"; #バックアップ元(Athenaのディレクトリ/save/) +$tdir="./backup_data/"; #バックアップ先 + +@files=( #ファイルのリスト + "account","athena","storage","party","guild","castle","pet" +); + + +#-------------------------------設定ここまで----------------------------- + + + + + + + + + + + +if($ARGV[0]=~/^\-r$/i || $ARGV[0]=~/\-\-(recover|restore)/i){ + #復元処理 + + $file=$ARGV[1]; + $sdir=$ARGV[2]||$sdir; + $tdir=$ARGV[3]||$tdir; + &restorecopy($_) foreach @files; + exit(0); +} + +#バックアップ処理 +$sdir=$ARGV[0]||$sdir; +$tdir=$ARGV[1]||$tdir; + +unless( -d $tdir ){ + print "$0: \"$tdir\" : No such directory\n"; + exit(1); +} + +(undef,$min,$hour,$day,$month,$year)=localtime; + +$file=sprintf("%04d%02d%02d%02d%02d", + $year+1900, $month+1, $day, $hour, $min ); + +&backupcopy($_) foreach @files; +exit(0); + +sub backupcopy { + my($name)= @_; + system("cp $sdir$name.txt $tdir$name$file.txt"); +} + +sub restorecopy { + my($name)= @_; + unless( -f "$sdir$name.txt" ){ + printf("$0: \"$sdir$name.txt\" not found!\n"); + return 0; + } + unless( -f "$tdir$name$file.txt" ){ + printf("$0: \"$tdir$name$file.txt\" not found!\n"); + return 0; + } + rename "$sdir$name.txt","$sdir$name.bak"; + system("cp $tdir$name$file.txt $sdir$name.txt"); +} diff --git a/src/tool/cgi/addaccount.cgi b/src/tool/cgi/addaccount.cgi new file mode 100644 index 000000000..2134a78a3 --- /dev/null +++ b/src/tool/cgi/addaccount.cgi @@ -0,0 +1,204 @@ +#!/usr/bin/perl + +#========================================================================= +# addaccount.cgi ver.1.00 +# ladminをラップした、アカウントを作成するCGI。 +# ladmin ver.1.04での動作を確認。 +# +# ** 設定方法 ** +# +# - 下の$ladmin変数にladminへのパスを設定すること。 +# - UNIX系OSで使用する場合はladminと共に改行コードを変換すること、また +# ファイル先頭行をperlの正しいパスにすること。例> $ which perl +# - サーバープログラムやブラウザによっては $cgiuri にこのファイルへの +# 完全なURIをセットしなければならない場合もある。 +# - perlにパスが通っていない場合は $perl をperlへの正しいパスにすること。 +# - 他は普通のCGIと同じです。(実行権やcgi-binフォルダなど) +# +# ** その他 ** +# addaccount.cgi をブラウザで開くとサンプルHTML(そのまま使えます)が +# 開きます。また、このcgiはブラウザから送られるAccept-Languageが +# jaで始まっていればメッセージの一部を日本語に変換します。 +# (IEならインターネットオプションの言語設定で一番上に日本語を置く) +# それ以外の場合は英語のまま出力します。 +#------------------------------------------------------------------------- + +my($ladmin) = "../ladmin"; # ladminのパス(おそらく変更が必要) + +my($cgiuri) = "./addaccount.cgi"; # このファイルのURI +my($perl) = "perl"; # perlのコマンド名 + + + +#--------------------------- 設定ここまで -------------------------------- + + + + + + +use strict; +use CGI; + +my($cgi)= new CGI; +my(%langconv)=( + 'Athena login-server administration tool.*' => '', + 'logged on.*' => '', +); + +# ----- 日本語環境なら変換テーブルをセット ----- +if($ENV{'HTTP_ACCEPT_LANGUAGE'}=~/^ja/){ + my(%tmp)=( + 'Account \[(.+)\] is successfully created.*' + => 'アカウント "$1" を作成しました.', + 'Account \[(.+)\] creation failed\. same account exists.*' + => 'アカウント "$1" は既に存在します.', + 'Illeagal charactor found in UserID.*' + => 'IDの中に不正な文字があります.', + 'Illeagal charactor found in Password.*' + => 'Passwordの中に不正な文字があります.', + 'input UserID 4-24 bytes.' + => 'IDは半角4〜24文字で入力してください.', + 'input Password 4-24 bytes.' + => 'Passwordは半角4〜24文字で入力してください.', + 'Illeagal gender.*' + => '性別がおかしいです.', + 'Cant connect to login server.*' + => 'ログインサーバーに接続できません.', + 'login error.*' + => 'ログインサーバーへの管理者権限ログインに失敗しました', + "Can't execute ladmin.*" + => 'ladminの実行に失敗しました', + 'UserID "(.+)" is already used.*' + => 'ID "$1" は既に使用されています.', + 'You can use UserID \"(.+)\".*' + => 'ID "$1" は使用可能です.', + + 'account making' =>'アカウント作成', + '\>UserID' =>'>ID', + '\>Password' =>'>パスワード', + '\>Gender' =>'>性別', + '\>Male' =>'>男性', + '\>Female' =>'>女性', + '\"Make Account\"' =>'"アカウント作成"', + '\"Check UserID\"' =>'"IDのチェック"', + ); + map { $langconv{$_}=$tmp{$_}; } keys (%tmp); +} + +# ----- 追加 ----- +if( $cgi->param("addaccount") ){ + my($userid)= $cgi->param("userid"); + my($passwd)= $cgi->param("passwd"); + my($gender)= lc(substr($cgi->param("gender"),0,1)); + if(length($userid)<4 || length($userid)>24){ + HttpError("input UserID 4-24 bytes."); + } + if(length($passwd)<4 || length($passwd)>24){ + HttpError("input Password 4-24 bytes."); + } + if($userid=~/[^0-9A-Za-z\@\_\-\']/){ + HttpError("Illeagal charactor found in UserID."); + } + if($passwd=~/[\x00-\x1f\x80-\xff\']/){ + HttpError("Illeagal charactor found in Password."); + } + if($gender!~/[mf]/){ + HttpError("Gender error."); + } + open PIPE,"$perl $ladmin --add $userid $gender $passwd |" + or HttpError("Can't execute ladmin."); + my(@msg)=; + close PIPE; + HttpMsg(@msg); +} +# ----- 存在チェック ----- +elsif( $cgi->param("check") ){ + my($userid)= $cgi->param("userid"); + if(length($userid)<4 || length($userid)>24){ + HttpError("input UserID 4-24 bytes."); + } + if($userid=~/[^0-9A-Za-z\@\_\-\']/){ + HttpError("Illeagal charactor found in UserID."); + } + open PIPE,"$perl $ladmin --search --regex \\b$userid\\b |" + or HttpError("Can't execute ladmin."); + my(@msg)=; + close PIPE; + if(scalar(@msg)==6 && (split /[\s\0]+/,substr($msg[4],11,24))[0] eq $userid){ + HttpMsg("NG : UserID \"$userid\" is already used."); + }elsif(scalar(@msg)==5){ + HttpMsg("OK : You can use UserID \"$userid\""); + } + HttpError("ladmin error ?\n---output---\n",@msg); +} + +# ----- フォーム ----- +else{ + print LangConv( <<"EOM" ); +Content-type: text/html\n + + + Athena account making cgi + + +

Athena account making cgi

+
+ + + + + + + + + + + + + + + + +
UserID
Password
Gender + Male + Female +
+ + +
+
+ + +EOM + exit; +} + +sub LangConv { + my(@lst)= @_; + my($a,$b,@out)=(); + foreach $a(@lst){ + foreach $b(keys %langconv){ + $a=~s/$b/$langconv{$b}/g; + my($rep1)=$1; + $a=~s/\$1/$rep1/g; + } + push @out,$a; + } + return @out; +} + +sub HttpMsg { + my($msg)=join("", LangConv(@_)); + $msg=~s/\n/
\n/g; + print LangConv("Content-type: text/html\n\n"),$msg; + exit; +} + +sub HttpError { + my($msg)=join("", LangConv(@_)); + $msg=~s/\n/
\n/g; + print LangConv("Content-type: text/html\n\n"),$msg; + exit; +} + diff --git a/src/tool/checkversion b/src/tool/checkversion new file mode 100644 index 000000000..135165236 --- /dev/null +++ b/src/tool/checkversion @@ -0,0 +1,85 @@ +#!/usr/bin/perl -w + +########################################################################## +# INFORMATION TOOL ABOUT THE SERVERS VERSION OF ATHENA +# +# By connection on a server, this software display the version of the +# designed server. +#------------------------------------------------------------------------- +# Usages: +# ./checkversion IP:port +# ./checkversion IP port +# perl checkversion IP:port +# perl checkversion IP port +# +# note: default port: 6900 +# +# When successfull, the software return the value 0. +# +########################################################################## + +#------------------------- start of configuration ------------------------ + +$connecttimeout = 10; # Connection Timeout (in seconds) + +#-------------------------- End of configuration ------------------------- + +use IO::Socket; + +unless($ARGV[0]) { + print "USAGE: $0 server_ip:port\n"; + exit(1); +} + +$server = $ARGV[0]; +$port = $ARGV[1]; +$port = $1 if ($server =~ s/:(\d+)//); +$port ||= 6900; + +# Connection to the server +my($so,$er) = (); +eval{ + $so = IO::Socket::INET->new( + PeerAddr=> $server, + PeerPort=> $port, + Proto => "tcp", + Timeout => $connecttimeout) or $er = 1; +}; + +if($er || $@) { + print "Can't not connect to server [$server:$port] !\n"; + exit(2); +} + +# Request for the server version +print $so pack("v",30000); # 0x7530 +$so->flush(); + +# Receiving of the answer of the server +if (read($so,$buf,10) < 10) { + print "Invalid answer. It isn't an athena server or it is a too old version.\n"; + exit(5); +} + +# Sending end of connection to the server +print $so pack("v",30002); # 0x7532 +$so->flush(); + +# Analyse of the answer +my($ret,$maver,$miver,$rev,$dev,$mod,$type,$mdver) = unpack("v c6 v",$buf); + +if ($ret != 30001) { # 0x7531 + print "Invalid answer. It isn't an athena server or it is a too old version.\n"; + exit(6); +} + +my(@stype) = (); +foreach $i(0..3) { + push @stype,(("login","char","inter","map")[$i]) if( $type & (1<<$i) ); +} +print " ".join("/",@stype)." server [$server:$port].\n"; +printf " Athena version %s-%d.%d", ("stable","dev")[$dev], $maver,$miver; +printf " revision %d",$rev if $rev; +printf "%s%d\n",("","-mod")[$mod],$mdver; + +exit(0); diff --git a/src/tool/convert.c b/src/tool/convert.c new file mode 100644 index 000000000..6cf36a686 --- /dev/null +++ b/src/tool/convert.c @@ -0,0 +1,296 @@ +#include +#include + +#define RETCODE "\r\n" + +#define MAX_INVENTORY 100 +#define MAX_CART 100 +#define MAX_SKILL 350 +#define GLOBAL_REG_NUM 16 + +struct item { + int id; + short nameid; + short amount; + short equip; + char identify; + char refine; + char attribute; + short card[4]; +}; +struct point{ + char map[16]; + short x,y; +}; +struct skill { + unsigned short id,lv,flag; +}; +struct global_reg { + char str[16]; + int value; +}; + +struct mmo_charstatus { + int char_id; + int account_id; + int base_exp,job_exp,zeny; + + short class; + short status_point,skill_point; + short hp,max_hp,sp,max_sp; + short option,karma,manner; + short hair,hair_color,clothes_color; + int party_id,guild_id,pet_id; + + short weapon,shield; + short head_top,head_mid,head_bottom; + + char name[24]; + unsigned char base_level,job_level; + unsigned char str,agi,vit,int_,dex,luk,char_num,sex; + + struct point last_point,save_point,memo_point[3]; + struct item inventory[MAX_INVENTORY],cart[MAX_CART]; + struct skill skill[MAX_SKILL]; + int global_reg_num; + struct global_reg global_reg[GLOBAL_REG_NUM]; +}; + +int mmo_char_tostr(char *str,struct mmo_charstatus *p) +{ + int i; + sprintf(str,"%d\t%d,%d\t%s\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" + "\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", + p->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->hp,p->max_hp,p->sp,p->max_sp, + p->str,p->agi,p->vit,p->int_,p->dex,p->luk, + p->status_point,p->skill_point, + p->option,p->karma,p->manner, // + p->party_id,p->guild_id,p->pet_id, + p->hair,p->hair_color,p->clothes_color, + p->weapon,p->shield,p->head_top,p->head_mid,p->head_bottom, + p->last_point.map,p->last_point.x,p->last_point.y, // + p->save_point.map,p->save_point.x,p->save_point.y + ); + strcat(str,"\t"); + for(i=0;i<3;i++) + if(p->memo_point[i].map[0]){ + sprintf(str+strlen(str),"%s,%d,%d",p->memo_point[i].map,p->memo_point[i].x,p->memo_point[i].y); + } + strcat(str,"\t"); + for(i=0;iinventory[i].nameid){ + sprintf(str+strlen(str),"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", + p->inventory[i].id,p->inventory[i].nameid,p->inventory[i].amount,p->inventory[i].equip, + p->inventory[i].identify,p->inventory[i].refine,p->inventory[i].attribute, + p->inventory[i].card[0],p->inventory[i].card[1],p->inventory[i].card[2],p->inventory[i].card[3]); + } + strcat(str,"\t"); + for(i=0;icart[i].nameid){ + sprintf(str+strlen(str),"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", + p->cart[i].id,p->cart[i].nameid,p->cart[i].amount,p->cart[i].equip, + p->cart[i].identify,p->cart[i].refine,p->cart[i].attribute, + p->cart[i].card[0],p->cart[i].card[1],p->cart[i].card[2],p->cart[i].card[3]); + } + strcat(str,"\t"); + for(i=0;iskill[i].id){ + sprintf(str+strlen(str),"%d,%d ",p->skill[i].id,p->skill[i].lv); + } + strcat(str,"\t"); + for(i=0;iglobal_reg_num;i++) + sprintf(str+strlen(str),"%s,%d ",p->global_reg[i].str,p->global_reg[i].value); + strcat(str,"\t"); + return 0; +} + +int mmo_char_fromstr(char *str,struct mmo_charstatus *p) +{ + int tmp_int[256]; + int set,next,len,i; + + set=sscanf(str,"%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" + "\t%d,%d,%d\t%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" + "\t%[^,],%d,%d\t%[^,],%d,%d%n", + &tmp_int[0],&tmp_int[1],&tmp_int[2],p->name, // + &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],&tmp_int[12], + &tmp_int[13],&tmp_int[14],&tmp_int[15],&tmp_int[16],&tmp_int[17],&tmp_int[18], + &tmp_int[19],&tmp_int[20], + &tmp_int[21],&tmp_int[22],&tmp_int[23], // + &tmp_int[24],&tmp_int[25], + &tmp_int[26],&tmp_int[27],&tmp_int[28], + &tmp_int[29],&tmp_int[30],&tmp_int[31],&tmp_int[32],&tmp_int[33], + p->last_point.map,&tmp_int[34],&tmp_int[35], // + p->save_point.map,&tmp_int[36],&tmp_int[37],&next + ); + p->char_id=tmp_int[0]; + p->account_id=tmp_int[1]; + p->char_num=tmp_int[2]; + p->class=tmp_int[3]; + p->base_level=tmp_int[4]; + p->job_level=tmp_int[5]; + p->base_exp=tmp_int[6]; + p->job_exp=tmp_int[7]; + p->zeny=tmp_int[8]; + p->hp=tmp_int[9]; + p->max_hp=tmp_int[10]; + p->sp=tmp_int[11]; + p->max_sp=tmp_int[12]; + p->str=tmp_int[13]; + p->agi=tmp_int[14]; + p->vit=tmp_int[15]; + p->int_=tmp_int[16]; + p->dex=tmp_int[17]; + p->luk=tmp_int[18]; + p->status_point=tmp_int[19]; + p->skill_point=tmp_int[20]; + p->option=tmp_int[21]; + p->karma=tmp_int[22]; + p->manner=tmp_int[23]; + p->party_id=tmp_int[24]; + p->guild_id=tmp_int[25]; + p->pet_id=0; + p->hair=tmp_int[26]; + p->hair_color=tmp_int[27]; + p->clothes_color=tmp_int[28]; + p->weapon=tmp_int[29]; + p->shield=tmp_int[30]; + p->head_top=tmp_int[31]; + p->head_mid=tmp_int[32]; + p->head_bottom=tmp_int[33]; + p->last_point.x=tmp_int[34]; + p->last_point.y=tmp_int[35]; + p->save_point.x=tmp_int[36]; + p->save_point.y=tmp_int[37]; + if(set!=41) + return 0; + if(str[next]=='\n' || str[next]=='\r') + return 1; // 新規データ + next++; + for(i=0;str[next] && str[next]!='\t';i++){ + set=sscanf(str+next,"%[^,],%d,%d%n",p->memo_point[i].map,&tmp_int[0],&tmp_int[1],&len); + if(set!=3) + return 0; + p->memo_point[i].x=tmp_int[0]; + p->memo_point[i].y=tmp_int[1]; + next+=len; + if(str[next]==' ') + next++; + } + next++; + for(i=0;str[next] && str[next]!='\t';i++){ + set=sscanf(str+next,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", + &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); + if(set!=11) + return 0; + p->inventory[i].id=tmp_int[0]; + p->inventory[i].nameid=tmp_int[1]; + p->inventory[i].amount=tmp_int[2]; + p->inventory[i].equip=tmp_int[3]; + p->inventory[i].identify=tmp_int[4]; + p->inventory[i].refine=tmp_int[5]; + p->inventory[i].attribute=tmp_int[6]; + p->inventory[i].card[0]=tmp_int[7]; + p->inventory[i].card[1]=tmp_int[8]; + p->inventory[i].card[2]=tmp_int[9]; + p->inventory[i].card[3]=tmp_int[10]; + next+=len; + if(str[next]==' ') + next++; + } + next++; + for(i=0;str[next] && str[next]!='\t';i++){ + set=sscanf(str+next,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", + &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); + if(set!=11) + return 0; + p->cart[i].id=tmp_int[0]; + p->cart[i].nameid=tmp_int[1]; + p->cart[i].amount=tmp_int[2]; + p->cart[i].equip=tmp_int[3]; + p->cart[i].identify=tmp_int[4]; + p->cart[i].refine=tmp_int[5]; + p->cart[i].attribute=tmp_int[6]; + p->cart[i].card[0]=tmp_int[7]; + p->cart[i].card[1]=tmp_int[8]; + p->cart[i].card[2]=tmp_int[9]; + p->cart[i].card[3]=tmp_int[10]; + next+=len; + if(str[next]==' ') + next++; + } + next++; + for(i=0;str[next] && str[next]!='\t';i++){ + set=sscanf(str+next,"%d,%d%n", + &tmp_int[0],&tmp_int[1],&len); + if(set!=2) + return 0; + p->skill[tmp_int[0]].id=tmp_int[0]; + p->skill[tmp_int[0]].lv=tmp_int[1]; + next+=len; + if(str[next]==' ') + next++; + } + next++; + for(i=0;str[next] && str[next]!='\t' && str[next]!='\n' && str[next]!='\r';i++){ //global_reg実装以前のathena.txt互換のため一応'\n'チェック + set=sscanf(str+next,"%[^,],%d%n", + p->global_reg[i].str,&p->global_reg[i].value,&len); + if(set!=2) + return 0; + next+=len; + if(str[next]==' ') + next++; + } + p->global_reg_num=i; + return 1; +} + +int mmo_char_convert(char *fname1,char *fname2) +{ + char line[65536]; + int ret; + struct mmo_charstatus char_dat; + FILE *ifp,*ofp; + + ifp=fopen(fname1,"r"); + ofp=fopen(fname2,"w"); + if(ifp==NULL) { + printf("file not found %s\n",fname1); + return 0; + } + if(ofp==NULL) { + printf("file open error %s\n",fname2); + return 0; + } + while(fgets(line,65535,ifp)){ + memset(&char_dat,0,sizeof(struct mmo_charstatus)); + ret=mmo_char_fromstr(line,&char_dat); + if(ret){ + mmo_char_tostr(line,&char_dat); + fprintf(ofp,"%s" RETCODE,line); + } + } + fcloseall(); + return 0; +} + +int main(int argc,char *argv[]) +{ + if(argc < 3) { + printf("Usage: convert \n"); + exit(0); + } + mmo_char_convert(argv[1],argv[2]); + + return 0; +} diff --git a/src/tool/getlogincount b/src/tool/getlogincount new file mode 100644 index 000000000..6a209924f --- /dev/null +++ b/src/tool/getlogincount @@ -0,0 +1,122 @@ +#!/usr/bin/perl -w + +########################################################################## +# INFORMATION TOOL ABOUT THE # OF ONLINE PLAYERS ON ATHENA SERVERS +# +# By connection on the athena login-server, this software displays the +# number of online players. +# +#------------------------------------------------------------------------- +# Software usage: +# Configure the IP, the port and a valid account of the server. +# After, use at your choice: +# ./getlogincount - display the number of online players on all servers. +# ./getlogincount --premier or +# ./getlogincount --first -- display the number of online players of the +# first server in the received list. +# ./getlogincount [servername] -- display the number of online players +# of the specified server. +# +# If successfull, the software return the value 0. +# +########################################################################## + +#------------------------------ CONFIGURATION ---------------------------- + +$loginserverip = "127.0.0.1"; # IP of the login-server +$loginserverport = 6900; # port of the login-server +$loginaccount = "s1"; # a valid account name +$loginpasswd = "p1"; # the password of the valid account name + +$connecttimeout = 10; # Connection timeout (in seconds) + +#------------------------------------------------------------------------- + +use IO::Socket; + +my($sname) = $ARGV[0]; +if (!defined($sname)) { + $sname = ""; +} + +# Connection to the login-server +my($so,$er) = (); +eval{ + $so = IO::Socket::INET->new( + PeerAddr=> $loginserverip, + PeerPort=> $loginserverport, + Proto => "tcp", + Timeout => $connecttimeout) or $er=1; +}; +if($er || $@){ + print "Can't not connect to the login-server [${loginserverip}:$loginserverport] !\n"; + exit(2); +} + +# Request to connect on login-server +print $so pack("v V a24 a24 C",0x0064,9,$loginaccount,$loginpasswd,3); +$so->flush(); + +# Fail to connect +if(unpack("v", &soread(\$so,2)) != 0x0069) { + print "Login error.\n"; + exit(3); +} + +# Get length of the received packet +my($plen) = unpack("v",&soread(\$so,2))-4; + +# Suppress information of the account (we need only information about the servers) +&soread(\$so,43); +$plen -= 43; + +# Check about the number of online servers +if ($plen < 32) { + printf "No server is connected to login-server.\n"; + exit(1); +} + +# Read information of the servers +my(@slist) = (); +for(;$plen > 0;$plen -= 32) { + my($name,$count) = unpack("x6 a20 V",&soread(\$so,32)); + $name = substr($name,0,index($name,"\0")); + push @slist, [ $name, $count ]; +} + +# Display the result +if($sname eq "--first" || $sname eq "--premier") { # If we ask only for the first server + printf "%-20s : %5d\n",$slist[0][0],$slist[0][1]; +} elsif ($sname eq "") { # If we ask for all servers + foreach $i(@slist) { + printf "%-20s : %5d\n",$i->[0],$i->[1]; + } +} else { # If we ask for a specified server (by its name) + my($flag) = 1; + foreach $i(@slist) { + if($i->[0] eq $sname) { + printf "%-20s : %5d\n",$i->[0],$i->[1]; + $flag = 0; + } + } + if($flag) { # If the server doesn't exist + printf "The server [$sname] doesn't exist.\n"; + exit(1); + } +} + +# End of the software +$so->shutdown(2); +$so->close(); +exit(0); + +# Sub-function: get data from the socket +sub soread { + my($so,$len) = @_; + my($sobuf); + if(read($$so,$sobuf,$len) < $len) { + print "Socket read error.\n"; + exit(5); + } + return $sobuf; +}; diff --git a/src/tool/ladmin b/src/tool/ladmin new file mode 100644 index 000000000..e3319d5de --- /dev/null +++ b/src/tool/ladmin @@ -0,0 +1,3793 @@ +#!/usr/bin/perl +use POSIX; +########################################################################## +# EAthena login-server remote administration tool +# New ladamin by [Yor] +########################################################################## +#-------------------------------INSTRUCTIONS------------------------------ +# Set the 4 variables below: +# IP of the login server. +# Port where the login-server listens incoming packets. +# Password of administration (same of config_athena.conf). +# Displayed language of the sofware (if not correct, english is used). +# IMPORTANT: +# Be sure that you authorize remote administration in login-server +# (see login_athena.conf, 'admin_state' parameter) +#------------------------------------------------------------------------- +my($loginserverip) = "127.0.0.1"; # IP of login-server +my($loginserverport) = 6900; # Port of login-server +my($loginserveradminpassword) = "admin"; # Administration password +my($connecttimeout) = 10; # Timeout of connection (in seconds) +my($passenc) = 2; # Encoding type of the password +my($defaultlanguage) = "E"; # Default language (F: Fran軋is/E: English) + # (if it's not 'F', default is English) + +#------------------------------------------------------------------------- +# LIST of COMMANDs that you can type at the prompt: +# To use these commands you can only type only the first letters. +# You must type a minimum of letters (you can not type 'a', +# because ladmin doesn't know if it's for 'aide' or for 'add') +# q <= quit, li <= list, pass <= passwd, etc. +# +# Note: every time you must give a account_name, you can use "" or '' (spaces can be included) +# +# aide/help/? +# Display the description of the commands +# aide/help/? [command] +# Display the description of the specified command +# +# add +# Create an account with the default email (a@a.com). +# Concerning the sex, only the first letter is used (F or M). +# The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail. +# When the password is omitted, the input is done without displaying of the pressed keys. +# add testname Male testpass +# +# ban/banish yyyy/mm/dd hh:mm:ss +# Changes the final date of a banishment of an account. +# Same command of banset, except that account_name is at end +# +# banadd +# Adds or substracts time from the final date of a banishment of an account. +# Modifier is done as follows: +# Adjustment value (-1, 1, +1, etc...) +# Modified element: +# a or y: year +# m: month +# j or d: day +# h: hour +# mn: minute +# s: second +# banadd testname +1m-2mn1s-6y +# this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. +# NOTE: If you modify the final date of a non-banished account, +# you fix the final date to (actual time +- adjustments) +# +# banset yyyy/mm/dd [hh:mm:ss] +# Changes the final date of a banishment of an account. +# Default time: 23:59:59 +# banset 0 +# Set a non-banished account (0 = unbanished). +# +# block +# Set state 5 (You have been blocked by the GM Team) to an account. +# Same command of state 5. +# +# check +# Check the validity of a password for an account +# NOTE: Server will never sends back a password. +# It's the only method you have to know if a password is correct. +# The other method is to have a ('physical') access to the accounts file. +# +# create +# Like the 'add' command, but with e-mail moreover. +# create testname Male my@mail.com testpass +# +# del +# Remove an account. +# This order requires confirmation. After confirmation, the account is deleted. +# +# email +# Modify the e-mail of an account. +# +# getcount +# Give the number of players online on all char-servers. +# +# gm [GM_level] +# Modify the GM level of an account. +# Default value remove GM level (GM level = 0). +# gm testname 80 +# +# id +# Give the id of an account. +# +# info +# Display complete information of an account. +# +# kami +# Sends a broadcast message on all map-server (in yellow). +# kamib +# Sends a broadcast message on all map-server (in blue). +# +# language +# Change the language of displaying. +# +# list/ls [start_id [end_id]] +# Display a list of accounts. +# 'start_id', 'end_id': indicate end and start identifiers. +# Research by name is not possible with this command. +# list 10 9999999 +# +# listBan/lsBan [start_id [end_id]] +# Like list/ls, but only for accounts with state or banished +# +# listGM/lsGM [start_id [end_id]] +# Like list/ls, but only for GM accounts +# +# listOK/lsOK [start_id [end_id]] +# Like list/ls, but only for accounts without state and not banished +# +# memo +# Modify the memo of an account. +# 'memo': it can have until 253 characters (with spaces or not). +# +# name +# Give the name of an account. +# +# passwd +# Change the password of an account. +# When new password is omitted, the input is done without displaying of the pressed keys. +# +# quit/end/exit +# End of the program of administration +# +# reloadGM +# Reload GM configuration file +# +# search +# Seek accounts. +# Displays the accounts whose names correspond. +# search -r/-e/--expr/--regex +# Seek accounts by regular expression. +# Displays the accounts whose names correspond. +# +# sex +# Modify the sex of an account. +# sex testname Male +# +# state +# Change the state of an account. +# 'new_state': state is the state of the packet 0x006a + 1. The possibilities are: +# 0 = Account ok 6 = Your Game's EXE file is not the latest version +# 1 = Unregistered ID 7 = You are Prohibited to log in until %s +# 2 = Incorrect Password 8 = Server is jammed due to over populated +# 3 = This ID is expired 9 = No MSG +# 4 = Rejected from Server 100 = This ID has been totally erased +# 5 = You have been blocked by the GM Team +# all other values are 'No MSG', then use state 9 please. +# 'error_message_#7': message of the code error 6 = Your are Prohibited to log in until %s (packet 0x006a) +# +# timeadd +# Adds or substracts time from the validity limit of an account. +# Modifier is done as follows: +# Adjustment value (-1, 1, +1, etc...) +# Modified element: +# a or y: year +# m: month +# j or d: day +# h: hour +# mn: minute +# s: second +# timeadd testname +1m-2mn1s-6y +# this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. +# NOTE: You can not modify a unlimited validity limit. +# If you want modify it, you want probably create a limited validity limit. +# So, at first, you must set the validity limit to a date/time. +# +# timeset yyyy/mm/dd [hh:mm:ss] +# Changes the validity limit of an account. +# Default time: 23:59:59 +# timeset 0 +# Gives an unlimited validity limit (0 = unlimited). +# +# unban/unbanish +# Unban an account. +# Same command of banset 0. +# +# unblock +# Set state 0 (Account ok) to an account. +# Same command of state 0. +# +# version +# Display the version of the login-server. +# +# who +# Displays complete information of an account. +# +#------------------------------------------------------------------------- +# Possibilities to execute ladmin in command line by usage of the software with a parameter: +# ./ladmin --mode param1 ... +# +# --makesymlink -- Create the symbolic links for a use in shell +# --add -- Create an account with the default email (or -a) +# --ban yyyy/mm/dd hh:mm:ss -- Change the final date of a banishment of an account (or -b) +# --banadd -- Add or substract time from the final date of a banishment of an account (or - ba) +# --banset yyyy/mm/dd [hh:mm:ss] -- Change the final date of a banishment of an account (or -bs) +# --banset 0 -- Unbanish an account (or -bs) +# --block -- Set state 5 to an account (or -bl) +# --check -- Check the validity of a password for an account (or -check) +# --create -- Create an account with email (or -c) +# --del -- Remove an account (or -d) +# --email -- Modify an email of an account (or -e) +# --getcount -- Give the number of players online on all char-servers (or -g) +# --gm -- Change the GM level of an account (or -gm) +# --id -- Give the id of an account (or -i) +# --info -- Display complete information of an account (or -info) +# --kami -- Sends a broadcast message on all map-server (in yellow). +# --kamib -- Sends a broadcast message on all map-server (in blue). +# --language -- Change the language of displaying (-lang). +# --list [First_id [Last_id]] -- Display a list of accounts (or -l) +# --listBan [start_id [end_id]] -- Display a list of accounts with state or banished (or -lBan) +# --listGM [First_id [Last_id]] -- Display a list of GM accounts (or -lGM) +# --listOK [start_id [end_id]] -- Display a list of accounts without state and not banished (or -lOK) +# --memo -- Modify the memo of an account (or -e) +# --name -- Give the name of an account (or -n) +# --passwd -- Change the password of an account (or -p) +# --reloadGM -- Reload GM configuration file (or -r) +# --search -- Seek accounts (or -s) +# --search -e/-r/--expr/--regex -- Seek accounts by REGEX (or -s) +# --sex -- Change the sex of an account (or -sex) +# --state -- Change the state of an account (or -t) +# --timeadd -- Add or substract time from the validity limit of an account (or - ta) +# --timeset yyyy/mm/dd [hh:mm:ss] -- Change the validify limit of an account (or -ts) +# --timeset 0 -- Give a unlimited validity limit (or -ts) +# --unban/unbanish -- Unban an account (or -uba) +# --unblock -- Set state 0 to an account (or -ubl) +# --version -- Display the version of the login-server (or -v) +# --who -- Display complete information of an account (or -w) +# +# ./ladmin --addaccount testname Male testpass +# +#------------------------------------------------------------------------- +# Possibilities to execute ladmin with symbolic links in Shell +# To create the symbolic links, execute ladmin with the '-- makesymlink' option. +# +# addaccount -- Create an account with the default email +# banaccount yyyy/mm/dd hh:mm:ss -- Change the final date of a banishment of an account +# banaddaccount -- Add or substract time from the final date of a banishment of an account +# bansetaccount yyyy/mm/dd [hh:mm:ss] -- Change the final date of a banishment of an account +# bansetaccount 0 -- Unbanish an account +# blockaccount -- Set state 5 (blocked by the GM Team) to an account +# checkaccount -- Check the validity of a password for an account +# createaccount -- Create an account with email +# delaccount -- Remove an account +# emailaccount -- Modify an email of an account +# getcount -- Give the number of players online on all char-servers +# gmaccount -- Change the GM level of an account +# idaccount -- Give the id of an account +# infoaccount -- Display complete information of an account +# kami -- Sends a broadcast message on all map-server (in yellow). +# kamib -- Sends a broadcast message on all map-server (in blue). +# ladminlanguage -- Change the language of displaying. +# listaccount [First_id [Last_id]] -- Display a list of accounts +# listBanaccount [start_id [end_id]] -- Display a list of accounts with state or banished +# listGMaccount [First_id [Last_id]] -- Display a list of GM accounts +# listOKaccount [start_id [end_id]] -- Display a list of accounts without state and not banished +# loginserverversion -- Display the version of the login-server +# memoaccount -- Modify the memo of an account +# nameaccount -- Give the name of an account +# passwdaccount -- Change the password of an account +# reloadGM -- Reload GM configuration file +# searchaccount -- Seek accounts +# searchaccount -e/-r/--expr/--regex -- Seek accounts by REGEX +# sexaccount -- Change the sex of an account (or -sex) +# stateaccount -- Change the state of an account +# timeaddaccount -- Add or substract time from the validity limit of an account +# timesetaccount yyyy/mm/dd [hh:mm:ss] -- Change the validify limit of an account +# timesetaccount 0 -- Give a unlimited validity limit +# unbanaccount -- Unban an account +# unblockaccount -- Set state 0 (Account ok) to an account +# whoaccount -- Display complete information of an account +# ./addaccount testname Male testpass +# +#------------------------------------------------------------------------- +# About the encoding: +# +# The Digest::MD5 module is necessary to use the encrypted password system. +# When the software cannot found the Digest::MD5 module, +# encoding is automatically disabled ($passenc=0), which allows +# to use this program in any cases. +# +#------------------------------------------------------------------------- +# How to use ladmin with UNIX: +# +# You excecute ladmin as a standard command. +# +# $ mv ladmin ladmin_org +# $ nkf -eLu ladmin_org > ladmin +# $ chmod 700 ladmin +# +# $ perl ladmin +# +########################################################################## + + +use strict; +use IO::Socket; +use Term::ReadLine; +eval { use POSIX qw(:termios_h); }; +eval { use Digest::MD5 qw(md5); } if $passenc; +$passenc = 0 if($@); + +my($ver) = "1.00"; + +# Start of termios +my($termios, $orgterml, $termlecho, $termlnoecho) = (); +eval{ + $termios = POSIX::Termios->new(); + $termios->getattr(fileno(STDIN)); + $orgterml = $termios->getlflag(); + $termlecho = ECHO | ECHOK | ICANON; + $termlnoecho = $orgterml & ~$termlecho; +}; + +# Modification of termios for the displaying of passwords (no displays for pressed keys) +sub cbreak() { + if ($termios) { + $termios->setlflag($termlnoecho); + $termios->setcc(VTIME, 1); + $termios->setattr(fileno(STDIN), TCSANOW); + } +} +# Modification of termios to return at the normal displaying (after input of the passwords) +sub cooked() { + if ($termios) { + $termios->setlflag($orgterml); + $termios->setcc(VTIME,0); + $termios->setattr(fileno(STDIN),TCSANOW); + } +} +END{ cooked() } + +if ($defaultlanguage eq "F") { + print "Outil d'administration distance de eAthena V.$ver\n"; +} else { + print "EAthena login-server administration tool V.$ver\n"; +} + +# Creation of the symbolic links for call of the program in line command of the shell +if ($ARGV[0] eq "--makesymlink") { + symlink $0, "loginserverversion"; + symlink $0, "addaccount"; + symlink $0, "banaccount"; + symlink $0, "banaddaccount"; + symlink $0, "bansetaccount"; + symlink $0, "blockaccount"; + symlink $0, "checkaccount"; + symlink $0, "createaccount"; + symlink $0, "delaccount"; + symlink $0, "emailaccount"; + symlink $0, "getcount"; + symlink $0, "gmaccount"; + symlink $0, "idaccount"; + symlink $0, "infoaccount"; + symlink $0, "kami"; + symlink $0, "kamib"; + symlink $0, "ladminlanguage"; + symlink $0, "listaccount"; + symlink $0, "listBanaccount"; + symlink $0, "listGMaccount"; + symlink $0, "listOKaccount"; + symlink $0, "memoaccount"; + symlink $0, "nameaccount"; + symlink $0, "passwdaccount"; + symlink $0, "reloadGM"; + symlink $0, "searchaccount"; + symlink $0, "sexaccount"; + symlink $0, "stateaccount"; + symlink $0, "timeaddaccount"; + symlink $0, "timesetaccount"; + symlink $0, "unbanaccount"; + symlink $0, "unblockaccount"; + symlink $0, "whoaccount"; + if ($defaultlanguage eq "F") { + print "Liens symbliques cr鳬s.\n"; + } else { + print "Symbolic links created.\n"; + } + exit(0); +} + +# Connection to the login-server +my($so,$er) = (); +eval{ + $so = IO::Socket::INET->new( + PeerAddr=> $loginserverip, + PeerPort=> $loginserverport, +# Proto => "tcp", + Timeout => $connecttimeout) or $er = 1; +}; +if ($er || $@) { + if ($defaultlanguage eq "F") { + print "\nImpossible de se connecter au serveur de login [${loginserverip}:$loginserverport] !\n"; + } else { + print "\nImpossible to have a connection with the login-server [${loginserverip}:$loginserverport] !\n"; + } + print "$!\n"; # Displaying of the error + exit(2); +} + +# Sending the administration password +if ($passenc == 0) { + print $so pack("v2a24",0x7918,0,$loginserveradminpassword); + $so->flush(); +} else { + print $so pack("v",0x791a); + $so->flush(); + my($buf) = readso(4); + if (unpack("v",$buf) != 0x01dc) { + if ($defaultlanguage eq "F") { + print "Erreur au login (馗hec de la cr饌tion de la clef md5).\n"; + } else { + print "Error at login (failure of the md5 key creation).\n"; + } + } + $buf = readso(unpack("x2v",$buf)-4); + my($md5bin) = md5(($passenc == 1) ? $buf.$loginserveradminpassword : $loginserveradminpassword.$buf); + print $so pack("v2a16",0x7918,$passenc,$md5bin); + $so->flush(); +} + +# Waiting of the server reply +my($buf) = readso(3); + +if (unpack("v",$buf) != 0x7919 || unpack("x2c",$buf) != 0) { + if ($defaultlanguage eq "F") { + print "Erreur de login:\n"; + print " - mot de passe incorrect,\n"; + print " - syst鑪e d'administration non activ, ou\n"; + print " - IP non autoris馥.\n"; + } else { + print "Error at login:\n"; + print " - incorrect password,\n"; + print " - administration system not activated, or\n"; + print " - unauthorised IP.\n"; + } + quit(); + exit(4); +} + +if ($defaultlanguage eq "F") { + print "Connexion 騁ablie.\n"; +} else { + print "Established connection.\n"; +} + +#------------------------------------------------------------------------- +# Here are checked the command lines with arguments and symbolic links (no prompt) + +if ($0 =~ /addaccount$/ || + (($ARGV[0] eq "-a" || $ARGV[0] eq "--add") && ((shift @ARGV), 1))) { + my($r) = addaccount($ARGV[0], $ARGV[1], $ARGV[2]); + quit(); + exit($r); +} elsif ($0 =~ /banaccount$/ || $0 =~ /banishaccount$/ || + (($ARGV[0] eq "-b" || $ARGV[0] eq "--ban" || $ARGV[0] eq "--banish") && ((shift @ARGV), 1))) { + my($r) = bansetaccount($ARGV[1], $ARGV[2], $ARGV[0]); + quit(); + exit($r); +} elsif ($0 =~ /banaddaccount$/ || + (($ARGV[0] eq "-ba" || $ARGV[0] eq "--banadd") && ((shift @ARGV), 1))) { + my($r) = banaddaccount($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /bansetaccount$/ || + (($ARGV[0] eq "-bs" || $ARGV[0] eq "--banset") && ((shift @ARGV), 1))) { + my($r) = bansetaccount($ARGV[0], $ARGV[1], $ARGV[2]); + quit(); + exit($r); +} elsif ($0 =~ /blockaccount$/ || + (($ARGV[0] eq "-bl" || $ARGV[0] eq "--block") && ((shift @ARGV), 1))) { + my($r) = changestate($ARGV[0], 5, ""); + quit(); + exit($r); +} elsif ($0 =~ /checkaccount$/ || + (($ARGV[0] eq "-check" || $ARGV[0] eq "--check") && ((shift @ARGV), 1))) { + my($r) = checkaccount($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /createaccount$/ || + (($ARGV[0] eq "-c" || $ARGV[0] eq "--create") && ((shift @ARGV), 1))) { + my($r) = createaccount($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]); + quit(); + exit($r); +} elsif ($0 =~ /delaccount$/ || + (($ARGV[0] eq "-d" || $ARGV[0] eq "--del") && ((shift @ARGV), 1))) { + my($r) = delaccount($ARGV[0]); + quit(); + exit($r); +} elsif ($0 =~ /emailaccount$/ || + (($ARGV[0] eq "-e" || $ARGV[0] eq "--email") && ((shift @ARGV), 1))) { + my($r) = changeemail($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /getcount$/ || + (($ARGV[0] eq "-g" || $ARGV[0] eq "--getcount") && ((shift @ARGV), 1))) { + my($r) = getlogincount(); + quit(); + exit($r); +} elsif ($0 =~ /gmaccount$/ || + (($ARGV[0] eq "-gm" || $ARGV[0] eq "--gm") && ((shift @ARGV), 1))) { + my($r) = changegmlevel($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /id$/ || + (($ARGV[0] eq "-i" || $ARGV[0] eq "--id") && ((shift @ARGV), 1))) { + my($r) = idaccount($ARGV[0]); + quit(); + exit($r); +} elsif ($0 =~ /infoaccount$/ || + (($ARGV[0] eq "-info" || $ARGV[0] eq "--info") && ((shift @ARGV), 1))) { + my($r) = infoaccount($ARGV[0]); + quit(); + exit($r); +} elsif ($0 =~ /kami$/ || + (($ARGV[0] eq "-kami" || $ARGV[0] eq "--kami") && ((shift @ARGV), 1))) { + my($r) = sendbroadcast(0, $ARGV[0]); + quit(); + exit($r); +} elsif ($0 =~ /kamib$/ || + (($ARGV[0] eq "-kamib" || $ARGV[0] eq "--kamib") && ((shift @ARGV), 1))) { + my($r) = sendbroadcast(0x10, $ARGV[0]); + quit(); + exit($r); +} elsif ($0 =~ /ladminlanguage$/ || + (($ARGV[0] eq "-lang" || $ARGV[0] eq "--language") && ((shift @ARGV), 1))) { + my($r) = changelanguage($ARGV[0]); + quit(); + exit($r); +} elsif ($0 =~ /listaccount$/ || + (($ARGV[0] eq "-l" || $ARGV[0] eq "--list") && ((shift @ARGV), 1))) { + my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 0); # 0: to list all + quit(); + exit($r); +} elsif ($0 =~ /listBanaccount$/ || + (($ARGV[0] eq "-lBan" || $ARGV[0] eq "--listBan") && ((shift @ARGV), 1))) { + my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 3); # 3: to list only accounts with state or banished + quit(); + exit($r); +} elsif ($0 =~ /listGMaccount$/ || + (($ARGV[0] eq "-lGM" || $ARGV[0] eq "--listGM") && ((shift @ARGV), 1))) { + my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 1); # 1: to list only GM + quit(); + exit($r); +} elsif ($0 =~ /listOKaccount$/ || + (($ARGV[0] eq "-lOK" || $ARGV[0] eq "--listOK") && ((shift @ARGV), 1))) { + my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 4); # 4: to list only accounts without state and not banished + quit(); + exit($r); +} elsif ($0 =~ /loginserverversion$/ || + (($ARGV[0] eq "-v" || $ARGV[0] eq "--version") && ((shift @ARGV), 1))) { + my($r) = checkloginversion(); + quit(); + exit($r); +} elsif ($0 =~ /memoaccount$/ || + (($ARGV[0] eq "-m" || $ARGV[0] eq "--memo") && ((shift @ARGV), 1))) { + my($r) = changememo($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /nameaccount$/ || + (($ARGV[0] eq "-n" || $ARGV[0] eq "--name") && ((shift @ARGV), 1))) { + my($r) = nameaccount(int($ARGV[0])); + quit(); + exit($r); +} elsif ($0 =~ /passwdaccount$/ || + (($ARGV[0] eq "-p" || $ARGV[0] eq "--passwd") && ((shift @ARGV), 1))) { + my($r) = changepasswd($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /reloadGM$/ || + (($ARGV[0] eq "-r" || $ARGV[0] eq "--reloadGM") && ((shift @ARGV), 1))) { + my($r) = reloadGM(); + quit(); + exit($r); +} elsif ($0 =~ /searchaccount$/ || + (($ARGV[0] eq "-s" || $ARGV[0] eq "--search") && ((shift @ARGV), 1))) { + my($r) = searchaccount($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /sexaccount$/ || + (($ARGV[0] eq "-sex" || $ARGV[0] eq "--sex") && ((shift @ARGV), 1))) { + my($r) = changesex($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /stateaccount$/ || + (($ARGV[0] eq "-t" || $ARGV[0] eq "--state") && ((shift @ARGV), 1))) { + my($r) = changestate($ARGV[0], $ARGV[1], $ARGV[2]); + quit(); + exit($r); +} elsif ($0 =~ /timeaddaccount$/ || + (($ARGV[0] eq "-ta" || $ARGV[0] eq "--timeadd") && ((shift @ARGV), 1))) { + my($r) = timeaddaccount($ARGV[0], $ARGV[1]); + quit(); + exit($r); +} elsif ($0 =~ /timesetaccount$/ || + (($ARGV[0] eq "-ts" || $ARGV[0] eq "--timeset") && ((shift @ARGV), 1))) { + my($r) = timesetaccount($ARGV[0], $ARGV[1], $ARGV[2]); + quit(); + exit($r); +} elsif ($0 =~ /unbanaccount$/ || $0 =~ /unbanishaccount$/ || + (($ARGV[0] eq "-uba" || $ARGV[0] eq "--unban" || $ARGV[0] eq "--unbanish") && ((shift @ARGV), 1))) { + my($r) = bansetaccount($ARGV[0], 0, ""); + quit(); + exit($r); +} elsif ($0 =~ /unblockaccount$/ || + (($ARGV[0] eq "-ubl" || $ARGV[0] eq "--unblock") && ((shift @ARGV), 1))) { + my($r) = changestate($ARGV[0], 0, ""); + quit(); + exit($r); +} elsif ($0 =~ /whoaccount$/ || + (($ARGV[0] eq "-w" || $ARGV[0] eq "--who") && ((shift @ARGV), 1))) { + my($r) = whoaccount($ARGV[0]); + quit(); + exit($r); +} + +#------------------------------------------------------------------------- +if ($defaultlanguage eq "F") { + print "Lecture de la version du serveur de login...\n"; +} else { + print "Reading of the version of the login-server...\n"; +} +checkloginversion(); + +# Set the prompt line +my($term) = new Term::ReadLine "ladmin"; + +# Here begin the infinite loop to read prompts +while(1) { + # Displaying of the prompt + print "\n"; + if ($defaultlanguage eq "F") { + printf "\033[32mPour afficher les commandes, tapez 'Entr馥'.\033[0m\n"; + } else { + printf "\033[32mTo list the commands, type 'enter'.\033[0m\n"; + } + my($cmd) = $term->readline("ladmin> "); + # split and recovery of the input + chomp $cmd; # remove cariage return + $cmd =~ s/\x1b\[\d*\w//g; # remove (esc)[(number)(1alpha) = screen control sequence + $cmd =~ s/[\x00-\x1f]//g; # remove control char + my($command, $parameters) = split /\s+/,$cmd,2; # extract command and parameters + $command = lc($command); # command in lowercase + my(@paramlist) = split /\s+/,$parameters; # get list of parameters + + if ($command eq "?" || $command eq "") { + $command = "aide" if ($defaultlanguage eq "F"); + $command = "help" if ($defaultlanguage ne "F"); + } + + # Analyse of the command + eval { +# help + if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? + displayhelp("aide", $paramlist[0]); + } elsif ("help" =~ /^\Q$command/) { + displayhelp("help", $paramlist[0]); + +# general commands + } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(.*)/)) { + addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # + } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { + addaccount($paramlist[0], $paramlist[1], ""); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(.*)/)) { + addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { + addaccount($paramlist[0], $paramlist[1], ""); # + } else { + @paramlist = split /\s+/,$parameters; + addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # + } + + } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) { + if (@paramlist = ($parameters =~ m/^(\S+)\s+(\S+)\s+"(.*)"/)) { # yyyy/mm/dd hh:mm:ss + bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # yyyy/mm/dd [hh:mm:ss] + } elsif (@paramlist = ($parameters =~ m/^(\S+)\s+(\S+)\s+'(.*)'/)) { # yyyy/mm/dd hh:mm:ss + bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # yyyy/mm/dd [hh:mm:ss] + } else { + @paramlist = split /\s+/,$parameters,3; # yyyy/mm/dd hh:mm:ss + bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # yyyy/mm/dd [hh:mm:ss] + } + + } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { + banaddaccount($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { + banaddaccount($paramlist[0], $paramlist[1]); # + } else { + @paramlist = split /\s+/,$parameters; + banaddaccount($paramlist[0], $paramlist[1]); # + } + + } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) { + bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] + } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { + bansetaccount($paramlist[0], $paramlist[1], "23:59:59"); # yyyy/mm/dd [hh:mm:ss] + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) { + bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { + bansetaccount($paramlist[0], $paramlist[1], "23:59:59"); # yyyy/mm/dd [hh:mm:ss] + } else { + @paramlist = split /\s+/,$parameters; + bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] + } + + } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) { + if (@paramlist = ($parameters =~ m/^"(.*)"/)) { + changestate($paramlist[0], 5, ""); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + changestate($paramlist[0], 5, ""); # + } else { + @paramlist = split /\s+/,$parameters,1; + changestate($paramlist[0], 5, ""); # + } + + } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) { + checkaccount($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) { + checkaccount($paramlist[0], ""); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) { + checkaccount($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + checkaccount($paramlist[0], ""); # + } else { + @paramlist = split /\s+/,$parameters; + checkaccount($paramlist[0], $paramlist[1]); # + } + + } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)\s+(.*)/)) { + createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # + } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) { + createaccount($paramlist[0], $paramlist[1], $paramlist[2], ""); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)\s+(.*)/)) { + createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) { + createaccount($paramlist[0], $paramlist[1], $paramlist[2], ""); # + } else { + @paramlist = split /\s+/,$parameters; + createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # + } + + } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) { + if (@paramlist = ($parameters =~ m/^"(.*)"/)) { + delaccount($paramlist[0]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + delaccount($paramlist[0]); # + } else { + @paramlist = split /\s+/,$parameters,1; + delaccount($paramlist[0]); # + } + + } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { + changeemail($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { + changeemail($paramlist[0], $paramlist[1]); # + } else { + @paramlist = split /\s+/,$parameters; + changeemail($paramlist[0], $paramlist[1]); # + } + + } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? + getlogincount(); + + } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { + changegmlevel($paramlist[0], int($paramlist[1])); # + } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) { + changegmlevel($paramlist[0], 0); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { + changegmlevel($paramlist[0], int($paramlist[1])); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + changegmlevel($paramlist[0], 0); # + } else { + @paramlist = split /\s+/,$parameters; + changegmlevel($paramlist[0], int($paramlist[1])); # + } + + } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? + if (@paramlist = ($parameters =~ m/^"(.*)"/)) { + idaccount($paramlist[0]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + idaccount($paramlist[0]); # + } else { + @paramlist = split /\s+/,$parameters,1; + idaccount($paramlist[0]); # + } + + } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? + infoaccount(int($paramlist[0])); # + + } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'? + @paramlist = split /\s+/,$parameters,1; + sendbroadcast(0, $paramlist[0]); # + + } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'? + @paramlist = split /\s+/,$parameters,1; + sendbroadcast(0x10, $paramlist[0]); # + + } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'? + changelanguage($paramlist[0]); # + + } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'? + listaccount(int($paramlist[0]), int($paramlist[1]), 0); # [start_id [end_id]] 0: to list all + + } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'? + listaccount(int($paramlist[0]), int($paramlist[1]), 3); # [start_id [end_id]] 3: to list only accounts with state or banished + + } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'? + listaccount(int($paramlist[0]), int($paramlist[1]), 1); # [start_id [end_id]] 1: to list only GM + + } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'? + listaccount(int($paramlist[0]), int($paramlist[1]), 4); # [start_id [end_id]] 4: to list only accounts without state and not banished + + } elsif ("memo" =~ /^\Q$command/) { + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) { + changememo($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) { + changememo($paramlist[0], $paramlist[1]); # + } else { + @paramlist = split /\s+/,$parameters,2; + changememo($paramlist[0], $paramlist[1]); # + } + + } elsif ("name" =~ /^\Q$command/) { + nameaccount(int($paramlist[0])); # + + } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) { + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) { + changepasswd($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) { + changepasswd($paramlist[0], ""); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) { + changepasswd($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + changepasswd($paramlist[0], ""); # + } else { + @paramlist = split /\s+/,$parameters,2; + changepasswd($paramlist[0], $paramlist[1]); # + } + + } elsif ("reloadgm" =~ /^\Q$command/) { + reloadGM(); + + } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? + $command ne "se") { # check 2 letters command: 'search' or 'sex'? + if (@paramlist = ($parameters =~ m/^(-{1,2}[re]\S*)\s+(.*)/)) { + searchaccount($paramlist[0], $paramlist[1]); # -r/-e/--expr/--regex | + } else { + @paramlist = split /\s+/,$parameters,1; + searchaccount($paramlist[0], ""); # -r/-e/--expr/--regex | + } + + } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? + $command ne "se") { # check 2 letters command: 'search' or 'sex'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { + changesex($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { + changesex($paramlist[0], $paramlist[1]); # + } else { + @paramlist = split /\s+/,$parameters; + changesex($paramlist[0], $paramlist[1]); # + } + + } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\d+)\s+(.*)/)) { + changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # + } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\d+)/)) { + changestate($paramlist[0], int($paramlist[1]), ""); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\d+)\s+(.*)/)) { + changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\d+)/)) { + changestate($paramlist[0], int($paramlist[1]), ""); # + } else { + @paramlist = split /\s+/,$parameters,3; + changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # + } + + } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { + timeaddaccount($paramlist[0], $paramlist[1]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { + timeaddaccount($paramlist[0], $paramlist[1]); # + } else { + @paramlist = split /\s+/,$parameters; + timeaddaccount($paramlist[0], $paramlist[1]); # + } + + } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? + if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) { + timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] + } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) { + timesetaccount($paramlist[0], $paramlist[1], "23:59:59"); # yyyy/mm/dd [hh:mm:ss] + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) { + timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] + } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) { + timesetaccount($paramlist[0], $paramlist[1], "23:59:59"); # yyyy/mm/dd [hh:mm:ss] + } else { + @paramlist = split /\s+/,$parameters; + timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # yyyy/mm/dd [hh:mm:ss] + } + + } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) { + if (@paramlist = ($parameters =~ m/^"(.*)"/)) { + bansetaccount($paramlist[0], 0, ""); # yyyy/mm/dd [hh:mm:ss] + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + bansetaccount($paramlist[0], 0, ""); # yyyy/mm/dd [hh:mm:ss] + } else { + @paramlist = split /\s+/,$parameters,1; + bansetaccount($paramlist[0], 0, ""); # yyyy/mm/dd [hh:mm:ss] + } + + } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) { + if (@paramlist = ($parameters =~ m/^"(.*)"/)) { + changestate($paramlist[0], 0, ""); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + changestate($paramlist[0], 0, ""); # + } else { + @paramlist = split /\s+/,$parameters,1; + changestate($paramlist[0], 0, ""); # + } + + } elsif ("version" =~ /^\Q$command/) { + checkloginversion(); + + } elsif ("who" =~ /^\Q$command/) { + if (@paramlist = ($parameters =~ m/^"(.*)"/)) { + whoaccount($paramlist[0]); # + } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) { + whoaccount($paramlist[0]); # + } else { + @paramlist = split /\s+/,$parameters,1; + whoaccount($paramlist[0]); # + } + +# quit + } elsif ("quit" =~ /^\Q$command/ || + (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'? + last; + +# unknown command + } elsif ($command) { + if ($defaultlanguage eq "F") { + print "Commande inconnue [".$command."]\n"; + } else { + print "Unknown command [".$command."]\n"; + } + } +# $term->addhistory($cmd) if $command; + }; + if ($@) { + if ($defaultlanguage eq "F") { + print "Erreur [".$command."]\n$@"; + } else { + print "Error [".$command."]\n$@"; + } + } +}; + +# End of the software +quit(); + +if ($defaultlanguage eq "F") { + print "Au revoir.\n"; +} else { + print "Bye.\n"; +} +exit(0); + +#-------------------------------------------------------------------------- + +# Sub-function: Displaying of the version of the login-server +sub checkloginversion() { + print $so pack("v",30000); # 0x7530 + $so->flush(); + $buf = readso(10); + # Analyse du Packet + my($ret, $maver, $miver, $rev, $dev, $mod, $type, $mdver) = unpack("vc6v", $buf); + if ($ret != 30001) { #0x7531 + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + exit(6); + } + + print " Login-Server [$loginserverip:$loginserverport]\n"; + printf " eAthena version %s-%d.%d", ("stable", "dev")[$dev], $maver, $miver; + printf " revision %d", $rev if $rev; + printf "%s%d.\n", ("", "-mod")[$mod], $mdver; + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Displaying of the help +sub displayhelp() { + my($help, $receivedcommand) = @_; + + my($command) = lc($receivedcommand); # command in lowercase + + if ($command eq "") { + $command = "not a command"; # any value that is not a command + } + + if ($command eq "?") { + $command = "aide" if ($defaultlanguage eq "F"); + $command = "help" if ($defaultlanguage ne "F"); + } + + if ($help eq "aide") { + if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? + printf "aide/help/?\n"; + printf " Affiche la description des commandes\n"; + printf "aide/help/? [commande]\n"; + printf " Affiche la description de la commande specifi馥\n"; + } elsif ("help" =~ /^\Q$command/) { + printf "aide/help/?\n"; + printf " Display the description of the commands\n"; + printf "aide/help/? [command]\n"; + printf " Display the description of the specified command\n"; + } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? + printf "add \n"; + printf " Cr馥 un compte avec l'email par d馭aut (a\@a.com).\n"; + printf " Concernant le sexe, seule la premi鑽e lettre compte (F ou M).\n"; + printf " L'e-mail est a\@a.com (e-mail par d馭aut). C'est comme n'avoir aucun e-mail.\n"; + printf " Lorsque motdepasse est omis, la saisie se fait sans que la frappe se voit.\n"; + printf " add testname Male testpass\n"; + } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) { + printf "ban/banish aaaa/mm/jj hh:mm:ss \n"; + printf " Change la date de fin de bannissement d'un compte.\n"; + printf " La diff駻ence avec banset est la position du nom du compte.\n"; + } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? + printf "banadd \n"; + printf " Ajoute ou soustrait du temps la date de banissement d'un compte.\n"; + printf " Les modificateurs sont construits comme suit:\n"; + printf " Valeur d'ajustement (-1, 1, +1, etc...)\n"; + printf " El駑ent modifi:\n"; + printf " a ou y: ann馥\n"; + printf " m: mois\n"; + printf " j ou d: jour\n"; + printf " h: heure\n"; + printf " mn: minute\n"; + printf " s: seconde\n"; + printf " banadd testname +1m-2mn1s-6a\n"; + printf " Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n"; + printf " et 6 ans dans le m麥e temps.\n"; + printf "NOTE: Si vous modifez la date de banissement d'un compte non bani,\n"; + printf " vous indiquez comme date (le moment actuel +- les ajustements)\n"; + } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? + printf "banset aaaa/mm/jj [hh:mm:ss]\n"; + printf " Change la date de fin de bannissement d'un compte.\n"; + printf " Heure par d馭aut: 23:59:59\n"; + printf "banset 0\n"; + printf " D饕anni un compte (0 = de-banni).\n"; + } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) { + printf "block \n"; + printf " Place le status d'un compte 5 (You have been blocked by the GM Team).\n"; + printf " La commande est l'駲uivalent de state 5.\n"; + } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? + printf "check \n"; + printf " V駻ifie la validit d'un mot de passe pour un compte\n"; + printf " NOTE: Le serveur n'enverra jamais un mot de passe.\n"; + printf " C'est la seule m騁hode que vous poss馘ez pour savoir\n"; + printf " si un mot de passe est le bon. L'autre m騁hode est\n"; + printf " d'avoir un acc鑚 ('physique') au fichier des comptes.\n"; + } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? + printf "create \n"; + printf " Comme la commande add, mais avec l'e-mail en plus.\n"; + printf " create testname Male mon\@mail.com testpass\n"; + } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) { + printf "del \n"; + printf " Supprime un compte.\n"; + printf " La commande demande confirmation. Apr鑚 confirmation, le compte est d騁ruit.\n"; + } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'? + printf "email \n"; + printf " Modifie l'e-mail d'un compte.\n"; + } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? + printf "getcount\n"; + printf " Donne le nombre de joueurs en ligne par serveur de char.\n"; + } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? + printf "gm [Niveau_GM]\n"; + printf " Modifie le niveau de GM d'un compte.\n"; + printf " Valeur par d馭aut: 0 (suppression du niveau de GM).\n"; + printf " gm nomtest 80\n"; + } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? + printf "id \n"; + printf " Donne l'id d'un compte.\n"; + } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? + printf "info \n"; + printf " Affiche les informations sur un compte.\n"; + } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'? + printf "kami \n"; + printf " Envoi un message g駭駻al sur tous les serveurs de map (en jaune).\n"; + } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'? + printf "kamib \n"; + printf " Envoi un message g駭駻al sur tous les serveurs de map (en bleu).\n"; + } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'? + printf("language \n"); + printf(" Change la langue d'affichage.\n"); + printf(" Langues possibles: 'Fran軋is' ou 'English'.\n"); + } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'? + printf "list/ls [Premier_id [Dernier_id]]\n"; + printf " Affiche une liste de comptes.\n"; + printf " 'Premier_id', 'Dernier_id': indique les identifiants de d駱art et de fin.\n"; + printf " La recherche par nom n'est pas possible avec cette commande.\n"; + printf " list 10 9999999\n"; + } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'? + printf "listBan/lsBan [Premier_id [Dernier_id]]\n"; + printf " Comme list/ls, mais seulement pour les comptes GM avec un statut ou bannis.\n"; + } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'? + printf "listGM/lsGM [Premier_id [Dernier_id]]\n"; + printf " Comme list/ls, mais seulement pour les comptes GM.\n"; + } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'? + printf "listOK/lsOK [Premier_id [Dernier_id]]\n"; + printf " Comme list/ls, mais seulement pour les comptes sans statut et non bannis.\n"; + } elsif ("memo" =~ /^\Q$command/) { + printf "memo \n"; + printf " Modifie le m駑o d'un compte.\n"; + printf " 'memo': Il peut avoir jusqu' 253 caract鑽es (avec des espaces ou non).\n"; + } elsif ("name" =~ /^\Q$command/) { + printf "name \n"; + printf " Donne le nom d'un compte.\n"; + } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) { + printf "passwd \n"; + printf " Change le mot de passe d'un compte.\n"; + printf " Lorsque nouveaumotdepasse est omis,\n"; + printf " la saisie se fait sans que la frappe ne se voit.\n"; + } elsif ("reloadgm" =~ /^\Q$command/) { + printf "reloadGM\n"; + printf " Reload GM configuration file\n"; + } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? + $command ne "se") { # check 2 letters command: 'search' or 'sex'? + printf "search \n"; + printf " Cherche des comptes.\n"; + printf " Affiche les comptes dont les noms correspondent.\n"; + printf "search -r/-e/--expr/--regex \n"; + printf " Cherche des comptes par expression reguli鑽e.\n"; + printf " Affiche les comptes dont les noms correspondent.\n"; + } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? + $command ne "se") { # check 2 letters command: 'search' or 'sex'? + printf "sex \n"; + printf " Modifie le sexe d'un compte.\n"; + printf " sex testname Male\n"; + } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'? + printf "state \n"; + printf " Change le statut d'un compte.\n"; + printf " 'nouveaustatut': Le statut est le m麥e que celui du packet 0x006a + 1.\n"; + printf " les possibilit駸 sont:\n"; + printf " 0 = Compte ok\n"; + printf " 1 = Unregistered ID\n"; + printf " 2 = Incorrect Password\n"; + printf " 3 = This ID is expired\n"; + printf " 4 = Rejected from Server\n"; + printf " 5 = You have been blocked by the GM Team\n"; + printf " 6 = Your Game's EXE file is not the latest version\n"; + printf " 7 = You are Prohibited to log in until...\n"; + printf " 8 = Server is jammed due to over populated\n"; + printf " 9 = No MSG\n"; + printf " 100 = This ID has been totally erased\n"; + printf " all other values are 'No MSG', then use state 9 please.\n"; + printf " 'message_erreur_7': message du code erreur 6 =\n"; + printf " = Your are Prohibited to log in until... (packet 0x006a)\n"; + } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? + printf "timeadd \n"; + printf " Ajoute/soustrait du temps la limite de validit d'un compte.\n"; + printf " Le modificateur est compos comme suit:\n"; + printf " Valeur modificatrice (-1, 1, +1, etc...)\n"; + printf " El駑ent modifi:\n"; + printf " a ou y: ann馥\n"; + printf " m: mois\n"; + printf " j ou d: jour\n"; + printf " h: heure\n"; + printf " mn: minute\n"; + printf " s: seconde\n"; + printf " timeadd testname +1m-2mn1s-6a\n"; + printf " Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n"; + printf " et 6 ans dans le m麥e temps.\n"; + printf "NOTE: Vous ne pouvez pas modifier une limite de validit illimit馥. Si vous\n"; + printf " d駸irez le faire, c'est que vous voulez probablement cr馥r un limite de\n"; + printf " validit limit馥. Donc, en premier, fix une limite de valitid.\n"; + } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? + printf "timeset aaaa/mm/jj [hh:mm:ss]\n"; + printf " Change la limite de validit d'un compte.\n"; + printf " Heure par d馭aut: 23:59:59\n"; + printf "timeset 0\n"; + printf " Donne une limite de validit illimit馥 (0 = illimit馥).\n"; + } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) { + printf "unban/unbanish \n"; + printf " Ote le banissement d'un compte.\n"; + printf " La commande est l'駲uivalent de banset 0.\n"; + } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) { + printf "unblock \n"; + printf " Place le status d'un compte 0 (Compte ok).\n"; + printf " La commande est l'駲uivalent de state 0.\n"; + } elsif ("version" =~ /^\Q$command/) { + printf "version\n"; + printf " Affiche la version du login-serveur.\n"; + } elsif ("who" =~ /^\Q$command/) { + printf "who \n"; + printf " Affiche les informations sur un compte.\n"; + } elsif ("quit" =~ /^\Q$command/ || + (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?\n"; + printf "quit/end/exit\n"; + printf " Fin du programme d'administration.\n"; + } else { + if ($receivedcommand ne "") { + printf "Commande inconnue [%s] pour l'aide. Affichage de toutes les commandes.\n", $receivedcommand; + } + print << "ENDOFAIDE"; + aide/help/? -- Affiche cet aide + aide/help/? [commande] -- Affiche l'aide de la commande + add -- Cr馥 un compte (sans email) + ban/banish aaaa/mm/jj hh:mm:ss -- Change la date finale de banismnt + banadd/ba -- Ajout/soustrait du temps la + exemple: ba moncompte +1m-2mn1s-2y date finale de banissement + banset/bs aaaa/mm/jj [hh:mm:ss] -- Change la date fin de banisemnt + banset/bs 0 -- D-banis un compte. + block -- Mets le status d'un compte 5 (blocked by the GM Team) + check -- V駻ifie un mot de passe d'un compte + create -- Cr馥 un compte (avec email) + del -- Supprime un compte + email -- Modifie l'e-mail d'un compte + getcount -- Donne le nb de joueurs en ligne + gm [Niveau_GM] -- Modifie le niveau de GM d'un compte + id -- Donne l'id d'un compte + info -- Affiche les infos sur un compte + kami -- Envoi un message g駭駻al (en jaune) + kamib -- Envoi un message g駭駻al (en bleu) + language -- Change la langue d'affichage. + list/ls [Premier_id [Dernier_id] ] -- Affiche une liste de comptes + listBan/lsBan [Premier_id [Dernier_id] ]-- Affiche une liste de comptes + avec un statut ou bannis + listGM/lsGM [Premier_id [Dernier_id] ] -- Affiche une liste de comptes GM + listOK/lsOK [Premier_id [Dernier_id] ] -- Affiche une liste de comptes + sans status et non bannis + memo -- Modifie le memo d'un compte + name -- Donne le nom d'un compte + passwd -- Change le mot de passe d'un compte + quit/end/exit -- Fin du programme d'administation + reloadGM -- Recharger le fichier de config des GM + search -- Cherche des comptes + search -e/-r/--expr/--regex -- Cherche des comptes par REGEX + sex -- Modifie le sexe d'un compte + state -- Change le statut d'1 compte + timeadd/ta -- Ajout/soustrait du temps la + exemple: ta moncompte +1m-2mn1s-2y limite de validit + timeset/ts aaaa/mm/jj [hh:mm:ss] -- Change la limite de validit + timeset/ts 0 -- limite de validit = illimit馥 + unban/unbanish -- Ote le banissement d'un compte + unblock -- Mets le status d'un compte 0 (Compte ok) + version -- Donne la version du login-serveur + who -- Affiche les infos sur un compte +ENDOFAIDE + printf(" Note: Pour les noms de compte avec des espaces, tapez \"\" (ou ').\n"); + } + } else { + if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? + printf "aide/help/?\n"; + printf " Display the description of the commands\n"; + printf "aide/help/? [command]\n"; + printf " Display the description of the specified command\n"; + } elsif ("help" =~ /^\Q$command/) { + printf "aide/help/?\n"; + printf " Display the description of the commands\n"; + printf "aide/help/? [command]\n"; + printf " Display the description of the specified command\n"; + } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'? + printf "add \n"; + printf " Create an account with the default email (a\@a.com).\n"; + printf " Concerning the sex, only the first letter is used (F or M).\n"; + printf " The e-mail is set to a\@a.com (default e-mail). It's like to have no e-mail.\n"; + printf " When the password is omitted,\n"; + printf " the input is done without displaying of the pressed keys.\n"; + printf " add testname Male testpass\n"; + } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) { + printf "ban/banish yyyy/mm/dd hh:mm:ss \n"; + printf " Changes the final date of a banishment of an account.\n"; + printf " The difference with banset is the position of the account name.\n"; + } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? + printf "banadd \n"; + printf " Adds or substracts time from the final date of a banishment of an account.\n"; + printf " Modifier is done as follows:\n"; + printf " Adjustment value (-1, 1, +1, etc...)\n"; + printf " Modified element:\n"; + printf " a or y: year\n"; + printf " m: month\n"; + printf " j or d: day\n"; + printf " h: hour\n"; + printf " mn: minute\n"; + printf " s: second\n"; + printf " banadd testname +1m-2mn1s-6y\n"; + printf " this example adds 1 month and 1 second, and substracts 2 minutes\n"; + printf " and 6 years at the same time.\n"; + printf "NOTE: If you modify the final date of a non-banished account,\n"; + printf " you fix the final date to (actual time +- adjustments)\n"; + } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'? + printf "banset yyyy/mm/dd [hh:mm:ss]\n"; + printf " Changes the final date of a banishment of an account.\n"; + printf " Default time: 23:59:59\n"; + printf "banset 0\n"; + printf " Set a non-banished account (0 = unbanished).\n"; + } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) { + printf "block \n"; + printf " Set state 5 (You have been blocked by the GM Team) to an account.\n"; + printf " Same command of state 5.\n"; + } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? + printf "check \n"; + printf " Check the validity of a password for an account.\n"; + printf " NOTE: Server will never sends back a password.\n"; + printf " It's the only method you have to know if a password is correct.\n"; + printf " The other method is to have a ('physical') access to the accounts file.\n"; + } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'? + printf "create \n"; + printf " Like the 'add' command, but with e-mail moreover.\n"; + printf " create testname Male my\@mail.com testpass\n"; + } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) { + printf "del \n"; + printf " Remove an account.\n"; + printf " This order requires confirmation. After confirmation, the account is deleted.\n"; + } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'? + printf "email \n"; + printf " Modify the e-mail of an account.\n"; + } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? + printf "getcount\n"; + printf " Give the number of players online on all char-servers.\n"; + } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'? + printf "gm [GM_level]\n"; + printf " Modify the GM level of an account.\n"; + printf " Default value remove GM level (GM level = 0).\n"; + printf " gm testname 80\n"; + } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? + printf "id \n"; + printf " Give the id of an account.\n"; + } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'? + printf "info \n"; + printf " Display complete information of an account.\n"; + } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'? + printf "kami \n"; + printf " Sends a broadcast message on all map-server (in yellow).\n"; + } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'? + printf "kamib \n"; + printf " Sends a broadcast message on all map-server (in blue).\n"; + } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'? + printf("language \n"); + printf(" Change the language of displaying.\n"); + printf(" Possible languages: Fran軋is or English.\n"); + } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'? + printf "list/ls [start_id [end_id]]\n"; + printf " Display a list of accounts.\n"; + printf " 'start_id', 'end_id': indicate end and start identifiers.\n"; + printf " Research by name is not possible with this command.\n"; + printf " list 10 9999999\n"; + } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'? + printf "listBan/lsBan [start_id [end_id]]\n"; + printf " Like list/ls, but only for accounts with state or banished.\n"; + } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'? + printf "listGM/lsGM [start_id [end_id]]\n"; + printf " Like list/ls, but only for GM accounts.\n"; + } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'? + printf "listOK/lsOK [start_id [end_id]]\n"; + printf " Like list/ls, but only for accounts without state and not banished.\n"; + } elsif ("memo" =~ /^\Q$command/) { + printf "memo \n"; + printf " Modify the memo of an account.\n"; + printf " 'memo': it can have until 253 characters (with spaces or not).\n"; + } elsif ("name" =~ /^\Q$command/) { + printf "name \n"; + printf " Give the name of an account.\n"; + } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) { + printf "passwd \n"; + printf " Change the password of an account.\n"; + printf " When new password is omitted,\n"; + printf " the input is done without displaying of the pressed keys.\n"; + } elsif ("reloadgm" =~ /^\Q$command/) { + printf "reloadGM\n"; + printf " Reload GM configuration file\n"; + } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? + $command ne "se") { # check 2 letters command: 'search' or 'sex'? + printf "search \n"; + printf " Seek accounts.\n"; + printf " Displays the accounts whose names correspond.\n"; + printf "search -r/-e/--expr/--regex \n"; + printf " Seek accounts by regular expression.\n"; + printf " Displays the accounts whose names correspond.\n"; + } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'? + $command ne "se") { # check 2 letters command: 'search' or 'sex'? + printf "sex \n"; + printf " Modify the sex of an account.\n"; + printf " sex testname Male\n"; + } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'? + printf "state \n"; + printf " Change the state of an account.\n"; + printf " 'new_state': state is the state of the packet 0x006a + 1.\n"; + printf " The possibilities are:\n"; + printf " 0 = Account ok\n"; + printf " 1 = Unregistered ID\n"; + printf " 2 = Incorrect Password\n"; + printf " 3 = This ID is expired\n"; + printf " 4 = Rejected from Server\n"; + printf " 5 = You have been blocked by the GM Team\n"; + printf " 6 = Your Game's EXE file is not the latest version\n"; + printf " 7 = You are Prohibited to log in until...\n"; + printf " 8 = Server is jammed due to over populated\n"; + printf " 9 = No MSG\n"; + printf " 100 = This ID has been totally erased\n"; + printf " all other values are 'No MSG', then use state 9 please.\n"; + printf " 'error_message_#7': message of the code error 6\n"; + printf " = Your are Prohibited to log in until... (packet 0x006a)\n"; + } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? + printf "timeadd \n"; + printf " Adds or substracts time from the validity limit of an account.\n"; + printf " Modifier is done as follows:\n"; + printf " Adjustment value (-1, 1, +1, etc...)\n"; + printf " Modified element:\n"; + printf " a or y: year\n"; + printf " m: month\n"; + printf " j or d: day\n"; + printf " h: hour\n"; + printf " mn: minute\n"; + printf " s: second\n"; + printf " timeadd testname +1m-2mn1s-6y\n"; + printf " this example adds 1 month and 1 second, and substracts 2 minutes\n"; + printf " and 6 years at the same time.\n"; + printf "NOTE: You can not modify a unlimited validity limit.\n"; + printf " If you want modify it, you want probably create a limited validity limit.\n"; + printf " So, at first, you must set the validity limit to a date/time.\n"; + } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'? + printf "timeset yyyy/mm/dd [hh:mm:ss]\n"; + printf " Changes the validity limit of an account.\n"; + printf " Default time: 23:59:59\n"; + printf "timeset 0\n"; + printf " Gives an unlimited validity limit (0 = unlimited).\n"; + } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) { + printf "unban/unbanish \n"; + printf " Remove the banishment of an account.\n"; + printf " This command works like banset 0.\n"; + } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) { + printf "unblock \n"; + printf " Set state 0 (Account ok) to an account.\n"; + printf " This command works like state 0.\n"; + } elsif ("version" =~ /^\Q$command/) { + printf "version\n"; + printf " Display the version of the login-server.\n"; + } elsif ("who" =~ /^\Q$command/) { + printf "who \n"; + printf " Displays complete information of an account.\n"; + } elsif ("quit" =~ /^\Q$command/ || + (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?\n"; + printf "quit/end/exit\n"; + printf " End of the program of administration.\n"; + } else { + if ($receivedcommand ne "") { + printf "Unknown command [%s] for help. Displaying of all commands.\n", $receivedcommand; + } + print << "ENDOFHELP"; + aide/help/? -- Display this help + aide/help/? [command] -- Display the help of the command + add -- Create an account with default email + ban/banish yyyy/mm/dd hh:mm:ss -- Change final date of a ban + banadd/ba -- Add or substract time from the final + example: ba apple +1m-2mn1s-2y date of a banishment of an account + banset/bs yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban + banset/bs 0 -- Un-banish an account + block -- Set state 5 (blocked by the GM Team) to an account + check -- Check the validity of a password + create -- Create an account with email + del -- Remove an account + email -- Modify an email of an account + getcount -- Give the number of players online + gm [GM_level] -- Modify the GM level of an account + id -- Give the id of an account + info -- Display all information of an account + kami -- Sends a broadcast message (in yellow) + kamib -- Sends a broadcast message (in blue) + language -- Change the language of displaying. + list/ls [First_id [Last_id]] -- Display a list of accounts + listBan/lsBan [First_id [Last_id]] -- Display a list of accounts + with state or banished + listGM/lsGM [First_id [Last_id]] -- Display a list of GM accounts + listOK/lsOK [First_id [Last_id]] -- Display a list of accounts + without state and not banished + memo -- Modify the memo of an account + name -- Give the name of an account + passwd -- Change the password of an account + quit/end/exit -- End of the program of administation + reloadGM -- Reload GM configuration file + search -- Seek accounts + search -e/-r/--expr/--regex -- Seek accounts by regular-expression + sex -- Modify the sex of an account + state -- Change the state + timeadd/ta -- Add or substract time from the + example: ta apple +1m-2mn1s-2y validity limit of an account + timeset/ts yyyy/mm/dd [hh:mm:ss] -- Change the validify limit + timeset/ts 0 -- Give a unlimited validity limit + unban/unbanish -- Remove the banishment of an account + unblock -- Set state 0 (Account ok) to an account + version -- Gives the version of the login-server + who -- Display all information of an account +ENDOFHELP + printf(" Note: To use spaces in an account name, type \"\" (or ').\n"); + } + } + + return 0; +} +#-------------------------------------------------------------------------- + +# Sub-function: Displaying of the accounts list +sub listaccount() { + my($st, $ed, $listflag) = @_; + my($i); + my($n) = (0); + # 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567 + if ($defaultlanguage eq "F") { + print " id_compte GM nom_utilisateur sexe count statut\n"; + } else { + print "account_id GM user_name sex count state\n"; + } + print "-------------------------------------------------------------------------------\n"; + while(1) { + print $so pack("vV2", 0x7920, $st, $ed); + $so->flush(); + $buf = readso(4); + if (unpack("v", $buf) != 0x7921) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + exit(10); + } + my($len) = unpack("x2v", $buf); + last if ($len <= 4); + for($i = 4; $i < $len; $i += 38) { + my(@dat) = unpack("VCa24cVV", readso(38)); + $st = $dat[0] + 1; + if ($listflag == 0 || + ($listflag == 1 && $dat[1] > 0) || # check GM flag + ($listflag == 3 && $dat[5] != 0) || # check with state or banished + ($listflag == 4 && $dat[5] == 0)) { # check without state and not banished + printf "%10d %2s %-24s%-5s %6d %-27s\n", $dat[0], + ($dat[1] == 0 ? " " : $dat[1]), + $dat[2], + ($defaultlanguage eq "F" ? ("Femme","Male","Servr")[$dat[3]] : ("Femal","Male","Servr")[$dat[3]]), + $dat[4], + (($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), + "Unregistered ID", + "Incorrect Password", + "This ID is expired", + "Rejected from Server", + "Blocked by the GM Team", # You have been blocked by the GM Team + "Your EXE file is too old", # Your Game's EXE file is not the latest version + "Banishement or\n Prohibited to login until %s", # You are Prohibited to log in until %s + "Server is over populated", # Server is jammed due to over populated + "No MSG", + "This ID is totally erased")[$dat[5] == 100 ? 10 : $dat[5]]; # This ID has been totally erased + $n++; + } + } + } + if ($defaultlanguage eq "F") { + if ($n == 0) { + print "Aucun compte trouv.\n"; + } elsif ($n == 1) { + print "1 compte trouv.\n"; + } else { + print "$n comptes trouv駸.\n"; + } + } else { + if ($n == 0) { + print "No account found.\n"; + } elsif ($n == 1) { + print "1 account found.\n"; + } else { + print "$n accounts found.\n"; + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: add an account with the default e-mail +sub addaccount() { + my($userid, $sex, $passwd) = @_; + if ($userid eq "" || !defined($userid)) { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " add nomtest Male motdepassetest\n"; + } else { + print "Please input an account name.\n"; + print " add testname Male testpass\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } +# if ($userid =~ /[^A-Za-z0-9\@-_]/) { +# if ($defaultlanguage eq "F") { +# print "Caract鑽e interdit trouv dans le nom du compte ".$`."[${&}]${'}\n"; +# } else { +# print "Illegal character found in the account name ".$`."[${&}]${'}\n"; +# } +# return 101; +# } + $sex = uc(substr($sex, 0, 1)); + if ($sex !~ /^[MF]$/) { + if ($defaultlanguage eq "F") { + print "Sexe incorrect [$sex]. Entrez M ou F svp.\n"; + } else { + print "Illegal gender [$sex]. Please input M or F.\n"; + } + return 103; + } + if ($passwd eq "") { + return 108 if (($passwd = typepasswd()) eq ""); + } + if (verify_password($passwd) == 0) { + return 104; + } + print $so pack("va24a24a1a40", 0x7930, $userid, $passwd, $sex, ""); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7931) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 106; + } + $buf = readso(28); + if (unpack("V", $buf) == -1 || unpack("V", $buf) == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec la cr饌tion du compte [$userid]. Un compte identique existe d駛.\n"; + } else { + print "Account [$userid] creation failed. Same account already exists.\n"; + } + return 107; + } else { + if ($defaultlanguage eq "F") { + printf "Compte [$userid] cr鳬 avec succ鑚 [id: %d].\n", unpack("V",$buf); + } else { + printf "Account [$userid] is successfully created [id: %d].\n", unpack("V",$buf); + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: add an account with an e-mail +sub createaccount() { + my($userid, $sex, $email, $passwd) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " create nomtest Male mon\@email.com motdepassetest\n"; + } else { + print "Please input an account name.\n"; + print " create testname Male my\@mail.com testpass\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } +# if ($userid =~ /[^A-Za-z0-9\@-_]/) { +# if ($defaultlanguage eq "F") { +# print "Caract鑽e interdit trouv dans le nom du compte ".$`."[${&}]${'}\n"; +# } else { +# print "Illegal character found in the account name ".$`."[${&}]${'}\n"; +# } +# return 101; +# } + $sex = uc(substr($sex, 0, 1)); + if ($sex !~ /^[MF]$/) { + if ($defaultlanguage eq "F") { + print "Sexe incorrect [$sex]. Entrez M ou F svp.\n"; + } else { + print "Illegal gender [$sex]. Please input M or F.\n"; + } + return 103; + } + if (length($email) < 3) { + if ($defaultlanguage eq "F") { + print "Email trop courte [$email]. Entrez une e-mail valide svp.\n"; + } else { + print "Email is too short [$email]. Please input a valid e-mail.\n"; + } + return 109; + } + if (length($email) > 39) { + if ($defaultlanguage eq "F") { + print "Email trop longue [$email]. Entrez une e-mail de 39 caract鑽es maximum svp.\n"; + } else { + print "Email is too long [$email]. Please input an e-mail with 39 bytes at the most.\n"; + } + return 109; + } + if (verify_email($email) == 0) { + if ($defaultlanguage eq "F") { + print "Email incorrecte [$email]. Entrez une e-mail valide svp.\n"; + } else { + print "Invalid email [$email]. Please input a valid e-mail.\n"; + } + return 109; + } + if ($passwd eq "") { + return 108 if (($passwd = typepasswd()) eq ""); + } + if (verify_password($passwd) == 0) { + return 104; + } + print $so pack("va24a24a1a40", 0x7930, $userid, $passwd, $sex, $email); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7931) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 106; + } + $buf = readso(28); + if (unpack("V", $buf) == -1 || unpack("V", $buf) == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec la cr饌tion du compte [$userid]. Un compte identique existe d駛.\n"; + } else { + print "Account [$userid] creation failed. Same account already exists.\n"; + } + return 107; + } else { + if ($defaultlanguage eq "F") { + printf "Compte [$userid] cr鳬 avec succ鑚 [id: %d].\n", unpack("V",$buf); + } else { + printf "Account [$userid] is successfully created [id: %d].\n", unpack("V",$buf); + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: deletion of an account +sub delaccount() { + my($userid) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " del nomtestasupprimer\n"; + } else { + print "Please input an account name.\n"; + print " del testnametodelete\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + if ($defaultlanguage eq "F") { + print "** Etes-vous vraiment sr de vouloir SUPPRIMER le compte [$userid]? (o/n) "; + } else { + print "** Are you really sure to DELETE account [$userid]? (y/n) "; + } + if (lc(substr(, 0, 1)) !~ /[oy]/) { + if ($defaultlanguage eq "F") { + print "Suppression annul馥\n."; + } else { + print "Deletion canceled\n"; + } + return 121; + } + print $so pack("va24", 0x7932, $userid); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7933) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 122; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec de la suppression du compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Account [$userid] deletion failed. Account doesn't exist.\n"; + } + return 123; + } else { + if ($defaultlanguage eq "F") { + print "Compte [$name][id: $id2] SUPPRIME avec succ鑚.\n"; + } else { + print "Account [$name][id: $id2] is successfully DELETED.\n"; + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: modification of a password +sub changepasswd() { + my($userid, $passwd) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " passwd nomtest nouveaumotdepasse\n"; + } else { + print "Please input an account name.\n"; + print " passwd testname newpassword\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + if ($passwd eq "") { + return 134 if (($passwd = typepasswd()) eq ""); + } + if (verify_password($passwd) == 0) { + return 131; + } + print $so pack("va24a24", 0x7934, $userid,$passwd); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7935) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 132; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec de la modification du mot de passe du compte [$userid].\n"; + print "Le compte [$userid] n'existe pas.\n"; + } else { + print "Account [$userid] password changing failed.\n"; + print "Account [$userid] doesn't exist.\n"; + } + return 133; + } else { + if ($defaultlanguage eq "F") { + print "Modification du mot de passe du compte [$name][id: $id2] r騏ssie.\n"; + } else { + print "Account [$name][id: $id2] password successfully changed.\n"; + } + } + return 130; +} + +#-------------------------------------------------------------------------- + +# Sub-function: modification of an account e-mail +sub changeemail() { + my($userid, $email) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " email testname nouveauemail\n"; + } else { + print "Please input an account name.\n"; + print " email testname newemail\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + if (length($email) < 3) { + if ($defaultlanguage eq "F") { + print "Email trop courte [$email]. Entrez une e-mail valide svp.\n"; + } else { + print "Email is too short [$email]. Please input a valid e-mail.\n"; + } + return 109; + } + if (length($email) > 39) { + if ($defaultlanguage eq "F") { + print "Email trop longue [$email]. Entrez une e-mail de 39 caract鑽es maximum svp.\n"; + } else { + print "Email is too long [$email]. Please input an e-mail with 39 bytes at the most.\n"; + } + return 109; + } + if (verify_email($email) == 0) { + if ($defaultlanguage eq "F") { + print "Email incorrect [$email]. Entrez une e-mail valide svp.\n"; + } else { + print "Invalid email [$email]. Please input a valid e-mail.\n"; + } + return 109; + } + print $so pack("va24a40", 0x7940, $userid, $email); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7941) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 162; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec de la modification de l'e-mail du compte [$userid].\n"; + print "Le compte [$userid] n'existe pas.\n"; + } else { + print "Account [$userid] e-mail changing failed.\n"; + print "Account [$userid] doesn't exist.\n"; + } + return 133; + } else { + if ($defaultlanguage eq "F") { + print "Modification de l'e-mail du compte [$name][id: $id2] r騏ssie.\n"; + } else { + print "Account [$name][id: $id2] e-mail successfully changed.\n"; + } + } + return 160; +} + +#-------------------------------------------------------------------------- + +# Sub-function: search of accounts +sub searchaccount() { + my($p1, $p2) = @_; + my($exp) = (""); + if ($p1 eq "-e" || $p1 eq "-r" || $p1 eq "--regex" || $p1 eq "--expr") { + if ($p2 eq "") { + if ($defaultlanguage eq "F") { + print "Entrez une expression r馮uli鑽e ou utilisez 'ls' pour avoir tous les comptes.\n"; + } else { + print "Input a regular expression or use 'ls' to obtain all accounts.\n"; + } + return 141; + } + $exp = $p2; + } else { + if ($p1 eq "") { + if ($defaultlanguage eq "F") { + print "Entrez une chane ou utilisez 'ls' pour avoir tous les comptes.\n"; + } else { + print "Input a string or use 'ls' to obtain all accounts.\n"; + } + return 141; + } + my($c) = 0; + $exp = lc($p1); + $exp =~ s/([\@])/\\$1/g; + $c += $exp =~ s/([\-\[\]])/\\$1/g; + $c += $exp =~ s/([\*\?])/.$1/g; + $c += $exp =~ s/\\\[(.)\\\-(.)\\\]/[$1-$2]/g; + $exp = "^$exp\$" if $c; + } + if (eval{ "" =~ /$exp/; }, $@) { + if ($defaultlanguage eq "F") { + print "Expression r馮uli鑽e non reconnue.\n"; + } else { + print "Regular-Expression compiling failed.\n"; + } + return 141; + } + my($i); + my($n, $st) = (0, 0); + # 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567 + if ($defaultlanguage eq "F") { + print " id_compte GM nom_utilisateur sexe count statut\n"; + } else { + print "account_id GM user_name sex count state\n"; + } + print "-------------------------------------------------------------------------------\n"; + while(1) { + print $so pack("vV2", 0x7920, $st, 0); + $so->flush(); + $buf = readso(4); + if (unpack("v", $buf) != 0x7921) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + exit(10); + } + my($len) = unpack("x2v", $buf); + last if ($len <= 4); + for($i = 4; $i < $len; $i += 38) { + my(@dat) = unpack("VCa24cVV", readso(38)); + $st = $dat[0] + 1; + next if (lc($dat[2]) !~ /$exp/); + printf "%10d %2s %-24s%-5s %6d %-27s\n", $dat[0], + ($dat[1] == 0 ? " " : $dat[1]), + $dat[2], + ($defaultlanguage eq "F" ? ("Femme","Male","Servr")[$dat[3]] : ("Femal","Male","Servr")[$dat[3]]), + $dat[4], + (($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), + "Unregistered ID", + "Incorrect Password", + "This ID is expired", + "Rejected from Server", + "Blocked by the GM Team", # You have been blocked by the GM Team + "Your EXE file is too old", # Your Game's EXE file is not the latest version + "Banishement or\n Prohibited to login until %s", # You are Prohibited to log in until %s + "Server is over populated", # Server is jammed due to over populated + "No MSG", + "This ID is totally erased")[$dat[5] == 100 ? 10 : $dat[5]]; # This ID has been totally erased + $n++; + } + } + if ($defaultlanguage eq "F") { + if ($n == 0) { + print "Aucun compte trouv.\n"; + } elsif ($n == 1) { + print "1 compte trouv.\n"; + } else { + print "$n comptes trouv駸.\n"; + } + } else { + if ($n == 0) { + print "No account found.\n"; + } elsif ($n == 1) { + print "1 account found.\n"; + } else { + print "$n accounts found.\n"; + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: modify the sex of an account +sub changesex() { + my($userid, $sex) = @_; + if ($userid eq "" || !defined($userid)) { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " sex nomtest Male\n"; + } else { + print "Please input an account name.\n"; + print " sex testname Male\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } +# if ($userid =~ /[^A-Za-z0-9\@-_]/) { +# if ($defaultlanguage eq "F") { +# print "Caract鑽e interdit trouv dans le nom du compte ".$`."[${&}]${'}\n"; +# } else { +# print "Illegal character found in the account name ".$`."[${&}]${'}\n"; +# } +# return 101; +# } + $sex = uc(substr($sex, 0, 1)); + if ($sex !~ /^[MF]$/) { + if ($defaultlanguage eq "F") { + print "Sexe incorrect [$sex]. Entrez M ou F svp.\n"; + } else { + print "Illegal gender [$sex]. Please input M or F.\n"; + } + return 103; + } + print $so pack("va24a1", 0x793c, $userid, $sex); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x793d) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec du changement du sexe du compte [$userid].\n"; + print "Le compte n'existe pas ou le sexe est d駛 celui demand.\n"; + } else { + print "Account [$userid] sex changing failed.\n"; + print "Account doesn't exist or the sex is already the good sex.\n"; + } + } else { + if ($defaultlanguage eq "F") { + print "Sexe du compte [$name][id: $id2] chang avec succ鑚.\n"; + } else { + print "Account [$name][id: $id2] sex successfully changed.\n"; + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: modify the GM level of an account +sub changegmlevel() { + my($userid, $gm_level) = @_; + if ($userid eq "" || !defined($userid)) { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " gm nomtest 80\n"; + } else { + print "Please input an account name.\n"; + print " gm testname 80\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } +# if ($userid =~ /[^A-Za-z0-9\@-_]/) { +# if ($defaultlanguage eq "F") { +# print "Caract鑽e interdit trouv dans le nom du compte ".$`."[${&}]${'}\n"; +# } else { +# print "Illegal character found in the account name ".$`."[${&}]${'}\n"; +# } +# return 101; +# } + $gm_level = int($gm_level); + if ($gm_level < 0 || $gm_level > 99) { + if ($defaultlanguage eq "F") { + print "Niveau de GM incorrect [$gm_level]. Entrez une valeur de 0 99 svp.\n"; + } else { + print "Illegal GM level [$gm_level]. Please input a value from 0 to 99.\n"; + } + return 103; + } + print $so pack("va24C", 0x793e, $userid, $gm_level); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x793f) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec du changement du niveau de GM du compte [$userid].\n"; + print "Le compte n'existe pas, le niveau de GM est d駛 celui demand,\n"; + print "ou il est impossible de modifier le fichier des comptes GM.\n"; + } else { + print "Account [$userid] GM level changing failed.\n"; + print "Account doesn't exist, the GM level is already the good GM level,\n"; + print "or it's impossible to modify the GM accounts file.\n"; + } + } else { + if ($defaultlanguage eq "F") { + print "Niveau de GM du compte [$name][id: $id2] chang avec succ鑚.\n"; + } else { + print "Account [$name][id: $id2] GM level successfully changed.\n"; + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Modification of a state +sub changestate { + my($userid, $s, $error_message) = @_; + # Valid values: 0: ok, or value of the 0x006a packet + 1 + if ($s eq "" || (($s < 0 || $s > 9) && $s != 100)) { + if ($defaultlanguage eq "F") { + print "Entrez une des valeurs suivantes svp:\n"; + print " 0 = Compte ok 6 = Your Game's EXE file is not the latest version\n"; + } else { + print "Please input one of these values:\n"; + print " 0 = Account ok 6 = Your Game's EXE file is not the latest version\n"; + } + print " 1 = Unregistered ID 7 = You are Prohibited to log in until %s\n"; + print " 2 = Incorrect Password 8 = Server is jammed due to over populated\n"; + print " 3 = This ID is expired 9 = No MSG\n"; + print " 4 = Rejected from Server 100 = This ID has been totally erased\n"; + print " 5 = You have been blocked by the GM Team\n"; + if ($defaultlanguage eq "F") { + print " state nomtest 5\n"; + print " state nomtest 7 fin de votre ban\n"; + print " block \n"; + print " unblock \n"; + } else { + print " state testname 5\n"; + print " state testname 7 end of your ban\n"; + print " block \n"; + print " unblock \n"; + } + return 151; + } + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " state nomtest 5\n"; + print " state nomtest 7 fin de votre ban\n"; + print " block \n"; + print " unblock \n"; + } else { + print "Please input an account name.\n"; + print " state testname 5\n"; + print " state testname 7 end of your ban\n"; + print " block \n"; + print " unblock \n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + if ($s != 7) { + $error_message = "-"; + } else { + if (length($error_message) < 1) { + if ($defaultlanguage eq "F") { + print "Message d'erreur trop court. Entrez un message de 1-19 caract鑽es.\n"; + } else { + print "Error message is too short. Please input a message of 1-19 bytes.\n"; + } + return 102; + } + if (length($error_message) > 19) { + if ($defaultlanguage eq "F") { + print "Message d'erreur trop long. Entrez un message de 1-19 caract鑽es.\n"; + } else { + print "Error message is too long. Please input a message of 1-19 bytes.\n"; + } + return 102; + } + } + print $so pack("va24Va20", 0x7936, $userid, $s, $error_message); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7937) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(32); + my(@dat) = unpack("Va24V", $buf); + while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { + chop($dat[1]); + }; + if ($dat[0] != -1 && $dat[0] != 4294967295) { + if ($defaultlanguage eq "F") { + print "Statut du compte [$dat[1]][id: $dat[0]] chang avec succ鑚 en ["; + } else { + print "Account [$dat[1]][id: $dat[0]] state successfully changed in ["; + } + print ((($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), + "Unregistered ID", + "Incorrect Password", + "This ID is expired", + "Rejected from Server", + "You have been blocked by the GM Team", + "Your Game's EXE file is not the latest version", + "You are Prohibited to log in until %s", + "Server is jammed due to over populated", + "No MSG", + "This ID has been totally erased")[$dat[2] == 100 ? 10 : $dat[2]]); + print "].\n"; + } else { + if ($defaultlanguage eq "F") { + print "Echec du changement du statut du compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Account [$userid] state changing failed. Account doesn't exist.\n"; + } + } +} + +#-------------------------------------------------------------------------- + +# Sub-function: Displaying of the number of online players +sub getlogincount { + # Request to the login-server + print $so pack("v", 0x7938); + $so->flush(); + + $buf = readso(4); + # Connection failed + if (unpack("v", $buf) != 0x7939) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + exit(3); + } + + # Get length of the received packet + my($len) = unpack("x2v", $buf) - 4; + + # Read information of the servers + if ($len < 1) { + if ($defaultlanguage eq "F") { + printf " Aucun serveur n'est connect au login serveur.\n"; + } else { + printf " No server is connected to the login-server.\n"; + } + } else { + my(@slist) = (); + for(; $len > 0; $len -= 32) { + my($name, $count) = unpack("x6 a20 V", readso(32)); + $name = substr($name, 0, index($name, "\0")); + push @slist, [ $name, $count ]; + } + # Displaying of result + my($i); + if ($defaultlanguage eq "F") { + printf " Nombre de joueurs en ligne (serveur: nb):\n"; + } else { + printf " Number of online players (server: number).\n"; + } + foreach $i(@slist) { + printf " %-20s : %5d\n", $i->[0], $i->[1]; + } + } +} + +#-------------------------------------------------------------------------- + +# Sub-function: Modification of a memo field +sub changememo { + my($userid, $memo) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " memo nomtest nouveau memo\n"; + } else { + print "Please input an account name.\n"; + print " memo testname new memo\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + if (length($memo) > 254) { + if ($defaultlanguage eq "F") { + print "M駑o trop long (".length($memo)." caract鑽es).\n"; + print "Entrez un m駑o de 254 caract鑽es maximum svp.\n"; + } else { + print "Memo is too long (".length($memo)." characters).\n"; + print "Please input a memo of 254 bytes at the maximum.\n"; + } + return 102; + } + if (length($memo) == 0) { + print $so pack("va24v", 0x7942, $userid, 0); + } else { + print $so pack("va24va".length($memo), 0x7942, $userid, length($memo), $memo); + } + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7943) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec du changement du m駑o du compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Account [$userid] memo changing failed. Account doesn't exist.\n"; + } + } else { + if ($defaultlanguage eq "F") { + print "M駑o du compte [$name][id: $id2] chang avec succ鑚.\n"; + } else { + print "Account [$name][id: $id2] memo successfully changed.\n"; + } + } +} + +#-------------------------------------------------------------------------- + +# Sub-function: Request to obtain an account id +sub idaccount() { + my($userid) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " id nomtest\n"; + } else { + print "Please input an account name.\n"; + print " id testname\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + print $so pack("va24", 0x7944, $userid); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7945) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 122; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Impossible de trouver l'id du compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Unabled to find the account [$userid] id. Account doesn't exist.\n"; + } + return 123; + } else { + if ($defaultlanguage eq "F") { + print "Le compte [$name] a pour id: $id2.\n"; + } else { + print "The account [$name] have the id: $id2.\n"; + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Request to obtain an account name +sub nameaccount() { + my($id) = @_; + if ($id < 0) { + if ($defaultlanguage eq "F") { + print "Entrez un id ayant une valeur positive svp.\n"; + } else { + print "Please input a positive value for the id.\n"; + } + return 136; + } + print $so pack("vV", 0x7946, $id); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7947) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 122; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if (length($name) == 0 || $name eq "") { + if ($defaultlanguage eq "F") { + print "Impossible de trouver le nom du compte [id: $id2]. Le compte n'existe pas.\n"; + } else { + print "Unabled to find the account [id: $id2] name. Account doesn't exist.\n"; + } + return 123; + } else { + if ($defaultlanguage eq "F") { + print "Le compte [id: $id2] a pour nom: $name.\n"; + } else { + print "The account [id: $id2] have the name: $name.\n"; + } + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Set a validity limit of an account +sub timesetaccount() { + my($userid, $date, $time) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print ": timeset aaaa/mm/jj [hh:mm:ss]\n"; + print " timeset 0 (0 = illimit)\n"; + printf " Heure par d馭aut [hh:mm:ss]: 23:59:59\n"; + } else { + print "Please input an account name.\n"; + print ": timeset yyyy/mm/dd [hh:mm:ss]\n"; + print " timeset 0 (0 = unlimited)\n"; + printf " Default time [hh:mm:ss]: 23:59:59\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + my($year, $month, $day) = split(/[.\-\/]/, $date); + my($hour, $minute, $second) = split(/:/, $time); + if ($time eq "") { + $hour = 23; + $minute = 59; + $second = 59; + } + my($timestamp); + if ($year eq "" || + ($year != 0 && ($month eq "" || $day eq "" || $hour eq "" || $minute eq "" || $second eq ""))) { + if ($defaultlanguage eq "F") { + print "Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"; + } else { + print "Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"; + } + return 102; + } + if ($year == 0) { + $timestamp = 0; + } else { + if ($year < 70) { + $year = $year + 100; + } + if ($year >= 1900) { + $year = $year - 1900; + } + if ($month < 1 || $month > 12) { + if ($defaultlanguage eq "F") { + print "Entrez un mois correct svp (entre 1 et 12).\n"; + } else { + print "Please give a correct value for the month (from 1 to 12).\n"; + } + return 102; + } + $month = $month - 1; + if ($day < 1 || $day > 31) { + if ($defaultlanguage eq "F") { + print "Entrez un jour correct svp (entre 1 et 31).\n"; + } else { + print "Please give a correct value for the day (from 1 to 31).\n"; + } + return 102; + } + if ((($month == 3 || $month == 5 || $month == 8 || $month == 10) && $day > 30) || + ($month == 1 && $day > 29)) { + if ($defaultlanguage eq "F") { + print "Entrez un jour correct en fonction du mois svp.\n"; + } else { + print "Please give a correct value for a day of this month.\n"; + } + return 102; + } + if ($hour < 0 || $hour > 23) { + if ($defaultlanguage eq "F") { + print "Entrez une heure correcte svp (entre 0 et 23).\n"; + } else { + print "Please give a correct value for the hour (from 0 to 23).\n"; + } + return 102; + } + if ($minute < 0 || $minute > 59) { + if ($defaultlanguage eq "F") { + print "Entrez des minutes correctes svp (entre 0 et 59).\n"; + } else { + print "Please give a correct value for the minutes (from 0 to 59).\n"; + } + return 102; + } + if ($second < 0 || $second > 59) { + if ($defaultlanguage eq "F") { + print "Entrez des secondes correctes svp (entre 0 et 59).\n"; + } else { + print "Please give a correct value for the seconds (from 0 to 59).\n"; + } + return 102; + } + $timestamp = POSIX::mktime($second, $minute, $hour, $day, $month, $year, 0, 0, -1); # -1: no winter/summer time modification + if ($timestamp == undef) { + if ($defaultlanguage eq "F") { + print "Date incorrecte.\n"; + print "Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"; + } else { + print "Invalid date.\n"; + print "Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"; + } + return 102; + } + } + + print $so pack("va24V", 0x7948, $userid, $timestamp); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7949) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(32); + my(@dat) = unpack("Va24V", $buf); + while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { + chop($dat[1]); + }; + if ($dat[0] != -1 && $dat[0] != 4294967295) { + if ($defaultlanguage eq "F") { + print "Limite de validit du compte [$dat[1]][id: $dat[0]] chang馥 avec succ鑚 ". + ($dat[2] == 0 ? "en [illimit饐.\n" : "pour 黎re jusqu'au ".(POSIX::ctime($dat[2]))); + } else { + print "Validity Limit of the account [$dat[1]][id: $dat[0]] successfully changed ". + ($dat[2] == 0 ? "to [unlimited].\n" : "to be until ".(POSIX::ctime($dat[2]))); + } + # localtime($dat[2]) is also possible to display instead of POSIX::ctime. + } else { + if ($defaultlanguage eq "F") { + print "Echec du changement de la validit du compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Account [$userid] validity limit changing failed. Account doesn't exist.\n"; + } + } + + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Add/substract time to the validity limit of an account +sub timeaddaccount() { + my($userid, $modif) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " timeadd nomtest +1m-2mn1s-6y\n"; + print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"; + print " et 6 ans dans le m麥e temps.\n"; + } else { + print "Please input an account name.\n"; + print " timeadd testname +1m-2mn1s-6y\n"; + print " this example adds 1 month and 1 second, and substracts 2 minutes\n"; + print " and 6 years at the same time.\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + my($year, $month, $day) = (0, 0 ,0); + my($hour, $minute, $second) = (0, 0 ,0); + + $modif = lc($modif); + while (length($modif) > 0) { + my($value) = int($modif); + if ($value == 0) { + $modif = substr($modif, 1); + } else { + if (substr($modif, 0, 1) =~ /[\-\+]/) { + $modif = substr($modif, 1); + } + while (length($modif) > 0 && substr($modif, 0, 1) =~ /[0-9]/) { + $modif = substr($modif, 1); + } + if (index($modif, "s") == 0) { + $second = $value; + $modif = substr($modif, 1); + } elsif (index($modif, "mn") == 0) { + $minute = $value; + $modif = substr($modif, 2); + } elsif (index($modif, "h") == 0) { + $hour = $value; + $modif = substr($modif, 1); + } elsif (index($modif, "d") == 0 || index($modif, "j") == 0) { + $day = $value; + $modif = substr($modif, 1); + } elsif (index($modif, "m") == 0) { + $month = $value; + $modif = substr($modif, 1); + } elsif (index($modif, "y") == 0 || index($modif, "a") == 0) { + $year = $value; + $modif = substr($modif, 1); + } else { + $modif = substr($modif, 1); + } + } + } + + if ($defaultlanguage eq "F") { + print " ann馥: $year\n"; + print " mois: $month\n"; + print " jour: $day\n"; + print " heure: $hour\n"; + print " minute: $minute\n"; + print " seconde: $second\n"; + } else { + print " year: $year\n"; + print " month: $month\n"; + print " day: $day\n"; + print " hour: $hour\n"; + print " minute: $minute\n"; + print " second: $second\n"; + } + + if ($year == 0 && $month == 0 && $day == 0 && $hour == 0 && $minute == 0 && $second == 0) { + if ($defaultlanguage eq "F") { + print "Vous devez entrer un ajustement avec cette commande, svp:\n"; + print " Valeur d'ajustement (-1, 1, +1, etc...)\n"; + print " Element modifi:\n"; + print " a ou y: ann馥\n"; + print " m: mois\n"; + print " j ou d: jour\n"; + print " h: heure\n"; + print " mn: minute\n"; + print " s: seconde\n"; + print " timeadd nomtest +1m-2mn1s-6y\n"; + print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"; + print " et 6 ans dans le m麥e temps.\n"; + } else { + print "Please give an adjustment with this command:\n"; + print " Adjustment value (-1, 1, +1, etc...)\n"; + print " Modified element:\n"; + print " a or y: year\n"; + print " m: month\n"; + print " j or d: day\n"; + print " h: hour\n"; + print " mn: minute\n"; + print " s: second\n"; + print " timeadd testname +1m-2mn1s-6y\n"; + print " this example adds 1 month and 1 second, and substracts 2 minutes\n"; + print " and 6 years at the same time.\n"; + } + return 137; + } + if ($year > 127 || $year < -127) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement d'ann馥s correct (de -127 127), svp.\n"; + } else { + print "Please give a correct adjustment for the years (from -127 to 127).\n"; + } + return 137; + } + if ($month > 255 || $month < -255) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement de mois correct (de -255 255), svp.\n"; + } else { + print "Please give a correct adjustment for the months (from -255 to 255).\n"; + } + return 137; + } + if ($day > 32767 || $day < -32767) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement de jours correct (de -32767 32767), svp.\n"; + } else { + print "Please give a correct adjustment for the days (from -32767 to 32767).\n"; + } + return 137; + } + if ($hour > 32767 || $hour < -32767) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement d'heures correct (de -32767 32767), svp.\n"; + } else { + print "Please give a correct adjustment for the hours (from -32767 to 32767).\n"; + } + return 137; + } + if ($minute > 32767 || $minute < -32767) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement de minutes correct (de -32767 32767), svp.\n"; + } else { + print "Please give a correct adjustment for the minutes (from -32767 to 32767).\n"; + } + return 137; + } + if ($second > 32767 || $second < -32767) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement de secondes correct (de -32767 32767), svp.\n"; + } else { + print "Please give a correct adjustment for the seconds (from -32767 to 32767).\n"; + } + return 137; + } + + print $so pack("va24vvvvvv", 0x7950, $userid, $year, $month, $day, $hour, $minute, $second); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x7951) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(32); + my(@dat) = unpack("Va24V", $buf); + while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { + chop($dat[1]); + }; + if ($dat[0] == -1 || $dat[0] == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec du changement de la validit du compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Account [$userid] validity limit changing failed. Account doesn't exist.\n"; + } + } elsif ($dat[2] == 0) { + if ($defaultlanguage eq "F") { + print "Limite de validit du compte [$dat[1]][id: $dat[0]] inchang馥.\n"; + print "Le compte a une validit illimit馥 ou\n"; + print "la modification est impossible avec les ajustements demand駸.\n"; + } else { + print "Validity limit of the account [$dat[1]][id: $dat[0]] unchanged.\n"; + print "The account have an unlimited validity limit or\n"; + print "the changing is impossible with the proposed adjustments.\n"; + } + } else { + if ($defaultlanguage eq "F") { + print "Limite de validit du compte [$dat[1]][id: $dat[0]] chang馥 avec succ鑚 ". + ($dat[2] == 0 ? "en [illimit饐.\n" : "pour 黎re jusqu'au ".(POSIX::ctime($dat[2]))); + } else { + print "Validity limit of the account [$dat[1]][id: $dat[0]] successfully changed ". + ($dat[2] == 0 ? "to [unlimited].\n" : "to be until ".(POSIX::ctime($dat[2]))); + } + # localtime($dat[2]) is also possible to display instead of POSIX::ctime. + } + + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Set the final date of a banishment of an account +sub bansetaccount() { + my($userid, $date, $time) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print ": banset aaaa/mm/jj [hh:mm:ss]\n"; + print " banset 0 (0 = d-bani)\n"; + print " ban/banish aaaa/mm/jj hh:mm:ss \n"; + print " unban/unbanish \n"; + printf " Heure par d馭aut [hh:mm:ss]: 23:59:59\n"; + } else { + print "Please input an account name.\n"; + print ": banset yyyy/mm/dd [hh:mm:ss]\n"; + print " banset 0 (0 = un-banished)\n"; + print " ban/banish yyyy/mm/dd hh:mm:ss \n"; + print " unban/unbanish \n"; + printf " Default time [hh:mm:ss]: 23:59:59\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + my($year, $month, $day) = split(/[.\-\/]/, $date); + my($hour, $minute, $second) = split(/:/, $time); + if ($time eq "") { + $hour = 23; + $minute = 59; + $second = 59; + } + my($timestamp); + if ($year eq "" || + ($year != 0 && ($month eq "" || $day eq "" || $hour eq "" || $minute eq "" || $second eq ""))) { + if ($defaultlanguage eq "F") { + print "Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"; + } else { + print "Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"; + } + return 102; + } + if ($year == 0) { + $timestamp = 0; + } else { + if ($year < 70) { + $year = $year + 100; + } + if ($year >= 1900) { + $year = $year - 1900; + } + if ($month < 1 || $month > 12) { + if ($defaultlanguage eq "F") { + print "Entrez un mois correct svp (entre 1 et 12).\n"; + } else { + print "Please give a correct value for the month (from 1 to 12).\n"; + } + return 102; + } + $month = $month - 1; + if ($day < 1 || $day > 31) { + if ($defaultlanguage eq "F") { + print "Entrez un jour correct svp (entre 1 et 31).\n"; + } else { + print "Please give a correct value for the day (from 1 to 31).\n"; + } + return 102; + } + if ((($month == 3 || $month == 5 || $month == 8 || $month == 10) && $day > 30) || + ($month == 1 && $day > 29)) { + if ($defaultlanguage eq "F") { + print "Entrez un jour correct en fonction du mois svp.\n"; + } else { + print "Please give a correct value for a day of this month.\n"; + } + return 102; + } + if ($hour < 0 || $hour > 23) { + if ($defaultlanguage eq "F") { + print "Entrez une heure correcte svp (entre 0 et 23).\n"; + } else { + print "Please give a correct value for the hour (from 0 to 23).\n"; + } + return 102; + } + if ($minute < 0 || $minute > 59) { + if ($defaultlanguage eq "F") { + print "Entrez des minutes correctes svp (entre 0 et 59).\n"; + } else { + print "Please give a correct value for the minutes (from 0 to 59).\n"; + } + return 102; + } + if ($second < 0 || $second > 59) { + if ($defaultlanguage eq "F") { + print "Entrez des secondes correctes svp (entre 0 et 59).\n"; + } else { + print "Please give a correct value for the seconds (from 0 to 59).\n"; + } + return 102; + } + $timestamp = POSIX::mktime($second, $minute, $hour, $day, $month, $year, 0, 0, -1); # -1: no winter/summer time modification + if ($timestamp == undef) { + if ($defaultlanguage eq "F") { + print "Date incorrecte.\n"; + print "Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n"; + } else { + print "Invalid date.\n"; + print "Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"; + } + return 102; + } + } + + print $so pack("va24V", 0x794a, $userid, $timestamp); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x794b) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(32); + my(@dat) = unpack("Va24V", $buf); + while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { + chop($dat[1]); + }; + if ($dat[0] != -1 && $dat[0] != 4294967295) { + if ($defaultlanguage eq "F") { + print "Date finale de banissement du compte [$dat[1]][id: $dat[0]] chang馥 avec succ鑚 ". + ($dat[2] == 0 ? "en [d-bannie].\n" : "pour 黎re jusqu'au ".(POSIX::ctime($dat[2]))); + } else { + print "Final date of banishment of the account [$dat[1]][id: $dat[0]] successfully changed ". + ($dat[2] == 0 ? "to [unbanished].\n" : "to be until ".(POSIX::ctime($dat[2]))); + } + # localtime($dat[2]) is also possible to display instead of POSIX::ctime. + } else { + if ($defaultlanguage eq "F") { + print "Echec du changement de la date finale de banissement du compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Account [$userid] final date of banishment changing failed. Account doesn't exist.\n"; + } + } + + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Add/substract time to the final date of a banishment of an account +sub banaddaccount() { + my($userid, $modif) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " banadd nomtest +1m-2mn1s-6y\n"; + print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"; + print " et 6 ans dans le m麥e temps.\n"; + } else { + print "Please input an account name.\n"; + print " banadd testname +1m-2mn1s-6y\n"; + print " this example adds 1 month and 1 second, and substracts 2 minutes\n"; + print " and 6 years at the same time.\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + my($year, $month, $day) = (0, 0 ,0); + my($hour, $minute, $second) = (0, 0 ,0); + + $modif = lc($modif); + while (length($modif) > 0) { + my($value) = int($modif); + if ($value == 0) { + $modif = substr($modif, 1); + } else { + if (substr($modif, 0, 1) =~ /[\-\+]/) { + $modif = substr($modif, 1); + } + while (length($modif) > 0 && substr($modif, 0, 1) =~ /[0-9]/) { + $modif = substr($modif, 1); + } + if (index($modif, "s") == 0) { + $second = $value; + $modif = substr($modif, 1); + } elsif (index($modif, "mn") == 0) { + $minute = $value; + $modif = substr($modif, 2); + } elsif (index($modif, "h") == 0) { + $hour = $value; + $modif = substr($modif, 1); + } elsif (index($modif, "d") == 0 || index($modif, "j") == 0) { + $day = $value; + $modif = substr($modif, 1); + } elsif (index($modif, "m") == 0) { + $month = $value; + $modif = substr($modif, 1); + } elsif (index($modif, "y") == 0 || index($modif, "a") == 0) { + $year = $value; + $modif = substr($modif, 1); + } else { + $modif = substr($modif, 1); + } + } + } + + if ($defaultlanguage eq "F") { + print " ann馥: $year\n"; + print " mois: $month\n"; + print " jour: $day\n"; + print " heure: $hour\n"; + print " minute: $minute\n"; + print " seconde: $second\n"; + } else { + print " year: $year\n"; + print " month: $month\n"; + print " day: $day\n"; + print " hour: $hour\n"; + print " minute: $minute\n"; + print " second: $second\n"; + } + + if ($year == 0 && $month == 0 && $day == 0 && $hour == 0 && $minute == 0 && $second == 0) { + if ($defaultlanguage eq "F") { + print "Vous devez entrer un ajustement avec cette commande, svp:\n"; + print " Valeur d'ajustement (-1, 1, +1, etc...)\n"; + print " Element modifi:\n"; + print " a ou y: ann馥\n"; + print " m: mois\n"; + print " j ou d: jour\n"; + print " h: heure\n"; + print " mn: minute\n"; + print " s: seconde\n"; + print " banadd nomtest +1m-2mn1s-6y\n"; + print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n"; + print " et 6 ans dans le m麥e temps.\n"; + } else { + print "Please give an adjustment with this command:\n"; + print " Adjustment value (-1, 1, +1, etc...)\n"; + print " Modified element:\n"; + print " a or y: year\n"; + print " m: month\n"; + print " j or d: day\n"; + print " h: hour\n"; + print " mn: minute\n"; + print " s: second\n"; + print " banadd testname +1m-2mn1s-6y\n"; + print " this example adds 1 month and 1 second, and substracts 2 minutes\n"; + print " and 6 years at the same time.\n"; + } + return 137; + } + if ($year > 127 || $year < -127) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement d'ann馥s correct (de -127 127), svp.\n"; + } else { + print "Please give a correct adjustment for the years (from -127 to 127).\n"; + } + return 137; + } + if ($month > 255 || $month < -255) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement de mois correct (de -255 255), svp.\n"; + } else { + print "Please give a correct adjustment for the months (from -255 to 255).\n"; + } + return 137; + } + if ($day > 32767 || $day < -32767) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement de jours correct (de -32767 32767), svp.\n"; + } else { + print "Please give a correct adjustment for the days (from -32767 to 32767).\n"; + } + return 137; + } + if ($hour > 32767 || $hour < -32767) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement d'heures correct (de -32767 32767), svp.\n"; + } else { + print "Please give a correct adjustment for the hours (from -32767 to 32767).\n"; + } + return 137; + } + if ($minute > 32767 || $minute < -32767) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement de minutes correct (de -32767 32767), svp.\n"; + } else { + print "Please give a correct adjustment for the minutes (from -32767 to 32767).\n"; + } + return 137; + } + if ($second > 32767 || $second < -32767) { + if ($defaultlanguage eq "F") { + print "Entrez un ajustement de secondes correct (de -32767 32767), svp.\n"; + } else { + print "Please give a correct adjustment for the seconds (from -32767 to 32767).\n"; + } + return 137; + } + + print $so pack("va24vvvvvv", 0x794c, $userid, $year, $month, $day, $hour, $minute, $second); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x794d) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(32); + my(@dat) = unpack("Va24V", $buf); + while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) { + chop($dat[1]); + }; + if ($dat[0] == -1 || $dat[0] == 4294967295) { + if ($defaultlanguage eq "F") { + print "Echec du changement de la date finale de banissement du compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Account [$userid] final date of banishment changing failed. Account doesn't exist.\n"; + } + } else { + if ($defaultlanguage eq "F") { + print "Date finale de banissement du compte [$dat[1]][id: $dat[0]] chang馥 avec succ鑚 ". + ($dat[2] == 0 ? "en [d-bannie].\n" : "pour 黎re jusqu'au ".(POSIX::ctime($dat[2]))); + } else { + print "Final date of banishment of the account [$dat[1]][id: $dat[0]] successfully changed ". + ($dat[2] == 0 ? "to [unbanished].\n" : "to be until ".(POSIX::ctime($dat[2]))); + } + # localtime($dat[2]) is also possible to display instead of POSIX::ctime. + } + + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Request to displaying information about an account (by its name) +sub whoaccount() { + my($userid) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " who nomtest\n"; + } else { + print "Please input an account name.\n"; + print " who testname\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + + print $so pack("va24", 0x7952, $userid); + $so->flush(); + + $buf = readso(2); + if (unpack("v", $buf) != 0x7953) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 122; + } + my($id2, $GM_level, $name, $sex, $count, $status, $error_message, $last_login, $last_ip, $email, $validite, $ban_date, $memo_size) = unpack("VCa24cVVa20a24a16a40VVv", readso(148)); + my($memo) = ""; + if ($memo_size > 0) { + $memo = unpack("a".$memo_size, readso($memo_size)); + } + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + while (length($error_message) > 0 && substr($error_message, length($error_message)-1, 1) eq chr(0)) { + chop($error_message); + }; + while (length($last_login) > 0 && substr($last_login, length($last_login)-1, 1) eq chr(0)) { + chop($last_login); + }; + while (length($last_ip) > 0 && substr($last_ip, length($last_ip)-1, 1) eq chr(0)) { + chop($last_ip); + }; + while (length($email) > 0 && substr($email, length($email)-1, 1) eq chr(0)) { + chop($email); + }; + while (length($memo) > 0 && substr($memo, length($memo)-1, 1) eq chr(0)) { + chop($memo); + }; + + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Impossible de trouver le compte [$userid]. Le compte n'existe pas.\n"; + } else { + print "Unabled to find the account [$userid]. Account doesn't exist.\n"; + } + return 123; + } else { + if ($defaultlanguage eq "F") { + print "Le compte [$userid] a les caract駻istiques suivantes:\n"; + } else { + print "The account [$userid] is set with:\n"; + } + if ($GM_level == 0) { + print " Id: $id2 (non-GM)\n"; + } else { + if ($defaultlanguage eq "F") { + print " Id: $id2 (GM niveau $GM_level)\n"; + } else { + print " Id: $id2 (GM level $GM_level)\n"; + } + } + if ($defaultlanguage eq "F") { + print " Nom: '$name'\n"; + print " Sexe: ".("Femme", "Male", "Serveur")[$sex]."\n"; + } else { + print " Name: '$name'\n"; + print " Sex: ".("Female", "Male", "Server")[$sex]."\n"; + } + print " E-mail: $email\n"; + if ($status == 7) { + print " Statut: 7 [You are Prohibited to log in until $error_message]\n"; + } else { + print " Statut: $status [".( + ($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), + "Unregistered ID", + "Incorrect Password", + "This ID is expired", + "Rejected from Server", + "You have been blocked by the GM Team", + "Your Game's EXE file is not the latest version", + "You are Prohibited to log in until %s", + "Server is jammed due to over populated", + "No MSG", + "This ID is totally erased")[$status == 100 ? 10 : $status]."]\n"; + } + if ($defaultlanguage eq "F") { + print " Banissement: ".($ban_date == 0 ? "non banni.\n" : "jusqu'au ".(POSIX::ctime($ban_date))); + print " Compteur: $count connexion".("s", "")[$count > 1 ? 0 : 1]."\n"; + print " Derni鑽e connexion le: $last_login (ip: $last_ip)\n"; + print " Limite de validit: ".($validite == 0 ? "illimit.\n" : "jusqu'au ".(POSIX::ctime($validite))); + } else { + print " Banishment: ".($ban_date == 0 ? "not banished.\n" : "until ".(POSIX::ctime($ban_date))); + print " Count: $count connection".("s", "")[$count > 1 ? 0 : 1]."\n"; + print " Last connection at: $last_login (ip: $last_ip)\n"; + print " Validity limit: ".($validite == 0 ? "unlimited.\n" : "until ".(POSIX::ctime($validite))); + } + print " Memo: '$memo'\n"; + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Request to displaying information about an account (by its id) +sub infoaccount() { + my($id) = @_; + if ($id < 0) { + if ($defaultlanguage eq "F") { + print "Entrez un id ayant une valeur positive svp.\n"; + } else { + print "Please input a positive value for the id.\n"; + } + return 136; + } + + print $so pack("vV", 0x7954, $id); + $so->flush(); + + $buf = readso(2); + if (unpack("v", $buf) != 0x7953) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 122; + } + my($id2, $GM_level, $name, $sex, $count, $status, $error_message, $last_login, $last_ip, $email, $validite, $ban_date, $memo_size) = unpack("VCa24cVVa20a24a16a40VVv", readso(148)); + my($memo) = ""; + if ($memo_size > 0) { + $memo = unpack("a".$memo_size, readso($memo_size)); + } + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + while (length($error_message) > 0 && substr($error_message, length($error_message)-1, 1) eq chr(0)) { + chop($error_message); + }; + while (length($last_login) > 0 && substr($last_login, length($last_login)-1, 1) eq chr(0)) { + chop($last_login); + }; + while (length($last_ip) > 0 && substr($last_ip, length($last_ip)-1, 1) eq chr(0)) { + chop($last_ip); + }; + while (length($email) > 0 && substr($email, length($email)-1, 1) eq chr(0)) { + chop($email); + }; + while (length($memo) > 0 && substr($memo, length($memo)-1, 1) eq chr(0)) { + chop($memo); + }; + + if (length($name) == 0 || $name eq "") { + if ($defaultlanguage eq "F") { + print "Impossible de trouver le nom du compte [id: $id2]. Le compte n'existe pas.\n"; + } else { + print "Unabled to find the account [id: $id2] name. Account doesn't exist.\n"; + } + return 123; + } else { + if ($defaultlanguage eq "F") { + print "Le compte [id: $id2] a les caract駻istiques suivantes:\n"; + } else { + print "The account [id: $id2] is set with:\n"; + } + if ($GM_level == 0) { + print " Id: $id2 (non-GM)\n"; + } else { + if ($defaultlanguage eq "F") { + print " Id: $id2 (GM niveau $GM_level)\n"; + } else { + print " Id: $id2 (GM level $GM_level)\n"; + } + } + if ($defaultlanguage eq "F") { + print " Nom: '$name'\n"; + print " Sexe: ".("Femme", "Male", "Serveur")[$sex]."\n"; + } else { + print " Name: '$name'\n"; + print " Sex: ".("Female", "Male", "Server")[$sex]."\n"; + } + print " E-mail: $email\n"; + if ($status == 7) { + print " Statut: 7 [You are Prohibited to log in until $error_message]\n"; + } else { + print " Statut: $status [".( + ($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"), + "Unregistered ID", + "Incorrect Password", + "This ID is expired", + "Rejected from Server", + "You have been blocked by the GM Team", + "Your Game's EXE file is not the latest version", + "You are Prohibited to log in until %s", + "Server is jammed due to over populated", + "No MSG", + "This ID is totally erased")[$status == 100 ? 10 : $status]."]\n"; + } + if ($defaultlanguage eq "F") { + print " Banissement: ".($ban_date == 0 ? "non banni.\n" : "jusqu'au ".(POSIX::ctime($ban_date))); + print " Compteur: $count connexion".("s", "")[$count > 1 ? 0 : 1]."\n"; + print " Derni鑽e connexion le: $last_login (ip: $last_ip)\n"; + print " Limite de validit: ".($validite == 0 ? "illimit.\n" : "jusqu'au ".(POSIX::ctime($validite))); + } else { + print " Banishment: ".($ban_date == 0 ? "not banished.\n" : "until ".(POSIX::ctime($ban_date))); + print " Count: $count connection".("s", "")[$count > 1 ? 0 : 1]."\n"; + print " Last connection at: $last_login (ip: $last_ip)\n"; + print " Validity limit: ".($validite == 0 ? "unlimited.\n" : "until ".(POSIX::ctime($validite))); + } + print " Memo: '$memo'\n"; + } + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Check the validity of a password +# (Note: never send back a password with login-server!! security of passwords) +sub checkaccount() { + my($userid, $passwd) = @_; + if ($userid eq "") { + if ($defaultlanguage eq "F") { + print "Entrez un nom de compte svp.\n"; + print " check testname motdepasse\n"; + } else { + print "Please input an account name.\n"; + print " check testname password\n"; + } + return 136; + } + if (verify_accountname($userid) == 0) { + return 102; + } + if ($passwd eq "") { + return 134 if (($passwd = typepasswd()) eq ""); + } + if (verify_password($passwd) == 0) { + return 131; + } + print $so pack("va24a24", 0x793a, $userid,$passwd); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x793b) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 132; + } + $buf = readso(28); + my($id2, $name) = unpack("Va24", $buf); + while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) { + chop($name); + }; + if ($id2 == -1 || $id2 == 4294967295) { + if ($defaultlanguage eq "F") { + print "Le compte [$userid] n'existe pas ou le mot de passe est incorrect.\n"; + } else { + print "The account [$userid] doesn't exist or the password is incorrect.\n"; + } + return 133; + } else { + if ($defaultlanguage eq "F") { + print "Le mot de passe donn correspond bien au compte [$name][id: $id2].\n"; + } else { + print "The proposed password is correct for the account [$name][id: $id2].\n"; + } + } + return 130; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Request to login-server to reload GM configuration file +sub reloadGM() { + print $so pack("v", 0x7955); + $so->flush(); + if ($defaultlanguage eq "F") { + print "Demande de recharger le fichier de configuration des GM envoy馥.\n"; + print "V駻ifiez les comptes GM actuels (apr鑚 rechargement):\n"; + } else { + print "Request to reload the GM configuration file sended.\n"; + print "Check the actual GM accounts (after reloading):\n"; + } + &listaccount(0, 0, 1); # 1: to list only GM + return 180; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Send a broadcast message +sub sendbroadcast() { + my($type, $message) = @_; + if ($message eq "" || length($message) == 0) { + if ($defaultlanguage eq "F") { + print "Entrez un message svp.\n"; + if ($type == 0) { + print " kami un message\n"; + } else { + print " kamib un message\n"; + } + } else { + print "Please input a message.\n"; + if ($type == 0) { + print " kami a message\n"; + } else { + print " kamib a message\n"; + } + } + return 136; + } + + print $so pack("vvVa".length($message), 0x794e, $type, length($message), $message); + $so->flush(); + $buf = readso(2); + if (unpack("v", $buf) != 0x794f) { + if ($defaultlanguage eq "F") { + print "Probl鑪e de connexion au serveur (r駱onse incorrecte).\n"; + } else { + print "Connection error to the server (incorrect answer).\n"; + } + return 152; + } + $buf = readso(2); + my($answer) = unpack("v", $buf); + if ($answer == -1 || $answer == 65535) { + if ($defaultlanguage eq "F") { + print "Echec de l'envoi du message. Aucun server de char en ligne.\n"; + } else { + print "Message sending failed. No online char-server.\n"; + } + } else { + if ($defaultlanguage eq "F") { + print "Message transmis au server de logins avec succ鑚.\n"; + } else { + print "Message successfully sended to login-server.\n"; + } + } +} + +#-------------------------------------------------------------------------- + +# Sub-function: Change language of displaying +sub changelanguage() { + my($language) = @_; + if ($language eq "" || length($language) == 0) { + if ($defaultlanguage == 'F') { + printf("Entrez une langue svp.\n"); + printf(" language english\n"); + printf(" language fran軋is\n"); + } else { + printf("Please input a language.\n"); + printf(" language english\n"); + printf(" language fran軋is\n"); + } + return 136; + } + + $language = uc(substr($language, 0, 1)); + if ($language =~ /^[EF]$/) { + $defaultlanguage = $language; + if ($defaultlanguage == 'F') { + printf("Changement de la langue d'affichage en Fran軋is.\n"); + } else { + printf("Displaying language changed to English.\n"); + } + } else { + if ($defaultlanguage == 'F') { + printf("Langue non param騁r馥 (langues possibles: 'Fran軋is' ou 'English').\n"); + } else { + printf("Undefined language (possible languages: Fran軋is or English).\n"); + } + } + + return 0; +} + +#-------------------------------------------------------------------------- + +# Sub-function: sending 'end of connection' packet +sub quit() { + print $so pack("v", 0x7532); + $so->flush(); +} + +#-------------------------------------------------------------------------- + +# Sub-function: Get datas from the socket +sub readso() { + my($len) = shift; + my($buf); + if (read($so, $buf, $len) < $len) { + if ($defaultlanguage eq "F") { + print "Erreur de lecture sur la Socket.\n"; + } else { + print "Socket read error.\n"; + } + exit(3); + } + return $buf; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Input of a password +sub typepasswd { + my($passwd1, $passwd2); + cbreak(); + if ($defaultlanguage eq "F") { + print "Entrez le mot de passe > "; $passwd1 = ; chomp($passwd1); print "\n"; + print "R-entrez le mot de passe > "; $passwd2 = ; chomp($passwd2); print "\n"; + } else { + print "Type the password > "; $passwd1 = ; chomp($passwd1); print "\n"; + print "Verify the password > "; $passwd2 = ; chomp($passwd2); print "\n"; + } + cooked(); + if ($passwd1 ne $passwd2) { + if ($defaultlanguage eq "F") { + print "Erreur de v駻ification du mot de passe: Saisissez le m麥e mot de passe svp.\n"; + } else { + print "Password verification failed. Please input same password.\n"; + } + return ""; + } + return $passwd1; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Return ordonal text of a number +sub makeordinal { + my($c) = shift; + if ($defaultlanguage eq "F") { + if ($c < 1) { + return $c; + } + return $c.("er", "鑪e")[$c == 1 ? 0 : 1]; + } else { + if ($c % 10 < 4 && $c % 10 != 0 && ($c < 10 || $c > 20)) { + return $c.("st","nd","rd")[$c % 10 - 1]; + } + return $c."th"; + } +} + +#-------------------------------------------------------------------------- + +# Sub-function: Test of the validity of an account name (return 0 if incorrect, and 1 if ok) +sub verify_accountname { + my($account_name) = @_; # Get the account_name + if ($account_name =~ /[\x00-\x1f]/) { # remove control char + my($c) = length($`) + 1; + if ($defaultlanguage eq "F") { + print "Caract鑽e interdit trouv dans le nom du compte (".makeordinal($c)." caract鑽e).\n"; + } else { + print "Illegal character found in the account name (".makeordinal($c)." character).\n"; + } + return 0; + } + if (length($account_name) < 4) { + if ($defaultlanguage eq "F") { + print "Nom du compte trop court. Entrez un nom de compte de 4-23 caract鑽es.\n"; + } else { + print "Account name is too short. Please input an account name of 4-23 bytes.\n"; + } + return 0; + } + if (length($account_name) > 23) { + if ($defaultlanguage eq "F") { + print "Nom du compte trop long. Entrez un nom de compte de 4-23 caract鑽es.\n"; + } else { + print "Account name is too long. Please input an account name of 4-23 bytes.\n"; + } + return 0; + } + return 1; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Test of the validity of password (return 0 if incorrect, and 1 if ok) +sub verify_password { + my($password) = @_; # Get the password + if ($password =~ /[\x00-\x1f]/) { + my($c) = length($`) + 1; + if ($defaultlanguage eq "F") { + print "Caract鑽e interdit trouv dans le mot de passe (".makeordinal($c)." caract鑽e).\n"; + } else { + print "Illegal character found in the password (".makeordinal($c)." character).\n"; + } + return 0; + } + if (length($password) < 4) { + if ($defaultlanguage eq "F") { + print "Mot de passe trop court. Entrez un mot de passe de 4-23 caract鑽es.\n"; + } else { + print "Password is too short. Please input a password of 4-23 bytes.\n"; + } + return 0; + } + if (length($password) > 23) { + if ($defaultlanguage eq "F") { + print "Mot de passe trop long. Entrez un mot de passe de 4-23 caract鑽es.\n"; + } else { + print "Password is too long. Please input a password of 4-23 bytes.\n"; + } + return 0; + } + return 1; +} + +#-------------------------------------------------------------------------- + +# Sub-function: Test of the validity of an e-mail (return 0 if incorrect, and 1 if ok) +sub verify_email { + my($email) = @_; # Get the e-mail + # To ignore a '.' before the @ (wanadoo, a provider, do that) + $email =~ s/\.\@/\@/; + # If the e-mail is void, it's not correct -> return 0 + if ($email eq '') { + return(0); + } + # If the e-mail have no "@", it's not correct -> return 0 + if ($email !~ /\@/) { + return(0); + } + # If the e-mail have a ",", a space, a tab or a ";", it's not correct -> return 0 + if ($email =~ /[\,|\s|\;]/) { + return(0) + }; + # IF + # (the e-mail contains 2 "@", or ".." or "@." or starts or finishes by a ".") + # OR IF + # (the e-mail doesn't contain "@localhost" AND + # - it doesn't contain characters followed by "@" itself followed by letters itself followed by "." and 2 or more letters + # - or an IP address) + # -> so, it's not good ! (finish !) + if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/ || + ($email !~ /^.+\@localhost$/ && + $email !~ /^.+\@\[?(\w|[-.])+\.[a-zA-Z]{2,3}|[0-9]{1,3}\]?$/)) { + return(0); # non-valid email + } else { + # If not, the e-email address is correct + return(1); # valid email + } +} \ No newline at end of file diff --git a/src/tool/mapcheck.sh b/src/tool/mapcheck.sh new file mode 100644 index 000000000..54cdd0765 --- /dev/null +++ b/src/tool/mapcheck.sh @@ -0,0 +1,34 @@ +#!/bin/sh +echo "============================================" +echo "= map server status checker... =" +echo "============================================" +./map-server.exe & +sleep 40 + +while [ 0 ] +do + pcpu=` top -n 1| grep map-server | awk '{print $9}' | awk 'BEGIN{FS="."} {print $1}' ` + if [ "$pcpu" -gt 80 ];then + echo "============================================" + echo "map server is more than 80% (now $pcpu%)" + echo "============================================" + ppid=` ps -a | grep map-server | awk '{print $1}' ` + kill $ppid + ./map-server.exe & + sleep 40 + else + pmapct=` ps -a| grep map-server | wc -l ` + if [ "$pmapct" -eq 0 ];then + echo "============================================" + echo "map server is not running..." + echo "restart map server..." + echo "============================================" + ./map-server.exe & + sleep 40 + #echo "test" + else + echo "map server is ok (now $pcpu%)..." + sleep 5 + fi + fi +done \ No newline at end of file diff --git a/src/tool/mapchecker.sh b/src/tool/mapchecker.sh new file mode 100644 index 000000000..5f26c9d4b --- /dev/null +++ b/src/tool/mapchecker.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +athena_dir="/home/athena/658/" + +while [ true ] ; do + +if [ ` ps fauxw | grep map-server | grep -v grep | wc -l ` -eq 0 ];then + #echo `date` " -- map-server crashed - restarting" + echo `date` " -- map-server crashed - restarting" >> /var/log/athena_status.log + killall -9 map-server + cd $athena_dir + nohup ./map-server ./conf/map_athena.conf ./inter_athena.conf & + sleep 240 + #sleep 40 #for fast pc's remove the "#" at the beginning of the line and delete the line above +fi + + +if [ ` ps fauxw | grep map-server | grep -v grep | awk '{print $3}' | awk 'BEGIN{FS="."} {print $1}' ` -gt 10 ];then + #echo `date` " -- mapserver cpuload over 10 - restarting" + echo `date` " -- mapserver cpuload over 10 - restarting" >> /var/log/athena_status.log + killall -9 map-server + cd $athena_dir + nohup ./map-server ./conf/map_athena.conf ./inter_athena.conf & + sleep 240 + #sleep 40 #for fast pc's remove the "#" at the beginning of the line and delete the line above + #echo `date` " -- restarted" + echo `date` " -- restarted" >> /var/log/athena_status.log +fi + +if [ ` ps fauxw | grep char-server | grep -v grep | wc -l ` -eq 0 ];then + #echo `date` " -- char server crashed - restarting" + echo `date` " -- char server crashed - restarting" >> /var/log/athena_status.log + killall -9 char-server + cd $athena_dir + nohup ./char-server ./conf/char_athena.conf ./conf/inter_athena.conf & + #echo `date` " -- restarted" + echo `date` " -- restarted" >> /var/log/athena_status.log + +fi + +if [ ` ps fauxw | grep login-server | grep -v grep | wc -l ` -eq 0 ];then + #echo `date` " -- login server crashed - restarting" + echo `date` " -- login server crashed - restarting" >> /var/log/athena_status.log + killall -9 login-server + cd $athena_dir + nohup ./login-server ./conf/login_athena.conf & + #echo `date` " -- restarted" + echo `date` " -- restarted" >> /var/log/athena_status.log + +fi + + +#echo `date` " -- everything is fine" +echo `date` " -- everything is fine" >> /var/log/athena_status.log +sleep 30 +done diff --git a/src/webserver/Makefile b/src/webserver/Makefile new file mode 100644 index 000000000..149f5a900 --- /dev/null +++ b/src/webserver/Makefile @@ -0,0 +1,20 @@ +all: + #Generate framework... + $(CC) -c parse.c + $(CC) -c generate.c + $(CC) -c htmlstyle.c + $(CC) -c logs.c + + #Generate "pages"... + cd pages && $(CC) -c about.c && cd .. + cd pages && $(CC) -c sample.c && cd .. + cd pages && $(CC) -c notdone.c && cd .. + + #Building the server... + $(CC) -o webserver main.c parse.o generate.o htmlstyle.o \ + logs.o pages/about.o pages/sample.o pages/notdone.o + +clean: + rm -f *.o + rm -f pages/*.o + rm -f webserver diff --git a/src/webserver/doc/API.txt b/src/webserver/doc/API.txt new file mode 100644 index 000000000..92f88c5e3 --- /dev/null +++ b/src/webserver/doc/API.txt @@ -0,0 +1,50 @@ +Here's the webserver API, so you can work on the webserver. + +My personal goal is to make this interface simple, so that coding it +will be like coding in some scripting language... + + + +char *get_param(char in_string[500], char swhat[500]); + +This function simply returns various data from the query string. + *Pass get_param NOTHING longer than 500 in length! + + What do I pass where in_string is? + The query string. + + What do I pass where swhat is? + One of two things... + Either 0 for the path of the 'page' + or you can pass it the param you wish to lookup. + + + + + + +char *get_query(char *inquery); + +This function simply returns a query string from the raw server request. +This is used once in main, I doubt you'll need it. + + + + + +void web_send(int sockin, char *in_data); + +Super easy way of sending data to a webpage! +Simply put in the socket name and then the data. + + Ex: + web_send(socket, "I like cheese!\n"); + + + + +char *html_header(char* title); +Easy way to print the eAthena header for the server. + + Ex: + web_send(sockethere, html_header("About")); diff --git a/src/webserver/doc/README b/src/webserver/doc/README new file mode 100644 index 000000000..edcabf1eb --- /dev/null +++ b/src/webserver/doc/README @@ -0,0 +1,11 @@ +This readme is intended for the programmers of eAthena. + +This webserver's apis are in API.txt. + +To make this simple, generate.c should handle most of the work this sever does +in terms of what people see. + +When a request is made the server shoots it off to generate.c. + +You are welcome to create more functions used by generate.c to generate pages +though, so don't feel limited by that one file. diff --git a/src/webserver/generate.c b/src/webserver/generate.c new file mode 100644 index 000000000..26d2c7492 --- /dev/null +++ b/src/webserver/generate.c @@ -0,0 +1,38 @@ + +void generate_page(char password[25], int sock_in, char *query, char *ip) +{ + char *page = get_param(query, 0); + char *ppass = get_param(query, "password"); + + + if ( (ppass == 0) || (strcmp(password, ppass) != 0) ) + { + web_send(sock_in, html_header("Enter your password")); + web_send(sock_in, "

NOT LOGGED IN!

\n"); + web_send(sock_in, "Enter your password:
\n\n"); + web_send(sock_in, "\n"); + } + else + { + + + //To make this simple, we will have a bunch of if statements + //that then shoot out data off into functions. + + + //The 'index' + if ( strcmp(page, "/") == 0 ) + generate_notdone(sock_in, query, ip); + + + //About page: + if ( strcmp(page, "/about.html") == 0 ) + generate_about(sock_in, query, ip); + + + //Test page: + if ( strcmp(page, "/testing/") == 0 ) + generate_sample(sock_in, query, ip); + + } +} diff --git a/src/webserver/htmlstyle.c b/src/webserver/htmlstyle.c new file mode 100644 index 000000000..a1320a385 --- /dev/null +++ b/src/webserver/htmlstyle.c @@ -0,0 +1,51 @@ +char output[10000]; + +char *html_header(char *title) +{ + memset(output, 0x0, 10000); + char *text = "\n" + "
\n" + "\n" + "
\n" + "\"Athena\"\n" + "
\n" + "
\n"; + "\n" + "
" + "
" + "\n" + "To the Forum
\n" + "\n" + "" + "
\n" + "
\n" + "Athena « Portal »
\n"; + + sprintf(output, "%s\n%s\n", title, text); + + return output; +} + + + +char *html_start_form(char *location, char *action) +{ + memset(output, 0x0, 10000); + sprintf(output, "", location, action); + return output; + + +} + + +char *html_end_forum(void) +{ + return "
"; +} + + + diff --git a/src/webserver/logs.c b/src/webserver/logs.c new file mode 100644 index 000000000..faa1abf80 --- /dev/null +++ b/src/webserver/logs.c @@ -0,0 +1,8 @@ +#include + +void log_visit(char *query, char *ip) +{ + time_t timer; + timer=time(NULL); + printf("%s - \"%s\" - %s", ip, query, asctime(localtime(&timer))); +} diff --git a/src/webserver/main.c b/src/webserver/main.c new file mode 100644 index 000000000..ac27c5e71 --- /dev/null +++ b/src/webserver/main.c @@ -0,0 +1,142 @@ +/*************************************************************************** + description + ------------------- + author : (C) 2004 by Michael J. Flickinger + email : mjflick@cpan.org + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BLOG 10 + +char *header = "\n"; +char recvin[500], password[25]; +int s_port; + +void sigchld_handler(int s) +{ + while(wait(NULL) > 0); +} + +int main(int argc, char **argv) +{ + if (argc < 3) + { + printf("eAthena Web Server\n"); + printf("usage: %s [password] [port]\n", argv[0]); + exit(0); + } + + s_port = atoi(argv[2]); + + if ((s_port < 1) || (s_port > 65534)) + { + printf("Error: The port you choose is not valid port.\n"); + exit(0); + } + + if (strlen(argv[1]) > 25) + { + printf("Error: Your password is too long.\n"); + printf("It must be shorter than 25 characters.\n"); + exit(0); + } + + memset(password, 0x0, 25); + memcpy(password, argv[1], strlen(argv[1])); + + int sockfd, new_fd; + struct sockaddr_in my_addr; + struct sockaddr_in their_addr; + int sin_size; + + struct sigaction sa; + + int yes=1; + + if ((sockfd = socket(AF_INET, SOCK_STREAM,0)) == -1) + { + perror("Darn, this is broken."); + exit(0); + } + + if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) + { + perror("Error... :-("); + } + + //Now we know we have a working socket. :-) + + my_addr.sin_family = AF_INET; + my_addr.sin_port = htons(s_port); + my_addr.sin_addr.s_addr = INADDR_ANY; + memset(&(my_addr.sin_zero), '\0', 8); + + if ( bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) + { + perror("can not bind to this port"); + exit(0); + } + + if ( listen(sockfd, BLOG) == -1) + { + perror("can not listen on port"); + exit(0); + } + + sa.sa_handler = sigchld_handler; + + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + + if (sigaction(SIGCHLD, &sa, NULL) == -1) + { + perror("sigaction sucks"); + exit(0); + } + + printf("The eAthena webserver is up and listening on port %i.\n", s_port); + + while(1) + { + sin_size = sizeof(struct sockaddr_in); + new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size); + + if (!fork()) + { + close(sockfd); + memset(recvin, 0x0, 500); + recv(new_fd, recvin, 500, 0); + send(new_fd, header, strlen(header), 0); + generate_page(password, new_fd, get_query(recvin), inet_ntoa(their_addr.sin_addr)); + log_visit(get_query(recvin), inet_ntoa(their_addr.sin_addr)); + + close(new_fd); + exit(0); + } + close(new_fd); + } + + return 0; +} diff --git a/src/webserver/pages/about.c b/src/webserver/pages/about.c new file mode 100644 index 000000000..f1d94d1e0 --- /dev/null +++ b/src/webserver/pages/about.c @@ -0,0 +1,6 @@ +void generate_about(int sock_in, char *query, char *ip) +{ +//printf("%s", html_header("About")); + web_send(sock_in, html_header("About")); + web_send(sock_in, "
eAthena Web Server!
\n"); +} diff --git a/src/webserver/pages/notdone.c b/src/webserver/pages/notdone.c new file mode 100644 index 000000000..07abd33da --- /dev/null +++ b/src/webserver/pages/notdone.c @@ -0,0 +1,5 @@ +void generate_notdone(int sock_in, char *query, char *ip) +{ + web_send(sock_in, "Not here!\n"); + web_send(sock_in, "

This page/feature is not done yet.
\n

"); +} diff --git a/src/webserver/pages/sample.c b/src/webserver/pages/sample.c new file mode 100644 index 000000000..7bec663f2 --- /dev/null +++ b/src/webserver/pages/sample.c @@ -0,0 +1,24 @@ + + +void generate_sample(int sock_in, char *query, char *ip) +{ + + char *name = get_param(query, "name"); + + web_send(sock_in, "SAMPLE\n"); + + + //If a name was not entered... + if ( name == '\0' ) + { + web_send(sock_in, "
\n"); + web_send(sock_in, "\n"); + web_send(sock_in, "\n"); + } + else + { + web_send(sock_in, "Your name is: "); + web_send(sock_in, get_param(query, "name")); + } +printf("OK!\n"); +} diff --git a/src/webserver/parse.c b/src/webserver/parse.c new file mode 100644 index 000000000..323261c6c --- /dev/null +++ b/src/webserver/parse.c @@ -0,0 +1,135 @@ +#include + +char filtered_query[2000]; +char rdata[500]; +char param_n[500]; +char param_d[500]; + + +char *get_query(char *inquery) +{ + memset(filtered_query, 0x0, 2000); + sscanf(inquery, "GET %s %[$]", filtered_query); + return(filtered_query); +} + +void web_send(int sockin, char *in_data) +{ + send(sockin, in_data, strlen(in_data), 0); +} + + +//THIS IS BAD CODE BE CAREFULL WITH IT! +//Watch out for buffer overflow... +//When using please make sure to check the string size. + +//Also note: +//I take no pride in this code, it is a really bad way of doing this... +char *get_param(char in_string[500], char swhat[500]) +{ + int i = 0; + int marker, iswitch, pint, dint; + char flux[500]; + memset(flux, 0x0, 500); + + //Get the path of out "page" + if (swhat == 0) + { + //while i is not equal to array size + while (i != 500) + { + //if there is a question mark, halt! + if (in_string[i] == '?') + { + i = 499; + } + else + rdata[i] = in_string[i]; + + i++; + } + return rdata; + } + else //so, we want a param... + { + //calculate where param begins + while (i != 500) + { + if (in_string[i] == '?') + { + marker = i + 1; + i = 499; + } + i++; + } + + i = 0; + + //keep morons from trying to crash this + if ((marker > 500)||(marker < 1)) + marker = 500; + + while(marker != 500) + { + if ((in_string[marker] != '&') && (in_string[marker] != '\0')) + { + flux[i] = in_string[marker]; + i++; + } + else + { + + //we have a param, now we must dig through it + + //clear temp vars + memset(param_n, 0x0, 500); + memset(param_d, 0x0, 500); + iswitch = 0; + pint = 0; + dint = 0; + i = 0; + + //split result into param_n and param_d + while(i != 500) + { + if ( (flux[i] != '=') && (flux[i] != '\0') ) + { + if (iswitch == 0) + { + param_n[pint] = flux[i]; + pint++; + } + else + { + param_d[dint] = flux[i]; + dint++; + } + } + else + { + iswitch = 1; + } + if (flux[i] == '\0') + i = 499; + + i++; + } + + if ( strcmp(param_n, swhat) == 0 ) + { + return param_d; + } + + i = 0; + } + + if (in_string[marker] == '\0') + { + marker = 499; + } + marker++; + } + return 0; + } +} + -- cgit v1.2.3-70-g09d2 From c49b2b2da95036696f3afcf49e176bac5328da53 Mon Sep 17 00:00:00 2001 From: celest Date: Tue, 29 Mar 2005 02:44:22 +0000 Subject: * Added auto create 'save' folder from 'save-tmpl' when compiling for the first time git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1318 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 2 ++ Makefile | 2 ++ 2 files changed, 4 insertions(+) (limited to 'Makefile') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 7fd141268..8f647ffc8 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,6 +1,8 @@ Date Added 03/29 + * Added auto create 'save' folder from 'save-tmpl' when compiling for the + first time, thanks to Jbain * Fixed 'use_sql_db' not read properly in SQL char server, thanks to Wallex * Added three fields to mmo_charstatus - father/mother/child needed for adoption system [veider] diff --git a/Makefile b/Makefile index 5bbe28131..65b191e50 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,8 @@ all: conf txt conf: cp -r conf-tmpl conf rm -rf conf/.svn conf/*/.svn + cp -r save-tmpl save + rm -rf save/.svn txt : src/common/GNUmakefile src/login/GNUmakefile src/char/GNUmakefile src/map/GNUmakefile src/ladmin/GNUmakefile conf cd src ; cd common ; $(MAKE) $(MKDEF) $@ ; cd .. -- cgit v1.2.3-70-g09d2 From bb2bdd9bca136495ab3a4b31755d58f97548f279 Mon Sep 17 00:00:00 2001 From: veider Date: Tue, 29 Mar 2005 21:51:46 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1339 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 2 +- src/common/socket.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 65b191e50..07d7a54b2 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ CC = gcc -pipe GCLIB = # GCLIB = -ldmalloc -PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT +PACKETDEF = -DPACKETVER=6 -DNEW_006b #PACKETDEF = -DPACKETVER=5 -DNEW_006b #PACKETDEF = -DPACKETVER=4 -DNEW_006b #PACKETDEF = -DPACKETVER=3 -DNEW_006b diff --git a/src/common/socket.h b/src/common/socket.h index 130c33d0c..a78b71ad1 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -14,6 +14,10 @@ #include #endif #include +// SO_REUSEPORT is predefined in FreeBSD in sys/socket.h so we only have to define if it's not +#ifndef SO_REUSEPORT +#define SO_REUSEPORT +#endif #include "malloc.h" -- cgit v1.2.3-70-g09d2 From 8766394782084eef1b77d39f5b8e54947847735f Mon Sep 17 00:00:00 2001 From: amber Date: Wed, 30 Mar 2005 01:17:30 +0000 Subject: Fix linux builds git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1340 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 2 +- src/common/socket.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 07d7a54b2..65b191e50 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ CC = gcc -pipe GCLIB = # GCLIB = -ldmalloc -PACKETDEF = -DPACKETVER=6 -DNEW_006b +PACKETDEF = -DPACKETVER=6 -DNEW_006b -DSO_REUSEPORT #PACKETDEF = -DPACKETVER=5 -DNEW_006b #PACKETDEF = -DPACKETVER=4 -DNEW_006b #PACKETDEF = -DPACKETVER=3 -DNEW_006b diff --git a/src/common/socket.h b/src/common/socket.h index a78b71ad1..6793cfdb5 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -14,11 +14,6 @@ #include #endif #include -// SO_REUSEPORT is predefined in FreeBSD in sys/socket.h so we only have to define if it's not -#ifndef SO_REUSEPORT -#define SO_REUSEPORT -#endif - #include "malloc.h" extern time_t tick_; -- cgit v1.2.3-70-g09d2 From 1150272fe0ef7330c35fcb8d31a59dd055cd490d Mon Sep 17 00:00:00 2001 From: amber Date: Thu, 31 Mar 2005 20:23:57 +0000 Subject: More g++ fixes to make it cleaner [MouseJstr] git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1362 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 2 ++ Makefile | 8 ++++---- src/login/login.c | 32 ++++++++++++++++---------------- src/map/clif.c | 2 +- src/map/mob.c | 20 ++++++++++---------- src/map/pc.c | 18 +++++++++--------- src/map/status.c | 18 +++++++++--------- 7 files changed, 51 insertions(+), 49 deletions(-) (limited to 'Makefile') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index c6adfd600..0ad920c30 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,6 +2,8 @@ Date Added 03/31 + * More pedantic g++ fixes so that it builds without any and + all warnings [SVN 1362: MouseJstr] * Removed some #include's causing warnings on some platforms [SVN 1360: MouseJstr] * Fixed a bug with InitTimer/StopTimer, thanks to ilpalazzo-sama diff --git a/Makefile b/Makefile index 65b191e50..0e9baabb4 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC = gcc -pipe # CC = gcc -pipe -DPCRE_SUPPORT -# CC = g++ +# CC = g++ --pipe # CC = gcc -pipe -DGCOLLECT # CC = gcc -pipe -DDMALLOC -DDMALLOC_FUNC_CHECK # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK @@ -26,15 +26,15 @@ else MAKE = make endif -OPT = -g -O2 -ffast-math +OPT = -g -O2 -ffast-math -Wall -Wno-sign-compare # OPT += -DDUMPSTACK -rdynamic ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) OS_TYPE = -DCYGWIN -CFLAGS = $(OPT) -Wall -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = $(OPT) -DFD_SETSIZE=4096 -I../common $(PACKETDEF) $(OS_TYPE) else OS_TYPE = -CFLAGS = $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) +CFLAGS = $(OPT) -I../common $(PACKETDEF) $(OS_TYPE) # CFLAGS = -DTWILIGHT $(OPT) -Wall -I../common $(PACKETDEF) $(OS_TYPE) endif diff --git a/src/login/login.c b/src/login/login.c index 7dafc7443..bef33c79e 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1954,7 +1954,7 @@ int parse_admin(int fd) { memcpy(ma.lastlogin, "-", 2); ma.sex = RFIFOB(fd,50); WFIFOW(fd,0) = 0x7931; - WFIFOL(fd,2) = -1; // WTF? usigned being set to a -1??? + WFIFOL(fd,2) = 0xffffffff; memcpy(WFIFOP(fd,6), RFIFOP(fd,2), 24); if (strlen(ma.userid) > 23 || strlen(ma.passwd) > 23) { login_log("'ladmin': Attempt to create an invalid account (account or pass is too long, ip: %s)" RETCODE, @@ -2000,7 +2000,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 26) return 0; WFIFOW(fd,0) = 0x7933; - WFIFOL(fd,2) = -1; // WTF? an unsigned being set to -1 + WFIFOL(fd,2) = 0xFFFFFFFF; account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2036,7 +2036,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 50) return 0; WFIFOW(fd,0) = 0x7935; - WFIFOL(fd,2) = -1; /// WTF??? an unsigned being set to a -1 + WFIFOL(fd,2) = 0xFFFFFFFF; /// WTF??? an unsigned being set to a -1 account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2066,7 +2066,7 @@ int parse_admin(int fd) { char error_message[20]; int statut; WFIFOW(fd,0) = 0x7937; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2141,7 +2141,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 50) return 0; WFIFOW(fd,0) = 0x793b; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2173,7 +2173,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 27) return 0; WFIFOW(fd,0) = 0x793d; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2225,7 +2225,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 27) return 0; WFIFOW(fd,0) = 0x793f; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2315,7 +2315,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 66) return 0; WFIFOW(fd,0) = 0x7941; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2350,7 +2350,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 28 || RFIFOREST(fd) < (28 + RFIFOW(fd,26))) return 0; WFIFOW(fd,0) = 0x7943; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2385,7 +2385,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 26) return 0; WFIFOW(fd,0) = 0x7945; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2434,7 +2434,7 @@ int parse_admin(int fd) { time_t timestamp; char tmpstr[2048]; WFIFOW(fd,0) = 0x7949; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2466,7 +2466,7 @@ int parse_admin(int fd) { time_t timestamp; char tmpstr[2048]; WFIFOW(fd,0) = 0x794b; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2514,7 +2514,7 @@ int parse_admin(int fd) { struct tm *tmtime; char tmpstr[2048]; WFIFOW(fd,0) = 0x794d; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2576,7 +2576,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 8 || RFIFOREST(fd) < (8 + RFIFOL(fd,4))) return 0; WFIFOW(fd,0) = 0x794f; - WFIFOW(fd,2) = -1; // WTF??? + WFIFOW(fd,2) = 0xFFFFFFFF; // WTF??? if (RFIFOL(fd,4) < 1) { login_log("'ladmin': Receiving a message for broadcast, but message is void (ip: %s)" RETCODE, ip); @@ -2621,7 +2621,7 @@ int parse_admin(int fd) { char tmpstr[2048]; char tmpstr2[2048]; WFIFOW(fd,0) = 0x7951; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); @@ -2675,7 +2675,7 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 26) return 0; WFIFOW(fd,0) = 0x7953; - WFIFOL(fd,2) = -1; // WTF??? + WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars((unsigned char *)account_name); diff --git a/src/map/clif.c b/src/map/clif.c index 3761f52bf..d3536b1c6 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4861,7 +4861,7 @@ int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type) WBUFL(buf,2) = sd->bl.id; if(sd->status.option&0x46) // WTF? a -1 to an unsigned value... - WBUFL(buf,6) = -1; + WBUFL(buf,6) = 0xFFFFFFFF; else if(pvprank<=0) pc_calc_pvprank(sd); diff --git a/src/map/mob.c b/src/map/mob.c index c9626fa72..d3ad36b2e 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2503,9 +2503,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=(int) (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=(int) (mob_db[md->class_].job_exp*per/256); if(job_exp < 1) job_exp = 1; } else { @@ -2513,9 +2513,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/tdmg; if(per>512) per=512; if(per<1) per=1; - base_exp=mob_db[md->class_].base_exp*per/256; + base_exp=(int) (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=(int) (mob_db[md->class_].job_exp*per/256); if(job_exp < 1) job_exp = 1; } @@ -2526,8 +2526,8 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) 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; + base_exp = (int) (base_exp *1.15); // pk_mode additional exp if monster >20 levels [Valaris] + job_exp = (int) (job_exp * 1.15); } } if(md->master_id) { @@ -2538,13 +2538,13 @@ 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(md->level > 0) zeny=(int) ((md->level+rand()%md->level)*per/256); // zeny calculation moblv + random moblv [Valaris] 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; + job_exp+=(int) (((md->level-mob_db[md->class_].lv)*mob_db[md->class_].job_exp*.03)*per/256); + base_exp+=(int) (((md->level-mob_db[md->class_].lv)*mob_db[md->class_].base_exp*.03)*per/256); } } @@ -2603,7 +2603,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) 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 = (int) (drop_rate*1.25); // pk_mode increase drops if 20 level difference [Valaris] if(drop_rate <= rand()%10000+1) { //if rate == 0, then it doesn't drop (from Freya) drop_ore = i; //we rmember an empty slot to put there ORE DISCOVERY drop later. continue; diff --git a/src/map/pc.c b/src/map/pc.c index 604960772..dc5792327 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4719,28 +4719,28 @@ 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(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; + sd->status.base_exp -= (int) ((double)pc_nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000); if(battle_config.pk_mode && src && src->type==BL_PC) - sd->status.base_exp -= (double)pc_nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000; + sd->status.base_exp -= (int) ((double)pc_nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000); else if(battle_config.death_penalty_type==2 && battle_config.death_penalty_base > 0) { if(pc_nextbaseexp(sd) > 0) - sd->status.base_exp -= (double)sd->status.base_exp * (double)battle_config.death_penalty_base/10000; + sd->status.base_exp -= (int) ((double)sd->status.base_exp * (double)battle_config.death_penalty_base/10000); if(battle_config.pk_mode && src && src->type==BL_PC) - sd->status.base_exp -= (double)sd->status.base_exp * (double)battle_config.death_penalty_base/10000; + sd->status.base_exp -= (int) ((double)sd->status.base_exp * (double)battle_config.death_penalty_base/10000); } if(sd->status.base_exp < 0) sd->status.base_exp = 0; clif_updatestatus(sd,SP_BASEEXP); if(battle_config.death_penalty_type==1 && battle_config.death_penalty_job > 0) - sd->status.job_exp -= (double)pc_nextjobexp(sd) * (double)battle_config.death_penalty_job/10000; + sd->status.job_exp -= (int) ((double)pc_nextjobexp(sd) * (double)battle_config.death_penalty_job/10000); if(battle_config.pk_mode && src && src->type==BL_PC) - sd->status.job_exp -= (double)pc_nextjobexp(sd) * (double)battle_config.death_penalty_job/10000; + sd->status.job_exp -= (int) ((double)pc_nextjobexp(sd) * (double)battle_config.death_penalty_job/10000); else if(battle_config.death_penalty_type==2 && battle_config.death_penalty_job > 0) { if(pc_nextjobexp(sd) > 0) - sd->status.job_exp -= (double)sd->status.job_exp * (double)battle_config.death_penalty_job/10000; + sd->status.job_exp -= (int) ((double)sd->status.job_exp * (double)battle_config.death_penalty_job/10000); if(battle_config.pk_mode && src && src->type==BL_PC) - sd->status.job_exp -= (double)sd->status.job_exp * (double)battle_config.death_penalty_job/10000; + sd->status.job_exp -= (int) ((double)sd->status.job_exp * (double)battle_config.death_penalty_job/10000); } if(sd->status.job_exp < 0) sd->status.job_exp = 0; @@ -4757,7 +4757,7 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage) if(md && md->state.state!=MS_DEAD && md->level < 99) { clif_misceffect(&md->bl,0); md->level++; - md->hp+=sd->status.max_hp*.1; + md->hp+=(int) (sd->status.max_hp*.1); } } diff --git a/src/map/status.c b/src/map/status.c index 00dc50c74..493544677 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -719,7 +719,7 @@ int status_calc_pc(struct map_session_data* sd,int first) sd->base_atk += 4; } if((skill=pc_checkskill(sd,SA_DRAGONOLOGY))>0 ){ // Dragonology increases +1 int every 2 levels - sd->paramb[3] += (skill+1)*0.5; + sd->paramb[3] += (int) ((skill+1)*0.5); } // ステ?タス?化による基本パラメ?タ補正 @@ -924,9 +924,9 @@ int status_calc_pc(struct map_session_data* sd,int first) sd->speed += (100-16*skill)*DEFAULT_WALK_SPEED/100; //sd->speed += (1.2*DEFAULT_WALK_SPEED - skill*9); if (pc_iscarton(sd) && (skill=pc_checkskill(sd,MC_PUSHCART))>0) // カ?トによる速度低下 - sd->speed += (10-skill) * (DEFAULT_WALK_SPEED * 0.1); + sd->speed += (short) ((10-skill) * (DEFAULT_WALK_SPEED * 0.1)); else if (pc_isriding(sd)) { // ペコペコ?りによる速度?加 - sd->speed -= (0.25 * DEFAULT_WALK_SPEED); + sd->speed -= (short) ((0.25 * DEFAULT_WALK_SPEED)); sd->max_weight += 10000; } if((skill=pc_checkskill(sd,CR_TRUST))>0) { // フェイス @@ -938,7 +938,7 @@ int status_calc_pc(struct map_session_data* sd,int first) sd->subele[3] += skill*5; } if((skill=pc_checkskill(sd,SA_ADVANCEDBOOK))>0 ) - aspd_rate -= skill*0.5; + aspd_rate -= (int) (skill*0.5); bl=sd->status.base_level; @@ -1251,7 +1251,7 @@ int status_calc_pc(struct map_session_data* sd,int first) sd->addeff[4] += sd->sc_data[SC_ENCPOISON].val2; if( sd->sc_data[SC_DANCING].timer!=-1 ){ // 演奏/ダンス使用中 - sd->speed = (double)sd->speed * (6.- 0.4 * pc_checkskill(sd, ((s_class.job == 19) ? BA_MUSICALLESSON : DC_DANCINGLESSON))); + sd->speed = (short) ((double)sd->speed * (6.- 0.4 * pc_checkskill(sd, ((s_class.job == 19) ? BA_MUSICALLESSON : DC_DANCINGLESSON)))); //sd->speed*=4; sd->nhealsp = 0; sd->nshealsp = 0; @@ -1528,7 +1528,7 @@ int status_calc_speed (struct map_session_data *sd) //sd->speed = (sd->speed * (155 - sd->sc_data[SC_DEFENDER].val1*5)) / 100; } if( sd->sc_data[SC_DANCING].timer!=-1 ){ - sd->speed = (double)sd->speed * (6.- 0.4 * pc_checkskill(sd, ((s_class.job == 19) ? BA_MUSICALLESSON : DC_DANCINGLESSON))); + sd->speed = (int) ((double)sd->speed * (6.- 0.4 * pc_checkskill(sd, ((s_class.job == 19) ? BA_MUSICALLESSON : DC_DANCINGLESSON)))); } if(sd->sc_data[SC_CURSE].timer!=-1) sd->speed += 450; @@ -1541,13 +1541,13 @@ int status_calc_speed (struct map_session_data *sd) if(sd->status.option&2 && (skill = pc_checkskill(sd,RG_TUNNELDRIVE))>0 ) sd->speed += (100-16*skill)*DEFAULT_WALK_SPEED/100; if (pc_iscarton(sd) && (skill=pc_checkskill(sd,MC_PUSHCART))>0) - sd->speed += (10-skill) * (DEFAULT_WALK_SPEED * 0.1); + sd->speed += (short) ((10-skill) * (DEFAULT_WALK_SPEED * 0.1)); else if (pc_isriding(sd)) { - sd->speed -= (0.25 * DEFAULT_WALK_SPEED); + sd->speed -= (short) ((0.25 * DEFAULT_WALK_SPEED)); } if((skill=pc_checkskill(sd,TF_MISS))>0) if(s_class.job==12) - sd->speed -= sd->speed *(skill*1.5)/100; + sd->speed -= (short) (sd->speed *(skill*1.5)/100); if(sd->speed_rate != 100) sd->speed = sd->speed*sd->speed_rate/100; -- cgit v1.2.3-70-g09d2 From c9d4ab83fc3ab94c4cafc8c90bbbca161edbac45 Mon Sep 17 00:00:00 2001 From: veider Date: Sat, 2 Apr 2005 22:56:22 +0000 Subject: Added NetBSD support into Makefile git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1384 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 1 + Makefile | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'Makefile') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index dad2a500b..81437c295 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,6 +2,7 @@ Date Added 04/03 + * Added NetBSD support into Makefile (Still lots of warrnings during compilation [veider] * Finished Valkyrie. Now it correctly works. Valhallana reborns players to High Novices. [Lupus] (added missed kRO condition: to reborn, player shouldn't have money nor items(equipment) ) Then Valhallana warps just reborn players to the home city of their main job. diff --git a/Makefile b/Makefile index 0e9baabb4..efd5ec40a 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,11 @@ MAKE = gmake else MAKE = make endif +ifeq ($(findstring NetBSD,$(PLATFORM)), NetBSD) +MAKE = gmake +else +MAKE = make +endif OPT = -g -O2 -ffast-math -Wall -Wno-sign-compare # OPT += -DDUMPSTACK -rdynamic -- cgit v1.2.3-70-g09d2 From f06a0799e01d7d7f0fd6b13925f48bea81a2bcea Mon Sep 17 00:00:00 2001 From: veider Date: Sun, 3 Apr 2005 00:35:56 +0000 Subject: Fixed my bug in Makefile (broke FreeBSD build) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1385 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Makefile | 2 -- 1 file changed, 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index efd5ec40a..86ccb0189 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,6 @@ MAKE = make endif ifeq ($(findstring NetBSD,$(PLATFORM)), NetBSD) MAKE = gmake -else -MAKE = make endif OPT = -g -O2 -ffast-math -Wall -Wno-sign-compare -- cgit v1.2.3-70-g09d2