From 61ec51abb422c4813347d5f2297e877f3a5ac22b Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Mon, 13 Dec 2004 10:51:29 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@552 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/grfio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/common/grfio.c') diff --git a/src/common/grfio.c b/src/common/grfio.c index ff01b6e76..2ba701632 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -30,6 +30,7 @@ #include "utils.h" #include "grfio.h" #include "mmo.h" +#include "showmsg.h" #ifdef MEMWATCH #include "memwatch.h" @@ -923,7 +924,8 @@ void grfio_init(char *fname) } fclose(data_conf); - printf("read %s done\n",fname); + sprintf(tmp_output,"Done reading GRF File: '\033[1;29m%s\033[0;0m'.\n",fname); + ShowStatus(tmp_output); } // end of reading grf-files.txt hashinit(); // hash table initialization -- cgit v1.2.3-70-g09d2 From 4aee20b0e1fdfb23d9336cea77a0985e463ea081 Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Tue, 14 Dec 2004 00:33:01 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@566 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 5 +++++ src/common/grfio.c | 8 +++++--- src/common/showmsg.c | 16 ++++++++-------- src/common/showmsg.h | 12 ++++++++++++ src/map/chrif.c | 14 +++++++++----- src/map/clif.c | 8 +++++--- src/map/guild.c | 4 +++- src/map/itemdb.c | 9 ++++++--- src/map/map.c | 44 ++++++++++++++++++++++++++++++++++++-------- src/map/mob.c | 3 ++- src/map/npc.c | 9 ++++++++- src/map/pc.c | 17 ++++++++++------- src/map/skill.c | 6 ++++-- 13 files changed, 113 insertions(+), 42 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index a7c1f33c1..af2df756c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,9 @@ Date Added 12/14 + * Replaced the way map loading was displayed into a progress-like way [MC Cameri] + * Fixed some typos in _ShowMessage() [MC Cameri] + * Replaced lots of more printf's in map-server with _ShowMessage() [MC Cameri] + * Added constants for console colors in showmsg.h [MC Cameri] * src/char_sql/int_guild.c:56 - t_mes2 was not big enough causing stack overrun's, corruptions, and crashes [MouseJstr] * common/mmo.h: changed base_level and job_level to unsigned int to increase max levels [Codemaster] @@ -28,6 +32,7 @@ Date Added rollback - fix by Freya [celest] * Removed 'type' paramater from pc_unequipitem to use 'flag' instead[celest] * Moved unequip checking code from clif.c to pc.c [celest] +>>>>>>> .r565 * Replaced many printf's in map-server with _ShowMessage(). [MC Cameri] * Skill timers for skills with id's higher then 450 were corrupting memory [MouseJstr] diff --git a/src/common/grfio.c b/src/common/grfio.c index 2ba701632..d3d39c106 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -614,7 +614,8 @@ static int grfio_entryread(char *gfname,int gentry) fp = fopen(gfname,"rb"); if(fp==NULL) { - printf("%s not found (grfio_entryread)\n",gfname); + sprintf(tmp_output,"GRF Data File not found: '\033[1;29m%s\033[0;0m'.\n",gfname); + ShowWarning(tmp_output); return 1; // 1:not found error } @@ -837,7 +838,8 @@ int grfio_add(char *fname) exit(1); } - printf("%s file reading...\n",fname); +// sprintf(tmp_output,"Reading GRF File: '%s'.\n",fname); +// ShowStatus(tmp_output); if (gentry_entrys>=gentry_maxentry) { char **new_gentry = (char**)realloc( @@ -924,7 +926,7 @@ void grfio_init(char *fname) } fclose(data_conf); - sprintf(tmp_output,"Done reading GRF File: '\033[1;29m%s\033[0;0m'.\n",fname); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n",fname); ShowStatus(tmp_output); } // end of reading grf-files.txt diff --git a/src/common/showmsg.c b/src/common/showmsg.c index e96f97e22..32b9dd22c 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -14,12 +14,12 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri char prefix[40]; char *output; if (strlen(string) <= 0) { - ShowError("Empty string passed to ShowMessage().\n"); + ShowError("Empty string passed to _ShowMessage().\n"); return 1; } switch (flag) { case MSG_STATUS: //Bright Green (To inform about good things) - strcpy(prefix,"\033[1;32m[Status]\033[0;0m:"); + strcpy(prefix,CL_GREEN"[Status]"CL_RESET":"); break; /* //Do we really need this now? [MC Cameri] case MSG_SQL: //Bright Violet (For dumping out anything related with SQL) @@ -27,19 +27,19 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri break; */ case MSG_INFORMATION: //Bright White (Variable information) - strcpy(prefix,"\033[1;29m[Info]\033[0;0m:"); + strcpy(prefix,CL_WHITE"[Info]"CL_RESET":"); break; case MSG_NOTICE: //Bright White (Less than a warning) - strcpy(prefix,"\033[1;29m[Notice]\033[0;0m:"); + strcpy(prefix,CL_WHITE"[Notice]"CL_RESET":"); break; case MSG_WARNING: //Bright Yellow - strcpy(prefix,"\033[1;33m[Warning]\033[0;0m:"); + strcpy(prefix,CL_YELLOW"[Warning]"CL_RESET":"); break; case MSG_ERROR: //Bright Red (Regular errors) - strcpy(prefix,"\033[1;31m[Error]\033[0;0m:"); + strcpy(prefix,CL_RED"[Error]"CL_RESET":"); break; case MSG_FATALERROR: //Bright Red (Fatal errors, abort(); if possible) - strcpy(prefix,"\033[1;31m[Fatal Error]\033[0;0m:"); + strcpy(prefix,CL_RED"[Fatal Error]"CL_RESET":"); break; default: ShowError("In function _ShowMessage() -> Invalid flag passed.\n"); @@ -48,7 +48,7 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri output = (char*)malloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // +2: space and a \0 if (output == NULL) { return 1; -// abort(); // Kill server? Deadly +// exit(1); // Kill server? Deadly } strcpy(output,prefix); strcat(output," "); diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 03ffe310b..59bd6a090 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -1,6 +1,18 @@ #ifndef _SHOWMSG_H_ #define _SHOWMSG_H_ +#define CL_RESET "\033[0;0m" +#define CL_NORMAL CL_RESET +#define CL_NONE CL_RESET +#define CL_WHITE "\033[1;29m" +#define CL_GRAY "\033[1;30m" +#define CL_RED "\033[1;31m" +#define CL_GREEN "\033[1;32m" +#define CL_YELLOW "\033[1;33m" +#define CL_BLUE "\033[1;34m" +#define CL_MAGENTA "\033[1;35m" +#define CL_CYAN "\033[1;36m" + extern char tmp_output[1024]; enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_ERROR,MSG_FATALERROR}; diff --git a/src/map/chrif.c b/src/map/chrif.c index 3d3f7d233..81c6744c2 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -23,6 +23,7 @@ #include "npc.h" #include "pc.h" #include "nullpo.h" +#include "showmsg.h" #ifdef MEMWATCH #include "memwatch.h" @@ -244,13 +245,16 @@ int chrif_connectack(int fd) printf("Connected to char-server failed %d.\n", RFIFOB(fd,2)); exit(1); } - printf("Connected to char-server (connection #%d).\n", fd); + sprintf(tmp_output,"Successfully connected to Char-Server (Connection #%d).\n",fd); + ShowStatus(tmp_output); chrif_state = 1; chrif_sendmap(fd); - printf("chrif: OnCharIfInit event done. (%d events)\n", npc_event_doall("OnCharIfInit")); - printf("chrif: OnInterIfInit event done. (%d events)\n", npc_event_doall("OnInterIfInit")); + sprintf(tmp_output,"Event '"CL_WHITE"OnCharIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnCharIfInit")); + ShowStatus(tmp_output); + sprintf(tmp_output,"Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit")); + ShowStatus(tmp_output); // Run Event [AgitInit] // printf("NPC_Event:[OnAgitInit] do (%d) events (Agit Initialize).\n", npc_event_doall("OnAgitInit")); @@ -856,8 +860,8 @@ int chrif_chardisconnect(struct map_session_data *sd) */ int chrif_recvgmaccounts(int fd) { - printf("From login-server: receiving of %d GM accounts information.\n", pc_read_gm_account(fd)); - + sprintf(tmp_output,"From login-server: receiving information of '"CL_WHITE"%d"CL_RESET"' GM accounts.\n", pc_read_gm_account(fd)); + ShowInfo(tmp_output); return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index 7e4605807..1f7130676 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -24,6 +24,7 @@ #include "../common/malloc.h" #include "../common/version.h" #include "../common/nullpo.h" +#include "../common/showmsg.h" #include "map.h" #include "chrif.h" @@ -10107,15 +10108,16 @@ static int clif_parse(int fd) { if (chrif_isconnect()) clif_quitsave(fd, sd); if (sd->status.name != NULL) - printf("Player [%s] has logged off your server.\n", sd->status.name); // Player logout display [Valaris] + sprintf(tmp_output,"%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris] else - printf("Player with account [%d] has logged off your server.\n", sd->bl.id); // Player logout display [Yor] + sprintf(tmp_output,"%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id); // Player logout display [Yor] } else if (sd) { // not authentified! (refused by char-server or disconnect before to be authentified) - printf("Player with account [%d] has logged off your server (not auth account).\n", sd->bl.id); // Player logout display [Yor] + sprintf(tmp_output,"Player not authenticated with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", sd->bl.id); // Player logout display [Yor] if (chrif_isconnect()) clif_quitsave(fd, sd); sd = 0; } + ShowInfo(tmp_output); close(fd); if (sd) // 追加 map_deliddb(&sd->bl); // 追加 diff --git a/src/map/guild.c b/src/map/guild.c index 2937940c3..ec2a636b9 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -18,6 +18,7 @@ #include "intif.h" #include "clif.h" #include "skill.h" +#include "showmsg.h" #ifdef MEMWATCH #include "memwatch.h" @@ -127,7 +128,8 @@ static int guild_read_castledb(void) ln++; } fclose(fp); - printf("read db/castle_db.txt done (count=%d)\n",ln); + sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/castle_db.txt"); + ShowStatus(tmp_output); return 0; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index cd915b92e..38795547e 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -552,7 +552,8 @@ static int itemdb_read_itemnametable(void) p++; } free(buf); - printf("read data\\idnum2itemdisplaynametable.txt done.\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","data\\idnum2itemdisplaynametable.txt"); + ShowStatus(tmp_output); return 0; } @@ -587,7 +588,8 @@ static int itemdb_read_cardillustnametable(void) p++; } free(buf); - printf("read data\\num2cardillustnametable.txt done.\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","data\\num2cardillustnametable.txt"); + ShowStatus(tmp_output); return 0; } @@ -631,7 +633,8 @@ static int itemdb_read_noequip(void) } fclose(fp); - printf("read db/item_noequip.txt done (count=%d)\n",ln); + sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/item_noequip.txt"); + ShowStatus(tmp_output); return 0; } #ifndef TXT_ONLY diff --git a/src/map/map.c b/src/map/map.c index 282d2795b..c00845158 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -104,6 +104,8 @@ static int online_timer(int,unsigned int,int,int); int CHECK_INTERVAL = 3600000; // [Valaris] int check_online_timer=0; // [Valaris] +static int pos = 0; + #endif /* not TXT_ONLY */ #define USE_AFM @@ -1588,16 +1590,26 @@ static int map_readmap(int m,char *fn, char *alias) { int x,y,xs,ys; struct gat_1cell {float high[4]; int type;} *p=NULL; int wh; + int i; + int e = 0; + size_t size; - + char progress[21] = " "; // read & convert fn gat=grfio_read(fn); if(gat==NULL) return -1; - - printf("\rLoading Maps [%d/%d]: %-50s ",m,map_num,fn); - fflush(stdout); - + //printf("\rLoading Maps [%d/%d]: %-50s ",m,map_num,fn); + if (map_num) { //avoid map-server crashing if there are 0 maps + printf("\r"); + ShowStatus("Progress: "); + i=m*20/420; + printf("["); + for (e=0;ename); // fflush(stdout); } - printf("\rNPCs Loaded: %d [Warps:%d Shops:%d Scripts:%d Mobs:%d]\n", + printf("\r"); + sprintf(tmp_output,"Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:\n\t-'" + CL_WHITE"%d"CL_RESET"' Warps\n\t-'" + CL_WHITE"%d"CL_RESET"' Shops\n\t-'" + CL_WHITE"%d"CL_RESET"' Scripts\n\t-'" + CL_WHITE"%d"CL_RESET"' Mobs\n", npc_id-START_NPC_NUM,npc_warp,npc_shop,npc_script,npc_mob); + ShowInfo(tmp_output); add_timer_func_list(npc_walktimer,"npc_walktimer"); // [Valaris] add_timer_func_list(npc_event_timer,"npc_event_timer"); diff --git a/src/map/pc.c b/src/map/pc.c index 3cb78e65a..7c5a8c077 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -826,13 +826,15 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars pc_calcstatus(sd,1); if (pc_isGM(sd)) - printf("Connection accepted: character '%s' (account: %d; GM level %d).\n", sd->status.name, sd->status.account_id, pc_isGM(sd)); + sprintf(tmp_output,"GM Character '"CL_WHITE"%s"CL_RESET"' logged in. (Acc. ID: '"CL_WHITE"%d"CL_RESET"', GM Level '"CL_WHITE"%d"CL_RESET"').\n", sd->status.name, sd->status.account_id, pc_isGM(sd)); else - printf("Connection accepted: Character '%s' (account: %d).\n", sd->status.name, sd->status.account_id); - + sprintf(tmp_output,"Character '"CL_WHITE"%s"CL_RESET"' logged in. (Account ID: '"CL_WHITE"%d"CL_RESET"').\n", sd->status.name, sd->status.account_id); + ShowInfo(tmp_output); //printf("pc: OnPCLogin event done. (%d events)\n", npc_event_doall("OnPCLogin") ); - if (npc_name2id("PCLoginEvent")) + if (npc_name2id("PCLoginEvent")) { run_script(npc_name2id("PCLoginEvent")->u.scr.script,0,sd->bl.id,npc_name2id("PCLoginEvent")->bl.id); // PCLoginNPC + ShowStatus("Event '\033[1;29mPCLoginEvent\033[0;0m' executed.\n"); + } // Send friends list clif_friends_list_send(sd); @@ -857,8 +859,8 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars fclose(fp); } else if(battle_config.error_log) { - sprintf(buf, "%s not found\n", motd_txt); - ShowWarning (buf); + sprintf(tmp_output, "In function pc_atuhok() -> File '"CL_WHITE"%s"CL_RESET"' not found.\n", motd_txt); + ShowWarning(tmp_output); } } @@ -7808,7 +7810,8 @@ int pc_readdb(void) break; } fclose(fp); - printf("read db/job_db2-2.txt done\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/job_db2-2.txt"); + ShowStatus(tmp_output); // スキルツリ? memset(skill_tree,0,sizeof(skill_tree)); diff --git a/src/map/skill.c b/src/map/skill.c index 3cdc4a8f4..3a0d02c8d 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -11531,7 +11531,8 @@ int skill_readdb(void) skill_db[i].blewcount[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]); } fclose(fp); - printf("read db/skill_db.txt done\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_db.txt"); + ShowStatus(tmp_output); fp=fopen("db/skill_require_db.txt","r"); if(fp==NULL){ @@ -11670,7 +11671,8 @@ int skill_readdb(void) skill_db[i].amount[9]=atoi(split[29]); } fclose(fp); - printf("read db/skill_require_db.txt done\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_cast_db.txt"); + ShowStatus(tmp_output); /* キャスティングデ?タベ?ス */ fp=fopen("db/skill_cast_db.txt","r"); -- cgit v1.2.3-70-g09d2 From 230c174da61cef240ab784bf7ca03c5fb8f99d89 Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Sun, 19 Dec 2004 17:00:07 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@643 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 1 + src/common/grfio.c | 4 ++-- src/common/showmsg.c | 4 ++-- src/map/guild.c | 2 +- src/map/itemdb.c | 14 +++++++------- src/map/map.c | 22 ++++++++++++---------- src/map/mob.c | 10 +++++----- src/map/npc.c | 4 ++-- src/map/pc.c | 20 ++++++++++---------- src/map/pet.c | 2 +- src/map/skill.c | 16 ++++++++-------- 11 files changed, 51 insertions(+), 48 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index 6836b4a5b..3c2718950 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,7 @@ Date Added 12/19 + * Replaced many \033[x;xm with their corresponding CL_xx constants [MC Cameri] * Separated NPCs and Maps from map_athena.conf into npcs_list.txt and maps_list.conf [MC Cameri] * Modified all the *_athena.conf's to have the import command enabled by default [Ajarn] * Added charcommand_conf.txt and log_conf.txt in conf-tmpl/import [Ajarn] diff --git a/src/common/grfio.c b/src/common/grfio.c index d3d39c106..507b66cb3 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -614,7 +614,7 @@ static int grfio_entryread(char *gfname,int gentry) fp = fopen(gfname,"rb"); if(fp==NULL) { - sprintf(tmp_output,"GRF Data File not found: '\033[1;29m%s\033[0;0m'.\n",gfname); + sprintf(tmp_output,"GRF Data File not found: '"CL_WHITE"%s"CL_RESET"'.\n",gfname); ShowWarning(tmp_output); return 1; // 1:not found error } @@ -926,7 +926,7 @@ void grfio_init(char *fname) } fclose(data_conf); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n",fname); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n",fname); ShowStatus(tmp_output); } // end of reading grf-files.txt diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 32b9dd22c..903fb583b 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -23,7 +23,7 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri break; /* //Do we really need this now? [MC Cameri] case MSG_SQL: //Bright Violet (For dumping out anything related with SQL) - strcpy(prefix,"\033[1;35m[SQL]\033[0;0m:"); + strcpy(prefix,CL_MAGENTA"[SQL]"CL_RESET":"); break; */ case MSG_INFORMATION: //Bright White (Variable information) @@ -60,7 +60,7 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri FILE *fp; fp=fopen(OUTPUT_MESSAGES_LOG,"a"); if (fp == NULL) { - printf("\033[1;31m[Error]\033[0;0m: Could not open \033[1;29m%s\033[0;0m, file not found.\n",OUTPUT_MESSAGES_LOG); + printf(CL_RED"[Error]"CL_RESET": Could not open '"CL_WHITE"%s"CL_RESET"', file not found.\n",OUTPUT_MESSAGES_LOG); fflush(stdout); return; } diff --git a/src/map/guild.c b/src/map/guild.c index ec2a636b9..83da2a809 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -128,7 +128,7 @@ static int guild_read_castledb(void) ln++; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/castle_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"db/castle_db.txt"); ShowStatus(tmp_output); return 0; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 38795547e..a68afd61f 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -384,7 +384,7 @@ static int itemdb_readdb(void) id->equip_script = parse_script(p,lines); } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,filename[i]); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,filename[i]); ShowStatus(tmp_output); } return 0; @@ -460,7 +460,7 @@ static int itemdb_read_randomitem() ln++; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",*pc,fn); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",*pc,fn); ShowStatus(tmp_output); } @@ -510,7 +510,7 @@ static int itemdb_read_itemavail(void) ln++; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/item_avail.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"db/item_avail.txt"); ShowStatus(tmp_output); return 0; } @@ -552,7 +552,7 @@ static int itemdb_read_itemnametable(void) p++; } free(buf); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","data\\idnum2itemdisplaynametable.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\idnum2itemdisplaynametable.txt"); ShowStatus(tmp_output); return 0; @@ -588,7 +588,7 @@ static int itemdb_read_cardillustnametable(void) p++; } free(buf); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","data\\num2cardillustnametable.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\num2cardillustnametable.txt"); ShowStatus(tmp_output); return 0; @@ -633,7 +633,7 @@ static int itemdb_read_noequip(void) } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/item_noequip.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"db/item_noequip.txt"); ShowStatus(tmp_output); return 0; } @@ -781,7 +781,7 @@ static int itemdb_read_sqldb(void) { printf("Database server error (retrieving rows from %s): %s\n", item_db_db, mysql_error(&mmysql_handle)); } - sprintf(tmp_output,"Done reading '\033[1;29m%lu\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",(unsigned long) mysql_num_rows(sql_res),item_db_db); + sprintf(tmp_output,"Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",(unsigned long) mysql_num_rows(sql_res),item_db_db); ShowStatus(tmp_output); } else diff --git a/src/map/map.c b/src/map/map.c index a59f45818..777818ec4 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1209,7 +1209,7 @@ void map_removenpc(void) { } } - sprintf(tmp_output,"Successfully removed and freed from memory '\033[1;29m%d\033[0;0m' NPCs.\n",n); + sprintf(tmp_output,"Successfully removed and freed from memory '"CL_WHITE"%d"CL_RESET"' NPCs.\n",n); ShowStatus(tmp_output); } @@ -2014,14 +2014,14 @@ int log_sql_init(void){ mysql_init(&mmysql_handle); //DB connection start - printf("\033[1;29m[SQL]\033[0;0m: Connecting to Log Database \033[1;29m%s\033[0;0m At \033[1;29m%s\033[0;0m...\n",log_db,log_db_ip); + printf(""CL_WHITE"[SQL]"CL_RESET": Connecting to Log Database "CL_WHITE"%s"CL_RESET" At "CL_WHITE"%s"CL_RESET"...\n",log_db,log_db_ip); if(!mysql_real_connect(&mmysql_handle, log_db_ip, log_db_id, log_db_pw, log_db ,log_db_port, (char *)NULL, 0)) { //pointer check - printf("\033[1;29m[SQL Error]\033[0;0m: %s\n",mysql_error(&mmysql_handle)); + printf(""CL_WHITE"[SQL Error]"CL_RESET": %s\n",mysql_error(&mmysql_handle)); exit(1); } else { - printf("\033[1;29m[SQL]\033[0;0m: Successfully \033[1;32mconnected\033[0;0m to Database \033[1;29m%s\033[0;0m.\n", log_db); + printf(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", log_db); } return 0; @@ -2261,6 +2261,8 @@ void do_final(void) { void map_helpscreen(int flag) { puts("Usage: map-server [options]"); puts("Options:"); + puts(CL_WHITE" Commands\t\t\tDescription"CL_RESET); + puts("---------------------------------------------"); puts(" --help, --h, --?, /? Displays this help screen"); puts(" --map-config Load map-server configuration from "); puts(" --battle-config Load battle configuration from "); @@ -2279,13 +2281,13 @@ void map_helpscreen(int flag) { } void map_versionscreen(int flag) { - printf("\033[1;29m" "eAthena version %d.%02d.%02d, Athena Mod version %d" "\033[0;0m\n", + printf("CL_WHITE" "eAthena version %d.%02d.%02d, Athena Mod version %d" CL_RESET"\n", ATHENA_MAJOR_VERSION, ATHENA_MINOR_VERSION, ATHENA_REVISION, ATHENA_MOD_VERSION); - puts("\033[1;32m" "Website/Forum:" "\033[0;0m" "\thttp://eathena.deltaanime.net/"); - puts("\033[1;32m" "Download URL:" "\033[0;0m" "\thttp://eathena.systeminplace.net/"); - puts("\033[1;32m" "IRC Channel:" "\033[0;0m" "\tirc://irc.deltaanime.net/#athena"); - puts("\nOpen \033[1;29mreadme.html\033[0;0m for more information."); + puts(CL_GREEN "Website/Forum:" "CL_RESET" "\thttp://eathena.deltaanime.net/"); + puts(CL_GREEN "Download URL:" "CL_RESET" "\thttp://eathena.systeminplace.net/"); + puts(CL_GREEN "IRC Channel:" "CL_RESET" "\tirc://irc.deltaanime.net/#athena"); + puts("\nOpen "CL_WHITE"readme.html"CL_RESET" for more information."); if (ATHENA_RELEASE_FLAG) ShowNotice("This version is not for release.\n"); if (flag) exit(1); } @@ -2457,7 +2459,7 @@ int do_init(int argc, char *argv[]) { if (imalive_on) add_timer_interval(gettick()+10, imalive_timer,0,0,imalive_time*1000); - sprintf(tmp_output,"Server is '\033[1;32mready\033[0m' and listening on port '\033[1;29m%d\033[0;0m'.\n\n", map_port); + sprintf(tmp_output,"Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map_port); ShowStatus(tmp_output); ticks = gettick(); diff --git a/src/map/mob.c b/src/map/mob.c index a2ddc9e99..27b2741c6 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3907,7 +3907,7 @@ static int mob_readdb(void) mob_db[class].clothes_color=0; //Add for player monster dye - Valaris } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n",filename[i]); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n",filename[i]); ShowStatus(tmp_output); } return 0; @@ -3973,7 +3973,7 @@ static int mob_readdb_mobavail(void) ln++; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/mob_avail.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"db/mob_avail.txt"); ShowStatus(tmp_output); return 0; } @@ -4021,7 +4021,7 @@ static int mob_read_randommonster(void) mob_db[class].summonper[i]=per; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n",mobfile[i]); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n",mobfile[i]); ShowStatus(tmp_output); } return 0; @@ -4174,7 +4174,7 @@ static int mob_readskilldb(void) mob_db[mob_id].maxskill=i+1; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n",filename[x]); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n",filename[x]); ShowStatus(tmp_output); } return 0; @@ -4331,7 +4331,7 @@ static int mob_read_sqldb(void) mob_db[class].head_buttom=0; } mysql_free_result(sql_res); - sprintf(tmp_output,"Done reading '\033[1;29m%lu\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,mob_db_db); + sprintf(tmp_output,"Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,mob_db_db); ShowStatus(tmp_output); } return 0; diff --git a/src/map/npc.c b/src/map/npc.c index 70bb4aa12..d9f515cfd 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -435,8 +435,8 @@ int npc_event_do_clock(int tid,unsigned int tick,int id,int data) int npc_event_do_oninit(void) { // int c = npc_event_doall("OnInit"); - sprintf(tmp_output,"Event '\033[1;29mOnInit\033[0;0m' executed with '\033[1" - ";29m%d\033[0;0m' NPCs.\n",npc_event_doall("OnInit")); + sprintf(tmp_output,"Event '"CL_WHITE"OnInit"CL_RESET"' executed with '" + CL_WHITE"%d"CL_RESET"' NPCs.\n",npc_event_doall("OnInit")); ShowStatus(tmp_output); add_timer_interval(gettick()+100, diff --git a/src/map/pc.c b/src/map/pc.c index 40d0cad79..4e90aebd2 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -834,7 +834,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars //printf("pc: OnPCLogin event done. (%d events)\n", npc_event_doall("OnPCLogin") ); if (npc_name2id("PCLoginEvent")) { run_script(npc_name2id("PCLoginEvent")->u.scr.script,0,sd->bl.id,npc_name2id("PCLoginEvent")->bl.id); // PCLoginNPC - ShowStatus("Event '\033[1;29mPCLoginEvent\033[0;0m' executed.\n"); + ShowStatus("Event '"CL_WHITE"PCLoginEvent"CL_RESET"' executed.\n"); } // Send friends list clif_friends_list_send(sd); @@ -7755,7 +7755,7 @@ int pc_readdb(void) break; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/exp.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/exp.txt"); ShowStatus(tmp_output); // JOB補正?値1 @@ -7790,7 +7790,7 @@ int pc_readdb(void) break; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/job_db1.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/job_db1.txt"); ShowStatus(tmp_output); // JOBボ?ナス @@ -7819,7 +7819,7 @@ int pc_readdb(void) break; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/job_db2.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/job_db2.txt"); ShowStatus(tmp_output); // JOBボ?ナス2 ?生職用 @@ -7844,7 +7844,7 @@ int pc_readdb(void) break; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/job_db2-2.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/job_db2-2.txt"); ShowStatus(tmp_output); // スキルツリ? @@ -7886,7 +7886,7 @@ int pc_readdb(void) } } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_tree.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_tree.txt"); ShowStatus(tmp_output); // ?性修正テ?ブル @@ -7933,7 +7933,7 @@ int pc_readdb(void) } } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/attr_fix.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/attr_fix.txt"); ShowStatus(tmp_output); // サイズ補正テ?ブル @@ -7963,7 +7963,7 @@ int pc_readdb(void) i++; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/size_fix.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/size_fix.txt"); ShowStatus(tmp_output); // 精?デ?タテ?ブル @@ -8000,7 +8000,7 @@ int pc_readdb(void) i++; } fclose(fp); //Lupus. close this file!!! - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/refine_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/refine_db.txt"); ShowStatus(tmp_output); return 0; @@ -8042,7 +8042,7 @@ static void pc_statpointdb(void) buf_stat = (char *) malloc (end + 1); l = fread(buf_stat,1,end,stp); fclose(stp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/statpoint.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/statpoint.txt"); ShowStatus(tmp_output); // printf("read db/statpoint.txt done (size=%d)\n",l); diff --git a/src/map/pet.c b/src/map/pet.c index 878c0aea5..c07fbc179 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1623,7 +1623,7 @@ int read_petdb() j++; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' pets in '\033[1;29m%s\033[0;0m'.\n",j,filename[i]); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' pets in '"CL_WHITE"%s"CL_RESET"'.\n",j,filename[i]); ShowStatus(tmp_output); } return 0; diff --git a/src/map/skill.c b/src/map/skill.c index 221118628..1f0e689f4 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -11588,7 +11588,7 @@ int skill_readdb(void) skill_db[i].blewcount[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]); } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_db.txt"); ShowStatus(tmp_output); fp=fopen("db/skill_require_db.txt","r"); @@ -11728,7 +11728,7 @@ int skill_readdb(void) skill_db[i].amount[9]=atoi(split[29]); } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_require_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_require_db.txt"); ShowStatus(tmp_output); /* キャスティングデ?タベ?ス */ @@ -11793,7 +11793,7 @@ int skill_readdb(void) skill_db[i].upkeep_time2[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]); } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_cast_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_cast_db.txt"); ShowStatus(tmp_output); /* 製造系スキルデ?タベ?ス */ @@ -11837,7 +11837,7 @@ int skill_readdb(void) break; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",k,filename[m]); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",k,filename[m]); ShowStatus(tmp_output); } @@ -11876,7 +11876,7 @@ int skill_readdb(void) break; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",k,"db/create_arrow_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",k,"db/create_arrow_db.txt"); ShowStatus(tmp_output); memset(skill_abra_db,0,sizeof(skill_abra_db)); @@ -11910,7 +11910,7 @@ int skill_readdb(void) break; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",k,"db/abra_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",k,"db/abra_db.txt"); ShowStatus(tmp_output); fp=fopen("db/skill_castnodex_db.txt","r"); @@ -11945,7 +11945,7 @@ int skill_readdb(void) skill_db[i].castnodex[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]); } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_castnodex_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_castnodex_db.txt"); ShowStatus(tmp_output); fp=fopen("db/skill_nocast_db.txt","r"); @@ -11975,7 +11975,7 @@ int skill_readdb(void) k++; } fclose(fp); - sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_nocast_db"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_nocast_db"); ShowStatus(tmp_output); return 0; -- cgit v1.2.3-70-g09d2 From 958273319fea7cdc8b82ec988ae6c235c7657ca2 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 20 Dec 2004 18:13:04 +0000 Subject: * Added auto reading leveluseskillspamount.txt and indoorrswtable.txt * Added check in grfio.c to prevent crashing git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@667 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 4 ++++ src/common/grfio.c | 17 ++++++++++------- src/map/atcommand.c | 2 +- src/map/npc.c | 38 ++++++++++++++++++++++++++++++++++++++ src/map/skill.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 8 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index ae0556076..ccc02a939 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,10 @@ Date Added 12/20 + * Added reading leveluseskillspamount.txt from the GRF to auto set sp used for each skill [celest] + * Added reading indoorrswtable.txt from the GRF to auto set 'indoor' mapflags + [celest] + * Added check in grfio.c to prevent crashing if a file wasn't found [celest] * Rolling GUILDCACHE and FASTCHAR into main branches/stable tree [MouseJstr] * Changed max_paramter to an unsigned int so that you can have over 255 as your max stat [Codemaster] diff --git a/src/common/grfio.c b/src/common/grfio.c index 507b66cb3..b005398cc 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -444,13 +444,13 @@ int grfio_size(char *fname) entry = filelist_find(fname); if (entry==NULL || entry->gentry<0) { // LocalFileCheck - char lfname[256],rname[256],*p; + char lfname[256],*rname,*p; FILELIST lentry; struct stat st; - if(strcmp(data_dir, "") != 0) { + if(strcmp(data_dir, "") != 0 && (rname=grfio_resnametable(fname,lfname))!=NULL) { //printf("%s\t",fname); - sprintf(rname,"%s",grfio_resnametable(fname,lfname)); + //sprintf(rname,"%s",grfio_resnametable(fname,lfname)); //printf("%s\n",rname); sprintf(lfname,"%s%s",data_dir,rname); //printf("%s\n",lfname); @@ -486,13 +486,16 @@ void* grfio_reads(char *fname, int *size) entry = filelist_find(fname); if (entry==NULL || entry->gentry<=0) { // LocalFileCheck - char lfname[256],rname[256],*p; + char lfname[256],*rname,*p; FILELIST lentry; strncpy(lfname,fname,255); - sprintf(rname,"%s",grfio_resnametable(fname,lfname)); - sprintf(lfname,"%s%s",data_dir,rname); - //printf("%s\n",lfname); + // i hope this is the correct way =p [celest] + if ((rname=grfio_resnametable(fname,lfname))!=NULL) { + //sprintf(rname,"%s",grfio_resnametable(fname,lfname)); + sprintf(lfname,"%s%s",data_dir,rname); + //printf("%s\n",lfname); + } for(p=&lfname[0];*p!=0;p++) if (*p=='\\') *p = '/'; // * At the time of Unix diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 742061caa..a1b90a5c3 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8710,4 +8710,4 @@ int atcommand_refreshonline( return 0; } -#endif /* end sql only */ \ No newline at end of file +#endif /* end sql only */ diff --git a/src/map/npc.c b/src/map/npc.c index d9f515cfd..7b616282f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -21,6 +21,7 @@ #include "pet.h" #include "battle.h" #include "skill.h" +#include "grfio.h" #include "showmsg.h" #ifdef MEMWATCH @@ -2135,6 +2136,39 @@ static int npc_parse_mapflag(char *w1,char *w2,char *w3,char *w4) return 0; } +static int npc_read_indoors(void) +{ + char *buf,*p; + int s, m; + + buf=grfio_reads("data\\indoorrswtable.txt",&s); + + if(buf==NULL) + return -1; + + buf[s]=0; + for(p=buf;p-buf= 0) + map[m].flag.indoors=1; + } + + p=strchr(p,10); + if(!p) break; + p++; + } + free(buf); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\indoorrswtable.txt"); + ShowStatus(tmp_output); + + return 0; +} + static int ev_db_final(void *key,void *data,va_list ap) { free(data); @@ -2227,6 +2261,10 @@ int do_init_npc(void) int busy = 0; char c = '-'; + // indoorrswtable.txt and etcinfo.txt [Celest] + npc_read_indoors(); + //npc_read_weather(); + ev_db=strdb_init(24); npcname_db=strdb_init(24); diff --git a/src/map/skill.c b/src/map/skill.c index ddfb04965..f74409caf 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -25,6 +25,7 @@ #include "chrif.h" #include "guild.h" #include "showmsg.h" +#include "grfio.h" #ifdef MEMWATCH #include "memwatch.h" @@ -11982,6 +11983,52 @@ int skill_readdb(void) return 0; } +/*=============================================== + * For reading leveluseskillspamount.txt [Celest] + *----------------------------------------------- + */ +static int skill_read_skillspamount(void) +{ + char *buf,*p; + struct skill_db *skill = NULL; + int s, idx, new_flag=1, level=1, sp=0; + + buf=grfio_reads("data\\leveluseskillspamount.txt",&s); + + if(buf==NULL) + return -1; + + buf[s]=0; + for(p=buf;p-bufsp[level-1]=sp; + level++; + } + + p=strchr(p,10); + if(!p) break; + p++; + } + free(buf); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\leveluseskillspamount.txt"); + ShowStatus(tmp_output); + + return 0; +} + void skill_reload(void) { /* @@ -12001,6 +12048,7 @@ void skill_reload(void) int do_init_skill(void) { skill_readdb(); + skill_read_skillspamount(); add_timer_func_list(skill_unit_timer,"skill_unit_timer"); add_timer_func_list(skill_castend_id,"skill_castend_id"); -- cgit v1.2.3-70-g09d2 From 8b050adff043c24bca4df7726c5b2bce0edf36ae Mon Sep 17 00:00:00 2001 From: ajarn Date: Thu, 23 Dec 2004 04:57:29 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@743 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 1 + src/common/grfio.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index e7aca8df0..e4164a59c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Date Added 12/22 + * Fixed a bug in grfio_read causing memory corruptions [MouseJstr] * Rearranged how guild messages, gm messages, and party messages are moved back and forth between the inter server and the map server.. eliminating unneeded round trips to eliminate diff --git a/src/common/grfio.c b/src/common/grfio.c index b005398cc..d27636d33 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -492,8 +492,10 @@ void* grfio_reads(char *fname, int *size) strncpy(lfname,fname,255); // i hope this is the correct way =p [celest] if ((rname=grfio_resnametable(fname,lfname))!=NULL) { + char tbuf[255]; //sprintf(rname,"%s",grfio_resnametable(fname,lfname)); - sprintf(lfname,"%s%s",data_dir,rname); + sprintf(tbuf,"%s%s",data_dir,rname); + strcpy(lfname, tbuf); //printf("%s\n",lfname); } -- cgit v1.2.3-70-g09d2 From 593b12ed67cf27b69563afd2d12752c7ebfee683 Mon Sep 17 00:00:00 2001 From: celest Date: Thu, 23 Dec 2004 13:08:54 +0000 Subject: * Added some of Shinomori's fixes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@751 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 4 +++- src/common/grfio.c | 20 +++++++++++++++----- src/common/mmo.h | 4 ---- src/common/socket.c | 5 +++++ src/login/login.h | 6 +++--- src/map/intif.c | 18 +++++++++++++++--- src/map/npc.c | 25 ++++++++++++++++++++----- src/map/pc.c | 12 +++++------- src/map/pc.h | 7 ++++--- 9 files changed, 70 insertions(+), 31 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index babbcc122..6bc8be064 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,9 +1,11 @@ Date Added 12/23 * Updated mapflags (added missing payon_in03,ayo_in01,ayo_in02, que_god01, que_god02) [Lupus] - * Updated Sacrifice [celest] + * Updated Sacrifice : it's now self-activating, and lasts for 5 attacks [celest] * Fixed compile errors in party.c [celest] * Moved SC_EDP back to 114 [celest] + * Added some of Shinomori's fixes [celest] + * Added optimisation in intif_parse_WisMessage from Freya [celest] 12/22 * Eliminated skill tree mapping since we have entries diff --git a/src/common/grfio.c b/src/common/grfio.c index d27636d33..c8c021b8d 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -140,7 +140,11 @@ static unsigned char NibbleData[4][64]={ */ static unsigned int getlong(unsigned char *p) { - return *p+p[1]*256+(p[2]+p[3]*256)*65536; +// return *p+p[1]*256+(p[2]+p[3]*256)*65536; + return p[0] + | p[1] << 0x08 + | p[2] << 0x10 + | p[3] << 0x18; // Shinomori } /*========================================== @@ -158,15 +162,17 @@ static void BitConvert(BYTE *Src,char *BitSwapTable) { int lop,prm; BYTE tmp[8]; - *(DWORD*)tmp=*(DWORD*)(tmp+4)=0; +// *(DWORD*)tmp=*(DWORD*)(tmp+4)=0; + memset(tmp,0,8); for(lop=0;lop!=64;lop++) { prm = BitSwapTable[lop]-1; if (Src[(prm >> 3) & 7] & BitMaskTable[prm & 7]) { tmp[(lop >> 3) & 7] |= BitMaskTable[lop & 7]; } } - *(DWORD*)Src = *(DWORD*)tmp; - *(DWORD*)(Src+4) = *(DWORD*)(tmp+4); +// *(DWORD*)Src = *(DWORD*)tmp; +// *(DWORD*)(Src+4) = *(DWORD*)(tmp+4); + memcpy(Src,tmp,8); } static void BitConvert4(BYTE *Src) @@ -194,7 +200,11 @@ static void BitConvert4(BYTE *Src) tmp[(lop >> 3) + 4] |= BitMaskTable[lop & 7]; } } - *(DWORD*)Src ^= *(DWORD*)(tmp+4); +// *(DWORD*)Src ^= *(DWORD*)(tmp+4); + Src[0] ^= tmp[4]; + Src[1] ^= tmp[5]; + Src[2] ^= tmp[6]; + Src[3] ^= tmp[7]; } static void decode_des_etc(BYTE *buf,int len,int type,int cycle) diff --git a/src/common/mmo.h b/src/common/mmo.h index 5ee6bf602..44069b85f 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -325,10 +325,6 @@ enum { #ifndef strnicmp #define strnicmp strncasecmp #endif -#ifndef strrchr -#define strrchr rindex -#endif - #endif #endif // _MMO_H_ diff --git a/src/common/socket.c b/src/common/socket.c index dfeebf03a..0f5b53550 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -17,6 +17,11 @@ #include #include #include + +#ifndef SIOCGIFCONF +#include // SIOCGIFCONF on Solaris, maybe others? [Shinomori] +#endif + #endif #include diff --git a/src/login/login.h b/src/login/login.h index 9ae4734fe..7370f5238 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -13,7 +13,7 @@ #define START_ACCOUNT_NUM 2000000 #define END_ACCOUNT_NUM 100000000 -int login_port; +extern int login_port; struct mmo_account { char* userid; char passwd[33]; @@ -36,6 +36,6 @@ struct mmo_char_server { int new; }; -struct mmo_char_server server[MAX_SERVERS]; -int server_fd[MAX_SERVERS]; +extern struct mmo_char_server server[MAX_SERVERS]; +extern int server_fd[MAX_SERVERS]; #endif diff --git a/src/map/intif.c b/src/map/intif.c index fd79acc0c..28f1b65a2 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -627,6 +627,7 @@ int intif_guild_castle_datasave(int castle_id,int index, int value) // Wisp/Page reception int intif_parse_WisMessage(int fd) { // rewritten by [Yor] struct map_session_data* sd; + char *wisp_source; int id=RFIFOL(fd,4); int i=0; //,j=0; @@ -651,9 +652,20 @@ int intif_parse_WisMessage(int fd) { // rewritten by [Yor] else{ */ - if(i == MAX_IGNORE_LIST) { - clif_wis_message(sd->fd,RFIFOP(fd,8),RFIFOP(fd,56),RFIFOW(fd,2)-56); - intif_wis_replay(RFIFOL(fd,4),0); // 送信成功 + else { + wisp_source = RFIFOP(fd,8); // speed up [Yor] + for(i=0;iignore[i].name, wisp_source)==0){ + break; + } + } + if(i==MAX_IGNORE_LIST) // run out of list, so we are not ignored + { + clif_wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56); + intif_wis_replay(id,0); // 送信成功 + } + else + intif_wis_replay(id, 2); // 受信拒否 } }else intif_wis_replay(id,1); // そんな人いません diff --git a/src/map/npc.c b/src/map/npc.c index 7b616282f..728e76a9c 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -32,13 +32,17 @@ struct npc_src_list { struct npc_src_list * next; - struct npc_src_list * prev; +// struct npc_src_list * prev; //[Shinomori] char name[4]; } ; -static struct npc_src_list *npc_src_first,*npc_src_last; +static struct npc_src_list *npc_src_first=NULL; +static struct npc_src_list *npc_src_last=NULL; static int npc_id=START_NPC_NUM; -static int npc_warp,npc_shop,npc_script,npc_mob; +static int npc_warp=0; +static int npc_shop=0; +static int npc_script=0; +static int npc_mob=0; int npc_get_new_npc_id(void){ return npc_id++; } @@ -1366,6 +1370,17 @@ void npc_addsrcfile(char *name) return; } + { + // prevent multiple insert of source files + struct npc_src_list *p=npc_src_first; + while( p ) + { // found the file, no need to insert it again + if( 0==strcmp(name,p->name) ) + return; + p=p->next; + } + } + len = sizeof(*new) + strlen(name); new=(struct npc_src_list *)aCalloc(1,len); new->next = NULL; @@ -2273,10 +2288,10 @@ int do_init_npc(void) memset(&ev_tm_b,-1,sizeof(ev_tm_b)); for(nsl=npc_src_first;nsl;nsl=nsl->next) { - if(nsl->prev){ + /*if(nsl->prev){ // [Shinomori] free(nsl->prev); nsl->prev = NULL; - } + }*/ fp=fopen(nsl->name,"r"); if (fp==NULL) { printf("file not found : %s\n",nsl->name); diff --git a/src/map/pc.c b/src/map/pc.c index 3cd14fcef..09ff43733 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -55,13 +55,11 @@ static char job_bonus[3][MAX_PC_CLASS][MAX_LEVEL]; static int exp_table[14][MAX_LEVEL]; static char statp[255][7]; -/*static struct { - int id; - int max; - struct { - short id,lv; - } need[6]; -} skill_tree[3][MAX_PC_CLASS][100];*/ // moved to pc.h - celest +// h-files are for declarations, not for implementations... [Shinomori] +struct skill_tree_entry skill_tree[3][MAX_PC_CLASS][100]; +// timer for night.day implementation +int day_timer_tid; +int night_timer_tid; static int atkmods[3][20]; // 武器ATKサイズ修正(size_fix.txt) static int refinebonus[5][3]; // 精?ボ?ナステ?ブル(refine_db.txt) diff --git a/src/map/pc.h b/src/map/pc.h index 1f294ce92..a32926886 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -181,7 +181,8 @@ struct skill_tree_entry { struct { short id,lv; } need[6]; -} skill_tree[3][MAX_PC_CLASS][100]; // Celest +}; // Celest +extern struct skill_tree_entry skill_tree[3][MAX_PC_CLASS][100]; int pc_read_gm_account(int fd); int pc_setinvincibletimer(struct map_session_data *sd,int); @@ -194,8 +195,8 @@ int do_init_pc(void); enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT}; // timer for night.day -int day_timer_tid; -int night_timer_tid; +extern int day_timer_tid; +extern int night_timer_tid; int map_day_timer(int,unsigned int,int,int); // by [yor] int map_night_timer(int,unsigned int,int,int); // by [yor] -- cgit v1.2.3-70-g09d2 From a028a5fa44a6eb6b0ed87781eb18b8555eb08837 Mon Sep 17 00:00:00 2001 From: celest Date: Sun, 26 Dec 2004 18:47:04 +0000 Subject: * Added Bitmap File system * Added --run_once flag git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@789 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 6 + conf-tmpl/map_athena.conf | 7 + src/common/grfio.c | 6 +- src/map/atcommand.c | 14 +- src/map/map.c | 403 +++++++++++++++++++++++++++++++++++++++------- src/map/map.h | 40 ++++- src/map/mob.c | 33 ++-- src/map/npc.c | 20 +-- src/map/path.c | 16 +- src/map/pc.c | 27 ++-- src/map/pet.c | 7 +- src/map/skill.c | 26 +-- 12 files changed, 462 insertions(+), 143 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index 5d1b3bcf5..835c1f1d5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,11 @@ Date Added 12/26 + * Added Bitmap File system from jA 1086 - automatically generates a cache + from maps in the GRF to speed up loading. You can enable/disable it with + read_map_from_bitmap in map_athena.conf. Note: AFM maps will override this + cache [celest] + * Added --run_once flag for the map server for testing purposes - closes itself + when everything is done loading [celest] * Added some code for Moonlit Petals and Basilica [celest] 12/24 diff --git a/conf-tmpl/map_athena.conf b/conf-tmpl/map_athena.conf index 9fa5335a0..7f099cb0f 100644 --- a/conf-tmpl/map_athena.conf +++ b/conf-tmpl/map_athena.conf @@ -44,6 +44,13 @@ char_port: 6121 // Map Server Port map_port: 5121 +//Preferred map loading method +//0: Read directly from grf, 1: Read from bitmap file +read_map_from_bitmap: 1 +// +//Where is the bitmap file stored? +map_bitmap_path: db/map.info + // Console Commands // Allow for console commands to be used on/off // This prevents usage of >& log.file diff --git a/src/common/grfio.c b/src/common/grfio.c index c8c021b8d..f9d99bd70 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -586,7 +586,7 @@ errret: if (buf!=NULL) free(buf); if (buf2!=NULL) free(buf2); if (in!=NULL) fclose(in); - exit(1); //return NULL; + return NULL; } /*========================================== @@ -964,9 +964,9 @@ void grfio_init(char *fname) if (strcmp(data_dir, "") == 0) // Id data_dir doesn't exist result4 = 1; // Data directory - +/* if (result != 0 && result2 != 0 && result3 != 0 && result4 != 0) { printf("not grf file readed exit!!\n"); exit(1); // It ends, if a resource cannot read one. - } + }*/ } diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4e40ea2ce..95744e653 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -953,9 +953,7 @@ int atcommand_send( WBUFW(buf,0)=0x18f; case 4: WBUFW(buf,0)=0x190; - } - - + } } return 0; } @@ -3604,11 +3602,11 @@ int atcommand_gat( for (y = 2; y >= -2; y--) { sprintf(output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, - map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y), - map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y), - map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y), - map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y), - map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y)); + map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y,CELL_CHKTYPE), + map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y,CELL_CHKTYPE), + map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y,CELL_CHKTYPE), + map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y,CELL_CHKTYPE), + map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y,CELL_CHKTYPE)); clif_displaymessage(fd, output); } diff --git a/src/map/map.c b/src/map/map.c index 55718a37d..46705dc8d 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -150,6 +150,25 @@ struct charid2nick { int req_id; }; +//各マップごとの最小限情報を入れるもの、READ_FROM_BITMAP用 +/*typedef struct{ + char fn[32];//ファイル名 + int xs,ys; //幅と高さ + int sizeinint;//intでの大きさ、1intに32セルの情報が入てる + int celltype[MAX_CELL_TYPE];//マップごとにそのタイプのセルがあれば対応する数字が入る、なければ1 + //(タイプ1そのものは0と同じ配列gat_fileused[0]に + long pos[MAX_CELL_TYPE];//ビットマップファイルでの場所、読み出す時に使う +} CELL_INFO;*/ + +//#define READ_FROM_GAT 0 //gatファイルから +//#define READ_FROM_BITMAP 1 //ビットマップファイルから +int map_read_flag = READ_FROM_GAT;//上の判定フラグ,どっちを使うかはmap_athana.conf内のread_map_from_bitmapで指定 + //0ならばREAD_FROM_GAT,1ならばREAD_FROM_BITMAP +int map_getcell(int,int x,int y,CELL_CHK cellchk); +int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk); + +char map_bitmap_filename[256]="db/map.info";//ビットマップファイルのデフォルトパス + char motd_txt[256] = "conf/motd.txt"; char help_txt[256] = "conf/help.txt"; @@ -769,7 +788,7 @@ int map_clearflooritem_timer(int tid,unsigned int tick,int id,int data) { *------------------------------------------ */ int map_searchrandfreecell(int m,int x,int y,int range) { - int free_cell,i,j,c; + int free_cell,i,j; for(free_cell=0,i=-range;i<=range;i++){ if(i+y<0 || i+y>=map[m].ys) @@ -777,7 +796,7 @@ int map_searchrandfreecell(int m,int x,int y,int range) { for(j=-range;j<=range;j++){ if(j+x<0 || j+x>=map[m].xs) continue; - if((c=read_gat(m,j+x,i+y))==1 || c==5) + if(map_getcell(m,j+x,i+y,CELL_CHKNOPASS)) continue; free_cell++; } @@ -791,7 +810,7 @@ int map_searchrandfreecell(int m,int x,int y,int range) { for(j=-range;j<=range;j++){ if(j+x<0 || j+x>=map[m].xs) continue; - if((c=read_gat(m,j+x,i+y))==1 || c==5) + if(map_getcell(m,j+x,i+y,CELL_CHKNOPASS)) continue; if(free_cell==0){ x+=j; @@ -1340,23 +1359,77 @@ int map_calc_dir( struct block_list *src,int x,int y) { // gat系 /*========================================== - * (m,x,y)の?態を調べる + * (m,x,y)の状態を調べる *------------------------------------------ */ -int map_getcell(int m,int x,int y) { - if(x<0 || x>=map[m].xs-1 || y<0 || y>=map[m].ys-1) - return 1; - return map[m].gat[x+y*map[m].xs]; + +int map_getcell(int m,int x,int y,CELL_CHK cellchk) +{ + return (m < 0 || m > MAX_MAP_PER_SERVER) ? 0 : map_getcellp(&map[m],x,y,cellchk); +} + +int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk) +{ + int j; + nullpo_ret(m); + if(x<0 || x>=m->xs-1 || y<0 || y>=m->ys-1) + { + if(cellchk==CELL_CHKNOPASS) return 1; + return 0; + } + j=x+y*m->xs; + + switch(cellchk) + { + case CELL_CHKTOUCH: + if(m->gat[j]&0x80) return 1;return 0; + case CELL_CHKWATER: + if(m->gat[j]==3) return 1;return 0; + case CELL_CHKHIGH: + if(m->gat[j]==5) return 1;return 0; + case CELL_CHKPASS: + if(m->gat[j]!=1&&m->gat[j]!=5) return 1; return 0; + case CELL_CHKNOPASS: + if(m->gat[j]==1||m->gat[j]==5) return 1; return 0; + case CELL_CHKTYPE: + return m->gat[j]; + default: return 0; + } + return 0; } /*========================================== - * (m,x,y)の?態をtにする + * (m,x,y)の状態を設定する *------------------------------------------ */ -int map_setcell(int m,int x,int y,int t) { +int map_setcell(int m,int x,int y,CELL_SET cellset) +{ + int i,j; + if(x<0 || x>=map[m].xs || y<0 || y>=map[m].ys) - return t; - return map[m].gat[x+y*map[m].xs]=t; + return 0; + j=x+y*map[m].xs; + switch(cellset) + { + case CELL_SETTOUCH: + return map[m].gat[j]|=0x80; + break; + case CELL_SETWATER://3 + i=3;break; + case CELL_SETPASS://0 + i=0;break; + case CELL_SETNOPASS://gat_fileused[0](READ_FROM_BITMAP)か1(READ_FROM_GAT) + i=1;break; + case CELL_SETHIGH://5 + i=5;break; + case CELL_SETNOHIGH://5 + i=5;break; + default: + return 0; + } + map[m].gat[j]=i; + + return 1; } /*========================================== @@ -1440,6 +1513,178 @@ static void map_readwater(char *watertxt) { } fclose(fp); } +/*========================================== +* マップキャッシュに追加する +*===========================================*/ + +// マップキャッシュの最大値 +#define MAX_CAHCE_MAX 768 + +//各マップごとの最小限情報を入れるもの、READ_FROM_BITMAP用 +struct MAP_CACHE_INFO { + char fn[32];//ファイル名 + int xs,ys; //幅と高さ + int water_height; + int pos; // データが入れてある場所 + int compressed; // zilb通せるようにする為の予約 + int compressed_len; // zilb通せるようにする為の予約 +}; // 56 byte + +struct { + struct MAP_CACHE_HEAD { + int sizeof_header; + int sizeof_map; + // 上の2つ改変不可 + int nmaps; // マップの個数 + int filesize; + } head; + struct MAP_CACHE_INFO *map; + FILE *fp; + int dirty; +} map_cache; + +static int map_cache_open(char *fn); +static void map_cache_close(void); +static int map_cache_read(struct map_data *m); +static int map_cache_write(struct map_data *m); + +static int map_cache_open(char *fn) { + atexit(map_cache_close); + if(map_cache.fp) { + map_cache_close(); + } + map_cache.fp = fopen(fn,"r+b"); + if(map_cache.fp) { + fread(&map_cache.head,1,sizeof(struct MAP_CACHE_HEAD),map_cache.fp); + fseek(map_cache.fp,0,SEEK_END); + if( + map_cache.head.sizeof_header == sizeof(struct MAP_CACHE_HEAD) && + map_cache.head.sizeof_map == sizeof(struct MAP_CACHE_INFO) && + map_cache.head.filesize == ftell(map_cache.fp) + ) { + // キャッシュ読み込み成功 + map_cache.map = aMalloc(sizeof(struct MAP_CACHE_INFO) * map_cache.head.nmaps); + fseek(map_cache.fp,sizeof(struct MAP_CACHE_HEAD),SEEK_SET); + fread(map_cache.map,sizeof(struct MAP_CACHE_INFO),map_cache.head.nmaps,map_cache.fp); + return 1; + } + fclose(map_cache.fp); + } else { + map_read_flag = CREATE_BITMAP; + } + // 読み込みに失敗したので新規に作成する + map_cache.fp = fopen(fn,"wb"); + if(map_cache.fp) { + memset(&map_cache.head,0,sizeof(struct MAP_CACHE_HEAD)); + map_cache.map = aCalloc(sizeof(struct MAP_CACHE_INFO),MAX_CAHCE_MAX); + map_cache.head.nmaps = MAX_CAHCE_MAX; + map_cache.head.sizeof_header = sizeof(struct MAP_CACHE_HEAD); + map_cache.head.sizeof_map = sizeof(struct MAP_CACHE_INFO); + + map_cache.head.filesize = sizeof(struct MAP_CACHE_HEAD); + map_cache.head.filesize += sizeof(struct MAP_CACHE_INFO) * map_cache.head.nmaps; + + map_cache.dirty = 1; + return 1; + } + return 0; +} + +static void map_cache_close(void) { + if(!map_cache.fp) { return; } + if(map_cache.dirty) { + fseek(map_cache.fp,0,SEEK_SET); + fwrite(&map_cache.head,1,sizeof(struct MAP_CACHE_HEAD),map_cache.fp); + fwrite(map_cache.map,map_cache.head.nmaps,sizeof(struct MAP_CACHE_INFO),map_cache.fp); + } + fclose(map_cache.fp); + free(map_cache.map); + map_cache.fp = NULL; + return; +} + +int map_cache_read(struct map_data *m) { + int i; + if(!map_cache.fp) { return 0; } + for(i = 0;i < map_cache.head.nmaps ; i++) { + if(!strcmp(m->name,map_cache.map[i].fn)) { + if(map_cache.map[i].water_height != map_waterheight(m->name)) { + // 水場の高さが違うので読み直し + return 0; + } else if(map_cache.map[i].compressed) { + // 圧縮ファイルは未対応 + return 0; + } else { + int size = map_cache.map[i].xs * map_cache.map[i].ys; + m->xs = map_cache.map[i].xs; + m->ys = map_cache.map[i].ys; + m->gat = (unsigned char *)aCalloc(m->xs * m->ys,sizeof(unsigned char)); + fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET); + if(fread(m->gat,1,size,map_cache.fp) == size) { + // 成功 + return 1; + } else { + // なぜかファイル後半が欠けてるので読み直し + m->xs = 0; + m->ys = 0; + free(m->gat); + m->gat = NULL; + return 0; + } + } + } + } + return 0; +} + +static int map_cache_write(struct map_data *m) { + int i; + if(!map_cache.fp) { return 0; } + for(i = 0;i < map_cache.head.nmaps ; i++) { + if(!strcmp(m->name,map_cache.map[i].fn)) { + // 同じエントリーがあれば上書き + if( + map_cache.map[i].xs == m->xs && map_cache.map[i].ys == m->ys && + !map_cache.map[i].compressed + ) { + // 幅と高さ同じで圧縮してないなら場所は変わらない + fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET); + fwrite(m->gat,m->xs,m->ys,map_cache.fp); + } else { + // 幅と高さが違うなら新しい場所に登録 + int size = m->xs * m->ys; + fseek(map_cache.fp,map_cache.head.filesize,SEEK_SET); + fwrite(m->gat,1,size,map_cache.fp); + map_cache.map[i].pos = map_cache.head.filesize; + map_cache.map[i].xs = m->xs; + map_cache.map[i].ys = m->ys; + map_cache.head.filesize += size; + } + map_cache.map[i].water_height = map_waterheight(m->name); + map_cache.dirty = 1; + return 0; + } + } + // 同じエントリが無ければ書き込める場所を探す + for(i = 0;i < map_cache.head.nmaps ; i++) { + if(map_cache.map[i].fn[0] == 0) { + // 新しい場所に登録 + int size = m->xs * m->ys; + strncpy(map_cache.map[i].fn,m->name,sizeof(map_cache.map[0].fn)); + fseek(map_cache.fp,map_cache.head.filesize,SEEK_SET); + fwrite(m->gat,1,size,map_cache.fp); + map_cache.map[i].pos = map_cache.head.filesize; + map_cache.map[i].xs = m->xs; + map_cache.map[i].ys = m->ys; + map_cache.map[i].water_height = map_waterheight(m->name); + map_cache.head.filesize += size; + map_cache.dirty = 1; + return 0; + } + } + // 書き込めなかった + return 1; +} #ifdef USE_AFM static int map_readafm(int m,char *fn) { @@ -1587,28 +1832,20 @@ static int map_readafm(int m,char *fn) { #endif /*========================================== - * マップ1枚?み?み - *------------------------------------------ - */ -static int map_readmap(int m,char *fn, char *alias) { + * マップ1枚読み込み + * ===================================================*/ +static int map_readmap(int m,char *fn, char *alias, int *map_cache) { unsigned char *gat=""; - int s; - int x,y,xs,ys; - struct gat_1cell {float high[4]; int type;} *p=NULL; - int wh; + size_t size; + int i; int e = 0; - - size_t size; char progress[21] = " "; - // read & convert fn - gat=grfio_read(fn); - if(gat==NULL) - return -1; + //printf("\rLoading Maps [%d/%d]: %-50s ",m,map_num,fn); if (map_num) { //avoid map-server crashing if there are 0 maps - printf("\r"); - ShowStatus("Progress: "); + printf("\r"); + ShowStatus("Progress: "); i=m*20/420; printf("["); for (e=0;etype==0){ + // 水場判定 + map[m].gat[x+y*xs]=(p->high[0]>wh || p->high[1]>wh || p->high[2]>wh || p->high[3]>wh) ? 3 : 0; + } else { + map[m].gat[x+y*xs]=p->type; + } + p++; + } + } + map_cache_write(&map[m]); + free(gat); + } + map[m].m=m; - xs=map[m].xs=*(int*)(gat+6); - ys=map[m].ys=*(int*)(gat+10); - map[m].gat = (unsigned char *)aCalloc(s = map[m].xs * map[m].ys,sizeof(unsigned char)); map[m].npc_num=0; map[m].users=0; memset(&map[m].flag,0,sizeof(map[m].flag)); if(battle_config.pk_mode) map[m].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] - wh=map_waterheight(map[m].name); - for(y=0;ytype==0){ - // 水場判定 - map[m].gat[x+y*xs]=(p->high[0]>wh || p->high[1]>wh || p->high[2]>wh || p->high[3]>wh) ? 3 : 0; - } else { - map[m].gat[x+y*xs]=p->type; - } - p++; - } - } - free(gat); - - map[m].bxs=(xs+BLOCK_SIZE-1)/BLOCK_SIZE; - map[m].bys=(ys+BLOCK_SIZE-1)/BLOCK_SIZE; + map[m].bxs=(map[m].xs+BLOCK_SIZE-1)/BLOCK_SIZE; + map[m].bys=(map[m].ys+BLOCK_SIZE-1)/BLOCK_SIZE; size = map[m].bxs * map[m].bys * sizeof(struct block_list*); map[m].block = (struct block_list **)aCalloc(1,size); map[m].block_mob = (struct block_list **)aCalloc(1,size); @@ -1671,18 +1928,31 @@ int map_readallmap(void) { #ifdef USE_AFM FILE *afm_file; #endif + int map_cache = 0; + + // マップキャッシュを開く + if(map_read_flag == READ_FROM_BITMAP) { + map_cache_open(map_bitmap_filename); + } - ShowStatus("Loading Maps...\n"); + sprintf(tmp_output, "Loading Maps%s...\n", + (map_read_flag == CREATE_BITMAP ? " (Generating Map Cache)" : + map_read_flag == READ_FROM_BITMAP ? " (w/ Map Cache)" : + map_read_flag == READ_FROM_AFM ? " (w/ AFM)" : "")); + ShowStatus(tmp_output); // 先に全部のャbプの存在を確認 for(i=0;igat[(x)+(y)*m->xs]) +#define read_gat(m,x,y) (map_getcell(m,x,y,CELL_CHKTYPE)) //ビットマップ使う場合結構CPUに負担かかるので、消極的に使おう +#define read_gatp(m,x,y) (map_getcellp(m,x,y,CELL_CHKTYPE)) //同上 struct flooritem_data { struct block_list bl; @@ -617,6 +622,25 @@ enum { LOOK_BASE,LOOK_HAIR,LOOK_WEAPON,LOOK_HEAD_BOTTOM,LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HAIR_COLOR,LOOK_CLOTHES_COLOR,LOOK_SHIELD,LOOK_SHOES }; +/*-------CELL_CHK*---------------- + * CELL_CHKPASS: セルは0,3,6のどっちかの場合は1を返す、以外は0 + * CELL_CHKNOPASS: セルは1、5のどっちかの場合は1を返す、以外は0 + * CELL_CHKWATER: セルは3の場合は1を返す、以外は0 + * CELL_CHKHIGH: セルは5の場合は1を返す、以外は0 + * CHELL_CHKTOUCH:セルはタッチ系の場合は1を返す、以外は0 + * CELL_CHKTYPE: セルのタイプを知りたい場合は1を返す、以外は0 +*/ +typedef enum { + CELL_CHKPASS,CELL_CHKNOPASS,CELL_CHKWATER=3,CELL_CHKHIGH=5,CELL_CHKTOUCH,CELL_CHKTYPE +} CELL_CHK; + +/*-------CELL_SET*--------------- + * ほとんどは上と対応、設定用 + */ +typedef enum { + CELL_SETPASS,CELL_SETNOPASS,CELL_SETWATER=3,CELL_SETHIGH=5,CELL_SETNOHIGH,CELL_SETTOUCH +} CELL_SET; + struct chat_data { struct block_list bl; @@ -638,6 +662,13 @@ extern int autosave_interval; extern int agit_flag; extern int night_flag; // 0=day, 1=night [Yor] +//------bitmap使用とgrfファイル使用両方対応できるために追加、また、 +//セルの取得や設定は列挙型CELL_CHK*とCELL_SET*を使った方が意図がわかりやすいので変更してみた +int map_getcell(int,int,int,CELL_CHK); +int map_getcellp(struct map_data*,int,int,CELL_CHK); +extern int map_read_flag; //セル情報のソース判定フラグ、0ならgrfファイル、1ならビットマップファイル +enum { READ_FROM_GAT, READ_FROM_AFM, READ_FROM_BITMAP, CREATE_BITMAP }; + extern char motd_txt[]; extern char help_txt[]; @@ -698,8 +729,7 @@ struct map_session_data * map_nick2sd(char*); int compare_item(struct item *a, struct item *b); // gat関連 -int map_getcell(int,int,int); -int map_setcell(int,int,int,int); +int map_setcell(int,int,int,CELL_SET); // その他 int map_check_dir(int s_dir,int t_dir); diff --git a/src/map/mob.c b/src/map/mob.c index 40bf4d1b0..7fa39b7ca 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -216,7 +216,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname, int x0,int y0,int x1,int y1, const char *mobname,int class,int amount,const char *event) { - int x,y,i,c,max,lx=-1,ly=-1,id=0; + int x,y,i,max,lx=-1,ly=-1,id=0; int m; if(strcmp(mapname,"this")==0) @@ -235,7 +235,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname, do{ x=rand()%(x1-x0+1)+x0; y=rand()%(y1-y0+1)+y0; - }while( ( (c=map_getcell(m,x,y))==1 || c==5)&& (++j)=max){ if(lx>=0){ // 検索に失敗したので以前に沸いた場所を使う x=lx; @@ -243,6 +243,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname, }else return 0; // 最初に沸く場所の検索を失敗したのでやめる } + if(x==0||y==0) printf("xory=0, x=%d,y=%d,x0=%d,y0=%d\n",x,y,x0,y0); id=mob_once_spawn(sd,mapname,x,y,mobname,class,1,event); lx=x; ly=y; @@ -461,7 +462,7 @@ static int mob_walktoxy_sub(struct mob_data *md); static int mob_walk(struct mob_data *md,unsigned int tick,int data) { int moveblock; - int i,ctype; + int i; static int dirx[8]={0,-1,-1,-1,0,1,1,1}; static int diry[8]={1,1,0,-1,-1,-1,0,1}; int x,y,dx,dy; @@ -486,8 +487,7 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data) x = md->bl.x; y = md->bl.y; - ctype = map_getcell(md->bl.m,x,y); - if(ctype == 1 || ctype == 5) { + if(map_getcell(md->bl.m,x,y,CELL_CHKNOPASS)) { mob_stop_walking(md,1); return 0; } @@ -495,8 +495,7 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data) dx = dirx[md->dir]; dy = diry[md->dir]; - ctype = map_getcell(md->bl.m,x+dx,y+dy); - if(ctype == 1 || ctype == 5) { + if(map_getcell(md->bl.m,x+dx,y+dy,CELL_CHKNOPASS)) { mob_walktoxy_sub(md); return 0; } @@ -925,7 +924,7 @@ int mob_spawn(int id) y=md->y0+rand()%(md->ys+1)-md->ys/2; } i++; - } while(((c=map_getcell(md->bl.m,x,y))==1 || c==5) && i<50); + } while(map_getcell(md->bl.m,x,y,CELL_CHKNOPASS) && i<50); if(i>=50){ // if(battle_config.error_log==1) @@ -1517,7 +1516,7 @@ static int mob_randomwalk(struct mob_data *md,int tick) x+=md->bl.x; y+=md->bl.y; - if((c=map_getcell(md->bl.m,x,y))!=1 && c!=5 && mob_walktoxy(md,x,y,1)==0){ + if((map_getcell(md->bl.m,x,y,CELL_CHKPASS)) && mob_walktoxy(md,x,y,1)==0){ md->move_fail_count=0; break; } @@ -2782,7 +2781,7 @@ int mob_warpslave(struct mob_data *md,int x, int y) */ int mob_warp(struct mob_data *md,int m,int x,int y,int type) { - int i=0,c,xs=0,ys=0,bx=x,by=y; + int i=0,xs=0,ys=0,bx=x,by=y; nullpo_retr(0, md); @@ -2803,7 +2802,7 @@ int mob_warp(struct mob_data *md,int m,int x,int y,int type) xs=ys=9; } - while( ( x<0 || y<0 || ((c=read_gat(m,x,y))==1 || c==5) ) && (i++)<1000 ){ + while( ( x<0 || y<0 || map_getcell(m,x,y,CELL_CHKNOPASS)) && (i++)<1000 ){ if( xs>0 && ys>0 && i<250 ){ // 指定位置付近の探索 x=bx+rand()%xs-xs/2; y=by+rand()%ys-ys/2; @@ -2906,14 +2905,14 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag) class = value[k]; if(class<=1000 || class>MAX_MOB_DB) continue; for(;amount>0;amount--){ - int x=0,y=0,c=0,i=0; + int x=0,y=0,i=0; md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data)); if(mob_db[class].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); else md->lootitem=NULL; - while((x<=0 || y<=0 || (c=map_getcell(m,x,y))==1 || c==5 ) && (i++)<100){ + while((x<=0 || y<=0 || map_getcell(m,x,y,CELL_CHKNOPASS)) && (i++)<100){ x=rand()%9-4+bx; y=rand()%9-4+by; } @@ -3611,24 +3610,24 @@ int mobskill_use(struct mob_data *md,unsigned int tick,int event) continue; // 自分の周囲 if( ms[i].target>=MST_AROUND1 ){ - int bx=x, by=y, i=0, c, m=bl->m, r=ms[i].target-MST_AROUND1; + int bx=x, by=y, i=0, m=bl->m, r=ms[i].target-MST_AROUND1; do{ bx=x + rand()%(r*2+3) - r; by=y + rand()%(r*2+3) - r; }while( ( bx<=0 || by<=0 || bx>=map[m].xs || by>=map[m].ys || - ((c=read_gat(m,bx,by))==1 || c==5) ) && (i++)<1000); + map_getcell(m,bx,by,CELL_CHKNOPASS)) && (i++)<1000); if(i<1000){ x=bx; y=by; } } // 相手の周囲 if( ms[i].target>=MST_AROUND5 ){ - int bx=x, by=y, i=0, c, m=bl->m, r=(ms[i].target-MST_AROUND5)+1; + int bx=x, by=y, i=0,m=bl->m, r=(ms[i].target-MST_AROUND5)+1; do{ bx=x + rand()%(r*2+1) - r; by=y + rand()%(r*2+1) - r; }while( ( bx<=0 || by<=0 || bx>=map[m].xs || by>=map[m].ys || - ((c=read_gat(m,bx,by))==1 || c==5) ) && (i++)<1000); + map_getcell(m,bx,by,CELL_CHKNOPASS)) && (i++)<1000); if(i<1000){ x=bx; y=by; } diff --git a/src/map/npc.c b/src/map/npc.c index 728e76a9c..9068909ea 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1126,7 +1126,7 @@ static int calc_next_walk_step(struct npc_data *nd) static int npc_walk(struct npc_data *nd,unsigned int tick,int data) { int moveblock; - int i,ctype; + int i; static int dirx[8]={0,-1,-1,-1,0,1,1,1}; static int diry[8]={1,1,0,-1,-1,-1,0,1}; int x,y,dx,dy; @@ -1151,8 +1151,7 @@ static int npc_walk(struct npc_data *nd,unsigned int tick,int data) x = nd->bl.x; y = nd->bl.y; - ctype = map_getcell(nd->bl.m,x,y); - if(ctype == 1 || ctype == 5) { + if(map_getcell(nd->bl.m,x,y,CELL_CHKNOPASS)) { npc_stop_walking(nd,1); return 0; } @@ -1160,8 +1159,7 @@ static int npc_walk(struct npc_data *nd,unsigned int tick,int data) dx = dirx[nd->dir]; dy = diry[nd->dir]; - ctype = map_getcell(nd->bl.m,x+dx,y+dy); - if(ctype == 1 || ctype == 5) { + if(map_getcell(nd->bl.m,x+dx,y+dy,CELL_CHKNOPASS)) { npc_walktoxy_sub(nd); return 0; } @@ -1468,11 +1466,9 @@ int npc_parse_warp(char *w1,char *w2,char *w3,char *w4) for(i=0;i=md->xs || y1<0 || y1>=md->ys || (i=read_gatp(md,x1,y1))==1 || i==5) + if(x1<0 || x1>=md->xs || y1<0 || y1>=md->ys || map_getcellp(md,x1,y1,CELL_CHKNOPASS)) return -1; // easy diff --git a/src/map/pc.c b/src/map/pc.c index 376efb313..d314d2e30 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3822,7 +3822,7 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *bl) int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrtype) { char mapname[24]; - int m=0,c=0,disguise=0; + int m=0,disguise=0; nullpo_retr(0, sd); @@ -3935,7 +3935,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt if(x <0 || x >= map[m].xs || y <0 || y >= map[m].ys) x=y=0; - if((x==0 && y==0) || (c=read_gat(m,x,y))==1 || c==5){ + if((x==0 && y==0) || map_getcell(m,x,y,CELL_CHKNOPASS)){ if(x||y) { if(battle_config.error_log) printf("stacked (%d,%d)\n",x,y); @@ -3943,7 +3943,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt do { x=rand()%(map[m].xs-2)+1; y=rand()%(map[m].ys-2)+1; - } while((c=read_gat(m,x,y))==1 || c==5); + } while(map_getcell(m,x,y,CELL_CHKNOPASS)); } if(sd->mapname[0] && sd->bl.prev != NULL){ @@ -4011,7 +4011,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt *------------------------------------------ */ int pc_randomwarp(struct map_session_data *sd, int type) { - int x,y,c,i=0; + int x,y,i=0; int m; nullpo_retr(0, sd); @@ -4024,7 +4024,7 @@ int pc_randomwarp(struct map_session_data *sd, int type) { do{ x=rand()%(map[m].xs-2)+1; y=rand()%(map[m].ys-2)+1; - } while (((c=read_gat(m,x,y)) == 1 || c == 5) && (i++) < 1000); + }while(map_getcell(m,x,y,CELL_CHKNOPASS) && (i++)<1000 ); if (i < 1000) pc_setpos(sd,map[m].name,x,y,type); @@ -4129,7 +4129,7 @@ static int calc_next_walk_step(struct map_session_data *sd) static int pc_walk(int tid,unsigned int tick,int id,int data) { struct map_session_data *sd; - int i,ctype; + int i; int moveblock; int x,y,dx,dy; @@ -4162,16 +4162,14 @@ static int pc_walk(int tid,unsigned int tick,int id,int data) x = sd->bl.x; y = sd->bl.y; - ctype = map_getcell(sd->bl.m,x,y); - if(ctype == 1 || ctype == 5) { + if(map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS)) { pc_stop_walking(sd,1); return 0; } sd->dir=sd->head_dir=sd->walkpath.path[sd->walkpath.path_pos]; dx = dirx[(int)sd->dir]; dy = diry[(int)sd->dir]; - ctype = map_getcell(sd->bl.m,x+dx,y+dy); - if(ctype == 1 || ctype == 5) { + if(map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS)) { pc_walktoxy_sub(sd); return 0; } @@ -4252,7 +4250,7 @@ static int pc_walk(int tid,unsigned int tick,int id,int data) skill_unit_move(&sd->bl,tick,1); // スキルユニットの?査 - if(map_getcell(sd->bl.m,x,y)&0x80) + if(map_getcell(sd->bl.m,x,y,CELL_CHKTOUCH)) npc_touch_areanpc(sd,sd->bl.m,x,y); else sd->areanpc_id=0; @@ -4378,15 +4376,14 @@ int pc_randomwalk(struct map_session_data *sd,int tick) nullpo_retr(0, sd); if(DIFF_TICK(sd->next_walktime,tick)<0){ - int i,x,y,c,d; + int i,x,y,d; d = rand()%7+5; for(i=0;ibl.x+r%(d*2+1)-d; y=sd->bl.y+r/(d*2+1)%(d*2+1)-d; - if((c=map_getcell(sd->bl.m,x,y))!=1 && c!=5 && pc_walktoxy(sd,x,y)==0){ + if((map_getcell(sd->bl.m,x,y,CELL_CHKPASS)) && pc_walktoxy(sd,x,y)==0) break; - } } // Working on this part later [celest] /*for(i=c=0;iwalkpath.path_len;i++){ // The next walk start time is calculated. @@ -4450,7 +4447,7 @@ int pc_movepos(struct map_session_data *sd,int dst_x,int dst_y) skill_unit_move(&sd->bl,gettick(),dist+7); // スキルユニットの?査 - if(map_getcell(sd->bl.m,sd->bl.x,sd->bl.y)&0x80) + if(map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKTOUCH)) npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); else sd->areanpc_id=0; diff --git a/src/map/pet.c b/src/map/pet.c index c07fbc179..be077b84e 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -203,7 +203,7 @@ static int pet_attack(struct pet_data *pd,unsigned int tick,int data) static int pet_walk(struct pet_data *pd,unsigned int tick,int data) { int moveblock; - int i,ctype; + int i; int x,y,dx,dy; nullpo_retr(0, pd); @@ -235,8 +235,7 @@ static int pet_walk(struct pet_data *pd,unsigned int tick,int data) dx = dirx[pd->dir]; dy = diry[pd->dir]; - ctype = map_getcell(pd->bl.m,x+dx,y+dy); - if(ctype == 1 || ctype == 5) { + if(map_getcell(pd->bl.m,x+dx,y+dy,CELL_CHKNOPASS)){ pet_walktoxy_sub(pd); return 0; } @@ -1058,7 +1057,7 @@ static int pet_randomwalk(struct pet_data *pd,int tick) int r=rand(); x=pd->bl.x+r%(d*2+1)-d; y=pd->bl.y+r/(d*2+1)%(d*2+1)-d; - if((c=map_getcell(pd->bl.m,x,y))!=1 && c!=5 && pet_walktoxy(pd,x,y)==0){ + if((map_getcell(pd->bl.m,x,y,CELL_CHKPASS))&&( pet_walktoxy(pd,x,y)==0)){ pd->move_fail_count=0; break; } diff --git a/src/map/skill.c b/src/map/skill.c index 3ede9313d..794059e82 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2069,13 +2069,13 @@ static int skill_timerskill(int tid, unsigned int tick, int id,int data ) break; case RG_INTIMIDATE: if(sd && !map[src->m].flag.noteleport) { - int x,y,i,j,c; + int x,y,i,j; pc_randomwarp(sd,3); for(i=0;i<16;i++) { j = rand()%8; x = sd->bl.x + dirx[j]; y = sd->bl.y + diry[j]; - if((c=map_getcell(sd->bl.m,x,y)) != 1 && c != 5) + if(map_getcell(sd->bl.m,x,y,CELL_CHKPASS)) break; } if(i >= 16) { @@ -2090,13 +2090,13 @@ static int skill_timerskill(int tid, unsigned int tick, int id,int data ) } } else if(md && !map[src->m].flag.monster_noteleport) { - int x,y,i,j,c; + int x,y,i,j; mob_warp(md,-1,-1,-1,3); for(i=0;i<16;i++) { j = rand()%8; x = md->bl.x + dirx[j]; y = md->bl.y + diry[j]; - if((c=map_getcell(md->bl.m,x,y)) != 1 && c != 5) + if(map_getcell(md->bl.m,x,y,CELL_CHKPASS)) break; } if(i >= 16) { @@ -5002,7 +5002,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil { int flag=0; for(i=0;i<2+(skilllv>>1);i++) { - int j=0, c; + int j=0; do { tmpx = x + (rand()%7 - 3); tmpy = y + (rand()%7 - 3); @@ -5015,7 +5015,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil else if(tmpy >= map[src->m].ys) tmpy = map[src->m].ys - 1; j++; - } while(((c=map_getcell(src->m,tmpx,tmpy))==1 || c==5) && j<100); + } while((map_getcell(src->m,tmpx,tmpy,CELL_CHKNOPASS)) && j<100); if(j >= 100) continue; if(flag==0){ @@ -5810,11 +5810,11 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, map_foreachinarea(skill_landprotector,src->m,ux,uy,ux,uy,BL_SKILL,skillid,&alive); if(skillid==WZ_ICEWALL && alive){ - val2=map_getcell(src->m,ux,uy); + val2=map_getcell(src->m,ux,uy,CELL_CHKTYPE); if(val2==5 || val2==1) alive=0; else { - map_setcell(src->m,ux,uy,5); + map_setcell(src->m,ux,uy,CELL_SETNOPASS); clif_changemapcell(src->m,ux,uy,5,0); } } @@ -6558,6 +6558,8 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick) break; case 0x8d: /* アイスウォ?ル */ + if(map_read_flag == READ_FROM_BITMAP) + map_setcell(src->bl.m,src->bl.x,src->bl.y,CELL_SETPASS); map_setcell(src->bl.m,src->bl.x,src->bl.y,src->val2); clif_changemapcell(src->bl.m,src->bl.x,src->bl.y,src->val2,1); break; @@ -7290,7 +7292,7 @@ int skill_check_condition(struct map_session_data *sd,int type) } break; case ST_WATER: - if(map_getcell(sd->bl.m,sd->bl.x,sd->bl.y) != 3 && (sd->sc_data[SC_DELUGE].timer==-1)){ //水場判定 + if((!map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER))&& (sd->sc_data[SC_DELUGE].timer==-1)){ //水場判定 clif_skill_fail(sd,skill,0,0); return 0; } @@ -10422,8 +10424,7 @@ int skill_check_cloaking(struct block_list *bl) else if(bl->type == BL_MOB && !battle_config.monster_cloak_check_type) return 0; for(i=0;im,bl->x+dx[i],bl->y+dy[i]); - if(c==1 || c==5) { + if(map_getcell(bl->m,bl->x+dx[i],bl->y+dy[i],CELL_CHKNOPASS)) { end=0; break; } @@ -10460,8 +10461,7 @@ int skill_type_cloaking(struct block_list *bl) return 0; for(i=0; im,bl->x+dx[i],bl->y+dy[i]); - if(c==1 || c==5) + if(map_getcell(bl->m,bl->x+dx[i],bl->y+dy[i],CELL_CHKNOPASS)) return 0; } return 1; -- cgit v1.2.3-70-g09d2 From b14ce328eaf0c82dff32ba156ec440ff1a07ac0d Mon Sep 17 00:00:00 2001 From: amber Date: Mon, 27 Dec 2004 16:29:44 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@821 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 ++ src/char_sql/char.c | 11 ++++++----- src/char_sql/int_guild.c | 15 ++++++++------- src/common/grfio.c | 7 ++++--- src/common/malloc.c | 6 ++++++ src/common/malloc.h | 16 ++++++++++++++++ src/common/utils.c | 5 +++-- src/ladmin/Makefile | 2 +- src/login_sql/login.c | 7 ++++--- src/map/battle.c | 10 +++++----- src/map/intif.c | 3 ++- src/map/itemdb.c | 2 +- src/map/map.c | 20 ++++++++++---------- src/map/mob.c | 2 +- src/map/npc.c | 12 ++++++------ src/map/pc.c | 10 +++++----- src/map/script.c | 8 ++++---- src/map/skill.c | 10 +++++----- src/map/storage.c | 5 +++-- 19 files changed, 92 insertions(+), 61 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index adc35d9f0..397ad7ccc 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,7 @@ Date Added 12/27 + * switched malloc,calloc,realloc to aMalloc, aCalloc, aRealloc + so support the use of a garbage collector (SVN 821) [MouseJstr] * Removed some printf's from map-sql [MC Cameri] * Uncommented MSG_SQL, for _ShowMessage(), usage: ShowSQL() [MC Cameri] * Removed fixed bugs in dev/bugs.txt [MC Cameri] diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 63e47a973..456fa0ac7 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -38,6 +38,7 @@ #include "itemdb.h" #include "inter.h" #include "db.h" +#include "malloc.h" #ifdef MEMWATCH #include "memwatch.h" @@ -266,7 +267,7 @@ void read_gm_account(void) { } lsql_res = mysql_store_result(&lmysql_handle); if (lsql_res) { - gm_account = calloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); + gm_account = aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); while ((lsql_row = mysql_fetch_row(lsql_res))) { gm_account[GM_num].account_id = atoi(lsql_row[0]); gm_account[GM_num].level = atoi(lsql_row[1]); @@ -330,7 +331,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ cp = numdb_search(char_db_,char_id); if (cp == NULL) { - cp = (struct mmo_charstatus *) malloc(sizeof(struct mmo_charstatus)); + cp = (struct mmo_charstatus *) aMalloc(sizeof(struct mmo_charstatus)); memset(cp, 0, sizeof(struct mmo_charstatus)); numdb_insert(char_db_, char_id,cp); } @@ -1130,7 +1131,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ printf("char data load success]\n"); //ok. all data load successfuly! - cp = (struct mmo_charstatus *) malloc(sizeof(struct mmo_charstatus)); + cp = (struct mmo_charstatus *) aMalloc(sizeof(struct mmo_charstatus)); memcpy(cp, p, sizeof(struct mmo_charstatus)); numdb_insert(char_db_, char_id,cp); @@ -2804,8 +2805,8 @@ int parse_char(int fd) { int parse_console(char *buf) { char *type,*command; - type = (char *)malloc(64); - command = (char *)malloc(64); + type = (char *)aMalloc(64); + command = (char *)aMalloc(64); memset(type,0,64); memset(command,0,64); diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index a30b9eb07..44ccdffbd 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -13,6 +13,7 @@ #include "mmo.h" #include "socket.h" #include "db.h" +#include "malloc.h" #include #include @@ -332,7 +333,7 @@ struct guild * inter_guild_fromsql(int guild_id) if (g != NULL) return g; - g = (struct guild *) malloc(sizeof(struct guild)); + g = (struct guild *) aMalloc(sizeof(struct guild)); memset(g,0,sizeof(struct guild)); // printf("Retrieve guild information from sql ......\n"); @@ -528,7 +529,7 @@ int inter_guildcastle_tosql(struct guild_castle *gc) gcopy = numdb_search(castle_db_,gc->castle_id); if (gcopy == NULL) { - gcopy = (struct guild_castle *) malloc(sizeof(struct guild_castle)); + gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); numdb_insert(castle_db_, gc->castle_id, gcopy); } else { if ((gc->guild_id == gcopy->guild_id ) && ( gc->economy == gcopy->economy ) && ( gc->defense == gcopy->defense ) && ( gc->triggerE == gcopy->triggerE ) && ( gc->triggerD == gcopy->triggerD ) && ( gc->nextTime == gcopy->nextTime ) && ( gc->payTime == gcopy->payTime ) && ( gc->createTime == gcopy->createTime ) && ( gc->visibleC == gcopy->visibleC ) && ( gc->visibleG0 == gcopy->visibleG0 ) && ( gc->visibleG1 == gcopy->visibleG1 ) && ( gc->visibleG2 == gcopy->visibleG2 ) && ( gc->visibleG3 == gcopy->visibleG3 ) && ( gc->visibleG4 == gcopy->visibleG4 ) && ( gc->visibleG5 == gcopy->visibleG5 ) && ( gc->visibleG6 == gcopy->visibleG6 ) && ( gc->visibleG7 == gcopy->visibleG7 ) && ( gc->Ghp0 == gcopy->Ghp0 ) && ( gc->Ghp1 == gcopy->Ghp1 ) && ( gc->Ghp2 == gcopy->Ghp2 ) && ( gc->Ghp3 == gcopy->Ghp3 ) && ( gc->Ghp4 == gcopy->Ghp4 ) && ( gc->Ghp5 == gcopy->Ghp5 ) && ( gc->Ghp6 == gcopy->Ghp6 ) && ( gc->Ghp7 == gcopy->Ghp7 )) @@ -578,7 +579,7 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) gcopy = numdb_search(castle_db_,gc->castle_id); if (gcopy == NULL) { - gcopy = (struct guild_castle *) malloc(sizeof(struct guild_castle)); + gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); numdb_insert(castle_db_, gc->castle_id, gcopy); } else { memcpy(gc, gcopy, sizeof(struct guild_castle)); @@ -678,9 +679,9 @@ int inter_guild_sql_init() guild_castleinfoevent_db_=numdb_init(); printf("interserver guild memory initialize.... (%d byte)\n",sizeof(struct guild)); - guild_pt = calloc(sizeof(struct guild), 1); - guild_pt2= calloc(sizeof(struct guild), 1); - guildcastle_pt=calloc(sizeof(struct guild_castle), 1); + guild_pt = aCalloc(sizeof(struct guild), 1); + guild_pt2= aCalloc(sizeof(struct guild), 1); + guildcastle_pt=aCalloc(sizeof(struct guild_castle), 1); inter_guild_readdb(); // Read exp @@ -1096,7 +1097,7 @@ int mapif_guild_castle_alldataload(int fd) { gcopy = numdb_search(castle_db_,gc->castle_id); if (gcopy == NULL) { - gcopy = (struct guild_castle *) malloc(sizeof(struct guild_castle)); + gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); numdb_insert(castle_db_, gc->castle_id, gcopy); } memcpy(gcopy, gc, sizeof(struct guild_castle)); diff --git a/src/common/grfio.c b/src/common/grfio.c index f9d99bd70..ea5bba6ab 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -31,6 +31,7 @@ #include "grfio.h" #include "mmo.h" #include "showmsg.h" +#include "malloc.h" #ifdef MEMWATCH #include "memwatch.h" @@ -350,7 +351,7 @@ static FILELIST* filelist_add(FILELIST *entry) } if (filelist_entrys>=filelist_maxentry) { - FILELIST *new_filelist = (FILELIST*)realloc( + FILELIST *new_filelist = (FILELIST*)aRealloc( (void*)filelist, (filelist_maxentry+FILELIST_ADDS)*sizeof(FILELIST) ); if (new_filelist != NULL) { filelist = new_filelist; @@ -395,7 +396,7 @@ static void filelist_adjust(void) { if (filelist!=NULL) { if (filelist_maxentry>filelist_entrys) { - FILELIST *new_filelist = (FILELIST*)realloc( + FILELIST *new_filelist = (FILELIST*)aRealloc( (void*)filelist,filelist_entrys*sizeof(FILELIST) ); if (new_filelist != NULL) { filelist = new_filelist; @@ -857,7 +858,7 @@ int grfio_add(char *fname) // ShowStatus(tmp_output); if (gentry_entrys>=gentry_maxentry) { - char **new_gentry = (char**)realloc( + char **new_gentry = (char**)aRealloc( (void*)gentry_table,(gentry_maxentry+GENTRY_ADDS)*sizeof(char*) ); if (new_gentry!=NULL) { int lop; diff --git a/src/common/malloc.c b/src/common/malloc.c index eda9bc218..dd1be030f 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -42,3 +42,9 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f } return ret; } + +void * _bcalloc(size_t size, size_t cnt) { + void *ret = malloc(size * cnt); + memset(ret, 0, size * cnt); + return ret; +} diff --git a/src/common/malloc.h b/src/common/malloc.h index 3733a5e55..7b09d7074 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -3,6 +3,21 @@ #include +#if defined(GCOLLECT) + +#include "gc.h" +#define aMalloc(n) GC_MALLOC(n) +#define aCalloc(m,n) _bcalloc(m,n) +#define aRealloc(p,n) GC_REALLOC(p,n) + +extern void * _bcalloc(size_t, size_t); + +#elif defined(BCHECK) +#define aMalloc(n) malloc(n) +#define aCalloc(m,n) calloc(m,n) +#define aRealloc(p,n) realloc(p,n) +#else + #if __STDC_VERSION__ < 199901L # if __GNUC__ >= 2 # define __func__ __FUNCTION__ @@ -21,5 +36,6 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f #define aCalloc(m,n) aCalloc_(m,n,ALC_MARK) #define aRealloc(p,n) aRealloc_(p,n,ALC_MARK) +#endif #endif diff --git a/src/common/utils.c b/src/common/utils.c index ccc81c1c5..9a7722478 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -3,6 +3,7 @@ #include #include #include +#include "malloc.h" void dump(unsigned char *buffer, int num) { @@ -142,7 +143,7 @@ int StringBuf_Printf(struct StringBuf *sbuf,const char *fmt,...) /* Else try again with more space. */ sbuf->max_ *= 2; // twice the old size off = sbuf->ptr_ - sbuf->buf_; - sbuf->buf_ = (char *) realloc(sbuf->buf_, sbuf->max_ + 1); + sbuf->buf_ = (char *) aRealloc(sbuf->buf_, sbuf->max_ + 1); sbuf->ptr_ = sbuf->buf_ + off; } } @@ -156,7 +157,7 @@ int StringBuf_Append(struct StringBuf *buf1,const struct StringBuf *buf2) if (size2 >= buf1_avail) { int off = buf1->ptr_ - buf1->buf_; buf1->max_ += size2; - buf1->buf_ = (char *) realloc(buf1->buf_, buf1->max_ + 1); + buf1->buf_ = (char *) aRealloc(buf1->buf_, buf1->max_ + 1); buf1->ptr_ = buf1->buf_ + off; } diff --git a/src/ladmin/Makefile b/src/ladmin/Makefile index 1b5ed3d97..ebe67a349 100644 --- a/src/ladmin/Makefile +++ b/src/ladmin/Makefile @@ -6,7 +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 ladmin: ladmin.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ ladmin.o md5calc.o $(COMMON_OBJ) + $(CC) -o ../../$@ ladmin.o md5calc.o $(COMMON_OBJ) $(LIB_S) ladmin.o: ladmin.c ladmin.h md5calc.h $(COMMON_H) md5calc.o: md5calc.c md5calc.h diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 687eb3b37..d7f91a20a 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -40,6 +40,7 @@ void Gettimeofday(struct timeval *timenow) #include #include #include +#include "malloc.h" //add include for DBMS(mysql) #include @@ -160,7 +161,7 @@ struct dbt *online_db; void add_online_user(int account_id) { int *p; - p = malloc(sizeof(int)); + p = aMalloc(sizeof(int)); if (p == NULL) { printf("add_online_user: memory allocation failure (malloc)!\n"); exit(0); @@ -1462,8 +1463,8 @@ int parse_login(int fd) { int parse_console(char *buf) { char *type,*command; - type = (char *)malloc(64); - command = (char *)malloc(64); + type = (char *)aMalloc(64); + command = (char *)aMalloc(64); memset(type,0,64); memset(command,0,64); diff --git a/src/map/battle.c b/src/map/battle.c index f7ca80a93..765ce9443 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -5416,11 +5416,11 @@ void battle_set_defaults() { battle_config.natural_heal_skill_interval=10000; battle_config.natural_heal_weight_rate=50; battle_config.item_name_override_grffile=1; - battle_config.item_equip_override_grffile=1; // [Celest] - battle_config.item_slots_override_grffile=1; // [Celest] - battle_config.indoors_override_grffile=1; // [Celest] - battle_config.skill_sp_override_grffile=1; // [Celest] - battle_config.cardillust_read_grffile=1; // [Celest] + battle_config.item_equip_override_grffile=0; // [Celest] + battle_config.item_slots_override_grffile=0; // [Celest] + battle_config.indoors_override_grffile=0; // [Celest] + battle_config.skill_sp_override_grffile=0; // [Celest] + battle_config.cardillust_read_grffile=0; // [Celest] battle_config.arrow_decrement=1; battle_config.max_aspd = 199; battle_config.max_hp = 32500; diff --git a/src/map/intif.c b/src/map/intif.c index 28f1b65a2..379589556 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -31,6 +31,7 @@ #include "guild.h" #include "pet.h" #include "nullpo.h" +#include "malloc.h" #ifdef MEMWATCH #include "memwatch.h" @@ -691,7 +692,7 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 .w .24B struct map_session_data *pl_sd; char Wisp_name[24]; char mbuf[255]; - char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) malloc((RFIFOW(fd,2) - 30)) : mbuf; + char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) aMalloc((RFIFOW(fd,2) - 30)) : mbuf; min_gm_level = (int)RFIFOW(fd,28); memcpy(Wisp_name, RFIFOP(fd,4), 24); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index cf6ab52d0..815034d8c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -764,7 +764,7 @@ static int itemdb_read_sqldb(void) // Insert a new row into the item database - /*id = calloc(sizeof(struct item_data), 1); + /*id = aCalloc(sizeof(struct item_data), 1); if (id == NULL) { diff --git a/src/map/map.c b/src/map/map.c index d89bf424d..91f82110f 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1769,7 +1769,7 @@ static int map_readafm(int m,char *fn) { map[m].m = m; xs = map[m].xs = afm_size[0]; ys = map[m].ys = afm_size[1]; - map[m].gat = calloc(s = map[m].xs * map[m].ys, 1); + map[m].gat = aCalloc(s = map[m].xs * map[m].ys, 1); if(map[m].gat==NULL){ printf("out of memory : map_readmap gat\n"); @@ -1792,14 +1792,14 @@ static int map_readafm(int m,char *fn) { map[m].bxs=(xs+BLOCK_SIZE-1)/BLOCK_SIZE; map[m].bys=(ys+BLOCK_SIZE-1)/BLOCK_SIZE; size = map[m].bxs * map[m].bys * sizeof(struct block_list*); - map[m].block = calloc(size, 1); + map[m].block = aCalloc(size, 1); if(map[m].block == NULL){ printf("out of memory : map_readmap block\n"); exit(1); } - map[m].block_mob = calloc(size, 1); + map[m].block_mob = aCalloc(size, 1); if (map[m].block_mob == NULL) { printf("out of memory : map_readmap block_mob\n"); exit(1); @@ -1807,14 +1807,14 @@ static int map_readafm(int m,char *fn) { size = map[m].bxs*map[m].bys*sizeof(int); - map[m].block_count = calloc(size, 1); + map[m].block_count = aCalloc(size, 1); if(map[m].block_count==NULL){ printf("out of memory : map_readmap block\n"); exit(1); } memset(map[m].block_count,0,size); - map[m].block_mob_count=calloc(size, 1); + map[m].block_mob_count=aCalloc(size, 1); if(map[m].block_mob_count==NULL){ printf("out of memory : map_readmap block_mob\n"); exit(1); @@ -2067,15 +2067,15 @@ int parse_console(char *buf) { int m, n; struct map_session_data *sd; - sd = calloc(sizeof(*sd), 1); + sd = aCalloc(sizeof(*sd), 1); sd->fd = 0; strcpy( sd->status.name , "console"); - type = (char *)malloc(64); - command = (char *)malloc(64); - map = (char *)malloc(64); - buf2 = (char *)malloc(72); + type = (char *)aMalloc(64); + command = (char *)aMalloc(64); + map = (char *)aMalloc(64); + buf2 = (char *)aMalloc(72); memset(type,0,64); memset(command,0,64); diff --git a/src/map/mob.c b/src/map/mob.c index 3c3fc76a5..f9b049254 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -286,7 +286,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname, for(count=0;counteventtimer[i]==-1 ) break; if(iu.scr.timer_event; int j,i=nd->u.scr.timeramount; - if(te==NULL) te=malloc(sizeof(struct npc_timerevent_list)); - else te=realloc( te, sizeof(struct npc_timerevent_list) * (i+1) ); + if(te==NULL) te=aMalloc(sizeof(struct npc_timerevent_list)); + else te=aRealloc( te, sizeof(struct npc_timerevent_list) * (i+1) ); if(te==NULL){ printf("npc_timerevent_import: out of memory !\n"); exit(1); @@ -1777,7 +1777,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line }else{ // duplicate -// nd->u.scr.label_list=malloc(sizeof(struct npc_label_list)*label_dupnum); +// nd->u.scr.label_list=aMalloc(sizeof(struct npc_label_list)*label_dupnum); // memcpy(nd->u.scr.label_list,label_dup,sizeof(struct npc_label_list)*label_dupnum); nd->u.scr.label_list=label_dup; // ラベルデータ共有 diff --git a/src/map/pc.c b/src/map/pc.c index ccf163f4e..f7837f838 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 = realloc(gm_account, sizeof(struct gm_account) * GM_num); + 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; @@ -6430,7 +6430,7 @@ int pc_setreg(struct map_session_data *sd,int reg,int val) } } sd->reg_num++; - sd->reg = realloc(sd->reg, sizeof(*(sd->reg)) * sd->reg_num); + sd->reg = aRealloc(sd->reg, sizeof(*(sd->reg)) * sd->reg_num); if (sd->reg == NULL){ printf("out of memory : pc_setreg\n"); exit(1); @@ -6481,7 +6481,7 @@ int pc_setregstr(struct map_session_data *sd,int reg,char *str) return 0; } sd->regstr_num++; - sd->regstr = realloc(sd->regstr, sizeof(sd->regstr[0]) * sd->regstr_num); + sd->regstr = aRealloc(sd->regstr, sizeof(sd->regstr[0]) * sd->regstr_num); if(sd->regstr==NULL){ printf("out of memory : pc_setreg\n"); exit(1); @@ -7750,7 +7750,7 @@ int pc_read_gm_account(int fd) free(gm_account); GM_num = 0; #ifdef TXT_ONLY - gm_account = calloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); + gm_account = aCalloc(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); @@ -7764,7 +7764,7 @@ int pc_read_gm_account(int fd) } lsql_res = mysql_store_result(&lmysql_handle); if (lsql_res) { - gm_account = calloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); + gm_account = aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); while ((lsql_row = mysql_fetch_row(lsql_res))) { gm_account[GM_num].account_id = atoi(lsql_row[0]); gm_account[GM_num].level = atoi(lsql_row[1]); diff --git a/src/map/script.c b/src/map/script.c index c226473b5..91245d19e 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5465,14 +5465,14 @@ int buildin_strmobinfo(struct script_state *st) if(num==1) { char *buf; - buf=calloc(24, 1); + buf=aCalloc(24, 1); buf=mob_db[class].name; push_str(st->stack,C_STR,buf); return 0; } else if(num==2) { char *buf; - buf=calloc(24, 1); + buf=aCalloc(24, 1); buf=mob_db[class].jname; push_str(st->stack,C_STR,buf); return 0; @@ -6137,7 +6137,7 @@ int buildin_getsavepoint(struct script_state *st) sd=script_rid2sd(st); type=conv_num(st,& (st->stack->stack_data[st->start+2])); - mapname=calloc(24, 1); + mapname=aCalloc(24, 1); x=sd->status.save_point.x; y=sd->status.save_point.y; @@ -6206,7 +6206,7 @@ int buildin_getmapxy(struct script_state *st){ //??????????? >>> Possible needly check function parameters on C_STR,C_INT,C_INT <<< ???????????// type=conv_num(st,& (st->stack->stack_data[st->start+5])); - mapname=calloc(24, 1); + mapname=aCalloc(24, 1); switch (type){ case 0: //Get Character Position diff --git a/src/map/skill.c b/src/map/skill.c index 794059e82..1e1c373cb 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -5598,7 +5598,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, group->range=range; if(skillid==HT_TALKIEBOX || skillid==RG_GRAFFITI){ - group->valstr=calloc(80, 1); + group->valstr=aCalloc(80, 1); if(group->valstr==NULL){ printf("skill_castend_map: out of memory !\n"); exit(1); @@ -6547,7 +6547,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick) src->bl.x,src->bl.y,1); if(group == NULL) return 0; - group->valstr=calloc(24, 1); + group->valstr=aCalloc(24, 1); if(group->valstr==NULL){ printf("skill_unit_onlimit: out of memory !\n"); exit(1); @@ -11204,9 +11204,9 @@ int skill_unit_move_unit_group( struct skill_unit_group *group, int m,int dx,int int i,j, *r_flag, *s_flag, *m_flag; struct skill_unit *unit1; struct skill_unit *unit2; - r_flag = (int *) malloc(sizeof(int) * group->unit_count); - s_flag = (int *) malloc(sizeof(int) * group->unit_count); - m_flag = (int *) malloc(sizeof(int) * group->unit_count); + r_flag = (int *) aMalloc(sizeof(int) * group->unit_count); + s_flag = (int *) aMalloc(sizeof(int) * group->unit_count); + m_flag = (int *) aMalloc(sizeof(int) * group->unit_count); memset(r_flag,0, sizeof(int) * group->unit_count);// ?承フラグ memset(s_flag,0, sizeof(int) * group->unit_count);// ?承フラグ memset(m_flag,0, sizeof(int) * group->unit_count);// ?承フラグ diff --git a/src/map/storage.c b/src/map/storage.c index bc97b1390..501a16709 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -11,6 +11,7 @@ #include "storage.h" #include "guild.h" #include "nullpo.h" +#include "malloc.h" #ifdef MEMWATCH #include "memwatch.h" @@ -71,7 +72,7 @@ struct storage *account2storage(int account_id) struct storage *stor; stor=numdb_search(storage_db,account_id); if(stor == NULL) { - stor = calloc(sizeof(struct storage), 1); + stor = aCalloc(sizeof(struct storage), 1); if(stor == NULL){ printf("storage: out of memory!\n"); exit(0); @@ -363,7 +364,7 @@ struct guild_storage *guild2storage(int guild_id) if(guild_search(guild_id) != NULL) { gs=numdb_search(guild_storage_db,guild_id); if(gs == NULL) { - gs = calloc(sizeof(struct guild_storage), 1); + gs = aCalloc(sizeof(struct guild_storage), 1); if(gs==NULL){ printf("storage: out of memory!\n"); exit(0); -- cgit v1.2.3-70-g09d2 From 7737e73dd299e813ba03d227b6113df4d5b557df Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 27 Dec 2004 19:22:37 +0000 Subject: * Updated map cache system from jA git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@824 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 + conf-tmpl/map_athena.conf | 5 +- src/common/grfio.c | 73 ++++++++++++++++++++++- src/common/grfio.h | 3 + src/map/map.c | 149 +++++++++++++++++++++++++++++++--------------- src/map/map.h | 6 +- 6 files changed, 188 insertions(+), 50 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index 209e486ef..713ff1501 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,7 @@ Date Added 12/27 + * Updated map cache system from jA 1087 - change read_map_from_bitmap to 2 to + enable zlib compression [celest] * don't delete alive_timers of -1 (SVN 823) [MouseJstr] * switched malloc,calloc,realloc to aMalloc, aCalloc, aRealloc so support the use of a garbage collector (SVN 821) [MouseJstr] diff --git a/conf-tmpl/map_athena.conf b/conf-tmpl/map_athena.conf index 7f099cb0f..39f5d97d8 100644 --- a/conf-tmpl/map_athena.conf +++ b/conf-tmpl/map_athena.conf @@ -45,7 +45,10 @@ char_port: 6121 map_port: 5121 //Preferred map loading method -//0: Read directly from grf, 1: Read from bitmap file +//0: Read directly from grf, 1: Read from bitmap file (without compression) +//2: Read from bitmap file (with compression). It is possible to reduce the map cache +// to 1MB for 400+ maps with compression enabled. If all maps are already loaded in the +// cache, Athena can boot without reading the grf files. read_map_from_bitmap: 1 // //Where is the bitmap file stored? diff --git a/src/common/grfio.c b/src/common/grfio.c index ea5bba6ab..37cf2b9ee 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -33,6 +33,30 @@ #include "showmsg.h" #include "malloc.h" +#ifdef _WIN32 + #include + #include "zlib_win32.h" + HINSTANCE zlib_dll; + #define zlib_inflateInit(strm) zlib_inflateInit_((strm),ZLIB_VERSION, sizeof(z_stream)) + #define zlib_deflateInit(strm, level) zlib_deflateInit_((strm),(level),ZLIB_VERSION,sizeof(z_stream)) + + int (WINAPI* zlib_inflateInit_) (z_streamp strm, const char *version, int stream_size); + int (WINAPI* zlib_inflate) (z_streamp strm, int flush); + int (WINAPI* zlib_inflateEnd) (z_streamp strm); + + int (WINAPI* zlib_deflateInit_) (z_streamp strm, int level, const char *version, int stream_size); + int (WINAPI* zlib_deflate) (z_streamp strm, int flush); + int (WINAPI* zlib_deflateEnd) (z_streamp strm); +#else + #include + #define zlib_inflateInit inflateInit + #define zlib_inflate inflate + #define zlib_inflateEnd inflateEnd + #define zlib_deflateInit deflateInit + #define zlib_deflate deflate + #define zlib_deflateEnd deflateEnd +#endif + #ifdef MEMWATCH #include "memwatch.h" #endif @@ -260,7 +284,7 @@ static void decode_des_etc(BYTE *buf,int len,int type,int cycle) * Grf data decode sub : zip *------------------------------------------ */ -static int decode_zip(Bytef* dest, uLongf* destLen, const Bytef* source, uLong sourceLen) +int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -290,6 +314,37 @@ static int decode_zip(Bytef* dest, uLongf* destLen, const Bytef* source, uLong s err = inflateEnd(&stream); return err; } + +int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; + + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + + err = zlib_deflateInit(&stream,Z_DEFAULT_COMPRESSION); + if (err != Z_OK) return err; + + err = zlib_deflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + zlib_inflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = zlib_deflateEnd(&stream); + return err; +} + /*********************************************************** *** File List Sobroutines *** ***********************************************************/ @@ -924,6 +979,22 @@ void grfio_init(char *fname) char line[1024], w1[1024], w2[1024]; int result = 0, result2 = 0, result3 = 0, result4 = 0; +#ifdef _WIN32 + if(!zlib_dll) { + zlib_dll = LoadLibrary("zlib.dll"); + (FARPROC)zlib_inflateInit_ = GetProcAddress(zlib_dll,"inflateInit_"); + (FARPROC)zlib_inflate = GetProcAddress(zlib_dll,"inflate"); + (FARPROC)zlib_inflateEnd = GetProcAddress(zlib_dll,"inflateEnd"); + (FARPROC)zlib_deflateInit_ = GetProcAddress(zlib_dll,"deflateInit_"); + (FARPROC)zlib_deflate = GetProcAddress(zlib_dll,"deflate"); + (FARPROC)zlib_deflateEnd = GetProcAddress(zlib_dll,"deflateEnd"); + if(zlib_dll == NULL) { + MessageBox(NULL,"Can't load zlib.dll","grfio.c",MB_OK); + exit(1); + } + } +#endif + data_conf = fopen(fname, "r"); // It will read, if there is grf-files.txt. diff --git a/src/common/grfio.h b/src/common/grfio.h index 53b9da8d4..f39e9af1b 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -8,6 +8,9 @@ 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); + // Accessor to GRF filenames char *grfio_setdatafile(const char *str); char *grfio_setadatafile(const char *str); diff --git a/src/map/map.c b/src/map/map.c index 83ef75762..f36ef0ccf 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -150,20 +150,9 @@ struct charid2nick { int req_id; }; -//各マップごとの最小限情報を入れるもの、READ_FROM_BITMAP用 -/*typedef struct{ - char fn[32];//ファイル名 - int xs,ys; //幅と高さ - int sizeinint;//intでの大きさ、1intに32セルの情報が入てる - int celltype[MAX_CELL_TYPE];//マップごとにそのタイプのセルがあれば対応する数字が入る、なければ1 - //(タイプ1そのものは0と同じ配列gat_fileused[0]に - long pos[MAX_CELL_TYPE];//ビットマップファイルでの場所、読み出す時に使う -} CELL_INFO;*/ - -//#define READ_FROM_GAT 0 //gatファイルから -//#define READ_FROM_BITMAP 1 //ビットマップファイルから -int map_read_flag = READ_FROM_GAT;//上の判定フラグ,どっちを使うかはmap_athana.conf内のread_map_from_bitmapで指定 - //0ならばREAD_FROM_GAT,1ならばREAD_FROM_BITMAP +int map_read_flag = READ_FROM_GAT; +// マップキャッシュ利用フラグ,どっちを使うかはmap_athana.conf内のread_map_from_bitmapで指定 +// 0ならば利用しない、1だと非圧縮保存、2だと圧縮して保存 int map_getcell(int,int x,int y,CELL_CHK cellchk); int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk); @@ -1569,9 +1558,9 @@ static int map_cache_open(char *fn) { return 1; } fclose(map_cache.fp); - } else { - map_read_flag = CREATE_BITMAP; - } + } else if (map_read_flag == READ_FROM_BITMAP || map_read_flag == READ_FROM_BITMAP_COMPRESSED) + ++map_read_flag; // set to CREATE flag + // 読み込みに失敗したので新規に作成する map_cache.fp = fopen(fn,"wb"); if(map_cache.fp) { @@ -1611,10 +1600,8 @@ int map_cache_read(struct map_data *m) { if(map_cache.map[i].water_height != map_waterheight(m->name)) { // 水場の高さが違うので読み直し return 0; - } else if(map_cache.map[i].compressed) { - // 圧縮ファイルは未対応 - return 0; - } else { + } else if(map_cache.map[i].compressed == 0) { + // 非圧縮ファイル int size = map_cache.map[i].xs * map_cache.map[i].ys; m->xs = map_cache.map[i].xs; m->ys = map_cache.map[i].ys; @@ -1625,12 +1612,36 @@ int map_cache_read(struct map_data *m) { return 1; } else { // なぜかファイル後半が欠けてるので読み直し - m->xs = 0; - m->ys = 0; - free(m->gat); - m->gat = NULL; + m->xs = 0; m->ys = 0; m->gat = NULL; free(m->gat); + return 0; + } + } else if(map_cache.map[i].compressed == 1) { + // 圧縮フラグ=1 : zlib + unsigned char *buf; + unsigned long dest_len; + int size_compress = map_cache.map[i].compressed_len; + m->xs = map_cache.map[i].xs; + m->ys = map_cache.map[i].ys; + m->gat = (unsigned char *)aMalloc(m->xs * m->ys * sizeof(unsigned char)); + buf = (unsigned char*)aMalloc(size_compress); + fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET); + if(fread(buf,1,size_compress,map_cache.fp) != size_compress) { + // なぜかファイル後半が欠けてるので読み直し + printf("fread error\n"); + m->xs = 0; m->ys = 0; m->gat = NULL; + free(m->gat); free(buf); return 0; } + dest_len = m->xs * m->ys; + decode_zip(m->gat,&dest_len,buf,size_compress); + if(dest_len != map_cache.map[i].xs * map_cache.map[i].ys) { + // 正常に解凍が出来てない + m->xs = 0; m->ys = 0; m->gat = NULL; + free(m->gat); free(buf); + return 0; + } + free(buf); + return 1; } } } @@ -1639,29 +1650,52 @@ int map_cache_read(struct map_data *m) { static int map_cache_write(struct map_data *m) { int i; + unsigned long len_new , len_old; + char *write_buf; if(!map_cache.fp) { return 0; } for(i = 0;i < map_cache.head.nmaps ; i++) { if(!strcmp(m->name,map_cache.map[i].fn)) { // 同じエントリーがあれば上書き - if( - map_cache.map[i].xs == m->xs && map_cache.map[i].ys == m->ys && - !map_cache.map[i].compressed - ) { - // 幅と高さ同じで圧縮してないなら場所は変わらない + if(map_cache.map[i].compressed == 0) { + len_old = map_cache.map[i].xs * map_cache.map[i].ys; + } else if(map_cache.map[i].compressed == 1) { + len_old = map_cache.map[i].compressed_len; + } else { + // サポートされてない形式なので長さ0 + len_old = 0; + } + if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { + // 圧縮保存 + // さすがに2倍に膨れる事はないという事で + write_buf = aMalloc(m->xs * m->ys * 2); + len_new = m->xs * m->ys * 2; + encode_zip(write_buf,&len_new,m->gat,m->xs * m->ys); + map_cache.map[i].compressed = 1; + map_cache.map[i].compressed_len = len_new; + } else { + len_new = m->xs * m->ys; + write_buf = m->gat; + map_cache.map[i].compressed = 0; + map_cache.map[i].compressed_len = 0; + } + if(len_new <= len_old) { + // サイズが同じか小さくなったので場所は変わらない fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET); - fwrite(m->gat,m->xs,m->ys,map_cache.fp); + fwrite(write_buf,1,len_new,map_cache.fp); } else { - // 幅と高さが違うなら新しい場所に登録 - int size = m->xs * m->ys; + // 新しい場所に登録 fseek(map_cache.fp,map_cache.head.filesize,SEEK_SET); - fwrite(m->gat,1,size,map_cache.fp); + fwrite(write_buf,1,len_new,map_cache.fp); map_cache.map[i].pos = map_cache.head.filesize; - map_cache.map[i].xs = m->xs; - map_cache.map[i].ys = m->ys; - map_cache.head.filesize += size; + map_cache.head.filesize += len_new; } + map_cache.map[i].xs = m->xs; + map_cache.map[i].ys = m->ys; map_cache.map[i].water_height = map_waterheight(m->name); map_cache.dirty = 1; + if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { + free(write_buf); + } return 0; } } @@ -1669,16 +1703,30 @@ static int map_cache_write(struct map_data *m) { for(i = 0;i < map_cache.head.nmaps ; i++) { if(map_cache.map[i].fn[0] == 0) { // 新しい場所に登録 - int size = m->xs * m->ys; + if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { + write_buf = aMalloc(m->xs * m->ys * 2); + len_new = m->xs * m->ys * 2; + encode_zip(write_buf,&len_new,m->gat,m->xs * m->ys); + map_cache.map[i].compressed = 1; + map_cache.map[i].compressed_len = len_new; + } else { + len_new = m->xs * m->ys; + write_buf = m->gat; + map_cache.map[i].compressed = 0; + map_cache.map[i].compressed_len = 0; + } strncpy(map_cache.map[i].fn,m->name,sizeof(map_cache.map[0].fn)); fseek(map_cache.fp,map_cache.head.filesize,SEEK_SET); - fwrite(m->gat,1,size,map_cache.fp); + fwrite(write_buf,1,len_new,map_cache.fp); map_cache.map[i].pos = map_cache.head.filesize; map_cache.map[i].xs = m->xs; map_cache.map[i].ys = m->ys; map_cache.map[i].water_height = map_waterheight(m->name); - map_cache.head.filesize += size; + map_cache.head.filesize += len_new; map_cache.dirty = 1; + if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { + free(write_buf); + } return 0; } } @@ -1931,13 +1979,14 @@ int map_readallmap(void) { int map_cache = 0; // マップキャッシュを開く - if(map_read_flag == READ_FROM_BITMAP) { + if(map_read_flag >= READ_FROM_BITMAP) { map_cache_open(map_bitmap_filename); } sprintf(tmp_output, "Loading Maps%s...\n", - (map_read_flag == CREATE_BITMAP ? " (Generating Map Cache)" : - map_read_flag == READ_FROM_BITMAP ? " (w/ Map Cache)" : + (map_read_flag == CREATE_BITMAP_COMPRESSED ? " (Generating Map Cache w/ Compression)" : + map_read_flag == CREATE_BITMAP ? " (Generating Map Cache)" : + map_read_flag >= READ_FROM_BITMAP ? " (w/ Map Cache)" : map_read_flag == READ_FROM_AFM ? " (w/ AFM)" : "")); ShowStatus(tmp_output); @@ -2001,8 +2050,8 @@ int map_readallmap(void) { ShowInfo(tmp_output); map_cache_close(); - if(map_read_flag == CREATE_BITMAP) { - map_read_flag = READ_FROM_BITMAP; + if(map_read_flag == CREATE_BITMAP || map_read_flag == CREATE_BITMAP_COMPRESSED) { + --map_read_flag; } if (maps_removed) { @@ -2214,10 +2263,14 @@ int map_config_read(char *cfgName) { } else if (strcmpi(w1, "mapreg_txt") == 0) { strcpy(mapreg_txt, w2); }else if(strcmpi(w1,"read_map_from_bitmap")==0){ - if (atoi(w2) == 1) + if (atoi(w2) == 2) + map_read_flag = READ_FROM_BITMAP_COMPRESSED; + else if (atoi(w2) == 1) map_read_flag = READ_FROM_BITMAP; else map_read_flag = READ_FROM_GAT; + }else if(strcmpi(w1,"map_bitmap_path")==0){ + strncpy(map_bitmap_filename,w2,255); } else if (strcmpi(w1, "import") == 0) { map_config_read(w2); } else if (strcmpi(w1, "console") == 0) { @@ -2408,7 +2461,9 @@ int sql_config_read(char *cfgName) } else if(strcmpi(w1,"log_db_port")==0) { log_db_port = atoi(w2); }else if(strcmpi(w1,"read_map_from_bitmap")==0){ - if (atoi(w2) == 1) + if (atoi(w2) == 2) + map_read_flag = READ_FROM_BITMAP_COMPRESSED; + else if (atoi(w2) == 1) map_read_flag = READ_FROM_BITMAP; else map_read_flag = READ_FROM_GAT; diff --git a/src/map/map.h b/src/map/map.h index dcda50978..cb8438352 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -668,7 +668,11 @@ extern int night_flag; // 0=day, 1=night [Yor] int map_getcell(int,int,int,CELL_CHK); int map_getcellp(struct map_data*,int,int,CELL_CHK); extern int map_read_flag; //セル情報のソース判定フラグ、0ならgrfファイル、1ならビットマップファイル -enum { READ_FROM_GAT, READ_FROM_AFM, READ_FROM_BITMAP, CREATE_BITMAP }; +enum { + READ_FROM_GAT, READ_FROM_AFM, + READ_FROM_BITMAP, CREATE_BITMAP, + READ_FROM_BITMAP_COMPRESSED, CREATE_BITMAP_COMPRESSED +}; extern char motd_txt[]; extern char help_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 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index 6441040a4..f7f3dddd7 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Date Added 12/29 + * Some code cleanup in prep for new debugging malloc (SVN 861) [MouseJstr] * Updated Soul Breaker's damage calculation [celest] * Updated Meteor Assault's cast delay to be not affected by dex [celest] * Changed int_guild.c so it will calculate average guild level only if > 0 diff --git a/Makefile b/Makefile index d9258179c..527693e4e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ # $Id: Makefile 158 2004-10-01 03:45:15Z PoW $ CC = gcc -pipe +# CC = gcc -pipe -x c++ # CC = gcc -pipe -DGCOLLECT # CC = /usr/local/bin/gcc -fbounds-checking -pipe -DBCHECK diff --git a/src/char/char.c b/src/char/char.c index 72d461865..e812e1de1 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -269,7 +269,7 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p) { "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%s,%d,%d\t%s,%d,%d,%d\t", p->char_id, p->account_id, p->char_num, p->name, // - p->class, p->base_level, p->job_level, + p->class_, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, p->hp, p->max_hp, p->sp, p->max_sp, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, @@ -397,7 +397,7 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) { p->char_id = tmp_int[0]; p->account_id = tmp_int[1]; p->char_num = tmp_int[2]; - p->class = tmp_int[3]; + p->class_ = tmp_int[3]; p->base_level = tmp_int[4]; p->job_level = tmp_int[5]; p->base_exp = tmp_int[6]; @@ -947,7 +947,7 @@ int make_new_char(int fd, unsigned char *dat) { char_dat[i].account_id = sd->account_id; char_dat[i].char_num = dat[30]; strcpy(char_dat[i].name, dat); - char_dat[i].class = 0; + char_dat[i].class_ = 0; char_dat[i].base_level = 1; char_dat[i].job_level = 1; char_dat[i].base_exp = 0; @@ -1156,12 +1156,12 @@ void create_online_files(void) { break; case 4: // by job (and job level) for(k = 0; k < players; k++) - if (char_dat[j].class < char_dat[id[k]].class || + if (char_dat[j].class_ < char_dat[id[k]].class_ || // if same job, we sort by job level. - (char_dat[j].class == char_dat[id[k]].class && + (char_dat[j].class_ == char_dat[id[k]].class_ && char_dat[j].job_level < char_dat[id[k]].job_level) || // if same job and job level, we sort by job exp. - (char_dat[j].class == char_dat[id[k]].class && + (char_dat[j].class_ == char_dat[id[k]].class_ && char_dat[j].job_level == char_dat[id[k]].job_level && char_dat[j].job_exp < char_dat[id[k]].job_exp)) { for(l = players; l > k; l--) @@ -1302,7 +1302,7 @@ void create_online_files(void) { } // displaying of the job if (online_display_option & 6) { - char * jobname = job_name(char_dat[j].class); + char * jobname = job_name(char_dat[j].class_); if ((online_display_option & 6) == 6) { fprintf(fp2, " %s %d/%d\n", jobname, char_dat[j].base_level, char_dat[j].job_level); fprintf(fp, "%-18s %3d/%3d ", jobname, char_dat[j].base_level, char_dat[j].job_level); @@ -1436,7 +1436,7 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { WFIFOW(fd,j+46) = (p->sp > 0x7fff) ? 0x7fff : p->sp; WFIFOW(fd,j+48) = (p->max_sp > 0x7fff) ? 0x7fff : p->max_sp; WFIFOW(fd,j+50) = DEFAULT_WALK_SPEED; // p->speed; - WFIFOW(fd,j+52) = p->class; + WFIFOW(fd,j+52) = p->class_; WFIFOW(fd,j+54) = p->hair; WFIFOW(fd,j+56) = p->weapon; WFIFOW(fd,j+58) = p->base_level; @@ -1717,7 +1717,7 @@ int parse_tologin(int fd) { if (acc > 0) { for (i = 0; i < char_num; i++) { if (char_dat[i].account_id == acc) { - int jobclass = char_dat[i].class; + int jobclass = char_dat[i].class_; char_dat[i].sex = sex; auth_fifo[i].sex = sex; if (jobclass == 19 || jobclass == 20 || @@ -1725,11 +1725,11 @@ int parse_tologin(int fd) { jobclass == 4042 || jobclass == 4043) { // job modification if (jobclass == 19 || jobclass == 20) { - char_dat[i].class = (sex) ? 19 : 20; + char_dat[i].class_ = (sex) ? 19 : 20; } else if (jobclass == 4020 || jobclass == 4021) { - char_dat[i].class = (sex) ? 4020 : 4021; + char_dat[i].class_ = (sex) ? 4020 : 4021; } else if (jobclass == 4042 || jobclass == 4043) { - char_dat[i].class = (sex) ? 4042 : 4043; + char_dat[i].class_ = (sex) ? 4042 : 4043; } // remove specifical skills of classes 19, 4020 and 4042 for(j = 315; j <= 322; j++) { @@ -2730,7 +2730,7 @@ int parse_char(int fd) { WFIFOW(fd,2+46) = (char_dat[i].sp > 0x7fff) ? 0x7fff : char_dat[i].sp; WFIFOW(fd,2+48) = (char_dat[i].max_sp > 0x7fff) ? 0x7fff : char_dat[i].max_sp; WFIFOW(fd,2+50) = DEFAULT_WALK_SPEED; // char_dat[i].speed; - WFIFOW(fd,2+52) = char_dat[i].class; + WFIFOW(fd,2+52) = char_dat[i].class_; WFIFOW(fd,2+54) = char_dat[i].hair; WFIFOW(fd,2+58) = char_dat[i].base_level; diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 8577b2a66..0ee4476fc 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -45,7 +45,7 @@ int inter_guild_tostr(char *str, struct guild *g) { len += sprintf(str + len, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\t%s\t", m->account_id, m->char_id, m->hair, m->hair_color, m->gender, - m->class, m->lv, m->exp, m->exp_payper, m->position, + m->class_, m->lv, m->exp, m->exp_payper, m->position, ((m->account_id > 0) ? m->name : "-")); } // 役職 @@ -138,7 +138,7 @@ int inter_guild_fromstr(char *str, struct guild *g) { m->hair = tmp_int[2]; m->hair_color = tmp_int[3]; m->gender = tmp_int[4]; - m->class = tmp_int[5]; + m->class_ = tmp_int[5]; m->lv = tmp_int[6]; m->exp = tmp_int[7]; m->exp_payper = tmp_int[8]; @@ -767,7 +767,7 @@ int mapif_guild_memberinfoshort(struct guild *g, int idx) { WBUFL(buf,10) = g->member[idx].char_id; WBUFB(buf,14) = g->member[idx].online; WBUFW(buf,15) = g->member[idx].lv; - WBUFW(buf,17) = g->member[idx].class; + WBUFW(buf,17) = g->member[idx].class_; mapif_sendall(buf, 19); return 0; } @@ -1101,7 +1101,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, if (g->member[i].account_id == account_id && g->member[i].char_id == char_id) { g->member[i].online = online; g->member[i].lv = lv; - g->member[i].class = class; + g->member[i].class_ = class; mapif_guild_memberinfoshort(g, i); } if (g->member[i].account_id > 0) { diff --git a/src/char/int_pet.c b/src/char/int_pet.c index cff1e434f..c08c4ccf3 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -30,7 +30,7 @@ int inter_pet_tostr(char *str,struct s_pet *p) p->intimate = 1000; len=sprintf(str,"%d,%d,%s\t%d,%d,%d,%d,%d,%d,%d,%d,%d", - p->pet_id,p->class,p->name,p->account_id,p->char_id,p->level,p->egg_id, + p->pet_id,p->class_,p->name,p->account_id,p->char_id,p->level,p->egg_id, p->equip,p->intimate,p->hungry,p->rename_flag,p->incuvate); return 0; @@ -52,7 +52,7 @@ int inter_pet_fromstr(char *str,struct s_pet *p) return 1; p->pet_id = tmp_int[0]; - p->class = tmp_int[1]; + p->class_ = tmp_int[1]; memcpy(p->name,tmp_str,24); p->account_id = tmp_int[2]; p->char_id = tmp_int[3]; @@ -225,7 +225,7 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet p->account_id = account_id; p->char_id = char_id; } - p->class = pet_class; + p->class_ = pet_class; p->level = pet_lv; p->egg_id = pet_egg_id; p->equip = pet_equip; diff --git a/src/char_sql/char.c b/src/char_sql/char.c index be8611889..6e982ac67 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -440,7 +440,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ //===================================================================================================== - if ((p->base_exp != cp->base_exp) || (p->class != cp->class) || + if ((p->base_exp != cp->base_exp) || (p->class_ != cp->class_) || (p->base_level != cp->base_level) || (p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) || (p->zeny != cp->zeny) || (p->last_point.x != cp->last_point.x) || (p->last_point.y != cp->last_point.y) || @@ -498,7 +498,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ "`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d'," "`hair`='%d',`hair_color`='%d',`clothes_color`='%d',`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d',`partner_id`='%d' WHERE `account_id`='%d' AND `char_id` = '%d'", - char_db, p->class, p->base_level, p->job_level, + char_db, p->class_, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, @@ -913,7 +913,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ p->account_id = atoi(sql_row[1]); p->char_num = atoi(sql_row[2]); strcpy(p->name, sql_row[3]); - p->class = atoi(sql_row[4]); + p->class_ = atoi(sql_row[4]); p->base_level = atoi(sql_row[5]); p->job_level = atoi(sql_row[6]); p->base_exp = atoi(sql_row[7]); @@ -1429,7 +1429,7 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { WFIFOW(fd,j+46) = (p->sp > 0x7fff) ? 0x7fff : p->sp; WFIFOW(fd,j+48) = (p->max_sp > 0x7fff) ? 0x7fff : p->max_sp; WFIFOW(fd,j+50) = DEFAULT_WALK_SPEED; // p->speed; - WFIFOW(fd,j+52) = p->class; + WFIFOW(fd,j+52) = p->class_; WFIFOW(fd,j+54) = p->hair; WFIFOW(fd,j+56) = p->weapon; WFIFOW(fd,j+58) = p->base_level; @@ -2539,7 +2539,7 @@ int parse_char(int fd) { WFIFOW(fd,2+46) = (char_dat[i].sp > 0x7fff) ? 0x7fff : char_dat[i].sp; WFIFOW(fd,2+48) = (char_dat[i].max_sp > 0x7fff) ? 0x7fff : char_dat[i].max_sp; WFIFOW(fd,2+50) = DEFAULT_WALK_SPEED; // char_dat[i].speed; - WFIFOW(fd,2+52) = char_dat[i].class; + WFIFOW(fd,2+52) = char_dat[i].class_; WFIFOW(fd,2+54) = char_dat[i].hair; WFIFOW(fd,2+58) = char_dat[i].base_level; diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 5fee88511..258c173cf 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -229,7 +229,7 @@ int inter_guild_tosql(struct guild *g,int flag) g->guild_id, m->account_id,m->char_id, m->hair,m->hair_color,m->gender, - m->class,m->lv,m->exp,m->exp_payper,m->online,m->position, + m->class_,m->lv,m->exp,m->exp_payper,m->online,m->position, 0,0, jstrescapecpy(t_member,m->name)); @@ -405,7 +405,7 @@ struct guild * inter_guild_fromsql(int guild_id) m->hair=atoi(sql_row[3]); m->hair_color=atoi(sql_row[4]); m->gender=atoi(sql_row[5]); - m->class=atoi(sql_row[6]); + m->class_=atoi(sql_row[6]); m->lv=atoi(sql_row[7]); m->exp=atoi(sql_row[8]); m->exp_payper=atoi(sql_row[9]); @@ -908,7 +908,7 @@ int mapif_guild_memberinfoshort(struct guild *g,int idx) WBUFL(buf,10)=g->member[idx].char_id; WBUFB(buf,14)=g->member[idx].online; WBUFW(buf,15)=g->member[idx].lv; - WBUFW(buf,17)=g->member[idx].class; + WBUFW(buf,17)=g->member[idx].class_; mapif_sendall(buf,19); return 0; } @@ -1283,7 +1283,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, g->member[i].online=online; g->member[i].lv=lv; - g->member[i].class=class; + g->member[i].class_=class; mapif_guild_memberinfoshort(g,i); idx = i; } @@ -1303,7 +1303,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); - sprintf(tmp_sql, "UPDATE `%s` SET `online`=%d,`lv`=%d,`class`=%d WHERE `char_id`=%d", guild_member_db, g->member[idx].online, g->member[idx].lv, g->member[idx].class, g->member[idx].char_id); + sprintf(tmp_sql, "UPDATE `%s` SET `online`=%d,`lv`=%d,`class`=%d WHERE `char_id`=%d", guild_member_db, g->member[idx].online, g->member[idx].lv, g->member[idx].class_, g->member[idx].char_id); if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 97548aeff..edad95f84 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -39,11 +39,11 @@ int inter_pet_tosql(int pet_id, struct s_pet *p) { if (sql_res!=NULL && mysql_num_rows(sql_res)>0) //row reside -> updating sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'", - pet_db, p->class, t_name, p->account_id, p->char_id, p->level, p->egg_id, + pet_db, p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id); else //no row -> insert sprintf(tmp_sql,"INSERT INTO `%s` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) VALUES ('%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - pet_db, pet_id, p->class, t_name, p->account_id, p->char_id, p->level, p->egg_id, + pet_db, pet_id, p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate); mysql_free_result(sql_res) ; //resource free if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -72,7 +72,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet *p){ sql_row = mysql_fetch_row(sql_res); p->pet_id = pet_id; - p->class = atoi(sql_row[1]); + p->class_ = atoi(sql_row[1]); memcpy(p->name, sql_row[2],24); p->account_id = atoi(sql_row[3]); p->char_id = atoi(sql_row[4]); @@ -215,7 +215,7 @@ int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_pt->account_id = account_id; pet_pt->char_id = char_id; } - pet_pt->class = pet_class; + pet_pt->class_ = pet_class; pet_pt->level = pet_lv; pet_pt->egg_id = pet_egg_id; pet_pt->equip = pet_equip; diff --git a/src/common/db.c b/src/common/db.c index 8996dda80..bc4e8451b 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -6,6 +6,7 @@ #include "db.h" #include "mmo.h" #include "utils.h" +#include "malloc.h" #ifdef MEMWATCH #include "memwatch.h" diff --git a/src/common/grfio.c b/src/common/grfio.c index 37cf2b9ee..440c3b2a3 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -284,7 +284,7 @@ static void decode_des_etc(BYTE *buf,int len,int type,int cycle) * Grf data decode sub : zip *------------------------------------------ */ -int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) +int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -294,7 +294,7 @@ int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - stream.next_out = dest; + stream.next_out = (Bytef*) dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; @@ -315,7 +315,7 @@ int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned return err; } -int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { +int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -324,7 +324,7 @@ int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - stream.next_out = dest; + stream.next_out = (Bytef*) dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; @@ -382,7 +382,7 @@ FILELIST *filelist_find(char *fname) { int hash; - for(hash=filelist_hash[filehash(fname)];hash>=0;hash=filelist[hash].next) { + for(hash=filelist_hash[filehash((unsigned char *) fname)];hash>=0;hash=filelist[hash].next) { if(strcmpi(filelist[hash].fn,fname)==0) break; } @@ -421,7 +421,7 @@ static FILELIST* filelist_add(FILELIST *entry) memcpy( &filelist[filelist_entrys], entry, sizeof(FILELIST) ); - hash = filehash(entry->fn); + hash = filehash((unsigned char *) entry->fn); filelist[filelist_entrys].next = filelist_hash[hash]; filelist_hash[hash] = filelist_entrys; @@ -576,7 +576,7 @@ void* grfio_reads(char *fname, int *size) lentry.declen = ftell(in); } fseek(in,0,0); // SEEK_SET - buf2 = calloc(lentry.declen+1024, 1); + buf2 = (unsigned char *) aCalloc(lentry.declen+1024, 1); if (buf2==NULL) { printf("file read memory allocate error : declen\n"); goto errret; @@ -598,7 +598,7 @@ void* grfio_reads(char *fname, int *size) } } if (entry!=NULL && entry->gentry>0) { // Archive[GRF] File Read - buf = calloc(entry->srclen_aligned+1024, 1); + buf = (unsigned char *) aCalloc(entry->srclen_aligned+1024, 1); if (buf==NULL) { printf("file read memory allocate error : srclen_aligned\n"); goto errret; @@ -614,7 +614,7 @@ void* grfio_reads(char *fname, int *size) fseek(in,entry->srcpos,0); fread(buf,1,entry->srclen_aligned,in); fclose(in); - buf2=calloc(entry->declen+1024, 1); + buf2 = (unsigned char *) aCalloc(entry->declen+1024, 1); if (buf2==NULL) { printf("file decode memory allocate error\n"); goto errret; @@ -694,7 +694,7 @@ static int grfio_entryread(char *gfname,int gentry) grf_size = ftell(fp); fseek(fp,0,0); // SEEK_SET fread(grf_header,1,0x2e,fp); - if(strcmp(grf_header,"Master of Magic") || fseek(fp,getlong(grf_header+0x1e),1)){ // SEEK_CUR + if(strcmp((const char *) grf_header,"Master of Magic") || fseek(fp,getlong(grf_header+0x1e),1)){ // SEEK_CUR fclose(fp); printf("%s read error\n",gfname); return 2; // 2:file format error @@ -704,7 +704,7 @@ static int grfio_entryread(char *gfname,int gentry) if (grf_version==0x01) { //****** Grf version 01xx ****** list_size = grf_size-ftell(fp); - grf_filelist = calloc(list_size, 1); + grf_filelist = (unsigned char *) aCalloc(list_size, 1); if(grf_filelist==NULL){ fclose(fp); printf("out of memory : grf_filelist\n"); @@ -725,13 +725,13 @@ static int grfio_entryread(char *gfname,int gentry) type = grf_filelist[ofs2+12]; if( type!=0 ){ // Directory Index ... skip fname = decode_filename(grf_filelist+ofs+6,grf_filelist[ofs]-6); - if(strlen(fname)>sizeof(aentry.fn)-1){ + if(strlen((const char *) fname)>sizeof(aentry.fn)-1){ printf("file name too long : %s\n",fname); free(grf_filelist); exit(1); } srclen=0; - if((period_ptr=strrchr(fname,'.'))!=NULL){ + if((period_ptr=strrchr((const char *) fname,'.'))!=NULL){ for(lop=0;lop<4;lop++) { if(strcmpi(period_ptr,".gnd\0.gat\0.act\0.str"+lop*5)==0) break; @@ -752,7 +752,7 @@ static int grfio_entryread(char *gfname,int gentry) aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e; aentry.cycle = srccount; aentry.type = type; - strncpy(aentry.fn,fname,sizeof(aentry.fn)-1); + strncpy(aentry.fn, (const char *) fname,sizeof(aentry.fn)-1); #ifdef GRFIO_LOCAL aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck #else @@ -779,13 +779,13 @@ static int grfio_entryread(char *gfname,int gentry) return 4; } - rBuf = calloc( rSize , 1); // Get a Read Size + rBuf = (unsigned char *) aCalloc( rSize , 1); // Get a Read Size if (rBuf==NULL) { fclose(fp); printf("out of memory : grf compress entry table buffer\n"); return 3; } - grf_filelist = calloc( eSize , 1); // Get a Extend Size + grf_filelist = (unsigned char *) aCalloc( eSize , 1); // Get a Extend Size if (grf_filelist==NULL) { free(rBuf); fclose(fp); @@ -806,7 +806,7 @@ static int grfio_entryread(char *gfname,int gentry) FILELIST aentry; fname = grf_filelist+ofs; - if (strlen(fname)>sizeof(aentry.fn)-1) { + if (strlen((const char *) fname)>sizeof(aentry.fn)-1) { printf("grf : file name too long : %s\n",fname); free(grf_filelist); exit(1); @@ -927,7 +927,7 @@ int grfio_add(char *fname) } } len = strlen( fname ); - buf = calloc(len+1, 1); + buf = aCalloc(len+1, 1); if (buf==NULL) { printf("out of memory : gentry\n"); exit(1); diff --git a/src/common/grfio.h b/src/common/grfio.h index f39e9af1b..3fa257e2f 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -8,8 +8,8 @@ void* grfio_read(char*); // GRFIO data file read void* grfio_reads(char*,int*); // GRFIO data file read & size get int grfio_size(char*); // GRFIO data file size get -int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen); -int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen); +int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); +int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); // Accessor to GRF filenames char *grfio_setdatafile(const char *str); diff --git a/src/common/mmo.h b/src/common/mmo.h index 617a870e9..41598509e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -114,7 +114,7 @@ struct s_pet { int account_id; int char_id; int pet_id; - short class; + short class_; short level; short egg_id;//pet egg id short equip;//pet equip name_id @@ -132,7 +132,7 @@ struct mmo_charstatus { int base_exp,job_exp,zeny; - short class; + short class_; short status_point,skill_point; int hp,max_hp,sp,max_sp; short option,karma,manner; @@ -204,7 +204,7 @@ struct party { struct guild_member { int account_id, char_id; - short hair,hair_color,gender,class,lv; + short hair,hair_color,gender,class_,lv; int exp,exp_payper; short online,position; int rsv1,rsv2; diff --git a/src/common/socket.c b/src/common/socket.c index 729f2fdfe..5d7d0775e 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -200,8 +200,8 @@ static int connect_client(int listen_fd) #endif CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, char, rfifo_size); - CREATE(session[fd]->wdata, char, wfifo_size); + CREATE(session[fd]->rdata, unsigned char, rfifo_size); + CREATE(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -339,8 +339,8 @@ int make_connection(long ip,int port) FD_SET(fd,&readfds); CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, char, rfifo_size); - CREATE(session[fd]->wdata, char, wfifo_size); + CREATE(session[fd]->rdata, unsigned char, rfifo_size); + CREATE(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -374,11 +374,11 @@ int realloc_fifo(int fd,int rfifo_size,int wfifo_size) { struct socket_data *s=session[fd]; if( s->max_rdata != rfifo_size && s->rdata_size < rfifo_size){ - RECREATE(s->rdata, char, rfifo_size); + RECREATE(s->rdata, unsigned char, rfifo_size); s->max_rdata = rfifo_size; } if( s->max_wdata != wfifo_size && s->wdata_size < wfifo_size){ - RECREATE(s->wdata, char, wfifo_size); + RECREATE(s->wdata, unsigned char, wfifo_size); s->max_wdata = wfifo_size; } return 0; diff --git a/src/common/socket.h b/src/common/socket.h index 9b0c05013..e5e065f33 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -12,6 +12,7 @@ #include #include #endif +#include "malloc.h" // define declaration diff --git a/src/common/strlib.c b/src/common/strlib.c index b113d96f5..9114c3d03 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -4,6 +4,7 @@ #include "strlib.h" #include "utils.h" +#include "malloc.h" //----------------------------------------------- // string lib. diff --git a/src/common/utils.h b/src/common/utils.h index d234e9351..0ac880a50 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -27,11 +27,11 @@ #define CREATE(result, type, number) do {\ if ((number) * sizeof(type) <= 0) \ printf("SYSERR: Zero bytes or less requested at %s:%d.\n", __FILE__, __LINE__); \ - if (!((result) = (type *) calloc ((number), sizeof(type)))) \ + if (!((result) = (type *) aCalloc ((number), sizeof(type)))) \ { perror("SYSERR: malloc failure"); abort(); } } while(0) #define RECREATE(result,type,number) do {\ - if (!((result) = (type *) realloc ((result), sizeof(type) * (number))))\ + if (!((result) = (type *) aRealloc ((result), sizeof(type) * (number))))\ { printf("SYSERR: realloc failure"); abort(); } } while(0) struct StringBuf { diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 45b87a2f3..dc6c55777 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -831,7 +831,7 @@ static int atmobsearch_sub(struct block_list *bl,va_list ap) md = (struct mob_data *)bl; - if(md && fd && (mob_id==-1 || (md->class==mob_id))){ + if(md && fd && (mob_id==-1 || (md->class_==mob_id))){ snprintf(output, sizeof output, "%2d[%3d:%3d] %s", ++number,bl->x, bl->y,md->name); clif_displaymessage(fd, output); @@ -1285,9 +1285,9 @@ int atcommand_who2( player_name[j] = tolower(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive if (pl_GM_level > 0) - sprintf(output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); else - sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); clif_displaymessage(fd, output); count++; } @@ -1478,9 +1478,9 @@ int atcommand_whomap2( if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level if (pl_sd->bl.m == map_id) { if (pl_GM_level > 0) - sprintf(output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); else - sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); clif_displaymessage(fd, output); count++; } @@ -1621,7 +1621,7 @@ int atcommand_whogm( if (strstr(player_name, match_text) != NULL) { // search with no case sensitive sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, output); - sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level); + sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); clif_displaymessage(fd, output); g = guild_search(pl_sd->status.guild_id); if (g == NULL) @@ -1884,30 +1884,30 @@ int atcommand_option( } sd->status.option = param3; // fix pecopeco display - if (sd->status.class == 13 || sd->status.class == 21 || sd->status.class == 4014 || sd->status.class == 4022) { + if (sd->status.class_ == 13 || sd->status.class_ == 21 || sd->status.class_ == 4014 || sd->status.class_ == 4022) { if (!pc_isriding(sd)) { // sd have the new value... - if (sd->status.class == 13) - sd->status.class = sd->view_class = 7; - else if (sd->status.class == 21) - sd->status.class = sd->view_class = 14; - else if (sd->status.class == 4014) - sd->status.class = sd->view_class = 4008; - else if (sd->status.class == 4022) - sd->status.class = sd->view_class = 4015; + if (sd->status.class_ == 13) + sd->status.class_ = sd->view_class = 7; + else if (sd->status.class_ == 21) + sd->status.class_ = sd->view_class = 14; + else if (sd->status.class_ == 4014) + sd->status.class_ = sd->view_class = 4008; + else if (sd->status.class_ == 4022) + sd->status.class_ = sd->view_class = 4015; } } else { if (pc_isriding(sd)) { // sd have the new value... if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor]) sd->status.option &= ~0x0020; } else { - if (sd->status.class == 7) - sd->status.class = sd->view_class = 13; - else if (sd->status.class == 14) - sd->status.class = sd->view_class = 21; - else if (sd->status.class == 4008) - sd->status.class = sd->view_class = 4014; - else if (sd->status.class == 4015) - sd->status.class = sd->view_class = 4022; + if (sd->status.class_ == 7) + sd->status.class_ = sd->view_class = 13; + else if (sd->status.class_ == 14) + sd->status.class_ = sd->view_class = 21; + else if (sd->status.class_ == 4008) + sd->status.class_ = sd->view_class = 4014; + else if (sd->status.class_ == 4015) + sd->status.class_ = sd->view_class = 4022; else sd->status.option &= ~0x0020; } @@ -2049,14 +2049,14 @@ int atcommand_jobchange( // fix pecopeco display if ((job != 13 && job != 21 && job != 4014 && job != 4022)) { if (pc_isriding(sd)) { - if (sd->status.class == 13) - sd->status.class = sd->view_class = 7; - if (sd->status.class == 21) - sd->status.class = sd->view_class = 14; - if (sd->status.class == 4014) - sd->status.class = sd->view_class = 4008; - if (sd->status.class == 4022) - sd->status.class = sd->view_class = 4015; + if (sd->status.class_ == 13) + sd->status.class_ = sd->view_class = 7; + if (sd->status.class_ == 21) + sd->status.class_ = sd->view_class = 14; + if (sd->status.class_ == 4014) + sd->status.class_ = sd->view_class = 4008; + if (sd->status.class_ == 4022) + sd->status.class_ = sd->view_class = 4015; sd->status.option &= ~0x0020; clif_changeoption(&sd->bl); pc_calcstatus(sd, 0); @@ -2280,9 +2280,9 @@ int atcommand_item( for (i = 0; i < number; i += get_count) { // if pet egg if (pet_id >= 0) { - sd->catch_target_class = pet_db[pet_id].class; + sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet(sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv, + pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); // if not pet egg @@ -2480,7 +2480,7 @@ int atcommand_joblevelup( int up_level = 50, level; struct pc_base_job s_class; nullpo_retr(-1, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); if (!message || !*message || (level = atoi(message)) == 0) { clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup )."); @@ -2492,7 +2492,7 @@ int atcommand_joblevelup( // super novices can go up to 99 [celest] else if (s_class.job == 23) up_level += 49; - else if (sd->status.class > 4007 && sd->status.class < 4023) + else if (sd->status.class_ > 4007 && sd->status.class_ < 4023) up_level += 20; if (level > 0) { @@ -2748,7 +2748,7 @@ int atcommand_model( hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR && cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) { //服の色変更 - if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) { + if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) { //服の色未実装職の判定 clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class. return -1; @@ -2814,7 +2814,7 @@ int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* } if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) { - if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) { + if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) { clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class. return -1; } else { @@ -2860,7 +2860,7 @@ int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* } if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) { - if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) { + if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) { clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class. return -1; } else { @@ -3976,10 +3976,10 @@ int atcommand_makeegg( if (pet_id < 0) pet_id = search_petDB_index(id, PET_EGG); if (pet_id >= 0) { - sd->catch_target_class = pet_db[pet_id].class; + sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet( sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv, + pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } else { @@ -4711,14 +4711,14 @@ int atcommand_character_joblevel( } if ((pl_sd = map_nick2sd(character)) != NULL) { - pl_s_class = pc_calc_base_job(pl_sd->status.class); + pl_s_class = pc_calc_base_job(pl_sd->status.class_); if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level if (pl_s_class.job == 0) max_level -= 40; // super novices can go up to 99 [celest] else if (pl_s_class.job == 23) max_level += 49; - else if (pl_sd->status.class > 4007 && pl_sd->status.class < 4023) + else if (pl_sd->status.class_ > 4007 && pl_sd->status.class_ < 4023) max_level += 20; if (level > 0) { @@ -5316,7 +5316,7 @@ int atcommand_charmodel( if (cloth_color != 0 && pl_sd->status.sex == 1 && - (pl_sd->status.class == 12 || pl_sd->status.class == 17)) { + (pl_sd->status.class_ == 12 || pl_sd->status.class_ == 17)) { clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class. return -1; } else { @@ -5782,7 +5782,7 @@ int atcommand_mapinfo( default: strcpy(direction, "Unknown"); break; } sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d", - ++i, nd->name, direction, nd->class, nd->bl.x, nd->bl.y); + ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y); clif_displaymessage(fd, output); } break; @@ -5826,15 +5826,15 @@ int atcommand_mount_peco( } if (!pc_isriding(sd)) { // if actually no peco - if (sd->status.class == 7 || sd->status.class == 14 || sd->status.class == 4008 || sd->status.class == 4015) { - if (sd->status.class == 7) - sd->status.class = sd->view_class = 13; - else if (sd->status.class == 14) - sd->status.class = sd->view_class = 21; - else if (sd->status.class == 4008) - sd->status.class = sd->view_class = 4014; - else if (sd->status.class == 4015) - sd->status.class = sd->view_class = 4022; + if (sd->status.class_ == 7 || sd->status.class_ == 14 || sd->status.class_ == 4008 || sd->status.class_ == 4015) { + if (sd->status.class_ == 7) + sd->status.class_ = sd->view_class = 13; + else if (sd->status.class_ == 14) + sd->status.class_ = sd->view_class = 21; + else if (sd->status.class_ == 4008) + sd->status.class_ = sd->view_class = 4014; + else if (sd->status.class_ == 4015) + sd->status.class_ = sd->view_class = 4022; pc_setoption(sd, sd->status.option | 0x0020); clif_displaymessage(fd, msg_table[102]); // Mounted Peco. } else { @@ -5842,14 +5842,14 @@ int atcommand_mount_peco( return -1; } } else { - if (sd->status.class == 13) - sd->status.class = sd->view_class = 7; - else if (sd->status.class == 21) - sd->status.class = sd->view_class = 14; - else if (sd->status.class == 4014) - sd->status.class = sd->view_class = 4008; - else if (sd->status.class == 4022) - sd->status.class = sd->view_class = 4015; + if (sd->status.class_ == 13) + sd->status.class_ = sd->view_class = 7; + else if (sd->status.class_ == 21) + sd->status.class_ = sd->view_class = 14; + else if (sd->status.class_ == 4014) + sd->status.class_ = sd->view_class = 4008; + else if (sd->status.class_ == 4022) + sd->status.class_ = sd->view_class = 4015; pc_setoption(sd, sd->status.option & ~0x0020); clif_displaymessage(fd, msg_table[214]); // Unmounted Peco. } @@ -5883,15 +5883,15 @@ int atcommand_char_mount_peco( } if (!pc_isriding(pl_sd)) { // if actually no peco - if (pl_sd->status.class == 7 || pl_sd->status.class == 14 || pl_sd->status.class == 4008 || pl_sd->status.class == 4015) { - if (pl_sd->status.class == 7) - pl_sd->status.class = pl_sd->view_class = 13; - else if (pl_sd->status.class == 14) - pl_sd->status.class = pl_sd->view_class = 21; - else if (pl_sd->status.class == 4008) - pl_sd->status.class = pl_sd->view_class = 4014; - else if (pl_sd->status.class == 4015) - pl_sd->status.class = pl_sd->view_class = 4022; + if (pl_sd->status.class_ == 7 || pl_sd->status.class_ == 14 || pl_sd->status.class_ == 4008 || pl_sd->status.class_ == 4015) { + if (pl_sd->status.class_ == 7) + pl_sd->status.class_ = pl_sd->view_class = 13; + else if (pl_sd->status.class_ == 14) + pl_sd->status.class_ = pl_sd->view_class = 21; + else if (pl_sd->status.class_ == 4008) + pl_sd->status.class_ = pl_sd->view_class = 4014; + else if (pl_sd->status.class_ == 4015) + pl_sd->status.class_ = pl_sd->view_class = 4022; pc_setoption(pl_sd, pl_sd->status.option | 0x0020); clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco. } else { @@ -5899,14 +5899,14 @@ int atcommand_char_mount_peco( return -1; } } else { - if (pl_sd->status.class == 13) - pl_sd->status.class = pl_sd->view_class = 7; - else if (pl_sd->status.class == 21) - pl_sd->status.class = pl_sd->view_class = 14; - else if (pl_sd->status.class == 4014) - pl_sd->status.class = pl_sd->view_class = 4008; - else if (pl_sd->status.class == 4022) - pl_sd->status.class = pl_sd->view_class = 4015; + if (pl_sd->status.class_ == 13) + pl_sd->status.class_ = pl_sd->view_class = 7; + else if (pl_sd->status.class_ == 21) + pl_sd->status.class_ = pl_sd->view_class = 14; + else if (pl_sd->status.class_ == 4014) + pl_sd->status.class_ = pl_sd->view_class = 4008; + else if (pl_sd->status.class_ == 4022) + pl_sd->status.class_ = pl_sd->view_class = 4015; pc_setoption(pl_sd, pl_sd->status.option & ~0x0020); clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco. } @@ -7175,7 +7175,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, if((pl_sd=map_nick2sd(target)) == NULL) return -1; - s_class = pc_calc_base_job(pl_sd->status.class); + s_class = pc_calc_base_job(pl_sd->status.class_); c = s_class.job; s = s_class.upper; @@ -7620,7 +7620,7 @@ atcommand_summon( if((md=(struct mob_data *)map_id2bl(id))){ md->master_id=sd->bl.id; md->state.special_mob_ai=1; - md->mode=mob_db[md->class].mode|0x04; + md->mode=mob_db[md->class_].mode|0x04; md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0); clif_misceffect2(&md->bl,344); } @@ -7894,7 +7894,7 @@ atcommand_petid(const int fd, struct map_session_data* sd, strcpy(temp0,pet_db[i].jname); strcpy(temp0, estr_lower(temp1)); if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) { - snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class, + snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_, pet_db[i].jname); if (cnt >= 100) { // Only if there are custom pets clif_displaymessage(fd, "Be more specific, can't send more than" diff --git a/src/map/battle.c b/src/map/battle.c index 1d699bd10..f59c179b5 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -64,11 +64,11 @@ int battle_get_class(struct block_list *bl) { nullpo_retr(0, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return ((struct mob_data *)bl)->class; + return ((struct mob_data *)bl)->class_; else if(bl->type==BL_PC && (struct map_session_data *)bl) - return ((struct map_session_data *)bl)->status.class; + return ((struct map_session_data *)bl)->status.class_; else if(bl->type==BL_PET && (struct pet_data *)bl) - return ((struct pet_data *)bl)->class; + return ((struct pet_data *)bl)->class_; else return 0; } @@ -115,11 +115,11 @@ int battle_get_range(struct block_list *bl) { nullpo_retr(0, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].range; + return mob_db[((struct mob_data *)bl)->class_].range; else if(bl->type==BL_PC && (struct map_session_data *)bl) return ((struct map_session_data *)bl)->attackrange; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].range; + return mob_db[((struct pet_data *)bl)->class_].range; else return 0; } @@ -152,10 +152,10 @@ int battle_get_max_hp(struct block_list *bl) struct status_change *sc_data=battle_get_sc_data(bl); int max_hp=1; if(bl->type==BL_MOB && ((struct mob_data*)bl)) { - max_hp = mob_db[((struct mob_data*)bl)->class].max_hp; + max_hp = mob_db[((struct mob_data*)bl)->class_].max_hp; if(battle_config.mobs_level_up) // mobs leveling up increase [Valaris] - max_hp+=(((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv)*battle_get_vit(bl); - if(mob_db[((struct mob_data*)bl)->class].mexp > 0) { + max_hp+=(((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv)*battle_get_vit(bl); + if(mob_db[((struct mob_data*)bl)->class_].mexp > 0) { if(battle_config.mvp_hp_rate != 100) max_hp = (max_hp * battle_config.mvp_hp_rate)/100; } @@ -165,8 +165,8 @@ int battle_get_max_hp(struct block_list *bl) } } else if(bl->type==BL_PET && ((struct pet_data*)bl)) { - max_hp = mob_db[((struct pet_data*)bl)->class].max_hp; - if(mob_db[((struct pet_data*)bl)->class].mexp > 0) { + max_hp = mob_db[((struct pet_data*)bl)->class_].max_hp; + if(mob_db[((struct pet_data*)bl)->class_].mexp > 0) { if(battle_config.mvp_hp_rate != 100) max_hp = (max_hp * battle_config.mvp_hp_rate)/100; } @@ -198,14 +198,14 @@ int battle_get_str(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && ((struct mob_data *)bl)) { - str = mob_db[((struct mob_data *)bl)->class].str; + str = mob_db[((struct mob_data *)bl)->class_].str; if(battle_config.mobs_level_up) // mobs leveling up increase [Valaris] - str+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + str+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && ((struct map_session_data *)bl)) return ((struct map_session_data *)bl)->paramc[0]; else if(bl->type==BL_PET && ((struct pet_data *)bl)) - str = mob_db[((struct pet_data *)bl)->class].str; + str = mob_db[((struct pet_data *)bl)->class_].str; if(sc_data) { if(sc_data[SC_LOUD].timer!=-1 && sc_data[SC_QUAGMIRE].timer == -1 && bl->type != BL_PC) @@ -235,14 +235,14 @@ int battle_get_agi(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl) { - agi=mob_db[((struct mob_data *)bl)->class].agi; + agi=mob_db[((struct mob_data *)bl)->class_].agi; if(battle_config.mobs_level_up) // increase of mobs leveling up [Valaris] - agi+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + agi+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) agi=((struct map_session_data *)bl)->paramc[1]; else if(bl->type==BL_PET && (struct pet_data *)bl) - agi=mob_db[((struct pet_data *)bl)->class].agi; + agi=mob_db[((struct pet_data *)bl)->class_].agi; if(sc_data) { if( sc_data[SC_INCREASEAGI].timer!=-1 && sc_data[SC_QUAGMIRE].timer == -1 && sc_data[SC_DONTFORGETME].timer == -1 && @@ -280,14 +280,14 @@ int battle_get_vit(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl) { - vit=mob_db[((struct mob_data *)bl)->class].vit; + vit=mob_db[((struct mob_data *)bl)->class_].vit; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - vit+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + vit+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) vit=((struct map_session_data *)bl)->paramc[2]; else if(bl->type==BL_PET && (struct pet_data *)bl) - vit=mob_db[((struct pet_data *)bl)->class].vit; + vit=mob_db[((struct pet_data *)bl)->class_].vit; if(sc_data) { if(sc_data[SC_STRIPARMOR].timer != -1 && bl->type!=BL_PC) vit = vit*60/100; @@ -311,14 +311,14 @@ int battle_get_int(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl){ - int_=mob_db[((struct mob_data *)bl)->class].int_; + int_=mob_db[((struct mob_data *)bl)->class_].int_; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - int_+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + int_+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) int_=((struct map_session_data *)bl)->paramc[3]; else if(bl->type==BL_PET && (struct pet_data *)bl) - int_=mob_db[((struct pet_data *)bl)->class].int_; + int_=mob_db[((struct pet_data *)bl)->class_].int_; if(sc_data) { if( sc_data[SC_BLESSING].timer != -1 && bl->type != BL_PC){ // ブレッシング @@ -347,14 +347,14 @@ int battle_get_dex(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl) { - dex=mob_db[((struct mob_data *)bl)->class].dex; + dex=mob_db[((struct mob_data *)bl)->class_].dex; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - dex+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + dex+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) dex=((struct map_session_data *)bl)->paramc[4]; else if(bl->type==BL_PET && (struct pet_data *)bl) - dex=mob_db[((struct pet_data *)bl)->class].dex; + dex=mob_db[((struct pet_data *)bl)->class_].dex; if(sc_data) { if(sc_data[SC_CONCENTRATE].timer!=-1 && sc_data[SC_QUAGMIRE].timer == -1 && bl->type != BL_PC) @@ -391,14 +391,14 @@ int battle_get_luk(struct block_list *bl) nullpo_retr(0, bl); sc_data=battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl) { - luk=mob_db[((struct mob_data *)bl)->class].luk; + luk=mob_db[((struct mob_data *)bl)->class_].luk; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - luk+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + luk+=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PC && (struct map_session_data *)bl) luk=((struct map_session_data *)bl)->paramc[5]; else if(bl->type==BL_PET && (struct pet_data *)bl) - luk=mob_db[((struct pet_data *)bl)->class].luk; + luk=mob_db[((struct pet_data *)bl)->class_].luk; if(sc_data) { if(sc_data[SC_GLORIA].timer!=-1 && bl->type != BL_PC) // グロリア(PCはpc.cで) @@ -580,9 +580,9 @@ int battle_get_atk(struct block_list *bl) if(bl->type==BL_PC && (struct map_session_data *)bl) atk = ((struct map_session_data*)bl)->watk; else if(bl->type==BL_MOB && (struct mob_data *)bl) - atk = mob_db[((struct mob_data*)bl)->class].atk1; + atk = mob_db[((struct mob_data*)bl)->class_].atk1; else if(bl->type==BL_PET && (struct pet_data *)bl) - atk = mob_db[((struct pet_data*)bl)->class].atk1; + atk = mob_db[((struct pet_data*)bl)->class_].atk1; if(sc_data) { if(sc_data[SC_PROVOKE].timer!=-1 && bl->type != BL_PC) @@ -627,9 +627,9 @@ int battle_get_atk2(struct block_list *bl) struct status_change *sc_data=battle_get_sc_data(bl); int atk2=0; if(bl->type==BL_MOB && (struct mob_data *)bl) - atk2 = mob_db[((struct mob_data*)bl)->class].atk2; + atk2 = mob_db[((struct mob_data*)bl)->class_].atk2; else if(bl->type==BL_PET && (struct pet_data *)bl) - atk2 = mob_db[((struct pet_data*)bl)->class].atk2; + atk2 = mob_db[((struct pet_data*)bl)->class_].atk2; if(sc_data) { if( sc_data[SC_IMPOSITIO].timer!=-1) atk2 += sc_data[SC_IMPOSITIO].val1*5; @@ -746,12 +746,12 @@ int battle_get_def(struct block_list *bl) skillid = ((struct map_session_data *)bl)->skillid; } else if(bl->type==BL_MOB && (struct mob_data *)bl) { - def = mob_db[((struct mob_data *)bl)->class].def; + def = mob_db[((struct mob_data *)bl)->class_].def; skilltimer = ((struct mob_data *)bl)->skilltimer; skillid = ((struct mob_data *)bl)->skillid; } else if(bl->type==BL_PET && (struct pet_data *)bl) - def = mob_db[((struct pet_data *)bl)->class].def; + def = mob_db[((struct pet_data *)bl)->class_].def; if(def < 1000000) { if(sc_data) { @@ -808,9 +808,9 @@ int battle_get_mdef(struct block_list *bl) if(bl->type==BL_PC && (struct map_session_data *)bl) mdef = ((struct map_session_data *)bl)->mdef; else if(bl->type==BL_MOB && (struct mob_data *)bl) - mdef = mob_db[((struct mob_data *)bl)->class].mdef; + mdef = mob_db[((struct mob_data *)bl)->class_].mdef; else if(bl->type==BL_PET && (struct pet_data *)bl) - mdef = mob_db[((struct pet_data *)bl)->class].mdef; + mdef = mob_db[((struct pet_data *)bl)->class_].mdef; if(mdef < 1000000) { if(sc_data) { @@ -842,9 +842,9 @@ int battle_get_def2(struct block_list *bl) if(bl->type==BL_PC) def2 = ((struct map_session_data *)bl)->def2; else if(bl->type==BL_MOB) - def2 = mob_db[((struct mob_data *)bl)->class].vit; + def2 = mob_db[((struct mob_data *)bl)->class_].vit; else if(bl->type==BL_PET) - def2 = mob_db[((struct pet_data *)bl)->class].vit; + def2 = mob_db[((struct pet_data *)bl)->class_].vit; if(sc_data) { if( sc_data[SC_ANGELUS].timer!=-1 && bl->type != BL_PC) @@ -872,11 +872,11 @@ int battle_get_mdef2(struct block_list *bl) nullpo_retr(0, bl); if(bl->type==BL_MOB) - mdef2 = mob_db[((struct mob_data *)bl)->class].int_ + (mob_db[((struct mob_data *)bl)->class].vit>>1); + mdef2 = mob_db[((struct mob_data *)bl)->class_].int_ + (mob_db[((struct mob_data *)bl)->class_].vit>>1); else if(bl->type==BL_PC) mdef2 = ((struct map_session_data *)bl)->mdef2 + (((struct map_session_data *)bl)->paramc[2]>>1); else if(bl->type==BL_PET) - mdef2 = mob_db[((struct pet_data *)bl)->class].int_ + (mob_db[((struct pet_data *)bl)->class].vit>>1); + mdef2 = mob_db[((struct pet_data *)bl)->class_].int_ + (mob_db[((struct pet_data *)bl)->class_].vit>>1); if(sc_data) { if( sc_data[SC_MINDBREAKER].timer!=-1 && bl->type != BL_PC) mdef2 -= (mdef2*6*sc_data[SC_MINDBREAKER].val1)/100; @@ -901,7 +901,7 @@ int battle_get_speed(struct block_list *bl) if(bl->type==BL_MOB && (struct mob_data *)bl) { speed = ((struct mob_data *)bl)->speed; if(battle_config.mobs_level_up) // increase from mobs leveling up [Valaris] - speed-=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class].lv; + speed-=((struct mob_data *)bl)->level - mob_db[((struct mob_data *)bl)->class_].lv; } else if(bl->type==BL_PET && (struct pet_data *)bl) speed = ((struct pet_data *)bl)->msd->petDB->speed; @@ -960,9 +960,9 @@ int battle_get_adelay(struct block_list *bl) struct status_change *sc_data=battle_get_sc_data(bl); int adelay=4000,aspd_rate = 100,i; if(bl->type==BL_MOB && (struct mob_data *)bl) - adelay = mob_db[((struct mob_data *)bl)->class].adelay; + adelay = mob_db[((struct mob_data *)bl)->class_].adelay; else if(bl->type==BL_PET && (struct pet_data *)bl) - adelay = mob_db[((struct pet_data *)bl)->class].adelay; + adelay = mob_db[((struct pet_data *)bl)->class_].adelay; if(sc_data) { //ツーハンドクイッケン使用時でクァグマイアでも私を忘れないで…でもない時は3割減算 @@ -1016,9 +1016,9 @@ int battle_get_amotion(struct block_list *bl) struct status_change *sc_data=battle_get_sc_data(bl); int amotion=2000,aspd_rate = 100,i; if(bl->type==BL_MOB && (struct mob_data *)bl) - amotion = mob_db[((struct mob_data *)bl)->class].amotion; + amotion = mob_db[((struct mob_data *)bl)->class_].amotion; else if(bl->type==BL_PET && (struct pet_data *)bl) - amotion = mob_db[((struct pet_data *)bl)->class].amotion; + amotion = mob_db[((struct pet_data *)bl)->class_].amotion; if(sc_data) { if(sc_data[SC_TWOHANDQUICKEN].timer != -1 && sc_data[SC_QUAGMIRE].timer == -1 && sc_data[SC_DONTFORGETME].timer == -1) // 2HQ @@ -1061,7 +1061,7 @@ int battle_get_dmotion(struct block_list *bl) nullpo_retr(0, bl); sc_data = battle_get_sc_data(bl); if(bl->type==BL_MOB && (struct mob_data *)bl){ - ret=mob_db[((struct mob_data *)bl)->class].dmotion; + ret=mob_db[((struct mob_data *)bl)->class_].dmotion; if(battle_config.monster_damage_delay_rate != 100) ret = ret*battle_config.monster_damage_delay_rate/400; } @@ -1071,7 +1071,7 @@ int battle_get_dmotion(struct block_list *bl) ret = ret*battle_config.pc_damage_delay_rate/400; } else if(bl->type==BL_PET && (struct pet_data *)bl) - ret=mob_db[((struct pet_data *)bl)->class].dmotion; + ret=mob_db[((struct pet_data *)bl)->class_].dmotion; else return 2000; @@ -1093,7 +1093,7 @@ int battle_get_element(struct block_list *bl) else if(bl->type==BL_PC && (struct map_session_data *)bl) ret=20+((struct map_session_data *)bl)->def_ele; // 防御属性Lv1 else if(bl->type==BL_PET && (struct pet_data *)bl) - ret = mob_db[((struct pet_data *)bl)->class].element; + ret = mob_db[((struct pet_data *)bl)->class_].element; if(sc_data) { if( sc_data[SC_BENEDICTIO].timer!=-1 ) // 聖体降福 @@ -1183,7 +1183,7 @@ int battle_get_guild_id(struct block_list *bl) if(bl->type==BL_PC && (struct map_session_data *)bl) return ((struct map_session_data *)bl)->status.guild_id; else if(bl->type==BL_MOB && (struct mob_data *)bl) - return ((struct mob_data *)bl)->class; + return ((struct mob_data *)bl)->class_; else if(bl->type==BL_SKILL && (struct skill_unit *)bl) return ((struct skill_unit *)bl)->group->guild_id; else @@ -1193,11 +1193,11 @@ int battle_get_race(struct block_list *bl) { nullpo_retr(0, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].race; + return mob_db[((struct mob_data *)bl)->class_].race; else if(bl->type==BL_PC && (struct map_session_data *)bl) return 7; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].race; + return mob_db[((struct pet_data *)bl)->class_].race; else return 0; } @@ -1205,11 +1205,11 @@ int battle_get_size(struct block_list *bl) { nullpo_retr(1, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].size; + return mob_db[((struct mob_data *)bl)->class_].size; else if(bl->type==BL_PC && (struct map_session_data *)bl) return 1; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].size; + return mob_db[((struct pet_data *)bl)->class_].size; else return 1; } @@ -1217,9 +1217,9 @@ int battle_get_mode(struct block_list *bl) { nullpo_retr(0x01, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].mode; + return mob_db[((struct mob_data *)bl)->class_].mode; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].mode; + return mob_db[((struct pet_data *)bl)->class_].mode; else return 0x01; // とりあえず動くということで1 } @@ -1228,9 +1228,9 @@ int battle_get_mexp(struct block_list *bl) { nullpo_retr(0, bl); if(bl->type==BL_MOB && (struct mob_data *)bl) - return mob_db[((struct mob_data *)bl)->class].mexp; + return mob_db[((struct mob_data *)bl)->class_].mexp; else if(bl->type==BL_PET && (struct pet_data *)bl) - return mob_db[((struct pet_data *)bl)->class].mexp; + return mob_db[((struct pet_data *)bl)->class_].mexp; else return 0; } @@ -1914,7 +1914,7 @@ static struct Damage battle_calc_pet_weapon_attack( atkmin = battle_get_atk(src); atkmax = battle_get_atk2(src); } - if(mob_db[pd->class].range>3 ) + if(mob_db[pd->class_].range>3 ) flag=(flag&~BF_RANGEMASK)|BF_LONG; if(atkmin > atkmax) atkmin = atkmax; @@ -2375,7 +2375,7 @@ static struct Damage battle_calc_mob_weapon_attack( atkmin = battle_get_atk(src); atkmax = battle_get_atk2(src); } - if(mob_db[md->class].range>3 ) + if(mob_db[md->class_].range>3 ) flag=(flag&~BF_RANGEMASK)|BF_LONG; if(atkmin > atkmax) atkmin = atkmax; @@ -2722,12 +2722,12 @@ static struct Damage battle_calc_mob_weapon_attack( int cardfix=100,i; cardfix=cardfix*(100-tsd->subele[s_ele])/100; // 属 性によるダメージ耐性 cardfix=cardfix*(100-tsd->subrace[s_race])/100; // 種族によるダメージ耐性 - if(mob_db[md->class].mode & 0x20) + if(mob_db[md->class_].mode & 0x20) cardfix=cardfix*(100-tsd->subrace[10])/100; else cardfix=cardfix*(100-tsd->subrace[11])/100; for(i=0;iadd_def_class_count;i++) { - if(tsd->add_def_classid[i] == md->class) { + if(tsd->add_def_classid[i] == md->class_) { cardfix=cardfix*(100-tsd->add_def_classrate[i])/100; break; } @@ -3798,7 +3798,7 @@ static struct Damage battle_calc_pc_weapon_attack( cardfix=cardfix*(100-tsd->subrace[11])/100; //ボス以外からの攻撃はダメージ減少 //特定Class用補正処理左手(少女の日記→ボンゴン用?) for(i=0;iadd_def_class_count;i++) { - if(tsd->add_def_classid[i] == sd->status.class) { + if(tsd->add_def_classid[i] == sd->status.class_) { cardfix=cardfix*(100-tsd->add_def_classrate[i])/100; break; } @@ -4984,7 +4984,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if(su && su->group->target_flag==BCT_NOENEMY) return 1; else if (battle_config.pk_mode && - (((struct map_session_data*)ss)->status.class==0 || ((struct map_session_data*)target)->status.class==0 || + (((struct map_session_data*)ss)->status.class_==0 || ((struct map_session_data*)target)->status.class_==0 || ((struct map_session_data*)ss)->status.base_level < battle_config.pk_min_level || ((struct map_session_data*)target)->status.base_level < battle_config.pk_min_level)) return 1; // prevent novice engagement in pk_mode [Valaris] diff --git a/src/map/charcommand.c b/src/map/charcommand.c index f8e3be983..1ced08777 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -309,14 +309,14 @@ int charcommand_jobchange( // fix pecopeco display if ((job != 13 && job != 21 && job != 4014 && job != 4022)) { if (pc_isriding(sd)) { - if (pl_sd->status.class == 13) - pl_sd->status.class = pl_sd->view_class = 7; - if (pl_sd->status.class == 21) - pl_sd->status.class = pl_sd->view_class = 14; - if (pl_sd->status.class == 4014) - pl_sd->status.class = pl_sd->view_class = 4008; - if (pl_sd->status.class == 4022) - pl_sd->status.class = pl_sd->view_class = 4015; + if (pl_sd->status.class_ == 13) + pl_sd->status.class_ = pl_sd->view_class = 7; + if (pl_sd->status.class_ == 21) + pl_sd->status.class_ = pl_sd->view_class = 14; + if (pl_sd->status.class_ == 4014) + pl_sd->status.class_ = pl_sd->view_class = 4008; + if (pl_sd->status.class_ == 4022) + pl_sd->status.class_ = pl_sd->view_class = 4015; pl_sd->status.option &= ~0x0020; clif_changeoption(&pl_sd->bl); pc_calcstatus(pl_sd, 0); @@ -502,7 +502,7 @@ int charcommand_stats( { "Zeny - %d", pl_sd->status.zeny }, { NULL, 0 } }; - sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class), "(level %d)"); + sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class_), "(level %d)"); sprintf(output, msg_table[53], pl_sd->status.name); // '%s' stats: clif_displaymessage(fd, output); for (i = 0; output_table[i].format != NULL; i++) { @@ -582,30 +582,30 @@ int charcommand_option( pl_sd->opt2 = opt2; pl_sd->status.option = opt3; // fix pecopeco display - if (pl_sd->status.class == 13 || pl_sd->status.class == 21 || pl_sd->status.class == 4014 || pl_sd->status.class == 4022) { + if (pl_sd->status.class_ == 13 || pl_sd->status.class_ == 21 || pl_sd->status.class_ == 4014 || pl_sd->status.class_ == 4022) { if (!pc_isriding(pl_sd)) { // pl_sd have the new value... - if (pl_sd->status.class == 13) - pl_sd->status.class = pl_sd->view_class = 7; - else if (pl_sd->status.class == 21) - pl_sd->status.class = pl_sd->view_class = 14; - else if (pl_sd->status.class == 4014) - pl_sd->status.class = pl_sd->view_class = 4008; - else if (pl_sd->status.class == 4022) - pl_sd->status.class = pl_sd->view_class = 4015; + if (pl_sd->status.class_ == 13) + pl_sd->status.class_ = pl_sd->view_class = 7; + else if (pl_sd->status.class_ == 21) + pl_sd->status.class_ = pl_sd->view_class = 14; + else if (pl_sd->status.class_ == 4014) + pl_sd->status.class_ = pl_sd->view_class = 4008; + else if (pl_sd->status.class_ == 4022) + pl_sd->status.class_ = pl_sd->view_class = 4015; } } else { if (pc_isriding(pl_sd)) { // pl_sd have the new value... if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor]) pl_sd->status.option &= ~0x0020; } else { - if (pl_sd->status.class == 7) - pl_sd->status.class = pl_sd->view_class = 13; - else if (pl_sd->status.class == 14) - pl_sd->status.class = pl_sd->view_class = 21; - else if (pl_sd->status.class == 4008) - pl_sd->status.class = pl_sd->view_class = 4014; - else if (pl_sd->status.class == 4015) - pl_sd->status.class = pl_sd->view_class = 4022; + if (pl_sd->status.class_ == 7) + pl_sd->status.class_ = pl_sd->view_class = 13; + else if (pl_sd->status.class_ == 14) + pl_sd->status.class_ = pl_sd->view_class = 21; + else if (pl_sd->status.class_ == 4008) + pl_sd->status.class_ = pl_sd->view_class = 4014; + else if (pl_sd->status.class_ == 4015) + pl_sd->status.class_ = pl_sd->view_class = 4022; else pl_sd->status.option &= ~0x0020; } @@ -701,7 +701,7 @@ int charcommand_stats_all(const int fd, struct map_session_data* sd, const char* else sprintf(gmlevel, " "); - sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp); + sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp); clif_displaymessage(fd, output); sprintf(output, "STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s", pl_sd->status.str, pl_sd->status.agi, pl_sd->status.vit, pl_sd->status.int_, pl_sd->status.dex, pl_sd->status.luk, pl_sd->status.zeny, gmlevel); clif_displaymessage(fd, output); @@ -1061,9 +1061,9 @@ int charcommand_item( for (i = 0; i < number; i += get_count) { // if pet egg if (pet_id >= 0) { - sd->catch_target_class = pet_db[pet_id].class; + sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet(sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv, + pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); // if not pet egg diff --git a/src/map/chrif.c b/src/map/chrif.c index 353533561..c04630300 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -606,7 +606,7 @@ int chrif_changedsex(int fd) sd = map_id2sd(acc); if (acc > 0) { if (sd != NULL && sd->status.sex != sex) { - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); if (sd->status.sex == 0) { sd->status.sex = 1; sd->sex = 1; @@ -641,9 +641,9 @@ int chrif_changedsex(int fd) clif_updatestatus(sd, SP_SKILLPOINT); // change job if necessary if (s_class.job == 20 || s_class.job == 4021 || s_class.job == 4043) - sd->status.class -= 1; + sd->status.class_ -= 1; else if (s_class.job == 19 || s_class.job == 4020 || s_class.job == 4042) - sd->status.class += 1; + sd->status.class_ += 1; } // save character chrif_save(sd); diff --git a/src/map/clif.c b/src/map/clif.c index 28cc58fcf..0f4746251 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -973,21 +973,21 @@ static int clif_mob0078(struct mob_data *md, unsigned char *buf) WBUFW(buf,8)=md->opt1; WBUFW(buf,10)=md->opt2; WBUFW(buf,12)=md->option; - WBUFW(buf,14)=mob_get_viewclass(md->class); - if((mob_get_viewclass(md->class) <= 23) || (mob_get_viewclass(md->class) == 812) || (mob_get_viewclass(md->class) >= 4001)) { - WBUFW(buf,12)|=mob_db[md->class].option; - WBUFW(buf,16)=mob_get_hair(md->class); - WBUFW(buf,18)=mob_get_weapon(md->class); - WBUFW(buf,20)=mob_get_head_buttom(md->class); - WBUFW(buf,22)=mob_get_shield(md->class); - WBUFW(buf,24)=mob_get_head_top(md->class); - WBUFW(buf,26)=mob_get_head_mid(md->class); - WBUFW(buf,28)=mob_get_hair_color(md->class); - WBUFW(buf,30)=mob_get_clothes_color(md->class); //Add for player monster dye - Valaris - WBUFB(buf,45)=mob_get_sex(md->class); - } - - if (md->class >= 1285 && md->class <= 1287 && md->guild_id) { // Added guardian emblems [Valaris] + WBUFW(buf,14)=mob_get_viewclass(md->class_); + if((mob_get_viewclass(md->class_) <= 23) || (mob_get_viewclass(md->class_) == 812) || (mob_get_viewclass(md->class_) >= 4001)) { + WBUFW(buf,12)|=mob_db[md->class_].option; + WBUFW(buf,16)=mob_get_hair(md->class_); + WBUFW(buf,18)=mob_get_weapon(md->class_); + WBUFW(buf,20)=mob_get_head_buttom(md->class_); + WBUFW(buf,22)=mob_get_shield(md->class_); + WBUFW(buf,24)=mob_get_head_top(md->class_); + WBUFW(buf,26)=mob_get_head_mid(md->class_); + WBUFW(buf,28)=mob_get_hair_color(md->class_); + WBUFW(buf,30)=mob_get_clothes_color(md->class_); //Add for player monster dye - Valaris + WBUFB(buf,45)=mob_get_sex(md->class_); + } + + if (md->class_ >= 1285 && md->class_ <= 1287 && md->guild_id) { // Added guardian emblems [Valaris] struct guild *g; struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if (gc && gc->guild_id > 0) { @@ -1025,23 +1025,23 @@ static int clif_mob007b(struct mob_data *md, unsigned char *buf) { WBUFW(buf,8)=md->opt1; WBUFW(buf,10)=md->opt2; WBUFW(buf,12)=md->option; - WBUFW(buf,14)=mob_get_viewclass(md->class); - if ((mob_get_viewclass(md->class) < 24) || (mob_get_viewclass(md->class) > 4000)) { - WBUFW(buf,12)|=mob_db[md->class].option; - WBUFW(buf,16)=mob_get_hair(md->class); - WBUFW(buf,18)=mob_get_weapon(md->class); - WBUFW(buf,20)=mob_get_head_buttom(md->class); + WBUFW(buf,14)=mob_get_viewclass(md->class_); + if ((mob_get_viewclass(md->class_) < 24) || (mob_get_viewclass(md->class_) > 4000)) { + WBUFW(buf,12)|=mob_db[md->class_].option; + WBUFW(buf,16)=mob_get_hair(md->class_); + WBUFW(buf,18)=mob_get_weapon(md->class_); + WBUFW(buf,20)=mob_get_head_buttom(md->class_); WBUFL(buf,22)=gettick(); - WBUFW(buf,26)=mob_get_shield(md->class); - WBUFW(buf,28)=mob_get_head_top(md->class); - WBUFW(buf,30)=mob_get_head_mid(md->class); - WBUFW(buf,32)=mob_get_hair_color(md->class); - WBUFW(buf,34)=mob_get_clothes_color(md->class); //Add for player monster dye - Valaris - WBUFB(buf,49)=mob_get_sex(md->class); + WBUFW(buf,26)=mob_get_shield(md->class_); + WBUFW(buf,28)=mob_get_head_top(md->class_); + WBUFW(buf,30)=mob_get_head_mid(md->class_); + WBUFW(buf,32)=mob_get_hair_color(md->class_); + WBUFW(buf,34)=mob_get_clothes_color(md->class_); //Add for player monster dye - Valaris + WBUFB(buf,49)=mob_get_sex(md->class_); } else WBUFL(buf,22)=gettick(); - if(md->class >= 1285 && md->class <= 1287 && md->guild_id) { // Added guardian emblems [Valaris] + if(md->class_ >= 1285 && md->class_ <= 1287 && md->guild_id) { // Added guardian emblems [Valaris] struct guild *g; struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc && gc->guild_id > 0){ @@ -1075,8 +1075,8 @@ static int clif_npc0078(struct npc_data *nd, unsigned char *buf) { WBUFW(buf,0)=0x78; WBUFL(buf,2)=nd->bl.id; WBUFW(buf,6)=nd->speed; - WBUFW(buf,14)=nd->class; - if ((nd->class == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) { + WBUFW(buf,14)=nd->class_; + if ((nd->class_ == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) { WBUFL(buf,22)=g->emblem_id; WBUFL(buf,26)=g->guild_id; } @@ -1099,8 +1099,8 @@ static int clif_npc007b(struct npc_data *nd, unsigned char *buf) { WBUFW(buf,0)=0x7b; WBUFL(buf,2)=nd->bl.id; WBUFW(buf,6)=nd->speed; - WBUFW(buf,14)=nd->class; - if ((nd->class == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) { + WBUFW(buf,14)=nd->class_; + if ((nd->class_ == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL)) { WBUFL(buf,22)=g->emblem_id; WBUFL(buf,26)=g->guild_id; } @@ -1127,18 +1127,18 @@ static int clif_pet0078(struct pet_data *pd, unsigned char *buf) { WBUFW(buf,0)=0x78; WBUFL(buf,2)=pd->bl.id; WBUFW(buf,6)=pd->speed; - WBUFW(buf,14)=mob_get_viewclass(pd->class); - if((mob_get_viewclass(pd->class) < 24) || (mob_get_viewclass(pd->class) > 4000)) { - WBUFW(buf,12)=mob_db[pd->class].option; - WBUFW(buf,16)=mob_get_hair(pd->class); - WBUFW(buf,18)=mob_get_weapon(pd->class); - WBUFW(buf,20)=mob_get_head_buttom(pd->class); - WBUFW(buf,22)=mob_get_shield(pd->class); - WBUFW(buf,24)=mob_get_head_top(pd->class); - WBUFW(buf,26)=mob_get_head_mid(pd->class); - WBUFW(buf,28)=mob_get_hair_color(pd->class); - WBUFW(buf,30)=mob_get_clothes_color(pd->class); //Add for player pet dye - Valaris - WBUFB(buf,45)=mob_get_sex(pd->class); + WBUFW(buf,14)=mob_get_viewclass(pd->class_); + if((mob_get_viewclass(pd->class_) < 24) || (mob_get_viewclass(pd->class_) > 4000)) { + WBUFW(buf,12)=mob_db[pd->class_].option; + WBUFW(buf,16)=mob_get_hair(pd->class_); + WBUFW(buf,18)=mob_get_weapon(pd->class_); + WBUFW(buf,20)=mob_get_head_buttom(pd->class_); + WBUFW(buf,22)=mob_get_shield(pd->class_); + WBUFW(buf,24)=mob_get_head_top(pd->class_); + WBUFW(buf,26)=mob_get_head_mid(pd->class_); + WBUFW(buf,28)=mob_get_hair_color(pd->class_); + WBUFW(buf,30)=mob_get_clothes_color(pd->class_); //Add for player pet dye - Valaris + WBUFB(buf,45)=mob_get_sex(pd->class_); } else { WBUFW(buf,16)=0x14; if((view = itemdb_viewid(pd->equip)) > 0) @@ -1169,19 +1169,19 @@ static int clif_pet007b(struct pet_data *pd, unsigned char *buf) { WBUFW(buf,0)=0x7b; WBUFL(buf,2)=pd->bl.id; WBUFW(buf,6)=pd->speed; - WBUFW(buf,14)=mob_get_viewclass(pd->class); - if((mob_get_viewclass(pd->class) < 24) || (mob_get_viewclass(pd->class) > 4000)) { - WBUFW(buf,12)=mob_db[pd->class].option; - WBUFW(buf,16)=mob_get_hair(pd->class); - WBUFW(buf,18)=mob_get_weapon(pd->class); - WBUFW(buf,20)=mob_get_head_buttom(pd->class); + WBUFW(buf,14)=mob_get_viewclass(pd->class_); + if((mob_get_viewclass(pd->class_) < 24) || (mob_get_viewclass(pd->class_) > 4000)) { + WBUFW(buf,12)=mob_db[pd->class_].option; + WBUFW(buf,16)=mob_get_hair(pd->class_); + WBUFW(buf,18)=mob_get_weapon(pd->class_); + WBUFW(buf,20)=mob_get_head_buttom(pd->class_); WBUFL(buf,22)=gettick(); - WBUFW(buf,26)=mob_get_shield(pd->class); - WBUFW(buf,28)=mob_get_head_top(pd->class); - WBUFW(buf,30)=mob_get_head_mid(pd->class); - WBUFW(buf,32)=mob_get_hair_color(pd->class); - WBUFW(buf,34)=mob_get_clothes_color(pd->class); //Add for player pet dye - Valaris - WBUFB(buf,49)=mob_get_sex(pd->class); + WBUFW(buf,26)=mob_get_shield(pd->class_); + WBUFW(buf,28)=mob_get_head_top(pd->class_); + WBUFW(buf,30)=mob_get_head_mid(pd->class_); + WBUFW(buf,32)=mob_get_hair_color(pd->class_); + WBUFW(buf,34)=mob_get_clothes_color(pd->class_); //Add for player pet dye - Valaris + WBUFB(buf,49)=mob_get_sex(pd->class_); } else { WBUFW(buf,16)=0x14; if ((view = itemdb_viewid(pd->equip)) > 0) @@ -1285,11 +1285,11 @@ int clif_spawnpc(struct map_session_data *sd) { clif_guild_emblem(sd,g); } // end addition [Valaris] - if (sd->status.class==13 || sd->status.class==21 || sd->status.class==4014 || sd->status.class==4022) + if (sd->status.class_==13 || sd->status.class_==21 || sd->status.class_==4014 || sd->status.class_==4022) pc_setoption(sd,sd->status.option|0x0020); // [Valaris] - if ((pc_isriding(sd) && pc_checkskill(sd,KN_RIDING)>0) && (sd->status.class==7 || - sd->status.class==14 || sd->status.class==4008 || sd->status.class==4015)) + if ((pc_isriding(sd) && pc_checkskill(sd,KN_RIDING)>0) && (sd->status.class_==7 || + sd->status.class_==14 || sd->status.class_==4008 || sd->status.class_==4015)) pc_setriding(sd); // update peco riders for people upgrading athena [Valaris] @@ -1318,7 +1318,7 @@ int clif_spawnnpc(struct npc_data *nd) nullpo_retr(0, nd); - if(nd->class < 0 || nd->flag&1 || nd->class == INVISIBLE_CLASS) + if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS) return 0; memset(buf,0,packet_len_table[0x7c]); @@ -1326,7 +1326,7 @@ int clif_spawnnpc(struct npc_data *nd) WBUFW(buf,0)=0x7c; WBUFL(buf,2)=nd->bl.id; WBUFW(buf,6)=nd->speed; - WBUFW(buf,20)=nd->class; + WBUFW(buf,20)=nd->class_; WBUFPOS(buf,36,nd->bl.x,nd->bl.y); clif_send(buf,packet_len_table[0x7c],&nd->bl,AREA); @@ -1348,7 +1348,7 @@ int clif_spawnmob(struct mob_data *md) nullpo_retr(0, md); - if (mob_get_viewclass(md->class) > 23 ) { + if (mob_get_viewclass(md->class_) > 23 ) { memset(buf,0,packet_len_table[0x7c]); WBUFW(buf,0)=0x7c; @@ -1357,7 +1357,7 @@ int clif_spawnmob(struct mob_data *md) WBUFW(buf,8)=md->opt1; WBUFW(buf,10)=md->opt2; WBUFW(buf,12)=md->option; - WBUFW(buf,20)=mob_get_viewclass(md->class); + WBUFW(buf,20)=mob_get_viewclass(md->class_); WBUFPOS(buf,36,md->bl.x,md->bl.y); clif_send(buf,packet_len_table[0x7c],&md->bl,AREA); } @@ -1365,8 +1365,8 @@ int clif_spawnmob(struct mob_data *md) len = clif_mob0078(md,buf); clif_send(buf,len,&md->bl,AREA); - if (mob_get_equip(md->class) > 0) // mob equipment [Valaris] - clif_mob_equip(md,mob_get_equip(md->class)); + if (mob_get_equip(md->class_) > 0) // mob equipment [Valaris] + clif_mob_equip(md,mob_get_equip(md->class_)); if(md->size==2) // tiny/big mobs [Valaris] clif_specialeffect(&md->bl,423,0); @@ -1389,13 +1389,13 @@ int clif_spawnpet(struct pet_data *pd) nullpo_retr(0, pd); - if (mob_get_viewclass(pd->class) >= MAX_PC_CLASS) { + if (mob_get_viewclass(pd->class_) >= MAX_PC_CLASS) { memset(buf,0,packet_len_table[0x7c]); WBUFW(buf,0)=0x7c; WBUFL(buf,2)=pd->bl.id; WBUFW(buf,6)=pd->speed; - WBUFW(buf,20)=mob_get_viewclass(pd->class); + WBUFW(buf,20)=mob_get_viewclass(pd->class_); WBUFPOS(buf,36,pd->bl.x,pd->bl.y); clif_send(buf,packet_len_table[0x7c],&pd->bl,AREA); @@ -3552,7 +3552,7 @@ void clif_getareachar_npc(struct map_session_data* sd,struct npc_data* nd) int len; nullpo_retv(sd); nullpo_retv(nd); - if(nd->class < 0 || nd->flag&1 || nd->class == INVISIBLE_CLASS) + if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS) return; if(nd->state.state == MS_WALK){ len = clif_npc007b(nd,WFIFOP(sd->fd,0)); @@ -3580,8 +3580,8 @@ int clif_movemob(struct mob_data *md) len = clif_mob007b(md,buf); clif_send(buf,len,&md->bl,AREA); - if(mob_get_equip(md->class) > 0) // mob equipment [Valaris] - clif_mob_equip(md,mob_get_equip(md->class)); + if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris] + clif_mob_equip(md,mob_get_equip(md->class_)); if(md->size==2) // tiny/big mobs [Valaris] clif_specialeffect(&md->bl,423,0); @@ -3739,8 +3739,8 @@ void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md) WFIFOSET(sd->fd,len); } - if(mob_get_equip(md->class) > 0) // mob equipment [Valaris] - clif_mob_equip(md,mob_get_equip(md->class)); + if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris] + clif_mob_equip(md,mob_get_equip(md->class_)); if(md->size==2) // tiny/big mobs [Valaris] clif_specialeffect(&md->bl,423,0); @@ -3976,7 +3976,7 @@ int clif_pcoutsight(struct block_list *bl,va_list ap) } break; case BL_NPC: - if( ((struct npc_data *)bl)->class != INVISIBLE_CLASS ) + if( ((struct npc_data *)bl)->class_ != INVISIBLE_CLASS ) clif_clearchar_id(bl->id,0,sd->fd); break; case BL_MOB: @@ -4191,7 +4191,7 @@ int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range) memset(WFIFOP(fd,14),0,24); if(!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn == 1 || (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) ) //WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_get_max(id) && sd->status.skill[skillid].flag ==0 )? 1:0; - WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class) && sd->status.skill[skillid].flag ==0 )? 1:0; + WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[skillid].flag ==0 )? 1:0; else WFIFOB(fd,38) = 0; WFIFOSET(fd,packet_len_table[0x147]); @@ -4226,7 +4226,7 @@ int clif_skillinfoblock(struct map_session_data *sd) memset(WFIFOP(fd,len+12),0,24); if(!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn == 1 || (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) ) //WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_get_max(id) && sd->status.skill[i].flag ==0 )? 1:0; - WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class) && sd->status.skill[i].flag ==0 )? 1:0; + WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[i].flag ==0 )? 1:0; else WFIFOB(fd,len+36) = 0; len+=37; @@ -4259,7 +4259,7 @@ int clif_skillup(struct map_session_data *sd,int skill_num) range = battle_get_range(&sd->bl) - (range + 1); WFIFOW(fd,8) = range; //WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_get_max(sd->status.skill[skill_num].id)) ? 1 : 0; - WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class)) ? 1 : 0; + WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0; WFIFOSET(fd,packet_len_table[0x10e]); return 0; @@ -4623,13 +4623,13 @@ int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) return 0; WBUFW(buf, 0)=0x18c; - WBUFW(buf, 2)=mob_get_viewclass(md->class); + WBUFW(buf, 2)=mob_get_viewclass(md->class_); WBUFW(buf, 4)=md->level; - WBUFW(buf, 6)=mob_db[md->class].size; + WBUFW(buf, 6)=mob_db[md->class_].size; WBUFL(buf, 8)=md->hp; WBUFW(buf,12)=battle_get_def2(&md->bl); - WBUFW(buf,14)=mob_db[md->class].race; - WBUFW(buf,16)=battle_get_mdef2(&md->bl) - (mob_db[md->class].vit>>1); + WBUFW(buf,14)=mob_db[md->class_].race; + WBUFW(buf,16)=battle_get_mdef2(&md->bl) - (mob_db[md->class_].vit>>1); WBUFW(buf,18)=battle_get_elem_type(&md->bl); for(i=0;i<9;i++) WBUFB(buf,20+i)= battle_attr_fix(100,i+1,md->def_ele); @@ -5831,7 +5831,7 @@ int clif_update_mobhp(struct mob_data *md) WBUFL(buf,2) = md->bl.id; memcpy(WBUFP(buf,6), md->name, 24); - sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class].max_hp); + sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class_].max_hp); WBUFW(buf, 0) = 0x195; memcpy(WBUFP(buf,30), mobhp, 24); WBUFL(buf,54) = 0; @@ -6023,7 +6023,7 @@ int clif_pet_emotion(struct pet_data *pd,int param) if(sd->petDB->talk_convert_class < 0) return 0; else if(sd->petDB->talk_convert_class > 0) { - param -= (pd->class - 100)*100; + param -= (pd->class_ - 100)*100; param += (sd->petDB->talk_convert_class - 100)*100; } } @@ -6501,7 +6501,7 @@ int clif_guild_memberlist(struct map_session_data *sd) WFIFOW(fd,c*104+12)=m->hair; WFIFOW(fd,c*104+14)=m->hair_color; WFIFOW(fd,c*104+16)=m->gender; - WFIFOW(fd,c*104+18)=m->class; + WFIFOW(fd,c*104+18)=m->class_; WFIFOW(fd,c*104+20)=m->lv; WFIFOL(fd,c*104+22)=m->exp; WFIFOL(fd,c*104+26)=m->online; @@ -7439,10 +7439,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if(sd->state.connect_new) { sd->state.connect_new = 0; - if(sd->status.class != sd->view_class) + if(sd->status.class_ != sd->view_class) clif_changelook(&sd->bl,LOOK_BASE,sd->view_class); if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 900) - clif_pet_emotion(sd->pd,(sd->pd->class - 100)*100 + 50 + pet_hungry_val(sd)); + clif_pet_emotion(sd->pd,(sd->pd->class_ - 100)*100 + 50 + pet_hungry_val(sd)); /* Stop players from spawning inside castles [Valaris] */ @@ -7753,7 +7753,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { nullpo_retv(md); memcpy(WFIFOP(fd,6), md->name, 24); - if (md->class >= 1285 && md->class <= 1288 && md->guild_id) { + if (md->class_ >= 1285 && md->class_ <= 1288 && md->guild_id) { struct guild *g; struct guild_castle *gc = guild_mapname2gc(map[md->bl.m].name); if (gc && gc->guild_id > 0 && (g = guild_search(gc->guild_id)) != NULL) { @@ -7767,7 +7767,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { } } else if (battle_config.show_mob_hp == 1) { char mobhp[50]; - sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class].max_hp); + sprintf(mobhp, "hp: %d/%d", md->hp, mob_db[md->class_].max_hp); WFIFOW(fd, 0) = 0x195; memcpy(WFIFOP(fd,30), mobhp, 24); WFIFOB(fd,54) = 0; @@ -7849,7 +7849,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < WFIFOSET(fd, WFIFOW(fd,2)); // Celest - if (pc_calc_base_job2 (sd->status.class) == 23 ) { + if (pc_calc_base_job2 (sd->status.class_) == 23 ) { int next = pc_nextbaseexp(sd)>0 ? pc_nextbaseexp(sd) : sd->status.base_exp; if ((sd->status.base_exp*100/next)%10 == 0) { estr_lower(RFIFOP(fd,4)); @@ -8680,17 +8680,17 @@ void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd) void clif_parse_RemoveOption(int fd,struct map_session_data *sd) { if(pc_isriding(sd)) { // jobchange when removing peco [Valaris] - if(sd->status.class==13) - sd->status.class=sd->view_class=7; + if(sd->status.class_==13) + sd->status.class_=sd->view_class=7; - if(sd->status.class==21) - sd->status.class=sd->view_class=14; + if(sd->status.class_==21) + sd->status.class_=sd->view_class=14; - if(sd->status.class==4014) - sd->status.class=sd->view_class=4008; + if(sd->status.class_==4014) + sd->status.class_=sd->view_class=4008; - if(sd->status.class==4022) - sd->status.class=sd->view_class=4015; + if(sd->status.class_==4022) + sd->status.class_=sd->view_class=4015; } pc_setoption(sd,0); @@ -10011,7 +10011,7 @@ void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd) { if(sd){ int nextbaseexp=pc_nextbaseexp(sd); - struct pc_base_job s_class = pc_calc_base_job(sd->status.class); + struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); if (battle_config.etc_log){ if(nextbaseexp != 0) printf("SuperNovice explosionspirits!! %d %d %d %d\n",sd->bl.id,s_class.job,sd->status.base_exp,(int)((double)1000*sd->status.base_exp/nextbaseexp)); diff --git a/src/map/guild.c b/src/map/guild.c index 7369757a7..ddaa05999 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -242,7 +242,7 @@ void guild_makemember(struct guild_member *m,struct map_session_data *sd) m->hair =sd->status.hair; m->hair_color =sd->status.hair_color; m->gender =sd->sex; - m->class =sd->status.class; + m->class_ =sd->status.class_; m->lv =sd->status.base_level; m->exp =0; m->exp_payper =0; @@ -722,7 +722,7 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online) return 0; intif_guild_memberinfoshort(g->guild_id, - sd->status.account_id,sd->status.char_id,online,sd->status.base_level,sd->status.class); + sd->status.account_id,sd->status.char_id,online,sd->status.base_level,sd->status.class_); if( !online ){ // ログアウトするならsdをクリアして終了 int i=guild_getindex(g,sd->status.account_id,sd->status.char_id); @@ -762,7 +762,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin oldonline=m->online; m->online=online; m->lv=lv; - m->class=class; + m->class_=class; idx=i; } if(m->account_id>0){ diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 815034d8c..e6a997976 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -158,7 +158,7 @@ struct item_data* itemdb_search(int nameid) id->weight=10; id->sex=2; id->elv=0; - id->class=0xffffffff; + id->class_=0xffffffff; id->flag.available=0; id->flag.value_notdc=0; //一応・・・ id->flag.value_notoc=0; @@ -339,7 +339,7 @@ static int itemdb_readdb(void) id->def=atoi(str[8]); id->range=atoi(str[9]); id->slot=atoi(str[10]); - id->class=atoi(str[11]); + id->class_=atoi(str[11]); id->sex=atoi(str[12]); if(id->equip != atoi(str[13])){ id->equip=atoi(str[13]); @@ -814,7 +814,7 @@ static int itemdb_read_sqldb(void) id->def = (sql_row[8] != NULL) ? atoi(sql_row[8]) : 0; id->range = (sql_row[9] != NULL) ? atoi(sql_row[9]) : 0; id->slot = (sql_row[10] != NULL) ? atoi(sql_row[10]) : 0; - id->class = (sql_row[11] != NULL) ? atoi(sql_row[11]) : 0; + id->class_ = (sql_row[11] != NULL) ? atoi(sql_row[11]) : 0; id->sex = (sql_row[12] != NULL) ? atoi(sql_row[12]) : 0; id->equip = (sql_row[13] != NULL) ? atoi(sql_row[13]) : 0; id->wlv = (sql_row[14] != NULL) ? atoi(sql_row[14]) : 0; diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 9ff3981a2..2ba6ae7f6 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -12,7 +12,7 @@ struct item_data { int value_buy; int value_sell; int type; - int class; + int class_; int sex; int equip; int weight; diff --git a/src/map/map.h b/src/map/map.h index ccedaacaf..405c34d65 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -348,7 +348,7 @@ struct npc_item_list { struct npc_data { struct block_list bl; short n; - short class,dir; + short class_,dir; short speed; char name[24]; char exname[24]; @@ -395,7 +395,7 @@ struct npc_data { struct mob_data { struct block_list bl; short n; - short base_class,class,dir,mode,level; + short base_class,class_,dir,mode,level; short m,x0,y0,xs,ys; char name[24]; int spawndelay1,spawndelay2; @@ -457,7 +457,7 @@ struct mob_data { struct pet_data { struct block_list bl; short n; - short class,dir; + short class_,dir; short speed; char name[24]; struct { diff --git a/src/map/mob.c b/src/map/mob.c index c6b772209..539a10c1a 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -99,7 +99,7 @@ int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class) memcpy(md->name,mobname,24); md->n = 0; - md->base_class = md->class = class; + md->base_class = md->class_ = class; md->bl.id= npc_get_new_npc_id(); memset(&md->state,0,sizeof(md->state)); @@ -600,11 +600,11 @@ static int mob_attack(struct mob_data *md,unsigned int tick,int data) if(!md->mode) - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; else mode=md->mode; - race=mob_db[md->class].race; + race=mob_db[md->class_].race; if(!(mode&0x80)){ md->target_id=0; md->state.targettype = NONE_ATTACKABLE; @@ -617,7 +617,7 @@ static int mob_attack(struct mob_data *md,unsigned int tick,int data) return 0; } - range = mob_db[md->class].range; + range = mob_db[md->class_].range; if(mode&1) range++; if(distance(md->bl.x,md->bl.y,tbl->x,tbl->y) > range) @@ -912,7 +912,7 @@ int mob_spawn(int id) map_delblock(&md->bl); } else - md->class = md->base_class; + md->class_ = md->base_class; md->bl.m =md->m; do { @@ -946,11 +946,11 @@ int mob_spawn(int id) md->move_fail_count = 0; if(!md->speed) - md->speed = mob_db[md->class].speed; - md->def_ele = mob_db[md->class].element; + md->speed = mob_db[md->class_].speed; + md->def_ele = mob_db[md->class_].element; if(!md->level) // [Valaris] - md->level=mob_db[md->class].lv; + md->level=mob_db[md->class_].lv; md->master_id=0; md->master_dist=0; @@ -964,7 +964,7 @@ int mob_spawn(int id) md->canmove_tick = tick; md->guild_id = 0; - if (md->class >= 1285 && md->class <= 1288) { + if (md->class_ >= 1285 && md->class_ <= 1288) { struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) md->guild_id = gc->guild_id; @@ -998,7 +998,7 @@ int mob_spawn(int id) md->hp = battle_get_max_hp(&md->bl); if(md->hp<=0){ - mob_makedummymobdb(md->class); + mob_makedummymobdb(md->class_); md->hp = battle_get_max_hp(&md->bl); } @@ -1094,7 +1094,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range) //=========== guildcastle guardian no search start=========== //when players are the guild castle member not attack them ! - if(md->class >= 1285 && md->class <= 1287){ + if(md->class_ >= 1285 && md->class_ <= 1287){ struct map_session_data *sd; struct guild *g=NULL; struct guild_castle *gc=guild_mapname2gc(map[bl->m].name); @@ -1171,10 +1171,10 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) sc_data = battle_get_sc_data(bl); option = battle_get_option(bl); - race=mob_db[md->class].race; + race=mob_db[md->class_].race; if(!md->mode) - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; else mode=md->mode; @@ -1236,13 +1236,13 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) return 0; if(!smd->mode) - mode=mob_db[smd->class].mode; + mode=mob_db[smd->class_].mode; else mode=smd->mode; // アクティブでターゲット射程内にいるなら、ロックする if( mode&0x04 ){ - race=mob_db[smd->class].race; + race=mob_db[smd->class_].race; //対象がPCの場合 if(tsd && !pc_isdead(tsd) && @@ -1295,7 +1295,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) nullpo_retr(0, itc=va_arg(ap,int *)); if(!md->mode) - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; else mode=md->mode; @@ -1332,8 +1332,8 @@ static int mob_ai_sub_hard_linksearch(struct block_list *bl,va_list ap) nullpo_retr(0, target=va_arg(ap,struct block_list *)); // same family free in a range at a link monster -- it will be made to lock if MOB is -/* if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && mob_db[md->class].mode&0x08){ - if( tmd->class==md->class && (!tmd->target_id || md->state.targettype == NONE_ATTACKABLE) && tmd->bl.m == md->bl.m){ +/* if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && mob_db[md->class_].mode&0x08){ + if( tmd->class_==md->class_ && (!tmd->target_id || md->state.targettype == NONE_ATTACKABLE) && tmd->bl.m == md->bl.m){ if( mob_can_reach(tmd,target,12) ){ // Reachability judging tmd->target_id=md->target_id; tmd->state.targettype = ATTACKABLE; @@ -1341,8 +1341,8 @@ static int mob_ai_sub_hard_linksearch(struct block_list *bl,va_list ap) } } }*/ - if( md->attacked_id > 0 && mob_db[md->class].mode&0x08){ - if( tmd->class==md->class && tmd->bl.m == md->bl.m && (!tmd->target_id || md->state.targettype == NONE_ATTACKABLE)){ + if( md->attacked_id > 0 && mob_db[md->class_].mode&0x08){ + if( tmd->class_==md->class_ && tmd->bl.m == md->bl.m && (!tmd->target_id || md->state.targettype == NONE_ATTACKABLE)){ if( mob_can_reach(tmd,target,12) ){ // Reachability judging tmd->target_id=md->attacked_id; tmd->state.targettype = ATTACKABLE; @@ -1368,7 +1368,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) if((bl=map_id2bl(md->master_id)) != NULL ) mmd=(struct mob_data *)bl; - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; // It is not main monster/leader. if(!mmd || mmd->bl.type!=BL_MOB || mmd->bl.id!=md->master_id) @@ -1439,7 +1439,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) struct map_session_data *sd=map_id2sd(mmd->target_id); if(sd!=NULL && !pc_isdead(sd) && sd->invincible_timer == -1 && !pc_isinvisible(sd)){ - race=mob_db[md->class].race; + race=mob_db[md->class_].race; if(mode&0x20 || (sd->sc_data[SC_TRICKDEAD].timer == -1 && sd->sc_data[SC_BASILICA].timer == -1 && ( (!pc_ishiding(sd) && !sd->state.gangsterparadise) || ((race == 4 || race == 6) && !sd->perfect_hiding) ) ) ){ // 妨害がないか判定 @@ -1457,7 +1457,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) struct map_session_data *sd=map_id2sd(md->target_id); if(sd!=NULL && !pc_isdead(sd) && sd->invincible_timer == -1 && !pc_isinvisible(sd)){ - race=mob_db[mmd->class].race; + race=mob_db[mmd->class_].race; if(mode&0x20 || (sd->sc_data[SC_TRICKDEAD].timer == -1 && (!(sd->status.option&0x06) || race==4 || race==6) @@ -1525,7 +1525,7 @@ static int mob_randomwalk(struct mob_data *md,int tick) md->target_dir = 0; if(md->move_fail_count>1000){ if(battle_config.error_log) - printf("MOB cant move. random spawn %d, class = %d\n",md->bl.id,md->class); + printf("MOB cant move. random spawn %d, class = %d\n",md->bl.id,md->class_); md->move_fail_count=0; mob_spawn(md->bl.id); } @@ -1577,11 +1577,11 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) } if(!md->mode) - mode=mob_db[md->class].mode; + mode=mob_db[md->class_].mode; else mode=md->mode; - race=mob_db[md->class].race; + race=mob_db[md->class_].race; // Abnormalities if((md->opt1 > 0 && md->opt1 != 6) || md->state.state==MS_DELAY || md->sc_data[SC_BLADESTOP].timer != -1) @@ -1674,7 +1674,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) ((pc_ishiding(tsd) || tsd->state.gangsterparadise) && !((race == 4 || race == 6) && !tsd->perfect_hiding) )) ) mob_unlocktarget(md,tick); // スキルなどによる策敵妨害 - else if(!battle_check_range(&md->bl,tbl,mob_db[md->class].range)){ + else if(!battle_check_range(&md->bl,tbl,mob_db[md->class_].range)){ // 攻撃範囲外なので移動 if(!(mode&1)){ // 移動しないモード mob_unlocktarget(md,tick); @@ -1889,7 +1889,7 @@ static int mob_ai_sub_lazy(void * key,void * data,va_list app) } if(DIFF_TICK(md->next_walktime,tick)<0 && - (mob_db[md->class].mode&1) && mob_can_move(md) ){ + (mob_db[md->class_].mode&1) && mob_can_move(md) ){ if( map[md->bl.m].users>0 ){ // Since PC is in the same map, somewhat better negligent processing is carried out. @@ -1900,7 +1900,7 @@ static int mob_ai_sub_lazy(void * key,void * data,va_list app) // MOB which is not not the summons MOB but BOSS, either sometimes reboils. else if( rand()%1000x0<=0 && md->master_id!=0 && - mob_db[md->class].mexp <= 0 && !(mob_db[md->class].mode & 0x20)) + mob_db[md->class_].mexp <= 0 && !(mob_db[md->class_].mode & 0x20)) mob_spawn(md->bl.id); }else{ @@ -1908,7 +1908,7 @@ static int mob_ai_sub_lazy(void * key,void * data,va_list app) // MOB which is not BOSS which is not Summons MOB, either -- a case -- sometimes -- leaping if( rand()%1000x0<=0 && md->master_id!=0 && - mob_db[md->class].mexp <= 0 && !(mob_db[md->class].mode & 0x20)) + mob_db[md->class_].mexp <= 0 && !(mob_db[md->class_].mode & 0x20)) mob_warp(md,-1,-1,-1,-1); } @@ -2018,7 +2018,7 @@ int mob_delete(struct mob_data *md) mob_changestate(md,MS_DEAD,0); clif_clearchar_area(&md->bl,1); map_delblock(&md->bl); - if(mob_get_viewclass(md->class) <= 1000) + if(mob_get_viewclass(md->class_) <= 1000) clif_clearchar_delay(gettick()+3000,&md->bl,0); mob_deleteslave(md); mob_setdelayspawn(md->bl.id); @@ -2220,7 +2220,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) md->hp-=damage; - if(md->class >= 1285 && md->class <=1287) { // guardian hp update [Valaris] + if(md->class_ >= 1285 && md->class_ <=1287) { // guardian hp update [Valaris] struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { @@ -2292,7 +2292,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(md->state.special_mob_ai == 2){//スフィアーマイン int skillidx=0; - if((skillidx=mob_skillid2skillidx(md->class,NPC_SELFDESTRUCTION2))>=0){ + if((skillidx=mob_skillid2skillidx(md->class_,NPC_SELFDESTRUCTION2))>=0){ md->mode |= 0x1; md->next_walktime=tick; mobskill_use_id(md,&md->bl,skillidx);//自爆詠唱開始 @@ -2374,13 +2374,13 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) // jAthena's exp formula // per = ((double)md->dmglog[i].dmg)*(9.+(double)((count > 6)? 6:count))/10./((double)max_hp) * dmg_rate; per = ((double)md->dmglog[i].dmg)*(9.+(double)((count > 6)? 6:count))/10./tdmg; - temp = (double)mob_db[md->class].base_exp * per; + temp = (double)mob_db[md->class_].base_exp * per; base_exp = (temp > 2147483647.)? 0x7fffffff:(int)temp; - if(mob_db[md->class].base_exp > 0 && base_exp < 1) base_exp = 1; + if(mob_db[md->class_].base_exp > 0 && base_exp < 1) base_exp = 1; if(base_exp < 0) base_exp = 0; - temp = (double)mob_db[md->class].job_exp * per; + temp = (double)mob_db[md->class_].job_exp * per; job_exp = (temp > 2147483647.)? 0x7fffffff:(int)temp; - if(mob_db[md->class].job_exp > 0 && job_exp < 1) job_exp = 1; + if(mob_db[md->class_].job_exp > 0 && job_exp < 1) job_exp = 1; if(job_exp < 0) job_exp = 0; } else if (battle_config.exp_calc_type == 1) { @@ -2388,9 +2388,9 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) per=(double)md->dmglog[i].dmg*256*(9+(double)((count > 6)? 6:count))/10/(double)max_hp; if(per>512) per=512; if(per<1) per=1; - base_exp=mob_db[md->class].base_exp*per/256; + base_exp=mob_db[md->class_].base_exp*per/256; if(base_exp < 1) base_exp = 1; - job_exp=mob_db[md->class].job_exp*per/256; + job_exp=mob_db[md->class_].job_exp*per/256; if(job_exp < 1) job_exp = 1; } else { @@ -2398,16 +2398,16 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) per=(double)md->dmglog[i].dmg*256*(9+(double)((count > 6)? 6:count))/10/tdmg; if(per>512) per=512; if(per<1) per=1; - base_exp=mob_db[md->class].base_exp*per/256; + base_exp=mob_db[md->class_].base_exp*per/256; if(base_exp < 1) base_exp = 1; - job_exp=mob_db[md->class].job_exp*per/256; + job_exp=mob_db[md->class_].job_exp*per/256; if(job_exp < 1) job_exp = 1; } - if(sd && battle_config.pk_mode && (mob_db[md->class].lv - sd->status.base_level >= 20)) { + if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { base_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] } - if(sd && battle_config.pk_mode && (mob_db[md->class].lv - sd->status.base_level >= 20)) { + if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { job_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] } if(md->master_id || (md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1)) { // for summoned creatures [Valaris] @@ -2417,12 +2417,12 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) else { if(battle_config.zeny_from_mobs) { if(md->level > 0) zeny=(md->level+rand()%md->level)*per/256; // zeny calculation moblv + random moblv [Valaris] - if(mob_db[md->class].mexp > 0) + if(mob_db[md->class_].mexp > 0) zeny*=rand()%250; } - if(battle_config.mobs_level_up && md->level > mob_db[md->class].lv) { // [Valaris] - job_exp+=((md->level-mob_db[md->class].lv)*mob_db[md->class].job_exp*.03)*per/256; - base_exp+=((md->level-mob_db[md->class].lv)*mob_db[md->class].base_exp*.03)*per/256; + if(battle_config.mobs_level_up && md->level > mob_db[md->class_].lv) { // [Valaris] + job_exp+=((md->level-mob_db[md->class_].lv)*mob_db[md->class_].job_exp*.03)*per/256; + base_exp+=((md->level-mob_db[md->class_].lv)*mob_db[md->class_].base_exp*.03)*per/256; } } @@ -2473,18 +2473,18 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(md->master_id || (md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1)) // Added [Valaris] break; // End - if(mob_db[md->class].dropitem[i].nameid <= 0) + if(mob_db[md->class_].dropitem[i].nameid <= 0) continue; - drop_rate = mob_db[md->class].dropitem[i].p; + drop_rate = mob_db[md->class_].dropitem[i].p; if(drop_rate <= 0 && battle_config.drop_rate0item) drop_rate = 1; if(battle_config.drops_by_luk>0 && sd && md) drop_rate+=(sd->status.luk*battle_config.drops_by_luk)/100; // drops affected by luk [Valaris] - if(sd && md && battle_config.pk_mode==1 && (mob_db[md->class].lv - sd->status.base_level >= 20)) drop_rate*=1.25; // pk_mode increase drops if 20 level difference [Valaris] + if(sd && md && battle_config.pk_mode==1 && (mob_db[md->class_].lv - sd->status.base_level >= 20)) drop_rate*=1.25; // pk_mode increase drops if 20 level difference [Valaris] if(drop_rate <= rand()%10000) continue; ditem=(struct delay_item_drop *)aCalloc(1,sizeof(struct delay_item_drop)); - ditem->nameid = mob_db[md->class].dropitem[i].nameid; + ditem->nameid = mob_db[md->class_].dropitem[i].nameid; log_item[i] = ditem->nameid; ditem->amount = 1; ditem->m = md->bl.m; @@ -2498,7 +2498,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) #ifndef TXT_ONLY if(log_config.drop > 0) - log_drop(mvp_sd, md->class, log_item); + log_drop(mvp_sd, md->class_, log_item); #endif // Ore Discovery [Celest] @@ -2520,7 +2520,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) #ifndef TXT_ONLY if(log_config.drop > 0) - log_drop(mvp_sd, md->class, log_item); + log_drop(mvp_sd, md->class_, log_item); #endif if(sd && sd->state.attack_type == BF_WEAPON) { @@ -2530,8 +2530,8 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(sd->monster_drop_itemid[i] <= 0) continue; if(sd->monster_drop_race[i] & (1<class].mode & 0x20 && sd->monster_drop_race[i] & 1<<10) || - (!(mob_db[md->class].mode & 0x20) && sd->monster_drop_race[i] & 1<<11) ) { + (mob_db[md->class_].mode & 0x20 && sd->monster_drop_race[i] & 1<<10) || + (!(mob_db[md->class_].mode & 0x20) && sd->monster_drop_race[i] & 1<<11) ) { if(sd->monster_drop_itemrate[i] <= rand()%10000) continue; @@ -2548,7 +2548,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) } } if(sd->get_zeny_num > 0) - pc_getzeny(sd,mob_db[md->class].lv*10 + rand()%(sd->get_zeny_num+1)); + pc_getzeny(sd,mob_db[md->class_].lv*10 + rand()%(sd->get_zeny_num+1)); } if(md->lootitem) { for(i=0;ilootitem_count;i++) { @@ -2568,11 +2568,11 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) } // mvp処理 - if(mvp_sd && mob_db[md->class].mexp > 0 ){ + if(mvp_sd && mob_db[md->class_].mexp > 0 ){ int log_mvp[2] = {0}; int j; int mexp; - temp = ((double)mob_db[md->class].mexp * (9.+(double)count)/10.); //[Gengar] + temp = ((double)mob_db[md->class_].mexp * (9.+(double)count)/10.); //[Gengar] mexp = (temp > 2147483647.)? 0x7fffffff:(int)temp; if(mexp < 1) mexp = 1; clif_mvp_effect(mvp_sd); // エフェクト @@ -2581,9 +2581,9 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) log_mvp[1] = mexp; for(j=0;j<3;j++){ i = rand() % 3; - if(mob_db[md->class].mvpitem[i].nameid <= 0) + if(mob_db[md->class_].mvpitem[i].nameid <= 0) continue; - drop_rate = mob_db[md->class].mvpitem[i].p; + drop_rate = mob_db[md->class_].mvpitem[i].p; if(drop_rate <= 0 && battle_config.drop_rate0item) drop_rate = 1; if(drop_rate < battle_config.item_drop_mvp_min) @@ -2593,7 +2593,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(drop_rate <= rand()%10000) continue; memset(&item,0,sizeof(item)); - item.nameid=mob_db[md->class].mvpitem[i].nameid; + item.nameid=mob_db[md->class_].mvpitem[i].nameid; item.identify=!itemdb_isequip3(item.nameid); clif_mvp_item(mvp_sd,item.nameid); log_mvp[0] = item.nameid; @@ -2607,7 +2607,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) } #ifndef TXT_ONLY if(log_config.mvpdrop > 0) - log_mvpdrop(mvp_sd, md->class, log_mvp); + log_mvpdrop(mvp_sd, md->class_, log_mvp); #endif } @@ -2649,7 +2649,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) clif_clearchar_area(&md->bl,1); if(md->level) md->level=0; map_delblock(&md->bl); - if(mob_get_viewclass(md->class) <= 1000) + if(mob_get_viewclass(md->class_) <= 1000) clif_clearchar_delay(tick+3000,&md->bl,0); mob_deleteslave(md); mob_setdelayspawn(md->bl.id); @@ -2683,7 +2683,7 @@ int mob_class_change(struct mob_data *md,int *value) max_hp = battle_get_max_hp(&md->bl); hp_rate = md->hp*100/max_hp; clif_mob_class_change(md,class); - md->class = class; + md->class_ = class; max_hp = battle_get_max_hp(&md->bl); if(battle_config.monster_class_change_full_recover==1) { md->hp = max_hp; @@ -2700,8 +2700,8 @@ int mob_class_change(struct mob_data *md,int *value) md->target_id = 0; md->move_fail_count = 0; - md->speed = mob_db[md->class].speed; - md->def_ele = mob_db[md->class].element; + md->speed = mob_db[md->class_].speed; + md->def_ele = mob_db[md->class_].element; mob_changestate(md,MS_IDLE,0); skill_castcancel(&md->bl,0); @@ -2742,7 +2742,7 @@ int mob_heal(struct mob_data *md,int heal) if( max_hp < md->hp ) md->hp = max_hp; - if(md->class >= 1285 && md->class <=1287) { // guardian hp update [Valaris] + if(md->class_ >= 1285 && md->class_ <=1287) { // guardian hp update [Valaris] struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { if(md->bl.id==gc->GID0) gc->Ghp0=md->hp; @@ -2835,7 +2835,7 @@ int mob_warp(struct mob_data *md,int m,int x,int y,int type) }else { m=md->bl.m; if(battle_config.error_log==1) - printf("MOB %d warp failed, class = %d\n",md->bl.id,md->class); + printf("MOB %d warp failed, class = %d\n",md->bl.id,md->class_); } md->target_id=0; // タゲを解除する @@ -2846,7 +2846,7 @@ int mob_warp(struct mob_data *md,int m,int x,int y,int type) if(type>0 && i==1000) { if(battle_config.battle_log) - printf("MOB %d warp to (%d,%d), class = %d\n",md->bl.id,x,y,md->class); + printf("MOB %d warp to (%d,%d), class = %d\n",md->bl.id,x,y,md->class_); } map_addblock(&md->bl); @@ -3107,7 +3107,7 @@ int mobskill_castend_id( int tid, unsigned int tick, int id,int data ) md->skilldelay[md->skillidx]=tick; if(battle_config.mob_skill_log) - printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class); + printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class_); // mob_stop_walking(md,0); switch( skill_get_nk(md->skillid) ) @@ -3117,7 +3117,7 @@ int mobskill_castend_id( int tid, unsigned int tick, int id,int data ) skill_castend_damage_id(&md->bl,bl,md->skillid,md->skilllv,tick,0); break; case 1:// 支援系 - if(!mob_db[md->class].skill[md->skillidx].val[0] && + if(!mob_db[md->class_].skill[md->skillidx].val[0] && (md->skillid==AL_HEAL || (md->skillid==ALL_RESURRECTION && bl->type != BL_PC)) && battle_check_undead(battle_get_race(bl),battle_get_elem_type(bl)) ) skill_castend_damage_id(&md->bl,bl,md->skillid,md->skilllv,tick,0); else @@ -3238,7 +3238,7 @@ int mobskill_castend_pos( int tid, unsigned int tick, int id,int data ) md->skilldelay[md->skillidx]=tick; if(battle_config.mob_skill_log) - printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class); + printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class_); // mob_stop_walking(md,0); skill_castend_pos2(&md->bl,md->skillx,md->skilly,md->skillid,md->skilllv,tick,0); @@ -3258,7 +3258,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx) int skill_id, skill_lv, forcecast = 0; nullpo_retr(0, md); - nullpo_retr(0, ms=&mob_db[md->class].skill[skill_idx]); + nullpo_retr(0, ms=&mob_db[md->class_].skill[skill_idx]); if( target==NULL && (target=map_id2bl(md->target_id))==NULL ) return 0; @@ -3326,7 +3326,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx) } if(battle_config.mob_skill_log) - printf("MOB skill use target_id=%d skill=%d lv=%d cast=%d, class = %d\n",target->id,skill_id,skill_lv,casttime,md->class); + printf("MOB skill use target_id=%d skill=%d lv=%d cast=%d, class = %d\n",target->id,skill_id,skill_lv,casttime,md->class_); if(casttime>0 || forcecast){ // 詠唱が必要 // struct mob_data *md2; @@ -3335,7 +3335,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx) md->bl.id, target->id, 0,0, skill_id,casttime); // 詠唱反応モンスター -/* if( target->type==BL_MOB && mob_db[(md2=(struct mob_data *)target)->class].mode&0x10 && +/* if( target->type==BL_MOB && mob_db[(md2=(struct mob_data *)target)->class_].mode&0x10 && md2->state.state!=MS_ATTACK){ md2->target_id=md->bl.id; md->state.targettype = ATTACKABLE; @@ -3379,7 +3379,7 @@ int mobskill_use_pos( struct mob_data *md, int skill_id, skill_lv; nullpo_retr(0, md); - nullpo_retr(0, ms=&mob_db[md->class].skill[skill_idx]); + nullpo_retr(0, ms=&mob_db[md->class_].skill[skill_idx]); if( md->bl.prev==NULL ) return 0; @@ -3424,7 +3424,7 @@ int mobskill_use_pos( struct mob_data *md, if(battle_config.mob_skill_log) printf("MOB skill use target_pos=(%d,%d) skill=%d lv=%d cast=%d, class = %d\n", - skill_x,skill_y,skill_id,skill_lv,casttime,md->class); + skill_x,skill_y,skill_id,skill_lv,casttime,md->class_); if( casttime>0 ) { // A cast time is required. mob_stop_walking(md,0); // 歩行停止 @@ -3475,7 +3475,7 @@ int mob_getfriendhpltmaxrate_sub(struct block_list *bl,va_list ap) return 0; rate=va_arg(ap,int); fr=va_arg(ap,struct mob_data **); - if( md->hp < mob_db[md->class].max_hp*rate/100 ) + if( md->hp < mob_db[md->class_].max_hp*rate/100 ) (*fr)=md; return 0; } @@ -3547,7 +3547,7 @@ int mobskill_use(struct mob_data *md,unsigned int tick,int event) int i,max_hp; nullpo_retr(0, md); - nullpo_retr(0, ms = mob_db[md->class].skill); + nullpo_retr(0, ms = mob_db[md->class_].skill); max_hp = battle_get_max_hp(&md->bl); @@ -3560,7 +3560,7 @@ int mobskill_use(struct mob_data *md,unsigned int tick,int event) if(md->sc_data[SC_SELFDESTRUCTION].timer!=-1) //自爆中はスキルを使わない return 0; - for(i=0;iclass].maxskill;i++){ + for(i=0;iclass_].maxskill;i++){ int c2=ms[i].cond2,flag=0; struct mob_data *fmd=NULL; @@ -3697,18 +3697,18 @@ int mob_gvmobcheck(struct map_session_data *sd, struct block_list *bl) nullpo_retr(0,bl); if(bl->type==BL_MOB && (md=(struct mob_data *)bl) && - (md->class == 1288 || md->class == 1287 || md->class == 1286 || md->class == 1285)) + (md->class_ == 1288 || md->class_ == 1287 || md->class_ == 1286 || md->class_ == 1285)) { struct guild_castle *gc=guild_mapname2gc(map[sd->bl.m].name); struct guild *g=guild_search(sd->status.guild_id); - if(g == NULL && md->class == 1288) + if(g == NULL && md->class_ == 1288) return 0;//ギルド未加入ならダメージ無し else if(gc != NULL && !map[sd->bl.m].flag.gvg) return 0;//砦内でGvじゃないときはダメージなし else if(g && gc != NULL && g->guild_id == gc->guild_id) return 0;//自占領ギルドのエンペならダメージ無し - else if(g && guild_checkskill(g,GD_APPROVAL) <= 0 && md->class == 1288) + else if(g && guild_checkskill(g,GD_APPROVAL) <= 0 && md->class_ == 1288) return 0;//正規ギルド承認がないとダメージ無し } diff --git a/src/map/npc.c b/src/map/npc.c index 4f6fa42ad..4ef38ff52 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -853,7 +853,7 @@ int npc_checknear(struct map_session_data *sd,int id) return 1; } - if (nd->class<0) // イベント系は常にOK + if (nd->class_<0) // イベント系は常にOK return 0; // エリア判定 @@ -1022,7 +1022,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) } //商人経験値 -/* if ((sd->status.class == 5) || (sd->status.class == 10) || (sd->status.class == 18)) { +/* if ((sd->status.class_ == 5) || (sd->status.class_ == 10) || (sd->status.class_ == 18)) { z = z * pc_checkskill(sd,MC_DISCOUNT) / ((1 + 300 / itemamount) * 4000) * battle_config.shop_exp; pc_gainexp(sd,0,z); }*/ @@ -1082,7 +1082,7 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list) } //商人経験値 -/* if ((sd->status.class == 5) || (sd->status.class == 10) || (sd->status.class == 18)) { +/* if ((sd->status.class_ == 5) || (sd->status.class_ == 10) || (sd->status.class_ == 18)) { z = z * pc_checkskill(sd,MC_OVERCHARGE) / ((1 + 500 / itemamount) * 4000) * battle_config.shop_exp ; pc_gainexp(sd,0,z); }*/ @@ -1449,9 +1449,9 @@ int npc_parse_warp(char *w1,char *w2,char *w3,char *w4) nd->chat_id=0; if (!battle_config.warp_point_debug) - nd->class=WARP_CLASS; + nd->class_=WARP_CLASS; else - nd->class=WARP_DEBUG_CLASS; + nd->class_=WARP_DEBUG_CLASS; nd->speed=200; nd->option = 0; nd->opt1 = 0; @@ -1535,7 +1535,7 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4) nd->dir = dir; nd->flag = 0; memcpy(nd->name, w3, 24); - nd->class = atoi(w4); + nd->class_ = atoi(w4); nd->speed = 200; nd->chat_id = 0; nd->option = 0; @@ -1732,7 +1732,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line nd->bl.id=npc_get_new_npc_id(); nd->dir = dir; nd->flag=0; - nd->class=class; + nd->class_=class; nd->speed=200; nd->u.scr.script=script; nd->u.scr.src_id=src_id; @@ -1743,7 +1743,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line nd->opt3 = 0; nd->walktimer=-1; - //printf("script npc %s %d %d read done\n",mapname,nd->bl.id,nd->class); + //printf("script npc %s %d %d read done\n",mapname,nd->bl.id,nd->class_); npc_script++; nd->bl.type=BL_NPC; nd->bl.subtype=SCRIPT; @@ -1965,7 +1965,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) memcpy(md->name,w3,24); md->n = i; - md->base_class = md->class = class; + md->base_class = md->class_ = class; md->bl.id=npc_get_new_npc_id(); md->m =m; md->x0=x; diff --git a/src/map/pc.c b/src/map/pc.c index e42122665..3288dd1bc 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -269,7 +269,7 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); //----------------------- // 死亡した @@ -308,7 +308,7 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { /* removed exp penalty on spawn [Valaris] */ - if(type&2 && sd->status.class != 0 && battle_config.zeny_penalty > 0 && !map[sd->bl.m].flag.nozenypenalty) { + if(type&2 && sd->status.class_ != 0 && battle_config.zeny_penalty > 0 && !map[sd->bl.m].flag.nozenypenalty) { int zeny = (int)((double)sd->status.zeny * (double)battle_config.zeny_penalty / 10000.); if(zeny < 1) zeny = 1; sd->status.zeny -= zeny; @@ -447,7 +447,7 @@ int pc_equippoint(struct map_session_data *sd,int n) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); if(sd->inventory_data[n]) { ep = sd->inventory_data[n]->equip; @@ -569,14 +569,14 @@ int pc_isequip(struct map_session_data *sd,int n) // as it allows all advanced classes to equip items their normal versions // could equip) // - if(((sd->status.class==13 || sd->status.class==4014) && ((1<<7)&item->class) == 0) || // have mounted classes use unmounted equipment [Valaris] - ((sd->status.class==21 || sd->status.class==4022) && ((1<<14)&item->class) == 0)) + if(((sd->status.class_==13 || sd->status.class_==4014) && ((1<<7)&item->class_) == 0) || // have mounted classes use unmounted equipment [Valaris] + ((sd->status.class_==21 || sd->status.class_==4022) && ((1<<14)&item->class_) == 0)) return 0; - if(sd->status.class!=13 && sd->status.class!=4014 && sd->status.class!=21 && sd->status.class!=4022) - if((sd->status.class<=4000 && ((1<status.class)&item->class) == 0) || (sd->status.class>4000 && sd->status.class<4023 && ((1<<(sd->status.class-4001))&item->class) == 0) || - (sd->status.class>=4023 && ((1<<(sd->status.class-4023))&item->class) == 0)) + if(sd->status.class_!=13 && sd->status.class_!=4014 && sd->status.class_!=21 && sd->status.class_!=4022) + if((sd->status.class_<=4000 && ((1<status.class_)&item->class_) == 0) || (sd->status.class_>4000 && sd->status.class_<4023 && ((1<<(sd->status.class_-4001))&item->class_) == 0) || + (sd->status.class_>=4023 && ((1<<(sd->status.class_-4023))&item->class_) == 0)) return 0; -// if(((1<status.class)&item->class) == 0) +// if(((1<status.class_)&item->class_) == 0) // return 0; if(map[sd->bl.m].flag.pvp && (item->flag.no_equip==1 || item->flag.no_equip==3)) return 0; @@ -735,7 +735,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->bl.prev = sd->bl.next = NULL; sd->weapontype1 = sd->weapontype2 = 0; - sd->view_class = sd->status.class; + sd->view_class = sd->status.class_; sd->speed = DEFAULT_WALK_SPEED; sd->state.dead_sit = 0; sd->dir = 0; @@ -984,7 +984,7 @@ int pc_calc_skilltree(struct map_session_data *sd) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); c = s_class.job; //s = (s_class.upper==1) ? 1 : 0 ; //?生以外は通常のスキル? s = s_class.upper; @@ -1193,7 +1193,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) nullpo_retr(0, sd); //?生や養子の場合の元の職業を算出する - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); b_speed = sd->speed; b_max_hp = sd->status.max_hp; @@ -1220,7 +1220,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) b_mdef = sd->mdef; b_mdef2 = sd->mdef2; b_class = sd->view_class; - sd->view_class = sd->status.class; + sd->view_class = sd->status.class_; b_base_atk = sd->base_atk; pc_calc_skilltree(sd); // スキルツリ?の計算 @@ -1847,12 +1847,12 @@ int pc_calcstatus(struct map_session_data* sd,int first) //Flee上昇 if( (skill=pc_checkskill(sd,TF_MISS))>0 ){ // 回避率?加 - if(sd->status.class==6||sd->status.class==4007 || sd->status.class==23){ + if(sd->status.class_==6||sd->status.class_==4007 || sd->status.class_==23){ sd->flee += skill*3; } - if(sd->status.class==12||sd->status.class==17||sd->status.class==4013||sd->status.class==4018) + if(sd->status.class_==12||sd->status.class_==17||sd->status.class_==4013||sd->status.class_==4018) sd->flee += skill*4; - if(sd->status.class==12||sd->status.class==4013) + if(sd->status.class_==12||sd->status.class_==4013) sd->speed -= sd->speed *(skill*1.5)/100; } if( (skill=pc_checkskill(sd,MO_DODGE))>0 ) // 見切り @@ -2211,7 +2211,7 @@ int pc_calcspeed (struct map_session_data *sd) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); b_speed = sd->speed; sd->speed = DEFAULT_WALK_SPEED ; @@ -3371,12 +3371,12 @@ int pc_isUseitem(struct map_session_data *sd,int n) return 0; if(item->elv > 0 && sd->status.base_level < item->elv) return 0; - if(((sd->status.class==13 || sd->status.class==4014) && ((1<<7)&item->class) == 0) || // have mounted classes use unmounted items [Valaris] - ((sd->status.class==21 || sd->status.class==4022) && ((1<<14)&item->class) == 0)) + if(((sd->status.class_==13 || sd->status.class_==4014) && ((1<<7)&item->class_) == 0) || // have mounted classes use unmounted items [Valaris] + ((sd->status.class_==21 || sd->status.class_==4022) && ((1<<14)&item->class_) == 0)) return 0; - if(sd->status.class!=13 && sd->status.class!=4014 && sd->status.class!=21 && sd->status.class!=4022) - if((sd->status.class<=4000 && ((1<status.class)&item->class) == 0) || (sd->status.class>4000 && sd->status.class<4023 && ((1<<(sd->status.class-4001))&item->class) == 0) || - (sd->status.class>=4023 && ((1<<(sd->status.class-4023))&item->class) == 0)) + if(sd->status.class_!=13 && sd->status.class_!=4014 && sd->status.class_!=21 && sd->status.class_!=4022) + if((sd->status.class_<=4000 && ((1<status.class_)&item->class_) == 0) || (sd->status.class_>4000 && sd->status.class_<4023 && ((1<<(sd->status.class_-4001))&item->class_) == 0) || + (sd->status.class_>=4023 && ((1<<(sd->status.class_-4023))&item->class_) == 0)) return 0; #ifndef TXT_ONLY @@ -3730,25 +3730,25 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl) int i,skill,rate,itemid,flag, count; struct mob_data *md; md=(struct mob_data *)bl; - if(!md->state.steal_flag && mob_db[md->class].mexp <= 0 && !(mob_db[md->class].mode&0x20) && - (!(md->class>1324 && md->class<1364))) // prevent stealing from treasure boxes [Valaris] + if(!md->state.steal_flag && mob_db[md->class_].mexp <= 0 && !(mob_db[md->class_].mode&0x20) && + (!(md->class_>1324 && md->class_<1364))) // prevent stealing from treasure boxes [Valaris] { if (md->sc_data && (md->sc_data[SC_STONE].timer != -1 || md->sc_data[SC_FREEZE].timer != -1)) return 0; skill = battle_config.skill_steal_type == 1 - ? (sd->paramc[4] - mob_db[md->class].dex)/2 + pc_checkskill(sd,TF_STEAL)*6 + 10 - : sd->paramc[4] - mob_db[md->class].dex + pc_checkskill(sd,TF_STEAL)*3 + 10; + ? (sd->paramc[4] - mob_db[md->class_].dex)/2 + pc_checkskill(sd,TF_STEAL)*6 + 10 + : sd->paramc[4] - mob_db[md->class_].dex + pc_checkskill(sd,TF_STEAL)*3 + 10; if(0 < skill) { for(count = 8; count <= 8 && count != 0; count--) { i = rand()%8; - itemid = mob_db[md->class].dropitem[i].nameid; + itemid = mob_db[md->class_].dropitem[i].nameid; if(itemid > 0 && itemdb_type(itemid) != 6) { - rate = (mob_db[md->class].dropitem[i].p / battle_config.item_rate_common * 100 * skill)/100; + rate = (mob_db[md->class_].dropitem[i].p / battle_config.item_rate_common * 100 * skill)/100; if(rand()%10000 < rate) { @@ -3796,9 +3796,9 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *bl) if (md->sc_data && (md->sc_data[SC_STONE].timer != -1 || md->sc_data[SC_FREEZE].timer != -1)) return 0; skill = pc_checkskill(sd,RG_STEALCOIN)*10; - rate = skill + (sd->status.base_level - mob_db[md->class].lv)*3 + sd->paramc[4]*2 + sd->paramc[5]*2; + rate = skill + (sd->status.base_level - mob_db[md->class_].lv)*3 + sd->paramc[4]*2 + sd->paramc[5]*2; if(rand()%1000 < rate) { - pc_getzeny(sd,mob_db[md->class].lv*10 + rand()%100); + pc_getzeny(sd,mob_db[md->class_].lv*10 + rand()%100); md->state.steal_coin_flag = 1; return 1; } @@ -4859,7 +4859,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) nullpo_retr(0, sd); if(sd->status.base_exp >= next && next > 0){ - struct pc_base_job s_class = pc_calc_base_job(sd->status.class); + struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); // base側レベルアップ?理 sd->status.base_exp -= next; @@ -4989,12 +4989,12 @@ int pc_nextbaseexp(struct map_session_data *sd) if(sd->status.base_level>=MAX_LEVEL || sd->status.base_level<=0) return 0; - if(sd->status.class==0) i=0; - else if(sd->status.class<=6) i=1; - else if(sd->status.class<=22) i=2; - else if(sd->status.class==23) i=3; - else if(sd->status.class==4001) i=4; - else if(sd->status.class<=4007) i=5; + if(sd->status.class_==0) i=0; + else if(sd->status.class_<=6) i=1; + else if(sd->status.class_<=22) i=2; + else if(sd->status.class_==23) i=3; + else if(sd->status.class_==4001) i=4; + else if(sd->status.class_<=4007) i=5; else i=6; return exp_table[i][sd->status.base_level-1]; @@ -5013,12 +5013,12 @@ int pc_nextjobexp(struct map_session_data *sd) if(sd->status.job_level>=MAX_LEVEL || sd->status.job_level<=0) return 0; - if(sd->status.class==0) i=7; - else if(sd->status.class<=6) i=8; - else if(sd->status.class<=22) i=9; - else if(sd->status.class==23) i=10; - else if(sd->status.class==4001) i=11; - else if(sd->status.class<=4007) i=12; + if(sd->status.class_==0) i=7; + else if(sd->status.class_<=6) i=8; + else if(sd->status.class_<=22) i=9; + else if(sd->status.class_==23) i=10; + else if(sd->status.class_==4001) i=11; + else if(sd->status.class_<=4007) i=12; else i=13; return exp_table[i][sd->status.job_level-1]; @@ -5037,12 +5037,12 @@ int pc_nextbaseafter(struct map_session_data *sd) if(sd->status.base_level>=MAX_LEVEL || sd->status.base_level<=0) return 0; - if(sd->status.class==0) i=0; - else if(sd->status.class<=6) i=1; - else if(sd->status.class<=22) i=2; - else if(sd->status.class==23) i=3; - else if(sd->status.class==4001) i=4; - else if(sd->status.class<=4007) i=5; + if(sd->status.class_==0) i=0; + else if(sd->status.class_<=6) i=1; + else if(sd->status.class_<=22) i=2; + else if(sd->status.class_==23) i=3; + else if(sd->status.class_==4001) i=4; + else if(sd->status.class_<=4007) i=5; else i=6; return exp_table[i][sd->status.base_level]; @@ -5061,12 +5061,12 @@ int pc_nextjobafter(struct map_session_data *sd) if(sd->status.job_level>=MAX_LEVEL || sd->status.job_level<=0) return 0; - if(sd->status.class==0) i=7; - else if(sd->status.class<=6) i=8; - else if(sd->status.class<=22) i=9; - else if(sd->status.class==23) i=10; - else if(sd->status.class==4001) i=11; - else if(sd->status.class<=4007) i=12; + if(sd->status.class_==0) i=7; + else if(sd->status.class_<=6) i=8; + else if(sd->status.class_<=22) i=9; + else if(sd->status.class_==23) i=10; + else if(sd->status.class_==4001) i=11; + else if(sd->status.class_<=4007) i=12; else i=13; return exp_table[i][sd->status.job_level]; @@ -5104,7 +5104,7 @@ int pc_statusup(struct map_session_data *sd,int type) nullpo_retr(0, sd); - max = (pc_calc_upper(sd->status.class)==2) ? 80 : battle_config.max_parameter; + max = (pc_calc_upper(sd->status.class_)==2) ? 80 : battle_config.max_parameter; need=pc_need_status_point(sd,type); if(typeSP_LUK || need<0 || need>sd->status.status_point){ @@ -5259,7 +5259,7 @@ int pc_skillup(struct map_session_data *sd,int skill_num) if( sd->status.skill_point>0 && sd->status.skill[skill_num].id!=0 && //sd->status.skill[skill_num].lv < skill_get_max(skill_num) ) - celest - sd->status.skill[skill_num].lv < skill_tree_get_max(skill_num, sd->status.class) ) + sd->status.skill[skill_num].lv < skill_tree_get_max(skill_num, sd->status.class_) ) { sd->status.skill[skill_num].lv++; sd->status.skill_point--; @@ -5285,7 +5285,7 @@ int pc_allskillup(struct map_session_data *sd) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); c = s_class.job; s = (s_class.upper==1) ? 1 : 0 ; //?生以外は通常のスキル? @@ -5313,7 +5313,7 @@ int pc_allskillup(struct map_session_data *sd) if(sd->status.skill[id].id==0 && (!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn) ) { sd->status.skill[id].id = id; // celest // sd->status.skill[id].lv=skill_get_max(id); - sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class); // celest + sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); // celest } } } @@ -5351,7 +5351,7 @@ int pc_resetlvl(struct map_session_data* sd,int type) sd->status.int_=1; sd->status.dex=1; sd->status.luk=1; - if(sd->status.class == 4001) + if(sd->status.class_ == 4001) sd->status.status_point=88; } @@ -5416,7 +5416,7 @@ int pc_resetstate(struct map_session_data* sd) // New statpoint table used here - Dexity sd->status.status_point = atoi (statp[sd->status.base_level - 1]); - if(sd->status.class >= 4001 && sd->status.class <= 4024) + if(sd->status.class_ >= 4001 && sd->status.class_ <= 4024) sd->status.status_point+=40; // End addition @@ -5504,7 +5504,7 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage) nullpo_retr(0, sd); //?生や養子の場合の元の職業を算出する - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); // ?に死んでいたら無? if(pc_isdead(sd)) return 0; @@ -5612,7 +5612,7 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage) } if(battle_config.death_penalty_type>0) { // changed penalty options, added death by player if pk_mode [Valaris] - if(sd->status.class != 0 && !map[sd->bl.m].flag.nopenalty && !map[sd->bl.m].flag.gvg){ // only novices will recieve no penalty + if(sd->status.class_ != 0 && !map[sd->bl.m].flag.nopenalty && !map[sd->bl.m].flag.gvg){ // only novices will recieve no penalty if(battle_config.death_penalty_type==1 && battle_config.death_penalty_base > 0) sd->status.base_exp -= (double)pc_nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000; if(battle_config.pk_mode && src && src->type==BL_PC) @@ -5748,7 +5748,7 @@ int pc_readparam(struct map_session_data *sd,int type) int val=0; struct pc_base_job s_class; - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); nullpo_retr(0, sd); @@ -5772,7 +5772,7 @@ int pc_readparam(struct map_session_data *sd,int type) if(val>=24 && val < 45) val+=3978; else - val= sd->status.class; + val= sd->status.class_; break; case SP_BASEJOB: val= s_class.job; @@ -5850,7 +5850,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) nullpo_retr(0, sd); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); switch(type){ case SP_BASELEVEL: @@ -5873,7 +5873,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) // super novices can go up to 99 [celest] else if (s_class.job == 23) up_level += 49; - else if (sd->status.class >= 4008 && sd->status.class <= 4022) + else if (sd->status.class_ >= 4008 && sd->status.class_ <= 4022) up_level += 20; if (val >= sd->status.job_level) { if (val > up_level)val = up_level; @@ -6160,7 +6160,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) int i; int b_class = 0; //?生や養子の場合の元の職業を算出する - struct pc_base_job s_class = pc_calc_base_job(sd->status.class); + struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); nullpo_retr(0, sd); @@ -6188,7 +6188,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if((sd->status.sex == 0 && job == 19) || (sd->status.sex == 1 && job == 20) || // not needed [celest] //(sd->status.sex == 0 && job == 4020) || (sd->status.sex == 1 && job == 4021) || - job == 22 || sd->status.class == b_class) //♀はバ?ドになれない、♂はダンサ?になれない、結婚衣裳もお?り + job == 22 || sd->status.class_ == b_class) //♀はバ?ドになれない、♂はダンサ?になれない、結婚衣裳もお?り return 1; // check if we are changing from 1st to 2nd job @@ -6203,7 +6203,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) pc_setglobalreg (sd, "jobchange_level", sd->change_level); - sd->status.class = sd->view_class = b_class; + sd->status.class_ = sd->view_class = b_class; sd->status.job_level=1; sd->status.job_exp=0; @@ -6369,17 +6369,17 @@ int pc_setriding(struct map_session_data *sd) if((pc_checkskill(sd,KN_RIDING)>0)){ // ライディングスキル所持 pc_setoption(sd,sd->status.option|0x0020); - if(sd->status.class==7) - sd->status.class=sd->view_class=13; + if(sd->status.class_==7) + sd->status.class_=sd->view_class=13; - if(sd->status.class==14) - sd->status.class=sd->view_class=21; + if(sd->status.class_==14) + sd->status.class_=sd->view_class=21; - if(sd->status.class==4008) - sd->status.class=sd->view_class=4014; + if(sd->status.class_==4008) + sd->status.class_=sd->view_class=4014; - if(sd->status.class==4015) - sd->status.class=sd->view_class=4022; + if(sd->status.class_==4015) + sd->status.class_=sd->view_class=4022; } return 0; @@ -6857,7 +6857,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos) // 二刀流?理 if ((pos==0x22) // 一?、?備要求箇所が二刀流武器かチェックする && (id->equip==2) // ? 手武器 - && (pc_checkskill(sd, AS_LEFT) > 0 || pc_calc_base_job2(sd->status.class) == 12) ) // 左手修?有 + && (pc_checkskill(sd, AS_LEFT) > 0 || pc_calc_base_job2(sd->status.class_) == 12) ) // 左手修?有 { int tpos=0; if(sd->equip_index[8] >= 0) @@ -7234,7 +7234,7 @@ int pc_ismarried(struct map_session_data *sd) */ int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd) { - if(sd == NULL || dstsd == NULL || sd->status.partner_id > 0 || dstsd->status.partner_id > 0 || pc_calc_upper(sd->status.class)==2) + if(sd == NULL || dstsd == NULL || sd->status.partner_id > 0 || dstsd->status.partner_id > 0 || pc_calc_upper(sd->status.class_)==2) return -1; sd->status.partner_id=dstsd->status.char_id; dstsd->status.partner_id=sd->status.char_id; @@ -7503,7 +7503,7 @@ static int pc_natural_heal_sp(struct map_session_data *sd) if(sd->nshealsp > 0) { if(sd->inchealsptick >= battle_config.natural_heal_skill_interval && sd->status.sp < sd->status.max_sp) { - struct pc_base_job s_class = pc_calc_base_job(sd->status.class); + struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); if(sd->doridori_counter && s_class.job == 23) bonus = sd->nshealsp*2; else diff --git a/src/map/pet.c b/src/map/pet.c index 80331bd0f..3c87a91e5 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -183,14 +183,14 @@ static int pet_attack(struct pet_data *pd,unsigned int tick,int data) return 0; } - mode=mob_db[pd->class].mode; - race=mob_db[pd->class].race; - if(mob_db[pd->class].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race != 4 && race != 6) ) { + mode=mob_db[pd->class_].mode; + race=mob_db[pd->class_].race; + if(mob_db[pd->class_].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race != 4 && race != 6) ) { pd->target_id=0; return 0; } - range = mob_db[pd->class].range + 1; + range = mob_db[pd->class_].range + 1; if(distance(pd->bl.x,pd->bl.y,md->bl.x,md->bl.y) > range) return 0; if(battle_config.monster_attack_direction_change) @@ -308,15 +308,15 @@ int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type) Assert((pd->msd == 0) || (pd->msd->pd == pd)); - if(bl && pd && bl->type == BL_MOB && sd->pet.intimate > 900 && sd->pet.hungry > 0 && pd->class != battle_get_class(bl) + if(bl && pd && bl->type == BL_MOB && sd->pet.intimate > 900 && sd->pet.hungry > 0 && pd->class_ != battle_get_class(bl) && pd->state.state != MS_DELAY) { - mode=mob_db[pd->class].mode; - race=mob_db[pd->class].race; + mode=mob_db[pd->class_].mode; + race=mob_db[pd->class_].race; md=(struct mob_data *)bl; if(md->bl.type != BL_MOB || pd->bl.m != md->bl.m || md->bl.prev == NULL || distance(pd->bl.x,pd->bl.y,md->bl.x,md->bl.y) > 13) return 0; - if(mob_db[pd->class].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race!=4 && race!=6) ) + if(mob_db[pd->class_].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race!=4 && race!=6) ) return 0; if(!type) { rate = sd->petDB->attack_rate; @@ -541,11 +541,11 @@ int search_petDB_index(int key,int type) int i; for(i=0;ipet.class,PET_CLASS); + i = search_petDB_index(sd->pet.class_,PET_CLASS); if(i < 0) { sd->status.pet_id = 0; return 1; @@ -720,7 +720,7 @@ int pet_data_init(struct map_session_data *sd) pd->bl.y = pd->to_y; pd->bl.id = npc_get_new_npc_id(); memcpy(pd->name,sd->pet.name,24); - pd->class = sd->pet.class; + pd->class_ = sd->pet.class_; pd->equip = sd->pet.equip; pd->dir = sd->dir; pd->speed = sd->petDB->speed; @@ -865,17 +865,17 @@ int pet_catch_process2(struct map_session_data *sd,int target_id) return 1; } - i = search_petDB_index(md->class,PET_CLASS); - if(md == NULL || md->bl.type != BL_MOB || md->bl.prev == NULL || i < 0 || sd->catch_target_class != md->class) { + i = search_petDB_index(md->class_,PET_CLASS); + if(md == NULL || md->bl.type != BL_MOB || md->bl.prev == NULL || i < 0 || sd->catch_target_class != md->class_) { clif_pet_rulet(sd,0); return 1; } //target_idによる敵→卵判定 // if(battle_config.etc_log) -// printf("mob_id = %d, mob_class = %d\n",md->bl.id,md->class); +// printf("mob_id = %d, mob_class = %d\n",md->bl.id,md->class_); //成功の場合 - pet_catch_rate = (pet_db[i].capture + (sd->status.base_level - mob_db[md->class].lv)*30 + sd->paramc[5]*20)*(200 - md->hp*100/mob_db[md->class].max_hp)/100; + pet_catch_rate = (pet_db[i].capture + (sd->status.base_level - mob_db[md->class_].lv)*30 + sd->paramc[5]*20)*(200 - md->hp*100/mob_db[md->class_].max_hp)/100; if(pet_catch_rate < 1) pet_catch_rate = 1; if(battle_config.pet_catch_rate != 100) pet_catch_rate = (pet_catch_rate*battle_config.pet_catch_rate)/100; @@ -885,7 +885,7 @@ int pet_catch_process2(struct map_session_data *sd,int target_id) clif_pet_rulet(sd,1); // if(battle_config.etc_log) // printf("rulet success %d\n",target_id); - intif_create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class,mob_db[pet_db[i].class].lv, + intif_create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class_,mob_db[pet_db[i].class_].lv, pet_db[i].EggID,0,pet_db[i].intimate,100,0,1,pet_db[i].jname); } else @@ -1111,7 +1111,7 @@ static int pet_randomwalk(struct pet_data *pd,int tick) pd->move_fail_count++; if(pd->move_fail_count>1000){ if(battle_config.error_log) - printf("PET cant move. hold position %d, class = %d\n",pd->bl.id,pd->class); + printf("PET cant move. hold position %d, class = %d\n",pd->bl.id,pd->class_); pd->move_fail_count=0; pet_changestate(pd,MS_DELAY,60000); return 0; @@ -1184,15 +1184,15 @@ static int pet_ai_sub_hard(struct pet_data *pd,unsigned int tick) pet_randomwalk(pd,tick); } else if(pd->target_id - MAX_FLOORITEM > 0) { - mode=mob_db[pd->class].mode; - race=mob_db[pd->class].race; + mode=mob_db[pd->class_].mode; + race=mob_db[pd->class_].race; md=(struct mob_data *)map_id2bl(pd->target_id); if(md == NULL || md->bl.type != BL_MOB || pd->bl.m != md->bl.m || md->bl.prev == NULL || distance(pd->bl.x,pd->bl.y,md->bl.x,md->bl.y) > 13) pet_unlocktarget(pd); - else if(mob_db[pd->class].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race!=4 && race!=6) ) + else if(mob_db[pd->class_].mexp <= 0 && !(mode&0x20) && (md->option & 0x06 && race!=4 && race!=6) ) pet_unlocktarget(pd); - else if(!battle_check_range(&pd->bl,&md->bl,mob_db[pd->class].range)){ + else if(!battle_check_range(&pd->bl,&md->bl,mob_db[pd->class_].range)){ if(pd->timer != -1 && pd->state.state == MS_WALK && distance(pd->to_x,pd->to_y,md->bl.x,md->bl.y) < 2) return 0; if( !pet_can_reach(pd,md->bl.x,md->bl.y)) @@ -1641,7 +1641,7 @@ int read_petdb() continue; //MobID,Name,JName,ItemID,EggID,AcceID,FoodID,"Fullness (1回の餌での満腹度増加率%)","HungryDeray (/min)","R_Hungry (空腹時餌やり親密度増加率%)","R_Full (とても満腹時餌やり親密度減少率%)","Intimate (捕獲時親密度%)","Die (死亡時親密度減少率%)","Capture (捕獲率%)",(Name) - pet_db[j].class = nameid; + pet_db[j].class_ = nameid; memcpy(pet_db[j].name,str[1],24); memcpy(pet_db[j].jname,str[2],24); pet_db[j].itemID=atoi(str[3]); diff --git a/src/map/pet.h b/src/map/pet.h index b811735b1..1664f42d5 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -6,7 +6,7 @@ #define PETLOOT_SIZE 20 // [Valaris] struct pet_db { - int class; + int class_; char name[24],jname[24]; int itemID; int EggID; diff --git a/src/map/script.c b/src/map/script.c index 788c755e5..7730c2ed9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3666,10 +3666,10 @@ int buildin_makepet(struct script_state *st) if (pet_id < 0) pet_id = search_petDB_index(id, PET_EGG); if (pet_id >= 0 && sd) { - sd->catch_target_class = pet_db[pet_id].class; + sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet( sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv, + pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } @@ -4426,13 +4426,13 @@ int buildin_changesex(struct script_state *st) { if (sd->status.sex == 0) { sd->status.sex = 1; sd->sex = 1; - if (sd->status.class == 20 || sd->status.class == 4021) - sd->status.class -= 1; + if (sd->status.class_ == 20 || sd->status.class_ == 4021) + sd->status.class_ -= 1; } else if (sd->status.sex == 1) { sd->status.sex = 0; sd->sex = 0; - if(sd->status.class == 19 || sd->status.class == 4020) - sd->status.class += 1; + if(sd->status.class_ == 19 || sd->status.class_ == 4020) + sd->status.class_ += 1; } chrif_char_ask_name(-1, sd->status.name, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex chrif_save(sd); @@ -4978,7 +4978,7 @@ int buildin_maprespawnguildid_sub(struct block_list *bl,va_list ap) pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,3); // end addition [Valaris] } if(md && flag&4){ - if(md->class < 1285 || md->class > 1288) + if(md->class_ < 1285 || md->class_ > 1288) mob_delete(md); } return 0; diff --git a/src/map/skill.c b/src/map/skill.c index af8db17cc..55b531fd7 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2969,7 +2969,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if( dstsd && dstsd->special_state.no_magic_damage ) heal=0; /* ?金蟲カ?ド(ヒ?ル量0) */ if (sd){ - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); if((skill=pc_checkskill(sd,HP_MEDITATIO))>0) // メディテイティオ heal += heal*skill*2/100; if(sd && dstsd && sd->status.partner_id == dstsd->status.char_id && s_class.job == 23 && sd->status.sex == 0) //自分も?象もPC、?象が自分のパ?トナ?、自分がスパノビ、自分が♀なら @@ -3157,8 +3157,8 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int clif_skill_nodamage(src,bl,skillid,skilllv,1); if (dstmd){ for(i=0;iclass == pet_db[i].class){ - pet_catch_process1(sd,dstmd->class); + if(dstmd->class_ == pet_db[i].class_){ + pet_catch_process1(sd,dstmd->class_); break; } } @@ -3391,7 +3391,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case CR_DEVOTION: /* ディボ?ション */ if(sd && dstsd){ //?生や養子の場合の元の職業を算出する - struct pc_base_job dst_s_class = pc_calc_base_job(dstsd->status.class); + struct pc_base_job dst_s_class = pc_calc_base_job(dstsd->status.class_); int lv = sd->status.base_level-dstsd->status.base_level; lv = (lv<0)?-lv:lv; @@ -3457,7 +3457,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int }else if(sd && dstmd){ //?象がモンスタ?の場合 //20%の確率で?象のLv*2のSPを回復する。成功したときはタ?ゲット(σ?Д?)σ????!! if(rand()%100<20){ - i=2*mob_db[dstmd->class].lv; + i=2*mob_db[dstmd->class_].lv; mob_target(dstmd,src,0); } } @@ -4303,7 +4303,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case NPC_PROVOCATION: clif_skill_nodamage(src,bl,skillid,skilllv,1); if(md) - clif_pet_performance(src,mob_db[md->class].skill[md->skillidx].val[0]); + clif_pet_performance(src,mob_db[md->class_].skill[md->skillidx].val[0]); break; case NPC_HALLUCINATION: @@ -4372,18 +4372,18 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int case NPC_SUMMONSLAVE: /* 手下召喚 */ case NPC_SUMMONMONSTER: /* MOB召喚 */ if(md) - mob_summonslave(md,mob_db[md->class].skill[md->skillidx].val,skilllv,(skillid==NPC_SUMMONSLAVE)?1:0); + mob_summonslave(md,mob_db[md->class_].skill[md->skillidx].val,skilllv,(skillid==NPC_SUMMONSLAVE)?1:0); break; case NPC_TRANSFORMATION: case NPC_METAMORPHOSIS: if(md) - mob_class_change(md,mob_db[md->class].skill[md->skillidx].val); + mob_class_change(md,mob_db[md->class_].skill[md->skillidx].val); break; case NPC_EMOTION: /* エモ?ション */ if(md) - clif_emotion(&md->bl,mob_db[md->class].skill[md->skillidx].val[0]); + clif_emotion(&md->bl,mob_db[md->class_].skill[md->skillidx].val[0]); break; case NPC_DEFENDER: @@ -6837,14 +6837,14 @@ static int skill_check_condition_char_sub(struct block_list *bl,va_list ap) nullpo_retr(0, c=va_arg(ap,int *)); nullpo_retr(0, ssd=(struct map_session_data*)src); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); //チェックしない設定ならcにありえない大きな?字を返して終了 if(!battle_config.player_skill_partner_check){ //本?はforeachの前にやりたいけど設定適用箇所をまとめるためにここへ (*c)=99; return 0; } - ss_class = pc_calc_base_job(ssd->status.class); + ss_class = pc_calc_base_job(ssd->status.class_); switch(ssd->skillid){ case PR_BENEDICTIO: /* 聖?降福 */ @@ -6898,7 +6898,7 @@ static int skill_check_condition_use_sub(struct block_list *bl,va_list ap) nullpo_retr(0, c=va_arg(ap,int *)); nullpo_retr(0, ssd=(struct map_session_data*)src); - s_class = pc_calc_base_job(sd->status.class); + s_class = pc_calc_base_job(sd->status.class_); //チェックしない設定ならcにありえない大きな?字を返して終了 if(!battle_config.player_skill_partner_check){ //本?はforeachの前にやりたいけど設定適用箇所をまとめるためにここへ @@ -6906,7 +6906,7 @@ static int skill_check_condition_use_sub(struct block_list *bl,va_list ap) return 0; } - ss_class = pc_calc_base_job(ssd->status.class); + ss_class = pc_calc_base_job(ssd->status.class_); skillid=ssd->skillid; skilllv=ssd->skilllv; //if(skilllv <= 0) return 0; @@ -6967,7 +6967,7 @@ static int skill_check_condition_mob_master_sub(struct block_list *bl,va_list ap nullpo_retr(0, mob_class=va_arg(ap,int)); nullpo_retr(0, c=va_arg(ap,int *)); - if(md->class==mob_class && md->master_id==src_id) + if(md->class_==mob_class && md->master_id==src_id) (*c)++; return 0; } @@ -7782,7 +7782,7 @@ int skill_use_id( struct map_session_data *sd, int target_id, clif_skillcasting( &sd->bl, sd->bl.id, target_id, 0,0, skill_num,casttime); /* 詠唱反?モンスタ? */ - if( bl->type==BL_MOB && (md=(struct mob_data *)bl) && mob_db[md->class].mode&0x10 && + if( bl->type==BL_MOB && (md=(struct mob_data *)bl) && mob_db[md->class_].mode&0x10 && md->state.state!=MS_ATTACK && sd->invincible_timer == -1){ md->target_id=sd->bl.id; md->state.targettype = ATTACKABLE; -- cgit v1.2.3-70-g09d2 From 2c5fabbc0b492cb5456e670ce9eb2352a11d5e3b Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Sun, 23 Jan 2005 20:38:44 +0000 Subject: update git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@968 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 138 +++++++ Dev/bugs.txt | 8 +- conf-tmpl/battle_athena.conf | 4 + db/packet_db.txt | 318 ++++++++------- db/skill_cast_db.txt | 2 +- npc/mobs/fields/yuno.txt | 170 +++++--- sql-files/database.sql | 3 - sql-files/mail.sql | 2 - src/char/char.c | 120 +++--- src/char/char.h | 6 +- src/char/int_guild.c | 24 +- src/char/int_party.c | 8 +- src/char/int_pet.c | 8 +- src/char/int_storage.c | 16 +- src/char/inter.c | 12 +- src/char_sql/char.c | 96 ++--- src/char_sql/char.h | 6 +- src/char_sql/int_guild.c | 196 ++++----- src/char_sql/int_party.c | 2 +- src/char_sql/int_pet.c | 2 +- src/char_sql/int_storage.c | 4 +- src/char_sql/inter.c | 4 +- src/char_sql/itemdb.c | 8 +- src/char_sql/itemdb.h | 2 +- src/common/core.c | 1 + src/common/db.c | 6 +- src/common/grfio.c | 68 ++-- src/common/grfio.h | 4 +- src/common/malloc.c | 23 +- src/common/malloc.h | 20 + src/common/mmo.h | 32 +- src/common/showmsg.c | 5 +- src/common/socket.c | 64 +-- src/common/socket.h | 3 +- src/common/strlib.c | 22 +- src/common/strlib.h | 6 +- src/common/timer.c | 10 +- src/common/utils.c | 9 +- src/common/utils.h | 6 + src/ladmin/ladmin.c | 10 +- src/login/login.c | 90 +++-- src/login/login.h | 2 +- src/login_sql/login.c | 26 +- src/login_sql/login.h | 2 +- src/map/atcommand.c | 164 ++++---- src/map/atcommand.h | 10 +- src/map/battle.c | 169 +++++--- src/map/battle.h | 7 +- src/map/charcommand.c | 4 +- src/map/chat.c | 6 +- src/map/clif.c | 388 ++++++++++-------- src/map/clif.h | 14 +- src/map/guild.c | 36 +- src/map/guild.h | 2 +- src/map/intif.c | 10 +- src/map/intif.h | 2 +- src/map/itemdb.c | 14 +- src/map/mail.c | 56 +-- src/map/map.c | 195 ++++----- src/map/map.h | 11 +- src/map/mob.c | 636 +++++++++++++++--------------- src/map/mob.h | 6 +- src/map/npc.c | 226 +++++------ src/map/party.c | 2 +- src/map/pc.c | 246 ++++++++---- src/map/pet.c | 4 +- src/map/script.c | 240 +++++------ src/map/skill.c | 536 ++++++++++++++++++------- src/map/skill.h | 15 +- src/map/storage.c | 12 +- src/map/vending.c | 6 +- src/txt-converter/char/char-converter.c | 106 ++--- src/txt-converter/char/char.h | 6 +- src/txt-converter/common/mmo.h | 10 +- src/txt-converter/login/login-converter.c | 8 +- 75 files changed, 2740 insertions(+), 1975 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index 6c019b932..4defcf648 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,142 @@ Date Added + +01/23 + * Forgot a couple small changes [SVN 35] [Ajarn] + * Changed map_data.gat and map_data_other_server.gat from unsigned char* + to char* (this might be needed, because of unicode or something, please + correct me if I'm wrong) [SVN 34] [Ajarn] + * Converted decode_zip, enconde_zip, remove_control_chars, mapif_sendall*, + and e_mail_check to use char* instead of unsigned char* (again, please test) + [SVN 34] [Ajarn] + * Modified skill unit group checking in skill_unit_onplace that might have + been causing crashes [celest] + * Updated packet 0x143 length's for version 14 (2004-11-01Sakexe) and version + 16 (2005-01-10Sakexe), thanks to jathena and ice2big [celest] + * Fixed login-server compile error with the "new" -> "new_" changes [celest] + +01/22 + * Fixed an error that was in my last commit (optimising g++ build) [SVN 29] + [Ajarn] + * Made strlib functions char*, instead of unsigned char*. Strings are meant + to be char. (Shouldn't break anyhting, but might, please test this for me) + [SVN 26] [Ajarn] + * Added cast for TXT version [SVN 25] [Ajarn] + * Added cast from allocation calls, from void* to intended type [SVN 24] [Ajarn] + * Changed bool -> bool_. Still need to make convertions between + char* and unsigned char* valid, and some other convertions too. + Also, sizeof is being used wierd in map.c, at least g++ + complains [SVN 22] [Ajarn] + * Changed the rest of the class variable names to class_ and all the new + variable names to new_, for futher g++ support [SVN 21] [Ajarn] + * Update both caster and target's SP after using Soul Change -- thanks to Aalye + / Freya [celest] + * Force a monster to switch attack target when being casted Provoke [celest] + * Corrected description for @enablenpc -- "@npcon" -> "@enablenpc" [celest] + * Since job normalising is still buggy require all 1st class skills to check + for Basic Skill level when calculating the skill tree [celest] + +01/21 + * Updated packet DB configurations : enable_packet_db, packet_db_ver, + -- check the .txt for description [celest] + + Note: For people having connection problems try setting 'enable_packet_db' + to 'no'... and use the latest client (01-10Sakexe) + + * Fixed a small typo in 12-06's packets -- 21b => 21d [celest] + * Updated packet_db.txt to only contain the latest version, like jAthena, + since there's not much point to re-read packets eA already supports + (although if you remove all the //'s it can still read multiple versions) + [celest] + * Added clif_config in clif.c - for keeping packet/client connections related + stuff [celest] + * Send 'Game Exe not latest version' to a client if it hasn't been authentified + yet, but is sending a non-connection-related packet to prevent crashing + -- assume the client is using an unknown exe [celest] + +01/20 + * Fixed compile time problems with the non-GC case [MouseJstr] + * Introduced aMallocA and aCallocA + + These two functions allocate "atomic" memory which means + "memory that does not contain references to other memory". + + This lets the garbage collector ignore these objects when searching + memory for references to other objects dramatically increasing + performance of the GC. + + When in doubt, use aMalloc and aCalloc. It is better to add + a tiny bit of work to the GC then do cause a crash due to memory + being cleaned up when it shouldn't. + [MouseJstr] + * Modified all calls to aMalloc and aCalloc that reference + atomic memory to use aMallocA and aCallocA + [MouseJstr] + * Modified the socket buffer allocator to use "atomic" memory + for the fifo data buffers [MouseJstr] +01/19 + * added support for the Hans-J. Boehm libC garbage collector + (A copy is in http://amber.stormbirds.org/~joshs/gc6.3.tar). + + It is ABSOLUTELY critical for people to use + aFree/aMalloc/aCalloc/aStrdup for this to work. If somebody + has just used free or malloc, this will crash when used with + the garbage collector. + + A amusing environmental variable to set is GC_PRINT_STATS (to 1) + so that you see real time statistics of leaked data being + recovered. + + grab a copy of the gc6.3.tar.. build it .. install it.. + modify the Makefile to have the + + CC = gcc -pipe -DGCOLLECT + GCLIB = -lgc + + lines... and make the sql servers (the txt server doesn't + build using this right now due to stupid Makefile issues) + + [MouseJstr] + * SVN 3 on http://svn.stormbirds.org/svn/eathena will be what + I diff against when I merge back into delta.. if we ever merge + back into delta [MouseJstr] + * Removed 12-06 Sakexe detection, since it doesn't seem to work, and + might be conflicting with 10-25 clients [celest] + * Update the Soul Burn target's SP when it has been successfully reduced to 0, + thanks to Aalye / Freya [celest] + * Moved SC_PRESERVE and SC_BATTLEORDERS's id so they'll display a status icon + when cast, thanks XiaoLin of cAthena [celest] + * Added missing code for Preserve -- i totally forgot to add it ^^; [celest] + +01/18 + * Added some skill bug fixes, thanks to Aalye / Freya [celest] + - stop player attacking if the target goes into hiding + - fixed Sword Reject not working against swords, only daggers + - additional check in case Marionette Control doesn't end properly even + when one of the partners has logged off + * Added stun, bleeding and SP loss effect for Pressure, thanks to DracoRpg + [celest] + * TEST: Fixed more compile warnings in MSVC [celest] + * TEST: Fixed some compile errors in MS Visual C++, thanks to Ser [celest] + +01/17 + * Some rewrites in skill_delayfix [celest] + - If the delay is < 0, add the weapon aspd delay to it + - If the skill is not weapon type, and has 0 delay, add 300ms as default + * Added min_skill_delay_limit as the minimum allowed delay for any skills + [celest] + * Some tidying up in battle_get_ functions [celest] + * Set exp table and job bonus table to 0 before reading - might solve some + memory bugs [celest] + * Updated skill range leniency code - If possible try and move towards the + skill target so that when casting it no longer falls out of range [celest] + +01/15 + * Added effects to enemies for Gospel [celest] + * Added mobs spawn to all Yuno fields (according to 4th Jan patch) [Lupus] + +01/14 + * Added party supporting effects for Gospel [celest] + 01/13 * Added and testing support for 2004-12-06Sakexe [celest] * Removed emblem changing requiring Glory of Guild limited to TXT only [celest] diff --git a/Dev/bugs.txt b/Dev/bugs.txt index bc85d6272..a1108f3a3 100644 --- a/Dev/bugs.txt +++ b/Dev/bugs.txt @@ -221,9 +221,7 @@ Problem: Berzebub, etc cards don't decrease aftercast delays Assigned: N/A Progress: 0% -Problem: Some clients that are able to log into eAthena servers properly are not able to when custom items are used. - I believe Celest may have accidentially "broken" a few things when she was attempting to create new packet - compatibility and removed old ones. +Problem: Older Clients are unable to log into the server, period. + Even if the packet_db is set to use the older clients, they still are unable to connect. Assigned: Celest -Progress: 0% - Celest: What version was the client using? \ No newline at end of file +Progress: 0% \ No newline at end of file diff --git a/conf-tmpl/battle_athena.conf b/conf-tmpl/battle_athena.conf index 9f7bd11a8..35b20f7d9 100644 --- a/conf-tmpl/battle_athena.conf +++ b/conf-tmpl/battle_athena.conf @@ -46,6 +46,10 @@ delay_rate: 100 // Note: On Official servers Dex does NOT affect delay time delay_dependon_dex: no +// Minimum allowed delay for ANY skills after casting (in miliseconds) (Note 1) +// Note: Setting this to anything above 0 can stop speedhacks. +min_skill_delay_limit: 100 + // At what dex does the cast time become zero (instacast) castrate_dex_scale: 150 diff --git a/db/packet_db.txt b/db/packet_db.txt index 28ae52fee..95591eacf 100644 --- a/db/packet_db.txt +++ b/db/packet_db.txt @@ -1,11 +1,23 @@ // The packet database allows you to add support for new clients, -// because packets change every release. -// This only allows 1 type of client at a time, make sure your +// because packets change every release. +// By default this only allows 1 type of client at a time, make sure your // client is the last one in the list // EX: You have client 628 and it goes up to 1021, // delete or comment (use //) till your client is last. -packet_ver: 5 + +// Whether to allow identifying clients via the packet DB +enable_packet_db: yes + +// Main packet version of the DB (default = Auto Detect) +packet_db_ver: default + +// Whether the packet DB takes higher precedence over the hardcoded packet +// length and functions, and whether to overwrite them when reading +prefer_packet_db: yes + + +// packet_ver: 5 0x0064,55 0x0065,17 0x0066,3 @@ -438,182 +450,182 @@ packet_ver: 5 //jROはここまで //2004-07-06kRO -packet_ver: 6 -0x0072,22,wanttoconnection,5:9:13:17:21 -0x0085,8,walktoxy,5 -0x00a7,13,useitem,5:9 -0x0113,15,useskilltoid,4:9:11 -0x0116,15,useskilltopos,4:9:11:13 -0x0190,95,useskilltopos,4:9:11:13:15 +// packet_ver: 6 +// 0x0072,22,wanttoconnection,5:9:13:17:21 +// 0x0085,8,walktoxy,5 +// 0x00a7,13,useitem,5:9 +// 0x0113,15,useskilltoid,4:9:11 +// 0x0116,15,useskilltopos,4:9:11:13 +// 0x0190,95,useskilltopos,4:9:11:13:15 //2004-07-13kRO -packet_ver: 7 -0x0072,39,wanttoconnection,12:22:30:34:38 -0x0085,9,walktoxy,6 -0x009b,13,changedir,5:12 -0x009f,10,takeitem,6 -0x00a7,17,useitem,6:13 -0x0113,19,useskilltoid,7:9:15 -0x0116,19,useskilltopos,7:9:15:17 -0x0190,99,useskilltopos,7:9:15:17:19 +// packet_ver: 7 +// 0x0072,39,wanttoconnection,12:22:30:34:38 +// 0x0085,9,walktoxy,6 +// 0x009b,13,changedir,5:12 +// 0x009f,10,takeitem,6 +// 0x00a7,17,useitem,6:13 +// 0x0113,19,useskilltoid,7:9:15 +// 0x0116,19,useskilltopos,7:9:15:17 +// 0x0190,99,useskilltopos,7:9:15:17:19 //2004-07-26kRO -packet_ver: 8 -0x0072,14,dropitem,5:12 -0x007e,33,wanttoconnection,12:18:24:28:32 -0x0085,20,useskilltoid,7:12:16 -0x0089,15,getcharnamerequest,11 -0x008c,23,useskilltopos,3:6:17:21 -0x0094,10,takeitem,6 -0x009b,6,walktoxy,3 -0x009f,13,changedir,5:12 -0x00a2,103,useskilltopos,3:6:17:21:23 -0x00a7,12,solvecharname,8 -0x00f3,-1,globalmessage,2:4 -0x00f5,17,useitem,6:12 -0x00f7,10,ticksend,6 -0x0113,16,movetokafra,5:12 -0x0116,2,closekafra,0 -0x0190,26,movefromkafra,10:22 -0x0193,9,actionrequest,3:8 +// packet_ver: 8 +// 0x0072,14,dropitem,5:12 +// 0x007e,33,wanttoconnection,12:18:24:28:32 +// 0x0085,20,useskilltoid,7:12:16 +// 0x0089,15,getcharnamerequest,11 +// 0x008c,23,useskilltopos,3:6:17:21 +// 0x0094,10,takeitem,6 +// 0x009b,6,walktoxy,3 +// 0x009f,13,changedir,5:12 +// 0x00a2,103,useskilltopos,3:6:17:21:23 +// 0x00a7,12,solvecharname,8 +// 0x00f3,-1,globalmessage,2:4 +// 0x00f5,17,useitem,6:12 +// 0x00f7,10,ticksend,6 +// 0x0113,16,movetokafra,5:12 +// 0x0116,2,closekafra,0 +// 0x0190,26,movefromkafra,10:22 +// 0x0193,9,actionrequest,3:8 //2004-08-09kRO -packet_ver: 9 -0x0072,17,dropitem,8:15 +// packet_ver: 9 +// 0x0072,17,dropitem,8:15 //9, +12, +7, +4, +4 -0x007e,37,wanttoconnection,9:21:28:32:36 -0x0085,26,useskilltoid,11:18:22 -0x0089,12,getcharnamerequest,8 -0x008c,40,useskilltopos,5:15:29:38 -0x0094,13,takeitem,9 -0x009b,15,walktoxy,12 -0x009f,12,changedir,7:11 -0x00a2,120,useskilltopos,5:15:29:38:40 -0x00a7,11,solvecharname,7 -0x00f5,24,useitem,9:20 -0x00f7,13,ticksend,9 -0x0113,23,movetokafra,5:19 -0x0190,26,movefromkafra,11:22 -0x0193,18,actionrequest,7:17 +// 0x007e,37,wanttoconnection,9:21:28:32:36 +// 0x0085,26,useskilltoid,11:18:22 +// 0x0089,12,getcharnamerequest,8 +// 0x008c,40,useskilltopos,5:15:29:38 +// 0x0094,13,takeitem,9 +// 0x009b,15,walktoxy,12 +// 0x009f,12,changedir,7:11 +// 0x00a2,120,useskilltopos,5:15:29:38:40 +// 0x00a7,11,solvecharname,7 +// 0x00f5,24,useitem,9:20 +// 0x00f7,13,ticksend,9 +// 0x0113,23,movetokafra,5:19 +// 0x0190,26,movefromkafra,11:22 +// 0x0193,18,actionrequest,7:17 //2004-08-16aSakexe -0x020f,0 -0x0210,0 -0x0211,0 -0x0212,26 -0x0213,26 -0x0214,42 +// 0x020f,0 +// 0x0210,0 +// 0x0211,0 +// 0x0212,26 +// 0x0213,26 +// 0x0214,42 //2004-08-17aSakexe -0x020f,10 -0x0210,22 +// 0x020f,10 +// 0x0210,22 //2004-09-06aSakexe -packet_ver: 10 +// packet_ver: 10 //0x0072,20,useitem,9:20 -0x007e,19,movetokafra,3:15 -0x0085,23,actionrequest,9:22 -0x0089,9,walktoxy,6 -0x008c,105,useskilltopos,10:14:18:23:25 -0x0094,17,dropitem,6:15 -0x009b,14,getcharnamerequest,10 -0x009f,-1,globalmessage,2:4 -0x00a2,14,solvecharname,10 -0x00a7,25,useskilltopos,10:14:18:23 -0x00f3,10,changedir,4:9 +// 0x007e,19,movetokafra,3:15 +// 0x0085,23,actionrequest,9:22 +// 0x0089,9,walktoxy,6 +// 0x008c,105,useskilltopos,10:14:18:23:25 +// 0x0094,17,dropitem,6:15 +// 0x009b,14,getcharnamerequest,10 +// 0x009f,-1,globalmessage,2:4 +// 0x00a2,14,solvecharname,10 +// 0x00a7,25,useskilltopos,10:14:18:23 +// 0x00f3,10,changedir,4:9 //7, +7, +10, +4, +6 -0x00f5,34,wanttoconnection,7:15:25:29:33 -0x00f7,2,closekafra,0 -0x0113,11,takeitem,7 -0x0116,11,ticksend,7 -0x0190,22,useskilltoid,9:15:18 -0x0193,17,movefromkafra,3:13 +// 0x00f5,34,wanttoconnection,7:15:25:29:33 +// 0x00f7,2,closekafra,0 +// 0x0113,11,takeitem,7 +// 0x0116,11,ticksend,7 +// 0x0190,22,useskilltoid,9:15:18 +// 0x0193,17,movefromkafra,3:13 //2004-09-21aSakexe by Sara -packet_ver: 11 -0x0072,18,useitem,10:14 -0x007e,25,movetokafra,6:21 -0x0085,9,actionrequest,3:8 -0x0089,14,walktoxy,11 -0x008c,109,useskilltopos,16:20:23:27:29 -0x0094,19,dropitem,12:17 -0x00a2,10,solvecharname,6 -0x00a7,29,useskilltopos,6:20:23:27 -0x00f3,18,changedir,8:17 -0x00f5,32,wanttoconnection,10:17:23:27:31 -0x009b,10,getcharnamerequest,6 -0x0113,14,takeitem,10 -0x0116,14,ticksend,10 -0x0190,14,useskilltoid,4:7:10 -0x0193,12,movefromkafra,4:8 +// packet_ver: 11 +// 0x0072,18,useitem,10:14 +// 0x007e,25,movetokafra,6:21 +// 0x0085,9,actionrequest,3:8 +// 0x0089,14,walktoxy,11 +// 0x008c,109,useskilltopos,16:20:23:27:29 +// 0x0094,19,dropitem,12:17 +// 0x00a2,10,solvecharname,6 +// 0x00a7,29,useskilltopos,6:20:23:27 +// 0x00f3,18,changedir,8:17 +// 0x00f5,32,wanttoconnection,10:17:23:27:31 +// 0x009b,10,getcharnamerequest,6 +// 0x0113,14,takeitem,10 +// 0x0116,14,ticksend,10 +// 0x0190,14,useskilltoid,4:7:10 +// 0x0193,12,movefromkafra,4:8 //2004-10-11aSakexe by Sara -packet_ver: 12 -0x0072,17,useitem,6:13 -0x007e,16,movetokafra,5:12 -0x0089,6,walktoxy,3 -0x008c,103,useskilltopos,2:6:17:21:23 -0x0094,14,dropitem,5:12 -0x009b,15,getcharnamerequest,11 -0x00a2,12,solvecharname,8 -0x00a7,23,useskilltopos,3:6:17:21 -0x00f3,13,changedir,5:12 -0x00f5,33,wanttoconnection,12:18:24:28:32 -0x0113,10,takeitem,6 -0x0116,10,ticksend,6 -0x0190,20,useskilltoid,7:12:16 -0x0193,26,movefromkafra,10:22 +// packet_ver: 12 +// 0x0072,17,useitem,6:13 +// 0x007e,16,movetokafra,5:12 +// 0x0089,6,walktoxy,3 +// 0x008c,103,useskilltopos,2:6:17:21:23 +// 0x0094,14,dropitem,5:12 +// 0x009b,15,getcharnamerequest,11 +// 0x00a2,12,solvecharname,8 +// 0x00a7,23,useskilltopos,3:6:17:21 +// 0x00f3,13,changedir,5:12 +// 0x00f5,33,wanttoconnection,12:18:24:28:32 +// 0x0113,10,takeitem,6 +// 0x0116,10,ticksend,6 +// 0x0190,20,useskilltoid,7:12:16 +// 0x0193,26,movefromkafra,10:22 //2004-10-25aSakexe by Sara -packet_ver: 13 -0x0072,13,useitem,5:9 -0x007e,13,movetokafra,6:9 -0x0085,15,actionrequest,4:14 -0x008c,108,useskilltopos,6:9:23:26:28 -0x0094,12,dropitem,6:10 -0x009b,10,getcharnamerequest,6 -0x00a2,16,solvecharname,12 -0x00a7,28,useskilltopos,6:9:23:26 -0x00f3,15,changedir,6:14 -0x00f5,29,wanttoconnection,5:14:20:24:28 -0x0113,9,takeitem,5 -0x0116,9,ticksend,5 -0x0190,26,useskilltoid,4:10:22 -0x0193,22,movefromkafra,12:18 +// packet_ver: 13 +// 0x0072,13,useitem,5:9 +// 0x007e,13,movetokafra,6:9 +// 0x0085,15,actionrequest,4:14 +// 0x008c,108,useskilltopos,6:9:23:26:28 +// 0x0094,12,dropitem,6:10 +// 0x009b,10,getcharnamerequest,6 +// 0x00a2,16,solvecharname,12 +// 0x00a7,28,useskilltopos,6:9:23:26 +// 0x00f3,15,changedir,6:14 +// 0x00f5,29,wanttoconnection,5:14:20:24:28 +// 0x0113,9,takeitem,5 +// 0x0116,9,ticksend,5 +// 0x0190,26,useskilltoid,4:10:22 +// 0x0193,22,movefromkafra,12:18 //2004-11-01aSakexe by Sara -packet_ver: 14 -0x0215,6 -0x0143,23,npcamountinput,2:6 -0x0145,19 +// packet_ver: 14 +// 0x0215,6 +// 0x0143,23,npcamountinput,2:6 +// 0x0145,19 //0x01f9,6,adopt,5 //2004-12-06aSakexe -packet_ver: 15 -0x0190,15,useitem,3:11 -0x0094,14,movetokafra,4:10 -0x009f,18,actionrequest,6:17 -0x00a7,7,walktoxy,4 -0x007e,30,useskilltopos,4:9:22:28 -0x0116,12,dropitem,4:10 -0x008c,13,getcharnamerequest,9 -0x0085,-1,globalmessage,2:4 -0x00f7,14,solvecharname,10 -0x0113,110,useskilltopos,4:9:22:28:30 -0x00f3,8,changedir,3:7 -0x00f5,29,wanttoconnection,3:10:20:24:28 -0x00a2,7,takeitem,3 -0x0089,7,ticksend,3 -0x0072,22,useskilltoid,8:12:18 -0x0193,21,movefromkafra,4:17 -0x009b,2,closekafra,0 -0x0222,6 -0x0221,-1 -0x021d,6 -0x0223,8 +// packet_ver: 15 +// 0x0190,15,useitem,3:11 +// 0x0094,14,movetokafra,4:10 +// 0x009f,18,actionrequest,6:17 +// 0x00a7,7,walktoxy,4 +// 0x007e,30,useskilltopos,4:9:22:28 +// 0x0116,12,dropitem,4:10 +// 0x008c,13,getcharnamerequest,9 +// 0x0085,-1,globalmessage,2:4 +// 0x00f7,14,solvecharname,10 +// 0x0113,110,useskilltopos,4:9:22:28:30 +// 0x00f3,8,changedir,3:7 +// 0x00f5,29,wanttoconnection,3:10:20:24:28 +// 0x00a2,7,takeitem,3 +// 0x0089,7,ticksend,3 +// 0x0072,22,useskilltoid,8:12:18 +// 0x0193,21,movefromkafra,4:17 +// 0x009b,2,closekafra,0 +// 0x0222,6 +// 0x0221,-1 +// 0x021d,6 +// 0x0223,8 //2005-01-10bSakexe by Sara -packet_ver: 16 +// packet_ver: 16 0x009b,32,wanttoconnection,3:12:23:27:31 0x0089,9,ticksend,5 0x00a7,13,walktoxy,10 @@ -631,5 +643,7 @@ packet_ver: 16 0x0072,26,useskilltoid,8:16:22 0x007e,114,useskilltopos,9:18:22:32:34 0x00a2,11,solvecharname,7 +0x0143,10,npcamountinput,2:6 -packet_ver: 17 \ No newline at end of file +// packet_ver: 17 +// Add new packets here \ No newline at end of file diff --git a/db/skill_cast_db.txt b/db/skill_cast_db.txt index af93d845d..774ca5aa0 100644 --- a/db/skill_cast_db.txt +++ b/db/skill_cast_db.txt @@ -32,7 +32,7 @@ 35,0,1000,0,0 //AL_CURE#キュアー# 45,0,0,60000:80000:100000:120000:140000:160000:180000:200000:220000:240000,0 //AC_CONCENTRATION#集中力向上# -46,0,1500,100,0 //AC_DOUBLE +46,0,-300,100,0 //AC_DOUBLE 47,0,1500,100,0 //AC_SHOWER 51,0,0,30000:60000:90000:120000:150000:180000:210000:240000:270000:300000,0 //TF_HIDING#ハイディング# diff --git a/npc/mobs/fields/yuno.txt b/npc/mobs/fields/yuno.txt index 7b0cbbb27..dd0f67335 100644 --- a/npc/mobs/fields/yuno.txt +++ b/npc/mobs/fields/yuno.txt @@ -3,58 +3,136 @@ //===== By: ================================================== //= Athena (1.0) //===== Current Version: ===================================== -//= 1.1 +//= 1.3 //===== Compatible With: ===================================== //= Any Athena Version //===== Additional Comments: ================================= //= 1.1 fixed tabs, names [Lupus] +//= 1.2 New/Better Spawn [Muad_Dib] +//= 1.3 Fix Up [Darkchild] //============================================================ -//(yuno_fild04.gat)* -yuno_fild04.gat,0,0,0,0 monster Goat 1372,40,0,0,0 -yuno_fild04.gat,0,0,0,0 monster Sleeper 1386,5,0,0,0 -yuno_fild04.gat,0,0,0,0 monster The Paper 1375,3,0,0,0 -yuno_fild04.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 -yuno_fild04.gat,0,0,0,0 monster Driller 1380,10,0,0,0 -yuno_fild04.gat,0,0,0,0 monster Poring 1002,20,0,0,0 +//======================================================================================== +// - Yuno Field 01 +//======================================================================================== + +yuno_fild01.gat,0,0,0,0 monster Poring 1002,55,0,0,0 +yuno_fild01.gat,0,0,0,0 monster Poporing 1031,35,0,0,0 +yuno_fild01.gat,0,0,0,0 monster Dustiness 1114,25,0,0,0 +yuno_fild01.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 +yuno_fild01.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 +yuno_fild01.gat,0,0,0,0 monster Shining Plant 1083,5,1800000,900000,1 +yuno_fild01.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 + +//======================================================================================== +// - Yuno Field 02 +//======================================================================================== + +yuno_fild02.gat,0,0,0,0 monster Sageworm 1281,5,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Dustiness 1114,15,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Kind of Beetle 1494,15,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Horn 1128,35,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Stainer 1174,25,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Wild Rose 1261,15,0,0,0 +yuno_fild02.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 +yuno_fild02.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 +yuno_fild02.gat,0,0,0,0 monster Green Plant 1080,15,180000,90000,1 + +//======================================================================================== +// - Yuno Field 03 +//======================================================================================== + +yuno_fild03.gat,0,0,0,0 monster Drops 1113,30,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Poring 1002,40,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Sidewinder 1037,5,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Poporing 1031,20,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Marin 1242,20,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Geographer 1368,15,0,0,0 +yuno_fild03.gat,0,0,0,0 monster Archangeling 1388,1,3600000,1800000,1 +yuno_fild03.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 +yuno_fild03.gat,0,0,0,0 monster Green Plant 1080,50,180000,90000,1 +yuno_fild03.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 + +//======================================================================================== +// - Yuno Field 04 +//======================================================================================== + +yuno_fild04.gat,0,0,0,0 monster Poring 1002,50,0,0,0 +yuno_fild04.gat,0,0,0,0 monster Pupa 1008,15,0,0,0 +yuno_fild04.gat,0,0,0,0 monster Drops 1113,30,0,0,0 +yuno_fild04.gat,0,0,0,0 monster Condor 1009,15,0,0,0 +yuno_fild04.gat,0,0,0,0 monster Creamy 1018,10,0,0,0 yuno_fild04.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 yuno_fild04.gat,0,0,0,0 monster Red Plant 1078,10,180000,90000,1 yuno_fild04.gat,0,0,0,0 monster Yellow Plant 1081,10,360000,180000,1 -yuno_fild04.gat,0,0,0,0 monster Harpy 1376,1,0,0,0 - -//(yuno_fild03.gat)* -yuno_fild03.gat,0,0,0,0 monster Goat 1372,60,0,0,0 -yuno_fild03.gat,0,0,0,0 monster Sleeper 1386,30,0,0,0 -yuno_fild03.gat,0,0,0,0 monster The Paper 1375,3,0,0,0 -yuno_fild03.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 -yuno_fild03.gat,0,0,0,0 monster Demon Pungus 1378,30,0,0,0 -yuno_fild03.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 -yuno_fild03.gat,0,0,0,0 monster Shining Plant 1083,2,1800000,900000,1 -yuno_fild03.gat,0,0,0,0 monster Blue Plant 1079,4,360000,180000,1 -yuno_fild03.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 -yuno_fild03.gat,0,0,0,0 monster Harpy 1376,2,0,0,0 - -//(yuno_fild02.gat)* -yuno_fild02.gat,0,0,0,0 monster Sleeper 1386,10,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Grand Peco 1369,70,0,0,0 -yuno_fild02.gat,0,0,0,0 monster The Paper 1375,1,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Driller 1380,30,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Dustiness 1114,20,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Poring 1002,20,0,0,0 -yuno_fild02.gat,0,0,0,0 monster Red Plant 1078,20,180000,90000,1 -yuno_fild02.gat,0,0,0,0 monster Shining Plant 1083,1,1800000,900000,1 -yuno_fild02.gat,0,0,0,0 monster Blue Plant 1079,3,360000,180000,1 -yuno_fild02.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 -yuno_fild02.gat,0,0,0,0 monster Archangeling 1388,1,3600000,1800000,1 - -//(yuno_fild01.gat)* -yuno_fild01.gat,0,0,0,0 monster Grand Peco 1369,3,0,0,0 -yuno_fild01.gat,0,0,0,0 monster Dustiness 1114,50,0,0,0 -yuno_fild01.gat,0,0,0,0 monster Poporing 1031,20,0,0,0 -yuno_fild01.gat,0,0,0,0 monster Poring 1002,20,0,0,0 -yuno_fild01.gat,0,0,0,0 monster Green Plant 1080,20,180000,90000,1 -yuno_fild01.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 -yuno_fild01.gat,0,0,0,0 monster Shining Plant 1083,3,1800000,900000,1 -yuno_fild01.gat,0,0,0,0 monster Blue Plant 1079,2,360000,180000,1 -yuno_fild01.gat,0,0,0,0 monster Yellow Plant 1081,23,360000,180000,1 + +//======================================================================================== +// - Yuno Field 05 +//======================================================================================== + +yuno_fild05.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 +yuno_fild05.gat,0,0,0,0 monster Goat 1372,5,0,0,0 +yuno_fild05.gat,0,0,0,0 monster Demon Pungus 1378,20,0,0,0 +yuno_fild05.gat,0,0,0,0 monster Sleeper 1386,45,0,0,0 +yuno_fild05.gat,0,0,0,0 monster The Paper 1375,15,0,0,0 +yuno_fild05.gat,0,0,0,0 monster Green Plant 1080,5,180000,90000,1 +yuno_fild05.gat,0,0,0,0 monster Yellow Plant 1081,10,360000,180000,1 +yuno_fild05.gat,0,0,0,0 monster Red Plant 1078,5,180000,90000,1 + +//======================================================================================== +// - Yuno Field 07 +//======================================================================================== + +yuno_fild07.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 +yuno_fild07.gat,0,0,0,0 monster Goat 1372,60,0,0,0 +yuno_fild07.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 +yuno_fild07.gat,0,0,0,0 monster Red Plant 1078,10,180000,90000,1 +yuno_fild07.gat,0,0,0,0 monster Yellow Plant 1081,15,360000,180000,1 + +//======================================================================================== +// - Yuno Field 08 +//======================================================================================== + +yuno_fild08.gat,0,0,0,0 monster Grand Peco 1369,20,0,0,0 +yuno_fild08.gat,0,0,0,0 monster Dustiness 1114,30,0,0,0 +yuno_fild08.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 +yuno_fild08.gat,0,0,0,0 monster Wild Rose 1261,15,0,0,0 +yuno_fild08.gat,0,0,0,0 monster Red Plant 1078,15,180000,90000,1 +yuno_fild08.gat,0,0,0,0 monster Yellow Plant 1081,20,360000,180000,1 +yuno_fild08.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 + +//======================================================================================== +// - Yuno Field 09 +//======================================================================================== + +yuno_fild09.gat,0,0,0,0 monster Gargoyle 1253,10,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Dustiness 1114,20,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1122,10,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1123,5,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1124,10,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1125,5,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Goblin 1126,5,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Horn 1128,25,0,0,0 +yuno_fild09.gat,0,0,0,0 monster Red Plant 1078,10,180000,90000,1 +yuno_fild09.gat,0,0,0,0 monster Yellow Plant 1081,15,360000,180000,1 +yuno_fild09.gat,0,0,0,0 monster Green Plant 1080,15,180000,90000,1 + +//======================================================================================== +// - Yuno Field 11 +//======================================================================================== + +yuno_fild11.gat,0,0,0,0 monster Sleeper 1386,55,0,0,0 +yuno_fild11.gat,0,0,0,0 monster Geographer 1368,20,0,0,0 +yuno_fild11.gat,0,0,0,0 monster Red Plant 1078,10,180000,90000,1 +yuno_fild11.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 +yuno_fild11.gat,0,0,0,0 monster Yellow Plant 1081,15,360000,180000,1 + +//======================================================================================== +// - Yuno Field 12 +//======================================================================================== + +yuno_fild12.gat,0,0,0,0 monster Dustiness 1114,35,0,0,0 +yuno_fild12.gat,0,0,0,0 monster Demon Pungus 1378,20,0,0,0 +yuno_fild12.gat,0,0,0,0 monster Green Plant 1080,10,180000,90000,1 +yuno_fild12.gat,0,0,0,0 monster Red Plant 1078,5,180000,90000,1 +yuno_fild12.gat,0,0,0,0 monster Yellow Plant 1081,10,360000,180000,1 diff --git a/sql-files/database.sql b/sql-files/database.sql index 9700ddb3a..1c379859f 100644 --- a/sql-files/database.sql +++ b/sql-files/database.sql @@ -1,6 +1,3 @@ -DROP DATABASE erag; -CREATE DATABASE erag; -USE erag; CREATE TABLE `item_db` ( `id` smallint(5) unsigned NOT NULL default '0', `name_english` varchar(24) NOT NULL default '', diff --git a/sql-files/mail.sql b/sql-files/mail.sql index 201142d59..62cc9d65d 100644 --- a/sql-files/mail.sql +++ b/sql-files/mail.sql @@ -1,5 +1,3 @@ -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `ragnarok`; -USE `ragnarok`; CREATE TABLE `mail` ( `message_id` int(11) NOT NULL auto_increment, `to_account_id` int(11) NOT NULL default '0', diff --git a/src/char/char.c b/src/char/char.c index 6aaae27b0..56d070e5d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -166,7 +166,7 @@ int char_log(char *fmt, ...) { //----------------------------------------------------- // Function to suppress control characters in a string. //----------------------------------------------------- -int remove_control_chars(unsigned char *str) { +int remove_control_chars(char *str) { int i; int change = 0; @@ -244,7 +244,7 @@ int mmo_friends_list_data_str(char *str, struct mmo_charstatus *p) { int i; char *str_p = str; str_p += sprintf(str_p, "%d", p->char_id); - + for (i=0;i<20;i++) { str_p += sprintf(str_p, ",%d,%s", p->friend_id[i],p->friend_name[i]); @@ -575,16 +575,16 @@ int parse_friend_txt(struct mmo_charstatus *p) char line[1024]; int i,cid=0,temp[20]; FILE *fp; - + // Open the file and look for the ID fp = fopen(friends_txt, "r"); if(fp == NULL) return 1; - + while(fgets(line, sizeof(line)-1, fp)) { - + if(line[0] == '/' && line[1] == '/') continue; @@ -612,7 +612,7 @@ int parse_friend_txt(struct mmo_charstatus *p) if (cid == p->char_id) break; } - + // No register of friends list if (cid == 0) { fclose(fp); @@ -638,12 +638,12 @@ int mmo_char_init(void) { FILE *fp; char_max = 256; - char_dat = calloc(sizeof(struct mmo_charstatus) * 256, 1); + char_dat = (struct mmo_charstatus*)aCalloc(sizeof(struct mmo_charstatus) * 256, 1); if (!char_dat) { printf("out of memory: mmo_char_init (calloc of char_dat).\n"); exit(1); } - online_chars = calloc(sizeof(struct online_chars) * 256, 1); + online_chars = (struct online_chars*)aCalloc(sizeof(struct online_chars) * 256, 1); if (!online_chars) { printf("out of memory: mmo_char_init (calloc of online_chars).\n"); exit(1); @@ -683,13 +683,13 @@ int mmo_char_init(void) { if (char_num >= char_max) { char_max += 256; - char_dat = realloc(char_dat, sizeof(struct mmo_charstatus) * char_max); + char_dat = (struct mmo_charstatus*)aRealloc(char_dat, sizeof(struct mmo_charstatus) * char_max); if (!char_dat) { printf("Out of memory: mmo_char_init (realloc of char_dat).\n"); char_log("Out of memory: mmo_char_init (realloc of char_dat)." RETCODE); exit(1); } - online_chars = realloc(online_chars, sizeof(struct online_chars) * char_max); + online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * char_max); if (!online_chars) { printf("Out of memory: mmo_char_init (realloc of online_chars).\n"); char_log("Out of memory: mmo_char_init (realloc of online_chars)." RETCODE); @@ -703,10 +703,10 @@ int mmo_char_init(void) { } ret = mmo_char_fromstr(line, &char_dat[char_num]); - + // Initialize friends list parse_friend_txt(&char_dat[char_num]); // Grab friends for the character - + if (ret > 0) { // negative value or zero for errors if (char_dat[char_num].char_id >= char_id_count) char_id_count = char_dat[char_num].char_id + 1; @@ -769,7 +769,7 @@ void mmo_char_sync(void) { int i, j, k; int lock; FILE *fp,*f_fp; - int id[char_num]; + int *id = (int *) aMalloc(sizeof(int) * char_num); // Sorting before save (by [Yor]) for(i = 0; i < char_num; i++) { @@ -825,9 +825,11 @@ void mmo_char_sync(void) { mmo_friends_list_data_str(f_line, &char_dat[id[i]]); fprintf(f_fp, "%s" RETCODE, f_line); } - + lock_fclose(f_fp, friends_txt, &lock); - + + aFree(id); + return; } @@ -847,7 +849,7 @@ int make_new_char(int fd, unsigned char *dat) { int i, j; struct char_session_data *sd; - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; // remove control characters from the name dat[23] = '\0'; @@ -921,13 +923,13 @@ int make_new_char(int fd, unsigned char *dat) { if (char_num >= char_max) { char_max += 256; - char_dat = realloc(char_dat, sizeof(struct mmo_charstatus) * char_max); + char_dat = (struct mmo_charstatus*)aRealloc(char_dat, sizeof(struct mmo_charstatus) * char_max); if (!char_dat) { printf("Out of memory: make_new_char (realloc of char_dat).\n"); char_log("Out of memory: make_new_char (realloc of char_dat)." RETCODE); exit(1); } - online_chars = realloc(online_chars, sizeof(struct online_chars) * char_max); + online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * char_max); if (!online_chars) { printf("Out of memory: make_new_char (realloc of online_chars).\n"); char_log("Out of memory: make_new_char (realloc of online_chars)." RETCODE); @@ -998,8 +1000,8 @@ int make_new_char(int fd, unsigned char *dat) { //---------------------------------------------------- // This function return the name of the job (by [Yor]) //---------------------------------------------------- -char * job_name(int class) { - switch (class) { +char * job_name(int class_) { + switch (class_) { case 0: return "Novice"; case 1: return "Swordsman"; case 2: return "Mage"; @@ -1550,7 +1552,7 @@ int disconnect_player(int accound_id) { // disconnect player if online on char-server for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == accound_id) { session[i]->eof = 1; return 1; @@ -1612,7 +1614,7 @@ int parse_tologin(int fd) { return 0; } - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; while(RFIFOREST(fd) >= 2) { // printf("parse_tologin: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd)); @@ -1645,7 +1647,7 @@ int parse_tologin(int fd) { return 0; // printf("parse_tologin 2713 : %d\n", RFIFOB(fd,6)); for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) { if (RFIFOB(fd,6) != 0) { WFIFOW(i,0) = 0x6c; WFIFOB(i,2) = 0x42; @@ -1683,7 +1685,7 @@ int parse_tologin(int fd) { if (RFIFOREST(fd) < 50) return 0; for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == RFIFOL(fd,2)) { memcpy(sd->email, RFIFOP(fd,6), 40); if (e_mail_check(sd->email) == 0) @@ -1891,7 +1893,7 @@ int parse_tologin(int fd) { int j, k; struct char_session_data *sd2; for (j = 0; j < fd_max; j++) { - if (session[j] && (sd2 = session[j]->session_data) && + if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) && sd2->account_id == char_dat[char_num-1].account_id) { for (k = 0; k < 9; k++) { if (sd2->found_char[k] == char_num-1) { @@ -1946,8 +1948,8 @@ int parse_tologin(int fd) { { char buf[32000]; if (gm_account != NULL) - free(gm_account); - gm_account = calloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); + aFree(gm_account); + gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); GM_num = 0; for (i = 4; i < RFIFOW(fd,2); i = i + 5) { gm_account[GM_num].account_id = RFIFOL(fd,i); @@ -2158,7 +2160,7 @@ int parse_frommap(int fd) { if (j == online_players_max) { // create 256 new slots online_players_max += 256; - online_chars = realloc(online_chars, sizeof(struct online_chars) * online_players_max); + online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * online_players_max); if (!online_chars) { printf("out of memory: parse_frommap - online_chars (realloc).\n"); exit(1); @@ -2515,7 +2517,7 @@ int parse_char(int fd) { return 0; } - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; while (RFIFOREST(fd) >= 2) { cmd = RFIFOW(fd,0); @@ -2539,7 +2541,7 @@ int parse_char(int fd) { // if (sd == NULL && cmd != 0x65 && cmd != 0x20b && cmd != 0x187 && // cmd != 0x2af8 && cmd != 0x7530 && cmd != 0x7532) // cmd = 0xffff; // パケットダンプを表示させる - + switch(cmd){ case 0x20b: //20040622暗号化ragexe対応 if (RFIFOREST(fd) < 19) @@ -2557,7 +2559,7 @@ int parse_char(int fd) { else printf("Account Logged On; Account ID: %d.\n", RFIFOL(fd,2)); if (sd == NULL) { - sd = session[fd]->session_data = calloc(sizeof(struct char_session_data), 1); + sd = session[fd]->session_data = (struct char_session_data*)aCalloc(sizeof(struct char_session_data), 1); memset(sd, 0, sizeof(struct char_session_data)); memcpy(sd->email, "no mail", 40); // put here a mail without '@' to refuse deletion if we don't receive the e-mail sd->connect_until_time = 0; // unknow or illimited (not displaying on map-server) @@ -2837,7 +2839,7 @@ int parse_char(int fd) { int j, k; struct char_session_data *sd2; for (j = 0; j < fd_max; j++) { - if (session[j] && (sd2 = session[j]->session_data) && + if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) && sd2->account_id == char_dat[char_num-1].account_id) { for (k = 0; k < 9; k++) { if (sd2->found_char[k] == char_num-1) { @@ -2947,29 +2949,29 @@ int parse_char(int fd) { // Console Command Parser [Wizputer] int parse_console(char *buf) { char *type,*command; - - type = (char *)malloc(64); - command = (char *)malloc(64); - + + type = (char *)aMalloc(64); + command = (char *)aMalloc(64); + memset(type,0,64); memset(command,0,64); - + printf("Console: %s\n",buf); - + if ( sscanf(buf, "%[^:]:%[^\n]", type , command ) < 2 ) sscanf(buf,"%[^\n]",type); - + printf("Type of command: %s || Command: %s \n",type,command); - - if(buf) free(buf); - if(type) free(type); - if(command) free(command); - + + if(buf) aFree(buf); + if(type) aFree(type); + if(command) aFree(command); + return 0; } // 全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) -int mapif_sendall(unsigned char *buf, unsigned int len) { +int mapif_sendall(char *buf, unsigned int len) { int i, c; c = 0; @@ -2985,7 +2987,7 @@ int mapif_sendall(unsigned char *buf, unsigned int len) { } // 自分以外の全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) -int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { +int mapif_sendallwos(int sfd, char *buf, unsigned int len) { int i, c; c = 0; @@ -3000,7 +3002,7 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { return c; } // MAPサーバーにデータ送信(map鯖生存確認有り) -int mapif_send(int fd, unsigned char *buf, unsigned int len) { +int mapif_send(int fd, char *buf, unsigned int len) { int i; if (fd >= 0) { @@ -3349,19 +3351,19 @@ void do_final(void) { } create_online_files(); - if(online_chars) free(online_chars); + if(online_chars) aFree(online_chars); mmo_char_sync(); inter_save(); - if(gm_account) free(gm_account); - if(char_dat) free(char_dat); + if(gm_account) aFree(gm_account); + if(char_dat) aFree(char_dat); delete_session(login_fd); delete_session(char_fd); for(i = 0; i < fd_max; i++) - if(session[i] != NULL) free(session[i]); + if(session[i] != NULL) aFree(session[i]); char_log("----End of char-server (normal end with closing of all files)." RETCODE); } @@ -3377,14 +3379,14 @@ int do_init(int argc, char **argv) { // moved behind char_config_read in case we changed the filename [celest] char_log("The char-server starting..." RETCODE); - if ((naddr_ != 0) && (login_ip_set_ == 0 || char_ip_set_ == 0)) { + if ((naddr_ != 0) && (login_ip_set_ == 0 || char_ip_set_ == 0)) { // The char server should know what IP address it is running on // - MouseJstr int localaddr = ntohl(addr_[0]); unsigned char *ptr = (unsigned char *) &localaddr; char buf[16]; sprintf(buf, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);; - if (naddr_ != 1) + if (naddr_ != 1) printf("Multiple interfaces detected.. using %s as our IP address\n", buf); else printf("Defaulting to %s as our IP address\n", buf); @@ -3393,9 +3395,9 @@ int do_init(int argc, char **argv) { if (char_ip_set_ == 0) strcpy(char_ip_str, buf); - if (ptr[0] == 192 && ptr[1] == 168) + if (ptr[0] == 192 && ptr[1] == 168) printf("Firewall detected.. edit lan_support.conf and char_athena.conf\n"); - } + } login_ip = inet_addr(login_ip_str); char_ip = inet_addr(char_ip_str); @@ -3406,7 +3408,7 @@ int do_init(int argc, char **argv) { } online_players_max = 256; - online_chars = calloc(sizeof(struct online_chars) * 256, 1); + online_chars = (struct online_chars*)aCalloc(sizeof(struct online_chars) * 256, 1); if (!online_chars) { printf("out of memory: do_init (calloc).\n"); exit(1); @@ -3432,7 +3434,7 @@ int do_init(int argc, char **argv) { add_timer_func_list(check_connect_login_server, "check_connect_login_server"); add_timer_func_list(send_users_tologin, "send_users_tologin"); add_timer_func_list(mmo_char_sync_timer, "mmo_char_sync_timer"); - + i = add_timer_interval(gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000); i = add_timer_interval(gettick() + 1000, send_users_tologin, 0, 0, 5 * 1000); i = add_timer_interval(gettick() + autosave_interval, mmo_char_sync_timer, 0, 0, autosave_interval); @@ -3446,12 +3448,12 @@ int do_init(int argc, char **argv) { add_timer_interval(gettick()+10, flush_timer,0,0,flush_time); - + if(anti_freeze_enable > 0) { add_timer_func_list(map_anti_freeze_system, "map_anti_freeze_system"); i = add_timer_interval(gettick() + 1000, map_anti_freeze_system, 0, 0, ANTI_FREEZE_INTERVAL * 1000); // checks every X seconds user specifies } - + if(console) { set_defaultconsoleparse(parse_console); start_console(); diff --git a/src/char/char.h b/src/char/char.h index 3ee2f9f6d..c70facba1 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -20,9 +20,9 @@ struct mmo_map_server{ int search_character_index(char* character_name); char * search_character_name(int index); -int mapif_sendall(unsigned char *buf, unsigned int len); -int mapif_sendallwos(int fd,unsigned char *buf, unsigned int len); -int mapif_send(int fd,unsigned char *buf, unsigned int len); +int mapif_sendall(char *buf, unsigned int len); +int mapif_sendallwos(int fd,char *buf, unsigned int len); +int mapif_send(int fd,char *buf, unsigned int len); int char_log(char *fmt, ...); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 0ee4476fc..348008e1d 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -398,7 +398,7 @@ int inter_guild_init() { continue; } - g = calloc(sizeof(struct guild), 1); + g = aCalloc(sizeof(struct guild), 1); if(g == NULL){ printf("int_guild: out of memory!\n"); exit(0); @@ -412,7 +412,7 @@ int inter_guild_init() { guild_calcinfo(g); } else { printf("int_guild: broken data [%s] line %d\n", guild_txt, c); - free(g); + aFree(g); } c++; } @@ -426,7 +426,7 @@ int inter_guild_init() { } while(fgets(line, sizeof(line)-1, fp)) { - gc = calloc(sizeof(struct guild_castle), 1); + gc = aCalloc(sizeof(struct guild_castle), 1); if(gc == NULL){ printf("int_guild: out of memory!\n"); exit(0); @@ -436,7 +436,7 @@ int inter_guild_init() { numdb_insert(castle_db, gc->castle_id, gc); } else { printf("int_guild: broken data [%s] line %d\n", castle_txt, c); - free(gc); + aFree(gc); } c++; } @@ -445,7 +445,7 @@ int inter_guild_init() { printf(" %s - making Default Data...\n", castle_txt); //デフォルトデータを作成 for(i = 0; i < MAX_GUILDCASTLE; i++) { - gc = calloc(sizeof(struct guild_castle), 1); + gc = aCalloc(sizeof(struct guild_castle), 1); if (gc == NULL) { printf("int_guild: out of memory!\n"); exit(0); @@ -577,7 +577,7 @@ int guild_check_empty(struct guild *g) { numdb_erase(guild_db, g->guild_id); inter_guild_storage_delete(g->guild_id); mapif_guild_broken(g->guild_id, 0); - free(g); + aFree(g); return 1; } @@ -765,7 +765,7 @@ int mapif_guild_memberinfoshort(struct guild *g, int idx) { WBUFL(buf, 2) = g->guild_id; WBUFL(buf, 6) = g->member[idx].account_id; WBUFL(buf,10) = g->member[idx].char_id; - WBUFB(buf,14) = g->member[idx].online; + WBUFB(buf,14) = (unsigned char)g->member[idx].online; WBUFW(buf,15) = g->member[idx].lv; WBUFW(buf,17) = g->member[idx].class_; mapif_sendall(buf, 19); @@ -965,7 +965,7 @@ int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_mem mapif_guild_created(fd, account_id, NULL); return 0; } - g = calloc(sizeof(struct guild), 1); + g = aCalloc(sizeof(struct guild), 1); if (g == NULL) { printf("int_guild: CreateGuild: out of memory !\n"); mapif_guild_created(fd, account_id, NULL); @@ -1085,7 +1085,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in } // オンライン/Lv更新 -int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class) { +int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class_) { struct guild *g; int i, alv, c; @@ -1101,7 +1101,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, if (g->member[i].account_id == account_id && g->member[i].char_id == char_id) { g->member[i].online = online; g->member[i].lv = lv; - g->member[i].class_ = class; + g->member[i].class_ = class_; mapif_guild_memberinfoshort(g, i); } if (g->member[i].account_id > 0) { @@ -1111,7 +1111,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, if (g->member[i].online) g->connect_member++; } - + if (c) // 平均レベル g->average_lv = alv / c; @@ -1147,7 +1147,7 @@ int mapif_parse_BreakGuild(int fd, int guild_id) { if(log_inter) inter_log("guild %s (id=%d) broken" RETCODE, g->name, guild_id); - free(g); + aFree(g); return 0; } diff --git a/src/char/int_party.c b/src/char/int_party.c index 194e96707..6b7f4361e 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -94,7 +94,7 @@ int inter_party_init() { continue; } - p = calloc(sizeof(struct party), 1); + p = aCalloc(sizeof(struct party), 1); if (p == NULL){ printf("int_party: out of memory!\n"); exit(0); @@ -107,7 +107,7 @@ int inter_party_init() { party_check_empty(p); } else { printf("int_party: broken data [%s] line %d\n", party_txt, c + 1); - free(p); + aFree(p); } c++; } @@ -199,7 +199,7 @@ int party_check_empty(struct party *p) { // 誰もいないので解散 mapif_party_broken(p->party_id, 0); numdb_erase(party_db, p->party_id); - free(p); + aFree(p); return 1; } @@ -391,7 +391,7 @@ int mapif_parse_CreateParty(int fd, int account_id, char *name, char *nick, char mapif_party_created(fd, account_id, NULL); return 0; } - p = calloc(sizeof(struct party), 1); + p = aCalloc(sizeof(struct party), 1); if (p == NULL) { printf("int_party: out of memory !\n"); mapif_party_created(fd,account_id,NULL); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index c08c4ccf3..0dd334514 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -88,7 +88,7 @@ int inter_pet_init() if( (fp=fopen(pet_txt,"r"))==NULL ) return 1; while(fgets(line,sizeof(line),fp)){ - p=calloc(sizeof(struct s_pet), 1); + p=aCalloc(sizeof(struct s_pet), 1); if(p==NULL){ printf("int_pet: out of memory!\n"); exit(0); @@ -100,7 +100,7 @@ int inter_pet_init() numdb_insert(pet_db,p->pet_id,p); }else{ printf("int_pet: broken data [%s] line %d\n",pet_txt,c); - free(p); + aFree(p); } c++; } @@ -210,7 +210,7 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name) { struct s_pet *p; - p=malloc(sizeof(struct s_pet)); + p=aMalloc(sizeof(struct s_pet)); if(p==NULL){ printf("int_pet: out of memory !\n"); mapif_pet_created(fd,account_id,NULL); @@ -282,7 +282,7 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data) pet_id = data->pet_id; p=numdb_search(pet_db,pet_id); if(p == NULL) { - p=malloc(sizeof(struct s_pet)); + p=aMalloc(sizeof(struct s_pet)); if(p==NULL){ printf("int_pet: out of memory !\n"); mapif_save_pet_ack(fd,account_id,1); diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 7a4022a55..73d50f323 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -192,7 +192,7 @@ struct storage *account2storage(int account_id) struct storage *s; s=numdb_search(storage_db,account_id); if(s == NULL) { - s = calloc(sizeof(struct storage), 1); + s = aCalloc(sizeof(struct storage), 1); if(s==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -210,7 +210,7 @@ struct guild_storage *guild2storage(int guild_id) if(inter_guild_search(guild_id) != NULL) { gs=numdb_search(guild_storage_db,guild_id); if(gs == NULL) { - gs = calloc(sizeof(struct guild_storage), 1); + gs = aCalloc(sizeof(struct guild_storage), 1); if(gs==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -242,7 +242,7 @@ int inter_storage_init() } while(fgets(line,65535,fp)){ sscanf(line,"%d",&tmp_int); - s=calloc(sizeof(struct storage), 1); + s=aCalloc(sizeof(struct storage), 1); if(s==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -254,7 +254,7 @@ int inter_storage_init() } else{ printf("int_storage: broken data [%s] line %d\n",storage_txt,c); - free(s); + aFree(s); } c++; } @@ -270,7 +270,7 @@ int inter_storage_init() } while(fgets(line,65535,fp)){ sscanf(line,"%d",&tmp_int); - gs=calloc(sizeof(struct guild_storage), 1); + gs=aCalloc(sizeof(struct guild_storage), 1); if(gs==NULL){ printf("int_storage: out of memory!\n"); exit(0); @@ -282,7 +282,7 @@ int inter_storage_init() } else{ printf("int_storage: broken data [%s] line %d\n",guild_storage_txt,c); - free(gs); + aFree(gs); } c++; } @@ -356,7 +356,7 @@ int inter_storage_delete(int account_id) inter_pet_delete(*((long *)(&s->storage[i].card[2]))); } numdb_erase(storage_db,account_id); - free(s); + aFree(s); } return 0; } @@ -372,7 +372,7 @@ int inter_guild_storage_delete(int guild_id) inter_pet_delete(*((long *)(&gs->storage[i].card[2]))); } numdb_erase(guild_storage_db,guild_id); - free(gs); + aFree(gs); } return 0; } diff --git a/src/char/inter.c b/src/char/inter.c index a6e2a4199..f0fe38f60 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -114,7 +114,7 @@ int inter_accreg_init() { while(fgets(line, sizeof(line)-1, fp)){ line[sizeof(line)-1] = '\0'; - reg = calloc(sizeof(struct accreg), 1); + reg = aCalloc(sizeof(struct accreg), 1); if (reg == NULL) { printf("inter: accreg: out of memory!\n"); exit(0); @@ -123,7 +123,7 @@ int inter_accreg_init() { numdb_insert(accreg_db, reg->account_id, reg); } else { printf("inter: accreg: broken data [%s] line %d\n", accreg_txt, c); - free(reg); + aFree(reg); } c++; } @@ -371,7 +371,7 @@ int check_ttl_wisdata() { // removed. not send information after a timeout. Just no answer for the player //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target numdb_erase(wis_db, wd->id); - free(wd); + aFree(wd); } } while(wis_delnum >= WISDELLIST_MAX); @@ -423,7 +423,7 @@ int mapif_parse_WisRequest(int fd) { mapif_send(fd, buf, 27); } else { - wd = (struct WisData *)calloc(sizeof(struct WisData), 1); + wd = (struct WisData *)aCalloc(sizeof(struct WisData), 1); if (wd == NULL){ printf("inter: WisRequest: out of memory !\n"); return 0; @@ -458,7 +458,7 @@ int mapif_parse_WisReply(int fd) { if ((--wd->count) <= 0 || flag != 1) { mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target numdb_erase(wis_db, id); - free(wd); + aFree(wd); } return 0; @@ -481,7 +481,7 @@ int mapif_parse_AccReg(int fd) { struct accreg *reg = numdb_search(accreg_db, RFIFOL(fd,4)); if (reg == NULL) { - if ((reg = calloc(sizeof(struct accreg), 1)) == NULL) { + if ((reg = aCalloc(sizeof(struct accreg), 1)) == NULL) { printf("inter: accreg: out of memory !\n"); exit(0); } diff --git a/src/char_sql/char.c b/src/char_sql/char.c index d7f17515b..876ea991d 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -73,7 +73,7 @@ char login_db_level[32] = "level"; int lowest_gm_level = 1; -unsigned char *SQL_CONF_NAME = "conf/inter_athena.conf"; +char *SQL_CONF_NAME = "conf/inter_athena.conf"; struct mmo_map_server server[MAX_MAP_SERVERS]; int server_fd[MAX_MAP_SERVERS]; @@ -206,9 +206,9 @@ void set_char_offline(int char_id, int account_id) { if ( char_id == 99 ) sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id); else { - cp = numdb_search(char_db_,char_id); + cp = (struct mmo_charstatus*)numdb_search(char_db_,char_id); if (cp != NULL) { - free(cp); + aFree(cp); numdb_erase(char_db_,char_id); } @@ -229,7 +229,7 @@ void set_char_offline(int char_id, int account_id) { //----------------------------------------------------- // Function to suppress control characters in a string. //----------------------------------------------------- -int remove_control_chars(unsigned char *str) { +int remove_control_chars(char *str) { int i; int change = 0; @@ -259,7 +259,7 @@ int isGM(int account_id) { void read_gm_account(void) { if (gm_account != NULL) - free(gm_account); + aFree(gm_account); GM_num = 0; sprintf(tmp_lsql, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`>='%d'",login_db_account_id,login_db_level,login_db,login_db_level,lowest_gm_level); @@ -268,7 +268,7 @@ void read_gm_account(void) { } lsql_res = mysql_store_result(&lmysql_handle); if (lsql_res) { - gm_account = aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); + gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); while ((lsql_row = mysql_fetch_row(lsql_res))) { gm_account[GM_num].account_id = atoi(lsql_row[0]); gm_account[GM_num].level = atoi(lsql_row[1]); @@ -329,7 +329,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if (char_id!=p->char_id) return 0; - cp = numdb_search(char_db_,char_id); + cp = (struct mmo_charstatus*)numdb_search(char_db_,char_id); if (cp == NULL) { cp = (struct mmo_charstatus *) aMalloc(sizeof(struct mmo_charstatus)); @@ -441,7 +441,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ //===================================================================================================== - if ((p->base_exp != cp->base_exp) || (p->class_ != cp->class_) || + if ((p->base_exp != cp->base_exp) || (p->class_ != cp->class_) || (p->base_level != cp->base_level) || (p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) || (p->zeny != cp->zeny) || (p->last_point.x != cp->last_point.x) || (p->last_point.y != cp->last_point.y) || @@ -457,7 +457,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ (p->shield != cp->shield) || (p->head_top != cp->head_top) || (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->partner_id != cp->partner_id)) { - + //}//---------------------------test count------------------------------ //check party_exist party_exist=0; @@ -546,7 +546,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ diff = 0; for(i=0;iskill[i].lv != 0) && (p->skill[i].id == 0)) + if ((p->skill[i].lv != 0) && (p->skill[i].id == 0)) p->skill[i].id = i; // Fix skill tree if((p->skill[i].id != cp->skill[i].id) || (p->skill[i].lv != cp->skill[i].lv) || @@ -589,7 +589,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ break; } } - + if (diff) { //printf("- Save global_reg_value data to MySQL!\n"); //`global_reg_value` (`char_id`, `str`, `value`) @@ -603,7 +603,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if (p->global_reg[i].str) { if(p->global_reg[i].value !=0){ sprintf(tmp_sql,"INSERT INTO `%s` (`char_id`, `str`, `value`) VALUES ('%d', '%s','%d')", - reg_db, char_id, jstrescapecpy(temp_str,(unsigned char*)p->global_reg[i].str), p->global_reg[i].value); + reg_db, char_id, jstrescapecpy(temp_str,p->global_reg[i].str), p->global_reg[i].value); if(mysql_query(&mysql_handle, tmp_sql)) { printf("DB server Error (insert `global_reg_value`)- %s\n", mysql_error(&mysql_handle)); } @@ -612,9 +612,9 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } - // Friends list + // Friends list // account_id, friend_id0, name0, ... - + tmp_p += sprintf(tmp_p, "REPLACE INTO `%s` (`id`, `account_id`",friend_db); diff = 0; @@ -623,7 +623,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ tmp_p += sprintf(tmp_p, ", `friend_id%d`, `name%d`", i, i); tmp_p += sprintf(tmp_p, ") VALUES (NULL, '%d'", char_id); - + for (i=0;i<20;i++) { tmp_p += sprintf(tmp_p, ", '%d', '%s'", p->friend_id[i], p->friend_name[i]); if ((p->friend_id[i] != cp->friend_id[i]) || @@ -633,7 +633,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ tmp_p += sprintf(tmp_p, ")"); - if (diff) + if (diff) mysql_query(&mysql_handle, tmp_sql); printf("saving char is done.\n"); @@ -882,9 +882,9 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ char *tmp_p = tmp_sql; struct mmo_charstatus *cp; - cp = numdb_search(char_db_,char_id); + cp = (struct mmo_charstatus*)numdb_search(char_db_,char_id); if (cp != NULL) - free(cp); + aFree(cp); memset(p, 0, sizeof(struct mmo_charstatus)); @@ -966,10 +966,10 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ } else printf("char2 - failed\n"); //Error?! ERRRRRR WHAT THAT SAY!? - if (p->last_point.x == 0 || p->last_point.y == 0 || p->last_point.map[0] == '\0') + if (p->last_point.x == 0 || p->last_point.y == 0 || p->last_point.map[0] == '\0') memcpy(&p->last_point, &start_point, sizeof(start_point)); - if (p->save_point.x == 0 || p->save_point.y == 0 || p->save_point.map[0] == '\0') + if (p->save_point.x == 0 || p->save_point.y == 0 || p->save_point.map[0] == '\0') memcpy(&p->save_point, &start_point, sizeof(start_point)); printf("char2 "); @@ -1102,10 +1102,10 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ sql_row = mysql_fetch_row(sql_res); i=mysql_num_rows(sql_res); - + // debugg //printf("mysql: %d\n",i); - + // Create an entry for the character if it doesnt already have one if(!i) { @@ -1188,15 +1188,15 @@ int mmo_char_sql_init(void) { printf("set char_id_count: %d.......\n",char_id_count); sprintf(tmp_sql , "REPLACE INTO `%s` SET `online`=0", char_db); - if (mysql_query(&mysql_handle, tmp_sql)) + if (mysql_query(&mysql_handle, tmp_sql)) printf("DB server Error - %s\n", mysql_error(&mysql_handle)); sprintf(tmp_sql , "REPLACE INTO `%s` SET `online`=0", guild_member_db); - if (mysql_query(&mysql_handle, tmp_sql)) + if (mysql_query(&mysql_handle, tmp_sql)) printf("DB server Error - %s\n", mysql_error(&mysql_handle)); sprintf(tmp_sql , "REPLACE INTO `%s` SET `connect_member`=0", guild_db); - if (mysql_query(&mysql_handle, tmp_sql)) + if (mysql_query(&mysql_handle, tmp_sql)) printf("DB server Error - %s\n", mysql_error(&mysql_handle)); printf("init end.......\n"); @@ -1212,10 +1212,10 @@ int make_new_char_sql(int fd, unsigned char *dat) { int i; //aphostropy error check! - fixed! - jstrescapecpy(t_name, dat); + jstrescapecpy(t_name, (char*)dat); printf("making new char -"); - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; // Check Authorised letters/symbols in the name of the character if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised @@ -1477,7 +1477,7 @@ int parse_tologin(int fd) { return 0; } - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; // hehe. no need to set user limite on SQL version. :P // but char limitation is good way to maintain server. :D @@ -1513,7 +1513,7 @@ int parse_tologin(int fd) { if(RFIFOREST(fd)<51) return 0; for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) { if (RFIFOB(fd,6) != 0) { WFIFOW(i,0) = 0x6c; WFIFOB(i,2) = 0x42; @@ -1546,7 +1546,7 @@ int parse_tologin(int fd) { if (RFIFOREST(fd) < 50) return 0; for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == RFIFOL(fd,2)) { sd->connect_until_time = (time_t)RFIFOL(fd,46); break; @@ -1606,22 +1606,22 @@ int parse_tologin(int fd) { sql_res = mysql_store_result(&mysql_handle); if (sql_res) { - int char_id, jobclass, skill_point, class; + int char_id, jobclass, skill_point, class_; sql_row = mysql_fetch_row(sql_res); char_id = atoi(sql_row[0]); jobclass = atoi(sql_row[1]); skill_point = atoi(sql_row[2]); - class = jobclass; + class_ = jobclass; if (jobclass == 19 || jobclass == 20 || jobclass == 4020 || jobclass == 4021 || jobclass == 4042 || jobclass == 4043) { // job modification if (jobclass == 19 || jobclass == 20) { - class = (sex) ? 19 : 20; + class_ = (sex) ? 19 : 20; } else if (jobclass == 4020 || jobclass == 4021) { - class = (sex) ? 4020 : 4021; + class_ = (sex) ? 4020 : 4021; } else if (jobclass == 4042 || jobclass == 4043) { - class = (sex) ? 4042 : 4043; + class_ = (sex) ? 4042 : 4043; } // remove specifical skills of classes 19,20 4020,4021 and 4042,4043 sprintf(tmp_sql, "SELECT `lv` FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id); @@ -1644,7 +1644,7 @@ int parse_tologin(int fd) { if (mysql_query(&mysql_handle, tmp_sql)) { printf("DB server Error (select `char`)- %s\n", mysql_error(&mysql_handle)); } - sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d' , `skill_point`='%d' , `weapon`='0' , `shield='0' , `head_top`='0' , `head_mid`='0' , `head_bottom`='0' WHERE `char_id` = '%d'",char_db, class, skill_point, char_id); + sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d' , `skill_point`='%d' , `weapon`='0' , `shield='0' , `head_top`='0' , `head_mid`='0' , `head_bottom`='0' WHERE `char_id` = '%d'",char_db, class_, skill_point, char_id); if (mysql_query(&mysql_handle, tmp_sql)) { printf("DB server Error (select `char`)- %s\n", mysql_error(&mysql_handle)); } @@ -1652,7 +1652,7 @@ int parse_tologin(int fd) { } // disconnect player if online on char-server for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == acc) { session[i]->eof = 1; break; @@ -1706,7 +1706,7 @@ int parse_tologin(int fd) { } // disconnect player if online on char-server for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data)) { + if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { if (sd->account_id == RFIFOL(fd,2)) { session[i]->eof = 1; break; @@ -2296,7 +2296,7 @@ int parse_char(int fd) { struct char_session_data *sd; unsigned char *p = (unsigned char *) &session[fd]->client_addr.sin_addr; - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; if(login_fd < 0) session[fd]->eof = 1; @@ -2353,7 +2353,7 @@ int parse_char(int fd) { */ if (sd == NULL) { CREATE(session[fd]->session_data, struct char_session_data, 1); - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; sd->connect_until_time = 0; // unknow or illimited (not displaying on map-server) } sd->account_id = RFIFOL(fd, 2); @@ -2843,15 +2843,15 @@ int parse_console(char *buf) { printf("Type of command: %s || Command: %s \n",type,command); - if(buf) free(buf); - if(type) free(type); - if(command) free(command); + if(buf) aFree(buf); + if(type) aFree(type); + if(command) aFree(command); return 0; } // MAP send all -int mapif_sendall(unsigned char *buf, unsigned int len) { +int mapif_sendall(char *buf, unsigned int len) { int i, c; int fd; @@ -2867,7 +2867,7 @@ int mapif_sendall(unsigned char *buf, unsigned int len) { return c; } -int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { +int mapif_sendallwos(int sfd, char *buf, unsigned int len) { int i, c; int fd; @@ -2883,7 +2883,7 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { return c; } -int mapif_send(int fd, unsigned char *buf, unsigned int len) { +int mapif_send(int fd, char *buf, unsigned int len) { int i; if (fd >= 0) { @@ -3016,12 +3016,12 @@ void do_final(void) { printf("DB server Error (insert `char`)- %s\n", mysql_error(&mysql_handle)); if(gm_account) { - free(gm_account); + aFree(gm_account); gm_account = 0; } if(char_dat) { - free(char_dat); + aFree(char_dat); char_dat = 0; } diff --git a/src/char_sql/char.h b/src/char_sql/char.h index c7261650b..17a938780 100644 --- a/src/char_sql/char.h +++ b/src/char_sql/char.h @@ -41,9 +41,9 @@ struct itemtemp{ struct itemtmp equip[MAX_GUILD_STORAGE],notequip[MAX_GUILD_STORAGE]; }; int memitemdata_to_sql(struct itemtemp mapitem, int eqcount, int noteqcount, int char_id,int tableswitch); -int mapif_sendall(unsigned char *buf,unsigned int len); -int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len); -int mapif_send(int fd,unsigned char *buf,unsigned int len); +int mapif_sendall(char *buf,unsigned int len); +int mapif_sendallwos(int fd,char *buf,unsigned int len); +int mapif_send(int fd,char *buf,unsigned int len); extern int autosave_interval; extern char db_path[]; diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 3f9243bfe..e3b8d30a8 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -46,7 +46,7 @@ static int _erase_guild(void *key, void *data, va_list ap) { int guild = va_arg(ap, int); struct guild_castle * castle = (struct guild_castle *) data; if (castle->guild_id == guild) { - free(castle); + aFree(castle); db_erase(castle_db_, key); } @@ -60,21 +60,21 @@ int inter_guild_tosql(struct guild *g,int flag) // 2 `guild_member` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`rsv1`,`rsv2`,`name`) // 4 `guild_position` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) // 8 `guild_alliance` (`guild_id`,`opposition`,`alliance_id`,`name`) - // 16 `guild_expulsion` (`guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3`) + // 16 `guild_expulsion` (`guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3`) // 32 `guild_skill` (`guild_id`,`id`,`lv`) - + char t_name[100],t_master[24],t_mes1[60],t_mes2[240],t_member[24],t_position[24],t_alliance[24]; // temporay storage for str convertion; char t_ename[24],t_emes[40]; char emblem_data[4096]; int i=0; int guild_exist=0,guild_member=0,guild_online_member=0; - + if (g->guild_id<=0) return -1; - + printf("(\033[1;35m%d\033[0m) Request save guild -(flag 0x%x) ",g->guild_id, flag); - + jstrescapecpy(t_name, g->name); - + //printf("- Check if guild %d exists\n",g->guild_id); sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_db,g->guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -87,7 +87,7 @@ int inter_guild_tosql(struct guild *g,int flag) //printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes")); } mysql_free_result(sql_res) ; //resource free - + if (guild_exist >0){ // Check members in party sprintf(tmp_sql,"SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_member_db, g->guild_id); @@ -98,13 +98,13 @@ int inter_guild_tosql(struct guild *g,int flag) sql_res = mysql_store_result(&mysql_handle) ; if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { sql_row = mysql_fetch_row(sql_res); - + guild_member = atoi (sql_row[0]); // printf("- Check members in guild %d : %d \n",g->guild_id,guild_member); } mysql_free_result(sql_res) ; //resource free - + // Delete old guild from sql if (flag&1||guild_member==0){ // printf("- Delete guild %d from guild\n",g->guild_id); @@ -164,7 +164,7 @@ int inter_guild_tosql(struct guild *g,int flag) sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_castle_db, g->guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `guild_castle`)- %s\n", mysql_error(&mysql_handle) ); - } + } db_foreach(castle_db_, _erase_guild, g->guild_id); } } @@ -175,14 +175,14 @@ int inter_guild_tosql(struct guild *g,int flag) if (g->member[i].account_id>0) guild_online_member++; i++; } - + // No member in guild , no need to create it in sql if (guild_member <= 0 && guild_online_member <=0) { inter_guild_storage_delete(g->guild_id); printf("No member in guild %d , break it! \n",g->guild_id); return -2; } - + // Insert new guild to sqlserver if (flag&1||guild_member==0){ int len=0; @@ -190,7 +190,7 @@ int inter_guild_tosql(struct guild *g,int flag) for(i=0;iemblem_len;i++){ len+=sprintf(emblem_data+len,"%02x",(unsigned char)(g->emblem_data[i])); //printf("%02x",(unsigned char)(g->emblem_data[i])); - } + } emblem_data[len] = '\0'; //printf("- emblem_len = %d \n",g->emblem_len); sprintf(tmp_sql,"INSERT INTO `%s` " @@ -204,7 +204,7 @@ int inter_guild_tosql(struct guild *g,int flag) printf("DB server Error (insert `guild`)- %s\n", mysql_error(&mysql_handle) ); } } - + if (flag&2||guild_member==0){ struct StringBuf sbuf; struct StringBuf sbuf2; @@ -238,16 +238,16 @@ int inter_guild_tosql(struct guild *g,int flag) } StringBuf_Printf(&sbuf2,")"); - if(mysql_query(&mysql_handle, StringBuf_Value(&sbuf))) + if(mysql_query(&mysql_handle, StringBuf_Value(&sbuf))) printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); - if(mysql_query(&mysql_handle, StringBuf_Value(&sbuf2))) + if(mysql_query(&mysql_handle, StringBuf_Value(&sbuf2))) printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); StringBuf_Destroy(&sbuf2); StringBuf_Destroy(&sbuf); } - + if (flag&4||guild_member==0){ //printf("- Insert guild %d to guild_position\n",g->guild_id); for(i=0;i0) { sql_row = mysql_fetch_row(sql_res); if (sql_row==NULL) { mysql_free_result(sql_res); - free(g); + aFree(g); return 0; } - + g->guild_id=atoi(sql_row[0]); strncpy(g->name,sql_row[1],24); strncpy(g->master,sql_row[2],24); @@ -382,7 +382,7 @@ struct guild * inter_guild_fromsql(int guild_id) if(c2>='a' && c2<='f')x2=c2-'a'+10; if(c2>='A' && c2<='F')x2=c2-'A'+10; g->emblem_data[i]=(x1<<4)|x2; - } + } } mysql_free_result(sql_res); @@ -392,7 +392,7 @@ struct guild * inter_guild_fromsql(int guild_id) //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_member`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -415,33 +415,33 @@ struct guild * inter_guild_fromsql(int guild_id) } } mysql_free_result(sql_res); - + //printf("- Read guild_position %d from sql \n",guild_id); sprintf(tmp_sql,"SELECT `guild_id`,`position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'",guild_position_db, guild_id); //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_position`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { int i; for(i=0;((sql_row = mysql_fetch_row(sql_res))&&iposition[position]; - strncpy(p->name,sql_row[2],24); + strncpy(p->name,sql_row[2],24); p->mode=atoi(sql_row[3]); - p->exp_mode=atoi(sql_row[4]); + p->exp_mode=atoi(sql_row[4]); } } - mysql_free_result(sql_res); + mysql_free_result(sql_res); //printf("- Read guild_alliance %d from sql \n",guild_id); sprintf(tmp_sql,"SELECT `guild_id`,`opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'",guild_alliance_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_alliance`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -455,12 +455,12 @@ struct guild * inter_guild_fromsql(int guild_id) } } mysql_free_result(sql_res); - + //printf("- Read guild_expulsion %d from sql \n",guild_id); sprintf(tmp_sql,"SELECT `guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3` FROM `%s` WHERE `guild_id`='%d'",guild_expulsion_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_expulsion`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -476,16 +476,16 @@ struct guild * inter_guild_fromsql(int guild_id) e->rsv1=atoi(sql_row[5]); e->rsv2=atoi(sql_row[6]); e->rsv3=atoi(sql_row[7]); - + } } mysql_free_result(sql_res); - + //printf("- Read guild_skill %d from sql \n",guild_id); sprintf(tmp_sql,"SELECT `guild_id`,`id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`",guild_skill_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_skill`)- %s\n", mysql_error(&mysql_handle) ); - free(g); + aFree(g); return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -497,7 +497,7 @@ struct guild * inter_guild_fromsql(int guild_id) } } mysql_free_result(sql_res); - + // printf("Successfully retrieve guild information from sql!\n"); numdb_insert(guild_db_, guild_id,g); @@ -542,8 +542,8 @@ int inter_guildcastle_tosql(struct guild_castle *gc) "(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`," "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`)" - "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')", - guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, + "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d')", + guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense, gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC, gc->visibleG0, gc->visibleG1, gc->visibleG2, gc->visibleG3, gc->visibleG4, gc->visibleG5, gc->visibleG6, gc->visibleG7, gc->Ghp0, gc->Ghp1, gc->Ghp2, gc->Ghp3, gc->Ghp4, gc->Ghp5, gc->Ghp6, gc->Ghp7); //printf(" %s\n",tmp_sql); @@ -558,7 +558,7 @@ int inter_guildcastle_tosql(struct guild_castle *gc) printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); return 0; } - + sprintf(tmp_sql,"UPDATE `%s` SET `castle_id`='%d' WHERE `guild_id`='%d'",guild_db, gc->castle_id,gc->guild_id); //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -567,7 +567,7 @@ int inter_guildcastle_tosql(struct guild_castle *gc) } db_foreach(guild_db_, _set_guild_castle, gc->castle_id,gc->guild_id); - + return 0; } // Read guild_castle from sql @@ -603,7 +603,7 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) mysql_free_result(sql_res); return 0; } - + gc->guild_id = atoi (sql_row[1]); gc->economy = atoi (sql_row[2]); gc->defense = atoi (sql_row[3]); @@ -629,7 +629,7 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) gc->Ghp5 = atoi (sql_row[23]); gc->Ghp6 = atoi (sql_row[24]); gc->Ghp7 = atoi (sql_row[25]); - + //printf("Read Castle %d of guild %d from sql \n",castle_id,gc->guild_id); } @@ -647,7 +647,7 @@ int inter_guild_readdb() FILE *fp; char line[1024]; for (i=0;i<100;i++) guild_exp[i]=0; - + fp=fopen("db/exp_guild.txt","r"); if(fp==NULL){ printf("can't read db/exp_guild.txt\n"); @@ -676,14 +676,14 @@ int inter_guild_sql_init() guild_expcache_db_=numdb_init(); guild_infoevent_db_=numdb_init(); guild_castleinfoevent_db_=numdb_init(); - + printf("interserver guild memory initialize.... (%d byte)\n",sizeof(struct guild)); guild_pt = aCalloc(sizeof(struct guild), 1); guild_pt2= aCalloc(sizeof(struct guild), 1); guildcastle_pt=aCalloc(sizeof(struct guild_castle), 1); - + inter_guild_readdb(); // Read exp - + sprintf (tmp_sql , "SELECT count(*) FROM `%s`",guild_db); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); @@ -702,13 +702,13 @@ int inter_guild_sql_init() printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); exit(0); } - + sql_res = mysql_store_result(&mysql_handle) ; sql_row = mysql_fetch_row(sql_res); guild_newid = atoi(sql_row[0])+1; mysql_free_result(sql_res); } - + printf("set guild_newid: %d.......\n",guild_newid); return 0; @@ -743,7 +743,7 @@ int guild_check_empty(struct guild *g) return 0; } } - + // 誰もいないので解散 mapif_guild_broken(g->guild_id,0); inter_guild_storage_delete(g->guild_id); @@ -795,7 +795,7 @@ int guild_calcinfo(struct guild *g) nextexp = guild_nextexp(g->guild_lv); } } - + // ギルドの次の経験値 g->next_exp = guild_nextexp(g->guild_lv); @@ -809,13 +809,13 @@ int guild_calcinfo(struct guild *g) if(g->member[i].account_id>0){ g->average_lv+=g->member[i].lv; c++; - + if(g->member[i].online>0) g->connect_member++; } } if(c) g->average_lv/=c; - + // 全データを送る必要がありそう if( g->max_member!=before.max_member || g->guild_lv!=before.guild_lv || @@ -823,7 +823,7 @@ int guild_calcinfo(struct guild *g) mapif_guild_info(-1,g); return 1; } - + return 0; } @@ -906,7 +906,7 @@ int mapif_guild_memberinfoshort(struct guild *g,int idx) WBUFL(buf, 2)=g->guild_id; WBUFL(buf, 6)=g->member[idx].account_id; WBUFL(buf,10)=g->member[idx].char_id; - WBUFB(buf,14)=g->member[idx].online; + WBUFB(buf,14)=(unsigned char)g->member[idx].online; WBUFW(buf,15)=g->member[idx].lv; WBUFW(buf,17)=g->member[idx].class_; mapif_sendall(buf,19); @@ -1121,7 +1121,7 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member { struct guild *g; int i; - + printf("CreateGuild\n"); g=search_guildname(name); if(g!=NULL&&g->guild_id>0){ @@ -1135,38 +1135,38 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member memcpy(g->name,name,24); memcpy(g->master,master->name,24); memcpy(&g->member[0],master,sizeof(struct guild_member)); - + g->position[0].mode=0x11; strcpy(g->position[ 0].name,"GuildMaster"); strcpy(g->position[MAX_GUILDPOSITION-1].name,"Newbie"); for(i=1;iposition[i].name,"Position %d",i+1); - + // Initialize guild property g->max_member=16; g->average_lv=master->lv; g->castle_id=-1; for(i=0;iskill[i].id=i + GD_SKILLBASE; - + // Save to sql printf("Create initialize OK!\n"); i=inter_guild_tosql(g,255); - + if (i<0) { mapif_guild_created(fd,account_id,NULL); return 0; } - + // Report to client mapif_guild_created(fd,account_id,g); mapif_guild_info(fd,g); - + if(log_inter) inter_log("guild %s (id=%d) created by master %s (id=%d)" RETCODE, name, g->guild_id, master->name, master->account_id ); - - + + return 0; } // Return guild info to client @@ -1191,10 +1191,10 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); return 0; } - + for(i=0;imax_member;i++){ if(g->member[i].account_id==0){ - + memcpy(&g->member[i],m,sizeof(struct guild_member)); mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,0); guild_calcinfo(g); @@ -1211,7 +1211,7 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int flag,const char *mes) { struct guild *g= inter_guild_fromsql(guild_id); - + if(g!=NULL&&g->guild_id>0){ int i; for(i=0;imax_member;i++){ @@ -1219,7 +1219,7 @@ int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int fl g->member[i].char_id==char_id){ printf("%d %d\n",i, (int)(&g->member[i])); printf("%d %s\n",i, g->member[i].name); - + if(flag){ // 追放の場合追放リストに入れる int j; for(j=0;jexplusion[j].name,g->member[i].name,24); memcpy(g->explusion[j].mes,mes,40); } - + mapif_guild_leaved(guild_id,account_id,char_id,flag,g->member[i].name,mes); printf("%d %d\n",i, (int)(&g->member[i])); printf("%d %s\n",i, (&g->member[i])->name); memset(&g->member[i],0,sizeof(struct guild_member)); - + if( guild_check_empty(g)==0 ) mapif_guild_info(-1,g);// まだ人がいるのでデータ送信 /* @@ -1259,12 +1259,12 @@ int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int fl } /* mapif_guild_leaved(guild_id,account_id,char_id,flag,g->member[i].name,mes); */ } - + return 0; } // Change member info int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, - int account_id,int char_id,int online,int lv,int class) + int account_id,int char_id,int online,int lv,int class_) { // Could speed up by manipulating only guild_member struct guild * g= inter_guild_fromsql(guild_id); @@ -1272,18 +1272,18 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, if(g==NULL||g->guild_id<=0) return 0; - + g->connect_member=0; idx = -1; - + for(i=0,alv=0,c=0;imax_member;i++){ if( g->member[i].account_id==account_id && g->member[i].char_id==char_id){ - + g->member[i].online=online; g->member[i].lv=lv; - g->member[i].class_=class; + g->member[i].class_=class_; mapif_guild_memberinfoshort(g,i); idx = i; } @@ -1300,13 +1300,13 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, g->average_lv=alv/c; sprintf(tmp_sql, "UPDATE `%s` SET `connect_member`=%d,`average_lv`=%d WHERE `guild_id`='%d'", guild_db, g->connect_member, g->average_lv, g->guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); sprintf(tmp_sql, "UPDATE `%s` SET `online`=%d,`lv`=%d,`class`=%d WHERE `char_id`=%d", guild_member_db, g->member[idx].online, g->member[idx].lv, g->member[idx].class_, g->member[idx].char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); - + return 0; } @@ -1316,7 +1316,7 @@ int mapif_parse_BreakGuild(int fd,int guild_id) struct guild *g= inter_guild_fromsql(guild_id); if(g==NULL) return 0; - + // Delete guild from sql //printf("- Delete guild %d from guild\n",guild_id); sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id); @@ -1348,7 +1348,7 @@ int mapif_parse_BreakGuild(int fd,int guild_id) if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `guild_position`)- %s\n", mysql_error(&mysql_handle) ); } - + //printf("- Delete guild %d from guild_castle\n",guild_id); sprintf(tmp_sql, "DELETE FROM `%s` WHERE `guild_id`='%d'",guild_castle_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -1356,19 +1356,19 @@ int mapif_parse_BreakGuild(int fd,int guild_id) } db_foreach(castle_db_, _erase_guild, guild_id); - + //printf("- Update guild %d of char\n",guild_id); sprintf(tmp_sql, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'",char_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `guild_position`)- %s\n", mysql_error(&mysql_handle) ); } - + inter_guild_storage_delete(guild_id); mapif_guild_broken(guild_id,0); - + if(log_inter) inter_log("guild %s (id=%d) broken" RETCODE,g->name,guild_id); - + return 0; } @@ -1416,7 +1416,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha struct guild * g = inter_guild_fromsql(guild_id); //printf("GuildMemberInfoChange %s \n",(type==GMI_EXP)?"GMI_EXP":"OTHER"); - + if(g==NULL){ return 0; } @@ -1437,7 +1437,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha inter_guild_tosql(g,3); // Change guild & guild_member break; } - case GMI_EXP: + case GMI_EXP: { // EXP int exp,oldexp=g->member[i].exp; exp=g->member[i].exp=*((unsigned int *)data); @@ -1447,11 +1447,11 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len); sprintf(tmp_sql, "UPDATE `%s` SET `guild_lv`=%d,`connect_member`=%d,`max_member`=%d,`average_lv`=%d,`exp`=%d,`next_exp`=%d,`skill_point`=%d WHERE `guild_id`='%d'", guild_db, g->guild_lv, g->connect_member, g->max_member, g->average_lv, g->exp, g->next_exp, g->skill_point, g->guild_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); sprintf(tmp_sql, "UPDATE `%s` SET `exp`=%d WHERE `char_id`=%d", guild_member_db, g->member[i].exp, g->member[i].char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) + if(mysql_query(&mysql_handle, tmp_sql) ) printf("DB server Error: %s - %s\n", tmp_sql, mysql_error(&mysql_handle) ); break; } @@ -1488,7 +1488,7 @@ int mapif_parse_GuildSkillUp(int fd,int guild_id,int skill_num,int account_id) if(g == NULL || idx < 0 || idx >= MAX_GUILDSKILL) return 0; //printf("GuildSkillUp\n"); - + if( g->skill_point>0 && g->skill[idx].id>0 && g->skill[idx].lv<10 ){ g->skill[idx].lv++; @@ -1511,10 +1511,10 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2, int j,i; g[0]= inter_guild_fromsql(guild_id1); g[1]= inter_guild_fromsql(guild_id2); - + if(g[0]==NULL || g[1]==NULL || g[0]->guild_id ==0 || g[1]->guild_id==0) return 0; - + if(!(flag&0x8)){ for(i=0;i<2-(flag&1);i++){ for(j=0;jguild_id<=0) return 0; memcpy(g->mes1,mes1,60); @@ -1557,7 +1557,7 @@ int mapif_parse_GuildNotice(int fd,int guild_id,const char *mes1,const char *mes int mapif_parse_GuildEmblem(int fd,int len,int guild_id,int dummy,const char *data) { struct guild * g= inter_guild_fromsql(guild_id); - + if(g==NULL||g->guild_id<=0) return 0; memcpy(g->emblem_data,data,len); diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index af3ad7dc3..9ea3a5635 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -207,7 +207,7 @@ int inter_party_sql_init(){ //memory alloc printf("interserver party memory initialize.... (%d byte)\n",sizeof(struct party)); - party_pt = calloc(sizeof(struct party), 1); + party_pt = aCalloc(sizeof(struct party), 1); sprintf (tmp_sql , "SELECT count(*) FROM `%s`",party_db); if(mysql_query(&mysql_handle, tmp_sql) ) { diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 44151c8e4..18172b066 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -105,7 +105,7 @@ int inter_pet_sql_init(){ //memory alloc printf("interserver pet memory initialize.... (%d byte)\n",sizeof(struct s_pet)); - pet_pt = calloc(sizeof(struct s_pet), 1); + pet_pt = aCalloc(sizeof(struct s_pet), 1); sprintf (tmp_sql , "SELECT count(*) FROM `%s`", pet_db); if(mysql_query(&mysql_handle, tmp_sql) ) { diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index 69eaf2469..e2d4010a1 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -191,8 +191,8 @@ int inter_storage_sql_init(){ //memory alloc printf("interserver storage memory initialize....(%d byte)\n",sizeof(struct storage)); - storage_pt=calloc(sizeof(struct storage), 1); - guild_storage_pt=calloc(sizeof(struct guild_storage), 1); + storage_pt=aCalloc(sizeof(struct storage), 1); + guild_storage_pt=aCalloc(sizeof(struct guild_storage), 1); memset(storage_pt,0,sizeof(struct storage)); memset(guild_storage_pt,0,sizeof(struct guild_storage)); diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 52a53f702..92a002898 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -402,7 +402,7 @@ int check_ttl_wisdata() { // removed. not send information after a timeout. Just no answer for the player //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target numdb_erase(wis_db, wd->id); - free(wd); + aFree(wd); } } while(wis_delnum >= WISDELLIST_MAX); @@ -490,7 +490,7 @@ int mapif_parse_WisReply(int fd) { if ((--wd->count) <= 0 || flag != 1) { mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target numdb_erase(wis_db, id); - free(wd); + aFree(wd); } return 0; diff --git a/src/char_sql/itemdb.c b/src/char_sql/itemdb.c index 0bed07c23..efd3df84b 100644 --- a/src/char_sql/itemdb.c +++ b/src/char_sql/itemdb.c @@ -172,7 +172,7 @@ static int itemdb_read_sqldb(void) // sql item_db read, shortened version of map // Insert a new row into the item database /* - id = calloc(sizeof(struct item_data), 1); + id = aCalloc(sizeof(struct item_data), 1); if (id == NULL) { printf("out of memory : itemdb_read_sqldb\n"); @@ -214,10 +214,10 @@ static int itemdb_final(void *key,void *data,va_list ap) id=data; if(id->use_script) - free(id->use_script); + aFree(id->use_script); if(id->equip_script) - free(id->equip_script); - free(id); + aFree(id->equip_script); + aFree(id); return 0; } diff --git a/src/char_sql/itemdb.h b/src/char_sql/itemdb.h index dea835e78..762873c8e 100644 --- a/src/char_sql/itemdb.h +++ b/src/char_sql/itemdb.h @@ -6,7 +6,7 @@ struct item_data { char name[24],jname[24]; int value_buy,value_sell,value_notdc,value_notoc; int type; - int class; + int class_; int sex; int equip; int weight; diff --git a/src/common/core.c b/src/common/core.c index 493aab850..a8c922fc3 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -9,6 +9,7 @@ #include #include +#include "../common/mmo.h" #include "core.h" #include "socket.h" #include "timer.h" diff --git a/src/common/db.c b/src/common/db.c index bc4e8451b..d76b7a44c 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -424,7 +424,7 @@ void* db_erase(struct dbt *table,void* key) #ifdef MALLOC_DBN free_dbn(p); #else - free(p); + aFree(p); #endif return data; } @@ -497,11 +497,11 @@ void db_final(struct dbt *table,int (*func)(void*,void*,va_list),...) #ifdef MALLOC_DBN free_dbn(p); #else - free(p); + aFree(p); #endif p=pn; } } - free(table); + aFree(table); va_end(ap); } diff --git a/src/common/grfio.c b/src/common/grfio.c index 440c3b2a3..6afd1d668 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -25,8 +25,6 @@ #include #include -#include - #include "utils.h" #include "grfio.h" #include "mmo.h" @@ -284,7 +282,7 @@ static void decode_des_etc(BYTE *buf,int len,int type,int cycle) * Grf data decode sub : zip *------------------------------------------ */ -int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) +int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -301,21 +299,21 @@ int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; - err = inflateInit(&stream); + err = zlib_inflateInit(&stream); if (err != Z_OK) return err; - err = inflate(&stream, Z_FINISH); + err = zlib_inflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { - inflateEnd(&stream); + zlib_inflateEnd(&stream); return err == Z_OK ? Z_BUF_ERROR : err; } *destLen = stream.total_out; - err = inflateEnd(&stream); + err = zlib_inflateEnd(&stream); return err; } -int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { +int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -513,14 +511,14 @@ int grfio_size(char *fname) char lfname[256],*rname,*p; FILELIST lentry; struct stat st; - + if(strcmp(data_dir, "") != 0 && (rname=grfio_resnametable(fname,lfname))!=NULL) { //printf("%s\t",fname); //sprintf(rname,"%s",grfio_resnametable(fname,lfname)); //printf("%s\n",rname); sprintf(lfname,"%s%s",data_dir,rname); //printf("%s\n",lfname); - } + } for(p=&lfname[0];*p!=0;p++) if (*p=='\\') *p = '/'; // * At the time of Unix @@ -557,7 +555,7 @@ void* grfio_reads(char *fname, int *size) strncpy(lfname,fname,255); // i hope this is the correct way =p [celest] - if ((rname=grfio_resnametable(fname,lfname))!=NULL) { + if ((rname=grfio_resnametable(fname,lfname))!=NULL) { char tbuf[255]; //sprintf(rname,"%s",grfio_resnametable(fname,lfname)); sprintf(tbuf,"%s%s",data_dir,rname); @@ -576,7 +574,7 @@ void* grfio_reads(char *fname, int *size) lentry.declen = ftell(in); } fseek(in,0,0); // SEEK_SET - buf2 = (unsigned char *) aCalloc(lentry.declen+1024, 1); + buf2 = (unsigned char *) aCallocA(lentry.declen+1024, 1); if (buf2==NULL) { printf("file read memory allocate error : declen\n"); goto errret; @@ -592,13 +590,13 @@ void* grfio_reads(char *fname, int *size) } else { printf("%s not found (grfio_reads)\n", fname); //goto errret; - free(buf2); + aFree(buf2); return NULL; } } } if (entry!=NULL && entry->gentry>0) { // Archive[GRF] File Read - buf = (unsigned char *) aCalloc(entry->srclen_aligned+1024, 1); + buf = (unsigned char *) aCallocA(entry->srclen_aligned+1024, 1); if (buf==NULL) { printf("file read memory allocate error : srclen_aligned\n"); goto errret; @@ -608,13 +606,13 @@ void* grfio_reads(char *fname, int *size) if(in==NULL) { printf("%s not found (grfio_reads)\n",gfname); //goto errret; - free(buf); + aFree(buf); return NULL; } fseek(in,entry->srcpos,0); fread(buf,1,entry->srclen_aligned,in); fclose(in); - buf2 = (unsigned char *) aCalloc(entry->declen+1024, 1); + buf2 = (unsigned char *) aCallocA(entry->declen+1024, 1); if (buf2==NULL) { printf("file decode memory allocate error\n"); goto errret; @@ -633,14 +631,14 @@ void* grfio_reads(char *fname, int *size) } else { memcpy(buf2,buf,entry->declen); } - free(buf); + aFree(buf); } if (size!=NULL && entry!=NULL) *size = entry->declen; return buf2; errret: - if (buf!=NULL) free(buf); - if (buf2!=NULL) free(buf2); + if (buf!=NULL) aFree(buf); + if (buf2!=NULL) aFree(buf2); if (in!=NULL) fclose(in); return NULL; } @@ -704,7 +702,7 @@ static int grfio_entryread(char *gfname,int gentry) if (grf_version==0x01) { //****** Grf version 01xx ****** list_size = grf_size-ftell(fp); - grf_filelist = (unsigned char *) aCalloc(list_size, 1); + grf_filelist = (unsigned char *) aCallocA(list_size, 1); if(grf_filelist==NULL){ fclose(fp); printf("out of memory : grf_filelist\n"); @@ -727,7 +725,7 @@ static int grfio_entryread(char *gfname,int gentry) fname = decode_filename(grf_filelist+ofs+6,grf_filelist[ofs]-6); if(strlen((const char *) fname)>sizeof(aentry.fn)-1){ printf("file name too long : %s\n",fname); - free(grf_filelist); + aFree(grf_filelist); exit(1); } srclen=0; @@ -762,7 +760,7 @@ static int grfio_entryread(char *gfname,int gentry) } ofs = ofs2 + 17; } - free(grf_filelist); + aFree(grf_filelist); } else if (grf_version==0x02) { //****** Grf version 02xx ****** unsigned char eheader[8]; @@ -779,15 +777,15 @@ static int grfio_entryread(char *gfname,int gentry) return 4; } - rBuf = (unsigned char *) aCalloc( rSize , 1); // Get a Read Size + rBuf = (unsigned char *) aCallocA( rSize , 1); // Get a Read Size if (rBuf==NULL) { fclose(fp); printf("out of memory : grf compress entry table buffer\n"); return 3; } - grf_filelist = (unsigned char *) aCalloc( eSize , 1); // Get a Extend Size + grf_filelist = (unsigned char *) aCallocA( eSize , 1); // Get a Extend Size if (grf_filelist==NULL) { - free(rBuf); + aFree(rBuf); fclose(fp); printf("out of memory : grf extract entry table buffer\n"); return 3; @@ -796,7 +794,7 @@ static int grfio_entryread(char *gfname,int gentry) fclose(fp); decode_zip(grf_filelist,&eSize,rBuf,rSize); // Decode function list_size = eSize; - free(rBuf); + aFree(rBuf); entrys = getlong(grf_header+0x26) - 7; @@ -808,7 +806,7 @@ static int grfio_entryread(char *gfname,int gentry) fname = grf_filelist+ofs; if (strlen((const char *) fname)>sizeof(aentry.fn)-1) { printf("grf : file name too long : %s\n",fname); - free(grf_filelist); + aFree(grf_filelist); exit(1); } ofs2 = ofs+strlen(grf_filelist+ofs)+1; @@ -839,7 +837,7 @@ static int grfio_entryread(char *gfname,int gentry) } ofs = ofs2 + 17; } - free(grf_filelist); + aFree(grf_filelist); } else { //****** Grf Other version ****** fclose(fp); @@ -859,11 +857,11 @@ static int grfio_entryread(char *gfname,int gentry) static void grfio_resourcecheck() { int size; - unsigned char *buf,*ptr; + char *buf,*ptr; char w1[256],w2[256],src[256],dst[256]; FILELIST *entry; - buf=grfio_reads("data\\resnametable.txt",&size); + buf = (char*)grfio_reads("data\\resnametable.txt",&size); buf[size] = 0; for(ptr=buf;ptr-buf #include #include #include "malloc.h" +#if !defined(DMALLOC) && !defined(GCOLLECT) && !defined(BCHECK) + void* aMalloc_( size_t size, const char *file, int line, const char *func ) { void *ret; @@ -45,9 +46,27 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f return ret; } +#endif + + +#if defined(GCOLLECT) + +void * _bcallocA(size_t size, size_t cnt) { + void *ret = aMallocA(size * cnt); + memset(ret, 0, size * cnt); + return ret; +} + void * _bcalloc(size_t size, size_t cnt) { - void *ret = malloc(size * cnt); + void *ret = aMalloc(size * cnt); memset(ret, 0, size * cnt); return ret; } #endif + +char * _bstrdup(const char *chr) { + int len = strlen(chr); + char *ret = aMalloc(len + 1); + strcpy(ret, chr); + return ret; +} diff --git a/src/common/malloc.h b/src/common/malloc.h index 860f8dd7b..b37c3b799 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -9,23 +9,39 @@ #define aMalloc(size) \ dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 0) +#define aMallocA(size) \ + dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 0) +#define aCallocA(count,size) \ + dmalloc_malloc(__FILE__, __LINE__, (count)*(size), DMALLOC_FUNC_CALLOC, 0, 0) #define aCalloc(count,size) \ dmalloc_malloc(__FILE__, __LINE__, (count)*(size), DMALLOC_FUNC_CALLOC, 0, 0) #define aRealloc(ptr,size) \ dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 0) +#define aFree(ptr) free(ptr) +#define aStrdup(ptr) strdup(ptr) #elif defined(GCOLLECT) #include "gc.h" #define aMalloc(n) GC_MALLOC(n) +#define aMallocA(n) GC_MALLOC_ATOMIC(n) +#define aCallocA(m,n) _bcallocA(m,n) #define aCalloc(m,n) _bcalloc(m,n) #define aRealloc(p,n) GC_REALLOC(p,n) +#define aFree(n) GC_FREE(n) +#define aStrdup(n) _bstrdup(n) extern void * _bcalloc(size_t, size_t); +extern void * _bcallocA(size_t, size_t); +extern char * _bstrdup(const char *); #elif defined(BCHECK) #define aMalloc(n) malloc(n) +#define aMallocA(n) malloc(n) #define aCalloc(m,n) calloc(m,n) +#define aCallocA(m,n) calloc(m,n) #define aRealloc(p,n) realloc(p,n) +#define aFree(n) free(n) +#define aStrdup(n) strdup(n) #else #if __STDC_VERSION__ < 199901L @@ -43,8 +59,12 @@ void* aCalloc_( size_t num, size_t size, const char *file, int line, const char void* aRealloc_( void *p, size_t size, const char *file, int line, const char *func ); #define aMalloc(n) aMalloc_(n,ALC_MARK) +#define aMallocA(n) aMalloc_(n,ALC_MARK) #define aCalloc(m,n) aCalloc_(m,n,ALC_MARK) +#define aCallocA(m,n) aCalloc_(m,n,ALC_MARK) #define aRealloc(p,n) aRealloc_(p,n,ALC_MARK) +#define aFree(ptr) free(ptr) +#define aStrdup(ptr) strdup(ptr) #endif diff --git a/src/common/mmo.h b/src/common/mmo.h index 41598509e..a8722e53e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -326,19 +326,25 @@ enum { GD_DEVELOPMENT=10014, }; -#ifndef _WIN32 -#ifndef strcmpi -#define strcmpi strcasecmp -#endif -#ifndef stricmp -#define stricmp strcasecmp -#endif -#ifndef strncmpi -#define strncmpi strncasecmp -#endif -#ifndef strnicmp -#define strnicmp strncasecmp -#endif +#ifndef __WIN32 + #ifndef strcmpi + #define strcmpi strcasecmp + #endif + #ifndef stricmp + #define stricmp strcasecmp + #endif + #ifndef strncmpi + #define strncmpi strncasecmp + #endif + #ifndef strnicmp + #define strnicmp strncasecmp + #endif +#else + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #ifndef strncmpi + #define strncmpi strnicmp + #endif #endif #endif // _MMO_H_ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 857a819bb..ddaae3a52 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,6 +2,7 @@ #include #include #include "showmsg.h" +#include "malloc.h" char tmp_output[1024] = {"\0"}; @@ -47,7 +48,7 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri return 1; } if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { - output = (char*)malloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) + output = (char*)aMalloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) if (output == NULL) { return 1; // exit(1); // Kill server? Deadly @@ -58,7 +59,7 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri strcat(output,string); printf(output); fflush(stdout); - free(output); + aFree(output); } /* if ((core_config.debug_output_level > -1) && (flag >= core_config.debug_output_level)) { diff --git a/src/common/socket.c b/src/common/socket.c index 764d4d821..72e7e3f22 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -3,11 +3,13 @@ #include #include #include +#include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include +#include #else #include #include @@ -16,7 +18,6 @@ #include #include #include -#include #ifndef SIOCGIFCONF #include // SIOCGIFCONF on Solaris, maybe others? [Shinomori] @@ -151,11 +152,11 @@ static int send_from_fifo(int fd) return 0; } -void flush_fifos() +void flush_fifos() { int i; for(i=0;ifunc_send == send_from_fifo) send_from_fifo(i); } @@ -177,20 +178,22 @@ static int connect_client(int listen_fd) int fd; struct sockaddr_in client_address; int len; +#ifndef _WIN32 int result; +#endif //printf("connect_client : %d\n",listen_fd); len=sizeof(client_address); - fd=accept(listen_fd,(struct sockaddr*)&client_address,&len); + fd = accept(listen_fd,(struct sockaddr*)&client_address,(socklen_t*)&len); if(fd_max<=fd) fd_max=fd+1; setsocketopts(fd); if(fd==-1) perror("accept"); - else + else FD_SET(fd,&readfds); #ifdef _WIN32 @@ -203,8 +206,8 @@ static int connect_client(int listen_fd) #endif CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, unsigned char, rfifo_size); - CREATE(session[fd]->wdata, unsigned char, wfifo_size); + CREATE_A(session[fd]->rdata, unsigned char, rfifo_size); + CREATE_A(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -240,7 +243,7 @@ int make_listen_port(int port) server_address.sin_family = AF_INET; server_address.sin_addr.s_addr = htonl( INADDR_ANY ); - server_address.sin_port = htons(port); + server_address.sin_port = htons((unsigned short)port); result = bind(fd, (struct sockaddr*)&server_address, sizeof(server_address)); if( result == -1 ) { @@ -271,12 +274,13 @@ int make_listen_port(int port) int console_recieve(int i) { int n; char *buf; - - CREATE(buf, char , 64); - + + CREATE_A(buf, char , 64); + memset(buf,0,sizeof(64)); n = read(0, buf , 64); + if ( n < 0 ) printf("Console input read error\n"); else @@ -298,21 +302,21 @@ static int null_console_parse(char *buf) // Console Input [Wizputer] int start_console(void) { FD_SET(0,&readfds); - + CREATE(session[0], struct socket_data, 1); if(session[0]==NULL){ printf("out of memory : start_console\n"); exit(1); } - + memset(session[0],0,sizeof(*session[0])); - + session[0]->func_recv = console_recieve; session[0]->func_console = default_console_parse; - + return 0; -} - +} + int make_connection(long ip,int port) { struct sockaddr_in server_address; @@ -320,14 +324,14 @@ int make_connection(long ip,int port) int result; fd = socket( AF_INET, SOCK_STREAM, 0 ); - if(fd_max<=fd) + if(fd_max<=fd) fd_max=fd+1; setsocketopts(fd); server_address.sin_family = AF_INET; server_address.sin_addr.s_addr = ip; - server_address.sin_port = htons(port); + server_address.sin_port = htons((unsigned short)port); #ifdef _WIN32 { @@ -343,8 +347,8 @@ int make_connection(long ip,int port) FD_SET(fd,&readfds); CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, unsigned char, rfifo_size); - CREATE(session[fd]->wdata, unsigned char, wfifo_size); + CREATE_A(session[fd]->rdata, unsigned char, rfifo_size); + CREATE_A(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -363,12 +367,12 @@ int delete_session(int fd) FD_CLR(fd,&readfds); if(session[fd]){ if(session[fd]->rdata) - free(session[fd]->rdata); + aFree(session[fd]->rdata); if(session[fd]->wdata) - free(session[fd]->wdata); + aFree(session[fd]->wdata); if(session[fd]->session_data) - free(session[fd]->session_data); - free(session[fd]); + aFree(session[fd]->session_data); + aFree(session[fd]); } session[fd]=NULL; //printf("delete_session:%d\n",fd); @@ -401,7 +405,7 @@ int WFIFOSET(int fd,int len) } s->wdata_size=(s->wdata_size+(len)+2048 < s->max_wdata) ? s->wdata_size+len : (printf("socket: %d wdata lost !!\n",fd),s->wdata_size); - if (s->wdata_size > (TCP_FRAME_LEN)) + if (s->wdata_size > (TCP_FRAME_LEN)) send_from_fifo(fd); return 0; } @@ -456,7 +460,7 @@ int do_parsepacket(void) for(i=0;irdata_tick != 0) && ((tick_ - session[i]->rdata_tick) > stall_time_)) + if ((session[i]->rdata_tick != 0) && ((tick_ - session[i]->rdata_tick) > stall_time_)) session[i]->eof = 1; if(session[i]->rdata_size==0 && session[i]->eof==0) continue; @@ -500,7 +504,7 @@ int Net_Init(void) unsigned int i; char fullhost[255]; struct hostent* hent; - + /* Start up the windows networking */ WSADATA wsaData; @@ -512,7 +516,7 @@ int Net_Init(void) if(gethostname(fullhost, sizeof(fullhost)) == SOCKET_ERROR) { printf("Ugg.. no hostname defined!\n"); return 0; - } + } // XXX This should look up the local IP addresses in the registry // instead of calling gethostbyname. However, the way IP addresses @@ -545,7 +549,7 @@ int Net_Init(void) return 0; } - for(pos = 0; pos < ic.ifc_len;) + for(pos = 0; pos < ic.ifc_len;) { struct ifreq * ir = (struct ifreq *) (ic.ifc_buf + pos); diff --git a/src/common/socket.h b/src/common/socket.h index 172712d26..68b204862 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,8 +5,9 @@ #include -#ifdef _WIN32 +#ifdef __WIN32 #include +#define close(fd) closesocket(fd) #else #include #include diff --git a/src/common/strlib.c b/src/common/strlib.c index 9114c3d03..ca6e38761 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -8,15 +8,15 @@ //----------------------------------------------- // string lib. -unsigned char* jstrescape (unsigned char* pt) { +char* jstrescape (char* pt) { //copy from here unsigned char * ptr; int i =0, j=0; - + //copy string to temporary - CREATE(ptr, char, J_MAX_MALLOC_SIZE); + CREATE_A(ptr, char, J_MAX_MALLOC_SIZE); strcpy (ptr,pt); - + while (ptr[i] != '\0') { switch (ptr[i]) { case '\'': @@ -32,14 +32,14 @@ unsigned char* jstrescape (unsigned char* pt) { } } pt[j++] = '\0'; - free (ptr); - return (unsigned char*) &pt[0]; + aFree (ptr); + return &pt[0]; } -unsigned char* jstrescapecpy (unsigned char* pt,unsigned char* spt) { +char* jstrescapecpy (char* pt,char* spt) { //copy from here int i =0, j=0; - + while (spt[i] != '\0') { switch (spt[i]) { case '\'': @@ -55,12 +55,12 @@ unsigned char* jstrescapecpy (unsigned char* pt,unsigned char* spt) { } } pt[j++] = '\0'; - return (unsigned char*) &pt[0]; + return &pt[0]; } -int jmemescapecpy (unsigned char* pt,unsigned char* spt, int size) { +int jmemescapecpy (char* pt,char* spt, int size) { //copy from here int i =0, j=0; - + while (i < size) { switch (spt[i]) { case '\'': diff --git a/src/common/strlib.h b/src/common/strlib.h index 6b6169083..54c52cf94 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -4,7 +4,7 @@ // String function library. // code by Jioh L. Jung (ziozzang@4wish.net) // This code is under license "BSD" -unsigned char* jstrescape (unsigned char* pt); -unsigned char* jstrescapecpy (unsigned char* pt,unsigned char* spt); -int jmemescapecpy (unsigned char* pt,unsigned char* spt, int size); +char* jstrescape (char* pt); +char* jstrescapecpy (char* pt,char* spt); +int jmemescapecpy (char* pt,char* spt, int size); #endif diff --git a/src/common/timer.c b/src/common/timer.c index 4c602b51e..8b52811b8 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -262,7 +262,7 @@ int add_timer(unsigned int tick,int (*func)(int,unsigned int,int,int),int id,int int j; if (timer_data_max == 0) { timer_data_max = 256; - CREATE(timer_data, struct TimerData, timer_data_max); + CREATE_A(timer_data, struct TimerData, timer_data_max); //timer_data[0] = NULL; } else { timer_data_max += 256; @@ -403,13 +403,13 @@ void timer_final(void) for(tfl = tfl_root; tfl; tfl = tfl_next) { tfl_next = tfl->next; - free(tfl); + aFree(tfl); tfl = NULL; } if(timer_heap) - free(timer_heap); + aFree(timer_heap); if(free_timer_list) - free(free_timer_list); + aFree(free_timer_list); if(timer_data) - free(timer_data); + aFree(timer_data); } diff --git a/src/common/utils.c b/src/common/utils.c index 9a7722478..732b1d366 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -4,6 +4,7 @@ #include #include #include "malloc.h" +#include "mmo.h" void dump(unsigned char *buffer, int num) { @@ -112,7 +113,7 @@ void str_lower(char *name) // Allocate a StringBuf [MouseJstr] struct StringBuf * StringBuf_Malloc() { - struct StringBuf * ret = (struct StringBuf *) malloc(sizeof(struct StringBuf)); + struct StringBuf * ret = (struct StringBuf *) aMallocA(sizeof(struct StringBuf)); StringBuf_Init(ret); return ret; } @@ -120,7 +121,7 @@ struct StringBuf * StringBuf_Malloc() // Initialize a previously allocated StringBuf [MouseJstr] void StringBuf_Init(struct StringBuf * sbuf) { sbuf->max_ = 1024; - sbuf->ptr_ = sbuf->buf_ = (char *) malloc(sbuf->max_ + 1); + sbuf->ptr_ = sbuf->buf_ = (char *) aMallocA(sbuf->max_ + 1); } // printf into a StringBuf, moving the pointer [MouseJstr] @@ -169,7 +170,7 @@ int StringBuf_Append(struct StringBuf *buf1,const struct StringBuf *buf2) // Destroy a StringBuf [MouseJstr] void StringBuf_Destroy(struct StringBuf *sbuf) { - free(sbuf->buf_); + aFree(sbuf->buf_); sbuf->ptr_ = sbuf->buf_ = 0; } @@ -177,7 +178,7 @@ void StringBuf_Destroy(struct StringBuf *sbuf) void StringBuf_Free(struct StringBuf *sbuf) { StringBuf_Destroy(sbuf); - free(sbuf); + aFree(sbuf); } // Return the built string from the StringBuf [MouseJstr] diff --git a/src/common/utils.h b/src/common/utils.h index 0ac880a50..63c3f21ec 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -30,6 +30,12 @@ if (!((result) = (type *) aCalloc ((number), sizeof(type)))) \ { perror("SYSERR: malloc failure"); abort(); } } while(0) +#define CREATE_A(result, type, number) do {\ + if ((number) * sizeof(type) <= 0) \ + printf("SYSERR: Zero bytes or less requested at %s:%d.\n", __FILE__, __LINE__); \ + if (!((result) = (type *) aCallocA ((number), sizeof(type)))) \ + { perror("SYSERR: malloc failure"); abort(); } } while(0) + #define RECREATE(result,type,number) do {\ if (!((result) = (type *) aRealloc ((result), sizeof(type) * (number))))\ { printf("SYSERR: realloc failure"); abort(); } } while(0) diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index c8b0d60f0..66f5b837f 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -280,7 +280,7 @@ int ladmin_log(char *fmt, ...) { fprintf(logfp, RETCODE); else { gettimeofday(&tv, NULL); - strftime(tmpstr, 24, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 24, date_format, localtime((const time_t*)&(tv.tv_sec))); sprintf(tmpstr + strlen(tmpstr), ".%03d: %s", (int)tv.tv_usec / 1000, fmt); vfprintf(logfp, tmpstr, ap); } @@ -294,7 +294,7 @@ int ladmin_log(char *fmt, ...) { //----------------------------------------------------- // Function to suppress control characters in a string. //----------------------------------------------------- -int remove_control_chars(unsigned char *str) { +int remove_control_chars(char *str) { int i; int change = 0; @@ -381,9 +381,9 @@ int verify_accountname(char* account_name) { //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- -int e_mail_check(unsigned char *email) { +int e_mail_check(char *email) { char ch; - unsigned char* last_arobas; + char* last_arobas; // athena limits if (strlen(email) < 3 || strlen(email) > 39) @@ -3266,7 +3266,7 @@ int parse_fromlogin(int fd) { } // printf("parse_fromlogin : %d %d %d\n", fd, RFIFOREST(fd), RFIFOW(fd,0)); - sd = session[fd]->session_data; + sd = (struct char_session_data*)session[fd]->session_data; while(RFIFOREST(fd) >= 2) { switch(RFIFOW(fd,0)) { diff --git a/src/login/login.c b/src/login/login.c index 5f8bde598..11c970aca 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,7 +2,7 @@ // new version of the login-server by [Yor] #include -#ifdef WIN32 +#ifdef __WIN32 #define WIN32_LEAN_AND_MEAN #include #include @@ -232,12 +232,12 @@ void addGM(int account_id, int level) { } return; } - + // if new account if (i == GM_num && do_add) { if (GM_num >= GM_max) { GM_max += 256; - gm_account_db = realloc(gm_account_db, sizeof(struct gm_account) * GM_max); + gm_account_db = (struct gm_account*)aRealloc(gm_account_db, sizeof(struct gm_account) * GM_max); memset(gm_account_db + (GM_max - 256), 0, sizeof(struct gm_account) * 256); } gm_account_db[GM_num].account_id = account_id; @@ -261,7 +261,7 @@ int read_gm_account() { struct stat file_stat; int start_range = 0, end_range = 0, is_range = 0, current_id = 0; - if(gm_account_db) free(gm_account_db); + if(gm_account_db) aFree(gm_account_db); GM_num = 0; if(GM_max < 0) GM_max = 256; gm_account_db = (struct gm_account*)aCalloc(GM_max, sizeof(struct gm_account)); @@ -302,7 +302,7 @@ int read_gm_account() { printf("read_gm_account: file [%s] invalid range, beginning of range is equal to end of range (line #%d).\n", GM_account_filename, line_counter); else if (start_range>end_range) printf("read_gm_account: file [%s] invalid range, beginning of range must be lower than end of range (line #%d).\n", GM_account_filename, line_counter); - else + else for (current_id = start_range;current_id<=end_range;current_id++) addGM(current_id,level); } else { @@ -620,7 +620,7 @@ int mmo_auth_init(void) { if (auth_num >= auth_max) { auth_max += 256; - auth_dat = realloc(auth_dat, sizeof(struct auth_dat) * auth_max); + auth_dat = (struct auth_dat*)aRealloc(auth_dat, sizeof(struct auth_dat) * auth_max); } memset(&auth_dat[auth_num], '\0', sizeof(struct auth_dat)); @@ -745,7 +745,7 @@ int mmo_auth_init(void) { if (auth_num >= auth_max) { auth_max += 256; - auth_dat = realloc(auth_dat, sizeof(struct auth_dat) * auth_max); + auth_dat = (struct auth_dat*)aRealloc(auth_dat, sizeof(struct auth_dat) * auth_max); } memset(&auth_dat[auth_num], '\0', sizeof(struct auth_dat)); @@ -871,7 +871,8 @@ void mmo_auth_sync(void) { FILE *fp; int i, j, k, lock; int account_id; - int id[auth_num]; + //int id[auth_num]; + int *id = (int *)aCalloc(auth_num, sizeof(int)); char line[65536]; // Sorting before save @@ -889,8 +890,10 @@ void mmo_auth_sync(void) { } // Data save - if ((fp = lock_fopen(account_filename, &lock)) == NULL) + if ((fp = lock_fopen(account_filename, &lock)) == NULL) { + if (id) free(id); return; + } fprintf(fp, "// Accounts file: here are saved all information about the accounts.\n"); fprintf(fp, "// Structure: ID, account name, password, last login time, sex, # of logins, state, email, error message for state 7, validity time, last (accepted) login ip, memo field, ban timestamp, repeated(register text, register value)\n"); @@ -921,6 +924,8 @@ void mmo_auth_sync(void) { if (auth_before_save_file < AUTH_BEFORE_SAVE_FILE) auth_before_save_file = AUTH_BEFORE_SAVE_FILE; + if (id) aFree(id); + return; } @@ -1019,7 +1024,7 @@ int mmo_auth_new(struct mmo_account* account, char sex, char* email) { if (auth_num >= auth_max) { auth_max += 256; - auth_dat = realloc(auth_dat, sizeof(struct auth_dat) * auth_max); + auth_dat = (struct auth_dat*)aRealloc(auth_dat, sizeof(struct auth_dat) * auth_max); memset(auth_dat, 0, sizeof(struct auth_dat) * auth_max); } @@ -1132,7 +1137,7 @@ int mmo_auth(struct mmo_account* account, int fd) { memcpy(user_password, account->passwd, 25); encpasswdok = 0; #ifdef PASSWORDENC - ld = session[fd]->session_data; + ld = (struct login_session_data*)session[fd]->session_data; if (account->passwdenc > 0) { int j = account->passwdenc; if (!ld) { @@ -1392,7 +1397,7 @@ int parse_fromchar(int fd) { break; // we receive a e-mail creation of an account with a default e-mail (no answer) - case 0x2715: + case 0x2715: if (RFIFOREST(fd) < 46) return 0; { @@ -1701,7 +1706,9 @@ int parse_fromchar(int fd) { acc = RFIFOL(fd,4); for(i = 0; i < auth_num; i++) { if (auth_dat[i].account_id == acc) { - unsigned char buf[RFIFOW(fd,2)+1]; + //unsigned char buf[RFIFOW(fd,2)+1]; + unsigned char *buf; + buf = (unsigned char*)aCalloc(RFIFOW(fd,2)+1, sizeof(unsigned char)); login_log("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s)." RETCODE, server[id].name, acc, ip); for(p = 8, j = 0; p < RFIFOW(fd,2) && j < ACCOUNT_REG2_NUM; p += 36, j++) { @@ -1718,6 +1725,7 @@ int parse_fromchar(int fd) { // Save mmo_auth_sync(); // printf("parse_fromchar: receiving (from the char-server) of account_reg2 (account id: %d).\n", acc); + if (buf) free(buf); break; } } @@ -1883,7 +1891,8 @@ int parse_admin(int fd) { return 0; { int st, ed, len; - int id[auth_num]; + //int id[auth_num]; + int *id=(int *)aCalloc(auth_num, sizeof(int)); st = RFIFOL(fd,2); ed = RFIFOL(fd,6); RFIFOSKIP(fd,10); @@ -1927,6 +1936,7 @@ int parse_admin(int fd) { } WFIFOW(fd,2) = len; WFIFOSET(fd,len); + if (id) free(id); } break; @@ -2114,7 +2124,7 @@ int parse_admin(int fd) { memcpy(WFIFOP(fd,4+server_num*32+6), server[i].name, 20); WFIFOW(fd,4+server_num*32+26) = server[i].users; WFIFOW(fd,4+server_num*32+28) = server[i].maintenance; - WFIFOW(fd,4+server_num*32+30) = server[i].new; + WFIFOW(fd,4+server_num*32+30) = server[i].new_; server_num++; } } @@ -2845,7 +2855,7 @@ int parse_login(int fd) { } else printf("parse_login: connection #%d, packet: 0x%x (with being read: %d).\n", fd, RFIFOW(fd,0), RFIFOREST(fd)); } - + switch(RFIFOW(fd,0)) { case 0x200: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. if (RFIFOREST(fd) < 26) @@ -2920,7 +2930,7 @@ int parse_login(int fd) { memcpy(WFIFOP(fd,47+server_num*32+6), server[i].name, 20); WFIFOW(fd,47+server_num*32+26) = server[i].users; WFIFOW(fd,47+server_num*32+28) = server[i].maintenance; - WFIFOW(fd,47+server_num*32+30) = server[i].new; + WFIFOW(fd,47+server_num*32+30) = server[i].new_; server_num++; } } @@ -2984,7 +2994,7 @@ int parse_login(int fd) { session[fd]->eof = 1; return 0; } - ld = session[fd]->session_data = (struct login_session_data*)aCalloc(1, sizeof(struct login_session_data)); + ld = (struct login_session_data*)session[fd]->session_data = (struct login_session_data*)aCalloc(1, sizeof(struct login_session_data)); if (!ld) { printf("login: Request for md5 key: memory allocation failure (malloc)!\n"); session[fd]->eof = 1; @@ -3036,7 +3046,7 @@ int parse_login(int fd) { memcpy(server[account.account_id].name, server_name, 20); server[account.account_id].users = 0; server[account.account_id].maintenance = RFIFOW(fd,82); - server[account.account_id].new = RFIFOW(fd,84); + server[account.account_id].new_ = RFIFOW(fd,84); server_fd[account.account_id] = fd; if(anti_freeze_enable) server_freezeflag[account.account_id] = 5; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed @@ -3105,7 +3115,7 @@ int parse_login(int fd) { if (!check_ladminip(session[fd]->client_addr.sin_addr.s_addr)) { login_log("'ladmin'-login: Connection in administration mode refused: IP isn't authorised (ladmin_allow, ip: %s)." RETCODE, ip); } else { - struct login_session_data *ld = session[fd]->session_data; + struct login_session_data *ld = (struct login_session_data*)session[fd]->session_data; if (RFIFOW(fd,2) == 0) { // non encrypted password unsigned char* password=""; memcpy(password, RFIFOP(fd,4), 24); @@ -3205,9 +3215,9 @@ int parse_console(char *buf) { char command[256]; memset(command,0,sizeof(command)); - + sscanf(buf, "%[^\n]", command); - + login_log("Console command :%s" RETCODE, command); if(strcmpi("shutdown", command) == 0 || @@ -3372,22 +3382,22 @@ int login_config_read(const char *cfgName) { admin_pass[sizeof(admin_pass)-1] = '\0'; } else if (strcmpi(w1, "ladminallowip") == 0) { if (strcmpi(w2, "clear") == 0) { - if (access_ladmin_allow) - free(access_ladmin_allow); + if (access_ladmin_allow) + aFree(access_ladmin_allow); access_ladmin_allow = NULL; access_ladmin_allownum = 0; } else { if (strcmpi(w2, "all") == 0) { // reset all previous values if (access_ladmin_allow) - free(access_ladmin_allow); + aFree(access_ladmin_allow); // set to all access_ladmin_allow = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); access_ladmin_allownum = 1; access_ladmin_allow[0] = '\0'; } else if (w2[0] && !(access_ladmin_allownum == 1 && access_ladmin_allow[0] == '\0')) { // don't add IP if already 'all' if (access_ladmin_allow) - access_ladmin_allow = realloc(access_ladmin_allow, (access_ladmin_allownum+1) * ACO_STRSIZE); + access_ladmin_allow = (char*)aRealloc(access_ladmin_allow, (access_ladmin_allownum+1) * ACO_STRSIZE); else access_ladmin_allow = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); strncpy(access_ladmin_allow + (access_ladmin_allownum++) * ACO_STRSIZE, w2, ACO_STRSIZE); @@ -3469,21 +3479,21 @@ int login_config_read(const char *cfgName) { } else if (strcmpi(w1, "allow") == 0) { if (strcmpi(w2, "clear") == 0) { if (access_allow) - free(access_allow); + aFree(access_allow); access_allow = NULL; access_allownum = 0; } else { if (strcmpi(w2, "all") == 0) { // reset all previous values if (access_allow) - free(access_allow); + aFree(access_allow); // set to all access_allow = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); access_allownum = 1; access_allow[0] = '\0'; } else if (w2[0] && !(access_allownum == 1 && access_allow[0] == '\0')) { // don't add IP if already 'all' if (access_allow) - access_allow = realloc(access_allow, (access_allownum+1) * ACO_STRSIZE); + access_allow = (char*)aRealloc(access_allow, (access_allownum+1) * ACO_STRSIZE); else access_allow = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); strncpy(access_allow + (access_allownum++) * ACO_STRSIZE, w2, ACO_STRSIZE); @@ -3493,21 +3503,21 @@ int login_config_read(const char *cfgName) { } else if (strcmpi(w1, "deny") == 0) { if (strcmpi(w2, "clear") == 0) { if (access_deny) - free(access_deny); + aFree(access_deny); access_deny = NULL; access_denynum = 0; } else { if (strcmpi(w2, "all") == 0) { // reset all previous values if (access_deny) - free(access_deny); + aFree(access_deny); // set to all access_deny = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); access_denynum = 1; access_deny[0] = '\0'; } else if (w2[0] && !(access_denynum == 1 && access_deny[0] == '\0')) { // don't add IP if already 'all' if (access_deny) - access_deny = realloc(access_deny, (access_denynum+1) * ACO_STRSIZE); + access_deny = (char*)aRealloc(access_deny, (access_denynum+1) * ACO_STRSIZE); else access_deny = (char*)aCalloc(ACO_STRSIZE, sizeof(char)); strncpy(access_deny + (access_denynum++) * ACO_STRSIZE, w2, ACO_STRSIZE); @@ -3877,18 +3887,18 @@ void do_final(void) { fflush(stdout); mmo_auth_sync(); - if(auth_dat) free(auth_dat); - if(gm_account_db) free(gm_account_db); - if(access_ladmin_allow) free(access_ladmin_allow); - if(access_allow) free(access_allow); - if(access_deny) free(access_deny); + if(auth_dat) aFree(auth_dat); + if(gm_account_db) aFree(gm_account_db); + if(access_ladmin_allow) aFree(access_ladmin_allow); + if(access_allow) aFree(access_allow); + if(access_deny) aFree(access_deny); for (i = 0; i < MAX_SERVERS; i++) { if ((fd = server_fd[i]) >= 0) { server_fd[i] = -1; memset(&server[i], 0, sizeof(struct mmo_char_server)); close(fd); delete_session(fd); - if(session[fd]) free(session[fd]); + if(session[fd]) aFree(session[fd]); } } close(login_fd); @@ -3929,7 +3939,7 @@ int do_init(int argc, char **argv) { // set_termfunc(mmo_auth_sync); set_defaultparse(parse_login); login_fd = make_listen_port(login_port); - + if(anti_freeze_enable > 0) { add_timer_func_list(char_anti_freeze_system, "char_anti_freeze_system"); i = add_timer_interval(gettick() + 1000, char_anti_freeze_system, 0, 0, ANTI_FREEZE_INTERVAL * 1000); @@ -3957,7 +3967,7 @@ int do_init(int argc, char **argv) { set_defaultconsoleparse(parse_console); start_console(); } - + login_log("The login-server is ready (Server is listening on the port %d)." RETCODE, login_port); printf("The login-server is \033[1;32mready\033[0m (Server is listening on the port %d).\n\n", login_port); diff --git a/src/login/login.h b/src/login/login.h index 7370f5238..4a5b5be0c 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -33,7 +33,7 @@ struct mmo_char_server { short port; int users; int maintenance; - int new; + int new_; }; extern struct mmo_char_server server[MAX_SERVERS]; diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 25df5310d..302e78b9e 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -161,7 +161,7 @@ struct dbt *online_db; void add_online_user(int account_id) { int *p; - p = aMalloc(sizeof(int)); + p = (int*)aMalloc(sizeof(int)); if (p == NULL) { printf("add_online_user: memory allocation failure (malloc)!\n"); exit(0); @@ -173,7 +173,7 @@ void add_online_user(int account_id) { int is_user_online(int account_id) { int *p; - p = numdb_search(online_db, account_id); + p = (int*)numdb_search(online_db, account_id); if (p == NULL) return 0; printf("Acccount %d\n",*p); @@ -182,8 +182,8 @@ int is_user_online(int account_id) { void remove_online_user(int account_id) { int *p; - p = numdb_erase(online_db,account_id); - free(p); + p = (int*)numdb_erase(online_db,account_id); + aFree(p); } //----------------------------------------------------- @@ -238,9 +238,9 @@ int remove_control_chars(unsigned char *str) { //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- -int e_mail_check(unsigned char *email) { +int e_mail_check(char *email) { char ch; - unsigned char* last_arobas; + char* last_arobas; // athena limits if (strlen(email) < 3 || strlen(email) > 39) @@ -394,7 +394,7 @@ int mmo_auth( struct mmo_account* account , int fd){ // auth start : time seed gettimeofday(&tv, NULL); - strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",localtime(&(tv.tv_sec))); + strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",localtime((const time_t*)&(tv.tv_sec))); sprintf(tmpstr+19, ".%03d", (int)tv.tv_usec/1000); jstrescapecpy(t_uid,account->userid); @@ -1217,7 +1217,7 @@ int parse_login(int fd) { memcpy(WFIFOP(fd,47+server_num*32+6), server[i].name, 20); WFIFOW(fd,47+server_num*32+26) = server[i].users; WFIFOW(fd,47+server_num*32+28) = server[i].maintenance; - WFIFOW(fd,47+server_num*32+30) = server[i].new; + WFIFOW(fd,47+server_num*32+30) = server[i].new_; server_num++; } } @@ -1407,7 +1407,7 @@ int parse_login(int fd) { memcpy(server[account.account_id].name,RFIFOP(fd,60),20); server[account.account_id].users=0; server[account.account_id].maintenance=RFIFOW(fd,82); - server[account.account_id].new=RFIFOW(fd,84); + server[account.account_id].new_=RFIFOW(fd,84); server_fd[account.account_id]=fd; if(anti_freeze_enable) server_freezeflag[account.account_id] = 5; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed @@ -1480,9 +1480,9 @@ int parse_console(char *buf) { printf("Type of command: %s || Command: %s \n",type,command); - if(buf) free(buf); - if(type) free(type); - if(command) free(command); + if(buf) aFree(buf); + if(type) aFree(type); + if(command) aFree(command); return 0; } @@ -1841,7 +1841,7 @@ int do_init(int argc,char **argv){ } // Online user database init - free(online_db); + aFree(online_db); online_db = numdb_init(); printf("The login-server is \033[1;32mready\033[0m (Server is listening on the port %d).\n\n", login_port); diff --git a/src/login_sql/login.h b/src/login_sql/login.h index 6335168d7..73892f4ef 100644 --- a/src/login_sql/login.h +++ b/src/login_sql/login.h @@ -34,7 +34,7 @@ struct mmo_char_server { short port; int users; int maintenance; - int new; + int new_; }; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4b245fd0b..c1f491910 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8,6 +8,7 @@ #include "../common/socket.h" #include "../common/timer.h" #include "../common/nullpo.h" +#include "../common/mmo.h" #include "log.h" #include "clif.h" @@ -465,7 +466,7 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_Send, "@send", 60, atcommand_send }, { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag }, { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris] - { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity + { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest] @@ -531,8 +532,8 @@ static AtCommandInfo atcommand_info[] = { * This function return the name of the job (by [Yor]) *---------------------------------------------------- */ -char * job_name(int class) { - switch (class) { +char * job_name(int class_) { + switch (class_) { case 0: return "Novice"; case 1: return "Swordsman"; case 2: return "Mage"; @@ -833,18 +834,18 @@ static int atmobsearch_sub(struct block_list *bl,va_list ap) static int number=0; struct mob_data *md; char output[128]; - + nullpo_retr(0, bl); - + if(!ap){ number=0; return 0; } mob_id = va_arg(ap,int); fd = va_arg(ap,int); - + md = (struct mob_data *)bl; - + if(md && fd && (mob_id==-1 || (md->class_==mob_id))){ snprintf(output, sizeof output, "%2d[%3d:%3d] %s", ++number,bl->x, bl->y,md->name); @@ -894,7 +895,7 @@ void rehash( const int fd, struct map_session_data* sd ) int map_id = 0; int LOADED_MAPS = map_num; - + for (map_id = 0; map_id < LOADED_MAPS;map_id++) { if (map_id > LOADED_MAPS) @@ -1023,7 +1024,7 @@ int atcommand_send( WBUFW(buf,0)=0x18f; case 4: WBUFW(buf,0)=0x190; - } + } } return 0; } @@ -1113,7 +1114,7 @@ int atcommand_where( snprintf(output, sizeof output, "%s %s %d %d", character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, output); - + return 0; } @@ -1135,7 +1136,7 @@ int atcommand_jumpto( clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto )."); return -1; } - + memset(character, '\0', sizeof character); if (sscanf(message, "%99[^\n]", character) < 1) return -1; @@ -1677,8 +1678,10 @@ int atcommand_whozeny( int i, j, count,c; char match_text[100]; char player_name[24]; - int zeny[clif_countusers()]; - int counted[clif_countusers()]; + //int zeny[clif_countusers()]; + //int counted[clif_countusers()]; + int *zeny = (int *)aCallocA(clif_countusers(), sizeof(int)); + int *counted = (int *)aCallocA(clif_countusers(), sizeof(int)); nullpo_retr(-1, sd); @@ -1732,6 +1735,9 @@ int atcommand_whozeny( clif_displaymessage(fd, output); } + free(zeny); + free(counted); + return 0; } @@ -1749,7 +1755,7 @@ int atcommand_happyhappyjoyjoy( for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) { e=rand()%40; - if(e==34) + if(e==34) e = 0; clif_emotion(&pl_sd->bl,e); } @@ -2177,7 +2183,7 @@ int atcommand_alive( clif_resurrection(&sd->bl, 1); clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle! return 0; - } + } return -1; } @@ -2296,8 +2302,8 @@ int atcommand_item( if (pet_id >= 0) { sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet(sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, - pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, + (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv, + (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); // if not pet egg } else { @@ -2447,7 +2453,7 @@ int atcommand_baselevelup( clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher. return -1; } // End Addition - if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow + if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow level = battle_config.maximum_level - sd->status.base_level; for (i = 1; i <= level; i++) sd->status.status_point += (sd->status.base_level + i + 14) / 5; @@ -2464,7 +2470,7 @@ int atcommand_baselevelup( clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower. return -1; } - if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow + if (level < -(int)battle_config.maximum_level || level < (1 - (int)sd->status.base_level)) // fix negativ overflow level = 1 - sd->status.base_level; if (sd->status.status_point > 0) { for (i = 0; i > level; i--) @@ -2491,7 +2497,8 @@ int atcommand_joblevelup( const int fd, struct map_session_data* sd, const char* command, const char* message) { - int up_level = 50, level; + unsigned int up_level = 50; + int level; struct pc_base_job s_class; nullpo_retr(-1, sd); s_class = pc_calc_base_job(sd->status.class_); @@ -2514,7 +2521,7 @@ int atcommand_joblevelup( clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher. return -1; } - if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow + if ((unsigned int)level > up_level || (unsigned int)level > (up_level - sd->status.job_level)) // fix positiv overflow level = up_level - sd->status.job_level; sd->status.job_level += level; clif_updatestatus(sd, SP_JOBLEVEL); @@ -2529,7 +2536,7 @@ int atcommand_joblevelup( clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower. return -1; } - if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow + if (level < -(int)up_level || level < (1 - (int)sd->status.job_level)) // fix negativ overflow level = 1 - sd->status.job_level; sd->status.job_level += level; clif_updatestatus(sd, SP_JOBLEVEL); @@ -3117,7 +3124,7 @@ int atcommand_monster( printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y); count = 0; - range = sqrt(number) / 2; + range = (int)sqrt(number) / 2; range = range * 2 + 5; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { j = 0; @@ -3209,7 +3216,7 @@ int atcommand_spawn( printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y); count = 0; - range = sqrt(number) / 2; + range = (int)sqrt(number) / 2; range = range * 2 + 5; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { j = 0; @@ -3848,9 +3855,9 @@ int atcommand_param( } new_value = (int)*status[index] + value; - if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow + if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow new_value = battle_config.max_parameter; - else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow + else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow new_value = 1; if (new_value != (int)*status[index]) { @@ -3893,9 +3900,9 @@ int atcommand_stat_all( for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) { new_value = (int)*status[index] + value; - if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow + if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow new_value = battle_config.max_parameter; - else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow + else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow new_value = 1; if (new_value != (int)*status[index]) { @@ -3993,8 +4000,8 @@ int atcommand_makeegg( sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet( sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, - pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, + (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv, + (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } else { clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist. @@ -4149,14 +4156,14 @@ atcommand_recall( char character[100]; char output[200]; struct map_session_data *pl_sd = NULL; - + nullpo_retr(-1, sd); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @recall )."); return -1; } - + memset(character, '\0', sizeof character); if(sscanf(message, "%99[^\n]", character) < 1) return -1; @@ -4658,7 +4665,7 @@ int atcommand_character_baselevel( clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher. return 0; } // End Addition - if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow + if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow level = battle_config.maximum_level - pl_sd->status.base_level; for (i = 1; i <= level; i++) pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5; @@ -4675,7 +4682,7 @@ int atcommand_character_baselevel( clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower. return -1; } - if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) // fix negativ overflow + if (level < -(int)battle_config.maximum_level || level < (1 - (int)pl_sd->status.base_level)) // fix negativ overflow level = 1 - pl_sd->status.base_level; if (pl_sd->status.status_point > 0) { for (i = 0; i > level; i--) @@ -4712,7 +4719,8 @@ int atcommand_character_joblevel( { struct map_session_data *pl_sd; char character[100]; - int max_level = 50, level = 0; + unsigned int max_level = 50; + int level = 0; //転生や養子の場合の元の職業を算出する struct pc_base_job pl_s_class; nullpo_retr(-1, sd); @@ -5195,7 +5203,7 @@ int atcommand_idsearch( { char item_name[100]; char output[200]; - int i, match; + unsigned int i, match; struct item_data *item; nullpo_retr(-1, sd); @@ -5652,7 +5660,7 @@ int atcommand_reloadscript( nullpo_retr(-1, sd); atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." ); atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" ); - + rehash( fd, sd ); atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." ); @@ -6090,7 +6098,7 @@ int atcommand_enablenpc(const int fd, struct map_session_data* sd, memset(NPCname, '\0', sizeof(NPCname)); if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) { - clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcon )."); + clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc )."); return -1; } @@ -6961,7 +6969,7 @@ atcommand_npcmove(const int fd, struct map_session_data* sd, int x = 0, y = 0; struct npc_data *nd = 0; nullpo_retr(-1, sd); - + if (!message || !*message) return -1; @@ -7010,7 +7018,7 @@ atcommand_addwarp(const int fd, struct map_session_data* sd, ret = npc_parse_warp(w1, "warp", w3, w4); - sprintf(output, "New warp NPC => %s",w3); + sprintf(output, "New warp NPC => %s",w3); clif_displaymessage(fd, output); @@ -7063,7 +7071,7 @@ atcommand_dropall(const int fd, struct map_session_data* sd, } /*========================================== * @chardropall by [MouseJstr] - * + * * Throw all the characters possessions on the ground. Normally * done in response to them being disrespectful of a GM *------------------------------------------ @@ -7139,7 +7147,7 @@ atcommand_charstoreall(const int fd, struct map_session_data* sd, if (!message || !*message) return -1; - if((pl_sd=map_nick2sd((char *) message)) == NULL) + if((pl_sd=map_nick2sd((char *) message)) == NULL) return -1; if (storage_storageopen(pl_sd) == 1) { @@ -7254,7 +7262,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, clif_displaymessage(fd, "Usage: @skilltree "); return -1; } - if((pl_sd=map_nick2sd(target)) == NULL) + if((pl_sd=map_nick2sd(target)) == NULL) return -1; s_class = pc_calc_base_job(pl_sd->status.class_); @@ -7265,8 +7273,8 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, tbl = job_name(c); - sprintf(output, "Player is using %s %s skill tree (%d basic points)", - s_class.upper ? "upper" : "lower", + sprintf(output, "Player is using %s %s skill tree (%d basic points)", + s_class.upper ? "upper" : "lower", tbl, pc_checkskill(pl_sd, 1)); clif_displaymessage(fd, output); @@ -7276,7 +7284,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, break; } } - + if (skillidx == -1) { sprintf(output, "I do not believe the player can use that skill"); clif_displaymessage(fd, output); @@ -7285,19 +7293,19 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, ent = &skill_tree[s][c][skillidx]; - for(j=0;j<5;j++) + for(j=0;j<5;j++) if( ent->need[j].id && - pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv) + pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv) { int idx = 0; char *desc; - while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id) + while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id) idx++; if (skill_names[idx].id == 0) desc = "Unknown skill"; else desc = skill_names[idx].desc; - sprintf(output, "player requires level %d of skill %s", + sprintf(output, "player requires level %d of skill %s", ent->need[j].lv, desc); clif_displaymessage(fd, output); meets = 0; @@ -7307,7 +7315,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd, sprintf(output, "I believe the player meets all the requirements for that skill"); clif_displaymessage(fd, output); } - + return 0; } @@ -7392,7 +7400,7 @@ atcommand_rings(const int fd, struct map_session_data* sd, { struct item item_tmp; int flag; - + memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = 2634; @@ -7456,7 +7464,7 @@ atcommand_grind(const int fd, struct map_session_data* sd, clif_displaymessage(fd, "Usage: @grind "); return -1; } - if((pl_sd=map_nick2sd(target)) == NULL) + if((pl_sd=map_nick2sd(target)) == NULL) return -1; for (skillnum = 1; skillnum < 500; skillnum++) { @@ -7512,7 +7520,7 @@ atcommand_rain( } else { map[sd->bl.m].flag.rain=1; clif_specialeffect(&sd->bl,effno,2); - clif_displaymessage(fd, "It is made to rain."); + clif_displaymessage(fd, "It is made to rain."); } return 0; } @@ -7536,7 +7544,7 @@ atcommand_snow( clif_specialeffect(&sd->bl,effno,2); clif_displaymessage(fd, "It is made to snow."); } - + return 0; } @@ -7629,7 +7637,7 @@ atcommand_clearweather( map[sd->bl.m].flag.leaves=0; //clif_specialeffect(&sd->bl,effno,2); // not required. [celest] return 0; -} +} /*=============================================================== * Sound Command - plays a sound for everyone! [Codemaster] @@ -7720,7 +7728,7 @@ atcommand_cleanmap( } /*========================================== - * + * *------------------------------------------ */ int @@ -7735,14 +7743,14 @@ atcommand_summon( int id = 0; struct mob_data *md; unsigned int tick=gettick(); - + nullpo_retr(-1, sd); if (!message || !*message) return -1; if (sscanf(message, "%99s", name) < 1) return -1; - + if ((mob_id = atoi(name)) == 0) mob_id = mobdb_searchname(name); if(mob_id == 0) @@ -7823,7 +7831,7 @@ atcommand_adjgmlvl( return -1; } - if((pl_sd=map_nick2sd((char *) user)) == NULL) + if((pl_sd=map_nick2sd((char *) user)) == NULL) return -1; pc_set_gm_level(pl_sd->status.account_id, newlev); @@ -7837,7 +7845,7 @@ atcommand_adjgmlvl( * * Open a trade window with a remote player * - * If I have to jump to a remote player one more time, I am + * If I have to jump to a remote player one more time, I am * gonna scream! *------------------------------------------ */ @@ -7876,7 +7884,7 @@ atcommand_setbattleflag( return -1; } - if (battle_set_value(flag, value) == 0) + if (battle_set_value(flag, value) == 0) clif_displaymessage(fd, "unknown battle_config flag"); else clif_displaymessage(fd, "battle_config set as requested"); @@ -7901,7 +7909,7 @@ int atcommand_unmute( if((pl_sd=map_nick2sd((char *) message)) != NULL) { if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) { pl_sd->status.manner = 0; // have to set to 0 first [celest] - skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1); + skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1); clif_displaymessage(sd->fd,"Player unmuted"); } else @@ -7932,7 +7940,7 @@ atcommand_uptime( seconds -= (seconds/hour>0)?(seconds/hour)*hour:0; minutes = seconds/minute; seconds -= (seconds/minute>0)?(seconds/minute)*minute:0; - + snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds); clif_displaymessage(fd,output); @@ -8013,7 +8021,7 @@ atcommand_petid(const int fd, struct map_session_data* sd, char temp0[100]; char temp1[100]; int cnt = 0, i = 0; - + nullpo_retr(-1, sd); if (!message || !*message) @@ -8066,7 +8074,7 @@ atcommand_identify( } } if (num > 0) { - clif_item_identify_list(sd); + clif_item_identify_list(sd); } else { clif_displaymessage(fd,"There are no items to appraise."); } @@ -8074,7 +8082,7 @@ atcommand_identify( } /*========================================== - * @gmotd (Global MOTD) + * @gmotd (Global MOTD) * by davidsiaw :P *------------------------------------------ */ @@ -8113,7 +8121,7 @@ int atcommand_misceffect( if (sscanf(message, "%d", &effect) < 1) return -1; clif_misceffect(&sd->bl,effect); - + return 0; } @@ -8128,7 +8136,7 @@ int charid2sessionid(int charid) if (pl_sd->status.char_id==charid) { session_id = i; break; } } } - + return session_id; } @@ -8143,7 +8151,7 @@ int accountid2sessionid(int accountid) if (pl_sd->status.account_id==accountid) { session_id = i; break; } } } - + return session_id; } @@ -8696,9 +8704,9 @@ atcommand_charkillableid( { if((pl_sd=session[session_id]->session_data) == NULL) return -1; - + pl_sd->special_state.killable = !pl_sd->special_state.killable; - + if(pl_sd->special_state.killable) clif_displaymessage(fd, "The player is now killable"); else @@ -8737,9 +8745,9 @@ atcommand_charkillableid2( { if((pl_sd=session[session_id]->session_data) == NULL) return -1; - + pl_sd->special_state.killable = !pl_sd->special_state.killable; - + if(pl_sd->special_state.killable) clif_displaymessage(fd, "The player is now killable"); else @@ -8762,7 +8770,7 @@ atcommand_charkillableid2( int atcommand_listmail( const int fd, struct map_session_data* sd, const char* command, const char* message) -{ +{ if(!battle_config.mail_system) return 0; @@ -8772,7 +8780,7 @@ int atcommand_listmail( mail_check(sd,3); else if(strlen(command)==9) mail_check(sd,2); - else + else mail_check(sd,1); return 0; } @@ -8823,7 +8831,7 @@ int atcommand_sendmail( if(strlen(command)==17) mail_send(sd,name,text,1); - else + else mail_send(sd,name,text,0); return 0; @@ -8842,7 +8850,7 @@ int atcommand_refreshonline( nullpo_retr(-1, sd); char_online_check(); - + return 0; } diff --git a/src/map/atcommand.h b/src/map/atcommand.h index f639d8c33..754a741b7 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -112,9 +112,9 @@ enum AtCommandType { AtCommand_CharSkReset, AtCommand_CharStReset, //by chbrules - AtCommand_CharModel, + AtCommand_CharModel, AtCommand_CharSKPoint, - AtCommand_CharSTPoint, + AtCommand_CharSTPoint, // AtCommand_CharZeny, //now #zeny AtCommand_RecallAll, AtCommand_ReloadItemDB, @@ -198,7 +198,7 @@ enum AtCommandType { AtCommand_CleanMap, // SQL-only commands start -#ifndef TXT_ONLY +#ifndef TXT_ONLY AtCommand_CheckMail, // [Valaris] AtCommand_ListMail, // [Valaris] AtCommand_ListNewMail, // [Valaris] @@ -206,7 +206,7 @@ enum AtCommandType { AtCommand_SendMail, // [Valaris] AtCommand_DeleteMail, // [Valaris] AtCommand_SendPriorityMail, // [Valaris] -// AtCommand_Sound, // [Valaris] +// AtCommand_Sound, // [Valaris] AtCommand_RefreshOnline, // [Valaris] // SQL-only commands end #endif @@ -272,7 +272,7 @@ int msg_config_read(const char *cfgName); char *estr_lower(char *str); -char * job_name(int class); +char * job_name(int class_); int e_mail_check(unsigned char *email); #endif diff --git a/src/map/battle.c b/src/map/battle.c index 3cff73a18..ce691158c 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -179,6 +179,10 @@ int battle_get_max_hp(struct block_list *bl) if(sc_data[SC_APPLEIDUN].timer!=-1) max_hp += ((5+sc_data[SC_APPLEIDUN].val1*2+((sc_data[SC_APPLEIDUN].val2+1)>>1) +sc_data[SC_APPLEIDUN].val3/10) * max_hp)/100; + if(sc_data[SC_GOSPEL].timer!=-1 && + sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 4) + max_hp += max_hp * 25 / 100; } if(max_hp < 1) max_hp = 1; return max_hp; @@ -429,16 +433,24 @@ int battle_get_flee(struct block_list *bl) else flee=battle_get_agi(bl) + battle_get_lv(bl); - if(sc_data) { - if(sc_data[SC_WHISTLE].timer!=-1 && bl->type != BL_PC) + if(bl->type != BL_PC && sc_data){ + if(sc_data[SC_WHISTLE].timer!=-1) flee += flee*(sc_data[SC_WHISTLE].val1+sc_data[SC_WHISTLE].val2 +(sc_data[SC_WHISTLE].val3>>16))/100; - if(sc_data[SC_BLIND].timer!=-1 && bl->type != BL_PC) + if(sc_data[SC_BLIND].timer!=-1) flee -= flee*25/100; - if(sc_data[SC_WINDWALK].timer!=-1 && bl->type != BL_PC) // ウィンドウォーク + if(sc_data[SC_WINDWALK].timer!=-1) // ウィンドウォーク flee += flee*(sc_data[SC_WINDWALK].val2)/100; - if(sc_data[SC_SPIDERWEB].timer!=-1 && bl->type != BL_PC) //スパイダーウェブ + if(sc_data[SC_SPIDERWEB].timer!=-1) //スパイダーウェブ flee -= flee*50/100; + if(sc_data[SC_GOSPEL].timer!=-1) { + if (sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 13) + flee += flee*5/100; + else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 7) + flee = 0; + } } if(flee < 1) flee = 1; return flee; @@ -460,16 +472,20 @@ int battle_get_hit(struct block_list *bl) else hit=battle_get_dex(bl) + battle_get_lv(bl); - if(sc_data) { - if(sc_data[SC_HUMMING].timer!=-1 && bl->type != BL_PC) // + if(bl->type != BL_PC && sc_data) { + if(sc_data[SC_HUMMING].timer!=-1) // hit += hit*(sc_data[SC_HUMMING].val1*2+sc_data[SC_HUMMING].val2 +sc_data[SC_HUMMING].val3)/100; - if(sc_data[SC_BLIND].timer!=-1 && bl->type != BL_PC) // 呪い + if(sc_data[SC_BLIND].timer!=-1) // 呪い hit -= hit*25/100; - if(sc_data[SC_TRUESIGHT].timer!=-1 && bl->type != BL_PC) // トゥルーサイト + if(sc_data[SC_TRUESIGHT].timer!=-1) // トゥルーサイト hit += 3*(sc_data[SC_TRUESIGHT].val1); - if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション + if(sc_data[SC_CONCENTRATION].timer!=-1) //コンセントレーション hit += (hit*(10*(sc_data[SC_CONCENTRATION].val1)))/100; + if(sc_data[SC_GOSPEL].timer!=-1 && + sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 14) + hit += hit*5/100; } if(hit < 1) hit = 1; return hit; @@ -560,7 +576,7 @@ int battle_get_baseatk(struct block_list *bl) if(sc_data[SC_CURSE].timer!=-1 ) //呪われていたら batk -= batk*25/100; //base_atkが25%減少 if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション - batk += batk*(5*sc_data[SC_CONCENTRATION].val1)/100; + batk += batk*(5*sc_data[SC_CONCENTRATION].val1)/100; } if(batk < 1) batk = 1; //base_atkは最低でも1 return batk; @@ -584,13 +600,22 @@ int battle_get_atk(struct block_list *bl) else if(bl->type==BL_PET && (struct pet_data *)bl) atk = mob_db[((struct pet_data*)bl)->class_].atk1; - if(sc_data) { - if(sc_data[SC_PROVOKE].timer!=-1 && bl->type != BL_PC) + if(bl->type != BL_PC && sc_data) { + if(sc_data[SC_PROVOKE].timer!=-1) atk = atk*(100+2*sc_data[SC_PROVOKE].val1)/100; - if(sc_data[SC_CURSE].timer!=-1 ) + if(sc_data[SC_CURSE].timer!=-1) atk -= atk*25/100; - if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション + if(sc_data[SC_CONCENTRATION].timer!=-1) //コンセントレーション atk += atk*(5*sc_data[SC_CONCENTRATION].val1)/100; + + if(sc_data[SC_GOSPEL].timer!=-1) { + if (sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 12) + atk += atk*8/100; + else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 6) + atk = 0; + } } if(atk < 0) atk = 0; return atk; @@ -605,9 +630,6 @@ int battle_get_atk_(struct block_list *bl) nullpo_retr(0, bl); if(bl->type==BL_PC && (struct map_session_data *)bl){ int atk=((struct map_session_data*)bl)->watk_; - - if(((struct map_session_data *)bl)->sc_data[SC_CURSE].timer!=-1 ) - atk -= atk*25/100; return atk; } else @@ -780,10 +802,19 @@ int battle_get_def(struct block_list *bl) def = def * (100 - sc_data[SC_SIGNUMCRUCIS].val2)/100; //永遠の混沌時はDEF0になる if(sc_data[SC_ETERNALCHAOS].timer!=-1) - def = 0; + def = 0; //コンセントレーション時は減算 if( sc_data[SC_CONCENTRATION].timer!=-1) def = (def*(100 - 5*sc_data[SC_CONCENTRATION].val1))/100; + + if(sc_data[SC_GOSPEL].timer!=-1) { + if (sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 11) + def += def*25/100; + else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 5) + def = 0; + } } } //詠唱中は詠唱時減算率に基づいて減算 @@ -859,6 +890,15 @@ int battle_get_def2(struct block_list *bl) //コンセントレーション時は減算 if( sc_data[SC_CONCENTRATION].timer!=-1) def2 = def2*(100 - 5*sc_data[SC_CONCENTRATION].val1)/100; + + if(sc_data[SC_GOSPEL].timer!=-1) { + if (sc_data[SC_GOSPEL].val4 == BCT_PARTY && + sc_data[SC_GOSPEL].val3 == 11) + def2 += def2*25/100; + else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 5) + def2 = 0; + } } if(def2 < 1) def2 = 1; return def2; @@ -942,6 +982,10 @@ int battle_get_speed(struct block_list *bl) speed = speed*150/100; if(sc_data[SC_SPEEDUP0].timer!=-1) speed -= speed*25/100; + if(sc_data[SC_GOSPEL].timer!=-1 && + sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 8) + speed = speed*125/100; } if(speed < 1) speed = 1; return speed; @@ -1002,6 +1046,10 @@ int battle_get_adelay(struct block_list *bl) //ディフェンダー時は加算 if(sc_data[SC_DEFENDER].timer != -1) adelay += (1100 - sc_data[SC_DEFENDER].val1*100); + if(sc_data[SC_GOSPEL].timer!=-1 && + sc_data[SC_GOSPEL].val4 == BCT_ENEMY && + sc_data[SC_GOSPEL].val3 == 8) + aspd_rate = aspd_rate*125/100; } if(aspd_rate != 100) adelay = adelay*aspd_rate/100; @@ -1315,7 +1363,7 @@ int battle_delay_damage_sub(int tid,unsigned int tick,int id,int data) struct battle_delay_damage_ *dat=(struct battle_delay_damage_ *)data; if( dat && map_id2bl(id)==dat->src && dat->target->prev!=NULL) battle_damage(dat->src,dat->target,dat->damage,dat->flag); - free(dat); + aFree(dat); return 0; } int battle_delay_damage(unsigned int tick,struct block_list *src,struct block_list *target,int damage,int flag) @@ -1487,11 +1535,11 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i struct mob_data *md=NULL; struct status_change *sc_data,*sc; short *sc_count; - int class; + int class_; nullpo_retr(0, bl); - class = battle_get_class(bl); + class_ = battle_get_class(bl); if(bl->type==BL_MOB) md=(struct mob_data *)bl; else sd=(struct map_session_data *)bl; @@ -1612,7 +1660,10 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i } // リジェクトソード if(sc_data[SC_REJECTSWORD].timer!=-1 && damage > 0 && flag&BF_WEAPON && - ((src->type==BL_PC && ((struct map_session_data *)src)->status.weapon == (1 || 2 || 3)) || src->type==BL_MOB )){ + // Fixed the condition check [Aalye] + (src->type==BL_MOB || (src->type==BL_PC && (((struct map_session_data *)src)->status.weapon == 1 || + ((struct map_session_data *)src)->status.weapon == 2 || + ((struct map_session_data *)src)->status.weapon == 3)))){ if(rand()%100 < (15*sc_data[SC_REJECTSWORD].val1)){ //反射確率は15*Lv damage = damage*50/100; clif_damage(bl,src,gettick(),0,0,damage,0,0,0); @@ -1630,22 +1681,22 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i damage<<=1; skill_status_change_end(bl, SC_SPIDERWEB, -1); } - + if(sc_data[SC_FOGWALL].timer != -1 && flag&BF_MAGIC) if(rand()%100 < sc_data[SC_FOGWALL].val2) damage = 0; } - if(class == 1288 || class == 1287 || class == 1286 || class == 1285) { -// if(class == 1288) { - if(class == 1288 && flag&BF_SKILL) + if(class_ == 1288 || class_ == 1287 || class_ == 1286 || class_ == 1285) { +// if(class_ == 1288) { + if(class_ == 1288 && flag&BF_SKILL) damage=0; if(src->type == BL_PC) { struct guild *g=guild_search(((struct map_session_data *)src)->status.guild_id); struct guild_castle *gc=guild_mapname2gc(map[bl->m].name); if(!((struct map_session_data *)src)->status.guild_id) damage=0; - if(gc && agit_flag==0 && class != 1288) // guardians cannot be damaged during non-woe [Valaris] + if(gc && agit_flag==0 && class_ != 1288) // guardians cannot be damaged during non-woe [Valaris] damage=0; // end woe check [Valaris] if(g == NULL) damage=0;//ギルド未加入ならダメージ無し @@ -2010,7 +2061,7 @@ static struct Damage battle_calc_pet_weapon_attack( blewcount=0; break; case AS_GRIMTOOTH: - damage = damage*(100+ 20*skill_lv)/100; + damage = damage*(100+ 20*skill_lv)/100; break; case AS_POISONREACT: // celest s_ele = 0; @@ -2208,7 +2259,7 @@ static struct Damage battle_calc_pet_weapon_attack( hitrate -= 50; if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中 t_sc_data[SC_STAN].timer!=-1 || // スタンは必中 - t_sc_data[SC_FREEZE].timer!=-1 || + t_sc_data[SC_FREEZE].timer!=-1 || (t_sc_data[SC_STONE].timer!=-1 && t_sc_data[SC_STONE].val2==0)) // 凍結は必中 hitrate = 1000000; } @@ -2221,7 +2272,7 @@ static struct Damage battle_calc_pet_weapon_attack( dmg_lv = ATK_DEF; } - + if(t_sc_data) { int cardfix=100; if(t_sc_data[SC_DEFENDER].timer != -1 && flag&BF_LONG) @@ -2507,7 +2558,7 @@ static struct Damage battle_calc_mob_weapon_attack( flag=(flag&~BF_SKILLMASK)|BF_NORMAL; break; case AS_GRIMTOOTH: - damage = damage*(100+ 20*skill_lv)/100; + damage = damage*(100+ 20*skill_lv)/100; break; case AS_POISONREACT: // celest s_ele = 0; @@ -2710,7 +2761,7 @@ static struct Damage battle_calc_mob_weapon_attack( hitrate -= 50; if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中 t_sc_data[SC_STAN].timer!=-1 || // スタンは必中 - t_sc_data[SC_FREEZE].timer!=-1 || + t_sc_data[SC_FREEZE].timer!=-1 || (t_sc_data[SC_STONE].timer!=-1 && t_sc_data[SC_STONE].val2==0)) // 凍結は必中 hitrate = 1000000; } @@ -2762,8 +2813,8 @@ static struct Damage battle_calc_mob_weapon_attack( if(damage < 0) damage = 0; // 属 性の適用 - if (!((battle_config.mob_ghostring_fix == 1) && - (battle_get_elem_type(target) == 8) && + if (!((battle_config.mob_ghostring_fix == 1) && + (battle_get_elem_type(target) == 8) && (target->type==BL_PC))) // [MouseJstr] if(skill_num != 0 || s_ele != 0 || !battle_config.mob_attack_attr_none) damage=battle_attr_fix(damage, s_ele, battle_get_element(target) ); @@ -3506,7 +3557,7 @@ static struct Damage battle_calc_pc_weapon_attack( /* int mdef1=battle_get_mdef(target); int mdef2=battle_get_mdef2(target); int imdef_flag=0; - + damage = ((damage * 5) + (skill_lv * battle_get_int(src) * 5) + rand()%500 + 500) /2; damage2 = ((damage2 * 5) + (skill_lv * battle_get_int(src) * 5) + rand()%500 + 500) /2; damage3 = damage; @@ -3520,7 +3571,7 @@ static struct Damage battle_calc_pc_weapon_attack( // calculate magic part of damage damage3 = skill_lv * battle_get_int(src) * 5; - + // ignores magic defense now [Celest] /*if(sd->ignore_mdef_ele & (1<ignore_mdef_race & (1<status.weapon > 16) {// 二刀流か? int dmg = damage, dmg2 = damage2; @@ -4258,7 +4309,7 @@ struct Damage battle_calc_magic_attack( } else if (target->type == BL_PC) { damage = ((struct map_session_data *)target)->status.sp * 2; matk_flag = 0; // don't consider matk and matk2 - } + } break; } } @@ -4554,6 +4605,7 @@ struct Damage battle_calc_attack( int attack_type, default: if(battle_config.error_log) printf("battle_calc_attack: unknwon attack type ! %d\n",attack_type); + memset(&d,0,sizeof(d)); break; } return d; @@ -4596,7 +4648,7 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target, } if(battle_check_target(src,target,BCT_ENEMY) <= 0 && - !battle_check_range(src,target,0)) + !battle_check_range(src,target,0)) return 0; // 攻撃対象外 race = battle_get_race(target); @@ -4810,8 +4862,8 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target, --t_sc_data[SC_POISONREACT].val2; } if (t_sc_data[SC_POISONREACT].val2<=0) - skill_status_change_end(target,SC_POISONREACT,-1); - } + skill_status_change_end(target,SC_POISONREACT,-1); + } } if (t_sc_data && t_sc_data[SC_BLADESTOP_WAIT].timer != -1 && !(battle_get_mode(src)&0x20)) { // ボスには無効 @@ -4911,7 +4963,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f return -1; if(ss->prev == NULL) return -1; - if(inf2&0x80 && + if(inf2&0x80 && (map[src->m].flag.pvp || pc_iskiller((struct map_session_data *)src, (struct map_session_data *)target)) && // [MouseJstr] !(target->type == BL_PC && pc_isinvisible((struct map_session_data *)target))) return 0; @@ -5037,7 +5089,7 @@ int battle_check_range(struct block_list *src,struct block_list *bl,int range) int dx,dy; struct walkpath_data wpd; int arange; - + nullpo_retr(0, src); nullpo_retr(0, bl); @@ -5182,7 +5234,7 @@ static const struct { { "item_slots_override_grffile", &battle_config.item_slots_override_grffile}, // [Celest] { "indoors_override_grffile", &battle_config.indoors_override_grffile}, // [Celest] { "skill_sp_override_grffile", &battle_config.skill_sp_override_grffile}, // [Celest] - { "cardillust_read_grffile", &battle_config.cardillust_read_grffile}, // [Celest] + { "cardillust_read_grffile", &battle_config.cardillust_read_grffile}, // [Celest] { "arrow_decrement", &battle_config.arrow_decrement }, { "max_aspd", &battle_config.max_aspd }, { "max_hp", &battle_config.max_hp }, @@ -5329,10 +5381,10 @@ static const struct { { "allow_atcommand_when_mute", &battle_config.allow_atcommand_when_mute}, // [celest] { "finding_ore_rate", &battle_config.finding_ore_rate}, // [celest] { "exp_calc_type", &battle_config.exp_calc_type}, // [celest] - { "double_login_system", &battle_config.double_login_system}, // [celest] + { "min_skill_delay_limit", &battle_config.min_skill_delay_limit}, // [celest] //SQL-only options start -#ifndef TXT_ONLY +#ifndef TXT_ONLY { "mail_system", &battle_config.mail_system }, // added by [Valaris] //SQL-only options end #endif @@ -5442,7 +5494,7 @@ void battle_set_defaults() { battle_config.item_slots_override_grffile=0; // [Celest] battle_config.indoors_override_grffile=0; // [Celest] battle_config.skill_sp_override_grffile=0; // [Celest] - battle_config.cardillust_read_grffile=0; // [Celest] + battle_config.cardillust_read_grffile=0; // [Celest] battle_config.arrow_decrement=1; battle_config.max_aspd = 199; battle_config.max_hp = 32500; @@ -5590,10 +5642,10 @@ void battle_set_defaults() { battle_config.castrate_dex_scale = 150; battle_config.area_size = 14; battle_config.exp_calc_type = 1; - battle_config.double_login_system = 0; + battle_config.min_skill_delay_limit = 100; //SQL-only options start -#ifndef TXT_ONLY +#ifndef TXT_ONLY battle_config.mail_system = 0; //SQL-only options end #endif @@ -5710,13 +5762,13 @@ void battle_validate_conf() { // at least 1 client must be accepted if ((battle_config.packet_ver_flag & 127) == 0) // added by [Yor] battle_config.packet_ver_flag = 127; // accept all clients - + if (battle_config.night_darkness_level > 10) // Celest battle_config.night_darkness_level = 10; if (battle_config.skill_range_leniency < 0) // Celest battle_config.skill_range_leniency = 0; - + if (battle_config.motd_type < 0) battle_config.motd_type = 0; else if (battle_config.motd_type > 1) @@ -5728,22 +5780,21 @@ void battle_validate_conf() { if (battle_config.vending_max_value > 10000000 || battle_config.vending_max_value<=0) // Lupus & Kobra_k88 battle_config.vending_max_value = 10000000; - if (battle_config.double_login_system < 0) - battle_config.double_login_system = 0; - + if (battle_config.min_skill_delay_limit < 10) + battle_config.min_skill_delay_limit = 10; // minimum delay of 10ms } /*========================================== * 設定ファイルを読み込む *------------------------------------------ */ -int battle_config_read(const char *cfgName) +int battle_config_read(const char *cfgName) { char line[1024], w1[1024], w2[1024]; FILE *fp; static int count = 0; - if ((count++) == 0) + if ((count++) == 0) battle_set_defaults(); fp = fopen(cfgName,"r"); diff --git a/src/map/battle.h b/src/map/battle.h index 29b537080..d88ea54c1 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -115,6 +115,7 @@ enum { BCT_NOPARTY =0x50000, BCT_ALL =0x20000, BCT_NOONE =0x60000, + BCT_SELF =0x60000, }; int battle_check_undead(int race,int element); @@ -291,7 +292,7 @@ extern struct Battle_Config { int prevent_logout; // Added by RoVeRT int alchemist_summon_reward; // [Valaris] - int maximum_level; + unsigned int maximum_level; int drops_by_luk; int monsters_ignore_gm; int equipment_breaking; @@ -348,7 +349,7 @@ extern struct Battle_Config { int zeny_from_mobs; // [Valaris] int mobs_level_up; // [Valaris] - int pk_min_level; // [celest] + unsigned int pk_min_level; // [celest] int skill_steal_type; // [celest] int skill_steal_rate; // [celest] int night_darkness_level; // [celest] @@ -357,7 +358,7 @@ extern struct Battle_Config { int allow_atcommand_when_mute; // [celest] int finding_ore_rate; // orn int exp_calc_type; - int double_login_system; + int min_skill_delay_limit; #ifndef TXT_ONLY /* SQL-only options */ int mail_system; // [Valaris] diff --git a/src/map/charcommand.c b/src/map/charcommand.c index 1ced08777..5d65c8f01 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -1063,8 +1063,8 @@ int charcommand_item( if (pet_id >= 0) { sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet(sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, - pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, + (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv, + (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); // if not pet egg } else { diff --git a/src/map/chat.c b/src/map/chat.c index c7ec13a5f..cfd2660e0 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -49,7 +49,7 @@ int chat_createchat(struct map_session_data *sd,int limit,int pub,char* pass,cha cd->bl.id = map_addobject(&cd->bl); if(cd->bl.id==0){ clif_createchat(sd,1); - free(cd); + aFree(cd); return 0; } pc_setchatid(sd,cd->bl.id); @@ -82,7 +82,7 @@ int chat_joinchat(struct map_session_data *sd,int chatid,char* pass) clif_joinchatfail(sd,1); return 0; } - if(chatid == sd->chatID) //Double Chat fix by Alex14, thx CHaNGeTe + if(chatid == (int)sd->chatID) //Double Chat fix by Alex14, thx CHaNGeTe { clif_joinchatfail(sd,1); return 0; @@ -290,7 +290,7 @@ int chat_createnpcchat(struct npc_data *nd,int limit,int pub,int trigger,char* t cd->bl.id = map_addobject(&cd->bl); if(cd->bl.id==0){ - free(cd); + aFree(cd); return 0; } nd->chat_id=cd->bl.id; diff --git a/src/map/clif.c b/src/map/clif.c index b72192690..38aa8ab26 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -53,11 +53,15 @@ #define STATE_BLIND 0x10 -int packet_db_ver = -1; // the packet version used by packet_db -int packet_db_connect_cmd = 0xF5; // the default packet used for connecting to the server - +struct Clif_Config clif_config; struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB]; +#define USE_PACKET_DB(sd) \ + clif_config.enable_packet_db && sd->packet_ver == clif_config.packet_db_ver + +#define IS_PACKET_DB_VER(cmd) \ + cmd == clif_config.connect_cmd + static const int packet_len_table[MAX_PACKET_DB] = { 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -66,7 +70,7 @@ static const int packet_len_table[MAX_PACKET_DB] = { //#0x0040 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2, + 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2, #if PACKETVER < 2 3, 28, 19, 11, 3, -1, 9, 5, 52, 51, 56, 58, 41, 2, 6, 6, #else // 78-7b 亀島以降 lv99エフェクト用 @@ -155,7 +159,7 @@ char talkie_mes[80]; * map鯖のip設定 *------------------------------------------ */ -void clif_setip(char *ip) +void clif_setip(char *ip) { memcpy(map_ip_str, ip, 16); map_ip = inet_addr(map_ip_str); @@ -165,7 +169,7 @@ void clif_setip(char *ip) * map鯖のport設定 *------------------------------------------ */ -void clif_setport(int port) +void clif_setport(int port) { map_port = port; } @@ -174,7 +178,7 @@ void clif_setport(int port) * map鯖のip読み出し *------------------------------------------ */ -in_addr_t clif_getip(void) +in_addr_t clif_getip(void) { return map_ip; } @@ -183,7 +187,7 @@ in_addr_t clif_getip(void) * map鯖のport読み出し *------------------------------------------ */ -int clif_getport(void) +int clif_getport(void) { return map_port; } @@ -192,7 +196,7 @@ int clif_getport(void) * *------------------------------------------ */ -int clif_countusers(void) +int clif_countusers(void) { int users = 0, i; struct map_session_data *sd; @@ -209,7 +213,7 @@ int clif_countusers(void) * 全てのclientに対してfunc()実行 *------------------------------------------ */ -int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) +int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) { int i; va_list ap; @@ -228,7 +232,7 @@ int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) * clif_sendでAREA*指定時用 *------------------------------------------ */ -int clif_send_sub(struct block_list *bl, va_list ap) +int clif_send_sub(struct block_list *bl, va_list ap) { unsigned char *buf; int len; @@ -902,17 +906,17 @@ static int clif_set007b(struct map_session_data *sd,unsigned char *buf) { * クラスチェンジ typeはMobの場合は1で他は0? *------------------------------------------ */ -int clif_class_change(struct block_list *bl,int class,int type) +int clif_class_change(struct block_list *bl,int class_,int type) { char buf[16]; nullpo_retr(0, bl); - if(class >= MAX_PC_CLASS) { + if(class_ >= MAX_PC_CLASS) { WBUFW(buf,0)=0x1b0; WBUFL(buf,2)=bl->id; WBUFB(buf,6)=type; - WBUFL(buf,7)=class; + WBUFL(buf,7)=class_; clif_send(buf,packet_len_table[0x1b0],bl,AREA); } @@ -922,9 +926,9 @@ int clif_class_change(struct block_list *bl,int class,int type) * *------------------------------------------ */ -int clif_mob_class_change(struct mob_data *md, int class) { +int clif_mob_class_change(struct mob_data *md, int class_) { char buf[16]; - int view = mob_get_viewclass(class); + int view = mob_get_viewclass(class_); nullpo_retr(0, md); @@ -961,7 +965,7 @@ int clif_mob_equip(struct mob_data *md, int nameid) { * MOB表示1 *------------------------------------------ */ -static int clif_mob0078(struct mob_data *md, unsigned char *buf) +static int clif_mob0078(struct mob_data *md, unsigned char *buf) { int level; @@ -3730,7 +3734,7 @@ void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md) int len; nullpo_retv(sd); nullpo_retv(md); - + if (session[sd->fd] == NULL) return; @@ -3749,7 +3753,7 @@ void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md) clif_specialeffect(&md->bl,423,0); else if(md->size==1) clif_specialeffect(&md->bl,421,0); - + } @@ -4049,8 +4053,8 @@ int clif_moboutsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); nullpo_retr(0, md=va_arg(ap,struct mob_data*)); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_clearchar_id(md->bl.id,0,sd->fd); } @@ -4071,8 +4075,8 @@ int clif_mobinsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); md=va_arg(ap,struct mob_data*); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_getareachar_mob(sd,md); } @@ -4093,8 +4097,8 @@ int clif_petoutsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); nullpo_retr(0, pd=va_arg(ap,struct pet_data*)); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_clearchar_id(pd->bl.id,0,sd->fd); } @@ -4112,8 +4116,8 @@ int clif_npcoutsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); nullpo_retr(0, nd=va_arg(ap,struct npc_data*)); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_clearchar_id(nd->bl.id,0,sd->fd); } @@ -4134,8 +4138,8 @@ int clif_petinsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); pd=va_arg(ap,struct pet_data*); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_getareachar_pet(sd,pd); } @@ -4153,8 +4157,8 @@ int clif_npcinsight(struct block_list *bl,va_list ap) nullpo_retr(0, ap); nd=va_arg(ap,struct npc_data*); - if(bl->type==BL_PC - && ((sd = (struct map_session_data*) bl) != NULL) + if(bl->type==BL_PC + && ((sd = (struct map_session_data*) bl) != NULL) && session[sd->fd] != NULL) { clif_getareachar_npc(sd,nd); } @@ -4701,7 +4705,7 @@ int clif_status_change(struct block_list *bl,int type,int flag) * Send message (modified by [Yor]) *------------------------------------------ */ -int clif_displaymessage(const int fd, char* mes) +int clif_displaymessage(const int fd, char* mes) { //Console [Wizputer] if (fd == 0) @@ -4724,13 +4728,13 @@ int clif_displaymessage(const int fd, char* mes) * 天の声を送信する *------------------------------------------ */ -int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag) +int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag) { unsigned char *buf; int lp; lp = (flag & 0x10) ? 8 : 4; - buf = (unsigned char*)aCalloc(len + lp, sizeof(unsigned char)); + buf = (unsigned char*)aCallocA(len + lp, sizeof(unsigned char)); WBUFW(buf,0) = 0x9a; WBUFW(buf,2) = len + lp; @@ -4743,7 +4747,7 @@ int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag) (flag == 3) ? SELF : ALL_CLIENT); - if(buf) free(buf); + if(buf) aFree(buf); return 0; } @@ -4893,7 +4897,7 @@ int clif_wis_message(int fd, char *nick, char *mes, int mes_len) // R 0097 *------------------------------------------ */ int clif_wis_end(int fd, int flag) // R 0098 .B: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target -{ +{ WFIFOW(fd,0) = 0x98; WFIFOW(fd,2) = flag; WFIFOSET(fd,packet_len_table[0x98]); @@ -5794,7 +5798,7 @@ int clif_hpmeter(struct map_session_data *sd) unsigned char buf[16]; unsigned char buf2[16]; int i; - + nullpo_retr(0, sd); WBUFW(buf,0)=0x107; @@ -5809,7 +5813,7 @@ int clif_hpmeter(struct map_session_data *sd) WFIFOSET(i,packet_len_table[0x107]); } } - + WBUFW(buf2,0)=0x106; WBUFL(buf2,2)=sd->status.account_id; WBUFW(buf2,6)=(sd->status.hp > 0x7fff)? 0x7fff:sd->status.hp; @@ -5821,7 +5825,7 @@ int clif_hpmeter(struct map_session_data *sd) WFIFOSET(i,packet_len_table[0x106]); } } - + return 0; } /*================================================== @@ -5834,7 +5838,7 @@ int clif_update_mobhp(struct mob_data *md) char mobhp[50]; nullpo_retr(0, md); - + WBUFW(buf,0) = 0x95; WBUFL(buf,2) = md->bl.id; @@ -5845,7 +5849,7 @@ int clif_update_mobhp(struct mob_data *md) WBUFL(buf,54) = 0; WBUFL(buf,78) = 0; clif_send(buf,packet_len_table[0x195],&md->bl,AREA); - + return 0; } /*========================================== @@ -6206,7 +6210,7 @@ int clif_combo_delay(struct block_list *bl,int wait) *------------------------------------------ */ int clif_bladestop(struct block_list *src,struct block_list *dst, - int bool) + int _bool) { unsigned char buf[32]; @@ -6216,7 +6220,7 @@ int clif_bladestop(struct block_list *src,struct block_list *dst, WBUFW(buf,0)=0x1d1; WBUFL(buf,2)=src->id; WBUFL(buf,6)=dst->id; - WBUFL(buf,10)=bool; + WBUFL(buf,10)=_bool; clif_send(buf,packet_len_table[0x1d1],src,AREA); @@ -6837,7 +6841,7 @@ int clif_guild_message(struct guild *g,int account_id,const char *mes,int len) struct map_session_data *sd; unsigned char *buf; - buf = (unsigned char*)aCalloc(len + 4, sizeof(unsigned char)); + buf = (unsigned char*)aCallocA(len + 4, sizeof(unsigned char)); WBUFW(buf, 0) = 0x17f; WBUFW(buf, 2) = len + 4; @@ -6846,7 +6850,7 @@ int clif_guild_message(struct guild *g,int account_id,const char *mes,int len) if ((sd = guild_getavailablesd(g)) != NULL) clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD); - if(buf) free(buf); + if(buf) aFree(buf); return 0; } @@ -7043,7 +7047,7 @@ void clif_callpartner(struct map_session_data *sd) * Adopt baby [Celest] *------------------------------------------ */ -void clif_adopt_process(struct map_session_data *sd) +void clif_adopt_process(struct map_session_data *sd) { int fd; nullpo_retv(sd); @@ -7054,7 +7058,7 @@ void clif_adopt_process(struct map_session_data *sd) } /*========================================== - * + * *------------------------------------------ */ void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) { @@ -7067,7 +7071,7 @@ void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) { * 座る *------------------------------------------ */ -void clif_sitting(struct map_session_data *sd) +void clif_sitting(struct map_session_data *sd) { unsigned char buf[64]; @@ -7083,13 +7087,13 @@ void clif_sitting(struct map_session_data *sd) * *------------------------------------------ */ -int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len) +int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len) { unsigned char *buf; nullpo_retr(0, sd); - buf = (unsigned char*)aCalloc(len + 8, sizeof(unsigned char)); + buf = (unsigned char*)aCallocA(len + 8, sizeof(unsigned char)); WBUFW(buf, 0) = 0x17f; WBUFW(buf, 2) = len + 8; @@ -7097,7 +7101,7 @@ int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len) clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); - if(buf) free(buf); + if(buf) aFree(buf); return 0; } @@ -7107,7 +7111,7 @@ int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len) *------------------------------------------ */ -int clif_GM_kickack(struct map_session_data *sd, int id) +int clif_GM_kickack(struct map_session_data *sd, int id) { int fd; @@ -7142,7 +7146,7 @@ int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int ty *------------------------------------------ */ -int clif_timedout(struct map_session_data *sd) +int clif_timedout(struct map_session_data *sd) { nullpo_retr(0, sd); @@ -7247,8 +7251,8 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) { struct map_session_data *pl_sd; int i; for(i = 0; i < fd_max; i++) { - if (session[i] && (pl_sd = session[i]->session_data) != NULL && - pl_sd->state.auth && + if (session[i] && (pl_sd = session[i]->session_data) != NULL && + pl_sd->state.auth && (pc_isGM((struct map_session_data *)&bl) > pc_isGM((struct map_session_data *)&pl_sd->bl))) clif_specialeffect(&pl_sd->bl, type, 1); } @@ -7278,10 +7282,10 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) { * *------------------------------------------ */ -void clif_parse_WantToConnection(int fd, struct map_session_data *sd) +void clif_parse_WantToConnection(int fd, struct map_session_data *sd) { struct map_session_data *old_sd; - int account_id; // account_id in the packet 0x72 or 0x7E + int cmd, account_id; // account_id in the packet 0x72 or 0x7E if (sd) { if (battle_config.error_log) @@ -7289,12 +7293,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) return; } + cmd = RFIFOW(fd,0); + // packet DB - if (RFIFOW(fd,0) == packet_db_connect_cmd) { + if (IS_PACKET_DB_VER(cmd)) { //printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd)); - account_id = RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[0]); + account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[0]); // 0x72 - } else if (RFIFOW(fd,0) == 0x72) { + } else if (cmd == 0x72) { //printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd)); if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) // 00 = Female, 01 = Male account_id = RFIFOL(fd,12); @@ -7303,14 +7309,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) else // old packet version account_id = RFIFOL(fd,2); // 0x7E - } else if (RFIFOW(fd,0) == 0x7E) { + } else if (cmd == 0x7E) { //printf("Received bytes %d with packet 0x7E.\n", RFIFOREST(fd)); if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) // 00 = Female, 01 = Male account_id = RFIFOL(fd,9); else account_id = RFIFOL(fd,12); // 0xF5 - } else if (RFIFOW(fd,0) == 0xF5) { + } else if (cmd == 0xF5) { //printf("Received bytes %d with packet 0xF5.\n", RFIFOREST(fd)); if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) // 00 = Female, 01 = Male account_id = RFIFOL(fd,7); @@ -7319,9 +7325,9 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male account_id = RFIFOL(fd,10); else { // 29 28 28 - if (RFIFOW(fd,1) == 0) // testing ^^; + /*if (RFIFOW(fd,1) == 0) // testing ^^; account_id = RFIFOL(fd,3); - else + else*/ account_id = RFIFOL(fd,5); } // 0x9B @@ -7339,14 +7345,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) sd = session[fd]->session_data = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data)); sd->fd = fd; + if (IS_PACKET_DB_VER(cmd)) { + sd->packet_ver = clif_config.packet_db_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) + pc_setnewpc(sd, account_id, RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[1]), + RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[2]), + RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[3]), + RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[4]), fd); // 0x72 - if (RFIFOW(fd,0) == packet_db_connect_cmd) { - sd->packet_ver = packet_db_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) - pc_setnewpc(sd, account_id, RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[1]), - RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[2]), - RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[3]), - RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[4]), fd); - } else if (RFIFOW(fd,0) == 0x72) { + } else if (cmd == 0x72) { if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) { // 00 = Female, 01 = Male sd->packet_ver = 7; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) pc_setnewpc(sd, account_id, RFIFOL(fd,22), RFIFOL(fd,30), RFIFOL(fd,34), RFIFOB(fd,38), fd); @@ -7358,7 +7364,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) pc_setnewpc(sd, account_id, RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18), fd); } // 0x7E - } else if (RFIFOW(fd,0) == 0x7E) { + } else if (cmd == 0x7E) { if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) { // 00 = Female, 01 = Male sd->packet_ver = 9; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) pc_setnewpc(sd, account_id, RFIFOL(fd,21), RFIFOL(fd,28), RFIFOL(fd,32), RFIFOB(fd,36), fd); @@ -7367,7 +7373,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) pc_setnewpc(sd, account_id, RFIFOL(fd,18), RFIFOL(fd,24), RFIFOL(fd,28), RFIFOB(fd,32), fd); } // 0xF5 - } else if (RFIFOW(fd,0) == 0xF5) { + } else if (cmd == 0xF5) { if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) { // 00 = Female, 01 = Male sd->packet_ver = 10; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) pc_setnewpc(sd, account_id, RFIFOL(fd,15), RFIFOL(fd,25), RFIFOL(fd,29), RFIFOB(fd,33), fd); @@ -7522,7 +7528,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) (sd->sc_data[SC_PROVOKE].timer==-1 || sd->sc_data[SC_PROVOKE].val2==0 )) // オートバーサーク発動 skill_status_change_start(&sd->bl,SC_PROVOKE,10,1,0,0,0,0); - + // if(time(&timer) < ((weddingtime=pc_readglobalreg(sd,"PC_WEDDING_TIME")) + 3600)) // skill_status_change_start(&sd->bl,SC_WEDDING,0,weddingtime,0,0,36000,0); @@ -7568,9 +7574,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) void clif_parse_TickSend(int fd, struct map_session_data *sd) { nullpo_retv(sd); - if (sd->packet_ver == packet_db_ver) { - sd->client_tick=RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - } else { + if (USE_PACKET_DB(sd)) { + sd->client_tick=RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: sd->client_tick = RFIFOL(fd,6); @@ -7597,7 +7603,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { case 16: sd->client_tick = RFIFOL(fd,5); break; - + default: // old version by default (and version 6 + 7) sd->client_tick = RFIFOL(fd,2); break; @@ -7614,7 +7620,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { */ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) { int x, y; - + nullpo_retv(sd); if (pc_isdead(sd)) { @@ -7642,6 +7648,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) { sd->sc_data[SC_BLADESTOP].timer !=-1 || //白刃取り sd->sc_data[SC_SPIDERWEB].timer !=-1 || //スパイダーウェッブ (sd->sc_data[SC_DANCING].timer !=-1 && sd->sc_data[SC_DANCING].val4) || //合奏スキル演奏中は動けない + (sd->sc_data[SC_GOSPEL].timer !=-1 && sd->sc_data[SC_GOSPEL].val4 == BCT_SELF) || // cannot move while gospel is in effect sd->sc_data[SC_CONFUSION].timer !=-1) return; if ((sd->status.option & 2) && pc_checkskill(sd, RG_TUNNELDRIVE) <= 0) @@ -7652,10 +7659,12 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) { pc_stopattack(sd); - if (sd->packet_ver == packet_db_ver) { + if (USE_PACKET_DB(sd)) { int cmd = RFIFOW(fd,0); - x = RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0]) * 4 + (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0] + 1) >> 6); - y = ((RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0]+1) & 0x3f) << 4) + (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0] + 2) >> 4); + x = RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]) * 4 + + (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 1) >> 6); + y = ((RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]+1) & 0x3f) << 4) + + (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 2) >> 4); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 6: @@ -7748,8 +7757,8 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { struct block_list *bl; int account_id; - if (sd->packet_ver == packet_db_ver) { - account_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); + if (USE_PACKET_DB(sd)) { + account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -7785,7 +7794,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { bl = map_id2bl(account_id); if (bl == NULL) return; - + WFIFOW(fd,0) = 0x95; WFIFOL(fd,2) = account_id; @@ -7881,13 +7890,13 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < nullpo_retv(sd); if ((is_atcommand(fd, sd, RFIFOP(fd,4), 0) != AtCommand_None) || (is_charcommand(fd, sd, RFIFOP(fd,4),0)!= CharCommand_None) || - (sd->sc_data && + (sd->sc_data && (sd->sc_data[SC_BERSERK].timer != -1 || //バーサーク時は会話も不可 sd->sc_data[SC_NOCHAT].timer != -1 ))) //チャット禁止 return; - message = (char*)aCalloc(RFIFOW(fd,2) + 128, sizeof(char)); - buf = (char*)aCalloc(RFIFOW(fd,2) + 4, sizeof(char)); + message = (char*)aCallocA(RFIFOW(fd,2) + 128, sizeof(char)); + buf = (char*)aCallocA(RFIFOW(fd,2) + 4, sizeof(char)); //printf("clif_parse_GlobalMessage: message: '%s'.\n", RFIFOP(fd,4)); if (strncmp(RFIFOP(fd,4), sd->status.name, strlen(sd->status.name)) != 0) { @@ -7912,9 +7921,9 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < if (battle_config.ban_spoof_namer > 0) { chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_spoof_namer, 0); // type: 2 - ban (year, month, day, hour, minute, second) clif_setwaitclose(fd); // forced to disconnect because of the hack - - if(message) free(message); - if(buf) free(buf); + + if(message) aFree(message); + if(buf) aFree(buf); return; } @@ -7958,8 +7967,8 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < } } - if(message) free(message); - if(buf) free(buf); + if(message) aFree(message); + if(buf) aFree(buf); return; } @@ -8038,9 +8047,9 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd) { nullpo_retv(sd); - if (sd->packet_ver == packet_db_ver) { - headdir = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - dir = RFIFOB(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + headdir = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + dir = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 7: @@ -8152,9 +8161,9 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { pc_stop_walking(sd, 0); pc_stopattack(sd); - if (sd->packet_ver == packet_db_ver) { - target_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - action_type = RFIFOB(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + action_type = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -8283,20 +8292,20 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 .w status.name, RFIFOP(fd,28)); if ((is_charcommand(fd, sd, gm_command, 0) != CharCommand_None) || (is_atcommand(fd, sd, gm_command, 0) != AtCommand_None) || - (sd && sd->sc_data && + (sd && sd->sc_data && (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可 sd->sc_data[SC_NOCHAT].timer != -1))) //チャット禁止 { - if(gm_command) free(gm_command); + if(gm_command) aFree(gm_command); return; } - if(gm_command) free(gm_command); + if(gm_command) aFree(gm_command); // searching destination character dstsd = map_nick2sd(RFIFOP(fd,4)); @@ -8360,8 +8369,8 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd) { nullpo_retv(sd); - if (sd->packet_ver == packet_db_ver) { - map_object_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); + if (USE_PACKET_DB(sd)) { + map_object_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 7: @@ -8436,9 +8445,9 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd) { sd->sc_data[SC_BERSERK].timer != -1)) ) //バーサーク return; - if (sd->packet_ver == packet_db_ver) { - item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2; - item_amount = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2; + item_amount = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -8505,8 +8514,8 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd) { if (sd->invincible_timer != -1) pc_delinvincibletimer(sd); - if (sd->packet_ver == packet_db_ver) { - pc_useitem(sd,RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2); + if (USE_PACKET_DB(sd)) { + pc_useitem(sd,RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 6: @@ -8888,10 +8897,10 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) { if (sd->chatID || sd->npc_id != 0 || sd->vender_id != 0) return; - if (sd->packet_ver == packet_db_ver) { - skilllv = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - skillnum = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); - target_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[2]); + if (USE_PACKET_DB(sd)) { + skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); + target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 6: @@ -8972,7 +8981,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) { return; } - if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) || + if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) || sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 || sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22) return; @@ -9021,11 +9030,11 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) { if(sd->chatID) return; skillmoreinfo = -1; - if (sd->packet_ver == packet_db_ver) { - skilllv = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); - skillnum = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); - x = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[2]); - y = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[3]); + if (USE_PACKET_DB(sd)) { + skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); + skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); + x = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]); + y = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[3]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 6: @@ -9146,7 +9155,7 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) { return; } - if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) || + if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) || sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 || sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22) return; @@ -9176,7 +9185,7 @@ void clif_parse_UseSkillMap(int fd,struct map_session_data *sd) if(sd->chatID) return; - if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->sc_data && + if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->sc_data && (sd->sc_data[SC_TRICKDEAD].timer != -1 || sd->sc_data[SC_BERSERK].timer!=-1 || sd->sc_data[SC_NOCHAT].timer!=-1 || @@ -9324,8 +9333,8 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd) void clif_parse_SolveCharName(int fd, struct map_session_data *sd) { int char_id; - if (sd->packet_ver == packet_db_ver) { - char_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]); + if (USE_PACKET_DB(sd)) { + char_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -9412,9 +9421,9 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) { if (sd->npc_id != 0 || sd->vender_id != 0) return; - if (sd->packet_ver == packet_db_ver) { - item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2; - item_amount = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2; + item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -9478,9 +9487,9 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) { nullpo_retv(sd); - if (sd->packet_ver == packet_db_ver) { - item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-1; - item_amount = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]); + if (USE_PACKET_DB(sd)) { + item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-1; + item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]); } else { switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) case 8: @@ -9649,7 +9658,7 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) { void clif_parse_PartyMessage(int fd, struct map_session_data *sd) { nullpo_retv(sd); if (is_charcommand(fd, sd, RFIFOP(fd,4), 0) != CharCommand_None) - return; + return; if (is_atcommand(fd, sd, RFIFOP(fd,4), 0) != AtCommand_None) return; if(sd->sc_data && @@ -10093,7 +10102,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by WFIFOW(fd,0) = 0x0d1; // R 00d1 .B .B: type: 0: deny, 1: allow, fail: 0: success, 1: fail WFIFOB(fd,2) = RFIFOB(fd,26); // do nothing only if nick can not exist - if (strlen(nick) < 4) { + if (strlen(nick) < 4) { WFIFOB(fd,3) = 1; // fail WFIFOSET(fd, packet_len_table[0x0d1]); if (RFIFOB(fd,26) == 0) // type @@ -10239,7 +10248,7 @@ void clif_parse_sn_doridori(int fd, struct map_session_data *sd) { * スパノビの爆裂波動 *------------------------------------------ */ -void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd) +void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd) { if(sd){ int nextbaseexp=pc_nextbaseexp(sd); @@ -10369,9 +10378,6 @@ void clif_parse_debug(int fd,struct map_session_data *sd) { int i, cmd; - if (packet_db_ver < 0) - return; - cmd = RFIFOW(fd,0); printf("packet debug 0x%4X\n",cmd); @@ -10562,11 +10568,12 @@ static int clif_parse(int fd) { packet_ver = sd->packet_ver; // check authentification packet to know packet version else { - // packet DB - if (cmd == packet_db_connect_cmd) { - if (RFIFOREST(fd) >= packet_db[packet_db_ver][cmd].len && - (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[4]) == 0 || RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[4]) == 1)) {// 00 = Female, 01 = Male - packet_ver = packet_db_ver; + // packet DB + if (IS_PACKET_DB_VER (cmd)) { + if (RFIFOREST(fd) >= packet_db[clif_config.packet_db_ver][cmd].len && + (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 0 || + RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 1)) {// 00 = Female, 01 = Male + packet_ver = clif_config.packet_db_ver; } // 0x72 } else if (cmd == 0x72) { @@ -10597,9 +10604,9 @@ static int clif_parse(int fd) { else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male packet_ver = 11; // 11: 21sept04 else if (RFIFOREST(fd) >= 29 && (RFIFOB(fd,28) == 0 || RFIFOB(fd,28) == 1)) { // 00 = Female, 01 = Male - if (RFIFOW(fd,1) == 0) // testing ^^; + /*if (RFIFOW(fd,1) == 0) // testing ^^; packet_ver = 15; - else + else*/ packet_ver = 13; // 13: 25oct04 (by [Yor]) } // -- some way to identify version 14 and 15? -- @@ -10625,7 +10632,9 @@ static int clif_parse(int fd) { (packet_ver == 14 && (battle_config.packet_ver_flag & 16) == 0) || (packet_ver == 15 && (battle_config.packet_ver_flag & 32) == 0) || (packet_ver == 16 && (battle_config.packet_ver_flag & 64) == 0) || - packet_ver > MAX_PACKET_VER) { // no support yet + packet_ver > MAX_PACKET_VER || // no packet version support yet + // identified version, but unknown client? + (!sd && packet_db[packet_ver][cmd].func != clif_parse_WantToConnection)) { WFIFOW(fd,0) = 0x6a; WFIFOB(fd,2) = 5; // 05 = Game's EXE is not the latest version WFIFOSET(fd,23); @@ -10731,8 +10740,8 @@ static int packetdb_readdb(void) FILE *fp; char line[1024]; int ln=0; - int cmd,j,packet_ver = 0; - char *str[32],*p,*str2[32],*p2; + int cmd,j,k,packet_ver; + char *str[32],*p,*str2[32],*p2,w1[24],w2[24]; struct { void (*func)(); @@ -10861,18 +10870,51 @@ static int packetdb_readdb(void) return 1; } - packet_db_ver = MAX_PACKET_VER; - + clif_config.packet_db_ver = MAX_PACKET_VER; + packet_ver = MAX_PACKET_VER; // read into packet_db's version by default + while(fgets(line,1020,fp)){ if(line[0]=='/' && line[1]=='/') continue; - if (sscanf(line,"packet_ver: %d",&packet_ver) == 1) { - memcpy(&packet_db[packet_ver], &packet_db[packet_ver - 1], sizeof(packet_db[0])); // copy into new version and continue - // i hope this isn't the wrong way to do things ^^; - continue; + if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) { + if(strcmpi(w1,"packet_ver")==0) { + packet_ver = atoi(w2); + // copy from previous version into new version and continue + // - indicating all following packets should be read into the newer version + // -- on 2nd thought, rereading everything isn't the best thing to do... + // memcpy(&packet_db[packet_ver], &packet_db[packet_ver - 1], sizeof(packet_db[0])); + continue; + } else if(strcmpi(w1,"packet_db_ver")==0) { + // optional: if you do not wish to read multiple versions from the packet_db, + // remove all "packet_ver: ##" lines, and define the packet DB version with this + if(strcmpi(w2,"default")==0) + clif_config.packet_db_ver = MAX_PACKET_VER; + else { + // to manually set the packet DB version + clif_config.packet_db_ver = atoi(w2); + // check for invalid version + if (clif_config.packet_db_ver > MAX_PACKET_VER || + clif_config.packet_db_ver < 0) + clif_config.packet_db_ver = MAX_PACKET_VER; + } + continue; + } else if(strcmpi(w1,"enable_packet_db")==0) { + // whether we want to allow identifying clients via the packet DB + clif_config.enable_packet_db = battle_config_switch(w2); + // if we don't want to read the packet DB, and use hardcoded values only + if (!clif_config.enable_packet_db) + return 0; + continue; + } else if(strcmpi(w1,"prefer_packet_db")==0) { + // whether the packet DB takes higher precedence over the hardcoded one (type 1) + // and whether to overwrite predefined packet length and functions when reading + // from the DB (type 2) + clif_config.prefer_packet_db = battle_config_switch(w2); // not used for now + continue; + } } - memset(str,0,sizeof(str)); + memset(str,0,sizeof(str)); for(j=0,p=line;j<4 && p;j++){ str[j]=p; p=strchr(p,','); @@ -10888,7 +10930,9 @@ static int packetdb_readdb(void) ShowError(tmp_output); continue; } - packet_db[packet_ver][cmd].len = atoi(str[1]); + k = atoi(str[1]); + // if (packet_db[packet_ver][cmd].len != k && clif_config.prefer_packet_db) // not used for now + packet_db[packet_ver][cmd].len = k; if(str[2]==NULL){ ln++; @@ -10897,13 +10941,15 @@ static int packetdb_readdb(void) for(j=0;j 2 /* && packet_db[cmd].pos[0] == 0 */) +// if(packet_db[clif_config.packet_db_ver][cmd].len > 2 /* && packet_db[cmd].pos[0] == 0 */) // printf("packet_db ver %d: %d 0x%x %d %s %p\n",packet_ver,ln,cmd,packet_db[packet_ver][cmd].len,str[2],packet_db[packet_ver][cmd].func); } - + fclose(fp); - sprintf(tmp_output,"Done reading packet version '"CL_WHITE"%d"CL_RESET"' in '"CL_WHITE"%s"CL_RESET"'.\n", packet_db_ver, "db/packet_db.txt"); + sprintf(tmp_output,"Done reading packet version '"CL_WHITE"%d"CL_RESET"' in '"CL_WHITE"%s"CL_RESET"'.\n", clif_config.packet_db_ver, "db/packet_db.txt"); ShowStatus(tmp_output); return 0; @@ -10936,6 +10984,11 @@ static int packetdb_readdb(void) int do_init_clif(void) { int i; + clif_config.enable_packet_db = 1; // whether to use the packet DB for client connection + clif_config.packet_db_ver = -1; // the main packet version of the DB + clif_config.prefer_packet_db = 1; // whether the packet version takes precedence + clif_config.connect_cmd = 0xF5; // the default packet used for connecting to the server + memset(packet_db,0,sizeof(packet_db)); // size of packet version 5 (old) @@ -11163,6 +11216,7 @@ int do_init_clif(void) { packet_db[14][0x21a].len = 282; packet_db[14][0x21b].len = 10; packet_db[14][0x21c].len = 10; +// packet_db[14][0x143].len = 23; // is this required? uncomment if it is // Init packet function calls for packet ver 15 memcpy(packet_db[15], packet_db[14], sizeof(packet_db[0])); packet_db[15][0x072].func = clif_parse_UseSkillToId; @@ -11200,7 +11254,7 @@ int do_init_clif(void) { packet_db[15][0x116].len = 12; packet_db[15][0x190].len = 15; packet_db[15][0x193].len = 21; - packet_db[15][0x21b].len = 6; + packet_db[15][0x21d].len = 6; packet_db[15][0x222].len = 6; packet_db[15][0x221].len = -1; packet_db[15][0x223].len = 8; @@ -11241,12 +11295,14 @@ int do_init_clif(void) { packet_db[16][0x116].len = 20; packet_db[16][0x09f].len = 17; packet_db[16][0x0f7].len = 21; - // Init packet function calls for packet ver 17 (packet db) - memcpy(packet_db[17], packet_db[16], sizeof(packet_db[0])); + packet_db[16][0x143].len = 10; + // Init packet function calls for the packet_db.txt (17) + memcpy(packet_db[MAX_PACKET_VER], packet_db[MAX_PACKET_VER - 1], sizeof(packet_db[0])); #endif - packetdb_readdb(); - + if (clif_config.enable_packet_db) + packetdb_readdb(); + set_defaultparse(clif_parse); #ifdef __WIN32 if (!make_listen_port(map_port)) { diff --git a/src/map/clif.h b/src/map/clif.h index d0cd2e86e..99e0752d1 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -16,7 +16,6 @@ typedef unsigned int in_addr_t; #define MAX_PACKET_DB 0x224 #define MAX_PACKET_VER 17 -extern int packet_db_ver; struct packet_db { short len; void (*func)(); @@ -24,6 +23,13 @@ struct packet_db { }; extern struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB]; +extern struct Clif_Config { + int enable_packet_db; + int packet_db_ver; + int prefer_packet_db; + int connect_cmd; +} clif_config; + void clif_setip(char*); void clif_setport(int); @@ -137,8 +143,8 @@ int clif_petinsight(struct block_list *bl,va_list ap); int clif_npcoutsight(struct block_list *bl,va_list ap); int clif_npcinsight(struct block_list *bl,va_list ap); -int clif_class_change(struct block_list *bl,int class,int type); -int clif_mob_class_change(struct mob_data *md,int class); +int clif_class_change(struct block_list *bl,int class_,int type); +int clif_mob_class_change(struct mob_data *md,int class_); int clif_mob_equip(struct mob_data *md,int nameid); // [Valaris] int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range); @@ -177,7 +183,7 @@ int clif_autospell(struct map_session_data *sd,int skilllv); int clif_devotion(struct map_session_data *sd,int target); int clif_spiritball(struct map_session_data *sd); int clif_combo_delay(struct block_list *src,int wait); -int clif_bladestop(struct block_list *src,struct block_list *dst,int bool); +int clif_bladestop(struct block_list *src,struct block_list *dst,int bool_); int clif_changemapcell(int m,int x,int y,int cell_type,int type); int clif_status_change(struct block_list *bl,int type,int flag); diff --git a/src/map/guild.c b/src/map/guild.c index 5f9e31794..8099ac934 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -284,7 +284,7 @@ int guild_payexp_timer_sub(void *key,void *data,va_list ap) c->exp=0; dellist[(*delp)++]=dataid; - free(c); + aFree(c); return 0; } int guild_payexp_timer(int tid,unsigned int tick,int id,int data) @@ -476,7 +476,7 @@ int guild_recv_info(struct guild *sg) // イベントの発生 if( (ev=numdb_search(guild_infoevent_db,sg->guild_id))!=NULL ){ numdb_erase(guild_infoevent_db,sg->guild_id); - for(;ev;ev2=ev->next,free(ev),ev=ev2){ + for(;ev;ev2=ev->next,aFree(ev),ev=ev2){ npc_event_do(ev->name); } } @@ -750,7 +750,7 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online) return 0; } // ギルドメンバのオンライン状態/Lv更新通知 -int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class) +int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_) { int i,alv,c,idx=0,om=0,oldonline=-1; struct guild *g=guild_search(guild_id); @@ -762,7 +762,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin oldonline=m->online; m->online=online; m->lv=lv; - m->class_=class; + m->class_=class_; idx=i; } if(m->account_id>0){ @@ -938,7 +938,7 @@ int guild_payexp(struct map_session_data *sd,int exp) return 0; if( (c=numdb_search(guild_expcache_db,sd->status.char_id))==NULL ){ - c=(struct guild_expcache *)aCalloc(1,sizeof(struct guild_expcache)); + c=(struct guild_expcache *)aCallocA(1,sizeof(struct guild_expcache)); c->guild_id=sd->status.guild_id; c->account_id=sd->status.account_id; c->char_id=sd->status.char_id; @@ -960,9 +960,9 @@ int guild_getexp(struct map_session_data *sd,int exp) if(sd->status.guild_id==0 || (g=guild_search(sd->status.guild_id))==NULL ) return 0; - + if( (c=numdb_search(guild_expcache_db,sd->status.char_id))==NULL ){ - c=(struct guild_expcache *)aCalloc(1,sizeof(struct guild_expcache)); + c=(struct guild_expcache *)aCallocA(1,sizeof(struct guild_expcache)); c->guild_id=sd->status.guild_id; c->account_id=sd->status.account_id; c->char_id=sd->status.char_id; @@ -1191,7 +1191,7 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id const char *guild_name[2]; struct map_session_data *sd[2]; int j,i; - + guild_id[0] = guild_id1; guild_id[1] = guild_id2; guild_name[0] = name1; @@ -1300,7 +1300,7 @@ int guild_broken(int guild_id,int flag) numdb_foreach(guild_db,guild_broken_sub,guild_id); numdb_erase(guild_db,guild_id); guild_storage_delete(guild_id); - free(g); + aFree(g); return 0; } @@ -1396,7 +1396,7 @@ int guild_castledataloadack(int castle_id,int index,int value) } if( (ev=numdb_search(guild_castleinfoevent_db,code))!=NULL ){ numdb_erase(guild_castleinfoevent_db,code); - for(;ev;ev2=ev->next,free(ev),ev=ev2){ + for(;ev;ev2=ev->next,aFree(ev),ev=ev2){ npc_event_do(ev->name); } } @@ -1500,7 +1500,7 @@ int guild_agit_end(void) int guild_gvg_eliminate_timer(int tid,unsigned int tick,int id,int data) { // Run One NPC_Event[OnAgitEliminate] size_t len = strlen((const char*)data); - char *evname=(char*)aCalloc(len + 4,sizeof(char)); + char *evname=(char*)aCallocA(len + 4,sizeof(char)); int c=0; if(!agit_flag) return 0; // Agit already End @@ -1517,7 +1517,7 @@ int guild_agit_break(struct mob_data *md) nullpo_retr(0, md); - evname=(char *)aCalloc(strlen(md->npc_event) + 1, sizeof(char)); + evname=(char *)aCallocA(strlen(md->npc_event) + 1, sizeof(char)); strcpy(evname,md->npc_event); // Now By User to Run [OnAgitBreak] NPC Event... @@ -1539,7 +1539,7 @@ int guild_checkcastles(struct guild *g) { for(i=0;iguild_id; - if(g->guild_id==cas_id) + if(g->guild_id==cas_id) nb_cas=nb_cas+1; } //end for return nb_cas; @@ -1570,12 +1570,12 @@ int guild_isallied(struct guild *g, struct guild_castle *gc) return 0; } - + static int guild_db_final(void *key,void *data,va_list ap) { struct guild *g=data; - free(g); + aFree(g); return 0; } @@ -1583,7 +1583,7 @@ static int castle_db_final(void *key,void *data,va_list ap) { struct guild_castle *gc=data; - free(gc); + aFree(gc); return 0; } @@ -1591,7 +1591,7 @@ static int guild_expcache_db_final(void *key,void *data,va_list ap) { struct guild_expcache *c=data; - free(c); + aFree(c); return 0; } @@ -1599,7 +1599,7 @@ static int guild_infoevent_db_final(void *key,void *data,va_list ap) { struct eventlist *ev=data; - free(ev); + aFree(ev); return 0; } diff --git a/src/map/guild.h b/src/map/guild.h index eefdcb04e..8f5243a8c 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -56,7 +56,7 @@ int guild_delalliance(struct map_session_data *sd,int guild_id,int flag); int guild_opposition(struct map_session_data *sd,int char_id); int guild_send_memberinfoshort(struct map_session_data *sd,int online); -int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class); +int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_); int guild_change_memberposition(int guild_id,int account_id,int char_id,int idx); int guild_memberposition_changed(struct guild *g,int idx,int pos); int guild_change_position(struct map_session_data *sd,int idx, diff --git a/src/map/intif.c b/src/map/intif.c index 9ba9b1ebb..3f1bbfe88 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -457,7 +457,7 @@ int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const cha } // ギルドメンバのオンライン状況/Lv更新要求 int intif_guild_memberinfoshort(int guild_id, - int account_id,int char_id,int online,int lv,int class) + int account_id,int char_id,int online,int lv,int class_) { if (CheckForCharServer()) return 0; @@ -467,7 +467,7 @@ int intif_guild_memberinfoshort(int guild_id, WFIFOL(inter_fd,10) = char_id; WFIFOB(inter_fd,14) = online; WFIFOW(inter_fd,15) = lv; - WFIFOW(inter_fd,17) = class; + WFIFOW(inter_fd,17) = class_; WFIFOSET(inter_fd,19); return 0; } @@ -640,7 +640,7 @@ int intif_parse_WisMessage(int fd) { // rewritten by [Yor] // if(battle_config.etc_log) // printf("intif_parse_wismessage: %d %s %s %s\n",id,RFIFOP(fd,6),RFIFOP(fd,30),RFIFOP(fd,54) ); - + sd=map_nick2sd(RFIFOP(fd,32)); // 送信先を探す if(sd!=NULL && strcmp(sd->status.name, RFIFOP(fd,32)) == 0){ /* @@ -698,7 +698,7 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 .w .24B struct map_session_data *pl_sd; char Wisp_name[24]; char mbuf[255]; - char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) aMalloc((RFIFOW(fd,2) - 30)) : mbuf; + char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) aMallocA((RFIFOW(fd,2) - 30)) : mbuf; min_gm_level = (int)RFIFOW(fd,28); memcpy(Wisp_name, RFIFOP(fd,4), 24); @@ -712,7 +712,7 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 .w .24B clif_wis_message(i, Wisp_name, message, strlen(message) + 1); if (message != mbuf) - free(message); + aFree(message); return 0; } diff --git a/src/map/intif.h b/src/map/intif.h index 5077dbe18..761c1ea63 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -33,7 +33,7 @@ int intif_guild_create(const char *name, const struct guild_member *master); int intif_guild_request_info(int guild_id); int intif_guild_addmember(int guild_id, struct guild_member *m); int intif_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes); -int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class); +int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class_); int intif_guild_break(int guild_id); int intif_guild_message(int guild_id, int account_id, char *mes, int len); int intif_guild_checkconflict(int guild_id, int account_id, int char_id); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index e6a997976..dd8de15d4 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -530,7 +530,7 @@ static int itemdb_read_itemnametable(void) if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\idnum2itemdisplaynametable.txt"); ShowStatus(tmp_output); @@ -566,7 +566,7 @@ static int itemdb_read_cardillustnametable(void) if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\num2cardillustnametable.txt"); ShowStatus(tmp_output); @@ -604,7 +604,7 @@ static int itemdb_read_itemslottable(void) if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\itemslottable.txt"); ShowStatus(tmp_output); @@ -636,7 +636,7 @@ static int itemdb_read_itemslotcounttable(void) if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\itemslotcounttable.txt"); ShowStatus(tmp_output); @@ -896,10 +896,10 @@ static int itemdb_final(void *key,void *data,va_list ap) nullpo_retr(0, id=data); if(id->use_script) - free(id->use_script); + aFree(id->use_script); if(id->equip_script) - free(id->equip_script); - free(id); + aFree(id->equip_script); + aFree(id); return 0; } diff --git a/src/map/mail.c b/src/map/mail.c index 5d63b6f80..74d2bf7c0 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -30,12 +30,12 @@ extern char msg_table[1000][256]; // Server messages (0-499 reserved for GM comm int mail_check(struct map_session_data *sd,int type) { - int i=0,new=0,priority=0; + int i=0,new_=0,priority=0; char message[50]; if(sd==NULL) return 0; - + sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`from_char_name`,`read_flag`,`priority`,`check_flag` FROM `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id`", mail_db, sd->status.account_id); if (mysql_query(&mail_handle, tmp_msql)) { @@ -64,7 +64,7 @@ int mail_check(struct map_session_data *sd,int type) } if(!atoi(mail_row[3])) { - new++; + new_++; if(atoi(mail_row[4])) priority++; if(type==2 || type==3) { @@ -88,28 +88,28 @@ int mail_check(struct map_session_data *sd,int type) sprintf(message, msg_table[513], i, mail_row[2]); clif_displaymessage(sd->fd, jstrescape(message)); } - + } - + mysql_free_result(mail_res); - + } else { printf("MySQL error (storing query result for %s): %s\n", mail_db, mysql_error(&mail_handle)); return 0; } - if(i>0 && new>0 && type==1) { - //sprintf(message, "You have %d new messages.", new); - sprintf(message, msg_table[514], new); + if(i>0 && new_>0 && type==1) { + //sprintf(message, "You have %d new messages.", new_); + sprintf(message, msg_table[514], new_); clif_displaymessage(sd->fd, jstrescape(message)); } - if(i>0 && new>0 && priority>0 && type==1) { + if(i>0 && new_>0 && priority>0 && type==1) { //sprintf(message, "You have %d unread priority messages.", priority); sprintf(message, msg_table[515], priority); clif_displaymessage(sd->fd, jstrescape(message)); } - if(!new) { + if(!new_) { //clif_displaymessage(sd->fd, "You have no new messages."); clif_displaymessage(sd->fd, msg_table[516]); } @@ -124,7 +124,7 @@ int mail_read(struct map_session_data *sd, int message_id) if(sd==NULL) return 0; - + sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`from_char_name`,`message`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id` LIMIT %d, 1",mail_db,sd->status.account_id,message_id-1); if (mysql_query(&mail_handle, tmp_msql)) { @@ -162,9 +162,9 @@ int mail_read(struct map_session_data *sd, int message_id) printf("DB server Error (update Read `%s`)- %s\n", mail_db, mysql_error(&mail_handle) ); } } - + mysql_free_result(mail_res); - + } else { printf("MySQL error (storing query result for %s): %s\n", mail_db, mysql_error(&mail_handle)); return 0; @@ -177,7 +177,7 @@ int mail_delete(struct map_session_data *sd, int message_id) { if(sd==NULL) return 0; - + sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id` LIMIT %d, 1",mail_db,sd->status.account_id,message_id-1); if (mysql_query(&mail_handle, tmp_msql)) { @@ -217,9 +217,9 @@ int mail_delete(struct map_session_data *sd, int message_id) //else clif_displaymessage(sd->fd,"Message deleted."); else clif_displaymessage(sd->fd,msg_table[521]); } - + mysql_free_result(mail_res); - + } else { printf("MySQL error (delete query result for %s): %s\n", mail_db, mysql_error(&mail_handle)); return 0; @@ -232,7 +232,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) { if(sd==NULL) return 0; - + if(pc_isGM(sd) < 80 && sd->mail_counter > 0) { //clif_displaymessage(sd->fd,"You must wait 10 minutes before sending another message"); clif_displaymessage(sd->fd,msg_table[522]); @@ -254,8 +254,8 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) if (mysql_query(&mail_handle, tmp_msql)) { printf("Database server error (executing query for %s): %s\n", char_db, mysql_error(&mail_handle)); return 0; - } - + } + mail_res = mysql_store_result(&mail_handle); if(mail_res) { if (mysql_num_rows(mail_res) == 0) { @@ -268,7 +268,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) while ((mail_row = mysql_fetch_row(mail_res))) { if(strcmp(name,"*")==0) { sprintf(tmp_msql, "INSERT DELAYED INTO `%s` (`to_account_id`,`from_account_id`,`from_char_name`,`message`,`priority`)" - " VALUES ('%d', '%d', '%s', '%s', '%d')",mail_db, atoi(mail_row[0]), sd->status.account_id, sd->status.name, jstrescape(message), flag); + " VALUES ('%d', '%d', '%s', '%s', '%d')",mail_db, atoi(mail_row[0]), sd->status.account_id, sd->status.name, jstrescape(message), flag); } else { sprintf(tmp_msql, "INSERT DELAYED INTO `%s` (`to_account_id`,`to_char_name`,`from_account_id`,`from_char_name`,`message`,`priority`)" @@ -276,7 +276,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) if(pc_isGM(sd) < 80) sd->mail_counter=5; } - + if(mysql_query(&mail_handle, tmp_msql) ) { mysql_free_result(mail_res); printf("DB server Error (insert `mail_db`)- %s\n", mysql_error(&mail_handle) ); @@ -295,18 +295,18 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag) int mail_check_timer(int tid,unsigned int tick,int id,int data) { struct map_session_data *sd = NULL; - int i; + int i; if(mail_timer != tid) return 0; sprintf(tmp_msql,"SELECT DISTINCT `to_account_id` FROM `%s` WHERE `read_flag` = '0' AND `check_flag` = '0'", mail_db); - + if (mysql_query(&mail_handle, tmp_msql)) { printf("Database server error (executing query for %s): %s\n", char_db, mysql_error(&mail_handle)); mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0); return 0; - } + } mail_res = mysql_store_result(&mail_handle); @@ -324,8 +324,8 @@ int mail_check_timer(int tid,unsigned int tick,int id,int data) if(pc_isGM(sd) < 80 && sd->mail_counter > 0) sd->mail_counter--; if(sd->status.account_id==atoi(mail_row[0])) - //clif_displaymessage(sd->fd, "You have new mail."); - clif_displaymessage(sd->fd, msg_table[526]); + //clif_displaymessage(sd->fd, "You have new mail."); + clif_displaymessage(sd->fd, msg_table[526]); } } } @@ -341,7 +341,7 @@ int mail_check_timer(int tid,unsigned int tick,int id,int data) } int do_init_mail(void) -{ +{ add_timer_func_list(mail_check_timer,"mail_check_timer"); mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0); return 0; diff --git a/src/map/map.c b/src/map/map.c index a591c97a2..55d571767 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -193,7 +193,7 @@ int map_getusers(void) { int map_freeblock( void *bl ) { if(block_free_lock==0){ - free(bl); + aFree(bl); bl = NULL; } else{ @@ -229,7 +229,7 @@ int map_freeblock_unlock(void) { // printf("map_freeblock_unlock: free %d object\n",block_free_count); // } for(i=0;ibl.id = map_addobject(&fitem->bl); if(fitem->bl.id==0){ - free(fitem); + aFree(fitem); return 0; } @@ -894,9 +894,9 @@ void map_addchariddb(int charid, char *name) { struct charid2nick *p=NULL; int req=0; - p=numdb_search(charid_db,charid); + p = (struct charid2nick*)numdb_search(charid_db,charid); if(p==NULL){ // デ?タベ?スにない - p = (struct charid2nick *)aCalloc(1,sizeof(struct charid2nick)); + p = (struct charid2nick *)aCallocA(1,sizeof(struct charid2nick)); p->req_id=0; }else numdb_erase(charid_db,charid); @@ -921,7 +921,7 @@ int map_reqchariddb(struct map_session_data * sd,int charid) { nullpo_retr(0, sd); - p=numdb_search(charid_db,charid); + p = (struct charid2nick*)numdb_search(charid_db,charid); if(p!=NULL) // デ?タベ?スにすでにある return 0; p = (struct charid2nick *)aCalloc(1,sizeof(struct charid2nick)); @@ -1005,7 +1005,7 @@ int map_quit(struct map_session_data *sd) { // check if we've been authenticated [celest] if (sd->state.auth) skill_castcancel(&sd->bl,0); // 詠唱を中?する - + skill_stop_dancing(&sd->bl,1);// ダンス/演奏中? if(sd->sc_data && sd->sc_data[SC_BERSERK].timer!=-1) //バ?サ?ク中の終了はHPを100に @@ -1052,7 +1052,7 @@ int map_quit(struct map_session_data *sd) { storage_storage_save(sd); if( sd->npc_stackbuf && sd->npc_stackbuf != NULL) { - free( sd->npc_stackbuf ); + aFree( sd->npc_stackbuf ); sd->npc_stackbuf = NULL; } @@ -1092,7 +1092,7 @@ struct map_session_data * map_id2sd(int id) { struct map_session_data *sd=NULL; for(i = 0; i < fd_max; i++) - if (session[i] && (sd = session[i]->session_data) && sd->bl.id == id) + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd->bl.id == id) return sd; return NULL; @@ -1103,7 +1103,7 @@ struct map_session_data * map_id2sd(int id) { *------------------------------------------ */ char * map_charid2nick(int id) { - struct charid2nick *p=numdb_search(charid_db,id); + struct charid2nick *p = (struct charid2nick*)numdb_search(charid_db,id); if(p==NULL) return NULL; @@ -1130,7 +1130,7 @@ struct map_session_data * map_nick2sd(char *nick) { nicklen = strlen(nick); for (i = 0; i < fd_max; i++) { - if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) + if (session[i] && (pl_sd = (struct map_session_data*)session[i]->session_data) && pl_sd->state.auth) // Without case sensitive check (increase the number of similar character names found) if (strnicmp(pl_sd->status.name, nick, nicklen) == 0) { // Strict comparison (if found, we finish the function immediatly with correct value) @@ -1160,7 +1160,7 @@ struct block_list * map_id2bl(int id) if(idbl); numdb_erase(id_db,map[m].npc[i]->bl.id); if(map[m].npc[i]->bl.subtype==SCRIPT) { -// free(map[m].npc[i]->u.scr.script); -// free(map[m].npc[i]->u.scr.label_list); +// aFree(map[m].npc[i]->u.scr.script); +// aFree(map[m].npc[i]->u.scr.label_list); } - free(map[m].npc[i]); + aFree(map[m].npc[i]); map[m].npc[i] = NULL; n++; } @@ -1238,7 +1238,7 @@ void map_removenpc(void) { int map_mapname2mapid(char *name) { struct map_data *md=NULL; - md=strdb_search(map_db,name); + md = (struct map_data*)strdb_search(map_db,name); #ifdef USE_AFM // If we can't find the .gat map try .afm instead [celest] @@ -1246,7 +1246,7 @@ int map_mapname2mapid(char *name) { char afm_name[16] = ""; strncpy(afm_name, name, strlen(name) - 4); strcat(afm_name, ".afm"); - md = strdb_search(map_db,afm_name); + md = (struct map_data*)strdb_search(map_db,afm_name); } #endif @@ -1262,7 +1262,7 @@ int map_mapname2mapid(char *name) { int map_mapname2ipport(char *name,int *ip,int *port) { struct map_data_other_server *mdos=NULL; - mdos=strdb_search(map_db,name); + mdos = (struct map_data_other_server*)strdb_search(map_db,name); if(mdos==NULL || mdos->gat) return -1; *ip=mdos->ip; @@ -1385,7 +1385,7 @@ int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk) case CELL_CHKTYPE: return m->gat[j]; default: return 0; - } + } return 0; } @@ -1396,7 +1396,7 @@ int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk) int map_setcell(int m,int x,int y,CELL_SET cellset) { int i,j; - + if(x<0 || x>=map[m].xs || y<0 || y>=map[m].ys) return 0; j=x+y*map[m].xs; @@ -1431,7 +1431,7 @@ int map_setipport(char *name,unsigned long ip,int port) { struct map_data *md=NULL; struct map_data_other_server *mdos=NULL; - md=strdb_search(map_db,name); + md = (struct map_data*)strdb_search(map_db,name); if(md==NULL){ // not exist -> add new data mdos=(struct map_data_other_server *)aCalloc(1,sizeof(struct map_data_other_server)); memcpy(mdos->name,name,24); @@ -1459,7 +1459,7 @@ int map_setipport(char *name,unsigned long ip,int port) { * 水場高さ設定 *------------------------------------------ */ -static struct { +static struct waterlist_ { char mapname[24]; int waterheight; } *waterlist=NULL; @@ -1487,7 +1487,7 @@ static void map_readwater(char *watertxt) { return; } if(waterlist==NULL) - waterlist=aCalloc(MAX_MAP_PER_SERVER,sizeof(*waterlist)); + waterlist = (struct waterlist_*)aCallocA(MAX_MAP_PER_SERVER,sizeof(*waterlist)); while(fgets(line,1020,fp) && n < MAX_MAP_PER_SERVER){ int wh,count; if(line[0] == '/' && line[1] == '/') @@ -1554,7 +1554,7 @@ static int map_cache_open(char *fn) { map_cache.head.filesize == ftell(map_cache.fp) ) { // キャッシュ読み込み成功 - map_cache.map = aMalloc(sizeof(struct MAP_CACHE_INFO) * map_cache.head.nmaps); + map_cache.map = (struct MAP_CACHE_INFO*)aMallocA(sizeof(struct MAP_CACHE_INFO) * map_cache.head.nmaps); fseek(map_cache.fp,sizeof(struct MAP_CACHE_HEAD),SEEK_SET); fread(map_cache.map,sizeof(struct MAP_CACHE_INFO),map_cache.head.nmaps,map_cache.fp); return 1; @@ -1567,7 +1567,7 @@ static int map_cache_open(char *fn) { map_cache.fp = fopen(fn,"wb"); if(map_cache.fp) { memset(&map_cache.head,0,sizeof(struct MAP_CACHE_HEAD)); - map_cache.map = aCalloc(sizeof(struct MAP_CACHE_INFO),MAX_CAHCE_MAX); + map_cache.map = (struct MAP_CACHE_INFO*)aCallocA(sizeof(struct MAP_CACHE_INFO),MAX_CAHCE_MAX); map_cache.head.nmaps = MAX_CAHCE_MAX; map_cache.head.sizeof_header = sizeof(struct MAP_CACHE_HEAD); map_cache.head.sizeof_map = sizeof(struct MAP_CACHE_INFO); @@ -1589,7 +1589,7 @@ static void map_cache_close(void) { fwrite(map_cache.map,map_cache.head.nmaps,sizeof(struct MAP_CACHE_INFO),map_cache.fp); } fclose(map_cache.fp); - free(map_cache.map); + aFree(map_cache.map); map_cache.fp = NULL; return; } @@ -1607,14 +1607,14 @@ int map_cache_read(struct map_data *m) { int size = map_cache.map[i].xs * map_cache.map[i].ys; m->xs = map_cache.map[i].xs; m->ys = map_cache.map[i].ys; - m->gat = (unsigned char *)aCalloc(m->xs * m->ys,sizeof(unsigned char)); + m->gat = (unsigned char *)aCallocA(m->xs * m->ys,sizeof(unsigned char)); fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET); if(fread(m->gat,1,size,map_cache.fp) == size) { // 成功 return 1; } else { // なぜかファイル後半が欠けてるので読み直し - m->xs = 0; m->ys = 0; m->gat = NULL; free(m->gat); + m->xs = 0; m->ys = 0; m->gat = NULL; aFree(m->gat); return 0; } } else if(map_cache.map[i].compressed == 1) { @@ -1624,14 +1624,14 @@ int map_cache_read(struct map_data *m) { int size_compress = map_cache.map[i].compressed_len; m->xs = map_cache.map[i].xs; m->ys = map_cache.map[i].ys; - m->gat = (unsigned char *)aMalloc(m->xs * m->ys * sizeof(unsigned char)); - buf = (unsigned char*)aMalloc(size_compress); + m->gat = (unsigned char *)aMallocA(m->xs * m->ys * sizeof(unsigned char)); + buf = (unsigned char*)aMallocA(size_compress); fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET); if(fread(buf,1,size_compress,map_cache.fp) != size_compress) { // なぜかファイル後半が欠けてるので読み直し printf("fread error\n"); m->xs = 0; m->ys = 0; m->gat = NULL; - free(m->gat); free(buf); + aFree(m->gat); aFree(buf); return 0; } dest_len = m->xs * m->ys; @@ -1639,10 +1639,10 @@ int map_cache_read(struct map_data *m) { if(dest_len != map_cache.map[i].xs * map_cache.map[i].ys) { // 正常に解凍が出来てない m->xs = 0; m->ys = 0; m->gat = NULL; - free(m->gat); free(buf); + aFree(m->gat); aFree(buf); return 0; } - free(buf); + aFree(buf); return 1; } } @@ -1669,7 +1669,7 @@ static int map_cache_write(struct map_data *m) { if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { // 圧縮保存 // さすがに2倍に膨れる事はないという事で - write_buf = aMalloc(m->xs * m->ys * 2); + write_buf = (char*)aMallocA(m->xs * m->ys * 2); len_new = m->xs * m->ys * 2; encode_zip(write_buf,&len_new,m->gat,m->xs * m->ys); map_cache.map[i].compressed = 1; @@ -1678,7 +1678,7 @@ static int map_cache_write(struct map_data *m) { len_new = m->xs * m->ys; write_buf = m->gat; map_cache.map[i].compressed = 0; - map_cache.map[i].compressed_len = 0; + map_cache.map[i].compressed_len = 0; } if(len_new <= len_old) { // サイズが同じか小さくなったので場所は変わらない @@ -1696,7 +1696,7 @@ static int map_cache_write(struct map_data *m) { map_cache.map[i].water_height = map_waterheight(m->name); map_cache.dirty = 1; if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { - free(write_buf); + aFree(write_buf); } return 0; } @@ -1706,7 +1706,7 @@ static int map_cache_write(struct map_data *m) { if(map_cache.map[i].fn[0] == 0) { // 新しい場所に登録 if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { - write_buf = aMalloc(m->xs * m->ys * 2); + write_buf = (char*)aMallocA(m->xs * m->ys * 2); len_new = m->xs * m->ys * 2; encode_zip(write_buf,&len_new,m->gat,m->xs * m->ys); map_cache.map[i].compressed = 1; @@ -1727,7 +1727,7 @@ static int map_cache_write(struct map_data *m) { map_cache.head.filesize += len_new; map_cache.dirty = 1; if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) { - free(write_buf); + aFree(write_buf); } return 0; } @@ -1819,7 +1819,8 @@ static int map_readafm(int m,char *fn) { map[m].m = m; xs = map[m].xs = afm_size[0]; ys = map[m].ys = afm_size[1]; - map[m].gat = aCalloc(s = map[m].xs * map[m].ys, 1); + // check this, unsigned where it might not need to be + map[m].gat = (unsigned char*)aCallocA(s = map[m].xs * map[m].ys, 1); if(map[m].gat==NULL){ printf("out of memory : map_readmap gat\n"); @@ -1842,14 +1843,14 @@ static int map_readafm(int m,char *fn) { map[m].bxs=(xs+BLOCK_SIZE-1)/BLOCK_SIZE; map[m].bys=(ys+BLOCK_SIZE-1)/BLOCK_SIZE; size = map[m].bxs * map[m].bys * sizeof(struct block_list*); - map[m].block = aCalloc(size, 1); + map[m].block = (struct block_list**)aCalloc(size, 1); if(map[m].block == NULL){ printf("out of memory : map_readmap block\n"); exit(1); } - map[m].block_mob = aCalloc(size, 1); + map[m].block_mob = (struct block_list**)aCalloc(size, 1); if (map[m].block_mob == NULL) { printf("out of memory : map_readmap block_mob\n"); exit(1); @@ -1857,14 +1858,14 @@ static int map_readafm(int m,char *fn) { size = map[m].bxs*map[m].bys*sizeof(int); - map[m].block_count = aCalloc(size, 1); + map[m].block_count = (int*)aCallocA(size, 1); if(map[m].block_count==NULL){ printf("out of memory : map_readmap block\n"); exit(1); } memset(map[m].block_count,0,size); - map[m].block_mob_count=aCalloc(size, 1); + map[m].block_mob_count = (int*)aCallocA(size, 1); if(map[m].block_mob_count==NULL){ printf("out of memory : map_readmap block_mob\n"); exit(1); @@ -1885,9 +1886,9 @@ static int map_readafm(int m,char *fn) { * マップ1枚読み込み * ===================================================*/ static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap) { - unsigned char *gat=""; + char *gat=""; size_t size; - + int i = 0; int e = 0; char progress[21] = " "; @@ -1925,19 +1926,20 @@ static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap) int s; int wh; int x,y,xs,ys; - struct gat_1cell {float high[4]; int type;} *p=NULL; + struct gat_1cell {float high[4]; int type;} *p=NULL; // read & convert fn - gat=grfio_read(fn); + // again, might not need to be unsigned char + gat = grfio_read(fn); if(gat==NULL) { return -1; // さすがにマップが読めないのはまずいので終了する //printf("Can't load map %s\n",fn); //exit(1); } - + xs=map[m].xs=*(int*)(gat+6); ys=map[m].ys=*(int*)(gat+10); - map[m].gat = (unsigned char *)aCalloc(s = map[m].xs * map[m].ys,sizeof(unsigned char)); + map[m].gat = (char *)aCallocA(s = map[m].xs * map[m].ys,sizeof(char)); wh=map_waterheight(map[m].name); for(y=0;y= READ_FROM_BITMAP) { map_cache_open(map_bitmap_filename); @@ -2032,7 +2034,7 @@ int map_readallmap(void) { char buf[64]; *p++ = '\0'; sprintf(buf,"data\\%s", p); - map[i].alias = strdup(buf); + map[i].alias = aStrdup(buf); } else map[i].alias = NULL; @@ -2041,20 +2043,20 @@ int map_readallmap(void) { map_delmap(map[i].name); maps_removed++; i--; - } + } } } - free(waterlist); + aFree(waterlist); printf("\r"); snprintf(tmp_output,sizeof(tmp_output),"Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps.%30s\n",map_num,""); ShowInfo(tmp_output); - + map_cache_close(); if(map_read_flag == CREATE_BITMAP || map_read_flag == CREATE_BITMAP_COMPRESSED) { --map_read_flag; } - + if (maps_removed) { snprintf(tmp_output,sizeof(tmp_output),"Maps Removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed); ShowNotice(tmp_output); @@ -2119,15 +2121,15 @@ int parse_console(char *buf) { int m, n; struct map_session_data *sd; - sd = aCalloc(sizeof(*sd), 1); + sd = (struct map_session_data*)aCalloc(sizeof(*sd), 1); sd->fd = 0; strcpy( sd->status.name , "console"); - type = (char *)aMalloc(64); - command = (char *)aMalloc(64); - map = (char *)aMalloc(64); - buf2 = (char *)aMalloc(72); + type = (char *)aMallocA(64); + command = (char *)aMallocA(64); + map = (char *)aMallocA(64); + buf2 = (char *)aMallocA(72); memset(type,0,64); memset(command,0,64); @@ -2184,12 +2186,12 @@ int parse_console(char *buf) { } end: - free(buf); - free(type); - free(command); - free(map); - free(buf2); - free(sd); + aFree(buf); + aFree(type); + aFree(command); + aFree(map); + aFree(buf2); + aFree(sd); return 0; } @@ -2317,7 +2319,7 @@ int inter_config_read(char *cfgName) if(i!=2) continue; if(strcmpi(w1,"stall_time")==0){ - stall_time_ = atoi(w2); + stall_time_ = atoi(w2); #ifndef TXT_ONLY } else if(strcmpi(w1,"item_db_db")==0){ strcpy(item_db_db,w2); @@ -2484,7 +2486,7 @@ void char_online_check(void) chrif_char_reset_offline(); for(i=0;isession_data) && sd && sd->state.auth && + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd))) if(sd->status.char_id) { chrif_char_online(sd); @@ -2523,21 +2525,22 @@ int flush_timer(int tid, unsigned int tick, int id, int data){ int id_db_final(void *k,void *d,va_list ap) { struct mob_data *id; - nullpo_retr(0, id=d); + nullpo_retr(0, id = (struct mob_data*)d); if(id->lootitem) - free(id->lootitem); + aFree(id->lootitem); if(id) - free(id); + aFree(id); return 0; } + int map_db_final(void *k,void *d,va_list ap) { struct map_data *id; - nullpo_retr(0, id=d); + nullpo_retr(0, id = (struct map_data*)d); if(id->gat) - free(id->gat); + aFree(id->gat); if(id) - free(id); + aFree(id); return 0; } int nick_db_final(void *k,void *d,va_list ap){ return 0; } @@ -2607,14 +2610,14 @@ void do_final(void) { do_final_guild(); /* for(i=0;i= (sizeof(mob_db) / sizeof(mob_db[0])) || mob_db[id].name[0] == '\0') return 0; @@ -85,28 +85,28 @@ int mobdb_checkid(const int id) * The minimum data set for MOB spawning *------------------------------------------ */ -int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class) +int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class_) { nullpo_retr(0, md); md->bl.prev=NULL; md->bl.next=NULL; if(strcmp(mobname,"--en--")==0) - memcpy(md->name,mob_db[class].name,24); + memcpy(md->name,mob_db[class_].name,24); else if(strcmp(mobname,"--ja--")==0) - memcpy(md->name,mob_db[class].jname,24); + memcpy(md->name,mob_db[class_].jname,24); else memcpy(md->name,mobname,24); md->n = 0; - md->base_class = md->class_ = class; + md->base_class = md->class_ = class_; md->bl.id= npc_get_new_npc_id(); memset(&md->state,0,sizeof(md->state)); md->timer = -1; md->target_id=0; md->attacked_id=0; - md->speed=mob_db[class].speed; + md->speed=mob_db[class_].speed; return 0; } @@ -117,10 +117,10 @@ int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class) *------------------------------------------ */ int mob_once_spawn(struct map_session_data *sd,char *mapname, - int x,int y,const char *mobname,int class,int amount,const char *event) + int x,int y,const char *mobname,int class_,int amount,const char *event) { struct mob_data *md=NULL; - int m,count,lv=255,r=class; + int m,count,lv=255,r=class_; if( sd ) lv=sd->status.base_level; @@ -130,27 +130,27 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname, else m=map_mapname2mapid(mapname); - if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>6000) // 値が異常なら召喚を止める + if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // 値が異常なら召喚を止める return 0; - if(class<0){ // ランダムに召喚 + if(class_<0){ // ランダムに召喚 int i=0; - int j=-class-1; + int j=-class_-1; int k; if(j>=0 && j=2000){ - class=mob_db[0].summonper[j]; + class_=mob_db[0].summonper[j]; } }else{ return 0; } // if(battle_config.etc_log) -// printf("mobclass=%d try=%d\n",class,i); +// printf("mobclass=%d try=%d\n",class_,i); } if(sd){ if(x<=0) x=sd->bl.x; @@ -163,21 +163,21 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname, md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data)); memset(md, '\0', sizeof *md); - if(class>4000) { // large/tiny mobs [Valaris] + if(class_>4000) { // large/tiny mobs [Valaris] md->size=2; - class-=4000; + class_-=4000; } - else if(class>MAX_MOB_DB) { + else if(class_>MAX_MOB_DB) { md->size=1; - class-=MAX_MOB_DB; + class_-=MAX_MOB_DB; } - if(mob_db[class].mode&0x02) + if(mob_db[class_].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); else md->lootitem=NULL; - mob_spawn_dataset(md,mobname,class); + mob_spawn_dataset(md,mobname,class_); md->bl.m=m; md->bl.x=x; md->bl.y=y; @@ -195,15 +195,15 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname, md->bl.type=BL_MOB; map_addiddb(&md->bl); mob_spawn(md->bl.id); - - if(class==1288) { // emperium hp based on defense level [Valaris] + + if(class_==1288) { // emperium hp based on defense level [Valaris] struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { - mob_db[class].max_hp+=2000*gc->defense; - md->hp=mob_db[class].max_hp; + mob_db[class_].max_hp+=2000*gc->defense; + md->hp=mob_db[class_].max_hp; } } // end addition [Valaris] - + } return (amount>0)?md->bl.id:0; @@ -214,7 +214,7 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname, */ int mob_once_spawn_area(struct map_session_data *sd,char *mapname, int x0,int y0,int x1,int y1, - const char *mobname,int class,int amount,const char *event) + const char *mobname,int class_,int amount,const char *event) { int x,y,i,max,lx=-1,ly=-1,id=0; int m; @@ -227,7 +227,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname, max=(y1-y0+1)*(x1-x0+1)*3; if(max>1000)max=1000; - if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>6000) // A summon is stopped if a value is unusual + if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // A summon is stopped if a value is unusual return 0; for(i=0;i=0 && class<=1000) || class>MAX_MOB_DB) // Invalid monster classes + if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // Invalid monster classes return 0; - if(class<0) + if(class_<0) return 0; - + if(sd){ if(x<=0) x=sd->bl.x; if(y<=0) y=sd->bl.y; } - + else if(x<=0 || y<=0) printf("mob_spawn_guardian: ??\n"); - + for(count=0;countbl.m=m; md->bl.x=x; md->bl.y=y; @@ -315,7 +315,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname, gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { - mob_db[class].max_hp+=2000*gc->defense; + mob_db[class_].max_hp+=2000*gc->defense; if(guardian==0) { md->hp=gc->Ghp0; gc->GID0=md->bl.id; } if(guardian==1) { md->hp=gc->Ghp1; gc->GID1=md->bl.id; } if(guardian==2) { md->hp=gc->Ghp2; gc->GID2=md->bl.id; } @@ -324,7 +324,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname, if(guardian==5) { md->hp=gc->Ghp5; gc->GID5=md->bl.id; } if(guardian==6) { md->hp=gc->Ghp6; gc->GID6=md->bl.id; } if(guardian==7) { md->hp=gc->Ghp7; gc->GID7=md->bl.id; } - + } } @@ -373,49 +373,49 @@ int mob_exclusion_check(struct mob_data *md,struct map_session_data *sd) * Appearance income of mob *------------------------------------------ */ -int mob_get_viewclass(int class) +int mob_get_viewclass(int class_) { - return mob_db[class].view_class; + return mob_db[class_].view_class; } -int mob_get_sex(int class) +int mob_get_sex(int class_) { - return mob_db[class].sex; + return mob_db[class_].sex; } -short mob_get_hair(int class) +short mob_get_hair(int class_) { - return mob_db[class].hair; + return mob_db[class_].hair; } -short mob_get_hair_color(int class) +short mob_get_hair_color(int class_) { - return mob_db[class].hair_color; + return mob_db[class_].hair_color; } -short mob_get_weapon(int class) +short mob_get_weapon(int class_) { - return mob_db[class].weapon; + return mob_db[class_].weapon; } -short mob_get_shield(int class) +short mob_get_shield(int class_) { - return mob_db[class].shield; + return mob_db[class_].shield; } -short mob_get_head_top(int class) +short mob_get_head_top(int class_) { - return mob_db[class].head_top; + return mob_db[class_].head_top; } -short mob_get_head_mid(int class) +short mob_get_head_mid(int class_) { - return mob_db[class].head_mid; + return mob_db[class_].head_mid; } -short mob_get_head_buttom(int class) +short mob_get_head_buttom(int class_) { - return mob_db[class].head_buttom; + return mob_db[class_].head_buttom; } -short mob_get_clothes_color(int class) // Add for player monster dye - Valaris +short mob_get_clothes_color(int class_) // Add for player monster dye - Valaris { - return mob_db[class].clothes_color; // End + return mob_db[class_].clothes_color; // End } -int mob_get_equip(int class) // mob equip [Valaris] +int mob_get_equip(int class_) // mob equip [Valaris] { - return mob_db[class].equip; + return mob_db[class_].equip; } /*========================================== * Is MOB in the state in which the present movement is possible or not? @@ -432,7 +432,7 @@ int mob_can_move(struct mob_data *md) md->sc_data[SC_AUTOCOUNTER].timer != -1 || //オートカウンター md->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り md->sc_data[SC_SPIDERWEB].timer != -1 //スパイダーウェッブ - ) + ) return 0; return 1; @@ -536,7 +536,7 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data) if(md->walkpath.path_pos>=md->walkpath.path_len) clif_fixmobpos(md); // とまったときに位置の再送信 - } + } return 0; } @@ -613,7 +613,7 @@ static int mob_attack(struct mob_data *md,unsigned int tick,int data) if(tsd && !(mode&0x20) && (tsd->sc_data[SC_TRICKDEAD].timer != -1 || tsd->sc_data[SC_BASILICA].timer != -1 || ((pc_ishiding(tsd) || tsd->state.gangsterparadise) && !((race == 4 || race == 6) && !tsd->perfect_hiding) ) ) ) { md->target_id=0; - md->state.targettype = NONE_ATTACKABLE; + md->state.targettype = NONE_ATTACKABLE; return 0; } @@ -739,7 +739,7 @@ static int mob_timer(int tid,unsigned int tick,int id,int data) if( (bl=map_id2bl(id)) == NULL ){ //攻撃してきた敵がもういないのは正常のようだ return 1; } - + if(!bl || !bl->type || bl->type!=BL_MOB) return 1; @@ -904,7 +904,7 @@ int mob_spawn(int id) if(!md || !md->bl.type || md->bl.type!=BL_MOB) return -1; - + md->last_spawntime=tick; if( md->bl.prev!=NULL ){ // clif_clearchar_area(&md->bl,3); @@ -969,7 +969,7 @@ int mob_spawn(int id) if(gc) md->guild_id = gc->guild_id; } - + md->deletetimer=-1; md->skilltimer=-1; @@ -1042,7 +1042,7 @@ int mob_stop_walking(struct mob_data *md,int type) if(md->state.state == MS_WALK || md->state.state == MS_IDLE) { int dx=0,dy=0; - + md->walkpath.path_len=0; if(type&4){ dx=md->to_x-md->bl.x; @@ -1101,7 +1101,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range) if(gc && agit_flag==0) // Guardians will not attack during non-woe time [Valaris] return 0; // end addition [Valaris] - + if(bl && bl->type == BL_PC){ nullpo_retr(0, sd=(struct map_session_data *)bl); if(!gc) @@ -1183,7 +1183,9 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) return 0; } // Nothing will be carried out if there is no mind of changing TAGE by TAGE ending. - if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && ( !(mode&0x04) || rand()%100>25) ) + if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && (!(mode&0x04) || rand()%100>25) && + // if the monster was provoked ignore the above rule [celest] + !(md->state.provoke_flag && md->state.provoke_flag == bl->id)) return 0; if(mode&0x20 || // Coercion is exerted if it is MVPMOB. @@ -1197,11 +1199,13 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) return 0; } - md->target_id=bl->id; // Since there was no disturbance, it locks on to target. + md->target_id = bl->id; // Since there was no disturbance, it locks on to target. if(bl->type == BL_PC || bl->type == BL_MOB) md->state.targettype = ATTACKABLE; else md->state.targettype = NONE_ATTACKABLE; + if (md->state.provoke_flag) + md->state.provoke_flag = 0; md->min_chase=dist+13; if(md->min_chase>26) md->min_chase=26; @@ -1245,9 +1249,9 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) race=mob_db[smd->class_].race; //対象がPCの場合 if(tsd && - !pc_isdead(tsd) && - tsd->bl.m == smd->bl.m && - tsd->invincible_timer == -1 && + !pc_isdead(tsd) && + tsd->bl.m == smd->bl.m && + tsd->invincible_timer == -1 && !pc_isinvisible(tsd) && (dist=distance(smd->bl.x,smd->bl.y,tsd->bl.x,tsd->bl.y))<9 ) @@ -1259,7 +1263,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) rand()%1000<1000/(++(*pcc)) ){ // 範囲内PCで等確率にする smd->target_id=tsd->bl.id; smd->state.targettype = ATTACKABLE; - smd->min_chase=13; + smd->min_chase=13; } } } @@ -1298,7 +1302,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) mode=mob_db[md->class_].mode; else mode=md->mode; - + if( !md->target_id && mode&0x02){ if(!md->lootitem || (battle_config.monster_loot_type == 1 && md->lootitem_count >= LOOTITEM_SIZE) ) @@ -1393,7 +1397,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) } // Although there is the master, since it is somewhat far, it approaches. - if((!md->target_id || md->state.targettype == NONE_ATTACKABLE) && mob_can_move(md) && + if((!md->target_id || md->state.targettype == NONE_ATTACKABLE) && mob_can_move(md) && (md->walkpath.path_pos>=md->walkpath.path_len || md->walkpath.path_len==0) && md->master_dist<15){ int i=0,dx,dy,ret; if(md->master_dist>4) { @@ -1716,7 +1720,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) ret=mob_walktoxy(md,md->bl.x+dx,md->bl.y+dy,0); i++; } while(ret && i<5); - + if(ret){ // 移動不可能な所からの攻撃なら2歩下る if(dx<0) dx=2; else if(dx>0) dx=-2; @@ -1969,13 +1973,13 @@ static int mob_delay_item_drop(int tid,unsigned int tick,int id,int data) clif_additem(ditem->first_sd,0,0,flag); map_addflooritem(&temp_item,1,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); } - free(ditem); + aFree(ditem); return 0; } map_addflooritem(&temp_item,1,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); - free(ditem); + aFree(ditem); return 0; } @@ -1995,13 +1999,13 @@ static int mob_delay_item_drop2(int tid,unsigned int tick,int id,int data) clif_additem(ditem->first_sd,0,0,flag); map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); } - free(ditem); + aFree(ditem); return 0; } map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); - free(ditem); + aFree(ditem); return 0; } @@ -2219,71 +2223,71 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) } md->hp-=damage; - + if(md->class_ >= 1285 && md->class_ <=1287) { // guardian hp update [Valaris] struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name); if(gc) { - if(md->bl.id==gc->GID0) { + if(md->bl.id==gc->GID0) { gc->Ghp0=md->hp; if(gc->Ghp0<=0) { guild_castledatasave(gc->castle_id,10,0); guild_castledatasave(gc->castle_id,18,0); } - } - if(md->bl.id==gc->GID1) { + } + if(md->bl.id==gc->GID1) { gc->Ghp1=md->hp; if(gc->Ghp1<=0) { guild_castledatasave(gc->castle_id,11,0); guild_castledatasave(gc->castle_id,19,0); } } - if(md->bl.id==gc->GID2) { + if(md->bl.id==gc->GID2) { gc->Ghp2=md->hp; if(gc->Ghp2<=0) { guild_castledatasave(gc->castle_id,12,0); guild_castledatasave(gc->castle_id,20,0); } } - if(md->bl.id==gc->GID3) { + if(md->bl.id==gc->GID3) { gc->Ghp3=md->hp; if(gc->Ghp3<=0) { guild_castledatasave(gc->castle_id,13,0); guild_castledatasave(gc->castle_id,21,0); } } - if(md->bl.id==gc->GID4) { + if(md->bl.id==gc->GID4) { gc->Ghp4=md->hp; if(gc->Ghp4<=0) { guild_castledatasave(gc->castle_id,14,0); guild_castledatasave(gc->castle_id,22,0); } } - if(md->bl.id==gc->GID5) { + if(md->bl.id==gc->GID5) { gc->Ghp5=md->hp; if(gc->Ghp5<=0) { guild_castledatasave(gc->castle_id,15,0); guild_castledatasave(gc->castle_id,23,0); } } - if(md->bl.id==gc->GID6) { + if(md->bl.id==gc->GID6) { gc->Ghp6=md->hp; if(gc->Ghp6<=0) { guild_castledatasave(gc->castle_id,16,0); guild_castledatasave(gc->castle_id,24,0); } } - if(md->bl.id==gc->GID7) { + if(md->bl.id==gc->GID7) { gc->Ghp7=md->hp; if(gc->Ghp7<=0) { guild_castledatasave(gc->castle_id,17,0); guild_castledatasave(gc->castle_id,25,0); - + } } } } // end addition [Valaris] - + if(md->option&2 ) skill_status_change_end(&md->bl, SC_HIDING, -1); if(md->option&4 ) @@ -2291,7 +2295,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(md->state.special_mob_ai == 2){//スフィアーマイン int skillidx=0; - + if((skillidx=mob_skillid2skillidx(md->class_,NPC_SELFDESTRUCTION2))>=0){ md->mode |= 0x1; md->next_walktime=tick; @@ -2403,10 +2407,10 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) job_exp=mob_db[md->class_].job_exp*per/256; if(job_exp < 1) job_exp = 1; } - + if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { base_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] - } + } if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) { job_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris] } @@ -2415,7 +2419,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) job_exp = 0; } else { - if(battle_config.zeny_from_mobs) { + if(battle_config.zeny_from_mobs) { if(md->level > 0) zeny=(md->level+rand()%md->level)*per/256; // zeny calculation moblv + random moblv [Valaris] if(mob_db[md->class_].mexp > 0) zeny*=rand()%250; @@ -2425,7 +2429,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) base_exp+=((md->level-mob_db[md->class_].lv)*mob_db[md->class_].base_exp*.03)*per/256; } } - + if((pid=tmpsd[i]->status.party_id)>0){ // パーティに入っている int j=0; for(j=0;jbl); if(sd->monster_drop_itemid[i] <= 0) continue; - if(sd->monster_drop_race[i] & (1<monster_drop_race[i] & (1<class_].mode & 0x20 && sd->monster_drop_race[i] & 1<<10) || (!(mob_db[md->class_].mode & 0x20) && sd->monster_drop_race[i] & 1<<11) ) { if(sd->monster_drop_itemrate[i] <= rand()%10000) @@ -2572,7 +2576,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) int log_mvp[2] = {0}; int j; int mexp; - temp = ((double)mob_db[md->class_].mexp * (9.+(double)count)/10.); //[Gengar] + temp = ((double)mob_db[md->class_].mexp * (9.+(double)count)/10.); //[Gengar] mexp = (temp > 2147483647.)? 0x7fffffff:(int)temp; if(mexp < 1) mexp = 1; clif_mvp_effect(mvp_sd); // エフェクト @@ -2617,7 +2621,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) if(md->npc_event[0] && strcmp(((md->npc_event)+strlen(md->npc_event)-13),"::OnAgitBreak") == 0) { printf("MOB.C: Run NPC_Event[OnAgitBreak].\n"); if (agit_flag == 1) //Call to Run NPC_Event[OnAgitBreak] - guild_agit_break(md); + guild_agit_break(md); } // SCRIPT実行 @@ -2665,7 +2669,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type) int mob_class_change(struct mob_data *md,int *value) { unsigned int tick = gettick(); - int i,c,hp_rate,max_hp,class,count = 0; + int i,c,hp_rate,max_hp,class_,count = 0; nullpo_retr(0, md); nullpo_retr(0, value); @@ -2677,13 +2681,13 @@ int mob_class_change(struct mob_data *md,int *value) while(count < 5 && value[count] > 1000 && value[count] <= MAX_MOB_DB) count++; if(count < 1) return 0; - class = value[rand()%count]; - if(class<=1000 || class>MAX_MOB_DB) return 0; + class_ = value[rand()%count]; + if(class_<=1000 || class_>MAX_MOB_DB) return 0; max_hp = battle_get_max_hp(&md->bl); hp_rate = md->hp*100/max_hp; - clif_mob_class_change(md,class); - md->class_ = class; + clif_mob_class_change(md,class_); + md->class_ = class_; max_hp = battle_get_max_hp(&md->bl); if(battle_config.monster_class_change_full_recover==1) { md->hp = max_hp; @@ -2694,7 +2698,7 @@ int mob_class_change(struct mob_data *md,int *value) if(md->hp > max_hp) md->hp = max_hp; else if(md->hp < 1) md->hp = 1; - memcpy(md->name,mob_db[class].jname,24); + memcpy(md->name,mob_db[class_].jname,24); memset(&md->state,0,sizeof(md->state)); md->attacked_id = 0; md->target_id = 0; @@ -2710,13 +2714,13 @@ int mob_class_change(struct mob_data *md,int *value) md->next_walktime = tick+rand()%50+5000; md->attackabletime = tick; md->canmove_tick = tick; - + for(i=0,c=tick-1000*3600*10;iskilldelay[i] = c; md->skillid=0; md->skilllv=0; - if(md->lootitem == NULL && mob_db[class].mode&0x02) + if(md->lootitem == NULL && mob_db[class_].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); skill_clear_unitgroup(&md->bl); @@ -2902,7 +2906,7 @@ int mob_countslave(struct mob_data *md) int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag) { struct mob_data *md; - int bx,by,m,count = 0,class,k,a = amount; + int bx,by,m,count = 0,class_,k,a = amount; nullpo_retr(0, md2); nullpo_retr(0, value); @@ -2918,12 +2922,12 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag) for(k=0;kMAX_MOB_DB) continue; + class_ = value[k]; + if(class_<=1000 || class_>MAX_MOB_DB) continue; for(;amount>0;amount--){ int x=0,y=0,i=0; md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data)); - if(mob_db[class].mode&0x02) + if(mob_db[class_].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); else md->lootitem=NULL; @@ -2937,7 +2941,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag) y=by; } - mob_spawn_dataset(md,"--ja--",class); + mob_spawn_dataset(md,"--ja--",class_); md->bl.m=m; md->bl.x=x; md->bl.y=y; @@ -3018,15 +3022,15 @@ int mob_counttargeted(struct mob_data *md,struct block_list *src,int target_lv) *MOBskillから該当skillidのskillidxを返す *------------------------------------------ */ -int mob_skillid2skillidx(int class,int skillid) +int mob_skillid2skillidx(int class_,int skillid) { int i; - struct mob_skill *ms=mob_db[class].skill; - + struct mob_skill *ms=mob_db[class_].skill; + if(ms==NULL) return -1; - for(i=0;ibl.type!=BL_MOB || md->bl.prev==NULL ) return 0; @@ -3259,7 +3263,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx) nullpo_retr(0, md); nullpo_retr(0, ms=&mob_db[md->class_].skill[skill_idx]); - + if( target==NULL && (target=map_id2bl(md->target_id))==NULL ) return 0; @@ -3692,10 +3696,10 @@ int mobskill_event(struct mob_data *md,int flag) int mob_gvmobcheck(struct map_session_data *sd, struct block_list *bl) { struct mob_data *md=NULL; - + nullpo_retr(0,sd); nullpo_retr(0,bl); - + if(bl->type==BL_MOB && (md=(struct mob_data *)bl) && (md->class_ == 1288 || md->class_ == 1287 || md->class_ == 1286 || md->class_ == 1285)) { @@ -3712,7 +3716,7 @@ int mob_gvmobcheck(struct map_session_data *sd, struct block_list *bl) return 0;//正規ギルド承認がないとダメージ無し } - + return 1; } /*========================================== @@ -3739,53 +3743,53 @@ int mobskill_deltimer(struct mob_data *md ) * Since un-setting [ mob ] up was used, it is an initial provisional value setup. *------------------------------------------ */ -static int mob_makedummymobdb(int class) +static int mob_makedummymobdb(int class_) { int i; - sprintf(mob_db[class].name,"mob%d",class); - sprintf(mob_db[class].jname,"mob%d",class); - mob_db[class].lv=1; - mob_db[class].max_hp=1000; - mob_db[class].max_sp=1; - mob_db[class].base_exp=2; - mob_db[class].job_exp=1; - mob_db[class].range=1; - mob_db[class].atk1=7; - mob_db[class].atk2=10; - mob_db[class].def=0; - mob_db[class].mdef=0; - mob_db[class].str=1; - mob_db[class].agi=1; - mob_db[class].vit=1; - mob_db[class].int_=1; - mob_db[class].dex=6; - mob_db[class].luk=2; - mob_db[class].range2=10; - mob_db[class].range3=10; - mob_db[class].size=0; - mob_db[class].race=0; - mob_db[class].element=0; - mob_db[class].mode=0; - mob_db[class].speed=300; - mob_db[class].adelay=1000; - mob_db[class].amotion=500; - mob_db[class].dmotion=500; - mob_db[class].dropitem[0].nameid=909; // Jellopy - mob_db[class].dropitem[0].p=1000; + sprintf(mob_db[class_].name,"mob%d",class_); + sprintf(mob_db[class_].jname,"mob%d",class_); + mob_db[class_].lv=1; + mob_db[class_].max_hp=1000; + mob_db[class_].max_sp=1; + mob_db[class_].base_exp=2; + mob_db[class_].job_exp=1; + mob_db[class_].range=1; + mob_db[class_].atk1=7; + mob_db[class_].atk2=10; + mob_db[class_].def=0; + mob_db[class_].mdef=0; + mob_db[class_].str=1; + mob_db[class_].agi=1; + mob_db[class_].vit=1; + mob_db[class_].int_=1; + mob_db[class_].dex=6; + mob_db[class_].luk=2; + mob_db[class_].range2=10; + mob_db[class_].range3=10; + mob_db[class_].size=0; + mob_db[class_].race=0; + mob_db[class_].element=0; + mob_db[class_].mode=0; + mob_db[class_].speed=300; + mob_db[class_].adelay=1000; + mob_db[class_].amotion=500; + mob_db[class_].dmotion=500; + mob_db[class_].dropitem[0].nameid=909; // Jellopy + mob_db[class_].dropitem[0].p=1000; for(i=1;i<8;i++){ - mob_db[class].dropitem[i].nameid=0; - mob_db[class].dropitem[i].p=0; + mob_db[class_].dropitem[i].nameid=0; + mob_db[class_].dropitem[i].p=0; } // Item1,Item2 - mob_db[class].mexp=0; - mob_db[class].mexpper=0; + mob_db[class_].mexp=0; + mob_db[class_].mexpper=0; for(i=0;i<3;i++){ - mob_db[class].mvpitem[i].nameid=0; - mob_db[class].mvpitem[i].p=0; + mob_db[class_].mvpitem[i].nameid=0; + mob_db[class_].mvpitem[i].p=0; } for(i=0;iMAX_MOB_DB) + class_=atoi(str[0]); + if(class_<=1000 || class_>MAX_MOB_DB) continue; - mob_db[class].view_class=class; - memcpy(mob_db[class].name,str[1],24); - memcpy(mob_db[class].jname,str[2],24); - mob_db[class].lv=atoi(str[3]); - mob_db[class].max_hp=atoi(str[4]); - mob_db[class].max_sp=atoi(str[5]); - - mob_db[class].base_exp=atoi(str[6]); - if(mob_db[class].base_exp < 0) - mob_db[class].base_exp = 0; - else if(mob_db[class].base_exp > 0 && (mob_db[class].base_exp*battle_config.base_exp_rate/100 > 1000000000 || - mob_db[class].base_exp*battle_config.base_exp_rate/100 < 0)) - mob_db[class].base_exp=1000000000; - else - mob_db[class].base_exp*= battle_config.base_exp_rate/100; - - mob_db[class].job_exp=atoi(str[7]); - if(mob_db[class].job_exp < 0) - mob_db[class].job_exp = 0; - else if(mob_db[class].job_exp > 0 && (mob_db[class].job_exp*battle_config.job_exp_rate/100 > 1000000000 || - mob_db[class].job_exp*battle_config.job_exp_rate/100 < 0)) - mob_db[class].job_exp=1000000000; - else - mob_db[class].job_exp*=battle_config.job_exp_rate/100; - - mob_db[class].range=atoi(str[8]); - mob_db[class].atk1=atoi(str[9]); - mob_db[class].atk2=atoi(str[10]); - mob_db[class].def=atoi(str[11]); - mob_db[class].mdef=atoi(str[12]); - mob_db[class].str=atoi(str[13]); - mob_db[class].agi=atoi(str[14]); - mob_db[class].vit=atoi(str[15]); - mob_db[class].int_=atoi(str[16]); - mob_db[class].dex=atoi(str[17]); - mob_db[class].luk=atoi(str[18]); - mob_db[class].range2=atoi(str[19]); - mob_db[class].range3=atoi(str[20]); - mob_db[class].size=atoi(str[21]); - mob_db[class].race=atoi(str[22]); - mob_db[class].element=atoi(str[23]); - mob_db[class].mode=atoi(str[24]); - mob_db[class].speed=atoi(str[25]); - mob_db[class].adelay=atoi(str[26]); - mob_db[class].amotion=atoi(str[27]); - mob_db[class].dmotion=atoi(str[28]); + mob_db[class_].view_class=class_; + memcpy(mob_db[class_].name,str[1],24); + memcpy(mob_db[class_].jname,str[2],24); + mob_db[class_].lv=atoi(str[3]); + mob_db[class_].max_hp=atoi(str[4]); + mob_db[class_].max_sp=atoi(str[5]); + + mob_db[class_].base_exp=atoi(str[6]); + if(mob_db[class_].base_exp < 0) + mob_db[class_].base_exp = 0; + else if(mob_db[class_].base_exp > 0 && (mob_db[class_].base_exp*battle_config.base_exp_rate/100 > 1000000000 || + mob_db[class_].base_exp*battle_config.base_exp_rate/100 < 0)) + mob_db[class_].base_exp=1000000000; + else + mob_db[class_].base_exp*= battle_config.base_exp_rate/100; + + mob_db[class_].job_exp=atoi(str[7]); + if(mob_db[class_].job_exp < 0) + mob_db[class_].job_exp = 0; + else if(mob_db[class_].job_exp > 0 && (mob_db[class_].job_exp*battle_config.job_exp_rate/100 > 1000000000 || + mob_db[class_].job_exp*battle_config.job_exp_rate/100 < 0)) + mob_db[class_].job_exp=1000000000; + else + mob_db[class_].job_exp*=battle_config.job_exp_rate/100; + + mob_db[class_].range=atoi(str[8]); + mob_db[class_].atk1=atoi(str[9]); + mob_db[class_].atk2=atoi(str[10]); + mob_db[class_].def=atoi(str[11]); + mob_db[class_].mdef=atoi(str[12]); + mob_db[class_].str=atoi(str[13]); + mob_db[class_].agi=atoi(str[14]); + mob_db[class_].vit=atoi(str[15]); + mob_db[class_].int_=atoi(str[16]); + mob_db[class_].dex=atoi(str[17]); + mob_db[class_].luk=atoi(str[18]); + mob_db[class_].range2=atoi(str[19]); + mob_db[class_].range3=atoi(str[20]); + mob_db[class_].size=atoi(str[21]); + mob_db[class_].race=atoi(str[22]); + mob_db[class_].element=atoi(str[23]); + mob_db[class_].mode=atoi(str[24]); + mob_db[class_].speed=atoi(str[25]); + mob_db[class_].adelay=atoi(str[26]); + mob_db[class_].amotion=atoi(str[27]); + mob_db[class_].dmotion=atoi(str[28]); for(i=0;i<8;i++){ int rate = 0,type,ratemin,ratemax; - mob_db[class].dropitem[i].nameid=atoi(str[29+i*2]); - type = itemdb_type(mob_db[class].dropitem[i].nameid); + mob_db[class_].dropitem[i].nameid=atoi(str[29+i*2]); + type = itemdb_type(mob_db[class_].dropitem[i].nameid); if (type == 0) { // Added [Valaris] rate = battle_config.item_rate_heal; ratemin = battle_config.item_drop_heal_min; @@ -3947,28 +3951,28 @@ static int mob_readdb(void) } rate = rate * atoi(str[30+i*2])/100; rate = (rate < ratemin)? ratemin: (rate > ratemax)? ratemax: rate; - mob_db[class].dropitem[i].p = rate; + mob_db[class_].dropitem[i].p = rate; } // Item1,Item2 - mob_db[class].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100; - mob_db[class].mexpper=atoi(str[46]); + mob_db[class_].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100; + mob_db[class_].mexpper=atoi(str[46]); for(i=0;i<3;i++){ - mob_db[class].mvpitem[i].nameid=atoi(str[47+i*2]); - mob_db[class].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100; + mob_db[class_].mvpitem[i].nameid=atoi(str[47+i*2]); + mob_db[class_].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100; } for(i=0;iMAX_MOB_DB) // 値が異常なら処理しない。 + if(class_<=1000 || class_>MAX_MOB_DB) // 値が異常なら処理しない。 continue; k=atoi(str[1]); if(k >= 0) - mob_db[class].view_class=k; - - if((mob_db[class].view_class < 24) || (mob_db[class].view_class > 4000)) { - mob_db[class].sex=atoi(str[2]); - mob_db[class].hair=atoi(str[3]); - mob_db[class].hair_color=atoi(str[4]); - mob_db[class].weapon=atoi(str[5]); - mob_db[class].shield=atoi(str[6]); - mob_db[class].head_top=atoi(str[7]); - mob_db[class].head_mid=atoi(str[8]); - mob_db[class].head_buttom=atoi(str[9]); - mob_db[class].option=atoi(str[10])&~0x46; - mob_db[class].clothes_color=atoi(str[11]); // Monster player dye option - Valaris + mob_db[class_].view_class=k; + + if((mob_db[class_].view_class < 24) || (mob_db[class_].view_class > 4000)) { + mob_db[class_].sex=atoi(str[2]); + mob_db[class_].hair=atoi(str[3]); + mob_db[class_].hair_color=atoi(str[4]); + mob_db[class_].weapon=atoi(str[5]); + mob_db[class_].shield=atoi(str[6]); + mob_db[class_].head_top=atoi(str[7]); + mob_db[class_].head_mid=atoi(str[8]); + mob_db[class_].head_buttom=atoi(str[9]); + mob_db[class_].option=atoi(str[10])&~0x46; + mob_db[class_].clothes_color=atoi(str[11]); // Monster player dye option - Valaris } - else if(atoi(str[2]) > 0) mob_db[class].equip=atoi(str[2]); // mob equipment [Valaris] + else if(atoi(str[2]) > 0) mob_db[class_].equip=atoi(str[2]); // mob equipment [Valaris] ln++; } @@ -4066,7 +4070,7 @@ static int mob_read_randommonster(void) return -1; } while(fgets(line,1020,fp)){ - int class,per; + int class_,per; if(line[0] == '/' && line[1] == '/') continue; memset(str,0,sizeof(str)); @@ -4079,10 +4083,10 @@ static int mob_read_randommonster(void) if(str[0]==NULL || str[2]==NULL) continue; - class = atoi(str[0]); + class_ = atoi(str[0]); per=atoi(str[2]); - if((class>1000 && class<=MAX_MOB_DB) || class==0) - mob_db[class].summonper[i]=per; + if((class_>1000 && class_<=MAX_MOB_DB) || class_==0) + mob_db[class_].summonper[i]=per; } fclose(fp); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n",mobfile[i]); @@ -4267,12 +4271,12 @@ void mob_reload(void) static int mob_read_sqldb(void) { char line[1024]; - int i,class; + int i,class_; long unsigned int ln=0; char *str[55],*p,*np; - + memset(mob_db,0,sizeof(mob_db)); - + sprintf (tmp_sql, "SELECT * FROM `%s`",mob_db_db); if(mysql_query(&mmysql_handle, tmp_sql) ) { printf("DB server Error (select %s to Memory)- %s\n",mob_db_db,mysql_error(&mmysql_handle) ); @@ -4301,53 +4305,53 @@ static int mob_read_sqldb(void) } else str[i]=p; } - - class=atoi(str[0]); - if(class<=1000 || class>MAX_MOB_DB) + + class_=atoi(str[0]); + if(class_<=1000 || class_>MAX_MOB_DB) continue; - + ln++; - - mob_db[class].view_class=class; - memcpy(mob_db[class].name,str[1],24); - memcpy(mob_db[class].jname,str[2],24); - mob_db[class].lv=atoi(str[3]); - mob_db[class].max_hp=atoi(str[4]); - mob_db[class].max_sp=atoi(str[5]); - mob_db[class].base_exp=atoi(str[6])* + + mob_db[class_].view_class=class_; + memcpy(mob_db[class_].name,str[1],24); + memcpy(mob_db[class_].jname,str[2],24); + mob_db[class_].lv=atoi(str[3]); + mob_db[class_].max_hp=atoi(str[4]); + mob_db[class_].max_sp=atoi(str[5]); + mob_db[class_].base_exp=atoi(str[6])* battle_config.base_exp_rate/100; - if(mob_db[class].base_exp <= 0) - mob_db[class].base_exp = 1; - mob_db[class].job_exp=atoi(str[7])* + if(mob_db[class_].base_exp <= 0) + mob_db[class_].base_exp = 1; + mob_db[class_].job_exp=atoi(str[7])* battle_config.job_exp_rate/100; - if(mob_db[class].job_exp <= 0) - mob_db[class].job_exp = 1; - mob_db[class].range=atoi(str[8]); - mob_db[class].atk1=atoi(str[9]); - mob_db[class].atk2=atoi(str[10]); - mob_db[class].def=atoi(str[11]); - mob_db[class].mdef=atoi(str[12]); - mob_db[class].str=atoi(str[13]); - mob_db[class].agi=atoi(str[14]); - mob_db[class].vit=atoi(str[15]); - mob_db[class].int_=atoi(str[16]); - mob_db[class].dex=atoi(str[17]); - mob_db[class].luk=atoi(str[18]); - mob_db[class].range2=atoi(str[19]); - mob_db[class].range3=atoi(str[20]); - mob_db[class].size=atoi(str[21]); - mob_db[class].race=atoi(str[22]); - mob_db[class].element=atoi(str[23]); - mob_db[class].mode=atoi(str[24]); - mob_db[class].speed=atoi(str[25]); - mob_db[class].adelay=atoi(str[26]); - mob_db[class].amotion=atoi(str[27]); - mob_db[class].dmotion=atoi(str[28]); + if(mob_db[class_].job_exp <= 0) + mob_db[class_].job_exp = 1; + mob_db[class_].range=atoi(str[8]); + mob_db[class_].atk1=atoi(str[9]); + mob_db[class_].atk2=atoi(str[10]); + mob_db[class_].def=atoi(str[11]); + mob_db[class_].mdef=atoi(str[12]); + mob_db[class_].str=atoi(str[13]); + mob_db[class_].agi=atoi(str[14]); + mob_db[class_].vit=atoi(str[15]); + mob_db[class_].int_=atoi(str[16]); + mob_db[class_].dex=atoi(str[17]); + mob_db[class_].luk=atoi(str[18]); + mob_db[class_].range2=atoi(str[19]); + mob_db[class_].range3=atoi(str[20]); + mob_db[class_].size=atoi(str[21]); + mob_db[class_].race=atoi(str[22]); + mob_db[class_].element=atoi(str[23]); + mob_db[class_].mode=atoi(str[24]); + mob_db[class_].speed=atoi(str[25]); + mob_db[class_].adelay=atoi(str[26]); + mob_db[class_].amotion=atoi(str[27]); + mob_db[class_].dmotion=atoi(str[28]); for(i=0;i<8;i++){ int rate = 0,type,ratemin,ratemax; - mob_db[class].dropitem[i].nameid=atoi(str[29+i*2]); - type = itemdb_type(mob_db[class].dropitem[i].nameid); + mob_db[class_].dropitem[i].nameid=atoi(str[29+i*2]); + type = itemdb_type(mob_db[class_].dropitem[i].nameid); if (type == 0) { // Added by Valaris rate = battle_config.item_rate_heal; ratemin = battle_config.item_drop_heal_min; @@ -4375,27 +4379,27 @@ static int mob_read_sqldb(void) } rate = (rate / 100) * atoi(str[30+i*2]); rate = (rate < ratemin)? ratemin: (rate > ratemax)? ratemax: rate; - mob_db[class].dropitem[i].p = rate; + mob_db[class_].dropitem[i].p = rate; } - - mob_db[class].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100; - mob_db[class].mexpper=atoi(str[46]); + + mob_db[class_].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100; + mob_db[class_].mexpper=atoi(str[46]); for(i=0;i<3;i++){ - mob_db[class].mvpitem[i].nameid=atoi(str[47+i*2]); - mob_db[class].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100; + mob_db[class_].mvpitem[i].nameid=atoi(str[47+i*2]); + mob_db[class_].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100; } for(i=0;iareanpc_id=nd->bl.id; npc_event(sd,strcat(name,"::OnTouch"),0); } - free(name); + aFree(name); return 0; } int npc_enable(const char *name,int flag) @@ -92,7 +92,7 @@ int npc_enable(const char *name,int flag) struct npc_data *nd=strdb_search(npcname_db,name); if (nd==NULL) return 0; - + if (flag&1) { // 有効化 nd->flag&=~1; clif_spawnnpc(nd); @@ -132,7 +132,7 @@ int npc_event_dequeue(struct map_session_data *sd) sd->npc_id=0; if (sd->eventqueue[0][0]) { // キューのイベント処理 - char *name=(char *)aCalloc(50,sizeof(char)); + char *name=(char *)aCallocA(50,sizeof(char)); int i; memcpy(name,sd->eventqueue[0],50); @@ -164,9 +164,9 @@ int npc_event_timer(int tid,unsigned int tick,int id,int data) struct map_session_data *sd=map_id2sd(id); if (sd==NULL) return 0; - + npc_event(sd,(const char *)data,0); - free((void*)data); + aFree((void*)data); return 0; } @@ -226,7 +226,7 @@ int npc_timer(int tid,unsigned int tick,int id,int data) // Added by RoVeRT { strdb_foreach(npcname_db,npc_timer_sub); - free((void*)data); + aFree((void*)data); return 0; }*/ /*========================================== @@ -239,14 +239,14 @@ int npc_event_export(void *key,void *data,va_list ap) char *lname=(char *)key; int pos=(int)data; struct npc_data *nd=va_arg(ap,struct npc_data *); - + if ((lname[0]=='O' || lname[0]=='o')&&(lname[1]=='N' || lname[1]=='n')) { struct event_data *ev; char *buf; char *p=strchr(lname,':'); // エクスポートされる ev=aCalloc(sizeof(struct event_data), 1); - buf=aCalloc(50, 1); + buf=aCallocA(50, 1); if (ev==NULL || buf==NULL) { printf("npc_event_export: out of memory !\n"); exit(1); @@ -344,17 +344,17 @@ int npc_event_doall_sub(void *key,void *data,va_list ap) run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id); (*c)++; } - + return 0; } int npc_event_doall(const char *name) { int c=0; char buf[64]="::"; - + strncpy(buf+2,name,62); strdb_foreach(ev_db,npc_event_doall_sub,&c,buf); - return c; + return c; } int npc_event_do_sub(void *key,void *data,va_list ap) @@ -380,7 +380,7 @@ int npc_event_do_sub(void *key,void *data,va_list ap) int npc_event_do(const char *name) { int c=0; - + if (*name==':' && name[1]==':') { return npc_event_doall(name+2); } @@ -400,7 +400,7 @@ int npc_event_do_clock(int tid,unsigned int tick,int id,int data) char buf[64]; char *day=""; int c=0; - + time(&timer); t=localtime(&timer); @@ -413,7 +413,7 @@ int npc_event_do_clock(int tid,unsigned int tick,int id,int data) case 5: day = "Fri"; break; case 6: day = "Sat"; break; } - + if (t->tm_min != ev_tm_b.tm_min ) { sprintf(buf,"OnMinute%02d",t->tm_min); c+=npc_event_doall(buf); @@ -460,7 +460,7 @@ int npc_addeventtimer(struct npc_data *nd,int tick,const char *name) if( nd->eventtimer[i]==-1 ) break; if(iu.scr.timer_event; int j,i=nd->u.scr.timeramount; - if(te==NULL) te=aMalloc(sizeof(struct npc_timerevent_list)); + if(te==NULL) te=aMallocA(sizeof(struct npc_timerevent_list)); else te=aRealloc( te, sizeof(struct npc_timerevent_list) * (i+1) ); if(te==NULL){ printf("npc_timerevent_import: out of memory !\n"); @@ -581,7 +581,7 @@ int npc_timerevent(int tid,unsigned int tick,int id,int data) nd->u.scr.timertick=tick; te=nd->u.scr.timer_event+ nd->u.scr.nexttimer; nd->u.scr.timerid = -1; - + t = nd->u.scr.timer+=data; nd->u.scr.nexttimer++; if( nd->u.scr.timeramount>nd->u.scr.nexttimer ){ @@ -605,7 +605,7 @@ int npc_timerevent_start(struct npc_data *nd, int rid) n=nd->u.scr.timeramount; if( nd->u.scr.nexttimer>=0 || n==0 ) return 0; - + for(j=0;ju.scr.timer_event[j].timer > nd->u.scr.timer ) break; @@ -617,7 +617,7 @@ int npc_timerevent_start(struct npc_data *nd, int rid) nd->u.scr.timertick=gettick(); if (rid >= 0) nd->u.scr.rid=rid; // changed to: attaching to given rid by default [Shinomori] // if rid is less than 0 leave it unchanged [celest] - + next = nd->u.scr.timer_event[j].timer - nd->u.scr.timer; nd->u.scr.timerid = add_timer(gettick()+next,npc_timerevent,nd->bl.id,next); return 0; @@ -743,7 +743,7 @@ int npc_event(struct map_session_data *sd,const char *eventname,int mob_kill) npc_event_dequeue(sd); return 0; } - + sd->npc_id=nd->bl.id; sd->npc_pos=run_script(nd->u.scr.script,ev->pos,sd->bl.id,nd->bl.id); return 0; @@ -764,7 +764,7 @@ int npc_command_sub(void *key,void *data,va_list ap) if (strcmp(command,temp)==0) run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id); } - + return 0; } @@ -793,7 +793,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y) f=0; continue; } - + switch(map[m].npc[i]->bl.subtype) { case WARP: xs=map[m].npc[i]->u.warp.xs; @@ -824,7 +824,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y) break; case SCRIPT: { - char *name=(char *)aCalloc(50,sizeof(char)); + char *name=(char *)aCallocA(50,sizeof(char)); memcpy(name,map[m].npc[i]->name,50); if(sd->areanpc_id==map[m].npc[i]->bl.id) @@ -832,7 +832,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y) sd->areanpc_id=map[m].npc[i]->bl.id; if(npc_event(sd,strcat(name,"::OnTouch"),0)>0) npc_click(sd,map[m].npc[i]->bl.id); - free(name); + aFree(name); break; } } @@ -855,7 +855,7 @@ int npc_checknear(struct map_session_data *sd,int id) printf("no such npc : %d\n",id); return 1; } - + if (nd->class_<0) // イベント系は常にOK return 0; @@ -968,7 +968,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) { struct npc_data *nd; double z; - int i,j,w,skill,itemamount=0,new=0; + int i,j,w,skill,itemamount=0,new_=0; nullpo_retr(3, sd); nullpo_retr(3, item_list); @@ -998,7 +998,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) case ADDITEM_EXIST: break; case ADDITEM_NEW: - new++; + new_++; break; case ADDITEM_OVERAMOUNT: return 2; @@ -1010,7 +1010,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) return 1; // zeny不足 if (w+sd->weight > sd->max_weight) return 2; // 重量超過 - if (pc_inventoryblank(sd)walkpath.path_pos>=nd->walkpath.path_len) clif_fixnpcpos(nd); // When npc stops, retransmission current of a position. - + } return 0; } @@ -1237,7 +1237,7 @@ static int npc_walktimer(int tid,unsigned int tick,int id,int data) if(nd->walktimer != tid){ return 0; } - + nd->walktimer=-1; if(nd->bl.prev == NULL) @@ -1302,7 +1302,7 @@ int npc_stop_walking(struct npc_data *nd,int type) if(nd->state.state == MS_WALK || nd->state.state == MS_IDLE) { int dx=0,dy=0; - + nd->walkpath.path_len=0; if(type&4){ dx=nd->to_x-nd->bl.x; @@ -1352,7 +1352,7 @@ void npc_clearsrcfile() while( p ) { struct npc_src_list *p2=p; p=p->next; - free(p2); + aFree(p2); } npc_src_first=NULL; npc_src_last=NULL; @@ -1363,7 +1363,7 @@ void npc_clearsrcfile() */ void npc_addsrcfile(char *name) { - struct npc_src_list *new; + struct npc_src_list *new_; size_t len; if ( strcmpi(name,"clear")==0 ) { @@ -1382,16 +1382,16 @@ void npc_addsrcfile(char *name) } } - len = sizeof(*new) + strlen(name); - new=(struct npc_src_list *)aCalloc(1,len); - new->next = NULL; - strncpy(new->name,name,strlen(name)+1); + len = sizeof(*new_) + strlen(name); + new_=(struct npc_src_list *)aCalloc(1,len); + new_->next = NULL; + strncpy(new_->name,name,strlen(name)+1); if (npc_src_first==NULL) - npc_src_first = new; + npc_src_first = new_; if (npc_src_last) - npc_src_last->next = new; + npc_src_last->next = new_; - npc_src_last=new; + npc_src_last=new_; } /*========================================== * 読み込むnpcファイルの削除 @@ -1411,7 +1411,7 @@ void npc_delsrcfile(char *name) *lp=p->next; if ( npc_src_last==p ) npc_src_last=pp; - free(p); + aFree(p); break; } } @@ -1525,7 +1525,7 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4) p=strchr(p,','); } if (pos == 0) { - free(nd); + aFree(nd); return 1; } nd->u.shop_item[pos++].nameid = 0; @@ -1545,7 +1545,7 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4) nd->opt1 = 0; nd->opt2 = 0; nd->opt3 = 0; - + nd = (struct npc_data *)aRealloc(nd, sizeof(struct npc_data) + sizeof(nd->u.shop_item[0]) * pos); @@ -1572,14 +1572,14 @@ int npc_convertlabel_db(void *key,void *data,va_list ap) struct npc_label_list *lst; int num; char *p=strchr(lname,':'); - + nullpo_retr(0, ap); nullpo_retr(0, nd=va_arg(ap,struct npc_data *)); lst=nd->u.scr.label_list; num=nd->u.scr.label_list_num; if(!lst){ - lst=(struct npc_label_list *)aCalloc(1,sizeof(struct npc_label_list)); + lst=(struct npc_label_list *)aCallocA(1,sizeof(struct npc_label_list)); num=0; }else lst=(struct npc_label_list *)aRealloc(lst,sizeof(struct npc_label_list)*(num+1)); @@ -1598,7 +1598,7 @@ int npc_convertlabel_db(void *key,void *data,va_list ap) */ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line,FILE *fp,int *lines) { - int x,y,dir=0,m,xs=0,ys=0,class=0; // [Valaris] thanks to fov + int x,y,dir=0,m,xs=0,ys=0,class_=0; // [Valaris] thanks to fov char mapname[24]; unsigned char *srcbuf=NULL,*script; int srcsize=65536; @@ -1627,7 +1627,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line if(strcmp(w2,"script")==0){ // スクリプトの解析 - srcbuf=(char *)aCalloc(srcsize,sizeof(char)); + srcbuf=(char *)aCallocA(srcsize,sizeof(char)); if (strchr(first_line,'{')) { strcpy(srcbuf,strchr(first_line,'{')); startline=*lines; @@ -1657,13 +1657,13 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line script=parse_script(srcbuf,startline); if (script==NULL) { // script parse error? - free(srcbuf); + aFree(srcbuf); return 1; } }else{ // duplicateする - + char srcname[128]; struct npc_data *nd2; if( sscanf(w2,"duplicate(%[^)])",srcname)!=1 ){ @@ -1678,22 +1678,22 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line label_dup=nd2->u.scr.label_list; label_dupnum=nd2->u.scr.label_list_num; src_id=nd2->bl.id; - + }// end of スクリプト解析 nd=(struct npc_data *)aCalloc(1,sizeof(struct npc_data)); if(m==-1){ // スクリプトコピー用のダミーNPC - - }else if( sscanf(w4,"%d,%d,%d",&class,&xs,&ys)==3) { + + }else if( sscanf(w4,"%d,%d,%d",&class_,&xs,&ys)==3) { // 接触型NPC int i,j; - + if (xs>=0)xs=xs*2+1; if (ys>=0)ys=ys*2+1; - - if (class>=0) { + + if (class_>=0) { for(i=0;iu.scr.xs=xs; nd->u.scr.ys=ys; } else { // クリック型NPC - class=atoi(w4); + class_=atoi(w4); nd->u.scr.xs=0; nd->u.scr.ys=0; } - - if (class<0 && m>=0) { // イベント型NPC + + if (class_<0 && m>=0) { // イベント型NPC evflag=1; } @@ -1735,7 +1735,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line nd->bl.id=npc_get_new_npc_id(); nd->dir = dir; nd->flag=0; - nd->class_=class; + nd->class_=class_; nd->speed=200; nd->u.scr.script=script; nd->u.scr.src_id=src_id; @@ -1766,21 +1766,21 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line //----------------------------------------- - // ラベルデータの準備 + // ラベルデータの準備 if(srcbuf){ // script本体がある場合の処理 - + // ラベルデータのコンバート label_db=script_get_label_db(); strdb_foreach(label_db,npc_convertlabel_db,nd); - + // もう使わないのでバッファ解放 - free(srcbuf); + aFree(srcbuf); }else{ // duplicate -// nd->u.scr.label_list=aMalloc(sizeof(struct npc_label_list)*label_dupnum); +// nd->u.scr.label_list=aMallocA(sizeof(struct npc_label_list)*label_dupnum); // memcpy(nd->u.scr.label_list,label_dup,sizeof(struct npc_label_list)*label_dupnum); nd->u.scr.label_list=label_dup; // ラベルデータ共有 @@ -1792,13 +1792,13 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line for(i=0;iu.scr.label_list_num;i++){ char *lname=nd->u.scr.label_list[i].name; int pos=nd->u.scr.label_list[i].pos; - + if ((lname[0]=='O' || lname[0]=='o')&&(lname[1]=='N' || lname[1]=='n')) { struct event_data *ev; char *buf; // エクスポートされる ev=(struct event_data *)aCalloc(1,sizeof(struct event_data)); - buf=(char *)aCalloc(50,sizeof(char)); + buf=(char *)aCallocA(50,sizeof(char)); if (strlen(lname)>24) { printf("npc_parse_script: label name error !\n"); exit(1); @@ -1810,7 +1810,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line } } } - + //----------------------------------------- // ラベルデータからタイマーイベント取り込み for(i=0;iu.scr.label_list_num;i++){ @@ -1822,7 +1822,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line struct npc_timerevent_list *te=nd->u.scr.timer_event; int j,k=nd->u.scr.timeramount; if(te==NULL) - te=(struct npc_timerevent_list *)aCalloc(1,sizeof(struct npc_timerevent_list)); + te=(struct npc_timerevent_list *)aCallocA(1,sizeof(struct npc_timerevent_list)); else te=(struct npc_timerevent_list *)aRealloc( te, sizeof(struct npc_timerevent_list) * (k+1) ); for(j=0;ju.scr.nexttimer=-1; nd->u.scr.timerid=-1; - + return 0; } @@ -1859,7 +1859,7 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li char *p; // スクリプトの解析 - srcbuf=(char *)aCalloc(srcsize,sizeof(char)); + srcbuf=(char *)aCallocA(srcsize,sizeof(char)); if (strchr(first_line,'{')) { strcpy(srcbuf,strchr(first_line,'{')); startline=*lines; @@ -1889,11 +1889,11 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li script=parse_script(srcbuf,startline); if (script==NULL) { // script parse error? - free(srcbuf); + aFree(srcbuf); return 1; } - p=(char *)aCalloc(50,sizeof(char)); + p=(char *)aCallocA(50,sizeof(char)); strncpy(p,w3,50); strdb_insert(script_get_userfunc_db(),p,script); @@ -1901,10 +1901,10 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li // label_db=script_get_label_db(); // もう使わないのでバッファ解放 - free(srcbuf); - + aFree(srcbuf); + // printf("function %s => %p\n",p,script); - + return 0; } @@ -1915,7 +1915,7 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li */ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) { - int m,x,y,xs,ys,class,num,delay1,delay2,level; + int m,x,y,xs,ys,class_,num,delay1,delay2,level; int i; char mapname[24]; char mobname[24]; @@ -1926,7 +1926,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) delay1=delay2=0; // 引数の個数チェック if (sscanf(w1,"%[^,],%d,%d,%d,%d",mapname,&x,&y,&xs,&ys) < 3 || - sscanf(w4,"%d,%d,%d,%d,%s",&class,&num,&delay1,&delay2,eventname) < 2 ) { + sscanf(w4,"%d,%d,%d,%d,%s",&class_,&num,&delay1,&delay2,eventname) < 2 ) { printf("bad monster line : %s\n",w3); return 1; } @@ -1941,13 +1941,13 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) for(i=0;i4000) { // large/tiny mobs [Valaris] + if(class_>4000) { // large/tiny mobs [Valaris] md->size=2; - class-=4000; + class_-=4000; } - else if(class>2000) { + else if(class_>2000) { md->size=1; - class-=2000; + class_-=2000; } md->bl.prev=NULL; @@ -1958,9 +1958,9 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) if(sscanf(w3,"%[^,],%d",mobname,&level) > 1) { if(strcmp(mobname,"--en--")==0) - memcpy(md->name,mob_db[class].name,24); + memcpy(md->name,mob_db[class_].name,24); else if(strcmp(mobname,"--ja--")==0) - memcpy(md->name,mob_db[class].jname,24); + memcpy(md->name,mob_db[class_].jname,24); md->level=level; } @@ -1968,7 +1968,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) memcpy(md->name,w3,24); md->n = i; - md->base_class = md->class_ = class; + md->base_class = md->class_ = class_; md->bl.id=npc_get_new_npc_id(); md->m =m; md->x0=x; @@ -1982,9 +1982,9 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4) md->timer = -1; md->target_id=0; md->attacked_id=0; - md->speed=mob_db[class].speed; + md->speed=mob_db[class_].speed; - if (mob_db[class].mode&0x02) + if (mob_db[class_].mode&0x02) md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item)); else md->lootitem=NULL; @@ -2122,19 +2122,19 @@ static int npc_parse_mapflag(char *w1,char *w2,char *w3,char *w4) } else if (strcmpi(w3,"noicewall")==0) { // noicewall [Valaris] map[m].flag.noicewall=1; - } + } else if (strcmpi(w3,"snow")==0) { // snow [Valaris] map[m].flag.snow=1; - } + } else if (strcmpi(w3,"fog")==0) { // fog [Valaris] map[m].flag.fog=1; - } + } else if (strcmpi(w3,"sakura")==0) { // sakura [Valaris] map[m].flag.sakura=1; - } + } else if (strcmpi(w3,"leaves")==0) { // leaves [Valaris] map[m].flag.leaves=1; - } + } else if (strcmpi(w3,"rain")==0) { // rain [Valaris] map[m].flag.rain=1; } @@ -2144,7 +2144,7 @@ static int npc_parse_mapflag(char *w1,char *w2,char *w3,char *w4) else if (strcmpi(w3,"nogo")==0) { // celest map[m].flag.nogo=1; } - + return 0; } @@ -2169,12 +2169,12 @@ static int npc_read_indoors(void) if ((m = map_mapname2mapid(map_name)) >= 0) map[m].flag.indoors=1; } - + p=strchr(p,10); if(!p) break; p++; } - free(buf); + aFree(buf); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\indoorrswtable.txt"); ShowStatus(tmp_output); @@ -2183,9 +2183,9 @@ static int npc_read_indoors(void) static int ev_db_final(void *key,void *data,va_list ap) { - free(data); + aFree(data); if(strstr(key,"::")!=NULL) - free(key); + aFree(key); return 0; } static int npcname_db_final(void *key,void *data,va_list ap) @@ -2214,49 +2214,49 @@ int do_final_npc(void) if((bl=map_id2bl(i))){ if(bl->type == BL_NPC && (nd = (struct npc_data *)bl)){ if(nd->chat_id && (cd=(struct chat_data*)map_id2bl(nd->chat_id))){ - free(cd); + aFree(cd); cd = NULL; } if(nd->bl.subtype == SCRIPT){ if(nd->u.scr.timer_event) - free(nd->u.scr.timer_event); + aFree(nd->u.scr.timer_event); if(nd->u.scr.src_id==0){ if(nd->u.scr.script){ - free(nd->u.scr.script); + aFree(nd->u.scr.script); nd->u.scr.script=NULL; } if(nd->u.scr.label_list){ - free(nd->u.scr.label_list); + aFree(nd->u.scr.label_list); nd->u.scr.label_list = NULL; } } } - free(nd); + aFree(nd); nd = NULL; }else if(bl->type == BL_MOB && (md = (struct mob_data *)bl)){ if(md->lootitem){ - free(md->lootitem); + aFree(md->lootitem); md->lootitem = NULL; } - free(md); + aFree(md); md = NULL; }else if(bl->type == BL_PET && (pd = (struct pet_data *)bl)){ - free(pd); + aFree(pd); pd = NULL; } } } - + return 0; } -void ev_release(struct dbn *db, int which) +void ev_release(struct dbn *db, int which) { if (which & 0x1) - free(db->key); + aFree(db->key); if (which & 0x2) - free(db->data); + aFree(db->data); } /*========================================== @@ -2281,12 +2281,12 @@ int do_init_npc(void) npcname_db=strdb_init(24); ev_db->release = ev_release; - + memset(&ev_tm_b,-1,sizeof(ev_tm_b)); for(nsl=npc_src_first;nsl;nsl=nsl->next) { /*if(nsl->prev){ // [Shinomori] - free(nsl->prev); + aFree(nsl->prev); nsl->prev = NULL; }*/ fp=fopen(nsl->name,"r"); diff --git a/src/map/party.c b/src/map/party.c index 28f05bab9..3c3c12886 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -30,7 +30,7 @@ int party_send_xyhp_timer(int tid,unsigned int tick,int id,int data); */ static int party_db_final(void *key,void *data,va_list ap) { - free(data); + aFree(data); return 0; } void do_final_party(void) diff --git a/src/map/pc.c b/src/map/pc.c index 2954dfddf..c17e8677b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -87,11 +87,11 @@ int pc_isGM(struct map_session_data *sd) { if (p == NULL) return 0; return p->level;*/ - + //For console [Wizputer] if ( sd->fd == 0 ) return 99; - + for(i = 0; i < GM_num; i++) if (gm_account[i].account_id == sd->status.account_id) return gm_account[i].level; @@ -218,7 +218,7 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) { sd->spiritball = 0; if(sd->spiritball >= max) { - if(sd->spirit_timer[0] != -1) + if(sd->spirit_timer[0] != -1) delete_timer(sd->spirit_timer[0],pc_spiritball_timer); memcpy( &sd->spirit_timer[0], &sd->spirit_timer[1], sizeof(sd->spirit_timer[0]) * (sd->spiritball - 1)); } else @@ -554,7 +554,7 @@ int pc_isequip(struct map_session_data *sd,int n) item = sd->inventory_data[n]; sc_data = battle_get_sc_data(&sd->bl); - //s_class = pc_calc_base_job(sd->status.class); + //s_class = pc_calc_base_job(sd->status.class_); if( battle_config.gm_allequip>0 && pc_isGM(sd)>=battle_config.gm_allequip ) return 1; @@ -599,7 +599,7 @@ int pc_break_equip(struct map_session_data *sd, unsigned short where) struct item_data* item; int i; int sc; - char output[255]; + char output[255]; if(sd == NULL) return -1; @@ -669,7 +669,7 @@ int pc_breakweapon(struct map_session_data *sd) return 1; } } - + return 0; } /*========================================== @@ -755,7 +755,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->skillitem = -1; sd->skillitemlv = -1; sd->invincible_timer = -1; - + sd->deal_locked = 0; sd->trade_partner = 0; @@ -772,7 +772,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->doridori_counter = 0; - sd->change_level = pc_readglobalreg(sd,"jobchange_level"); + sd->change_level = pc_readglobalreg(sd,"jobchange_level"); #ifndef TXT_ONLY // mail system [Valaris] if(battle_config.mail_system) @@ -790,7 +790,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->dev.val1[i] = 0; sd->dev.val2[i] = 0; } - + // アカウント??の送信要求 intif_request_accountreg(sd); @@ -876,7 +876,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars sd->state.event_death = pc_readglobalreg(sd,"PCDieEvent"); sd->state.event_kill = pc_readglobalreg(sd,"PCKillEvent"); sd->state.event_disconnect = pc_readglobalreg(sd,"PCLogoffEvent"); - + if (night_flag == 1 && !map[sd->bl.m].flag.indoors) { char tmpstr[1024]; strcpy(tmpstr, msg_txt(500)); // Actually, it's the night... @@ -1016,7 +1016,7 @@ int pc_calc_skilltree(struct map_session_data *sd) for(i=0;istatus.skill[i].flag != 13) + if (sd->status.skill[i].flag != 13) sd->status.skill[i].id=0; if (sd->status.skill[i].flag && sd->status.skill[i].flag != 13){ // cardスキルなら、 sd->status.skill[i].lv=(sd->status.skill[i].flag==1)?0:sd->status.skill[i].flag-2; // 本?のlvに @@ -1030,13 +1030,13 @@ int pc_calc_skilltree(struct map_session_data *sd) sd->status.skill[i].id=i; for(i=210;i<291;i++) sd->status.skill[i].id=i; - for(i=304;i<337;i++){ + for(i=304;i<338;i++){ if(i==331) continue; sd->status.skill[i].id=i; } if(battle_config.enable_upper_class){ //confで無?でなければ?み?む - for(i=355;istatus.skill[i].id=i; + for(i=355;i<411;i++) + sd->status.skill[i].id=i; } }else{ do { @@ -1052,6 +1052,8 @@ int pc_calc_skilltree(struct map_session_data *sd) break; } } + if (id >= 2 && id <= 53 && pc_checkskill(sd, NV_BASIC) < 9) + f=0; } if(f && sd->status.skill[id].id==0 ){ sd->status.skill[id].id=id; @@ -1073,7 +1075,7 @@ int pc_calc_skilltree_normalize_job(int c, struct map_session_data *sd) { c = 0; //else if((sd->status.skill_point >= sd->status.job_level && skill_point < 58) && ((c > 6 && c < 23) || (c > 4007 && c < 4023) || (c > 4029 && c < 4045))) { //else if ((sd->status.skill_point >= sd->status.job_level && skill_point < 58) && (c > 6 && c < 23)) { - else if ((sd->status.skill_point >= sd->status.job_level && skill_point < sd->change_level+8) && (c > 6 && c < 23)) { + else if (sd->status.skill_point >= sd->status.job_level && ((sd->change_level > 0 && skill_point < sd->change_level+8) || skill_point < 58) && (c > 6 && c < 23)) { switch(c) { case 7: case 13: @@ -1178,7 +1180,7 @@ int pc_checkweighticon(struct map_session_data *sd) flag=1; if(sd->weight*10 >= sd->max_weight*9) flag=2; - + if(flag==1){ if(sd->sc_data[SC_WEIGHT50].timer==-1) skill_status_change_start(&sd->bl,SC_WEIGHT50,0,0,0,0,0,0); @@ -1670,6 +1672,16 @@ int pc_calcstatus(struct map_session_data* sd,int first) sd->paramb[5] += sd->status.luk+psd->status.luk/2 > 99 ? 99-sd->status.luk : psd->status.luk/2; } } + if(sd->sc_data[SC_GOSPEL].timer!=-1 && sd->sc_data[SC_GOSPEL].val4 == BCT_PARTY){ + if (sd->sc_data[SC_GOSPEL].val3 == 6) { + sd->paramb[0]+= 2; + sd->paramb[1]+= 2; + sd->paramb[2]+= 2; + sd->paramb[3]+= 2; + sd->paramb[4]+= 2; + sd->paramb[5]+= 2; + } + } } //1度も死んでないJob70スパノビに+10 @@ -1769,7 +1781,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) else if (pc_isriding(sd)) { // ペコペコ?りによる速度?加 sd->speed -= (0.25 * DEFAULT_WALK_SPEED); sd->max_weight += 10000; - } + } if((skill=pc_checkskill(sd,CR_TRUST))>0) { // フェイス sd->status.max_hp += skill*200; sd->subele[6] += skill*5; @@ -1788,7 +1800,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) sd->status.max_hp = sd->status.max_hp * 130/100; else if (s_class.upper==2) sd->status.max_hp = sd->status.max_hp * 70/100; - + if(sd->hprate!=100) sd->status.max_hp = sd->status.max_hp*sd->hprate/100; @@ -1910,6 +1922,13 @@ int pc_calcstatus(struct map_session_data* sd,int first) } if(sd->sc_data[SC_POISON].timer!=-1) // 毒?態 sd->def2 = sd->def2*75/100; + if(sd->sc_data[SC_CURSE].timer!=-1){ + sd->base_atk = sd->base_atk*75/100; + sd->watk = sd->watk*75/100; + index = sd->equip_index[8]; + if(index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == 4) + sd->watk_ = sd->watk_*75/100; + } if(sd->sc_data[SC_DRUMBATTLE].timer!=-1){ // ?太鼓の響き sd->watk += sd->sc_data[SC_DRUMBATTLE].val2; sd->def += sd->sc_data[SC_DRUMBATTLE].val3; @@ -2113,8 +2132,62 @@ int pc_calcstatus(struct map_session_data* sd,int first) sd->def = 100; if(sd->sc_data[SC_BARRIER].timer!=-1) sd->mdef = 100; + + if(sd->sc_data[SC_GOSPEL].timer!=-1) { + if (sd->sc_data[SC_GOSPEL].val4 == BCT_PARTY){ + switch (sd->sc_data[SC_GOSPEL].val3) + { + case 4: + sd->status.max_hp += sd->status.max_hp * 25 / 100; + if(sd->status.max_hp > battle_config.max_hp) + sd->status.max_hp = battle_config.max_hp; + break; + case 5: + sd->status.max_sp += sd->status.max_sp * 25 / 100; + if(sd->status.max_sp > battle_config.max_sp) + sd->status.max_sp = battle_config.max_sp; + break; + case 11: + sd->def += sd->def * 25 / 100; + sd->def2 += sd->def2 * 25 / 100; + break; + case 12: + sd->base_atk += sd->base_atk * 8 / 100; + break; + case 13: + sd->flee += sd->flee * 5 / 100; + break; + case 14: + sd->hit += sd->hit * 5 / 100; + break; + } + } else if (sd->sc_data[SC_GOSPEL].val4 == BCT_ENEMY){ + switch (sd->sc_data[SC_GOSPEL].val3) + { + case 5: + sd->def = 0; + sd->def2 = 0; + break; + case 6: + sd->base_atk = 0; + sd->watk = 0; + sd->watk2 = 0; + break; + case 7: + sd->flee = 0; + break; + case 8: + sd->speed_rate += 75; + aspd_rate += 75; + break; + } + } + } } + if (sd->speed_rate <= 0) + sd->speed_rate = 1; + if(sd->speed_rate != 100) sd->speed = sd->speed*sd->speed_rate/100; if(sd->speed < 1) sd->speed = 1; @@ -2216,7 +2289,7 @@ int pc_calcstatus(struct map_session_data* sd,int first) clif_updatestatus(sd,SP_CARTINFO);*/ //if(sd->status.hpstatus.max_hp>>2 && pc_checkskill(sd,SM_AUTOBERSERK)>0 && - if(sd->status.hpstatus.max_hp>>2 && sd->sc_data[SC_AUTOBERSERK].timer != -1 && + if(sd->status.hpstatus.max_hp>>2 && sd->sc_data[SC_AUTOBERSERK].timer != -1 && (sd->sc_data[SC_PROVOKE].timer==-1 || sd->sc_data[SC_PROVOKE].val2==0 ) && !pc_isdead(sd)) // オ?トバ?サ?ク?動 skill_status_change_start(&sd->bl,SC_PROVOKE,10,1,0,0,0,0); @@ -2239,7 +2312,7 @@ int pc_calcspeed (struct map_session_data *sd) b_speed = sd->speed; sd->speed = DEFAULT_WALK_SPEED ; - + if(sd->sc_count){ if(sd->sc_data[SC_INCREASEAGI].timer!=-1 && sd->sc_data[SC_QUAGMIRE].timer == -1 && sd->sc_data[SC_DONTFORGETME].timer == -1){ // 速度?加 sd->speed -= sd->speed *25/100; @@ -2303,7 +2376,7 @@ int pc_calcspeed (struct map_session_data *sd) if(sd->speed_rate != 100) sd->speed = sd->speed*sd->speed_rate/100; if(sd->speed < 1) sd->speed = 1; - + if(sd->skilltimer != -1 && (skill = pc_checkskill(sd,SA_FREECAST)) > 0) { sd->prev_speed = sd->speed; sd->speed = sd->speed*(175 - skill*5)/100; @@ -2932,7 +3005,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag !=2){ sd->random_attack_increase_add = type2; sd->random_attack_increase_per += val; - } + } break; case SP_WEAPON_ATK: if(sd->state.lr_flag != 2) @@ -3662,7 +3735,7 @@ int pc_item_refine(struct map_session_data *sd,int idx) int flag = 1, i = 0, ep = 0, per; int material[5] = { 0, 1010, 1011, 984, 984 }; struct item *item; - + nullpo_retr(0, sd); item = &sd->status.inventory[idx]; @@ -3681,7 +3754,7 @@ int pc_item_refine(struct map_session_data *sd,int idx) per = percentrefinery [itemdb_wlv (item->nameid)][(int)item->refine]; //per += pc_checkskill(sd,BS_WEAPONRESEARCH); per *= (75 + sd->status.job_level/2)/100; - + if (per > rand() % 100) { flag = 0; item->refine++; @@ -3691,7 +3764,7 @@ int pc_item_refine(struct map_session_data *sd,int idx) pc_unequipitem(sd,idx,3); } clif_refine(sd->fd,sd,0,idx,item->refine); - clif_delitem(sd,idx,1); + clif_delitem(sd,idx,1); clif_additem(sd,idx,1,0); if (ep) pc_equipitem(sd,idx,ep); @@ -3777,7 +3850,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl) if(itemid > 0 && itemdb_type(itemid) != 6) { rate = (mob_db[md->class_].dropitem[i].p / battle_config.item_rate_common * 100 * skill)/100; - + if(rand()%10000 < rate) { struct item tmp_item; @@ -3882,7 +3955,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt if(sd->sc_data[SC_DANCING].timer!=-1) // clear dance effect when warping [Valaris] skill_stop_dancing(&sd->bl,0); } - + if(sd->status.option&2) skill_status_change_end(&sd->bl, SC_HIDING, -1); if(sd->status.option&4) @@ -3894,7 +3967,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt pet_stopattack(sd->pd); pet_changestate(sd->pd,MS_IDLE,0); } - + if(sd->disguise) { // clear disguises when warping [Valaris] clif_clearchar(&sd->bl, 9); disguise=sd->disguise; @@ -4000,13 +4073,13 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt if(disguise) // disguise teleport fix [Valaris] sd->disguise=disguise; - + memcpy(sd->mapname,mapname,24); sd->bl.m = m; sd->to_x = x; sd->to_y = y; - // moved and changed dance effect stopping + // moved and changed dance effect stopping sd->bl.x = x; sd->bl.y = y; @@ -4336,19 +4409,19 @@ int pc_walktoxy(struct map_session_data *sd,int x,int y) if (sd->sc_data && sd->status.guild_id > 0) { struct skill_unit *su; struct skill_unit_group *sg; - if (sd->state.leadership_flag && (su=(struct skill_unit *)sd->state.leadership_flag) && + if (sd->state.leadership_flag && (su=(struct skill_unit *)sd->state.leadership_flag) && (sg=su->group) && sg->src_id == sd->bl.id) { skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y)); } - if (sd->state.glorywounds_flag && (su=(struct skill_unit *)sd->state.glorywounds_flag) && + if (sd->state.glorywounds_flag && (su=(struct skill_unit *)sd->state.glorywounds_flag) && (sg=su->group) && sg->src_id == sd->bl.id) { skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y)); } - if (sd->state.soulcold_flag && (su=(struct skill_unit *)sd->state.soulcold_flag) && + if (sd->state.soulcold_flag && (su=(struct skill_unit *)sd->state.soulcold_flag) && (sg=su->group) && sg->src_id == sd->bl.id) { skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y)); } - if (sd->state.hawkeyes_flag && (su=(struct skill_unit *)sd->state.hawkeyes_flag) && + if (sd->state.hawkeyes_flag && (su=(struct skill_unit *)sd->state.hawkeyes_flag) && (sg=su->group) && sg->src_id == sd->bl.id) { skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y)); } @@ -4392,7 +4465,7 @@ int pc_randomwalk(struct map_session_data *sd,int tick) { const int retrycount = 20; nullpo_retr(0, sd); - + if(DIFF_TICK(sd->next_walktime,tick)<0){ int i,x,y,d; d = rand()%7+5; @@ -4608,7 +4681,7 @@ struct pc_base_job pc_calc_base_job(int b_class) }else{ bj.type = 2; } - + return bj; } @@ -4624,7 +4697,7 @@ int pc_calc_base_job2 (int b_class) return b_class - 4001; else if(b_class == 4045) return 23; - return b_class - 4023; + return b_class - 4023; } int pc_calc_upper(int b_class) @@ -4668,8 +4741,12 @@ int pc_attack_timer(int tid,unsigned int tick,int id,int data) if(bl==NULL || bl->prev == NULL) return 0; - if(bl->type == BL_PC && pc_isdead((struct map_session_data *)bl)) - return 0; + if(bl->type == BL_PC) { + if (pc_isdead((struct map_session_data *)bl)) + return 0; + else if (pc_ishiding((struct map_session_data *)bl)) + return 0; + } // 同じmapでないなら攻?しない // PCが死んでても攻?しない @@ -4685,7 +4762,7 @@ int pc_attack_timer(int tid,unsigned int tick,int id,int data) return 0; if(sd->sc_data[SC_BLADESTOP].timer != -1) return 0; - } + } //if((opt = battle_get_option(bl)) != NULL && *opt&0x46) if((opt = battle_get_option(bl)) != NULL && *opt&0x42) @@ -4774,13 +4851,13 @@ int pc_attack(struct map_session_data *sd,int target_id,int type) return 1; sd->idletime = tick_; - + if(bl->type==BL_NPC) { // monster npcs [Valaris] //npc_click(sd,RFIFOL(sd->fd,2)); npc_click(sd,target_id); // submitted by leinsirk10 [Celest] return 0; } - + if(!battle_check_target(&sd->bl,bl,BCT_ENEMY)) return 1; if(sd->attacktimer != -1) @@ -4972,7 +5049,7 @@ int pc_gainexp(struct map_session_data *sd,int base_exp,int job_exp) sd->status.base_exp += base_exp; if(sd->status.base_exp < 0) sd->status.base_exp = 0; - + while(pc_checkbaselevelup(sd)) ; clif_updatestatus(sd,SP_BASEEXP); @@ -4985,13 +5062,13 @@ int pc_gainexp(struct map_session_data *sd,int base_exp,int job_exp) sd->status.job_exp += job_exp; if(sd->status.job_exp < 0) sd->status.job_exp = 0; - + while(pc_checkjoblevelup(sd)) ; clif_updatestatus(sd,SP_JOBEXP); if(battle_config.disp_experience){ - sprintf(output, + sprintf(output, "Experienced Gained Base:%d Job:%d",base_exp,job_exp); clif_disp_onlyself(sd,output,strlen(output)); } @@ -5124,7 +5201,7 @@ int pc_need_status_point(struct map_session_data *sd,int type) int pc_statusup(struct map_session_data *sd,int type) { int max, need,val = 0; - + nullpo_retr(0, sd); max = (pc_calc_upper(sd->status.class_)==2) ? 80 : battle_config.max_parameter; @@ -5326,17 +5403,21 @@ int pc_allskillup(struct map_session_data *sd) sd->status.skill[i].lv=skill_get_max(i); for(i=210;i<291;i++) sd->status.skill[i].lv=skill_get_max(i); - for(i=304;istatus.skill[i].lv=skill_get_max(i); } + if(battle_config.enable_upper_class){ //confで無?でなければ?み?む + for(i=355;i<411;i++) + sd->status.skill[i].id=i; + } } else { for(i=0;(id=skill_tree[s][c][i].id)>0;i++){ if(sd->status.skill[id].id==0 && (!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn) ) { sd->status.skill[id].id = id; // celest // sd->status.skill[id].lv=skill_get_max(id); - sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); // celest + sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); // celest } } } @@ -5352,9 +5433,9 @@ int pc_allskillup(struct map_session_data *sd) int pc_resetlvl(struct map_session_data* sd,int type) { int i; - + nullpo_retr(0, sd); - + for(i=1;istatus.skill[i].lv = 0; } @@ -5395,7 +5476,7 @@ int pc_resetlvl(struct map_session_data* sd,int type) if(type == 4){ sd->status.job_level=1; sd->status.job_exp=0; - } + } clif_updatestatus(sd,SP_STATUSPOINT); clif_updatestatus(sd,SP_STR); @@ -5444,7 +5525,7 @@ int pc_resetstate(struct map_session_data* sd) sd->status.status_point = atoi (statp[sd->status.base_level - 1]); if(sd->status.class_ >= 4001 && sd->status.class_ <= 4024) sd->status.status_point+=52; // extra 52+48=100 stat points -// End addition +// End addition // Removed by Dexity - old count // add += sumsp(sd->status.str); @@ -5794,7 +5875,7 @@ int pc_readparam(struct map_session_data *sd,int type) { int val=0; struct pc_base_job s_class; - + s_class = pc_calc_base_job(sd->status.class_); nullpo_retr(0, sd); @@ -6208,12 +6289,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) int b_class = 0; //?生や養子の場合の元の職業を算出する struct pc_base_job s_class = pc_calc_base_job(sd->status.class_); - + nullpo_retr(0, sd); if (upper < 0 || upper > 2) //現在?生かどうかを判?する upper = s_class.upper; - + b_class = job; //通常職ならjobそのまんま if (job < 23) { if (upper == 1) @@ -6248,8 +6329,8 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) else sd->change_level = 0; - pc_setglobalreg (sd, "jobchange_level", sd->change_level); - + pc_setglobalreg (sd, "jobchange_level", sd->change_level); + sd->status.class_ = sd->view_class = b_class; sd->status.job_level=1; @@ -6276,12 +6357,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) clif_equiplist(sd); if(pc_isriding(sd)) { // remove peco status if changing into invalid class [Valaris] - if(!(pc_checkskill(sd,KN_RIDING))) + if(!(pc_checkskill(sd,KN_RIDING))) pc_setoption(sd,sd->status.option|-0x0000); if(pc_checkskill(sd,KN_RIDING)>0) pc_setriding(sd); } - + return 0; } @@ -6418,13 +6499,13 @@ int pc_setriding(struct map_session_data *sd) if(sd->status.class_==7) sd->status.class_=sd->view_class=13; - + if(sd->status.class_==14) sd->status.class_=sd->view_class=21; - + if(sd->status.class_==4008) sd->status.class_=sd->view_class=4014; - + if(sd->status.class_==4015) sd->status.class_=sd->view_class=4022; } @@ -6772,7 +6853,7 @@ int pc_eventtimer(int tid,unsigned int tick,int id,int data) break; } } - free((void *)data); + aFree((void *)data); if(i==MAX_EVENTTIMER) { if(battle_config.error_log) printf("pc_eventtimer: no such event timer\n"); @@ -6795,7 +6876,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) if( sd->eventtimer[i]==-1 ) break; if(ieventtimer[i]=add_timer(gettick()+tick, pc_eventtimer,sd->bl.id,(int)evname); @@ -7035,7 +7116,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos) */ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { - nullpo_retr(0, sd); + nullpo_retr(0, sd); // -- moonsoul (if player is berserk then cannot unequip) // @@ -7243,7 +7324,7 @@ int pc_calc_pvprank(struct map_session_data *sd) nullpo_retr(0, sd); nullpo_retr(0, m=&map[sd->bl.m]); - + old=sd->pvp_rank; if( !(m->flag.pvp) ) @@ -7385,8 +7466,8 @@ static int pc_spheal(struct map_session_data *sd) if(gc) { struct guild *g; g=guild_search(sd->status.guild_id); - if(g && g->guild_id == gc->guild_id) - a += a; + if(g && g->guild_id == gc->guild_id) + a += a; } // end addition [Valaris] return a; @@ -7415,8 +7496,8 @@ static int pc_hpheal(struct map_session_data *sd) if(gc) { struct guild *g; g=guild_search(sd->status.guild_id); - if(g && g->guild_id == gc->guild_id) - a += a; + if(g && g->guild_id == gc->guild_id) + a += a; } // end addition [Valaris] return a; @@ -7680,8 +7761,8 @@ static int pc_natural_heal_sub(struct map_session_data *sd,va_list ap) { // -- moonsoul (if conditions below altered to disallow natural healing if under berserk status) if ((battle_config.natural_heal_weight_rate > 100 || sd->weight*100/sd->max_weight < battle_config.natural_heal_weight_rate) && - !pc_isdead(sd) && - !pc_ishiding(sd) && + !pc_isdead(sd) && + !pc_ishiding(sd) && //-- cannot regen for 5 minutes after using Berserk --- [Celest] DIFF_TICK (gettick(), sd->canregen_tick)>=0 && (sd->sc_data && !(sd->sc_data[SC_POISON].timer != -1 && sd->sc_data[SC_SLOWPOISON].timer == -1) && @@ -7746,7 +7827,7 @@ static int pc_autosave_sub(struct map_session_data *sd,va_list ap) { nullpo_retr(0, sd); - Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); + Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); if(save_flag==0 && sd->fd>last_save_fd){ struct guild_castle *gc=NULL; @@ -7807,10 +7888,10 @@ int pc_read_gm_account(int fd) int i = 0; #endif if (gm_account != NULL) - free(gm_account); + aFree(gm_account); GM_num = 0; #ifdef TXT_ONLY - gm_account = aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); + gm_account = aCallocA(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); for (i = 4; i < RFIFOW(fd,2); i = i + 5) { gm_account[GM_num].account_id = RFIFOL(fd,i); gm_account[GM_num].level = (int)RFIFOB(fd,i+4); @@ -7824,7 +7905,7 @@ int pc_read_gm_account(int fd) } lsql_res = mysql_store_result(&lmysql_handle); if (lsql_res) { - gm_account = aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); + gm_account = aCallocA(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1); while ((lsql_row = mysql_fetch_row(lsql_res))) { gm_account[GM_num].account_id = atoi(lsql_row[0]); gm_account[GM_num].level = atoi(lsql_row[1]); @@ -7832,7 +7913,7 @@ int pc_read_gm_account(int fd) GM_num++; } } - + mysql_free_result(lsql_res); #endif /* TXT_ONLY */ return GM_num; @@ -7926,7 +8007,7 @@ int pc_readdb(void) char line[1024],*p; // 必要??値?み?み - + memset(exp_table,0,sizeof(exp_table)); fp=fopen("db/exp.txt","r"); if(fp==NULL){ printf("can't read db/exp.txt\n"); @@ -7997,6 +8078,7 @@ int pc_readdb(void) ShowStatus(tmp_output); // JOBボ?ナス + memset(job_bonus,0,sizeof(job_bonus)); fp=fopen("db/job_db2.txt","r"); if(fp==NULL){ printf("can't read db/job_db2.txt\n"); @@ -8076,7 +8158,7 @@ int pc_readdb(void) for(j=0;skill_tree[u][i][j].id;j++); skill_tree[u][i][j].id=atoi(split[1]); skill_tree[u][i][j].max=atoi(split[2]); - + //not required - Celest //skill_tree[2][i][j].id=atoi(split[1]); //養子職は良く分からないので暫定 //skill_tree[2][i][j].max=atoi(split[2]); //養子職は良く分からないので暫定 @@ -8242,7 +8324,7 @@ static void pc_statpointdb(void) end = ftell(stp); rewind(stp); - buf_stat = (char *) malloc (end + 1); + buf_stat = (char *) aMallocA (end + 1); l = fread(buf_stat,1,end,stp); fclose(stp); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/statpoint.txt"); @@ -8251,7 +8333,7 @@ static void pc_statpointdb(void) for(i=0;i<255;i++) { j=0; - while (*(buf_stat+k)!='\n') { + while (*(buf_stat+k)!='\n') { statp[i][j]=*(buf_stat+k); j++;k++; } @@ -8259,7 +8341,7 @@ static void pc_statpointdb(void) k++; } - free(buf_stat); + aFree(buf_stat); } /*========================================== diff --git a/src/map/pet.c b/src/map/pet.c index c198c1fb5..99f2a4d95 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1376,7 +1376,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) clif_additem(sd,0,0,flag); map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); } - free(ditem); + aFree(ditem); } else add_timer(gettick()+540+i,pet_delay_item_drop2,(int)ditem,0); @@ -1399,7 +1399,7 @@ int pet_delay_item_drop2(int tid,unsigned int tick,int id,int data) map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0); - free(ditem); + aFree(ditem); return 0; } diff --git a/src/map/script.c b/src/map/script.c index a6b65e213..35645eaab 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -507,7 +507,7 @@ struct { {buildin_npctalk,"npctalk","*"}, // [Valaris] {buildin_hasitems,"hasitems","*"}, // [Valaris] {buildin_mobcount,"mobcount","ss"}, - {buildin_getlook,"getlook","i"}, + {buildin_getlook,"getlook","i"}, {buildin_getsavepoint,"getsavepoint","i"}, {buildin_npcspeed,"npcspeed","i"}, // [Valaris] {buildin_npcwalkto,"npcwalkto","ii"}, // [Valaris] @@ -576,14 +576,14 @@ static int add_str(const unsigned char *p) int i; char *lowcase; - lowcase=strdup(p); + lowcase=aStrdup(p); for(i=0;lowcase[i];i++) lowcase[i]=tolower(lowcase[i]); if((i=search_str(lowcase))>=0){ - free(lowcase); + aFree(lowcase); return i; } - free(lowcase); + aFree(lowcase); i=calc_hash(p); if(str_hash[i]==0){ @@ -605,7 +605,7 @@ static int add_str(const unsigned char *p) str_data=aRealloc(str_data,sizeof(str_data[0])*str_data_size); memset(str_data + (str_data_size - 128), '\0', 128); } - while(str_pos+strlen(p)+1>=str_size){ + while(str_pos+(int)strlen(p)+1>=str_size){ str_size+=256; str_buf=(char *)aRealloc(str_buf,str_size); memset(str_buf + (str_size - 256), '\0', 256); @@ -1159,7 +1159,7 @@ unsigned char* parse_script(unsigned char *src,int line) read_constdb(); } first=0; - script_buf=(unsigned char *)aCalloc(SCRIPT_BLOCK_SIZE,sizeof(unsigned char)); + script_buf=(unsigned char *)aCallocA(SCRIPT_BLOCK_SIZE,sizeof(unsigned char)); script_pos=0; script_size=SCRIPT_BLOCK_SIZE; str_data[LABEL_NEXTLINE].type=C_NOP; @@ -1395,7 +1395,7 @@ char* conv_str(struct script_state *st,struct script_data *data) get_val(st,data); if(data->type==C_INT){ char *buf; - buf=(char *)aCalloc(16,sizeof(char)); + buf=(char *)aCallocA(16,sizeof(char)); sprintf(buf,"%d",data->u.num); data->type=C_STR; data->u.str=buf; @@ -1421,7 +1421,7 @@ int conv_num(struct script_state *st,struct script_data *data) p=data->u.str; data->u.num = atoi(p); if(data->type==C_STR) - free(p); + aFree(p); data->type=C_INT; } return data->u.num; @@ -1478,7 +1478,7 @@ void push_copy(struct script_stack *stack,int pos) push_str(stack,C_CONSTSTR,stack->stack_data[pos].u.str); break; case C_STR: - push_str(stack,C_STR,strdup(stack->stack_data[pos].u.str)); + push_str(stack,C_STR,aStrdup(stack->stack_data[pos].u.str)); break; default: push_val(stack,stack->stack_data[pos].type,stack->stack_data[pos].u.num); @@ -1495,7 +1495,7 @@ void pop_stack(struct script_stack* stack,int start,int end) int i; for(i=start;istack_data[i].type==C_STR){ - free(stack->stack_data[i].u.str); + aFree(stack->stack_data[i].u.str); } } if(stack->sp>end){ @@ -1663,7 +1663,7 @@ int buildin_menu(struct script_state *st) char *buf; int len,i; struct map_session_data *sd; - + sd=script_rid2sd(st); if(sd->state.menu_or_input==0){ @@ -1673,14 +1673,14 @@ int buildin_menu(struct script_state *st) conv_str(st,& (st->stack->stack_data[i])); len+=strlen(st->stack->stack_data[i].u.str)+1; } - buf=(char *)aCalloc(len,sizeof(char)); + buf=(char *)aCallocA(len,sizeof(char)); buf[0]=0; for(i=st->start+2,len=0;iend;i+=2){ strcat(buf,st->stack->stack_data[i].u.str); strcat(buf,":"); } clif_scriptmenu(script_rid2sd(st),st->oid,buf); - free(buf); + aFree(buf); } else if(sd->npc_menu==0xff){ // cansel sd->state.menu_or_input=0; st->state=END; @@ -2522,7 +2522,7 @@ int buildin_delitem(struct script_state *st) if(sd->inventory_data[i]->type==7 && sd->status.inventory[i].card[0] == (short)0xff00 && search_petDB_index(nameid, PET_EGG) >= 0 ){ intif_delete_petdata(*((long *)(&sd->status.inventory[i].card[1]))); //clear egg flag. so it won't be put in IMPORTANT items (eggs look like item with 2 cards ^_^) - sd->status.inventory[i].card[1] = sd->status.inventory[i].card[0] = 0; + sd->status.inventory[i].card[1] = sd->status.inventory[i].card[0] = 0; //now this egg'll be deleted as a common unimportant item } //is this item important? does it have cards? or Player's name? or Refined/Upgraded @@ -2551,7 +2551,7 @@ int buildin_delitem(struct script_state *st) continue; if(sd->status.inventory[i].amount>=amount){ - pc_delitem(sd,i,amount,0); + pc_delitem(sd,i,amount,0); return 0; //we deleted exact amount of items. now exit } else { amount-=sd->status.inventory[i].amount; @@ -2627,7 +2627,7 @@ char *buildin_getpartyname_sub(int party_id) if(p!=NULL){ char *buf; - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strcpy(buf,p->name); return buf; } @@ -2684,7 +2684,7 @@ char *buildin_getguildname_sub(int guild_id) if(g!=NULL){ char *buf; - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strcpy(buf,g->name); return buf; } @@ -2713,7 +2713,7 @@ char *buildin_getguildmaster_sub(int guild_id) if(g!=NULL){ char *buf; - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strncpy(buf,g->master, 23); return buf; } @@ -2763,7 +2763,7 @@ int buildin_strcharinfo(struct script_state *st) num=conv_num(st,& (st->stack->stack_data[st->start+2])); if(num==0){ char *buf; - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strncpy(buf,sd->status.name, 23); push_str(st->stack,C_STR,buf); } @@ -2830,7 +2830,7 @@ int buildin_getequipname(struct script_state *st) struct item_data* item; char *buf; - buf=(char *)aCalloc(64,sizeof(char)); + buf=(char *)aCallocA(64,sizeof(char)); sd=script_rid2sd(st); num=conv_num(st,& (st->stack->stack_data[st->start+2])); i=pc_checkequip(sd,equip[num-1]); @@ -2856,9 +2856,9 @@ int buildin_getbrokenid(struct script_state *st) { int i,num,id=0,brokencounter=0; struct map_session_data *sd; - + sd=script_rid2sd(st); - + num=conv_num(st,& (st->stack->stack_data[st->start+2])); for(i=0; istatus.inventory[i].attribute==1){ @@ -2869,7 +2869,7 @@ int buildin_getbrokenid(struct script_state *st) } } } - + push_val(st->stack,C_INT,id); return 0; @@ -2887,7 +2887,7 @@ int buildin_repair(struct script_state *st) sd=script_rid2sd(st); - + num=conv_num(st,& (st->stack->stack_data[st->start+2])); for(i=0; istatus.inventory[i].attribute==1){ @@ -2941,7 +2941,7 @@ int buildin_getequipisenableref(struct script_state *st) i=pc_checkequip(sd,equip[num-1]); if(i >= 0 && num<7 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_refine) // replaced by Celest - /*(num!=1 + /*(num!=1 || sd->inventory_data[i]->def > 1 || (sd->inventory_data[i]->def==1 && sd->inventory_data[i]->equip_script==NULL) || (sd->inventory_data[i]->def<=0 && sd->inventory_data[i]->equip_script!=NULL)))*/ @@ -3245,15 +3245,15 @@ int buildin_getskilllv(struct script_state *st) return 0; } /*========================================== - * getgdskilllv(Guild_ID, Skill_ID); - * skill_id = 10000 : GD_APPROVAL - * 10001 : GD_KAFRACONTACT - * 10002 : GD_GUARDIANRESEARCH - * 10003 : GD_GUARDUP - * 10004 : GD_EXTENSION + * getgdskilllv(Guild_ID, Skill_ID); + * skill_id = 10000 : GD_APPROVAL + * 10001 : GD_KAFRACONTACT + * 10002 : GD_GUARDIANRESEARCH + * 10003 : GD_GUARDUP + * 10004 : GD_EXTENSION *------------------------------------------ */ -int buildin_getgdskilllv(struct script_state *st) +int buildin_getgdskilllv(struct script_state *st) { int guild_id=conv_num(st,& (st->stack->stack_data[st->start+2])); int skill_id=conv_num(st,& (st->stack->stack_data[st->start+3])); @@ -3590,7 +3590,7 @@ int buildin_gettimestr(struct script_state *st) fmtstr=conv_str(st,& (st->stack->stack_data[st->start+2])); maxlen=conv_num(st,& (st->stack->stack_data[st->start+3])); - tmpstr=(char *)aCalloc(maxlen+1,sizeof(char)); + tmpstr=(char *)aCallocA(maxlen+1,sizeof(char)); strftime(tmpstr,maxlen,fmtstr,localtime(&now)); tmpstr[maxlen]='\0'; @@ -3677,8 +3677,8 @@ int buildin_makepet(struct script_state *st) sd->catch_target_class = pet_db[pet_id].class_; intif_create_pet( sd->status.account_id, sd->status.char_id, - pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv, - pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, + (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv, + (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } @@ -3727,19 +3727,19 @@ int buildin_guildgetexp(struct script_state *st) */ int buildin_monster(struct script_state *st) { - int class,amount,x,y; + int class_,amount,x,y; char *str,*map,*event=""; map =conv_str(st,& (st->stack->stack_data[st->start+2])); x =conv_num(st,& (st->stack->stack_data[st->start+3])); y =conv_num(st,& (st->stack->stack_data[st->start+4])); str =conv_str(st,& (st->stack->stack_data[st->start+5])); - class=conv_num(st,& (st->stack->stack_data[st->start+6])); + class_=conv_num(st,& (st->stack->stack_data[st->start+6])); amount=conv_num(st,& (st->stack->stack_data[st->start+7])); if( st->end>st->start+8 ) event=conv_str(st,& (st->stack->stack_data[st->start+8])); - mob_once_spawn(map_id2sd(st->rid),map,x,y,str,class,amount,event); + mob_once_spawn(map_id2sd(st->rid),map,x,y,str,class_,amount,event); return 0; } /*========================================== @@ -3748,7 +3748,7 @@ int buildin_monster(struct script_state *st) */ int buildin_areamonster(struct script_state *st) { - int class,amount,x0,y0,x1,y1; + int class_,amount,x0,y0,x1,y1; char *str,*map,*event=""; map =conv_str(st,& (st->stack->stack_data[st->start+2])); @@ -3757,12 +3757,12 @@ int buildin_areamonster(struct script_state *st) x1 =conv_num(st,& (st->stack->stack_data[st->start+5])); y1 =conv_num(st,& (st->stack->stack_data[st->start+6])); str =conv_str(st,& (st->stack->stack_data[st->start+7])); - class=conv_num(st,& (st->stack->stack_data[st->start+8])); + class_=conv_num(st,& (st->stack->stack_data[st->start+8])); amount=conv_num(st,& (st->stack->stack_data[st->start+9])); if( st->end>st->start+10 ) event=conv_str(st,& (st->stack->stack_data[st->start+10])); - mob_once_spawn_area(map_id2sd(st->rid),map,x0,y0,x1,y1,str,class,amount,event); + mob_once_spawn_area(map_id2sd(st->rid),map,x0,y0,x1,y1,str,class_,amount,event); return 0; } /*========================================== @@ -3974,7 +3974,7 @@ int buildin_attachnpctimer(struct script_state *st) struct map_session_data *sd; struct npc_data *nd; - nd=(struct npc_data *)map_id2bl(st->oid); + nd=(struct npc_data *)map_id2bl(st->oid); if( st->end > st->start+2 ) { char *name = conv_str(st,& (st->stack->stack_data[st->start+2])); sd=map_nick2sd(name); @@ -4270,7 +4270,7 @@ int buildin_sc_start(struct script_state *st) bl = map_id2bl(conv_num(st,& (st->stack->stack_data[st->start+5]))); else bl = map_id2bl(st->rid); - + if (bl != 0) { if(bl->type == BL_PC && ((struct map_session_data *)bl)->state.potionpitcher_flag) bl = map_id2bl(((struct map_session_data *)bl)->skilltarget); @@ -5101,7 +5101,7 @@ int buildin_getcastlename(struct script_state *st) for(i=0;imap_name)==0){ - buf=(char *)aCalloc(24,sizeof(char)); + buf=(char *)aCallocA(24,sizeof(char)); strncpy(buf,gc->castle_name,24); break; } @@ -5343,8 +5343,8 @@ int buildin_failedremovecards(struct script_state *st) if( (sd->status.inventory[i].card[c-1] > 4000 && sd->status.inventory[i].card[c-1] < 5000) || itemdb_type(sd->status.inventory[i].card[c-1]) == 6){ // [Celest] - - cardflag = 1; + + cardflag = 1; if(typefail == 2){ // 武具のみ損失なら、カードは受け取らせる item_tmp.id=0,item_tmp.nameid=sd->status.inventory[i].card[c-1]; @@ -5561,39 +5561,39 @@ int buildin_strmobinfo(struct script_state *st) { int num=conv_num(st,& (st->stack->stack_data[st->start+2])); - int class=conv_num(st,& (st->stack->stack_data[st->start+3])); + int class_=conv_num(st,& (st->stack->stack_data[st->start+3])); - if(num<=0 || num>=8 || (class>=0 && class<=1000) || class >2000) + if(num<=0 || num>=8 || (class_>=0 && class_<=1000) || class_ >2000) return 0; if(num==1) { char *buf; - buf=aCalloc(24, 1); -// buf=mob_db[class].name; + buf=aCallocA(24, 1); +// buf=mob_db[class_].name; // for string assignments you would need to go for c++ [Shinomori] - strcpy(buf,mob_db[class].name); + strcpy(buf,mob_db[class_].name); push_str(st->stack,C_STR,buf); return 0; } else if(num==2) { char *buf; - buf=aCalloc(24, 1); -// buf=mob_db[class].jname; + buf=aCallocA(24, 1); +// buf=mob_db[class_].jname; // for string assignments you would need to go for c++ [Shinomori] - strcpy(buf,mob_db[class].jname); + strcpy(buf,mob_db[class_].jname); push_str(st->stack,C_STR,buf); return 0; } else if(num==3) - push_val(st->stack,C_INT,mob_db[class].lv); + push_val(st->stack,C_INT,mob_db[class_].lv); else if(num==4) - push_val(st->stack,C_INT,mob_db[class].max_hp); + push_val(st->stack,C_INT,mob_db[class_].max_hp); else if(num==5) - push_val(st->stack,C_INT,mob_db[class].max_sp); + push_val(st->stack,C_INT,mob_db[class_].max_sp); else if(num==6) - push_val(st->stack,C_INT,mob_db[class].base_exp); + push_val(st->stack,C_INT,mob_db[class_].base_exp); else if(num==7) - push_val(st->stack,C_INT,mob_db[class].job_exp); + push_val(st->stack,C_INT,mob_db[class_].job_exp); return 0; } @@ -5603,20 +5603,20 @@ int buildin_strmobinfo(struct script_state *st) */ int buildin_guardian(struct script_state *st) { - int class=0,amount=1,x=0,y=0,guardian=0; + int class_=0,amount=1,x=0,y=0,guardian=0; char *str,*map,*event=""; map =conv_str(st,& (st->stack->stack_data[st->start+2])); x =conv_num(st,& (st->stack->stack_data[st->start+3])); y =conv_num(st,& (st->stack->stack_data[st->start+4])); str =conv_str(st,& (st->stack->stack_data[st->start+5])); - class=conv_num(st,& (st->stack->stack_data[st->start+6])); + class_=conv_num(st,& (st->stack->stack_data[st->start+6])); amount=conv_num(st,& (st->stack->stack_data[st->start+7])); event=conv_str(st,& (st->stack->stack_data[st->start+8])); if( st->end>st->start+9 ) guardian=conv_num(st,& (st->stack->stack_data[st->start+9])); - mob_spawn_guardian(map_id2sd(st->rid),map,x,y,str,class,amount,event,guardian); + mob_spawn_guardian(map_id2sd(st->rid),map,x,y,str,class_,amount,event,guardian); return 0; } @@ -5657,7 +5657,7 @@ int buildin_getitemname(struct script_state *st) i_data = NULL; i_data = itemdb_search(item_id); - item_name=(char *)aCalloc(24,sizeof(char)); + item_name=(char *)aCallocA(24,sizeof(char)); strncpy(item_name,i_data->jname,23); push_str(st->stack,C_STR,item_name); @@ -5671,12 +5671,12 @@ int buildin_getitemname(struct script_state *st) int buildin_petskillbonus(struct script_state *st) { - int type,val,duration,timer; + int type,val,duration,timer; struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5691,7 +5691,7 @@ int buildin_petskillbonus(struct script_state *st) pd->skillbonusduration=-1; pd->skillbonustimer=-1; - + pet_skill_bonus(sd,pd,type,val,duration,timer,0); return 0; @@ -5719,7 +5719,7 @@ int buildin_petloot(struct script_state *st) if(!max) return 0; - + pd->loot=1; pd->lootmax=max; @@ -5790,14 +5790,14 @@ int buildin_clearitem(struct script_state *st) */ int buildin_classchange(struct script_state *st) { - int class,type; + int _class,type; struct block_list *bl=map_id2bl(st->oid); - + if(bl==NULL) return 0; - class=conv_num(st,& (st->stack->stack_data[st->start+2])); + _class=conv_num(st,& (st->stack->stack_data[st->start+2])); type=conv_num(st,& (st->stack->stack_data[st->start+3])); - clif_class_change(bl,class,type); + clif_class_change(bl,_class,type); return 0; } @@ -5867,9 +5867,9 @@ int buildin_petrecovery(struct script_state *st) { struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5893,9 +5893,9 @@ int buildin_petheal(struct script_state *st) { struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5911,7 +5911,7 @@ int buildin_petheal(struct script_state *st) return 0; } - + /*========================================== * pet magnificat [Valaris] *------------------------------------------ @@ -5919,9 +5919,9 @@ int buildin_petheal(struct script_state *st) int buildin_petmag(struct script_state *st) { struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5946,9 +5946,9 @@ int buildin_petmag(struct script_state *st) int buildin_petskillattack(struct script_state *st) { struct pet_data *pd; - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if(sd==NULL || sd->pd==NULL) return 0; pd=sd->pd; @@ -5957,7 +5957,7 @@ int buildin_petskillattack(struct script_state *st) return 0; pd->skilltype=conv_num(st,& (st->stack->stack_data[st->start+2])); - pd->skillval=conv_num(st,& (st->stack->stack_data[st->start+3])); + pd->skillval=conv_num(st,& (st->stack->stack_data[st->start+3])); pd->skillduration=conv_num(st,& (st->stack->stack_data[st->start+4])); pd->skilltimer=conv_num(st,& (st->stack->stack_data[st->start+5])); @@ -5973,11 +5973,11 @@ int buildin_petskillattack(struct script_state *st) int buildin_skilleffect(struct script_state *st) { struct map_session_data *sd; - + int skillid=conv_num(st,& (st->stack->stack_data[st->start+2])); int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3])); sd=script_rid2sd(st); - + clif_skill_nodamage(&sd->bl,&sd->bl,skillid,skilllv,1); return 0; @@ -5990,9 +5990,9 @@ int buildin_skilleffect(struct script_state *st) int buildin_npcskilleffect(struct script_state *st) { struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid); - + int skillid=conv_num(st,& (st->stack->stack_data[st->start+2])); - int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3])); + int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3])); int x=conv_num(st,& (st->stack->stack_data[st->start+4])); int y=conv_num(st,& (st->stack->stack_data[st->start+5])); @@ -6036,13 +6036,13 @@ int buildin_specialeffect2(struct script_state *st) int buildin_nude(struct script_state *st) { - struct map_session_data *sd=script_rid2sd(st); + struct map_session_data *sd=script_rid2sd(st); int i; if(sd==NULL) return 0; - - for(i=0;i<11;i++) + + for(i=0;i<11;i++) if(sd->equip_index[i] >= 0) pc_unequipitem(sd,sd->equip_index[i],2); @@ -6118,7 +6118,7 @@ int buildin_message(struct script_state *st) * area) [Valaris] *------------------------------------------ */ - + int buildin_npctalk(struct script_state *st) { char *str; @@ -6148,16 +6148,16 @@ int buildin_hasitems(struct script_state *st) { int i; struct map_session_data *sd; - + sd=script_rid2sd(st); - + for(i=0; istatus.inventory[i].amount) { push_val(st->stack,C_INT,1); return 0; } } - + push_val(st->stack,C_INT,0); return 0; @@ -6262,7 +6262,7 @@ int buildin_getsavepoint(struct script_state *st) sd=script_rid2sd(st); type=conv_num(st,& (st->stack->stack_data[st->start+2])); - mapname=aCalloc(24, 1); + mapname=aCallocA(24, 1); x=sd->status.save_point.x; y=sd->status.save_point.y; @@ -6331,7 +6331,7 @@ int buildin_getmapxy(struct script_state *st){ //??????????? >>> Possible needly check function parameters on C_STR,C_INT,C_INT <<< ???????????// type=conv_num(st,& (st->stack->stack_data[st->start+5])); - mapname=aCalloc(24, 1); + mapname=aCallocA(24, 1); switch (type){ case 0: //Get Character Position @@ -6363,7 +6363,7 @@ int buildin_getmapxy(struct script_state *st){ } x=nd->bl.x; - y=nd->bl.y; + y=nd->bl.y; strncpy(mapname,map[nd->bl.m].name,24); printf(">>>>%s %d %d\n",mapname,x,y); break; @@ -6385,7 +6385,7 @@ int buildin_getmapxy(struct script_state *st){ return 0; } x=pd->bl.x; - y=pd->bl.y; + y=pd->bl.y; strncpy(mapname,map[pd->bl.m].name,24); printf(">>>>%s %d %d\n",mapname,x,y); @@ -6491,7 +6491,7 @@ int buildin_logmes(struct script_state *st) int buildin_summon(struct script_state *st) { - int class, id; + int _class, id; char *str,*event=""; struct map_session_data *sd; struct mob_data *md; @@ -6500,11 +6500,11 @@ int buildin_summon(struct script_state *st) if (sd) { int tick = gettick(); str =conv_str(st,& (st->stack->stack_data[st->start+2])); - class=conv_num(st,& (st->stack->stack_data[st->start+3])); + _class=conv_num(st,& (st->stack->stack_data[st->start+3])); if( st->end>st->start+4 ) event=conv_str(st,& (st->stack->stack_data[st->start+4])); - id=mob_once_spawn(sd, "this", 0, 0, str,class,1,event); + id=mob_once_spawn(sd, "this", 0, 0, str,_class,1,event); if((md=(struct mob_data *)map_id2bl(id))){ md->master_id=sd->bl.id; md->state.special_mob_ai=1; @@ -6608,14 +6608,14 @@ void op_add(struct script_state* st) st->stack->stack_data[st->stack->sp-1].u.num += st->stack->stack_data[st->stack->sp].u.num; } else { // ssの予定 char *buf; - buf=(char *)aCalloc(strlen(st->stack->stack_data[st->stack->sp-1].u.str)+ + buf=(char *)aCallocA(strlen(st->stack->stack_data[st->stack->sp-1].u.str)+ strlen(st->stack->stack_data[st->stack->sp].u.str)+1,sizeof(char)); strcpy(buf,st->stack->stack_data[st->stack->sp-1].u.str); strcat(buf,st->stack->stack_data[st->stack->sp].u.str); if(st->stack->stack_data[st->stack->sp-1].type==C_STR) - free(st->stack->stack_data[st->stack->sp-1].u.str); + aFree(st->stack->stack_data[st->stack->sp-1].u.str); if(st->stack->stack_data[st->stack->sp].type==C_STR) - free(st->stack->stack_data[st->stack->sp].u.str); + aFree(st->stack->stack_data[st->stack->sp].u.str); st->stack->stack_data[st->stack->sp-1].type=C_STR; st->stack->stack_data[st->stack->sp-1].u.str=buf; } @@ -6657,8 +6657,8 @@ void op_2str(struct script_state *st,int op,int sp1,int sp2) push_val(st->stack,C_INT,a); - if(st->stack->stack_data[sp1].type==C_STR) free(s1); - if(st->stack->stack_data[sp2].type==C_STR) free(s2); + if(st->stack->stack_data[sp1].type==C_STR) aFree(s1); + if(st->stack->stack_data[sp2].type==C_STR) aFree(s2); } /*========================================== * 二項演算子(数値) @@ -6672,7 +6672,11 @@ void op_2num(struct script_state *st,int op,int i1,int i2) break; case C_MUL: { + #ifndef _MSC_VER long long res = i1 * i2; + #else + __int64 res = i1 * i2; + #endif if (res > 2147483647 ) i1 = 2147483647; else @@ -6988,7 +6992,7 @@ int run_script_main(unsigned char *script,int pos,int rid,int oid,struct script_ struct map_session_data *sd=map_id2sd(st->rid); if(sd/* && sd->npc_stackbuf==NULL*/){ if( sd->npc_stackbuf ) - free( sd->npc_stackbuf ); + aFree( sd->npc_stackbuf ); sd->npc_stackbuf = (char *)aCalloc(sizeof(stack->stack_data[0])*stack->sp_max,sizeof(char)); memcpy(sd->npc_stackbuf, stack->stack_data, sizeof(stack->stack_data[0]) * stack->sp_max); sd->npc_stack = stack->sp; @@ -7022,7 +7026,7 @@ int run_script(unsigned char *script,int pos,int rid,int oid) stack.sp_max=sd->npc_stackmax; stack.stack_data=(struct script_data *)aCalloc(stack.sp_max,sizeof(stack.stack_data[0])); memcpy(stack.stack_data,sd->npc_stackbuf,sizeof(stack.stack_data[0])*stack.sp_max); - free(sd->npc_stackbuf); + aFree(sd->npc_stackbuf); sd->npc_stackbuf=NULL; }else{ // スタック初期化 @@ -7036,7 +7040,7 @@ int run_script(unsigned char *script,int pos,int rid,int oid) st.oid=oid; run_script_main(script,pos,rid,oid,&st,rootscript); - free(stack.stack_data); + aFree(stack.stack_data); stack.stack_data=NULL; return st.pos; } @@ -7065,14 +7069,14 @@ int mapreg_setregstr(int num,const char *str) char *p; if( (p=numdb_search(mapregstr_db,num))!=NULL ) - free(p); + aFree(p); if( str==NULL || *str==0 ){ numdb_erase(mapregstr_db,num); mapreg_dirty=1; return 0; } - p=(char *)aCalloc(strlen(str)+1, sizeof(char)); + p=(char *)aCallocA(strlen(str)+1, sizeof(char)); strcpy(p,str); numdb_insert(mapregstr_db,num,p); mapreg_dirty=1; @@ -7102,7 +7106,7 @@ static int script_load_mapreg() printf("%s: %s broken data !\n",mapreg_txt,buf1); continue; } - p=(char *)aCalloc(strlen(buf2) + 1,sizeof(char)); + p=(char *)aCallocA(strlen(buf2) + 1,sizeof(char)); strcpy(p,buf2); s=add_str(buf1); numdb_insert(mapregstr_db,(i<<24)|s,p); @@ -7170,7 +7174,7 @@ static int script_autosave_mapreg(int tid,unsigned int tick,int id,int data) } /*========================================== - * + * *------------------------------------------ */ static int set_posword(char *p) @@ -7256,7 +7260,7 @@ static int mapreg_db_final(void *key,void *data,va_list ap) } static int mapregstr_db_final(void *key,void *data,va_list ap) { - free(data); + aFree(data); return 0; } static int scriptlabel_db_final(void *key,void *data,va_list ap) @@ -7265,8 +7269,8 @@ static int scriptlabel_db_final(void *key,void *data,va_list ap) } static int userfunc_db_final(void *key,void *data,va_list ap) { - free(key); - free(data); + aFree(key); + aFree(data); return 0; } int do_final_script() @@ -7274,7 +7278,7 @@ int do_final_script() if(mapreg_dirty>=0) script_save_mapreg(); if(script_buf) - free(script_buf); + aFree(script_buf); if(mapreg_db) numdb_final(mapreg_db,mapreg_db_final); @@ -7286,9 +7290,9 @@ int do_final_script() strdb_final(userfunc_db,userfunc_db_final); if (str_data) - free(str_data); + aFree(str_data); if (str_buf) - free(str_buf); + aFree(str_buf); return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index 8ede774e3..16cb26c06 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -730,7 +730,7 @@ const struct skill_name_db skill_names[] = { { WZ_STORMGUST, "STORMGUST", "Storm_Gust" } , { WZ_VERMILION, "VERMILION", "Lord_of_Vermilion" } , { WZ_WATERBALL, "WATERBALL", "Water_Ball" } , - { 0, 0, 0 } + { 0, 0, 0 } }; static const int dirx[8]={0,-1,-1,-1,0,1,1,1}; @@ -890,8 +890,8 @@ int skillnotok(int skillid, struct map_session_data *sd) { if (sd == 0) return 0; - if (!(skillid >= 10000 && skillid < 10015)) - if ((skillid > MAX_SKILL) || (skillid < 0)) + if (!(skillid >= 10000 && skillid < 10015)) + if ((skillid > MAX_SKILL) || (skillid < 0)) return 1; if (pc_isGM(sd) >= 20) @@ -1055,12 +1055,12 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s //if(skilllv <= 0) return 0; if(skillid > 0 && skilllv <= 0) return 0; // don't forget auto attacks! - celest - if(src->type==BL_PC){ - nullpo_retr(0, sd=(struct map_session_data *)src); - }else if(src->type==BL_MOB){ - nullpo_retr(0, md=(struct mob_data *)src); //未使用? - }else if(src->type==BL_PET){ - nullpo_retr(0, pd=(struct pet_data *)src); // [Valaris] + if (src->type == BL_PC){ + nullpo_retr(0, sd = (struct map_session_data *)src); + } else if (src->type == BL_MOB){ + nullpo_retr(0, md = (struct mob_data *)src); //未使用? + } else if (src->type == BL_PET){ + nullpo_retr(0, pd = (struct pet_data *)src); // [Valaris] } //?象の耐性 @@ -1088,6 +1088,13 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s if(sc_def_luk<50) sc_def_luk=50; } + if (dstsd && dstsd->sc_count && dstsd->sc_data[SC_GOSPEL].timer != -1 && + dstsd->sc_data[SC_GOSPEL].val4 == BCT_PARTY && + dstsd->sc_data[SC_GOSPEL].val3 == 3) { + sc_def_mdef -= 25; + sc_def_vit -= 25; + sc_def_int -= 25; + } if(sc_def_mdef<0) sc_def_mdef=0; if(sc_def_vit<0) @@ -1291,18 +1298,18 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s // case WZ_METEOR: if(rand()%100 < sc_def_vit) - skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); + skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); break; case WZ_VERMILION: if(rand()%100 < sc_def_int) - skill_status_change_start(bl,SC_BLIND,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); + skill_status_change_start(bl,SC_BLIND,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); break; // -- moonsoul (stun ability of new champion skill tigerfist) // case CH_TIGERFIST: if( rand()%100 < (10 + skilllv*10)*sc_def_vit/100 ) { - int sec = skill_get_time2 (skillid,skilllv) - (double)battle_get_agi(bl)*0.1; + int sec = skill_get_time2 (skillid,skilllv) - battle_get_agi(bl)/10; skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,sec,0); } break; @@ -1577,7 +1584,7 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds return 0; if(bl->type == BL_PC && pc_isdead((struct map_session_data *)bl)) //?象がPCですでに死んでいたら何もしない return 0; - if(bl->type == BL_PC && skillnotok(skillid, (struct map_session_data *) bl)) + if(bl->type == BL_PC && skillnotok(skillid, (struct map_session_data *) bl)) return 0; // [MouseJstr] if(sc_data && sc_data[SC_HIDING].timer != -1) { //ハイディング?態で if(skill_get_pl(skillid) != 2) //スキルの?性が地?性でなければ何もしない @@ -2297,7 +2304,7 @@ int skill_cleartimerskill(struct block_list *src) */ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int skillid,int skilllv,unsigned int tick,int flag ) { - struct map_session_data *sd=NULL; + struct map_session_data *sd = NULL; struct status_change *sc_data = battle_get_sc_data(src); int i; @@ -2374,7 +2381,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case LK_SPIRALPIERCE: /* スパイラルピア?ス */ case LK_HEADCRUSH: /* ヘッドクラッシュ */ case LK_JOINTBEAT: /* ジョイントビ?ト */ - case PA_PRESSURE: /* プレッシャ? */ +// case PA_PRESSURE: /* プレッシャ? */ // case PA_SACRIFICE: /* サクリファイス */ case SN_SHARPSHOOTING: /* シャ?プシュ?ティング */ case CG_ARROWVULCAN: /* アロ?バルカン */ @@ -2383,6 +2390,22 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case ITM_TOMAHAWK: skill_attack(BF_WEAPON,src,src,bl,skillid,skilllv,tick,flag); break; + case PA_PRESSURE: /* プレッシャ? */ + skill_attack(BF_WEAPON,src,src,bl,skillid,skilllv,tick,flag); + if (rand()%100 < 50) + skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(PA_PRESSURE,skilllv),0); + else + skill_status_change_start(bl,SC_BLEEDING,skilllv,0,0,0,skill_get_time2(PA_PRESSURE,skilllv),0); + if (bl->type == BL_PC) { + int sp; + struct map_session_data *tsd = (struct map_session_data *)bl; + nullpo_retb (tsd); + sp = tsd->status.max_sp * 10 * skilllv / 100; + if (sp > tsd->status.sp) sp = tsd->status.sp; + tsd->status.sp -= sp; + pc_heal(sd,0,-sp); + } + break; case NPC_DARKBREATH: clif_emotion(src,7); skill_attack(BF_MISC,src,src,bl,skillid,skilllv,tick,flag); @@ -2429,7 +2452,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s else if (bl->type == BL_MOB) ((struct mob_data *)bl)->dir=dir; clif_changed_dir(bl); - //skill_blown(src,bl,skill_get_blewcount(skillid,skilllv)); + //skill_blown(src,bl,skill_get_blewcount(skillid,skilllv)); } else if(src->type == BL_PC) clif_skill_fail(sd,sd->skillid,0,0); @@ -2558,7 +2581,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s if (skillid == ASC_METEORASSAULT) clif_skill_nodamage(src,bl,skillid,skilllv,1); - + skill_area_temp[1]=bl->id; skill_area_temp[2]=x; skill_area_temp[3]=y; @@ -2752,7 +2775,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case WZ_FROSTNOVA: /* フロストノヴァ */ skill_castend_pos2(src,bl->x,bl->y,skillid,skilllv,tick,0); //skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,flag); - map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); + map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); break; case WZ_SIGHTRASHER: @@ -2806,8 +2829,10 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s clif_skill_nodamage(src,bl,skillid,skilllv,1); if (skilllv == 5) skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,0 ); - if (bl->type == BL_PC) + if (bl->type == BL_PC) { ((struct map_session_data *)bl)->status.sp = 0; + clif_updatestatus((struct map_session_data *)bl,SP_SP); + } } else { clif_skill_nodamage(src,src,skillid,skilllv,1); if (skilllv == 5) @@ -2961,7 +2986,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int return 1; if (skillnotok(skillid, (struct map_session_data *)bl)) // [MouseJstr] return 0; - + map_freeblock_lock(); switch(skillid) { @@ -2971,7 +2996,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int int heal_get_jobexp; int skill; struct pc_base_job s_class; - + if( dstsd && dstsd->special_state.no_magic_damage ) heal=0; /* ?金蟲カ?ド(ヒ?ル量0) */ if (sd){ @@ -2981,7 +3006,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if(sd && dstsd && sd->status.partner_id == dstsd->status.char_id && s_class.job == 23 && sd->status.sex == 0) //自分も?象もPC、?象が自分のパ?トナ?、自分がスパノビ、自分が♀なら heal = heal*2; //スパノビの嫁が旦那にヒ?ルすると2倍になる } - + clif_skill_nodamage(src,bl,skillid,heal,1); heal_get_jobexp = battle_heal(NULL,bl,heal,0,0); @@ -3192,11 +3217,11 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int struct status_change *tsc_data = battle_get_sc_data(bl); int sc = SkillStatusChangeTable[skillid]; int sc2 = SC_MARIONETTE2; - + if((dstsd->bl.type!=BL_PC) || (sd->bl.id == dstsd->bl.id) || (!sd->status.party_id) - || (sd->status.party_id != dstsd->status.party_id)) { + || (sd->status.party_id != dstsd->status.party_id)) { clif_skill_fail(sd,skillid,0,0); map_freeblock_unlock(); return 1; @@ -3218,7 +3243,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } clif_skill_nodamage(src,bl,skillid,skilllv,1); } - } + } break; case SA_FLAMELAUNCHER: // added failure chance and chance to break weapon if turned on [Valaris] @@ -3303,7 +3328,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int skill_status_change_start(bl,SkillStatusChangeTable[skillid],skilllv,0,0,0,skill_get_time(skillid,skilllv),0 ); skill_status_change_start(src,SC_BLOCKSKILL,skilllv,0,skillid,0,10000,0 ); break; - + case SM_AUTOBERSERK: // Celest { struct status_change *tsc_data = battle_get_sc_data(bl); @@ -3317,7 +3342,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } } break; - + case AS_ENCHANTPOISON: // Prevent spamming [Valaris] if(bl->type==BL_PC) { struct map_session_data *sd2=(struct map_session_data *)bl; @@ -3385,11 +3410,12 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int skill_status_change_end(bl,SC_SLEEP,-1); } - if(bl->type==BL_MOB) { + if(dstmd) { int range = skill_get_range(skillid,skilllv); if(range < 0) range = battle_get_range(src) - (range + 1); - mob_target((struct mob_data *)bl,src,range); + md->state.provoke_flag = src->id; + mob_target(dstmd,src,range); } } break; @@ -3506,7 +3532,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int clif_skill_produce_mix_list(sd,256); clif_skill_nodamage(src,bl,skillid,skilllv,1); } - break; + break; case BS_HAMMERFALL: /* ハンマ?フォ?ル */ clif_skill_nodamage(src,bl,skillid,skilllv,1); if( bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_weapon_damage ) @@ -3733,6 +3759,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int skill_clear_unitgroup(src); clif_skill_nodamage(src,bl,skillid,skilllv,1); skill_unitsetting(src,skillid,skilllv,src->x,src->y,0); + skill_status_change_start(src,SkillStatusChangeTable[skillid],skilllv,0,0,BCT_SELF,skill_get_time(skillid,skilllv),0); break; case BD_ADAPTATION: /* アドリブ */ @@ -4402,20 +4429,20 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking) pc_breakweapon((struct map_session_data *)bl); break; - + case NPC_BREAKARMOR: clif_skill_nodamage(src,bl,skillid,skilllv,1); if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking) pc_breakarmor((struct map_session_data *)bl); break; - + case NPC_BREAKHELM: clif_skill_nodamage(src,bl,skillid,skilllv,1); if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking) // since we don't have any code for helm breaking yet... pc_breakweapon((struct map_session_data *)bl); break; - + case NPC_BREAKSHIELD: clif_skill_nodamage(src,bl,skillid,skilllv,1); if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking) @@ -4449,7 +4476,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if(map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto || map[dstsd->bl.m].flag.nowarp){ clif_skill_teleportmessage(sd,1); return 0; - } + } skill_unitsetting(src,skillid,skilllv,sd->bl.x,sd->bl.y,0); } break; @@ -4500,7 +4527,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); } } - + } if(su->group->unit_id == 0x91 && su->group->val2){ struct block_list *target=map_id2bl(su->group->val2); @@ -4595,7 +4622,9 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int sd->status.sp = sp2; dstsd->status.sp = sp1; clif_heal(sd->fd,SP_SP,sp2); + clif_updatestatus(sd,SP_SP); clif_heal(dstsd->fd,SP_SP,sp1); + clif_updatestatus(dstsd,SP_SP); } else if (dstmd) { if (dstmd->state.soul_change_flag) { clif_skill_fail(sd,skillid,0,0); @@ -4607,6 +4636,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int sp2 = sd->status.max_sp - sd->status.sp; sd->status.sp += sp2; clif_heal(sd->fd,SP_SP,sp2); + clif_updatestatus(sd,SP_SP); dstmd->state.soul_change_flag = 1; } } @@ -4661,6 +4691,15 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } } break; + case ST_PRESERVE: + if (sd){ + if (sd->sc_count && sd->sc_data[SC_PRESERVE].timer != -1) + skill_status_change_end(src, SC_PRESERVE, -1 ); + else + skill_status_change_start(src,SC_PRESERVE,skilllv,0,0,0,skill_get_time(skillid, skilllv),0 ); + clif_skill_nodamage(src,src,skillid,skilllv,1); + } + break; // New guild skills [Celest] case GD_BATTLEORDER: @@ -4713,7 +4752,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int } } break; - case GD_RESTORE: + case GD_RESTORE: { struct guild *g = NULL; // Only usable during WoE @@ -4725,8 +4764,8 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int if(flag&1) { if (dstsd && dstsd->status.guild_id == sd->status.guild_id) { int hp, sp; - hp = dstsd->status.max_hp*0.9; - sp = dstsd->status.max_sp*0.9; + hp = dstsd->status.max_hp*9/10; + sp = dstsd->status.max_sp*9/10; sp = dstsd->status.sp + sp <= dstsd->status.max_sp ? sp : dstsd->status.max_sp - dstsd->status.sp; clif_skill_nodamage(src,bl,AL_HEAL,hp,1); battle_heal(NULL,bl,hp,sp,0); @@ -4937,8 +4976,8 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil if(src->type==BL_PC){ nullpo_retr(0, sd=(struct map_session_data *)src); } - if( skillid != WZ_METEOR && - skillid != WZ_SIGHTRASHER && + if( skillid != WZ_METEOR && + skillid != WZ_SIGHTRASHER && skillid != AM_CANNIBALIZE && skillid != AM_SPHEREMINE) clif_skill_poseffect(src,skillid,skilllv,x,y,tick); @@ -5015,7 +5054,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil case HT_TALKIEBOX: /* ト?キ?ボックス */ skill_unitsetting(src,skillid,skilllv,x,y,0); break; - + case RG_GRAFFITI: /* Graffiti [Valaris] */ skill_clear_unitgroup(src); skill_unitsetting(src,skillid,skilllv,x,y,0); @@ -5088,7 +5127,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil mx = x;// + (rand()%10 - 5); my = y;// + (rand()%10 - 5); - + id=mob_once_spawn(sd,"this",mx,my,"--ja--", summons[skilllv-1] ,1,""); if( (md=(struct mob_data *)map_id2bl(id)) !=NULL ){ md->master_id=sd->bl.id; @@ -5138,7 +5177,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil map_foreachinarea(skill_area_sub, src->m,x-3,y-3,x+3,y+3,0, src,skillid,skilllv,tick,flag|BCT_ALL|1, - skill_castend_nodamage_id); + skill_castend_nodamage_id); } } } @@ -5175,7 +5214,7 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_MARIONETTE].timer != -1) return 0; - + if (sd->sc_data[SC_BLOCKSKILL].timer!=-1) if (skill_num == sd->sc_data[SC_BLOCKSKILL].val3) return 0; @@ -5243,7 +5282,7 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma return 0; if((group=skill_unitsetting(&sd->bl,sd->skillid,sd->skilllv,sd->skillx,sd->skilly,0))==NULL) return 0; - group->valstr=(char *)aCalloc(24,sizeof(char)); + group->valstr=(char *)aCallocA(24,sizeof(char)); memcpy(group->valstr,map,24); group->val2=(x<<16)|y; } @@ -5287,7 +5326,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, else count=3; limit=skill_get_time(skillid,skilllv); if(sc_data) { - if (sc_data[SC_VIOLENTGALE].timer!=-1) limit *= 1.5; + if (sc_data[SC_VIOLENTGALE].timer!=-1) limit = limit*3/2; } // check for sc_data first - Celest // if (((struct map_session_data *)src)->sc_data[SC_VIOLENTGALE].timer!=-1) @@ -5337,7 +5376,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, if(skilllv < 6) range=1; else - range=2; + range=2; break; case MG_THUNDERSTORM: /* サンダ?スト?ム */ @@ -5629,7 +5668,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, group->range=range; if(skillid==HT_TALKIEBOX || skillid==RG_GRAFFITI){ - group->valstr=aCalloc(80, 1); + group->valstr=aCallocA(80, 1); if(group->valstr==NULL){ printf("skill_castend_map: out of memory !\n"); exit(1); @@ -6079,13 +6118,13 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int { struct status_change *sc_data=battle_get_sc_data(bl); if(sg->val2==0 && sc_data && sc_data[SC_ANKLE].timer==-1){ - int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE); - int sec=skill_get_time2(sg->skill_id,sg->skill_lv) - (double)battle_get_agi(bl)*0.1; + int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE); + int sec = skill_get_time2(sg->skill_id,sg->skill_lv) - battle_get_agi(bl)/10; if(battle_get_mode(bl)&0x20) sec = sec/5; battle_stopwalking(bl,1); skill_status_change_start(bl,SC_ANKLE,sg->skill_lv,0,0,0,sec,0); - + if(moveblock) map_delblock(bl); bl->x = src->bl.x; bl->y = src->bl.y; @@ -6127,7 +6166,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int case 0x8e: /* クァグマイア */ { struct status_change *sc_data=battle_get_sc_data(bl); - int type=SkillStatusChangeTable[sg->skill_id]; + int type=SkillStatusChangeTable[sg->skill_id]; if( bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_magic_damage ) break; if(sc_data && sc_data[type].timer==-1) @@ -6153,7 +6192,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int if (sc_data[type].timer==-1) skill_status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); else if((unit2=(struct skill_unit *)sc_data[type].val2) && unit2 != src ){ - if( unit2->group != 0 && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) + if( unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) skill_status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); ts->tick-=sg->interval; } @@ -6210,7 +6249,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int skill_status_change_start(bl,type,sg->skill_lv,(sg->val1)>>16,(sg->val1)&0xffff, (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); else if((unit2=(struct skill_unit *)sc_data[type].val4) && unit2 != src ){ - if( unit2->group != 0 && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) + if( unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) skill_status_change_start(bl,type,sg->skill_lv,(sg->val1)>>16,(sg->val1)&0xffff, (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); ts->tick-=sg->interval; @@ -6489,7 +6528,7 @@ int skill_unit_onout(struct skill_unit *src,struct block_list *bl,unsigned int t { struct map_session_data *sd; if (bl->type == BL_PC && (sd=(struct map_session_data *)bl) && sd->state.hawkeyes_flag > 0) - sd->state.hawkeyes_flag = 0; + sd->state.hawkeyes_flag = 0; } break; @@ -6578,7 +6617,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick) src->bl.x,src->bl.y,1); if(group == NULL) return 0; - group->valstr=aCalloc(24, 1); + group->valstr=aCallocA(24, 1); if(group->valstr==NULL){ printf("skill_unit_onlimit: out of memory !\n"); exit(1); @@ -6619,7 +6658,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick) struct map_session_data *sd; if ((sd = (struct map_session_data *)(map_id2bl(sg->src_id)))!= NULL) { sd->state.glorywounds_flag = 0; - } + } } break; case 0xc3: // GD_SOULCOLD @@ -6627,7 +6666,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick) struct map_session_data *sd; if ((sd = (struct map_session_data *)(map_id2bl(sg->src_id)))!= NULL) { sd->state.soulcold_flag = 0; - } + } } break; case 0xc4: // GD_HAWKEYES @@ -6905,7 +6944,7 @@ static int skill_check_condition_use_sub(struct block_list *bl,va_list ap) nullpo_retr(0, ssd=(struct map_session_data*)src); s_class = pc_calc_base_job(sd->status.class_); - + //チェックしない設定ならcにありえない大きな?字を返して終了 if(!battle_config.player_skill_partner_check){ //本?はforeachの前にやりたいけど設定適用箇所をまとめるためにここへ (*c)=99; @@ -7034,7 +7073,7 @@ int skill_check_condition(struct map_session_data *sd,int type) (sd->sc_data[SC_MARIONETTE].timer != -1 && sd->skillid != CG_MARIONETTE)){ clif_skill_fail(sd,sd->skillid,0,0); return 0; /* ?態異常や沈?など */ - } + } } skill = sd->skillid; lv = sd->skilllv; @@ -7192,7 +7231,7 @@ int skill_check_condition(struct map_session_data *sd,int type) break; case MG_FIREWALL: /* ファイア?ウォ?ル */ case WZ_QUAGMIRE: - case WZ_FIREPILLAR: // celest + case WZ_FIREPILLAR: // celest case PF_FOGWALL: /* ?制限 */ if(battle_config.pc_land_skill_limit) { @@ -7340,7 +7379,7 @@ int skill_check_condition(struct map_session_data *sd,int type) if(((itemid[i] >= 715 && itemid[i] <= 717) || itemid[i] == 1065) && sd->sc_data[SC_INTOABYSS].timer != -1) continue; if(skill == WZ_FIREPILLAR && lv<=5) - continue; // no gemstones for 1-5 [Celest] + continue; // no gemstones for 1-5 [Celest] if(skill == AM_POTIONPITCHER && i != x) continue; @@ -7357,7 +7396,7 @@ int skill_check_condition(struct map_session_data *sd,int type) if(!(type&1)) return 1; - if(skill != AM_POTIONPITCHER && + if(skill != AM_POTIONPITCHER && skill != CR_SLIMPITCHER && skill != MG_STONECURSE) { if(skill == AL_WARP && !(type&2)) @@ -7408,7 +7447,7 @@ int skill_castfix( struct block_list *bl, int time ) nullpo_retr(0, md=(struct mob_data*)bl); skill = md->skillid; lv = md->skilllv; - } else { + } else { nullpo_retr(0, sd=(struct map_session_data*)bl); skill = sd->skillid; lv = sd->skilllv; @@ -7451,13 +7490,13 @@ int skill_delayfix( struct block_list *bl, int time ) { struct status_change *sc_data; struct map_session_data *sd = NULL; - int skill,lv = 0; - int delayrate=100; - + int skill = 0,lv = 0; + int delayrate = 100; + nullpo_retr(0, bl); - if(bl->type==BL_PC){ - nullpo_retr(0, sd=(struct map_session_data*)bl); + if(bl->type == BL_PC){ + nullpo_retr(0, sd = (struct map_session_data*)bl); skill = sd->skillid; lv = sd->skilllv; } @@ -7466,24 +7505,32 @@ int skill_delayfix( struct block_list *bl, int time ) sc_data = battle_get_sc_data(bl); - // instant cast attack skills depend on aspd as delay [celest] - if (time <= 0 && skill_db[skill].skill_type == BF_WEAPON) - time = battle_get_adelay (bl)/2; - if(sd) { delayrate=((struct map_session_data *)bl)->delayrate; + // instant cast attack skills depend on aspd as delay [celest] + if (time == 0) { + if (skill_db[skill].skill_type == BF_WEAPON) + time = battle_get_adelay (bl)/2; + else + time = 300; // default delay, according to official servers + } else if (time < 0) + time = abs(time) + battle_get_adelay (bl)/2; // if set to <0, the aspd delay will be added + if(battle_config.delay_dependon_dex && /* dexの影響を計算する */ !skill_get_delaynodex(skill, lv)) // if skill casttime is allowed to be reduced by dex - time=time*(battle_config.castrate_dex_scale - battle_get_dex(bl))/(battle_config.castrate_dex_scale); + time = time * (battle_config.castrate_dex_scale - battle_get_dex(bl)) / (battle_config.castrate_dex_scale); - time=time*delayrate*battle_config.delay_rate/10000; + time = time * delayrate * battle_config.delay_rate / 10000; + + if (time < battle_config.min_skill_delay_limit) // check minimum skill delay + time = battle_config.min_skill_delay_limit; } /* ブラギの詩 */ - if(sc_data && sc_data[SC_POEMBRAGI].timer!=-1 ) - time=time*(100-(sc_data[SC_POEMBRAGI].val1*3+sc_data[SC_POEMBRAGI].val2 - +(sc_data[SC_POEMBRAGI].val3&0xffff)))/100; + if(sc_data && sc_data[SC_POEMBRAGI].timer != -1 ) + time = time * (100 - (sc_data[SC_POEMBRAGI].val1 * 3 + sc_data[SC_POEMBRAGI].val2 + + (sc_data[SC_POEMBRAGI].val3 & 0xffff))) / 100; return (time>0)?time:0; } @@ -7512,10 +7559,10 @@ int skill_use_id( struct map_session_data *sd, int target_id, } if(sd->bl.m != bl->m || pc_isdead(sd)) return 0; - + if(skillnotok(skill_num, sd)) // [MouseJstr] return 0; - + sc_data=sd->sc_data; /* 沈?や異常(ただし、グリムなどの判定をする) */ @@ -7598,7 +7645,7 @@ int skill_use_id( struct map_session_data *sd, int target_id, case ST_CHASEWALK: return 0; } - }*/ + }*/ if(skill_get_inf2(skill_num)&0x200 && sd->bl.id == target_id) return 0; @@ -7671,15 +7718,27 @@ int skill_use_id( struct map_session_data *sd, int target_id, if(!skill_check_condition(sd,0)) return 0; - /* 射程と障害物チェック */ - range = skill_get_range(skill_num,skill_lv); - if(range < 0) - range = battle_get_range(&sd->bl) - (range + 1); - // be lenient if the skill was cast before we have moved to the correct position [Celest] - if (sd->walktimer != -1) - range += battle_config.skill_range_leniency; - if(!battle_check_range(&sd->bl,bl,range) ) - return 0; + { + int check_range_flag = 0; + + /* 射程と障害物チェック */ + range = skill_get_range(skill_num,skill_lv); + if(range < 0) + range = battle_get_range(&sd->bl) - (range + 1); + // be lenient if the skill was cast before we have moved to the correct position [Celest] + if (sd->walktimer != -1) + range += battle_config.skill_range_leniency; + else check_range_flag = 1; + if(!battle_check_range(&sd->bl,bl,range)) { + if (check_range_flag && battle_check_range(&sd->bl,bl,range + battle_config.skill_range_leniency)) { + int dir, mask[8][2] = {{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}}; + dir = map_calc_dir(&sd->bl,bl->x,bl->y); + pc_walktoxy (sd, sd->bl.x + mask[dir][0] * battle_config.skill_range_leniency, + sd->bl.y + mask[dir][1] * battle_config.skill_range_leniency); + } else + return 0; + } + } if(bl->type==BL_PC) { target_sd=(struct map_session_data*)bl; @@ -7745,13 +7804,12 @@ int skill_use_id( struct map_session_data *sd, int target_id, case WE_MALE: case WE_FEMALE: { + struct map_session_data *p_sd = pc_get_partner(sd); + nullpo_retr (0, p_sd) if(skill_num == WE_MALE && sd->status.hp <= ((15*sd->status.max_hp)/100)) // Requires more than 15% of Max HP for WE_MALE return 0; if(skill_num == WE_FEMALE && sd->status.sp <= ((15*sd->status.max_sp)/100)) // Requires more than 15% of Max SP for WE_FEMALE return 0; - struct map_session_data *p_sd = NULL; - if((p_sd = pc_get_partner(sd)) == NULL) - return 0; target_id = p_sd->bl.id; //rangeをもう1回?査 range = skill_get_range(skill_num,skill_lv); @@ -7905,7 +7963,7 @@ int skill_use_pos( struct map_session_data *sd, /* if(map[sd->bl.m].flag.gvg && (skill_num == SM_ENDURE || skill_num == AL_TELEPORT || - skill_num == AL_WARP || skill_num == WZ_ICEWALL || + skill_num == AL_WARP || skill_num == WZ_ICEWALL || skill_num == TF_BACKSLIDING)) return 0;*/ @@ -8023,7 +8081,7 @@ int skill_castcancel(struct block_list *bl,int type) } sd->skilltimer=-1; clif_skillcastcancel(bl); - } + } return 0; }else if(bl->type==BL_MOB){ @@ -8695,12 +8753,14 @@ int skill_status_change_timer_sub(struct block_list *bl, va_list ap ) break; case SC_RUWACH: /* ルアフ */ if( (*battle_get_option(bl))&6 ){ - skill_status_change_end( bl, SC_HIDING, -1); - skill_status_change_end( bl, SC_CLOAKING, -1); if(battle_check_target( src,bl, BCT_ENEMY ) > 0) { - struct status_change *sc_data = battle_get_sc_data(bl); - if (sc_data) + struct status_change *sc_data = battle_get_sc_data(bl); // check whether the target is hiding/cloaking [celest] + if (sc_data && (sc_data[SC_HIDING].timer != -1 || // if the target is using a special hiding, i.e not using normal hiding/cloaking, don't bother + sc_data[SC_CLOAKING].timer != -1)) { + skill_status_change_end( bl, SC_HIDING, -1); + skill_status_change_end( bl, SC_CLOAKING, -1); skill_attack(BF_MAGIC,src,src,bl,AL_RUWACH,sc_data[type].val1,tick,0); + } } } break; @@ -8712,7 +8772,7 @@ int skill_status_change_timer_sub(struct block_list *bl, va_list ap ) * ステ?タス異常終了 *------------------------------------------ */ -int skill_status_change_end(struct block_list* bl, int type, int tid) +int skill_status_change_end(struct block_list* bl, int type, int tid) { struct status_change* sc_data; int opt_flag=0, calc_flag = 0; @@ -8798,8 +8858,6 @@ int skill_status_change_end(struct block_list* bl, int type, int tid) case SC_MELTDOWN: /* メルトダウン */ // Celest case SC_EDP: - case SC_MARIONETTE: - case SC_MARIONETTE2: case SC_SLOWDOWN: case SC_SPEEDUP0: /* case SC_LEADERSHIP: @@ -8816,7 +8874,7 @@ int skill_status_change_end(struct block_list* bl, int type, int tid) break; case SC_BERSERK: /* バ?サ?ク */ calc_flag = 1; - clif_status_change(bl,SC_INCREASEAGI,0); /* アイコン消去 */ + clif_status_change(bl,SC_INCREASEAGI,0); /* アイコン消去 */ break; case SC_DEVOTION: /* ディボ?ション */ { @@ -8900,14 +8958,32 @@ int skill_status_change_end(struct block_list* bl, int type, int tid) case SC_CONFUSION: { struct map_session_data *sd=NULL; - if(bl->type == BL_PC && (sd=(struct map_session_data *)bl)){ + if(bl->type == BL_PC && (sd=(struct map_session_data *)bl)){ sd->next_walktime = -1; } } break; - } - if(bl->type==BL_PC && type 0 && + (sc_data = battle_get_sc_data(pbl)) && + sc_data[type2].timer != -1) + skill_status_change_end(pbl, type2, -1); + } + calc_flag = 1; + } + break; + } + + if(bl->type==BL_PC && + (type 0) { sc_data[type].timer = add_timer( 500 + tick, skill_status_change_timer, @@ -9437,7 +9513,7 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data) 1000 + tick, skill_status_change_timer, bl->id, data); return 0; - } + } } break; @@ -9451,7 +9527,7 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data) bl->id, data); } break;*/ - + // Celest case SC_CONFUSION: { @@ -9475,7 +9551,159 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data) } } break; - } + + case SC_GOSPEL: + { + int calc_flag = 0; + if (sc_data[type].val3 > 0) { + sc_data[type].val3 = 0; + calc_flag = 1; + } + if(sd && sc_data[type].val4 == BCT_SELF){ + int hp, sp; + hp = (sc_data[type].val1 > 5) ? 45 : 30; + sp = (sc_data[type].val1 > 5) ? 35 : 20; + if(sd->status.hp - hp > 0 && + sd->status.sp - sp > 0){ + sd->status.hp -= hp; + sd->status.sp -= sp; + clif_updatestatus(sd,SP_HP); + clif_updatestatus(sd,SP_SP); + if ((sc_data[type].val2 -= 10000) > 0) { + sc_data[type].timer = add_timer( + 10000+tick, skill_status_change_timer, + bl->id, data); + return 0; + } + } + } else if (sd && sc_data[type].val4 == BCT_PARTY) { + int i; + switch ((i = rand() % 12)) { + case 1: // heal between 100-1000 + { + struct block_list tbl; + int heal = rand() % 900 + 100; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,AL_HEAL,heal,1); + battle_heal(NULL,bl,heal,0,0); + } + break; + case 2: // end negative status + { + int j; + for (j=0; j<4; j++) + if(sc_data[i + SC_POISON].timer!=-1) { + skill_status_change_end(bl,j,-1); + break; + } + } + break; + case 3: // +25% resistance to negative status + case 4: // +25% max hp + case 5: // +25% max sp + case 6: // +2 to all stats + case 11: // +25% armor and vit def + case 12: // +8% atk + case 13: // +5% flee + case 14: // +5% hit + sc_data[type].val3 = i; + if (i == 6 || + (i >= 11 && i <= 14)) + calc_flag = 1; + break; + case 7: // level 5 bless + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,AL_BLESSING,5,1); + skill_status_change_start(bl,SkillStatusChangeTable[AL_BLESSING],5,0,0,0,10000,0 ); + } + break; + case 8: // level 5 increase agility + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,AL_INCAGI,5,1); + skill_status_change_start(bl,SkillStatusChangeTable[AL_INCAGI],5,0,0,0,10000,0 ); + } + break; + case 9: // holy element to weapon + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,PR_ASPERSIO,1,1); + skill_status_change_start(bl,SkillStatusChangeTable[PR_ASPERSIO],1,0,0,0,10000,0 ); + } + break; + case 10: // holy element to armour + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,PR_BENEDICTIO,1,1); + skill_status_change_start(bl,SkillStatusChangeTable[PR_BENEDICTIO],1,0,0,0,10000,0 ); + } + break; + default: + break; + } + } else if (sc_data[type].val4 == BCT_ENEMY) { + int i; + switch ((i = rand() % 8)) { + case 1: // damage between 300-800 + case 2: // damage between 150-550 (ignore def) + battle_damage(NULL, bl, rand() % 500,0); // temporary damage + break; + case 3: // random status effect + { + int effect[3] = { + SC_CURSE, + SC_BLIND, + SC_POISON }; + skill_status_change_start(bl,effect[rand()%3],1,0,0,0,10000,0 ); + } + break; + case 4: // level 10 provoke + { + struct block_list tbl; + tbl.id = 0; + tbl.m = bl->m; + tbl.x = bl->x; + tbl.y = bl->y; + clif_skill_nodamage(&tbl,bl,SM_PROVOKE,1,1); + skill_status_change_start(bl,SkillStatusChangeTable[SM_PROVOKE],10,0,0,0,10000,0 ); + } + break; + case 5: // 0 def + case 6: // 0 atk + case 7: // 0 flee + case 8: // -75% move speed and aspd + sc_data[type].val3 = i; + calc_flag = 1; + break; + default: + break; + } + } + if (sd && calc_flag) + pc_calcstatus (sd, 0); + } + break; + } return skill_status_change_end( bl,type,tid ); } @@ -9510,7 +9738,7 @@ int skill_encchant_eremental_end(struct block_list *bl,int type) * ステ?タス異常開始 *------------------------------------------ */ -int skill_status_change_start(struct block_list *bl, int type, int val1, int val2, int val3, int val4, int tick, int flag) +int skill_status_change_start(struct block_list *bl, int type, int val1, int val2, int val3, int val4, int tick, int flag) { struct map_session_data *sd = NULL; struct status_change* sc_data; @@ -9660,7 +9888,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val break; case SC_DECREASEAGI: /* 速度減少 */ if (bl->type == BL_PC) // Celest - tick>>=1; + tick>>=1; calc_flag = 1; if(sc_data[SC_INCREASEAGI].timer!=-1 ) skill_status_change_end(bl,SC_INCREASEAGI,-1); @@ -9718,7 +9946,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val calc_flag = 1; break; case SC_POISONREACT: /* ポイズンリアクト */ - val2=val1/2 + val1%2; // [Celest] + val2=val1/2 + val1%2; // [Celest] break; case SC_IMPOSITIO: /* インポシティオマヌス */ calc_flag = 1; @@ -9756,7 +9984,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val case SC_TRICKDEAD: /* 死んだふり */ if (bl->type == BL_PC) { pc_stopattack((struct map_session_data *)sd); - } + } break; case SC_QUAGMIRE: /* クァグマイア */ calc_flag = 1; @@ -9814,7 +10042,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val case SC_STRIPSHIELD: if (val2==0) val2=85; break; - case SC_STRIPARMOR: + case SC_STRIPARMOR: case SC_STRIPHELM: case SC_CP_WEAPON: case SC_CP_SHIELD: @@ -9970,7 +10198,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val case SC_WEDDING: //結婚用(結婚衣裳になって?くのが?いとか) { time_t timer; - + calc_flag = 1; tick = 10000; if(!val2) @@ -9983,7 +10211,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val if(!battle_config.muting_players) break; - + tick = 60000; if(!val2) val2 = time(&timer); @@ -10243,6 +10471,30 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val case SC_BASILICA: // [celest] break; + case SC_GOSPEL: + if (val4 == BCT_SELF) { // self effect + int i; + if (sd) { + sd->canact_tick += tick; + sd->canmove_tick += tick; + } + val2 = tick; + tick = 1000; + for (i=0; i<=26; i++) { + if(sc_data[i].timer!=-1) + skill_status_change_end(bl,i,-1); + } + for (i=58; i<=62; i++) { + if(sc_data[i].timer!=-1) + skill_status_change_end(bl,i,-1); + } + for (i=132; i<=136; i++) { + if(sc_data[i].timer!=-1) + skill_status_change_end(bl,i,-1); + } + } + break; + case SC_MARIONETTE: /* マリオネットコントロ?ル */ case SC_MARIONETTE2: val2 = tick; @@ -10284,6 +10536,9 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val // calc_flag = 1; // not sure of effects yet [celest] break; + case SC_PRESERVE: + break; + case SC_BLOCKSKILL: if (!tick) tick = 60000; if (!val3) val3 = -1; @@ -10307,7 +10562,8 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val return 0; } - if(bl->type==BL_PC && typetype==BL_PC && + (typevalstr=NULL; } - map_freeblock(group->unit); /* free()の替わり */ + map_freeblock(group->unit); /* aFree()の替わり */ group->unit=NULL; group->src_id=0; group->group_id=0; @@ -11243,9 +11491,9 @@ int skill_unit_move_unit_group( struct skill_unit_group *group, int m,int dx,int int i,j, *r_flag, *s_flag, *m_flag; struct skill_unit *unit1; struct skill_unit *unit2; - r_flag = (int *) aMalloc(sizeof(int) * group->unit_count); - s_flag = (int *) aMalloc(sizeof(int) * group->unit_count); - m_flag = (int *) aMalloc(sizeof(int) * group->unit_count); + r_flag = (int *) aMallocA(sizeof(int) * group->unit_count); + s_flag = (int *) aMallocA(sizeof(int) * group->unit_count); + m_flag = (int *) aMallocA(sizeof(int) * group->unit_count); memset(r_flag,0, sizeof(int) * group->unit_count);// ?承フラグ memset(s_flag,0, sizeof(int) * group->unit_count);// ?承フラグ memset(m_flag,0, sizeof(int) * group->unit_count);// ?承フラグ @@ -11316,9 +11564,9 @@ int skill_unit_move_unit_group( struct skill_unit_group *group, int m,int dx,int } } } - free(r_flag); - free(s_flag); - free(m_flag); + aFree(r_flag); + aFree(s_flag); + aFree(m_flag); } } return 0; @@ -11470,7 +11718,7 @@ int skill_produce_mix( struct map_session_data *sd, else make_per = 1000 + sd->status.base_level*30 + sd->paramc[3]*20 + sd->paramc[4]*15 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300; } else if (skill_produce_db[idx].req_skill == ASC_CDP) { - make_per = 2000 + 40*sd->paramc[4] + 20*sd->paramc[5]; + make_per = 2000 + 40*sd->paramc[4] + 20*sd->paramc[5]; //make_per = 20 + (20*sd->paramc[4])/50 + (20*sd->paramc[5])/100; } else { if(nameid == 998) @@ -11493,7 +11741,7 @@ int skill_produce_mix( struct map_session_data *sd, if(make_per < 1) make_per = 1; - if(skill_produce_db[idx].req_skill==AM_PHARMACY || + if(skill_produce_db[idx].req_skill==AM_PHARMACY || skill_produce_db[idx].req_skill==ASC_CDP) { if( battle_config.pp_rate!=100 ) make_per=make_per*battle_config.pp_rate/100; @@ -12059,7 +12307,7 @@ int skill_readdb(void) i -= 9500; else if(i<=0 || i>MAX_SKILL_DB) continue; - + memset(split2,0,sizeof(split2)); for(j=0,p=split[1];j blank) + new_++; + if (new_ > blank) return; // 種類数超過 break; case ADDITEM_OVERAMOUNT: diff --git a/src/txt-converter/char/char-converter.c b/src/txt-converter/char/char-converter.c index 7b35fda63..1c5028d7e 100644 --- a/src/txt-converter/char/char-converter.c +++ b/src/txt-converter/char/char-converter.c @@ -16,16 +16,16 @@ #define STORAGE_MEMINC 16 - + #include "char.h" #include "../../common/strlib.h" #ifdef MEMWATCH #include "memwatch.h" #endif - + char pet_txt[256]="save/pet.txt"; -char storage_txt[256]="save/storage.txt"; +char storage_txt[256]="save/storage.txt"; MYSQL mysql_handle; MYSQL_RES* sql_res ; @@ -89,18 +89,18 @@ int inter_pet_fromstr(char *str, struct s_pet *p) int s; int tmp_int[16]; char tmp_str[256]; - + memset(p, 0, sizeof(struct s_pet)); - + // printf("sscanf pet main info\n"); s=sscanf(str,"%d, %d,%[^\t]\t%d, %d, %d, %d, %d, %d, %d, %d, %d", &tmp_int[0], &tmp_int[1], tmp_str, &tmp_int[2], &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10]); if(s!=12) return 1; - + p->pet_id = tmp_int[0]; - p->class = tmp_int[1]; + p->class_ = tmp_int[1]; memcpy(p->name, tmp_str, 24); p->account_id = tmp_int[2]; p->char_id = tmp_int[3]; @@ -126,11 +126,11 @@ int inter_pet_fromstr(char *str, struct s_pet *p) //--------------------------------------------------------- int inter_pet_tosql(int pet_id, struct s_pet *p) { //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) - + char tmp_sql[65535]; MYSQL_RES* sql_res ; MYSQL_ROW sql_row ; - + jstrescapecpy (t_name, p->name); if(p->hungry < 0) p->hungry = 0; @@ -148,19 +148,19 @@ int inter_pet_tosql(int pet_id, struct s_pet *p) { sql_row = mysql_fetch_row(sql_res); //row fetching if (!sql_row) //no row -> insert sprintf(tmp_sql,"INSERT INTO `pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) VALUES ('%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - p->pet_id, p->class, t_name, p->account_id, p->char_id, p->level, p->egg_id, + p->pet_id, p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate); else //row reside -> updating sprintf(tmp_sql, "UPDATE `pet` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'", - p->class, t_name, p->account_id, p->char_id, p->level, p->egg_id, + p->class_, t_name, p->account_id, p->char_id, p->level, p->egg_id, p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id); mysql_free_result(sql_res) ; //resource free if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } - + printf ("pet dump success! - %d:%s\n", pet_id, p->name); - + return 0; } @@ -168,22 +168,22 @@ int storage_tosql(int account_id,struct storage *p){ // id -> DB dump // storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} int i,j; - + j=0; - + //printf ("starting storage dump to DB - id: %d\n", account_id); - + //delete old data. sprintf(tmp_sql,"DELETE FROM `storage` WHERE `account_id`='%d'",account_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } - + //printf ("all storage item was deleted ok\n"); - + for(i=0;istorage[i].nameid , p->storage[i].amount); - + if( (p->storage[i].nameid) && (p->storage[i].amount) ){ sprintf(tmp_sql,"INSERT INTO `storage` (`account_id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`card0`,`card1`,`card2`,`card3`,`broken`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", p->account_id, p->storage[i].nameid, p->storage[i].amount, p->storage[i].equip, @@ -212,7 +212,7 @@ int storage_fromstr(char *str, struct storage *p) if(set!=2) return 0; if(str[next]=='\n' || str[next]=='\r') - return 1; + return 1; next++; for(i=0;str[next] && str[next]!='\t';i++){ if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", @@ -233,7 +233,7 @@ int storage_fromstr(char *str, struct storage *p) p->storage[i].broken = tmp_int[11]; next += len; if (str[next] == ' ') - next++; + next++; } else if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", @@ -251,12 +251,12 @@ int storage_fromstr(char *str, struct storage *p) p->storage[i].card[1] = tmp_int[8]; p->storage[i].card[2] = tmp_int[9]; p->storage[i].card[3] = tmp_int[10]; - p->storage[i].broken = 0; + p->storage[i].broken = 0; next += len; if (str[next] == ' ') - next++; + next++; } - + else return 0; } return 1; @@ -337,7 +337,7 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) { p->char_id = tmp_int[0]; p->account_id = tmp_int[1]; p->char_num = tmp_int[2]; - p->class = tmp_int[3]; + p->class_ = tmp_int[3]; p->base_level = tmp_int[4]; p->job_level = tmp_int[5]; p->base_exp = tmp_int[6]; @@ -508,10 +508,10 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) { //========================================================================================================== int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ int i,save_flag; - + save_flag = char_id; printf("request save char data... (%d)\n",char_id); - + //`char`( `char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`, //9 //`str`,`agi`,`vit`,`int`,`dex`,`luk`, //15 //`max_hp`,`hp`,`max_sp`,`sp`,`status_point`,`skill_point`, //21 @@ -525,7 +525,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ "`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d'," "`hair`='%d',`hair_color`='%d',`clothes_color`='%d',`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `partner_id` = '%d'", - char_id,p->account_id,p->char_num,p->name,p->class, p->base_level, p->job_level, + char_id,p->account_id,p->char_num,p->name,p->class_, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, @@ -535,17 +535,17 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ p->last_point.map, p->last_point.x, p->last_point.y, p->save_point.map, p->save_point.x, p->save_point.y, p->partner_id ); - + if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) ); } - + //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) sprintf(tmp_sql,"DELETE FROM `memo` WHERE `char_id`='%d'",char_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `memo`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;i<10;i++){ if(p->memo_point[i].map[0]){ @@ -560,7 +560,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `inventory`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;iinventory[i].nameid){ @@ -579,7 +579,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `cart_inventory`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;icart[i].nameid){ @@ -593,14 +593,14 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } } - - + + //`skill` (`char_id`, `id`, `lv`) sprintf(tmp_sql,"DELETE FROM `skill` WHERE `char_id`='%d'",char_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `skill`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;iskill[i].id){ @@ -618,7 +618,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `global_reg_value`)- %s\n", mysql_error(&mysql_handle) ); } - + //insert here. for(i=0;iglobal_reg_num;i++){ if(p->global_reg[i].value !=0){ @@ -629,10 +629,10 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } } - + printf("saving char is done... (%d)\n",char_id); save_flag = 0; - + return 0; } //========================================================================================================== @@ -645,7 +645,7 @@ int mmo_char_init(void){ char input; FILE *fp; - + //DB connection initialized mysql_init(&mysql_handle); printf("Connect DB server.... (inter server)\n"); @@ -658,7 +658,7 @@ int mmo_char_init(void){ else { printf ("connect success! (inter server)\n"); } - + printf("Warning : Make sure you backup your databases before continuing!\n"); @@ -667,14 +667,14 @@ int mmo_char_init(void){ if(input == 'y' || input == 'Y'){ printf("\nConverting Character Database...\n"); fp=fopen("save/athena.txt","r"); - char_dat=malloc(sizeof(char_dat[0])*256); + char_dat = (struct mmo_charstatus*)malloc(sizeof(char_dat[0])*256); char_max=256; if(fp==NULL) return 0; while(fgets(line, 65535, fp)){ if(char_num>=char_max){ char_max+=256; - char_dat=realloc(char_dat, sizeof(char_dat[0]) *char_max); + char_dat = (struct mmo_charstatus*)realloc(char_dat, sizeof(char_dat[0]) *char_max); } memset(&char_dat[char_num], 0, sizeof(char_dat[0])); ret=mmo_char_fromstr(line, &char_dat[char_num]); @@ -689,8 +689,8 @@ int mmo_char_init(void){ printf("char data convert end\n"); fclose(fp); } - - while(getchar() != '\n'); + + while(getchar() != '\n'); printf("\nDo you wish to convert your Storage Database to SQL? (y/n) : "); input=getchar(); if(input == 'y' || input == 'Y') { @@ -700,14 +700,14 @@ int mmo_char_init(void){ printf("cant't read : %s\n",storage_txt); return 0; } - + while(fgets(line,65535,fp)){ set=sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]); if(set==2) { if(i==0){ - storage=malloc(sizeof(struct storage)); + storage = (struct storage*)malloc(sizeof(struct storage)); }else{ - storage=realloc(storage,sizeof(struct storage)*(i+1)); + storage = (struct storage*)realloc(storage,sizeof(struct storage)*(i+1)); } memset(&storage[i],0,sizeof(struct storage)); storage[i].account_id=tmp_int[0]; @@ -718,7 +718,7 @@ int mmo_char_init(void){ } fclose(fp); } - + while(getchar() != '\n'); printf("\nDo you wish to convert your Pet Database to SQL? (y/n) : "); input=getchar(); @@ -726,8 +726,8 @@ int mmo_char_init(void){ printf("\nConverting Pet Database...\n"); if( (fp=fopen(pet_txt,"r")) ==NULL ) return 1; - - p=malloc(sizeof(struct s_pet)); + + p = (struct s_pet*)malloc(sizeof(struct s_pet)); while(fgets(line, sizeof(line), fp)){ if(p==NULL){ printf("int_pet: out of memory!\n"); @@ -792,7 +792,7 @@ int inter_config_read(const char *cfgName) { } } fclose(fp); - + printf("Reading interserver configuration: Done\n"); return 0; @@ -825,7 +825,7 @@ int char_config_read(const char *cfgName) { } fclose(fp); printf("Reading configuration: Done\n"); - + return 0; } diff --git a/src/txt-converter/char/char.h b/src/txt-converter/char/char.h index b5864b31c..e1d5c90dc 100644 --- a/src/txt-converter/char/char.h +++ b/src/txt-converter/char/char.h @@ -24,9 +24,9 @@ struct mmo_map_server{ char map[MAX_MAP_PER_SERVER][16]; }; -int mapif_sendall(unsigned char *buf,unsigned int len); -int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len); -int mapif_send(int fd,unsigned char *buf,unsigned int len); +int mapif_sendall(char *buf,unsigned int len); +int mapif_sendallwos(int fd,char *buf,unsigned int len); +int mapif_send(int fd,char *buf,unsigned int len); extern int autosave_interval; diff --git a/src/txt-converter/common/mmo.h b/src/txt-converter/common/mmo.h index eb02b6879..e8ef2b987 100644 --- a/src/txt-converter/common/mmo.h +++ b/src/txt-converter/common/mmo.h @@ -87,7 +87,7 @@ struct s_pet { int account_id; int char_id; int pet_id; - short class; + short class_; short level; short egg_id;//pet egg id short equip;//pet equip name_id @@ -105,7 +105,7 @@ struct mmo_charstatus { int base_exp,job_exp,zeny; - short class; + short class_; short status_point,skill_point; int hp,max_hp,sp,max_sp; short option,karma,manner; @@ -168,7 +168,7 @@ struct party { struct guild_member { int account_id, char_id; - short hair,hair_color,gender,class,lv; + short hair,hair_color,gender,class_,lv; int exp,exp_payper; short online,position; int rsv1,rsv2; @@ -237,8 +237,8 @@ struct guild_castle { int Ghp4; int Ghp5; int Ghp6; - int Ghp7; - int GID0; + int Ghp7; + int GID0; int GID1; int GID2; int GID3; diff --git a/src/txt-converter/login/login-converter.c b/src/txt-converter/login/login-converter.c index a277ca949..f452d70aa 100644 --- a/src/txt-converter/login/login-converter.c +++ b/src/txt-converter/login/login-converter.c @@ -40,7 +40,7 @@ struct { int sex,delflag; } auth_fifo[AUTH_FIFO_SIZE]; int auth_fifo_pos=0; -struct { +struct auth_dat_ { int account_id, sex; char userid[24], pass[24], lastlogin[24]; int logincount; @@ -72,7 +72,7 @@ char db_server_logindb[32] = "ragnarok"; int isGM(int account_id) { struct gm_account *p; - p = numdb_search(gm_account_db,account_id); + p = (struct gm_account*)numdb_search(gm_account_db,account_id); if( p == NULL) return 0; return p->level; @@ -95,7 +95,7 @@ int read_gm_account() if(line[0] == '/' || line[1] == '/' || line[2] == '/') continue; - p=malloc(sizeof(struct gm_account)); + p = (struct gm_account*)malloc(sizeof(struct gm_account)); if(p==NULL){ printf("gm_account: out of memory!\n"); exit(0); @@ -145,7 +145,7 @@ int mmo_auth_init(void) fp=fopen("save/account.txt","r"); - auth_dat=malloc(sizeof(auth_dat[0])*256); + auth_dat = (struct auth_dat_*)malloc(sizeof(auth_dat[0])*256); auth_max=256; if(fp==NULL) return 0; -- cgit v1.2.3-70-g09d2 From 1310c6d32bed847857db9ca574b7a69fda640620 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Sun, 23 Jan 2005 21:55:17 +0000 Subject: forgot something... git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@970 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/grfio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/grfio.c') diff --git a/src/common/grfio.c b/src/common/grfio.c index 6afd1d668..013c21c74 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -282,7 +282,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; @@ -313,7 +313,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; -- cgit v1.2.3-70-g09d2 From 60c5d7f50c39c55f1ac7121fb1391e4c49966824 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Mon, 24 Jan 2005 00:15:41 +0000 Subject: Some more changes for g++ git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@972 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 3 +- src/char/char.c | 8 ++--- src/char/char.h | 6 ++-- src/char_sql/char.c | 12 +++---- src/char_sql/char.h | 6 ++-- src/common/db.c | 12 ++++--- src/common/grfio.c | 23 +++++++------ src/ladmin/ladmin.c | 8 ++--- src/login/login.c | 20 +++++------ src/login_sql/login.c | 10 +++--- src/map/chrif.c | 94 +++++++++++++++++++++++++-------------------------- src/map/map.c | 18 +++++----- 12 files changed, 113 insertions(+), 107 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index e424cf83c..02ef7b0b3 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,7 +1,8 @@ Date Added 01/23 - * Reverted back some of the char* changes [SVN 970] [Ajarn] + * Fixed the sizeof errors in g++ [SVN 972] [Ajarn] + * Reverted back some of the char* changes [SVN 972] [Ajarn] * Changed parse_script to now return char* [SVN 969] [Ajarn] * Converted run_script and run_script_main from unsigned char* to char* [SVN 969] [Ajarn] diff --git a/src/char/char.c b/src/char/char.c index 56d070e5d..fb154c51c 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -152,7 +152,7 @@ int char_log(char *fmt, ...) { fprintf(logfp, RETCODE); else { gettimeofday(&tv, NULL); - strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", localtime(&(tv.tv_sec))); + strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", localtime((const time_t*)&(tv.tv_sec))); sprintf(tmpstr + 19, ".%03d: %s", (int)tv.tv_usec / 1000, fmt); vfprintf(logfp, tmpstr, ap); } @@ -2971,7 +2971,7 @@ int parse_console(char *buf) { } // 全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) -int mapif_sendall(char *buf, unsigned int len) { +int mapif_sendall(unsigned char *buf, unsigned int len) { int i, c; c = 0; @@ -2987,7 +2987,7 @@ int mapif_sendall(char *buf, unsigned int len) { } // 自分以外の全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) -int mapif_sendallwos(int sfd, char *buf, unsigned int len) { +int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { int i, c; c = 0; @@ -3002,7 +3002,7 @@ int mapif_sendallwos(int sfd, char *buf, unsigned int len) { return c; } // MAPサーバーにデータ送信(map鯖生存確認有り) -int mapif_send(int fd, char *buf, unsigned int len) { +int mapif_send(int fd, unsigned char *buf, unsigned int len) { int i; if (fd >= 0) { diff --git a/src/char/char.h b/src/char/char.h index c70facba1..3ee2f9f6d 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -20,9 +20,9 @@ struct mmo_map_server{ int search_character_index(char* character_name); char * search_character_name(int index); -int mapif_sendall(char *buf, unsigned int len); -int mapif_sendallwos(int fd,char *buf, unsigned int len); -int mapif_send(int fd,char *buf, unsigned int len); +int mapif_sendall(unsigned char *buf, unsigned int len); +int mapif_sendallwos(int fd,unsigned char *buf, unsigned int len); +int mapif_send(int fd,unsigned char *buf, unsigned int len); int char_log(char *fmt, ...); diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 876ea991d..7c0f75737 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -1219,11 +1219,11 @@ int make_new_char_sql(int fd, unsigned char *dat) { // Check Authorised letters/symbols in the name of the character if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised - for (i = 0; i < strlen(dat); i++) + for (i = 0; i < strlen(const char*dat); i++) if (strchr(char_name_letters, dat[i]) == NULL) return -1; } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden - for (i = 0; i < strlen(dat); i++) + for (i = 0; i < strlen(const char*)dat); i++) if (strchr(char_name_letters, dat[i]) != NULL) return -1; } // else, all letters/symbols are authorised (except control char removed before) @@ -2763,7 +2763,7 @@ int parse_char(int fd) { if (server_fd[i] < 0) break; } - if (i == MAX_MAP_SERVERS || strcmp(RFIFOP(fd,2), userid) || strcmp(RFIFOP(fd,26), passwd)) { + if (i == MAX_MAP_SERVERS || strcmp((const char*)RFIFOP(fd,2), userid) || strcmp((const char*)RFIFOP(fd,26), passwd)) { WFIFOB(fd,2) = 3; WFIFOSET(fd, 3); } else { @@ -2851,7 +2851,7 @@ int parse_console(char *buf) { } // MAP send all -int mapif_sendall(char *buf, unsigned int len) { +int mapif_sendall(unsigned char *buf, unsigned int len) { int i, c; int fd; @@ -2867,7 +2867,7 @@ int mapif_sendall(char *buf, unsigned int len) { return c; } -int mapif_sendallwos(int sfd, char *buf, unsigned int len) { +int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { int i, c; int fd; @@ -2883,7 +2883,7 @@ int mapif_sendallwos(int sfd, char *buf, unsigned int len) { return c; } -int mapif_send(int fd, char *buf, unsigned int len) { +int mapif_send(int fd, unsigned char *buf, unsigned int len) { int i; if (fd >= 0) { diff --git a/src/char_sql/char.h b/src/char_sql/char.h index 17a938780..c7261650b 100644 --- a/src/char_sql/char.h +++ b/src/char_sql/char.h @@ -41,9 +41,9 @@ struct itemtemp{ struct itemtmp equip[MAX_GUILD_STORAGE],notequip[MAX_GUILD_STORAGE]; }; int memitemdata_to_sql(struct itemtemp mapitem, int eqcount, int noteqcount, int char_id,int tableswitch); -int mapif_sendall(char *buf,unsigned int len); -int mapif_sendallwos(int fd,char *buf,unsigned int len); -int mapif_send(int fd,char *buf,unsigned int len); +int mapif_sendall(unsigned char *buf,unsigned int len); +int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len); +int mapif_send(int fd,unsigned char *buf,unsigned int len); extern int autosave_interval; extern char db_path[]; diff --git a/src/common/db.c b/src/common/db.c index d76b7a44c..12d54176c 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -42,18 +42,20 @@ static void free_dbn(struct dbn* add_dbn) } #endif +// maybe change the void* to const char* ??? static int strdb_cmp(struct dbt* table,void* a,void* b) { if(table->maxlen) - return strncmp(a,b,table->maxlen); - return strcmp(a,b); + return strncmp((const char*)a,(const char*)b,table->maxlen); + return strcmp((const char*)a,(const char*)b); } +// maybe change the void* to unsigned char* ??? static unsigned int strdb_hash(struct dbt* table,void* a) { int i; unsigned int h; - unsigned char *p=a; + unsigned char *p = (unsigned char*)a; i=table->maxlen; if(i==0) i=0x7fffffff; @@ -131,14 +133,14 @@ void * db_search2(struct dbt *table, const char *key) { int i,sp; struct dbn *p,*pn,*stack[64]; - int slen = strlen(key); + int slen = strlen(key); for(i=0;iht[i])==NULL) continue; sp=0; while(1){ - if (strnicmp(key, p->key, slen) == 0) + if (strnicmp(key, (const char*)p->key, slen) == 0) return p->data; if((pn=p->left)!=NULL){ if(p->right){ diff --git a/src/common/grfio.c b/src/common/grfio.c index 013c21c74..6454d5048 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -656,7 +656,7 @@ void* grfio_read(char *fname) * Resource filename decode *------------------------------------------ */ -static unsigned char * decode_filename(unsigned char *buf,int len) +static char * decode_filename(unsigned char *buf,int len) { int lop; for(lop=0;lopsizeof(aentry.fn)-1){ + if(strlen(fname)>sizeof(aentry.fn)-1){ printf("file name too long : %s\n",fname); aFree(grf_filelist); exit(1); } srclen=0; - if((period_ptr=strrchr((const char *) fname,'.'))!=NULL){ + if((period_ptr=strrchr(fname,'.'))!=NULL){ for(lop=0;lop<4;lop++) { if(strcmpi(period_ptr,".gnd\0.gat\0.act\0.str"+lop*5)==0) break; @@ -750,7 +750,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, (const char *) fname,sizeof(aentry.fn)-1); + strncpy(aentry.fn, 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 @@ -777,13 +777,13 @@ static int grfio_entryread(char *gfname,int gentry) return 4; } - rBuf = (unsigned char *) aCallocA( rSize , 1); // Get a Read Size + rBuf = (unsigned char *)aCallocA( rSize , 1); // Get a Read Size if (rBuf==NULL) { fclose(fp); printf("out of memory : grf compress entry table buffer\n"); return 3; } - grf_filelist = (unsigned char *) aCallocA( eSize , 1); // Get a Extend Size + grf_filelist = (unsigned char *)aCallocA( eSize , 1); // Get a Extend Size if (grf_filelist==NULL) { aFree(rBuf); fclose(fp); @@ -803,13 +803,14 @@ static int grfio_entryread(char *gfname,int gentry) int ofs2,srclen,srccount,type; FILELIST aentry; - fname = grf_filelist+ofs; - if (strlen((const char *) fname)>sizeof(aentry.fn)-1) { + fname = (char*)(grf_filelist+ofs); + if (strlen(fname)>sizeof(aentry.fn)-1) { printf("grf : file name too long : %s\n",fname); aFree(grf_filelist); exit(1); } - ofs2 = ofs+strlen(grf_filelist+ofs)+1; + //ofs2 = ofs+strlen((char*)(grf_filelist+ofs))+1; + ofs2 = ofs+strlen(fname)+1; type = grf_filelist[ofs2+12]; if(type==1 || type==3 || type==5) { srclen=getlong(grf_filelist+ofs2); diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index 66f5b837f..de177ba8a 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -3316,11 +3316,11 @@ int parse_fromlogin(int fd) { memcpy(md5key, RFIFOP(fd,4), RFIFOW(fd,2) - 4); md5key[sizeof(md5key)-1] = '0'; if (passenc == 1) { - strncpy(md5str, RFIFOP(fd,4), RFIFOW(fd,2) - 4); + strncpy(md5str, (const char*)RFIFOP(fd,4), RFIFOW(fd,2) - 4); strcat(md5str, loginserveradminpassword); } else if (passenc == 2) { strncpy(md5str, loginserveradminpassword, sizeof(loginserveradminpassword)); - strcat(md5str, RFIFOP(fd,4)); + strcat(md5str, (const char*)RFIFOP(fd,4)); } MD5_String2binary(md5str, md5bin); WFIFOW(login_fd,0) = 0x7918; // Request for administation login (encrypted password) @@ -3815,7 +3815,7 @@ int parse_fromlogin(int fd) { case 0x7947: // answer of an account name search if (RFIFOREST(fd) < 30) return 0; - if (strcmp(RFIFOP(fd,6), "") == 0) { + if (strcmp((const char*)RFIFOP(fd,6), "") == 0) { if (defaultlanguage == 'F') { printf("Impossible de trouver le nom du compte [%d]. Le compte n'existe pas.\n", RFIFOL(fd,2)); ladmin_log("Impossible de trouver le nom du compte [%d]. Le compte n'existe pas." RETCODE, RFIFOL(fd,2)); @@ -4032,7 +4032,7 @@ int parse_fromlogin(int fd) { connect_until_time = (time_t)RFIFOL(fd,140); ban_until_time = (time_t)RFIFOL(fd,144); memset(memo, '\0', sizeof(memo)); - strncpy(memo, RFIFOP(fd,150), RFIFOW(fd,148)); + strncpy(memo, (const char*)RFIFOP(fd,150), RFIFOW(fd,148)); if (RFIFOL(fd,2) == -1) { if (defaultlanguage == 'F') { printf("Impossible de trouver le compte [%s]. Le compte n'existe pas.\n", parameters); diff --git a/src/login/login.c b/src/login/login.c index 11c970aca..1a0faddb0 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -186,7 +186,7 @@ int login_log(char *fmt, ...) { else { va_start(ap, fmt); gettimeofday(&tv, NULL); - strftime(tmpstr, 24, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 24, date_format, localtime((const time_t*)&(tv.tv_sec))); sprintf(tmpstr + strlen(tmpstr), ".%03d: %s", (int)tv.tv_usec / 1000, fmt); vfprintf(log_fp, tmpstr, ap); va_end(ap); @@ -326,14 +326,14 @@ int check_ipmask(unsigned int ip, const unsigned char *str) { unsigned int mask = 0, i = 0, m, ip2, a0, a1, a2, a3; unsigned char *p = (unsigned char *)&ip2, *p2 = (unsigned char *)&mask; - if (sscanf(str, "%d.%d.%d.%d/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0) + if (sscanf((const char*)str, "%d.%d.%d.%d/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0) return 0; p[0] = a0; p[1] = a1; p[2] = a2; p[3] = a3; - if (sscanf(str+i, "%d.%d.%d.%d", &a0, &a1, &a2, &a3) == 4) { + if (sscanf((const char*)str+i, "%d.%d.%d.%d", &a0, &a1, &a2, &a3) == 4) { p2[0] = a0; p2[1] = a1; p2[2] = a2; p2[3] = a3; mask = ntohl(mask); - } else if (sscanf(str+i, "%d", &m) == 1 && m >= 0 && m <= 32) { + } else if (sscanf((const char*)(str+i), "%d", &m) == 1 && m >= 0 && m <= 32) { for(i = 0; i < m && i < 32; i++) mask = (mask >> 1) | 0x80000000; } else { @@ -372,7 +372,7 @@ int check_ip(unsigned int ip) { for(i = 0; i < access_allownum; i++) { access_ip = access_allow + i * ACO_STRSIZE; - if (memcmp(access_ip, buf, strlen(access_ip)) == 0 || check_ipmask(ip, access_ip)) { + if (memcmp(access_ip, buf, strlen(access_ip)) == 0 || check_ipmask(ip, (unsigned char*)access_ip)) { if(access_order == ACO_ALLOW_DENY) return 1; // With 'allow, deny' (deny if not allow), allow has priority flag = ACF_ALLOW; @@ -382,7 +382,7 @@ int check_ip(unsigned int ip) { for(i = 0; i < access_denynum; i++) { access_ip = access_deny + i * ACO_STRSIZE; - if (memcmp(access_ip, buf, strlen(access_ip)) == 0 || check_ipmask(ip, access_ip)) { + if (memcmp(access_ip, buf, strlen(access_ip)) == 0 || check_ipmask(ip, (unsigned char*)access_ip)) { //flag = ACF_DENY; // not necessary to define flag return 0; // At this point, if it's 'deny', we refuse connection. } @@ -420,7 +420,7 @@ int check_ladminip(unsigned int ip) { for(i = 0; i < access_ladmin_allownum; i++) { access_ip = access_ladmin_allow + i * ACO_STRSIZE; - if (memcmp(access_ip, buf, strlen(access_ip)) == 0 || check_ipmask(ip, access_ip)) { + if (memcmp(access_ip, buf, strlen(access_ip)) == 0 || check_ipmask(ip, (unsigned char*)access_ip)) { return 1; } } @@ -431,7 +431,7 @@ int check_ladminip(unsigned int ip) { //----------------------------------------------------- // Function to suppress control characters in a string. //----------------------------------------------------- -int remove_control_chars(unsigned char *str) { +int remove_control_chars(char *str) { int i; int change = 0; @@ -448,9 +448,9 @@ int remove_control_chars(unsigned char *str) { //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- -int e_mail_check(unsigned char *email) { +int e_mail_check(char *email) { char ch; - unsigned char* last_arobas; + char* last_arobas; // athena limits if (strlen(email) < 3 || strlen(email) > 39) diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 302e78b9e..c4c8bdafc 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -1177,8 +1177,8 @@ int parse_login(int fd) { printf("client connection request %s from %d.%d.%d.%d\n", RFIFOP(fd, 6), p[0], p[1], p[2], p[3]); - account.userid = RFIFOP(fd, 6); - account.passwd = RFIFOP(fd, 30); + account.userid = (char*)RFIFOP(fd, 6); + account.passwd = (char*)RFIFOP(fd, 30); #ifdef PASSWORDENC account.passwdenc= (RFIFOW(fd,0)==0x64)?0:PASSWORDENC; #else @@ -1186,7 +1186,7 @@ int parse_login(int fd) { #endif result=mmo_auth(&account, fd); - jstrescapecpy(t_uid,RFIFOP(fd, 6)); + jstrescapecpy(t_uid,(char*)RFIFOP(fd, 6)); if(result==-1){ int gm_level = isGM(account.account_id); if (min_level_to_connect > gm_level) { @@ -1392,8 +1392,8 @@ int parse_login(int fd) { printf("server connection request %s @ %d.%d.%d.%d:%d (%d.%d.%d.%d)\n", RFIFOP(fd, 60), RFIFOB(fd, 54), RFIFOB(fd, 55), RFIFOB(fd, 56), RFIFOB(fd, 57), RFIFOW(fd, 58), p[0], p[1], p[2], p[3]); - account.userid = RFIFOP(fd, 2); - account.passwd = RFIFOP(fd, 26); + account.userid = (char*)RFIFOP(fd, 2); + account.passwd = (char*)RFIFOP(fd, 26); account.passwdenc = 0; server_name = RFIFOP(fd,60); result = mmo_auth(&account, fd); diff --git a/src/map/chrif.c b/src/map/chrif.c index f7e6781d6..cda7b42e2 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -50,7 +50,7 @@ static int char_init_done = 0; * *------------------------------------------ */ -void chrif_setuserid(char *id) +void chrif_setuserid(char *id) { strncpy(userid, id, 24); } @@ -59,7 +59,7 @@ void chrif_setuserid(char *id) * *------------------------------------------ */ -void chrif_setpasswd(char *pwd) +void chrif_setpasswd(char *pwd) { strncpy(passwd, pwd, 24); } @@ -68,7 +68,7 @@ void chrif_setpasswd(char *pwd) * *------------------------------------------ */ -void chrif_setip(char *ip) +void chrif_setip(char *ip) { strncpy(char_ip_str, ip, 16); char_ip = inet_addr(char_ip_str); @@ -78,7 +78,7 @@ void chrif_setip(char *ip) * *------------------------------------------ */ -void chrif_setport(int port) +void chrif_setport(int port) { char_port = port; } @@ -87,7 +87,7 @@ void chrif_setport(int port) * *------------------------------------------ */ -int chrif_isconnect(void) +int chrif_isconnect(void) { return chrif_state == 2; } @@ -96,7 +96,7 @@ int chrif_isconnect(void) * *------------------------------------------ */ -int chrif_save(struct map_session_data *sd) +int chrif_save(struct map_session_data *sd) { nullpo_retr(-1, sd); @@ -119,7 +119,7 @@ int chrif_save(struct map_session_data *sd) * *------------------------------------------ */ -int chrif_connect(int fd) +int chrif_connect(int fd) { WFIFOW(fd,0) = 0x2af8; memcpy(WFIFOP(fd,2), userid, 24); @@ -136,7 +136,7 @@ int chrif_connect(int fd) * マップ送信 *------------------------------------------ */ -int chrif_sendmap(int fd) +int chrif_sendmap(int fd) { int i; @@ -167,7 +167,7 @@ int chrif_recvmap(int fd) ip = RFIFOL(fd,4); port = RFIFOW(fd,8); for(i = 10, j = 0; i < RFIFOW(fd,2); i += 16, j++) { - map_setipport(RFIFOP(fd,i), ip, port); + map_setipport((char*)RFIFOP(fd,i), ip, port); // if (battle_config.etc_log) // printf("recv map %d %s\n", j, RFIFOP(fd,i)); } @@ -181,15 +181,15 @@ int chrif_recvmap(int fd) * マップ鯖間移動のためのデータ準備要求 *------------------------------------------ */ -int chrif_changemapserver(struct map_session_data *sd, char *name, int x, int y, int ip, short port) +int chrif_changemapserver(struct map_session_data *sd, char *name, int x, int y, int ip, short port) { int i, s_ip; nullpo_retr(-1, sd); - + if (!sd || char_fd < 1 ) return -1; - + s_ip = 0; for(i = 0; i < fd_max; i++) if (session[i] && session[i]->session_data == sd) { @@ -218,7 +218,7 @@ int chrif_changemapserver(struct map_session_data *sd, char *name, int x, int y, * マップ鯖間移動ack *------------------------------------------ */ -int chrif_changemapserverack(int fd) +int chrif_changemapserverack(int fd) { struct map_session_data *sd = map_id2sd(RFIFOL(fd,2)); @@ -231,7 +231,7 @@ int chrif_changemapserverack(int fd) pc_authfail(sd->fd); return 0; } - clif_changemapserver(sd, RFIFOP(fd,18), RFIFOW(fd,34), RFIFOW(fd,36), RFIFOL(fd,38), RFIFOW(fd,42)); + clif_changemapserver(sd, (char*)RFIFOP(fd,18), RFIFOW(fd,34), RFIFOW(fd,36), RFIFOL(fd,38), RFIFOW(fd,42)); return 0; } @@ -240,7 +240,7 @@ int chrif_changemapserverack(int fd) * *------------------------------------------ */ -int chrif_connectack(int fd) +int chrif_connectack(int fd) { if (RFIFOB(fd,2)) { printf("Connected to char-server failed %d.\n", RFIFOB(fd,2)); @@ -273,7 +273,7 @@ int chrif_connectack(int fd) * *------------------------------------------ */ -int chrif_sendmapack(int fd) +int chrif_sendmapack(int fd) { if (RFIFOB(fd,2)) { printf("chrif : send map list to char server failed %d\n", RFIFOB(fd,2)); @@ -291,7 +291,7 @@ int chrif_sendmapack(int fd) * *------------------------------------------ */ -int chrif_authreq(struct map_session_data *sd) +int chrif_authreq(struct map_session_data *sd) { int i; @@ -319,7 +319,7 @@ int chrif_authreq(struct map_session_data *sd) * *------------------------------------------ */ -int chrif_charselectreq(struct map_session_data *sd) +int chrif_charselectreq(struct map_session_data *sd) { int i, s_ip; @@ -349,7 +349,7 @@ int chrif_charselectreq(struct map_session_data *sd) * キャラ名問い合わせ *------------------------------------------ */ -int chrif_searchcharid(int char_id) +int chrif_searchcharid(int char_id) { if (!char_id || char_fd < 1) return -1; @@ -365,11 +365,11 @@ int chrif_searchcharid(int char_id) * GMに変化要求 *------------------------------------------ */ -int chrif_changegm(int id, const char *pass, int len) +int chrif_changegm(int id, const char *pass, int len) { if (battle_config.etc_log) printf("chrif_changegm: account: %d, password: '%s'.\n", id, pass); - + if (char_fd < 1 ) return -1; @@ -386,14 +386,14 @@ int chrif_changegm(int id, const char *pass, int len) * Change Email *------------------------------------------ */ -int chrif_changeemail(int id, const char *actual_email, const char *new_email) +int chrif_changeemail(int id, const char *actual_email, const char *new_email) { if (battle_config.etc_log) printf("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email); - + if (char_fd < 1 ) return -1; - + WFIFOW(char_fd,0) = 0x2b0c; WFIFOL(char_fd,2) = id; memcpy(WFIFOP(char_fd,6), actual_email, 40); @@ -414,11 +414,11 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) * 5: changesex *------------------------------------------ */ -int chrif_char_ask_name(int id, char * character_name, short operation_type, int year, int month, int day, int hour, int minute, int second) +int chrif_char_ask_name(int id, char * character_name, short operation_type, int year, int month, int day, int hour, int minute, int second) { if (char_fd < 1 ) return -1; - + WFIFOW(char_fd, 0) = 0x2b0e; WFIFOL(char_fd, 2) = id; // account_id of who ask (for answer) -1 if nobody memcpy(WFIFOP(char_fd,6), character_name, 24); @@ -470,7 +470,7 @@ int chrif_changesex(int id, int sex) { * 3: login-server offline *------------------------------------------ */ -int chrif_char_ask_name_answer(int fd) +int chrif_char_ask_name_answer(int fd) { int acc; struct map_session_data *sd; @@ -573,7 +573,7 @@ int chrif_char_ask_name_answer(int fd) * End of GM change (@GM) (modified by Yor) *------------------------------------------ */ -int chrif_changedgm(int fd) +int chrif_changedgm(int fd) { int acc, level; struct map_session_data *sd = NULL; @@ -599,7 +599,7 @@ int chrif_changedgm(int fd) * 性別変化終了 (modified by Yor) *------------------------------------------ */ -int chrif_changedsex(int fd) +int chrif_changedsex(int fd) { int acc, sex, i; struct map_session_data *sd; @@ -671,14 +671,14 @@ int chrif_changedsex(int fd) * アカウント変数保存要求 *------------------------------------------ */ -int chrif_saveaccountreg2(struct map_session_data *sd) +int chrif_saveaccountreg2(struct map_session_data *sd) { int p, j; nullpo_retr(-1, sd); - + if (char_fd < 1 ) return -1; - + p = 8; for(j = 0; j < sd->status.account_reg2_num; j++) { struct global_reg *reg = &sd->status.account_reg2[j]; @@ -700,7 +700,7 @@ int chrif_saveaccountreg2(struct map_session_data *sd) * アカウント変数通知 *------------------------------------------ */ -int chrif_accountreg2(int fd) +int chrif_accountreg2(int fd) { int j, p; struct map_session_data *sd; @@ -722,7 +722,7 @@ int chrif_accountreg2(int fd) * 離婚情報同期要求 *------------------------------------------ */ -int chrif_divorce(int char_id, int partner_id) +int chrif_divorce(int char_id, int partner_id) { struct map_session_data *sd = NULL; @@ -748,7 +748,7 @@ int chrif_divorce(int char_id, int partner_id) * Disconnection of a player (account has been deleted in login-server) by [Yor] *------------------------------------------ */ -int chrif_accountdeletion(int fd) +int chrif_accountdeletion(int fd) { int acc; struct map_session_data *sd; @@ -775,7 +775,7 @@ int chrif_accountdeletion(int fd) * Disconnection of a player (account has been banned of has a status, from login-server) by [Yor] *------------------------------------------ */ -int chrif_accountban(int fd) +int chrif_accountban(int fd) { int acc; struct map_session_data *sd; @@ -865,7 +865,7 @@ int chrif_chardisconnect(struct map_session_data *sd) * Receiving GM accounts and their levels from char-server by [Yor] *------------------------------------------ */ -int chrif_recvgmaccounts(int fd) +int chrif_recvgmaccounts(int fd) { sprintf(tmp_output,"From login-server: receiving information of '"CL_WHITE"%d"CL_RESET"' GM accounts.\n", pc_read_gm_account(fd)); ShowInfo(tmp_output); @@ -877,11 +877,11 @@ int chrif_recvgmaccounts(int fd) * Request to reload GM accounts and their levels: send to char-server by [Yor] *------------------------------------------ */ -int chrif_reloadGMdb(void) +int chrif_reloadGMdb(void) { if (char_fd < 1 ) return -1; - + WFIFOW(char_fd,0) = 0x2af7; WFIFOSET(char_fd, 2); @@ -892,15 +892,15 @@ int chrif_reloadGMdb(void) * Send rates and motd to char server [Wizputer] *------------------------------------------ */ - int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) + int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) { char buf[256]; FILE *fp; int i; - + if (char_fd < 1 ) return -1; - + WFIFOW(char_fd,0) = 0x2b16; WFIFOW(char_fd,2) = base_rate; WFIFOW(char_fd,4) = job_rate; @@ -932,7 +932,7 @@ int chrif_reloadGMdb(void) *----------------------------------------- */ -int chrif_char_offline(struct map_session_data *sd) +int chrif_char_offline(struct map_session_data *sd) { if (char_fd < 1) return -1; @@ -979,7 +979,7 @@ int chrif_char_reset_offline(void) { *----------------------------------------- */ -int chrif_char_online(struct map_session_data *sd) +int chrif_char_online(struct map_session_data *sd) { if (char_fd < 1) return -1; @@ -997,7 +997,7 @@ int chrif_char_online(struct map_session_data *sd) * *------------------------------------------ */ -int chrif_parse(int fd) +int chrif_parse(int fd) { int packet_len, cmd; // only char-server can have an access to here. @@ -1048,7 +1048,7 @@ int chrif_parse(int fd) case 0x2b03: clif_charselectok(RFIFOL(fd,2)); break; case 0x2b04: chrif_recvmap(fd); break; case 0x2b06: chrif_changemapserverack(fd); break; - case 0x2b09: map_addchariddb(RFIFOL(fd,2), RFIFOP(fd,6)); break; + case 0x2b09: map_addchariddb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break; case 0x2b0b: chrif_changedgm(fd); break; case 0x2b0d: chrif_changedsex(fd); break; case 0x2b0f: chrif_char_ask_name_answer(fd); break; @@ -1084,7 +1084,7 @@ int send_users_tochar(int tid, unsigned int tick, int id, int data) { WFIFOW(char_fd,0) = 0x2aff; for (i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) && sd->state.auth && + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd->state.auth && !((battle_config.hide_GM_session || (sd->status.option & OPTION_HIDE)) && pc_isGM(sd))) { WFIFOL(char_fd,6+4*users) = sd->status.char_id; users++; diff --git a/src/map/map.c b/src/map/map.c index dc92d4113..00643faca 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1521,14 +1521,16 @@ struct MAP_CACHE_INFO { int compressed_len; // zilb通せるようにする為の予約 }; // 56 byte -struct { - struct MAP_CACHE_HEAD { - int sizeof_header; - int sizeof_map; - // 上の2つ改変不可 - int nmaps; // マップの個数 - int filesize; - } head; +struct MAP_CACHE_HEAD { + int sizeof_header; + int sizeof_map; + // 上の2つ改変不可 + int nmaps; // マップの個数 + int filesize; +}; + +struct map_cache_ { + struct MAP_CACHE_HEAD head; struct MAP_CACHE_INFO *map; FILE *fp; int dirty; -- cgit v1.2.3-70-g09d2 From 817a048b554ed05fda836a9b55e0dc9a816334b7 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Mon, 24 Jan 2005 03:12:42 +0000 Subject: A lot of changes. login and char server compile under both TXT and SQL under g++. Same for the convertors (login and char). One change that I felt iffy about, but it worked, was the char* buf -> unsinged char* bug in clif.c git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@975 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 2 + src/char/char.c | 28 +++--- src/char/int_guild.c | 14 +-- src/char/int_party.c | 12 +-- src/char/int_pet.c | 18 ++-- src/char/int_storage.c | 20 ++-- src/char/inter.c | 18 ++-- src/char_sql/char.c | 4 +- src/char_sql/int_guild.c | 36 +++---- src/char_sql/int_party.c | 166 ++++++++++++++++---------------- src/char_sql/int_pet.c | 54 +++++------ src/char_sql/int_storage.c | 34 +++---- src/char_sql/inter.c | 50 +++++----- src/char_sql/itemdb.c | 8 +- src/common/grfio.c | 4 +- src/common/malloc.c | 8 +- src/common/strlib.c | 4 +- src/ladmin/md5calc.c | 6 +- src/login/login.c | 98 +++++++++---------- src/login/md5calc.c | 6 +- src/login_sql/md5calc.c | 6 +- src/map/clif.c | 235 +++++++++++++++++++++++---------------------- 22 files changed, 417 insertions(+), 414 deletions(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index 02ef7b0b3..9d51367f1 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,8 @@ Date Added 01/23 + * char-server (SQL & TXT), login-server (SQL & TXT), and txt-coonvertors + (char and login) all compile on g++ now [svn 975] [Ajarn] * Fixed the sizeof errors in g++ [SVN 972] [Ajarn] * Reverted back some of the char* changes [SVN 972] [Ajarn] * Changed parse_script to now return char* [SVN 969] [Ajarn] diff --git a/src/char/char.c b/src/char/char.c index fb154c51c..d851ea854 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -853,14 +853,14 @@ int make_new_char(int fd, unsigned char *dat) { // remove control characters from the name dat[23] = '\0'; - if (remove_control_chars(dat)) { + if (remove_control_chars((char*)dat)) { char_log("Make new char error (control char received in the name): (connection #%d, account: %d)." RETCODE, fd, sd->account_id); return -1; } // check lenght of character name - if (strlen(dat) < 4) { + if (strlen((const char*)dat) < 4) { char_log("Make new char error (character name too small): (connection #%d, account: %d, name: '%s')." RETCODE, fd, sd->account_id, dat); return -1; @@ -902,8 +902,8 @@ int make_new_char(int fd, unsigned char *dat) { } for(i = 0; i < char_num; i++) { - if ((name_ignoring_case != 0 && strcmp(char_dat[i].name, dat) == 0) || - (name_ignoring_case == 0 && strcmpi(char_dat[i].name, dat) == 0)) { + if ((name_ignoring_case != 0 && strcmp(char_dat[i].name, (const char*)dat) == 0) || + (name_ignoring_case == 0 && strcmpi(char_dat[i].name, (const char*)dat) == 0)) { char_log("Make new char error (name already exists): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %d), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d." RETCODE, fd, sd->account_id, dat[30], dat, char_dat[i].name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[24] + dat[25] + dat[26] + dat[27] + dat[28] + dat[29], dat[33], dat[31]); return -1; @@ -915,7 +915,7 @@ int make_new_char(int fd, unsigned char *dat) { } } - if (strcmp(wisp_server_name, dat) == 0) { + if (strcmp(wisp_server_name, (const char*)dat) == 0) { char_log("Make new char error (name used is wisp name for server): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %d), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d." RETCODE, fd, sd->account_id, dat[30], dat, char_dat[i].name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[24] + dat[25] + dat[26] + dat[27] + dat[28] + dat[29], dat[33], dat[31]); return -1; @@ -949,7 +949,7 @@ int make_new_char(int fd, unsigned char *dat) { char_dat[i].char_id = char_id_count++; char_dat[i].account_id = sd->account_id; char_dat[i].char_num = dat[30]; - strcpy(char_dat[i].name, dat); + strcpy(char_dat[i].name, (const char*)dat); char_dat[i].class_ = 0; char_dat[i].base_level = 1; char_dat[i].job_level = 1; @@ -1507,9 +1507,9 @@ int char_divorce(struct mmo_charstatus *cs) { //------------------------------------------------------------ // E-mail check: return 0 (not correct) or 1 (valid). by [Yor] //------------------------------------------------------------ -int e_mail_check(unsigned char *email) { +int e_mail_check(char *email) { char ch; - unsigned char* last_arobas; + char* last_arobas; // athena limits if (strlen(email) < 3 || strlen(email) > 39) @@ -1585,7 +1585,7 @@ static int char_delete(struct mmo_charstatus *cs) { // 離婚 if (cs->partner_id){ // 離婚情報をmapに通知 - char buf[10]; + unsigned char buf[10]; WBUFW(buf,0) = 0x2b12; WBUFL(buf,2) = cs->char_id; WBUFL(buf,6) = cs->partner_id; @@ -1798,7 +1798,7 @@ int parse_tologin(int fd) { if (i == MAX_MAP_SERVERS) char_log("'ladmin': Receiving a message for broadcast, but no map-server is online." RETCODE); else { - char buf[128]; + unsigned char buf[128]; char message[RFIFOL(fd,4) + 1]; // +1 to add a null terminated if not exist in the packet int lp; char *p; @@ -1946,7 +1946,7 @@ int parse_tologin(int fd) { if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; { - char buf[32000]; + unsigned char buf[32000]; if (gm_account != NULL) aFree(gm_account); gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); @@ -2559,7 +2559,7 @@ int parse_char(int fd) { else printf("Account Logged On; Account ID: %d.\n", RFIFOL(fd,2)); if (sd == NULL) { - sd = session[fd]->session_data = (struct char_session_data*)aCalloc(sizeof(struct char_session_data), 1); + sd = (struct char_session_data*)session[fd]->session_data = (struct char_session_data*)aCalloc(sizeof(struct char_session_data), 1); memset(sd, 0, sizeof(struct char_session_data)); memcpy(sd->email, "no mail", 40); // put here a mail without '@' to refuse deletion if we don't receive the e-mail sd->connect_until_time = 0; // unknow or illimited (not displaying on map-server) @@ -2881,7 +2881,7 @@ int parse_char(int fd) { if (server_fd[i] < 0) break; } - if (i == MAX_MAP_SERVERS || strcmp(RFIFOP(fd,2), userid) || strcmp(RFIFOP(fd,26), passwd)){ + if (i == MAX_MAP_SERVERS || strcmp((char*)RFIFOP(fd,2), userid) || strcmp((char*)RFIFOP(fd,26), passwd)){ WFIFOB(fd,2) = 3; WFIFOSET(fd,3); RFIFOSKIP(fd,60); @@ -3019,7 +3019,7 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len) { int send_users_tologin(int tid, unsigned int tick, int id, int data) { int users = count_users(); - char buf[16]; + unsigned char buf[16]; if (login_fd > 0 && session[login_fd]) { // send number of user to login server diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 348008e1d..b95817599 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -1419,21 +1419,21 @@ int mapif_parse_GuildCheck(int fd, int guild_id, int account_id, int char_id) { // ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない int inter_guild_parse_frommap(int fd) { switch(RFIFOW(fd,0)) { - case 0x3030: mapif_parse_CreateGuild(fd, RFIFOL(fd,4), RFIFOP(fd,8), (struct guild_member *)RFIFOP(fd,32)); break; + case 0x3030: mapif_parse_CreateGuild(fd, RFIFOL(fd,4), (char*)RFIFOP(fd,8), (struct guild_member *)RFIFOP(fd,32)); break; case 0x3031: mapif_parse_GuildInfo(fd, RFIFOL(fd,2)); break; case 0x3032: mapif_parse_GuildAddMember(fd, RFIFOL(fd,4), (struct guild_member *)RFIFOP(fd,8)); break; - case 0x3034: mapif_parse_GuildLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOP(fd,15)); break; + case 0x3034: mapif_parse_GuildLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), (const char*)RFIFOP(fd,15)); break; case 0x3035: mapif_parse_GuildChangeMemberInfoShort(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOW(fd,15), RFIFOW(fd,17)); break; case 0x3036: mapif_parse_BreakGuild(fd, RFIFOL(fd,2)); break; - case 0x3037: mapif_parse_GuildMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); break; + case 0x3037: mapif_parse_GuildMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break; case 0x3038: mapif_parse_GuildCheck(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break; - case 0x3039: mapif_parse_GuildBasicInfoChange(fd, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOP(fd,10), RFIFOW(fd,2)-10); break; - case 0x303A: mapif_parse_GuildMemberInfoChange(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOL(fd,12), RFIFOW(fd,16), RFIFOP(fd,18), RFIFOW(fd,2)-18); break; + case 0x3039: mapif_parse_GuildBasicInfoChange(fd, RFIFOL(fd,4), RFIFOW(fd,8), (const char*)RFIFOP(fd,10), RFIFOW(fd,2)-10); break; + case 0x303A: mapif_parse_GuildMemberInfoChange(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOL(fd,12), RFIFOW(fd,16), (const char*)RFIFOP(fd,18), RFIFOW(fd,2)-18); break; case 0x303B: mapif_parse_GuildPosition(fd, RFIFOL(fd,4), RFIFOL(fd,8), (struct guild_position *)RFIFOP(fd,12)); break; case 0x303C: mapif_parse_GuildSkillUp(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break; case 0x303D: mapif_parse_GuildAlliance(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18)); break; - case 0x303E: mapif_parse_GuildNotice(fd, RFIFOL(fd,2), RFIFOP(fd,6), RFIFOP(fd,66)); break; - case 0x303F: mapif_parse_GuildEmblem(fd, RFIFOW(fd,2)-12, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12)); break; + case 0x303E: mapif_parse_GuildNotice(fd, RFIFOL(fd,2), (const char*)RFIFOP(fd,6), (const char*)RFIFOP(fd,66)); break; + case 0x303F: mapif_parse_GuildEmblem(fd, RFIFOW(fd,2)-12, RFIFOL(fd,4), RFIFOL(fd,8), (const char*)RFIFOP(fd,12)); break; case 0x3040: mapif_parse_GuildCastleDataLoad(fd, RFIFOW(fd,2), RFIFOB(fd,4)); break; case 0x3041: mapif_parse_GuildCastleDataSave(fd, RFIFOW(fd,2), RFIFOB(fd,4), RFIFOL(fd,5)); break; diff --git a/src/char/int_party.c b/src/char/int_party.c index 6b7f4361e..c95d13620 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -94,7 +94,7 @@ int inter_party_init() { continue; } - p = aCalloc(sizeof(struct party), 1); + p = (struct party*)aCalloc(sizeof(struct party), 1); if (p == NULL){ printf("int_party: out of memory!\n"); exit(0); @@ -572,15 +572,15 @@ int mapif_parse_PartyCheck(int fd, int party_id, int account_id, char *nick) { // ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない int inter_party_parse_frommap(int fd) { switch(RFIFOW(fd,0)) { - case 0x3020: mapif_parse_CreateParty(fd, RFIFOL(fd,2), RFIFOP(fd,6), RFIFOP(fd,30), RFIFOP(fd,54), RFIFOW(fd,70)); break; + case 0x3020: mapif_parse_CreateParty(fd, RFIFOL(fd,2), (char*)RFIFOP(fd,6), (char*)RFIFOP(fd,30), (char*)RFIFOP(fd,54), RFIFOW(fd,70)); break; case 0x3021: mapif_parse_PartyInfo(fd, RFIFOL(fd,2)); break; - case 0x3022: mapif_parse_PartyAddMember(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOP(fd,10), RFIFOP(fd,34), RFIFOW(fd,50)); break; + case 0x3022: mapif_parse_PartyAddMember(fd, RFIFOL(fd,2), RFIFOL(fd,6), (char*)RFIFOP(fd,10), (char*)RFIFOP(fd,34), RFIFOW(fd,50)); break; case 0x3023: mapif_parse_PartyChangeOption(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOW(fd,10), RFIFOW(fd,12)); break; case 0x3024: mapif_parse_PartyLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6)); break; - case 0x3025: mapif_parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOP(fd,10), RFIFOB(fd,26), RFIFOW(fd,27)); break; + case 0x3025: mapif_parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), (char*)RFIFOP(fd,10), RFIFOB(fd,26), RFIFOW(fd,27)); break; case 0x3026: mapif_parse_BreakParty(fd, RFIFOL(fd,2)); break; - case 0x3027: mapif_parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); break; - case 0x3028: mapif_parse_PartyCheck(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOP(fd,10)); break; + case 0x3027: mapif_parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break; + case 0x3028: mapif_parse_PartyCheck(fd, RFIFOL(fd,2), RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break; default: return 0; } diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 0dd334514..f690e554e 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -41,16 +41,16 @@ int inter_pet_fromstr(char *str,struct s_pet *p) int s; int tmp_int[16]; char tmp_str[256]; - + memset(p,0,sizeof(struct s_pet)); - + // printf("sscanf pet main info\n"); s=sscanf(str,"%d,%d,%[^\t]\t%d,%d,%d,%d,%d,%d,%d,%d,%d",&tmp_int[0],&tmp_int[1],tmp_str,&tmp_int[2], &tmp_int[3],&tmp_int[4],&tmp_int[5],&tmp_int[6],&tmp_int[7],&tmp_int[8],&tmp_int[9],&tmp_int[10]); if(s!=12) return 1; - + p->pet_id = tmp_int[0]; p->class_ = tmp_int[1]; memcpy(p->name,tmp_str,24); @@ -88,7 +88,7 @@ int inter_pet_init() if( (fp=fopen(pet_txt,"r"))==NULL ) return 1; while(fgets(line,sizeof(line),fp)){ - p=aCalloc(sizeof(struct s_pet), 1); + p = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); if(p==NULL){ printf("int_pet: out of memory!\n"); exit(0); @@ -242,11 +242,11 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet p->intimate = 0; else if(p->intimate > 1000) p->intimate = 1000; - + numdb_insert(pet_db,p->pet_id,p); - + mapif_pet_created(fd,account_id,p); - + return 0; } @@ -292,7 +292,7 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data) p->pet_id = data->pet_id; if(p->pet_id == 0) data->pet_id = p->pet_id = pet_newid++; - numdb_insert(pet_db,p->pet_id,p); + numdb_insert(pet_db,p->pet_id,p); } if(data->hungry < 0) data->hungry = 0; @@ -322,7 +322,7 @@ int mapif_delete_pet(int fd,int pet_id) int mapif_parse_CreatePet(int fd) { mapif_create_pet(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOW(fd,14),RFIFOW(fd,16),RFIFOL(fd,18), - RFIFOL(fd,20),RFIFOB(fd,22),RFIFOB(fd,23),RFIFOP(fd,24)); + RFIFOL(fd,20),RFIFOB(fd,22),RFIFOB(fd,23),(char*)RFIFOP(fd,24)); return 0; } diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 73d50f323..8e4711cec 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -56,7 +56,7 @@ int storage_fromstr(char *str,struct storage *p) if(set!=2) return 1; if(str[next]=='\n' || str[next]=='\r') - return 0; + return 0; next++; for(i=0;str[next] && str[next]!='\t';i++){ if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", @@ -76,7 +76,7 @@ int storage_fromstr(char *str,struct storage *p) p->storage[i].card[3] = tmp_int[10]; next += len; if (str[next] == ' ') - next++; + next++; } else if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", @@ -96,9 +96,9 @@ int storage_fromstr(char *str,struct storage *p) p->storage[i].card[3] = tmp_int[10]; next += len; if (str[next] == ' ') - next++; + next++; } - + else return 1; } return 0; @@ -138,7 +138,7 @@ int guild_storage_fromstr(char *str,struct guild_storage *p) if(set!=2) return 1; if(str[next]=='\n' || str[next]=='\r') - return 0; + return 0; next++; for(i=0;str[next] && str[next]!='\t';i++){ if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", @@ -158,7 +158,7 @@ int guild_storage_fromstr(char *str,struct guild_storage *p) p->storage[i].card[3] = tmp_int[10]; next += len; if (str[next] == ' ') - next++; + next++; } else if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", @@ -178,9 +178,9 @@ int guild_storage_fromstr(char *str,struct guild_storage *p) p->storage[i].card[3] = tmp_int[10]; next += len; if (str[next] == ' ') - next++; + next++; } - + else return 1; } return 0; @@ -242,7 +242,7 @@ int inter_storage_init() } while(fgets(line,65535,fp)){ sscanf(line,"%d",&tmp_int); - 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); @@ -270,7 +270,7 @@ int inter_storage_init() } while(fgets(line,65535,fp)){ sscanf(line,"%d",&tmp_int); - 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); diff --git a/src/char/inter.c b/src/char/inter.c index f0fe38f60..ac460d4c4 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -114,7 +114,7 @@ int inter_accreg_init() { while(fgets(line, sizeof(line)-1, fp)){ line[sizeof(line)-1] = '\0'; - reg = aCalloc(sizeof(struct accreg), 1); + reg = (struct accreg*)aCalloc(sizeof(struct accreg), 1); if (reg == NULL) { printf("inter: accreg: out of memory!\n"); exit(0); @@ -325,7 +325,7 @@ int mapif_account_reg(int fd, unsigned char *src) { // アカウント変数要求返信 int mapif_account_reg_reply(int fd,int account_id) { - struct accreg *reg = numdb_search(accreg_db,account_id); + struct accreg *reg = (struct accreg*)numdb_search(accreg_db,account_id); WFIFOW(fd,0) = 0x3804; WFIFOL(fd,4) = account_id; @@ -366,7 +366,7 @@ int check_ttl_wisdata() { wis_delnum = 0; numdb_foreach(wis_db, check_ttl_wisdata_sub, tick); for(i = 0; i < wis_delnum; i++) { - struct WisData *wd = numdb_search(wis_db, wis_dellist[i]); + struct WisData *wd = (struct WisData*)numdb_search(wis_db, wis_dellist[i]); printf("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst); // removed. not send information after a timeout. Just no answer for the player //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target @@ -403,7 +403,7 @@ int mapif_parse_WisRequest(int fd) { } // search if character exists before to ask all map-servers - if ((index = search_character_index(RFIFOP(fd,28))) == -1) { + if ((index = search_character_index((char*)RFIFOP(fd,28))) == -1) { unsigned char buf[27]; WBUFW(buf, 0) = 0x3802; memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), 24); @@ -413,9 +413,9 @@ int mapif_parse_WisRequest(int fd) { } else { // to be sure of the correct name, rewrite it memset(RFIFOP(fd,28), 0, 24); - strncpy(RFIFOP(fd,28), search_character_name(index), 24); + strncpy((char*)RFIFOP(fd,28), search_character_name(index), 24); // if source is destination, don't ask other servers. - if (strcmp(RFIFOP(fd,4),RFIFOP(fd,28)) == 0) { + if (strcmp((char*)RFIFOP(fd,4),(char*)RFIFOP(fd,28)) == 0) { unsigned char buf[27]; WBUFW(buf, 0) = 0x3802; memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), 24); @@ -450,7 +450,7 @@ int mapif_parse_WisRequest(int fd) { // Wisp/page transmission result int mapif_parse_WisReply(int fd) { int id = RFIFOL(fd,2), flag = RFIFOB(fd,6); - struct WisData *wd = numdb_search(wis_db, id); + struct WisData *wd = (struct WisData*)numdb_search(wis_db, id); if (wd == NULL) return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server @@ -478,10 +478,10 @@ int mapif_parse_WisToGM(int fd) { // アカウント変数保存要求 int mapif_parse_AccReg(int fd) { int j, p; - struct accreg *reg = numdb_search(accreg_db, RFIFOL(fd,4)); + struct accreg *reg = (struct accreg*)numdb_search(accreg_db, RFIFOL(fd,4)); if (reg == NULL) { - if ((reg = aCalloc(sizeof(struct accreg), 1)) == NULL) { + if ((reg = (struct accreg*)aCalloc(sizeof(struct accreg), 1)) == NULL) { printf("inter: accreg: out of memory !\n"); exit(0); } diff --git a/src/char_sql/char.c b/src/char_sql/char.c index df3c40bda..e4ae162eb 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -2654,7 +2654,7 @@ int parse_char(int fd) { //Divorce [Wizputer] if (sql_row[1] != 0) { - char buf[64]; + unsigned char buf[64]; sprintf(tmp_sql,"UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d'",char_db,atoi(sql_row[1])); if(mysql_query(&mysql_handle, tmp_sql)) { printf("DB server Error - %s\n", mysql_error(&mysql_handle)); @@ -2900,7 +2900,7 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len) { int send_users_tologin(int tid, unsigned int tick, int id, int data) { int users = count_users(); - char buf[16]; + unsigned char buf[16]; if (login_fd > 0 && session[login_fd]) { // send number of user to login server diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index e3b8d30a8..de6fc0ed0 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -329,11 +329,11 @@ struct guild * inter_guild_fromsql(int guild_id) if (guild_id==0) return 0; - g = numdb_search(guild_db_,guild_id); + g = (struct guild*)numdb_search(guild_db_,guild_id); if (g != NULL) return g; - g = (struct guild *) aMalloc(sizeof(struct guild)); + g = (struct guild*)aMalloc(sizeof(struct guild)); memset(g,0,sizeof(struct guild)); // printf("Retrieve guild information from sql ......\n"); @@ -527,9 +527,9 @@ int inter_guildcastle_tosql(struct guild_castle *gc) if (gc==NULL) return 0; //printf("Save to guild_castle\n"); - gcopy = numdb_search(castle_db_,gc->castle_id); + gcopy = (struct guild_castle*)numdb_search(castle_db_,gc->castle_id); if (gcopy == NULL) { - gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); + gcopy = (struct guild_castle*)aMalloc(sizeof(struct guild_castle)); numdb_insert(castle_db_, gc->castle_id, gcopy); } else { if ((gc->guild_id == gcopy->guild_id ) && ( gc->economy == gcopy->economy ) && ( gc->defense == gcopy->defense ) && ( gc->triggerE == gcopy->triggerE ) && ( gc->triggerD == gcopy->triggerD ) && ( gc->nextTime == gcopy->nextTime ) && ( gc->payTime == gcopy->payTime ) && ( gc->createTime == gcopy->createTime ) && ( gc->visibleC == gcopy->visibleC ) && ( gc->visibleG0 == gcopy->visibleG0 ) && ( gc->visibleG1 == gcopy->visibleG1 ) && ( gc->visibleG2 == gcopy->visibleG2 ) && ( gc->visibleG3 == gcopy->visibleG3 ) && ( gc->visibleG4 == gcopy->visibleG4 ) && ( gc->visibleG5 == gcopy->visibleG5 ) && ( gc->visibleG6 == gcopy->visibleG6 ) && ( gc->visibleG7 == gcopy->visibleG7 ) && ( gc->Ghp0 == gcopy->Ghp0 ) && ( gc->Ghp1 == gcopy->Ghp1 ) && ( gc->Ghp2 == gcopy->Ghp2 ) && ( gc->Ghp3 == gcopy->Ghp3 ) && ( gc->Ghp4 == gcopy->Ghp4 ) && ( gc->Ghp5 == gcopy->Ghp5 ) && ( gc->Ghp6 == gcopy->Ghp6 ) && ( gc->Ghp7 == gcopy->Ghp7 )) @@ -573,13 +573,13 @@ int inter_guildcastle_tosql(struct guild_castle *gc) // Read guild_castle from sql int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) { - struct guild_castle *gcopy; + struct guild_castle *gcopy; if (gc==NULL) return 0; //printf("Read from guild_castle\n"); - gcopy = numdb_search(castle_db_, castle_id); + gcopy = (struct guild_castle*)numdb_search(castle_db_, castle_id); if (gcopy == NULL) { - gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); + gcopy = (struct guild_castle*)aMalloc(sizeof(struct guild_castle)); numdb_insert(castle_db_, gc->castle_id, gcopy); } else { memcpy(gc, gcopy, sizeof(struct guild_castle)); @@ -678,9 +678,9 @@ int inter_guild_sql_init() guild_castleinfoevent_db_=numdb_init(); printf("interserver guild memory initialize.... (%d byte)\n",sizeof(struct guild)); - guild_pt = aCalloc(sizeof(struct guild), 1); - guild_pt2= aCalloc(sizeof(struct guild), 1); - guildcastle_pt=aCalloc(sizeof(struct guild_castle), 1); + guild_pt = (struct guild*)aCalloc(sizeof(struct guild), 1); + guild_pt2= (struct guild*)aCalloc(sizeof(struct guild), 1); + guildcastle_pt = (struct guild_castle*)aCalloc(sizeof(struct guild_castle), 1); inter_guild_readdb(); // Read exp @@ -1094,7 +1094,7 @@ int mapif_guild_castle_alldataload(int fd) { gc->Ghp7 = atoi(sql_row[25]); memcpy(WFIFOP(fd,len), gc, sizeof(struct guild_castle)); - gcopy = numdb_search(castle_db_,gc->castle_id); + gcopy = (struct guild_castle*)numdb_search(castle_db_,gc->castle_id); if (gcopy == NULL) { gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); numdb_insert(castle_db_, gc->castle_id, gcopy); @@ -1671,21 +1671,21 @@ int mapif_parse_GuildCheck(int fd,int guild_id,int account_id,int char_id) int inter_guild_parse_frommap(int fd) { switch(RFIFOW(fd,0)){ - case 0x3030: mapif_parse_CreateGuild(fd,RFIFOL(fd,4),RFIFOP(fd,8),(struct guild_member *)RFIFOP(fd,32)); break; + case 0x3030: mapif_parse_CreateGuild(fd,RFIFOL(fd,4),(char*)RFIFOP(fd,8),(struct guild_member *)RFIFOP(fd,32)); break; case 0x3031: mapif_parse_GuildInfo(fd,RFIFOL(fd,2)); break; case 0x3032: mapif_parse_GuildAddMember(fd,RFIFOL(fd,4),(struct guild_member *)RFIFOP(fd,8)); break; - case 0x3034: mapif_parse_GuildLeave(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOP(fd,15)); break; + case 0x3034: mapif_parse_GuildLeave(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(const char*)RFIFOP(fd,15)); break; case 0x3035: mapif_parse_GuildChangeMemberInfoShort(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); break; case 0x3036: mapif_parse_BreakGuild(fd,RFIFOL(fd,2)); break; - case 0x3037: mapif_parse_GuildMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOP(fd,12),RFIFOW(fd,2)-12); break; + case 0x3037: mapif_parse_GuildMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),(char*)RFIFOP(fd,12),RFIFOW(fd,2)-12); break; case 0x3038: mapif_parse_GuildCheck(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); break; - case 0x3039: mapif_parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),RFIFOP(fd,10),RFIFOW(fd,2)-10); break; - case 0x303A: mapif_parse_GuildMemberInfoChange(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOL(fd,12),RFIFOW(fd,16),RFIFOP(fd,18),RFIFOW(fd,2)-18); break; + case 0x3039: mapif_parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),(const char*)RFIFOP(fd,10),RFIFOW(fd,2)-10); break; + case 0x303A: mapif_parse_GuildMemberInfoChange(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOL(fd,12),RFIFOW(fd,16),(const char*)RFIFOP(fd,18),RFIFOW(fd,2)-18); break; case 0x303B: mapif_parse_GuildPosition(fd,RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); break; case 0x303C: mapif_parse_GuildSkillUp(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); break; case 0x303D: mapif_parse_GuildAlliance(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18)); break; - case 0x303E: mapif_parse_GuildNotice(fd,RFIFOL(fd,2),RFIFOP(fd,6),RFIFOP(fd,66)); break; - case 0x303F: mapif_parse_GuildEmblem(fd,RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOP(fd,12)); break; + case 0x303E: mapif_parse_GuildNotice(fd,RFIFOL(fd,2),(const char*)RFIFOP(fd,6),(const char*)RFIFOP(fd,66)); break; + case 0x303F: mapif_parse_GuildEmblem(fd,RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8),(const char*)RFIFOP(fd,12)); break; case 0x3040: mapif_parse_GuildCastleDataLoad(fd,RFIFOW(fd,2),RFIFOB(fd,4)); break; case 0x3041: mapif_parse_GuildCastleDataSave(fd,RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5)); break; diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index 9ea3a5635..b8a4a1160 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -8,7 +8,7 @@ #include #include "char.h" #include "../common/strlib.h" -#include "socket.h" +#include "socket.h" static struct party *party_pt; static int party_newid=100; @@ -23,24 +23,24 @@ int mapif_parse_PartyLeave(int fd,int party_id,int account_id); int inter_party_tosql(int party_id,struct party *p) { // 'party' ('party_id','name','exp','item','leader') - + char t_name[100]; char t_member[24]; int party_member = 0, party_online_member = 0; int party_exist = 0; int leader_id = 0; int i = 0; - + printf("(\033[1;64m%d\033[0m) Request save party - ",party_id); - + jstrescapecpy(t_name, p->name); - + if (p==NULL || party_id==0 || p->party_id ==0 || party_id!=p->party_id) { printf("- Party pointer or party_id error \n"); return 0; } - - // Check if party exists + + // Check if party exists sprintf(tmp_sql,"SELECT count(*) FROM `%s` WHERE `party_id`='%d'",party_db, party_id); // TBR if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); @@ -57,29 +57,29 @@ int inter_party_tosql(int party_id,struct party *p) if (party_exist >0){ // Check members in party sprintf(tmp_sql,"SELECT count(*) FROM `%s` WHERE `party_id`='%d'",char_db, party_id); // TBR - if(mysql_query(&mysql_handle, tmp_sql) ) { + if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); return 0; } sql_res = mysql_store_result(&mysql_handle) ; if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { sql_row = mysql_fetch_row(sql_res); - + party_member = atoi (sql_row[0]); // printf("- Check members in party %d : %d \n",party_id,party_member); } mysql_free_result(sql_res) ; //resource free - + party_online_member = 0; i=0; while (imember[i].account_id>0) party_online_member++; i++; } - + //if (party_online_member==0) printf("- No member online \n"); else printf("- Some member %d online \n", party_online_member); - + if (party_member <= 0 && party_online_member == 0) { // Delete the party, if has no member. @@ -92,29 +92,29 @@ int inter_party_tosql(int party_id,struct party *p) return 0; } else { // Update party information, if exists - + int i=0; - + for (i=0;imember[i].account_id>0){ sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `name`='%s'", - char_db, party_id, p->member[i].account_id,jstrescapecpy(t_member,p->member[i].name)); + char_db, party_id, p->member[i].account_id,jstrescapecpy(t_member,p->member[i].name)); //printf("%s",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) ); } } } - - + + sprintf(tmp_sql,"UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d', `leader_id`=`leader_id` WHERE `party_id`='%d'", - party_db, t_name,p->exp,p->item,party_id); + party_db, t_name,p->exp,p->item,party_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (inset/update `party`)- %s\n", mysql_error(&mysql_handle) ); } - + // printf("- Update party %d information \n",party_id); } } else { @@ -128,18 +128,18 @@ int inter_party_tosql(int party_id,struct party *p) printf("DB server Error (inset/update `party`)- %s\n", mysql_error(&mysql_handle) ); return 0; } - + sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `name`='%s'", - char_db, party_id,leader_id, jstrescapecpy(t_member,p->member[i].name)); + char_db, party_id,leader_id, jstrescapecpy(t_member,p->member[i].name)); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (inset/update `party`)- %s\n", mysql_error(&mysql_handle) ); } - - //printf("- Insert new party %d \n",party_id); + + //printf("- Insert new party %d \n",party_id); } - + printf("Party save success\n"); - return 0; + return 0; } @@ -148,15 +148,15 @@ int inter_party_fromsql(int party_id,struct party *p) { int leader_id=0; printf("(\033[1;64m%d\033[0m) Request load party - ",party_id); - + memset(p, 0, sizeof(struct party)); - + sprintf(tmp_sql,"SELECT `party_id`, `name`,`exp`,`item`, `leader_id` FROM `%s` WHERE `party_id`='%d'",party_db, party_id); // TBR if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `party`)- %s\n", mysql_error(&mysql_handle) ); return 0; } - + sql_res = mysql_store_result(&mysql_handle) ; if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { sql_row = mysql_fetch_row(sql_res); @@ -171,9 +171,9 @@ int inter_party_fromsql(int party_id,struct party *p) // printf("- Cannot find party %d \n",party_id); return 0; } - + mysql_free_result(sql_res); - + // Load members sprintf(tmp_sql,"SELECT `account_id`, `name`,`base_level`,`last_map`,`online` FROM `%s` WHERE `party_id`='%d'",char_db, party_id); // TBR if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -195,20 +195,20 @@ int inter_party_fromsql(int party_id,struct party *p) // printf("- %d members found in party %d \n",i,party_id); } mysql_free_result(sql_res); - - + + printf("Party load success\n"); return 0; - + } int inter_party_sql_init(){ int i; - + //memory alloc printf("interserver party memory initialize.... (%d byte)\n",sizeof(struct party)); - party_pt = aCalloc(sizeof(struct party), 1); - + party_pt = (struct party*)aCalloc(sizeof(struct party), 1); + sprintf (tmp_sql , "SELECT count(*) FROM `%s`",party_db); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); @@ -225,16 +225,16 @@ int inter_party_sql_init(){ if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } - + sql_res = mysql_store_result(&mysql_handle) ; - + sql_row = mysql_fetch_row(sql_res); party_newid = atoi (sql_row[0])+1; mysql_free_result(sql_res); } - + printf("set party_newid: %d.......\n",party_newid); - + return 0; } @@ -245,8 +245,8 @@ struct party* search_partyname(char *str) struct party *p=NULL; int leader_id = 0; char t_name[24]; - - sprintf(tmp_sql,"SELECT `party_id`, `name`,`exp`,`item`,`leader_id` FROM `%s` WHERE `name`='%s'",party_db, jstrescapecpy(t_name,str)); + + sprintf(tmp_sql,"SELECT `party_id`, `name`,`exp`,`item`,`leader_id` FROM `%s` WHERE `name`='%s'",party_db, jstrescapecpy(t_name,str)); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `party`)- %s\n", mysql_error(&mysql_handle) ); } @@ -477,12 +477,12 @@ int mapif_parse_CreateParty(int fd,int account_id,char *name,char *nick,char *ma p->member[0].leader=1; p->member[0].online=1; p->member[0].lv=lv; - + inter_party_tosql(p->party_id,p); - + mapif_party_created(fd,account_id,p); mapif_party_info(fd,p); - + return 0; } // パーティ情報要求 @@ -494,7 +494,7 @@ int mapif_parse_PartyInfo(int fd,int party_id) return 0; } inter_party_fromsql(party_id, p); - + if(p->party_id >= 0) mapif_party_info(fd,p); else @@ -506,23 +506,23 @@ int mapif_parse_PartyAddMember(int fd,int party_id,int account_id,char *nick,cha { struct party *p; int i; - + p = party_pt; if(p==NULL){ printf("int_party: out of memory !\n"); return 0; } inter_party_fromsql(party_id, p); - + if(p->party_id <= 0){ mapif_party_memberadded(fd,party_id,account_id,1); return 0; } - + for(i=0;imember[i].account_id==0){ int flag=0; - + p->member[i].account_id=account_id; memcpy(p->member[i].name,nick,24); memcpy(p->member[i].map,map,16); @@ -538,7 +538,7 @@ int mapif_parse_PartyAddMember(int fd,int party_id,int account_id,char *nick,cha } if(flag) mapif_party_optionchanged(fd,p,0,0); - + inter_party_tosql(party_id, p); return 0; } @@ -552,25 +552,25 @@ int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int { struct party *p; int flag=0; - + p = party_pt; if(p==NULL){ printf("int_party: out of memory !\n"); return 0; } - + inter_party_fromsql(party_id, p); - + if(p->party_id <= 0){ return 0; } - + p->exp=exp; if( exp>0 && !party_check_exp_share(p) ){ flag|=0x01; p->exp=0; } - + p->item=item; mapif_party_optionchanged(fd,p,account_id,flag); @@ -586,27 +586,27 @@ int mapif_parse_PartyLeave(int fd,int party_id,int account_id) printf("int_party: out of memory !\n"); return 0; } - + inter_party_fromsql(party_id, p); - + if(p->party_id >= 0){ int i,j; for(i=0;imember[i].account_id==account_id){ //printf("p->member[i].account_id = %d , account_id = %d \n",p->member[i].account_id,account_id); mapif_party_leaved(party_id,account_id,p->member[i].name); - - - + + + // Update char information, does the name need encoding? - sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `name`='%s'", + sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `name`='%s'", char_db, party_id, jstrescapecpy(t_member,p->member[i].name)); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) ); } -// printf("Delete member %s from MySQL \n", p->member[i].name); - +// printf("Delete member %s from MySQL \n", p->member[i].name); + if (p->member[i].leader==1){ for(j=0;jmember[j].account_id>0&&j!=i){ mapif_party_leaved(party_id,p->member[j].account_id,p->member[j].name); // Update char information, does the name need encoding? - sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `name`='%s'", + sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `name`='%s'", char_db, party_id, jstrescapecpy(t_member,p->member[i].name)); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) ); } -// printf("Delete member %s from MySQL \n", p->member[j].name); +// printf("Delete member %s from MySQL \n", p->member[j].name); } } // Delete the party, if has no member. @@ -628,9 +628,9 @@ int mapif_parse_PartyLeave(int fd,int party_id,int account_id) printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } // printf("Leader breaks party %d \n",party_id); - memset(p, 0, sizeof(struct party)); + memset(p, 0, sizeof(struct party)); }else memset(&p->member[i],0,sizeof(struct party_member)); - + break; } @@ -642,8 +642,8 @@ int mapif_parse_PartyLeave(int fd,int party_id,int account_id) inter_party_tosql(party_id,p); // Break the party if no member */ }else{ - sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `online`='1'", - char_db, party_id, account_id); + sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `online`='1'", + char_db, party_id, account_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) ); } @@ -655,21 +655,21 @@ int mapif_parse_PartyChangeMap(int fd,int party_id,int account_id,char *map,int { struct party *p; int i; - + p = party_pt; if(p==NULL){ printf("int_party: out of memory !\n"); return 0; } inter_party_fromsql(party_id, p); - + if(p->party_id <= 0){ return 0; } for(i=0;imember[i].account_id==account_id){ int flag=0; - + memcpy(p->member[i].map,map,16); p->member[i].online=online; p->member[i].lv=lv; @@ -691,20 +691,20 @@ int mapif_parse_PartyChangeMap(int fd,int party_id,int account_id,char *map,int int mapif_parse_BreakParty(int fd,int party_id) { struct party *p; - + p = party_pt; if(p==NULL){ printf("int_party: out of memory !\n"); return 0; } - + inter_party_fromsql(party_id, p); - + if(p->party_id <= 0){ return 0; } inter_party_tosql(party_id,p); - + mapif_party_broken(fd,party_id); return 0; } @@ -727,15 +727,15 @@ int mapif_parse_PartyCheck(int fd,int party_id,int account_id,char *nick) int inter_party_parse_frommap(int fd) { switch(RFIFOW(fd,0)){ - case 0x3020: mapif_parse_CreateParty(fd,RFIFOL(fd,2),RFIFOP(fd,6),RFIFOP(fd,30),RFIFOP(fd,54),RFIFOW(fd,70)); break; + case 0x3020: mapif_parse_CreateParty(fd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,30),(char*)RFIFOP(fd,54),RFIFOW(fd,70)); break; case 0x3021: mapif_parse_PartyInfo(fd,RFIFOL(fd,2)); break; - case 0x3022: mapif_parse_PartyAddMember(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOP(fd,10),RFIFOP(fd,34),RFIFOW(fd,50)); break; + case 0x3022: mapif_parse_PartyAddMember(fd,RFIFOL(fd,2),RFIFOL(fd,6),(char*)RFIFOP(fd,10),(char*)RFIFOP(fd,34),RFIFOW(fd,50)); break; case 0x3023: mapif_parse_PartyChangeOption(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12)); break; case 0x3024: mapif_parse_PartyLeave(fd,RFIFOL(fd,2),RFIFOL(fd,6)); break; - case 0x3025: mapif_parse_PartyChangeMap(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOP(fd,10),RFIFOB(fd,26),RFIFOW(fd,27)); break; + case 0x3025: mapif_parse_PartyChangeMap(fd,RFIFOL(fd,2),RFIFOL(fd,6),(char*)RFIFOP(fd,10),RFIFOB(fd,26),RFIFOW(fd,27)); break; case 0x3026: mapif_parse_BreakParty(fd,RFIFOL(fd,2)); break; - case 0x3027: mapif_parse_PartyMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOP(fd,12),RFIFOW(fd,2)-12); break; - case 0x3028: mapif_parse_PartyCheck(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOP(fd,10)); break; + case 0x3027: mapif_parse_PartyMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),(char*)RFIFOP(fd,12),RFIFOW(fd,2)-12); break; + case 0x3028: mapif_parse_PartyCheck(fd,RFIFOL(fd,2),RFIFOL(fd,6),(char*)RFIFOP(fd,10)); break; default: return 0; } diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 18172b066..35a7710a7 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -18,11 +18,11 @@ static int pet_newid = 100; int inter_pet_tosql(int pet_id, struct s_pet *p) { //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) char t_name[100]; - + printf("request save pet: %d.......\n",pet_id); - + jstrescapecpy(t_name, p->name); - + if(p->hungry < 0) p->hungry = 0; else if(p->hungry > 100) @@ -36,7 +36,7 @@ int inter_pet_tosql(int pet_id, struct s_pet *p) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } sql_res = mysql_store_result(&mysql_handle) ; - if (sql_res!=NULL && mysql_num_rows(sql_res)>0) + 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, @@ -49,19 +49,19 @@ int inter_pet_tosql(int pet_id, struct s_pet *p) { if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (inset/update `pet`)- %s\n", mysql_error(&mysql_handle) ); } - + printf("pet save success.......\n"); return 0; } int inter_pet_fromsql(int pet_id, struct s_pet *p){ - + printf("request load pet: %d.......\n",pet_id); - + memset(p, 0, sizeof(struct s_pet)); - + //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) - + sprintf(tmp_sql,"SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'",pet_db, pet_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `pet`)- %s\n", mysql_error(&mysql_handle) ); @@ -70,7 +70,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet *p){ sql_res = mysql_store_result(&mysql_handle) ; if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { sql_row = mysql_fetch_row(sql_res); - + p->pet_id = pet_id; p->class_ = atoi(sql_row[1]); memcpy(p->name, sql_row[2],24); @@ -92,20 +92,20 @@ int inter_pet_fromsql(int pet_id, struct s_pet *p){ p->intimate = 0; else if(p->intimate > 1000) p->intimate = 1000; - + mysql_free_result(sql_res); - + printf("pet load success.......\n"); return 0; } //---------------------------------------------- - + int inter_pet_sql_init(){ int i; - + //memory alloc printf("interserver pet memory initialize.... (%d byte)\n",sizeof(struct s_pet)); - pet_pt = aCalloc(sizeof(struct s_pet), 1); + pet_pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); sprintf (tmp_sql , "SELECT count(*) FROM `%s`", pet_db); if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -124,22 +124,22 @@ int inter_pet_sql_init(){ if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } - + sql_res = mysql_store_result(&mysql_handle) ; - + sql_row = mysql_fetch_row(sql_res); pet_newid = atoi (sql_row[0])+1; //should SET MAX existing PET ID + 1 [Lupus] mysql_free_result(sql_res); } - + printf("set pet_newid: %d.......\n",pet_newid); - + return 0; } //---------------------------------- int inter_pet_delete(int pet_id){ printf("request delete pet: %d.......\n",pet_id); - + sprintf(tmp_sql,"DELETE FROM `%s` WHERE `pet_id`='%d'",pet_db, pet_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); @@ -232,19 +232,19 @@ int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_pt->intimate = 0; else if(pet_pt->intimate > 1000) pet_pt->intimate = 1000; - + inter_pet_tosql(pet_pt->pet_id,pet_pt); - + mapif_pet_created(fd, account_id, pet_pt); - + return 0; } int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){ memset(pet_pt, 0, sizeof(struct s_pet)); - + inter_pet_fromsql(pet_id, pet_pt); - + if(pet_pt!=NULL) { if(pet_pt->incuvate == 1) { pet_pt->account_id = pet_pt->char_id = 0; @@ -267,7 +267,7 @@ int mapif_save_pet(int fd, int account_id, struct s_pet *data) { if(sizeof(struct s_pet)!=len-8) { printf("inter pet: data size error %d %d\n", sizeof(struct s_pet), len-8); } - + else{ if(data->hungry < 0) data->hungry = 0; @@ -292,7 +292,7 @@ int mapif_delete_pet(int fd, int pet_id){ int mapif_parse_CreatePet(int fd){ mapif_create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOL(fd, 18), - RFIFOL(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), RFIFOP(fd, 24)); + RFIFOL(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), (char*)RFIFOP(fd, 24)); return 0; } diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index e2d4010a1..b93fc5b7d 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -24,7 +24,7 @@ int storage_tosql(int account_id,struct storage *p){ struct itemtemp mapitem; for(i=0;istorage[i].nameid>0){ - if(itemdb_isequip(p->storage[i].nameid)==1){ + if(itemdb_isequip(p->storage[i].nameid)==1){ mapitem.equip[eqcount].flag=0; mapitem.equip[eqcount].id = p->storage[i].id; mapitem.equip[eqcount].nameid=p->storage[i].nameid; @@ -39,7 +39,7 @@ int storage_tosql(int account_id,struct storage *p){ mapitem.equip[eqcount].card[3] = p->storage[i].card[3]; eqcount++; } - else if(itemdb_isequip(p->storage[i].nameid)==0){ + else if(itemdb_isequip(p->storage[i].nameid)==0){ mapitem.notequip[noteqcount].flag=0; mapitem.notequip[noteqcount].id = p->storage[i].id; mapitem.notequip[noteqcount].nameid=p->storage[i].nameid; @@ -66,18 +66,18 @@ int storage_tosql(int account_id,struct storage *p){ // DB -> storage data conversion int storage_fromsql(int account_id, struct storage *p){ int i=0; - + memset(p,0,sizeof(struct storage)); //clean up memory p->storage_amount = 0; p->account_id = account_id; - + // storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} sprintf(tmp_sql,"SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`card0`,`card1`,`card2`,`card3` FROM `%s` WHERE `account_id`='%d'",storage_db, account_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } sql_res = mysql_store_result(&mysql_handle) ; - + if (sql_res) { while((sql_row = mysql_fetch_row(sql_res))) { //start to fetch p->storage[i].id= atoi(sql_row[0]); @@ -95,7 +95,7 @@ int storage_fromsql(int account_id, struct storage *p){ } mysql_free_result(sql_res); } - + printf ("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount); return 1; } @@ -108,7 +108,7 @@ int guild_storage_tosql(int guild_id, struct guild_storage *p){ struct itemtemp mapitem; for(i=0;istorage[i].nameid>0){ - if(itemdb_isequip(p->storage[i].nameid)==1){ + if(itemdb_isequip(p->storage[i].nameid)==1){ mapitem.equip[eqcount].flag=0; mapitem.equip[eqcount].id = p->storage[i].id; mapitem.equip[eqcount].nameid=p->storage[i].nameid; @@ -123,7 +123,7 @@ int guild_storage_tosql(int guild_id, struct guild_storage *p){ mapitem.equip[eqcount].card[3] = p->storage[i].card[3]; eqcount++; } - else if(itemdb_isequip(p->storage[i].nameid)==0){ + else if(itemdb_isequip(p->storage[i].nameid)==0){ mapitem.notequip[noteqcount].flag=0; mapitem.notequip[noteqcount].id = p->storage[i].id; mapitem.notequip[noteqcount].nameid=p->storage[i].nameid; @@ -163,7 +163,7 @@ int guild_storage_fromsql(int guild_id, struct guild_storage *p){ printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); } sql_res = mysql_store_result(&mysql_handle) ; - + if (sql_res) { while((sql_row = mysql_fetch_row(sql_res))) { //start to fetch p->storage[i].id= atoi(sql_row[0]); @@ -188,14 +188,14 @@ int guild_storage_fromsql(int guild_id, struct guild_storage *p){ //--------------------------------------------------------- // storage data initialize int inter_storage_sql_init(){ - + //memory alloc printf("interserver storage memory initialize....(%d byte)\n",sizeof(struct storage)); - storage_pt=aCalloc(sizeof(struct storage), 1); - guild_storage_pt=aCalloc(sizeof(struct guild_storage), 1); + storage_pt = (struct storage*)aCalloc(sizeof(struct storage), 1); + guild_storage_pt = (struct guild_storage*)aCalloc(sizeof(struct guild_storage), 1); memset(storage_pt,0,sizeof(struct storage)); memset(guild_storage_pt,0,sizeof(struct guild_storage)); - + return 1; } // 倉庫データ削除 @@ -243,7 +243,7 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id) { int guild_exist=0; WFIFOW(fd,0)=0x3818; - + // Check if guild exists, I may write a function for this later, coz I use it several times. //printf("- Check if guild %d exists\n",g->guild_id); sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id); @@ -257,7 +257,7 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id) //printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes")); } mysql_free_result(sql_res) ; //resource free - + if(guild_exist==1) { guild_storage_fromsql(guild_id,guild_storage_pt); WFIFOW(fd,2)=sizeof(struct guild_storage)+12; @@ -296,7 +296,7 @@ int mapif_parse_LoadStorage(int fd){ int mapif_parse_SaveStorage(int fd){ int account_id=RFIFOL(fd,4); int len=RFIFOW(fd,2); - + if(sizeof(struct storage)!=len-8){ printf("inter storage: data size error %d %d\n",sizeof(struct storage),len-8); }else{ @@ -335,7 +335,7 @@ int mapif_parse_SaveGuildStorage(int fd) //printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes")); } mysql_free_result(sql_res) ; //resource free - + if(guild_exist==1) { memcpy(guild_storage_pt,RFIFOP(fd,12),sizeof(struct guild_storage)); guild_storage_tosql(guild_id,guild_storage_pt); diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 92a002898..6d0ed144a 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -87,20 +87,20 @@ static int wis_dellist[WISDELLIST_MAX], wis_delnum; //-------------------------------------------------------- // Save account_reg to sql (type=2) int inter_accreg_tosql(int account_id,struct accreg *reg){ - + int j; char temp_str[32]; if (account_id<=0) return 0; reg->account_id=account_id; - + //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) sprintf(tmp_sql,"DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'",reg_db, account_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (delete `global_reg_value`)- %s\n", mysql_error(&mysql_handle) ); } - + if (reg->reg_num<=0) return 0; - + for(j=0;jreg_num;j++){ if(reg->reg[j].str != NULL){ sprintf(tmp_sql,"INSERT INTO `%s` (`type`, `account_id`, `str`, `value`) VALUES (2,'%d', '%s','%d')", @@ -120,7 +120,7 @@ int inter_accreg_fromsql(int account_id,struct accreg *reg) if (reg==NULL) return 0; memset(reg, 0, sizeof(struct accreg)); reg->account_id=account_id; - + //`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`) sprintf (tmp_sql, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'",reg_db, reg->account_id); if(mysql_query(&mysql_handle, tmp_sql) ) { @@ -129,7 +129,7 @@ int inter_accreg_fromsql(int account_id,struct accreg *reg) sql_res = mysql_store_result(&mysql_handle); if (sql_res) { - for(j=0;(sql_row = mysql_fetch_row(sql_res));j++){ + for(j=0;(sql_row = mysql_fetch_row(sql_res));j++){ memcpy(reg->reg[j].str, sql_row[0],32); reg->reg[j].value = atoi(sql_row[1]); } @@ -144,7 +144,7 @@ int inter_accreg_sql_init() { CREATE(accreg_pt, struct accreg, 1); return 0; - + } /*========================================== @@ -190,7 +190,7 @@ int inter_config_read(const char *cfgName) { } //Logins information to be read from the inter_athena.conf //for character deletion (checks email in the loginDB) - + else if(strcmpi(w1,"login_server_ip")==0){ strcpy(login_server_ip, w2); printf ("set login_server_ip : %s\n",w2); @@ -226,7 +226,7 @@ int inter_config_read(const char *cfgName) { } } fclose(fp); - + printf ("success reading interserver configuration\n"); return 0; @@ -244,7 +244,7 @@ int inter_log(char *fmt,...) sprintf(tmp_sql,"INSERT DELAYED INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')",interlog_db, jstrescapecpy(temp_str,str)); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (insert `interlog`)- %s\n", mysql_error(&mysql_handle) ); - } + } va_end(ap); return 0; @@ -255,10 +255,10 @@ int inter_log(char *fmt,...) int inter_init(const char *file) { //int i; - + printf ("interserver initialize...\n"); inter_config_read(file); - + //DB connection initialized mysql_init(&mysql_handle); printf("Connect Character DB server.... (Character Server)\n"); @@ -271,7 +271,7 @@ int inter_init(const char *file) else { printf ("Connect Success! (Character Server)\n"); } - + mysql_init(&lmysql_handle); printf("Connect Character DB server.... (login server)\n"); if(!mysql_real_connect(&lmysql_handle, login_server_ip, login_server_id, login_server_pw, @@ -286,7 +286,7 @@ int inter_init(const char *file) inter_guild_sql_init(); inter_storage_sql_init(); inter_party_sql_init(); - + inter_pet_sql_init(); inter_accreg_sql_init(); @@ -335,7 +335,7 @@ int mapif_wis_message(struct WisData *wd) { int mapif_wis_end(struct WisData *wd,int flag) { unsigned char buf[27]; - + WBUFW(buf, 0)=0x3802; memcpy(WBUFP(buf, 2),wd->src,24); WBUFB(buf,26)=flag; @@ -358,7 +358,7 @@ int mapif_account_reg_reply(int fd,int account_id) { struct accreg *reg=accreg_pt; inter_accreg_fromsql(account_id,reg); - + WFIFOW(fd,0)=0x3804; WFIFOL(fd,4)=account_id; if(reg->reg_num==0){ @@ -397,7 +397,7 @@ int check_ttl_wisdata() { wis_delnum = 0; numdb_foreach(wis_db, check_ttl_wisdata_sub, tick); for(i = 0; i < wis_delnum; i++) { - struct WisData *wd = numdb_search(wis_db, wis_dellist[i]); + struct WisData *wd = (struct WisData*)numdb_search(wis_db, wis_dellist[i]); printf("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst); // removed. not send information after a timeout. Just no answer for the player //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target @@ -448,9 +448,9 @@ int mapif_parse_WisRequest(int fd) { } else { // to be sure of the correct name, rewrite it memset(RFIFOP(fd,28), 0, 24); - strncpy(RFIFOP(fd,28), sql_row[0], 24); + strncpy((char*)RFIFOP(fd,28), sql_row[0], 24); // if source is destination, don't ask other servers. - if (strcmp(RFIFOP(fd,4),RFIFOP(fd,28)) == 0) { + if (strcmp((char*)RFIFOP(fd,4),(char*)RFIFOP(fd,28)) == 0) { unsigned char buf[27]; WBUFW(buf, 0) = 0x3802; memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), 24); @@ -482,7 +482,7 @@ int mapif_parse_WisRequest(int fd) { // Wisp/page transmission result int mapif_parse_WisReply(int fd) { int id = RFIFOL(fd,2), flag = RFIFOB(fd,6); - struct WisData *wd = numdb_search(wis_db, id); + struct WisData *wd = (struct WisData*)numdb_search(wis_db, id); if (wd == NULL) return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server @@ -504,13 +504,13 @@ int mapif_parse_AccReg(int fd) struct accreg *reg=accreg_pt; int account_id = RFIFOL(fd,4); memset(accreg_pt,0,sizeof(struct accreg)); - + for(j=0,p=8;jreg[j].str,RFIFOP(fd,p),32); reg->reg[j].value=RFIFOL(fd,p+32); } reg->reg_num=j; - + inter_accreg_tosql(account_id,reg); mapif_account_reg(fd,RFIFOP(fd,0)); // Send confirm message to map return 0; @@ -539,7 +539,7 @@ int inter_parse_frommap(int fd) // パケット長を調べる if( (len=inter_check_length(fd,inter_recv_packet_length[cmd-0x3000]))==0 ) return 2; - + switch(cmd){ case 0x3000: mapif_parse_GMmessage(fd); break; case 0x3001: mapif_parse_WisRequest(fd); break; @@ -569,9 +569,9 @@ int inter_check_length(int fd, int length) return 0; length = RFIFOW(fd, 2); } - + if(RFIFOREST(fd)=20000) continue; @@ -185,7 +185,7 @@ static int itemdb_read_sqldb(void) // sql item_db read, shortened version of map // ---------- */ id=itemdb_search(nameid); - + memcpy(id->name, sql_row[1], 24); memcpy(id->jname, sql_row[2], 24); @@ -212,7 +212,7 @@ static int itemdb_final(void *key,void *data,va_list ap) { struct item_data *id; - id=data; + id = (struct item_data*)data; if(id->use_script) aFree(id->use_script); if(id->equip_script) diff --git a/src/common/grfio.c b/src/common/grfio.c index 6454d5048..5453a4b5d 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -574,7 +574,7 @@ void* grfio_reads(char *fname, int *size) lentry.declen = ftell(in); } fseek(in,0,0); // SEEK_SET - buf2 = (unsigned char *) aCallocA(lentry.declen+1024, 1); + buf2 = (unsigned char *)aCallocA(lentry.declen+1024, 1); if (buf2==NULL) { printf("file read memory allocate error : declen\n"); goto errret; @@ -612,7 +612,7 @@ void* grfio_reads(char *fname, int *size) fseek(in,entry->srcpos,0); fread(buf,1,entry->srclen_aligned,in); fclose(in); - buf2 = (unsigned char *) aCallocA(entry->declen+1024, 1); + buf2 = (unsigned char *)aCallocA(entry->declen+1024, 1); if (buf2==NULL) { printf("file decode memory allocate error\n"); goto errret; diff --git a/src/common/malloc.c b/src/common/malloc.c index a00399a0e..089a9db18 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -8,7 +8,7 @@ void* aMalloc_( size_t size, const char *file, int line, const char *func ) { void *ret; - + // printf("%s:%d: in func %s: malloc %d\n",file,line,func,size); ret=malloc(size); if(ret==NULL){ @@ -21,7 +21,7 @@ void* aMalloc_( size_t size, const char *file, int line, const char *func ) void* aCalloc_( size_t num, size_t size, const char *file, int line, const char *func ) { void *ret; - + // printf("%s:%d: in func %s: calloc %d %d\n",file,line,func,num,size); ret=calloc(num,size); if(ret==NULL){ @@ -35,7 +35,7 @@ void* aCalloc_( size_t num, size_t size, const char *file, int line, const char void* aRealloc_( void *p, size_t size, const char *file, int line, const char *func ) { void *ret; - + // printf("%s:%d: in func %s: realloc %p %d\n",file,line,func,p,size); ret=realloc(p,size); if(ret==NULL){ @@ -66,7 +66,7 @@ void * _bcalloc(size_t size, size_t cnt) { char * _bstrdup(const char *chr) { int len = strlen(chr); - char *ret = aMalloc(len + 1); + char *ret = (char*)aMalloc(len + 1); strcpy(ret, chr); return ret; } diff --git a/src/common/strlib.c b/src/common/strlib.c index ca6e38761..64c8e154f 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -10,12 +10,12 @@ // string lib. char* jstrescape (char* pt) { //copy from here - unsigned char * ptr; + char *ptr; int i =0, j=0; //copy string to temporary CREATE_A(ptr, char, J_MAX_MALLOC_SIZE); - strcpy (ptr,pt); + strcpy(ptr,pt); while (ptr[i] != '\0') { switch (ptr[i]) { diff --git a/src/ladmin/md5calc.c b/src/ladmin/md5calc.c index 7b9a9a2c6..c6c958583 100644 --- a/src/ladmin/md5calc.c +++ b/src/ladmin/md5calc.c @@ -96,7 +96,7 @@ static void MD5_Round_Calculate(const unsigned char *block, //Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D) unsigned int A=*A2, B=*B2, C=*C2, D=*D2; unsigned int AA = A,BB = B,CC = C,DD = D; - + //It is a large region variable reluctantly because of calculation of a round. . . for Round1...4 pX = X; @@ -187,7 +187,7 @@ void MD5_String2binary(const char * string, char * output) memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. padding_message[copy_len] |= 0x80; //The next of a message is 1. - //1-4 + //1-4 //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. if (56 <= copy_len) { MD5_Round_Calculate(padding_message, A,B,C,D); @@ -226,7 +226,7 @@ void MD5_String(const char * string, char * output) { unsigned char digest[16]; - MD5_String2binary(string,digest); + MD5_String2binary(string,(char*)digest); sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[ 0], digest[ 1], digest[ 2], digest[ 3], diff --git a/src/login/login.c b/src/login/login.c index 1a0faddb0..5736963d3 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -971,7 +971,7 @@ int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { //----------------------------------------------------- void send_GM_accounts() { int i; - char buf[32767]; + unsigned char buf[32767]; int len; len = 4; @@ -1239,7 +1239,7 @@ int mmo_auth(struct mmo_account* account, int fd) { } gettimeofday(&tv, NULL); - strftime(tmpstr, 24, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 24, date_format, localtime((const time_t*)&(tv.tv_sec))); sprintf(tmpstr + strlen(tmpstr), ".%03d", (int)tv.tv_usec / 1000); account->account_id = auth_dat[i].account_id; @@ -1463,7 +1463,7 @@ int parse_fromchar(int fd) { WBUFW(buf,0) = 0x2721; WBUFL(buf,2) = acc; WBUFL(buf,6) = 0; - if (strcmp(RFIFOP(fd,8), gm_pass) == 0) { + if (strcmp((char*)RFIFOP(fd,8), gm_pass) == 0) { // only non-GM can become GM if (isGM(acc) == 0) { // if we autorise creation @@ -1473,7 +1473,7 @@ int parse_fromchar(int fd) { char tmpstr[24]; struct timeval tv; gettimeofday(&tv, NULL); - strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 23, date_format, localtime((const time_t*)&(tv.tv_sec))); fprintf(fp, RETCODE "// %s: @GM command on account %d" RETCODE "%d %d" RETCODE, tmpstr, acc, acc, level_new_gm); fclose(fp); WBUFL(buf,6) = level_new_gm; @@ -1801,7 +1801,7 @@ int parse_fromchar(int fd) { logfp = fopen(login_log_unknown_packets_filename, "a"); if (logfp) { gettimeofday(&tv, NULL); - strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 23, date_format, localtime((const time_t*)&(tv.tv_sec))); fprintf(logfp, "%s.%03d: receiving of an unknown packet -> disconnection" RETCODE, tmpstr, (int)tv.tv_usec / 1000); fprintf(logfp, "parse_fromchar: connection #%d (ip: %s), packet: 0x%x (with being read: %d)." RETCODE, fd, ip, RFIFOW(fd,0), RFIFOREST(fd)); fprintf(logfp, "Detail (in hex):" RETCODE); @@ -1945,13 +1945,13 @@ int parse_admin(int fd) { return 0; { struct mmo_account ma; - ma.userid = RFIFOP(fd, 2); + ma.userid = (char*)RFIFOP(fd, 2); memcpy(ma.passwd, RFIFOP(fd, 26), 24); ma.passwd[24] = '\0'; memcpy(ma.lastlogin, "-", 2); ma.sex = RFIFOB(fd,50); WFIFOW(fd,0) = 0x7931; - WFIFOL(fd,2) = -1; + WFIFOL(fd,2) = -1; // WTF? usigned being set to a -1??? 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, @@ -1997,8 +1997,8 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 26) return 0; WFIFOW(fd,0) = 0x7933; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF? an unsigned being set to -1 + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); i = search_account_index(account_name); @@ -2014,7 +2014,7 @@ int parse_admin(int fd) { // save deleted account in log file login_log("'ladmin': Account deletion (account: %s, id: %d, ip: %s) - saved in next line:" RETCODE, auth_dat[i].userid, auth_dat[i].account_id, ip); - mmo_auth_tostr(buf, &auth_dat[i]); + mmo_auth_tostr((char*)buf, &auth_dat[i]); login_log("%s" RETCODE, buf); // delete account memset(auth_dat[i].userid, '\0', sizeof(auth_dat[i].userid)); @@ -2033,8 +2033,8 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 50) return 0; WFIFOW(fd,0) = 0x7935; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; /// WTF??? an unsigned being set to a -1 + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); i = search_account_index(account_name); @@ -2063,8 +2063,8 @@ int parse_admin(int fd) { char error_message[20]; int statut; WFIFOW(fd,0) = 0x7937; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); statut = RFIFOL(fd,26); @@ -2138,8 +2138,8 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 50) return 0; WFIFOW(fd,0) = 0x793b; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); i = search_account_index(account_name); @@ -2170,8 +2170,8 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 27) return 0; WFIFOW(fd,0) = 0x793d; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); memcpy(WFIFOP(fd,6), account_name, 24); @@ -2222,8 +2222,8 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 27) return 0; WFIFOW(fd,0) = 0x793f; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); memcpy(WFIFOP(fd,6), account_name, 24); @@ -2250,7 +2250,7 @@ int parse_admin(int fd) { if ((fp2 = lock_fopen(GM_account_filename, &lock)) != NULL) { if ((fp = fopen(GM_account_filename, "r")) != NULL) { gettimeofday(&tv, NULL); - strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 23, date_format, localtime((const time_t*)&(tv.tv_sec))); modify_flag = 0; // read/write GM file while(fgets(line, sizeof(line)-1, fp)) { @@ -2312,8 +2312,8 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 66) return 0; WFIFOW(fd,0) = 0x7941; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); memcpy(WFIFOP(fd,6), account_name, 24); @@ -2347,8 +2347,8 @@ 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; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); i = search_account_index(account_name); @@ -2382,8 +2382,8 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 26) return 0; WFIFOW(fd,0) = 0x7945; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); i = search_account_index(account_name); @@ -2409,7 +2409,7 @@ int parse_admin(int fd) { memset(WFIFOP(fd,6), '\0', 24); for(i = 0; i < auth_num; i++) { if (auth_dat[i].account_id == RFIFOL(fd,2)) { - strncpy(WFIFOP(fd,6), auth_dat[i].userid, 24); + strncpy((char*)WFIFOP(fd,6), auth_dat[i].userid, 24); login_log("'ladmin': Request (by id) of an account name (account: %s, id: %d, ip: %s)" RETCODE, auth_dat[i].userid, RFIFOL(fd,2), ip); break; @@ -2418,7 +2418,7 @@ int parse_admin(int fd) { if (i == auth_num) { login_log("'ladmin': Name request (by id) of an unknown account (id: %d, ip: %s)" RETCODE, RFIFOL(fd,2), ip); - strncpy(WFIFOP(fd,6), "", 24); + strncpy((char*)WFIFOP(fd,6), "", 24); } WFIFOSET(fd,30); RFIFOSKIP(fd,6); @@ -2431,8 +2431,8 @@ int parse_admin(int fd) { time_t timestamp; char tmpstr[2048]; WFIFOW(fd,0) = 0x7949; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); timestamp = (time_t)RFIFOL(fd,26); @@ -2463,8 +2463,8 @@ int parse_admin(int fd) { time_t timestamp; char tmpstr[2048]; WFIFOW(fd,0) = 0x794b; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); timestamp = (time_t)RFIFOL(fd,26); @@ -2511,8 +2511,8 @@ int parse_admin(int fd) { struct tm *tmtime; char tmpstr[2048]; WFIFOW(fd,0) = 0x794d; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); i = search_account_index(account_name); @@ -2573,7 +2573,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; + WFIFOW(fd,2) = -1; // WTF??? if (RFIFOL(fd,4) < 1) { login_log("'ladmin': Receiving a message for broadcast, but message is void (ip: %s)" RETCODE, ip); @@ -2586,7 +2586,7 @@ int parse_admin(int fd) { login_log("'ladmin': Receiving a message for broadcast, but no char-server is online (ip: %s)" RETCODE, ip); } else { - char buf[32000]; + unsigned char buf[32000]; char message[32000]; WFIFOW(fd,2) = 0; memset(message, '\0', sizeof(message)); @@ -2618,8 +2618,8 @@ int parse_admin(int fd) { char tmpstr[2048]; char tmpstr2[2048]; WFIFOW(fd,0) = 0x7951; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); i = search_account_index(account_name); @@ -2672,8 +2672,8 @@ int parse_admin(int fd) { if (RFIFOREST(fd) < 26) return 0; WFIFOW(fd,0) = 0x7953; - WFIFOL(fd,2) = -1; - account_name = RFIFOP(fd,2); + WFIFOL(fd,2) = -1; // WTF??? + account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; remove_control_chars(account_name); i = search_account_index(account_name); @@ -2739,7 +2739,7 @@ int parse_admin(int fd) { if (i == auth_num) { login_log("'ladmin': Attempt to obtain information (by the id) of an unknown account (id: %d, ip: %s)" RETCODE, RFIFOL(fd,2), ip); - strncpy(WFIFOP(fd,7), "", 24); + strncpy((char*)WFIFOP(fd,7), "", 24); WFIFOW(fd,148) = 0; WFIFOSET(fd,150); } @@ -2762,7 +2762,7 @@ int parse_admin(int fd) { logfp = fopen(login_log_unknown_packets_filename, "a"); if (logfp) { gettimeofday(&tv, NULL); - strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 23, date_format, localtime((const time_t*)&(tv.tv_sec))); fprintf(logfp, "%s.%03d: receiving of an unknown packet -> disconnection" RETCODE, tmpstr, (int)tv.tv_usec / 1000); fprintf(logfp, "parse_admin: connection #%d (ip: %s), packet: 0x%x (with being read: %d)." RETCODE, fd, ip, RFIFOW(fd,0), RFIFOREST(fd)); fprintf(logfp, "Detail (in hex):" RETCODE); @@ -2874,7 +2874,7 @@ int parse_login(int fd) { if (RFIFOREST(fd) < ((RFIFOW(fd,0) == 0x64) ? 55 : 47)) return 0; - account.userid = RFIFOP(fd,6); + account.userid = (char*)RFIFOP(fd,6); account.userid[23] = '\0'; remove_control_chars(account.userid); if (RFIFOW(fd,0) == 0x64) { @@ -3022,15 +3022,15 @@ int parse_login(int fd) { return 0; { int GM_value, len; - unsigned char* server_name; - account.userid = RFIFOP(fd,2); + char* server_name; + account.userid = (char*)RFIFOP(fd,2); account.userid[23] = '\0'; remove_control_chars(account.userid); memcpy(account.passwd, RFIFOP(fd,26), 24); account.passwd[24] = '\0'; remove_control_chars(account.passwd); account.passwdenc = 0; - server_name = RFIFOP(fd,60); + server_name = (char*)RFIFOP(fd,60); server_name[19] = '\0'; remove_control_chars(server_name); login_log("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (ip: %s)" RETCODE, @@ -3117,7 +3117,7 @@ int parse_login(int fd) { } else { struct login_session_data *ld = (struct login_session_data*)session[fd]->session_data; if (RFIFOW(fd,2) == 0) { // non encrypted password - unsigned char* password=""; + char* password=""; memcpy(password, RFIFOP(fd,4), 24); password[24] = '\0'; remove_control_chars(password); @@ -3167,7 +3167,7 @@ int parse_login(int fd) { logfp = fopen(login_log_unknown_packets_filename, "a"); if (logfp) { gettimeofday(&tv, NULL); - strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec))); + strftime(tmpstr, 23, date_format, localtime((const time_t*)&(tv.tv_sec))); fprintf(logfp, "%s.%03d: receiving of an unknown packet -> disconnection" RETCODE, tmpstr, (int)tv.tv_usec / 1000); fprintf(logfp, "parse_login: connection #%d (ip: %s), packet: 0x%x (with being read: %d)." RETCODE, fd, ip, RFIFOW(fd,0), RFIFOREST(fd)); fprintf(logfp, "Detail (in hex):" RETCODE); diff --git a/src/login/md5calc.c b/src/login/md5calc.c index 96bfc34d0..0ee64476d 100644 --- a/src/login/md5calc.c +++ b/src/login/md5calc.c @@ -96,7 +96,7 @@ static void MD5_Round_Calculate(const unsigned char *block, //Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D) unsigned int A=*A2, B=*B2, C=*C2, D=*D2; unsigned int AA = A,BB = B,CC = C,DD = D; - + //It is a large region variable reluctantly because of calculation of a round. . . for Round1...4 pX = X; @@ -187,7 +187,7 @@ void MD5_String2binary(const char * string, char * output) memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. padding_message[copy_len] |= 0x80; //The next of a message is 1. - //1-4 + //1-4 //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. if (56 <= copy_len) { MD5_Round_Calculate(padding_message, A,B,C,D); @@ -226,7 +226,7 @@ void MD5_String(const char * string, char * output) { unsigned char digest[16]; - MD5_String2binary(string,digest); + MD5_String2binary(string,(char*)digest); sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[ 0], digest[ 1], digest[ 2], digest[ 3], diff --git a/src/login_sql/md5calc.c b/src/login_sql/md5calc.c index 58cea1246..856c7ecb0 100644 --- a/src/login_sql/md5calc.c +++ b/src/login_sql/md5calc.c @@ -95,7 +95,7 @@ static void MD5_Round_Calculate(const unsigned char *block, //Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D) unsigned int A=*A2, B=*B2, C=*C2, D=*D2; unsigned int AA = A,BB = B,CC = C,DD = D; - + //It is a large region variable reluctantly because of calculation of a round. . . for Round1...4 pX = X; @@ -186,7 +186,7 @@ void MD5_String2binary(const char * string, char * output) memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. padding_message[copy_len] |= 0x80; //The next of a message is 1. - //1-4 + //1-4 //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. if (56 <= copy_len) { MD5_Round_Calculate(padding_message, A,B,C,D); @@ -225,7 +225,7 @@ void MD5_String(const char * string, char * output) { unsigned char digest[16]; - MD5_String2binary(string,digest); + MD5_String2binary(string,(char*)digest); sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[ 0], digest[ 1], digest[ 2], digest[ 3], diff --git a/src/map/clif.c b/src/map/clif.c index 38aa8ab26..7b088068f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -202,7 +202,7 @@ int clif_countusers(void) struct map_session_data *sd; for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) && sd && sd->state.auth && + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd))) users++; } @@ -221,7 +221,7 @@ int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) va_start(ap,func); for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) && sd && sd->state.auth) + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth) func(sd, ap); } va_end(ap); @@ -300,7 +300,7 @@ int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) { switch(type) { case ALL_CLIENT: // 全クライアントに送信 for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth) { + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) { if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version memcpy(WFIFOP(i,0), buf, len); WFIFOSET(i,len); @@ -310,7 +310,7 @@ int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) { break; case ALL_SAMEMAP: // 同じマップの全クライアントに送信 for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m) { + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m) { if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version memcpy(WFIFOP(i,0), buf, len); WFIFOSET(i,len); @@ -391,7 +391,7 @@ int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) { } } for (i = 0; i < fd_max; i++){ - if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth) { + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) { if (sd->partyspy == p->party_id) { if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version memcpy(WFIFOP(sd->fd,0), buf, len); @@ -441,7 +441,7 @@ int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) { } } for (i = 0; i < fd_max; i++){ - if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth) { + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth) { if (sd->guildspy == g->guild_id) { if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version memcpy(WFIFOP(sd->fd,0), buf, len); @@ -590,7 +590,7 @@ static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf) { *------------------------------------------ */ int clif_dropflooritem(struct flooritem_data *fitem) { - char buf[64]; + unsigned char buf[64]; nullpo_retr(0, fitem); @@ -908,7 +908,7 @@ static int clif_set007b(struct map_session_data *sd,unsigned char *buf) { */ int clif_class_change(struct block_list *bl,int class_,int type) { - char buf[16]; + unsigned char buf[16]; nullpo_retr(0, bl); @@ -927,7 +927,7 @@ int clif_class_change(struct block_list *bl,int class_,int type) *------------------------------------------ */ int clif_mob_class_change(struct mob_data *md, int class_) { - char buf[16]; + unsigned char buf[16]; int view = mob_get_viewclass(class_); nullpo_retr(0, md); @@ -1539,7 +1539,7 @@ void clif_setwaitclose(int fd) { struct map_session_data *sd; // if player is not already in the game (double connection probably) - if ((sd = session[fd]->session_data) == NULL) { + if ((sd = (struct map_session_data*)session[fd]->session_data) == NULL) { // limited timer, just to send information. add_timer(gettick() + 1000, clif_waitclose, fd, 0); } else @@ -1595,7 +1595,7 @@ int clif_changemapserver(struct map_session_data *sd, char *mapname, int x, int *------------------------------------------ */ int clif_fixpos(struct block_list *bl) { - char buf[16]; + unsigned char buf[16]; nullpo_retr(0, bl); @@ -1701,7 +1701,7 @@ int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) { WFIFOW(fd,0)=0xb4; WFIFOW(fd,2)=strlen(mes)+9; WFIFOL(fd,4)=npcid; - strcpy(WFIFOP(fd,8),mes); + strcpy((char*)WFIFOP(fd,8),mes); WFIFOSET(fd,WFIFOW(fd,2)); return 0; @@ -1754,7 +1754,7 @@ int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) { WFIFOW(fd,0)=0xb7; WFIFOW(fd,2)=strlen(mes)+8; WFIFOL(fd,4)=npcid; - strcpy(WFIFOP(fd,8),mes); + strcpy((char*)WFIFOP(fd,8),mes); WFIFOSET(fd,WFIFOW(fd,2)); return 0; @@ -1827,7 +1827,7 @@ int clif_cutin(struct map_session_data *sd, char *image, int type) { fd=sd->fd; WFIFOW(fd,0)=0x1b3; - strncpy(WFIFOP(fd,2),image,64); + strncpy((char*)WFIFOP(fd,2),image,64); WFIFOB(fd,66)=type; WFIFOSET(fd,packet_len_table[0x1b3]); @@ -2841,7 +2841,7 @@ int clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok) */ int clif_misceffect(struct block_list* bl,int type) { - char buf[32]; + unsigned char buf[32]; nullpo_retr(0, bl); @@ -2875,7 +2875,7 @@ int clif_misceffect2(struct block_list *bl, int type) { */ int clif_changeoption(struct block_list* bl) { - char buf[32]; + unsigned char buf[32]; short option; struct status_change *sc_data; static const int omask[]={ 0x10,0x20 }; @@ -2895,7 +2895,7 @@ int clif_changeoption(struct block_list* bl) WBUFB(buf,12) = 0; // ?? if(bl->type==BL_PC) { // disguises [Valaris] - struct map_session_data *sd=((struct map_session_data *)bl); + struct map_session_data *sd=(struct map_session_data *)bl; if(sd && sd->disguise > 23 && sd->disguise < 4001) { clif_send(buf,packet_len_table[0x119],bl,AREA_WOS); clif_spawnpc(sd); @@ -2942,7 +2942,7 @@ int clif_useitemack(struct map_session_data *sd,int index,int amount,int ok) WFIFOB(fd,6)=ok; WFIFOSET(fd,packet_len_table[0xa8]); #else - char buf[32]; + unsigned char buf[32]; WBUFW(buf,0)=0x1c8; WBUFW(buf,2)=index+2; @@ -2984,19 +2984,19 @@ int clif_createchat(struct map_session_data *sd,int fail) */ int clif_dispchat(struct chat_data *cd,int fd) { - char buf[128]; // 最大title(60バイト)+17 + unsigned char buf[128]; // 最大title(60バイト)+17 if(cd==NULL || *cd->owner==NULL) return 1; WBUFW(buf,0)=0xd7; - WBUFW(buf,2)=strlen(cd->title)+17; + WBUFW(buf,2)=strlen((const char*)cd->title)+17; WBUFL(buf,4)=(*cd->owner)->id; WBUFL(buf,8)=cd->bl.id; WBUFW(buf,12)=cd->limit; WBUFW(buf,14)=cd->users; WBUFB(buf,16)=cd->pub; - strcpy(WBUFP(buf,17),cd->title); + strcpy((char*)WBUFP(buf,17),(const char*)cd->title); if(fd){ memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2)); WFIFOSET(fd,WBUFW(buf,2)); @@ -3014,19 +3014,19 @@ int clif_dispchat(struct chat_data *cd,int fd) */ int clif_changechatstatus(struct chat_data *cd) { - char buf[128]; // 最大title(60バイト)+17 + unsigned char buf[128]; // 最大title(60バイト)+17 if(cd==NULL || cd->usersd[0]==NULL) return 1; WBUFW(buf,0)=0xdf; - WBUFW(buf,2)=strlen(cd->title)+17; + WBUFW(buf,2)=strlen((char*)cd->title)+17; WBUFL(buf,4)=cd->usersd[0]->bl.id; WBUFL(buf,8)=cd->bl.id; WBUFW(buf,12)=cd->limit; WBUFW(buf,14)=cd->users; WBUFB(buf,16)=cd->pub; - strcpy(WBUFP(buf,17),cd->title); + strcpy((char*)WBUFP(buf,17),(const char*)cd->title); clif_send(buf,WBUFW(buf,2),&cd->usersd[0]->bl,CHAT); return 0; @@ -3038,7 +3038,7 @@ int clif_changechatstatus(struct chat_data *cd) */ int clif_clearchat(struct chat_data *cd,int fd) { - char buf[32]; + unsigned char buf[32]; nullpo_retr(0, cd); @@ -3104,7 +3104,7 @@ int clif_joinchatok(struct map_session_data *sd,struct chat_data* cd) */ int clif_addchat(struct chat_data* cd,struct map_session_data *sd) { - char buf[32]; + unsigned char buf[32]; nullpo_retr(0, sd); nullpo_retr(0, cd); @@ -3123,7 +3123,7 @@ int clif_addchat(struct chat_data* cd,struct map_session_data *sd) */ int clif_changechatowner(struct chat_data* cd,struct map_session_data *sd) { - char buf[64]; + unsigned char buf[64]; nullpo_retr(0, sd); nullpo_retr(0, cd); @@ -3146,7 +3146,7 @@ int clif_changechatowner(struct chat_data* cd,struct map_session_data *sd) */ int clif_leavechat(struct chat_data* cd,struct map_session_data *sd) { - char buf[32]; + unsigned char buf[32]; nullpo_retr(0, sd); nullpo_retr(0, cd); @@ -3173,7 +3173,7 @@ int clif_traderequest(struct map_session_data *sd,char *name) fd=sd->fd; WFIFOW(fd,0)=0xe5; - strcpy(WFIFOP(fd,2),name); + strcpy((char*)WFIFOP(fd,2),name); WFIFOSET(fd,packet_len_table[0xe5]); return 0; @@ -3897,7 +3897,7 @@ int clif_clearchar_skillunit(struct skill_unit *unit,int fd) */ int clif_01ac(struct block_list *bl) { - char buf[32]; + unsigned char buf[32]; nullpo_retr(0, bl); @@ -4579,10 +4579,10 @@ int clif_skill_warppoint(struct map_session_data *sd,int skill_num, fd=sd->fd; WFIFOW(fd,0)=0x11c; WFIFOW(fd,2)=skill_num; - strncpy(WFIFOP(fd, 4),map1,16); - strncpy(WFIFOP(fd,20),map2,16); - strncpy(WFIFOP(fd,36),map3,16); - strncpy(WFIFOP(fd,52),map4,16); + strncpy((char*)WFIFOP(fd, 4),map1,16); + strncpy((char*)WFIFOP(fd,20),map2,16); + strncpy((char*)WFIFOP(fd,36),map3,16); + strncpy((char*)WFIFOP(fd,52),map4,16); WFIFOSET(fd,packet_len_table[0x11c]); return 0; } @@ -4824,11 +4824,12 @@ int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type) WFIFOL(sd->fd,10) = pvpnum; WFIFOSET(sd->fd,packet_len_table[0x19a]); } else { - char buf[32]; + unsigned char buf[32]; WBUFW(buf,0) = 0x19a; WBUFL(buf,2) = sd->bl.id; if(sd->status.option&0x46) + // WTF? a -1 to an unsigned value... WBUFL(buf,6) = -1; else if(pvprank<=0) @@ -4851,7 +4852,7 @@ int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type) int clif_send0199(int map,int type) { struct block_list bl; - char buf[16]; + unsigned char buf[16]; bl.m = map; WBUFW(buf,0)=0x199; @@ -5117,7 +5118,7 @@ int clif_item_skill(struct map_session_data *sd,int skillid,int skilllv,const ch if(range < 0) range = battle_get_range(&sd->bl) - (range + 1); WFIFOW(fd,12)=range; - strncpy(WFIFOP(fd,14),name,24); + strncpy((char*)WFIFOP(fd,14),name,24); WFIFOB(fd,38)=0; WFIFOSET(fd,packet_len_table[0x147]); return 0; @@ -5360,7 +5361,7 @@ int clif_showvendingboard(struct block_list* bl,char *message,int fd) WBUFW(buf,0)=0x131; WBUFL(buf,2)=bl->id; - strncpy(WBUFP(buf,6),message,80); + strncpy((char*)WBUFP(buf,6),message,80); if(fd){ memcpy(WFIFOP(fd,0),buf,packet_len_table[0x131]); WFIFOSET(fd,packet_len_table[0x131]); @@ -5807,7 +5808,7 @@ int clif_hpmeter(struct map_session_data *sd) WBUFW(buf,8)=sd->bl.y; for(i=0;isession_data) && md->state.auth && + if(session[i] && (md = (struct map_session_data*)session[i]->session_data) && md->state.auth && md->bl.m == sd->bl.m && pc_isGM(md) && sd != md){ memcpy(WFIFOP(i,0),buf,packet_len_table[0x107]); WFIFOSET(i,packet_len_table[0x107]); @@ -5819,7 +5820,7 @@ int clif_hpmeter(struct map_session_data *sd) WBUFW(buf2,6)=(sd->status.hp > 0x7fff)? 0x7fff:sd->status.hp; WBUFW(buf2,8)=(sd->status.max_hp > 0x7fff)? 0x7fff:sd->status.max_hp; for(i=0;isession_data) && md->state.auth && + if(session[i] && (md = (struct map_session_data*)session[i]->session_data) && md->state.auth && md->bl.m == sd->bl.m && pc_isGM(md) && sd != md){ memcpy(WFIFOP(i,0),buf2,packet_len_table[0x106]); WFIFOSET(i,packet_len_table[0x106]); @@ -6234,7 +6235,7 @@ int clif_bladestop(struct block_list *src,struct block_list *dst, int clif_changemapcell(int m,int x,int y,int cell_type,int type) { struct block_list bl; - char buf[32]; + unsigned char buf[32]; bl.m = m; bl.x = x; @@ -6424,32 +6425,32 @@ int clif_guild_basicinfo(struct map_session_data *sd) if(g->guild_id == gc->guild_id) t++; } - if (t==1) strncpy(WFIFOP(fd,94),"One Castle",20); - else if (t==2) strncpy(WFIFOP(fd,94),"Two Castles",20); - else if (t==3) strncpy(WFIFOP(fd,94),"Three Castles",20); - else if (t==4) strncpy(WFIFOP(fd,94),"Four Castles",20); - else if (t==5) strncpy(WFIFOP(fd,94),"Five Castles",20); - else if (t==6) strncpy(WFIFOP(fd,94),"Six Castles",20); - else if (t==7) strncpy(WFIFOP(fd,94),"Seven Castles",20); - else if (t==8) strncpy(WFIFOP(fd,94),"Eight Castles",20); - else if (t==9) strncpy(WFIFOP(fd,94),"Nine Castles",20); - else if (t==10) strncpy(WFIFOP(fd,94),"Ten Castles",20); - else if (t==11) strncpy(WFIFOP(fd,94),"Eleven Castles",20); - else if (t==12) strncpy(WFIFOP(fd,94),"Twelve Castles",20); - else if (t==13) strncpy(WFIFOP(fd,94),"Thirteen Castles",20); - else if (t==14) strncpy(WFIFOP(fd,94),"Fourteen Castles",20); - else if (t==15) strncpy(WFIFOP(fd,94),"Fifteen Castles",20); - else if (t==16) strncpy(WFIFOP(fd,94),"Sixteen Castles",20); - else if (t==17) strncpy(WFIFOP(fd,94),"Seventeen Castles",20); - else if (t==18) strncpy(WFIFOP(fd,94),"Eighteen Castles",20); - else if (t==19) strncpy(WFIFOP(fd,94),"Nineteen Castles",20); - else if (t==20) strncpy(WFIFOP(fd,94),"Twenty Castles",20); - else if (t==21) strncpy(WFIFOP(fd,94),"Twenty One Castles",20); - else if (t==22) strncpy(WFIFOP(fd,94),"Twenty Two Castles",20); - else if (t==23) strncpy(WFIFOP(fd,94),"Twenty Three Castles",20); - else if (t==24) strncpy(WFIFOP(fd,94),"Twenty Four Castles",20); - else if (t==MAX_GUILDCASTLE) strncpy(WFIFOP(fd,94),"Total Domination",20); - else strncpy(WFIFOP(fd,94),"None Taken",20); + if (t==1) strncpy((char*)WFIFOP(fd,94),"One Castle",20); + else if (t==2) strncpy((char*)WFIFOP(fd,94),"Two Castles",20); + else if (t==3) strncpy((char*)WFIFOP(fd,94),"Three Castles",20); + else if (t==4) strncpy((char*)WFIFOP(fd,94),"Four Castles",20); + else if (t==5) strncpy((char*)WFIFOP(fd,94),"Five Castles",20); + else if (t==6) strncpy((char*)WFIFOP(fd,94),"Six Castles",20); + else if (t==7) strncpy((char*)WFIFOP(fd,94),"Seven Castles",20); + else if (t==8) strncpy((char*)WFIFOP(fd,94),"Eight Castles",20); + else if (t==9) strncpy((char*)WFIFOP(fd,94),"Nine Castles",20); + else if (t==10) strncpy((char*)WFIFOP(fd,94),"Ten Castles",20); + else if (t==11) strncpy((char*)WFIFOP(fd,94),"Eleven Castles",20); + else if (t==12) strncpy((char*)WFIFOP(fd,94),"Twelve Castles",20); + else if (t==13) strncpy((char*)WFIFOP(fd,94),"Thirteen Castles",20); + else if (t==14) strncpy((char*)WFIFOP(fd,94),"Fourteen Castles",20); + else if (t==15) strncpy((char*)WFIFOP(fd,94),"Fifteen Castles",20); + else if (t==16) strncpy((char*)WFIFOP(fd,94),"Sixteen Castles",20); + else if (t==17) strncpy((char*)WFIFOP(fd,94),"Seventeen Castles",20); + else if (t==18) strncpy((char*)WFIFOP(fd,94),"Eighteen Castles",20); + else if (t==19) strncpy((char*)WFIFOP(fd,94),"Nineteen Castles",20); + else if (t==20) strncpy((char*)WFIFOP(fd,94),"Twenty Castles",20); + else if (t==21) strncpy((char*)WFIFOP(fd,94),"Twenty One Castles",20); + else if (t==22) strncpy((char*)WFIFOP(fd,94),"Twenty Two Castles",20); + else if (t==23) strncpy((char*)WFIFOP(fd,94),"Twenty Three Castles",20); + else if (t==24) strncpy((char*)WFIFOP(fd,94),"Twenty Four Castles",20); + else if (t==MAX_GUILDCASTLE) strncpy((char*)WFIFOP(fd,94),"Total Domination",20); + else strncpy((char*)WFIFOP(fd,94),"None Taken",20); WFIFOSET(fd,packet_len_table[WFIFOW(fd,0)]); clif_guild_emblem(sd,g); // Guild emblem vanish fix [Valaris] @@ -7251,7 +7252,7 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) { struct map_session_data *pl_sd; int i; for(i = 0; i < fd_max; i++) { - if (session[i] && (pl_sd = session[i]->session_data) != NULL && + if (session[i] && (pl_sd = (struct map_session_data*)session[i]->session_data) != NULL && pl_sd->state.auth && (pc_isGM((struct map_session_data *)&bl) > pc_isGM((struct map_session_data *)&pl_sd->bl))) clif_specialeffect(&pl_sd->bl, type, 1); @@ -7261,7 +7262,7 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) { struct map_session_data *sd; int i; for(i = 0; i < fd_max; i++) { - if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m) + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m) clif_specialeffect(&sd->bl, type, 1); } } @@ -7342,7 +7343,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd) if (sd != 0) clif_setwaitclose(sd->fd); // Set session to EOF } else { - sd = session[fd]->session_data = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data)); + sd = (struct map_session_data*)session[fd]->session_data = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data)); sd->fd = fd; if (IS_PACKET_DB_VER(cmd)) { @@ -7885,27 +7886,27 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { */ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c .w .?B char *message; - char *buf; + unsigned char *buf; nullpo_retv(sd); - if ((is_atcommand(fd, sd, RFIFOP(fd,4), 0) != AtCommand_None) || - (is_charcommand(fd, sd, RFIFOP(fd,4),0)!= CharCommand_None) || + if ((is_atcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != AtCommand_None) || + (is_charcommand(fd, sd, (char*)RFIFOP(fd,4),0)!= CharCommand_None) || (sd->sc_data && (sd->sc_data[SC_BERSERK].timer != -1 || //バーサーク時は会話も不可 sd->sc_data[SC_NOCHAT].timer != -1 ))) //チャット禁止 return; message = (char*)aCallocA(RFIFOW(fd,2) + 128, sizeof(char)); - buf = (char*)aCallocA(RFIFOW(fd,2) + 4, sizeof(char)); + buf = (unsigned char*)aCallocA(RFIFOW(fd,2) + 4, sizeof(char)); //printf("clif_parse_GlobalMessage: message: '%s'.\n", RFIFOP(fd,4)); - if (strncmp(RFIFOP(fd,4), sd->status.name, strlen(sd->status.name)) != 0) { + if (strncmp((char*)RFIFOP(fd,4), sd->status.name, strlen(sd->status.name)) != 0) { printf("Hack on global message: character '%s' (account: %d), use an other name to send a (normal) message.\n", sd->status.name, sd->status.account_id); // information is sended to all online GM sprintf(message, "Hack on global message (normal message): character '%s' (account: %d) uses another name.", sd->status.name, sd->status.account_id); intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message, strlen(message) + 1); - if (strlen(RFIFOP(fd,4)) == 0) + if (strlen((char*)RFIFOP(fd,4)) == 0) strcpy(message, " This player sends a void name and a void message."); else sprintf(message, " This player sends (name:message): '%s'.", RFIFOP(fd,4)); @@ -7946,16 +7947,16 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < 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)); - if (sd->state.snovice_flag == 0 && strstr(RFIFOP(fd,4), msg_txt(540))) + estr_lower((char*)RFIFOP(fd,4)); + if (sd->state.snovice_flag == 0 && strstr((char*)RFIFOP(fd,4), msg_txt(540))) sd->state.snovice_flag = 1; else if (sd->state.snovice_flag == 1) { sprintf(message, msg_txt(541), sd->status.name); estr_lower(message); - if (strstr(RFIFOP(fd,4), message)) + if (strstr((char*)RFIFOP(fd,4), message)) sd->state.snovice_flag = 2; } - else if (sd->state.snovice_flag == 2 && strstr(RFIFOP(fd,4), msg_txt(542))) + else if (sd->state.snovice_flag == 2 && strstr((char*)RFIFOP(fd,4), msg_txt(542))) sd->state.snovice_flag = 3; else if (sd->state.snovice_flag == 3) { int i; @@ -8292,7 +8293,7 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 .w status.name, RFIFOP(fd,28)); if ((is_charcommand(fd, sd, gm_command, 0) != CharCommand_None) || @@ -8308,16 +8309,16 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 .w status.name, RFIFOP(fd,4)) != 0) // not exactly same name + strcmp(dstsd->status.name, (const char*)RFIFOP(fd,4)) != 0) // not exactly same name // send message to inter-server - intif_wis_message(sd, RFIFOP(fd,4), RFIFOP(fd,28), RFIFOW(fd,2)-28); + intif_wis_message(sd, (char*)RFIFOP(fd,4), (char*)RFIFOP(fd,28), RFIFOW(fd,2)-28); // player is on this map-server else { // if you send to your self, don't send anything to others @@ -8336,7 +8337,7 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 .w fd, sd->status.name, RFIFOP(fd,28), RFIFOW(fd,2) - 28); + clif_wis_message(dstsd->fd, sd->status.name, (char*)RFIFOP(fd,28), RFIFOW(fd,2) - 28); clif_wis_end(fd, 0); // type: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target } } @@ -8356,7 +8357,7 @@ void clif_parse_GMmessage(int fd, struct map_session_data *sd) { if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && (pc_isGM(sd) >= get_atcommand_level(AtCommand_Broadcast))) - intif_GMmessage(RFIFOP(fd,4), RFIFOW(fd,2)-4, 0); + intif_GMmessage((char*)RFIFOP(fd,4), RFIFOW(fd,2)-4, 0); } /*========================================== @@ -8688,7 +8689,7 @@ void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd) void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd) { if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 4){ - chat_createchat(sd,RFIFOW(fd,4),RFIFOB(fd,6),RFIFOP(fd,7),RFIFOP(fd,15),RFIFOW(fd,2)-15); + chat_createchat(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15); } else clif_skill_fail(sd,1,0,3); } @@ -8699,7 +8700,7 @@ void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd) */ void clif_parse_ChatAddMember(int fd,struct map_session_data *sd) { - chat_joinchat(sd,RFIFOL(fd,2),RFIFOP(fd,6)); + chat_joinchat(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6)); } /*========================================== @@ -8708,7 +8709,7 @@ void clif_parse_ChatAddMember(int fd,struct map_session_data *sd) */ void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd) { - chat_changechatstatus(sd,RFIFOW(fd,4),RFIFOB(fd,6),RFIFOP(fd,7),RFIFOP(fd,15),RFIFOW(fd,2)-15); + chat_changechatstatus(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15); } /*========================================== @@ -8717,7 +8718,7 @@ void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd) */ void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd) { - chat_changechatowner(sd,RFIFOP(fd,6)); + chat_changechatowner(sd,(char*)RFIFOP(fd,6)); } /*========================================== @@ -8726,7 +8727,7 @@ void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd) */ void clif_parse_KickFromChat(int fd,struct map_session_data *sd) { - chat_kickchat(sd,RFIFOP(fd,2)); + chat_kickchat(sd,(char*)RFIFOP(fd,2)); } /*========================================== @@ -9196,7 +9197,7 @@ void clif_parse_UseSkillMap(int fd,struct map_session_data *sd) if(sd->invincible_timer != -1) pc_delinvincibletimer(sd); - skill_castend_map(sd,RFIFOW(fd,2),RFIFOP(fd,4)); + skill_castend_map(sd,RFIFOW(fd,2),(char*)RFIFOP(fd,4)); } /*========================================== * メモ要求 @@ -9269,7 +9270,7 @@ void clif_parse_NpcStringInput(int fd,struct map_session_data *sd) memcpy(sd->npc_str,RFIFOP(fd,8),sizeof(sd->npc_str)); sd->npc_str[sizeof(sd->npc_str)-1]=0; } else - strcpy(sd->npc_str,RFIFOP(fd,8)); + strcpy(sd->npc_str,(char*)RFIFOP(fd,8)); npc_scriptcont(sd,RFIFOL(fd,4)); } @@ -9590,7 +9591,7 @@ void clif_parse_CloseKafra(int fd, struct map_session_data *sd) { */ void clif_parse_CreateParty(int fd, struct map_session_data *sd) { if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) { - party_create(sd,RFIFOP(fd,2)); + party_create(sd,(char*)RFIFOP(fd,2)); } else clif_skill_fail(sd,1,0,4); } @@ -9601,9 +9602,9 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) { */ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7){ - party_create(sd, RFIFOP(fd,2)); + party_create(sd,(char*)RFIFOP(fd,2)); } else - clif_skill_fail(sd, 1, 0, 4); + clif_skill_fail(sd,1,0,4); } /*========================================== @@ -9640,7 +9641,7 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { *------------------------------------------ */ void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) { - party_removemember(sd,RFIFOL(fd,2),RFIFOP(fd,6)); + party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6)); } /*========================================== @@ -9657,16 +9658,16 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) { */ void clif_parse_PartyMessage(int fd, struct map_session_data *sd) { nullpo_retv(sd); - if (is_charcommand(fd, sd, RFIFOP(fd,4), 0) != CharCommand_None) + if (is_charcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != CharCommand_None) return; - if (is_atcommand(fd, sd, RFIFOP(fd,4), 0) != AtCommand_None) + if (is_atcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != AtCommand_None) return; if(sd->sc_data && (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可 sd->sc_data[SC_NOCHAT].timer!=-1)) //チャット禁止 return; - party_send_message(sd, RFIFOP(fd,4), RFIFOW(fd,2)-4); + party_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4); } /*========================================== @@ -9702,7 +9703,7 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) { *------------------------------------------ */ void clif_parse_OpenVending(int fd,struct map_session_data *sd) { - vending_openvending(sd, RFIFOW(fd,2), RFIFOP(fd,4), RFIFOB(fd,84), RFIFOP(fd,85)); + vending_openvending(sd, RFIFOW(fd,2), (char*)RFIFOP(fd,4), RFIFOB(fd,84), RFIFOP(fd,85)); } /*========================================== @@ -9735,7 +9736,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) { *------------------------------------------ */ void clif_parse_CreateGuild(int fd,struct map_session_data *sd) { - guild_create(sd, RFIFOP(fd,6)); + guild_create(sd, (char*)RFIFOP(fd,6)); } /*========================================== @@ -9785,7 +9786,7 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) { int i; for(i = 4; i < RFIFOW(fd,2); i += 40 ){ - guild_change_position(sd, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), RFIFOP(fd,i+16)); + guild_change_position(sd, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16)); } } @@ -9819,7 +9820,7 @@ void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) { *------------------------------------------ */ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) { - guild_change_emblem(sd,RFIFOW(fd,2)-4,RFIFOP(fd,4)); + guild_change_emblem(sd,RFIFOW(fd,2)-4,(char*)RFIFOP(fd,4)); } /*========================================== @@ -9827,7 +9828,7 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) { *------------------------------------------ */ void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd) { - guild_change_notice(sd,RFIFOL(fd,2),RFIFOP(fd,6),RFIFOP(fd,66)); + guild_change_notice(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,66)); } /*========================================== @@ -9851,7 +9852,7 @@ void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) { *------------------------------------------ */ void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { - guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOP(fd,14)); + guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14)); } /*========================================== @@ -9859,7 +9860,7 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { *------------------------------------------ */ void clif_parse_GuildExplusion(int fd,struct map_session_data *sd) { - guild_explusion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOP(fd,14)); + guild_explusion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14)); } /*========================================== @@ -9868,16 +9869,16 @@ void clif_parse_GuildExplusion(int fd,struct map_session_data *sd) { */ void clif_parse_GuildMessage(int fd,struct map_session_data *sd) { nullpo_retv(sd); - if (is_charcommand(fd, sd, RFIFOP(fd, 4), 0) != CharCommand_None) + if (is_charcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != CharCommand_None) return; - if (is_atcommand(fd, sd, RFIFOP(fd, 4), 0) != AtCommand_None) + if (is_atcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != AtCommand_None) return; if(sd->sc_data && (sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可 sd->sc_data[SC_NOCHAT].timer!=-1)) //チャット禁止 return; - guild_send_message(sd, RFIFOP(fd,4), RFIFOW(fd,2)-4); + guild_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4); } /*========================================== @@ -9917,7 +9918,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { *------------------------------------------ */ void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { - guild_break(sd,RFIFOP(fd,2)); + guild_break(sd,(char*)RFIFOP(fd,2)); } // pet @@ -9941,7 +9942,7 @@ void clif_parse_SendEmotion(int fd, struct map_session_data *sd) { } void clif_parse_ChangePetName(int fd, struct map_session_data *sd) { - pet_change_name(sd,RFIFOP(fd,2)); + pet_change_name(sd,(char*)RFIFOP(fd,2)); } // Kick (right click menu for GM "(name) force to quit") @@ -10081,7 +10082,7 @@ void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *sd) WFIFOW(fd,0) = 0x1e0; WFIFOL(fd,2) = tid; - sprintf(WFIFOP(fd,6),"%d",tid); + sprintf((char*)WFIFOP(fd,6),"%d",tid); // memcpy(WFIFOP(fd,6), "TESTNAME", 24); WFIFOSET(fd, packet_len_table[0x1e0]); @@ -10095,7 +10096,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by memset(output, '\0', sizeof(output)); - nick = RFIFOP(fd,2); // speed up + nick = (char*)RFIFOP(fd,2); // speed up RFIFOB(fd,25) = '\0'; // to be sure that the player name have at maximum 23 characters //printf("Ignore: char '%s' state: %d\n", nick, RFIFOB(fd,26)); @@ -10216,7 +10217,7 @@ void clif_parse_skillMessage(int fd, struct map_session_data *sd) { // Added by y = RFIFOB(fd,6); x = RFIFOB(fd,8); - mes = RFIFOP(fd,10); + mes = (char*)RFIFOP(fd,10); // skill 220 = graffiti // printf("skill: %d %d location: %3d %3d message: %s\n", skillid, skilllv, x, y, (char*)mes); @@ -10292,7 +10293,7 @@ void clif_parse_friends_list_add(int fd, struct map_session_data *sd) { struct map_session_data *f_sd; int i; - f_sd = map_nick2sd(RFIFOP(fd,2)); + f_sd = map_nick2sd((char*)RFIFOP(fd,2)); // Friend doesn't exist (no player with this name) if (f_sd == NULL) { @@ -10504,7 +10505,7 @@ static int clif_parse(int fd) { int packet_len = 0, cmd, packet_ver; struct map_session_data *sd; - sd = session[fd]->session_data; + sd = (struct map_session_data*)session[fd]->session_data; // 接続が切れてるので後始末 if (!chrif_isconnect() || session[fd]->eof) { // char鯖に繋がってない間は接続禁止 (!chrif_isconnect()) -- cgit v1.2.3-70-g09d2 From d47ef1caf4153d3810a7d289f8dc0b8d01daa902 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec> Date: Sun, 6 Feb 2005 05:11:18 +0000 Subject: Upped max_files git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1054 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 1 + src/common/grfio.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/common/grfio.c') diff --git a/Changelog.txt b/Changelog.txt index e29af9d08..f48c06ecf 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,7 @@ Date Added 02/05 + * increased the max_files allowed in a grf [1054: MouseJstr] * Changed the way char deletion works for SQL [1051: Ajarn] - If the email the client fails check then check if the email is blank and the DB email is a@a.com (default) diff --git a/src/common/grfio.c b/src/common/grfio.c index 5453a4b5d..2d47ff4e4 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -96,7 +96,7 @@ typedef struct { //Since char defines *FILELIST.gentry, the maximum which can be added by grfio_add becomes by 127 pieces. #define GENTRY_LIMIT 127 -#define FILELIST_LIMIT 32768 // temporary maximum, and a theory top maximum are 2G. +#define FILELIST_LIMIT 65536 // temporary maximum, and a theory top maximum are 2G. static FILELIST *filelist; static int filelist_entrys; -- cgit v1.2.3-70-g09d2 From ff8a0342bc95eb2064ed7c620a0c410a92fde310 Mon Sep 17 00:00:00 2001 From: celest Date: Thu, 17 Feb 2005 16:28:36 +0000 Subject: * Readded Chemical Protection * Removed some old eA code that was causing Frost Nova to do an extra hit * Corrected Vulcan Arrow's hits in skill_db * Readded zlib and zconf .h files to under /lib * Fixed some compile errors in Windows * Changed remove_control_characters back to supporting korean chars * Moved some other code around git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1125 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 12 + db/skill_db.txt | 2 +- src/char/char.c | 18 +- src/char_sql/char.c | 19 +- src/common/grfio.c | 2 +- src/common/socket.c | 1 + src/common/strlib.c | 18 + src/common/strlib.h | 3 + src/ladmin/ladmin.c | 18 +- src/lib/zconf_win32.h | 279 ++++++++++++++++ src/lib/zlib_win32.h | 893 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/login/login.c | 19 +- src/login_sql/login.c | 17 - src/map/skill.c | 253 +------------- src/map/skill.h | 201 ------------ src/map/status.c | 231 +++++++++++++ src/map/status.h | 201 ++++++++++++ 17 files changed, 1658 insertions(+), 529 deletions(-) create mode 100644 src/lib/zconf_win32.h create mode 100644 src/lib/zlib_win32.h (limited to 'src/common/grfio.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 743da2c3f..3a4d1a239 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,6 +1,18 @@ Date Added 02/17 + * Readded Chemical Protection -- i forgot to check for it when changing some + jA stuff earlier, sorry ^^; [celest] + * Removed some old eA code that was causing Frost Nova to do an extra hit + [celest] + * Corrected Vulcan Arrow's hits in skill_db -- the bug appeared when the + correct numbers hardcoded were removed [celest] + * Readded zlib and zconf .h files to under /lib for compiling in Windows, + thanks to Ser [celest] + * Fixed some compile errors in Windows, thanks to Ser [celest] + * Changed remove_control_characters back to supporting korean chars [celest] + * Moved some other code around [celest] + * Added Shinomori's changes to Dissonance -- don't increment the timer again if the target has died [celest] * Changed some nullpo checks back to normal null checks -- in some situations diff --git a/db/skill_db.txt b/db/skill_db.txt index f9b2b234f..d7b4fd9d0 100644 --- a/db/skill_db.txt +++ b/db/skill_db.txt @@ -451,7 +451,7 @@ //391,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //ST_STEALBACKPACK#スティ?ルバックパック# 392,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //CR_ALCHEMY#アルケ??# 393,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //CR_SYNTHESISPOTION#??ションシンセシス# -394,8,8,1,0,0,10,2,no,0,0,0,weapon,0 //CG_ARROWVULCAN#アロ?バルカン# +394,8,8,1,0,0,10,9,no,0,0,0,weapon,0 //CG_ARROWVULCAN#アロ?バルカン# 395,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //CG_MOONLIT#月明りの泉に落ちる花びら# 396,0,6,16,0,1,1,1,yes,0,0,0,magic,1 //CG_MARIONETTE#?リオネットコントロ?ル# 397,4,8,1,0,0,5,1,no,0,0,0,weapon,0 //LK_SPIRALPIERCE#スパイラルピア?ス# diff --git a/src/char/char.c b/src/char/char.c index 038000aab..72de37e03 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -17,6 +17,7 @@ #include #include +#include "../common/strlib.h" #include "core.h" #include "socket.h" #include "timer.h" @@ -166,23 +167,6 @@ int char_log(char *fmt, ...) { return 0; } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char *str) { - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //---------------------------------------------------------------------- // Determine if an account (id) is a GM account // and returns its level (or 0 if it isn't a GM account or if not found) diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 133d78296..db62d05cf 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -18,7 +18,6 @@ #include #endif -#include "../common/utils.h" #include #include #include @@ -34,6 +33,7 @@ #include #include "char.h" +#include "../common/utils.h" #include "../common/strlib.h" #include "itemdb.h" #include "inter.h" @@ -232,23 +232,6 @@ void set_char_offline(int char_id, int account_id) { WFIFOSET(login_fd,6); } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char *str) { - int i; - int change = 0; - - for(i = 0; i < strlen(str); i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //---------------------------------------------------------------------- // Determine if an account (id) is a GM account // and returns its level (or 0 if it isn't a GM account or if not found) diff --git a/src/common/grfio.c b/src/common/grfio.c index 2d47ff4e4..0c628d163 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -33,7 +33,7 @@ #ifdef _WIN32 #include - #include "zlib_win32.h" + #include "../lib/zlib_win32.h" HINSTANCE zlib_dll; #define zlib_inflateInit(strm) zlib_inflateInit_((strm),ZLIB_VERSION, sizeof(z_stream)) #define zlib_deflateInit(strm, level) zlib_deflateInit_((strm),(level),ZLIB_VERSION,sizeof(z_stream)) diff --git a/src/common/socket.c b/src/common/socket.c index f43ca108c..02ba49cb9 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -10,6 +10,7 @@ #include #include #include +typedef int socklen_t; #else #include #include diff --git a/src/common/strlib.c b/src/common/strlib.c index 64c8e154f..2b130e76d 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -78,3 +78,21 @@ int jmemescapecpy (char* pt,char* spt, int size) { // copy size is 0 ~ (j-1) return j; } + +//----------------------------------------------------- +// Function to suppress control characters in a string. +//----------------------------------------------------- +//int remove_control_chars(char *str) { +int remove_control_chars(unsigned char *str) { + int i; + int change = 0; + + for(i = 0; str[i]; i++) { + if (str[i] < 32) { + str[i] = '_'; + change = 1; + } + } + + return change; +} diff --git a/src/common/strlib.h b/src/common/strlib.h index 54c52cf94..55920f823 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -7,4 +7,7 @@ char* jstrescape (char* pt); char* jstrescapecpy (char* pt,char* spt); int jmemescapecpy (char* pt,char* spt, int size); + +// custom functions +int remove_control_chars(unsigned char *); #endif diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index de177ba8a..0453efa1d 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -36,6 +36,7 @@ void Gettimeofday(struct timeval *timenow) #include // valist #include // tolower +#include "../common/strlib.h" #include "../common/core.h" #include "../common/socket.h" #include "ladmin.h" @@ -291,23 +292,6 @@ int ladmin_log(char *fmt, ...) { return 0; } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char *str) { - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //--------------------------------------------- // Function to return ordonal text of a number. //--------------------------------------------- diff --git a/src/lib/zconf_win32.h b/src/lib/zconf_win32.h new file mode 100644 index 000000000..c5048fe91 --- /dev/null +++ b/src/lib/zconf_win32.h @@ -0,0 +1,279 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTRVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/src/lib/zlib_win32.h b/src/lib/zlib_win32.h new file mode 100644 index 000000000..aa4b49250 --- /dev/null +++ b/src/lib/zlib_win32.h @@ -0,0 +1,893 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.3, July 9th, 1998 + + Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "zconf_win32.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.3" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/src/login/login.c b/src/login/login.c index f925f5e2a..221913b5b 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -15,6 +15,7 @@ void Gettimeofday(struct timeval *timenow) return; } #define gettimeofday(timenow, dummy) Gettimeofday(timenow) +#define in_addr_t unsigned long #else #include #include @@ -43,6 +44,7 @@ void Gettimeofday(struct timeval *timenow) #include "../common/lock.h" #include "../common/malloc.h" #include "../common/buffer.h" +#include "../common/strlib.h" #ifdef PASSWORDENC #include "md5calc.h" @@ -436,23 +438,6 @@ int check_ladminip(unsigned int ip) { return 0; } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char *str) { - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- diff --git a/src/login_sql/login.c b/src/login_sql/login.c index f387e32c1..c7c4cd9d1 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -223,23 +223,6 @@ int isGM(int account_id) { return level; } -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(unsigned char *str) { - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (str[i] < 32) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- diff --git a/src/map/skill.c b/src/map/skill.c index 61cd89ebd..240ad284e 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -36,237 +36,6 @@ #define STATE_BLIND 0x10 #define swap(x,y) { int t; t = x; x = y; y = t; } -/* スキル番?=>ステ?タス異常番??換テ?ブル */ -int SkillStatusChangeTable[]={ /* skill.hのenumのSC_***とあわせること */ -/* 0- */ - -1,-1,-1,-1,-1,-1, - SC_PROVOKE, /* プロボック */ - -1, 1,-1, -/* 10- */ - SC_SIGHT, /* サイト */ - -1,-1,-1,-1, - SC_FREEZE, /* フロストダイバ? */ - SC_STONE, /* スト?ンカ?ス */ - -1,-1,-1, -/* 20- */ - -1,-1,-1,-1, - SC_RUWACH, /* ルアフ */ - -1,-1,-1,-1, - SC_INCREASEAGI, /* 速度?加 */ -/* 30- */ - SC_DECREASEAGI, /* 速度減少 */ - -1, - SC_SIGNUMCRUCIS, /* シグナムクルシス */ - SC_ANGELUS, /* エンジェラス */ - SC_BLESSING, /* ブレッシング */ - -1,-1,-1,-1,-1, -/* 40- */ - -1,-1,-1,-1,-1, - SC_CONCENTRATE, /* 集中力向上 */ - -1,-1,-1,-1, -/* 50- */ - -1, - SC_HIDING, /* ハイディング */ - -1,-1,-1,-1,-1,-1,-1,-1, -/* 60- */ - SC_TWOHANDQUICKEN, /* 2HQ */ - SC_AUTOCOUNTER, - -1,-1,-1,-1, - SC_IMPOSITIO, /* インポシティオマヌス */ - SC_SUFFRAGIUM, /* サフラギウム */ - SC_ASPERSIO, /* アスペルシオ */ - SC_BENEDICTIO, /* 聖?降福 */ -/* 70- */ - -1, - SC_SLOWPOISON, - -1, - SC_KYRIE, /* キリエエレイソン */ - SC_MAGNIFICAT, /* マグニフィカ?ト */ - SC_GLORIA, /* グロリア */ - SC_DIVINA, /* レックスディビ?ナ */ - -1, - SC_AETERNA, /* レックスエ?テルナ */ - -1, -/* 80- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 90- */ - -1,-1, - SC_QUAGMIRE, /* クァグマイア */ - -1,-1,-1,-1,-1,-1,-1, -/* 100- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 110- */ - -1, - SC_ADRENALINE, /* アドレナリンラッシュ */ - SC_WEAPONPERFECTION,/* ウェポンパ?フェクション */ - SC_OVERTHRUST, /* オ?バ?トラスト */ - SC_MAXIMIZEPOWER, /* マキシマイズパワ? */ - -1,-1,-1,-1,-1, -/* 120- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 130- */ - -1,-1,-1,-1,-1, - SC_CLOAKING, /* クロ?キング */ - SC_STAN, /* ソニックブロ? */ - -1, - SC_ENCPOISON, /* エンチャントポイズン */ - SC_POISONREACT, /* ポイズンリアクト */ -/* 140- */ - SC_POISON, /* ベノムダスト */ - SC_SPLASHER, /* ベナムスプラッシャ? */ - -1, - SC_TRICKDEAD, /* 死んだふり */ - -1,-1,SC_AUTOBERSERK,-1,-1,-1, -/* 150- */ - -1,-1,-1,-1,-1, - SC_LOUD, /* ラウドボイス */ - -1, - SC_ENERGYCOAT, /* エナジ?コ?ト */ - -1,-1, -/* 160- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1, - SC_SELFDESTRUCTION, - -1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1, - SC_KEEPING, - -1,-1, - SC_BARRIER, - -1,-1, - SC_HALLUCINATION, - -1,-1, -/* 210- */ - -1,-1,-1,-1,-1, - SC_STRIPWEAPON, - SC_STRIPSHIELD, - SC_STRIPARMOR, - SC_STRIPHELM, - -1, -/* 220- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 230- */ - -1,-1,-1,-1, - SC_CP_WEAPON, - SC_CP_SHIELD, - SC_CP_ARMOR, - SC_CP_HELM, - -1,-1, -/* 240- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1, - SC_AUTOGUARD, -/* 250- */ - -1,-1, - SC_REFLECTSHIELD, - -1,-1, - SC_DEVOTION, - SC_PROVIDENCE, - SC_DEFENDER, - SC_SPEARSQUICKEN, - -1, -/* 260- */ - -1,-1,-1,-1,-1,-1,-1,-1, - SC_STEELBODY, - SC_BLADESTOP_WAIT, -/* 270- */ - SC_EXPLOSIONSPIRITS, - SC_EXTREMITYFIST, - -1,-1,-1,-1, - SC_MAGICROD, - -1,-1,-1, -/* 280- */ - SC_FLAMELAUNCHER, - SC_FROSTWEAPON, - SC_LIGHTNINGLOADER, - SC_SEISMICWEAPON, - -1, - SC_VOLCANO, - SC_DELUGE, - SC_VIOLENTGALE, - SC_LANDPROTECTOR, - -1, -/* 290- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 300- */ - -1,-1,-1,-1,-1,-1, - SC_LULLABY, - SC_RICHMANKIM, - SC_ETERNALCHAOS, - SC_DRUMBATTLE, -/* 310- */ - SC_NIBELUNGEN, - SC_ROKISWEIL, - SC_INTOABYSS, - SC_SIEGFRIED, - -1,-1,-1, - SC_DISSONANCE, - -1, - SC_WHISTLE, -/* 320- */ - SC_ASSNCROS, - SC_POEMBRAGI, - SC_APPLEIDUN, - -1,-1, - SC_UGLYDANCE, - -1, - SC_HUMMING, - SC_DONTFORGETME, - SC_FORTUNE, -/* 330- */ - SC_SERVICE4U, - SC_SELFDESTRUCTION, - -1,-1,-1,-1,-1,-1,-1,-1, -/* 340- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 350- */ - -1,-1,-1,-1,-1, - SC_AURABLADE, - SC_PARRYING, - SC_CONCENTRATION, - SC_TENSIONRELAX, - SC_BERSERK, -/* 360- */ - SC_BERSERK, - SC_ASSUMPTIO, - SC_BASILICA, - -1,-1,-1, - SC_MAGICPOWER, - -1, - SC_SACRIFICE, - SC_GOSPEL, -/* 370- */ - -1,-1,-1,-1,-1,-1,-1,-1, - SC_EDP, - -1, -/* 380- */ - SC_TRUESIGHT, - -1,-1, - SC_WINDWALK, - SC_MELTDOWN, - -1,-1, - SC_CARTBOOST, - -1, - SC_CHASEWALK, -/* 390- */ - SC_REJECTSWORD, - -1,-1,-1,-1, - SC_MOONLIT, - SC_MARIONETTE, - -1, - SC_HEADCRUSH, - SC_JOINTBEAT, -/* 400 */ - -1,-1, - SC_MINDBREAKER, - SC_MEMORIZE, - SC_FOGWALL, - SC_SPIDERWEB, - -1,-1,-1,-1, -/* 410- */ - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -}; - const struct skill_name_db skill_names[] = { { AC_CHARGEARROW, "CHARGEARROW", "Charge_Arrow" } , { AC_CONCENTRATION, "CONCENTRATION", "Improve_Concentration" } , @@ -883,7 +652,7 @@ int skill_get_unit_id(int id,int flag) case WZ_SIGHTRASHER: return 0x86; /* サイトラッシャ? */ case WZ_METEOR: return 0x86; /* メテオスト?ム */ case WZ_VERMILION: return 0x86; /* ロ?ドオブヴァ?ミリオン */ - case WZ_FROSTNOVA: return 0x86; /* フロストノヴァ */ + //case WZ_FROSTNOVA: return 0x86; /* フロストノヴァ */ case WZ_STORMGUST: return 0x86; /* スト?ムガスト(とりあえずLoVと同じで?理) */ case CR_GRANDCROSS: return 0x86; /* グランドクロス */ case NPC_DARKGRANDCROSS: return 0x86; /*闇グランドクロス*/ @@ -2751,7 +2520,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s break; case WZ_FROSTNOVA: /* フロストノヴァ */ - skill_castend_pos2(src,bl->x,bl->y,skillid,skilllv,tick,0); + //skill_castend_pos2(src,bl->x,bl->y,skillid,skilllv,tick,0); //skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,flag); map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); break; @@ -3982,8 +3751,12 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int return 1; } - if (tsc_data && tsc_data[scid].timer != -1) - break; + if (tsc_data) { + if (tsc_data[scid].timer != -1) + break; + if (tsc_data[skillid - RG_STRIPWEAPON + SC_CP_WEAPON].timer != -1) + break; + } if (dstsd && dstsd->unstripable_equip & equip) break; @@ -4956,7 +4729,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil case WZ_SIGHTRASHER: case WZ_QUAGMIRE: /* クァグマイア */ case WZ_VERMILION: /* ロ?ドオブヴァ?ミリオン */ - case WZ_FROSTNOVA: /* フロストノヴァ */ + //case WZ_FROSTNOVA: /* フロストノヴァ */ case WZ_STORMGUST: /* スト?ムガスト */ case WZ_HEAVENDRIVE: /* ヘヴンズドライブ */ case PR_SANCTUARY: /* サンクチュアリ */ @@ -5306,10 +5079,10 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, range=1; break; - case WZ_FROSTNOVA: /* フロストノヴァ */ - limit=500; - range=5; - break; + //case WZ_FROSTNOVA: /* フロストノヴァ */ + // limit=500; + // range=5; + // break; case WZ_HEAVENDRIVE: /* ヘヴンズドライブ */ limit=500; diff --git a/src/map/skill.h b/src/map/skill.h index af2d79f59..c06ab270f 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -180,207 +180,6 @@ enum { ST_RECOV_WEIGHT_RATE,ST_MOVE_ENABLE,ST_WATER, }; -enum { // struct map_session_data の status_changeの番?テ?ブル -// SC_SENDMAX未?はクライアントへの通知あり。 -// 2-2次職の値はなんかめちゃくちゃっぽいので暫定。たぶん?更されます。 - SC_SENDMAX = 128, // note: max is now 182, but we'll need to do alot of moving around - SC_PROVOKE = 0, - SC_ENDURE = 1, - SC_TWOHANDQUICKEN = 2, - SC_CONCENTRATE = 3, - SC_HIDING = 4, - SC_CLOAKING = 5, - SC_ENCPOISON = 6, - SC_POISONREACT = 7, - SC_QUAGMIRE = 8, - SC_ANGELUS = 9, - SC_BLESSING = 10, - SC_SIGNUMCRUCIS = 11, - SC_INCREASEAGI = 12, - SC_DECREASEAGI = 13, - SC_SLOWPOISON = 14, - SC_IMPOSITIO = 15, - SC_SUFFRAGIUM = 16, - SC_ASPERSIO = 17, - SC_BENEDICTIO = 18, - SC_KYRIE = 19, - SC_MAGNIFICAT = 20, - SC_GLORIA = 21, - SC_AETERNA = 22, - SC_ADRENALINE = 23, - SC_WEAPONPERFECTION = 24, - SC_OVERTHRUST = 25, - SC_MAXIMIZEPOWER = 26, - SC_RIDING = 27, - SC_FALCON = 28, - SC_TRICKDEAD = 29, - SC_LOUD = 30, - SC_ENERGYCOAT = 31, - SC_HALLUCINATION = 34, - SC_WEIGHT50 = 35, - SC_WEIGHT90 = 36, - SC_SPEEDPOTION0 = 37, - SC_SPEEDPOTION1 = 38, - SC_SPEEDPOTION2 = 39, - SC_SPEEDPOTION3 = 40, -//-- 40-50 - SC_STRIPWEAPON = 50, - SC_STRIPSHIELD = 51, - SC_STRIPARMOR = 52, - SC_STRIPHELM = 53, - SC_CP_WEAPON = 54, - SC_CP_SHIELD = 55, - SC_CP_ARMOR = 56, - SC_CP_HELM = 57, - SC_AUTOGUARD = 58, - SC_REFLECTSHIELD = 59, - SC_DEVOTION = 60, - SC_PROVIDENCE = 61, - SC_DEFENDER = 62, - SC_AUTOSPELL = 65, - SC_SPEARSQUICKEN = 68, -//-- 69-85 - SC_EXPLOSIONSPIRITS = 86, - SC_STEELBODY = 87, - SC_COMBO = 89, - SC_FLAMELAUNCHER = 90, - SC_FROSTWEAPON = 91, - SC_LIGHTNINGLOADER = 92, - SC_SEISMICWEAPON = 93, -//-- 94-102 - SC_AURABLADE = 103, /* オ?ラブレ?ド */ - SC_PARRYING = 104, /* パリイング */ - SC_CONCENTRATION = 105, /* コンセントレ?ション */ - SC_TENSIONRELAX = 106, /* テンションリラックス */ - SC_BERSERK = 107, /* バ?サ?ク */ -//-- 108, 109 - SC_ASSUMPTIO = 110, /* アシャンプティオ */ -//-- 111, 112 - SC_MAGICPOWER = 113, /* 魔法力?幅 */ -//-- 114 - SC_TRUESIGHT = 115, /* トゥル?サイト */ - SC_WINDWALK = 116, /* ウインドウォ?ク */ - SC_MELTDOWN = 117, /* メルトダウン */ - SC_CARTBOOST = 118, /* カ?トブ?スト */ -//-- 119 - SC_REJECTSWORD = 120, /* リジェクトソ?ド */ - SC_MARIONETTE = 121, /* マリオネットコントロ?ル */ -//-- 122, 123 - SC_HEADCRUSH = 124, /* ヘッドクラッシュ */ - SC_JOINTBEAT = 125, /* ジョイントビ?ト */ -//-- 126, 127 - - SC_STONE = 128, - SC_FREEZE = 129, -// <-- 130 = a baby skill status? - SC_STAN = 130, - SC_SLEEP = 131, -// <-- 132 = another baby skill? - SC_POISON = 132, - SC_CURSE = 133, - SC_SILENCE = 134, - SC_CONFUSION = 135, - SC_BLIND = 136, - SC_DIVINA = SC_SILENCE, - - SC_SAFETYWALL = 140, - SC_PNEUMA = 141, - SC_WATERBALL = 142, - SC_ANKLE = 143, - SC_DANCING = 144, - SC_KEEPING = 145, - SC_BARRIER = 146, - - SC_MAGICROD = 149, - SC_SIGHT = 150, - SC_RUWACH = 151, - SC_AUTOCOUNTER = 152, - SC_VOLCANO = 153, - SC_DELUGE = 154, - SC_VIOLENTGALE = 155, - SC_BLADESTOP_WAIT = 156, - SC_BLADESTOP = 157, - SC_EXTREMITYFIST = 158, - SC_GRAFFITI = 159, - - SC_LULLABY =160, - SC_RICHMANKIM =161, - SC_ETERNALCHAOS =162, - SC_DRUMBATTLE =163, - SC_NIBELUNGEN =164, - SC_ROKISWEIL =165, - SC_INTOABYSS =166, - SC_SIEGFRIED =167, - SC_DISSONANCE =168, - SC_WHISTLE =169, - SC_ASSNCROS =170, - SC_POEMBRAGI =171, - SC_APPLEIDUN =172, - SC_UGLYDANCE =173, - SC_HUMMING =174, - SC_DONTFORGETME =175, - SC_FORTUNE =176, - SC_SERVICE4U =177, - SC_SPIDERWEB =180, /* スパイダ?ウェッブ */ -// SC_EDP // moved - SC_SACRIFICE =184, /* サクリファイス */ - SC_WEDDING =187, //結婚用(結婚衣裳になって?くのが?いとか) - SC_NOCHAT =188, //赤エモ?態 - SC_SPLASHER =189, /* ベナムスプラッシャ? */ - SC_SELFDESTRUCTION =190, /* 自爆 */ - SC_MEMORIZE =197, /* メモライズ */ // changed from 181 to 192 - SC_DPOISON =198, /* 猛毒 */ - -// Used by English Team - SC_BROKNARMOR =32, - SC_BROKNWEAPON =33, - SC_SPEEDUP0 =41, // for skill speedup - SC_SPEEDUP1 =42, // for skill speedup - SC_SLOWDOWN =45, // for skill slowdown - SC_AUTOBERSERK =46, - SC_SIGHTTRASHER =73, - SC_BASILICA =102, // temporarily use this before an actual id is found [celest] - SC_EDP =114, /* エフェクトが判明したら移動 */ - SC_MARIONETTE2 =122, // Marionette target - SC_ENSEMBLE =159, - SC_FOGWALL =178, - SC_GOSPEL =179, - SC_PRESERVE =181, - SC_BATTLEORDERS =182, - SC_MOONLIT =183, - SC_ATKPOT =185, // [Valaris] - SC_MATKPOT =186, // [Valaris] - SC_MINDBREAKER =191, - SC_SPELLBREAKER =192, - SC_LANDPROTECTOR =193, - SC_ADAPTATION =194, - SC_CHASEWALK =195, - SC_REGENERATION =196, - - -// [Celest] - SC_BLEEDING = 124, // Temporarily same id as headcrush - -// -- testing various SC effects -// SC_AURABLADE =81, -// SC_CONCENTRATION =83, -// SC_TENSIONRELAX =84, -// SC_BERSERK =85, -// SC_CALLSPIRITS =100, -// SC_PARRYING =100, -// SC_FREECAST =101, -// SC_ABSORBSPIRIT =102, -// SC_ASSUMPTIO =114, -// SC_SHARPSHOOT =127, -// SC_GANGSTER =184, -// SC_CANNIBALIZE =186, -// SC_SPHEREMINE =187, -// SC_METEOSTORM =189, -// SC_CASTCANCEL =190, -// SC_SPIDERWEB =191, -}; -extern int SkillStatusChangeTable[]; - enum { NV_BASIC = 1, diff --git a/src/map/status.c b/src/map/status.c index 412308f59..6c2300dca 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -23,6 +23,237 @@ #include "script.h" #include "showmsg.h" +/* スキル番?=>ステ?タス異常番??換テ?ブル */ +int SkillStatusChangeTable[]={ /* status.hのenumのSC_***とあわせること */ +/* 0- */ + -1,-1,-1,-1,-1,-1, + SC_PROVOKE, /* プロボック */ + -1, 1,-1, +/* 10- */ + SC_SIGHT, /* サイト */ + -1,-1,-1,-1, + SC_FREEZE, /* フロストダイバ? */ + SC_STONE, /* スト?ンカ?ス */ + -1,-1,-1, +/* 20- */ + -1,-1,-1,-1, + SC_RUWACH, /* ルアフ */ + -1,-1,-1,-1, + SC_INCREASEAGI, /* 速度?加 */ +/* 30- */ + SC_DECREASEAGI, /* 速度減少 */ + -1, + SC_SIGNUMCRUCIS, /* シグナムクルシス */ + SC_ANGELUS, /* エンジェラス */ + SC_BLESSING, /* ブレッシング */ + -1,-1,-1,-1,-1, +/* 40- */ + -1,-1,-1,-1,-1, + SC_CONCENTRATE, /* 集中力向上 */ + -1,-1,-1,-1, +/* 50- */ + -1, + SC_HIDING, /* ハイディング */ + -1,-1,-1,-1,-1,-1,-1,-1, +/* 60- */ + SC_TWOHANDQUICKEN, /* 2HQ */ + SC_AUTOCOUNTER, + -1,-1,-1,-1, + SC_IMPOSITIO, /* インポシティオマヌス */ + SC_SUFFRAGIUM, /* サフラギウム */ + SC_ASPERSIO, /* アスペルシオ */ + SC_BENEDICTIO, /* 聖?降福 */ +/* 70- */ + -1, + SC_SLOWPOISON, + -1, + SC_KYRIE, /* キリエエレイソン */ + SC_MAGNIFICAT, /* マグニフィカ?ト */ + SC_GLORIA, /* グロリア */ + SC_DIVINA, /* レックスディビ?ナ */ + -1, + SC_AETERNA, /* レックスエ?テルナ */ + -1, +/* 80- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 90- */ + -1,-1, + SC_QUAGMIRE, /* クァグマイア */ + -1,-1,-1,-1,-1,-1,-1, +/* 100- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 110- */ + -1, + SC_ADRENALINE, /* アドレナリンラッシュ */ + SC_WEAPONPERFECTION,/* ウェポンパ?フェクション */ + SC_OVERTHRUST, /* オ?バ?トラスト */ + SC_MAXIMIZEPOWER, /* マキシマイズパワ? */ + -1,-1,-1,-1,-1, +/* 120- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 130- */ + -1,-1,-1,-1,-1, + SC_CLOAKING, /* クロ?キング */ + SC_STAN, /* ソニックブロ? */ + -1, + SC_ENCPOISON, /* エンチャントポイズン */ + SC_POISONREACT, /* ポイズンリアクト */ +/* 140- */ + SC_POISON, /* ベノムダスト */ + SC_SPLASHER, /* ベナムスプラッシャ? */ + -1, + SC_TRICKDEAD, /* 死んだふり */ + -1,-1,SC_AUTOBERSERK,-1,-1,-1, +/* 150- */ + -1,-1,-1,-1,-1, + SC_LOUD, /* ラウドボイス */ + -1, + SC_ENERGYCOAT, /* エナジ?コ?ト */ + -1,-1, +/* 160- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1, + SC_SELFDESTRUCTION, + -1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1, + SC_KEEPING, + -1,-1, + SC_BARRIER, + -1,-1, + SC_HALLUCINATION, + -1,-1, +/* 210- */ + -1,-1,-1,-1,-1, + SC_STRIPWEAPON, + SC_STRIPSHIELD, + SC_STRIPARMOR, + SC_STRIPHELM, + -1, +/* 220- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 230- */ + -1,-1,-1,-1, + SC_CP_WEAPON, + SC_CP_SHIELD, + SC_CP_ARMOR, + SC_CP_HELM, + -1,-1, +/* 240- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1, + SC_AUTOGUARD, +/* 250- */ + -1,-1, + SC_REFLECTSHIELD, + -1,-1, + SC_DEVOTION, + SC_PROVIDENCE, + SC_DEFENDER, + SC_SPEARSQUICKEN, + -1, +/* 260- */ + -1,-1,-1,-1,-1,-1,-1,-1, + SC_STEELBODY, + SC_BLADESTOP_WAIT, +/* 270- */ + SC_EXPLOSIONSPIRITS, + SC_EXTREMITYFIST, + -1,-1,-1,-1, + SC_MAGICROD, + -1,-1,-1, +/* 280- */ + SC_FLAMELAUNCHER, + SC_FROSTWEAPON, + SC_LIGHTNINGLOADER, + SC_SEISMICWEAPON, + -1, + SC_VOLCANO, + SC_DELUGE, + SC_VIOLENTGALE, + SC_LANDPROTECTOR, + -1, +/* 290- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 300- */ + -1,-1,-1,-1,-1,-1, + SC_LULLABY, + SC_RICHMANKIM, + SC_ETERNALCHAOS, + SC_DRUMBATTLE, +/* 310- */ + SC_NIBELUNGEN, + SC_ROKISWEIL, + SC_INTOABYSS, + SC_SIEGFRIED, + -1,-1,-1, + SC_DISSONANCE, + -1, + SC_WHISTLE, +/* 320- */ + SC_ASSNCROS, + SC_POEMBRAGI, + SC_APPLEIDUN, + -1,-1, + SC_UGLYDANCE, + -1, + SC_HUMMING, + SC_DONTFORGETME, + SC_FORTUNE, +/* 330- */ + SC_SERVICE4U, + SC_SELFDESTRUCTION, + -1,-1,-1,-1,-1,-1,-1,-1, +/* 340- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 350- */ + -1,-1,-1,-1,-1, + SC_AURABLADE, + SC_PARRYING, + SC_CONCENTRATION, + SC_TENSIONRELAX, + SC_BERSERK, +/* 360- */ + SC_BERSERK, + SC_ASSUMPTIO, + SC_BASILICA, + -1,-1,-1, + SC_MAGICPOWER, + -1, + SC_SACRIFICE, + SC_GOSPEL, +/* 370- */ + -1,-1,-1,-1,-1,-1,-1,-1, + SC_EDP, + -1, +/* 380- */ + SC_TRUESIGHT, + -1,-1, + SC_WINDWALK, + SC_MELTDOWN, + -1,-1, + SC_CARTBOOST, + -1, + SC_CHASEWALK, +/* 390- */ + SC_REJECTSWORD, + -1,-1,-1,-1, + SC_MOONLIT, + SC_MARIONETTE, + -1, + SC_HEADCRUSH, + SC_JOINTBEAT, +/* 400 */ + -1,-1, + SC_MINDBREAKER, + SC_MEMORIZE, + SC_FOGWALL, + SC_SPIDERWEB, + -1,-1,-1,-1, +/* 410- */ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +}; + static int max_weight_base[MAX_PC_CLASS]; static int hp_coefficient[MAX_PC_CLASS]; static int hp_coefficient2[MAX_PC_CLASS]; diff --git a/src/map/status.h b/src/map/status.h index 0a7dda382..dbb4ec21c 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1,6 +1,207 @@ #ifndef _STATUS_H_ #define _STATUS_H_ +enum { // struct map_session_data の status_changeの番?テ?ブル +// SC_SENDMAX未?はクライアントへの通知あり。 +// 2-2次職の値はなんかめちゃくちゃっぽいので暫定。たぶん?更されます。 + SC_SENDMAX = 128, // note: max is now 182, but we'll need to do alot of moving around + SC_PROVOKE = 0, + SC_ENDURE = 1, + SC_TWOHANDQUICKEN = 2, + SC_CONCENTRATE = 3, + SC_HIDING = 4, + SC_CLOAKING = 5, + SC_ENCPOISON = 6, + SC_POISONREACT = 7, + SC_QUAGMIRE = 8, + SC_ANGELUS = 9, + SC_BLESSING = 10, + SC_SIGNUMCRUCIS = 11, + SC_INCREASEAGI = 12, + SC_DECREASEAGI = 13, + SC_SLOWPOISON = 14, + SC_IMPOSITIO = 15, + SC_SUFFRAGIUM = 16, + SC_ASPERSIO = 17, + SC_BENEDICTIO = 18, + SC_KYRIE = 19, + SC_MAGNIFICAT = 20, + SC_GLORIA = 21, + SC_AETERNA = 22, + SC_ADRENALINE = 23, + SC_WEAPONPERFECTION = 24, + SC_OVERTHRUST = 25, + SC_MAXIMIZEPOWER = 26, + SC_RIDING = 27, + SC_FALCON = 28, + SC_TRICKDEAD = 29, + SC_LOUD = 30, + SC_ENERGYCOAT = 31, + SC_HALLUCINATION = 34, + SC_WEIGHT50 = 35, + SC_WEIGHT90 = 36, + SC_SPEEDPOTION0 = 37, + SC_SPEEDPOTION1 = 38, + SC_SPEEDPOTION2 = 39, + SC_SPEEDPOTION3 = 40, +//-- 40-50 + SC_STRIPWEAPON = 50, + SC_STRIPSHIELD = 51, + SC_STRIPARMOR = 52, + SC_STRIPHELM = 53, + SC_CP_WEAPON = 54, + SC_CP_SHIELD = 55, + SC_CP_ARMOR = 56, + SC_CP_HELM = 57, + SC_AUTOGUARD = 58, + SC_REFLECTSHIELD = 59, + SC_DEVOTION = 60, + SC_PROVIDENCE = 61, + SC_DEFENDER = 62, + SC_AUTOSPELL = 65, + SC_SPEARSQUICKEN = 68, +//-- 69-85 + SC_EXPLOSIONSPIRITS = 86, + SC_STEELBODY = 87, + SC_COMBO = 89, + SC_FLAMELAUNCHER = 90, + SC_FROSTWEAPON = 91, + SC_LIGHTNINGLOADER = 92, + SC_SEISMICWEAPON = 93, +//-- 94-102 + SC_AURABLADE = 103, /* オ?ラブレ?ド */ + SC_PARRYING = 104, /* パリイング */ + SC_CONCENTRATION = 105, /* コンセントレ?ション */ + SC_TENSIONRELAX = 106, /* テンションリラックス */ + SC_BERSERK = 107, /* バ?サ?ク */ +//-- 108, 109 + SC_ASSUMPTIO = 110, /* アシャンプティオ */ +//-- 111, 112 + SC_MAGICPOWER = 113, /* 魔法力?幅 */ +//-- 114 + SC_TRUESIGHT = 115, /* トゥル?サイト */ + SC_WINDWALK = 116, /* ウインドウォ?ク */ + SC_MELTDOWN = 117, /* メルトダウン */ + SC_CARTBOOST = 118, /* カ?トブ?スト */ +//-- 119 + SC_REJECTSWORD = 120, /* リジェクトソ?ド */ + SC_MARIONETTE = 121, /* マリオネットコントロ?ル */ +//-- 122, 123 + SC_HEADCRUSH = 124, /* ヘッドクラッシュ */ + SC_JOINTBEAT = 125, /* ジョイントビ?ト */ +//-- 126, 127 + + SC_STONE = 128, + SC_FREEZE = 129, +// <-- 130 = a baby skill status? + SC_STAN = 130, + SC_SLEEP = 131, +// <-- 132 = another baby skill? + SC_POISON = 132, + SC_CURSE = 133, + SC_SILENCE = 134, + SC_CONFUSION = 135, + SC_BLIND = 136, + SC_DIVINA = SC_SILENCE, + + SC_SAFETYWALL = 140, + SC_PNEUMA = 141, + SC_WATERBALL = 142, + SC_ANKLE = 143, + SC_DANCING = 144, + SC_KEEPING = 145, + SC_BARRIER = 146, + + SC_MAGICROD = 149, + SC_SIGHT = 150, + SC_RUWACH = 151, + SC_AUTOCOUNTER = 152, + SC_VOLCANO = 153, + SC_DELUGE = 154, + SC_VIOLENTGALE = 155, + SC_BLADESTOP_WAIT = 156, + SC_BLADESTOP = 157, + SC_EXTREMITYFIST = 158, + SC_GRAFFITI = 159, + + SC_LULLABY =160, + SC_RICHMANKIM =161, + SC_ETERNALCHAOS =162, + SC_DRUMBATTLE =163, + SC_NIBELUNGEN =164, + SC_ROKISWEIL =165, + SC_INTOABYSS =166, + SC_SIEGFRIED =167, + SC_DISSONANCE =168, + SC_WHISTLE =169, + SC_ASSNCROS =170, + SC_POEMBRAGI =171, + SC_APPLEIDUN =172, + SC_UGLYDANCE =173, + SC_HUMMING =174, + SC_DONTFORGETME =175, + SC_FORTUNE =176, + SC_SERVICE4U =177, + SC_SPIDERWEB =180, /* スパイダ?ウェッブ */ +// SC_EDP // moved + SC_SACRIFICE =184, /* サクリファイス */ + SC_WEDDING =187, //結婚用(結婚衣裳になって?くのが?いとか) + SC_NOCHAT =188, //赤エモ?態 + SC_SPLASHER =189, /* ベナムスプラッシャ? */ + SC_SELFDESTRUCTION =190, /* 自爆 */ + SC_MEMORIZE =197, /* メモライズ */ // changed from 181 to 192 + SC_DPOISON =198, /* 猛毒 */ + +// Used by English Team + SC_BROKNARMOR =32, + SC_BROKNWEAPON =33, + SC_SPEEDUP0 =41, // for skill speedup + SC_SPEEDUP1 =42, // for skill speedup + SC_SLOWDOWN =45, // for skill slowdown + SC_AUTOBERSERK =46, + SC_SIGHTTRASHER =73, + SC_BASILICA =102, // temporarily use this before an actual id is found [celest] + SC_EDP =114, /* エフェクトが判明したら移動 */ + SC_MARIONETTE2 =122, // Marionette target + SC_ENSEMBLE =159, + SC_FOGWALL =178, + SC_GOSPEL =179, + SC_PRESERVE =181, + SC_BATTLEORDERS =182, + SC_MOONLIT =183, + SC_ATKPOT =185, // [Valaris] + SC_MATKPOT =186, // [Valaris] + SC_MINDBREAKER =191, + SC_SPELLBREAKER =192, + SC_LANDPROTECTOR =193, + SC_ADAPTATION =194, + SC_CHASEWALK =195, + SC_REGENERATION =196, + + +// [Celest] + SC_BLEEDING = 124, // Temporarily same id as headcrush + +// -- testing various SC effects +// SC_AURABLADE =81, +// SC_CONCENTRATION =83, +// SC_TENSIONRELAX =84, +// SC_BERSERK =85, +// SC_CALLSPIRITS =100, +// SC_PARRYING =100, +// SC_FREECAST =101, +// SC_ABSORBSPIRIT =102, +// SC_ASSUMPTIO =114, +// SC_SHARPSHOOT =127, +// SC_GANGSTER =184, +// SC_CANNIBALIZE =186, +// SC_SPHEREMINE =187, +// SC_METEOSTORM =189, +// SC_CASTCANCEL =190, +// SC_SPIDERWEB =191, +}; +extern int SkillStatusChangeTable[]; + // パラメータ所得系 battle.c より移動 int status_get_class(struct block_list *bl); int status_get_dir(struct block_list *bl); -- cgit v1.2.3-70-g09d2 From f65bf4bd28cd9240c889bfd2a1f4650d91760a2d Mon Sep 17 00:00:00 2001 From: celest Date: Tue, 22 Feb 2005 16:08:24 +0000 Subject: * Corrected Spiral Pierce's hits in the skill_db * Moved /common/*.o into a obj folder when compiling * Updated core and map server to jA 1094~1115 git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1162 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 20 + Readme-jap | 2939 +++++++++++++++++++++++++++++++++++++- db/skill_cast_db.txt | 20 +- db/skill_db.txt | 2 +- db/skill_unit_db.txt | 78 + src/char/Makefile | 2 +- src/char_sql/Makefile | 2 +- src/common/Makefile | 34 +- src/common/core.c | 74 +- src/common/db.c | 20 +- src/common/db.h | 10 +- src/common/grfio.c | 55 +- src/common/malloc.c | 484 ++++++- src/common/malloc.h | 8 +- src/ladmin/Makefile | 2 +- src/login/Makefile | 2 +- src/login_sql/Makefile | 2 +- src/map/Makefile | 102 +- src/map/atcommand.c | 52 +- src/map/atcommand.h | 2 + src/map/battle.c | 16 +- src/map/chrif.c | 11 + src/map/chrif.h | 1 + src/map/guild.c | 10 +- src/map/itemdb.c | 18 +- src/map/map.c | 152 +- src/map/map.h | 39 +- src/map/mob.c | 98 +- src/map/path.c | 2 +- src/map/pc.c | 93 +- src/map/skill.c | 2822 +++++++++++++++--------------------- src/map/skill.h | 36 +- src/map/status.c | 31 +- src/map/status.h | 2 +- src/txt-converter/char/Makefile | 2 +- src/txt-converter/login/Makefile | 2 +- 36 files changed, 5225 insertions(+), 2020 deletions(-) create mode 100644 db/skill_unit_db.txt (limited to 'src/common/grfio.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index f6c7813ce..0703d2cb9 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,5 +1,25 @@ Date Added +02/23 + * Corrected Spiral Pierce's hits in the skill_db [celest] + * Moved /common/*.o into a obj folder when compiling [celest] + * Updated core and map server to jA 1094~1115 [celest] + - Added End_of_exam's Memory Manager for detecting memory problems. + To enable remove the // in malloc.c line 11 + // #define USE_MEMMGR + - Added @npctalk and @pettalk + - Added support for jA's local zlib + - Fixed a bug with path search long + - Updated malloc.c to support Memwatch + - Added DB data loss detection + - Added db/skill_unit_db.txt + - Updated skill unit system + - Changed Waterball to the new timerskill system + ~ For more detailed logs check 'Readme-jap' (knowledge in japanese required, + obviously ^^;) + Please test if there's any skills that might have suddenly stopped working, + thanks ^^; + 02/22 * Revised New Cards, added missing effects, fixed bugs [Lupus] ~20 cards to check left 8) But in 22 Feb some new cards have been announced T__T' diff --git a/Readme-jap b/Readme-jap index 6bf23c87b..9956e4bd0 100644 --- a/Readme-jap +++ b/Readme-jap @@ -1,3 +1,2923 @@ +-------------------- +//1114-fix1 by 稀枝 + +・zlibをmap-server内部に取り込めるオプションを追加 +・makeがMinGW+Msysで正常に通るよう修正 +・win32_start.batにチェック追加 + + (src/common/zlib) + trees.h - anybody's guess上のzlib_1_2_1_staticlibより取り込み + inffixed.h - 同上 + inffast.h - 同上 + crc32.h - 同上 + compress.c - 同上 + deflate.h - 同上 + inftrees.h - 同上 + zutil.c - 同上 + crc32.c - 同上 + inflate.h - 同上 + inffast.c - 同上 + trees.c - 同上 + inflate.c - 同上 + zconf.h - 同上 + deflate.c - 同上 + inftrees.c - 同上 + zutil.h - 同上 + zlib.h - 同上 + adler32.c - 同上 + Makefile - LOCALZLIBが指定されている時のみコンパイルします。 + + (src/map/) + Makefile - MinGWの場合、引数-wsock32を追加します。 + - LOCALZLIBが指定されている場合リンクします。 + - LOCALZLIBが無い場合だけzlib.aをリンクします。 + (src/char/) + Makefile - MinGWの場合、引数-wsock32を追加します。 + (src/login/) + Makefile - MinGWの場合、引数-wsock32を追加します。 + (src/common/grfio.c) - Zlibを内包した際に_WIN32と競合しないよう変更 + - zlib_win32.h zconf_win32.hを廃止 + + (./) + Makefile - #Link Zlib(NOTrecommended)、zlibを内包します。 + win32_start.bat - athena-startの半クローン化。初期起動でこけなくなるはずです。 + +-------------------- +//1113 by End_of_exam + +・linux 環境で大量のwarning が出ていたのを修正(malloc.h) +・map_quit() でcharid_db のデータを削除しないように変更(map.c thanks to lemitさん) +・pc_eventtimer(), npc_event_timer() のfree()で警告が出ていたのを修正(pc.c npc.c) +・map_eraseipport() がメモリリークしていたバグを修正(map.c) +・addtimer 命令に指定するイベント名が23文字に制限されていたのを無制限にする(pc.c) +・pc_cleareventtimer() , pc_deleventtimer() がメモリリークしていたバグを修正 + (pc.c thanks to Shinomoriさん) + + (src/common/) + malloc.h - "#undef strdup" を追加 + + (src/map/) + npc.c - npc_event_timer() 修正 + pc.c - pc_eventtimer() , pc_addeventtimer() , pc_cleareventtimer(), + pc_deleventtimer() 修正 + map.c - map_quit() , map_eraseipport() 修正 + +-------------------- +//1112 by lizorett +・PCがマップ移動中に、そのPCが設置したスキルユニットのskill_unit_onoutが呼ばれ +ない問題(map-severが落ちる可能性あり)を修正 +・バジリカを仕様に併せて修正 +・正常終了時にchar-serverがコアダンプする問題を修正 +・mobがウォータボール使用時のヒット数を修正(skill_db.txtに指定した数ヒット) +・コーティングされている場合にはストリップできないよう変更 +・属性場を使用した際、前に出していた属性場が消えないことがある問題を修正 + + (db) + skill_db.txt + - mobのウォータボールのカウント数をDBにいれた + skill_unit_db.txt + - バジリカを修正 + (char) + char.c - do_final()のchar_datのメモリ開放位置を変更 + (map) + clif.c - バジリカ時に攻撃などができないよう変更 + map.c - バジリカ位置をセルのフラグに入れるよう変更 + map.h - バジリカ用のセルフラグ追加 + mob.c - バジリカに進入できないように変更 + pc.c - 移動時(蝿など)にバジリカを消すよう修正 + skill.c - バジリカ修正 + - ウォータボール修正 + - skill_unit_onoutの呼び出しを修正 + - コーティングされている箇所はストリップ不可に変更 + +-------------------- +//1111 by Toshi^2 +・pc系mobに転生&養子を指定できるように変更。 + db/mob_avail.txtに説明文を追加したので、それを参照してください。 + + (db) + mob_avail.txt - 引数の説明を追加。 + (src/map) + clif.c - clif_mob0078() clif_mob007b() clif_pet0078() clif_pet007b() 修正 + mob.c - mob_readdb_mobavail() 修正 + mob.h - 構造体mob_dbに「short trans」を追加、mob_availのtransフラグを格納。 + +-------------------- +//1110 by lizorett +・ユニット系スキル(ニュマ、ダンス等)でmap_server.exeが落ちる問題を修正 + (トレースではskill_unit_onplace/skill_unit_onoutで落ちる) +・サンクチュアリの人数カウント方法を変更(本鯖仕様) +・マグヌスの範囲を広げ、使用したユニットが削除されるようにする(本鯖仕様) +・デボーションの距離が短くなる問題を修正(バグ報告スレッド part8 >>15) +・デボーションでnullpoが出る問題を修正 +・mobのインティミデイトが成功するとmap-serverが落ちる問題を修正(バグ報告スレッ +ド part8 >>42) +・ウォーターボールの仕様を本鯖に近づける(水場が少ない場合にはhit数が減る、 +デリュージ上で実行するとユニットが欠ける) +・ファーマシーの製造成功確率のコードを変更 + + (db) + skill_unit_db.txt + - ユニットID/配置などをdb化しています + (src/map) + map.h - skill_unit_groupのメンバ変更 + mob.c - 移動時にスキルユニット判断(skill_unit_out_all/skill_unit_move) + を追加 + - 足元置き/重複置き判断を変更 + pc.c - 移動時にスキルユニット判断(同上)を追加 + - 無敵時間が終わる際にスキルユニット判断(同上)を追加 + skill.h - skill_dbの参照関数をdefineに変更 + - スキル配置を入れるskill_unit_layout構造体を定義 + - SC_WATERBALL削除 + skill.c - unit_idをdb化(skill_unit_db.txt) + - スキルユニットのレイアウトを起動時に定義 + - 移動時にスキルユニット判断(同上)を追加 + - 足元置き/重複置き判断を変更 + - スキルユニットの移動処理を変更 + - デボーションの修正 + - mobのインティミデイトで落ちる問題を修正 + - ウォータボールの仕様変更 + status.c- SC_WATERBALLの処理を削除 + +-------------------- +//1109 by End_of_exam + +1108に引き続きメモリリークのバグ修正です。2つ共に深刻なバグなので、 +最新版に更新しない方でも修正することをおすすめします。 + +・ペットが床にアイテムを落とす時、ペットを卵に戻す時にメモリリークが発生 + していたバグを修正。(pet.c) + +・キャラクター依存一時変数の利用したキャラがログアウトするとメモリリークが + 発生していたバグを修正(map.c) + + (src/map) + map.c - map_quit() 修正 + pet.c - pet_remove_map(), pet_return_egg() pet_lootitem_drop() 修正 + +-------------------- +//1108 by End_of_exam + +・以前作ったメモリマネージャーを統合。(malloc.c core.c) + 有効にするには、malloc.c内部のコメントを外す必要があります。開発に協力して + 頂ける方は、メモリマネージャを有効にして、チェック結果(map-server.logなど)を + アップロードしてくれると助かります。 + +  1. guild.c がコンパイルエラーになったので修正(guild.c) +  2. pet.c がメモリ解放し忘れていたので、do_final_pet() を追加(pet.c) +  3. do_final_socket を追加して、終了時に全ての接続を切断する(socket.c) +  4. deplicate の元スクリプトが終了時にfreeされないバグを修正(npc.c) +  5. do_final_script で開放されないメモリがあるバグを修正(script.c) +  6. do_init_*** の呼ばれる順番がおかしかったのを修正(map.c) +  7. イベント名が重複したときにメッセージを出すように変更(npc.c) +  8. map_quit() 内部でcharid_db をfreeし忘れているバグを修正(map.c) + + 特に8.は最重要で、キャラがログアウトする度にメモリリークが発生するという、 + 最悪な結果になっていました。気になる方は修正しておきましょう。 + +・delete_session でNULLチェックを怠っていたバグを修正(socket.c) +・chrif_disconnect_sub でdelete_session を呼ぶように変更(chrif.c) +・マルチラインコメント(/* 〜 */)の解析を忘れていたバグを修正(npc.c) +・銀行などのNPC でZenyがMAX_ZENYにならないバグを修正(pc.c) +・1107の製造確率が一部消されていたのを修正(skill.c thanks to lizorettさん) +・セージ転職試験のイベントが衝突を起こしていたのを修正(npc.c) +  npc_parse_script : dup event jobsage_2nd::OnTimer150000 +  npc_parse_script : dup event jobsage_2nd::OnTimer30000 +  npc_parse_script : dup event jobsage_success::OnTimer7000 +  npc_parse_script : dup event jobsage_success::OnTimer3000 + + (src/common) + core.c - do_init_memmgr() 追加 + malloc.c - メモリマネージャの追加 + malloc.h - メモリマネージャの追加 + socket.c - delete_sessionのバグ、do_final_socketの追加 + + (src/map) + chrif.c - chrif_disconnect_sub() を修正 + guild.c - guild_recv_info(), guild_castledataloadack() 修正 + map.c - map_quit() のメモリリーク、do_final,do_init 修正 + npc.c - npc_parse_script_line() , npc_parse_script() 他修正 + pc.c - pc_setparam() 修正 + pet.c - do_final_pet() 追加 + pet.h - do_final_pet() 追加 + script.c - do_init_script(), do_final_script() 修正 + skill.c - skill_produce_mix() 修正 + +-------------------- +//1107 by code +・@npctalk, @pettalkコマンド追加 +・ダメージの遅延を実装 +・@mesを全体発言に修正 +・ファーマシーの製造成功確率修正 +・@storageで倉庫が二重で開くことがないよう修正 +・scriptに globalmes, getmapmobs 関数を追加 + + (/src/map) + atcommand.c + atcommand.h + battle.c + clif.c + clif.h + npc.c + npc.h + script.c + skill.c + storage.c + +-------------------- +//1106 by sylpheed + +・item_rate_details:1が動かなかったのを修正 + + (src/map/) + mob.c + +-------------------- +//1105 by End_of_exam + +・1101のマップの再分配が上手くいかないバグを修正(char.c thanks to Mystleさん) + + (src/char/) + char.c - parse_frommap() 修正 + +-------------------- +//1104 by nameless +・BCC32のコンパイルオプションなどの最適化 +・BCC32/VC++で最適な最適化オプションを見つけるためのベンチ +・bcc32_clean.batとbcc32_make.batを統合、クリーンビルドの失敗をしないように。 + +※P4だからとかOpteronだから特定オプションで早いということではないようです。 +※P4でもロットによっては-5が最適だったり-3 -O2が最適だったりするものがあるようです +※思い込みでオプションをつけないようにするために作りました。 +※少しでもレスポンスを上げて運用したいという人は活用してください。 + + (/) + bcc32_make.bat + + 最適化オプションの追加と警告メッセージで深刻ではないものを + 完全に表示しないように設定、bcc32_clean.batをmakeに統合した + ので確実にクリーンビルドできるようになりました + + bench.bat + bench.c + + 最適なコンパイルオプションを見つけるためのベンチです。 + bench.batでコンパイル&実行が行われます。 + 結果はbench.txtに格納されますので数値の一番小さいものを選ん + でbcc32_make.batの23行目に追加・修正してあげてください。 + ※初期状態ではbcc32用になっていますので +-------------------- +//1103 by End_of_exam + +・char_athena.conf のdefault_map_typeが0 になっている時に、PVPガイドで + セーブした後、PVPエリア内でログアウトしたキャラがログインできなくなる + バグを修正。(npc_etc_pvp.txt) 多くの方々からの情報提供感謝します。 + (npc_etc_pvp.txt 内部の ".gat" の付け忘れと、このミスに対応していない +  pc.c のバグです。このパッチを当てないでこのバグを修正したい場合、 +  添付した修正ファイルを参考にしながら、npc_etc_pvp.txtに".gat"を +  付加してください。) + +・do_final内部で不正な処理を行う場合があるのを修正(map.c thanks to lizorettさん) +・マップキャッシュの読み込みに失敗したときにメモリリークしていたバグを修正(map.c) + + (src/map) + pc.c - pc_setsavepoint() 修正 + map.c - do_final(), map_cache_read() 修正 + + (src/char) + char.c - search_mapserver() , parse_char() 修正 + + (script/npc/etc) + npc_etc_pvp.txt - ".gat" を付加する + +-------------------- +//1102 by 人柱さんA +・バグ報告スレ >>35-37にあった修正版 + 詳しいことはスレを見てください + (src/map) + pc.c + +-------------------- +//1101 by End_of_exam + +・socket関連の修正(socket.c socket.h) + + 1. FIFO関連をfd が不正(fd<=0)の時にも正常に動作するように変更 + 2. socket.h の内部を色々と整理 + 3. make_connection() が接続に失敗した時にエラーを返さないバグを修正 +   その変更に合わせて、chrif.c check_connect_char_server() , char.c +   check_connect_login_server() を修正。これでサーバーゾンビ化のバグは +   解決したと思いますが、再発したら報告をお願いします。 + +・char - map 間のコネクションを見直し(char.c chrif.c map.c map.h) + + 1. char - map 間のコネクションが切れたら、map 鯖に接続しているキャラを +  全て切断するようにする。これは、同期を取るのが難しいのと、char鯖との +  通信が必要な処理(パーティ、ギルド、ペット他)ができなくなるためです。 + 2. 複数のmap 鯖で同じマップを担当することがあるバグを修正 + 3. map 鯖の割り当て方法の見直し +  複数のmap 鯖で同じマップを読み込めば、どれか1つが落ちている時でも、 +  正常なmap 鯖にログインできるようになりました。例えば、同じマップを +  map鯖AとBに読み込ませておけば、Aが落ちている時にはBに、Bが落ちている +  時にはAに転送されます。ただし、優先順位の指定はまだ出来てないので、 +  1つのmap 鯖に人数が集中しすぎる可能性があります。 + + (src/map) + chrif.c - map 鯖の割り当て方法の見直し + map.c - map 鯖の割り当て方法の見直し + map.h - map 鯖の割り当て方法の見直し + + (src/char) + char.c - map 鯖の割り当て方法の見直し + + (src/common) + socket.c - 色々修正(上記参照) + socket.h - 色々修正(上記参照) + +-------------------- +//1100 by nyankochan +・1098の修正 + (src/map) + pc.c + +-------------------- +//1099 by End_of_exam + +・mapflag nosave が不正な時に起動を中断させるようにする(npc.c) +・pc_autosave が呼ばれる回数が異常に高くなるバグを修正(pc.c) + +pc_autosave() の内部が、 + +> interval = autosave_interval/(clif_countusers()+1); +> if(interval <= 0) +> interval = 1; + +という風になっているので、1マップサーバーに200人のキャラが接続してると、 +autosave_interval(def:15 * 1000) / 200 = 0.075 秒ごとに関数が呼ばれます。 +さすがにこの状態だとchar鯖が厳しくなるので、関数を呼び出す最小間隔を +0.2 秒に変更しました。 + + (src/map) + pc.c - pc_autosave が呼ばれる回数が異常に高くなるバグを修正 + npc.c - mapflag nosave が不正な時に起動を中断させる + +-------------------- +//1098 by nyankochan +・入手装備品の個数1固定 + (src/map) + pc.c + +-------------------- +//1097 by End_of_exam + +主にバグ修正です。バグ報告してくれた皆様に感謝、感謝。 + +・Zeny増殖対策(pc.c trade.c script.c) + 1. 交換、pc_setparam でMAX_ZENY を超える場合があるバグを修正 + 2. スクリプトにオーバーフロー対策を追加 + +・ログイン成功時・アカウント変数更新時に無条件にmmo_auth_sync を + 呼んでいたのをタイマーを使用した定期更新に変更(login.c login_athena.conf) + +・db関係にバグが潜んでいる模様なので、チェック機構を追加する(db.c db.h) + 一部アカウントのみログイン不可、倉庫ロスト、@whoで表示されるキャラが + 一部消えるなどのバグの原因がdb関連にある模様です。 + 「db_foreach : data lost %d of %d item(s)」というメッセージが表示 + された場合はバグがある(dbに入っているはずのデータが消えた)ので、 + 報告をお願いします。 + +・ある方法で通常より強いキャラが作れてしまうバグの修正(char.c) +・ギルドの役職名に不正な文字が使えるバグを修正(int_guild.c) +・スクリプト内で0での除算時が起こった時にINT_MAXを返すようにする(script.c) + + (conf/) + login_athena.conf - autosave_time の追加 + + (src/common) + db.h - チェック機構の追加 + db.c - チェック機構の追加 + + (src/login) + login.c - mmo_auth_sync にタイマーを適用 + + (src/char) + char.c - 通常より強いキャラが作れてしまうバグの修正 + int_guild.c - ギルドの役職名に不正な文字が使えるバグを修正 + + (src/map) + trade.c - MAX_ZENY を超える場合があるバグを修正 + pc.c - MAX_ZENY を超える場合があるバグを修正 + script.c - オーバーフロー対策、0での除算時の処理を追加 + +-------------------- +//1096 by lizorett +・壁越しにスキルが撃ててしまうバグを修正(バグ報告スレッド part8 >>28) + + (src/map) + path.c - 壁越しにスキルが撃ててしまうバグを修正 + +-------------------- +//1095 by lizorett +・スクリプトのエスケープ判断を変更 +・スキルユニットグループのgroup_idの範囲を変更 +・skill_unitsetting()で全てのスキルでskill_get_time()を使用するよう変更 +・サイトラッシャーをユニットスキルから範囲攻撃魔法に変更(本鯖仕様) + + (src/map) + skill.c - skill_unitgrouptickset_* で skill_id/group_idが重ならないよう + にgroup_idの範囲を制限 + - SkillStatusChangeTableにSC_SAFETYWALL,SC_PNEUMA追加 + - skill_unitsetting()で全てのスキルでskill_get_time()を使用する + よう変更 + - サイトラッシャーを範囲攻撃魔法に変更 + npc.c - エスケープ判断をparse_simpleexpr()と同様にし、全角判断を削除 + (db) + skill_cast_db.txt + - TS/MS/LoV/FN/SG/HD/GXにupkeep_timeを設定 + +-------------------- +//1094 by End_of_exam + +・サブルーチン呼び出し構文の追加(script.c npc.c npc_convertlabel_db()) +・逆アセンブル処理の追加(script.c , DEBUG_DISASM を有効にしてください。) +・switch の一時変数消去位置を変更(script.c) +・RERUNLINEの衝動が怪しかったので修正(script.c / h , map.h) +・ソースを読みやすくするためにbuildin_*をファイル最後に移動(script.c) +・新しく加わった構文のサンプルとして「ハノイの塔」を追加(npc_test_hanoi.txt) +・buildin_getitemname 修正(script.c , 質問スレッド Part14 >>129-130) + +・bcc でコンパイルした時に落ちるバグを修正(map.c map_id2bl 内部) +・Windowsでコンパイルした時に、gettick()のキャッシュが無効になっていたのを + 修正(timer.c , thanks to Shinomori) + + (src/common) + timer.c gettick() のバグ修正 + + (src/map) + script.c 色々変更(上記参照) + script.h struct script_state 修正 + npc.c npc_convertlabel_db() で落ちるのを修正 + map.c map_id2bl() を修正(落ちるのはbcc だけ?) + map.h map_session_data 修正 + + (doc/) + script_ref.txt function 構文の追加 + + (script/sample/) + npc_test_hanoi.txt ハノイの塔 + +-------------------- +//1093 by いど + +・サーバースナップショット + +-------------------- +//1092 by lizorett +・遠距離攻撃のパス検索アルゴリズムを本鯖と同じになるよう変更 +・ストームガスト、ロードオブヴァーミリオンを重ねた場合、片方からだけダメージを +受けるよう修正(仕様が不明なので先に見つけたユニットから攻撃するようにしています) +・アイテムが一つしかない場合、アイテムを使用してもエフェクトが表示されない問題 +を修正 +・セーフティーウォール使用時にアドレス不正となる場合がある問題を修正 +・map_getcell/map_setcellの仕様変更 +・1085のビットマップ対応の痕跡の消去 +・1088のアイスウォールの変更を巻き戻し(本鯖に合わせる) +・全角判断(npc.c)を修正(For English User Forum >>54) + + (注意) map_athena.confのマップキャッシュ指定を行うパラメータ名を変更しています + + (conf) + map_athena.conf - read_map_from_bitmapをread_map_from_cache に変更 + - map_bitmap_pathをmap_cache_fileに変更 + (src/map) + map.h - セルタイプ名称変更(CELL_CHKHIGH,CELL_CHKTYPE)、 + 削除(CELL_SET*) + - skill_unit_group_ticksetメンバ名変更(group_id -> id) + - ビットマップ関連の記述の痕跡を削除 + map.c - map_getcell() セルタイプ名称変更と若干のコード変更 + - map_setcell()を1084以前の仕様に戻し、CELL_SETNPCの + フラグを追加 + - map_cache関連の細かな修正 + npc.c - 全角判断(is_zenkaku)を正確に行うよう変更 + - map_getcell()のセルタイプ名称変更に追従 + pc.c - アイテムが一つしかない場合、使用時のエフェクトが表示 + されない問題を修正 + - map_getcell()のセルタイプ名称変更に追従 + skill.c - ストームガスト、ロードオブヴァーミリオンを重ねた場合 + 片方からだけダメージを受けるよう修正 + - セーフティーウォール使用時にアドレス不正となる場合が + ある問題を修正 + - map_getcell()のセルタイプ名称変更に追従 + skill.h - 関数定義変更 + path.c - 遠距離攻撃のパス検索処理を追加(path_search_long) + - map_getcell()のセルタイプ名称変更に追従 + battle.c - 遠距離攻撃のパス検索を使用するよう変更 + +-------------------- +//1091 by End_of_exam + +** 注意 ** + + 今回のパッチは改造内容が複雑なので、導入は慎重に行ってください。 + status.c / h への分離は、関数名の置き換えだけに留めたつもりですが、 + 思わぬバグが潜んでいる可能性があります。 + +・スパゲティ対策の一環として、ステータス計算、状態異常に関わる部分を + status.c / h として分離。battle.c から39KB程 , skill.c から41KB程 , + pc.c から38KB程移動できました。少々強引ですが、スキル使用や攻撃などの + 処理の流れをつかみやすくするためには、battle.c / skill.c の中身を + 減らす必要があると考えたためです。 + + battle_get_* => status_get_* + skill_status_change_* => status_change_* + pc_calcstatus => status_calc_pc + pc_calc_sigma => status_calc_sigma + pc_getrefinebonus => status_getrefinebonus + pc_percentrefinery => status_percentrefinery + +・battle.c , script.c の巻き戻りを戻す +・npc.c の怪しい変更を戻し、きちんとNUL を付け加えるようにする +・script.c のミスを直す(jump_non_zero => jump_zero 意味が逆になってました…) +・skill.c の武器修理 のコメントミスを修正 +・WIN32でコンパイルした時、最大接続人数が60人程に制限されていたバグを修正 + + (/) + athena.dsw , athena.dsp , bcc32_make.bat , src/login/login.dsp + src/char/char.dsp , src/map/map.dsp + コンパイル条件の変更 + + (src/map/) + 上の分離に合わせてコンパイルエラーの出ないように修正 + +-------------------- +//1090 by Sapientia +・チャットの便利さのために叫ぶ追加 (ギルドチャットと区分するためにウェチギシの前に [叫ぶこと]が付き) +・atcomand_athena.conf で onlymes を 0で設定して皆使うように活性化 + オリジナルなのでデフォルトで GMだけ使うことができるように設定しました. +・@mes [言うこと] で使用 + + (src/map) + atcommand.c atcommand_charkami 追加 + atcommand.h + clif.c clif_onlymessage 追加 + clif.h + (src/conf) + atcommand_athena.conf onlymes 追加 + help.txt @mes 説明追加 + + +-------------------- +//1089 by 聖 +・VC.NET2003でコンパイルすると大量に警告が出るのを修正 +・その他バッファオーバーフロー等の細かいバグ修正 + + (src/char) + int_guild.c 警告箇所を修正 + + (src/map) + atcommand.c, battle.c, clif.c, itemdb.c, pc.c, pc.h, script.c, skill.c + 警告箇所を修正 + npc.c 警告箇所とバッファオーバーフロー修正 + +-------------------- +//1088 by Sapientia +・ウィザドスキル Icewall このキャラクターやモンスター足もとに設置されることを防止 +・ロードナイトスキル Berserk 使用の時 HPが 1/3になれば回復するバグ修正 + + (src/map) + pc.c Berserk 修正 + skill.c Icewall 修正 + +-------------------- +//1087 by End_of_exam + +・マップキャッシュに圧縮機能を追加(1MB程に縮まるようです) +・npc.c の巻き戻りを修正(質問スレッド Part14 , 111) +・map_athena.conf のコメントアウトを修正(Athena雑談スレッドPart7 , 146) +・Windows 用の起動スクリプトを追加してみる(eAthena のを元に改造) + + (/) + win32_start.bat Windows 用の起動ファイル + + (src/map) + map.c 圧縮機能の追加 + npc.c 巻き戻りを修正 + + (src/common) + grfio.c decode_zip , encode_zip のエクスポート + grfio.h decode_zip , encode_zip のエクスポート + + (conf/) + map_athena.conf 修正 + +-------------------- +//1086 by End_of_exam + +主に1085のバグ修正だったりもします。 +「てめー、1から書き直しやがって」という突っ込みだけは勘弁してくださいませ。 + +・データ構造の大変更(map.c) + マップを削除&追加しても正しく動くように変更 + マップキャッシュ作成中に強制終了すると再起動時に不安定になるバグを修正 + 圧縮フラグの追加(需要あるのか不明。compressを真にすると、現在のソースで + 読めなくなります。) + +・なんか衝動があやしすぎるので、ビットマップ処理を撤廃する(map.c map.h) + npc_touch_areanpc : some bug がたくさん出てくる -> 原因不明? + 恐らく通行可能判定が正しく設定されていないっぽいんですが謎です。 + #read_map_from_bitmap の設定を省くとログイン時に落ちるバグを修正 + +・キャッシュ内に全てのマップがあれば、grf 無しでも動作するように変更。(grfio.c map.c) + + (src/map) + map.c バグ修正他 + map.h バグ修正他 + + (src/common) + grfio.c ファイルが見つからない時にexit を呼ばないように修正 + +-------------------- +//1085 by zalem +・マップデータの読み込みはビットマップファイルから行なえるような機能追加 + + grfファイルから一度ビットマップファイルを作成して以後はその + 作成されたビットマップフォーマットのファイルからマップ情報を読み込む + という方法を採ることによって、map-serverが立ち上がる時マップ情報を読み取る + のに掛かる時間がほとんどなくなる、また1intに32個のセル情報が格納できるの + で、map情報に関するメモリ使用量も3割り近くまで減るので(そのかわりに + ある程度CPUの負担が大きくなる)、追加してみた。 + conf/map_athena.confのread_map_from_bitmapオプションで利用する + かどうかを指定でき、その下にあるmap_bitmap_pathでファイル名を変更する + (デフォルトでdb/map.info) + まだテスト段階なので、導入はご慎重に(一応Linuxで、いろいろと + テストしてみたが...) + +・map_getcell()に4番目引数の追加とmap_setcell()の4番目引数の変更 + + 関数の利用意図がわかりやすいように、そしてこれからの変更を容易にする + ために、map_getcell()とmap_setcell()のそれぞれ4番目の引数を追加、変更してみた、 + map_getcell()の4番目の引数はmap.hで定義されてるCELL_CHK列挙型、map_setcell() + の4番目の引数はmap.hで定義されてるCELL_SET列挙型をとるように変更.また、上の + Featureに対応するため、map_getcell()をポインタに変更した。 + + 主な変更点: + + src/map/map.h read_gat(),read_gatp()マクロの変更 + 列挙型 CELL_CHK,CELL_SETを追加,map_getcell(),map_setcel()用 + map_data構造体にメンバーint* gat_fileused[MAX_CELL_TYPE+2]追加 + src/map/map.c map_getcell()を関数型ポインタに変更,map_getcellp()をread_gatp() + のために追加,実際に下の四つの関数のどっちに指すかはmap_read_flagによる + map_getcell_gat(),map_getcell_bitmap() 追加 + map_getcellp_gat(),map_getcellp_bitmap() 追加 + map_setcell() 変更 + map_createbitmap() 追加 + map_readmapfromfile() 追加 + map_readallmap() 変更 + map_config_read() 変更 + do_final() 変更 + 以下の*.cファイル内のmap_getcell(),map_setcell(),read_gat(),read_gatp()を呼出した部分をすべて変更 + src/map/atcommand.c + src/map/mob.c + src/map/npc.c + src/map/path.c + src/map/pc.c + src/map/pet.c + src/map/skill.c + + conf/map_athena.conf read_map_from_bitmap,map_bitmap_path 追加 + +-------------------- +//1084 by lizorett +・経験値獲得のバグ修正(バグ報告スレッド part7 >>134) + (src/map) + mob.c 経験値計算修正 + +-------------------- +//1083 by End_of_exam special thanks to lizorettさん +・ソケットのデストラクタ処理の追加 + (common/socket.c common/socket.h login/login.c char/char.c map/clif.c map/chrif.c) + ソケットを閉じる時の処理の流れが変更になります。今までソケットを閉じる場合は、 + まずsession[fd]->eof を真にした後、パーズルーチン内で後処理(メモリ解放など) + していました。ですが、close(fd); が2重に実行されてサーバーが落ちるなどの + バグが発生していたり、処理の流れがつかみにくいといった理由から、socket.c 内部で + 全て処理するように変更しました。ソケットを閉じる時の主な流れは次の通りです。 + + 1. ソース内からsession[fd]->eof = 1; をする + 2. socket.c 内からsession[fd]->destruct() が呼ばれる + 3. メモリの解放&後処理(socket.c delete_session内部) + + close(fd) は、session[fd]->eof = 1; に置き換えました(#define)。 + また、delete_session() を明示的に呼ぶ必要はありません。 + +・マップ鯖分配時のアイテムdupe問題修正(map/map.c map/pc.c map/chrif.c) + ソケット切断時に倉庫データのキャッシュを消すように変更 + 2重ログイン時にマップサーバーが違った場合にも切断できるように修正 + +・古いバージョンでログインした時にmap鯖が落ちるバグを修正(map/clif.c) + clif_parse() 内部 + + if(packet_db[cmd].len==0) { + -> if(cmd>116,>>125,>>126 のファイルを念のためマージ + + (db/) + skill_db.txt, skill_cast_db.txt, skill_require_db.txt + - サクリファイスの記述を修正/追加 + (src/map/) + battle.c - エンチャントデッドリーポイズンの変更 + - サクリファイスの実装 + - ストームガストのノックバック方向を変更 + - 白刃取りをボスに無効に変更 + skill.h - SC_SACRIFICEを追加 + skill.c - サクリファイスの実装 + - skill_castend_damage_id()のMG_FROSTDIVER/MG_STONECURSEに + NULLチェックを追加 + mob.c - 経験値の配分を修正 + script.c - 個別に出されていたファイルをマージ(>>125) + npc.c - 個別に出されていたファイルをマージ(>>126) + (src/common) + core.c - 個別に出されていたファイルをマージ(>>116) + +-------------------- +//1081 by End_of_exam +・「ループ構文の方も実装してください」という要望を貰ったので、 + for , while , do - while 構文を導入。個人的に余り需要は無いと思うのですが…。 + +・elseが完全に解析できてなかったバグを修正。 +・switch のbreak; が場所によってはコンパイルエラーになるバグを修正。 + + (src/map/) + script.c : 構文を拡張。色々整理。 + + (doc/) + script_ref.txt : 上の修正に合わせて変更。 + +-------------------- +//1080 by End_of_exam + +・スクリプトを if - else if - else 構文 , switch 構文に対応させました。 + 多重ネストが可能ですので、今までより見やすいスクリプトが書けると思います。 + if(aa) { aaa(); } else if(bb) { cc; if(dd) { ee() } else { ff(); } } + それに伴い、__ から始まる変数やラベルを用いると、不都合が生じる可能性があります。 + +・スクリプトに新しい関数(select関数・menu命令の関数版)を追加しました。 + + (src/map/) + script.c : 構文を拡張 + npc.c : npc_perse_script の修正( { , } のネストに対応 ) + + (script/) + npc/town/npc_town_alberta.txt : 一カ所 goto が抜けてたので修正 + sample/npc_debug_pota.txt : switch , select を使って書き直し + (デバッグに使わせて貰いました) + + (doc/) + script_ref.txt : 上の修正に合わせて変更 +-------------------- +//1079 by Yuuki +・石化中にストーンカースを使うと石化解除 +・FDでスキル追加効果を使うと氷化中ダメージ判定で先に割れてもう一度氷化判定がくるのでスキル追加効果つかわず +・BBで睡眠石化氷化が割れないバグの修正(独自のダメージ判定使ってたので消して正規のダメージ判定に戻した) +・ディレイ0のスキルにadelay/2追加(G鯖でTS使って検証した結果最もこれが近かった通常攻撃よりはやかったので) + + (src/map) + skill.c + +-------------------- +//1078 by End_of_exam + +・Visual C++ 6.0 / bcc32 でコンパイル出来るように修正(別途zlib.dll が必要) +・1074は欠番にします。色々とご迷惑をかけた事をお詫びします。 + +** 注意 ** + 今回のバージョンの完全な動作確認はしていません(人柱版扱いにしてください)。 + 本格的な運用に踏み切る前には、必ず動作確認をするようにしてください。 + 場合によっては、コンパイル出来ない、不正な動作になる…等々の問題が起こるかも + しれませんが、そのときは、騒がず、慌てずに、ネ申の降臨を待つようお願いします。 + +** お願い ** + このパッチを完全版にしてくれる方、使用感レポートを投稿してくれる方を募集します。 + パッチを公開するついでに、大量のwarning を修正してくれたら嬉しいな〜、と思ってみたり。 + + (/) + bcc32_make.bat , bcc32_clean.bat + bcc32 でコンパイル / クリーン を簡単にするためのバッチファイル。 + + athena.dsp , athena.dsw , src/login/login.dsp , src/char/char.dsp , + src/map/map.dsp + Visual C++ 用のプロジェクトファイル & ワークスペース + + (src/) + コンパイル出来るように色々修正。 + + (src/common/timer.c) + 独自の手抜きアルゴリズム(2分ソート)を採用したバージョン。 + +-------------------- +//1077 by sylpheed +・サーバースナップショット +・下記二つを取り込み +質問スレッド Part14-41 Plalaさん +バグ報告スレッド part7-68 ...さん + +1074は取り込んでいません。 + +-------------------- +//1076 by mare +・韓国公知の通りアリスとジルタスのエサの変更。 +・GMのアブラカタブラ専用スキルのフラグが消えてたので復活。 +・ブラックスミスギルド員にプリーストの場合のセリフを追加。 +・クラスチェンジで全ての指定IDボスが出るように(なってるといいなぁ) + (db) + pet_db.txt + (conf) + battle_athena.conf + (script/npc/job) + npc_job_10blacksmith.txt + (src/map) + mob.c +-------------------- +//1075 by kag +・弓手用の指貫の効果実装の布石 +・効果がはっきりとしないのでitem_dbの修正はいれていません。 +・1075番でいいのかなぁと思ったり。 + + (db) + const.txt + bWeponAtk=1073とbWeponAtkRate=1074を追加 + + (src/map) + battle.c + int battle_get_baseatk()修正 + static struct Damage battle_calc_pc_weapon_attack()修正 + map.h + int weapon_atk[16],weapon_atk_rate[16]; + SP_WEPON_ATK,SP_WEPON_ATK_RATE, // 1073-1074を追加 + pc.c + memset(sd->weapon_atk,0,sizeof(sd->weapon_atk)); + memset(sd->weapon_atk_rate,0,sizeof(sd->weapon_atk_rate));を追加 + + pc_bonus2() 修正 + (doc) + item_bonus.txt + bWeponAtk,bWeponAtkRate,bHPDrainValue,bSPDrainValue 追加。 + +-------------------- +//1073 by LP@@ +・アコスキルの一部及びサイトスキルの修正(日本には今月末に来る筈?@2004/12/06) +速度減少は移動速度減少量が、シグナムクルシスは成功率、DEF減少量の増加量が +はっきりしなかったので弄っていません。 + (src/map) + battle.c + デーモンベイン、ディバインプロテクション計算式を修正。 + skill.c + ルアフ、サイトの有効範囲を修正(両方10x10→ルアフ5x5,サイト7x7)。 + + (db) + skill_cast.db + アクアベネディクタの詠唱及びディレイを修正。 + +//1072 by kag +・転生スキルを中心に修正 + (src/map) + battle.c + 魔法力増幅をスキルレベル*5%に修正。 + 矢撃ちに矢のATKが乗らなくなるように修正。 + オーラブレードの追加ダメージを100に修正。 + バーサークの与ダメを2倍になるように修正。 + ヘッドクラッシュの計算式を修正。 + スパイラルピアースの計算式だけ修正。 + プレッシャーの計算式を修正。 + 連柱崩撃の計算式を修正。 + ソードリジェクトの反射率をスキルレベル*15%に修正。 + アローバルカンの計算式を修正。矢の属性が乗るように修正。 + ファルコンアサルトの計算式を修正。頑強フラグで1ダメになるように修正。 + ブリッツビートを頑強フラグで1ダメになるように修正。 + デモンストレーションを必中、カードを乗らないように修正。 + アシッドテラーを防御無視、必中、無属性、カードを乗らないように修正。 + skill.c + 魔法力増幅に0.7秒の固定詠唱追加。 + LP@@ さんのアスムキリエ重複不可を追加。 + + (db) + skill_db.txt + 狂気孔を詠唱妨害できるように修正。 + skill_cast_db.txt + プレッシャーの詠唱、ディレイを追加。 + 猛虎硬派山のディレイを追加。 + ライフ置き換えのディレイを追加。 + ファルコンアサルトの詠唱、ディレイを追加。 + ウインドウォークのディレイ、持続時間を変更。 + アローバルカンの詠唱、ディレイを追加。 + クリエイトデッドリーポイズンのディレイを追加。 + skill_require_db.txt + オーラブレードの消費SPを修正。 + コンセントレーションの消費SPを修正。 + 魔法力増幅の消費SPを修正。 + ナパームバルカンの消費SPを修正。 + プレッシャーの消費SPを修正。 + サクリファイスの消費SPを修正。 + 猛虎硬派山の消費SPを修正。 + リジェクトソードの消費SPを修正。 + +//1071 by ICO +・npc_job_09wizard.txt,npc_job_16sage.txtを修正 +・取り巻きが召喚系スキルを使用する際の挙動を修正 + + (src/map) + mob.c + 取り巻きの召喚系スキルを規制するタイミングを変更 + skill.c + 召喚系スキルの発動条件を修正 + +//1070 by sylpheed +・ドロップ率のレートごとの調整を追加 + ドロップ設定1〜9 10〜99 100〜999 1000〜10000で個別に倍率と最低/最高値の設定が可能です +・@weather 0 が動かないのを修正 +・転生二次職のHP/SP25%上昇実装 +ドロップ倍率はeAthenaのアイテム種類毎の設定を移植しても良かったのですが +種類毎だとレートの開きが大きい場合があり、あまり意味がないため +このような形でレート詳細設定を追加してみました。 +mob_dbを弄るより楽にドロップ率の変更ができると思います。 + +weather 0が動かないのは理由が良くわからなかったので +動くように修正するついでに、雨フラグ消去時に +虹が出るように追加してみました。 + +転生のHP/SPに関しては、転生していても二次職になってない場合 +増加はしないようなので、そのように実装してみました。 +wedding_modifydisplay: yes の時にドレス/タキシードを装備解除すると +増加分が消えてしまいます・・・ +わかる方いたら修正お願いしますorz + + (src/map) + atcommand.c + @weather関連の修正(case 0を実行するように修正) + 雨フラグを消した場合虹が出るようにしてみました(JP蔵で使えるか不明) + (マップ移動しないと天候が消えないのはragexeの仕様かな?) + battle.c + battle.h + mob.c + item_rate_details関連を追加 + pc.c + 転生二次職時のHP/SP最大値25%増加を追加 + 転生していても二次職でない場合はHP/SP増加は無しのようです + (conf) + help.txt 修正 + msg_athena.conf 112追加 + + (doc) + conf_ref.txt 修正 + help.txt 修正 + +//1069 by lizorett (2004/11/26) special thanks to 名無し様@g@me +・メルトダウンの実装 +・魔法力増幅が詠唱のある魔法で有効にならなかった問題を修正 +・map-serverがダウンする問題の修正(質問スレッド Part13 >>55) +・map-serverに不正IDでログインするとchar-serverがダウンする問題の修正 +・サフラギウムが無詠唱スキルで取り消されない問題を修正 +・重複して猛毒状態とならないよう修正 +・マグナムブレイクのダメージを修正 +・バーサク中にHP/SP吸収、毒などのダメージを受けるよう修正 +・月光剣のSP吸収量が増加していく問題を修正(暫定) +・@helpにキーワード検索機能を追加 + + (src/map) + battle.c - マジックパワーによるMATK増加の実装 + - 武器鎧破壊をpc_break_equip()に書き換え + - HP/SP吸収を修正 + map.h - 装備破壊の定義を追加 + pc.c - pc_break_armor()/pc_break_weapon()を、新規の装備破壊の + 関数pc_break_equip()に統合 + - 魔法力増幅のコードを削除(battle.cで行う) + - HP/SP吸収関係の変数の初期化を追加 + pc.h - 関数定義を修正 + skill.c - メルトダウンによる装備破壊を実装 + - 魔法力増幅に関する修正 + - 重複して猛毒状態とならないよう修正 + clif.c - map-serverがダウンする問題の修正 + atcommand.c - @helpにキーワード検索を追加("@help jobchange"など) + (src/char) + char.c - char-serverがダウンする問題の修正 + (db) + const.txt - bUnbreakableHelm, bUnbreakableShield追加 + skill_cast_db.txt + - メルトダウンの状態異常時間を設定 + +//1068 by huge +・atcommandをいくつか追加と、eAthenaからいくつか移植。(help.txt参照) +・非GMキャラが@で始まる発言をした時、そのまま表示するようにした。(GMレベル0のコマンドは実行) +・天気コマンドに合わせて、mapflag設定できるように。 +・scriptをいくつか追加と、eAthenaから一つ移植。 +・初期HP倍率とSP倍率をbattle_athenaで設定できるようにした。 +・全キャラが、GMには位置・HPを通知させるようbattle_athenaで設定できるようにした。 +・ドクロドロップについて、battle_athenaで設定できるようにした。 +・GMのアイテムドロップや交換についてGMレベルを制限できるようにした。 +・ディテクティングスキル修正。 +※デフォルトの日本クライアントだと、雨で落ちます。 + + (conf/) + atcommand_athena.conf 修正 + battle_athena.conf 修正 + help.txt 修正 + msg_athena.conf 修正 + + (doc/) + help.txt 修正 + script_ref.txt 修正 + conf_ref.txt 修正 + + (src/map/) + atcommand.c + atcommnad.h + guild.h party.hを読む様に修正 + is_atcommand() 修正 + atcommand() 修正 + ※移植・新規コマンドについては help.txt を確認して下さい。 + battle.c + battle.h + hp_rate,sp_rate,hp_meter,bone_drop 追加 + clif.c + clif.h + clif_spawnpc() 修正 + clif_hpmeter() 追加 + guild.c + guild.h + guild_searchname() 追加 + guild_searchname_sub() 追加 + map.h + 天候に関するflag追加 + npc.c + npc_parse_mapflag() 修正 + party.c + party.h + party_searchname() 追加 + party_searchname_sub() 追加 + pc.c + pc.h + pc_calcstatus() 修正 + pc_damage() 修正 + pc_walk() 修正 + pc_can_drop() 追加 + script.c + gmcommand 移植追加 + dispbottom 追加 + getusersname 追加 + recovery 追加 + petinfo 追加 + checkequipedcard 追加 + getexp 削除(setを使うようにして下さい) + skill.c + skill.h + skill_castend_pos2() 修正 + + +Athena雑談スレッドPart7 >>54 もっさりさんの分 + 記述漏れがあったらすいません。 +-------------------- +//1067 by kai +・メディテイティオによるヒール回復量増加の効果を修正 +・アドバンスドカタール研究の修正 +・PvP時におけるアスムプティオの効果を修正 + + (src/map) + skill.c + 2120行 heal += heal*(skill*2)/100; //メディテイティオの修正 + + battle.c + 1723行 damage += dmg*(10+(skill * 2))/100; //アドバンスドカタール研究の修正 + + 2598〜2599、3580〜3582行 アスムプティオの修正 + if(map[target->m].flag.pvp)としダメージ計算を2/3に修正 + +-------------------- +//1066 by lizorett (2004/11/17) special thanks to 名無し様@g@me +・デッドリーポイズン作成実装 +・エンチャントデッドリーポイズン実装 +・ソウルブレイカー実装 +・battle_weapon_attackで未初期化の値が戻されるバグ修正 +・他使用SPの変更等の細かい修正 + + (db) + const.txt - 猛毒(SC_DPoison)を追加 + item_db.txt - 緑ハーブ,緑ポーション,万能薬に猛毒を治す効果を追加 + produce_db.txt - デッドリーポイズンの材料の定義を追加 + skill_cast_db.txtエンチャントデッドリーポイズン、ソウルブレイカー + の定義を修正/追加 + skill_db.txt - ソウルブレイカー/エンチャントデッドリーポイズン/ + デッドリーポイズン作成の定義を修正 + - ナパームバルカンのヒット数修正 + skill_require_db.txt + - エンチャントデッドリーポイズンが毒薬の瓶を使用する + ように修正 + - ソウルブレーカー/メテオアサルトの使用SPを修正 + (src/map) + battle.h - battle_config.cdp_rateを追加 + battle.c - ソウルブレーカー実装 + - メテオアサルトにカード効果がかからないよう変更 + - 4213行の条件で未初期化の値が戻されるバグ修正 + - battle_config.cdp_rateを追加 + skill.h - デッドリーポイズン作成の材料が7つなので、テーブル + を追加。材料の最大数をdefineで変更できるよう修正 + - SC_DPOISON(182)/SC_EDP(183)を追加 + skill.c - 猛毒効果を追加 + - デッドリーポイズン作成を実装 +-------------------- +//1065 by End_of_exam + +・サーバーゾンビ化に暫定対処 +・calc_index(path.c)の不都合を修正 + + (common/) + timer.c + TIMER_MIN_INTERVEL(タイマーの最小インターバル)を追加しました。 + それに伴い、do_timer() の戻り値の最低を 10ms から 50ms に変更しました。 + + selectが10ms以内に終わらない環境だと、モンスターを大量召還した時などに、 + クライアントからのパケットに反応しなくなる模様です。 + ローカルテスト(モンスター大量召還)をしてみたところ、25msに変更した時点で + 改善しましたが、環境によっては50msでも不十分かもしれません。 + その場合は、TIMER_MIN_INTERVELを増やして様子を見てください。 + + 同様の現象として、多数のクライアントが接続するとサーバーが反応しなくなる + というのがありますが、このパッチによってある程度改善されるかもしれません。 + + (map/) + map.h : MAX_WALKPATH + path.c 内の calc_indexが不都合を起こす(48*48-1 = 1000 1111 1111(b)) ため、 + MAX_WALKPATHを 48 から 32 に変更しました。(32*32-1 = 0011 1111 1111(b)) + + #define calc_index(x,y) (((x)+(y)*MAX_WALKPATH) & (MAX_WALKPATH*MAX_WALKPATH-1)) +-------------------- +//1064 by nameless +・GCC 3.3.0/3.3.1が内包する0/0=変数最大値の問題対策(int:65535/long:4294967294) +・魔法防御・防御・属性防御が正しく適用されない問題を修正 +・ナパームバルカンを単体魔法のコードに修正し、呪い効果を実装 + + (src/map) + skill.c + 442〜448行 不等号[<]を[>]に修正 + 512〜519行 不等号[>]を[<]に修正 + 529〜538行 コンパイラバグの訂正方法と例/*〜*/の部分を + gccのバージョンに合わせて生かしたり殺したり + してください。3.3.2からは直っているようです + 1857行 ナパームバルカンを追加 + 660〜664行 ナパームバルカンの呪い効果を追加 + (src/char) + char.c + 修正しきれていなかった部分を修正しました。 + +-------------------- +//1063 by 七誌 +・月光剣の効果実装 +・左手カードによる、武器攻撃時のHP/SP吸収効果が右手に影響する様に修正(本鯖仕様) + (left_cardfix_to_rightがyesの時のみ。noだと従来通り) + + (db) + const.txt + bHPDrainValue=1071とbSPDrainValue=1072を追加 + item_db.txt + 月光剣のEquipScriptにbonus2 bSPDrainValue,100,3を追加 + + (src/map) + battle.c + battle_weapon_attack() 修正 + map.h + short hp_drain_value,sp_drain_value,hp_drain_value_,sp_drain_value_;を追加 + SP_HP_DRAIN_VALUE,SP_SP_DRAIN_VALUE, // 1071-1072を追加 + pc.c + pc_bonus2() 修正 + +-------------------- +//1062 by nameless +・パケット送受信での誤送信修正 +・バグ報告スレッド part7 からの取り込み・修正 >> 56,57,58 +・fix1059の取り込み +・ハイウィズのネイパームバルカンの実装(eA取り込み) +・CPU最適化コードの修正(athlon系)・追加(玄人箱/Linux Zaurus) + + (/) + Makefile + athlon系最適化の修正 + 玄人箱(Kuro-Box 200MHz版[PPC 603x]) + 玄人箱(Kuro-Box 266MHz版[PPC 604x]) + Linux Zaurus (SL-C7xx) + の最適化コードを記述 + + (db) + skill_cast_db.txt + 400,500,1200:1600:2000:2400:2500,0,0 //HW_NAPALMVULCAN#ナパームバルカン# + (src/map) + clif.c + clif_parse() 修正 + (src/char) + char.c + 1367行 cmd = RFIFOW(fd,0);追加 + (src/map) + skill.c + switch(skillid)にcase HW_NAPALMVULCAN:以下20行ほど追加 +-------------------- +//1061 by lizorett (2004/11/9) +・不正なギルドスキルパケットを受けた場合にmap/charサーバが落ちる現象を修正 +・不正なパケットを受けた場合にcharサーバが落ちる現象を修正 +・結婚したキャラを削除するとcharサーバが落ちる現象を修正 +・青箱を一つだけ持った状態で青箱から青箱がでると、青箱が消えるたように見える + (リログすると見える)問題を修正 +・スナッチャーのスキル失敗を表示しないようにできる設定を追加 +・デボーションのレベル制限(10レベル差)を変更できる設定を追加 + + (src/common) + mmo.h + ギルドスキルのenumを追加(src/map/skill.hから移動) + (src/map) + skill.h + ギルドスキルのenumを削除(src/common/mmo.hに移動) + guild.c + guild_checkskill スキルの範囲チェックを追加 + guild_skillup スキルの範囲チェックを追加 + skill.c + skill_additional_effect display_snatcher_skill_failの処理を追加 + skill_castend_nodamage_id devotion_level_differenceの処理を追加 + battle.c + display_snatcher_skill_fail,devotion_level_differenceの初期化を追加 + (src/char) + int_guild.c + guild_checkskill スキルの範囲チェックを追加 + mapif_parse_GuildSkillUp スキルの範囲チェックを追加 + char.c + parse_char 不正なパケットを受けた場合にはダンプするよう修正 + char_divorce i1052 変更 + (/src/map) + atcommand.c + ATCOMMAND_FUNC(whop); 追加 + { AtCommand_WhoP,"@who+",0, atcommand_whop }, 追加 + atcommand.h + AtCommand_WhoP, 追加 +-------------------- +//1051 by Plala +・ペコペコ騎乗時MAX Weightを増やせるようにしました。 +battle_athena.confで設定可能です。 + + (conf/) + battle_athena.conf + riding_weight 追加 + (map/) + battle.c + battle_config.riding_weight 追加 + battle.h + int riding_weight; 追加 + clif.c + clif_parse_RemoveOption 変更 + pc.c + int pc_calcstatus 変更 + 1415にsd->max_weight +=battle_config.riding_weight; を追加 + (common/) + version.h + Ver 1050->1051 変更 +-------------------- +//1050 by code +・各種天候操作コマンドの見直し +※いちいち@misceffectで呼び出さずに簡単に天候操作を行えるように +※クライアント依存は落ち葉ではなく雨でした、間違いました(^-^; + + (src/common/) + version.h + Ver 1049->1050 変更 + (/src/map) + atcommand.c + AtCommand_Rain{} 変更 + AtCommand_Snow{} 変更 + AtCommand_Cherry{} 変更 + AtCommand_Fog{} 変更 + AtCommand_Maple{} 変更 + +-------------------- +//1049 by code +・霧、落葉の2つの天候操作コマンドを追加しました。 +※落ち葉に関してはクライアント依存なのでjROだと落ちるかも… + + GMコマンド追加 + @fog 霧 + @maple 落葉 + + (conf/) + atcommand_athena.conf + fog: 1 追加 + maple: 1 追加 + + msg_athena.conf + 87: 霧が立ち込めました。 追加 + 88: 落ち葉が降ってきました。 追加 + (/src/common/) + version.h + Ver 1048->1049 変更 + (/src/map) + atcommand.c + ATCOMMAND_FUNC(fog); 追加 + ATCOMMAND_FUNC(maple); 追加 + { AtCommand_fog,"@fog",0, atcommand_fog }, 追加 + { AtCommand_maple,"@maple",0, atcommand_maple }, 追加 + + atcommand.h + AtCommand_Fog, 追加 + AtCommand_Maple, 追加 + +-------------------- +//1048 by code +・雨、雪、サクラ吹雪の3つの天候操作コマンドを追加しました。 +※衝動的に追加してしまったのでバグがあるかも知れません(汗 + + GMコマンド追加 + @rain 雨 + @snow 雪 + @cherry サクラ吹雪 + + (conf/) + atcommand_athena.conf + rain: 1 追加 + snow: 1 追加 + cherry: 1 追加 + + msg_athena.conf + 84: 雨が降り出しました。 追加 + 85: 雪が降り出しました。 追加 + 86: サクラ吹雪を降らせます。 追加 + (/src/common/) + version.h + Ver 1047->1048 変更 + (/src/map) + atcommand.c + ATCOMMAND_FUNC(rain); 追加 + ATCOMMAND_FUNC(snow); 追加 + ATCOMMAND_FUNC(cherry); 追加 + { AtCommand_rain,"@rain",0, atcommand_rain }, 追加 + { AtCommand_snow,"@snow",0, atcommand_snow }, 追加 + { AtCommand_cherry,"@cherry",0, atcommand_cherry }, 追加 + + atcommand.h + AtCommand_Rain, 追加 + AtCommand_Snow, 追加 + AtCommand_Cherry, 追加 + +-------------------- +//1047 by SVN +・製造アイテムの製作者の名前を引くmap←→charのパケットが間違っていたのを修正 +・二重ログインをした時にchar-serverが落ちる可能性があったのを修正 +・ガーディアンをGv時間外に殴れた、ID指定のスキルが当たった、skill_unitなスキル攻撃が当たったのを修正 +・グラフィティのRangeをとりあえず3にしてみた + (db/) + skill_db.txt + (char/) + char.c + parse_frommap() + (map/) + clif.c + clif_parse_ActionRequest() 変更 + clif_parse_UseSkillToId() 変更 + mob.c + mob_gvmobcheck() 追加 + mob.h + mob_gvmobcheck() 定義追加 + skill.c + skill_attack() 変更 + +-------------------- +//1046 by SVN +※db/packet_db.txtは2004-09-06aSakexe用なので、jROクライアントで使用する際は「//jROはここまで」以下をコメントアウトするか削除してください + +・変更点が多いので詳細はファイル、関数ごとに記述しています +・1045にそのまま上書きしても動作しますが、使われないファイルがいくつか残ります +・script/以下は名前が変更されているファイルが大量にあるのでscript/の変更点を参考にしてください +・スクリプト用の関数や命令が増えたり仕様が変更されているものがあります + 基本的には互換性があるはずですが、getgdskilllv()だけは第二引数を数字ではなくスキル名(GD_APPROVALなど)に置き換える必要があります + getgdskilllv()が使われている/script/npc/gvg_big5/*.* は中国語で必要ないので削除してください + 追加や変更に関しては概ねscript_ref.txtに反映してありますが、詳細はscript.cの変更点を読んでください +・追加された@コマンドについては@helpとatcommand.cの変更点を読んでください +・追加された設定はconf_ref.txtを参照してください +・記述漏れの変更点もあるかもしれません + +追加したファイルは「A」 +変更したファイルは「C」 +削除したファイルは「D」 +移動したファイルは「M」 + / + C athena-start + ./conf/import 以下を起動時に自動作成するように変更 + seqコマンドを使わないようにしてFreeBSDでも動作するように変更 + start + すでにAthenaが起動している時は何もしないように変更 + execで ./ がダブっていたので削除 + stop + FreeBSDでもシェルに戻るように変更 + kill + 同上 + C Makefile + PACKETDEF に PACKETVER=6 を追加 + FreeBSDを判定して make と gmake を切り替えるように変更 + CFLAGS を分解して弄りやすいように変更 + C start + 1行目のシェル指定が正しくなかったのを変更 + すでにAthenaが起動している時は何もしないように変更 + 起動確認の条件式を athena-start と同じ物に変更 + bin/tool/ + シェルスクリプトの改行コードを CRLF から LF のみに変更 + C getlogincount + ログインバージョンを $loginversion として変更できるように変更 + C ladmin + アカウント名に「-」を使えるように変更 + + conf/ + D import/ + 配布物から削除(athena-start start で自動作成される) + C atcommand_athena.conf + shuffle maintenance misceffect 追加 + C char_athena.conf + default_map_type default_map_name 追加 + C help.txt + 説明追加 + C login_athena.conf + login_version login_type 追加 + C map_athena.conf + npc map 色々変更 + C mapflag.txt + 最新版に更新 + C msg_athena.conf + 81以降追加 + C water_height.txt + 最新版に更新 + db/ + C castle_db.txt + ギルド解体時に発生する OnGuildBreak イベントのために 追加 + C const.txt + GvGの開始時間等を設定できるように追加 + マップフラグ mf_notrade mf_noskill 追加 + パラメータ PartnerId Cart 追加 + ボーナス bBreakWeaponRate bBreakArmorRate bAddStealRate bUnbreakableWeapon bUnbreakableArmor 追加 + ステータス変化 SC_WEDDING 追加 + スクリプト命令 getgdskilllv 用に GD_APPROVAL など追加 + C exp.txt + 転生二次職がBaseLv12になるときに必要な経験値を41→481に修正 + C item_db.txt + C mob_db.txt + C mob_skill_db.txt + C skill_cast_db.txt + C skill_db.txt + C skill_require_db.txt + C skill_tree.txt + 最新版に更新 + A packet_db.txt + パケット定義ファイル追加 + doc/ + C client_packet.txt + 新しく判明したパケットをいくつか追加 + C conf_ref.txt + 新しく追加した設定の説明を追加 + C db_ref.txt + skill_cast_db.txt の list_hp_rate list_sp_rate で負数を指定した時の挙動を追加 + C help.txt + conf/help.txt 同様に変更 + C inter_server_packet.txt + 新規で追加したパケットを追加と実態とあっていなかった部分を修正 + C item.txt + 最新版に更新 + C item_bonus.txt + 新規で追加されたボーナスを追加 + C script_ref.txt + 新規命令の追加と既存命令の変更など + C serverlink_packet.txt + 新規で追加したパケットを追加と既存で書かれていなかったパケットの追加 + script/ + mob/ + C npc_monster.txt + 最新版に更新 + ニブルヘイムのMobはnpc_parse_mob()の変更サンプルになってます + npc/ + ほぼすべてのNPCをnpc_function.txtを使ったユーザー定義関数と複製などで書き換え + 移動したファイルに関しては移動後のファイルが含まれているので移動前のファイルのみ削除してください + 例) etc/npc_etc_cTower.txt は含まれているので npc_cTower.txt を削除 + M npc_cTower.txt + →etc/npc_etc_cTower.txt + A npc_function.txt + M npc_pota.txt + →../sample/npc_debug_pota.txt + M npc_pvp.txt + M npc_pvproom.txt + 2ファイル合体 + →etc/npc_etc_pvp.txt + M npc_resetJ.txt + →../sample/npc_debug_reset.txt + A etc/ + A npc_etc_gefenia.txt + C gvg/ + すべてev_agit_common.txtを使ったユーザー定義関数で書き換え + すべて削除してからこのパッチを当ててください + ギルド解散時に砦を放棄するためにev_agit_砦.txtにOnGuildBreakイベントを追加 + D test/ + A ev_agit_common.txt + D ev_agit_event.txt + D TEST_prtg_cas01_AbraiJ.txt + D TEST_prtg_cas01_mob.txt + D gvg_big5/ + C job/ + 転職スクリプトの名前をnpc_job_[JOB番号][ジョブ名].txtに変更 + すべて削除してからこのパッチを当ててください + C quest/ + M npc_event_arrow.txt + →../../sample/npc_debug_arrow.txt + A npc_event_hat2.txt + ニブル同時実装の新頭装備スクリプトを追加 + src/ + calloc() realloc() を極力各型にキャストするように変更 + calloc() 後に memset() で \0 を埋めていたのを削除 + calloc() なのに(サイズ*個数,1)で指定していたのを(個数,サイズ)に変更 + メモリ確保をエラー処理をまとめた関数に書き換え + malloc() → aMalloc() + calloc() → aCalloc() + realloc() → aRealloc() + strcpy() を strncpy() に極力変更 + + char/ + C char.c + スペースでインデントされていたところをタブで統一 + A isGM() + A read_gm_account() + GMアカウントが必要になったので追加 + C mmo_char_tostr() + C mmo_char_fromstr() + nullpoチェック追加 + C count_users() + 必要ない{}を削除 + C char_delete() + nullチェック追加 + 削除メッセージをコンソールに表示するようにした + 削除時に接続しているキャラを切断するようmap-serverに通知(0x2b19パケット)するようにした + C parse_tologin() + C 0x2713 + char-serverメンテナンス設定時はGM以外入れないようにした + 接続数制限で最大値でもGMは接続できるようにした + C 0x272a + 0x2730を0x272aに変更して番号を詰めた + アカウント削除した時にキャラが一部消されない問題を修正 + A 0x272c + 受信時にlogin-serverに通知(0x2b15パケット)してメンテナンス状態になるようにした + A char_erasemap() + map-server切断時に他map-serverにマップの削除を通知(0x2b16パケット)するようにした + これにより他map-server管轄のマップに移動しようとして、そのmap-serverが切断されていたら、 + pc_setpos()で存在しないマップということで移動しようとしなくなるので、 + クライアントが「永遠にお待ちください状態」にならないようになります + C parse_frommap() + map-server切断時にchar_erasemap()を実行するようにした + map-server切断時に管轄のマップにキャラが残っていたら切断を他map-serverに通知(0x2b17パケット)するようにした + C 0x2afc + 認証失敗時に char_dat[].mapip/mapport を 0 にするようにした + 認証成功時に char_dat[].mapip/mapport をmap-serverのIPアドレスとポートにするようにした + 認証成功時に他map-serverにキャラがログインしたことを通知(0x2b09パケット)するようにした + C 0x2b02 + C 0x2b05 + コンソールへの出力にパケット番号を記述するようにした + C 0x2b08 + パケット仕様を変更して account_id mapip mapport も通知するように変更 + map-serverに接続していない時はすべて 0 が入ります + A 0x2b13 + map-server起動途中などでキャラがログインできないようにする server[].active フラグを操作する + active = 0 でキャラはログインできずに切断される + map-serverが起動を完了したときに active = 1 にするパケットが送られてくる + A 0x2b14 + char-serverをメンテナンス状態にする char_maintenance フラグを操作する + login-serverにも通知(0x272bパケット)してワールド選択画面でメンテナンス表示をする + メンテナンス状態ではGM以外のユーザーはログインできません + A 0x2b18 + キャラクターの切断を他map-serverに通知(0x2b17パケット)するようにした + C search_mapserver() + 引数に struct mmo_charstatus *cd を追加 + cdが渡された&探しているマップが接続しているmap-serverに無かったときに、最初に見つけたmap-serverの最初に見つけたマップに接続するようにした + これは char_athena.conf default_map_type: 2 の時の挙動です + C parse_char() + C 0x65 + メンテナンス状態の時にGM以外を切断するようにした + 最大接続数が設定されていて最大接続数のときもGMは接続できるようにした + C 0x66 + char-serverに接続しているmap-serverにlast_pointが見つけられなかったときに、 + default_map_type&1 の時は default_map_name に接続する + default_map_type&2 の時は 最初に見つけたmap-serverの最初に見つけたマップに接続する + それでも見つからない時は切断するようにした + コンソールへの出力にパケット番号を記述するようにした + C 0x2af8 + 他マップに接続しているキャラ情報を通知(0x2b09パケット)するようにした + C 0x187 + S 0187パケットを返信するようにした + C check_connect_login_server() + char_portをWFIFOLで送っていたのをWFIFOWに修正 + 80と82の間が空いていたのを詰めてパケット長を86→84に変更 + C char_config_read() + default_map_type default_map_name を読み込むようにした + A gm_account_db_final() + 確保した gm_account_db のメモリを終了時に開放するようにした + C do_final() + inter.c など他ファイルの終了処理(do_final_*)を追加した + exit_dbn() でdb用のメモリを開放するようにした + 接続されているmap-serverのセッションを削除するようにした + do_final_timer()でtimerを終了させるようにした + C do_init() + server[].active = 0 で初期化 + read_gm_account() でGMアカウントファイルを読み込むようにした + C char.h + mmo_map_server に active フラグを追加した + C int_guild.c + C mapif_parse_GuildSkillUp() + ギルドポイントを消費しないでギルドスキルを上げるために int flag を追加 + C inter_guild_parse_frommap() + 0x303C + パケット定義を変更してflagを追加した + A guild_db_final() + A castle_db_final() + A do_final_int_guild() + 終了時にメモリを開放するようにした + C int_guild.h + A do_final_int_guild() + 定義を追加 + C int_party.c + A party_db_final() + A do_final_int_party() + 終了時にメモリを開放するようにした + C int_party.h + A do_final_int_party() + 定義を追加 + C int_pet.c + A pet_db_final() + A do_final_int_pet() + 終了時にメモリを開放するようにした + C int_pet.h + A do_final_int_pet() + 定義を追加 + C int_storage.c + A storage_db_final() + A guild_storage_db_final() + A do_final_int_storage() + 終了時にメモリを開放するようにした + C int_storage.h + A do_final_int_storage() + 定義を追加 + C inter.c + パケット長定義を変更 + A mapif_parse_CharPosReq() + 0x3090パケットへの対応 + キャラの位置要求をmap-serverに通知(0x3890パケット)する + A mapif_parse_CharPos() + 0x3091パケットへの対応 + キャラの位置要求をしたキャラに位置情報を通知(0x3891パケット)する + A mapif_parse_CharMoveReq() + 0x3092パケットへの対応 + 要求したキャラまで対象のキャラを飛ばす要求を通知(0x3892パケット)をする + A mapif_parse_DisplayMessage() + 0x3093パケットへの対応 + キャラにメッセージを送信(0x3893パケット)する + C inter_parse_frommap() + 各追加パケットへの対応を追加した + A wis_db_final() + A accreg_db_final() + A do_final_inter() + 終了時にメモリを開放するようにした + C inter.h + A do_final_inter() + 定義を追加 + C Makefile + A nullpo.o nullpo.h を追加 + A malloc.o malloc.h を追加 + common/ + C db.c + A exit_dbn() + 終了時にメモリを開放するために追加 + C db.h + A exit_dbn() + 定義追加 + A malloc.h + A malloc.c + メモリ確保関数のまとめ + C mmo.h + C mmp_charstatus + mapip mapport 追加 + C guild_castle + castle_event 追加 + C Makefile + A malloc.o malloc.h malloc.c を追加 + C nullpo.h + 古いgccでコンパイルできるように\を削除 + C socket.c + C recv_to_fifo() + 汎用性を高めるために read() を recv() に変更 + C send_from_fifo() + 汎用性を高めるために write() を send() に変更 + C timer.c + A do_final_timer() + 終了時にメモリを開放するようにした + C timer.h + A do_final_timer() + 定義追加 + login/ + C login.c + A login_version login_type + clientinfo.xmlで指定する login_version login_type でログインを規制するときに使います + C parse_fromchar() + A 0x272b + server[].maintenance フラグを変更する + 変更した内容をchar-serverに返信(0x272cパケット)する + C parse_admin() + C 0x7932 + 0x2730→0x272a に変更 + C parse_login() + C 0x64 0x01dd + login_version login_type を判定するようにした + C 0x2710 + パケット長の定義が正しくなかったのを修正した + char.c check_connect_login_server の変更を反映 + C login_config_read() + login_version login_typeの読み込みを追加 + A gm_account_db_final() + C do_final() + 終了時にメモリを開放するように変更 + C Makefile + A malloc.o malloc.h を追加 + map/ + C atcommand.c + コンパイルオプションでmemwatchを読み込めるようにした + C atcommand_where() + 他map-serverにいるキャラの居場所も表示できるようにした + C atcommand_jumpto() + 他map-serverにいるキャラにも飛べるようにした + C atcommand_who() + ワールド内のすべてにいるキャラを表示するようにした + C atcommand_go() + ニブルヘルムの移動ポイントを変更 + C atcommand_recall() + 他map-serverにいるキャラも呼び出せるようにした + A atshuffle_sub() + A atcommand_shuffle() + PCとMOBのシャッフルを行う @shuffle を追加 + A atcommand_maintenance() + char-serverをメンテナンス状態にする @maintenance を追加 + A atcommand_misceffect() + 実行したキャラから0x1f3パケットを発信してエフェクトを表示する @misceffect を追加 + A atcommand_summon() + コールホムンクルスと叫んで指定したMobを召喚する @summon を追加 + 召喚されたMobは他のMob(Pv等では敵対PC含む)を攻撃します + 召喚されたMobに攻撃されたMobは召喚主を攻撃します(バイオプラントのフローラと同じ挙動) + 召喚されたMobは1分後に消滅します + ネタなので隠しコマンドとしてhelp.txtには記述してません + C atcommand.h + 追加した@コマンドを AtCommandType に追加 + C msg_table[] を外から使えるようにするためにexternした + C battle.c + コンパイルオプションでmemwatchを読み込めるようにした + A battle_config.castle_defense_rate + 本鯖で防御値がどのように影響するか具体的には分からなかったので、砦の防御値を反映させる率を設定できるようにした + C battle_get_opt1() + C battle_get_opt2() + C battle_get_option() + NPCのオプションも返すようにした + A battle_get_opt3() + opt3を返すように追加 + C battle_calc_damage() + 砦内のMobへのダメージは防御値で減算(ダメージ*(防御値/100)*(castle_defense_rate/100))されるようにした + ガーディアンにはスキルが効くようにした + C battle_calc_pet_weapon_attack() + C battle_calc_mob_weapon_attack() + C battle_calc_pc_weapon_attack() + ベナムスプラッシャーのダメージ計算をするようにした + C battle_weapon_attack() + 武器攻撃による即死の仕様を変更 + 武器、鎧破壊の確率計算をするように変更 + ベナムスプラッシャーが解除されるように変更 + C battle_check_target() + src じゃなくて ss からparty_id guild_idを取得するように修正 + target=BCT_NOENEMY なスキル 口笛、ハミングなどがPvP、GvGの時にも他PCに影響するようにした + Mobがspecial_aiならMobを敵とみなすようにした + C battle_config_read() + castle_defense_rate を読み込むようにした + C battle.h + A battle_get_opt3() + 定義追加 + C Battle_Config + castle_defense_rate 追加 + C chat.c + C chat_createnpcchat() + 引数に int pub を追加 + pub=3 ではチャットの看板に(0/20)のような表示がされなくなります + A do_final_chat() + 何もしてないけどとりあえず追加 + C chat.h + C chat_createnpcchat() + 定義を変更 + A do_final_chat() + 定義を追加 + C chrif.c + パケット長テーブルを拡張 + C chrif_connect() + C chrif_changemapserver() + WFIFOLでポートを送っていたのをWFIFOWに修正 + A chrif_recverasemap() + 他map-serverが切断されたことがchar-serverより通知された時に、そのmap-serverが管理していたマップの情報を削除するようにした + A chrif_mapactive() + map-server起動準備中に0、完了時に1をchar-serverに通知(0x2b13)して起動途中にユーザーがログインできないようにした + A chrif_maintenance() + char-serverをメンテナンス状態にしたり解除したりを通知(0x2b14)する + A chrif_maintenanceack() + char-serverをメンテナンス状態にした時の応答 + メンテナンス状態にした旨をマップ内に通知する + A chrif_chardisconnect() + char-serverにキャラが切断されたことを通知(0x2b18)する + A chrif_parse_chardisconnectreq() + char-serverからのキャラ切断要求を受けて、対象キャラがいる場合には切断する + C chrif_parse() + C 0x2b09 + map_addchariddb() の引数増加に対応 + A 0x2b15 + A 0x2b16 + A 0x2b17 + A 0x2b19 + 各新規パケットに対応 + C check_connect_char_server() + 接続時char-serverにmap-serverの準備が出来たことを通知するようにした + A do_final_chrif() + 終了時にchar-serverとの接続を削除するようにした + C chrif.h + A chrif_mapactive() + A chrif_maintenance() + A chrif_chardisconnect() + A do_final_chrif() + 定義を追加 + C clif.c + すべてのパケット定義を packet_db から読み込むように変更 + packet_db.txtを変更することで、度々変更される韓国クライアントのパケット定義に対応しやすくなります + packet_len_table[] は packet_db[].len に置き換わりました + をinclude + clif_parse_*を先頭で宣言するようにした + clif_parse_*内のRFIFO系で使われている第2引数は packet_db[cmd].pos[] で表記されるようになりました + パケット番号の最大値を MAX_PACKET_DB で定義するようにした + C clif_set0078() + C clif_set007b() + パケットの内容が本鯖と違っていたのでguild_emblem_id,manner,opt3を正しく送るように変更 + C clif_class_change() + Mob以外のNPCでも使えるようにした + C clif_mob0078() + C clif_mob007b() + ガーディアンにギルドエンブレムを表示するように変更 + C clif_npc0078() + ワープポータルをギルドフラッグにするオプションを有効にした時にmap-serverが落ちる問題を修正 + C clif_spawnnpc() + NPCが無効でもHide状態の時はパケットを送るように変更 + C clif_quitsave() + キャラ終了時にchar-serverに切断を通知するようにした + C clif_scriptmenu() + C clif_dispchat() + C clif_changechatstatus() + lenに1バイト追加 + C clif_updatestatus() + マナーポイントを送信するようにした + A clif_changestatus() + 周囲に赤エモ状態であることを送信 + A clif_misceffect2() + エフェクトを発生させるパケットを送信 + @misceffect, misceffect命令で使用 + C clif_changeoption() + 状態異常時以外は状態異常アイコン表示パケットを送らないようにした + PCの時は clif_changelook() を送信するようにした(結婚衣裳表示用?) + C clif_traderequest() + 取引パケットの 0xe5 → 0x1f4 に仮対応(本鯖での算出式は不明なのでとりあえず char_id を送信) + C clif_tradestart() + 取引パケットの 0xe7 → 0x1f5 に仮対応(本鯖での算出式は不明なのでとりあえず char_id を送信) + C clif_getareachar_pc() + マナーポイントが負数の時には赤エモ表示パケットを送信するようにした + C clif_getareachar_npc() + NPCのHide状態に対応 + C clif_getareachar_skillunit() + C clif_skill_nodamage() + 自爆の時はhealを負数にできるようにした + C clif_skill_setunit() + グラフィティに対応 + A clif_item_repair_list() + 武器修理スキルに対応しようとしたけどパケットが分からないので頓挫中 + C clif_produceeffect() + map_addchariddb() の引数増加に対応 + C clif_guild_skillinfo() + 未実装ギルドスキル カリスマを表示しないようにした + C clif_callpartner() + あなたに逢いたい 使用時に相手の名前を叫ぶようにした + C clif_sitting() + 引数 fd は不要なので削除 + C clif_GM_kick() + フラグを0にするようにした + A clif_wisexin() + Wis拒否許可の応答を送信 + A clif_wisall() + Wis全拒否許可の応答を送信 + A clif_soundeffect() + SEを鳴らすパケットを送信 + soundeffect命令で使用 + C clif_parse_LoadEndAck() + 結婚後のウェディングドレスやタキシードの状態をログアウトしても1時間は継続されるようにした + 赤エモ状態はログアウトしてもログインした時からまた継続するようにした + C clif_parse_QuitGame() + C clif_parse_Restart() + 終了できない条件を pc_isquitable() にまとめた + C clif_parse_GlobalMessage() + C clif_parse_Wis() + C clif_parse_PartyMessage() + C clif_parse_GuildMessage() + 赤エモ状態では発言できないようにした + C clif_parse_ActionRequest() + ギルド未加入などの場合はガーディアンやエンペリウムを殴れないようにした + clif_sitting()の引数変更に対応 + C clif_parse_UseItem() + 赤エモ状態ではアイテムを使えないようにした + C clif_parse_EquipItem() + アイテムが破壊されている時は装備できないようにした + C clif_parse_TradeRequest() + C clif_parse_TradeAck() + notradeマップでは取引要請を送れないようにした + C clif_parse_UseSkillToId() + C clif_parse_UseSkillToPos() + C clif_parse_UseSkillMap() + noskillマップではスキルを使用できないようにした + チャット中はスキルを使用できないようにした + 赤エモ中はスキルを使用できないようにした + ウェディング状態ではスキルを使用できないようにした + C clif_parse_MoveToKafra() + itemdb_isdropable()==0 は倉庫に入れられないようにした + C clif_parse_GMReqNoChat() + GM右クリックで赤エモを付与・解除できるようにした + C clif_parse_GMReqNoChatCount() + 本鯖での返答パケットがよく分からないので仮対応 + 本当はアカウント名が返るのかな? + C clif_parse_sn_explosionspirits() + クライアントからパケットが来た時にコンソールにログを表示するようにした + BaseLv99以上の時に0で除算する可能性があるのを回避 + A pstrcmp() + clif_parse_wisexin()のqsort()で使用 + A clif_parse_wisexin() + Wis拒否許可に対応 + A clif_parse_wisexlist() + Wis拒否リスト表示に対応 + A clif_parse_wisall() + Wis全拒否許可に対応 + A clif_parse_GMkillall() + GMコマンド/killall(=@kickall)に対応 + A clif_parse_GMsummon() + GMコマンド/summon(=@recall)に対応 + A clif_parse_GMshift() + GMコマンド/shift(=@jumpto)に対応 + A clif_parse_debug() + packet_db.txtのデバグ用に追加 + パケット内容をダンプします + C clif_parse() + clif_parse_func_table を削除(packet_db[cmd].funcに入るようになりました) + A packetdb_readdb() + packet_db.txtを読み込みます + フォーマットは パケット番号,パケット長[,コマンド,コマンド引数の位置(:区切りで複数指定)] + コマンド引数の位置は各コマンドに対応する関数内で設定されているのでclif.cを読まないと分からない難解なフォーマットです + 変更されたパケットはpacket_db.txtの末尾に追加します + 古いクライアントを利用する場合には不要な定義を末尾から削除すればよいようにします + A do_final_clif() + 終了時にセッションを削除するようにした + C do_init_clif() + packet_dbを読み込むようにした + 終了時にセッションを削除できるように make_listen_port() の戻り値を map_fd に入れるようにした + C clif.h + A MAX_PACKET_DB + A struct packet_db + A clif_changestatus() + A clif_misceffect2() + A clif_callpartner() + A clif_sitting() + A clif_soundeffect() + A clif_item_repair_list() + A do_final_clif() + 定義を追加 + C clif_class_change + clif_mob_class_change() から変更 + C guild.c + C guild_read_castledb() + castle_event を読み込むようにした + C guild_skillup() + 引数を変更 + flag=1 でギルドポイントを使用しないようにした + C guild_broken() + ギルド解散時に所有砦を破棄するための OnGuildBreak イベントを追加 + A guild_db_final() + A castle_db_final() + A guild_expcache_db_final() + A guild_infoevent_db_final() + A do_final_guild() + 終了時にメモリを開放するようにした + C guild.h + C guild_skillup() + 定義を変更 + A do_final_guild() + 定義を追加 + C intif.c + atcommand.h をinclude + packet_len_table[] 拡張 + C intif_guild_skillup() + 引数 flag 追加 + A intif_charposreq() + キャラの場所要求パケットを送信 + flag=1 @jumpto + flag=0 @where + A intif_jumpto() + 他map-serverのキャラに @jumpto 出来るようにした + A intif_where() + 他map-serverのキャラに @where 出来るようにした + A intif_charmovereq() + キャラを呼び寄せる + flag=1 @recall + flag=0 あなたに逢いたい + A intif_displaymessage() + 他map-serverのキャラにメッセージを送れるようにした + (Wisではなくて送りっぱなし。@recall 成功時用) + C intif_parse_WisMessage() + Wis拒否の判定をするようにした + A intif_parse_CharPosReq() + キャラの居場所をInterへ返答 + A intif_parse_CharPos() + キャラの居場所がInterから送られてきたので + flag=1 キャラの場所へ移動(@jumpto) + flag=0 キャラの場所を表示(@where) + A intif_parse_CharMoveReq() + キャラがいたら指定位置に移動させる + flag=1 @recall なのでGMレベルを比較、メッセージを表示 + A intif_parse_DisplayMessage() + 指定キャラにメッセージを送信 + C intif_parse() + 新パケットを追加 + C intif.h + C intif_guild_skillup() + 定義変更 + A intif_jumpto() + A intif_where() + A intif_charmovereq() + A intif_displaymessage() + 定義の追加 + C itemdb.c + A itemdb_isdropable() + アイテムが捨てられるかどうかの判定をする + A itemdb_read_cardillustnametable() + grfファイルから num2cardillustnametable.txt を読み込む + cutincard命令で使用 + C do_init_itemdb() + itemdb_read_cardillustnametable() を追加 + C itemdb.h + C struct item_data + char cardillustname[64] 追加 + A itemdb_isdropable() + 定義の追加 + C Makefile + A malloc.o malloc.h を追加 + C map.c + C struct charid2nick + @whoで他map-serverのキャラも表示できるように account_id ip port を追加 + C map_freeblock() + C map_freeblock_unlock() + 二重free()対策でNULLを代入するようにした + C map_delblock() + 見やすいように繰り返し使用される変数をまとめた + C map_addchariddb() + charid2nick の拡張にあわせて引数を増やした + A map_delchariddb() + charid_db からキャラを削除(実際にはip portを0に)する + C map_quit() + 結婚状態中はログアウトしても1時間は状態が続くようにPCグローバル変数 PC_WEDDING_TIME に開始時間を記録するようにした + C map_id2bl() + 見やすいように書き換え + A map_eraseipport() + 他map-server管理のマップを map_db から削除する + A map_who_sub() + A map_who() + 他map-serverにいるキャラも @who で表示されるようにした + 表示上キャラが残ることがあるのは調査中 + A id_db_final() + A map_db_final() + A nick_db_final() + A charid_db_final() + C do_final() + 終了時にメモリを開放するように変更 + C map.h + A MAX_WIS_REFUSAL + Wis拒否リストの保存最大値 + C struct map_session_data + C special_state + A unbreakable_weapon + 武器が絶対に壊れない + A unbreakable_armor + 鎧が絶対に壊れない + A opt3 + 画面外から入ってきたキャラの状態 + A areanpc_id + OnTouchイベントを実行したNPCのID + A wis_refusal[][] + Wis拒否リスト + A wis_all + Wis全拒否フラグ + A break_weapon_rate + 武器破壊率 + A break_armor_rate + 鎧破壊率 + A add_steal_rate + 追加スティール率 + C struct npc_data + A opt1,opt2,opt3,option + PCと同じ + C u.scr + A src_id + 終了時のメモリ開放用 + C struct mob_data + A opt3 + PCと同じ + A guild_id + ガーディアンなどで使用 + D exclusion_* + 関連関数を消したので削除した + C struct map_data + C flag + A notrade + 取引禁止マップフラグ + A noskill + スキル使用禁止マップフラグ + 定数の追加 + SP_PARTNER SP_CART + SP_BREAK_WEAPON_RATE SP_BREAK_ARMOR_RATE SP_ADD_STEAL_RATE + SP_UNBREAKABLE_WEAPON SP_UNBREAKABLE_ARMOR + D talkie_mes[] + 定義削除 + C map_addchariddb() + 定義変更 + A map_delchariddb() + A map_eraseipport() + A map_who() + 定義追加 + C mob.c + D mob_exclusion_add() + D mob_exclusion_check() + 意味がある使用をされていないのとbattle_check_target()で代用できるので削除した + C mob_stop_walking() + type&4で目的の場所まで距離があれば1歩進んで止まるようにした + C mob_attack() + MobがMobを攻撃できるようにした + C mob_target() + C mob_ai_sub_hard_slavemob() + mob_exclusion_check()を削除 + C mob_ai_sub_hard_activesearch() + C mob_ai_sub_hard() + special_mob_aiな場合はMobも索敵するようにした + ルートモンスターが目標のアイテムを見失った時は目的の場所まで歩かないようにした + C mob_damage() + スフィアマインが殴られた時に自爆しなかったのを修正した + スフィアマインが殴られて自爆する時に移動するようにした + srcがMobの時はsrcのターゲットを外すようにした + C mob_skillid2skillidx() + インデックスが0から始まるのにエラーも0を返すしていたのを修正した + スフィアマインが殴られても自爆しない原因はこれ + C mobskill_use() + 自爆状態ではスキルを使用できないようにした + C mob_spawn() + ガーディアンとエンペリウムが砦で発生した場合は guild_id を設定 + opt3 を 0 で初期化 + C mob_can_reach() + GvG以外ではガーディアンは何もしないようにした + C mob_catch_delete() + Mobが消えるときのエフェクトを type で指定できるようにした + C mob_timer_delete() + スフィアマインとバイオプラントが消えるときはテレポエフェクトで消えるようにした + C mob_deleteslave_sub() + nullチェック前に代入している部分を修正 + C mob_class_change() + clif_class_change() の変更に対応 + C mob.h + C mob_catch_delete() + 定義変更 + D mob_exclusion_add() + D mob_exclusion_check() + 定義削除 + C npc.c + C struct npc_src_list + A prev + 終了時のメモリ開放用に追加 + C npc_checknear() + イベントPCの場合に常にOKを返していなかったのを修正 + A npc_enable_sub() + npc_enable() から呼ばれて周囲のPCにOnTouchイベントを実行する + C npc_enable() + flag による挙動を追加 + flag=2 NPCのHide状態を解除する + flag=4 NPCをHide状態にする + HideしているNPCは無効になります + 有効にした時に npc_enable_sub() を呼ぶようにした + C npc_event() + エラー時は1を返すように変更 + OnTouchイベントから呼ばれたときはイベントが見つからないエラーを返さないようにした + C npc_touch_areanpc() + PCがエリア内を通った時に何度も実行されるのを修正 + NPCにOnTouchイベントがあった場合には実行するようにした + 互換性を保つためにOnTouchイベントが無い場合は今までと同じように動きます + C npc_parse_warp() + option,opt1,opt2,opt3 を 0 で初期化 + C npc_parse_warp() + C npc_parse_shop() + IDをnpc_get_new_npc_id()で取得するようにした + option,opt1,opt2,opt3 を 0 で初期化 + C npc_convertlabel_db() + メモリ確保後にnullかどうか確認していないのを修正 + C npc_parse_script() + bad duplicate name!エラー表示が改行されていなかったのを修正 + 終了時メモリ開放用にduplicateで src_id を挿入 + IDをnpc_get_new_npc_id()で取得するようにした + option,opt1,opt2,opt3 を 0 で初期化 + C npc_parse_mob() + memwatch対策でメモリを一括確保しないようにした + モンスター名に --ja-- --en-- を指定するとmob_dbの名前を使うようにした + IDをnpc_get_new_npc_id()で取得するようにした + C npc_parse_mapflag() + notrade noskill を読み込むようにした + A ev_db_final() + A npcname_db_final() + A do_final_npc() + 終了時にメモリを開放するようにした + C do_init_npc() + メモリを開放するようにした + C npc.h + A do_final_npc() + 定義の追加 + C party.c + A party_db_final() + A do_final_party() + 終了時にメモリを開放するようにした + C party.h + A do_final_party() + 定義の追加 + C pc.c + A pc_numisGM() + account_idでGMかどうか判断する + A pc_isquitable() + PCが終了できる状態にあるかどうか判断する + 1を返すときは終了できない + C pc_counttargeted_sub() + Mob状態によって値を正しく返さないような気がするので条件を仮変更 + C pc_makesavestatus() + マナーポイントが正数の場合は 0 にする + C pc_authok() + wis_all を 0 で初期化 + map_addchariddb() の変更に対応と常に実行するようにした + C pc_calcstatus() + break_weapon_rate break_armor_rate add_steal_rate を 0 で初期化 + 結婚状態では歩く速度が半分になるようにした + C pc_bonus() + SP_UNBREAKABLE_WEAPON SP_UNBREAKABLE_ARMOR SP_BREAK_WEAPON_RATE SP_BREAK_ARMOR_RATE SP_ADD_STEAL_RATE + 処理を追加 + C pc_dropitem() + アイテムを捨てられるかどうか判定するようにした + C pc_putitemtocart() + アイテムをカートに移動できるか判定するようにした + C pc_steal_item() + スティール率に add_steal_rate を加算するようにした + C pc_walk() + C pc_movepos() + 範囲NPCがいないときには areanpc_id=0 にした + C pc_checkbaselevelup() + スパノビがレベルアップした時にかかるスキルのレベルを本鯖にあわせた + C pc_skillup() + guild_skillup() の変更に対応 + C pc_damage() + スパノビがExp99%でHPが0になるとHPが回復して金剛状態になるようにした + C pc_readparam() + nullチェック前にsdを使っていたのを修正 + A SP_PARTNER + 結婚相手のchar_id + A SP_CART + カートを引いている場合は0以上が返る + C pc_jobchange() + マナーポイントが負数の場合は赤エモ表示するようにした + A pc_break_weapon() + 武器破壊をする + A pc_break_armor() + 鎧破壊をする + C pc_natural_heal_sp() + スパノビは爆裂状態でもSPが自然回復するようにした + A gm_account_db_final() + A do_final_pc() + 終了時にメモリ開放するようにした + C pc.h + A pc_numisGM() + A pc_isquitable() + A pc_break_weapon() + A pc_break_armor() + A do_final_pc() + 定義追加 + C pet.c + C pet_data_init() + C pet_lootitem_drop() + メモリ確保できたかどうか確認していなかったので修正 + C pet_catch_process2() + mob_catch_delete() の変更に対応 + C script.c + 追加した関数のプロトタイプを先頭に追加 + buildin_func[]に追加した命令や関数を追加 + 演算子に C_R_SHIFT C_L_SHIFT を追加 + C parse_subexpr() + 演算子 >> << 追加 + C get_val() + PC主体の変数でPCがアタッチされていなかったらエラーを出すようにした + PC主体の変数でsd=NULLだった場合にはpc_read*で取得に行かないようにした + A buildin_close2() + スクリプトを中断してCloseボタンを表示します + C buildin_areawarp_sub() + RandomだけでなくSavePointにも飛ばせるようにした + A buildin_cutincard() + カードのアイテムIDを指定することでカード画像を表示します + C buildin_getitem() + 引数を変更して鑑定した状態で渡すかどうかを指定できるようにした + account_idを指定することで、そのPCにアイテムを渡せるようにした(結婚用拡張) + C buildin_getitem2() + account_idを指定することで、そのPCにアイテムを渡せるようにした(結婚用拡張) + C buildin_readparam() + キャラ名を指定することで、そのPCのパラメータを読み取れるようにした + C buildin_getcharid() + キャラ名を指定することで、そのPCの関係IDを取得できるようにした + A buildin_getpartymember() + 指定IDのパーティ人数の取得とパーティーメンバーのIDを配列で取得できます + A buildin_guildskill() + ギルドスキルを覚えることができます + C buildin_getgdskilllv() + ギルドスキルIDをGD_APPROVALのようなスキル名で指定するようにした + A buildin_hideoffnpc() + Hide状態のNPCを表示する + A buildin_hideonnpc() + NPCをHide状態にする + C buildin_sc_start() + ID指定したキャラを状態異常にできるようにした + A buildin_sc_start2() + 確率指定でキャラを状態異常にできます(アイス、おもち等で使用) + A buildin_getscrate() + 状態異常耐性を計算した確率を返す + C buildin_changebase() + IDで指定したキャラの見た目を変更することができるようにした + C buildin_waitingroom() + limit=0の時は(1/10)を表示しないようにした + C buildin_setmapflag() + MF_NOTRADE MF_NOSKILL を追加 + C buildin_flagemblem() + NPCが特定できなかったときにmap-serverが落ちる問題を修正 + A buildin_getinventorylist() + 配列で所持品を返します + A buildin_getskilllist() + 配列で所有スキルを返します + A buildin_clearitem() + 所持アイテムを削除します + A buildin_getrepairableitemcount() + 壊れているアイテムを数えます + A buildin_repairitem() + 壊れているアイテムをすべて修理します + A buildin_classchange() + NPCをクラスチェンジします + A buildin_misceffect() + エフェクトを表示します + A buildin_soundeffect() + 指定したSEを鳴らします + C op_2num() + C run_script_main() + シフト演算子を追加 + A mapreg_db_final() + A mapregstr_db_final() + A scriptlabel_db_final() + A userfunc_db_final() + C do_final_script() + 終了時にメモリを開放するようにした + C skill.c + intif.h をinclude + コメントのスキル名をjRO仕様に書き換え + C SkillStatusChangeTable[] + ベナムスプラッシャー グラフィティ 自爆 自爆2 を追加 + C skill_additional_effect() + ベナムスプラッシャー追加 + アンクルスネアを削除 + C skill_attack() + チャット中にスキルが影響しないようにした(チャットキャンセル) + ベナムスプラッシャーはSkillLv=-1でclif_skill_damage()するようにした + 自爆はダメージ表示しないようにした + C skill_castend_damage_id() + アシッドテラーで武器破壊をするようにした + ベナムスプラッシャーが3*3の範囲攻撃をするようにした + 自爆の処理を変更した + C skill_castend_nodamage_id() + sdとdstsdでPCかどうかを判定するようにした + スパノビの嫁がヒールを使うと回復量が2倍になるようにした + clif_sitting()の変更に対応 + 武器修理はパケットが分からないのでコメントアウト + ストリップ〜、ケミカル〜をスキルユニットに使用した場合、map-serverが落ちる問題を修正 + 君だけは護るよ、あなたの為に犠牲になりますの計算をMAX_HPまたはMAX_SPからするようにした + あなたに逢いたい を相手の名前を叫ぶ、複数設置できない等、本鯖風にした + アンクルスネアでPCが引っかかっている時にリムーブトラップしてもPCが動けるようにならなかったのを修正 + アンコールを叫ぶようにした + ベナムスプラッシャーを実装した + 自爆で自爆状態を開始するようにした + C skill_castend_pos2() + バイオプラント、スフィアマイン + パケット順番を変更 + 指定した場所に設置するようにした + 効果時間をskill_cast_db.txtで指定するようにした + mob_exclusion_add()を削除 + グラフィティを実装、1個しか置けません + C skill_castend_map() + ワープポータルは実際の設置時にブルージェムストーンを消費するようにした + C skill_unitsetting() + グラフィティのスキルユニットを1個に修正 + トーキーボックス、グラフィティの文字列は sd->message に格納するようにした + C skill_unit_onplace() + チャット時はスキルユニットが動作しないようにした(チャットキャンセル) + アンクルスネアにかかる処理をskill_additional_effect()から移動 + ワープポータルに術者が乗ったら消えるようにした + デモンストレーションによる武器破壊をするようにした + アンクルスネア、スパイダーウェッブでメモリアクセス違反が起きる可能性があったのを修正 + C skill_unit_onout() + アンクルスネアで「}」が足りなかったために近くを通りかかっただけで1秒後罠に戻ってしまったのを修正 + C skill_unit_onlimit() + ワープポータル発動前の処理を削除 + あなたに逢いたいを他map-serverにいても呼べるようにした + A skill_check_condition_mob_master_sub() + マップ内で同じPCから出たバイオプラントやスフィアマインの数を数える + C skill_check_condition() + hp_rateとsp_rateに負数を指定すると消費計算をMax値からするようにした + あなたに逢いたいを結婚していない状態で使ったら使用失敗を表示するようにした + バイオプラントとスフィアマインの設置数をskill_cast_db.txtで設定できるようにした + ファイアーウォールの数制限を skill_use_pos() から移動 + C skill_use_id() + バジリカをGvGでは使用できないようにした + ベナムスプラッシャーは対象が毒状態でなければ使用失敗 + C skill_use_pos() + ファイアーウォールの数制限を skill_check_condition() に移動 + C skill_status_change_end() + opt3の処理を追加 + 結婚状態の終了を追加 + ベナムスプラッシャーを追加 + 自爆を追加 + C skill_status_change_timer() + 結婚状態と赤エモ状態のタイマー再設定を追加 + 自爆状態では1秒ごとに速度が変化するようにした + C skill_status_change_start() + opt3の処理を追加 + グラフィティは追加で置いたら前のは消えるようにした + 結婚状態と赤エモ状態を追加 + グラフィティは状態異常開始時にスキルユニットを設置するようにした + ベナムスプラッシャーは特に何も追加はなし + 自爆は詠唱パケットをここで送るようにした + C skill_status_change_clear() + opt3の処理を追加 + C skill_unit_timer_sub() + ワープポータル発動前が時間切れになるときに見た目を変更して本鯖のように効果音が出るようにした + ブラストマイン以外の罠は時間切れで罠に戻るようにした + C skill.h + 状態異常にスキル名をいくつかつけたり、新規の状態異常を増やした + C storage.c + A storage_db_final() + A guild_storage_db_final() + C do_final_storage() + 終了時にメモリを開放するようにした + C trade.c + C trade_tradeadditem() + C trade_tradecommit() + itemdb_isdropable()で交換できないアイテムを判定するようにした + C vending.c + vending_purchasereq() + 金額計算をdoubleでするようにしてintで桁あふれしないようにした + +-------------------- +//1045 by TEILU + +・スティール、スティールコイン、スナッチャーの失敗メッセージが + レベルが1〜9の時に変だったので修正。 + (map/) + skill.c + +・精錬の可否を情報サイトを元にDBに設定。(頭装備はrusiさん作成分を使用) + (db/) + item_db.txt + +・ファイアーウォールが制限数を超えたときにスキル使用失敗が + 出るタイミングを変更。 + (map/) + skill.c + +・アブラカタブラ専用スキルをgm_all_skill設定時に表示できるように変更。 + battle_athena.confのgm_all_skill_add_abraにyesを設定すれば + スキルリストに表示されるようになります。 + (conf/) + battle_athena.conf + (db/) + skill_require_db.txt + (map/) + battle.c + battle.h + pc.c + +-------------------- +//1044 by TEILU + +・1042で@itemidentifyの権限の設定を忘れていたので追加。 + (conf/) + atcommand_athena.conf + +・スティール、スティールコイン、スナッチャーの失敗時に + 失敗メッセージを表示するように変更。 + (map/) + skill.c + +・アイテムDBに精錬可否フラグのカラムを追加 + 精錬の可否をDBを参照するように修正 + ※とりあえず中段、下段、中下段の頭装備とアクセサリ以外の + 装備品はすべて精錬可の設定でDBを作りました。 + DBは修正が必要になります。 + (db/) + item_db.txt + (map/) + itemdb.c + itemdb.h + script.c + +-------------------- +//1043 by dusk +・docフォルダ・confフォルダ内のhelp.txtに1042(TEILUさん)の説明追加 + @itemidentifyの説明は72行目の@itemresetの下に。 + +・Valkyrie Realms 5 (右上)の旗の修正 + Valkyrie Realms 5 (右上)の旗を見ると未取得状態コメントばっかり出ていたのを + ちゃんと確認できるように。 + ※ Valkyrie Realmsの各砦に戻る旗とは違います。 + prtg_cas05.txt内のギルドダンジョンに入るレバー以外の + getcastledata "prtg_cas05.gat",1,@GIDp5;を + set @GIDp5,getcastledata("prtg_cas05.gat",1);に修正。 + +-------------------- +//1042 by TEILU + +・@healコマンドに何も渡さないと完全回復するように変更。 + (map/) + atcommand.c + +・@itemitemidentifyコマンドの追加 + 未鑑定の所持アイテムを全て鑑定します。 + (conf/) + msg_athena.conf + (map/) + atcommand.c + atcommand.h + +-------------------- +//1041 by mare + FIX NPC Script Command - buildin_getgdskilllv() + Add NPC Sctipt Command - buildin_agitcheck() + (script/npc/job/) + npc_job_wizard.txt + ラウレルさんの台詞、ノビとプリの場合の分追加 +------------------- +//1040 by 胡蝶蘭 + +・サーバー間接続のパケット表追加 + (doc/) + serverlink_packet.txt + inter<->map 以外のサーバー間接続のパケット表 + +・仕様スレの Login_ID2 関係でごにょごにょ +・サーバー間接続のパケット一部変更 + (login/) + login.c + auth_fifo に ip メンバ追加 + パケット変更に伴う変更他 + (char/) + char.c + auth_fifo に login_id2, ip メンバ追加 + パケット変更に伴う変更他 + (map/) + chrif.c + chrif_authok()追加 + パケット変更に伴う変更他 + +・自動再起動スクリプト start にコメントで簡単な説明追加 + start + コメント追加 + +-------------------- +//1039 by Ni+S + ・ギルド関係のスクリプト + 所有者の居ないアジトから、ギルドに所属してないキャラなら + ギルドダンジョンに入れてしまうという不具合がありました + + これは、所有者の居ないアジトの値が0であり、 + getcharid(2)でギルドIDを返すのですが、 + ギルドに所属していないキャラはgetcharid(2)で0を返す為、 + 値が一致してしまい起こっていた現象でした + 未所属キャラが入れないように修正しました + + ・ファーマシー/ポーション作成DB + レッドスリムポーション + イエロースリムポーション + ホワイトスリムポーション + の材料を、空のポーション瓶から試験管に修正 + +-------------------- +//1038 by Plala +・転職NPC関連の重大なバグ修正 + (script/npc/job) + npc_job_aco.txt 修正 + npc_job_merchant.txt 修正 + npc_job_thief.txt 修正 + + ・上記NPCで途中までクエストを進めて他の職に転職すると、 + 再び転職可能だった点を修正しました + + +-------------------- +//1037 by 胡蝶蘭 + +** FOR ENGLISH DEVELOPERS ** +DO NOT UPLOAD IF YOU DON'T USE JAPANESE ENCODE (SHIFT-JIS) ! +WHY WE(JAPANESE) REPAIR ERROR CHARACTER AFTER EVERY YOUR UPLOADING ? +BREAKING IS EASY, REPAIRING IS VERY DIFFICULT ! + +** 英語圏の開発者の方へ(日本語訳) ** +日本語エンコード(シフトJIS)を使う気が無いならアップロードしないてください! +なぜ我々(日本人)があなた方のアップロードのたびに文字化けを直さなければならないんですか? +壊すのは簡単ですが、直すのはとても難しいんです! + +・文字化けを根性で修正 + (map/) + script.c + +・ladminがPOSIX必須に。Digest::MD5が無くても実行できるように修正 +・serverstatus.cgiで、Net::Pingが無くても実行できるように修正 + (bin/tool/) + ladmin + (bin/tool/cgi/) + serverstatus.cgi + +・script_refで抜けてるものでわかるものを修正 + 何故かscript_refから抜けてるもの(getargなど)の一部を再び追加 + ** アップロードするときは最新パッチからの差分をアップロードしましょう ** + (doc/) + script_ref.txt + +・account_making.txt修正 + ladminスクリプトのパス + (doc/) + accoun_tmaking.txt + +-------------------- +//1036 by Michael +・追加 Script Command: + getequipid(EquipPos); EquipPos: 1-10 + gettimetick(Type); Type: 0 SystemTick, 1 TimeSecondTick(0-86399) + gettime(Type); Type: 1 Sec, 2 Min, 3 Hour, 4 Weekday, 5, Monthday, 6 Month, 7 Year + gettimestr("TimeFMT", Len); TimeFMT: Time format strinf / Len: String Length + + (map/) + script.c + buildin_getequipid(); 追加 + buildin_gettimetick(); 追加 + buildin_gettime(); 追加 + buildin_gettimestr(); 追加 + +-------------------- +//1035 by Michael +・追加 GVG Script NPC edit from Aegis NPC(Chinese-big5 version), Please someone translate to Japanese. +・修正 NPC Script Command - buildin_getgdskilllv() + getgdskilllv(Guild_ID, Skill_ID); + + (map/) + script.c + buildin_getgdskilllv() 修正 + +-------------------- +//1034 by (Pepermint) + FIX NPC Script Command - buildin_getgdskilllv() + Add NPC Sctipt Command - buildin_agitcheck() + (map/) + script.c + buildin_getgdskilllv() 修正 + buildin_agitcheck() 追加 + +-------------------- +//1033 by Michael +・追加 NPC Script Command - buildin_getgdskilllv() + getgdskilllv(Guild_ID, Skill_ID); + skill_id = 1:GD_APPROVAL,2:GD_KAFRACONTACT,3:GD_GUARDIANRESEARCH,4:GD_CHARISMA,5:GD_EXTENSION + + (map/) + script.c + buildin_getgdskilllv() 追加 + -------------------- //1032 by (凸) ・1031で何故か削除されていたbuildin_getitemname()を復活 @@ -17,7 +2937,7 @@ script.c buildin_getitemname() 復活 ----------------------------------------- +-------------------- //1031 by huge ・NPCのscriptに、makepetを追加。 makepet 卵ID; で、ペットを作成します。 @@ -110,11 +3030,11 @@ pc.c pc_calcstatus() 変更 skill.c - + skill_status_change_end() 変更 skill_status_change_start() 変更とNULLチェック修正 skill.h 変更 - + -------------------- //1027 by Ni+S ・getitemname関数追加 @@ -125,7 +3045,7 @@ script.c getitemname()追加 ----------------------------------------- +-------------------- //1026 by (凸) ・1023で入れてなかったclif.hを同梱 ・バイオプラントとスフィアーマインで出したmobを倒すとmob_timer_delete()でnullpoが出る問題を解決したつもり @@ -150,7 +3070,6 @@ ・オーラブレード武器制限を素手以外全てに修正 ・コンセントレーション武器制限を両手槍のみから片手槍+両手槍へ修正 ・トゥルーサイト効果時間を修正 -・ファルコンアサルト武器制限を解除、素手を含めた全てで使用可能に (db/) job_db2-2.txt 変更 @@ -164,7 +3083,7 @@ (db/) produce_db.txt 変更 ----------------------------------------- +-------------------- //1023 by (凸) ・1022でエンバグしたnpc_parse_script()を戻し ・スパイラルピアースの重量追加ダメージ計算式をちょっと変更 @@ -403,13 +3322,17 @@ -------------------- //1014 by (Pepermint) -I fixed again the problem if you put minus sign(-) in front of digits, +I fixed again the problem if you put minus sign(-) in front of digits, the error comes up when you puchase a item. -When you put a minus sign(-), the error sign will be changed shrotage of +When you put a minus sign(-), the error sign will be changed shrotage of amount as original server dose. I tested with it in ver. 1013, it was working +-------------------- +//1013 by (凸) +・サーバースナップショット + -------------------- //1012 by (凸) ・help.txtにある@goの説明から13と14を削除 diff --git a/db/skill_cast_db.txt b/db/skill_cast_db.txt index 92e458588..93badb7a2 100644 --- a/db/skill_cast_db.txt +++ b/db/skill_cast_db.txt @@ -16,7 +16,7 @@ 18,2000:1850:1700:1550:1400:1250:1100:950:800:650,0,5000:6000:7000:8000:9000:10000:11000:12000:13000:14000,0 //MG_FIREWALL#ファイアーウォール# 19,700:1400:2100:2800:3500:4200:4900:5600:6300:7000,1000:1200:1400:1600:1800:2000:2200:2400:2600:2800,0,0 //MG_FIREBOLT#ファイアーボルト# 20,700:1400:2100:2800:3500:4200:4900:5600:6300:7000,1000:1200:1400:1600:1800:2000:2200:2400:2600:2800,0,0 //MG_LIGHTNINGBOLT#ライトニングボルト# -21,1000:2000:3000:4000:5000:6000:7000:8000:9000:10000,2000,0,0 //MG_THUNDERSTORM#サンダーストーム# +21,1000:2000:3000:4000:5000:6000:7000:8000:9000:10000,2000,500,0 //MG_THUNDERSTORM#サンダーストーム# 24,0,0,10000,0 //AL_RUWACH#ルアフ# 25,0,0,10000,0 //AL_PNEUMA#ニューマ# @@ -62,17 +62,17 @@ 78,0,3000,600000,0 //PR_LEXAETERNA#レックスエーテルナ# 79,15000,4000,5000:6000:7000:8000:9000:10000:11000:12000:13000:14000,0 //PR_MAGNUS#マグヌスエクソシズム# 80,3000:2700:2400:2100:1800:1500:1200:900:600:300,2000,30000,0 //WZ_FIREPILLAR#ファイアーピラー# -81,700,2000,0,0 //WZ_SIGHTRASHER#サイトラッシャー# +81,700,2000,500,0 //WZ_SIGHTRASHER#サイトラッシャー# -83,15000,2000:3000:3000:4000:4000:5000:5000:6000:6000:7000,0,3200:3400:3600:3800:4000:4200:4400:4600:4800:5000 //WZ_METEOR#メテオストーム# +83,15000,2000:3000:3000:4000:4000:5000:5000:6000:6000:7000,500,3200:3400:3600:3800:4000:4200:4400:4600:4800:5000 //WZ_METEOR#メテオストーム# 84,2500:3000:3500:4000:4500:5000:5500:6000:6500:7000,0,0,0 //WZ_JUPITEL#ユピテルサンダー# -85,15000:14500:14000:13500:13000:12500:12000:11500:11000:10500,5000,0,5500:6000:6500:7000:7500:8000:8500:9000:9500:10000 //WZ_VERMILION#ロードオブヴァーミリオン# +85,15000:14500:14000:13500:13000:12500:12000:11500:11000:10500,5000,4100,5500:6000:6500:7000:7500:8000:8500:9000:9500:10000 //WZ_VERMILION#ロードオブヴァーミリオン# 86,1000:2000:3000:4000:5000,0,0,0 //WZ_WATERBALL#ウォーターボール# 87,0,0,5000:10000:15000:20000:25000:30000:35000:40000:45000:50000,0 //WZ_ICEWALL#アイスウォール# 88,5000:4700:4400:4100:3800:3500:3200:2900:2700:2500,1000,0,3000:3500:4000:4500:5000:5500:6000:6500:7000:7500 //WZ_FROSTNOVA#フロストノヴァ# -89,6000:7000:8000:9000:10000:11000:12000:13000:14000:15000,5000,0,10000:11000:12000:13000:14000:15000:16000:17000:18000:19000 //WZ_STORMGUST#ストームガスト# +89,6000:7000:8000:9000:10000:11000:12000:13000:14000:15000,5000,4600,10000:11000:12000:13000:14000:15000:16000:17000:18000:19000 //WZ_STORMGUST#ストームガスト# 90,1000:2000:3000:4000:5000,700,0,0 //WZ_EARTHSPIKE#アーススパイク# -91,1000:2000:3000:4000:5000,700,0,0 //WZ_HEAVENDRIVE#ヘヴンズドライブ# +91,1000:2000:3000:4000:5000,700,500,0 //WZ_HEAVENDRIVE#ヘヴンズドライブ# 92,0,1000,5000:10000:15000:20000:25000,5000:10000:15000:20000:25000 //WZ_QUAGMIRE#クァグマイア# 110,0,0,0,6000:7000:8000:9000:10000:11000 //BS_HAMMERFALL#ハンマーフォール# @@ -155,7 +155,7 @@ 251,0,700,0,0 //CR_SHIELDBOOMERANG#シールドブーメラン# 252,0,0,300000,0 //CR_REFLECTSHIELD#リフレクトシールド# 253,0,0,0,10000:11000:12000:13000:14000:15000:16000:17000:18000:19000 //CR_HOLYCROSS#ホーリークロス# -254,3000,1500,0,10000:11000:12000:13000:14000:15000:16000:17000:18000:19000 //CR_GRANDCROSS#グランドクロス# +254,3000,1500,1000,10000:11000:12000:13000:14000:15000:16000:17000:18000:19000 //CR_GRANDCROSS#グランドクロス# 256,3000,0,180000,0 //CR_PROVIDENCE#プロヴィデンス# 257,0,800,180000,0 //CR_DEFENDER#ディフェンダー# @@ -218,6 +218,8 @@ 335,3000,0,0,0 //WE_FEMALE#あなたに尽くします# 336,0,0,10000,0 //WE_CALLPARTNER#あなたに逢いたい# +339,3000,1500,1000,10000:11000:12000:13000:14000:15000:16000:17000:18000:19000 //NPC_DARKGRANDCROSS#闇グランドクロス + 355,0,0,40000:60000:80000:100000:120000,0 //LK_AURABLADE#オーラブレード# 356,0,0,15000:20000:25000:30000:35000:40000:45000:50000:55000:60000,0 //LK_PARRYING#パリイング# 357,0,0,25000:30000:35000:40000:45000,0 //LK_CONCENTRATION#コンセントレーション# @@ -270,6 +272,10 @@ 476,1000,1000,75000:90000:105000:120000:135000,0 //ST_FULLSTRIP## 479,2000,0,120000:240000:360000:480000:600000,0 //CR_FULLPROTECTION## +10006,0,0,300000,0 //GD_LEADERSHIP## +10007,0,0,300000,0 //GD_GLORYWOUNDS## +10008,0,0,300000,0 //GD_SOULCOLD## +10009,0,0,300000,0 //GD_HAWKEYES## 10010,100,1000,60000,0 //GD_BATTLEORDER## 10011,100,1000,60000,0 //GD_REGENERATION## 10012,100,1000,0,0 //GD_RESTORE## diff --git a/db/skill_db.txt b/db/skill_db.txt index d7b4fd9d0..c66c43a33 100644 --- a/db/skill_db.txt +++ b/db/skill_db.txt @@ -454,7 +454,7 @@ 394,8,8,1,0,0,10,9,no,0,0,0,weapon,0 //CG_ARROWVULCAN#アロ?バルカン# 395,0,0,4,0,1,1,1,yes,0,0,0,magic,0 //CG_MOONLIT#月明りの泉に落ちる花びら# 396,0,6,16,0,1,1,1,yes,0,0,0,magic,1 //CG_MARIONETTE#?リオネットコントロ?ル# -397,4,8,1,0,0,5,1,no,0,0,0,weapon,0 //LK_SPIRALPIERCE#スパイラルピア?ス# +397,4,8,1,0,0,5,5,no,0,0,0,weapon,0 //LK_SPIRALPIERCE#スパイラルピア?ス# 398,4,6,1,0,0,5,1,no,0,0,0,weapon,0 //LK_HEADCRUSH#ヘッドクラッシュ# 399,4,6,1,0,0,10,1,no,0,0,0,weapon,0 //LK_JOINTBEAT#ジョイントビ?ト# 400,8,8,1,8,0,5,1:2:3:4:5,yes,0,0,0,magic,0 //HW_NAPALMVULCAN#ナパ??バルカン# diff --git a/db/skill_unit_db.txt b/db/skill_unit_db.txt new file mode 100644 index 000000000..9c0616e30 --- /dev/null +++ b/db/skill_unit_db.txt @@ -0,0 +1,78 @@ +// id,unit,unit,layout,range,interval,target,flag +// position -1:特殊, 0:1*1, 1:3*3, 2:5*5,..., 5:11*11 +// target friend:NOENEMY, party:PARTY, 0x20000:BCT_ALL, enemy:ENEMY +// flag 0x001(UF_DEFNOTENEMY) defunit_not_enemyの影響を受ける +// 0x002(UF_NOREITERRATION) 重ね置き不可 +// 0x004(UF_NOFOOTSET) 足元置き不可 +// 0x008(UF_NOOVERLAP) 効果が重複しない +// 0x100(UF_DANCE) ダンススキル +// 0x200(UF_ENSEMBLE) 合奏スキル +// +// 0x89,0x8a,0x8b 表示無し +// 0x9a 炎属性の詠唱みたいなエフェクト +// 0x9b 水属性の詠唱みたいなエフェクト +// 0x9c 風属性の詠唱みたいなエフェクト +// 0x9d 白い小さなエフェクト +// +// u1 u2 lay r intr target flag + 12,0x7e, , 0, 0, -1,all, 0x003 //MG_SAFETYWALL#セイフティウォール + 18,0x7f, , -1, 0, 1,enemy, 0x000 //MG_FIREWALL#ファイアーウォール + 21,0x86, , 0, 1,1000,enemy, 0x008 //MG_THUNDERSTORM#サンダーストーム + 25,0x85, , 1, 0, -1,all, 0x003 //AL_PNEUMA#ニューマ + 27,0x81,0x80, 0, 0, -1,all, 0x002 //AL_WARP#ワープポータル + 70,0x83, , -1, 1,1000,all, 0x000 //PR_SANCTUARY#サンクチュアリ + 79,0x84, , -1, 1,3000,enemy, 0x000 //PR_MAGNUS#マグヌスエクソシズム + 80,0x87,0x88, 0, 1,2000,enemy, 0x002 //WZ_FIREPILLAR#ファイアーピラー + 83,0x86, , 0, 3,1000,enemy, 0x000 //WZ_METEOR#メテオストーム + 85,0x86, , 0, 6,1000,enemy, 0x008 //WZ_VERMILION#ロードオブヴァーミリオン + 87,0x8d, , -1, 0, -1,all, 0x000 //WZ_ICEWALL#アイスウォール + 88,0x86, , 0, 2,1000,enemy, 0x000 //WZ_FROSTNOVA#フロストノヴァ + 89,0x86, , 0, 5, 450,enemy, 0x000 //WZ_STORMGUST#ストームガスト + 91,0x86, , 0, 2,1000,enemy, 0x000 //WZ_HEAVENDRIVE#ヘヴンズドライブ + 92,0x8e, , 2, 0, -1,enemy, 0x000 //WZ_QUAGMIRE#クァグマイア +115,0x90, , 0, 1,1000,enemy, 0x002 //HT_SKIDTRAP#スキッドトラップ +116,0x93, , 0, 1,1000,enemy, 0x002 //HT_LANDMINE#ランドマイン +117,0x91, , 0, 1,1000,enemy, 0x002 //HT_ANKLESNARE#アンクルスネア +118,0x94, , 0, 1,1000,enemy, 0x002 //HT_SHOCKWAVE#ショックウェーブトラップ +119,0x95, , 0, 2,1000,enemy, 0x002 //HT_SANDMAN#サンドマン +120,0x96, , 0, 1,1000,enemy, 0x002 //HT_FLASHER#フラッシャー +121,0x97, , 0, 1,1000,enemy, 0x002 //HT_FREEZINGTRAP#フリージングトラップ +122,0x8f, , 0, 1,1000,enemy, 0x002 //HT_BLASTMINE#ブラストマイン +123,0x98, , 0, 2,1000,enemy, 0x002 //HT_CLAYMORETRAP#クレイモアトラップ +125,0x99, , 0, 1,1000,all, 0x002 //HT_TALKIEBOX#トーキーボックス +140,0x92, , -1, 0,1000,enemy, 0x000 //AS_VENOMDUST#ベナムダスト +220,0xb0, , 0, 0, -1,all, 0x002 //RG_GRAFFITI#グラフィティ +229,0xb1, , 0, 1,1000,enemy, 0x000 //AM_DEMONSTRATION#デモンストレーション +254,0x86, , -1, 0, 300,enemy, 0x000 //CR_GRANDCROSS#グランドクロス +285,0x9a, , 3, 0, -1,all, 0x000 //SA_VOLCANO#ボルケーノ +286,0x9b, , 3, 0, -1,all, 0x000 //SA_DELUGE#デリュージ +287,0x9c, , 3, 0, -1,all, 0x000 //SA_VIOLENTGALE#バイオレントゲイル +288,0x9d, , 3, 0, -1,all, 0x000 //SA_LANDPROTECTOR#ランドプロテクター +306,0x9e, , 4, 0, -1,all, 0x300 //BD_LULLABY#子守歌 +307,0x9f, , 4, 0, -1,party, 0x300 //BD_RICHMANKIM#ニヨルドの宴 +308,0xa0, , 4, 0, -1,enemy, 0x300 //BD_ETERNALCHAOS#永遠の混沌 +309,0xa1, , 4, 0, -1,party, 0x300 //BD_DRUMBATTLEFIELD#戦太鼓の響き +310,0xa2, , 4, 0, -1,party, 0x300 //BD_RINGNIBELUNGEN#ニーベルングの指輪 +311,0xa3, , 4, 0, -1,all, 0x300 //BD_ROKISWEIL#ロキの叫び +312,0xa4, , 4, 0, -1,party, 0x300 //BD_INTOABYSS#深淵の中に +313,0xa5, , 4, 0, -1,party, 0x300 //BD_SIEGFRIED#不死身のジークフリード +317,0xa6, , 3, 0, -1,enemy, 0x100 //BA_DISSONANCE#不協和音 +319,0xa7, , 3, 0, -1,friend,0x100 //BA_WHISTLE#口笛 +320,0xa8, , 3, 0, -1,friend,0x100 //BA_ASSASSINCROSS#夕陽のアサシンクロス +321,0xa9, , 3, 0, -1,friend,0x100 //BA_POEMBRAGI#ブラギの詩 +322,0xaa, , 3, 0, -1,friend,0x100 //BA_APPLEIDUN#イドゥンの林檎 +325,0xab, , 3, 0, -1,enemy, 0x100 //DC_UGLYDANCE#自分勝手なダンス +327,0xac, , 3, 0, -1,friend,0x100 //DC_HUMMING#ハミング +328,0xad, , 3, 0, -1,enemy, 0x100,0 //DC_DONTFORGETME#私を忘れないで… +329,0xae, , 3, 0, -1,friend,0x100,0 //DC_FORTUNEKISS#幸運のキス +330,0xaf, , 3, 0, -1,party, 0x100,0 //DC_SERVICEFORYOU#サービスフォーユー +336,0xb2, , 0,-1, -1,all, 0x000,0 //WE_CALLPARTNER#あなたに逢いたい +339,0x86, , -1, 0, 300,enemy, 0x000,0 //NPC_DARKGRANDCROSS#闇グランドクロス +362,0xb4, , 0, 3, 300,all, 0x000,0 //HP_BASILICA#バジリカ +369,0xb3, , 3, 0, -1,all, 0x000,0 //PA_GOSPEL#ゴスペル +404,0xb6, , -1, 0, -1,all, 0x000,0 //PF_FOGWALL#フォグウォール +405,0xb7, , 0, 1,1000,enemy, 0x002,0 //PF_SPIDERWEB#スパイダーウェッブ +10006,0xc1, , 0, 2, -1,all, 0x000,0 //GD_LEADERSHIP +10007,0xc2, , 0, 2, -1,all, 0x000,0 //GD_GLORYWOUNDS +10008,0xc3, , 0, 2, -1,all, 0x000,0 //GD_SOULCOLD +10009,0xc4, , 0, 2, -1,all, 0x000,0 //GD_HAWKEYES diff --git a/src/char/Makefile b/src/char/Makefile index 3c09db92c..aee0e69e2 100644 --- a/src/char/Makefile +++ b/src/char/Makefile @@ -1,7 +1,7 @@ all: char-server txt: char-server -COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o ../common/obj/db.o ../common/obj/lock.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/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 ../../$@ $> $(LIB_S) diff --git a/src/char_sql/Makefile b/src/char_sql/Makefile index e206dd211..1741b5ab6 100644 --- a/src/char_sql/Makefile +++ b/src/char_sql/Makefile @@ -1,7 +1,7 @@ all: char-server_sql sql: char-server_sql -COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o ../common/utils.o ../common/strlib.o +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o ../common/obj/strlib.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o itemdb.o $(COMMON_OBJ) diff --git a/src/common/Makefile b/src/common/Makefile index eaa7205d2..c387c2e01 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -1,15 +1,23 @@ -txt sql all: core.o socket.o timer.o grfio.o db.o lock.o nullpo.o malloc.o showmsg.o - -core.o: core.c core.h showmsg.h -socket.o: socket.c socket.h mmo.h showmsg.h -timer.o: timer.c timer.h showmsg.h -grfio.o: grfio.c grfio.h showmsg.h -db.o: db.c db.h showmsg.h -lock.o: lock.h showmsg.h -nullpo.o: nullpo.c nullpo.h showmsg.h -malloc.o: malloc.c malloc.h showmsg.h -showmsg.o: showmsg.c showmsg.h -strlib.o: strlib.c strlib.h utils.h +txt sql all: obj common + +obj: + mkdir obj + +common: obj/core.o obj/socket.o obj/timer.o obj/grfio.o obj/db.o obj/lock.o obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o + +obj/%.o: %.c + $(COMPILE.c) $(OUTPUT_OPTION) $< + +obj/core.o: core.c core.h showmsg.h +obj/socket.o: socket.c socket.h mmo.h showmsg.h +obj/timer.o: timer.c timer.h showmsg.h +obj/grfio.o: grfio.c grfio.h showmsg.h +obj/db.o: db.c db.h showmsg.h +obj/lock.o: lock.h showmsg.h +obj/nullpo.o: nullpo.c nullpo.h showmsg.h +obj/malloc.o: malloc.c malloc.h showmsg.h +obj/showmsg.o: showmsg.c showmsg.h +obj/strlib.o: strlib.c strlib.h utils.h clean: - rm -f *.o + rm -f *.o obj diff --git a/src/common/core.c b/src/common/core.c index fbd607080..016ade08d 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -9,10 +9,13 @@ #include #include #ifdef DUMPSTACK -#include + #ifndef _WIN32 // HAVE_EXECINFO_H + #include + #endif #endif #include "../common/mmo.h" +#include "malloc.h" #include "core.h" #include "socket.h" #include "timer.h" @@ -92,44 +95,44 @@ static void sig_proc(int sn) * Dumps the stack using glibc's backtrace *----------------------------------------- */ -#ifdef DUMPSTACK static void sig_dump(int sn) { - FILE *fp; - void* array[20]; + #ifdef DUMPSTACK + FILE *fp; + void* array[20]; - char **stack; - size_t size; - int no = 0; - char tmp[256]; + char **stack; + size_t size; + int no = 0; + char tmp[256]; - // search for a usable filename - do { - sprintf(tmp,"save/stackdump_%04d.txt", ++no); - } while((fp = fopen(tmp,"r")) && (fclose(fp), no < 9999)); - // dump the trace into the file - if ((fp = fopen (tmp,"w")) != NULL) { + // search for a usable filename + do { + sprintf(tmp,"save/stackdump_%04d.txt", ++no); + } while((fp = fopen(tmp,"r")) && (fclose(fp), no < 9999)); + // dump the trace into the file + if ((fp = fopen (tmp,"w")) != NULL) { - fprintf(fp,"Exception: %s\n", strsignal(sn)); - fprintf(fp,"Stack trace:\n"); - size = backtrace (array, 20); - stack = backtrace_symbols (array, size); + fprintf(fp,"Exception: %s\n", strsignal(sn)); + fprintf(fp,"Stack trace:\n"); + size = backtrace (array, 20); + stack = backtrace_symbols (array, size); - for (no = 0; no < size; no++) { + for (no = 0; no < size; no++) { - fprintf(fp, "%s\n", stack[no]); + fprintf(fp, "%s\n", stack[no]); - } - fprintf(fp,"End of stack trace\n"); + } + fprintf(fp,"End of stack trace\n"); - fclose(fp); - free(stack); - } + fclose(fp); + free(stack); + } + #endif // When pass the signal to the system's default handler compat_signal(sn, SIG_DFL); raise(sn); } -#endif int get_svn_revision(char *svnentry) { // Warning: minor syntax checking char line[1024]; @@ -204,28 +207,20 @@ int main(int argc,char **argv) compat_signal(SIGPIPE,SIG_IGN); compat_signal(SIGTERM,sig_proc); compat_signal(SIGINT,sig_proc); - -#ifndef DUMPSTACK - // Signal to create coredumps by system when necessary (crash) - compat_signal(SIGSEGV, SIG_DFL); - compat_signal(SIGFPE, SIG_DFL); - compat_signal(SIGILL, SIG_DFL); - #ifndef _WIN32 - compat_signal(SIGBUS, SIG_DFL); - compat_signal(SIGTRAP, SIG_DFL); - #endif -#else + + // Signal to create coredumps by system when necessary (crash) compat_signal(SIGSEGV, sig_dump); compat_signal(SIGFPE, sig_dump); compat_signal(SIGILL, sig_dump); #ifndef _WIN32 compat_signal(SIGBUS, sig_dump); - compat_signal(SIGTRAP, SIG_DFL); + compat_signal(SIGTRAP, SIG_DFL); #endif -#endif display_title(); + do_init_memmgr(argv[0]); // 一番最初に実行する必要がある + tick_ = time(0); do_init(argc,argv); @@ -234,5 +229,6 @@ int main(int argc,char **argv) do_sendrecv(next); do_parsepacket(); } + return 0; } diff --git a/src/common/db.c b/src/common/db.c index 12d54176c..9f2c75a68 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -65,7 +65,7 @@ static unsigned int strdb_hash(struct dbt* table,void* a) return h; } -struct dbt* strdb_init(int maxlen) +struct dbt* strdb_init_(int maxlen,const char *file,int line) { int i; struct dbt* table; @@ -77,6 +77,9 @@ struct dbt* strdb_init(int maxlen) table->maxlen=maxlen; for(i=0;iht[i]=NULL; + table->alloc_file = file; + table->alloc_line = line; + table->item_count = 0; return table; } @@ -98,7 +101,7 @@ static unsigned int numdb_hash(struct dbt* table,void* a) return (unsigned int)a; } -struct dbt* numdb_init(void) +struct dbt* numdb_init_(const char *file,int line) { int i; struct dbt* table; @@ -110,6 +113,9 @@ struct dbt* numdb_init(void) table->maxlen=sizeof(int); for(i=0;iht[i]=NULL; + table->alloc_file = file; + table->alloc_line = line; + table->item_count = 0; return table; } @@ -400,6 +406,7 @@ struct dbn* db_insert(struct dbt *table,void* key,void* data) db_rebalance(p,&table->ht[hash]); } } + table->item_count++; return p; } @@ -428,12 +435,14 @@ void* db_erase(struct dbt *table,void* key) #else aFree(p); #endif + table->item_count--; return data; } void db_foreach(struct dbt *table,int (*func)(void*,void*,va_list),...) { int i,sp; + int count = 0; // red-black treeなので64個stackがあれば2^32個ノードまで大丈夫 struct dbn *p,*pn,*stack[64]; va_list ap; @@ -449,6 +458,7 @@ void db_foreach(struct dbt *table,int (*func)(void*,void*,va_list),...) // printf("Warning: no data for key %d in db_foreach (db.c) !\n",(int)p->key); //} else { func(p->key, p->data, ap); + count++; //} if((pn=p->left)!=NULL){ if(p->right){ @@ -466,6 +476,12 @@ void db_foreach(struct dbt *table,int (*func)(void*,void*,va_list),...) } } } + if(count != table->item_count) { + printf( + "db_foreach : data lost %d of %d item(s) allocated from %s line %d\n", + table->item_count - count,count,table->alloc_file,table->alloc_line + ); + } va_end(ap); } diff --git a/src/common/db.h b/src/common/db.h index ea9aceab0..c31f5bfaa 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -22,6 +22,9 @@ struct dbt { void (*release)(struct dbn*,int which); int maxlen; struct dbn *ht[HASH_SIZE]; + int item_count; // vf? + const char* alloc_file; // DB?t@C + int alloc_line; // DB?s }; #define strdb_search(t,k) db_search((t),(void*)(k)) @@ -34,9 +37,12 @@ struct dbt { #define numdb_erase(t,k) db_erase ((t),(void*)(k)) #define numdb_foreach db_foreach #define numdb_final db_final +#define strdb_init(a) strdb_init_(a,__FILE__,__LINE__) +#define numdb_init() numdb_init_(__FILE__,__LINE__) + +struct dbt* strdb_init_(int maxlen,const char *file,int line); +struct dbt* numdb_init_(const char *file,int line); -struct dbt* strdb_init(int maxlen); -struct dbt* numdb_init(void); void* db_search(struct dbt *table,void* key); void* db_search2(struct dbt *table, const char *key); // [MouseJstr] struct dbn* db_insert(struct dbt *table,void* key,void* data); diff --git a/src/common/grfio.c b/src/common/grfio.c index 0c628d163..224ea909e 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -32,21 +32,36 @@ #include "malloc.h" #ifdef _WIN32 - #include - #include "../lib/zlib_win32.h" - HINSTANCE zlib_dll; - #define zlib_inflateInit(strm) zlib_inflateInit_((strm),ZLIB_VERSION, sizeof(z_stream)) - #define zlib_deflateInit(strm, level) zlib_deflateInit_((strm),(level),ZLIB_VERSION,sizeof(z_stream)) - - int (WINAPI* zlib_inflateInit_) (z_streamp strm, const char *version, int stream_size); - int (WINAPI* zlib_inflate) (z_streamp strm, int flush); - int (WINAPI* zlib_inflateEnd) (z_streamp strm); - - int (WINAPI* zlib_deflateInit_) (z_streamp strm, int level, const char *version, int stream_size); - int (WINAPI* zlib_deflate) (z_streamp strm, int flush); - int (WINAPI* zlib_deflateEnd) (z_streamp strm); + #ifdef LOCALZLIB + #include "../lib/zlib/zlib.h" + #define zlib_inflateInit inflateInit + #define zlib_inflate inflate + #define zlib_inflateEnd inflateEnd + #define zlib_deflateInit deflateInit + #define zlib_deflate deflate + #define zlib_deflateEnd deflateEnd + #else + #include + #include "../lib/zlib_win32.h" + HINSTANCE zlib_dll; + #define zlib_inflateInit(strm) zlib_inflateInit_((strm),ZLIB_VERSION, sizeof(z_stream)) + #define zlib_deflateInit(strm, level) zlib_deflateInit_((strm),(level),ZLIB_VERSION,sizeof(z_stream)) + + int (WINAPI* zlib_inflateInit_) (z_streamp strm, const char *version, int stream_size); + int (WINAPI* zlib_inflate) (z_streamp strm, int flush); + int (WINAPI* zlib_inflateEnd) (z_streamp strm); + + int (WINAPI* zlib_deflateInit_) (z_streamp strm, int level, const char *version, int stream_size); + int (WINAPI* zlib_deflate) (z_streamp strm, int flush); + int (WINAPI* zlib_deflateEnd) (z_streamp strm); + #endif #else - #include + #ifdef LOCALZLIB + #include "zlib/zlib.h" + #else + #include + #endif + #define zlib_inflateInit inflateInit #define zlib_inflate inflate #define zlib_inflateEnd inflateEnd @@ -966,6 +981,16 @@ void grfio_final(void) } gentry_table = NULL; gentry_entrys = gentry_maxentry = 0; + +#ifdef _WIN32 + #ifndef LOCALZLIB + FreeLibrary(zlib_dll); + zlib_inflateInit_ = NULL; + zlib_inflate = NULL; + zlib_inflateEnd = NULL; + #endif +#endif + } /*========================================== @@ -979,6 +1004,7 @@ void grfio_init(char *fname) int result = 0, result2 = 0, result3 = 0, result4 = 0; #ifdef _WIN32 + #ifndef LOCALZLIB if(!zlib_dll) { zlib_dll = LoadLibrary("zlib.dll"); (FARPROC)zlib_inflateInit_ = GetProcAddress(zlib_dll,"inflateInit_"); @@ -992,6 +1018,7 @@ void grfio_init(char *fname) exit(1); } } + #endif #endif data_conf = fopen(fname, "r"); diff --git a/src/common/malloc.c b/src/common/malloc.c index 089a9db18..40c9f34bf 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -3,14 +3,25 @@ #include #include "malloc.h" -#if !defined(DMALLOC) && !defined(GCOLLECT) && !defined(BCHECK) +#ifdef MEMWATCH +#include "memwatch.h" +#endif + +// 独自メモリマネージャを使用する場合、次のコメントを外してください。 +// #define USE_MEMMGR + +#if !defined(DMALLOC) && !defined(GCOLLECT) && !defined(BCHECK) && !defined(USE_MEMMGR) void* aMalloc_( size_t size, const char *file, int line, const char *func ) { void *ret; // printf("%s:%d: in func %s: malloc %d\n",file,line,func,size); +#ifdef MEMWATCH + ret=mwMalloc(size,file,line); +#else ret=malloc(size); +#endif if(ret==NULL){ printf("%s:%d: in func %s: malloc error out of memory!\n",file,line,func); exit(1); @@ -23,7 +34,11 @@ void* aCalloc_( size_t num, size_t size, const char *file, int line, const char void *ret; // printf("%s:%d: in func %s: calloc %d %d\n",file,line,func,num,size); +#ifdef MEMWATCH + ret=mwCalloc(num,size,file,line); +#else ret=calloc(num,size); +#endif if(ret==NULL){ printf("%s:%d: in func %s: calloc error out of memory!\n",file,line,func); exit(1); @@ -37,7 +52,11 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f void *ret; // printf("%s:%d: in func %s: realloc %p %d\n",file,line,func,p,size); +#ifdef MEMWATCH + ret=mwRealloc(p,size,file,line); +#else ret=realloc(p,size); +#endif if(ret==NULL){ printf("%s:%d: in func %s: realloc error out of memory!\n",file,line,func); exit(1); @@ -46,10 +65,39 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f return ret; } +void* aStrdup_( const void *p, const char *file, int line, const char *func ) +{ + void *ret; + + // printf("%s:%d: in func %s: strdup %p\n",file,line,func,p); +#ifdef MEMWATCH + ret=mwStrdup(p,file,line); +#else + ret=strdup(p); +#endif + if(ret==NULL){ + printf("%s:%d: in func %s: strdup error out of memory!\n",file,line,func); + exit(1); + + } + return ret; +} + +void aFree_( void *p, const char *file, int line, const char *func ) +{ + // printf("%s:%d: in func %s: free %p\n",file,line,func,p); +#ifdef MEMWATCH + mwFree(p,file,line); +#else + free(p); #endif +} +int do_init_memmgr(const char* file) { + return 0; +} -#if defined(GCOLLECT) +#elif defined(GCOLLECT) void * _bcallocA(size_t size, size_t cnt) { void *ret = aMallocA(size * cnt); @@ -62,7 +110,6 @@ void * _bcalloc(size_t size, size_t cnt) { memset(ret, 0, size * cnt); return ret; } -#endif char * _bstrdup(const char *chr) { int len = strlen(chr); @@ -70,3 +117,434 @@ char * _bstrdup(const char *chr) { strcpy(ret, chr); return ret; } + +#elif defined(USE_MEMMGR) + +/* USE_MEMMGR */ + +/* + * メモリマネージャ + * malloc , free の処理を効率的に出来るようにしたもの。 + * 複雑な処理を行っているので、若干重くなるかもしれません。 + * + * データ構造など(説明下手ですいません^^; ) + * ・メモリを複数の「ブロック」に分けて、さらにブロックを複数の「ユニット」 + * に分けています。ユニットのサイズは、1ブロックの容量を複数個に均等配分 + * したものです。たとえば、1ユニット32KBの場合、ブロック1つは32Byteのユ + * ニットが、1024個集まって出来ていたり、64Byteのユニットが 512個集まって + * 出来ていたりします。(padding,unit_head を除く) + * + * ・ユニット同士はリンクリスト(block_prev,block_next) でつながり、同じサイ + * ズを持つユニット同士もリンクリスト(samesize_prev,samesize_nect) でつな + * がっています。それにより、不要となったメモリの再利用が効率的に行えます。 + */ + +/* ブロックに入るデータ量 */ +#define BLOCK_DATA_SIZE 80*1024 + +/* 一度に確保するブロックの数。 */ +#define BLOCK_ALLOC 32 + +/* ブロックのアライメント */ +#define BLOCK_ALIGNMENT 64 + +/* ブロック */ +struct block { + int block_no; /* ブロック番号 */ + struct block* block_prev; /* 前に確保した領域 */ + struct block* block_next; /* 次に確保した領域 */ + int samesize_no; /* 同じサイズの番号 */ + struct block* samesize_prev; /* 同じサイズの前の領域 */ + struct block* samesize_next; /* 同じサイズの次の領域 */ + int unit_size; /* ユニットのバイト数 0=未使用 */ + int unit_hash; /* ユニットのハッシュ */ + int unit_count; /* ユニットの数 */ + int unit_used; /* 使用済みユニット */ + char data[BLOCK_DATA_SIZE]; +}; + +struct unit_head { + struct block* block; + int size; + const char* file; + int line; +}; + +static struct block* block_first = NULL; +static struct block* block_last = NULL; +static struct block* block_unused = NULL; + +/* ユニットへのハッシュ。80KB/64Byte = 1280個 */ +static struct block* unit_first[BLOCK_DATA_SIZE/BLOCK_ALIGNMENT]; /* 最初 */ +static struct block* unit_unfill[BLOCK_DATA_SIZE/BLOCK_ALIGNMENT]; /* 埋まってない */ +static struct block* unit_last[BLOCK_DATA_SIZE/BLOCK_ALIGNMENT]; /* 最後 */ + +/* メモリを使い回せない領域用のデータ */ +struct unit_head_large { + struct unit_head_large* prev; + struct unit_head_large* next; + struct unit_head unit_head; +}; +static struct unit_head_large *unit_head_large_first = NULL; + +static struct block* block_malloc(void); +static void block_free(struct block* p); +static void memmgr_info(void); + +void* aMalloc_(size_t size, const char *file, int line, const char *func ) { + int i; + struct block *block; + int size_hash = (size+BLOCK_ALIGNMENT-1) / BLOCK_ALIGNMENT; + size = size_hash * BLOCK_ALIGNMENT; /* アライメントの倍数に切り上げ */ + + if(size == 0) { + return NULL; + } + + /* ブロック長を超える領域の確保には、malloc() を用いる */ + /* その際、unit_head.block に NULL を代入して区別する */ + if(size > BLOCK_DATA_SIZE - sizeof(struct unit_head)) { +#ifdef MEMWATCH + struct unit_head_large* p = (struct unit_head_large*)mwMalloc(sizeof(struct unit_head_large) + size,file,line); +#else + struct unit_head_large* p = (struct unit_head_large*)malloc(sizeof(struct unit_head_large) + size); +#endif + if(p != NULL) { + p->unit_head.block = NULL; + p->unit_head.size = size; + p->unit_head.file = file; + p->unit_head.line = line; + if(unit_head_large_first == NULL) { + unit_head_large_first = p; + p->next = NULL; + p->prev = NULL; + } else { + unit_head_large_first->prev = p; + p->prev = NULL; + p->next = unit_head_large_first; + unit_head_large_first = p; + } + return (char *)p + sizeof(struct unit_head_large); + } else { + printf("MEMMGR::memmgr_alloc failed.\n"); + exit(1); + } + } + + /* 同一サイズのブロックが確保されていない時、新たに確保する */ + if(unit_unfill[size_hash] == NULL) { + block = block_malloc(); + if(unit_first[size_hash] == NULL) { + /* 初回確保 */ + unit_first[size_hash] = block; + unit_last[size_hash] = block; + block->samesize_no = 0; + block->samesize_prev = NULL; + block->samesize_next = NULL; + } else { + /* 連結作業 */ + unit_last[size_hash]->samesize_next = block; + block->samesize_no = unit_last[size_hash]->samesize_no + 1; + block->samesize_prev = unit_last[size_hash]; + block->samesize_next = NULL; + unit_last[size_hash] = block; + } + unit_unfill[size_hash] = block; + block->unit_size = size + sizeof(struct unit_head); + block->unit_count = BLOCK_DATA_SIZE / block->unit_size; + block->unit_used = 0; + block->unit_hash = size_hash; + /* 未使用Flagを立てる */ + for(i=0;iunit_count;i++) { + ((struct unit_head*)(&block->data[block->unit_size * i]))->block = NULL; + } + } + /* ユニット使用個数加算 */ + block = unit_unfill[size_hash]; + block->unit_used++; + + /* ユニット内を全て使い果たした */ + if(block->unit_count == block->unit_used) { + do { + unit_unfill[size_hash] = unit_unfill[size_hash]->samesize_next; + } while( + unit_unfill[size_hash] != NULL && + unit_unfill[size_hash]->unit_count == unit_unfill[size_hash]->unit_used + ); + } + + /* ブロックの中の空きユニット捜索 */ + for(i=0;iunit_count;i++) { + struct unit_head *head = (struct unit_head*)(&block->data[block->unit_size * i]); + if(head->block == NULL) { + head->block = block; + head->size = size; + head->line = line; + head->file = file; + return (char *)head + sizeof(struct unit_head); + } + } + // ここに来てはいけない。 + printf("MEMMGR::memmgr_malloc() serious error.\n"); + memmgr_info(); + exit(1); + return NULL; +}; + +void* aCalloc_(size_t num, size_t size, const char *file, int line, const char *func ) { + void *p = aMalloc_(num * size,file,line,func); + memset(p,0,num * size); + return p; +} + +void* aRealloc_(void *memblock, size_t size, const char *file, int line, const char *func ) { + size_t old_size; + if(memblock == NULL) { + return aMalloc_(size,file,line,func); + } + + old_size = ((struct unit_head *)((char *)memblock - sizeof(struct unit_head)))->size; + if(old_size > size) { + // サイズ縮小 -> そのまま返す(手抜き) + return memblock; + } else { + // サイズ拡大 + void *p = aMalloc_(size,file,line,func); + if(p != NULL) { + memcpy(p,memblock,old_size); + } + aFree_(memblock,file,line,func); + return p; + } +} + +void* aStrdup_(const void* string, const char *file, int line, const char *func ) { + if(string == NULL) { + return NULL; + } else { + int len = strlen(string); + char *p = (char *)aMalloc_(len + 1,file,line,func); + memcpy(p,string,len+1); + return p; + } +} + +void aFree_(void *ptr, const char *file, int line, const char *func ) { + struct unit_head *head = (struct unit_head *)((char *)ptr - sizeof(struct unit_head)); + if(ptr == NULL) { + return; + } else if(head->block == NULL && head->size > BLOCK_DATA_SIZE - sizeof(struct unit_head)) { + /* malloc() で直に確保された領域 */ + struct unit_head_large *head_large = (struct unit_head_large *)((char *)ptr - sizeof(struct unit_head_large)); + if(head_large->prev) { + head_large->prev->next = head_large->next; + } else { + unit_head_large_first = head_large->next; + } + if(head_large->next) { + head_large->next->prev = head_large->prev; + } + free(head_large); + return; + } else { + /* ユニット解放 */ + struct block *block = head->block; + if(head->block == NULL) { + printf("memmgr: args of aFree is freed pointer %s line %d\n",file,line); + } else { + head->block = NULL; + if(--block->unit_used == 0) { + /* ブロックの解放 */ + if(unit_unfill[block->unit_hash] == block) { + /* 空きユニットに指定されている */ + do { + unit_unfill[block->unit_hash] = unit_unfill[block->unit_hash]->samesize_next; + } while( + unit_unfill[block->unit_hash] != NULL && + unit_unfill[block->unit_hash]->unit_count == unit_unfill[block->unit_hash]->unit_used + ); + } + if(block->samesize_prev == NULL && block->samesize_next == NULL) { + /* 独立ブロックの解放 */ + unit_first[block->unit_hash] = NULL; + unit_last[block->unit_hash] = NULL; + unit_unfill[block->unit_hash] = NULL; + } else if(block->samesize_prev == NULL) { + /* 先頭ブロックの解放 */ + unit_first[block->unit_hash] = block->samesize_next; + (block->samesize_next)->samesize_prev = NULL; + } else if(block->samesize_next == NULL) { + /* 末端ブロックの解放 */ + unit_last[block->unit_hash] = block->samesize_prev; + (block->samesize_prev)->samesize_next = NULL; + } else { + /* 中間ブロックの解放 */ + (block->samesize_next)->samesize_prev = block->samesize_prev; + (block->samesize_prev)->samesize_next = block->samesize_next; + } + block_free(block); + } else { + /* 空きユニットの再設定 */ + if( + unit_unfill[block->unit_hash] == NULL || + unit_unfill[block->unit_hash]->samesize_no > block->samesize_no + ) { + unit_unfill[block->unit_hash] = block; + } + } + } + } +} + +/* 現在の状況を表示する */ +static void memmgr_info(void) { + int i; + struct block *p; + printf("** Memory Maneger Information **\n"); + if(block_first == NULL) { + printf("Uninitialized.\n"); + return; + } + printf( + "Blocks: %04u , BlockSize: %06u Byte , Used: %08uKB\n", + block_last->block_no+1,sizeof(struct block), + (block_last->block_no+1) * sizeof(struct block) / 1024 + ); + p = block_first; + for(i=0;i<=block_last->block_no;i++) { + printf(" Block #%04u : ",p->block_no); + if(p->unit_size == 0) { + printf("unused.\n"); + } else { + printf( + "size: %05u byte. used: %04u/%04u prev:", + p->unit_size - sizeof(struct unit_head),p->unit_used,p->unit_count + ); + if(p->samesize_prev == NULL) { + printf("NULL"); + } else { + printf("%04u",(p->samesize_prev)->block_no); + } + printf(" next:"); + if(p->samesize_next == NULL) { + printf("NULL"); + } else { + printf("%04u",(p->samesize_next)->block_no); + } + printf("\n"); + } + p = p->block_next; + } +} + +/* ブロックを確保する */ +static struct block* block_malloc(void) { + if(block_unused != NULL) { + /* ブロック用の領域は確保済み */ + struct block* ret = block_unused; + do { + block_unused = block_unused->block_next; + } while(block_unused != NULL && block_unused->unit_size != 0); + return ret; + } else { + /* ブロック用の領域を新たに確保する */ + int i; + int block_no; + struct block* p = (struct block *)calloc(sizeof(struct block),BLOCK_ALLOC); + if(p == NULL) { + printf("MEMMGR::block_alloc failed.\n"); + exit(1); + } + if(block_first == NULL) { + /* 初回確保 */ + block_no = 0; + block_first = p; + } else { + block_no = block_last->block_no + 1; + block_last->block_next = p; + p->block_prev = block_last; + } + block_last = &p[BLOCK_ALLOC - 1]; + /* ブロックを連結させる */ + for(i=0;iunit_size = 1; + return p; + } +} + +static void block_free(struct block* p) { + /* free() せずに、未使用フラグを付けるだけ */ + p->unit_size = 0; + /* 未使用ポインターを更新する */ + if(block_unused == NULL) { + block_unused = p; + } else if(block_unused->block_no > p->block_no) { + block_unused = p; + } +} + +static char memmer_logfile[128]; + +static FILE* memmgr_log(void) { + FILE *fp = fopen(memmer_logfile,"w"); + if(!fp) { fp = stdout; } + fprintf(fp,"memmgr: memory leaks found\n"); + return fp; +} + +static void memmer_exit(void) { + FILE *fp = NULL; + int i; + int count = 0; + struct block *block = block_first; + struct unit_head_large *large = unit_head_large_first; + while(block) { + if(block->unit_size) { + if(!fp) { fp = memmgr_log(); } + for(i=0;iunit_count;i++) { + struct unit_head *head = (struct unit_head*)(&block->data[block->unit_size * i]); + if(head->block != NULL) { + fprintf( + fp,"%04d : %s line %d size %d\n",++count, + head->file,head->line,head->size + ); + } + } + } + block = block->block_next; + } + while(large) { + if(!fp) { fp = memmgr_log(); } + fprintf( + fp,"%04d : %s line %d size %d\n",++count, + large->unit_head.file, + large->unit_head.line,large->unit_head.size + ); + large = large->next; + } + if(!fp) { + printf("memmgr: no memory leaks found.\n"); + } else { + printf("memmgr: memory leaks found.\n"); + } +} + +int do_init_memmgr(const char* file) { + sprintf(memmer_logfile,"%s.log",file); + atexit(memmer_exit); + printf("memmgr: initialised: %s\n",memmer_logfile); + return 0; +} + +#endif diff --git a/src/common/malloc.h b/src/common/malloc.h index d90665487..45451c9e0 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -59,15 +59,19 @@ void* aMalloc_( size_t size, const char *file, int line, const char *func ); void* aCalloc_( size_t num, size_t size, const char *file, int line, const char *func ); void* aRealloc_( void *p, size_t size, const char *file, int line, const char *func ); + void aFree_( void *p, const char *file, int line, const char *func ); + void* aStrdup_( const void *p, const char *file, int line, const char *func ); # define aMalloc(n) aMalloc_(n,ALC_MARK) # define aMallocA(n) aMalloc_(n,ALC_MARK) # define aCalloc(m,n) aCalloc_(m,n,ALC_MARK) # define aCallocA(m,n) aCalloc_(m,n,ALC_MARK) # define aRealloc(p,n) aRealloc_(p,n,ALC_MARK) -# define aFree(ptr) free(ptr) -# define aStrdup(ptr) strdup(ptr) +# define aStrdup(p) aStrdup_(p,ALC_MARK) +# define aFree(p) do { aFree_(p,ALC_MARK); if(p != NULL) { p = NULL; } } while(0) #endif +int do_init_memmgr(const char* file); + #endif diff --git a/src/ladmin/Makefile b/src/ladmin/Makefile index ebe67a349..20722350b 100644 --- a/src/ladmin/Makefile +++ b/src/ladmin/Makefile @@ -2,7 +2,7 @@ all: ladmin txt: ladmin sql: ladmin -COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h ladmin: ladmin.o md5calc.o $(COMMON_OBJ) diff --git a/src/login/Makefile b/src/login/Makefile index 482503969..01810b1d1 100644 --- a/src/login/Makefile +++ b/src/login/Makefile @@ -1,7 +1,7 @@ all: login-server txt: login-server -COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o ../common/obj/db.o ../common/obj/lock.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/lock.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h login-server: login.o md5calc.o $(COMMON_OBJ) diff --git a/src/login_sql/Makefile b/src/login_sql/Makefile index 18b023fe6..20b01c66d 100644 --- a/src/login_sql/Makefile +++ b/src/login_sql/Makefile @@ -2,7 +2,7 @@ all: login-server_sql sql: login-server_sql shared_libs=all -COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/db.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h login-server_sql: login.o md5calc.o $(COMMON_OBJ) diff --git a/src/map/Makefile b/src/map/Makefile index 884e8b902..b413c8a62 100644 --- a/src/map/Makefile +++ b/src/map/Makefile @@ -10,7 +10,9 @@ txtobj: sqlobj: mkdir sqlobj -COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o ../common/utils.o ../common/strlib.o +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o ../common/obj/grfio.o ../common/obj/db.o ../common/obj/lock.o ../common/obj/nullpo.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o ../common/obj/strlib.o + +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/grfio.h ../common/db.h ../common/lock.h ../common/nullpo.h ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h LIBS = -lz -lm 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) @@ -25,56 +27,56 @@ txtobj/%.o: %.c sqlobj/%.o: %.c $(COMPILE.c) $(OUTPUT_OPTION) $< -txtobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h ../common/core.h ../common/timer.h ../common/db.h ../common/grfio.h ../common/mmo.h ../common/showmsg.h -txtobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/showmsg.h -txtobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/showmsg.h -txtobj/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 -txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h ../common/timer.h ../common/socket.h ../common/mmo.h ../common/showmsg.h -txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h -txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h -txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h -txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h ../common/mmo.h ../common/showmsg.h -txtobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h ../common/mmo.h ../common/showmsg.h -txtobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -txtobj/log.o: log.c log.h map.h ../common/nullpo.h -txtobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h +txtobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h $(COMMON_H) +txtobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) +txtobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h $(COMMON_H) +txtobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h $(COMMON_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_H) +txtobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_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_H) +txtobj/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) +txtobj/path.o: path.c map.h battle.h $(COMMON_H) +txtobj/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) +txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h $(COMMON_H) +txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h $(COMMON_H) +txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) +txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h $(COMMON_H) +txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) +txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) +txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) +txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h $(COMMON_H) +txtobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) +txtobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h $(COMMON_H) +txtobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h $(COMMON_H) +txtobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) +txtobj/log.o: log.c log.h map.h $(COMMON_H) +txtobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -sqlobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h log.h ../common/core.h ../common/timer.h ../common/db.h ../common/grfio.h ../common/mmo.h ../common/showmsg.h -sqlobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/version.h ../common/showmsg.h -sqlobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h log.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/showmsg.h -sqlobj/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 -sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h log.h ../common/timer.h ../common/socket.h ../common/mmo.h ../common/showmsg.h -sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h -sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h -sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h -sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h ../common/mmo.h ../common/showmsg.h -sqlobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h ../common/mmo.h ../common/showmsg.h -sqlobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h ../common/db.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h -sqlobj/mail.o: mail.c mail.h ../common/showmsg.h ../common/strlib.h ../common/utils.h -sqlobj/log.o: log.c log.h map.h ../common/nullpo.h -sqlobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h +sqlobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h log.h $(COMMON_H) +sqlobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) +sqlobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h $(COMMON_H) +sqlobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h log.h $(COMMON_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_H) +sqlobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_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_H) +sqlobj/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) +sqlobj/path.o: path.c map.h battle.h $(COMMON_H) +sqlobj/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) +sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h log.h $(COMMON_H) +sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h $(COMMON_H) +sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) +sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h $(COMMON_H) +sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) +sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) +sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) +sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h $(COMMON_H) +sqlobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) +sqlobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h $(COMMON_H) +sqlobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h $(COMMON_H) +sqlobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) +sqlobj/mail.o: mail.c mail.h $(COMMON_H) +sqlobj/log.o: log.c log.h map.h $(COMMON_H) +sqlobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) clean: rm -rf *.o ../../map-server ../../map-server_sql sqlobj txtobj diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 12e6c2306..3169c75ab 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9,6 +9,7 @@ #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/mmo.h" +#include "../common/db.h" #include "log.h" #include "clif.h" @@ -210,6 +211,8 @@ ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw ACMD_FUNC(misceffect); // by MC Cameri ACMD_FUNC(mobsearch); ACMD_FUNC(cleanmap); +ACMD_FUNC(npctalk); +ACMD_FUNC(pettalk); ACMD_FUNC(autoloot); // by Upa-Kun #ifndef TXT_ONLY @@ -484,6 +487,8 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri { AtCommand_MobSearch, "@mobsearch", 0, atcommand_mobsearch }, { AtCommand_CleanMap, "@cleanmap", 0, atcommand_cleanmap }, + { AtCommand_NpcTalk, "@npctalk", 0, atcommand_npctalk }, + { AtCommand_PetTalk, "@pettalk", 0, atcommand_pettalk }, #ifndef TXT_ONLY // sql-only commands { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris] @@ -1743,8 +1748,8 @@ int atcommand_whozeny( clif_displaymessage(fd, output); } - free(zeny); - free(counted); + aFree(zeny); + aFree(counted); return 0; } @@ -7789,6 +7794,49 @@ atcommand_cleanmap( return 0; } +/*========================================== + * NPC/PETに話させる + *------------------------------------------ + */ +int +atcommand_npctalk( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char name[100],mes[100]; + struct npc_data *nd; + + if (sscanf(message, "%s %99[^\n]", name, mes) < 2) + return -1; + + if (!(nd = npc_name2id(name))) + return -1; + + clif_message(&nd->bl, mes); + return 0; +} +int +atcommand_pettalk( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char mes[100],temp[100]; + struct pet_data *pd; + + nullpo_retr(-1, sd); + + if(!sd->status.pet_id || !(pd=sd->pd)) + return -1; + + if (sscanf(message, "%99[^\n]", mes) < 1) + return -1; + + snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes); + clif_message(&pd->bl, temp); + + return 0; +} + /*========================================== * *------------------------------------------ diff --git a/src/map/atcommand.h b/src/map/atcommand.h index cb260db19..ea6849476 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -196,6 +196,8 @@ enum AtCommandType { AtCommand_MiscEffect, // by MC Cameri AtCommand_MobSearch, AtCommand_CleanMap, + AtCommand_NpcTalk, + AtCommand_PetTalk, // SQL-only commands start #ifndef TXT_ONLY diff --git a/src/map/battle.c b/src/map/battle.c index 707362f7f..605fd30e0 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -59,15 +59,17 @@ int battle_counttargeted(struct block_list *bl,struct block_list *src,int target // ダメージの遅延 struct battle_delay_damage_ { - struct block_list *src,*target; + struct block_list *src; + int target; int damage; int flag; }; int battle_delay_damage_sub(int tid,unsigned int tick,int id,int data) { struct battle_delay_damage_ *dat=(struct battle_delay_damage_ *)data; - if( dat && map_id2bl(id)==dat->src && dat->target->prev!=NULL) - battle_damage(dat->src,dat->target,dat->damage,dat->flag); + struct block_list *target=map_id2bl(dat->target); + if( dat && map_id2bl(id)==dat->src && target && target->prev!=NULL) + battle_damage(dat->src,target,dat->damage,dat->flag); aFree(dat); return 0; } @@ -80,7 +82,7 @@ int battle_delay_damage(unsigned int tick,struct block_list *src,struct block_li dat->src=src; - dat->target=target; + dat->target=target->id; dat->damage=damage; dat->flag=flag; add_timer(tick,battle_delay_damage_sub,src->id,(int)dat); @@ -256,7 +258,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i flag&BF_SHORT && skill_num != NPC_GUIDEDATTACK) { // セーフティウォール struct skill_unit *unit; - unit = map_find_skill_unit_oncell(bl->m,bl->x,bl->y,MG_SAFETYWALL); + unit = (struct skill_unit *)sc_data[SC_SAFETYWALL].val2; if (unit) { if (unit->group && (--unit->group->val2)<=0) skill_delunit(unit); @@ -3501,7 +3503,7 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target, if(sd && sd->splash_range > 0 && (wd.damage > 0 || wd.damage2 > 0) ) skill_castend_damage_id(src,target,0,-1,tick,0); map_freeblock_lock(); - battle_damage(src,target,(wd.damage+wd.damage2),0); + battle_delay_damage(tick+wd.amotion,src,target,(wd.damage+wd.damage2),0); if(target->prev != NULL && (target->type != BL_PC || (target->type == BL_PC && !pc_isdead((struct map_session_data *)target) ) ) ) { if(wd.damage > 0 || wd.damage2 > 0) { @@ -3652,7 +3654,7 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target, } if(rdamage > 0) - battle_damage(target,src,rdamage,0); + battle_delay_damage(tick+wd.amotion,src,target,rdamage,0); if(t_sc_data && t_sc_data[SC_AUTOCOUNTER].timer != -1 && t_sc_data[SC_AUTOCOUNTER].val4 > 0) { if(t_sc_data[SC_AUTOCOUNTER].val3 == src->id) battle_weapon_attack(target,src,tick,0x8000|t_sc_data[SC_AUTOCOUNTER].val1); diff --git a/src/map/chrif.c b/src/map/chrif.c index a04c483d5..bbc6a51e5 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1011,6 +1011,8 @@ int chrif_disconnect(int fd) { ShowWarning(tmp_output); clif_foreachclient(chrif_disconnect_sub); chrif_connected = 0; + // 他のmap 鯖のデータを消す + map_eraseallipport(); } close(fd); return 0; @@ -1146,6 +1148,15 @@ int check_connect_char_server(int tid, unsigned int tick, int id, int data) { if (chrif_isconnect()) displayed = 0; return 0; } +/*========================================== + * 終了 + *------------------------------------------ + */ +int do_final_chrif(void) +{ + delete_session(char_fd); + return 0; +} /*========================================== * diff --git a/src/map/chrif.h b/src/map/chrif.h index 7f55d23d6..03ff83f6a 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -31,6 +31,7 @@ int chrif_changesex(int id, int sex); int chrif_chardisconnect(struct map_session_data *sd); int check_connect_char_server(int tid, unsigned int tick, int id, int data); +int do_final_chrif(void); int do_init_chrif(void); int chrif_flush_fifo(void); diff --git a/src/map/guild.c b/src/map/guild.c index d0d7f14dd..ea9c3795f 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -477,8 +477,11 @@ int guild_recv_info(struct guild *sg) // イベントの発生 if( (ev=numdb_search(guild_infoevent_db,sg->guild_id))!=NULL ){ numdb_erase(guild_infoevent_db,sg->guild_id); - for(;ev;ev2=ev->next,aFree(ev),ev=ev2){ + while(ev){ npc_event_do(ev->name); + ev2=ev->next; + aFree(ev); + ev=ev2; } } @@ -1400,8 +1403,11 @@ int guild_castledataloadack(int castle_id,int index,int value) } if( (ev=numdb_search(guild_castleinfoevent_db,code))!=NULL ){ numdb_erase(guild_castleinfoevent_db,code); - for(;ev;ev2=ev->next,aFree(ev),ev=ev2){ + while(ev){ npc_event_do(ev->name); + ev2=ev->next; + aFree(ev); + ev=ev2; } } return 1; diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 41e2e2a75..82149946d 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -379,8 +379,10 @@ static int itemdb_readdb(void) 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]); - ShowStatus(tmp_output); + if (ln > 0) { + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,filename[i]); + ShowStatus(tmp_output); + } ln=0; // reset to 0 } return 0; @@ -456,8 +458,10 @@ static int itemdb_read_randomitem() ln++; } fclose(fp); - sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",*pc,fn); - ShowStatus(tmp_output); + if (*pc > 0) { + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",*pc,fn); + ShowStatus(tmp_output); + } } return 0; @@ -699,8 +703,10 @@ static int itemdb_read_noequip(void) } fclose(fp); - sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"db/item_noequip.txt"); - ShowStatus(tmp_output); + if (ln > 0) { + sprintf(tmp_output,"Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"db/item_noequip.txt"); + ShowStatus(tmp_output); + } return 0; } diff --git a/src/map/map.c b/src/map/map.c index ee597789c..d402ac06c 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -403,12 +403,13 @@ int map_count_oncell(int m, int x, int y) { /* * ォサォ・セェホフェヒフクェトェアェソォケォュォ・讚ヒォテォネェレェケ */ -struct skill_unit *map_find_skill_unit_oncell(int m,int x,int y,int skill_id) +struct skill_unit *map_find_skill_unit_oncell(struct block_list *target,int x,int y,int skill_id,struct skill_unit *out_unit) { - int bx,by; + int m,bx,by; struct block_list *bl; int i,c; struct skill_unit *unit; + m = target->m; if (x < 0 || y < 0 || (x >= map[m].xs) || (y >= map[m].ys)) return NULL; @@ -421,7 +422,10 @@ struct skill_unit *map_find_skill_unit_oncell(int m,int x,int y,int skill_id) if (bl->x != x || bl->y != y || bl->type != BL_SKILL) continue; unit = (struct skill_unit *) bl; - if (unit->alive && unit->group->skill_id == skill_id) + if (unit==out_unit || !unit->alive || + !unit->group || unit->group->skill_id!=skill_id) + continue; + if (battle_check_target(&unit->bl,target,unit->group->target_flag)>0) return unit; } return NULL; @@ -1622,7 +1626,7 @@ struct map_session_data * map_nick2sd(char *nick) { struct block_list * map_id2bl(int id) { struct block_list *bl=NULL; - if(id= 0 && id < sizeof(objects)/sizeof(objects[0])) bl = objects[id]; else bl = (struct block_list*)numdb_search(id_db,id); @@ -1826,7 +1830,7 @@ int map_getcell(int m,int x,int y,cell_t cellchk) int map_getcellp(struct map_data* m,int x,int y,cell_t cellchk) { - int j; + int type; nullpo_ret(m); if(x<0 || x>=m->xs-1 || y<0 || y>=m->ys-1) @@ -1834,24 +1838,28 @@ int map_getcellp(struct map_data* m,int x,int y,cell_t cellchk) if(cellchk==CELL_CHKNOPASS) return 1; return 0; } - j=x+y*m->xs; + type = m->gat[x+y*m->xs]; + if (cellchk<0x10) + type &= CELL_MASK; switch(cellchk) { case CELL_CHKPASS: - return (m->gat[j] != 1 && m->gat[j] != 5); + return (type!=1 && type!=5); case CELL_CHKNOPASS: - return (m->gat[j] == 1 || m->gat[j] == 5); + return (type==1 || type==5); case CELL_CHKWALL: - return (m->gat[j] == 1); - case CELL_CHKNPC: - return (m->gat[j]&0x80); + return (type==1); case CELL_CHKWATER: - return (m->gat[j] == 3); + return (type==3); case CELL_CHKGROUND: - return (m->gat[j] == 5); + return (type==5); case CELL_GETTYPE: - return m->gat[j]; + return type; + case CELL_CHKNPC: + return (type&CELL_NPC); + case CELL_CHKBASILICA: + return (type&CELL_BASILICA); default: return 0; } @@ -1868,10 +1876,20 @@ void map_setcell(int m,int x,int y,int cell) return; j=x+y*map[m].xs; - if (cell == CELL_SETNPC) - map[m].gat[j] |= 0x80; - else - map[m].gat[j] = cell; + switch (cell) { + case CELL_SETNPC: + map[m].gat[j] |= CELL_NPC; + break; + case CELL_SETBASILICA: + map[m].gat[j] |= CELL_BASILICA; + break; + case CELL_CLRBASILICA: + map[m].gat[j] &= ~CELL_BASILICA; + break; + default: + map[m].gat[j] = (map[m].gat[j]&~CELL_MASK) + cell; + break; + } } /*========================================== @@ -1889,15 +1907,39 @@ int map_setipport(char *name,unsigned long ip,int port) { mdos->gat = NULL; mdos->ip = ip; mdos->port = port; + mdos->map = NULL; strdb_insert(map_db,mdos->name,mdos); + } else if(md->gat){ + if(ip!=clif_getip() || port!=clif_getport()){ + // 読み込んでいたけど、担当外になったマップ + mdos=(struct map_data_other_server *)aCalloc(1,sizeof(struct map_data_other_server)); + memcpy(mdos->name,name,24); + mdos->gat = NULL; + mdos->ip = ip; + mdos->port = port; + mdos->map = md; + strdb_insert(map_db,mdos->name,mdos); + // printf("from char server : %s -> %08lx:%d\n",name,ip,port); + } else { + // 読み込んでいて、担当になったマップ(何もしない) + ; + } } else { - if(md->gat){ // local -> check data - if(ip!=clif_getip() || port!=clif_getport()){ - printf("from char server : %s -> %08lx:%d\n",name,ip,port); - return 1; + mdos=(struct map_data_other_server *)md; + if(ip == clif_getip() && port == clif_getport()) { + // 自分の担当になったマップ + if(mdos->map == NULL) { + // 読み込んでいないので終了する + printf("map_setipport : %s is not loaded.\n",name); + exit(1); + } else { + // 読み込んでいるので置き換える + md = mdos->map; + free(mdos); + strdb_insert(map_db,md->name,md); } - } else { // update - mdos=(struct map_data_other_server *)md; + } else { + // 他の鯖の担当マップなので置き換えるだけ mdos->ip = ip; mdos->port = port; } @@ -1905,6 +1947,56 @@ int map_setipport(char *name,unsigned long ip,int port) { return 0; } +/*========================================== + * 他鯖管理のマップを全て削除 + *------------------------------------------ + */ +int map_eraseallipport_sub(void *key,void *data,va_list va) { + struct map_data_other_server *mdos = (struct map_data_other_server*)data; + if(mdos->gat == NULL && mdos->map == NULL) { + strdb_erase(map_db,key); + free(mdos); + } + return 0; +} + +int map_eraseallipport(void) { + strdb_foreach(map_db,map_eraseallipport_sub); + return 1; +} + +/*========================================== + * 他鯖管理のマップをdbから削除 + *------------------------------------------ + */ +int map_eraseipport(char *name,unsigned long ip,int port) +{ + struct map_data *md; + struct map_data_other_server *mdos; +// unsigned char *p=(unsigned char *)&ip; + + md=strdb_search(map_db,name); + if(md){ + if(md->gat) // local -> check data + return 0; + else { + mdos=(struct map_data_other_server *)md; + if(mdos->ip==ip && mdos->port == port) { + if(mdos->map) { + // このマップ鯖でも読み込んでいるので移動できる + return 1; // 呼び出し元で chrif_sendmap() をする + } else { + strdb_erase(map_db,name); + free(mdos); + } +// if(battle_config.etc_log) +// printf("erase map %s %d.%d.%d.%d:%d\n",name,p[0],p[1],p[2],p[3],port); + } + } + } + return 0; +} + // 初期化周り /*========================================== * 水場高さ設定 @@ -2043,7 +2135,7 @@ static void map_cache_close(void) fwrite(map_cache.map,map_cache.head.nmaps,sizeof(struct map_cache_info),map_cache.fp); } fclose(map_cache.fp); - free(map_cache.map); + aFree(map_cache.map); map_cache.fp = NULL; return; } @@ -2085,16 +2177,16 @@ int map_cache_read(struct map_data *m) if(fread(buf,1,size_compress,map_cache.fp) != size_compress) { // なぜかファイル後半が欠けてるので読み直し printf("fread error\n"); - m->xs = 0; m->ys = 0; m->gat = NULL; - free(m->gat); free(buf); + free(m->gat); m->xs = 0; m->ys = 0; m->gat = NULL; + free(buf); return 0; } dest_len = m->xs * m->ys; decode_zip(m->gat,&dest_len,buf,size_compress); if(dest_len != map_cache.map[i].xs * map_cache.map[i].ys) { // 正常に解凍が出来てない - m->xs = 0; m->ys = 0; m->gat = NULL; - free(m->gat); free(buf); + free(m->gat); m->xs = 0; m->ys = 0; m->gat = NULL; + free(buf); return 0; } free(buf); @@ -3069,7 +3161,7 @@ void do_final(void) { strdb_final(nick_db, nick_db_final); numdb_final(charid_db, charid_db_final); - + do_final_chrif(); // この内部でキャラを全て切断する do_final_script(); do_final_itemdb(); do_final_storage(); diff --git a/src/map/map.h b/src/map/map.h index 2963a316e..96cbc9fb3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -20,7 +20,7 @@ #define MAX_STATUSCHANGE 210 #define MAX_SKILLUNITGROUP 32 #define MAX_MOBSKILLUNITGROUP 8 -#define MAX_SKILLUNITGROUPTICKSET 128 +#define MAX_SKILLUNITGROUPTICKSET 32 #define MAX_SKILLTIMERSKILL 32 #define MAX_MOBSKILLTIMERSKILL 10 #define MAX_MOBSKILL 32 @@ -85,13 +85,13 @@ struct skill_unit_group { int src_id; int party_id; int guild_id; - int map,range; + int map; int target_flag; unsigned int tick; int limit,interval; int skill_id,skill_lv; - int val1,val2; + int val1,val2,val3; char *valstr; int unit_id; int group_id; @@ -582,6 +582,7 @@ struct map_data_other_server { unsigned char *gat; // NULL固定にして判断 unsigned long ip; unsigned int port; + struct map_data* map; }; struct flooritem_data { @@ -646,20 +647,29 @@ enum { LOOK_BASE,LOOK_HAIR,LOOK_WEAPON,LOOK_HEAD_BOTTOM,LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HAIR_COLOR,LOOK_CLOTHES_COLOR,LOOK_SHIELD,LOOK_SHOES }; +// CELL +#define CELL_MASK 0x0f +#define CELL_NPC 0x80 // NPCセル +#define CELL_BASILICA 0x40 // BASILICAセル /* - * map_getcell()ェヌ゙ナ鯑ェオェェォユォ鬮ー + * map_getcell()で使用されるフラグ */ typedef enum { - CELL_CHKWALL=1, // ロ(ォサォォソォ、ォラ1) - CELL_CHKWATER=3, // 筰゙(ォサォォソォ、ォラ3) - CELL_CHKGROUND=5, // 「リ。ェレェ(ォサォォソォ、ォラ5) - CELL_CHKNPC=0x80, // ォソォテォチォソォ、ォラェホNPC(ォサォォソォ、ォラ0x80ォユォ鬮ー) - CELL_CHKPASS, // ラホヲハヲメ(ォサォォソォ、ォラ1,5、鞣) - CELL_CHKNOPASS, // ラホヲワハヲ(ォサォォソォ、ォラ1,5) - CELL_GETTYPE // ォサォォソォ、ォラェレェケ + CELL_CHKWALL=0, // 壁(セルタイプ1) + CELL_CHKWATER, // 水場(セルタイプ3) + CELL_CHKGROUND, // 地面障害物(セルタイプ5) + CELL_CHKPASS, // 通過可能(セルタイプ1,5以外) + CELL_CHKNOPASS, // 通過不可(セルタイプ1,5) + CELL_GETTYPE, // セルタイプを返す + CELL_CHKNPC=0x10, // タッチタイプのNPC(セルタイプ0x80フラグ) + CELL_CHKBASILICA, // バジリカ(セルタイプ0x40フラグ) } cell_t; -// map_setcell()ェヌ゙ナ鯑ェオェェォユォ鬮ー -#define CELL_SETNPC 0x80 // ォソォテォチォソォ、ォラェホNPCェォサォテォネ +// map_setcell()で使用されるフラグ +enum { + CELL_SETNPC=0x10, // タッチタイプのNPCをセット + CELL_SETBASILICA, // バジリカをセット + CELL_CLRBASILICA, // バジリカをクリア +}; struct chat_data { struct block_list bl; @@ -718,7 +728,7 @@ void map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int int map_countnearpc(int,int,int); //block関連に追加 int map_count_oncell(int m,int x,int y); -struct skill_unit *map_find_skill_unit_oncell(int m,int x,int y,int skill_id); +struct skill_unit *map_find_skill_unit_oncell(struct block_list *,int x,int y,int skill_id,struct skill_unit *); // 一時的object関連 int map_addobject(struct block_list *); int map_delobject(int); @@ -747,6 +757,7 @@ int map_mapname2mapid(char*); int map_mapname2ipport(char*,int*,int*); int map_setipport(char *name,unsigned long ip,int port); int map_eraseipport(char *name,unsigned long ip,int port); +int map_eraseallipport(void); void map_addiddb(struct block_list *); void map_deliddb(struct block_list *bl); int map_foreachiddb(int (*)(void*,void*,va_list),...); diff --git a/src/map/mob.c b/src/map/mob.c index 74a1c5889..9b2f91da1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -496,10 +496,16 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data) dx = dirx[md->dir]; dy = diry[md->dir]; - if(map_getcell(md->bl.m,x+dx,y+dy,CELL_CHKNOPASS)) { + if (map_getcell(md->bl.m,x+dx,y+dy,CELL_CHKBASILICA) && !(status_get_mode(&md->bl)&0x20)) { + mob_stop_walking(md,1); + return 0; + } + + if (map_getcell(md->bl.m,x+dx,y+dy,CELL_CHKNOPASS)) { mob_walktoxy_sub(md); return 0; } + if (skill_check_basilica (&md->bl,x+dx,y+dy) || skill_check_moonlit (&md->bl,x+dx,y+dy)) { mob_walktoxy_sub(md); @@ -515,18 +521,18 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data) if(md->min_chase>13) md->min_chase--; + skill_unit_move(&md->bl,tick,0); if(moveblock) map_delblock(&md->bl); md->bl.x = x; md->bl.y = y; if(moveblock) map_addblock(&md->bl); + skill_unit_move(&md->bl,tick,1); map_foreachinmovearea(clif_mobinsight,md->bl.m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_PC,md); md->state.state=MS_IDLE; if(md->option&4) skill_check_cloaking(&md->bl); - - skill_unit_move(&md->bl,tick,1); // スキルユニットの検査 } if((i=calc_next_walk_step(md))>0){ i = i>>1; @@ -712,7 +718,7 @@ int mob_changestate(struct mob_data *md,int state,int type) md->last_deadtime=gettick(); // Since it died, all aggressors' attack to this mob is stopped. clif_foreachclient(mob_stopattacked,md->bl.id); - skill_unit_out_all(&md->bl,gettick(),1); + skill_unit_move(&md->bl,gettick(),0); status_change_clear(&md->bl,2); // ステータス異常を解除する skill_clear_unitgroup(&md->bl); // 全てのスキルユニットグループを削除する skill_cleartimerskill(&md->bl); @@ -789,11 +795,21 @@ static int mob_timer(int tid,unsigned int tick,int id,int data) static int mob_walktoxy_sub(struct mob_data *md) { struct walkpath_data wpd; + int x,y; + static int dirx[8]={0,-1,-1,-1,0,1,1,1}; + static int diry[8]={1,1,0,-1,-1,-1,0,1}; nullpo_retr(0, md); if(path_search(&wpd,md->bl.m,md->bl.x,md->bl.y,md->to_x,md->to_y,md->state.walk_easy)) return 1; + x = md->bl.x+dirx[wpd.path[0]]; + y = md->bl.y+diry[wpd.path[0]]; + if (map_getcell(md->bl.m,x,y,CELL_CHKBASILICA) && !(status_get_mode(&md->bl)&0x20)) { + md->state.change_walk_target=0; + return 1; + } + memcpy(&md->walkpath,&wpd,sizeof(wpd)); md->state.change_walk_target=0; @@ -909,7 +925,7 @@ int mob_spawn(int id) md->last_spawntime=tick; if( md->bl.prev!=NULL ){ // clif_clearchar_area(&md->bl,3); - skill_unit_out_all(&md->bl,gettick(),1); +// skill_unit_move(&md->bl,tick,0); map_delblock(&md->bl); } else @@ -939,8 +955,6 @@ int mob_spawn(int id) md->dir=0; md->target_dir=0; - map_addblock(&md->bl); - memset(&md->state,0,sizeof(md->state)); md->attacked_id = 0; md->target_id = 0; @@ -1003,6 +1017,9 @@ int mob_spawn(int id) md->hp = status_get_max_hp(&md->bl); } + map_addblock(&md->bl); + skill_unit_move(&md->bl,tick,1); + clif_spawnmob(md); return 0; @@ -2876,6 +2893,7 @@ int mob_warpslave(struct mob_data *md,int x, int y) int mob_warp(struct mob_data *md,int m,int x,int y,int type) { int i=0,xs=0,ys=0,bx=x,by=y; + int tick = gettick(); nullpo_retr(0, md); @@ -2889,7 +2907,7 @@ int mob_warp(struct mob_data *md,int m,int x,int y,int type) return 0; clif_clearchar_area(&md->bl,type); } - skill_unit_out_all(&md->bl,gettick(),1); + skill_unit_move(&md->bl,tick,0); map_delblock(&md->bl); if(bx>0 && by>0){ // 位置指定の場合周囲9セルを探索 @@ -2928,6 +2946,7 @@ int mob_warp(struct mob_data *md,int m,int x,int y,int type) } map_addblock(&md->bl); + skill_unit_move(&md->bl,tick,1); if(type>0) { clif_spawnmob(md); @@ -3241,59 +3260,16 @@ int mobskill_castend_pos( int tid, unsigned int tick, int id,int data ) return 0; } - if(battle_config.monster_skill_reiteration == 0) { - range = -1; - switch(md->skillid) { - case MG_SAFETYWALL: - case WZ_FIREPILLAR: - case HT_SKIDTRAP: - case HT_LANDMINE: - case HT_ANKLESNARE: - case HT_SHOCKWAVE: - case HT_SANDMAN: - case HT_FLASHER: - case HT_FREEZINGTRAP: - case HT_BLASTMINE: - case HT_CLAYMORETRAP: - case PF_SPIDERWEB: /* スパイダーウェッブ */ - range = 0; - break; - case AL_PNEUMA: - case AL_WARP: - range = 1; - break; - } - if(range >= 0) { - if(skill_check_unit_range(md->bl.m,md->skillx,md->skilly,range,md->skillid) > 0) - return 0; - } - } - if(battle_config.monster_skill_nofootset) { - range = -1; - switch(md->skillid) { - case WZ_FIREPILLAR: - case HT_SKIDTRAP: - case HT_LANDMINE: - case HT_ANKLESNARE: - case HT_SHOCKWAVE: - case HT_SANDMAN: - case HT_FLASHER: - case HT_FREEZINGTRAP: - case HT_BLASTMINE: - case HT_CLAYMORETRAP: - case AM_DEMONSTRATION: - case PF_SPIDERWEB: /* スパイダーウェッブ */ - range = 1; - break; - case AL_WARP: - range = 0; - break; - } - if(range >= 0) { - if(skill_check_unit_range2(md->bl.m,md->skillx,md->skilly,range) > 0) - return 0; - } - } + if (!battle_config.monster_skill_reiteration && + skill_get_unit_flag(md->skillid)&UF_NOREITERATION && + skill_check_unit_range(md->bl.m,md->skillx,md->skilly,md->skillid,md->skilllv)) + return 0; + + if(battle_config.monster_skill_nofootset && + skill_get_unit_flag(md->skillid)&UF_NOFOOTSET && + skill_check_unit_range2(md->bl.m,md->skillx,md->skilly,md->skillid,md->skilllv)) + return 0; + if(battle_config.monster_land_skill_limit) { maxcount = skill_get_maxcount(md->skillid); diff --git a/src/map/path.c b/src/map/path.c index dae7fc59a..92ea4941e 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -273,7 +273,7 @@ int path_search_long(int m,int x0,int y0,int x1,int y1) else weight = abs(y1 - y0); - while (x0 != x1 && y0 != y1) { + while (x0 != x1 || y0 != y1) { if (map_getcellp(md,x0,y0,CELL_CHKWALL)) return 0; wx += dx; diff --git a/src/map/pc.c b/src/map/pc.c index 416e05f97..0a5ef8a67 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -140,6 +140,7 @@ static int pc_invincible_timer(int tid,unsigned int tick,int id,int data) { return 0; } sd->invincible_timer=-1; + skill_unit_move(&sd->bl,tick,1); return 0; } @@ -160,6 +161,7 @@ int pc_delinvincibletimer(struct map_session_data *sd) { delete_timer(sd->invincible_timer,pc_invincible_timer); sd->invincible_timer = -1; } + skill_unit_move(&sd->bl,gettick(),1); return 0; } @@ -2244,7 +2246,12 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount) i = pc_search_inventory(sd,0); if(i >= 0) { memcpy(&sd->status.inventory[i],item_data,sizeof(sd->status.inventory[0])); - sd->status.inventory[i].amount=amount; + if(itemdb_isequip2(data)){ + sd->status.inventory[i].amount=1; + amount=1; + } else { + sd->status.inventory[i].amount=amount; + } sd->inventory_data[i]=data; clif_additem(sd,i,amount,0); } @@ -2480,7 +2487,12 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun for(i=0;istatus.cart[i].nameid==0){ memcpy(&sd->status.cart[i],item_data,sizeof(sd->status.cart[0])); - sd->status.cart[i].amount=amount; + if(itemdb_isequip2(data)){ + sd->status.inventory[i].amount=1; + amount=1; + } else { + sd->status.inventory[i].amount=amount; + } sd->cart_num++; clif_cart_additem(sd,i,amount,0); break; @@ -2877,6 +2889,13 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt status_change_end(&sd->bl,SC_BLADESTOP,-1); if(sd->sc_data[SC_DANCING].timer!=-1) // clear dance effect when warping [Valaris] skill_stop_dancing(&sd->bl,0); + if (sd->sc_data[SC_BASILICA].timer!=-1) { + int i; + for (i=0;iskillunit[i].skill_id==HP_BASILICA) + skill_delunitgroup(&sd->skillunit[i]); + status_change_end(&sd->bl,SC_BASILICA,-1); + } } if(sd->status.option&2) @@ -2910,7 +2929,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt int ip,port; if(map_mapname2ipport(mapname,&ip,&port)==0){ skill_stop_dancing(&sd->bl,1); - skill_unit_out_all(&sd->bl,gettick(),1); + skill_unit_move(&sd->bl,gettick(),0); clif_clearchar_area(&sd->bl,clrtype&0xffff); skill_gangsterparadise(sd,0); map_delblock(&sd->bl); @@ -2966,7 +2985,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt } if(sd->mapname[0] && sd->bl.prev != NULL){ - skill_unit_out_all(&sd->bl,gettick(),1); + skill_unit_move(&sd->bl,gettick(),0); clif_clearchar_area(&sd->bl,clrtype&0xffff); skill_gangsterparadise(sd,0); map_delblock(&sd->bl); @@ -3199,10 +3218,12 @@ static int pc_walk(int tid,unsigned int tick,int id,int data) x += dx; y += dy; + skill_unit_move(&sd->bl,tick,0); if(moveblock) map_delblock(&sd->bl); sd->bl.x = x; sd->bl.y = y; if(moveblock) map_addblock(&sd->bl); + skill_unit_move(&sd->bl,tick,1); #if 0 if (sd->status.guild_id > 0) { @@ -3250,20 +3271,15 @@ static int pc_walk(int tid,unsigned int tick,int id,int data) if (sd->sc_data[SC_DEVOTION].val1) skill_devotion2(&sd->bl,sd->sc_data[SC_DEVOTION].val1); - if (sd->sc_data[SC_BASILICA].timer != -1) { // Basilica cancels if caster moves [celest] - struct skill_unit *su; - if ((su = (struct skill_unit *)sd->sc_data[SC_BASILICA].val4)) { - struct skill_unit_group *sg; - if ((sg = su->group) && sg->src_id == sd->bl.id) { - status_change_end(&sd->bl,SC_BASILICA,-1); - skill_delunitgroup (sg); - } - } + if (sd->sc_data[SC_BASILICA].timer!=-1) { // Basilica cancels if caster moves [celest] + int i; + for (i=0;iskillunit[i].skill_id==HP_BASILICA) + skill_delunitgroup(&sd->skillunit[i]); + status_change_end(&sd->bl,SC_BASILICA,-1); } } - skill_unit_move(&sd->bl,tick,1); // スキルユニットの?査 - if(map_getcell(sd->bl.m,x,y,CELL_CHKNPC)) npc_touch_areanpc(sd,sd->bl.m,x,y); else @@ -3420,7 +3436,8 @@ int pc_randomwalk(struct map_session_data *sd,int tick) int pc_movepos(struct map_session_data *sd,int dst_x,int dst_y) { int moveblock; - int dx,dy,dist; + int dx,dy; + int tick = gettick(); struct walkpath_data wpd; @@ -3433,16 +3450,17 @@ int pc_movepos(struct map_session_data *sd,int dst_x,int dst_y) dx = dst_x - sd->bl.x; dy = dst_y - sd->bl.y; - dist = distance(sd->bl.x,sd->bl.y,dst_x,dst_y); moveblock = ( sd->bl.x/BLOCK_SIZE != dst_x/BLOCK_SIZE || sd->bl.y/BLOCK_SIZE != dst_y/BLOCK_SIZE); map_foreachinmovearea(clif_pcoutsight,sd->bl.m,sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,sd->bl.x+AREA_SIZE,sd->bl.y+AREA_SIZE,dx,dy,0,sd); + skill_unit_move(&sd->bl,tick,0); if(moveblock) map_delblock(&sd->bl); sd->bl.x = dst_x; sd->bl.y = dst_y; if(moveblock) map_addblock(&sd->bl); + skill_unit_move(&sd->bl,tick,1); map_foreachinmovearea(clif_pcinsight,sd->bl.m,sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,sd->bl.x+AREA_SIZE,sd->bl.y+AREA_SIZE,-dx,-dy,0,sd); @@ -3459,8 +3477,6 @@ int pc_movepos(struct map_session_data *sd,int dst_x,int dst_y) if(sd->status.option&4) // クロ?キングの消滅?査 skill_check_cloaking(&sd->bl); - skill_unit_move(&sd->bl,gettick(),dist+7); // スキルユニットの?査 - if(map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); else @@ -3781,7 +3797,7 @@ int pc_attack(struct map_session_data *sd,int target_id,int type) return 0; } - if(!battle_check_target(&sd->bl,bl,BCT_ENEMY)) + if(battle_check_target(&sd->bl,bl,BCT_ENEMY) <= 0) return 1; if(sd->attacktimer != -1) pc_stopattack(sd); @@ -4612,7 +4628,7 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage) skill_castcancel(&sd->bl,0); // 詠唱の中止 clif_clearchar_area(&sd->bl,1); pc_setdead(sd); - skill_unit_out_all(&sd->bl,gettick(),1); + skill_unit_move(&sd->bl,gettick(),0); if(sd->sc_data[SC_BLADESTOP].timer!=-1)//白刃は事前に解除 status_change_end(&sd->bl,SC_BLADESTOP,-1); pc_setglobalreg(sd,"PC_DIE_COUNTER",++sd->die_counter); //死にカウンタ?書き?み @@ -4967,7 +4983,21 @@ int pc_setparam(struct map_session_data *sd,int type,int val) sd->status.status_point = val; break; case SP_ZENY: - sd->status.zeny = val; + if(val <= MAX_ZENY) { + // MAX_ZENY 以下なら代入 + sd->status.zeny = val; + } else { + if(sd->status.zeny > val) { + // Zeny が減少しているなら代入 + sd->status.zeny = val; + } else if(sd->status.zeny <= MAX_ZENY) { + // Zeny が増加していて、現在の値がMAX_ZENY 以下ならMAX_ZENY + sd->status.zeny = MAX_ZENY; + } else { + // Zeny が増加していて、現在の値がMAX_ZENY より下なら増加分を無視 + ; + } + } break; case SP_BASEEXP: if(pc_nextbaseexp(sd) > 0) { @@ -5761,6 +5791,7 @@ int pc_setaccountreg2(struct map_session_data *sd,char *reg,int val) int pc_eventtimer(int tid,unsigned int tick,int id,int data) { struct map_session_data *sd=map_id2sd(id); + char *p = (char *)data; int i; if(sd==NULL) return 0; @@ -5768,11 +5799,11 @@ int pc_eventtimer(int tid,unsigned int tick,int id,int data) for(i=0;ieventtimer[i]==tid ){ sd->eventtimer[i]=-1; - npc_event(sd,(const char *)data,0); + npc_event(sd,p,0); break; } } - aFree((void *)data); + aFree(p); if(i==MAX_EVENTTIMER) { if(battle_config.error_log) printf("pc_eventtimer: no such event timer\n"); @@ -5795,8 +5826,9 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) if( sd->eventtimer[i]==-1 ) break; if(ieventtimer[i]=add_timer(gettick()+tick, pc_eventtimer,sd->bl.id,(int)evname); sd->eventcount++; @@ -5819,12 +5851,15 @@ int pc_deleventtimer(struct map_session_data *sd,const char *name) return 0; for(i=0;ieventtimer[i]!=-1 && strcmp( - (char *)(get_timer(sd->eventtimer[i])->data), name)==0 ){ + if( sd->eventtimer[i]!=-1 ) { + char *p = (char *)(get_timer(sd->eventtimer[i])->data); + if(strcmp(p, name)==0) { delete_timer(sd->eventtimer[i],pc_eventtimer); sd->eventtimer[i]=-1; sd->eventcount--; + free(p); break; + } } return 0; @@ -5865,8 +5900,10 @@ int pc_cleareventtimer(struct map_session_data *sd) for(i=0;ieventtimer[i]!=-1 ){ + char *p = (char *)(get_timer(sd->eventtimer[i])->data); delete_timer(sd->eventtimer[i],pc_eventtimer); sd->eventtimer[i]=-1; + free(p); } return 0; diff --git a/src/map/skill.c b/src/map/skill.c index 9ae3e2ba4..3d3411b16 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -556,6 +556,12 @@ int skill_get_mhp( int id ,int lv ){ skill_get (skill_db[id].mhp[lv-1], id, lv); int skill_get_castnodex( int id ,int lv ){ skill_get (skill_db[id].castnodex[lv-1], id, lv); } int skill_get_delaynodex( int id ,int lv ){ skill_get (skill_db[id].delaynodex[lv-1], id, lv); } int skill_get_nocast ( int id ){ skill_get (skill_db[id].nocast, id, 1); } +int skill_get_unit_id ( int id, int flag ){ skill_get (skill_db[id].unit_id[flag], id, 1); } +int skill_get_unit_layout_type( int id ,int lv ){ skill_get (skill_db[id].unit_layout_type[lv-1], id, lv); } +int skill_get_unit_interval( int id ){ skill_get (skill_db[id].unit_interval, id, 1); } +int skill_get_unit_range( int id ){ skill_get (skill_db[id].unit_range, id, 1); } +int skill_get_unit_target( int id ){ skill_get (skill_db[id].unit_target, id, 1); } +int skill_get_unit_flag( int id ){ skill_get (skill_db[id].unit_flag, id, 1); } int skill_tree_get_max(int id, int b_class){ struct pc_base_job s_class = pc_calc_base_job(b_class); @@ -577,6 +583,9 @@ int skill_clear_element_field(struct block_list *bl); int skill_landprotector(struct block_list *bl, va_list ap ); int skill_trap_splash(struct block_list *bl, va_list ap ); int skill_count_target(struct block_list *bl, va_list ap ); +struct skill_unit_group_tickset *skill_unitgrouptickset_search(struct block_list *bl,struct skill_unit_group *sg,int tick); +int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int tick); +int skill_unit_effect(struct block_list *bl,va_list ap); // [MouseJstr] - skill ok to cast? and when? int skillnotok(int skillid, struct map_session_data *sd) @@ -635,96 +644,53 @@ static int distance(int x0,int y0,int x1,int y1) return dx>dy ? dx : dy; } -/* スキルユニットIDを返す(これもデ?タベ?スに入れたいな) */ -int skill_get_unit_id(int id,int flag) +/* スキルユニットの配置情報を返す */ +struct skill_unit_layout skill_unit_layout[MAX_SKILL_UNIT_LAYOUT]; +int firewall_unit_pos; +int icewall_unit_pos; + +struct skill_unit_layout *skill_get_unit_layout(int skillid,int skilllv,struct block_list *src,int x,int y) { + + int pos = skill_get_unit_layout_type(skillid,skilllv); + int dir; - switch(id){ - case MG_SAFETYWALL: return 0x7e; /* セイフティウォ?ル */ - case MG_FIREWALL: return 0x7f; /* ファイア?ウォ?ル */ - case AL_WARP: return (flag==0)?0x81:0x80; /* ワ?プポ?タル */ - case PR_BENEDICTIO: return 0x82; /* 聖?降福 */ - case PR_SANCTUARY: return 0x83; /* サンクチュアリ */ - case PR_MAGNUS: return 0x84; /* マグヌスエクソシズム */ - case AL_PNEUMA: return 0x85; /* ニュ?マ */ - case MG_THUNDERSTORM: return 0x86; /* サンダ?スト?ム */ - case WZ_HEAVENDRIVE: return 0x86; /* ヘヴンズドライブ */ - case WZ_SIGHTRASHER: return 0x86; /* サイトラッシャ? */ - case WZ_METEOR: return 0x86; /* メテオスト?ム */ - case WZ_VERMILION: return 0x86; /* ロ?ドオブヴァ?ミリオン */ - //case WZ_FROSTNOVA: return 0x86; /* フロストノヴァ */ - case WZ_STORMGUST: return 0x86; /* スト?ムガスト(とりあえずLoVと同じで?理) */ - case CR_GRANDCROSS: return 0x86; /* グランドクロス */ - case NPC_DARKGRANDCROSS: return 0x86; /*闇グランドクロス*/ - case WZ_FIREPILLAR: return (flag==0)?0x87:0x88; /* ファイア?ピラ? */ - case HT_TALKIEBOX: return 0x99; /* ト?キ?ボックス */ - case WZ_ICEWALL: return 0x8d; /* アイスウォ?ル */ - case WZ_QUAGMIRE: return 0x8e; /* クァグマイア */ - case HT_BLASTMINE: return 0x8f; /* ブラストマイン */ - case HT_SKIDTRAP: return 0x90; /* スキッドトラップ */ - case HT_ANKLESNARE: return 0x91; /* アンクルスネア */ - case AS_VENOMDUST: return 0x92; /* ベノムダスト */ - case HT_LANDMINE: return 0x93; /* ランドマイン */ - case HT_SHOCKWAVE: return 0x94; /* ショックウェ?ブトラップ */ - case HT_SANDMAN: return 0x95; /* サンドマン */ - case HT_FLASHER: return 0x96; /* フラッシャ? */ - case HT_FREEZINGTRAP: return 0x97; /* フリ?ジングトラップ */ - case HT_CLAYMORETRAP: return 0x98; /* クレイモア?トラップ */ - case SA_VOLCANO: return 0x9a; /* ボルケ?ノ */ - case SA_DELUGE: return 0x9b; /* デリュ?ジ */ - case SA_VIOLENTGALE: return 0x9c; /* バイオレントゲイル */ - case SA_LANDPROTECTOR: return 0x9d; /* ランドプロテクタ? */ - case BD_LULLABY: return 0x9e; /* 子守歌 */ - case BD_RICHMANKIM: return 0x9f; /* ニヨルドの宴 */ - case BD_ETERNALCHAOS: return 0xa0; /* 永遠の混沌 */ - case BD_DRUMBATTLEFIELD:return 0xa1; /* ?太鼓の響き */ - case BD_RINGNIBELUNGEN: return 0xa2; /* ニ?ベルングの指輪 */ - case BD_ROKISWEIL: return 0xa3; /* ロキの叫び */ - case BD_INTOABYSS: return 0xa4; /* 深淵の中に */ - case BD_SIEGFRIED: return 0xa5; /* 不死身のジ?クフリ?ド */ - case BA_DISSONANCE: return 0xa6; /* 不協和音 */ - case BA_WHISTLE: return 0xa7; /* 口笛 */ - case BA_ASSASSINCROSS: return 0xa8; /* 夕陽のアサシンクロス */ - case BA_POEMBRAGI: return 0xa9; /* ブラギの詩 */ - case BA_APPLEIDUN: return 0xaa; /* イドゥンの林檎 */ - case DC_UGLYDANCE: return 0xab; /* 自分勝手なダンス */ - case DC_HUMMING: return 0xac; /* ハミング */ - case DC_DONTFORGETME: return 0xad; /* 私を忘れないで… */ - case DC_FORTUNEKISS: return 0xae; /* 幸運のキス */ - case DC_SERVICEFORYOU: return 0xaf; /* サ?ビスフォ?ユ? */ - case RG_GRAFFITI: return 0xb0; /* グラフィティ */ - case AM_DEMONSTRATION: return 0xb1; /* デモンストレ?ション */ - case WE_CALLPARTNER: return 0xb2; /* あなたに逢いたい */ - case PA_GOSPEL: return 0xb3; /* ゴスペル */ - case HP_BASILICA: return 0xb4; /* バジリカ */ -// case CG_MOONLIT: return 0xb5; - case PF_FOGWALL: return 0xb6; /* フォグウォ?ル */ - case PF_SPIDERWEB: return 0xb7; /* スパイダ?ウェッブ */ - // temporary unit ID's [Celest] - case GD_LEADERSHIP: return 0xc1; - case GD_GLORYWOUNDS: return 0xc2; - case GD_SOULCOLD: return 0xc3; - case GD_HAWKEYES: return 0xc4; - } - return 0; - /* - 0x89,0x8a,0x8b 表示無し - 0x9a 炎?性の詠唱みたいなエフェクト - 0x9b 水?性の詠唱みたいなエフェクト - 0x9c 風?性の詠唱みたいなエフェクト - 0x9d 白い小さなエフェクト - 0xb1 Alchemist Demonstration - 0xb2 = Pink Warp Portal - 0xb3 = Gospel For Paladin - 0xb4 = Basilica - 0xb5 = Empty - 0xb6 = Fog Wall for Professor - 0xb7 = Spider Web for Professor - 0xb8 = Empty - 0xb9 = - */ + if (pos!=-1) + return &skill_unit_layout[pos]; + + if (src->x==x && src->y==y) + dir = 2; + else + dir = map_calc_dir(src,x,y); + + if (skillid==MG_FIREWALL) + return &skill_unit_layout[firewall_unit_pos+dir]; + else if (skillid==WZ_ICEWALL) + return &skill_unit_layout[icewall_unit_pos+dir]; + + printf("unknown unit layout for skill %d, %d\n",skillid,skilllv); + return &skill_unit_layout[0]; } +// case GD_LEADERSHIP: return 0xc1; +// case GD_GLORYWOUNDS: return 0xc2; +// case GD_SOULCOLD: return 0xc3; +// case GD_HAWKEYES: return 0xc4; +// 0x89,0x8a,0x8b 表示無し +// 0x9a 炎?性の詠唱みたいなエフェクト +// 0x9b 水?性の詠唱みたいなエフェクト +// 0x9c 風?性の詠唱みたいなエフェクト +// 0x9d 白い小さなエフェクト +// 0xb1 Alchemist Demonstration +// 0xb2 = Pink Warp Portal +// 0xb3 = Gospel For Paladin +// 0xb4 = Basilica +// 0xb5 = Empty +// 0xb6 = Fog Wall for Professor +// 0xb7 = Spider Web for Professor +// 0xb8 = Empty +// 0xb9 = + /*========================================== * スキル追加?果 *------------------------------------------ @@ -1162,16 +1128,16 @@ int skill_blown( struct block_list *src, struct block_list *target,int count) nullpo_retr(0, target); if(target->type==BL_PC){ - nullpo_retr(0, sd=(struct map_session_data *)target); + sd=(struct map_session_data *)target; }else if(target->type==BL_MOB){ - nullpo_retr(0, md=(struct mob_data *)target); + md=(struct mob_data *)target; }else if(target->type==BL_PET){ - nullpo_retr(0, pd=(struct pet_data *)target); + pd=(struct pet_data *)target; }else if(target->type==BL_SKILL){ - nullpo_retr(0, su=(struct skill_unit *)target); + su=(struct skill_unit *)target; }else return 0; - if(!(count&0x10000 && (sd||md||pd||su))){ /* 指定なしなら位置?係から方向を求める */ + if(!(count&0x10000)){ /* 指定なしなら位置関係から方向を求める */ dx=target->x-src->x; dx=(dx>0)?1:((dx<0)?-1: 0); dy=target->y-src->y; dy=(dy>0)?1:((dy<0)?-1: 0); } @@ -1228,18 +1194,13 @@ int skill_blown( struct block_list *src, struct block_list *target,int count) if(su){ skill_unit_move_unit_group(su->group,target->m,dx,dy); }else{ -// struct status_change *sc_data=status_get_sc_data(target); - if(moveblock) map_delblock(target); - target->x=nx; - target->y=ny; - if(moveblock) map_addblock(target); -/*ダンス中にエフェクトは移動しないらしい - if(sc_data && sc_data[SC_DANCING].timer!=-1){ //?象がダンス中なのでエフェクトも移動 - struct skill_unit_group *sg=(struct skill_unit_group *)sc_data[SC_DANCING].val2; - if(sg) - skill_unit_move_unit_group(sg,target->m,dx,dy); - } -*/ + int tick = gettick(); + skill_unit_move(target,tick,0); + if(moveblock) map_delblock(target); + target->x=nx; + target->y=ny; + if(moveblock) map_addblock(target); + skill_unit_move(target,tick,1); } if(sd) { /* ?面?に入ってきたので表示 */ @@ -1258,8 +1219,6 @@ int skill_blown( struct block_list *src, struct block_list *target,int count) pd->state.state = prev_state; } - skill_unit_move(target,gettick(),(count&0xffff)+7); /* スキルユニットの判定 */ - return 0; } @@ -1480,9 +1439,6 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds //武器スキル?ここまで switch(skillid){ - case WZ_SIGHTRASHER: - clif_skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion, damage, dmg.div_, skillid, (lv!=0)?lv:skilllv, 5); - break; case AS_SPLASHER: clif_skill_damage(dsrc,bl,tick,dmg.amotion,dmg.dmotion, damage, dmg.div_, skillid, -1, 5); break; @@ -1495,11 +1451,9 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds default: clif_skill_damage(dsrc,bl,tick,dmg.amotion,dmg.dmotion, damage, dmg.div_, skillid, (lv!=0)?lv:skilllv, (skillid==0)? 5:type ); } - if(dmg.blewcount > 0 && !map[src->m].flag.gvg) { /* 吹き飛ばし?理とそのパケット */ - if(skillid == WZ_SIGHTRASHER) - skill_blown(src,bl,dmg.blewcount); - else - skill_blown(dsrc,bl,dmg.blewcount); + /* 吹き飛ばし処理とそのパケット */ + if (dmg.blewcount > 0 && bl->type!=BL_SKILL && !map[src->m].flag.gvg) { + skill_blown(dsrc,bl,dmg.blewcount); if(bl->type == BL_MOB) clif_fixmobpos((struct mob_data *)bl); else if(bl->type == BL_PET) @@ -1510,8 +1464,12 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds map_freeblock_lock(); /* ?際にダメ?ジ?理を行う */ - if(skillid || flag) - battle_damage(src,bl,damage,0); + if (skillid || flag) { + if (attack_type&BF_WEAPON) + battle_delay_damage(tick+dmg.amotion,src,bl,damage,0); + else + battle_damage(src,bl,damage,0); + } if(skillid == RG_INTIMIDATE && damage > 0 && !(status_get_mode(bl)&0x20) && !map[src->m].flag.gvg ) { int s_lv = status_get_lv(src),t_lv = status_get_lv(bl); int rate = 50 + skilllv * 5; @@ -1594,8 +1552,12 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds battle_heal(NULL,bl,0,-sp,0); } - if((skillid || flag) && rdamage > 0) - battle_damage(bl,src,rdamage,0); + if ((skillid || flag) && rdamage>0) { + if (attack_type&BF_WEAPON) + battle_delay_damage(tick+dmg.amotion,bl,src,rdamage,0); + else + battle_damage(bl,src,rdamage,0); + } if(attack_type&BF_WEAPON && sc_data && sc_data[SC_AUTOCOUNTER].timer != -1 && sc_data[SC_AUTOCOUNTER].val4 > 0) { if(sc_data[SC_AUTOCOUNTER].val3 == dsrc->id) @@ -1647,9 +1609,8 @@ int skill_area_sub( struct block_list *bl,va_list ap ) static int skill_check_unit_range_sub( struct block_list *bl,va_list ap ) { struct skill_unit *unit; - int *c,x,y,range,sx[4],sy[4]; - int t_range,tx[4],ty[4]; - int i,r_flag,skillid; + int *c; + int skillid,unit_id; nullpo_retr(0, bl); nullpo_retr(0, ap); @@ -1662,57 +1623,46 @@ static int skill_check_unit_range_sub( struct block_list *bl,va_list ap ) if(!unit->alive) return 0; - x = va_arg(ap,int); - y = va_arg(ap,int); - range = va_arg(ap,int); skillid = va_arg(ap,int); + unit_id = unit->group->unit_id; - if(skillid == MG_SAFETYWALL || skillid == AL_PNEUMA) { - if(unit->group->unit_id != 0x7e && unit->group->unit_id != 0x85) + if (skillid==MG_SAFETYWALL || skillid==AL_PNEUMA) { + if(unit_id != 0x7e && unit_id != 0x85) return 0; - } - else if(skillid == AL_WARP) { - if((unit->group->unit_id < 0x8f || unit->group->unit_id > 0x99) && unit->group->unit_id != 0x92) + } else if (skillid==AL_WARP) { + if ((unit_id<0x8f || unit_id>0x99) && unit_id!=0x92) return 0; - } - else if((skillid >= HT_SKIDTRAP && skillid <= HT_CLAYMORETRAP) || skillid == HT_TALKIEBOX) { - if((unit->group->unit_id < 0x8f || unit->group->unit_id > 0x99) && unit->group->unit_id != 0x92) + } else if ((skillid>=HT_SKIDTRAP && skillid<=HT_CLAYMORETRAP) || skillid==HT_TALKIEBOX) { + if ((unit_id<0x8f || unit_id>0x99) && unit_id!=0x92) return 0; - } - else if(skillid == WZ_FIREPILLAR) { - if(unit->group->unit_id != 0x87) + } else if (skillid==WZ_FIREPILLAR) { + if (unit_id!=0x87) return 0; - } - else return 0; - t_range=(unit->range!=0)? unit->range:unit->group->range; - tx[0] = tx[3] = unit->bl.x - t_range; - tx[1] = tx[2] = unit->bl.x + t_range; - ty[0] = ty[1] = unit->bl.y - t_range; - ty[2] = ty[3] = unit->bl.y + t_range; - sx[0] = sx[3] = x - range; - sx[1] = sx[2] = x + range; - sy[0] = sy[1] = y - range; - sy[2] = sy[3] = y + range; - for(i=r_flag=0;i<4;i++) { - if(sx[i] >= tx[0] && sx[i] <= tx[1] && sy[i] >= ty[0] && sy[i] <= ty[2]) { - r_flag = 1; - break; - } - if(tx[i] >= sx[0] && tx[i] <= sx[1] && ty[i] >= sy[0] && ty[i] <= sy[2]) { - r_flag = 1; - break; - } - } - if(r_flag) (*c)++; + } else if (skillid==HP_BASILICA) { + if ((unit_id<0x8f || unit_id>0x99) && unit_id!=0x92 && unit_id!=0x83) + return 0; + } else + return 0; + + (*c)++; return 0; } -int skill_check_unit_range(int m,int x,int y,int range,int skillid) +int skill_check_unit_range(int m,int x,int y,int skillid,int skilllv) { int c = 0; + int range = skill_get_unit_range(skillid); + int layout_type = skill_get_unit_layout_type(skillid,skilllv); + if (layout_type==-1 || layout_type>MAX_SQUARE_LAYOUT) { + printf("skill_check_unit_range: unsupported layout type %d for skill %d\n",layout_type,skillid); + return 0; + } - map_foreachinarea(skill_check_unit_range_sub,m,x-10,y-10,x+10,y+10,BL_SKILL,&c,x,y,range,skillid); + // とりあえず正方形のユニットレイアウトのみ対応 + range += layout_type; + map_foreachinarea(skill_check_unit_range_sub,m, + x-range,y-range,x+range,y+range,BL_SKILL,&c,skillid); return c; } @@ -1720,6 +1670,8 @@ int skill_check_unit_range(int m,int x,int y,int range,int skillid) static int skill_check_unit_range2_sub( struct block_list *bl,va_list ap ) { int *c; + int skillid; + nullpo_retr(0, bl); nullpo_retr(0, ap); @@ -1731,16 +1683,29 @@ static int skill_check_unit_range2_sub( struct block_list *bl,va_list ap ) if(bl->type == BL_PC && pc_isdead((struct map_session_data *)bl)) return 0; + skillid = va_arg(ap,int); + if (skillid==HP_BASILICA && bl->type==BL_PC) + return 0; + (*c)++; return 0; } -int skill_check_unit_range2(int m,int x,int y,int range) +int skill_check_unit_range2(int m,int x,int y,int skillid, int skilllv) { int c = 0; + int range = skill_get_unit_range(skillid); + int layout_type = skill_get_unit_layout_type(skillid,skilllv); + if (layout_type==-1 || layout_type>MAX_SQUARE_LAYOUT) { + printf("skill_check_unit_range2: unsupported layout type %d for skill %d\n",layout_type,skillid); + return 0; + } - map_foreachinarea(skill_check_unit_range2_sub,m,x-range,y-range,x+range,y+range,0,&c); + // とりあえず正方形のユニットレイアウトのみ対応 + range += layout_type; + map_foreachinarea(skill_check_unit_range2_sub,m, + x-range,y-range,x+range,y+range,0,&c,skillid); return c; } @@ -1758,6 +1723,27 @@ int skill_area_sub_count(struct block_list *src,struct block_list *target,int sk return 0; } +int skill_count_water(struct block_list *src,int range) +{ + int i,x,y,cnt = 0,size = range*2+1; + struct skill_unit *unit; + + for (i=0;ix+(i%size-range); + y = src->y+(i/size-range); + if (map_getcell(src->m,x,y,CELL_CHKWATER)) { + cnt++; + continue; + } + unit = map_find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL); + if (unit) { + cnt++; + skill_delunit(unit); + } + } + return cnt; +} + /*========================================== * *------------------------------------------ @@ -1877,6 +1863,14 @@ static int skill_timerskill(int tid, unsigned int tick, int id,int data ) src->x+range,src->y+range,0,src,skl->skill_id,skl->skill_lv,tick); break; + case WZ_WATERBALL: + if (skl->type>1) { + skl->timer = 0; // skill_addtimerskillで使用されないように + skill_addtimerskill(src,tick+150,target->id,0,0,skl->skill_id,skl->skill_lv,skl->type-1,skl->flag); + skl->timer = -1; + } + skill_attack(BF_MAGIC,src,src,target,skl->skill_id,skl->skill_lv,tick,skl->flag); + break; default: skill_attack(skl->type,src,src,target,skl->skill_id,skl->skill_lv,tick,skl->flag); break; @@ -2047,7 +2041,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s if(sd && pc_isdead(sd)) return 1; - if((skillid == WZ_SIGHTRASHER || skillid == CR_GRANDCROSS || skillid == NPC_DARKGRANDCROSS) && src != bl) + if((skillid == CR_GRANDCROSS || skillid == NPC_DARKGRANDCROSS) && src != bl) bl = src; if(bl->prev == NULL) return 1; @@ -2445,8 +2439,17 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s case WZ_WATERBALL: /* ウォ?タ?ボ?ル */ skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,flag); - if(skilllv>1) - status_change_start(src,SC_WATERBALL,skilllv,bl->id,0,0,0,0); + if (skilllv>1) { + int cnt,range; + range = skilllv>5?2:skilllv/2; + if (sd) + cnt = skill_count_water(src,range)-1; + else + cnt = skill_get_num(skillid,skilllv)-1; + if (cnt>0) + skill_addtimerskill(src,tick+150,bl->id,0,0, + skillid,skilllv,cnt,flag); + } break; case PR_BENEDICTIO: /* 聖?降福 */ @@ -2457,6 +2460,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s /* 魔法系範?攻?スキル */ case MG_NAPALMBEAT: /* ナパ?ムビ?ト */ case MG_FIREBALL: /* ファイヤ?ボ?ル */ + case WZ_SIGHTRASHER: /* サイトラッシャー */ if(flag&1){ /* 個別にダメ?ジを?える */ if(bl->id!=skill_area_temp[1]){ @@ -2469,27 +2473,46 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s skill_area_temp[0]| 0x0500); } }else{ - int ar=(skillid==MG_NAPALMBEAT)?1:2; + int ar; + skill_area_temp[0]=0; skill_area_temp[1]=bl->id; - if(skillid==MG_NAPALMBEAT){ /* ナパ?ムでは先に?える */ - skill_area_temp[0]=0; - map_foreachinarea(skill_area_sub, - bl->m,bl->x-1,bl->y-1,bl->x+1,bl->y+1,0, - src,skillid,skilllv,tick, flag|BCT_ENEMY , - skill_area_sub_count); - }else{ - skill_area_temp[0]=0; - skill_area_temp[2]=bl->x; - skill_area_temp[3]=bl->y; + switch (skillid) { + case MG_NAPALMBEAT: + ar = 1; + /* ナパームビートは分散ダメージなので敵の数を数える */ + map_foreachinarea(skill_area_sub, + bl->m,bl->x-ar,bl->y-ar,bl->x+ar,bl->y+ar,0, + src,skillid,skilllv,tick,flag|BCT_ENEMY, + skill_area_sub_count); + break; + case MG_FIREBALL: + ar = 2; + skill_area_temp[2]=bl->x; + skill_area_temp[3]=bl->y; + /* ターゲットに攻撃を加える(スキルエフェクト表示) */ + skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick, + skill_area_temp[0]); + break; + case WZ_SIGHTRASHER: + default: + ar = 3; + bl = src; + status_change_end(src,SC_SIGHT,-1); + break; } - /* まずタ?ゲットに攻?を加える */ - skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick, - skill_area_temp[0] ); - /* その後タ?ゲット以外の範??の敵全?に?理を行う */ + if (skillid==WZ_SIGHTRASHER) { + /* スキルエフェクト表示 */ + clif_skill_nodamage(src,bl,skillid,skilllv,1); + } else { + /* ターゲットに攻撃を加える(スキルエフェクト表示) */ + skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick, + skill_area_temp[0]); + } + /* ターゲット以外の範囲内の敵全体に処理を行う */ map_foreachinarea(skill_area_sub, - bl->m,bl->x-ar,bl->y-ar,bl->x+ar,bl->y+ar,0, - src,skillid,skilllv,tick, flag|BCT_ENEMY|1, - skill_castend_damage_id); + bl->m,bl->x-ar,bl->y-ar,bl->x+ar,bl->y+ar,0, + src,skillid,skilllv,tick, flag|BCT_ENEMY|1, + skill_castend_damage_id); } break; @@ -2528,12 +2551,6 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY); break; - case WZ_SIGHTRASHER: - clif_skill_nodamage(src,bl,skillid,skilllv,1); - skill_castend_pos2(src,bl->x,bl->y,skillid,skilllv,tick,0); - status_change_end(src,SC_SIGHT,-1); - break; - /* その他 */ case HT_BLITZBEAT: /* ブリッツビ?ト */ if(flag&1){ @@ -4688,7 +4705,6 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil nullpo_retr(0, sd=(struct map_session_data *)src); } if( skillid != WZ_METEOR && - skillid != WZ_SIGHTRASHER && skillid != AM_CANNIBALIZE && skillid != AM_SPHEREMINE) clif_skill_poseffect(src,skillid,skilllv,x,y,tick); @@ -4739,7 +4755,6 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil case AL_PNEUMA: /* ニュ?マ */ case WZ_ICEWALL: /* アイスウォ?ル */ case WZ_FIREPILLAR: /* ファイアピラ? */ - case WZ_SIGHTRASHER: case WZ_QUAGMIRE: /* クァグマイア */ case WZ_VERMILION: /* ロ?ドオブヴァ?ミリオン */ //case WZ_FROSTNOVA: /* フロストノヴァ */ @@ -5007,349 +5022,137 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid,int skilllv,int x,int y,int flag) { struct skill_unit_group *group; - int i,count=1,limit=10000,val1=0,val2=0; - int target=BCT_ENEMY,interval=1000,range=0; - int dir=0,aoe_diameter=0; // -- aoe_diameter (moonsoul) added for sage Area Of Effect skills + int i,limit,val1=0,val2=0,val3=0; + int count=0; + int target,interval,range,unit_flag; + struct skill_unit_layout *layout; struct status_change *sc_data; nullpo_retr(0, src); + limit = skill_get_time(skillid,skilllv); + range = skill_get_unit_range(skillid); + interval = skill_get_unit_interval(skillid); + target = skill_get_unit_target(skillid); + unit_flag = skill_get_unit_flag(skillid); + layout = skill_get_unit_layout(skillid,skilllv,src,x,y); + + if (unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy) + target = BCT_NOENEMY; + sc_data = status_get_sc_data(src); // for firewall and fogwall - celest switch(skillid){ /* 設定 */ case MG_SAFETYWALL: /* セイフティウォ?ル */ - limit=skill_get_time(skillid,skilllv); val2=skilllv+1; - interval = -1; - target=(battle_config.defnotenemy)?BCT_NOENEMY:BCT_ALL; break; - case MG_FIREWALL: /* ファイヤ?ウォ?ル */ - if(src->x == x && src->y == y) - dir = 2; - else - dir=map_calc_dir(src,x,y); - if(dir&1) count=5; - else count=3; - limit=skill_get_time(skillid,skilllv); - if(sc_data) { - if (sc_data[SC_VIOLENTGALE].timer!=-1) limit = limit*3/2; - } - // check for sc_data first - Celest - // if (((struct map_session_data *)src)->sc_data[SC_VIOLENTGALE].timer!=-1) - // limit *= 1.5; + if(sc_data && sc_data[SC_VIOLENTGALE].timer!=-1) + limit = limit*3/2; val2=4+skilllv; - interval=1; - break; - - case AL_PNEUMA: /* ニュ?マ */ - limit=skill_get_time(skillid,skilllv); - interval = -1; - target=(battle_config.defnotenemy)?BCT_NOENEMY:BCT_ALL; - count = 9; break; case AL_WARP: /* ワ?プポ?タル */ - target=BCT_ALL; val1=skilllv+6; if(flag==0) limit=2000; - else - limit=skill_get_time(skillid,skilllv); break; case PR_SANCTUARY: /* サンクチュアリ */ - count=21; - limit=skill_get_time(skillid,skilllv); val1=(skilllv+3)*2; val2=(skilllv>6)?777:skilllv*100; - target=BCT_ALL; - range=1; - break; - - case PR_MAGNUS: /* マグヌスエクソシズム */ - count=33; - limit=skill_get_time(skillid,skilllv); - interval=3000; + interval += 500; break; case WZ_FIREPILLAR: /* ファイア?ピラ? */ - if(flag==0) - limit=skill_get_time(skillid,skilllv); - else + if(flag!=0) limit=1000; - interval=2000; val1=skilllv+2; - if(skilllv < 6) - range=1; - else + if(skilllv >= 6) range=2; break; - case MG_THUNDERSTORM: /* サンダ?スト?ム */ - limit=500; - range=1; - break; - - //case WZ_FROSTNOVA: /* フロストノヴァ */ - // limit=500; - // range=5; - // break; - - case WZ_HEAVENDRIVE: /* ヘヴンズドライブ */ - limit=500; - range=2; - break; - - case WZ_METEOR: /* メテオスト?ム */ - limit=500; - range=3; - break; - - case WZ_SIGHTRASHER: - limit=500; - count=41; - break; - - case WZ_VERMILION: /* ロ?ドオブヴァ?ミリオン */ - limit=4100; - interval=1000; - range=6; - break; - - case WZ_ICEWALL: /* アイスウォ?ル */ - limit=skill_get_time(skillid,skilllv); - count=5; - break; - - case WZ_STORMGUST: /* スト?ムガスト */ - limit=4600; - interval=450; - range=5; - break; - - case WZ_QUAGMIRE: /* クァグマイア */ - limit=skill_get_time(skillid,skilllv); - interval=200; - count=25; - break; - case HT_SANDMAN: /* サンドマン */ case HT_CLAYMORETRAP: /* クレイモア?トラップ */ - limit=skill_get_time(skillid,skilllv); - // longer trap times in WOE [celest] - if (map[src->m].flag.gvg) limit *= 4; - range=2; - break; case HT_SKIDTRAP: /* スキッドトラップ */ case HT_LANDMINE: /* ランドマイン */ case HT_ANKLESNARE: /* アンクルスネア */ - case PF_SPIDERWEB: /* スパイダ?ウェッブ */ case HT_FLASHER: /* フラッシャ? */ case HT_FREEZINGTRAP: /* フリ?ジングトラップ */ case HT_BLASTMINE: /* ブラストマイン */ - limit=skill_get_time(skillid,skilllv); // longer trap times in WOE [celest] - if (skillid != PF_SPIDERWEB && map[src->m].flag.gvg) - limit *= 4; - range=1; - break; - - case HT_TALKIEBOX: /* ト?キ?ボックス */ - limit=skill_get_time(skillid,skilllv); - range=1; - target=BCT_ALL; + if (map[src->m].flag.gvg) limit *= 4; break; - case HT_SHOCKWAVE: /* ショックウェ?ブトラップ */ - limit=skill_get_time(skillid,skilllv); - range=1; val1=skilllv*15+10; break; - case AS_VENOMDUST: /* ベノムダスト */ - limit=skill_get_time(skillid,skilllv); - interval=1000; - count=5; - break; - - case CR_GRANDCROSS: /* グランドクロス */ - case NPC_DARKGRANDCROSS: /*闇グランドクロス*/ - count=29; - limit=1000; - interval=300; - break; - - case SA_VOLCANO: /* ボルケ?ノ */ - case SA_DELUGE: /* デリュ?ジ */ - case SA_VIOLENTGALE: /* バイオレントゲイル */ - limit=skill_get_time(skillid,skilllv); - //count=skilllv<=2?25:(skilllv<=4?49:81); - count=49; - target=BCT_ALL; - break; - case SA_LANDPROTECTOR: /* グランドクロス */ - limit=skill_get_time(skillid,skilllv); // changed to get duration from cast_db (moonsoul) - val1=skilllv*15+10; - aoe_diameter=skilllv+skilllv%2+5; - target=BCT_ALL; - count=aoe_diameter*aoe_diameter; // -- this will not function if changed to ^2 (moonsoul) - break; - - case BD_LULLABY: /* 子守唄 */ - case BD_ETERNALCHAOS: /* エタ?ナルカオス */ - case BD_ROKISWEIL: /* ロキの叫び */ - count=81; - limit=skill_get_time(skillid,skilllv); - range=5; - target=(skillid==BD_ETERNALCHAOS ? BCT_ENEMY : BCT_ALL); - break; - case BD_RICHMANKIM: - case BD_DRUMBATTLEFIELD: /* ?太鼓の響き */ - case BD_RINGNIBELUNGEN: /* ニ?ベルングの指輪 */ - case BD_INTOABYSS: /* 深淵の中に */ - case BD_SIEGFRIED: /* 不死身のジ?クフリ?ド */ - count=81; - limit=skill_get_time(skillid,skilllv); - range=5; - target=BCT_PARTY; + { + int aoe_diameter; // -- aoe_diameter (moonsoul) added for sage Area Of Effect skills + val1=skilllv*15+10; + aoe_diameter=skilllv+skilllv%2+5; + count=aoe_diameter*aoe_diameter; // -- this will not function if changed to ^2 (moonsoul) + } break; case BA_WHISTLE: /* 口笛 */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_NOENEMY; if(src->type == BL_PC) val1 = (pc_checkskill((struct map_session_data *)src,BA_MUSICALLESSON)+1)>>1; val2 = ((status_get_agi(src)/10)&0xffff)<<16; val2 |= (status_get_luk(src)/10)&0xffff; break; case DC_HUMMING: /* ハミング */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_NOENEMY; if(src->type == BL_PC) val1 = (pc_checkskill((struct map_session_data *)src,DC_DANCINGLESSON)+1)>>1; val2 = status_get_dex(src)/10; break; - - case BA_DISSONANCE: /* 不協和音 */ - case DC_UGLYDANCE: /* 自分勝手なダンス */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_ENEMY; - break; - case DC_DONTFORGETME: /* 私を忘れないで… */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_ENEMY; if(src->type == BL_PC) val1 = (pc_checkskill((struct map_session_data *)src,DC_DANCINGLESSON)+1)>>1; val2 = ((status_get_str(src)/20)&0xffff)<<16; val2 |= (status_get_agi(src)/10)&0xffff; break; case BA_POEMBRAGI: /* ブラギの詩 */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_NOENEMY; if(src->type == BL_PC) val1 = pc_checkskill((struct map_session_data *)src,BA_MUSICALLESSON); val2 = ((status_get_dex(src)/10)&0xffff)<<16; val2 |= (status_get_int(src)/5)&0xffff; break; case BA_APPLEIDUN: /* イドゥンの林檎 */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_NOENEMY; if(src->type == BL_PC) val1 = ((pc_checkskill((struct map_session_data *)src,BA_MUSICALLESSON))&0xffff)<<16; - else - val1 = 0; - val1 |= (status_get_vit(src))&0xffff; - val2 = 0;//回復用タイムカウンタ(6秒?に1?加) + val2 |= (status_get_vit(src))&0xffff; + val3 = 0;//回復用タイムカウンタ(6秒?に1?加) break; case DC_SERVICEFORYOU: /* サ?ビスフォ?ユ? */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_PARTY; if(src->type == BL_PC) val1 = (pc_checkskill((struct map_session_data *)src,DC_DANCINGLESSON)+1)>>1; val2 = status_get_int(src)/10; break; case BA_ASSASSINCROSS: /* 夕陽のアサシンクロス */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_NOENEMY; if(src->type == BL_PC) val1 = (pc_checkskill((struct map_session_data *)src,BA_MUSICALLESSON)+1)>>1; val2 = status_get_agi(src)/20; break; case DC_FORTUNEKISS: /* 幸運のキス */ - count=49; - limit=skill_get_time(skillid,skilllv); - range=3; - target=BCT_NOENEMY; if(src->type == BL_PC) val1 = (pc_checkskill((struct map_session_data *)src,DC_DANCINGLESSON)+1)>>1; val2 = status_get_luk(src)/10; break; - case AM_DEMONSTRATION: /* デモンストレ?ション */ - limit=skill_get_time(skillid,skilllv); - interval=1000; - range=1; - target=BCT_ENEMY; - break; - - case WE_CALLPARTNER: /* あなたに逢いたい */ - limit=skill_get_time(skillid,skilllv); - range=-1; - break; - case HP_BASILICA: /* バジリカ */ - limit=skill_get_time(skillid,skilllv); - target=BCT_ALL; - range=3; //Fix to prevent the priest from walking while Basilica is up. battle_stopwalking(src,1); - //status_change_start(src,SC_ANKLE,skilllv,0,0,0,limit,0); - //sd->canmove_tick = gettick() + limit; // added later [celest] - break; - - case PA_GOSPEL: /* ゴスペル */ - count=49; - target=BCT_PARTY; - limit=skill_get_time(skillid,skilllv); break; -/* case CG_MOONLIT: - range=1; - target=BCT_ALL; - limit=skill_get_time(skillid,skilllv); - break;*/ - case PF_FOGWALL: /* フォグウォ?ル */ - count=15; - limit=skill_get_time(skillid,skilllv); - if(sc_data) { - if (sc_data[SC_DELUGE].timer!=-1) limit *= 2; - } + if(sc_data && sc_data[SC_DELUGE].timer!=-1) limit *= 2; break; case RG_GRAFFITI: /* Graffiti */ count=1; // Leave this at 1 [Valaris] - limit=600000; // Time length [Valaris] break; case GD_LEADERSHIP: @@ -5360,20 +5163,16 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, target=BCT_ALL; limit=300000; break; - - default: - if(battle_config.error_log) - printf ("skill_unitsetting: Unknown skill id = %d\n",skillid); - return 0; } - nullpo_retr(NULL, group=skill_initunitgroup(src,count,skillid,skilllv,skill_get_unit_id(skillid,flag&1))); + nullpo_retr(NULL, group=skill_initunitgroup(src,(count > 0 ? count : layout->count), + skillid,skilllv,skill_get_unit_id(skillid,flag&1))); group->limit=limit; group->val1=val1; group->val2=val2; + group->val3=val3; group->target_flag=target; group->interval=interval; - group->range=range; if(skillid==HT_TALKIEBOX || skillid==RG_GRAFFITI){ group->valstr=aCallocA(80, 1); @@ -5383,200 +5182,20 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, } memcpy(group->valstr,talkie_mes,80); } - for(i=0;icount;i++){ struct skill_unit *unit; - int ux=x,uy=y,val1=skilllv,val2=0,limit=group->limit,alive=1; - int range=group->range; - switch(skillid){ /* 設定 */ - case AL_PNEUMA: /* ニュ?マ */ - { - static const int dx[9]={-1, 0, 1,-1, 0, 1,-1, 0, 1}; - static const int dy[9]={-1,-1,-1, 0, 0, 0, 1, 1, 1}; - ux+=dx[i]; - uy+=dy[i]; - } - break; + int ux,uy,val1=skilllv,val2=0,limit=group->limit,alive=1; + ux = x + layout->dx[i]; + uy = y + layout->dy[i]; + switch (skillid) { case MG_FIREWALL: /* ファイヤ?ウォ?ル */ - { - if(dir&1){ /* 斜め配置 */ - static const int dx[][5]={ - { 1,1,0,0,-1 }, { -1,-1,0,0,1 }, - },dy[][5]={ - { 1,0,0,-1,-1 }, { 1,0,0,-1,-1 }, - }; - ux+=dx[(dir>>1)&1][i]; - uy+=dy[(dir>>1)&1][i]; - }else{ /* 上下配置 */ - if(dir%4==0) /* 上下 */ - ux+=i-1; - else /* 左右 */ - uy+=i-1; - } - val2=group->val2; - } - break; - - case PR_SANCTUARY: /* サンクチュアリ */ - { - static const int dx[]={ - -1,0,1, -2,-1,0,1,2, -2,-1,0,1,2, -2,-1,0,1,2, -1,0,1 }; - static const int dy[]={ - -2,-2,-2, -1,-1,-1,-1,-1, 0,0,0,0,0, 1,1,1,1,1, 2,2,2, }; - ux+=dx[i]; - uy+=dy[i]; - } - break; - - case PR_MAGNUS: /* マグヌスエクソシズム */ - { - static const int dx[]={ -1,0,1, -1,0,1, -3,-2,-1,0,1,2,3, - -3,-2,-1,0,1,2,3, -3,-2,-1,0,1,2,3, -1,0,1, -1,0,1, }; - static const int dy[]={ - -3,-3,-3, -2,-2,-2, -1,-1,-1,-1,-1,-1,-1, - 0,0,0,0,0,0,0, 1,1,1,1,1,1,1, 2,2,2, 3,3,3 }; - ux+=dx[i]; - uy+=dy[i]; - } + val2=group->val2; break; - - case WZ_SIGHTRASHER: - { - static const int dx[]={ - -5, 0, 5, -4, 0, 4, -3, 0, 3, -2, 0, 2, -1, 0, 1, -5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, -1, 0, 1, -2, 0, 2, -3, 0, 3, -4, 0, 4, -5, 0, 5 }; - static const int dy[]={ - -5,-5,-5, -4,-4,-4, -3,-3,-3, -2,-2,-2, -1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5 }; - ux+=dx[i]; - uy+=dy[i]; - } - break; - case WZ_ICEWALL: /* アイスウォ?ル */ - { - static const int dirx[8]={0,-1,-1,-1,0,1,1,1}; - static const int diry[8]={1,1,0,-1,-1,-1,0,1}; if(skilllv <= 1) val1 = 500; else val1 = 200 + 200*skilllv; - if(src->x == x && src->y == y) - dir = 2; - else - dir=map_calc_dir(src,x,y); - ux+=(2-i)*diry[dir]; - uy+=(i-2)*dirx[dir]; - } - break; - - case WZ_QUAGMIRE: /* クァグマイア */ - ux+=(i%5-2); - uy+=(i/5-2); - if(i==12) - range=2; - else - range=-1; - - break; - - case AS_VENOMDUST: /* ベノムダスト */ - { - static const int dx[]={-1,0,0,0,1}; - static const int dy[]={0,-1,0,1,0}; - ux+=dx[i]; - uy+=dy[i]; - } - break; - - case CR_GRANDCROSS: /* グランドクロス */ - case NPC_DARKGRANDCROSS: /*闇グランドクロス*/ - { - static const int dx[]={ - 0, 0, -1,0,1, -2,-1,0,1,2, -4,-3,-2,-1,0,1,2,3,4, -2,-1,0,1,2, -1,0,1, 0, 0, }; - static const int dy[]={ - -4, -3, -2,-2,-2, -1,-1,-1,-1,-1, 0,0,0,0,0,0,0,0,0, 1,1,1,1,1, 2,2,2, 3, 4, }; - ux+=dx[i]; - uy+=dy[i]; - } - break; - case SA_VOLCANO: /* ボルケ?ノ */ - case SA_DELUGE: /* デリュ?ジ */ - case SA_VIOLENTGALE: /* バイオレントゲイル */ - { - int u_range=0,central=0; - if(skilllv<=2){ - u_range=2; - central=12; - }else if(skilllv<=4){ - u_range=3; - central=24; - }else if(skilllv>=5){ - u_range=4; - central=40; - } - ux+=(i%(u_range*2+1)-u_range); - uy+=(i/(u_range*2+1)-u_range); - - if(i==central) - range=u_range;//中央のユニットの?果範?は全範? - else - range=-1;//中央以外のユニットは飾り - } - break; - case SA_LANDPROTECTOR: /* ランドプロテクタ? */ - { - int u_range=0; - - if(skilllv<=2) u_range=3; - else if(skilllv<=4) u_range=4; - else if(skilllv>=5) u_range=5; - - ux+=(i%(u_range*2+1)-u_range); - uy+=(i/(u_range*2+1)-u_range); - - range=0; - } - break; - - /* ダンスなど */ - case BD_LULLABY: /* 子守歌 */ - case BD_RICHMANKIM: /* ニヨルドの宴 */ - case BD_ETERNALCHAOS: /* 永遠の混沌 */ - case BD_DRUMBATTLEFIELD:/* ?太鼓の響き */ - case BD_RINGNIBELUNGEN: /* ニ?ベルングの指輪 */ - case BD_ROKISWEIL: /* ロキの叫び */ - case BD_INTOABYSS: /* 深淵の中に */ - case BD_SIEGFRIED: /* 不死身のジ?クフリ?ド */ - ux+=(i%9-4); - uy+=(i/9-4); - if(i==40) - range=4; /* 中心の場合は範?を4にオ?バ?ライド */ - else - range=-1; /* 中心じゃない場合は範?を-1にオ?バ?ライド */ - break; - case BA_DISSONANCE: /* 不協和音 */ - case BA_WHISTLE: /* 口笛 */ - case BA_ASSASSINCROSS: /* 夕陽のアサシンクロス */ - case BA_POEMBRAGI: /* ブラギの詩 */ - case BA_APPLEIDUN: /* イドゥンの林檎 */ - case DC_UGLYDANCE: /* 自分勝手なダンス */ - case DC_HUMMING: /* ハミング */ - case DC_DONTFORGETME: /* 私を忘れないで… */ - case DC_FORTUNEKISS: /* 幸運のキス */ - case DC_SERVICEFORYOU: /* サ?ビスフォ?ユ? */ -// case CG_MOONLIT: - ux+=(i%7-3); - uy+=(i/7-3); - if(i==40) - range=4; /* 中心の場合は範?を4にオ?バ?ライド */ - else - range=-1; /* 中心じゃない場合は範?を-1にオ?バ?ライド */ - break; - case PA_GOSPEL: /* ゴスペル */ - ux+=(i%7-3); - uy+=(i/7-3); - break; - case PF_FOGWALL: /* フォグウォ?ル */ - ux+=(i%5-2); - uy+=(i/5-1); break; case RG_GRAFFITI: /* Graffiti [Valaris] */ ux+=(i%5-2); @@ -5603,7 +5222,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, unit->val2=val2; unit->limit=limit; unit->range=range; - + // [celest] if (sc_data) { // attach the unit's id to the caster @@ -5642,6 +5261,10 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid, break; } } + if (range==0) + map_foreachinarea(skill_unit_effect,unit->bl.m + ,unit->bl.x,unit->bl.y,unit->bl.x,unit->bl.y + ,0,&unit->bl,gettick(),1); } } return group; @@ -5655,123 +5278,284 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int { struct skill_unit_group *sg; struct block_list *ss; - struct skill_unit_group_tickset *ts; - struct map_session_data *srcsd=NULL; - int diff,goflag,splash_count=0; + struct skill_unit *unit2; struct status_change *sc_data; + int type; nullpo_retr(0, src); nullpo_retr(0, bl); - sc_data = status_get_sc_data(bl); - - if( bl->prev==NULL || !src->alive || (bl->type == BL_PC && pc_isdead((struct map_session_data *)bl) ) ) + + if(bl->prev==NULL || !src->alive || + (bl->type == BL_PC && pc_isdead((struct map_session_data *)bl))) return 0; nullpo_retr(0, sg=src->group); nullpo_retr(0, ss=map_id2bl(sg->src_id)); + + sc_data = status_get_sc_data(bl); + type = SkillStatusChangeTable[sg->skill_id]; - if(ss->type == BL_PC) - nullpo_retr(0, srcsd=(struct map_session_data *)ss); - if(srcsd && srcsd->chatID) + if (battle_check_target(&src->bl,bl,sg->target_flag)<=0) return 0; - if( bl->type != BL_PC && bl->type != BL_MOB ) + // 対象がLP上に居る場合は無効 + if (map_find_skill_unit_oncell(bl,bl->x,bl->y,SA_LANDPROTECTOR,NULL)) return 0; - nullpo_retr(0, ts = skill_unitgrouptickset_search(bl, sg)); - diff=DIFF_TICK(tick,ts->tick); - goflag=(diff>sg->interval || diff<0); - if (sg->skill_id == CR_GRANDCROSS && !battle_config.gx_allhit) // 重なっていたら3HITしない - goflag = (diff>sg->interval*map_count_oncell(bl->m,bl->x,bl->y) || diff<0); - - //?象がLP上に居る場合は無? - map_foreachinarea(skill_landprotector,bl->m,bl->x,bl->y,bl->x,bl->y,BL_SKILL,0,&goflag); - if(!goflag) - return 0; - ts->tick=tick; + switch (sg->unit_id) { + case 0x85: /* ニューマ */ + case 0x7e: /* セイフティウォール */ + if (sc_data && sc_data[type].timer == -1) + status_change_start(bl,type,sg->skill_lv,(int)src,0,0,0,0); + break; - switch(sg->unit_id){ - case 0x83: /* サンクチュアリ */ - { - int race=status_get_race(bl); - int damage_flag = (battle_check_undead(race,status_get_elem_type(bl)) || race == 6)? 1:0; + case 0x80: /* ワープポータル(発動後) */ + if(bl->type==BL_PC){ + struct map_session_data *sd = (struct map_session_data *)bl; + if(sd && src->bl.m == bl->m && src->bl.x == bl->x && src->bl.y == bl->y && + src->bl.x == sd->to_x && src->bl.y == sd->to_y) { + if( battle_config.chat_warpportal || !sd->chatID ){ + pc_setpos(sd,sg->valstr,sg->val2>>16,sg->val2&0xffff,3); + if(sg->src_id == bl->id || (strcmp(map[src->bl.m].name,sg->valstr) == 0 && + src->bl.x == (sg->val2>>16) && src->bl.y == (sg->val2&0xffff) )) + skill_delunitgroup(sg); + if (--sg->val1<=0) + skill_delunitgroup(sg); + } + } + } else if(bl->type==BL_MOB && battle_config.mob_warpportal){ + int m = map_mapname2mapid(sg->valstr); + mob_warp((struct mob_data *)bl,m,sg->val2>>16,sg->val2&0xffff,3); + } + break; - if( status_get_hp(bl)>=status_get_max_hp(bl) && !damage_flag) - break; + case 0x8e: /* クァグマイア */ + if(bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_magic_damage ) + break; + if(sc_data && sc_data[type].timer==-1) + status_change_start(bl,type,sg->skill_lv,(int)src,0,0, + skill_get_time2(sg->skill_id,sg->skill_lv),0); + break; - if((sg->val1--)<=0){ - skill_delunitgroup(sg); - return 0; - } - if(!damage_flag) { - int heal=sg->val2; - if( bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_magic_damage) - heal=0; /* ?金蟲カ?ド(ヒ?ル量0) */ - clif_skill_nodamage(&src->bl,bl,AL_HEAL,heal,1); - battle_heal(NULL,bl,heal,0,0); - } - else { - // reduce healing count if this was meant for damaging [celest] - sg->val1 /= 2; - skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); - } + case 0x9a: /* ボルケ?ノ */ + case 0x9b: /* デリュ?ジ */ + case 0x9c: /* バイオレントゲイル */ + if (sc_data && sc_data[type].timer!=-1) { + unit2 = (struct skill_unit *)sc_data[type].val4; + if (unit2 && unit2->group && + (unit2==src || DIFF_TICK(sg->tick,unit2->group->tick)<=0)) + break; } + status_change_start(bl,type,sg->skill_lv,(int)src,0,0, + skill_get_time2(sg->skill_id,sg->skill_lv),0); break; - case 0x84: /* マグヌスエクソシズム */ - { - int race=status_get_race(bl); - int damage_flag = (battle_check_undead(race,status_get_elem_type(bl)) || race == 6)? 1:0; + case 0x9e: /* 子守唄 */ + case 0x9f: /* ニヨルドの宴 */ + case 0xa0: /* 永遠の混沌 */ + case 0xa1: /* ?太鼓の響き */ + case 0xa2: /* ニ?ベルングの指輪 */ + case 0xa3: /* ロキの叫び */ + case 0xa4: /* 深淵の中に */ + case 0xa5: /* 不死身のジ?クフリ?ド */ + case 0xa6: /* 不協和音 */ + case 0xa7: /* 口笛 */ + case 0xa8: /* 夕陽のアサシンクロス */ + case 0xa9: /* ブラギの詩 */ + case 0xaa: /* イドゥンの林檎 */ + case 0xab: /* 自分勝手なダンス */ + case 0xac: /* ハミング */ + case 0xad: /* 私を忘れないで… */ + case 0xae: /* 幸運のキス */ + case 0xaf: /* サ?ビスフォ?ユ? */ + case 0xb4: + if (sg->src_id==bl->id) + break; + if (sc_data && sc_data[type].timer!=-1) { + unit2 = (struct skill_unit *)sc_data[type].val4; + if (unit2 && unit2->group && + (unit2 == src || DIFF_TICK(sg->tick,unit2->group->tick)<=0)) + break; + } + status_change_start(bl,type,sg->skill_lv,sg->val1,sg->val2, + (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); + break; - if(!damage_flag) - return 0; - skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); + case 0xb6: /* フォグウォ?ル */ + if (sc_data && sc_data[type].timer!=-1) { + unit2 = (struct skill_unit *)sc_data[type].val4; + if (unit2 && unit2->group && + (unit2 == src || DIFF_TICK(sg->tick,unit2->group->tick)<=0)) + break; } + status_change_start(bl,type,sg->skill_lv,sg->val1,sg->val2, + (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); + skill_additional_effect(ss,bl,sg->skill_id,sg->skill_lv,BF_MISC,tick); break; - case 0x85: /* ニュ?マ */ + // New guild skills [Celest] + case 0xc1: // GD_LEADERSHIP { - struct skill_unit *unit2; - int type=SC_PNEUMA; - if(sc_data) { - if (sc_data[type].timer==-1) - status_change_start(bl,type,sg->skill_lv,(int)src,0,0,0,0); - else if((unit2 = (struct skill_unit *)sc_data[type].val2) && unit2 != src){ - if(unit2 && unit2->group && DIFF_TICK(sg->tick,unit2->group->tick) > 0) - status_change_start(bl,type,sg->skill_lv,(int)src,0,0,0,0); - ts->tick-=sg->interval; + struct map_session_data *sd, *tsd; + tsd=(struct map_session_data *)ss; + if (tsd && (sd=(struct map_session_data *)bl) && + sd->status.guild_id == tsd->status.guild_id && + sd != tsd) { + sd->state.leadership_flag = (int)src; + status_calc_pc (sd, 0); + } + } + break; + case 0xc2: // GD_GLORYWOUNDS + { + struct map_session_data *sd, *tsd; + tsd=(struct map_session_data *)ss; + if (tsd && (sd=(struct map_session_data *)bl) && + sd->status.guild_id == tsd->status.guild_id && + sd != tsd) { + sd->state.glorywounds_flag = (int)src; + status_calc_pc (sd, 0); + } + } + break; + case 0xc3: // GD_SOULCOLD + { + struct map_session_data *sd, *tsd; + tsd=(struct map_session_data *)ss; + if (tsd && (sd=(struct map_session_data *)bl) && + sd->status.guild_id == tsd->status.guild_id && + sd != tsd) { + sd->state.soulcold_flag = (int)src; + status_calc_pc (sd, 0); } - } } break; - case 0x7e: /* セイフティウォ?ル */ - if (sc_data) { - status_change_start(bl,SC_SAFETYWALL,sg->skill_lv,(int)src,0,0,0,0); - ts->tick-=sg->interval; + case 0xc4: // GD_HAWKEYES + { + struct map_session_data *sd, *tsd; + tsd=(struct map_session_data *)ss; + if (tsd && (sd=(struct map_session_data *)bl) && + sd->status.guild_id == tsd->status.guild_id && + sd != tsd) { + sd->state.hawkeyes_flag = (int)src; + status_calc_pc (sd, 0); + } } break; - case 0x86: /* ロ?ドオブヴァ?ミリオン(&スト?ムガスト &グランドクロス) */ - skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); + case 0xb2: /* あなたを_?いたいです */ + case 0xb3: /* ゴスペル */ + //case 0xb6: /* フォグウォ?ル */ - moved [celest] + //とりあえず何もしない break; + /* default: + if(battle_config.error_log) + printf("skill_unit_onplace: Unknown skill unit id=%d block=%d\n",sg->unit_id,bl->id); + break;*/ + } + + return 0; +} + +/*========================================== + * スキルユニットの発動イベント(タイマー発動) + *------------------------------------------ + */ +int skill_unit_onplace_timer(struct skill_unit *src,struct block_list *bl,unsigned int tick) +{ + struct skill_unit_group *sg; + struct block_list *ss; + int splash_count=0; + struct status_change *sc_data; + struct skill_unit_group_tickset *ts; + int type; + int diff=0; + + nullpo_retr(0, src); + nullpo_retr(0, bl); + + if (bl->type!=BL_PC && bl->type!=BL_MOB) + return 0; + + if (bl->prev==NULL || !src->alive || + (bl->type==BL_PC && pc_isdead((struct map_session_data *)bl))) + return 0; + + nullpo_retr(0, sg=src->group); + nullpo_retr(0, ss=map_id2bl(sg->src_id)); + sc_data = status_get_sc_data(bl); + type = SkillStatusChangeTable[sg->skill_id]; + + // 対象がLP上に居る場合は無効 + if (map_find_skill_unit_oncell(bl,bl->x,bl->y,SA_LANDPROTECTOR,NULL)) + return 0; + + // 前に影響を受けてからintervalの間は影響を受けない + nullpo_retr(0,ts = skill_unitgrouptickset_search(bl,sg,tick)); + diff = DIFF_TICK(tick,ts->tick); + if (sg->skill_id == PR_SANCTUARY) + diff += 500; // 新規に回復したユニットだけカウントするための仕掛け + if (diff < 0) + return 0; + ts->tick = tick+sg->interval; + // GXは重なっていたら3HITしない + if (sg->skill_id==CR_GRANDCROSS && !battle_config.gx_allhit) + ts->tick += sg->interval*(map_count_oncell(bl->m,bl->x,bl->y)-1); - case 0x7f: /* ファイヤ?ウォ?ル */ - if( (src->val2--)>0) - skill_attack(BF_MAGIC,ss,&src->bl,bl, - sg->skill_id,sg->skill_lv,tick,0); - if( src->val2<=0 ) + switch (sg->unit_id) { + case 0x83: /* サンクチュアリ */ + { + int race=status_get_race(bl); + + if (battle_check_undead(race,status_get_elem_type(bl)) || race==6) { + if (skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0)) { + // reduce healing count if this was meant for damaging [celest] + // sg->val1 /= 2; + sg->val1--; // チャットキャンセルに対応 + } + } else { + int heal = sg->val2; + if (status_get_hp(bl)>=status_get_max_hp(bl)) + break; + if(bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_magic_damage) + heal=0; /* 黄金蟲カード(ヒール量0) */ + clif_skill_nodamage(&src->bl,bl,AL_HEAL,heal,1); + battle_heal(NULL,bl,heal,0,0); + if (diff>=500) + sg->val1--; // 新規に入ったユニットだけカウント + } + if (sg->val1<=0) + skill_delunitgroup(sg); + break; + } + + case 0x84: /* マグヌスエクソシズム */ + { + int race = status_get_race(bl); + if (!battle_check_undead(race,status_get_elem_type(bl)) && race!=6) + return 0; + skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); + src->val2++; + break; + } + + case 0x7f: /* ファイヤーウォール */ + skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); + if (--src->val2<=0) skill_delunit(src); break; - - case 0x87: /* ファイア?ピラ?(?動前) */ + case 0x86: /* ロードオブヴァーミリオン(TS,MS,FN,SG,HD,GX,闇GX) */ + skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); + break; + case 0x87: /* ファイアーピラー(発動前) */ skill_delunit(src); skill_unitsetting(ss,sg->skill_id,sg->skill_lv,src->bl.x,src->bl.y,1); break; - case 0x88: /* ファイア?ピラ?(?動後) */ - if(DIFF_TICK(tick,sg->tick) < 150) - //skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); - map_foreachinarea(skill_attack_area,bl->m,bl->x-1,bl->y-1,bl->x+1,bl->y+1,0,BF_MAGIC,ss,&src->bl,sg->skill_id,sg->skill_lv,tick,0,BCT_ENEMY); // area damage [Celest] + case 0x88: /* ファイアーピラー(発動後) */ + map_foreachinarea(skill_attack_area,bl->m,bl->x-1,bl->y-1,bl->x+1,bl->y+1,0, + BF_MAGIC,ss,&src->bl,sg->skill_id,sg->skill_lv,tick,0,BCT_ENEMY); // area damage [Celest] + //skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); break; case 0x90: /* スキッドトラップ */ @@ -5784,7 +5568,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int clif_changelook(&src->bl,LOOK_BASE,sg->unit_id); sg->limit=DIFF_TICK(tick,sg->tick)+1500; } - break; + break; case 0x93: /* ランドマイン */ skill_attack(BF_MISC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); @@ -5813,22 +5597,22 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int break; case 0x91: /* アンクルスネア */ - { - struct status_change *sc_data=status_get_sc_data(bl); - if(sg->val2==0 && sc_data && sc_data[SC_ANKLE].timer==-1){ - int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE); - int sec = skill_get_time2(sg->skill_id,sg->skill_lv) - status_get_agi(bl)*100; - if(status_get_mode(bl)&0x20) - sec = sec/5; - if (sec < 3000) // minimum time of 3 seconds [celest] - sec = 3000; - battle_stopwalking(bl,1); - status_change_start(bl,SC_ANKLE,sg->skill_lv,0,0,0,sec,0); - + if(sg->val2==0 && sc_data && sc_data[SC_ANKLE].timer==-1){ + int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE); + int sec = skill_get_time2(sg->skill_id,sg->skill_lv) - status_get_agi(bl)*100; + if(status_get_mode(bl)&0x20) + sec = sec/5; + if (sec < 3000) // minimum time of 3 seconds [celest] + sec = 3000; + battle_stopwalking(bl,1); + status_change_start(bl,SC_ANKLE,sg->skill_lv,0,0,0,sec,0); + + skill_unit_move(bl,tick,0); if(moveblock) map_delblock(bl); bl->x = src->bl.x; bl->y = src->bl.y; if(moveblock) map_addblock(bl); + skill_unit_move(bl,tick,1); if(bl->type == BL_MOB) clif_fixmobpos((struct mob_data *)bl); else if(bl->type == BL_PET) @@ -5836,156 +5620,26 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int else clif_fixpos(bl); clif_01ac(&src->bl); - sg->limit=DIFF_TICK(tick,sg->tick) + sec; + sg->limit=DIFF_TICK(tick,sg->tick) + sec; sg->val2=bl->id; - } + sg->interval = -1; + src->range = 0; } break; - case 0x80: /* ワ?プポ?タル(?動後) */ - if(bl->type==BL_PC){ - struct map_session_data *sd = (struct map_session_data *)bl; - if(sd && src->bl.m == bl->m && src->bl.x == bl->x && src->bl.y == bl->y && src->bl.x == sd->to_x && src->bl.y == sd->to_y) { - if( battle_config.chat_warpportal || !sd->chatID ){ - if((sg->val1--)>0){ - pc_setpos(sd,sg->valstr,sg->val2>>16,sg->val2&0xffff,3); - if(sg->src_id == bl->id ||( strcmp(map[src->bl.m].name,sg->valstr) == 0 && src->bl.x == (sg->val2>>16) && src->bl.y == (sg->val2&0xffff) )) - skill_delunitgroup(sg); - }else - skill_delunitgroup(sg); - } - } - }else if(bl->type==BL_MOB && battle_config.mob_warpportal){ - int m=map_mapname2mapid(sg->valstr); - struct mob_data *md; - md=(struct mob_data *)bl; - mob_warp((struct mob_data *)bl,m,sg->val2>>16,sg->val2&0xffff,3); - } - break; - - case 0x8e: /* クァグマイア */ - { - struct status_change *sc_data=status_get_sc_data(bl); - int type=SkillStatusChangeTable[sg->skill_id]; - if( bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_magic_damage ) - break; - if(sc_data && sc_data[type].timer==-1) - status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); - } - break; case 0x92: /* ベノムダスト */ - { - struct status_change *sc_data=status_get_sc_data(bl); - int type=SkillStatusChangeTable[sg->skill_id]; - if(sc_data && sc_data[type].timer==-1 ) - status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); - } + if(sc_data && sc_data[type].timer==-1 ) + status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); break; - case 0x9a: /* ボルケ?ノ */ - case 0x9b: /* デリュ?ジ */ - case 0x9c: /* バイオレントゲイル */ - { - struct skill_unit *unit2; - struct status_change *sc_data=status_get_sc_data(bl); - int type=SkillStatusChangeTable[sg->skill_id]; - if(sc_data) { - if (sc_data[type].timer==-1) - status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); - else if((unit2=(struct skill_unit *)sc_data[type].val2) && unit2 != src ){ - if(unit2 && unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) - status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0); - ts->tick-=sg->interval; - } - } - } break; - - case 0x9e: /* 子守唄 */ - case 0x9f: /* ニヨルドの宴 */ - case 0xa0: /* 永遠の混沌 */ - case 0xa1: /* ?太鼓の響き */ - case 0xa2: /* ニ?ベルングの指輪 */ - case 0xa3: /* ロキの叫び */ - case 0xa4: /* 深淵の中に */ - case 0xa5: /* 不死身のジ?クフリ?ド */ - case 0xa6: /* 不協和音 */ - case 0xa7: /* 口笛 */ - case 0xa8: /* 夕陽のアサシンクロス */ - case 0xa9: /* ブラギの詩 */ - case 0xab: /* 自分勝手なダンス */ - case 0xac: /* ハミング */ - case 0xad: /* 私を忘れないで… */ - case 0xae: /* 幸運のキス */ - case 0xaf: /* サ?ビスフォ?ユ? */ - case 0xb4: -// case 0xb6: /* フォグウォ?ル */ - { - struct skill_unit *unit2; - struct status_change *sc_data=status_get_sc_data(bl); - int type=SkillStatusChangeTable[sg->skill_id]; - if(sg->src_id == bl->id) - break; - if(sc_data) { - if (sc_data[type].timer==-1) - status_change_start(bl,type,sg->skill_lv,sg->val1,sg->val2, - (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); - else if( (unit2=(struct skill_unit *)sc_data[type].val4) && unit2 != src ){ - if(unit2 && unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) - status_change_start(bl,type,sg->skill_lv,sg->val1,sg->val2, - (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); - ts->tick-=sg->interval; - } - } - } break; - - case 0xaa: /* イドゥンの林檎 */ - { - struct skill_unit *unit2; - struct status_change *sc_data=status_get_sc_data(bl); - int type=SkillStatusChangeTable[sg->skill_id]; - if(sg->src_id == bl->id) - break; - if(sc_data) { - if (sc_data[type].timer==-1) - status_change_start(bl,type,sg->skill_lv,(sg->val1)>>16,(sg->val1)&0xffff, - (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); - else if((unit2=(struct skill_unit *)sc_data[type].val4) && unit2 != src ){ - if(unit2 && unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) - status_change_start(bl,type,sg->skill_lv,(sg->val1)>>16,(sg->val1)&0xffff, - (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); - ts->tick-=sg->interval; - } - } - } break; - - case 0xb6: /* フォグウォ?ル */ - { - struct skill_unit *unit2; - struct status_change *sc_data=status_get_sc_data(bl); - int type=SkillStatusChangeTable[sg->skill_id]; - if(sc_data) { - if (sc_data[type].timer==-1) { - status_change_start(bl,type,sg->skill_lv,sg->val1,sg->val2, - (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); - skill_additional_effect(ss,bl,sg->skill_id,sg->skill_lv,BF_MISC,tick); - } - else if( (unit2=(struct skill_unit *)sc_data[type].val4) && unit2 != src ){ - if(unit2 && unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 ) { - status_change_start(bl,type,sg->skill_lv,sg->val1,sg->val2, - (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); - skill_additional_effect(ss,bl,sg->skill_id,sg->skill_lv,BF_MISC,tick); - } -// ts->tick-=sg->interval; - } - } - } break; case 0xb1: /* デモンストレ?ション */ skill_attack(BF_WEAPON,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); if(bl->type == BL_PC && rand()%100 < sg->skill_lv && battle_config.equipment_breaking) pc_breakweapon((struct map_session_data *)bl); break; - case 0x99: /* ト?キ?ボックス */ - if(sg->src_id == bl->id) //自分が踏んでも?動しない + + case 0x99: /* トーキーボックス */ + if(sg->src_id == bl->id) //自分が踏んでも発動しない break; if(sg->val2==0){ clif_talkiebox(&src->bl,sg->valstr); @@ -5994,76 +5648,41 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int sg->limit=DIFF_TICK(tick,sg->tick)+5000; sg->val2=-1; //踏んだ } - break; - case 0xb2: /* あなたを_?いたいです */ - case 0xb3: /* ゴスペル */ - //case 0xb6: /* フォグウォ?ル */ - moved [celest] - //とりあえず何もしない - break; + break; + + //case 0xb4: /* バジリカ */ + /*if (battle_check_target(&src->bl,bl,BCT_ENEMY)>0 && + !(status_get_mode(bl)&0x20)) + skill_blown(&src->bl,bl,1); + if (sg->src_id==bl->id) + break; + if (battle_check_target(&src->bl,bl,BCT_NOENEMY)>0) { + type = SkillStatusChangeTable[sg->skill_id]; + status_change_start(bl,type,sg->skill_lv,sg->val1,sg->val2, + (int)src,sg->interval+100,0); + } + break;*/ case 0xb7: /* スパイダ?ウェッブ */ if(sg->val2==0){ int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE); skill_additional_effect(ss,bl,sg->skill_id,sg->skill_lv,BF_MISC,tick); + skill_unit_move(bl,tick,0); if(moveblock) map_delblock(bl); - bl->x = (&src->bl)->x; - bl->y = (&src->bl)->y; + bl->x = src->bl.x; + bl->y = src->bl.y; if(moveblock) map_addblock(bl); - if(bl->type == BL_MOB) - clif_fixmobpos((struct mob_data *)bl); - else if(bl->type == BL_PET) - clif_fixpetpos((struct pet_data *)bl); - else - clif_fixpos(bl); - clif_01ac(&src->bl); - sg->limit=DIFF_TICK(tick,sg->tick) + skill_get_time2(sg->skill_id,sg->skill_lv); + skill_unit_move(bl,tick,1); + if(bl->type == BL_MOB) + clif_fixmobpos((struct mob_data *)bl); + else if(bl->type == BL_PET) + clif_fixpetpos((struct pet_data *)bl); + else + clif_fixpos(bl); + sg->limit = DIFF_TICK(tick,sg->tick)+skill_get_time2(sg->skill_id,sg->skill_lv); sg->val2=bl->id; - } - break; - - // New guild skills [Celest] - case 0xc1: // GD_LEADERSHIP - { - struct map_session_data *sd; - if (srcsd && bl->type == BL_PC && (sd=(struct map_session_data *)bl) && - sd->status.guild_id == srcsd->status.guild_id && - sd != srcsd) { - sd->state.leadership_flag = (int)src; - status_calc_pc (sd, 0); - } - } - break; - case 0xc2: // GD_GLORYWOUNDS - { - struct map_session_data *sd; - if (srcsd && bl->type == BL_PC && (sd=(struct map_session_data *)bl) && - sd->status.guild_id == srcsd->status.guild_id && - sd != srcsd) { - sd->state.glorywounds_flag = (int)src; - status_calc_pc (sd, 0); - } - } - break; - case 0xc3: // GD_SOULCOLD - { - struct map_session_data *sd; - if (srcsd && bl->type == BL_PC && (sd=(struct map_session_data *)bl) && - sd->status.guild_id == srcsd->status.guild_id && - sd != srcsd) { - sd->state.soulcold_flag = (int)src; - status_calc_pc (sd, 0); - } - } - break; - case 0xc4: // GD_HAWKEYES - { - struct map_session_data *sd; - if (srcsd && bl->type == BL_PC && (sd=(struct map_session_data *)bl) && - sd->status.guild_id == srcsd->status.guild_id && - sd != srcsd) { - sd->state.hawkeyes_flag = (int)src; - status_calc_pc (sd, 0); - } + sg->interval = -1; + src->range = 0; } break; @@ -6072,6 +5691,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int printf("skill_unit_onplace: Unknown skill unit id=%d block=%d\n",sg->unit_id,bl->id); break;*/ } + if(bl->type==BL_MOB && ss!=bl) /* スキル使用?件のMOBスキル */ { if(battle_config.mob_changetarget_byskill == 1) @@ -6095,77 +5715,41 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int int skill_unit_onout(struct skill_unit *src,struct block_list *bl,unsigned int tick) { struct skill_unit_group *sg; + struct status_change *sc_data; + int type; nullpo_retr(0, src); nullpo_retr(0, bl); nullpo_retr(0, sg=src->group); + sc_data = status_get_sc_data(bl); + type = SkillStatusChangeTable[sg->skill_id]; - if( bl->prev==NULL || !src->alive ) - return 0; - - if( bl->type!=BL_PC && bl->type!=BL_MOB ) + if (bl->prev==NULL || !src->alive || + (bl->type == BL_PC && pc_isdead((struct map_session_data *)bl))) return 0; switch(sg->unit_id){ - case 0x7e: /* セイフティウォ?ル */ - case 0x85: /* ニュ?マ */ + case 0x7e: /* セイフティウォール */ + case 0x85: /* ニューマ */ case 0x8e: /* クァグマイア */ - { - struct status_change *sc_data=status_get_sc_data(bl); - int type= - (sg->unit_id==0x85)?SC_PNEUMA: - ((sg->unit_id==0x7e)?SC_SAFETYWALL: - SC_QUAGMIRE); - if((type != SC_QUAGMIRE || bl->type != BL_MOB) && - sc_data && sc_data[type].timer!=-1 && ((struct skill_unit *)sc_data[type].val2)==src){ - status_change_end(bl,type,-1); - } - } break; - - case 0x91: /* アンクルスネア */ - { - struct block_list *target=map_id2bl(sg->val2); - if( target && target==bl ){ - status_change_end(bl,SC_ANKLE,-1); - sg->limit=DIFF_TICK(tick,sg->tick)+1000; - } + case 0x9a: /* ボルケーノ */ + case 0x9b: /* デリュージ */ + case 0x9c: /* バイオレントゲイル */ + if (type==SC_QUAGMIRE && bl->type==BL_MOB) + break; + if (sc_data && sc_data[type].timer!=-1 && sc_data[type].val2==(int)src) { + status_change_end(bl,type,-1); } break; -// case 0xb5: - case 0xb8: - { - struct block_list *target=map_id2bl(sg->val2); - if( target==bl ) - status_change_end(bl,SC_SPIDERWEB,-1); + case 0x91: /* アンクルスネア */ + { + struct block_list *target = map_id2bl(sg->val2); + if(target && target == bl){ + status_change_end(bl,SC_ANKLE,-1); sg->limit=DIFF_TICK(tick,sg->tick)+1000; } break; - case 0xb6: - { - struct block_list *target=map_id2bl(sg->val2); - struct status_change *sc_data=status_get_sc_data(bl); - if( target==bl ) { - status_change_end(bl,SC_FOGWALL,-1); - if (sc_data && sc_data[SC_BLIND].timer!=-1) - sc_data[SC_BLIND].timer = add_timer( - gettick() + 30000, status_change_timer, bl->id, 0); - } - //sg->limit=DIFF_TICK(tick,sg->tick)+1000; - } - break; - case 0x9a: /* ボルケ?ノ */ - case 0x9b: /* デリュ?ジ */ - case 0x9c: /* バイオレントゲイル */ - { - struct status_change *sc_data=status_get_sc_data(bl); - struct skill_unit *su; - int type=SkillStatusChangeTable[sg->skill_id]; - if( sc_data && sc_data[type].timer!=-1 && (su=((struct skill_unit *)sc_data[type].val2)) && su == src ){ - status_change_end(bl,type,-1); - } - } - break; - + } case 0x9e: /* 子守唄 */ case 0x9f: /* ニヨルドの宴 */ case 0xa0: /* 永遠の混沌 */ @@ -6185,24 +5769,32 @@ int skill_unit_onout(struct skill_unit *src,struct block_list *bl,unsigned int t case 0xae: /* 幸運のキス */ case 0xaf: /* サ?ビスフォ?ユ? */ case 0xb4: - { - struct status_change *sc_data=status_get_sc_data(bl); - struct skill_unit *su; - int type=SkillStatusChangeTable[sg->skill_id]; - if( sc_data && sc_data[type].timer!=-1 && (su=((struct skill_unit *)sc_data[type].val4)) && su == src ){ - status_change_end(bl,type,-1); - } + if (sc_data[type].timer!=-1 && sc_data[type].val4==(int)src) { + status_change_end(bl,type,-1); } break; + + case 0xb6: + { + struct block_list *target = map_id2bl(sg->val2); + if(target && target==bl) { + status_change_end(bl,SC_FOGWALL,-1); + if (sc_data && sc_data[SC_BLIND].timer!=-1) + sc_data[SC_BLIND].timer = add_timer( + gettick() + 30000, status_change_timer, bl->id, 0); + } + break; + } + case 0xb7: /* スパイダ?ウェッブ */ { - struct block_list *target=map_id2bl(sg->val2); - if( target && target==bl ) + struct block_list *target = map_id2bl(sg->val2); + if (target && target==bl) status_change_end(bl,SC_SPIDERWEB,-1); - sg->limit=DIFF_TICK(tick,sg->tick)+1000; + sg->limit = DIFF_TICK(tick,sg->tick)+1000; + break; } - break; - // New guild skills [Celest] + // New guild skills [Celest] case 0xc1: // GD_LEADERSHIP { struct map_session_data *sd; @@ -6231,73 +5823,53 @@ int skill_unit_onout(struct skill_unit *src,struct block_list *bl,unsigned int t sd->state.hawkeyes_flag = 0; } break; - /* default: if(battle_config.error_log) printf("skill_unit_onout: Unknown skill unit id=%d block=%d\n",sg->unit_id,bl->id); break;*/ } - skill_unitgrouptickset_delete(bl,sg); + return 0; } + /*========================================== - * スキルユニットの削除イベント + * スキルユニット効果発動/離脱処理(foreachinarea) + * bl: ユニット(BL_PC/BL_MOB) *------------------------------------------ */ -int skill_unit_ondelete(struct skill_unit *src,struct block_list *bl,unsigned int tick) +int skill_unit_effect(struct block_list *bl,va_list ap) { - struct skill_unit_group *sg; + struct skill_unit *unit; + struct skill_unit_group *group; + int flag; + unsigned int tick; - nullpo_retr(0, src); nullpo_retr(0, bl); - nullpo_retr(0, sg = src->group); + nullpo_retr(0, ap); + nullpo_retr(0, unit=va_arg(ap,struct skill_unit*)); + tick = va_arg(ap,unsigned int); + flag = va_arg(ap,unsigned int); - if( bl->prev==NULL || !src->alive ) + if (bl->type!=BL_PC && bl->type!=BL_MOB) return 0; - if( bl->type!=BL_PC && bl->type!=BL_MOB ) + if (!unit->alive || bl->prev==NULL) return 0; - switch(sg->unit_id){ - case 0x85: /* ニュ?マ */ - case 0x7e: /* セイフティウォ?ル */ - case 0x8e: /* クァグマイヤ */ - case 0x9a: /* ボルケ?ノ */ - case 0x9b: /* デリュ?ジ */ - case 0x9c: /* バイオレントゲイル */ - case 0x9e: /* 子守唄 */ - case 0x9f: /* ニヨルドの宴 */ - case 0xa0: /* 永遠の混沌 */ - case 0xa1: /* ?太鼓の響き */ - case 0xa2: /* ニ?ベルングの指輪 */ - case 0xa3: /* ロキの叫び */ - case 0xa4: /* 深淵の中に */ - case 0xa5: /* 不死身のジ?クフリ?ド */ - case 0xa6: /* 不協和音 */ - case 0xa7: /* 口笛 */ - case 0xa8: /* 夕陽のアサシンクロス */ - case 0xa9: /* ブラギの詩 */ - case 0xaa: /* イドゥンの林檎 */ - case 0xab: /* 自分勝手なダンス */ - case 0xac: /* ハミング */ - case 0xad: /* 私を忘れないで… */ - case 0xae: /* 幸運のキス */ - case 0xaf: /* サ?ビスフォ?ユ? */ - case 0xb4: - case 0xc1: - case 0xc2: - case 0xc3: - case 0xc4: - return skill_unit_onout(src,bl,tick); + nullpo_retr(0, group=unit->group); -/* default: - if(battle_config.error_log) - printf("skill_unit_ondelete: Unknown skill unit id=%d block=%d\n",sg->unit_id,bl->id); - break;*/ + if (flag) + skill_unit_onplace(unit,bl,tick); + else { + skill_unit_onout(unit,bl,tick); + unit = map_find_skill_unit_oncell(bl,bl->x,bl->y,group->skill_id,unit); + if (unit) + skill_unit_onplace(unit,bl,tick); } - skill_unitgrouptickset_delete(bl,sg); + return 0; } + /*========================================== * スキルユニットの限界イベント *------------------------------------------ @@ -6435,10 +6007,7 @@ int skill_castend_pos( int tid, unsigned int tick, int id,int data ) return 0; } - if(battle_config.pc_skill_reiteration == 0) { - range = -1; - switch(sd->skillid) { - case MG_SAFETYWALL: + /*case MG_SAFETYWALL: case WZ_FIREPILLAR: case HT_SKIDTRAP: case HT_LANDMINE: @@ -6451,28 +6020,23 @@ int skill_castend_pos( int tid, unsigned int tick, int id,int data ) case HT_CLAYMORETRAP: case HT_TALKIEBOX: case AL_WARP: - case PF_SPIDERWEB: /* スパイダ?ウェッブ */ - case RG_GRAFFITI: /* グラフィティ */ + case PF_SPIDERWEB: + case RG_GRAFFITI: range = 0; break; case AL_PNEUMA: range = 1; - break; - } - if(range >= 0) { - if(skill_check_unit_range(sd->bl.m,sd->skillx,sd->skilly,range,sd->skillid) > 0) { - clif_skill_fail(sd,sd->skillid,0,0); - sd->canact_tick = tick; - sd->canmove_tick = tick; - sd->skillitem = sd->skillitemlv = -1; - return 0; - } - } + break;*/ + if (!battle_config.pc_skill_reiteration && + skill_get_unit_flag(sd->skillid)&UF_NOREITERATION && + skill_check_unit_range(sd->bl.m,sd->skillx,sd->skilly,sd->skillid,sd->skilllv)) { + clif_skill_fail(sd,sd->skillid,0,0); + sd->canact_tick = tick; + sd->canmove_tick = tick; + sd->skillitem = sd->skillitemlv = -1; + return 0; } - if(battle_config.pc_skill_nofootset) { - range = -1; - switch(sd->skillid) { - case WZ_FIREPILLAR: + /*case WZ_FIREPILLAR: case HT_SKIDTRAP: case HT_LANDMINE: case HT_ANKLESNARE: @@ -6483,25 +6047,22 @@ int skill_castend_pos( int tid, unsigned int tick, int id,int data ) case HT_BLASTMINE: case HT_CLAYMORETRAP: case HT_TALKIEBOX: - case PF_SPIDERWEB: /* スパイダ?ウェッブ */ + case PF_SPIDERWEB: case WZ_ICEWALL: range = 2; break; case AL_WARP: range = 0; - break; - } - if(range >= 0) { - if(skill_check_unit_range2(sd->bl.m,sd->skillx,sd->skilly,range) > 0) { - clif_skill_fail(sd,sd->skillid,0,0); - sd->canact_tick = tick; - sd->canmove_tick = tick; - sd->skillitem = sd->skillitemlv = -1; - return 0; - } - } + break;*/ + if (battle_config.pc_skill_nofootset && + skill_get_unit_flag(sd->skillid)&UF_NOFOOTSET && + skill_check_unit_range2(sd->bl.m,sd->skillx,sd->skilly,sd->skillid,sd->skilllv)) { + clif_skill_fail(sd,sd->skillid,0,0); + sd->canact_tick = tick; + sd->canmove_tick = tick; + sd->skillitem = sd->skillitemlv = -1; + return 0; } - if(battle_config.pc_land_skill_limit) { maxcount = skill_get_maxcount(sd->skillid); if(maxcount > 0) { @@ -7523,22 +7084,22 @@ int skill_use_id( struct map_session_data *sd, int target_id, return 0; } break; - // removed on 12/14's patch [celest] - //case AS_SPLASHER: /* ベナムスプラッシャ? */ - /* { - struct status_change *t_sc_data = status_get_sc_data(bl); - if(t_sc_data && t_sc_data[SC_POISON].timer==-1){ - clif_skill_fail(sd,skill_num,0,10); - return 0; - } - } - break;*/ case PF_MEMORIZE: /* メモライズ */ casttime = 12000; break; case HW_MAGICPOWER: casttime = 700; break; + case HP_BASILICA: /* バジリカ */ + if (skill_check_unit_range(sd->bl.m,sd->bl.x,sd->bl.y,sd->skillid,sd->skilllv)) { + clif_skill_fail(sd,sd->skillid,0,0); + return 0; + } + if (skill_check_unit_range2(sd->bl.m,sd->bl.x,sd->bl.y,sd->skillid,sd->skilllv)) { + clif_skill_fail(sd,sd->skillid,0,0); + return 0; + } + break; case GD_BATTLEORDER: case GD_REGENERATION: case GD_RESTORE: @@ -7991,13 +7552,14 @@ int skill_devotion3(struct block_list *bl,int target) int n,r=0; nullpo_retr(1, bl); + md = (struct map_session_data *)bl; - if( (md = (struct map_session_data *)bl) == NULL || (sd = map_id2sd(target)) == NULL ) + if ((sd = map_id2sd(target))==NULL) return 1; else r = distance(bl->x,bl->y,sd->bl.x,sd->bl.y); - if(pc_checkskill(sd,CR_DEVOTION)+6 < r){ // 許容範?を超えてた + if(pc_checkskill(md,CR_DEVOTION)+6 < r){ // 許容範?を超えてた for(n=0;n<5;n++) if(md->dev.val1[n]==target) md->dev.val2[n]=0; // 離れた時は、?を切るだけ @@ -8249,11 +7811,27 @@ int skill_abra_dataset(int skilllv) //NPCスキルはダメ if(skill >= NPC_PIERCINGATT && skill <= NPC_SUMMONMONSTER) return 0; //演奏スキルはダメ - if(skill_is_danceskill(skill)) return 0; + if (skill_get_unit_flag(skill)&UF_DANCE) return 0; return skill; } +/*========================================== + * バジリカのセルを設定する + *------------------------------------------ + */ +void skill_basilica_cell(struct skill_unit *unit,int flag) +{ + int i,x,y,range = skill_get_unit_range(HP_BASILICA); + int size = range*2+1; + + for (i=0;ibl.x+(i%size-range); + y = unit->bl.y+(i/size-range); + map_setcell(unit->bl.m,x,y,flag); + } +} + /*========================================== * *------------------------------------------ @@ -8293,16 +7871,20 @@ int skill_clear_element_field(struct block_list *bl) { struct mob_data *md=NULL; struct map_session_data *sd=NULL; - int i,skillid; + int i,max,skillid; nullpo_retr(0, bl); - if(bl->type==BL_MOB) - md=(struct mob_data *)bl; - if(bl->type==BL_PC) - sd=(struct map_session_data *)bl; + if (bl->type==BL_MOB) { + max = MAX_MOBSKILLUNITGROUP; + md = (struct mob_data *)bl; + } else if(bl->type==BL_PC) { + max = MAX_SKILLUNITGROUP; + sd = (struct map_session_data *)bl; + } else + return 0; - for(i=0;iskillunit[i].skill_id; if(skillid==SA_DELUGE||skillid==SA_VOLCANO||skillid==SA_VIOLENTGALE||skillid==SA_LANDPROTECTOR) @@ -8372,7 +7954,8 @@ int skill_idun_heal(struct block_list *bl, va_list ap ) * 指定範??でsrcに?して有?なタ?ゲットのblの?を?える(foreachinarea) *------------------------------------------ */ -int skill_count_target(struct block_list *bl, va_list ap ){ +int skill_count_target(struct block_list *bl, va_list ap) +{ struct block_list *src; int *c; @@ -8527,48 +8110,6 @@ int skill_type_cloaking(struct block_list *bl) *---------------------------------------------------------------------------- */ -/*========================================== - * 演奏/ダンススキルかどうか判定 - * 引? スキルID - * ?り ダンスじゃない=0 合奏=2 それ以外のダンス=1 - *------------------------------------------ - */ -int skill_is_danceskill(int id) -{ - int i; - switch(id){ - case BD_LULLABY: /* 子守歌 */ - case BD_RICHMANKIM: /* ニヨルドの宴 */ - case BD_ETERNALCHAOS: /* 永遠の混沌 */ - case BD_DRUMBATTLEFIELD: /* ?太鼓の響き */ - case BD_RINGNIBELUNGEN: /* ニ?ベルングの指輪 */ - case BD_ROKISWEIL: /* ロキの叫び */ - case BD_INTOABYSS: /* 深淵の中に */ - case BD_SIEGFRIED: /* 不死身のジ?クフリ?ド */ - case BD_RAGNAROK: /* 神?の?昏 */ - case CG_MOONLIT: /* 月明りの泉に落ちる花びら */ - i=2; - break; - case BA_DISSONANCE: /* 不協和音 */ - case BA_FROSTJOKE: /* 寒いジョ?ク */ - case BA_WHISTLE: /* 口笛 */ - case BA_ASSASSINCROSS: /* 夕陽のアサシンクロス */ - case BA_POEMBRAGI: /* ブラギの詩 */ - case BA_APPLEIDUN: /* イドゥンの林檎 */ - case DC_UGLYDANCE: /* 自分勝手なダンス */ - case DC_SCREAM: /* スクリ?ム */ - case DC_HUMMING: /* ハミング */ - case DC_DONTFORGETME: /* 私を忘れないで… */ - case DC_FORTUNEKISS: /* 幸運のキス */ - case DC_SERVICEFORYOU: /* サ?ビスフォ?ユ? */ - i=1; - break; - default: - i=0; - } - return i; -} - /*========================================== * 演奏/ダンスをやめる * flag 1で合奏中なら相方にユニットを任せる @@ -8650,10 +8191,13 @@ struct skill_unit *skill_initunit(struct skill_unit_group *group,int idx,int x,i map_addblock(&unit->bl); clif_skill_setunit(unit); + +// if (group->skill_id==HP_BASILICA) +// skill_basilica_cell(unit,CELL_SETBASILICA); + return unit; } -int skill_unit_timer_sub_ondelete( struct block_list *bl, va_list ap ); /*========================================== * スキルユニット削除 *------------------------------------------ @@ -8661,7 +8205,6 @@ int skill_unit_timer_sub_ondelete( struct block_list *bl, va_list ap ); int skill_delunit(struct skill_unit *unit) { struct skill_unit_group *group; - int range; nullpo_retr(0, unit); if(!unit->alive) @@ -8671,11 +8214,15 @@ int skill_delunit(struct skill_unit *unit) /* onlimitイベント呼び出し */ skill_unit_onlimit( unit,gettick() ); - /* ondeleteイベント呼び出し */ - range=group->range; - map_foreachinarea( skill_unit_timer_sub_ondelete, unit->bl.m, - unit->bl.x-range,unit->bl.y-range,unit->bl.x+range,unit->bl.y+range,0, - &unit->bl,gettick() ); + /* onoutイベント呼び出し */ + if (!unit->range) { + map_foreachinarea(skill_unit_effect,unit->bl.m, + unit->bl.x,unit->bl.y,unit->bl.x,unit->bl.y,0, + &unit->bl,gettick(),0); + } + +// if (group->skill_id==HP_BASILICA) +// skill_basilica_cell(unit,CELL_CLRBASILICA); clif_skill_delunit(unit); @@ -8691,7 +8238,7 @@ int skill_delunit(struct skill_unit *unit) * スキルユニットグル?プ初期化 *------------------------------------------ */ -static int skill_unit_group_newid=10; +static int skill_unit_group_newid = MAX_SKILL_DB; struct skill_unit_group *skill_initunitgroup(struct block_list *src, int count,int skillid,int skilllv,int unit_id) { @@ -8743,7 +8290,7 @@ struct skill_unit_group *skill_initunitgroup(struct block_list *src, group->guild_id=status_get_guild_id(src); group->group_id=skill_unit_group_newid++; if(skill_unit_group_newid<=0) - skill_unit_group_newid=10; + skill_unit_group_newid = MAX_SKILL_DB; group->unit=(struct skill_unit *)aCalloc(count,sizeof(struct skill_unit)); group->unit_count=count; group->val1=group->val2=0; @@ -8751,39 +8298,23 @@ struct skill_unit_group *skill_initunitgroup(struct block_list *src, group->skill_lv=skilllv; group->unit_id=unit_id; group->map=src->m; - group->range=0; group->limit=10000; group->interval=1000; group->tick=gettick(); group->valstr=NULL; - if( skill_is_danceskill(skillid) ){ + if (skill_get_unit_flag(skillid)&UF_DANCE) { struct map_session_data *sd = NULL; if(src->type==BL_PC && (sd=(struct map_session_data *)src) ){ sd->skillid_dance=skillid; sd->skilllv_dance=skilllv; } status_change_start(src,SC_DANCING,skillid,(int)group,0,0,skill_get_time(skillid,skilllv)+1000,0); - switch(skillid){ //合奏スキルは相方をダンス?態にする - case BD_LULLABY: /* 子守歌 */ - case BD_RICHMANKIM: /* ニヨルドの宴 */ - case BD_ETERNALCHAOS: /* 永遠の混沌 */ - case BD_DRUMBATTLEFIELD: /* ?太鼓の響き */ - case BD_RINGNIBELUNGEN: /* ニ?ベルングの指輪 */ - case BD_ROKISWEIL: /* ロキの叫び */ - case BD_INTOABYSS: /* 深淵の中に */ - case BD_SIEGFRIED: /* 不死身のジ?クフリ?ド */ - case BD_RAGNAROK: /* 神?の?昏 */ - case CG_MOONLIT: /* 月明りの泉に落ちる花びら */ - { - int range=1; - int c=0; - if(sd){ - map_foreachinarea(skill_check_condition_use_sub,sd->bl.m, - sd->bl.x-range,sd->bl.y-range, - sd->bl.x+range,sd->bl.y+range,BL_PC,&sd->bl,&c); - } - } + //合奏スキルは相方をダンス状態にする + if (sd && skill_get_unit_flag(skillid)&UF_ENSEMBLE) { + int c=0; + map_foreachinarea(skill_check_condition_use_sub,sd->bl.m, + sd->bl.x-1,sd->bl.y-1,sd->bl.x+1,sd->bl.y+1,BL_PC,&sd->bl,&c); } } return group; @@ -8803,7 +8334,8 @@ int skill_delunitgroup(struct skill_unit_group *group) return 0; src=map_id2bl(group->src_id); - if( skill_is_danceskill(group->skill_id) ){ //ダンススキルはダンス?態を解除する + //ダンススキルはダンス状態を解除する + if (skill_get_unit_flag(group->skill_id)&UF_DANCE) { if(src) status_change_end(src,SC_DANCING,-1); } @@ -8841,13 +8373,14 @@ int skill_clear_unitgroup(struct block_list *src) if(src->type==BL_PC){ group=((struct map_session_data *)src)->skillunit; maxsug=MAX_SKILLUNITGROUP; - }else if(src->type==BL_MOB){ + } else if(src->type==BL_MOB){ group=((struct mob_data *)src)->skillunit; maxsug=MAX_MOBSKILLUNITGROUP; - }else if(src->type==BL_PET){ // [Valaris] + } else if(src->type==BL_PET){ // [Valaris] group=((struct pet_data *)src)->skillunit; maxsug=MAX_MOBSKILLUNITGROUP; - } + } else + return 0; if(group){ int i; for(i=0;iinterval==-1) + return NULL; if (bl->type == BL_PC) set = ((struct map_session_data *)bl)->skillunittick; @@ -8890,16 +8411,16 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search( else return 0; - if (skill_unit_overlap_type(sg->skill_id)) - id = s = sg->skill_id; + if (skill_get_unit_flag(group->skill_id)&UF_NOOVERLAP) + id = s = group->skill_id; else - id = s = sg->group_id; + id = s = group->group_id; for (i=0; i0 || set[k].id==0)) j=k; } @@ -8908,101 +8429,41 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search( sprintf (tmp_output, "skill_unitgrouptickset_search: tickset is full\n"); ShowWarning (tmp_output); } - for (i = 0; itype == BL_PC) - set=((struct map_session_data *)bl)->skillunittick; - else if (bl->type == BL_MOB) - set=((struct mob_data *)bl)->skillunittick; - else - return 0; - - if (skill_unit_overlap_type(sg->skill_id)) - id = s = sg->skill_id; - else - id = s = sg->group_id; - - for(i=0; ialive ) { - struct skill_unit_group *sg; - sg = su->group; - if(sg && battle_check_target(src,bl,sg->target_flag )>0) - skill_unit_onplace( su, bl, tick ); - } - return 0; -} + if (bl->type!=BL_PC && bl->type!=BL_MOB) + return 0; + if (!unit->alive || bl->prev==NULL) + return 0; -/*========================================== - * スキルユニットタイマ?削除?理用(foreachinarea) - *------------------------------------------ - */ -int skill_unit_timer_sub_ondelete( struct block_list *bl, va_list ap ) -{ - struct block_list *src; - struct skill_unit *su; - unsigned int tick; + nullpo_retr(0, group=unit->group); - nullpo_retr(0, bl); - nullpo_retr(0, ap); - src=va_arg(ap,struct block_list*); + if (battle_check_target(&unit->bl,bl,group->target_flag)<=0) + return 0; - tick=va_arg(ap,unsigned int); - su = (struct skill_unit *)src; + skill_unit_onplace_timer(unit,bl,tick); - if( su && su->alive ){ - struct skill_unit_group *sg; - sg = su->group; - if( sg && battle_check_target(src,bl,sg->target_flag )>0 ) - skill_unit_ondelete( su, bl, tick ); - } return 0; } @@ -9020,28 +8481,37 @@ int skill_unit_timer_sub( struct block_list *bl, va_list ap ) nullpo_retr(0, bl); nullpo_retr(0, ap); nullpo_retr(0, unit=(struct skill_unit *)bl); - nullpo_retr(0, group=unit->group); tick=va_arg(ap,unsigned int); if(!unit->alive) return 0; - range=(unit->range!=0)?unit->range:group->range; + nullpo_retr(0, group=unit->group); + range = unit->range; - /* onplaceイベント呼び出し */ - if(unit->alive && unit->range>=0){ - map_foreachinarea( skill_unit_timer_sub_onplace, bl->m, - bl->x-range,bl->y-range,bl->x+range,bl->y+range,0, - bl,tick); - if(group->unit_id == 0xaa && DIFF_TICK(tick,group->tick)>=6000*group->val2){ - map_foreachinarea( skill_idun_heal, bl->m, - bl->x-range,bl->y-range,bl->x+range,bl->y+range,0,unit); - group->val2++; + /* onplace_timerイベント呼び出し */ + if (range>=0 && group->interval!=-1) { + map_foreachinarea(skill_unit_timer_sub_onplace, bl->m, + bl->x-range,bl->y-range,bl->x+range,bl->y+range,0,bl,tick); + if (!unit->alive) + return 0; + // マグヌスは発動したユニットは削除する + if (group->skill_id==PR_MAGNUS && unit->val2) { + skill_delunit(unit); + return 0; } } + // イドゥンの林檎による回復 + if (group->unit_id==0xaa && DIFF_TICK(tick,group->tick)>=6000*group->val3) { + struct block_list *src = map_id2bl(group->src_id); + int range = skill_get_unit_layout_type(group->skill_id,group->skill_lv); + nullpo_retr(0, src); + map_foreachinarea(skill_idun_heal,src->m, + src->x-range,src->y-range,src->x+range,src->y+range,0,unit); + group->val3++; + } /* 時間切れ削除 */ - if(unit->alive && - (DIFF_TICK(tick,group->tick)>=group->limit || DIFF_TICK(tick,group->tick)>=unit->limit) ){ + if((DIFF_TICK(tick,group->tick)>=group->limit || DIFF_TICK(tick,group->tick)>=unit->limit)){ switch(group->unit_id){ case 0x8f: /* ブラストマイン */ group->unit_id = 0x8c; @@ -9113,96 +8583,37 @@ int skill_unit_timer( int tid,unsigned int tick,int id,int data) return 0; } -/*========================================== - * スキルユニット移動時?理用(foreachinarea) - *------------------------------------------ - */ -int skill_unit_out_all_sub( struct block_list *bl, va_list ap ) -{ - struct skill_unit *unit; - struct skill_unit_group *group; - struct block_list *src; - int range; - unsigned int tick; - - nullpo_retr(0, bl); - nullpo_retr(0, ap); - nullpo_retr(0, src=va_arg(ap,struct block_list*)); - nullpo_retr(0, unit=(struct skill_unit *)bl); - nullpo_retr(0, group=unit->group); - - tick=va_arg(ap,unsigned int); - - if(!unit->alive || src->prev==NULL) - return 0; - - range=(unit->range!=0)?unit->range:group->range; - - if( range<0 || battle_check_target(bl,src,group->target_flag )<=0 ) - return 0; - - if( src->x >= bl->x-range && src->x <= bl->x+range && - src->y >= bl->y-range && src->y <= bl->y+range ) - skill_unit_onout( unit, src, tick ); - - return 0; -} - - -/*========================================== - * スキルユニット移動時?理 - *------------------------------------------ - */ -int skill_unit_out_all( struct block_list *bl,unsigned int tick,int range) -{ - nullpo_retr(0, bl); - - if( bl->prev==NULL ) - return 0; - - if(range<7) - range=7; - map_foreachinarea( skill_unit_out_all_sub, - bl->m,bl->x-range,bl->y-range,bl->x+range,bl->y+range,BL_SKILL, - bl,tick ); - - return 0; -} - /*========================================== * スキルユニット移動時?理用(foreachinarea) *------------------------------------------ */ int skill_unit_move_sub( struct block_list *bl, va_list ap ) { - struct skill_unit *unit; + struct skill_unit *unit = (struct skill_unit *)bl; struct skill_unit_group *group; - struct block_list *src; - int range; - unsigned int tick; + struct block_list *target; + unsigned int tick,flag; nullpo_retr(0, bl); nullpo_retr(0, ap); - nullpo_retr(0, unit=(struct skill_unit *)bl); - nullpo_retr(0, src=va_arg(ap,struct block_list*)); - - tick=va_arg(ap,unsigned int); + nullpo_retr(0, target=va_arg(ap,struct block_list*)); + tick = va_arg(ap,unsigned int); + flag = va_arg(ap,int); - if(!unit->alive || src->prev==NULL) + if (target->type!=BL_PC && target->type!=BL_MOB) return 0; - if((group=unit->group) == NULL) + nullpo_retr(0, group=unit->group); + if (group->interval!=-1) return 0; - range=(unit->range!=0)?unit->range:group->range; - if( range<0 || battle_check_target(bl,src,group->target_flag )<=0 ) + if (!unit->alive || target->prev==NULL) return 0; - if( src->x >= bl->x-range && src->x <= bl->x+range && - src->y >= bl->y-range && src->y <= bl->y+range ) - skill_unit_onplace( unit, src, tick ); + if (flag) + skill_unit_onplace(unit,target,tick); else - skill_unit_onout( unit, src, tick ); + skill_unit_onout(unit,target,tick); return 0; } @@ -9211,54 +8622,16 @@ int skill_unit_move_sub( struct block_list *bl, va_list ap ) * スキルユニット移動時?理 *------------------------------------------ */ -int skill_unit_move( struct block_list *bl,unsigned int tick,int range) -{ - nullpo_retr(0, bl); - - if( bl->prev==NULL ) - return 0; - - if(range<7) - range=7; - map_foreachinarea( skill_unit_move_sub, - bl->m,bl->x-range,bl->y-range,bl->x+range,bl->y+range,BL_SKILL, - bl,tick ); - - return 0; -} - -/*========================================== - * スキルユニット自?の移動時?理(foreachinarea) - *------------------------------------------ - */ -int skill_unit_move_unit_group_sub( struct block_list *bl, va_list ap ) +int skill_unit_move(struct block_list *bl,unsigned int tick,int flag) { - struct skill_unit *unit; - struct skill_unit_group *group; - struct block_list *src; - int range; - unsigned int tick; - nullpo_retr(0, bl); - nullpo_retr(0, ap); - nullpo_retr(0, src=va_arg(ap,struct block_list*)); - nullpo_retr(0, unit=(struct skill_unit *)src); - nullpo_retr(0, group=unit->group); - - tick=va_arg(ap,unsigned int); - if(!unit->alive || bl->prev==NULL) + if(bl->prev==NULL ) return 0; - range=(unit->range!=0)?unit->range:group->range; + map_foreachinarea(skill_unit_move_sub, + bl->m,bl->x,bl->y,bl->x,bl->y,BL_SKILL,bl,tick,flag); - if( range<0 || battle_check_target(src,bl,group->target_flag )<=0 ) - return 0; - if( bl->x >= src->x-range && bl->x <= src->x+range && - bl->y >= src->y-range && bl->y <= src->y+range ) - skill_unit_onplace( unit, bl, tick ); - else - skill_unit_onout( unit, bl, tick ); return 0; } @@ -9269,115 +8642,97 @@ int skill_unit_move_unit_group_sub( struct block_list *bl, va_list ap ) */ int skill_unit_move_unit_group( struct skill_unit_group *group, int m,int dx,int dy) { + int i,j; + int tick = gettick(); + int *m_flag; + struct skill_unit *unit1; + struct skill_unit *unit2; + nullpo_retr(0, group); + if (group->unit_count<=0) + return 0; + if (group->unit==NULL) + return 0; - if( group->unit_count<=0) + // 移動可能なスキルはダンス系と、ブラストマイン、クレイモアートラップのみ + if (!(skill_get_unit_flag(group->skill_id)&UF_DANCE) && + group->skill_id!=HT_CLAYMORETRAP && group->skill_id!=HT_BLASTMINE) return 0; - if(group->unit!=NULL){ - if(!battle_config.unit_movement_type){ - int i; - for(i=0;iunit_count;i++){ - struct skill_unit *unit=&group->unit[i]; - if(unit->alive && !(m==unit->bl.m && dx==0 && dy==0)){ - int range=unit->range; - map_delblock(&unit->bl); - unit->bl.m = m; - unit->bl.x += dx; - unit->bl.y += dy; - map_addblock(&unit->bl); - clif_skill_setunit(unit); - if(range>0){ - if(range<7) - range=7; - map_foreachinarea( skill_unit_move_unit_group_sub, unit->bl.m, - unit->bl.x-range,unit->bl.y-range,unit->bl.x+range,unit->bl.y+range,0, - &unit->bl,gettick() ); - } - } + m_flag = malloc(sizeof(int)*group->unit_count); + memset(m_flag,0,sizeof(int)*group->unit_count);// 移動フラグ + // 先にフラグを全部決める + // m_flag + // 0: 単純移動 + // 1: ユニットを移動する(現位置からユニットがなくなる) + // 2: 残留&新位置が移動先となる(移動先にユニットが存在しない) + // 3: 残留 + for(i=0;iunit_count;i++){ + unit1=&group->unit[i]; + if (!unit1->alive || unit1->bl.m!=m) + continue; + for(j=0;junit_count;j++){ + unit2=&group->unit[j]; + if (!unit2->alive) + continue; + if (unit1->bl.x+dx==unit2->bl.x && unit1->bl.y+dy==unit2->bl.y){ + // 移動先にユニットがかぶっている + m_flag[i] |= 0x1; } - }else{ - int i,j, *r_flag, *s_flag, *m_flag; - struct skill_unit *unit1; - struct skill_unit *unit2; - r_flag = (int *) aMallocA(sizeof(int) * group->unit_count); - s_flag = (int *) aMallocA(sizeof(int) * group->unit_count); - m_flag = (int *) aMallocA(sizeof(int) * group->unit_count); - memset(r_flag,0, sizeof(int) * group->unit_count);// ?承フラグ - memset(s_flag,0, sizeof(int) * group->unit_count);// ?承フラグ - memset(m_flag,0, sizeof(int) * group->unit_count);// ?承フラグ - - //先にフラグを全部決める - for(i=0;iunit_count;i++){ - int move_check=0;// かぶりフラグ - unit1=&group->unit[i]; - for(j=0;junit_count;j++){ - unit2=&group->unit[j]; - if(unit1->bl.m==m && unit1->bl.x+dx==unit2->bl.x && unit1->bl.y+dy==unit2->bl.y){ - //移動先にユニットがかぶってたら - s_flag[i]=1;// 移動前のユニットナンバ?の?承フラグon - r_flag[j]=1;// かぶるユニットナンバ?の?留フラグon - move_check=1;//ユニットがかぶった。 - break; - } - } - if(!move_check)// ユニットがかぶってなかったら - m_flag[i]=1;// 移動前ユニットナンバ?の移動フラグon - } - - //フラグに基づいてユニット移動 - for(i=0;iunit_count;i++){ - unit1=&group->unit[i]; - if(m_flag[i]){// 移動フラグがonで - if(!r_flag[i]){// ?留フラグがoffなら - //?純移動(rangeも?承の必要無し) - int range=unit1->range; - map_delblock(&unit1->bl); - unit1->bl.m = m; - unit1->bl.x += dx; - unit1->bl.y += dy; - map_addblock(&unit1->bl); - clif_skill_setunit(unit1); - if(range > 0){ - if(range < 7) - range = 7; - map_foreachinarea( skill_unit_move_unit_group_sub, unit1->bl.m, - unit1->bl.x-range,unit1->bl.y-range,unit1->bl.x+range,unit1->bl.y+range,0, - &unit1->bl,gettick() ); - } - }else{// ?留フラグがonなら - //空ユニットになるので、?承可能なユニットを探す - for(j=0;junit_count;j++){ - unit2=&group->unit[j]; - if(s_flag[j] && !r_flag[j]){ - // ?承移動(range?承付き) - int range=unit1->range; - map_delblock(&unit2->bl); - unit2->bl.m = m; - unit2->bl.x = unit1->bl.x + dx; - unit2->bl.y = unit1->bl.y + dy; - unit2->range = unit1->range; - map_addblock(&unit2->bl); - clif_skill_setunit(unit2); - if(range > 0){ - if(range < 7) - range = 7; - map_foreachinarea( skill_unit_move_unit_group_sub, unit2->bl.m, - unit2->bl.x-range,unit2->bl.y-range,unit2->bl.x+range,unit2->bl.y+range,0, - &unit2->bl,gettick() ); - } - s_flag[j]=0;// ?承完了したのでoff - break; - } - } - } + if (unit1->bl.x-dx==unit2->bl.x && unit1->bl.y-dy==unit2->bl.y){ + // ユニットがこの場所にやってくる + m_flag[i] |= 0x2; + } + } + } + // フラグに基づいてユニット移動 + // フラグが1のunitを探し、フラグが2のunitの移動先に移す + j = 0; + for (i=0;iunit_count;i++) { + unit1=&group->unit[i]; + if (!unit1->alive) + continue; + if (!(m_flag[i]&0x2)) { + // ユニットがなくなる場所でスキルユニット影響を消す + map_foreachinarea(skill_unit_effect,unit1->bl.m, + unit1->bl.x,unit1->bl.y,unit1->bl.x,unit1->bl.y,0, + &unit1->bl,tick,0); + } + if (m_flag[i]==0) { + // 単純移動 + map_delblock(&unit1->bl); + unit1->bl.m = m; + unit1->bl.x += dx; + unit1->bl.y += dy; + map_addblock(&unit1->bl); + clif_skill_setunit(unit1); + } else if (m_flag[i]==1) { + // フラグが2のものを探してそのユニットの移動先に移動 + for(;junit_count;j++) { + if (m_flag[j]==2) { + // 継承移動 + unit2 = &group->unit[j]; + if (!unit2->alive) + continue; + map_delblock(&unit1->bl); + unit1->bl.m = m; + unit1->bl.x = unit2->bl.x+dx; + unit1->bl.y = unit2->bl.y+dy; + map_addblock(&unit1->bl); + clif_skill_setunit(unit1); + j++; + break; } } - aFree(r_flag); - aFree(s_flag); - aFree(m_flag); + } + if (!(m_flag[i]&0x2)) { + // 移動後の場所でスキルユニットを発動 + map_foreachinarea(skill_unit_effect,unit1->bl.m, + unit1->bl.x,unit1->bl.y,unit1->bl.x,unit1->bl.y,0, + &unit1->bl,tick,1); } } + free(m_flag); return 0; } @@ -9505,25 +8860,29 @@ int skill_produce_mix( struct map_session_data *sd, if(!equip) { // Corrected rates [DracoRPG] --------------------------// if(skill_produce_db[idx].req_skill==AM_PHARMACY) { + make_per = pc_checkskill(sd,AM_LEARNINGPOTION)*100 + + pc_checkskill(sd,AM_PHARMACY)*300 + sd->status.job_level*20 + + sd->status.dex*10+sd->status.int_*5; + if(nameid >= 501 && nameid <= 505) // Normal potions - make_per = 2000 + sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300 + pc_checkskill(sd,AM_POTIONPITCHER)*100; - if(nameid >= 605 && nameid <= 606) // Anodyne & Aloevera (not sure of the formula, I put the same base value as normal pots but without the Aid Potion bonus since they are not throwable pots ^^) - make_per = 2000 + sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300; + make_per += 2000 + pc_checkskill(sd,AM_POTIONPITCHER)*100; + else if(nameid >= 605 && nameid <= 606) // Anodyne & Aloevera (not sure of the formula, I put the same base value as normal pots but without the Aid Potion bonus since they are not throwable pots ^^) + make_per += 2000; else if(nameid >= 545 && nameid <= 547) // Concentrated potions - make_per = sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300; + ; else if(nameid == 970) // Alcohol - make_per = 1000 + sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300; + make_per += 1000; else if(nameid == 7135) // Bottle Grenade - make_per = 500 + sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300 + pc_checkskill(sd,AM_DEMONSTRATION)*100; + make_per += 500 + pc_checkskill(sd,AM_DEMONSTRATION)*100; else if(nameid == 7136) // Acid Bottle - make_per = 500 + sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300 + pc_checkskill(sd,AM_ACIDTERROR)*100; + make_per += 500 + pc_checkskill(sd,AM_ACIDTERROR)*100; else if(nameid == 7137) // Plant Bottle - make_per = 500 + sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300 + pc_checkskill(sd,AM_CANNIBALIZE)*100; + make_per += 500 + pc_checkskill(sd,AM_CANNIBALIZE)*100; else if(nameid == 7138) // Marine Sphere Bottle - make_per = 500 + sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300 + pc_checkskill(sd,AM_SPHEREMINE)*100; + make_per += 500 + pc_checkskill(sd,AM_SPHEREMINE)*100; else if(nameid == 7139) // Glistening Coat - make_per = 500 + sd->status.job_level*20 + sd->paramc[4]*10 + sd->paramc[5]*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300 + pc_checkskill(sd,AM_CP_WEAPON)*100 + - pc_checkskill(sd,AM_CP_SHIELD)*100 + pc_checkskill(sd,AM_CP_ARMOR)*100 + pc_checkskill(sd,AM_CP_HELM)*100; + make_per += 500 + pc_checkskill(sd,AM_CP_WEAPON)*100 + pc_checkskill(sd,AM_CP_SHIELD)*100 + + pc_checkskill(sd,AM_CP_ARMOR)*100 + pc_checkskill(sd,AM_CP_HELM)*100; else make_per = 1000 + sd->status.base_level*30 + sd->paramc[3]*20 + sd->paramc[4]*15 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300; } else if (skill_produce_db[idx].req_skill == ASC_CDP) { @@ -9604,8 +8963,7 @@ int skill_produce_mix( struct map_session_data *sd, clif_additem(sd,0,0,flag); map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); } - } - else { + } else { if(log_config.produce > 0) log_produce(sd,nameid,slot1,slot2,slot3,0); @@ -9675,6 +9033,213 @@ int skill_arrow_create( struct map_session_data *sd,int nameid) * 初期化系 */ +/*---------------------------------------------------------------------------- + * 初期化系 + */ + +/* + * 文字列処理 + * ',' で区切って val に戻す + */ +int skill_split_str(char *str,char **val,int num) +{ + int i; + + for (i=0; iMAX_SKILL_DB) continue; - memset(split2,0,sizeof(split2)); - for(j=0,p=split[1];jMAX_SKILL_DB) continue; - memset(split2,0,sizeof(split2)); - for(j=0,p=split[1];j=10000 && i<10015) // for guild skills [Celest] + i -= 9500; + else if(i<=0 || i>MAX_SKILL_DB) + continue; + skill_db[i].unit_id[0] = strtol(split[1],NULL,16); + skill_db[i].unit_id[1] = strtol(split[2],NULL,16); + skill_split_atoi(split[3],skill_db[i].unit_layout_type); + skill_db[i].unit_range = atoi(split[4]); + skill_db[i].unit_interval = atoi(split[5]); + + if( strcmpi(split[6],"noenemy")==0 ) skill_db[i].unit_target=BCT_NOENEMY; + else if( strcmpi(split[6],"friend")==0 ) skill_db[i].unit_target=BCT_NOENEMY; + else if( strcmpi(split[6],"party")==0 ) skill_db[i].unit_target=BCT_PARTY; + else if( strcmpi(split[6],"all")==0 ) skill_db[i].unit_target=BCT_ALL; + else if( strcmpi(split[6],"enemy")==0 ) skill_db[i].unit_target=BCT_ENEMY; + else if( strcmpi(split[6],"self")==0 ) skill_db[i].unit_target=BCT_SELF; + else skill_db[i].unit_target = strtol(split[6],NULL,16); + + skill_db[i].unit_flag = strtol(split[7],NULL,16); + k++; } fclose(fp); - sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_cast_db.txt"); + sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_unit_db.txt"); ShowStatus(tmp_output); + skill_init_unit_layout(); /* 製造系スキルデ?タベ?ス */ memset(skill_produce_db,0,sizeof(skill_produce_db)); @@ -9990,16 +9476,11 @@ int skill_readdb(void) if(line[0]=='/' && line[1]=='/') continue; memset(split,0,sizeof(split)); - for(j=0,p=line;j<3 + MAX_PRODUCE_RESOURCE * 2 && p;j++){ - split[j]=p; - p=strchr(p,','); - if(p) *p++=0; - } + j = skill_split_str(line,split,(3 + MAX_PRODUCE_RESOURCE * 2)); if(split[0]==0) //fixed by Lupus continue; i=atoi(split[0]); - if(i<=0) - continue; + if(i<=0) continue; skill_produce_db[k].nameid=i; skill_produce_db[k].itemlv=atoi(split[1]); @@ -10031,11 +9512,7 @@ int skill_readdb(void) if(line[0]=='/' && line[1]=='/') continue; memset(split,0,sizeof(split)); - for(j=0,p=line;j<13 && p;j++){ - split[j]=p; - p=strchr(p,','); - if(p) *p++=0; - } + j = skill_split_str(line,split,13); if(split[0]==0) //fixed by Lupus continue; i=atoi(split[0]); @@ -10068,11 +9545,7 @@ int skill_readdb(void) if(line[0]=='/' && line[1]=='/') continue; memset(split,0,sizeof(split)); - for(j=0,p=line;j<13 && p;j++){ - split[j]=p; - p=strchr(p,','); - if(p) *p++=0; - } + j = skill_split_str(line,split,13); if(split[0]==0) //fixed by Lupus continue; i=atoi(split[0]); @@ -10096,15 +9569,11 @@ int skill_readdb(void) return 1; } while(fgets(line,1020,fp)){ - char *split[50], *split2[MAX_SKILL_LEVEL]; + char *split[50]; if(line[0]=='/' && line[1]=='/') continue; memset(split,0,sizeof(split)); - for(j=0,p=line;j<3 && p;j++){ - split[j]=p; - p=strchr(p,','); - if(p) *p++=0; - } + j = skill_split_str(line,split,3); if(split[0]==0) //fixed by Lupus continue; i=atoi(split[0]); @@ -10113,25 +9582,10 @@ int skill_readdb(void) else if(i<=0 || i>MAX_SKILL_DB) continue; - memset(split2,0,sizeof(split2)); - for(j=0,p=split[1];j5) //レベルが5以上の場合は25?に制限(1?目はすでに打ってるので-1) - val3=5*5-1; - else - val3= (val1|1)*(val1|1)-1; - break; - /* スキルじゃない/時間に?係しない */ case SC_RIDING: calc_flag = 1; @@ -4361,21 +4355,6 @@ int status_change_timer(int tid, unsigned int tick, int id, int data) } break; - case SC_WATERBALL: /* ウォ?タ?ボ?ル */ - { - struct block_list *target=map_id2bl(sc_data[type].val2); - if (!target || !target->prev) - break; // target has been killed in previous hits, no need to raise an alarm ^^; - // nullpo_retb(target); - // nullpo_retb(target->prev); - skill_attack(BF_MAGIC,bl,bl,target,WZ_WATERBALL,sc_data[type].val1,tick,0); - if((--sc_data[type].val3)>0) { - sc_data[type].timer=add_timer( 150+tick,status_change_timer, bl->id, data ); - return 0; - } - } - break; - case SC_ENDURE: /* インデュア */ case SC_AUTOBERSERK: // Celest if(sd && sd->special_state.infinite_endure) { diff --git a/src/map/status.h b/src/map/status.h index d788c7b50..fbeee7300 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -111,7 +111,7 @@ enum { // struct map_session_data //-- 137-139 SC_SAFETYWALL = 140, SC_PNEUMA = 141, - SC_WATERBALL = 142, +//-- 142 SC_ANKLE = 143, SC_DANCING = 144, SC_KEEPING = 145, diff --git a/src/txt-converter/char/Makefile b/src/txt-converter/char/Makefile index a4cca87fd..6b85a04db 100644 --- a/src/txt-converter/char/Makefile +++ b/src/txt-converter/char/Makefile @@ -1,7 +1,7 @@ all: char-converter sql: char-converter -COMMON_OBJ = ../../common/core.o ../../common/socket.o ../../common/timer.o ../../common/grfio.o ../../common/db.o ../../common/lock.o ../../common/nullpo.o ../../common/malloc.o ../../common/showmsg.o ../../common/strlib.o +COMMON_OBJ = ../../common/obj/core.o ../../common/obj/socket.o ../../common/obj/timer.o ../../common/obj/grfio.o ../../common/obj/db.o ../../common/obj/lock.o ../../common/obj/nullpo.o ../../common/obj/malloc.o ../../common/obj/showmsg.o ../../common/obj/strlib.o char-converter: char-converter.o $(COMMON_OBJ) $(CC) -o ../../../$@ $^ $(LIB_S) diff --git a/src/txt-converter/login/Makefile b/src/txt-converter/login/Makefile index 56b97e772..7158931d0 100644 --- a/src/txt-converter/login/Makefile +++ b/src/txt-converter/login/Makefile @@ -1,7 +1,7 @@ all: login-converter sql: login-converter -COMMON_OBJ = ../../common/core.o ../../common/socket.o ../../common/timer.o ../../common/grfio.o ../../common/db.o ../../common/lock.o ../../common/nullpo.o ../../common/malloc.o ../../common/showmsg.o ../../common/strlib.o +COMMON_OBJ = ../../common/obj/core.o ../../common/obj/socket.o ../../common/obj/timer.o ../../common/obj/grfio.o ../../common/obj/db.o ../../common/obj/lock.o ../../common/obj/nullpo.o ../../common/obj/malloc.o ../../common/obj/showmsg.o ../../common/obj/strlib.o COMMON_H = ../../common/core.h ../../common/socket.h ../../common/timer.h ../../common/mmo.h ../../common/version.h ../../common/db.h ../../common/malloc.h ../../common/strlib.h -- cgit v1.2.3-70-g09d2 From 9c0c26a552ab3e66a6595d033988906eb8576e6e Mon Sep 17 00:00:00 2001 From: amber Date: Wed, 30 Mar 2005 19:49:57 +0000 Subject: Made the map-server build cleanly using Microsoft Visual Studio [MouseJstr] git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1345 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 3 + src/common/core.c | 2 +- src/common/grfio.c | 2 +- src/map/Makefile.win32 | 13 +- src/map/pc.c | 5 +- src/map/status.c | 5 +- src/zlib/FAQ | 337 +++++++++++ src/zlib/README | 126 ++++ src/zlib/adler32.c | 74 +++ src/zlib/compress.c | 79 +++ src/zlib/crc32.c | 333 +++++++++++ src/zlib/crc32.h | 441 ++++++++++++++ src/zlib/deflate.c | 1502 ++++++++++++++++++++++++++++++++++++++++++++++++ src/zlib/deflate.h | 325 +++++++++++ src/zlib/inffast.c | 305 ++++++++++ src/zlib/inffast.h | 11 + src/zlib/inffixed.h | 94 +++ src/zlib/inflate.c | 1274 ++++++++++++++++++++++++++++++++++++++++ src/zlib/inflate.h | 117 ++++ src/zlib/inftrees.c | 328 +++++++++++ src/zlib/inftrees.h | 55 ++ src/zlib/trees.c | 1215 +++++++++++++++++++++++++++++++++++++++ src/zlib/trees.h | 128 +++++ src/zlib/zconf.h | 326 +++++++++++ src/zlib/zlib.h | 1200 ++++++++++++++++++++++++++++++++++++++ src/zlib/zutil.c | 319 ++++++++++ src/zlib/zutil.h | 263 +++++++++ 27 files changed, 8873 insertions(+), 9 deletions(-) create mode 100644 src/zlib/FAQ create mode 100644 src/zlib/README create mode 100644 src/zlib/adler32.c create mode 100644 src/zlib/compress.c create mode 100644 src/zlib/crc32.c create mode 100644 src/zlib/crc32.h create mode 100644 src/zlib/deflate.c create mode 100644 src/zlib/deflate.h create mode 100644 src/zlib/inffast.c create mode 100644 src/zlib/inffast.h create mode 100644 src/zlib/inffixed.h create mode 100644 src/zlib/inflate.c create mode 100644 src/zlib/inflate.h create mode 100644 src/zlib/inftrees.c create mode 100644 src/zlib/inftrees.h create mode 100644 src/zlib/trees.c create mode 100644 src/zlib/trees.h create mode 100644 src/zlib/zconf.h create mode 100644 src/zlib/zlib.h create mode 100644 src/zlib/zutil.c create mode 100644 src/zlib/zutil.h (limited to 'src/common/grfio.c') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 6de6a0c76..527b8e7f5 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,6 +2,9 @@ Date Added 03/30 + * Made the map-server build cleanly using Microsoft Visual + Studio.. entirely native code without any cygwin dependency + [SVN: 1345 MouseJstr] * Fixed @reloadgmdb in SQL -- after reloading ask the char to forward the new accounts back to the map [celest] * Added base code for loading Ser's UPNP plugin [celest] diff --git a/src/common/core.c b/src/common/core.c index 41b73b219..b325b96e4 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -250,7 +250,7 @@ void pid_create(const char* file) { } #define LOG_UPTIME 0 -void log_uptime() +void log_uptime(void) { #if LOG_UPTIME time_t curtime; diff --git a/src/common/grfio.c b/src/common/grfio.c index 224ea909e..ed01cf82e 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -33,7 +33,7 @@ #ifdef _WIN32 #ifdef LOCALZLIB - #include "../lib/zlib/zlib.h" + #include "zlib.h" #define zlib_inflateInit inflateInit #define zlib_inflate inflate #define zlib_inflateEnd inflateEnd diff --git a/src/map/Makefile.win32 b/src/map/Makefile.win32 index 9a0a0b174..2ab3f957a 100644 --- a/src/map/Makefile.win32 +++ b/src/map/Makefile.win32 @@ -15,25 +15,28 @@ txtobj: sqlobj: mkdir sqlobj -ZLIBDIR = C:/eathena/zlib122 -PACKETDEF = -DPACKETVER=5 -DNEW_006b -D__WIN32 +ZLIBDIR = ../zlib +PACKETDEF = -DPACKETVER=5 -DNEW_006b -D__WIN32 -DLOCALZLIB # OPT = /MDd /D_DEBUG OPT = LINKOPT = /debug /SUBSYSTEM:CONSOLE # OPT = /O2 CFLAGS = $(OPT) /nologo /I../common /I$(ZLIBDIR) $(PACKETDEF) /D_WIN32 -COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o +COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o ../common/strlib.o ../common/utils.o + LIBS = "WSOCK32.LIB" # "WSOCK32.LIB" "USER32.LIB" "ADVAPI32.LIB" "MSVCRT.LIB" "OLDNAMES.LIB" "KERNEL32.LIB" -TXTOBJS = 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/battle.o txtobj/intif.o txtobj/trade.o txtobj/party.o txtobj/vending.o txtobj/guild.o txtobj/pet.o $(COMMON_OBJ) $(ZLIBDIR)/inflate.o $(ZLIBDIR)/adler32.o $(ZLIBDIR)/crc32.o $(ZLIBDIR)/inftrees.o $(ZLIBDIR)/zutil.o $(ZLIBDIR)/inffast.o +TXTOBJS = 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) $(ZLIBDIR)/inflate.o $(ZLIBDIR)/deflate.o $(ZLIBDIR)/trees.o $(ZLIBDIR)/adler32.o $(ZLIBDIR)/compress.o $(ZLIBDIR)/crc32.o $(ZLIBDIR)/inftrees.o $(ZLIBDIR)/zutil.o $(ZLIBDIR)/inffast.o + +SQLOBJS = 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/log.o $(COMMON_OBJ) $(ZLIBDIR)/inflate.o $(ZLIBDIR)/adler32.o $(ZLIBDIR)/crc32.o $(ZLIBDIR)/inftrees.o $(ZLIBDIR)/zutil.o $(ZLIBDIR)/inffast.o map-server: $(TXTOBJS) link $(LINKOPT) /out:../../$@.exe $(TXTOBJS) $(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/battle.o sqlobj/intif.o sqlobj/trade.o sqlobj/party.o sqlobj/vending.o sqlobj/guild.o sqlobj/pet.o sqlobj/mail.o $(COMMON_OBJ) +map-server_sql: $(SQLOBJS) link $(LINKOPT) /out:../../$@.exe $> $(LIBS) txtobj/%.o: %.c diff --git a/src/map/pc.c b/src/map/pc.c index b9185c8b8..e82a5d246 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3236,7 +3236,10 @@ static int pc_walk(int tid,unsigned int tick,int id,int data) int moveblock; int x,y,dx,dy; - nullpo_retr_f(0, (sd=map_id2sd(id)), "id=%d", id); + sd=map_id2sd(id); +#ifndef _WIN32 + nullpo_retr_f(0, sd, "id=%d", id); +#endif if(sd->walktimer != tid){ if(battle_config.error_log) diff --git a/src/map/status.c b/src/map/status.c index 65f9e0cd4..00dc50c74 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4300,7 +4300,10 @@ int status_change_timer(int tid, unsigned int tick, int id, int data) // security system to prevent forgetting timer removal int temp_timerid; - nullpo_retr_f(0, bl=map_id2bl(id), "id=%d data=%d",id,data); + bl=map_id2bl(id); +#ifndef _WIN32 + nullpo_retr_f(0, bl, "id=%d data=%d",id,data); +#endif nullpo_retr(0, sc_data=status_get_sc_data(bl)); if(bl->type==BL_PC) diff --git a/src/zlib/FAQ b/src/zlib/FAQ new file mode 100644 index 000000000..bb5355fc6 --- /dev/null +++ b/src/zlib/FAQ @@ -0,0 +1,337 @@ + + Frequently Asked Questions about zlib + + +If your question is not there, please check the zlib home page +http://www.zlib.org which may have more recent information. +The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html + + + 1. Is zlib Y2K-compliant? + + Yes. zlib doesn't handle dates. + + 2. Where can I get a Windows DLL version? + + The zlib sources can be compiled without change to produce a DLL. + See the file win32/DLL_FAQ.txt in the zlib distribution. + Pointers to the precompiled DLL are found in the zlib web site at + http://www.zlib.org. + + 3. Where can I get a Visual Basic interface to zlib? + + See + * http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm + * contrib/visual-basic.txt in the zlib distribution + * win32/DLL_FAQ.txt in the zlib distribution + + 4. compress() returns Z_BUF_ERROR. + + Make sure that before the call of compress, the length of the compressed + buffer is equal to the total size of the compressed buffer and not + zero. For Visual Basic, check that this parameter is passed by reference + ("as any"), not by value ("as long"). + + 5. deflate() or inflate() returns Z_BUF_ERROR. + + Before making the call, make sure that avail_in and avail_out are not + zero. When setting the parameter flush equal to Z_FINISH, also make sure + that avail_out is big enough to allow processing all pending input. + Note that a Z_BUF_ERROR is not fatal--another call to deflate() or + inflate() can be made with more input or output space. A Z_BUF_ERROR + may in fact be unavoidable depending on how the functions are used, since + it is not possible to tell whether or not there is more output pending + when strm.avail_out returns with zero. + + 6. Where's the zlib documentation (man pages, etc.)? + + It's in zlib.h for the moment, and Francis S. Lin has converted it to a + web page zlib.html. Volunteers to transform this to Unix-style man pages, + please contact us (zlib@gzip.org). Examples of zlib usage are in the files + example.c and minigzip.c. + + 7. Why don't you use GNU autoconf or libtool or ...? + + Because we would like to keep zlib as a very small and simple + package. zlib is rather portable and doesn't need much configuration. + + 8. I found a bug in zlib. + + Most of the time, such problems are due to an incorrect usage of + zlib. Please try to reproduce the problem with a small program and send + the corresponding source to us at zlib@gzip.org . Do not send + multi-megabyte data files without prior agreement. + + 9. Why do I get "undefined reference to gzputc"? + + If "make test" produces something like + + example.o(.text+0x154): undefined reference to `gzputc' + + check that you don't have old files libz.* in /usr/lib, /usr/local/lib or + /usr/X11R6/lib. Remove any old versions, then do "make install". + +10. I need a Delphi interface to zlib. + + See the contrib/delphi directory in the zlib distribution. + +11. Can zlib handle .zip archives? + + Not by itself, no. See the directory contrib/minizip in the zlib + distribution. + +12. Can zlib handle .Z files? + + No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt + the code of uncompress on your own. + +13. How can I make a Unix shared library? + + make clean + ./configure -s + make + +14. How do I install a shared zlib library on Unix? + + After the above, then: + + make install + + However, many flavors of Unix come with a shared zlib already installed. + Before going to the trouble of compiling a shared version of zlib and + trying to install it, you may want to check if it's already there! If you + can #include , it's there. The -lz option will probably link to it. + +15. I have a question about OttoPDF. + + We are not the authors of OttoPDF. The real author is on the OttoPDF web + site: Joel Hainley, jhainley@myndkryme.com. + +16. Can zlib decode Flate data in an Adobe PDF file? + + Yes. See http://www.fastio.com/ (ClibPDF), or http://www.pdflib.com/ . + To modify PDF forms, see http://sourceforge.net/projects/acroformtool/ . + +17. Why am I getting this "register_frame_info not found" error on Solaris? + + After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib + generates an error such as: + + ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so: + symbol __register_frame_info: referenced symbol not found + + The symbol __register_frame_info is not part of zlib, it is generated by + the C compiler (cc or gcc). You must recompile applications using zlib + which have this problem. This problem is specific to Solaris. See + http://www.sunfreeware.com for Solaris versions of zlib and applications + using zlib. + +18. Why does gzip give an error on a file I make with compress/deflate? + + The compress and deflate functions produce data in the zlib format, which + is different and incompatible with the gzip format. The gz* functions in + zlib on the other hand use the gzip format. Both the zlib and gzip + formats use the same compressed data format internally, but have different + headers and trailers around the compressed data. + +19. Ok, so why are there two different formats? + + The gzip format was designed to retain the directory information about + a single file, such as the name and last modification date. The zlib + format on the other hand was designed for in-memory and communication + channel applications, and has a much more compact header and trailer and + uses a faster integrity check than gzip. + +20. Well that's nice, but how do I make a gzip file in memory? + + You can request that deflate write the gzip format instead of the zlib + format using deflateInit2(). You can also request that inflate decode + the gzip format using inflateInit2(). Read zlib.h for more details. + + Note that you cannot specify special gzip header contents (e.g. a file + name or modification date), nor will inflate tell you what was in the + gzip header. If you need to customize the header or see what's in it, + you can use the raw deflate and inflate operations and the crc32() + function and roll your own gzip encoding and decoding. Read the gzip + RFC 1952 for details of the header and trailer format. + +21. Is zlib thread-safe? + + Yes. However any library routines that zlib uses and any application- + provided memory allocation routines must also be thread-safe. zlib's gz* + functions use stdio library routines, and most of zlib's functions use the + library memory allocation routines by default. zlib's Init functions allow + for the application to provide custom memory allocation routines. + + Of course, you should only operate on any given zlib or gzip stream from a + single thread at a time. + +22. Can I use zlib in my commercial application? + + Yes. Please read the license in zlib.h. + +23. Is zlib under the GNU license? + + No. Please read the license in zlib.h. + +24. The license says that altered source versions must be "plainly marked". So + what exactly do I need to do to meet that requirement? + + You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In + particular, the final version number needs to be changed to "f", and an + identification string should be appended to ZLIB_VERSION. Version numbers + x.x.x.f are reserved for modifications to zlib by others than the zlib + maintainers. For example, if the version of the base zlib you are altering + is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and + ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also + update the version strings in deflate.c and inftrees.c. + + For altered source distributions, you should also note the origin and + nature of the changes in zlib.h, as well as in ChangeLog and README, along + with the dates of the alterations. The origin should include at least your + name (or your company's name), and an email address to contact for help or + issues with the library. + + Note that distributing a compiled zlib library along with zlib.h and + zconf.h is also a source distribution, and so you should change + ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes + in zlib.h as you would for a full source distribution. + +25. Will zlib work on a big-endian or little-endian architecture, and can I + exchange compressed data between them? + + Yes and yes. + +26. Will zlib work on a 64-bit machine? + + It should. It has been tested on 64-bit machines, and has no dependence + on any data types being limited to 32-bits in length. If you have any + difficulties, please provide a complete problem report to zlib@gzip.org + +27. Will zlib decompress data from the PKWare Data Compression Library? + + No. The PKWare DCL uses a completely different compressed data format + than does PKZIP and zlib. However, you can look in zlib's contrib/blast + directory for a possible solution to your problem. + +28. Can I access data randomly in a compressed stream? + + No, not without some preparation. If when compressing you periodically + use Z_FULL_FLUSH, carefully write all the pending data at those points, + and keep an index of those locations, then you can start decompression + at those points. You have to be careful to not use Z_FULL_FLUSH too + often, since it can significantly degrade compression. + +29. Does zlib work on MVS, OS/390, CICS, etc.? + + We don't know for sure. We have heard occasional reports of success on + these systems. If you do use it on one of these, please provide us with + a report, instructions, and patches that we can reference when we get + these questions. Thanks. + +30. Is there some simpler, easier to read version of inflate I can look at + to understand the deflate format? + + First off, you should read RFC 1951. Second, yes. Look in zlib's + contrib/puff directory. + +31. Does zlib infringe on any patents? + + As far as we know, no. In fact, that was originally the whole point behind + zlib. Look here for some more information: + + http://www.gzip.org/#faq11 + +32. Can zlib work with greater than 4 GB of data? + + Yes. inflate() and deflate() will process any amount of data correctly. + Each call of inflate() or deflate() is limited to input and output chunks + of the maximum value that can be stored in the compiler's "unsigned int" + type, but there is no limit to the number of chunks. Note however that the + strm.total_in and strm_total_out counters may be limited to 4 GB. These + counters are provided as a convenience and are not used internally by + inflate() or deflate(). The application can easily set up its own counters + updated after each call of inflate() or deflate() to count beyond 4 GB. + compress() and uncompress() may be limited to 4 GB, since they operate in a + single call. gzseek() and gztell() may be limited to 4 GB depending on how + zlib is compiled. See the zlibCompileFlags() function in zlib.h. + + The word "may" appears several times above since there is a 4 GB limit + only if the compiler's "long" type is 32 bits. If the compiler's "long" + type is 64 bits, then the limit is 16 exabytes. + +33. Does zlib have any security vulnerabilities? + + The only one that we are aware of is potentially in gzprintf(). If zlib + is compiled to use sprintf() or vsprintf(), then there is no protection + against a buffer overflow of a 4K string space, other than the caller of + gzprintf() assuring that the output will not exceed 4K. On the other + hand, if zlib is compiled to use snprintf() or vsnprintf(), which should + normally be the case, then there is no vulnerability. The ./configure + script will display warnings if an insecure variation of sprintf() will + be used by gzprintf(). Also the zlibCompileFlags() function will return + information on what variant of sprintf() is used by gzprintf(). + + If you don't have snprintf() or vsnprintf() and would like one, you can + find a portable implementation here: + + http://www.ijs.si/software/snprintf/ + + Note that you should be using the most recent version of zlib. Versions + 1.1.3 and before were subject to a double-free vulnerability. + +34. Is there a Java version of zlib? + + Probably what you want is to use zlib in Java. zlib is already included + as part of the Java SDK in the java.util.zip package. If you really want + a version of zlib written in the Java language, look on the zlib home + page for links: http://www.zlib.org/ + +35. I get this or that compiler or source-code scanner warning when I crank it + up to maximally-pedantic. Can't you guys write proper code? + + Many years ago, we gave up attempting to avoid warnings on every compiler + in the universe. It just got to be a waste of time, and some compilers + were downright silly. So now, we simply make sure that the code always + works. + +36. Will zlib read the (insert any ancient or arcane format here) compressed + data format? + + Probably not. Look in the comp.compression FAQ for pointers to various + formats and associated software. + +37. How can I encrypt/decrypt zip files with zlib? + + zlib doesn't support encryption. The original PKZIP encryption is very weak + and can be broken with freely available programs. To get strong encryption, + use GnuPG, http://www.gnupg.org/ , which already includes zlib compression. + For PKZIP compatible "encryption", look at http://www.info-zip.org/ + +38. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? + + "gzip" is the gzip format, and "deflate" is the zlib format. They should + probably have called the second one "zlib" instead to avoid confusion + with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616 + correctly points to the zlib specification in RFC 1950 for the "deflate" + transfer encoding, there have been reports of servers and browsers that + incorrectly produce or expect raw deflate data per the deflate + specficiation in RFC 1951, most notably Microsoft. So even though the + "deflate" transfer encoding using the zlib format would be the more + efficient approach (and in fact exactly what the zlib format was designed + for), using the "gzip" transfer encoding is probably more reliable due to + an unfortunate choice of name on the part of the HTTP 1.1 authors. + + Bottom line: use the gzip format for HTTP 1.1 encoding. + +39. Does zlib support the new "Deflate64" format introduced by PKWare? + + No. PKWare has apparently decided to keep that format proprietary, since + they have not documented it as they have previous compression formats. + In any case, the compression improvements are so modest compared to other + more modern approaches, that it's not worth the effort to implement. + +40. Can you please sign these lengthy legal documents and fax them back to us + so that we can use your software in our product? + + No. Go away. Shoo. diff --git a/src/zlib/README b/src/zlib/README new file mode 100644 index 000000000..c3453b8e8 --- /dev/null +++ b/src/zlib/README @@ -0,0 +1,126 @@ +ZLIB DATA COMPRESSION LIBRARY + +zlib 1.2.2 is a general purpose data compression library. All the code is +thread safe. The data format used by the zlib library is described by RFCs +(Request for Comments) 1950 to 1952 in the files +http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) +and rfc1952.txt (gzip format). These documents are also available in other +formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html + +All functions of the compression library are documented in the file zlib.h +(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example +of the library is given in the file example.c which also tests that the library +is working correctly. Another example is given in the file minigzip.c. The +compression library itself is composed of all source files except example.c and +minigzip.c. + +To compile all files and run the test program, follow the instructions given at +the top of Makefile. In short "make test; make install" should work for most +machines. For Unix: "./configure; make test; make install" For MSDOS, use one +of the special makefiles such as Makefile.msc. For VMS, use Make_vms.com or +descrip.mms. + +Questions about zlib should be sent to , or to Gilles Vollant + for the Windows DLL version. The zlib home page is +http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem, +please check this site to verify that you have the latest version of zlib; +otherwise get the latest version and check whether the problem still exists or +not. + +PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking +for help. + +Mark Nelson wrote an article about zlib for the Jan. 1997 +issue of Dr. Dobb's Journal; a copy of the article is available in +http://dogma.net/markn/articles/zlibtool/zlibtool.htm + +The changes made in version 1.2.2 are documented in the file ChangeLog. + +Unsupported third party contributions are provided in directory "contrib". + +A Java implementation of zlib is available in the Java Development Kit +http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html +See the zlib home page http://www.zlib.org for details. + +A Perl interface to zlib written by Paul Marquess is in the +CPAN (Comprehensive Perl Archive Network) sites +http://www.cpan.org/modules/by-module/Compress/ + +A Python interface to zlib written by A.M. Kuchling is +available in Python 1.5 and later versions, see +http://www.python.org/doc/lib/module-zlib.html + +A zlib binding for TCL written by Andreas Kupries is +availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html + +An experimental package to read and write files in .zip format, written on top +of zlib by Gilles Vollant , is available in the +contrib/minizip directory of zlib. + + +Notes for some targets: + +- For Windows DLL versions, please see win32/DLL_FAQ.txt + +- For 64-bit Irix, deflate.c must be compiled without any optimization. With + -O, one libpng test fails. The test works in 32 bit mode (with the -n32 + compiler flag). The compiler bug has been reported to SGI. + +- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works + when compiled with cc. + +- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is + necessary to get gzprintf working correctly. This is done by configure. + +- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with + other compilers. Use "make test" to check your compiler. + +- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. + +- For PalmOs, see http://palmzlib.sourceforge.net/ + +- When building a shared, i.e. dynamic library on Mac OS X, the library must be + installed before testing (do "make install" before "make test"), since the + library location is specified in the library. + + +Acknowledgments: + + The deflate format used by zlib was defined by Phil Katz. The deflate + and zlib specifications were written by L. Peter Deutsch. Thanks to all the + people who reported problems and suggested various improvements in zlib; + they are too numerous to cite here. + +Copyright notice: + + (C) 1995-2004 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* +receiving lengthy legal documents to sign. The sources are provided +for free but without warranty of any kind. The library has been +entirely written by Jean-loup Gailly and Mark Adler; it does not +include third-party code. + +If you redistribute modified sources, we would appreciate that you include +in the file ChangeLog history information documenting your changes. Please +read the FAQ for more information on the distribution of modified source +versions. diff --git a/src/zlib/adler32.c b/src/zlib/adler32.c new file mode 100644 index 000000000..dd6d60f7a --- /dev/null +++ b/src/zlib/adler32.c @@ -0,0 +1,74 @@ +/* adler32.c -- compute the Adler-32 checksum of a data stream + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +#define BASE 65521UL /* largest prime smaller than 65536 */ +#define NMAX 5552 +/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + +#define DO1(buf,i) {s1 += buf[i]; s2 += s1;} +#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); +#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); +#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); +#define DO16(buf) DO8(buf,0); DO8(buf,8); + +#ifdef NO_DIVIDE +# define MOD(a) \ + do { \ + if (a >= (BASE << 16)) a -= (BASE << 16); \ + if (a >= (BASE << 15)) a -= (BASE << 15); \ + if (a >= (BASE << 14)) a -= (BASE << 14); \ + if (a >= (BASE << 13)) a -= (BASE << 13); \ + if (a >= (BASE << 12)) a -= (BASE << 12); \ + if (a >= (BASE << 11)) a -= (BASE << 11); \ + if (a >= (BASE << 10)) a -= (BASE << 10); \ + if (a >= (BASE << 9)) a -= (BASE << 9); \ + if (a >= (BASE << 8)) a -= (BASE << 8); \ + if (a >= (BASE << 7)) a -= (BASE << 7); \ + if (a >= (BASE << 6)) a -= (BASE << 6); \ + if (a >= (BASE << 5)) a -= (BASE << 5); \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ + if (a >= BASE) a -= BASE; \ + } while (0) +#else +# define MOD(a) a %= BASE +#endif + +/* ========================================================================= */ +uLong ZEXPORT adler32(adler, buf, len) + uLong adler; + const Bytef *buf; + uInt len; +{ + unsigned long s1 = adler & 0xffff; + unsigned long s2 = (adler >> 16) & 0xffff; + int k; + + if (buf == Z_NULL) return 1L; + + while (len > 0) { + k = len < NMAX ? (int)len : NMAX; + len -= k; + while (k >= 16) { + DO16(buf); + buf += 16; + k -= 16; + } + if (k != 0) do { + s1 += *buf++; + s2 += s1; + } while (--k); + MOD(s1); + MOD(s2); + } + return (s2 << 16) | s1; +} diff --git a/src/zlib/compress.c b/src/zlib/compress.c new file mode 100644 index 000000000..5a7eeeeb2 --- /dev/null +++ b/src/zlib/compress.c @@ -0,0 +1,79 @@ +/* compress.c -- compress a memory buffer + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +/* =========================================================================== + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ +int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; + int level; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; +#ifdef MAXSEG_64K + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; +#endif + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; + + err = deflateInit(&stream, level); + if (err != Z_OK) return err; + + err = deflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + deflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = deflateEnd(&stream); + return err; +} + +/* =========================================================================== + */ +int ZEXPORT compress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); +} + +/* =========================================================================== + If the default memLevel or windowBits for deflateInit() is changed, then + this function needs to be updated. + */ +uLong ZEXPORT compressBound (sourceLen) + uLong sourceLen; +{ + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; +} diff --git a/src/zlib/crc32.c b/src/zlib/crc32.c new file mode 100644 index 000000000..7373092ee --- /dev/null +++ b/src/zlib/crc32.c @@ -0,0 +1,333 @@ +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Thanks to Rodney Brown for his contribution of faster + * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing + * tables for updating the shift register in one step with three exclusive-ors + * instead of four steps with four exclusive-ors. This results about a factor + * of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. + */ + +/* @(#) $Id$ */ + +/* + Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore + protection on the static variables used to control the first-use generation + of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should + first call get_crc_table() to initialize the tables before allowing more than + one thread to use crc32(). + */ + +#ifdef MAKECRCH +# include +# ifndef DYNAMIC_CRC_TABLE +# define DYNAMIC_CRC_TABLE +# endif /* !DYNAMIC_CRC_TABLE */ +#endif /* MAKECRCH */ + +#include "zutil.h" /* for STDC and FAR definitions */ + +#define local static + +/* Find a four-byte integer type for crc32_little() and crc32_big(). */ +#ifndef NOBYFOUR +# ifdef STDC /* need ANSI C limits.h to determine sizes */ +# include +# define BYFOUR +# if (UINT_MAX == 0xffffffffUL) + typedef unsigned int u4; +# else +# if (ULONG_MAX == 0xffffffffUL) + typedef unsigned long u4; +# else +# if (USHRT_MAX == 0xffffffffUL) + typedef unsigned short u4; +# else +# undef BYFOUR /* can't find a four-byte integer type! */ +# endif +# endif +# endif +# endif /* STDC */ +#endif /* !NOBYFOUR */ + +/* Definitions for doing the crc four data bytes at a time. */ +#ifdef BYFOUR +# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ + (((w)&0xff00)<<8)+(((w)&0xff)<<24)) + local unsigned long crc32_little OF((unsigned long, + const unsigned char FAR *, unsigned)); + local unsigned long crc32_big OF((unsigned long, + const unsigned char FAR *, unsigned)); +# define TBLS 8 +#else +# define TBLS 1 +#endif /* BYFOUR */ + +#ifdef DYNAMIC_CRC_TABLE + +local volatile int crc_table_empty = 1; +local unsigned long FAR crc_table[TBLS][256]; +local void make_crc_table OF((void)); +#ifdef MAKECRCH + local void write_table OF((FILE *, const unsigned long FAR *)); +#endif /* MAKECRCH */ + +/* + Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The first table is simply the CRC of all possible eight bit values. This is + all the information needed to generate CRCs on data a byte at a time for all + combinations of CRC register values and incoming bytes. The remaining tables + allow for word-at-a-time CRC calculation for both big-endian and little- + endian machines, where a word is four bytes. +*/ +local void make_crc_table() +{ + unsigned long c; + int n, k; + unsigned long poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static volatile int first = 1; /* flag to limit concurrent making */ + static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* See if another task is already doing this (not thread-safe, but better + than nothing -- significantly reduces duration of vulnerability in + case the advice about DYNAMIC_CRC_TABLE is ignored) */ + if (first) { + first = 0; + + /* make exclusive-or pattern from polynomial (0xedb88320UL) */ + poly = 0UL; + for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) + poly |= 1UL << (31 - p[n]); + + /* generate a crc for every 8-bit value */ + for (n = 0; n < 256; n++) { + c = (unsigned long)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[0][n] = c; + } + +#ifdef BYFOUR + /* generate crc for each value followed by one, two, and three zeros, + and then the byte reversal of those as well as the first table */ + for (n = 0; n < 256; n++) { + c = crc_table[0][n]; + crc_table[4][n] = REV(c); + for (k = 1; k < 4; k++) { + c = crc_table[0][c & 0xff] ^ (c >> 8); + crc_table[k][n] = c; + crc_table[k + 4][n] = REV(c); + } + } +#endif /* BYFOUR */ + + crc_table_empty = 0; + } + else { /* not first */ + /* wait for the other guy to finish (not efficient, but rare) */ + while (crc_table_empty) + ; + } + +#ifdef MAKECRCH + /* write out CRC tables to crc32.h */ + { + FILE *out; + + out = fopen("crc32.h", "w"); + if (out == NULL) return; + fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); + fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); + fprintf(out, "local const unsigned long FAR "); + fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); + write_table(out, crc_table[0]); +# ifdef BYFOUR + fprintf(out, "#ifdef BYFOUR\n"); + for (k = 1; k < 8; k++) { + fprintf(out, " },\n {\n"); + write_table(out, crc_table[k]); + } + fprintf(out, "#endif\n"); +# endif /* BYFOUR */ + fprintf(out, " }\n};\n"); + fclose(out); + } +#endif /* MAKECRCH */ +} + +#ifdef MAKECRCH +local void write_table(out, table) + FILE *out; + const unsigned long FAR *table; +{ + int n; + + for (n = 0; n < 256; n++) + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], + n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); +} +#endif /* MAKECRCH */ + +#else /* !DYNAMIC_CRC_TABLE */ +/* ======================================================================== + * Tables of CRC-32s of all single-byte values, made by make_crc_table(). + */ +#include "crc32.h" +#endif /* DYNAMIC_CRC_TABLE */ + +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const unsigned long FAR * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + return (const unsigned long FAR *)crc_table; +} + +/* ========================================================================= */ +#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) +#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 + +/* ========================================================================= */ +unsigned long ZEXPORT crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + if (buf == Z_NULL) return 0UL; + +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + +#ifdef BYFOUR + if (sizeof(void *) == sizeof(ptrdiff_t)) { + u4 endian; + + endian = 1; + if (*((unsigned char *)(&endian))) + return crc32_little(crc, buf, len); + else + return crc32_big(crc, buf, len); + } +#endif /* BYFOUR */ + crc = crc ^ 0xffffffffUL; + while (len >= 8) { + DO8; + len -= 8; + } + if (len) do { + DO1; + } while (--len); + return crc ^ 0xffffffffUL; +} + +#ifdef BYFOUR + +/* ========================================================================= */ +#define DOLIT4 c ^= *buf4++; \ + c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ + crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] +#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 + +/* ========================================================================= */ +local unsigned long crc32_little(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = (u4)crc; + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + len--; + } + + buf4 = (const u4 FAR *)buf; + while (len >= 32) { + DOLIT32; + len -= 32; + } + while (len >= 4) { + DOLIT4; + len -= 4; + } + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + } while (--len); + c = ~c; + return (unsigned long)c; +} + +/* ========================================================================= */ +#define DOBIG4 c ^= *++buf4; \ + c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ + crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] +#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 + +/* ========================================================================= */ +local unsigned long crc32_big(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = REV((u4)crc); + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + len--; + } + + buf4 = (const u4 FAR *)buf; + buf4--; + while (len >= 32) { + DOBIG32; + len -= 32; + } + while (len >= 4) { + DOBIG4; + len -= 4; + } + buf4++; + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + } while (--len); + c = ~c; + return (unsigned long)(REV(c)); +} + +#endif /* BYFOUR */ diff --git a/src/zlib/crc32.h b/src/zlib/crc32.h new file mode 100644 index 000000000..5de49bc97 --- /dev/null +++ b/src/zlib/crc32.h @@ -0,0 +1,441 @@ +/* crc32.h -- tables for rapid CRC calculation + * Generated automatically by crc32.c + */ + +local const unsigned long FAR crc_table[TBLS][256] = +{ + { + 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, + 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, + 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, + 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, + 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, + 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, + 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, + 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, + 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, + 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, + 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, + 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, + 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, + 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, + 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, + 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, + 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, + 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, + 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, + 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, + 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, + 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, + 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, + 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, + 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, + 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, + 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, + 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, + 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, + 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, + 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, + 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, + 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, + 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, + 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, + 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, + 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, + 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, + 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, + 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, + 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, + 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, + 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, + 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, + 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, + 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, + 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, + 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, + 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, + 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, + 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, + 0x2d02ef8dUL +#ifdef BYFOUR + }, + { + 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, + 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, + 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, + 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, + 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, + 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, + 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, + 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, + 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, + 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, + 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, + 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, + 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, + 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, + 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, + 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, + 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, + 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, + 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, + 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, + 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, + 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, + 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, + 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, + 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, + 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, + 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, + 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, + 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, + 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, + 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, + 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, + 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, + 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, + 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, + 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, + 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, + 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, + 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, + 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, + 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, + 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, + 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, + 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, + 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, + 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, + 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, + 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, + 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, + 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, + 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, + 0x9324fd72UL + }, + { + 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, + 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, + 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, + 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, + 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, + 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, + 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, + 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, + 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, + 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, + 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, + 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, + 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, + 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, + 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, + 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, + 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, + 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, + 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, + 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, + 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, + 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, + 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, + 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, + 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, + 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, + 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, + 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, + 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, + 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, + 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, + 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, + 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, + 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, + 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, + 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, + 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, + 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, + 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, + 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, + 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, + 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, + 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, + 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, + 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, + 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, + 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, + 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, + 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, + 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, + 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, + 0xbe9834edUL + }, + { + 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, + 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, + 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, + 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, + 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, + 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, + 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, + 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, + 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, + 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, + 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, + 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, + 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, + 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, + 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, + 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, + 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, + 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, + 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, + 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, + 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, + 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, + 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, + 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, + 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, + 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, + 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, + 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, + 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, + 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, + 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, + 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, + 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, + 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, + 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, + 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, + 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, + 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, + 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, + 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, + 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, + 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, + 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, + 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, + 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, + 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, + 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, + 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, + 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, + 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, + 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, + 0xde0506f1UL + }, + { + 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, + 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, + 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, + 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, + 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, + 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, + 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, + 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, + 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, + 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, + 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, + 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, + 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, + 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, + 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, + 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, + 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, + 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, + 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, + 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, + 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, + 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, + 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, + 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, + 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, + 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, + 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, + 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, + 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, + 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, + 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, + 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, + 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, + 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, + 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, + 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, + 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, + 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, + 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, + 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, + 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, + 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, + 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, + 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, + 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, + 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, + 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, + 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, + 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, + 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, + 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, + 0x8def022dUL + }, + { + 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, + 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, + 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, + 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, + 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, + 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, + 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, + 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, + 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, + 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, + 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, + 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, + 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, + 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, + 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, + 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, + 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, + 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, + 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, + 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, + 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, + 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, + 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, + 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, + 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, + 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, + 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, + 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, + 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, + 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, + 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, + 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, + 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, + 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, + 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, + 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, + 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, + 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, + 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, + 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, + 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, + 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, + 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, + 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, + 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, + 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, + 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, + 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, + 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, + 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, + 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, + 0x72fd2493UL + }, + { + 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, + 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, + 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, + 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, + 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, + 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, + 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, + 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, + 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, + 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, + 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, + 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, + 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, + 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, + 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, + 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, + 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, + 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, + 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, + 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, + 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, + 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, + 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, + 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, + 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, + 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, + 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, + 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, + 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, + 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, + 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, + 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, + 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, + 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, + 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, + 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, + 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, + 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, + 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, + 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, + 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, + 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, + 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, + 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, + 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, + 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, + 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, + 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, + 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, + 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, + 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, + 0xed3498beUL + }, + { + 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, + 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, + 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, + 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, + 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, + 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, + 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, + 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, + 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, + 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, + 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, + 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, + 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, + 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, + 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, + 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, + 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, + 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, + 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, + 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, + 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, + 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, + 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, + 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, + 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, + 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, + 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, + 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, + 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, + 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, + 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, + 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, + 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, + 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, + 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, + 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, + 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, + 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, + 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, + 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, + 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, + 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, + 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, + 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, + 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, + 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, + 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, + 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, + 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, + 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, + 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, + 0xf10605deUL +#endif + } +}; diff --git a/src/zlib/deflate.c b/src/zlib/deflate.c new file mode 100644 index 000000000..33a41e9ce --- /dev/null +++ b/src/zlib/deflate.c @@ -0,0 +1,1502 @@ +/* deflate.c -- compress data using the deflation algorithm + * Copyright (C) 1995-2004 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process depends on being able to identify portions + * of the input text which are identical to earlier input (within a + * sliding window trailing behind the input currently being processed). + * + * The most straightforward technique turns out to be the fastest for + * most input files: try all possible matches and select the longest. + * The key feature of this algorithm is that insertions into the string + * dictionary are very simple and thus fast, and deletions are avoided + * completely. Insertions are performed at each input character, whereas + * string matches are performed only when the previous match ends. So it + * is preferable to spend more time in matches to allow very fast string + * insertions and avoid deletions. The matching algorithm for small + * strings is inspired from that of Rabin & Karp. A brute force approach + * is used to find longer strings when a small match has been found. + * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze + * (by Leonid Broukhis). + * A previous version of this file used a more sophisticated algorithm + * (by Fiala and Greene) which is guaranteed to run in linear amortized + * time, but has a larger average cost, uses more memory and is patented. + * However the F&G algorithm may be faster for some highly redundant + * files if the parameter max_chain_length (described below) is too large. + * + * ACKNOWLEDGEMENTS + * + * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and + * I found it in 'freeze' written by Leonid Broukhis. + * Thanks to many people for bug reports and testing. + * + * REFERENCES + * + * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". + * Available in http://www.ietf.org/rfc/rfc1951.txt + * + * A description of the Rabin and Karp algorithm is given in the book + * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. + * + * Fiala,E.R., and Greene,D.H. + * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 + * + */ + +/* @(#) $Id$ */ + +#include "deflate.h" + +const char deflate_copyright[] = + " deflate 1.2.2 Copyright 1995-2004 Jean-loup Gailly "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* =========================================================================== + * Function prototypes. + */ +typedef enum { + need_more, /* block not completed, need more input or more output */ + block_done, /* block flush performed */ + finish_started, /* finish started, need only more output at next deflate */ + finish_done /* finish done, accept no more input or output */ +} block_state; + +typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +/* Compression function. Returns the block state after the call. */ + +local void fill_window OF((deflate_state *s)); +local block_state deflate_stored OF((deflate_state *s, int flush)); +local block_state deflate_fast OF((deflate_state *s, int flush)); +#ifndef FASTEST +local block_state deflate_slow OF((deflate_state *s, int flush)); +#endif +local void lm_init OF((deflate_state *s)); +local void putShortMSB OF((deflate_state *s, uInt b)); +local void flush_pending OF((z_streamp strm)); +local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +#ifndef FASTEST +#ifdef ASMV + void match_init OF((void)); /* asm code initialization */ + uInt longest_match OF((deflate_state *s, IPos cur_match)); +#else +local uInt longest_match OF((deflate_state *s, IPos cur_match)); +#endif +#endif +local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); + +#ifdef DEBUG +local void check_match OF((deflate_state *s, IPos start, IPos match, + int length)); +#endif + +/* =========================================================================== + * Local data + */ + +#define NIL 0 +/* Tail of hash chains */ + +#ifndef TOO_FAR +# define TOO_FAR 4096 +#endif +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ +typedef struct config_s { + ush good_length; /* reduce lazy search above this match length */ + ush max_lazy; /* do not perform lazy search above this match length */ + ush nice_length; /* quit search above this match length */ + ush max_chain; + compress_func func; +} config; + +#ifdef FASTEST +local const config configuration_table[2] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ +#else +local const config configuration_table[10] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ +/* 2 */ {4, 5, 16, 8, deflate_fast}, +/* 3 */ {4, 6, 32, 32, deflate_fast}, + +/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ +/* 5 */ {8, 16, 32, 32, deflate_slow}, +/* 6 */ {8, 16, 128, 128, deflate_slow}, +/* 7 */ {8, 32, 128, 256, deflate_slow}, +/* 8 */ {32, 128, 258, 1024, deflate_slow}, +/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ +#endif + +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ + +#define EQUAL 0 +/* result of memcmp for equal strings */ + +#ifndef NO_DUMMY_DECL +struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ +#endif + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ +#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) + + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * If this file is compiled with -DFASTEST, the compression level is forced + * to 1, and no hash chains are maintained. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef FASTEST +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#else +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#endif + +/* =========================================================================== + * Initialize the hash table (avoiding 64K overflow for 16 bit systems). + * prev[] will be initialized on the fly. + */ +#define CLEAR_HASH(s) \ + s->head[s->hash_size-1] = NIL; \ + zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + +/* ========================================================================= */ +int ZEXPORT deflateInit_(strm, level, version, stream_size) + z_streamp strm; + int level; + const char *version; + int stream_size; +{ + return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, version, stream_size); + /* To do: ignore strm->next_in if we use it as window */ +} + +/* ========================================================================= */ +int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + version, stream_size) + z_streamp strm; + int level; + int method; + int windowBits; + int memLevel; + int strategy; + const char *version; + int stream_size; +{ + deflate_state *s; + int wrap = 1; + static const char my_version[] = ZLIB_VERSION; + + ushf *overlay; + /* We overlay pending_buf and d_buf+l_buf. This works since the average + * output size for (length,distance) codes is <= 24 bits. + */ + + if (version == Z_NULL || version[0] != my_version[0] || + stream_size != sizeof(z_stream)) { + return Z_VERSION_ERROR; + } + if (strm == Z_NULL) return Z_STREAM_ERROR; + + strm->msg = Z_NULL; + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + + if (windowBits < 0) { /* suppress zlib wrapper */ + wrap = 0; + windowBits = -windowBits; + } +#ifdef GZIP + else if (windowBits > 15) { + wrap = 2; /* write gzip wrapper instead */ + windowBits -= 16; + } +#endif + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || + windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || + strategy < 0 || strategy > Z_RLE) { + return Z_STREAM_ERROR; + } + if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ + s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); + if (s == Z_NULL) return Z_MEM_ERROR; + strm->state = (struct internal_state FAR *)s; + s->strm = strm; + + s->wrap = wrap; + s->w_bits = windowBits; + s->w_size = 1 << s->w_bits; + s->w_mask = s->w_size - 1; + + s->hash_bits = memLevel + 7; + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); + + s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + + s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ + + overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + s->pending_buf = (uchf *) overlay; + s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + + if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || + s->pending_buf == Z_NULL) { + s->status = FINISH_STATE; + strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); + deflateEnd (strm); + return Z_MEM_ERROR; + } + s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + + s->level = level; + s->strategy = strategy; + s->method = (Byte)method; + + return deflateReset(strm); +} + +/* ========================================================================= */ +int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) + z_streamp strm; + const Bytef *dictionary; + uInt dictLength; +{ + deflate_state *s; + uInt length = dictLength; + uInt n; + IPos hash_head = 0; + + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || + strm->state->wrap == 2 || + (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) + return Z_STREAM_ERROR; + + s = strm->state; + if (s->wrap) + strm->adler = adler32(strm->adler, dictionary, dictLength); + + if (length < MIN_MATCH) return Z_OK; + if (length > MAX_DIST(s)) { + length = MAX_DIST(s); +#ifndef USE_DICT_HEAD + dictionary += dictLength - length; /* use the tail of the dictionary */ +#endif + } + zmemcpy(s->window, dictionary, length); + s->strstart = length; + s->block_start = (long)length; + + /* Insert all strings in the hash table (except for the last two bytes). + * s->lookahead stays null, so s->ins_h will be recomputed at the next + * call of fill_window. + */ + s->ins_h = s->window[0]; + UPDATE_HASH(s, s->ins_h, s->window[1]); + for (n = 0; n <= length - MIN_MATCH; n++) { + INSERT_STRING(s, n, hash_head); + } + if (hash_head) hash_head = 0; /* to make compiler happy */ + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateReset (strm) + z_streamp strm; +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { + return Z_STREAM_ERROR; + } + + strm->total_in = strm->total_out = 0; + strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ + strm->data_type = Z_UNKNOWN; + + s = (deflate_state *)strm->state; + s->pending = 0; + s->pending_out = s->pending_buf; + + if (s->wrap < 0) { + s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ + } + s->status = s->wrap ? INIT_STATE : BUSY_STATE; + strm->adler = +#ifdef GZIP + s->wrap == 2 ? crc32(0L, Z_NULL, 0) : +#endif + adler32(0L, Z_NULL, 0); + s->last_flush = Z_NO_FLUSH; + + _tr_init(s); + lm_init(s); + + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflatePrime (strm, bits, value) + z_streamp strm; + int bits; + int value; +{ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + strm->state->bi_valid = bits; + strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateParams(strm, level, strategy) + z_streamp strm; + int level; + int strategy; +{ + deflate_state *s; + compress_func func; + int err = Z_OK; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + if (level < 0 || level > 9 || strategy < 0 || strategy > Z_RLE) { + return Z_STREAM_ERROR; + } + func = configuration_table[s->level].func; + + if (func != configuration_table[level].func && strm->total_in != 0) { + /* Flush the last buffer: */ + err = deflate(strm, Z_PARTIAL_FLUSH); + } + if (s->level != level) { + s->level = level; + s->max_lazy_match = configuration_table[level].max_lazy; + s->good_match = configuration_table[level].good_length; + s->nice_match = configuration_table[level].nice_length; + s->max_chain_length = configuration_table[level].max_chain; + } + s->strategy = strategy; + return err; +} + +/* ========================================================================= + * For the default windowBits of 15 and memLevel of 8, this function returns + * a close to exact, as well as small, upper bound on the compressed size. + * They are coded as constants here for a reason--if the #define's are + * changed, then this function needs to be changed as well. The return + * value for 15 and 8 only works for those exact settings. + * + * For any setting other than those defaults for windowBits and memLevel, + * the value returned is a conservative worst case for the maximum expansion + * resulting from using fixed blocks instead of stored blocks, which deflate + * can emit on compressed data for some combinations of the parameters. + * + * This function could be more sophisticated to provide closer upper bounds + * for every combination of windowBits and memLevel, as well as wrap. + * But even the conservative upper bound of about 14% expansion does not + * seem onerous for output buffer allocation. + */ +uLong ZEXPORT deflateBound(strm, sourceLen) + z_streamp strm; + uLong sourceLen; +{ + deflate_state *s; + uLong destLen; + + /* conservative upper bound */ + destLen = sourceLen + + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11; + + /* if can't get parameters, return conservative bound */ + if (strm == Z_NULL || strm->state == Z_NULL) + return destLen; + + /* if not default parameters, return conservative bound */ + s = strm->state; + if (s->w_bits != 15 || s->hash_bits != 8 + 7) + return destLen; + + /* default settings: return tight bound for that case */ + return compressBound(sourceLen); +} + +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +local void putShortMSB (s, b) + deflate_state *s; + uInt b; +{ + put_byte(s, (Byte)(b >> 8)); + put_byte(s, (Byte)(b & 0xff)); +} + +/* ========================================================================= + * Flush as much pending output as possible. All deflate() output goes + * through this function so some applications may wish to modify it + * to avoid allocating a large strm->next_out buffer and copying into it. + * (See also read_buf()). + */ +local void flush_pending(strm) + z_streamp strm; +{ + unsigned len = strm->state->pending; + + if (len > strm->avail_out) len = strm->avail_out; + if (len == 0) return; + + zmemcpy(strm->next_out, strm->state->pending_out, len); + strm->next_out += len; + strm->state->pending_out += len; + strm->total_out += len; + strm->avail_out -= len; + strm->state->pending -= len; + if (strm->state->pending == 0) { + strm->state->pending_out = strm->state->pending_buf; + } +} + +/* ========================================================================= */ +int ZEXPORT deflate (strm, flush) + z_streamp strm; + int flush; +{ + int old_flush; /* value of flush param for previous deflate call */ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + flush > Z_FINISH || flush < 0) { + return Z_STREAM_ERROR; + } + s = strm->state; + + if (strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0) || + (s->status == FINISH_STATE && flush != Z_FINISH)) { + ERR_RETURN(strm, Z_STREAM_ERROR); + } + if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); + + s->strm = strm; /* just in case */ + old_flush = s->last_flush; + s->last_flush = flush; + + /* Write the header */ + if (s->status == INIT_STATE) { +#ifdef GZIP + if (s->wrap == 2) { + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, 255); + s->status = BUSY_STATE; + strm->adler = crc32(0L, Z_NULL, 0); + } + else +#endif + { + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags; + + if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) + level_flags = 0; + else if (s->level < 6) + level_flags = 1; + else if (s->level == 6) + level_flags = 2; + else + level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + s->status = BUSY_STATE; + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = adler32(0L, Z_NULL, 0); + } + } + + /* Flush as much pending output as possible */ + if (s->pending != 0) { + flush_pending(strm); + if (strm->avail_out == 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUF_ERROR. + */ + } else if (strm->avail_in == 0 && flush <= old_flush && + flush != Z_FINISH) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s->status == FINISH_STATE && strm->avail_in != 0) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* Start a new block or continue the current one. + */ + if (strm->avail_in != 0 || s->lookahead != 0 || + (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { + block_state bstate; + + bstate = (*(configuration_table[s->level].func))(s, flush); + + if (bstate == finish_started || bstate == finish_done) { + s->status = FINISH_STATE; + } + if (bstate == need_more || bstate == finish_started) { + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } + if (bstate == block_done) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(s); + } else { /* FULL_FLUSH or SYNC_FLUSH */ + _tr_stored_block(s, (char*)0, 0L, 0); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush == Z_FULL_FLUSH) { + CLEAR_HASH(s); /* forget history */ + } + } + flush_pending(strm); + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + Assert(strm->avail_out > 0, "bug2"); + + if (flush != Z_FINISH) return Z_OK; + if (s->wrap <= 0) return Z_STREAM_END; + + /* Write the trailer */ +#ifdef GZIP + if (s->wrap == 2) { + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); + put_byte(s, (Byte)(strm->total_in & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); + } + else +#endif + { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + flush_pending(strm); + /* If avail_out is zero, the application will call deflate again + * to flush the rest. + */ + if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ + return s->pending != 0 ? Z_OK : Z_STREAM_END; +} + +/* ========================================================================= */ +int ZEXPORT deflateEnd (strm) + z_streamp strm; +{ + int status; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + + status = strm->state->status; + if (status != INIT_STATE && status != BUSY_STATE && + status != FINISH_STATE) { + return Z_STREAM_ERROR; + } + + /* Deallocate in reverse order of allocations: */ + TRY_FREE(strm, strm->state->pending_buf); + TRY_FREE(strm, strm->state->head); + TRY_FREE(strm, strm->state->prev); + TRY_FREE(strm, strm->state->window); + + ZFREE(strm, strm->state); + strm->state = Z_NULL; + + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; +} + +/* ========================================================================= + * Copy the source state to the destination state. + * To simplify the source, this is not supported for 16-bit MSDOS (which + * doesn't have enough memory anyway to duplicate compression states). + */ +int ZEXPORT deflateCopy (dest, source) + z_streamp dest; + z_streamp source; +{ +#ifdef MAXSEG_64K + return Z_STREAM_ERROR; +#else + deflate_state *ds; + deflate_state *ss; + ushf *overlay; + + + if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + return Z_STREAM_ERROR; + } + + ss = source->state; + + *dest = *source; + + ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); + if (ds == Z_NULL) return Z_MEM_ERROR; + dest->state = (struct internal_state FAR *) ds; + *ds = *ss; + ds->strm = dest; + + ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); + ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); + overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); + ds->pending_buf = (uchf *) overlay; + + if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || + ds->pending_buf == Z_NULL) { + deflateEnd (dest); + return Z_MEM_ERROR; + } + /* following zmemcpy do not work for 16-bit MSDOS */ + zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); + zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); + zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + + ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); + ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); + ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; + + ds->l_desc.dyn_tree = ds->dyn_ltree; + ds->d_desc.dyn_tree = ds->dyn_dtree; + ds->bl_desc.dyn_tree = ds->bl_tree; + + return Z_OK; +#endif /* MAXSEG_64K */ +} + +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local int read_buf(strm, buf, size) + z_streamp strm; + Bytef *buf; + unsigned size; +{ + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, strm->next_in, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, strm->next_in, len); + } +#endif + zmemcpy(buf, strm->next_in, len); + strm->next_in += len; + strm->total_in += len; + + return (int)len; +} + +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init (s) + deflate_state *s; +{ + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +#ifdef ASMV + match_init(); /* initialize the asm code */ +#endif +} + +#ifndef FASTEST +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + * OUT assertion: the match length is not greater than s->lookahead. + */ +#ifndef ASMV +/* For 80x86 and 680x0, an optimized version will be provided in match.asm or + * match.S. The code will be functionally equivalent. + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + int best_len = s->prev_length; /* best match length so far */ + int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + s->strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Posf *prev = s->prev; + uInt wmask = s->w_mask; + +#ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; + register ush scan_start = *(ushf*)scan; + register ush scan_end = *(ushf*)(scan+best_len-1); +#else + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end = scan[best_len]; +#endif + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + Assert(cur_match < s->strstart, "no future"); + match = s->window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2: + */ +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ushf*)(match+best_len-1) != scan_end || + *(ushf*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++, match++; + do { + } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + +#else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + +#endif /* UNALIGNED_OK */ + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; +#ifdef UNALIGNED_OK + scan_end = *(ushf*)(scan+best_len-1); +#else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; +#endif + } + } while ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0); + + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + return s->lookahead; +} +#endif /* ASMV */ +#endif /* FASTEST */ + +/* --------------------------------------------------------------------------- + * Optimized version for level == 1 or strategy == Z_RLE only + */ +local uInt longest_match_fast(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + Assert(cur_match < s->strstart, "no future"); + + match = s->window + cur_match; + + /* Return failure if the match length is less than 2: + */ + if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match += 2; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + + if (len < MIN_MATCH) return MIN_MATCH - 1; + + s->match_start = cur_match; + return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; +} + +#ifdef DEBUG +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +local void check_match(s, start, match, length) + deflate_state *s; + IPos start, match; + int length; +{ + /* check that the match is indeed a match */ + if (zmemcmp(s->window + match, + s->window + start, length) != EQUAL) { + fprintf(stderr, " start %u, match %u, length %d\n", + start, match, length); + do { + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + } while (--length != 0); + z_error("invalid match"); + } + if (z_verbose > 1) { + fprintf(stderr,"\\[%d,%d]", start-match, length); + do { putc(s->window[start++], stderr); } while (--length != 0); + } +} +#else +# define check_match(s, start, match, length) +#endif /* DEBUG */ + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(s) + deflate_state *s; +{ + register unsigned n, m; + register Posf *p; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize+MAX_DIST(s)) { + + zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); + + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif + more += wsize; + } + if (s->strm->avail_in == 0) return; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead >= MIN_MATCH) { + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK_ONLY(s, eof) { \ + _tr_flush_block(s, (s->block_start >= 0L ? \ + (charf *)&s->window[(unsigned)s->block_start] : \ + (charf *)Z_NULL), \ + (ulg)((long)s->strstart - s->block_start), \ + (eof)); \ + s->block_start = s->strstart; \ + flush_pending(s->strm); \ + Tracev((stderr,"[FLUSH]")); \ +} + +/* Same but force premature exit if necessary. */ +#define FLUSH_BLOCK(s, eof) { \ + FLUSH_BLOCK_ONLY(s, eof); \ + if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ +} + +/* =========================================================================== + * Copy without compression as much as possible from the input stream, return + * the current block state. + * This function does not insert new strings in the dictionary since + * uncompressible data is probably not useful. This function is used + * only for the level=0 compression option. + * NOTE: this function should be optimized to avoid extra copying from + * window to pending_buf. + */ +local block_state deflate_stored(s, flush) + deflate_state *s; + int flush; +{ + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited + * to pending_buf_size, and each stored block has a 5 byte header: + */ + ulg max_block_size = 0xffff; + ulg max_start; + + if (max_block_size > s->pending_buf_size - 5) { + max_block_size = s->pending_buf_size - 5; + } + + /* Copy as much as possible from input to output: */ + for (;;) { + /* Fill the window as much as possible: */ + if (s->lookahead <= 1) { + + Assert(s->strstart < s->w_size+MAX_DIST(s) || + s->block_start >= (long)s->w_size, "slide too late"); + + fill_window(s); + if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; + + if (s->lookahead == 0) break; /* flush the current block */ + } + Assert(s->block_start >= 0L, "block gone"); + + s->strstart += s->lookahead; + s->lookahead = 0; + + /* Emit a stored block if pending_buf will be full: */ + max_start = s->block_start + max_block_size; + if (s->strstart == 0 || (ulg)s->strstart >= max_start) { + /* strstart == 0 is possible when wraparound on 16-bit machine */ + s->lookahead = (uInt)(s->strstart - max_start); + s->strstart = (uInt)max_start; + FLUSH_BLOCK(s, 0); + } + /* Flush if we may have to slide, otherwise block_start may become + * negative and the data will be gone: + */ + if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { + FLUSH_BLOCK(s, 0); + } + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * Compress as much as possible from the input stream, return the current + * block state. + * This function does not perform lazy evaluation of matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +local block_state deflate_fast(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head = NIL; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ +#ifdef FASTEST + if ((s->strategy < Z_HUFFMAN_ONLY) || + (s->strategy == Z_RLE && s->strstart - hash_head == 1)) { + s->match_length = longest_match_fast (s, hash_head); + } +#else + if (s->strategy < Z_HUFFMAN_ONLY) { + s->match_length = longest_match (s, hash_head); + } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { + s->match_length = longest_match_fast (s, hash_head); + } +#endif + /* longest_match() or longest_match_fast() sets match_start */ + } + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->match_start, s->match_length); + + _tr_tally_dist(s, s->strstart - s->match_start, + s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ +#ifndef FASTEST + if (s->match_length <= s->max_insert_length && + s->lookahead >= MIN_MATCH) { + s->match_length--; /* string at strstart already in table */ + do { + s->strstart++; + INSERT_STRING(s, s->strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s->match_length != 0); + s->strstart++; + } else +#endif + { + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +#ifndef FASTEST +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +local block_state deflate_slow(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head = NIL; /* head of hash chain */ + int bflush; /* set if current block must be flushed */ + + /* Process the input block. */ + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + */ + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = MIN_MATCH-1; + + if (hash_head != NIL && s->prev_length < s->max_lazy_match && + s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + if (s->strategy < Z_HUFFMAN_ONLY) { + s->match_length = longest_match (s, hash_head); + } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { + s->match_length = longest_match_fast (s, hash_head); + } + /* longest_match() or longest_match_fast() sets match_start */ + + if (s->match_length <= 5 && (s->strategy == Z_FILTERED +#if TOO_FAR <= 32767 + || (s->match_length == MIN_MATCH && + s->strstart - s->match_start > TOO_FAR) +#endif + )) { + + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + s->match_length = MIN_MATCH-1; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { + uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; + /* Do not insert strings in hash table beyond this. */ + + check_match(s, s->strstart-1, s->prev_match, s->prev_length); + + _tr_tally_dist(s, s->strstart -1 - s->prev_match, + s->prev_length - MIN_MATCH, bflush); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. If there is not + * enough lookahead, the last two strings are not inserted in + * the hash table. + */ + s->lookahead -= s->prev_length-1; + s->prev_length -= 2; + do { + if (++s->strstart <= max_insert) { + INSERT_STRING(s, s->strstart, hash_head); + } + } while (--s->prev_length != 0); + s->match_available = 0; + s->match_length = MIN_MATCH-1; + s->strstart++; + + if (bflush) FLUSH_BLOCK(s, 0); + + } else if (s->match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { + FLUSH_BLOCK_ONLY(s, 0); + } + s->strstart++; + s->lookahead--; + if (s->strm->avail_out == 0) return need_more; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + s->match_available = 1; + s->strstart++; + s->lookahead--; + } + } + Assert (flush != Z_NO_FLUSH, "no flush?"); + if (s->match_available) { + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + s->match_available = 0; + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} +#endif /* FASTEST */ diff --git a/src/zlib/deflate.h b/src/zlib/deflate.h new file mode 100644 index 000000000..043328367 --- /dev/null +++ b/src/zlib/deflate.h @@ -0,0 +1,325 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-2002 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef DEFLATE_H +#define DEFLATE_H + +#include "zutil.h" + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer creation by deflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip encoding + should be left enabled. */ +#ifndef NO_GZIP +# define GZIP +#endif + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define INIT_STATE 42 +#define BUSY_STATE 113 +#define FINISH_STATE 666 +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + int pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + Byte method; /* STORED (for zip only) or DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to supress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + uchf *l_buf; /* buffer for literals or lengths */ + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt last_lit; /* running index in l_buf */ + + ushf *d_buf; + /* Buffer for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + int last_eob_len; /* bit length of EOB code for last block */ + +#ifdef DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + + /* in trees.c */ +void _tr_init OF((deflate_state *s)); +int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); +void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, + int eof)); +void _tr_align OF((deflate_state *s)); +void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, + int eof)); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch _length_code[]; + extern uch _dist_code[]; +#else + extern const uch _length_code[]; + extern const uch _dist_code[]; +#endif + +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (length); \ + ush dist = (distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif /* DEFLATE_H */ diff --git a/src/zlib/inffast.c b/src/zlib/inffast.c new file mode 100644 index 000000000..af9f38f9a --- /dev/null +++ b/src/zlib/inffast.c @@ -0,0 +1,305 @@ +/* inffast.c -- fast decoding + * Copyright (C) 1995-2004 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifndef ASMINF + +/* Allow machine dependent optimization for post-increment or pre-increment. + Based on testing to date, + Pre-increment preferred for: + - PowerPC G3 (Adler) + - MIPS R5000 (Randers-Pehrson) + Post-increment preferred for: + - none + No measurable difference: + - Pentium III (Anderson) + - M68060 (Nikl) + */ +#ifdef POSTINC +# define OFF 0 +# define PUP(a) *(a)++ +#else +# define OFF 1 +# define PUP(a) *++(a) +#endif + +/* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state->mode == LEN + strm->avail_in >= 6 + strm->avail_out >= 258 + start >= strm->avail_out + state->bits < 8 + + On return, state->mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm->avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm->avail_out >= 258 for each loop to avoid checking for + output space. + */ +void inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + unsigned char FAR *in; /* local strm->next_in */ + unsigned char FAR *last; /* while in < last, enough input available */ + unsigned char FAR *out; /* local strm->next_out */ + unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ + unsigned char FAR *end; /* while out < end, enough space available */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned write; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const FAR *lcode; /* local strm->lencode */ + code const FAR *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + code this; /* retrieved table entry */ + unsigned op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned char FAR *from; /* where to copy match from */ + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + in = strm->next_in - OFF; + last = in + (strm->avail_in - 5); + out = strm->next_out - OFF; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); + wsize = state->wsize; + whave = state->whave; + write = state->write; + window = state->window; + hold = state->hold; + bits = state->bits; + lcode = state->lencode; + dcode = state->distcode; + lmask = (1U << state->lenbits) - 1; + dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + do { + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + this = lcode[hold & lmask]; + dolen: + op = (unsigned)(this.bits); + hold >>= op; + bits -= op; + op = (unsigned)(this.op); + if (op == 0) { /* literal */ + Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", this.val)); + PUP(out) = (unsigned char)(this.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(this.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + } + Tracevv((stderr, "inflate: length %u\n", len)); + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + this = dcode[hold & dmask]; + dodist: + op = (unsigned)(this.bits); + hold >>= op; + bits -= op; + op = (unsigned)(this.op); + if (op & 16) { /* distance base */ + dist = (unsigned)(this.val); + op &= 15; /* number of extra bits */ + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + } + dist += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + Tracevv((stderr, "inflate: distance %u\n", dist)); + op = (unsigned)(out - beg); /* max distance in output */ + if (dist > op) { /* see if copy from window */ + op = dist - op; /* distance back in window */ + if (op > whave) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + from = window - OFF; + if (write == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + else if (write < op) { /* wrap around window */ + from += wsize + write - op; + op -= write; + if (op < len) { /* some from end of window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = window - OFF; + if (write < len) { /* some from start of window */ + op = write; + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + } + else { /* contiguous in window */ + from += write - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + else { + from = out - dist; /* copy direct from output */ + do { /* minimum length is three */ + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } while (len > 2); + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + } + else if ((op & 64) == 0) { /* 2nd level distance code */ + this = dcode[this.val + (hold & ((1U << op) - 1))]; + goto dodist; + } + else { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + } + else if ((op & 64) == 0) { /* 2nd level length code */ + this = lcode[this.val + (hold & ((1U << op) - 1))]; + goto dolen; + } + else if (op & 32) { /* end-of-block */ + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + else { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + } while (in < last && out < end); + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + len = bits >> 3; + in -= len; + bits -= len << 3; + hold &= (1U << bits) - 1; + + /* update state and return */ + strm->next_in = in + OFF; + strm->next_out = out + OFF; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end)); + state->hold = hold; + state->bits = bits; + return; +} + +/* + inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): + - Using bit fields for code structure + - Different op definition to avoid & for extra bits (do & for table bits) + - Three separate decoding do-loops for direct, window, and write == 0 + - Special case for distance > 1 copies to do overlapped load and store copy + - Explicit branch predictions (based on measured branch probabilities) + - Deferring match copy and interspersed it with decoding subsequent codes + - Swapping literal/length else + - Swapping window/direct else + - Larger unrolled copy loops (three is about right) + - Moving len -= 3 statement into middle of loop + */ + +#endif /* !ASMINF */ diff --git a/src/zlib/inffast.h b/src/zlib/inffast.h new file mode 100644 index 000000000..614fa7877 --- /dev/null +++ b/src/zlib/inffast.h @@ -0,0 +1,11 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +void inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/src/zlib/inffixed.h b/src/zlib/inffixed.h new file mode 100644 index 000000000..423d5c5b5 --- /dev/null +++ b/src/zlib/inffixed.h @@ -0,0 +1,94 @@ + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by makefixed(). + */ + + /* WARNING: this file should *not* be used by applications. It + is part of the implementation of the compression library and + is subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} + }; + + static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} + }; diff --git a/src/zlib/inflate.c b/src/zlib/inflate.c new file mode 100644 index 000000000..81d93b0a7 --- /dev/null +++ b/src/zlib/inflate.c @@ -0,0 +1,1274 @@ +/* inflate.c -- zlib decompression + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * Change history: + * + * 1.2.beta0 24 Nov 2002 + * - First version -- complete rewrite of inflate to simplify code, avoid + * creation of window when not needed, minimize use of window when it is + * needed, make inffast.c even faster, implement gzip decoding, and to + * improve code readability and style over the previous zlib inflate code + * + * 1.2.beta1 25 Nov 2002 + * - Use pointers for available input and output checking in inffast.c + * - Remove input and output counters in inffast.c + * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 + * - Remove unnecessary second byte pull from length extra in inffast.c + * - Unroll direct copy to three copies per loop in inffast.c + * + * 1.2.beta2 4 Dec 2002 + * - Change external routine names to reduce potential conflicts + * - Correct filename to inffixed.h for fixed tables in inflate.c + * - Make hbuf[] unsigned char to match parameter type in inflate.c + * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) + * to avoid negation problem on Alphas (64 bit) in inflate.c + * + * 1.2.beta3 22 Dec 2002 + * - Add comments on state->bits assertion in inffast.c + * - Add comments on op field in inftrees.h + * - Fix bug in reuse of allocated window after inflateReset() + * - Remove bit fields--back to byte structure for speed + * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths + * - Change post-increments to pre-increments in inflate_fast(), PPC biased? + * - Add compile time option, POSTINC, to use post-increments instead (Intel?) + * - Make MATCH copy in inflate() much faster for when inflate_fast() not used + * - Use local copies of stream next and avail values, as well as local bit + * buffer and bit count in inflate()--for speed when inflate_fast() not used + * + * 1.2.beta4 1 Jan 2003 + * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings + * - Move a comment on output buffer sizes from inffast.c to inflate.c + * - Add comments in inffast.c to introduce the inflate_fast() routine + * - Rearrange window copies in inflate_fast() for speed and simplification + * - Unroll last copy for window match in inflate_fast() + * - Use local copies of window variables in inflate_fast() for speed + * - Pull out common write == 0 case for speed in inflate_fast() + * - Make op and len in inflate_fast() unsigned for consistency + * - Add FAR to lcode and dcode declarations in inflate_fast() + * - Simplified bad distance check in inflate_fast() + * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new + * source file infback.c to provide a call-back interface to inflate for + * programs like gzip and unzip -- uses window as output buffer to avoid + * window copying + * + * 1.2.beta5 1 Jan 2003 + * - Improved inflateBack() interface to allow the caller to provide initial + * input in strm. + * - Fixed stored blocks bug in inflateBack() + * + * 1.2.beta6 4 Jan 2003 + * - Added comments in inffast.c on effectiveness of POSTINC + * - Typecasting all around to reduce compiler warnings + * - Changed loops from while (1) or do {} while (1) to for (;;), again to + * make compilers happy + * - Changed type of window in inflateBackInit() to unsigned char * + * + * 1.2.beta7 27 Jan 2003 + * - Changed many types to unsigned or unsigned short to avoid warnings + * - Added inflateCopy() function + * + * 1.2.0 9 Mar 2003 + * - Changed inflateBack() interface to provide separate opaque descriptors + * for the in() and out() functions + * - Changed inflateBack() argument and in_func typedef to swap the length + * and buffer address return values for the input function + * - Check next_in and next_out for Z_NULL on entry to inflate() + * + * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifdef MAKEFIXED +# ifndef BUILDFIXED +# define BUILDFIXED +# endif +#endif + +/* function prototypes */ +local void fixedtables OF((struct inflate_state FAR *state)); +local int updatewindow OF((z_streamp strm, unsigned out)); +#ifdef BUILDFIXED + void makefixed OF((void)); +#endif +local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, + unsigned len)); + +int ZEXPORT inflateReset(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + strm->total_in = strm->total_out = state->total = 0; + strm->msg = Z_NULL; + strm->adler = 1; /* to support ill-conceived Java test suite */ + state->mode = HEAD; + state->last = 0; + state->havedict = 0; + state->wsize = 0; + state->whave = 0; + state->hold = 0; + state->bits = 0; + state->lencode = state->distcode = state->next = state->codes; + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + +int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) +z_streamp strm; +int windowBits; +const char *version; +int stream_size; +{ + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL) return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + state = (struct inflate_state FAR *) + ZALLOC(strm, 1, sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (voidpf)state; + if (windowBits < 0) { + state->wrap = 0; + windowBits = -windowBits; + } + else { + state->wrap = (windowBits >> 4) + 1; +#ifdef GUNZIP + if (windowBits < 48) windowBits &= 15; +#endif + } + if (windowBits < 8 || windowBits > 15) { + ZFREE(strm, state); + strm->state = Z_NULL; + return Z_STREAM_ERROR; + } + state->wbits = (unsigned)windowBits; + state->window = Z_NULL; + return inflateReset(strm); +} + +int ZEXPORT inflateInit_(strm, version, stream_size) +z_streamp strm; +const char *version; +int stream_size; +{ + return inflateInit2_(strm, DEF_WBITS, version, stream_size); +} + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +local void fixedtables(state) +struct inflate_state FAR *state; +{ +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +#ifdef MAKEFIXED +#include + +/* + Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also + defines BUILDFIXED, so the tables are built on the fly. makefixed() writes + those tables to stdout, which would be piped to inffixed.h. A small program + can simply call makefixed to do this: + + void makefixed(void); + + int main(void) + { + makefixed(); + return 0; + } + + Then that can be linked with zlib built with MAKEFIXED defined and run: + + a.out > inffixed.h + */ +void makefixed() +{ + unsigned low, size; + struct inflate_state state; + + fixedtables(&state); + puts(" /* inffixed.h -- table for decoding fixed codes"); + puts(" * Generated automatically by makefixed()."); + puts(" */"); + puts(""); + puts(" /* WARNING: this file should *not* be used by applications."); + puts(" It is part of the implementation of this library and is"); + puts(" subject to change. Applications should only use zlib.h."); + puts(" */"); + puts(""); + size = 1U << 9; + printf(" static const code lenfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 7) == 0) printf("\n "); + printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, + state.lencode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); + size = 1U << 5; + printf("\n static const code distfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 6) == 0) printf("\n "); + printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, + state.distcode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); +} +#endif /* MAKEFIXED */ + +/* + Update the window with the last wsize (normally 32K) bytes written before + returning. If window does not exist yet, create it. This is only called + when a window is already in use, or when output has been written during this + inflate call, but the end of the deflate stream has not been reached yet. + It is also called to create a window for dictionary data when a dictionary + is loaded. + + Providing output buffers larger than 32K to inflate() should provide a speed + advantage, since only the last 32K of output is copied to the sliding window + upon return from inflate(), and since all distances after the first 32K of + output will fall in the output data, making match copies simpler and faster. + The advantage may be dependent on the size of the processor's data caches. + */ +local int updatewindow(strm, out) +z_streamp strm; +unsigned out; +{ + struct inflate_state FAR *state; + unsigned copy, dist; + + state = (struct inflate_state FAR *)strm->state; + + /* if it hasn't been done already, allocate space for the window */ + if (state->window == Z_NULL) { + state->window = (unsigned char FAR *) + ZALLOC(strm, 1U << state->wbits, + sizeof(unsigned char)); + if (state->window == Z_NULL) return 1; + } + + /* if window not in use yet, initialize */ + if (state->wsize == 0) { + state->wsize = 1U << state->wbits; + state->write = 0; + state->whave = 0; + } + + /* copy state->wsize or less output bytes into the circular window */ + copy = out - strm->avail_out; + if (copy >= state->wsize) { + zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); + state->write = 0; + state->whave = state->wsize; + } + else { + dist = state->wsize - state->write; + if (dist > copy) dist = copy; + zmemcpy(state->window + state->write, strm->next_out - copy, dist); + copy -= dist; + if (copy) { + zmemcpy(state->window, strm->next_out - copy, copy); + state->write = copy; + state->whave = state->wsize; + } + else { + state->write += dist; + if (state->write == state->wsize) state->write = 0; + if (state->whave < state->wsize) state->whave += dist; + } + } + return 0; +} + +/* Macros for inflate(): */ + +/* check function to use adler32() for zlib or crc32() for gzip */ +#ifdef GUNZIP +# define UPDATE(check, buf, len) \ + (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) +#else +# define UPDATE(check, buf, len) adler32(check, buf, len) +#endif + +/* check macros for header crc */ +#ifdef GUNZIP +# define CRC2(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + check = crc32(check, hbuf, 2); \ + } while (0) + +# define CRC4(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + hbuf[2] = (unsigned char)((word) >> 16); \ + hbuf[3] = (unsigned char)((word) >> 24); \ + check = crc32(check, hbuf, 4); \ + } while (0) +#endif + +/* Load registers with state in inflate() for speed */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Restore state from registers in inflate() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflate() + if there is no input available. */ +#define PULLBYTE() \ + do { \ + if (have == 0) goto inf_leave; \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflate(). */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* Reverse the bytes in a 32-bit value */ +#define REVERSE(q) \ + ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + +/* + inflate() uses a state machine to process as much input data and generate as + much output data as possible before returning. The state machine is + structured roughly as follows: + + for (;;) switch (state) { + ... + case STATEn: + if (not enough input data or output space to make progress) + return; + ... make progress ... + state = STATEm; + break; + ... + } + + so when inflate() is called again, the same case is attempted again, and + if the appropriate resources are provided, the machine proceeds to the + next state. The NEEDBITS() macro is usually the way the state evaluates + whether it can proceed or should return. NEEDBITS() does the return if + the requested bits are not available. The typical use of the BITS macros + is: + + NEEDBITS(n); + ... do something with BITS(n) ... + DROPBITS(n); + + where NEEDBITS(n) either returns from inflate() if there isn't enough + input left to load n bits into the accumulator, or it continues. BITS(n) + gives the low n bits in the accumulator. When done, DROPBITS(n) drops + the low n bits off the accumulator. INITBITS() clears the accumulator + and sets the number of available bits to zero. BYTEBITS() discards just + enough bits to put the accumulator on a byte boundary. After BYTEBITS() + and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. + + NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return + if there is no input available. The decoding of variable length codes uses + PULLBYTE() directly in order to pull just enough bytes to decode the next + code, and no more. + + Some states loop until they get enough input, making sure that enough + state information is maintained to continue the loop where it left off + if NEEDBITS() returns in the loop. For example, want, need, and keep + would all have to actually be part of the saved state in case NEEDBITS() + returns: + + case STATEw: + while (want < need) { + NEEDBITS(n); + keep[want++] = BITS(n); + DROPBITS(n); + } + state = STATEx; + case STATEx: + + As shown above, if the next state is also the next case, then the break + is omitted. + + A state may also return if there is not enough output space available to + complete that state. Those states are copying stored data, writing a + literal byte, and copying a matching string. + + When returning, a "goto inf_leave" is used to update the total counters, + update the check value, and determine whether any progress has been made + during that inflate() call in order to return the proper return code. + Progress is defined as a change in either strm->avail_in or strm->avail_out. + When there is a window, goto inf_leave will update the window with the last + output written. If a goto inf_leave occurs in the middle of decompression + and there is no window currently, goto inf_leave will create one and copy + output to the window for the next call of inflate(). + + In this implementation, the flush parameter of inflate() only affects the + return code (per zlib.h). inflate() always writes as much as possible to + strm->next_out, given the space available and the provided input--the effect + documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers + the allocation of and copying into a sliding window until necessary, which + provides the effect documented in zlib.h for Z_FINISH when the entire input + stream available. So the only thing the flush parameter actually does is: + when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it + will return Z_BUF_ERROR if it has not reached the end of the stream. + */ + +int ZEXPORT inflate(strm, flush) +z_streamp strm; +int flush; +{ + struct inflate_state FAR *state; + unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned in, out; /* save starting available input and output */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code this; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ +#ifdef GUNZIP + unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ +#endif + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0)) + return Z_STREAM_ERROR; + + state = (struct inflate_state FAR *)strm->state; + if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ + LOAD(); + in = have; + out = left; + ret = Z_OK; + for (;;) + switch (state->mode) { + case HEAD: + if (state->wrap == 0) { + state->mode = TYPEDO; + break; + } + NEEDBITS(16); +#ifdef GUNZIP + if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ + state->check = crc32(0L, Z_NULL, 0); + CRC2(state->check, hold); + INITBITS(); + state->mode = FLAGS; + break; + } + state->flags = 0; /* expect zlib header */ + if (!(state->wrap & 1) || /* check if zlib header allowed */ +#else + if ( +#endif + ((BITS(8) << 8) + (hold >> 8)) % 31) { + strm->msg = (char *)"incorrect header check"; + state->mode = BAD; + break; + } + if (BITS(4) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + DROPBITS(4); + if (BITS(4) + 8 > state->wbits) { + strm->msg = (char *)"invalid window size"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: zlib header ok\n")); + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = hold & 0x200 ? DICTID : TYPE; + INITBITS(); + break; +#ifdef GUNZIP + case FLAGS: + NEEDBITS(16); + state->flags = (int)(hold); + if ((state->flags & 0xff) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + if (state->flags & 0xe000) { + strm->msg = (char *)"unknown header flags set"; + state->mode = BAD; + break; + } + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + state->mode = TIME; + case TIME: + NEEDBITS(32); + if (state->flags & 0x0200) CRC4(state->check, hold); + INITBITS(); + state->mode = OS; + case OS: + NEEDBITS(16); + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + state->mode = EXLEN; + case EXLEN: + if (state->flags & 0x0400) { + NEEDBITS(16); + state->length = (unsigned)(hold); + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + } + state->mode = EXTRA; + case EXTRA: + if (state->flags & 0x0400) { + copy = state->length; + if (copy > have) copy = have; + if (copy) { + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + state->length -= copy; + } + if (state->length) goto inf_leave; + } + state->mode = NAME; + case NAME: + if (state->flags & 0x0800) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + } while (len && copy < have); + if (state->flags & 0x02000) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + state->mode = COMMENT; + case COMMENT: + if (state->flags & 0x1000) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + } while (len && copy < have); + if (state->flags & 0x02000) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + state->mode = HCRC; + case HCRC: + if (state->flags & 0x0200) { + NEEDBITS(16); + if (hold != (state->check & 0xffff)) { + strm->msg = (char *)"header crc mismatch"; + state->mode = BAD; + break; + } + INITBITS(); + } + strm->adler = state->check = crc32(0L, Z_NULL, 0); + state->mode = TYPE; + break; +#endif + case DICTID: + NEEDBITS(32); + strm->adler = state->check = REVERSE(hold); + INITBITS(); + state->mode = DICT; + case DICT: + if (state->havedict == 0) { + RESTORE(); + return Z_NEED_DICT; + } + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = TYPE; + case TYPE: + if (flush == Z_BLOCK) goto inf_leave; + case TYPEDO: + if (state->last) { + BYTEBITS(); + state->mode = CHECK; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + state->last ? " (last)" : "")); + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + Tracev((stderr, "inflate: fixed codes block%s\n", + state->last ? " (last)" : "")); + state->mode = LEN; /* decode codes */ + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + state->last ? " (last)" : "")); + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + case STORED: + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %u\n", + state->length)); + INITBITS(); + state->mode = COPY; + case COPY: + copy = state->length; + if (copy) { + if (copy > have) copy = have; + if (copy > left) copy = left; + if (copy == 0) goto inf_leave; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + break; + } + Tracev((stderr, "inflate: stored end\n")); + state->mode = TYPE; + break; + case TABLE: + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); +#ifndef PKZIP_BUG_WORKAROUND + if (state->nlen > 286 || state->ndist > 30) { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } +#endif + Tracev((stderr, "inflate: table sizes ok\n")); + state->have = 0; + state->mode = LENLENS; + case LENLENS: + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + state->have = 0; + state->mode = CODELENS; + case CODELENS: + while (state->have < state->nlen + state->ndist) { + for (;;) { + this = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if (this.val < 16) { + NEEDBITS(this.bits); + DROPBITS(this.bits); + state->lens[state->have++] = this.val; + } + else { + if (this.val == 16) { + NEEDBITS(this.bits + 2); + DROPBITS(this.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = state->lens[state->have - 1]; + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (this.val == 17) { + NEEDBITS(this.bits + 3); + DROPBITS(this.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(this.bits + 7); + DROPBITS(this.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (state->mode == BAD) break; + + /* build code tables */ + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (code const FAR *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + &(state->next), &(state->distbits), state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + state->mode = LEN; + case LEN: + if (have >= 6 && left >= 258) { + RESTORE(); + inflate_fast(strm, out); + LOAD(); + break; + } + for (;;) { + this = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if (this.op && (this.op & 0xf0) == 0) { + last = this; + for (;;) { + this = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + this.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(this.bits); + state->length = (unsigned)this.val; + if ((int)(this.op) == 0) { + Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", this.val)); + state->mode = LIT; + break; + } + if (this.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + if (this.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + state->extra = (unsigned)(this.op) & 15; + state->mode = LENEXT; + case LENEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + } + Tracevv((stderr, "inflate: length %u\n", state->length)); + state->mode = DIST; + case DIST: + for (;;) { + this = state->distcode[BITS(state->distbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if ((this.op & 0xf0) == 0) { + last = this; + for (;;) { + this = state->distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + this.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(this.bits); + if (this.op & 64) { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)this.val; + state->extra = (unsigned)(this.op) & 15; + state->mode = DISTEXT; + case DISTEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + } + if (state->offset > state->whave + out - left) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + Tracevv((stderr, "inflate: distance %u\n", state->offset)); + state->mode = MATCH; + case MATCH: + if (left == 0) goto inf_leave; + copy = out - left; + if (state->offset > copy) { /* copy from window */ + copy = state->offset - copy; + if (copy > state->write) { + copy -= state->write; + from = state->window + (state->wsize - copy); + } + else + from = state->window + (state->write - copy); + if (copy > state->length) copy = state->length; + } + else { /* copy from output */ + from = put - state->offset; + copy = state->length; + } + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do { + *put++ = *from++; + } while (--copy); + if (state->length == 0) state->mode = LEN; + break; + case LIT: + if (left == 0) goto inf_leave; + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + case CHECK: + if (state->wrap) { + NEEDBITS(32); + out -= left; + strm->total_out += out; + state->total += out; + if (out) + strm->adler = state->check = + UPDATE(state->check, put - out, out); + out = left; + if (( +#ifdef GUNZIP + state->flags ? hold : +#endif + REVERSE(hold)) != state->check) { + strm->msg = (char *)"incorrect data check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: check matches trailer\n")); + } +#ifdef GUNZIP + state->mode = LENGTH; + case LENGTH: + if (state->wrap && state->flags) { + NEEDBITS(32); + if (hold != (state->total & 0xffffffffUL)) { + strm->msg = (char *)"incorrect length check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: length matches trailer\n")); + } +#endif + state->mode = DONE; + case DONE: + ret = Z_STREAM_END; + goto inf_leave; + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + default: + return Z_STREAM_ERROR; + } + + /* + Return from inflate(), updating the total counts and the check value. + If there was no progress during the inflate() call, return a buffer + error. Call updatewindow() to create and/or update the window state. + Note: a memory error from inflate() is non-recoverable. + */ + inf_leave: + RESTORE(); + if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) + if (updatewindow(strm, out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + in -= strm->avail_in; + out -= strm->avail_out; + strm->total_in += in; + strm->total_out += out; + state->total += out; + if (state->wrap && out) + strm->adler = state->check = + UPDATE(state->check, strm->next_out - out, out); + strm->data_type = state->bits + (state->last ? 64 : 0) + + (state->mode == TYPE ? 128 : 0); + if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) + ret = Z_BUF_ERROR; + return ret; +} + +int ZEXPORT inflateEnd(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->window != Z_NULL) ZFREE(strm, state->window); + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + +int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) +z_streamp strm; +const Bytef *dictionary; +uInt dictLength; +{ + struct inflate_state FAR *state; + unsigned long id; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->mode != DICT) return Z_STREAM_ERROR; + + /* check for correct dictionary id */ + id = adler32(0L, Z_NULL, 0); + id = adler32(id, dictionary, dictLength); + if (id != state->check) return Z_DATA_ERROR; + + /* copy dictionary to window */ + if (updatewindow(strm, strm->avail_out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + if (dictLength > state->wsize) { + zmemcpy(state->window, dictionary + dictLength - state->wsize, + state->wsize); + state->whave = state->wsize; + } + else { + zmemcpy(state->window + state->wsize - dictLength, dictionary, + dictLength); + state->whave = dictLength; + } + state->havedict = 1; + Tracev((stderr, "inflate: dictionary set\n")); + return Z_OK; +} + +/* + Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found + or when out of input. When called, *have is the number of pattern bytes + found in order so far, in 0..3. On return *have is updated to the new + state. If on return *have equals four, then the pattern was found and the + return value is how many bytes were read including the last byte of the + pattern. If *have is less than four, then the pattern has not been found + yet and the return value is len. In the latter case, syncsearch() can be + called again with more data and the *have state. *have is initialized to + zero for the first call. + */ +local unsigned syncsearch(have, buf, len) +unsigned FAR *have; +unsigned char FAR *buf; +unsigned len; +{ + unsigned got; + unsigned next; + + got = *have; + next = 0; + while (next < len && got < 4) { + if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) + got++; + else if (buf[next]) + got = 0; + else + got = 4 - got; + next++; + } + *have = got; + return next; +} + +int ZEXPORT inflateSync(strm) +z_streamp strm; +{ + unsigned len; /* number of bytes to look at or looked at */ + unsigned long in, out; /* temporary to save total_in and total_out */ + unsigned char buf[4]; /* to restore bit buffer to byte string */ + struct inflate_state FAR *state; + + /* check parameters */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; + + /* if first time, start search in bit buffer */ + if (state->mode != SYNC) { + state->mode = SYNC; + state->hold <<= state->bits & 7; + state->bits -= state->bits & 7; + len = 0; + while (state->bits >= 8) { + buf[len++] = (unsigned char)(state->hold); + state->hold >>= 8; + state->bits -= 8; + } + state->have = 0; + syncsearch(&(state->have), buf, len); + } + + /* search available input */ + len = syncsearch(&(state->have), strm->next_in, strm->avail_in); + strm->avail_in -= len; + strm->next_in += len; + strm->total_in += len; + + /* return no joy or set up to restart inflate() on a new block */ + if (state->have != 4) return Z_DATA_ERROR; + in = strm->total_in; out = strm->total_out; + inflateReset(strm); + strm->total_in = in; strm->total_out = out; + state->mode = TYPE; + return Z_OK; +} + +/* + Returns true if inflate is currently at the end of a block generated by + Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + implementation to provide an additional safety check. PPP uses + Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored + block. When decompressing, PPP checks that at the end of input packet, + inflate is waiting for these length bytes. + */ +int ZEXPORT inflateSyncPoint(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + return state->mode == STORED && state->bits == 0; +} + +int ZEXPORT inflateCopy(dest, source) +z_streamp dest; +z_streamp source; +{ + struct inflate_state FAR *state; + struct inflate_state FAR *copy; + unsigned char FAR *window; + + /* check input */ + if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || + source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)source->state; + + /* allocate space */ + copy = (struct inflate_state FAR *) + ZALLOC(source, 1, sizeof(struct inflate_state)); + if (copy == Z_NULL) return Z_MEM_ERROR; + window = Z_NULL; + if (state->window != Z_NULL) { + window = (unsigned char FAR *) + ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); + if (window == Z_NULL) { + ZFREE(source, copy); + return Z_MEM_ERROR; + } + } + + /* copy state */ + *dest = *source; + *copy = *state; + copy->lencode = copy->codes + (state->lencode - state->codes); + copy->distcode = copy->codes + (state->distcode - state->codes); + copy->next = copy->codes + (state->next - state->codes); + if (window != Z_NULL) + zmemcpy(window, state->window, 1U << state->wbits); + copy->window = window; + dest->state = (voidpf)copy; + return Z_OK; +} diff --git a/src/zlib/inflate.h b/src/zlib/inflate.h new file mode 100644 index 000000000..b6965127b --- /dev/null +++ b/src/zlib/inflate.h @@ -0,0 +1,117 @@ +/* inflate.h -- internal inflate state definition + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer decoding by inflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip decoding + should be left enabled. */ +#ifndef NO_GZIP +# define GUNZIP +#endif + +/* Possible inflate modes between inflate() calls */ +typedef enum { + HEAD, /* i: waiting for magic header */ +#ifdef GUNZIP + FLAGS, /* i: waiting for method and flags (gzip) */ + TIME, /* i: waiting for modification time (gzip) */ + OS, /* i: waiting for extra flags and operating system (gzip) */ + EXLEN, /* i: waiting for extra length (gzip) */ + EXTRA, /* i: waiting for extra bytes (gzip) */ + NAME, /* i: waiting for end of file name (gzip) */ + COMMENT, /* i: waiting for end of comment (gzip) */ + HCRC, /* i: waiting for header crc (gzip) */ +#endif + DICTID, /* i: waiting for dictionary check value */ + DICT, /* waiting for inflateSetDictionary() call */ + TYPE, /* i: waiting for type bits, including last-flag bit */ + TYPEDO, /* i: same, but skip check to exit inflate on new block */ + STORED, /* i: waiting for stored size (length and complement) */ + COPY, /* i/o: waiting for input or output to copy stored block */ + TABLE, /* i: waiting for dynamic block table lengths */ + LENLENS, /* i: waiting for code length code lengths */ + CODELENS, /* i: waiting for length/lit and distance code lengths */ + LEN, /* i: waiting for length/lit code */ + LENEXT, /* i: waiting for length extra bits */ + DIST, /* i: waiting for distance code */ + DISTEXT, /* i: waiting for distance extra bits */ + MATCH, /* o: waiting for output space to copy string */ + LIT, /* o: waiting for output space to write literal */ + CHECK, /* i: waiting for 32-bit check value */ +#ifdef GUNZIP + LENGTH, /* i: waiting for 32-bit length (gzip) */ +#endif + DONE, /* finished check, done -- remain here until reset */ + BAD, /* got a data error -- remain here until reset */ + MEM, /* got an inflate() memory error -- remain here until reset */ + SYNC /* looking for synchronization bytes to restart inflate() */ +} inflate_mode; + +/* + State transitions between above modes - + + (most modes can go to the BAD or MEM mode -- not shown for clarity) + + Process header: + HEAD -> (gzip) or (zlib) + (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME + NAME -> COMMENT -> HCRC -> TYPE + (zlib) -> DICTID or TYPE + DICTID -> DICT -> TYPE + Read deflate blocks: + TYPE -> STORED or TABLE or LEN or CHECK + STORED -> COPY -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN + Read deflate codes: + LEN -> LENEXT or LIT or TYPE + LENEXT -> DIST -> DISTEXT -> MATCH -> LEN + LIT -> LEN + Process trailer: + CHECK -> LENGTH -> DONE + */ + +/* state maintained between inflate() calls. Approximately 7K bytes. */ +struct inflate_state { + inflate_mode mode; /* current inflate mode */ + int last; /* true if processing last block */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + int havedict; /* true if dictionary provided */ + int flags; /* gzip header method and flags (0 if zlib) */ + unsigned long check; /* protected copy of check value */ + unsigned long total; /* protected copy of output count */ + /* sliding window */ + unsigned wbits; /* log base 2 of requested window size */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned write; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* bit accumulator */ + unsigned long hold; /* input bit accumulator */ + unsigned bits; /* number of bits in "in" */ + /* for string and stored block copying */ + unsigned length; /* literal or length of data to copy */ + unsigned offset; /* distance back to copy string from */ + /* for table and code decoding */ + unsigned extra; /* extra bits needed */ + /* fixed and dynamic code tables */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ +}; diff --git a/src/zlib/inftrees.c b/src/zlib/inftrees.c new file mode 100644 index 000000000..214cb236c --- /dev/null +++ b/src/zlib/inftrees.c @@ -0,0 +1,328 @@ +/* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2004 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" + +#define MAXBITS 15 + +const char inflate_copyright[] = + " inflate 1.2.2 Copyright 1995-2004 Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* + Build a set of tables to decode the provided canonical Huffman code. + The code lengths are lens[0..codes-1]. The result starts at *table, + whose indices are 0..2^bits-1. work is a writable array of at least + lens shorts, which is used as a work area. type is the type of code + to be generated, CODES, LENS, or DISTS. On return, zero is success, + -1 is an invalid code, and +1 means that ENOUGH isn't enough. table + on return points to the next available entry's address. bits is the + requested root table index bits, and on return it is the actual root + table index bits. It will differ if the request is greater than the + longest code or if it is less than the shortest code. + */ +int inflate_table(type, lens, codes, table, bits, work) +codetype type; +unsigned short FAR *lens; +unsigned codes; +code FAR * FAR *table; +unsigned FAR *bits; +unsigned short FAR *work; +{ + unsigned len; /* a code's length in bits */ + unsigned sym; /* index of code symbols */ + unsigned min, max; /* minimum and maximum code lengths */ + unsigned root; /* number of index bits for root table */ + unsigned curr; /* number of index bits for current table */ + unsigned drop; /* code bits to drop for sub-table */ + int left; /* number of prefix codes available */ + unsigned used; /* code entries in table used */ + unsigned huff; /* Huffman code */ + unsigned incr; /* for incrementing code, index */ + unsigned fill; /* index for replicating entries */ + unsigned low; /* low bits for current root entry */ + unsigned mask; /* mask for low root bits */ + code this; /* table entry for duplication */ + code FAR *next; /* next available space in table */ + const unsigned short FAR *base; /* base value table to use */ + const unsigned short FAR *extra; /* extra bits table to use */ + int end; /* use base and extra for symbol > end */ + unsigned short count[MAXBITS+1]; /* number of codes of each length */ + unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ + static const unsigned short lbase[31] = { /* Length codes 257..285 base */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + static const unsigned short lext[31] = { /* Length codes 257..285 extra */ + 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 198}; + static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577, 0, 0}; + static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ + 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, + 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 28, 28, 29, 29, 64, 64}; + + /* + Process a set of code lengths to create a canonical Huffman code. The + code lengths are lens[0..codes-1]. Each length corresponds to the + symbols 0..codes-1. The Huffman code is generated by first sorting the + symbols by length from short to long, and retaining the symbol order + for codes with equal lengths. Then the code starts with all zero bits + for the first code of the shortest length, and the codes are integer + increments for the same length, and zeros are appended as the length + increases. For the deflate format, these bits are stored backwards + from their more natural integer increment ordering, and so when the + decoding tables are built in the large loop below, the integer codes + are incremented backwards. + + This routine assumes, but does not check, that all of the entries in + lens[] are in the range 0..MAXBITS. The caller must assure this. + 1..MAXBITS is interpreted as that code length. zero means that that + symbol does not occur in this code. + + The codes are sorted by computing a count of codes for each length, + creating from that a table of starting indices for each length in the + sorted table, and then entering the symbols in order in the sorted + table. The sorted table is work[], with that space being provided by + the caller. + + The length counts are used for other purposes as well, i.e. finding + the minimum and maximum length codes, determining if there are any + codes at all, checking for a valid set of lengths, and looking ahead + at length counts to determine sub-table sizes when building the + decoding tables. + */ + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAXBITS; len++) + count[len] = 0; + for (sym = 0; sym < codes; sym++) + count[lens[sym]]++; + + /* bound code lengths, force root to be within code lengths */ + root = *bits; + for (max = MAXBITS; max >= 1; max--) + if (count[max] != 0) break; + if (root > max) root = max; + if (max == 0) { /* no symbols to code at all */ + this.op = (unsigned char)64; /* invalid code marker */ + this.bits = (unsigned char)1; + this.val = (unsigned short)0; + *(*table)++ = this; /* make a table to force an error */ + *(*table)++ = this; + *bits = 1; + return 0; /* no symbols, but wait for decoding to report error */ + } + for (min = 1; min <= MAXBITS; min++) + if (count[min] != 0) break; + if (root < min) root = min; + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) return -1; /* over-subscribed */ + } + if (left > 0 && (type == CODES || (codes - count[0] != 1))) + return -1; /* incomplete set */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + count[len]; + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) + if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; + + /* + Create and fill in decoding tables. In this loop, the table being + filled is at next and has curr index bits. The code being used is huff + with length len. That code is converted to an index by dropping drop + bits off of the bottom. For codes where len is less than drop + curr, + those top drop + curr - len bits are incremented through all values to + fill the table with replicated entries. + + root is the number of index bits for the root table. When len exceeds + root, sub-tables are created pointed to by the root entry with an index + of the low root bits of huff. This is saved in low to check for when a + new sub-table should be started. drop is zero when the root table is + being filled, and drop is root when sub-tables are being filled. + + When a new sub-table is needed, it is necessary to look ahead in the + code lengths to determine what size sub-table is needed. The length + counts are used for this, and so count[] is decremented as codes are + entered in the tables. + + used keeps track of how many table entries have been allocated from the + provided *table space. It is checked when a LENS table is being made + against the space in *table, ENOUGH, minus the maximum space needed by + the worst case distance code, MAXD. This should never happen, but the + sufficiency of ENOUGH has not been proven exhaustively, hence the check. + This assumes that when type == LENS, bits == 9. + + sym increments through all symbols, and the loop terminates when + all codes of length max, i.e. all codes, have been processed. This + routine permits incomplete codes, so another loop after this one fills + in the rest of the decoding tables with invalid code markers. + */ + + /* set up for code type */ + switch (type) { + case CODES: + base = extra = work; /* dummy value--not used */ + end = 19; + break; + case LENS: + base = lbase; + base -= 257; + extra = lext; + extra -= 257; + end = 256; + break; + default: /* DISTS */ + base = dbase; + extra = dext; + end = -1; + } + + /* initialize state for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = *table; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = (unsigned)(-1); /* trigger new sub-table when len > root */ + used = 1U << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if (type == LENS && used >= ENOUGH - MAXD) + return 1; + + /* process all codes and make table entries */ + for (;;) { + /* create table entry */ + this.bits = (unsigned char)(len - drop); + if ((int)(work[sym]) < end) { + this.op = (unsigned char)0; + this.val = work[sym]; + } + else if ((int)(work[sym]) > end) { + this.op = (unsigned char)(extra[work[sym]]); + this.val = base[work[sym]]; + } + else { + this.op = (unsigned char)(32 + 64); /* end of block */ + this.val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1U << (len - drop); + fill = 1U << curr; + do { + fill -= incr; + next[(huff >> drop) + fill] = this; + } while (fill != 0); + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + + /* go to next symbol, update count, len */ + sym++; + if (--(count[len]) == 0) { + if (len == max) break; + len = lens[work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) != low) { + /* if first time, transition to sub-tables */ + if (drop == 0) + drop = root; + + /* increment past last table */ + next += 1U << curr; + + /* determine length of next table */ + curr = len - drop; + left = (int)(1 << curr); + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) break; + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1U << curr; + if (type == LENS && used >= ENOUGH - MAXD) + return 1; + + /* point entry in root table to sub-table */ + low = huff & mask; + (*table)[low].op = (unsigned char)curr; + (*table)[low].bits = (unsigned char)root; + (*table)[low].val = (unsigned short)(next - *table); + } + } + + /* + Fill in rest of table for incomplete codes. This loop is similar to the + loop above in incrementing huff for table indices. It is assumed that + len is equal to curr + drop, so there is no loop needed to increment + through high index bits. When the current sub-table is filled, the loop + drops back to the root table to fill in any remaining entries there. + */ + this.op = (unsigned char)64; /* invalid code marker */ + this.bits = (unsigned char)(len - drop); + this.val = (unsigned short)0; + while (huff != 0) { + /* when done with sub-table, drop back to root table */ + if (drop != 0 && (huff & mask) != low) { + drop = 0; + len = root; + next = *table; + this.bits = (unsigned char)len; + } + + /* put invalid code marker in table */ + next[huff >> drop] = this; + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + } + + /* set return parameters */ + *table += used; + *bits = root; + return 0; +} diff --git a/src/zlib/inftrees.h b/src/zlib/inftrees.h new file mode 100644 index 000000000..1dbfe53a6 --- /dev/null +++ b/src/zlib/inftrees.h @@ -0,0 +1,55 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + +/* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 0001eeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + +/* Maximum size of dynamic tree. The maximum found in a long but non- + exhaustive search was 1004 code structures (850 for length/literals + and 154 for distances, the latter actually the result of an + exhaustive search). The true maximum is not known, but the value + below is more than safe. */ +#define ENOUGH 1440 +#define MAXD 154 + +/* Type of code to build for inftable() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; + +extern int inflate_table OF((codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work)); diff --git a/src/zlib/trees.c b/src/zlib/trees.c new file mode 100644 index 000000000..26f3cf161 --- /dev/null +++ b/src/zlib/trees.c @@ -0,0 +1,1215 @@ +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1995-2003 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in a compressed form which is itself + * a Huffman encoding of the lengths of all the code strings (in + * ascending order by source values). The actual code strings are + * reconstructed from the lengths in the inflate process, as described + * in the deflate specification. + * + * REFERENCES + * + * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". + * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + */ + +/* @(#) $Id$ */ + +/* #define GEN_TREES_H */ + +#include "deflate.h" + +#ifdef DEBUG +# include +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +local const int extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +local const uch bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +#define Buf_size (8 * 2*sizeof(char)) +/* Number of bits used within bi_buf. (bi_buf might be implemented on + * more than 16 bits on some systems.) + */ + +/* =========================================================================== + * Local data. These are initialized only once. + */ + +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) || !defined(STDC) +/* non ANSI compilers may not accept trees.h */ + +local ct_data static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +local ct_data static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +uch _dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +uch _length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +local int base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +local int base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + +struct static_tree_desc_s { + const ct_data *static_tree; /* static tree or NULL */ + const intf *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ +}; + +local static_tree_desc static_l_desc = +{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; + +local static_tree_desc static_d_desc = +{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; + +local static_tree_desc static_bl_desc = +{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; + +/* =========================================================================== + * Local (static) routines in this file. + */ + +local void tr_static_init OF((void)); +local void init_block OF((deflate_state *s)); +local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); +local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); +local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); +local void build_tree OF((deflate_state *s, tree_desc *desc)); +local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local int build_bl_tree OF((deflate_state *s)); +local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, + int blcodes)); +local void compress_block OF((deflate_state *s, ct_data *ltree, + ct_data *dtree)); +local void set_data_type OF((deflate_state *s)); +local unsigned bi_reverse OF((unsigned value, int length)); +local void bi_windup OF((deflate_state *s)); +local void bi_flush OF((deflate_state *s)); +local void copy_block OF((deflate_state *s, charf *buf, unsigned len, + int header)); + +#ifdef GEN_TREES_H +local void gen_trees_header OF((void)); +#endif + +#ifndef DEBUG +# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) + /* Send a code of the given tree. c and tree must not have side effects */ + +#else /* DEBUG */ +# define send_code(s, c, tree) \ + { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ + send_bits(s, tree[c].Code, tree[c].Len); } +#endif + +/* =========================================================================== + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +#ifdef DEBUG +local void send_bits OF((deflate_state *s, int value, int length)); + +local void send_bits(s, value, length) + deflate_state *s; + int value; /* value to send */ + int length; /* number of bits */ +{ + Tracevv((stderr," l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + s->bits_sent += (ulg)length; + + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (s->bi_valid > (int)Buf_size - length) { + s->bi_buf |= (value << s->bi_valid); + put_short(s, s->bi_buf); + s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); + s->bi_valid += length - Buf_size; + } else { + s->bi_buf |= value << s->bi_valid; + s->bi_valid += length; + } +} +#else /* !DEBUG */ + +#define send_bits(s, value, length) \ +{ int len = length;\ + if (s->bi_valid > (int)Buf_size - len) {\ + int val = value;\ + s->bi_buf |= (val << s->bi_valid);\ + put_short(s, s->bi_buf);\ + s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ + s->bi_valid += len - Buf_size;\ + } else {\ + s->bi_buf |= (value) << s->bi_valid;\ + s->bi_valid += len;\ + }\ +} +#endif /* DEBUG */ + + +/* the arguments must not have side effects */ + +/* =========================================================================== + * Initialize the various 'constant' tables. + */ +local void tr_static_init() +{ +#if defined(GEN_TREES_H) || !defined(STDC) + static int static_init_done = 0; + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + if (static_init_done) return; + + /* For some embedded targets, global variables are not initialized: */ + static_l_desc.static_tree = static_ltree; + static_l_desc.extra_bits = extra_lbits; + static_d_desc.static_tree = static_dtree; + static_d_desc.extra_bits = extra_dbits; + static_bl_desc.extra_bits = extra_blbits; + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1< dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + _dist_code[256 + dist++] = (uch)code; + } + } + Assert (dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse((unsigned)n, 5); + } + static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) || !defined(STDC) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef DEBUG +# include +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() +{ + FILE *header = fopen("trees.h", "w"); + int i; + + Assert (header != NULL, "Can't open trees.h"); + fprintf(header, + "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", _dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", _length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "local const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); + } + + fclose(header); +} +#endif /* GEN_TREES_H */ + +/* =========================================================================== + * Initialize the tree data structures for a new zlib stream. + */ +void _tr_init(s) + deflate_state *s; +{ + tr_static_init(); + + s->l_desc.dyn_tree = s->dyn_ltree; + s->l_desc.stat_desc = &static_l_desc; + + s->d_desc.dyn_tree = s->dyn_dtree; + s->d_desc.stat_desc = &static_d_desc; + + s->bl_desc.dyn_tree = s->bl_tree; + s->bl_desc.stat_desc = &static_bl_desc; + + s->bi_buf = 0; + s->bi_valid = 0; + s->last_eob_len = 8; /* enough lookahead for inflate */ +#ifdef DEBUG + s->compressed_len = 0L; + s->bits_sent = 0L; +#endif + + /* Initialize the first block of the first file: */ + init_block(s); +} + +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(s) + deflate_state *s; +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->last_lit = s->matches = 0; +} + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + + +/* =========================================================================== + * Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. + */ +#define pqremove(s, tree, top) \ +{\ + top = s->heap[SMALLEST]; \ + s->heap[SMALLEST] = s->heap[s->heap_len--]; \ + pqdownheap(s, tree, SMALLEST); \ +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +#define smaller(tree, n, m, depth) \ + (tree[n].Freq < tree[m].Freq || \ + (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +local void pqdownheap(s, tree, k) + deflate_state *s; + ct_data *tree; /* the tree to restore */ + int k; /* node to move down */ +{ + int v = s->heap[k]; + int j = k << 1; /* left son of k */ + while (j <= s->heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < s->heap_len && + smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { + j++; + } + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, s->heap[j], s->depth)) break; + + /* Exchange v with the smallest son */ + s->heap[k] = s->heap[j]; k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + s->heap[k] = v; +} + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +local void gen_bitlen(s, desc) + deflate_state *s; + tree_desc *desc; /* the tree descriptor */ +{ + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const intf *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ + + for (h = s->heap_max+1; h < HEAP_SIZE; h++) { + n = s->heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (ush)bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) continue; /* not a leaf node */ + + s->bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + s->opt_len += (ulg)f * (bits + xbits); + if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); + } + if (overflow == 0) return; + + Trace((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length-1; + while (s->bl_count[bits] == 0) bits--; + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s->bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = s->bl_count[bits]; + while (n != 0) { + m = s->heap[--h]; + if (m > max_code) continue; + if (tree[m].Len != (unsigned) bits) { + Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s->opt_len += ((long)bits - (long)tree[m].Len) + *(long)tree[m].Freq; + tree[m].Len = (ush)bits; + } + n--; + } + } +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes (tree, max_code, bl_count) + ct_data *tree; /* the tree to decorate */ + int max_code; /* largest code with non zero frequency */ + ushf *bl_count; /* number of codes at each bit length */ +{ + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + ush code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + bl_count[bits-1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node; /* new node being created */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + s->heap_len = 0, s->heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + s->heap[++(s->heap_len)] = max_code = n; + s->depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (s->heap_len < 2) { + node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); + tree[node].Freq = 1; + s->depth[node] = 0; + s->opt_len--; if (stree) s->static_len -= stree[node].Len; + /* node is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + node = elems; /* next internal node of the tree */ + do { + pqremove(s, tree, n); /* n = node of least frequency */ + m = s->heap[SMALLEST]; /* m = node of next least frequency */ + + s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ + s->heap[--(s->heap_max)] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? + s->depth[n] : s->depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (ush)node; +#ifdef DUMP_BL_TREE + if (tree == s->bl_tree) { + fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + s->heap[SMALLEST] = node++; + pqdownheap(s, tree, SMALLEST); + + } while (s->heap_len >= 2); + + s->heap[--(s->heap_max)] = s->heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen(s, (tree_desc *)desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes ((ct_data *)tree, max_code, s->bl_count); +} + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. + */ +local void scan_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (ush)0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + s->bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) s->bl_tree[curlen].Freq++; + s->bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + s->bl_tree[REPZ_3_10].Freq++; + } else { + s->bl_tree[REPZ_11_138].Freq++; + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +local void send_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { send_code(s, curlen, s->bl_tree); } while (--count != 0); + + } else if (curlen != 0) { + if (curlen != prevlen) { + send_code(s, curlen, s->bl_tree); count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); + + } else if (count <= 10) { + send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); + + } else { + send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +local int build_bl_tree(s) + deflate_state *s; +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); + scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(s, (tree_desc *)(&(s->bl_desc))); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { + if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; + } + /* Update opt_len to include the bit length tree and counts */ + s->opt_len += 3*(max_blindex+1) + 5+5+4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", + s->opt_len, s->static_len)); + + return max_blindex; +} + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +local void send_all_trees(s, lcodes, dcodes, blcodes) + deflate_state *s; + int lcodes, dcodes, blcodes; /* number of codes for each tree */ +{ + int rank; /* index in bl_order */ + + Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); +} + +/* =========================================================================== + * Send a stored block + */ +void _tr_stored_block(s, buf, stored_len, eof) + deflate_state *s; + charf *buf; /* input block */ + ulg stored_len; /* length of input block */ + int eof; /* true if this is the last block for a file */ +{ + send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ +#ifdef DEBUG + s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; + s->compressed_len += (stored_len + 4) << 3; +#endif + copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ +} + +/* =========================================================================== + * Send one empty static block to give enough lookahead for inflate. + * This takes 10 bits, of which 7 may remain in the bit buffer. + * The current inflate code requires 9 bits of lookahead. If the + * last two codes for the previous block (real code plus EOB) were coded + * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode + * the last real code. In this case we send two empty static blocks instead + * of one. (There are no problems if the previous block is stored or fixed.) + * To simplify the code, we assume the worst case of last real code encoded + * on one bit only. + */ +void _tr_align(s) + deflate_state *s; +{ + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif + bi_flush(s); + /* Of the 10 bits for the empty block, we have already sent + * (10 - bi_valid) bits. The lookahead for the last real code (before + * the EOB of the previous block) was thus at least one plus the length + * of the EOB plus what we have just sent of the empty static block. + */ + if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; +#endif + bi_flush(s); + } + s->last_eob_len = 7; +} + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. + */ +void _tr_flush_block(s, buf, stored_len, eof) + deflate_state *s; + charf *buf; /* input block, or NULL if too old */ + ulg stored_len; /* length of input block */ + int eof; /* true if this is the last block for a file */ +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex = 0; /* index of last bit length code of non zero freq */ + + /* Build the Huffman trees unless a stored block is forced */ + if (s->level > 0) { + + /* Check if the file is ascii or binary */ + if (s->strm->data_type == Z_UNKNOWN) set_data_type(s); + + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); + + /* Determine the best encoding. Compute the block lengths in bytes. */ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; + + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + + } else { + Assert(buf != (char*)0, "lost buf"); + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + +#ifdef FORCE_STORED + if (buf != (char*)0) { /* force stored block */ +#else + if (stored_len+4 <= opt_lenb && buf != (char*)0) { + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + _tr_stored_block(s, buf, stored_len, eof); + +#ifdef FORCE_STATIC + } else if (static_lenb >= 0) { /* force static trees */ +#else + } else if (static_lenb == opt_lenb) { +#endif + send_bits(s, (STATIC_TREES<<1)+eof, 3); + compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->static_len; +#endif + } else { + send_bits(s, (DYN_TREES<<1)+eof, 3); + send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, + max_blindex+1); + compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->opt_len; +#endif + } + Assert (s->compressed_len == s->bits_sent, "bad compressed size"); + /* The above check is made mod 2^32, for files larger than 512 MB + * and uLong implemented on 32 bits. + */ + init_block(s); + + if (eof) { + bi_windup(s); +#ifdef DEBUG + s->compressed_len += 7; /* align on byte boundary */ +#endif + } + Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, + s->compressed_len-7*eof)); +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int _tr_tally (s, dist, lc) + deflate_state *s; + unsigned dist; /* distance of matched string */ + unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + s->d_buf[s->last_lit] = (ush)dist; + s->l_buf[s->last_lit++] = (uch)lc; + if (dist == 0) { + /* lc is the unmatched char */ + s->dyn_ltree[lc].Freq++; + } else { + s->matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush)dist < (ush)MAX_DIST(s) && + (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); + + s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_dtree[d_code(dist)].Freq++; + } + +#ifdef TRUNCATE_BLOCK + /* Try to guess if it is profitable to stop the current block here */ + if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { + /* Compute an upper bound for the compressed length */ + ulg out_length = (ulg)s->last_lit*8L; + ulg in_length = (ulg)((long)s->strstart - s->block_start); + int dcode; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += (ulg)s->dyn_dtree[dcode].Freq * + (5L+extra_dbits[dcode]); + } + out_length >>= 3; + Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", + s->last_lit, in_length, out_length, + 100L - out_length*100L/in_length)); + if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; + } +#endif + return (s->last_lit == s->lit_bufsize-1); + /* We avoid equality with lit_bufsize because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(s, ltree, dtree) + deflate_state *s; + ct_data *ltree; /* literal tree */ + ct_data *dtree; /* distance tree */ +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->last_lit != 0) do { + dist = s->d_buf[lx]; + lc = s->l_buf[lx++]; + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ + Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, + "pendingBuf overflow"); + + } while (lx < s->last_lit); + + send_code(s, END_BLOCK, ltree); + s->last_eob_len = ltree[END_BLOCK].Len; +} + +/* =========================================================================== + * Set the data type to ASCII or BINARY, using a crude approximation: + * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. + * IN assertion: the fields freq of dyn_ltree are set and the total of all + * frequencies does not exceed 64K (to fit in an int on 16 bit machines). + */ +local void set_data_type(s) + deflate_state *s; +{ + int n = 0; + unsigned ascii_freq = 0; + unsigned bin_freq = 0; + while (n < 7) bin_freq += s->dyn_ltree[n++].Freq; + while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq; + while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq; + s->strm->data_type = bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII; +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +local unsigned bi_reverse(code, len) + unsigned code; /* the value to invert */ + int len; /* its bit length */ +{ + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(s) + deflate_state *s; +{ + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(s) + deflate_state *s; +{ + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef DEBUG + s->bits_sent = (s->bits_sent+7) & ~7; +#endif +} + +/* =========================================================================== + * Copy a stored block, storing first the length and its + * one's complement if requested. + */ +local void copy_block(s, buf, len, header) + deflate_state *s; + charf *buf; /* the input data */ + unsigned len; /* its length */ + int header; /* true if block header must be written */ +{ + bi_windup(s); /* align on byte boundary */ + s->last_eob_len = 8; /* enough lookahead for inflate */ + + if (header) { + put_short(s, (ush)len); + put_short(s, (ush)~len); +#ifdef DEBUG + s->bits_sent += 2*16; +#endif + } +#ifdef DEBUG + s->bits_sent += (ulg)len<<3; +#endif + while (len--) { + put_byte(s, *buf++); + } +} diff --git a/src/zlib/trees.h b/src/zlib/trees.h new file mode 100644 index 000000000..1ca868b84 --- /dev/null +++ b/src/zlib/trees.h @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/src/zlib/zconf.h b/src/zlib/zconf.h new file mode 100644 index 000000000..b849dbb63 --- /dev/null +++ b/src/zlib/zconf.h @@ -0,0 +1,326 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2004 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +# ifdef FAR +# undef FAR +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(deflateBound,"DEBND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(compressBound,"CMBND") +# pragma map(inflate_table,"INTABL") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/src/zlib/zlib.h b/src/zlib/zlib.h new file mode 100644 index 000000000..e067b127b --- /dev/null +++ b/src/zlib/zlib.h @@ -0,0 +1,1200 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.2, October 3rd, 2004 + + Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.2" +#define ZLIB_VERNUM 0x1220 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it get to the next deflate block boundary. When decoding the zlib + or gzip format, this will cause inflate() to return immediately after the + header and before the first block. When doing a raw inflate, inflate() will + go ahead and process the first block, and will return when it gets to the end + of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR. If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_stream FAR *strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/src/zlib/zutil.c b/src/zlib/zutil.c new file mode 100644 index 000000000..a94cdb80c --- /dev/null +++ b/src/zlib/zutil.c @@ -0,0 +1,319 @@ +/* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-2003 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" + +#ifndef NO_DUMMY_DECL +struct internal_state {int dummy;}; /* for buggy compilers */ +#endif + +#ifndef STDC +extern void exit OF((int)); +#endif + +const char * const z_errmsg[10] = { +"need dictionary", /* Z_NEED_DICT 2 */ +"stream end", /* Z_STREAM_END 1 */ +"", /* Z_OK 0 */ +"file error", /* Z_ERRNO (-1) */ +"stream error", /* Z_STREAM_ERROR (-2) */ +"data error", /* Z_DATA_ERROR (-3) */ +"insufficient memory", /* Z_MEM_ERROR (-4) */ +"buffer error", /* Z_BUF_ERROR (-5) */ +"incompatible version",/* Z_VERSION_ERROR (-6) */ +""}; + + +const char * ZEXPORT zlibVersion() +{ + return ZLIB_VERSION; +} + +uLong ZEXPORT zlibCompileFlags() +{ + uLong flags; + + flags = 0; + switch (sizeof(uInt)) { + case 2: break; + case 4: flags += 1; break; + case 8: flags += 2; break; + default: flags += 3; + } + switch (sizeof(uLong)) { + case 2: break; + case 4: flags += 1 << 2; break; + case 8: flags += 2 << 2; break; + default: flags += 3 << 2; + } + switch (sizeof(voidpf)) { + case 2: break; + case 4: flags += 1 << 4; break; + case 8: flags += 2 << 4; break; + default: flags += 3 << 4; + } + switch (sizeof(z_off_t)) { + case 2: break; + case 4: flags += 1 << 6; break; + case 8: flags += 2 << 6; break; + default: flags += 3 << 6; + } +#ifdef DEBUG + flags += 1 << 8; +#endif +#if defined(ASMV) || defined(ASMINF) + flags += 1 << 9; +#endif +#ifdef ZLIB_WINAPI + flags += 1 << 10; +#endif +#ifdef BUILDFIXED + flags += 1 << 12; +#endif +#ifdef DYNAMIC_CRC_TABLE + flags += 1 << 13; +#endif +#ifdef NO_GZCOMPRESS + flags += 1 << 16; +#endif +#ifdef NO_GZIP + flags += 1 << 17; +#endif +#ifdef PKZIP_BUG_WORKAROUND + flags += 1 << 20; +#endif +#ifdef FASTEST + flags += 1 << 21; +#endif +#ifdef STDC +# ifdef NO_vsnprintf + flags += 1 << 25; +# ifdef HAS_vsprintf_void + flags += 1 << 26; +# endif +# else +# ifdef HAS_vsnprintf_void + flags += 1 << 26; +# endif +# endif +#else + flags += 1 << 24; +# ifdef NO_snprintf + flags += 1 << 25; +# ifdef HAS_sprintf_void + flags += 1 << 26; +# endif +# else +# ifdef HAS_snprintf_void + flags += 1 << 26; +# endif +# endif +#endif + return flags; +} + +#ifdef DEBUG + +# ifndef verbose +# define verbose 0 +# endif +int z_verbose = verbose; + +void z_error (m) + char *m; +{ + fprintf(stderr, "%s\n", m); + exit(1); +} +#endif + +/* exported to allow conversion of error code to string for compress() and + * uncompress() + */ +const char * ZEXPORT zError(err) + int err; +{ + return ERR_MSG(err); +} + +#if defined(_WIN32_WCE) + /* does not exist on WCE */ + int errno = 0; +#endif + +#ifndef HAVE_MEMCPY + +void zmemcpy(dest, source, len) + Bytef* dest; + const Bytef* source; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); +} + +int zmemcmp(s1, s2, len) + const Bytef* s1; + const Bytef* s2; + uInt len; +{ + uInt j; + + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; +} + +void zmemzero(dest, len) + Bytef* dest; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); +} +#endif + + +#ifdef SYS16BIT + +#ifdef __TURBOC__ +/* Turbo C in 16-bit mode */ + +# define MY_ZCALLOC + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use zcfree(). + */ + +#define MAX_PTR 10 +/* 10*64K = 640K */ + +local int next_ptr = 0; + +typedef struct ptr_table_s { + voidpf org_ptr; + voidpf new_ptr; +} ptr_table; + +local ptr_table table[MAX_PTR]; +/* This table is used to remember the original form of pointers + * to large buffers (64K). Such pointers are normalized with a zero offset. + * Since MSDOS is not a preemptive multitasking OS, this table is not + * protected from concurrent access. This hack doesn't work anyway on + * a protected system like OS/2. Use Microsoft C instead. + */ + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + voidpf buf = opaque; /* just to make some compilers happy */ + ulg bsize = (ulg)items*size; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + int n; + if (*(ush*)&ptr != 0) { /* object < 64K */ + farfree(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + farfree(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + ptr = opaque; /* just to make some compilers happy */ + Assert(0, "zcfree: ptr not found"); +} + +#endif /* __TURBOC__ */ + + +#ifdef M_I86 +/* Microsoft C in 16-bit mode */ + +# define MY_ZCALLOC + +#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +# define _halloc halloc +# define _hfree hfree +#endif + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + return _halloc((long)items, size); +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + _hfree(ptr); +} + +#endif /* M_I86 */ + +#endif /* SYS16BIT */ + + +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +#ifndef STDC +extern voidp malloc OF((uInt size)); +extern voidp calloc OF((uInt items, uInt size)); +extern void free OF((voidpf ptr)); +#endif + +voidpf zcalloc (opaque, items, size) + voidpf opaque; + unsigned items; + unsigned size; +{ + if (opaque) items += size - size; /* make compiler happy */ + return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : + (voidpf)calloc(items, size); +} + +void zcfree (opaque, ptr) + voidpf opaque; + voidpf ptr; +{ + free(ptr); + if (opaque) return; /* make compiler happy */ +} + +#endif /* MY_ZCALLOC */ diff --git a/src/zlib/zutil.h b/src/zlib/zutil.h new file mode 100644 index 000000000..08f944034 --- /dev/null +++ b/src/zlib/zutil.h @@ -0,0 +1,263 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2003 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#define ZLIB_INTERNAL +#include "zlib.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#ifdef WIN32 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ +# define OS_CODE 0x0b +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0f +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS + /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 + /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# define vsnprintf _vsnprintf +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +#endif +#ifdef VMS +# define NO_vsnprintf +#endif + +#ifdef HAVE_STRERROR +# ifndef VMS + extern char *strerror OF((int)); +# endif +# define zstrerror(errnum) strerror(errnum) +#else +# define zstrerror(errnum) "" +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int z_verbose; + extern void z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); +void zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* ZUTIL_H */ -- cgit v1.2.3-70-g09d2 From 80692921f7ae8ec1ffad6aede7a36547662fb7e8 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 4 Apr 2005 15:08:47 +0000 Subject: some aesthetics changes ^^ git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1399 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/dll.h | 6 +++--- src/common/grfio.c | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/common/grfio.c') diff --git a/src/common/dll.h b/src/common/dll.h index ec6f8cbed..50854da4d 100644 --- a/src/common/dll.h +++ b/src/common/dll.h @@ -6,7 +6,7 @@ #include #define DLL_OPEN(x) LoadLibrary(x) - #define DLL_SYM(x,y,z) (FARPROC)x=GetProcAddress(y,z) + #define DLL_SYM(x,y,z) (FARPROC)(x) = GetProcAddress(y,z) #define DLL_CLOSE(x) FreeLibrary(x) #define DLL HINSTANCE @@ -14,9 +14,9 @@ #include #define DLL_OPEN(x) dlopen(x,RTLD_NOW) - #define DLL_SYM(x,y,z) x=(void *)dlsym(y,z) + #define DLL_SYM(x,y,z) (x) = (void *)dlsym(y,z) #define DLL_CLOSE(x) dlclose(x) - #define DLL void* + #define DLL void * #endif diff --git a/src/common/grfio.c b/src/common/grfio.c index ed01cf82e..1a3829bf7 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -25,11 +25,11 @@ #include #include -#include "utils.h" #include "grfio.h" -#include "mmo.h" -#include "showmsg.h" -#include "malloc.h" +#include "../common/utils.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/malloc.h" #ifdef _WIN32 #ifdef LOCALZLIB @@ -41,9 +41,9 @@ #define zlib_deflate deflate #define zlib_deflateEnd deflateEnd #else - #include #include "../lib/zlib_win32.h" - HINSTANCE zlib_dll; + #include "../common/dll.h" + DLL zlib_dll; #define zlib_inflateInit(strm) zlib_inflateInit_((strm),ZLIB_VERSION, sizeof(z_stream)) #define zlib_deflateInit(strm, level) zlib_deflateInit_((strm),(level),ZLIB_VERSION,sizeof(z_stream)) @@ -984,7 +984,7 @@ void grfio_final(void) #ifdef _WIN32 #ifndef LOCALZLIB - FreeLibrary(zlib_dll); + DLL_CLOSE(zlib_dll); zlib_inflateInit_ = NULL; zlib_inflate = NULL; zlib_inflateEnd = NULL; @@ -1006,13 +1006,13 @@ void grfio_init(char *fname) #ifdef _WIN32 #ifndef LOCALZLIB if(!zlib_dll) { - zlib_dll = LoadLibrary("zlib.dll"); - (FARPROC)zlib_inflateInit_ = GetProcAddress(zlib_dll,"inflateInit_"); - (FARPROC)zlib_inflate = GetProcAddress(zlib_dll,"inflate"); - (FARPROC)zlib_inflateEnd = GetProcAddress(zlib_dll,"inflateEnd"); - (FARPROC)zlib_deflateInit_ = GetProcAddress(zlib_dll,"deflateInit_"); - (FARPROC)zlib_deflate = GetProcAddress(zlib_dll,"deflate"); - (FARPROC)zlib_deflateEnd = GetProcAddress(zlib_dll,"deflateEnd"); + zlib_dll = DLL_OPEN ("zlib.dll"); + DLL_SYM (zlib_inflateInit_, zlib_dll, "inflateInit_"); + DLL_SYM (zlib_inflate, zlib_dll, "inflate"); + DLL_SYM (zlib_inflateEnd, zlib_dll, "inflateEnd"); + DLL_SYM (zlib_deflateInit_, zlib_dll, "deflateInit_"); + DLL_SYM (zlib_deflate, zlib_dll, "deflate"); + DLL_SYM (zlib_deflateEnd, zlib_dll, "deflateEnd"); if(zlib_dll == NULL) { MessageBox(NULL,"Can't load zlib.dll","grfio.c",MB_OK); exit(1); -- cgit v1.2.3-70-g09d2