diff options
Diffstat (limited to 'src')
88 files changed, 10873 insertions, 3252 deletions
diff --git a/src/char/HPMchar.c b/src/char/HPMchar.c index c34866e53..e0f81c61f 100644 --- a/src/char/HPMchar.c +++ b/src/char/HPMchar.c @@ -47,10 +47,13 @@ #include "common/db.h" #include "common/des.h" #include "common/ers.h" +#include "common/md5calc.h" #include "common/memmgr.h" +#include "common/mutex.h" #include "common/mapindex.h" #include "common/mmo.h" #include "common/nullpo.h" +#include "common/random.h" #include "common/showmsg.h" #include "common/socket.h" #include "common/spinlock.h" diff --git a/src/char/char.c b/src/char/char.c index cf2f7d87c..9275678e6 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -474,9 +474,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) if( p->show_equip ) opt |= OPT_SHOW_EQUIP; - if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%u', `job_level`='%u'," + if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d'," "`base_exp`='%u', `job_exp`='%u', `zeny`='%d'," - "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%u',`skill_point`='%u'," + "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d'," "`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d'," "`option`='%u',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',`elemental_id`='%d'," "`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," @@ -958,8 +958,8 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_INT, &p.base_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_INT, &p.job_level, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL) @@ -973,8 +973,8 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p.status_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_INT, &p.skill_point, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL) @@ -1068,8 +1068,8 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_INT, &p->base_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_INT, &p->job_level, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL) @@ -1083,8 +1083,8 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_INT, &p->status_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_INT, &p->skill_point, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL) @@ -4222,7 +4222,7 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) {// CH: <0829>.W <char id>.L <birth date:YYMMDD>.6B char birthdate[8+1]; int char_id, i; - unsigned int base_level; + int base_level; char* data; time_t delete_date; @@ -4256,7 +4256,7 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) return; } - SQL->GetData(inter->sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10); + SQL->GetData(inter->sql_handle, 0, &data, NULL); base_level = atoi(data); SQL->GetData(inter->sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10); if( !delete_date || delete_date>time(NULL) ) @@ -4271,8 +4271,8 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) return; } - if( ( char_del_level > 0 && base_level >= (unsigned int)char_del_level ) || ( char_del_level < 0 && base_level <= (unsigned int)(-char_del_level) ) ) - {// character level config restriction + if ((char_del_level > 0 && base_level >= char_del_level) || (char_del_level < 0 && base_level <= -char_del_level)) { + // character level config restriction chr->delete2_accept_ack(fd, char_id, 2); // 2: Due to system settings can not be deleted return; } @@ -5758,11 +5758,25 @@ static CMDLINEARG(netconfig) chr->NET_CONF_NAME = aStrdup(params); return true; } + +/** + * --run-once handler + * + * Causes the server to run its loop once, and shutdown. Useful for testing. + * @see cmdline->exec + */ +static CMDLINEARG(runonce) +{ + core->runflag = CORE_ST_STOP; + return true; +} + /** * Initializes the command line arguments handlers. */ void cmdline_args_init_local(void) { + CMDLINEARG_DEF2(run-once, runonce, "Closes server after loading (testing).", CMDLINE_OPT_NORMAL); CMDLINEARG_DEF2(char-config, charconfig, "Alternative char-server configuration.", CMDLINE_OPT_PARAM); CMDLINEARG_DEF2(inter-config, interconfig, "Alternative inter-server configuration.", CMDLINE_OPT_PARAM); CMDLINEARG_DEF2(net-config, netconfig, "Alternative network configuration.", CMDLINE_OPT_PARAM); @@ -5801,11 +5815,13 @@ int do_init(int argc, char **argv) { sockt->net_config_read(chr->NET_CONF_NAME); chr->sql_config_read(chr->SQL_CONF_NAME); +#ifndef BUILDBOT if (strcmp(chr->userid, "s1")==0 && strcmp(chr->passwd, "p1")==0) { ShowWarning("Using the default user/password s1/p1 is NOT RECOMMENDED.\n"); ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n"); ShowNotice("And then change the user/password to use in conf/char-server.conf (or conf/import/char_conf.txt)\n"); } +#endif inter->init_sql(chr->INTER_CONF_NAME); // inter server configuration diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 21f38d049..d2507a2f9 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -146,22 +146,17 @@ int inter_guild_tosql(struct guild *g,int flag) *t_info = '\0'; // Insert a new guild the guild - if (flag&GS_BASIC && g->guild_id == -1) - { + if (flag&GS_BASIC && g->guild_id == -1) { strcat(t_info, " guild_create"); // Create a new guild - if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` " - "(`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) " - "VALUES ('%s', '%s', '%d', '%d', '%d', '%d')", - guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) ) - { + if (SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` " + "(`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) " + "VALUES ('%s', '%s', '%d', '%d', '%d', '%d')", + guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id)) { Sql_ShowDebug(inter->sql_handle); - if (g->guild_id == -1) - return 0; //Failed to create guild! - } - else - { + return 0; //Failed to create guild! + } else { g->guild_id = (int)SQL->LastInsertId(inter->sql_handle); new_guild = 1; } diff --git a/src/char/inter.c b/src/char/inter.c index d277abec9..756ae32c7 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -474,7 +474,7 @@ void mapif_parse_accinfo(int fd) inter->msg_to_fd(fd, u_fd, aid, "Your query returned the following %d results, please be more specific...",(int)SQL->NumRows(inter->sql_handle)); while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) { int class_; - short base_level, job_level, online; + int base_level, job_level, online; char name[NAME_LENGTH]; SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data); @@ -546,7 +546,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) { char *data; int char_id, class_; - short char_num, base_level, job_level, online; + int char_num, base_level, job_level, online; char name[NAME_LENGTH]; SQL->GetData(inter->sql_handle, 0, &data, NULL); char_id = atoi(data); diff --git a/src/common/HPM.c b/src/common/HPM.c index 02b675704..8e0bbe992 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -389,12 +389,12 @@ bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, CmdlineExecF ARR_FIND(0, VECTOR_LENGTH(cmdline->args_data), i, strcmp(VECTOR_INDEX(cmdline->args_data, i).name, name) == 0); - if (i != VECTOR_LENGTH(cmdline->args_data)) { - ShowError("HPM:add_arg:%s duplicate! (from %s)\n",name,HPM->pid2name(pluginID)); - return false; - } + if (i != VECTOR_LENGTH(cmdline->args_data)) { + ShowError("HPM:add_arg:%s duplicate! (from %s)\n",name,HPM->pid2name(pluginID)); + return false; + } - return cmdline->arg_add(pluginID, name, '\0', func, help, has_param ? CMDLINE_OPT_PARAM : CMDLINE_OPT_NORMAL); + return cmdline->arg_add(pluginID, name, '\0', func, help, has_param ? CMDLINE_OPT_PARAM : CMDLINE_OPT_NORMAL); } /** diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index 3d25d7330..d0e23811c 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + #ifndef HPM_DATA_CHECK_H #define HPM_DATA_CHECK_H @@ -148,7 +150,8 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #define COMMON_DB_H #endif // COMMON_DB_H #ifdef COMMON_DES_H - { "BIT64", sizeof(struct BIT64), SERVER_TYPE_ALL }, + { "des_bit64", sizeof(struct des_bit64), SERVER_TYPE_ALL }, + { "des_interface", sizeof(struct des_interface), SERVER_TYPE_ALL }, #else #define COMMON_DES_H #endif // COMMON_DES_H @@ -157,6 +160,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define COMMON_ERS_H #endif // COMMON_ERS_H + #ifdef COMMON_GRFIO_H + { "grfio_interface", sizeof(struct grfio_interface), SERVER_TYPE_MAP }, + #else + #define COMMON_GRFIO_H + #endif // COMMON_GRFIO_H #ifdef COMMON_HPMI_H { "HPMi_interface", sizeof(struct HPMi_interface), SERVER_TYPE_ALL }, { "hplugin_info", sizeof(struct hplugin_info), SERVER_TYPE_ALL }, @@ -169,6 +177,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define COMMON_MAPINDEX_H #endif // COMMON_MAPINDEX_H + #ifdef COMMON_MD5CALC_H + { "md5_interface", sizeof(struct md5_interface), SERVER_TYPE_ALL }, + #else + #define COMMON_MD5CALC_H + #endif // COMMON_MD5CALC_H #ifdef COMMON_MEMMGR_H { "malloc_interface", sizeof(struct malloc_interface), SERVER_TYPE_ALL }, #else @@ -208,11 +221,21 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define COMMON_MMO_H #endif // COMMON_MMO_H + #ifdef COMMON_MUTEX_H + { "mutex_interface", sizeof(struct mutex_interface), SERVER_TYPE_ALL }, + #else + #define COMMON_MUTEX_H + #endif // COMMON_MUTEX_H #ifdef COMMON_NULLPO_H { "nullpo_interface", sizeof(struct nullpo_interface), SERVER_TYPE_ALL }, #else #define COMMON_NULLPO_H #endif // COMMON_NULLPO_H + #ifdef COMMON_RANDOM_H + { "rnd_interface", sizeof(struct rnd_interface), SERVER_TYPE_ALL }, + #else + #define COMMON_RANDOM_H + #endif // COMMON_RANDOM_H #ifdef COMMON_SHOWMSG_H { "showmsg_interface", sizeof(struct showmsg_interface), SERVER_TYPE_ALL }, #else @@ -228,7 +251,7 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #define COMMON_SOCKET_H #endif // COMMON_SOCKET_H #ifdef COMMON_SPINLOCK_H - { "SPIN_LOCK", sizeof(struct SPIN_LOCK), SERVER_TYPE_ALL }, + { "spin_lock", sizeof(struct spin_lock), SERVER_TYPE_ALL }, #else #define COMMON_SPINLOCK_H #endif // COMMON_SPINLOCK_H @@ -251,6 +274,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define COMMON_SYSINFO_H #endif // COMMON_SYSINFO_H + #ifdef COMMON_THREAD_H + { "thread_interface", sizeof(struct thread_interface), SERVER_TYPE_ALL }, + #else + #define COMMON_THREAD_H + #endif // COMMON_THREAD_H #ifdef COMMON_TIMER_H { "TimerData", sizeof(struct TimerData), SERVER_TYPE_ALL }, { "timer_interface", sizeof(struct timer_interface), SERVER_TYPE_ALL }, @@ -648,6 +676,7 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { { "casecheck_data", sizeof(struct casecheck_data), SERVER_TYPE_MAP }, { "reg_db", sizeof(struct reg_db), SERVER_TYPE_MAP }, { "script_array", sizeof(struct script_array), SERVER_TYPE_MAP }, + { "script_buf", sizeof(struct script_buf), SERVER_TYPE_MAP }, { "script_code", sizeof(struct script_code), SERVER_TYPE_MAP }, { "script_data", sizeof(struct script_data), SERVER_TYPE_MAP }, { "script_function", sizeof(struct script_function), SERVER_TYPE_MAP }, @@ -662,6 +691,7 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { { "script_syntax_data", sizeof(struct script_syntax_data), SERVER_TYPE_MAP }, { "str_data_struct", sizeof(struct str_data_struct), SERVER_TYPE_MAP }, { "string_translation", sizeof(struct string_translation), SERVER_TYPE_MAP }, + { "string_translation_entry", sizeof(struct string_translation_entry), SERVER_TYPE_MAP }, #else #define MAP_SCRIPT_H #endif // MAP_SCRIPT_H diff --git a/src/common/HPMSymbols.inc.h b/src/common/HPMSymbols.inc.h index a6bf1622b..7ccb960de 100644 --- a/src/common/HPMSymbols.inc.h +++ b/src/common/HPMSymbols.inc.h @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + #if !defined(HERCULES_CORE) #ifdef COMMON_UTILS_H /* HCache */ struct HCache_interface *HCache; @@ -66,6 +68,9 @@ struct core_interface *core; #ifdef COMMON_DB_H /* DB */ struct db_interface *DB; #endif // COMMON_DB_H +#ifdef COMMON_DES_H /* des */ +struct des_interface *des; +#endif // COMMON_DES_H #ifdef MAP_DUEL_H /* duel */ struct duel_interface *duel; #endif // MAP_DUEL_H @@ -75,6 +80,9 @@ struct elemental_interface *elemental; #ifdef CHAR_GEOIP_H /* geoip */ struct geoip_interface *geoip; #endif // CHAR_GEOIP_H +#ifdef COMMON_GRFIO_H /* grfio */ +struct grfio_interface *grfio; +#endif // COMMON_GRFIO_H #ifdef MAP_GUILD_H /* guild */ struct guild_interface *guild; #endif // MAP_GUILD_H @@ -165,12 +173,18 @@ struct mapit_interface *mapit; #ifdef MAP_MAPREG_H /* mapreg */ struct mapreg_interface *mapreg; #endif // MAP_MAPREG_H +#ifdef COMMON_MD5CALC_H /* md5 */ +struct md5_interface *md5; +#endif // COMMON_MD5CALC_H #ifdef MAP_MERCENARY_H /* mercenary */ struct mercenary_interface *mercenary; #endif // MAP_MERCENARY_H #ifdef MAP_MOB_H /* mob */ struct mob_interface *mob; #endif // MAP_MOB_H +#ifdef COMMON_MUTEX_H /* mutex */ +struct mutex_interface *mutex; +#endif // COMMON_MUTEX_H #ifdef MAP_NPC_H /* npc_chat */ struct npc_chat_interface *npc_chat; #endif // MAP_NPC_H @@ -204,6 +218,9 @@ struct pincode_interface *pincode; #ifdef MAP_QUEST_H /* quest */ struct quest_interface *quest; #endif // MAP_QUEST_H +#ifdef COMMON_RANDOM_H /* rnd */ +struct rnd_interface *rnd; +#endif // COMMON_RANDOM_H #ifdef MAP_SCRIPT_H /* script */ struct script_interface *script; #endif // MAP_SCRIPT_H @@ -240,6 +257,9 @@ struct sv_interface *sv; #ifdef COMMON_SYSINFO_H /* sysinfo */ struct sysinfo_interface *sysinfo; #endif // COMMON_SYSINFO_H +#ifdef COMMON_THREAD_H /* thread */ +struct thread_interface *thread; +#endif // COMMON_THREAD_H #ifdef COMMON_TIMER_H /* timer */ struct timer_interface *timer; #endif // COMMON_TIMER_H @@ -298,6 +318,9 @@ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("core", core)) return "core"; #ifdef COMMON_DB_H /* DB */ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("DB", DB)) return "DB"; #endif // COMMON_DB_H +#ifdef COMMON_DES_H /* des */ +if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("des", des)) return "des"; +#endif // COMMON_DES_H #ifdef MAP_DUEL_H /* duel */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("duel", duel)) return "duel"; #endif // MAP_DUEL_H @@ -307,6 +330,9 @@ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("elemental", elemental)) retu #ifdef CHAR_GEOIP_H /* geoip */ if ((server_type&(SERVER_TYPE_CHAR)) && !HPM_SYMBOL("geoip", geoip)) return "geoip"; #endif // CHAR_GEOIP_H +#ifdef COMMON_GRFIO_H /* grfio */ +if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("grfio", grfio)) return "grfio"; +#endif // COMMON_GRFIO_H #ifdef MAP_GUILD_H /* guild */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("guild", guild)) return "guild"; #endif // MAP_GUILD_H @@ -397,12 +423,18 @@ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mapit", mapit)) return "mapi #ifdef MAP_MAPREG_H /* mapreg */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mapreg", mapreg)) return "mapreg"; #endif // MAP_MAPREG_H +#ifdef COMMON_MD5CALC_H /* md5 */ +if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("md5", md5)) return "md5"; +#endif // COMMON_MD5CALC_H #ifdef MAP_MERCENARY_H /* mercenary */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mercenary", mercenary)) return "mercenary"; #endif // MAP_MERCENARY_H #ifdef MAP_MOB_H /* mob */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mob", mob)) return "mob"; #endif // MAP_MOB_H +#ifdef COMMON_MUTEX_H /* mutex */ +if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("mutex", mutex)) return "mutex"; +#endif // COMMON_MUTEX_H #ifdef MAP_NPC_H /* npc_chat */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("npc_chat", npc_chat)) return "npc_chat"; #endif // MAP_NPC_H @@ -436,6 +468,9 @@ if ((server_type&(SERVER_TYPE_CHAR)) && !HPM_SYMBOL("pincode", pincode)) return #ifdef MAP_QUEST_H /* quest */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("quest", quest)) return "quest"; #endif // MAP_QUEST_H +#ifdef COMMON_RANDOM_H /* rnd */ +if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("rnd", rnd)) return "rnd"; +#endif // COMMON_RANDOM_H #ifdef MAP_SCRIPT_H /* script */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("script", script)) return "script"; #endif // MAP_SCRIPT_H @@ -472,6 +507,9 @@ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("sv", sv)) return "sv"; #ifdef COMMON_SYSINFO_H /* sysinfo */ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("sysinfo", sysinfo)) return "sysinfo"; #endif // COMMON_SYSINFO_H +#ifdef COMMON_THREAD_H /* thread */ +if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("thread", thread)) return "thread"; +#endif // COMMON_THREAD_H #ifdef COMMON_TIMER_H /* timer */ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("timer", timer)) return "timer"; #endif // COMMON_TIMER_H diff --git a/src/common/console.c b/src/common/console.c index 0be33e5c3..f1b4523e2 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -57,6 +57,7 @@ struct console_interface console_s; struct console_interface *console; #ifdef CONSOLE_INPUT struct console_input_interface console_input_s; +struct spin_lock console_ptlock_s; struct { char queue[CONSOLE_PARSE_SIZE][MAX_CONSOLE_INPUT]; @@ -464,45 +465,45 @@ void *cThread_main(void *x) { console->input->parse(input); if( input[0] != '\0' ) {/* did we get something? */ - EnterSpinLock(&console->input->ptlock); + EnterSpinLock(console->input->ptlock); if( cinput.count == CONSOLE_PARSE_SIZE ) { - LeaveSpinLock(&console->input->ptlock); + LeaveSpinLock(console->input->ptlock); continue;/* drop */ } safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT); - LeaveSpinLock(&console->input->ptlock); + LeaveSpinLock(console->input->ptlock); } } - ramutex_lock( console->input->ptmutex ); - racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); - ramutex_unlock( console->input->ptmutex ); + mutex->lock(console->input->ptmutex); + mutex->cond_wait(console->input->ptcond, console->input->ptmutex, -1); + mutex->unlock(console->input->ptmutex); } return NULL; } int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; - EnterSpinLock(&console->input->ptlock); + EnterSpinLock(console->input->ptlock); for(i = 0; i < cinput.count; i++) { console->input->parse_sub(cinput.queue[i]); } cinput.count = 0; - LeaveSpinLock(&console->input->ptlock); - racond_signal(console->input->ptcond); + LeaveSpinLock(console->input->ptlock); + mutex->cond_signal(console->input->ptcond); return 0; } void console_parse_final(void) { if( console->input->ptstate ) { InterlockedDecrement(&console->input->ptstate); - racond_signal(console->input->ptcond); + mutex->cond_signal(console->input->ptcond); /* wait for thread to close */ - rathread_wait(console->input->pthread, NULL); + thread->wait(console->input->pthread, NULL); - racond_destroy(console->input->ptcond); - ramutex_destroy(console->input->ptmutex); + mutex->cond_destroy(console->input->ptcond); + mutex->destroy(console->input->ptmutex); } } void console_parse_init(void) { @@ -510,12 +511,12 @@ void console_parse_init(void) { console->input->ptstate = 1; - InitializeSpinLock(&console->input->ptlock); + InitializeSpinLock(console->input->ptlock); - console->input->ptmutex = ramutex_create(); - console->input->ptcond = racond_create(); + console->input->ptmutex = mutex->create(); + console->input->ptcond = mutex->cond_create(); - if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){ + if( (console->input->pthread = thread->create(console->input->pthread_main, NULL)) == NULL ){ ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n"); exit(EXIT_FAILURE); } @@ -563,6 +564,7 @@ void console_defaults(void) console->display_gplnotice = display_gplnotice; #ifdef CONSOLE_INPUT console->input = &console_input_s; + console->input->ptlock = &console_ptlock_s; console->input->parse_init = console_parse_init; console->input->parse_final = console_parse_final; console->input->parse_timer = console_parse_timer; diff --git a/src/common/console.h b/src/common/console.h index 57c750a7d..dd3a9cf2e 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -22,12 +22,14 @@ #include "common/hercules.h" #include "common/db.h" -#include "common/mutex.h" #include "common/spinlock.h" -#include "common/thread.h" /* Forward Declarations */ struct Sql; // common/sql.h +struct cond_data; +struct mutex_data; +struct spin_lock; +struct thread_handle; /** * Queue Max @@ -71,11 +73,11 @@ struct CParseEntry { struct console_input_interface { #ifdef CONSOLE_INPUT /* vars */ - SPIN_LOCK ptlock;/* parse thread lock */ - rAthread *pthread;/* parse thread */ - volatile int32 ptstate;/* parse thread state */ - ramutex *ptmutex;/* parse thread mutex */ - racond *ptcond;/* parse thread cond */ + struct spin_lock *ptlock; ///< parse thread lock. + struct thread_handle *pthread; ///< parse thread. + volatile int32 ptstate; ///< parse thread state. + struct mutex_data *ptmutex; ///< parse thread mutex. + struct cond_data *ptcond; ///< parse thread conditional variable. /* */ VECTOR_DECL(struct CParseEntry *) command_list; VECTOR_DECL(struct CParseEntry *) commands; diff --git a/src/common/core.c b/src/common/core.c index ccd80c44b..63123dfea 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -26,23 +26,27 @@ #include "common/cbasetypes.h" #include "common/console.h" #include "common/db.h" +#include "common/des.h" +#include "common/grfio.h" #include "common/memmgr.h" #include "common/mmo.h" -#include "common/random.h" +#include "common/nullpo.h" #include "common/showmsg.h" #include "common/strlib.h" #include "common/sysinfo.h" -#include "common/nullpo.h" +#include "common/timer.h" +#include "common/utils.h" #ifndef MINICORE # include "common/HPM.h" # include "common/conf.h" # include "common/ers.h" +# include "common/md5calc.h" +# include "common/mutex.h" +# include "common/random.h" # include "common/socket.h" # include "common/sql.h" # include "common/thread.h" -# include "common/timer.h" -# include "common/utils.h" #endif #ifndef _WIN32 @@ -54,6 +58,28 @@ #include <stdio.h> #include <stdlib.h> +/* + * Uncomment the line below if you want to silence the root warning on startup + * (not recommended, as it opens the machine to security risks. You should + * never ever run software as root unless it requires the extra privileges + * (which Hercules does not.) + * More info: + * http://www.tldp.org/HOWTO/Security-HOWTO/local-security.html + * http://www.gentoo.org/doc/en/security/security-handbook.xml?style=printable&part=1&chap=1#doc_chap4 + * http://wiki.centos.org/TipsAndTricks/BecomingRoot + * http://fedoraproject.org/wiki/Configuring_Sudo + * https://help.ubuntu.com/community/RootSudo + * http://www.freebsdwiki.net/index.php/Root + * + * If your service provider forces (or encourages) you to run server software + * as root, please complain to them before and after uncommenting this line, + * since it is a very bad idea. + * Please note that NO SUPPORT will be given if you uncomment the following line. + */ +//#define I_AM_AWARE_OF_THE_RISK_AND_STILL_WANT_TO_RUN_HERCULES_AS_ROOT +// And don't complain to us if the XYZ plugin you installed wiped your hard disk, or worse. +// Note: This feature is deprecated, and should not be used. + /// Called when a terminate signal is received. void (*shutdown_callback)(void) = NULL; @@ -172,11 +198,51 @@ void signals_init (void) { /** * Warns the user if executed as superuser (root) + * + * @retval false if the check didn't pass and the program should be terminated. */ -void usercheck(void) { +bool usercheck(void) +{ +#ifndef _WIN32 if (sysinfo->is_superuser()) { - ShowWarning("You are running Hercules with root privileges, it is not necessary.\n"); + if (!isatty(fileno(stdin))) { +#ifdef BUILDBOT + return true; +#else // BUILDBOT + ShowFatalError("You are running Hercules with root privileges, it is not necessary, nor recommended. " + "Aborting.\n"); + return false; // Don't allow noninteractive execution regardless. +#endif // BUILDBOT + } + ShowError("You are running Hercules with root privileges, it is not necessary, nor recommended.\n"); +#ifdef I_AM_AWARE_OF_THE_RISK_AND_STILL_WANT_TO_RUN_HERCULES_AS_ROOT +#ifndef BUILDBOT +#warning This Hercules build is not eligible to obtain support by the developers. +#warning The setting I_AM_AWARE_OF_THE_RISK_AND_STILL_WANT_TO_RUN_HERCULES_AS_ROOT is deprecated and should not be used. +#endif // BUILDBOT +#else // not I_AM_AWARE_OF_THE_RISK_AND_STILL_WANT_TO_RUN_HERCULES_AS_ROOT + ShowNotice("Execution will be paused for 60 seconds. Press Ctrl-C if you wish to quit.\n"); + ShowNotice("If you want to get rid of this message, please open %s and uncomment, near the top, the line saying:\n" + "\t\"//#define I_AM_AWARE_OF_THE_RISK_AND_STILL_WANT_TO_RUN_HERCULES_AS_ROOT\"\n", __FILE__); + ShowNotice("Note: In a near future, this courtesy notice will go away. " + "Please update your infrastructure not to require root privileges before then.\n"); + ShowWarning("It's recommended that you " CL_WHITE "press CTRL-C now!" CL_RESET "\n"); + { + int i; + for (i = 0; i < 60; i++) { + ShowMessage("\a *"); + HSleep(1); + } + } + ShowMessage("\n"); + ShowNotice("Resuming operations with root privileges. " + CL_RED "If anything breaks, you get to keep the pieces, " + "and the Hercules developers won't be able to help you." + CL_RESET "\n"); +#endif // I_AM_AWARE_OF_THE_RISK_AND_STILL_WANT_TO_RUN_HERCULES_AS_ROOT } +#endif // not _WIN32 + return true; } void core_defaults(void) { @@ -191,12 +257,18 @@ void core_defaults(void) { malloc_defaults(); showmsg_defaults(); cmdline_defaults(); + des_defaults(); + grfio_defaults(); // Note: grfio is lazily loaded. grfio->init() and grfio->final() are not automatically called. #ifndef MINICORE + mutex_defaults(); libconfig_defaults(); sql_defaults(); timer_defaults(); db_defaults(); socket_defaults(); + rnd_defaults(); + md5_defaults(); + thread_defaults(); #endif } /** @@ -426,7 +498,8 @@ int main (int argc, char **argv) { if (!(showmsg->silent&0x1)) console->display_title(); - usercheck(); + if (!usercheck()) + return EXIT_FAILURE; #ifdef MINICORE // minimalist Core do_init(argc,argv); @@ -435,7 +508,7 @@ int main (int argc, char **argv) { set_server_type(); Sql_Init(); - rathread_init(); + thread->init(); DB->init(); signals_init(); @@ -446,8 +519,7 @@ int main (int argc, char **argv) { timer->init(); /* timer first */ - rnd_init(); - srand((unsigned int)timer->gettick()); + rnd->init(); console->init(); @@ -472,8 +544,9 @@ int main (int argc, char **argv) { timer->final(); sockt->final(); DB->final(); - rathread_final(); + thread->final(); ers_final(); + rnd->final(); #endif cmdline->final(); //sysinfo->final(); Called by iMalloc->final() diff --git a/src/common/db.h b/src/common/db.h index d7d111c86..1c0955221 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -1395,6 +1395,16 @@ HPShared struct db_interface *DB; } while(false) /** + * Removes all values from the vector. + * + * Does not free the allocated data. + */ +#define VECTOR_TRUNCATE(_vec) \ + do { \ + VECTOR_LENGTH(_vec) = 0; \ + } while (false) + +/** * Clears the vector, freeing allocated data. * * @param _vec Vector. diff --git a/src/common/des.c b/src/common/des.c index ce64309f3..c680610e9 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -24,23 +24,23 @@ #include "common/cbasetypes.h" -/// DES (Data Encryption Standard) algorithm, modified version. -/// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099. -/// @see http://en.wikipedia.org/wiki/Data_Encryption_Standard -/// @see http://en.wikipedia.org/wiki/DES_supplementary_material +/** @file + * Implementation of the des interface. + */ +struct des_interface des_s; +struct des_interface *des; /// Bitmask for accessing individual bits of a byte. static const uint8_t mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; - -/// Initial permutation (IP). -static void IP(BIT64* src) +/** + * Initial permutation (IP). + */ +static void des_IP(struct des_bit64 *src) { - BIT64 tmp = {{0}}; - static const uint8_t ip_table[64] = { 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, @@ -51,24 +51,23 @@ static void IP(BIT64* src) 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7, }; + struct des_bit64 tmp = {{0}}; + int i; - size_t i; - for( i = 0; i < ARRAYLENGTH(ip_table); ++i ) - { + for(i = 0; i < ARRAYLENGTH(ip_table); ++i) { uint8_t j = ip_table[i] - 1; - if( src->b[(j >> 3) & 7] & mask[j & 7] ) - tmp .b[(i >> 3) & 7] |= mask[i & 7]; + if (src->b[(j >> 3) & 7] & mask[j & 7]) + tmp.b[(i >> 3) & 7] |= mask[i & 7]; } *src = tmp; } - -/// Final permutation (IP^-1). -static void FP(BIT64* src) +/** + * Final permutation (IP^-1). + */ +static void des_FP(struct des_bit64 *src) { - BIT64 tmp = {{0}}; - static const uint8_t fp_table[64] = { 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, @@ -79,24 +78,26 @@ static void FP(BIT64* src) 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25, }; + struct des_bit64 tmp = {{0}}; + int i; - size_t i; - for( i = 0; i < ARRAYLENGTH(fp_table); ++i ) - { + for (i = 0; i < ARRAYLENGTH(fp_table); ++i) { uint8_t j = fp_table[i] - 1; - if( src->b[(j >> 3) & 7] & mask[j & 7] ) - tmp .b[(i >> 3) & 7] |= mask[i & 7]; + if (src->b[(j >> 3) & 7] & mask[j & 7]) + tmp.b[(i >> 3) & 7] |= mask[i & 7]; } *src = tmp; } - -/// Expansion (E). -/// Expands upper four 8-bits (32b) into eight 6-bits (48b). -static void E(BIT64* src) +/** + * Expansion (E). + * + * Expands upper four 8-bits (32b) into eight 6-bits (48b). + */ +static void des_E(struct des_bit64 *src) { - BIT64 tmp = {{0}}; + struct des_bit64 tmp = {{0}}; #if 0 // original @@ -110,13 +111,12 @@ static void E(BIT64* src) 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1, }; + int i; - size_t i; - for( i = 0; i < ARRAYLENGTH(expand_table); ++i ) - { + for (i = 0; i < ARRAYLENGTH(expand_table); ++i) { uint8_t j = expand_table[i] - 1; - if( src->b[j / 8 + 4] & mask[j % 8] ) - tmp .b[i / 6 + 0] |= mask[i % 6]; + if (src->b[j / 8 + 4] & mask[j % 8]) + tmp.b[i / 6 + 0] |= mask[i % 6]; } #endif // optimized @@ -132,12 +132,11 @@ static void E(BIT64* src) *src = tmp; } - -/// Transposition (P-BOX). -static void TP(BIT64* src) +/** + * Transposition (P-BOX). + */ +static void des_TP(struct des_bit64 *src) { - BIT64 tmp = {{0}}; - static const uint8_t tp_table[32] = { 16, 7, 20, 21, 29, 12, 28, 17, @@ -148,25 +147,27 @@ static void TP(BIT64* src) 19, 13, 30, 6, 22, 11, 4, 25, }; + struct des_bit64 tmp = {{0}}; + int i; - size_t i; - for( i = 0; i < ARRAYLENGTH(tp_table); ++i ) - { + for (i = 0; i < ARRAYLENGTH(tp_table); ++i) { uint8_t j = tp_table[i] - 1; - if( src->b[(j >> 3) + 0] & mask[j & 7] ) - tmp .b[(i >> 3) + 4] |= mask[i & 7]; + if (src->b[(j >> 3) + 0] & mask[j & 7]) + tmp.b[(i >> 3) + 4] |= mask[i & 7]; } *src = tmp; } -/// Substitution boxes (S-boxes). -/// NOTE: This implementation was optimized to process two nibbles in one step (twice as fast). -static void SBOX(BIT64* src) +/** + * Substitution boxes (S-boxes). + * + * This implementation was optimized to process two nibbles in one step (twice + * as fast). + */ +static void des_SBOX(struct des_bit64 *src) { - BIT64 tmp = {{0}}; - static const uint8_t s_table[4][64] = { { 0xef, 0x03, 0x41, 0xfd, 0xd8, 0x74, 0x1e, 0x47, 0x26, 0xef, 0xfb, 0x22, 0xb3, 0xd8, 0x84, 0x1e, @@ -190,10 +191,10 @@ static void SBOX(BIT64* src) 0xa0, 0x9f, 0xf6, 0x5c, 0x6a, 0x09, 0x8d, 0xf0, 0x0f, 0xe3, 0x53, 0x25, 0x95, 0x36, 0x28, 0xcb, } }; + struct des_bit64 tmp = {{0}}; + int i; - size_t i; - for( i = 0; i < ARRAYLENGTH(s_table); ++i ) - { + for (i = 0; i < ARRAYLENGTH(s_table); ++i) { tmp.b[i] = (s_table[i][src->b[i*2+0]] & 0xf0) | (s_table[i][src->b[i*2+1]] & 0x0f); } @@ -201,15 +202,17 @@ static void SBOX(BIT64* src) *src = tmp; } - -/// DES round function. -/// XORs src[0..3] with TP(SBOX(E(src[4..7]))). -static void RoundFunction(BIT64* src) +/** + * DES round function. + * + * XORs src[0..3] with TP(SBOX(E(src[4..7]))). + */ +static void des_RoundFunction(struct des_bit64 *src) { - BIT64 tmp = *src; - E(&tmp); - SBOX(&tmp); - TP(&tmp); + struct des_bit64 tmp = *src; + des_E(&tmp); + des_SBOX(&tmp); + des_TP(&tmp); src->b[0] ^= tmp.b[4]; src->b[1] ^= tmp.b[5]; @@ -217,20 +220,30 @@ static void RoundFunction(BIT64* src) src->b[3] ^= tmp.b[7]; } - -void des_decrypt_block(BIT64* block) +/// @copydoc des_interface::decrypt_block() +void des_decrypt_block(struct des_bit64 *block) { - IP(block); - RoundFunction(block); - FP(block); + des_IP(block); + des_RoundFunction(block); + des_FP(block); } - -void des_decrypt(unsigned char* data, size_t size) +/// @copydoc des_interface::decrypt() +void des_decrypt(unsigned char *data, size_t size) { - BIT64* p = (BIT64*)data; + struct des_bit64 *p = (struct des_bit64 *)data; size_t i; - for( i = 0; i*8 < size; i += 8 ) - des_decrypt_block(p); + for (i = 0; i*8 < size; i += 8) + des->decrypt_block(p); +} + +/** + * Interface base initialization. + */ +void des_defaults(void) +{ + des = &des_s; + des->decrypt = des_decrypt; + des->decrypt_block = des_decrypt_block; } diff --git a/src/common/des.h b/src/common/des.h index d62b5cc49..9924a044b 100644 --- a/src/common/des.h +++ b/src/common/des.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -21,14 +21,49 @@ #ifndef COMMON_DES_H #define COMMON_DES_H -#include "common/cbasetypes.h" +#include "common/hercules.h" + +/** + * @file + * + * DES (Data Encryption Standard) algorithm, modified version. + * + * @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099 + * @see http://en.wikipedia.org/wiki/Data_Encryption_Standard + * @see http://en.wikipedia.org/wiki/DES_supplementary_material + */ + +/* Struct definitions */ /// One 64-bit block. -typedef struct BIT64 { uint8_t b[8]; } BIT64; +struct des_bit64 { + uint8_t b[8]; +}; + +/* Interface */ + +/// The des interface. +struct des_interface { + /** + * Decrypts a block. + * + * @param[in,out] block The block to decrypt (in-place). + */ + void (*decrypt_block) (struct des_bit64 *block); + + /** + * Decrypts a buffer. + * + * @param [in,out] data The buffer to decrypt (in-place). + * @param [in] size The size of the data. + */ + void (*decrypt) (unsigned char *data, size_t size); +}; #ifdef HERCULES_CORE -void des_decrypt_block(BIT64* block); -void des_decrypt(unsigned char* data, size_t size); +void des_defaults(void); #endif // HERCULES_CORE +HPShared struct des_interface *des; ///< Pointer to the des interface implementation. + #endif // COMMON_DES_H diff --git a/src/common/grfio.c b/src/common/grfio.c index c6e47d357..0a9708f17 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -35,10 +35,12 @@ #include <sys/stat.h> #include <zlib.h> -//---------------------------- -// file entry table struct -//---------------------------- -typedef struct FILELIST { +/** @file + * Implementation of the GRF I/O interface. + */ + +/// File entry table struct. +struct grf_filelist { int srclen; ///< compressed size int srclen_aligned; int declen; ///< original size @@ -48,11 +50,13 @@ typedef struct FILELIST { char fn[128-4*5]; ///< file name char *fnd; ///< if the file was cloned, contains name of original file int8 gentry; ///< read grf file select -} FILELIST; +}; -#define FILELIST_TYPE_FILE 0x01 // entry is a file -#define FILELIST_TYPE_ENCRYPT_MIXED 0x02 // encryption mode 0 (header DES + periodic DES/shuffle) -#define FILELIST_TYPE_ENCRYPT_HEADER 0x04 // encryption mode 1 (header DES only) +enum grf_filelist_type { + FILELIST_TYPE_FILE = 0x01, ///< entry is a file + FILELIST_TYPE_ENCRYPT_MIXED = 0x02, ///< encryption mode 0 (header DES + periodic DES/shuffle) + FILELIST_TYPE_ENCRYPT_HEADER = 0x04, ///< encryption mode 1 (header DES only) +}; //gentry ... > 0 : data read from a grf file (gentry_table[gentry-1]) //gentry ... 0 : data read from a local file (data directory) @@ -64,7 +68,7 @@ typedef struct FILELIST { //#define GRFIO_LOCAL // stores info about every loaded file -FILELIST* filelist = NULL; +struct grf_filelist *filelist = NULL; int filelist_entrys = 0; int filelist_maxentry = 0; @@ -76,24 +80,30 @@ int gentry_maxentry = 0; // the path to the data directory char data_dir[1024] = ""; +struct grfio_interface grfio_s; +struct grfio_interface *grfio; + // little endian char array to uint conversion -static unsigned int getlong(unsigned char* p) +static unsigned int getlong(unsigned char *p) { return (p[0] << 0 | p[1] << 8 | p[2] << 16 | p[3] << 24); } -static void NibbleSwap(unsigned char* src, int len) +static void NibbleSwap(unsigned char *src, int len) { - while( len > 0 ) - { + while (len > 0) { *src = (*src >> 4) | (*src << 4); ++src; --len; } } -/// Substitutes some specific values for others, leaves rest intact. Obfuscation. -/// NOTE: Operation is symmetric (calling it twice gives back the original input). +/** + * (De)-obfuscates data. + * + * Substitutes some specific values for others, leaves rest intact. + * NOTE: Operation is symmetric (calling it twice gives back the original input). + */ static uint8_t grf_substitution(uint8_t in) { uint8_t out; @@ -121,9 +131,9 @@ static uint8_t grf_substitution(uint8_t in) } #if 0 /* this is not used anywhere, is it ok to delete? */ -static void grf_shuffle_enc(BIT64* src) +static void grf_shuffle_enc(struct des_bit64 *src) { - BIT64 out; + struct des_bit64 out; out.b[0] = src->b[3]; out.b[1] = src->b[4]; @@ -138,9 +148,9 @@ static void grf_shuffle_enc(BIT64* src) } #endif // 0 -static void grf_shuffle_dec(BIT64* src) +static void grf_shuffle_dec(struct des_bit64 *src) { - BIT64 out; + struct des_bit64 out; out.b[0] = src->b[3]; out.b[1] = src->b[4]; @@ -154,29 +164,42 @@ static void grf_shuffle_dec(BIT64* src) *src = out; } -static void grf_decode_header(unsigned char* buf, size_t len) +/** + * Decodes header-encrypted grf data. + * + * @param[in,out] buf Data to decode (in-place). + * @param[in] len Length of the data. + */ +static void grf_decode_header(unsigned char *buf, size_t len) { - BIT64* p = (BIT64*)buf; - size_t nblocks = len / sizeof(BIT64); + struct des_bit64 *p = (struct des_bit64 *)buf; + size_t nblocks = len / sizeof(struct des_bit64); size_t i; // first 20 blocks are all des-encrypted - for( i = 0; i < 20 && i < nblocks; ++i ) - des_decrypt_block(&p[i]); + for (i = 0; i < 20 && i < nblocks; ++i) + des->decrypt_block(&p[i]); // the rest is plaintext, done. } -static void grf_decode_full(unsigned char* buf, size_t len, int cycle) +/** + * Decodes fully encrypted grf data + * + * @param[in,out] buf Data to decode (in-place). + * @param[in] len Length of the data. + * @param[in] cycle The current decoding cycle. + */ +static void grf_decode_full(unsigned char *buf, size_t len, int cycle) { - BIT64* p = (BIT64*)buf; - size_t nblocks = len / sizeof(BIT64); + struct des_bit64 *p = (struct des_bit64 *)buf; + size_t nblocks = len / sizeof(struct des_bit64); int dcycle, scycle; size_t i, j; // first 20 blocks are all des-encrypted - for( i = 0; i < 20 && i < nblocks; ++i ) - des_decrypt_block(&p[i]); + for (i = 0; i < 20 && i < nblocks; ++i) + des->decrypt_block(&p[i]); // after that only one of every 'dcycle' blocks is des-encrypted dcycle = cycle; @@ -186,17 +209,16 @@ static void grf_decode_full(unsigned char* buf, size_t len, int cycle) // so decrypt/de-shuffle periodically j = (size_t)-1; // 0, adjusted to fit the ++j step - for( i = 20; i < nblocks; ++i ) - { - if( i % dcycle == 0 ) - {// decrypt block - des_decrypt_block(&p[i]); + for (i = 20; i < nblocks; ++i) { + if (i % dcycle == 0) { + // decrypt block + des->decrypt_block(&p[i]); continue; } ++j; - if( j % scycle == 0 && j != 0 ) - {// de-shuffle block + if (j % scycle == 0 && j != 0) { + // de-shuffle block grf_shuffle_dec(&p[i]); continue; } @@ -205,22 +227,25 @@ static void grf_decode_full(unsigned char* buf, size_t len, int cycle) } } -/// Decodes grf data. -/// @param buf data to decode (in-place) -/// @param len length of the data -/// @param entry_type flags associated with the data -/// @param entry_len true (unaligned) length of the data -static void grf_decode(unsigned char* buf, size_t len, char entry_type, int entry_len) +/** + * Decodes grf data. + * + * @param[in,out] buf Data to decode (in-place). + * @param[in] len Length of the data + * @param[in] entry_type Flags associated with the data. + * @param[in] entry_len True (unaligned) length of the data. + */ +static void grf_decode(unsigned char *buf, size_t len, char entry_type, int entry_len) { - if( entry_type & FILELIST_TYPE_ENCRYPT_MIXED ) - {// fully encrypted + if (entry_type & FILELIST_TYPE_ENCRYPT_MIXED) { + // fully encrypted int digits; int cycle; int i; // compute number of digits of the entry length digits = 1; - for( i = 10; i <= entry_len; i *= 10 ) + for (i = 10; i <= entry_len; i *= 10) ++digits; // choose size of gap between two encrypted blocks @@ -232,51 +257,47 @@ static void grf_decode(unsigned char* buf, size_t len, char entry_type, int entr : digits + 15; grf_decode_full(buf, len, cycle); - } - else - if( entry_type & FILELIST_TYPE_ENCRYPT_HEADER ) - {// header encrypted + } else if (entry_type & FILELIST_TYPE_ENCRYPT_HEADER) { + // header encrypted grf_decode_header(buf, len); } - else - {// plaintext - ; - } + /* else plaintext */ } -/****************************************************** - *** Zlib Subroutines *** - ******************************************************/ +/* Zlib Subroutines */ -/// zlib crc32 -unsigned long grfio_crc32(const unsigned char* buf, unsigned int len) +/// @copydoc grfio_interface::crc32() +unsigned long grfio_crc32(const unsigned char *buf, unsigned int len) { return crc32(crc32(0L, Z_NULL, 0), buf, len); } -/// zlib uncompress -int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen) +/// @copydoc grfio_interface::decode_zip +int grfio_decode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) { - return uncompress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen); + return uncompress(dest, dest_len, source, source_len); } -/// zlib compress -int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen) { - if( *destLen == 0 ) /* [Ind/Hercules] */ - *destLen = compressBound(sourceLen); - if( dest == NULL ) { /* [Ind/Hercules] */ - CREATE(dest, unsigned char, *destLen); +/// @copydoc grfio_interface::encode_zip +int grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) +{ + if (*dest_len == 0) /* [Ind/Hercules] */ + *dest_len = compressBound(source_len); + if (dest == NULL) { + /* [Ind/Hercules] */ + CREATE(dest, unsigned char, *dest_len); } - return compress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen); + return compress(dest, dest_len, source, source_len); } -/*********************************************************** - *** File List Subroutines *** - ***********************************************************/ -// file list hash table +/* File List Subroutines */ + +/// File list hash table int filelist_hash[256]; -// initializes the table that holds the first elements of all hash chains +/** + * Initializes the table that holds the first elements of all hash chains + */ static void hashinit(void) { int i; @@ -284,26 +305,37 @@ static void hashinit(void) filelist_hash[i] = -1; } -// hashes a filename string into a number from {0..255} -static int filehash(const char* fname) +/** + * Hashes a filename string into a number from {0..255} + * + * @param fname The filename to hash. + * @return The hash. + */ +static int grf_filehash(const char *fname) { - unsigned int hash = 0; - while(*fname) { + uint32 hash = 0; + while (*fname != '\0') { hash = (hash<<1) + (hash>>7)*9 + TOLOWER(*fname); fname++; } return hash & 255; } -// finds a FILELIST entry with the specified file name -static FILELIST* filelist_find(const char* fname) +/** + * Finds a grf_filelist entry with the specified file name + * + * @param fname The file to find. + * @return The file entry. + * @retval NULL if the file wasn't found. + */ +static struct grf_filelist *grfio_filelist_find(const char *fname) { int hash, index; - if (!filelist) + if (filelist == NULL) return NULL; - hash = filelist_hash[filehash(fname)]; + hash = filelist_hash[grf_filehash(fname)]; for (index = hash; index != -1; index = filelist[index].next) if(!strcmpi(filelist[index].fn, fname)) break; @@ -311,16 +343,23 @@ static FILELIST* filelist_find(const char* fname) return (index >= 0) ? &filelist[index] : NULL; } -// returns the original file name -char* grfio_find_file(const char* fname) +/// @copydoc grfio_interface::find_file() +const char *grfio_find_file(const char *fname) { - FILELIST *flist = filelist_find(fname); - if (!flist) return NULL; + struct grf_filelist *flist = grfio_filelist_find(fname); + if (flist == NULL) + return NULL; return (!flist->fnd ? flist->fn : flist->fnd); } -// adds a FILELIST entry into the list of loaded files -static FILELIST* filelist_add(FILELIST* entry) { +/** + * Adds a grf_filelist entry into the list of loaded files. + * + * @param entry The entry to add. + * @return A pointer to the added entry. + */ +static struct grf_filelist *grfio_filelist_add(struct grf_filelist *entry) +{ int hash; nullpo_ret(entry); #ifdef __clang_analyzer__ @@ -331,16 +370,16 @@ static FILELIST* filelist_add(FILELIST* entry) { #define FILELIST_ADDS 1024 // number increment of file lists ` if (filelist_entrys >= filelist_maxentry) { - filelist = (FILELIST *)aRealloc(filelist, (filelist_maxentry + FILELIST_ADDS) * sizeof(FILELIST)); - memset(filelist + filelist_maxentry, '\0', FILELIST_ADDS * sizeof(FILELIST)); + filelist = aRealloc(filelist, (filelist_maxentry + FILELIST_ADDS) * sizeof(struct grf_filelist)); + memset(filelist + filelist_maxentry, '\0', FILELIST_ADDS * sizeof(struct grf_filelist)); filelist_maxentry += FILELIST_ADDS; } #undef FILELIST_ADDS - memcpy(&filelist[filelist_entrys], entry, sizeof(FILELIST)); + memcpy(&filelist[filelist_entrys], entry, sizeof(struct grf_filelist)); - hash = filehash(entry->fn); + hash = grf_filehash(entry->fn); filelist[filelist_entrys].next = filelist_hash[hash]; filelist_hash[hash] = filelist_entrys; @@ -349,63 +388,69 @@ static FILELIST* filelist_add(FILELIST* entry) { return &filelist[filelist_entrys - 1]; } -// adds a new FILELIST entry or overwrites an existing one -static FILELIST* filelist_modify(FILELIST* entry) +/** + * Adds a new grf_filelist entry or overwrites an existing one. + * + * @param entry The entry to add. + * @return A pointer to the added entry. + */ +static struct grf_filelist *grfio_filelist_modify(struct grf_filelist *entry) { - FILELIST* fentry = filelist_find(entry->fn); + struct grf_filelist *fentry = grfio_filelist_find(entry->fn); if (fentry != NULL) { int tmp = fentry->next; - memcpy(fentry, entry, sizeof(FILELIST)); + memcpy(fentry, entry, sizeof(struct grf_filelist)); fentry->next = tmp; } else { - fentry = filelist_add(entry); + fentry = grfio_filelist_add(entry); } return fentry; } -// shrinks the file list array if too long -static void filelist_compact(void) +/// Shrinks the file list array if too long. +static void grfio_filelist_compact(void) { if (filelist == NULL) return; if (filelist_entrys < filelist_maxentry) { - filelist = (FILELIST *)aRealloc(filelist, filelist_entrys * sizeof(FILELIST)); + filelist = aRealloc(filelist, filelist_entrys * sizeof(struct grf_filelist)); filelist_maxentry = filelist_entrys; } } -/*********************************************************** - *** Grfio Subroutines *** - ***********************************************************/ +/* GRF I/O Subroutines */ -/// Combines are resource path with the data folder location to create local resource path. -static void grfio_localpath_create(char* buffer, size_t size, const char* filename) +/** + * Combines a resource path with the data folder location to create local + * resource path. + * + * @param[out] buffer The output buffer. + * @param[in] size The size of the output buffer. + * @param[in] filename Resource path. + */ +static void grfio_localpath_create(char *buffer, size_t size, const char *filename) { - unsigned int i; + int i; size_t len; len = strlen(data_dir); - if( data_dir[0] == '\0' || data_dir[len-1] == '/' || data_dir[len-1] == '\\' ) - { + if (data_dir[0] == '\0' || data_dir[len-1] == '/' || data_dir[len-1] == '\\') safesnprintf(buffer, size, "%s%s", data_dir, filename); - } else - { safesnprintf(buffer, size, "%s/%s", data_dir, filename); - } // normalize path - for( i = 0; buffer[i] != '\0'; ++i ) - if( buffer[i] == '\\' ) + for (i = 0; buffer[i] != '\0'; ++i) + if (buffer[i] == '\\') buffer[i] = '/'; } -/// Reads a file into a newly allocated buffer (from grf or data directory). +/// @copydoc grfio_interface::reads() void *grfio_reads(const char *fname, int *size) { - FILELIST* entry = filelist_find(fname); + struct grf_filelist *entry = grfio_filelist_find(fname); if (entry == NULL || entry->gentry <= 0) { // LocalFileCheck char lfname[256]; @@ -424,7 +469,7 @@ void *grfio_reads(const char *fname, int *size) return NULL; } fseek(in,0,SEEK_SET); - buf = (unsigned char *)aMalloc(declen+1); // +1 for resnametable zero-termination + buf = aMalloc(declen+1); // +1 for resnametable zero-termination buf[declen] = '\0'; if (fread(buf, 1, declen, in) != (size_t)declen) { ShowError("An error occurred in fread grfio_reads, fname=%s \n",fname); @@ -454,7 +499,7 @@ void *grfio_reads(const char *fname, int *size) if (in != NULL) { int fsize = entry->srclen_aligned; - unsigned char *buf = (unsigned char *)aMalloc(fsize); + unsigned char *buf = aMalloc(fsize); unsigned char *buf2 = NULL; if (fseek(in, entry->srcpos, SEEK_SET) != 0 || fread(buf, 1, fsize, in) != (size_t)fsize) { @@ -465,14 +510,14 @@ void *grfio_reads(const char *fname, int *size) } fclose(in); - buf2 = (unsigned char *)aMalloc(entry->declen+1); // +1 for resnametable zero-termination + buf2 = aMalloc(entry->declen+1); // +1 for resnametable zero-termination buf2[entry->declen] = '\0'; if (entry->type & FILELIST_TYPE_FILE) { // file uLongf len; grf_decode(buf, fsize, entry->type, entry->srclen); len = entry->declen; - decode_zip(buf2, &len, buf, entry->srclen); + grfio->decode_zip(buf2, &len, buf, entry->srclen); if (len != (uLong)entry->declen) { ShowError("decode_zip size mismatch err: %d != %d\n", (int)len, entry->declen); aFree(buf); @@ -498,35 +543,51 @@ void *grfio_reads(const char *fname, int *size) return NULL; } -/// Decodes encrypted filename from a version 01xx grf index. -static char* decode_filename(unsigned char* buf, int len) +/** + * Decodes encrypted filename from a version 01xx grf index. + * + * @param[in,out] buf The encrypted filename (decrypted in-place). + * @param[in] len The filename length. + * @return A pointer to the decrypted filename. + */ +static char *grfio_decode_filename(unsigned char *buf, int len) { - int lop; - for(lop=0;lop<len;lop+=8) { - NibbleSwap(&buf[lop],8); - des_decrypt(&buf[lop],8); + int i; + for (i = 0; i < len; i += 8) { + NibbleSwap(&buf[i],8); + des->decrypt(&buf[i],8); } return (char*)buf; } -/// Compares file extension against known large file types. -/// @return true if the file should undergo full mode 0 decryption, and true otherwise. -static bool isFullEncrypt(const char* fname) +/** + * Compares file extension against known large file types. + * + * @param fname The file name. + * @return true if the file should undergo full mode 0 decryption, and true otherwise. + */ +static bool grfio_is_full_encrypt(const char *fname) { - const char* ext = strrchr(fname, '.'); - if( ext != NULL ) { - static const char extensions[4][5] = { ".gnd", ".gat", ".act", ".str" }; - size_t i; - for( i = 0; i < ARRAYLENGTH(extensions); ++i ) - if( strcmpi(ext, extensions[i]) == 0 ) + const char *ext = strrchr(fname, '.'); + if (ext != NULL) { + static const char *extensions[] = { ".gnd", ".gat", ".act", ".str" }; + int i; + for (i = 0; i < ARRAYLENGTH(extensions); ++i) + if (strcmpi(ext, extensions[i]) == 0) return false; } return true; } -/// Loads all entries in the specified grf file into the filelist. -/// @param gentry index of the grf file name in the gentry_table +/** + * Loads all entries in the specified grf file into the filelist. + * + * @param grfname Name of the grf file. + * @param gentry Index of the grf file name in the gentry_table. + * @return Error code. + * @retval 0 in case of success. + */ static int grfio_entryread(const char *grfname, int gentry) { long grf_size; @@ -535,12 +596,11 @@ static int grfio_entryread(const char *grfname, int gentry) unsigned char *grf_filelist; FILE *fp = fopen(grfname, "rb"); - if( fp == NULL ) { - ShowWarning("GRF data file not found: '%s'\n",grfname); + if (fp == NULL) { + ShowWarning("GRF data file not found: '%s'\n", grfname); return 1; // 1:not found error - } else { - ShowInfo("GRF data file found: '%s'\n",grfname); } + ShowInfo("GRF data file found: '%s'\n", grfname); fseek(fp,0,SEEK_END); grf_size = ftell(fp); @@ -551,7 +611,7 @@ static int grfio_entryread(const char *grfname, int gentry) fclose(fp); return 2; // 2:file format error } - if (strcmp((const char*)grf_header,"Master of Magic") != 0 || fseek(fp,getlong(grf_header+0x1e),SEEK_CUR) != 0) { + if (strcmp((const char*)grf_header, "Master of Magic") != 0 || fseek(fp, getlong(grf_header+0x1e), SEEK_CUR) != 0) { fclose(fp); ShowError("GRF %s read error\n", grfname); return 2; // 2:file format error @@ -561,9 +621,8 @@ static int grfio_entryread(const char *grfname, int gentry) if (grf_version == 0x01) { // ****** Grf version 01xx ****** - long list_size; - list_size = grf_size - ftell(fp); - grf_filelist = (unsigned char *)aMalloc(list_size); + long list_size = grf_size - ftell(fp); + grf_filelist = aMalloc(list_size); if (fread(grf_filelist,1,list_size,fp) != (size_t)list_size) { ShowError("Couldn't read all grf_filelist element of %s \n", grfname); aFree(grf_filelist); @@ -576,11 +635,11 @@ static int grfio_entryread(const char *grfname, int gentry) // Get an entry for (entry = 0, ofs = 0; entry < entrys; ++entry) { - FILELIST aentry; + struct grf_filelist aentry = { 0 }; int ofs2 = ofs+getlong(grf_filelist+ofs)+4; unsigned char type = grf_filelist[ofs2+12]; if (type&FILELIST_TYPE_FILE) { - char *fname = decode_filename(grf_filelist+ofs+6, grf_filelist[ofs]-6); + char *fname = grfio_decode_filename(grf_filelist+ofs+6, grf_filelist[ofs]-6); int srclen = getlong(grf_filelist+ofs2+0) - getlong(grf_filelist+ofs2+8) - 715; if (strlen(fname) > sizeof(aentry.fn) - 1) { @@ -589,7 +648,7 @@ static int grfio_entryread(const char *grfname, int gentry) return 5; // 5: file name too long } - type |= isFullEncrypt(fname) ? FILELIST_TYPE_ENCRYPT_MIXED : FILELIST_TYPE_ENCRYPT_HEADER; + type |= grfio_is_full_encrypt(fname) ? FILELIST_TYPE_ENCRYPT_MIXED : FILELIST_TYPE_ENCRYPT_HEADER; aentry.srclen = srclen; aentry.srclen_aligned = getlong(grf_filelist+ofs2+4)-37579; @@ -603,7 +662,7 @@ static int grfio_entryread(const char *grfname, int gentry) #else aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck #endif - filelist_modify(&aentry); + grfio_filelist_modify(&aentry); } ofs = ofs2 + 17; @@ -630,7 +689,7 @@ static int grfio_entryread(const char *grfname, int gentry) return 4; } - rBuf = (unsigned char *)aMalloc(rSize); // Get a Read Size + rBuf = aMalloc(rSize); // Get a Read Size if (fread(rBuf,1,rSize,fp) != rSize) { ShowError("An error occurred in fread \n"); fclose(fp); @@ -638,8 +697,8 @@ static int grfio_entryread(const char *grfname, int gentry) return 4; } fclose(fp); - grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size - decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function + grf_filelist = aMalloc(eSize); // Get a Extend Size + grfio->decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function aFree(rBuf); entrys = getlong(grf_header+0x26) - 7; @@ -647,7 +706,7 @@ static int grfio_entryread(const char *grfname, int gentry) // Get an entry for (entry = 0, ofs = 0; entry < entrys; ++entry) { - FILELIST aentry; + struct grf_filelist aentry; char *fname = (char*)(grf_filelist+ofs); int ofs2 = ofs + (int)strlen(fname)+1; int type = grf_filelist[ofs2+12]; @@ -672,84 +731,89 @@ static int grfio_entryread(const char *grfname, int gentry) #else aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck #endif - filelist_modify(&aentry); + grfio_filelist_modify(&aentry); } ofs = ofs2 + 17; } aFree(grf_filelist); - } else {// ****** Grf Other version ****** + } else { + // ****** Grf Other version ****** fclose(fp); ShowError("GRF version %04x not supported\n",getlong(grf_header+0x2a)); return 4; } - filelist_compact(); // Unnecessary area release of filelist + grfio_filelist_compact(); // Unnecessary area release of filelist return 0; // 0:no error } -static bool grfio_parse_restable_row(const char* row) +/** + * Parses a Resource file table row. + * + * @param row The row data. + * @return success state. + * @retval true in case of success. + */ +static bool grfio_parse_restable_row(const char *row) { char w1[256], w2[256]; char src[256], dst[256]; char local[256]; - FILELIST* entry; + struct grf_filelist *entry = NULL; if (sscanf(row, "%255[^#\r\n]#%255[^#\r\n]#", w1, w2) != 2) return false; - if( strstr(w2, ".gat") == NULL && strstr(w2, ".rsw") == NULL ) + if (strstr(w2, ".gat") == NULL && strstr(w2, ".rsw") == NULL) return false; // we only need the maps' GAT and RSW files sprintf(src, "data\\%s", w1); sprintf(dst, "data\\%s", w2); - entry = filelist_find(dst); - if( entry != NULL ) - {// alias for GRF resource - FILELIST fentry; - memcpy(&fentry, entry, sizeof(FILELIST)); + entry = grfio_filelist_find(dst); + if (entry != NULL) { + // alias for GRF resource + struct grf_filelist fentry = *entry; safestrncpy(fentry.fn, src, sizeof(fentry.fn)); fentry.fnd = aStrdup(dst); - filelist_modify(&fentry); + grfio_filelist_modify(&fentry); return true; } grfio_localpath_create(local, sizeof(local), dst); - if( exists(local) ) - {// alias for local resource - FILELIST fentry; - memset(&fentry, 0, sizeof(fentry)); + if (exists(local)) { + // alias for local resource + struct grf_filelist fentry = { 0 }; safestrncpy(fentry.fn, src, sizeof(fentry.fn)); fentry.fnd = aStrdup(dst); - filelist_modify(&fentry); + grfio_filelist_modify(&fentry); return true; } return false; } -/// Grfio Resource file check. +/** + * Grfio Resource file check. + */ static void grfio_resourcecheck(void) { char restable[256]; - char *buf; - int size; - FILE* fp; - int i = 0; + char *buf = NULL; + FILE *fp = NULL; + int size = 0, i = 0; // read resnametable from data directory and return if successful grfio_localpath_create(restable, sizeof(restable), "data\\resnametable.txt"); fp = fopen(restable, "rb"); - if( fp != NULL ) - { + if (fp != NULL) { char line[256]; - while( fgets(line, sizeof(line), fp) ) - { - if( grfio_parse_restable_row(line) ) + while (fgets(line, sizeof(line), fp)) { + if (grfio_parse_restable_row(line)) ++i; } @@ -759,20 +823,19 @@ static void grfio_resourcecheck(void) } // read resnametable from loaded GRF's, only if it cannot be loaded from the data directory - buf = (char *)grfio_reads("data\\resnametable.txt", &size); - if( buf != NULL ) - { - char *ptr; + buf = grfio->reads("data\\resnametable.txt", &size); + if (buf != NULL) { + char *ptr = NULL; buf[size] = '\0'; ptr = buf; - while( ptr - buf < size ) - { - if( grfio_parse_restable_row(ptr) ) + while (ptr - buf < size) { + if (grfio_parse_restable_row(ptr)) ++i; ptr = strchr(ptr, '\n'); - if( ptr == NULL ) break; + if (ptr == NULL) + break; ptr++; } @@ -782,13 +845,19 @@ static void grfio_resourcecheck(void) } } -/// Reads a grf file and adds it to the list. -static int grfio_add(const char* fname) +/** + * Reads a grf file and adds it to the list. + * + * @param fname The file name to read. + * @return Error code. + * @retval 0 in case of success. + */ +static int grfio_add(const char *fname) { if (gentry_entrys >= gentry_maxentry) { #define GENTRY_ADDS 4 // The number increment of gentry_table entries gentry_maxentry += GENTRY_ADDS; - gentry_table = (char**)aRealloc(gentry_table, gentry_maxentry * sizeof(char*)); + gentry_table = aRealloc(gentry_table, gentry_maxentry * sizeof(char*)); memset(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS); #undef GENTRY_ADDS } @@ -798,7 +867,7 @@ static int grfio_add(const char* fname) return grfio_entryread(fname, gentry_entrys - 1); } -/// Finalizes grfio. +/// @copydoc grfio_interface::final() void grfio_final(void) { if (filelist != NULL) { @@ -824,36 +893,33 @@ void grfio_final(void) gentry_entrys = gentry_maxentry = 0; } -/// Initializes grfio. -void grfio_init(const char* fname) +/// @copydoc grfio_interface::init() +void grfio_init(const char *fname) { - FILE* data_conf; + FILE *data_conf; int grf_num = 0; hashinit(); // hash table initialization data_conf = fopen(fname, "r"); - if( data_conf != NULL ) - { + if (data_conf != NULL) { char line[1024]; - while( fgets(line, sizeof(line), data_conf) ) - { + while (fgets(line, sizeof(line), data_conf)) { char w1[1024], w2[1024]; - if( line[0] == '/' && line[1] == '/' ) + if (line[0] == '/' && line[1] == '/') continue; // skip comments if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2) continue; // skip unrecognized lines // Entry table reading - if( strcmp(w1, "grf") == 0 ) // GRF file - { - if( grfio_add(w2) == 0 ) + if (strcmp(w1, "grf") == 0) { + // GRF file + if (grfio_add(w2) == 0) ++grf_num; - } - else if( strcmp(w1,"data_dir") == 0 ) // Data directory - { + } else if (strcmp(w1,"data_dir") == 0) { + // Data directory safestrncpy(data_dir, w2, sizeof(data_dir)); } } @@ -862,12 +928,25 @@ void grfio_init(const char* fname) ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n", fname); } - if( grf_num == 0 ) + if (grf_num == 0) ShowInfo("No GRF loaded, using default data directory\n"); // Unnecessary area release of filelist - filelist_compact(); + grfio_filelist_compact(); // Resource check grfio_resourcecheck(); } + +/// Interface base initialization. +void grfio_defaults(void) +{ + grfio = &grfio_s; + grfio->init = grfio_init; + grfio->final = grfio_final; + grfio->reads = grfio_reads; + grfio->find_file = grfio_find_file; + grfio->crc32 = grfio_crc32; + grfio->decode_zip = grfio_decode_zip; + grfio->encode_zip = grfio_encode_zip; +} diff --git a/src/common/grfio.h b/src/common/grfio.h index 36ed8fb39..857bc507e 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -21,16 +21,104 @@ #ifndef COMMON_GRFIO_H #define COMMON_GRFIO_H +#include "common/hercules.h" + +/** @file + * GRF I/O library. + */ + +/// The GRF I/O interface. +struct grfio_interface { + /** + * Interface initialization. + * + * @param fname Name of the configuration file. + */ + void (*init) (const char *fname); + + /// Interface finalization. + void (*final) (void); + + /** + * Reads a file into a newly allocated buffer (from grf or data directory). + * + * @param[in] fname Name of the file to read. + * @param[out] size Buffer to return the size of the read file (optional). + * @return The file data. + * @retval NULL in case of error. + */ + void *(*reads) (const char *fname, int *size); + + /** + * Finds a file in the grf or data directory + * + * @param fname The file to find. + * @return The original file name. + * @retval NULL if the file wasn't found. + */ + const char *(*find_file) (const char *fname); + + /** + * Calculates a CRC32 hash. + * + * @param buf The data to hash. + * @param len Data length. + * + * @return The CRC32 hash. + */ + unsigned long (*crc32) (const unsigned char *buf, unsigned int len); + + /** + * Decompresses ZIP data. + * + * Decompresses the source buffer into the destination buffer. + * source_len is the byte length of the source buffer. Upon entry, + * dest_len 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, dest_len is the + * actual size of the uncompressed buffer. + * + * @param[in,out] dest The destination (uncompressed) buffer. + * @param[in,out] dest_len Max length of the destination buffer, returns length of the decompressed data. + * @param[in] source The source (compressed) buffer. + * @param[in] source_len Source data length. + * @return error code. + * @retval Z_OK in case of success. + */ + int (*decode_zip) (void *dest, unsigned long *dest_len, const void *source, unsigned long source_len); + + /** + * Compresses data to ZIP format. + * + * Compresses the source buffer into the destination buffer. + * source_len is the byte length of the source buffer. Upon entry, + * dest_len is the total size of the destination buffer, which must be + * at least the value returned by compressBound(source_len). Upon + * exit, dest_len is the actual size of the compressed buffer. + * + * @param[in,out] dest The destination (compressed) buffer (if NULL, a new buffer will be created). + * @param[in,out] dest_len Max length of the destination buffer (if 0, it will be calculated). + * @param[in] source The source (uncompressed) buffer. + * @param[in] source_len Source data length. + */ + int (*encode_zip) (void *dest, unsigned long *dest_len, const void *source, unsigned long source_len); +}; + +/** + * Reads a file into a newly allocated buffer (from grf or data directory) + * + * @param fn The filename to read. + * + * @see grfio_interface::reads() + * @related grfio_interface + */ +#define grfio_read(fn) grfio->reads((fn), NULL) + #ifdef HERCULES_CORE -void grfio_init(const char* fname); -void grfio_final(void); -void* grfio_reads(const char* fname, int* size); -char* grfio_find_file(const char* fname); -#define grfio_read(fn) grfio_reads((fn), NULL) - -unsigned long grfio_crc32(const unsigned char *buf, unsigned int len); -int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); -int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); +void grfio_defaults(void); #endif // HERCULES_CORE +HPShared struct grfio_interface *grfio; ///< Pointer to the grfio interface. #endif /* COMMON_GRFIO_H */ diff --git a/src/common/md5calc.c b/src/common/md5calc.c index d346c8aa4..bd6b48f10 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -20,27 +20,27 @@ */ #define HERCULES_CORE -/*********************************************************** - * md5 calculation algorithm - * - * The source code referred to the following URL. - * http://www.geocities.co.jp/SiliconValley-Oakland/8878/lab17/lab17.html - * - ***********************************************************/ - #include "md5calc.h" #include "common/cbasetypes.h" +#include "common/nullpo.h" #include "common/random.h" #include <stdio.h> #include <stdlib.h> #include <string.h> -// Global variable +/** @file + * Implementation of the md5 interface. + */ + +struct md5_interface md5_s; +struct md5_interface *md5; + +/// Global variable static unsigned int *pX; -// String Table +/// String Table static const unsigned int T[] = { 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4 @@ -60,99 +60,102 @@ static const unsigned int T[] = { 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60 }; -// ROTATE_LEFT The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC. +/// The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC. #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) // The function used for other calculation -static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z) +static unsigned int md5_F(unsigned int X, unsigned int Y, unsigned int Z) { return (X & Y) | (~X & Z); } -static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z) + +static unsigned int md5_G(unsigned int X, unsigned int Y, unsigned int Z) { return (X & Z) | (Y & ~Z); } -static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z) + +static unsigned int md5_H(unsigned int X, unsigned int Y, unsigned int Z) { return X ^ Y ^ Z; } -static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z) + +static unsigned int md5_I(unsigned int X, unsigned int Y, unsigned int Z) { return Y ^ (X | ~Z); } -static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI, +static unsigned int md5_Round(unsigned int a, unsigned int b, unsigned int FGHI, unsigned int k, unsigned int s, unsigned int i) { return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s); } -static void Round1(unsigned int *a, unsigned int b, unsigned int c, +static void md5_Round1(unsigned int *a, unsigned int b, unsigned int c, unsigned int d,unsigned int k, unsigned int s, unsigned int i) { - *a = Round(*a, b, F(b,c,d), k, s, i); + *a = md5_Round(*a, b, md5_F(b,c,d), k, s, i); } -static void Round2(unsigned int *a, unsigned int b, unsigned int c, +static void md5_Round2(unsigned int *a, unsigned int b, unsigned int c, unsigned int d,unsigned int k, unsigned int s, unsigned int i) { - *a = Round(*a, b, G(b,c,d), k, s, i); + *a = md5_Round(*a, b, md5_G(b,c,d), k, s, i); } -static void Round3(unsigned int *a, unsigned int b, unsigned int c, +static void md5_Round3(unsigned int *a, unsigned int b, unsigned int c, unsigned int d,unsigned int k, unsigned int s, unsigned int i) { - *a = Round(*a, b, H(b,c,d), k, s, i); + *a = md5_Round(*a, b, md5_H(b,c,d), k, s, i); } -static void Round4(unsigned int *a, unsigned int b, unsigned int c, +static void md5_Round4(unsigned int *a, unsigned int b, unsigned int c, unsigned int d,unsigned int k, unsigned int s, unsigned int i) { - *a = Round(*a, b, I(b,c,d), k, s, i); + *a = md5_Round(*a, b, md5_I(b,c,d), k, s, i); } -static void MD5_Round_Calculate(const unsigned char *block, +static void md5_Round_Calculate(const unsigned char *block, unsigned int *A2, unsigned int *B2, unsigned int *C2, unsigned int *D2) { //create X It is since it is required. unsigned int X[16]; //512bit 64byte - int j,k; + int j, k; //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; + 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; //Copy block(padding_message) i into X - for (j=0,k=0; j<64; j+=4,k++) - X[k] = ( (unsigned int )block[j] ) // 8byte*4 -> 32byte conversion - | ( ((unsigned int )block[j+1]) << 8 ) // A function called Decode as used in the field of RFC - | ( ((unsigned int )block[j+2]) << 16 ) - | ( ((unsigned int )block[j+3]) << 24 ); - + for (j = 0, k = 0; j < 64; j += 4, k++) { + X[k] = ((unsigned int)block[j]) // 8byte*4 -> 32byte conversion + | (((unsigned int)block[j+1]) << 8) // A function called Decode as used in the field of RFC + | (((unsigned int)block[j+2]) << 16) + | (((unsigned int)block[j+3]) << 24); + } //Round 1 - Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3); - Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7); - Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11); - Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15); + md5_Round1(&A,B,C,D, 0, 7, 0); md5_Round1(&D,A,B,C, 1, 12, 1); md5_Round1(&C,D,A,B, 2, 17, 2); md5_Round1(&B,C,D,A, 3, 22, 3); + md5_Round1(&A,B,C,D, 4, 7, 4); md5_Round1(&D,A,B,C, 5, 12, 5); md5_Round1(&C,D,A,B, 6, 17, 6); md5_Round1(&B,C,D,A, 7, 22, 7); + md5_Round1(&A,B,C,D, 8, 7, 8); md5_Round1(&D,A,B,C, 9, 12, 9); md5_Round1(&C,D,A,B, 10, 17, 10); md5_Round1(&B,C,D,A, 11, 22, 11); + md5_Round1(&A,B,C,D, 12, 7, 12); md5_Round1(&D,A,B,C, 13, 12, 13); md5_Round1(&C,D,A,B, 14, 17, 14); md5_Round1(&B,C,D,A, 15, 22, 15); //Round 2 - Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19); - Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23); - Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27); - Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31); + md5_Round2(&A,B,C,D, 1, 5, 16); md5_Round2(&D,A,B,C, 6, 9, 17); md5_Round2(&C,D,A,B, 11, 14, 18); md5_Round2(&B,C,D,A, 0, 20, 19); + md5_Round2(&A,B,C,D, 5, 5, 20); md5_Round2(&D,A,B,C, 10, 9, 21); md5_Round2(&C,D,A,B, 15, 14, 22); md5_Round2(&B,C,D,A, 4, 20, 23); + md5_Round2(&A,B,C,D, 9, 5, 24); md5_Round2(&D,A,B,C, 14, 9, 25); md5_Round2(&C,D,A,B, 3, 14, 26); md5_Round2(&B,C,D,A, 8, 20, 27); + md5_Round2(&A,B,C,D, 13, 5, 28); md5_Round2(&D,A,B,C, 2, 9, 29); md5_Round2(&C,D,A,B, 7, 14, 30); md5_Round2(&B,C,D,A, 12, 20, 31); //Round 3 - Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35); - Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39); - Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43); - Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47); + md5_Round3(&A,B,C,D, 5, 4, 32); md5_Round3(&D,A,B,C, 8, 11, 33); md5_Round3(&C,D,A,B, 11, 16, 34); md5_Round3(&B,C,D,A, 14, 23, 35); + md5_Round3(&A,B,C,D, 1, 4, 36); md5_Round3(&D,A,B,C, 4, 11, 37); md5_Round3(&C,D,A,B, 7, 16, 38); md5_Round3(&B,C,D,A, 10, 23, 39); + md5_Round3(&A,B,C,D, 13, 4, 40); md5_Round3(&D,A,B,C, 0, 11, 41); md5_Round3(&C,D,A,B, 3, 16, 42); md5_Round3(&B,C,D,A, 6, 23, 43); + md5_Round3(&A,B,C,D, 9, 4, 44); md5_Round3(&D,A,B,C, 12, 11, 45); md5_Round3(&C,D,A,B, 15, 16, 46); md5_Round3(&B,C,D,A, 2, 23, 47); //Round 4 - Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51); - Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55); - Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59); - Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63); + md5_Round4(&A,B,C,D, 0, 6, 48); md5_Round4(&D,A,B,C, 7, 10, 49); md5_Round4(&C,D,A,B, 14, 15, 50); md5_Round4(&B,C,D,A, 5, 21, 51); + md5_Round4(&A,B,C,D, 12, 6, 52); md5_Round4(&D,A,B,C, 3, 10, 53); md5_Round4(&C,D,A,B, 10, 15, 54); md5_Round4(&B,C,D,A, 1, 21, 55); + md5_Round4(&A,B,C,D, 8, 6, 56); md5_Round4(&D,A,B,C, 15, 10, 57); md5_Round4(&C,D,A,B, 6, 15, 58); md5_Round4(&B,C,D,A, 13, 21, 59); + md5_Round4(&A,B,C,D, 4, 6, 60); md5_Round4(&D,A,B,C, 11, 10, 61); md5_Round4(&C,D,A,B, 2, 15, 62); md5_Round4(&B,C,D,A, 9, 21, 63); // Then perform the following additions. (let's add) *A2 = A + AA; @@ -164,7 +167,8 @@ static void MD5_Round_Calculate(const unsigned char *block, memset(pX, 0, sizeof(X)); } -static void MD5_String2binary(const char * string, unsigned char * output) +/// @copydoc md5_interface::binary() +static void md5_string2binary(const char *string, unsigned char *output) { //var /*8bit*/ @@ -196,7 +200,7 @@ static void MD5_String2binary(const char * string, unsigned char * output) //1-2 Repeat calculation until length becomes less than 64 bytes. for (i=string_byte_len; 64<=i; i-=64,pstring+=64) - MD5_Round_Calculate(pstring, A,B,C,D); + md5_Round_Calculate(pstring, A,B,C,D); //1-3 copy_len = string_byte_len % 64; //The number of bytes which remained is computed. @@ -207,7 +211,7 @@ static void MD5_String2binary(const char * string, unsigned char * output) //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); + md5_Round_Calculate(padding_message, A,B,C,D); memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0. } @@ -219,31 +223,26 @@ static void MD5_String2binary(const char * string, unsigned char * output) if (UINT_MAX / 8 < string_byte_len) { unsigned int high = (string_byte_len - UINT_MAX / 8) * 8; memcpy(&padding_message[60], &high, 4); - } else + } else { memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0. + } //Step 4.Process Message in 16-Word Blocks (calculation of MD5) - MD5_Round_Calculate(padding_message, A,B,C,D); + md5_Round_Calculate(padding_message, A,B,C,D); //Step 5.Output (output) memcpy(output,msg_digest,16); } -//------------------------------------------------------------------- -// The function for the exteriors - -/** output is the coded binary in the character sequence which wants to code string. */ -void MD5_Binary(const char * string, unsigned char * output) -{ - MD5_String2binary(string,output); -} - -/** output is the coded character sequence in the character sequence which wants to code string. */ -void MD5_String(const char *string, char *output) +/// @copydoc md5_interface::string() +void md5_string(const char *string, char *output) { unsigned char digest[16]; - MD5_String2binary(string,digest); + nullpo_retv(string); + nullpo_retv(output); + + md5->binary(string,digest); snprintf(output, 33, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[ 0], digest[ 1], digest[ 2], digest[ 3], digest[ 4], digest[ 5], digest[ 6], digest[ 7], @@ -251,11 +250,24 @@ void MD5_String(const char *string, char *output) digest[12], digest[13], digest[14], digest[15]); } -/** output is a sequence of non-zero characters to be used as password salt. */ -void MD5_Salt(unsigned int len, char * output) +/// @copydoc md5_interface::salt(); +void md5_salt(int len, char *output) { - unsigned int i; - for( i = 0; i < len; ++i ) + int i; + Assert_retv(len > 0); + + for (i = 0; i < len; ++i) output[i] = (char)(1 + rnd() % 255); } + +/** + * Interface base initialization. + */ +void md5_defaults(void) +{ + md5 = &md5_s; + md5->binary = md5_string2binary; + md5->string = md5_string; + md5->salt = md5_salt; +} diff --git a/src/common/md5calc.h b/src/common/md5calc.h index 0294c3ca1..b4d4995f9 100644 --- a/src/common/md5calc.h +++ b/src/common/md5calc.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -21,10 +21,46 @@ #ifndef COMMON_MD5CALC_H #define COMMON_MD5CALC_H +#include "common/hercules.h" + +/** @file + * md5 calculation algorithm. + * + * The source code referred to the following URL. + * http://www.geocities.co.jp/SiliconValley-Oakland/8878/lab17/lab17.html + */ + +/// The md5 interface +struct md5_interface { + /** + * Hashes a string, returning the hash in string format. + * + * @param[in] string The source string (NUL terminated). + * @param[out] output Output buffer (at least 33 bytes available). + */ + void (*string) (const char *string, char *output); + + /** + * Hashes a string, returning the buffer in binary format. + * + * @param[in] string The source string. + * @param[out] output Output buffer (at least 16 bytes available). + */ + void (*binary) (const char *string, unsigned char *output); + + /** + * Generates a random salt. + * + * @param[in] len The desired salt length. + * @param[out] output The output buffer (at least len bytes available). + */ + void (*salt) (int len, char *output); +}; + #ifdef HERCULES_CORE -void MD5_String(const char * string, char * output); -void MD5_Binary(const char * string, unsigned char * output); -void MD5_Salt(unsigned int len, char * output); +void md5_defaults(void); #endif // HERCULES_CORE +HPShared struct md5_interface *md5; ///< Pointer to the md5 interface. + #endif /* COMMON_MD5CALC_H */ diff --git a/src/common/mmo.h b/src/common/mmo.h index a2080d900..0a5d9d053 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -125,29 +125,69 @@ //Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) #define MAX_BANK_ZENY INT_MAX +#ifndef MAX_LEVEL #define MAX_LEVEL 175 +#endif #define MAX_FAME 1000000000 #define MAX_CART 100 +#ifndef MAX_SKILL #define MAX_SKILL 1478 +#endif +#ifndef MAX_SKILL_ID #define MAX_SKILL_ID 10015 // [Ind/Hercules] max used skill ID +#endif +#ifndef MAX_SKILL_TREE // Update this max as necessary. 86 is the value needed for Expanded Super Novice. #define MAX_SKILL_TREE 86 +#endif +#ifndef DEFAULT_WALK_SPEED #define DEFAULT_WALK_SPEED 150 +#endif +#ifndef MIN_WALK_SPEED #define MIN_WALK_SPEED 20 /* below 20 clips animation */ +#endif +#ifndef MAX_WALK_SPEED #define MAX_WALK_SPEED 1000 +#endif +#ifndef MAX_STORAGE #define MAX_STORAGE 600 +#endif +#ifndef MAX_GUILD_STORAGE #define MAX_GUILD_STORAGE 600 +#endif +#ifndef MAX_PARTY #define MAX_PARTY 12 +#endif +#ifndef BASE_GUILD_SIZE #define BASE_GUILD_SIZE 16 // Base guild members (without GD_EXTENSION) +#endif +#ifndef MAX_GUILD #define MAX_GUILD (BASE_GUILD_SIZE+10*6) // Increased max guild members +6 per 1 extension levels [Lupus] +#endif +#ifndef MAX_GUILDPOSITION #define MAX_GUILDPOSITION 20 // Increased max guild positions to accomodate for all members [Valaris] (removed) [PoW] +#endif +#ifndef MAX_GUILDEXPULSION #define MAX_GUILDEXPULSION 32 +#endif +#ifndef MAX_GUILDALLIANCE #define MAX_GUILDALLIANCE 16 +#endif +#ifndef MAX_GUILDSKILL #define MAX_GUILDSKILL 15 // Increased max guild skills because of new skills [Sara-chan] +#endif +#ifndef MAX_GUILDLEVEL #define MAX_GUILDLEVEL 50 +#endif +#ifndef MAX_GUARDIANS #define MAX_GUARDIANS 8 // Local max per castle. [Skotlex] +#endif +#ifndef MAX_QUEST_OBJECTIVES #define MAX_QUEST_OBJECTIVES 3 // Max quest objectives for a quest +#endif +#ifndef MAX_START_ITEMS #define MAX_START_ITEMS 32 // Max number of items allowed to be given to a char whenever it's created. [mkbu95] +#endif // for produce #define MIN_ATTRIBUTE 0 @@ -170,7 +210,9 @@ #define MAP_NAME_LENGTH (11 + 1) #define MAP_NAME_LENGTH_EXT (MAP_NAME_LENGTH + 4) +#ifndef MAX_FRIENDS #define MAX_FRIENDS 40 +#endif #define MAX_MEMOPOINTS 3 // Size of the fame list arrays. @@ -186,8 +228,12 @@ #define MAX_GUILDMES2 120 // Base Homun skill. +#ifndef HM_SKILLBASE #define HM_SKILLBASE 8001 +#endif +#ifndef MAX_HOMUNSKILL #define MAX_HOMUNSKILL 43 +#endif // Mail System #define MAIL_MAX_INBOX 30 @@ -195,13 +241,23 @@ #define MAIL_BODY_LENGTH 200 // Mercenary System +#ifndef MC_SKILLBASE #define MC_SKILLBASE 8201 +#endif +#ifndef MAX_MERCSKILL #define MAX_MERCSKILL 40 +#endif // Elemental System +#ifndef MAX_ELEMENTALSKILL #define MAX_ELEMENTALSKILL 42 +#endif +#ifndef EL_SKILLBASE #define EL_SKILLBASE 8401 +#endif +#ifndef MAX_ELESKILLTREE #define MAX_ELESKILLTREE 3 +#endif // The following system marks a different job ID system used by the map server, // which makes a lot more sense than the normal one. [Skotlex] @@ -233,7 +289,9 @@ enum item_types { IT_AMMO, //10 IT_DELAYCONSUME,//11 IT_CASH = 18, +#ifndef IT_MAX IT_MAX +#endif }; #define INDEX_NOT_FOUND (-1) ///< Used as invalid/failure value in various functions that return an index @@ -253,6 +311,11 @@ struct quest { enum quest_state state; ///< Current quest state }; +enum attribute_flag { + ATTR_NONE = 0, + ATTR_BROKEN = 1, +}; + struct item { int id; short nameid; @@ -325,7 +388,9 @@ enum e_item_bound_type { IBT_GUILD = 0x2, IBT_PARTY = 0x3, IBT_CHARACTER = 0x4, +#ifndef IBT_MAX IBT_MAX = 0x4, +#endif }; enum { @@ -505,7 +570,7 @@ struct mmo_charstatus { int bank_vault; short class_; - unsigned int status_point,skill_point; + int status_point, skill_point; int hp,max_hp,sp,max_sp; unsigned int option; short manner; // Defines how many minutes a char will be muted, each negative point is equivalent to a minute. @@ -525,7 +590,7 @@ struct mmo_charstatus { short robe; char name[NAME_LENGTH]; - unsigned int base_level,job_level; + int base_level, job_level; short str,agi,vit,int_,dex,luk; unsigned char slot,sex; @@ -772,7 +837,9 @@ enum { GD_RESTORE=10012, GD_EMERGENCYCALL=10013, GD_DEVELOPMENT=10014, +#ifndef GD_MAX GD_MAX, +#endif }; //These mark the ID of the jobs, as expected by the client. [Skotlex] @@ -929,7 +996,9 @@ enum { JOB_OBORO, JOB_REBELLION = 4215, +#ifndef JOB_MAX JOB_MAX, +#endif }; //Total number of classes (for data storage) @@ -966,7 +1035,9 @@ enum weapon_type { W_GRENADE, //21 W_HUUMA, //22 W_2HSTAFF, //23 +#ifndef MAX_SINGLE_WEAPON_TYPE MAX_SINGLE_WEAPON_TYPE, +#endif // dual-wield constants W_DOUBLE_DD, ///< 2 daggers W_DOUBLE_SS, ///< 2 swords @@ -974,7 +1045,9 @@ enum weapon_type { W_DOUBLE_DS, ///< dagger + sword W_DOUBLE_DA, ///< dagger + axe W_DOUBLE_SA, ///< sword + axe +#ifndef MAX_WEAPON_TYPE MAX_WEAPON_TYPE, +#endif }; enum ammo_type { diff --git a/src/common/mutex.c b/src/common/mutex.c index 0f02b153f..bdc2fb4dc 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) rAthena Project (www.rathena.org) * * Hercules is free software: you can redistribute it and/or modify @@ -34,7 +34,14 @@ #include <sys/time.h> #endif -struct ramutex{ +/** @file + * Implementation of the mutex interface. + */ + +struct mutex_interface mutex_s; +struct mutex_interface *mutex; + +struct mutex_data { #ifdef WIN32 CRITICAL_SECTION hMutex; #else @@ -42,32 +49,26 @@ struct ramutex{ #endif }; -struct racond{ +struct cond_data { #ifdef WIN32 HANDLE events[2]; ra_align(8) volatile LONG nWaiters; CRITICAL_SECTION waiters_lock; - #define EVENT_COND_SIGNAL 0 #define EVENT_COND_BROADCAST 1 - #else pthread_cond_t hCond; #endif }; -//////////////////// -// Mutex -// -// Implementation: -// +/* Mutex */ -ramutex *ramutex_create(void) { - struct ramutex *m; - - m = (struct ramutex*)aMalloc( sizeof(struct ramutex) ); +/// @copydoc mutex_interface::create() +struct mutex_data *mutex_create(void) +{ + struct mutex_data *m = aMalloc(sizeof(struct mutex_data)); if (m == NULL) { - ShowFatalError("ramutex_create: OOM while allocating %"PRIuS" bytes.\n", sizeof(struct ramutex)); + ShowFatalError("ramutex_create: OOM while allocating %"PRIuS" bytes.\n", sizeof(struct mutex_data)); return NULL; } @@ -78,10 +79,11 @@ ramutex *ramutex_create(void) { #endif return m; -}//end: ramutex_create() - -void ramutex_destroy(ramutex *m) { +} +/// @copydoc mutex_interface::destroy() +void mutex_destroy(struct mutex_data *m) +{ #ifdef WIN32 DeleteCriticalSection(&m->hMutex); #else @@ -89,53 +91,49 @@ void ramutex_destroy(ramutex *m) { #endif aFree(m); +} -}//end: ramutex_destroy() - -void ramutex_lock(ramutex *m) { - +/// @copydoc mutex_interface::lock() +void mutex_lock(struct mutex_data *m) +{ #ifdef WIN32 EnterCriticalSection(&m->hMutex); #else pthread_mutex_lock(&m->hMutex); #endif -}//end: ramutex_lock +} -bool ramutex_trylock(ramutex *m) { +/// @copydoc mutex_interface::trylock() +bool mutex_trylock(struct mutex_data *m) +{ #ifdef WIN32 - if(TryEnterCriticalSection(&m->hMutex) != FALSE) + if (TryEnterCriticalSection(&m->hMutex) != FALSE) return true; - - return false; #else - if(pthread_mutex_trylock(&m->hMutex) == 0) + if (pthread_mutex_trylock(&m->hMutex) == 0) return true; - - return false; #endif -}//end: ramutex_trylock() + return false; +} -void ramutex_unlock(ramutex *m) { +/// @copydoc mutex_interface::unlock() +void mutex_unlock(struct mutex_data *m) +{ #ifdef WIN32 LeaveCriticalSection(&m->hMutex); #else pthread_mutex_unlock(&m->hMutex); #endif +} -}//end: ramutex_unlock() - -/////////////// -// Condition Variables -// -// Implementation: -// +/* Conditional variable */ -racond *racond_create(void) { - struct racond *c; - - c = (struct racond*)aMalloc( sizeof(struct racond) ); +/// @copydoc mutex_interface::cond_create() +struct cond_data *cond_create(void) +{ + struct cond_data *c = aMalloc(sizeof(struct cond_data)); if (c == NULL) { - ShowFatalError("racond_create: OOM while allocating %"PRIuS" bytes\n", sizeof(struct racond)); + ShowFatalError("racond_create: OOM while allocating %"PRIuS" bytes\n", sizeof(struct cond_data)); return NULL; } @@ -149,21 +147,25 @@ racond *racond_create(void) { #endif return c; -}//end: racond_create() +} -void racond_destroy(racond *c) { +/// @copydoc mutex_interface::cond_destroy() +void cond_destroy(struct cond_data *c) +{ #ifdef WIN32 - CloseHandle( c->events[ EVENT_COND_SIGNAL ] ); - CloseHandle( c->events[ EVENT_COND_BROADCAST ] ); - DeleteCriticalSection( &c->waiters_lock ); + CloseHandle(c->events[EVENT_COND_SIGNAL]); + CloseHandle(c->events[EVENT_COND_BROADCAST]); + DeleteCriticalSection(&c->waiters_lock); #else pthread_cond_destroy(&c->hCond); #endif aFree(c); -}//end: racond_destroy() +} -void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) { +/// @copydoc mutex_interface::cond_wait() +void cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) +{ #ifdef WIN32 register DWORD ms; int result; @@ -173,7 +175,7 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) { c->nWaiters++; LeaveCriticalSection(&c->waiters_lock); - if(timeout_ticks < 0) + if (timeout_ticks < 0) ms = INFINITE; else ms = (timeout_ticks > MAXDWORD) ? (MAXDWORD - 1) : (DWORD)timeout_ticks; @@ -181,27 +183,27 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) { // we can release the mutex (m) here, cause win's // manual reset events maintain state when used with // SetEvent() - ramutex_unlock(m); + mutex->unlock(m); result = WaitForMultipleObjects(2, c->events, FALSE, ms); EnterCriticalSection(&c->waiters_lock); c->nWaiters--; - if( (result == WAIT_OBJECT_0 + EVENT_COND_BROADCAST) && (c->nWaiters == 0) ) + if ((result == WAIT_OBJECT_0 + EVENT_COND_BROADCAST) && (c->nWaiters == 0)) is_last = true; // Broadcast called! LeaveCriticalSection(&c->waiters_lock); // we are the last waiter that has to be notified, or to stop waiting // so we have to do a manual reset - if(is_last == true) + if (is_last == true) ResetEvent( c->events[EVENT_COND_BROADCAST] ); - ramutex_lock(m); + mutex->lock(m); #else - if(timeout_ticks < 0){ - pthread_cond_wait( &c->hCond, &m->hMutex ); - }else{ + if (timeout_ticks < 0) { + pthread_cond_wait(&c->hCond, &m->hMutex); + } else { struct timespec wtime; int64 exact_timeout = timer->gettick() + timeout_ticks; @@ -210,11 +212,12 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) { pthread_cond_timedwait( &c->hCond, &m->hMutex, &wtime); } - #endif -}//end: racond_wait() +} -void racond_signal(racond *c) { +/// @copydoc mutex_interface::cond_signal() +void cond_signal(struct cond_data *c) +{ #ifdef WIN32 # if 0 bool has_waiters = false; @@ -225,13 +228,15 @@ void racond_signal(racond *c) { if(has_waiters == true) # endif // 0 - SetEvent( c->events[ EVENT_COND_SIGNAL ] ); + SetEvent(c->events[EVENT_COND_SIGNAL]); #else pthread_cond_signal(&c->hCond); #endif -}//end: racond_signal() +} -void racond_broadcast(racond *c) { +/// @copydoc mutex_interface::cond_broadcast() +void cond_broadcast(struct cond_data *c) +{ #ifdef WIN32 # if 0 bool has_waiters = false; @@ -242,8 +247,27 @@ void racond_broadcast(racond *c) { if(has_waiters == true) # endif // 0 - SetEvent( c->events[ EVENT_COND_BROADCAST ] ); + SetEvent(c->events[EVENT_COND_BROADCAST]); #else pthread_cond_broadcast(&c->hCond); #endif -}//end: racond_broadcast() +} + +/** + * Interface base initialization. + */ +void mutex_defaults(void) +{ + mutex = &mutex_s; + mutex->create = mutex_create; + mutex->destroy = mutex_destroy; + mutex->lock = mutex_lock; + mutex->trylock = mutex_trylock; + mutex->unlock = mutex_unlock; + + mutex->cond_create = cond_create; + mutex->cond_destroy = cond_destroy; + mutex->cond_wait = cond_wait; + mutex->cond_signal = cond_signal; + mutex->cond_broadcast = cond_broadcast; +} diff --git a/src/common/mutex.h b/src/common/mutex.h index e49791493..0569fb0da 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) rAthena Project (www.rathena.org) * * Hercules is free software: you can redistribute it and/or modify @@ -21,91 +21,111 @@ #ifndef COMMON_MUTEX_H #define COMMON_MUTEX_H -#include "common/cbasetypes.h" +#include "common/hercules.h" -typedef struct ramutex ramutex; // Mutex -typedef struct racond racond; // Condition Var - -#ifdef HERCULES_CORE -/** - * Creates a Mutex - * - * @return not NULL +/** @file + * Mutex and conditional variables implementation for Hercules. */ -ramutex *ramutex_create(void); -/** - * Destroys a Mutex - * - * @param m - the mutex to destroy - */ -void ramutex_destroy(ramutex *m); +/* Opaque types */ -/** - * Gets a lock - * - * @param m - the mutex to lock - */ -void ramutex_lock(ramutex *m); +struct mutex_data; ///< Mutex +struct cond_data; ///< Conditional variable -/** - * Trys to get the Lock - * - * @param m - the mutex try to lock - * - * @return boolean (true = got the lock) - */ -bool ramutex_trylock(ramutex *m); +/* Interface */ -/** - * Unlocks a mutex - * - * @param m - the mutex to unlock - */ -void ramutex_unlock(ramutex *m); +/// The mutex interface. +struct mutex_interface { + /** + * Creates a mutex. + * + * @return The created mutex. + */ + struct mutex_data *(*create) (void); + /** + * Destroys a mutex. + * + * @param m the mutex to destroy. + */ + void (*destroy) (struct mutex_data *m); -/** - * Creates a Condition variable - * - * @return not NULL - */ -racond *racond_create(void); + /** + * Gets a lock. + * + * This function blocks until the lock can be acquired. + * + * @param m The mutex to lock. + */ + void (*lock) (struct mutex_data *m); -/** - * Destroy a Condition variable - * - * @param c - the condition variable to destroy - */ -void racond_destroy(racond *c); + /** + * Tries to get a lock. + * + * This function returns immediately. + * + * @param m The mutex to try to lock. + * @return success status. + * @retval true if the lock was acquired. + * @retval false if the mutex couldn't be locked. + */ + bool (*trylock) (struct mutex_data *m); -/** - * Waits Until state is signaled - * - * @param c - the condition var to wait for signaled state - * @param m - the mutex used for synchronization - * @param timeout_ticks - timeout in ticks ( -1 = INFINITE ) - */ -void racond_wait(racond *c, ramutex *m, sysint timeout_ticks); + /** + * Unlocks a mutex. + * + * @param m The mutex to unlock. + */ + void (*unlock) (struct mutex_data *m); -/** - * Sets the given condition var to signaled state - * - * @param c - condition var to set in signaled state. - * - * @note: - * Only one waiter gets notified. - */ -void racond_signal(racond *c); + /** + * Creates a conditional variable. + * + * @return the created conditional variable. + */ + struct cond_data *(*cond_create) (void); -/** - * Sets notifies all waiting threads thats signaled. - * @param c - condition var to set in signaled state - * - * @note: - * All Waiters getting notified. - */ -void racond_broadcast(racond *c); + /** + * Destroys a conditional variable. + * + * @param c the conditional variable to destroy. + */ + void (*cond_destroy) (struct cond_data *c); + + /** + * Waits Until state is signaled. + * + * @param c The condition var to wait for signaled state. + * @param m The mutex used for synchronization. + * @param timeout_ticks Timeout in ticks (-1 = INFINITE) + */ + void (*cond_wait) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks); + + /** + * Sets the given condition var to signaled state. + * + * @remark + * Only one waiter gets notified. + * + * @param c Condition var to set in signaled state. + */ + void (*cond_signal) (struct cond_data *c); + + /** + * Sets notifies all waiting threads thats signaled. + * + * @remark + * All Waiters getting notified. + * + * @param c Condition var to set in signaled state. + */ + void (*cond_broadcast) (struct cond_data *c); +}; + +#ifdef HERCULES_CORE +void mutex_defaults(void); #endif // HERCULES_CORE +HPShared struct mutex_interface *mutex; ///< Pointer to the mutex interface. + #endif /* COMMON_MUTEX_H */ diff --git a/src/common/random.c b/src/common/random.c index ba70a5c1d..b3a13e054 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -27,6 +27,7 @@ #include "common/timer.h" // gettick #include <mt19937ar/mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 +#include <stdlib.h> #if defined(WIN32) # include "common/winapi.h" @@ -35,8 +36,14 @@ # include <unistd.h> #endif +/** @file + * Implementation of the random number generator interface. + */ + +struct rnd_interface rnd_s; +struct rnd_interface *rnd; -/// Initializes the random number generator with an appropriate seed. +/// @copydoc rnd_interface::init() void rnd_init(void) { unsigned long seed = (unsigned long)timer->gettick(); @@ -53,53 +60,64 @@ void rnd_init(void) #endif // HAVE_GETTID #endif init_genrand(seed); + + // Also initialize the stdlib rng, just in case it's used somewhere. + srand((unsigned int)seed); } +/// @copydoc rnd_interface::final() +void rnd_final(void) +{ +} -/// Initializes the random number generator. +/// @copydoc rnd_interface::seed() void rnd_seed(uint32 seed) { init_genrand(seed); } - -/// Generates a random number in the interval [0, SINT32_MAX] -int32 rnd(void) +/// @copydoc rnd_interface::random() +int32 rnd_random(void) { return (int32)genrand_int31(); } - -/// Generates a random number in the interval [0, dice_faces) -/// NOTE: interval is open ended, so dice_faces is excluded (unless it's 0) +/// @copydoc rnd_interface::roll() uint32 rnd_roll(uint32 dice_faces) { - return (uint32)(rnd_uniform()*dice_faces); + return (uint32)(rnd->uniform()*dice_faces); } - -/// Generates a random number in the interval [min, max] -/// Returns min if range is invalid. +/// @copydoc rnd_interface::value() int32 rnd_value(int32 min, int32 max) { - if( min >= max ) + if (min >= max) return min; - return min + (int32)(rnd_uniform()*(max-min+1)); + return min + (int32)(rnd->uniform()*(max-min+1)); } - -/// Generates a random number in the interval [0.0, 1.0) -/// NOTE: interval is open ended, so 1.0 is excluded +/// @copydoc rnd_interface::uniform() double rnd_uniform(void) { return ((uint32)genrand_int32())*(1.0/4294967296.0);// divided by 2^32 } - -/// Generates a random number in the interval [0.0, 1.0) with 53-bit resolution -/// NOTE: interval is open ended, so 1.0 is excluded -/// NOTE: 53 bits is the maximum precision of a double +/// @copydoc rnd_interface::uniform53() double rnd_uniform53(void) { return genrand_res53(); } + +/// Interface base initialization. +void rnd_defaults(void) +{ + rnd = &rnd_s; + rnd->init = rnd_init; + rnd->final = rnd_final; + rnd->seed = rnd_seed; + rnd->random = rnd_random; + rnd->roll = rnd_roll; + rnd->value = rnd_value; + rnd->uniform = rnd_uniform; + rnd->uniform53 = rnd_uniform53; +} diff --git a/src/common/random.h b/src/common/random.h index 0b5abbcdc..1b249ef19 100644 --- a/src/common/random.h +++ b/src/common/random.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -21,17 +21,81 @@ #ifndef COMMON_RANDOM_H #define COMMON_RANDOM_H -#include "common/cbasetypes.h" +#include "common/hercules.h" + +/** @file + * The random number generator interface. + */ + +/// Random interface. +struct rnd_interface { + /** + * Interface initialization. + * + * During initialization, the RNG is seeded with a random seed. + */ + void (*init) (void); + + /// Interface finalization. + void (*final) (void); + + /** + * Re-seeds the random number generator. + * + * @param seed The new seed. + */ + void (*seed) (uint32 seed); + + /** + * Generates a random number in the interval [0, SINT32_MAX]. + */ + int32 (*random) (void); + + /** + * Generates a random number in the interval [0, dice_faces). + * + * @remark + * interval is open ended, so dice_faces is excluded (unless it's 0) + */ + uint32 (*roll) (uint32 dice_faces); + + /** + * Generates a random number in the interval [min, max]. + * + * @retval min if range is invalid. + */ + int32 (*value) (int32 min, int32 max); + + /** + * Generates a random number in the interval [0.0, 1.0) + * + * @remark + * interval is open ended, so 1.0 is excluded + */ + double (*uniform) (void); + + /** + * Generates a random number in the interval [0.0, 1.0) with 53-bit resolution. + * + * 53 bits is the maximum precision of a double. + * + * @remark + * interval is open ended, so 1.0 is excluded + */ + double (*uniform53) (void); +}; + +/** + * Utlity macro to call the frequently used rnd_interface#random(). + * + * @related rnd_interface. + */ +#define rnd() rnd->random() #ifdef HERCULES_CORE -void rnd_init(void); -void rnd_seed(uint32); - -int32 rnd(void);// [0, SINT32_MAX] -uint32 rnd_roll(uint32 dice_faces);// [0, dice_faces) -int32 rnd_value(int32 min, int32 max);// [min, max] -double rnd_uniform(void);// [0.0, 1.0) -double rnd_uniform53(void);// [0.0, 1.0) +void rnd_defaults(void); #endif // HERCULES_CORE +HPShared struct rnd_interface *rnd; ///< Pointer to the random interface. + #endif /* COMMON_RANDOM_H */ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 8ed8efc1d..d8864684d 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -804,7 +804,11 @@ void showmsg_showConfigWarning(struct config_setting_t *config, const char *stri StrBuf->AppendStr(&buf, string); StrBuf->Printf(&buf, " (%s:%u)\n", config_setting_source_file(config), config_setting_source_line(config)); va_start(ap, string); +#ifdef BUILDBOT + vShowMessage_(MSG_ERROR, StrBuf->Value(&buf), ap); +#else // BUILDBOT vShowMessage_(MSG_WARNING, StrBuf->Value(&buf), ap); +#endif // BUILDBOT va_end(ap); StrBuf->Destroy(&buf); } diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 7b48d0df2..303c8dd28 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -130,7 +130,11 @@ struct showmsg_interface { #define ShowSQL(fmt, ...) (showmsg->showSQL((fmt), ##__VA_ARGS__)) #define ShowInfo(fmt, ...) (showmsg->showInfo((fmt), ##__VA_ARGS__)) #define ShowNotice(fmt, ...) (showmsg->showNotice((fmt), ##__VA_ARGS__)) +#ifdef BUILDBOT +#define ShowWarning(fmt, ...) (showmsg->showError((fmt), ##__VA_ARGS__)) +#else // BUILDBOT #define ShowWarning(fmt, ...) (showmsg->showWarning((fmt), ##__VA_ARGS__)) +#endif // BUILDBOT #define ShowDebug(fmt, ...) (showmsg->showDebug((fmt), ##__VA_ARGS__)) #define ShowError(fmt, ...) (showmsg->showError((fmt), ##__VA_ARGS__)) #define ShowFatalError(fmt, ...) (showmsg->showFatalError((fmt), ##__VA_ARGS__)) diff --git a/src/common/socket.c b/src/common/socket.c index 5d4ea06a0..af5e8aa73 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -38,35 +38,39 @@ #include <stdlib.h> #include <sys/types.h> +#ifdef SOCKET_EPOLL +#include <sys/epoll.h> +#endif // SOCKET_EPOLL + #ifdef WIN32 # include "common/winapi.h" -#else +#else // WIN32 # include <arpa/inet.h> # include <errno.h> # include <net/if.h> # include <netdb.h> #if defined __linux__ || defined __linux # include <linux/tcp.h> -#else +#else // defined __linux__ || defined __linux # include <netinet/in.h> # include <netinet/tcp.h> -#endif +#endif // defined __linux__ || defined __linux # include <sys/ioctl.h> # include <sys/socket.h> # include <sys/time.h> # include <unistd.h> -# ifndef SIOCGIFCONF -# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] -# endif -# ifndef FIONBIO -# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] -# endif +#ifndef SIOCGIFCONF +# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] +#endif // SIOCGIFCONF +#ifndef FIONBIO +# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] +#endif // FIONBIO -# ifdef HAVE_SETRLIMIT -# include <sys/resource.h> -# endif -#endif +#ifdef HAVE_SETRLIMIT +# include <sys/resource.h> +#endif // HAVE_SETRLIMIT +#endif // WIN32 /** * Socket Interface Source @@ -82,7 +86,7 @@ struct socket_data **session; void send_shortlist_add_fd(int fd); // Do pending network sends (and eof handling) from the shortlist. void send_shortlist_do_sends(void); -#endif +#endif // SEND_SHORTLIST ///////////////////////////////////////////////////////////////////// #if defined(WIN32) @@ -212,7 +216,7 @@ char* sErr(int code) #define sFD_ZERO FD_ZERO ///////////////////////////////////////////////////////////////////// -#else +#else // defined(WIN32) ///////////////////////////////////////////////////////////////////// // nix portability layer @@ -244,29 +248,40 @@ char* sErr(int code) #define sFD_ZERO FD_ZERO ///////////////////////////////////////////////////////////////////// -#endif +#endif // defined(WIN32) ///////////////////////////////////////////////////////////////////// #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 -#endif +#endif // MSG_NOSIGNAL +#ifndef SOCKET_EPOLL +// Select based Event Dispatcher: fd_set readfds; +#else // SOCKET_EPOLL +// Epoll based Event Dispatcher: +static int epoll_maxevents = (FD_SETSIZE / 2); +static int epfd = SOCKET_ERROR; +static struct epoll_event epevent; +static struct epoll_event *epevents = NULL; + +#endif // SOCKET_EPOLL + // Maximum packet size in bytes, which the client is able to handle. // Larger packets cause a buffer overflow and stack corruption. #if PACKETVER >= 20131223 static size_t socket_max_client_packet = 0xFFFF; -#else +#else // PACKETVER >= 20131223 static size_t socket_max_client_packet = 0x6000; -#endif +#endif // PACKETVER >= 20131223 #ifdef SHOW_SERVER_STATS // Data I/O statistics static size_t socket_data_i = 0, socket_data_ci = 0, socket_data_qi = 0; static size_t socket_data_o = 0, socket_data_co = 0, socket_data_qo = 0; static time_t socket_data_last_tick = 0; -#endif +#endif // SHOW_SERVER_STATS // initial recv buffer size (this will also be the max. size) // biggest known packet: S 0153 <len>.w <emblem data>.?B -> 24x24 256 color .bmp (0153 + len.w + 1618/1654/1756 bytes) @@ -282,14 +297,14 @@ static time_t socket_data_last_tick = 0; int send_shortlist_array[FD_SETSIZE];// we only support FD_SETSIZE sockets, limit the array to that int send_shortlist_count = 0;// how many fd's are in the shortlist uint32 send_shortlist_set[(FD_SETSIZE+31)/32];// to know if specific fd's are already in the shortlist -#endif +#endif // SEND_SHORTLIST static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseFunc func_parse); #ifndef MINICORE int ip_rules = 1; static int connect_check(uint32 ip); -#endif +#endif // MINICORE const char* error_msg(void) { @@ -380,13 +395,13 @@ void setsocketopts(int fd, struct hSockOpt *opt) ShowWarning("setsocketopts: Unable to set SO_LINGER mode for connection #%d!\n", fd); #ifdef TCP_THIN_LINEAR_TIMEOUTS - if (sSetsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, (char *)&yes, sizeof(yes))) - ShowWarning("setsocketopts: Unable to set TCP_THIN_LINEAR_TIMEOUTS mode for connection #%d!\n", fd); -#endif + if (sSetsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, (char *)&yes, sizeof(yes))) + ShowWarning("setsocketopts: Unable to set TCP_THIN_LINEAR_TIMEOUTS mode for connection #%d!\n", fd); +#endif // TCP_THIN_LINEAR_TIMEOUTS #ifdef TCP_THIN_DUPACK - if (sSetsockopt(fd, IPPROTO_TCP, TCP_THIN_DUPACK, (char *)&yes, sizeof(yes))) - ShowWarning("setsocketopts: Unable to set TCP_THIN_DUPACK mode for connection #%d!\n", fd); -#endif + if (sSetsockopt(fd, IPPROTO_TCP, TCP_THIN_DUPACK, (char *)&yes, sizeof(yes))) + ShowWarning("setsocketopts: Unable to set TCP_THIN_DUPACK mode for connection #%d!\n", fd); +#endif // TCP_THIN_DUPACK } /*====================================== @@ -398,7 +413,7 @@ void set_eof(int fd) #ifdef SEND_SHORTLIST // Add this socket to the shortlist for eof handling. send_shortlist_add_fd(fd); -#endif +#endif // SEND_SHORTLIST sockt->session[fd]->flag.eof = 1; } } @@ -436,7 +451,7 @@ int recv_to_fifo(int fd) { socket_data_ci += len; } -#endif +#endif // SHOW_SERVER_STATS return 0; } @@ -453,12 +468,12 @@ int send_from_fifo(int fd) len = sSend(fd, (const char *) sockt->session[fd]->wdata, (int)sockt->session[fd]->wdata_size, MSG_NOSIGNAL); if( len == SOCKET_ERROR ) - {//An exception has occurred + { //An exception has occurred if( sErrno != S_EWOULDBLOCK ) { //ShowDebug("send_from_fifo: %s, ending connection #%d\n", error_msg(), fd); #ifdef SHOW_SERVER_STATS socket_data_qo -= sockt->session[fd]->wdata_size; -#endif +#endif // SHOW_SERVER_STATS sockt->session[fd]->wdata_size = 0; //Clear the send queue as we can't send anymore. [Skotlex] sockt->eof(fd); } @@ -480,7 +495,7 @@ int send_from_fifo(int fd) { socket_data_co += len; } -#endif +#endif // SHOW_SERVER_STATS } return 0; @@ -534,11 +549,27 @@ int connect_client(int listen_fd) { sockt->close(fd); return -1; } -#endif +#endif // MINICORE - if( sockt->fd_max <= fd ) sockt->fd_max = fd + 1; +#ifndef SOCKET_EPOLL + // Select Based Event Dispatcher sFD_SET(fd,&readfds); +#else // SOCKET_EPOLL + // Epoll based Event Dispatcher + epevent.data.fd = fd; + epevent.events = EPOLLIN; + + if(epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &epevent) == SOCKET_ERROR){ + ShowError("connect_client: New Socket #%d failed to add to epoll event dispatcher: %s\n", fd, error_msg()); + sClose(fd); + return -1; + } + +#endif // SOCKET_EPOLL + + if( sockt->fd_max <= fd ) sockt->fd_max = fd + 1; + create_session(fd, recv_to_fifo, send_from_fifo, default_func_parse); sockt->session[fd]->client_addr = ntohl(client_address.sin_addr.s_addr); @@ -586,8 +617,26 @@ int make_listen_bind(uint32 ip, uint16 port) exit(EXIT_FAILURE); } + +#ifndef SOCKET_EPOLL + // Select Based Event Dispatcher + sFD_SET(fd,&readfds); + +#else // SOCKET_EPOLL + // Epoll based Event Dispatcher + epevent.data.fd = fd; + epevent.events = EPOLLIN; + + if(epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &epevent) == SOCKET_ERROR){ + ShowError("make_listen_bind: failed to add listener socket #%d to epoll event dispatcher: %s\n", fd, error_msg()); + sClose(fd); + exit(EXIT_FAILURE); + } + +#endif // SOCKET_EPOLL + if(sockt->fd_max <= fd) sockt->fd_max = fd + 1; - sFD_SET(fd, &readfds); + create_session(fd, connect_client, null_send, null_parse); sockt->session[fd]->client_addr = 0; // just listens @@ -637,9 +686,26 @@ int make_connection(uint32 ip, uint16 port, struct hSockOpt *opt) { //Now the socket can be made non-blocking. [Skotlex] sockt->set_nonblocking(fd, 1); - if (sockt->fd_max <= fd) sockt->fd_max = fd + 1; + +#ifndef SOCKET_EPOLL + // Select Based Event Dispatcher sFD_SET(fd,&readfds); +#else // SOCKET_EPOLL + // Epoll based Event Dispatcher + epevent.data.fd = fd; + epevent.events = EPOLLIN; + + if(epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &epevent) == SOCKET_ERROR){ + ShowError("make_connection: failed to add socket #%d to epoll event dispatcher: %s\n", fd, error_msg()); + sClose(fd); + return -1; + } + +#endif // SOCKET_EPOLL + + if(sockt->fd_max <= fd) sockt->fd_max = fd + 1; + create_session(fd, recv_to_fifo, send_from_fifo, default_func_parse); sockt->session[fd]->client_addr = ntohl(remote_address.sin_addr.s_addr); @@ -668,7 +734,7 @@ static void delete_session(int fd) #ifdef SHOW_SERVER_STATS socket_data_qi -= sockt->session[fd]->rdata_size - sockt->session[fd]->rdata_pos; socket_data_qo -= sockt->session[fd]->wdata_size; -#endif +#endif // SHOW_SERVER_STATS aFree(sockt->session[fd]->rdata); aFree(sockt->session[fd]->wdata); if( sockt->session[fd]->session_data ) @@ -741,7 +807,7 @@ int rfifoskip(int fd, size_t len) s->rdata_pos = s->rdata_pos + len; #ifdef SHOW_SERVER_STATS socket_data_qi -= len; -#endif +#endif // SHOW_SERVER_STATS return 0; } @@ -792,7 +858,7 @@ int wfifoset(int fd, size_t len) s->wdata_size += len; #ifdef SHOW_SERVER_STATS socket_data_qo += len; -#endif +#endif // SHOW_SERVER_STATS //If the interserver has 200% of its normal size full, flush the data. if( s->flag.server && s->wdata_size >= 2*FIFOSIZE_SERVERLINK ) sockt->flush(fd); @@ -806,22 +872,24 @@ int wfifoset(int fd, size_t len) #ifdef SEND_SHORTLIST send_shortlist_add_fd(fd); -#endif +#endif // SEND_SHORTLIST return 0; } int do_sockets(int next) { +#ifndef SOCKET_EPOLL fd_set rfd; struct timeval timeout; +#endif // SOCKET_EPOLL int ret,i; // PRESEND Timers are executed before do_sendrecv and can send packets and/or set sessions to eof. // Send remaining data and process client-side disconnects here. #ifdef SEND_SHORTLIST send_shortlist_do_sends(); -#else +#else // SEND_SHORTLIST for (i = 1; i < sockt->fd_max; i++) { if(!sockt->session[fd] @@ -830,7 +898,10 @@ int do_sockets(int next) if(sockt->session[fd]>wdata_size) sockt->session[fd]>func_send(i); } -#endif +#endif // SEND_SHORTLIST + +#ifndef SOCKET_EPOLL + // Select based Event Dispatcher: // can timeout until the next tick timeout.tv_sec = next/1000; @@ -848,6 +919,20 @@ int do_sockets(int next) } return 0; // interrupted by a signal, just loop and try again } +#else // SOCKET_EPOLL + // Epoll based Event Dispatcher + + ret = epoll_wait(epfd, epevents, epoll_maxevents, next); + if(ret == SOCKET_ERROR) + { + if( sErrno != S_EINTR ) + { + ShowFatalError("do_sockets: epoll_wait() failed, %s!\n", error_msg()); + exit(EXIT_FAILURE); + } + return 0; // interrupted by a signal, just loop and try again + } +#endif // SOCKET_EPOLL sockt->last_tick = time(NULL); @@ -859,7 +944,33 @@ int do_sockets(int next) if( sockt->session[fd] ) sockt->session[fd]->func_recv(fd); } -#else +#elif defined(SOCKET_EPOLL) + // epoll based selection + + for( i = 0; i < ret; i++ ) + { + struct epoll_event *it = &epevents[i]; + struct socket_data *sock = sockt->session[ it->data.fd ]; + + if(!sock) + continue; + + if ((it->events & EPOLLERR) || + (it->events & EPOLLHUP) || + (!(it->events & EPOLLIN))) + { + // Got Error on this connection + sockt->eof( it->data.fd ); + + } else if (it->events & EPOLLIN) { + // data wainting + sock->func_recv( it->data.fd ); + + } + + } + +#else // defined(SOCKET_EPOLL) // otherwise assume that the fd_set is a bit-array and enumerate it in a standard way for( i = 1; ret && i < sockt->fd_max; ++i ) { @@ -869,12 +980,12 @@ int do_sockets(int next) --ret; } } -#endif +#endif // defined(SOCKET_EPOLL) // POSTSEND Send remaining data and handle eof sessions. #ifdef SEND_SHORTLIST send_shortlist_do_sends(); -#else +#else // SEND_SHORTLIST for (i = 1; i < sockt->fd_max; i++) { if(!sockt->session[i]) @@ -888,7 +999,7 @@ int do_sockets(int next) sockt->session[i]->func_parse(i); //This should close the session immediately. } } -#endif +#endif // SEND_SHORTLIST // parse input data on each socket for(i = 1; i < sockt->fd_max; i++) @@ -931,14 +1042,14 @@ int do_sockets(int next) sprintf(buf, "In: %.03f kB/s (%.03f kB/s, Q: %.03f kB) | Out: %.03f kB/s (%.03f kB/s, Q: %.03f kB) | RAM: %.03f MB", socket_data_i/1024., socket_data_ci/1024., socket_data_qi/1024., socket_data_o/1024., socket_data_co/1024., socket_data_qo/1024., iMalloc->usage()/1024.); #ifdef _WIN32 SetConsoleTitle(buf); -#else +#else // _WIN32 ShowMessage("\033[s\033[1;1H\033[2K%s\033[u", buf); -#endif +#endif // _WIN32 socket_data_last_tick = sockt->last_tick; socket_data_i = socket_data_ci = 0; socket_data_o = socket_data_co = 0; } -#endif +#endif // SHOW_SERVER_STATS return 0; } @@ -1160,7 +1271,7 @@ int access_ipmask(const char* str, AccessControl* acc) return 1; } ////////////////////////////// -#endif +#endif // MINICORE ////////////////////////////// int socket_config_read(const char* cfgName) @@ -1184,7 +1295,15 @@ int socket_config_read(const char* cfgName) sockt->stall_time = atoi(w2); if( sockt->stall_time < 3 ) sockt->stall_time = 3;/* a minimum is required to refrain it from killing itself */ + } +#ifdef SOCKET_EPOLL + else if(!strcmpi(w1, "epoll_maxevents")) { + epoll_maxevents = atoi(w2); + if(epoll_maxevents < 16){ + epoll_maxevents = 16; // minimum that seems to be useful + } } +#endif // SOCKET_EPOLL #ifndef MINICORE else if (!strcmpi(w1, "enable_ip_rules")) { ip_rules = config_switch(w2); @@ -1218,7 +1337,7 @@ int socket_config_read(const char* cfgName) access_debug = config_switch(w2); else if (!strcmpi(w1,"socket_max_client_packet")) socket_max_client_packet = strtoul(w2, NULL, 0); -#endif +#endif // MINICORE else if (!strcmpi(w1, "import")) socket_config_read(w2); else @@ -1239,7 +1358,7 @@ void socket_final(void) aFree(access_allow); if( access_deny ) aFree(access_deny); -#endif +#endif // MINICORE for( i = 1; i < sockt->fd_max; i++ ) if(sockt->session[i]) @@ -1255,6 +1374,18 @@ void socket_final(void) VECTOR_CLEAR(sockt->lan_subnets); VECTOR_CLEAR(sockt->allowed_ips); VECTOR_CLEAR(sockt->trusted_ips); + +#ifdef SOCKET_EPOLL + if(epfd != SOCKET_ERROR){ + close(epfd); + epfd = SOCKET_ERROR; + } + if(epevents != NULL){ + aFree(epevents); + epevents = NULL; + } +#endif // SOCKET_EPOLL + } /// Closes a socket. @@ -1264,7 +1395,17 @@ void socket_close(int fd) return;// invalid sockt->flush(fd); // Try to send what's left (although it might not succeed since it's a nonblocking socket) + +#ifndef SOCKET_EPOLL + // Select based Event Dispatcher sFD_CLR(fd, &readfds);// this needs to be done before closing the socket +#else // SOCKET_EPOLL + // Epoll based Event Dispatcher + epevent.data.fd = fd; + epevent.events = EPOLLIN; + epoll_ctl(epfd, EPOLL_CTL_DEL, fd, &epevent); // removing the socket from epoll when it's being closed is not required but recommended +#endif // SOCKET_EPOLL + sShutdown(fd, SHUT_RDWR); // Disallow further reads/writes sClose(fd); // We don't really care if these closing functions return an error, we are just shutting down and not reusing this socket. if (sockt->session[fd]) delete_session(fd); @@ -1401,20 +1542,39 @@ void socket_init(void) } } } -#endif +#endif // defined(HAVE_SETRLIMIT) && !defined(CYGWIN) // Get initial local ips sockt->naddr_ = sockt->getips(sockt->addr_,16); + socket_config_read(SOCKET_CONF_FILENAME); + +#ifndef SOCKET_EPOLL + // Select based Event Dispatcher: sFD_ZERO(&readfds); + ShowInfo("Server uses '" CL_WHITE "select" CL_RESET "' as event dispatcher\n"); + +#else // SOCKET_EPOLL + // Epoll based Event Dispatcher: + epfd = epoll_create(FD_SETSIZE); // 2.6.8 or newer ignores the expected socket amount argument + if(epfd == SOCKET_ERROR){ + ShowError("Failed to Create Epoll Event Dispatcher: %s\n", error_msg()); + exit(EXIT_FAILURE); + } + + memset(&epevent, 0x00, sizeof(struct epoll_event)); + epevents = aCalloc(epoll_maxevents, sizeof(struct epoll_event)); + + ShowInfo("Server uses '" CL_WHITE "epoll" CL_RESET "' with up to " CL_WHITE "%d" CL_RESET " events per cycle as event dispatcher\n", epoll_maxevents); + +#endif // SOCKET_EPOLL + #if defined(SEND_SHORTLIST) memset(send_shortlist_set, 0, sizeof(send_shortlist_set)); -#endif +#endif // defined(SEND_SHORTLIST) CREATE(sockt->session, struct socket_data *, FD_SETSIZE); - socket_config_read(SOCKET_CONF_FILENAME); - // initialize last send-receive tick sockt->last_tick = time(NULL); @@ -1427,7 +1587,7 @@ void socket_init(void) connect_history = uidb_alloc(DB_OPT_RELEASE_DATA); timer->add_func_list(connect_check_clear, "connect_check_clear"); timer->add_interval(timer->gettick()+1000, connect_check_clear, 0, 0, 5*60*1000); -#endif +#endif // MINICORE ShowInfo("Server supports up to '"CL_WHITE"%"PRIu64""CL_RESET"' concurrent connections.\n", rlim_cur); } @@ -1617,7 +1777,7 @@ void send_shortlist_do_sends(void) } } } -#endif +#endif // SEND_SHORTLIST /** * Checks whether the given IP comes from LAN or WAN. @@ -1752,10 +1912,12 @@ void socket_net_config_read(const char *filename) ShowError("No allowed server IP ranges configured. This server won't be able to accept connections from any char servers.\n"); } ARR_FIND(0, VECTOR_LENGTH(sockt->allowed_ips), i, SUBNET_MATCH(0, VECTOR_INDEX(sockt->allowed_ips, i).ip, VECTOR_INDEX(sockt->allowed_ips, i).mask)); +#ifndef BUILDBOT if (i != VECTOR_LENGTH(sockt->allowed_ips)) { ShowWarning("Using a wildcard IP range in the allowed server IPs is NOT RECOMMENDED.\n"); ShowNotice("Please edit your '%s' allowed list to fit your network configuration.\n", filename); } +#endif // BUILDBOT libconfig->destroy(&network_config); return; } diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 4d9c4c668..c04416285 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) rAthena Project (www.rathena.org) * * Hercules is free software: you can redistribute it and/or modify @@ -37,74 +37,75 @@ #endif #ifdef WIN32 - -typedef struct __declspec( align(64) ) SPIN_LOCK{ +struct __declspec(align(64)) spin_lock { volatile LONG lock; volatile LONG nest; volatile LONG sync_lock; -} SPIN_LOCK; +}; #else -typedef struct SPIN_LOCK{ - volatile int32 lock; - volatile int32 nest; // nesting level. - - volatile int32 sync_lock; -} __attribute__((aligned(64))) SPIN_LOCK; +struct spin_lock { + volatile int32 lock; + volatile int32 nest; // nesting level. + volatile int32 sync_lock; +} __attribute__((aligned(64))); #endif - #ifdef HERCULES_CORE -static forceinline void InitializeSpinLock(SPIN_LOCK *lck){ - lck->lock = 0; - lck->nest = 0; - lck->sync_lock = 0; +static forceinline void InitializeSpinLock(struct spin_lock *lck) +{ + lck->lock = 0; + lck->nest = 0; + lck->sync_lock = 0; } -static forceinline void FinalizeSpinLock(SPIN_LOCK *lck){ +static forceinline void FinalizeSpinLock(struct spin_lock *lck) +{ return; } -#define getsynclock(l) do { if(InterlockedCompareExchange((l), 1, 0) == 0) break; rathread_yield(); } while(/*always*/1) +#define getsynclock(l) do { if(InterlockedCompareExchange((l), 1, 0) == 0) break; thread->yield(); } while(/*always*/1) #define dropsynclock(l) do { InterlockedExchange((l), 0); } while(0) -static forceinline void EnterSpinLock(SPIN_LOCK *lck){ - int tid = rathread_get_tid(); +static forceinline void EnterSpinLock(struct spin_lock *lck) +{ + int tid = thread->get_tid(); - // Get Sync Lock && Check if the requester thread already owns the lock. - // if it owns, increase nesting level - getsynclock(&lck->sync_lock); - if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){ - InterlockedIncrement(&lck->nest); - dropsynclock(&lck->sync_lock); - return; // Got Lock - } - // drop sync lock + // Get Sync Lock && Check if the requester thread already owns the lock. + // if it owns, increase nesting level + getsynclock(&lck->sync_lock); + if (InterlockedCompareExchange(&lck->lock, tid, tid) == tid) { + InterlockedIncrement(&lck->nest); dropsynclock(&lck->sync_lock); - - // Spin until we've got it ! - while(1){ - if(InterlockedCompareExchange(&lck->lock, tid, 0) == 0){ - InterlockedIncrement(&lck->nest); - return; // Got Lock - } - rathread_yield(); // Force ctxswitch to another thread. + return; // Got Lock + } + // drop sync lock + dropsynclock(&lck->sync_lock); + + // Spin until we've got it ! + while (true) { + if (InterlockedCompareExchange(&lck->lock, tid, 0) == 0) { + InterlockedIncrement(&lck->nest); + return; // Got Lock } + thread->yield(); // Force ctxswitch to another thread. + } } -static forceinline void LeaveSpinLock(SPIN_LOCK *lck){ - int tid = rathread_get_tid(); +static forceinline void LeaveSpinLock(struct spin_lock *lck) +{ + int tid = thread->get_tid(); - getsynclock(&lck->sync_lock); + getsynclock(&lck->sync_lock); - if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){ // this thread owns the lock. - if(InterlockedDecrement(&lck->nest) == 0) - InterlockedExchange(&lck->lock, 0); // Unlock! - } + if (InterlockedCompareExchange(&lck->lock, tid, tid) == tid) { // this thread owns the lock. + if (InterlockedDecrement(&lck->nest) == 0) + InterlockedExchange(&lck->lock, 0); // Unlock! + } - dropsynclock(&lck->sync_lock); + dropsynclock(&lck->sync_lock); } #endif // HERCULES_CORE diff --git a/src/common/strlib.c b/src/common/strlib.c index 9690151b4..b67adb63c 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -772,6 +772,7 @@ size_t sv_escape_c(char* out_dest, const char* src, size_t len, const char* esca case '\v': out_dest[j++] = 'v'; break; case '\f': out_dest[j++] = 'f'; break; case '\?': out_dest[j++] = '?'; break; + case '\"': out_dest[j++] = '"'; break; default:// to octal out_dest[j++] = '0'+((char)(((unsigned char)src[i]&0700)>>6)); out_dest[j++] = '0'+((char)(((unsigned char)src[i]&0070)>>3)); diff --git a/src/common/thread.c b/src/common/thread.c index b724344e6..aaafab943 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) rAthena Project (www.rathena.org) * * Hercules is free software: you can redistribute it and/or modify @@ -20,10 +20,6 @@ */ #define HERCULES_CORE -// Basic Threading abstraction (for pthread / win32 based systems) -// -// Author: Florian Wilkemeyer <fw@f-ws.de> - #include "thread.h" #include "common/cbasetypes.h" @@ -48,13 +44,22 @@ #define HAS_TLS #endif -#define RA_THREADS_MAX 64 +/** @file + * Thread interface implementation. + * @author Florian Wilkemeyer <fw@f-ws.de> + */ + +struct thread_interface thread_s; +struct thread_interface *thread; -struct rAthread { +/// The maximum amount of threads. +#define THREADS_MAX 64 + +struct thread_handle { unsigned int myID; - RATHREAD_PRIO prio; - rAthreadProc proc; + enum thread_priority prio; + threadFunc proc; void *param; #ifdef WIN32 @@ -68,16 +73,17 @@ struct rAthread { __thread int g_rathread_ID = -1; #endif -/// -/// Subystem Code -/// -static struct rAthread l_threads[RA_THREADS_MAX]; +// Subystem Code + +static struct thread_handle l_threads[THREADS_MAX]; -void rathread_init(void) { - register unsigned int i; - memset(&l_threads, 0x00, RA_THREADS_MAX * sizeof(struct rAthread) ); +/// @copydoc thread_interface::init() +void thread_init(void) +{ + register int i; + memset(&l_threads, 0x00, THREADS_MAX * sizeof(struct thread_handle)); - for(i = 0; i < RA_THREADS_MAX; i++){ + for (i = 0; i < THREADS_MAX; i++) { l_threads[i].myID = i; } @@ -85,46 +91,53 @@ void rathread_init(void) { #ifdef HAS_TLS g_rathread_ID = 0; #endif - l_threads[0].prio = RAT_PRIO_NORMAL; - l_threads[0].proc = (rAthreadProc)0xDEADCAFE; + l_threads[0].prio = THREADPRIO_NORMAL; + l_threads[0].proc = (threadFunc)0xDEADCAFE; -}//end: rathread_init() +} -void rathread_final(void) { - register unsigned int i; +/// @copydoc thread_interface::final() +void thread_final(void) +{ + register int i; // Unterminated Threads Left? - // Shouldn't happen .. - // Kill 'em all! - // - for(i = 1; i < RA_THREADS_MAX; i++){ - if(l_threads[i].proc != NULL){ - ShowWarning("rAthread_final: unterminated Thread (tid %u entryPoint %p) - forcing to terminate (kill)\n", i, l_threads[i].proc); - rathread_destroy(&l_threads[i]); + // Shouldn't happen ... Kill 'em all! + for (i = 1; i < THREADS_MAX; i++) { + if (l_threads[i].proc != NULL){ + ShowWarning("thread_final: unterminated Thread (tid %d entry_point %p) - forcing to terminate (kill)\n", i, l_threads[i].proc); + thread->destroy(&l_threads[i]); } } +} -}//end: rathread_final() - -// gets called whenever a thread terminated .. -static void rat_thread_terminated(rAthread *handle) { +/** + * Gets called whenever a thread terminated. + * + * @param handle The terminated thread's handle. + */ +static void thread_terminated(struct thread_handle *handle) +{ // Preserve handle->myID and handle->hThread, set everything else to its default value handle->param = NULL; handle->proc = NULL; - handle->prio = RAT_PRIO_NORMAL; -}//end: rat_thread_terminated() + handle->prio = THREADPRIO_NORMAL; +} #ifdef WIN32 -DWORD WINAPI raThreadMainRedirector(LPVOID p){ +DWORD WINAPI thread_main_redirector(LPVOID p) +{ #else -static void *raThreadMainRedirector( void *p ){ +static void *thread_main_redirector(void *p) +{ sigset_t set; // on Posix Thread platforms #endif void *ret; + struct thread_handle *self = p; // Update myID @ TLS to right id. #ifdef HAS_TLS - g_rathread_ID = ((rAthread*)p)->myID; + g_rathread_ID = self->myID; #endif #ifndef WIN32 @@ -138,66 +151,68 @@ static void *raThreadMainRedirector( void *p ){ (void)sigaddset(&set, SIGPIPE); pthread_sigmask(SIG_BLOCK, &set, NULL); - #endif - ret = ((rAthread*)p)->proc( ((rAthread*)p)->param ) ; + ret = self->proc(self->param); #ifdef WIN32 - CloseHandle( ((rAthread*)p)->hThread ); + CloseHandle(self->hThread); #endif - rat_thread_terminated( (rAthread*)p ); + thread_terminated(self); #ifdef WIN32 return (DWORD)ret; #else return ret; #endif -}//end: raThreadMainRedirector() +} + +// API Level -/// -/// API Level -/// -rAthread *rathread_create(rAthreadProc entryPoint, void *param) { - return rathread_createEx( entryPoint, param, (1<<23) /*8MB*/, RAT_PRIO_NORMAL ); -}//end: rathread_create() +/// @copydoc thread_interface::create() +struct thread_handle *thread_create(threadFunc entry_point, void *param) +{ + return thread->create_opt(entry_point, param, (1<<23) /*8MB*/, THREADPRIO_NORMAL); +} -rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio) { +/// @copydoc thread_interface::create_opt() +struct thread_handle *thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) +{ #ifndef WIN32 pthread_attr_t attr; #endif size_t tmp; - unsigned int i; - rAthread *handle = NULL; + int i; + struct thread_handle *handle = NULL; // given stacksize aligned to systems pagesize? - tmp = szStack % sysinfo->getpagesize(); - if(tmp != 0) - szStack += tmp; + tmp = stack_size % sysinfo->getpagesize(); + if (tmp != 0) + stack_size += tmp; // Get a free Thread Slot. - for(i = 0; i < RA_THREADS_MAX; i++){ + for (i = 0; i < THREADS_MAX; i++) { if(l_threads[i].proc == NULL){ handle = &l_threads[i]; break; } } - if(handle == NULL){ - ShowError("rAthread: cannot create new thread (entryPoint: %p) - no free thread slot found!", entryPoint); + if (handle == NULL) { + ShowError("thread_create_opt: cannot create new thread (entry_point: %p) - no free thread slot found!", entry_point); return NULL; } - handle->proc = entryPoint; + handle->proc = entry_point; handle->param = param; #ifdef WIN32 - handle->hThread = CreateThread(NULL, szStack, raThreadMainRedirector, (void*)handle, 0, NULL); + handle->hThread = CreateThread(NULL, stack_size, thread_main_redirector, handle, 0, NULL); #else pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, szStack); + pthread_attr_setstacksize(&attr, stack_size); - if(pthread_create(&handle->hThread, &attr, raThreadMainRedirector, (void*)handle) != 0){ + if (pthread_create(&handle->hThread, &attr, thread_main_redirector, handle) != 0) { handle->proc = NULL; handle->param = NULL; return NULL; @@ -205,99 +220,122 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack pthread_attr_destroy(&attr); #endif - rathread_prio_set( handle, prio ); + thread->prio_set(handle, prio); return handle; -}//end: rathread_createEx +} -void rathread_destroy(rAthread *handle) { +/// @copydoc thread_interface::destroy() +void thread_destroy(struct thread_handle *handle) +{ #ifdef WIN32 - if( TerminateThread(handle->hThread, 0) != FALSE){ + if (TerminateThread(handle->hThread, 0) != FALSE) { CloseHandle(handle->hThread); - rat_thread_terminated(handle); + thread_terminated(handle); } #else - if( pthread_cancel( handle->hThread ) == 0){ + if (pthread_cancel(handle->hThread) == 0) { // We have to join it, otherwise pthread wont re-cycle its internal resources assoc. with this thread. - pthread_join( handle->hThread, NULL ); + pthread_join(handle->hThread, NULL); // Tell our manager to release resources ;) - rat_thread_terminated(handle); + thread_terminated(handle); } #endif -}//end: rathread_destroy() +} -rAthread *rathread_self(void) { +struct thread_handle *thread_self(void) +{ #ifdef HAS_TLS - rAthread *handle = &l_threads[g_rathread_ID]; + struct thread_handle *handle = &l_threads[g_rathread_ID]; - if(handle->proc != NULL) // entry point set, so its used! + if (handle->proc != NULL) // entry point set, so its used! return handle; #else // .. so no tls means we have to search the thread by its api-handle .. int i; - #ifdef WIN32 - HANDLE hSelf; - hSelf = GetCurrent = GetCurrentThread(); - #else - pthread_t hSelf; - hSelf = pthread_self(); - #endif +#ifdef WIN32 + HANDLE hSelf; + hSelf = GetCurrent = GetCurrentThread(); +#else + pthread_t hSelf; + hSelf = pthread_self(); +#endif - for(i = 0; i < RA_THREADS_MAX; i++){ - if(l_threads[i].hThread == hSelf && l_threads[i].proc != NULL) + for (i = 0; i < THREADS_MAX; i++) { + if (l_threads[i].hThread == hSelf && l_threads[i].proc != NULL) return &l_threads[i]; } #endif return NULL; -}//end: rathread_self() +} -int rathread_get_tid(void) { - -#ifdef HAS_TLS +/// @copydoc thread_interface::get_tid() +int thread_get_tid(void) +{ +#if defined(HAS_TLS) return g_rathread_ID; +#elif defined(WIN32) + return (int)GetCurrentThreadId(); #else - // TODO - #ifdef WIN32 - return (int)GetCurrentThreadId(); - #else - return (int)pthread_self(); - #endif + return (int)pthread_self(); #endif +} -}//end: rathread_get_tid() - -bool rathread_wait(rAthread *handle, void **out_exitCode) { +/// @copydoc thread_interface::wait() +bool thread_wait(struct thread_handle *handle, void **out_exit_code) +{ // Hint: // no thread data cleanup routine call here! // its managed by the callProxy itself.. - // #ifdef WIN32 WaitForSingleObject(handle->hThread, INFINITE); return true; #else - if(pthread_join(handle->hThread, out_exitCode) == 0) + if (pthread_join(handle->hThread, out_exit_code) == 0) return true; return false; #endif -}//end: rathread_wait() +} -void rathread_prio_set(rAthread *handle, RATHREAD_PRIO prio) { - handle->prio = RAT_PRIO_NORMAL; +/// @copydoc thread_interface::prio_set() +void thread_prio_set(struct thread_handle *handle, enum thread_priority prio) +{ + handle->prio = THREADPRIO_NORMAL; //@TODO -}//end: rathread_prio_set() +} -RATHREAD_PRIO rathread_prio_get(rAthread *handle) { +/// @copydoc thread_interface::prio_get() +enum thread_priority thread_prio_get(struct thread_handle *handle) +{ return handle->prio; -}//end: rathread_prio_get() +} -void rathread_yield(void) { +/// @copydoc thread_interface::yield() +void thread_yield(void) { #ifdef WIN32 SwitchToThread(); #else sched_yield(); #endif -}//end: rathread_yield() +} + +/// Interface base initialization. +void thread_defaults(void) +{ + thread = &thread_s; + thread->init = thread_init; + thread->final = thread_final; + thread->create = thread_create; + thread->create_opt = thread_create_opt; + thread->destroy = thread_destroy; + thread->self = thread_self; + thread->get_tid = thread_get_tid; + thread->wait = thread_wait; + thread->prio_set = thread_prio_set; + thread->prio_get = thread_prio_get; + thread->yield = thread_yield; +} diff --git a/src/common/thread.h b/src/common/thread.h index 261735306..c668afbb4 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) rAthena Project (www.rathena.org) * * Hercules is free software: you can redistribute it and/or modify @@ -21,114 +21,136 @@ #ifndef COMMON_THREAD_H #define COMMON_THREAD_H -#include "common/cbasetypes.h" +#include "common/hercules.h" -typedef struct rAthread rAthread; -typedef void* (*rAthreadProc)(void*); - -typedef enum RATHREAD_PRIO { - RAT_PRIO_LOW = 0, - RAT_PRIO_NORMAL, - RAT_PRIO_HIGH -} RATHREAD_PRIO; - - -#ifdef HERCULES_CORE -/** - * Creates a new Thread - * - * @param entyPoint - entryProc, - * @param param - general purpose parameter, would be given as parameter to the thread's entry point. - * - * @return not NULL if success +/** @file + * Basic Threading abstraction (for pthread / win32 based systems). */ -rAthread *rathread_create(rAthreadProc entryPoint, void *param); +/* Opaque Types */ +struct thread_handle; ///< Thread handle. +typedef void *(*threadFunc)(void *); ///< Thread entry point function. + +/* Enums */ + +/// Thread priority +enum thread_priority { + THREADPRIO_LOW = 0, + THREADPRIO_NORMAL, + THREADPRIO_HIGH +}; + +/// The thread interface +struct thread_interface { + /// Interface initialization. + void (*init) (void); + + /// Interface finalization. + void (*final) (void); + + /** + * Creates a new Thread. + * + * @param enty_point Thread's entry point. + * @param param General purpose parameter, would be given as + * parameter to the thread's entry point. + * + * @return The created thread object. + * @retval NULL in vase of failure. + */ + struct thread_handle *(*create) (threadFunc entry_point, void *param); + + /** + * Creates a new Thread (with more creation options). + * + * @param enty_point Thread's entry point. + * @param param General purpose parameter, would be given as + * parameter to the thread's entry point. + * @param stack_size Stack Size in bytes. + * @param prio Priority of the Thread in the OS scheduler. + * + * @return The created thread object. + * @retval NULL in case of failure. + */ + struct thread_handle *(*create_opt) (threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); + + /** + * Destroys the given Thread immediately. + * + * @remark + * The Handle gets invalid after call! don't use it afterwards. + * + * @param handle The thread to destroy. + */ + void (*destroy) (struct thread_handle *handle); + + /** + * Returns the thread handle of the thread calling this function. + * + * @remark + * This won't work in the program's main thread. + * + * @warning + * The underlying implementation might not perform very well, cache + * the value received! + * + * @return the thread handle. + * @retval NULL in case of failure. + */ + struct thread_handle *(*self) (void); + + /** + * Returns own thread id (TID). + * + * @remark + * This is an unique identifier for the calling thread, and depends + * on platform/ compiler, and may not be the systems Thread ID! + * + * @return the thread ID. + * @retval -1 in case of failure. + */ + int (*get_tid) (void); + + /** + * Waits for the given thread to terminate. + * + * @param[in] handle The thread to wait (join) for. + * @param[out] out_exit_code Pointer to return the exit code of the + * given thread after termination (optional). + * + * @retval true if the given thread has been terminated. + */ + bool (*wait) (struct thread_handle *handle, void **out_exit_code); + + /** + * Sets the given priority in the OS scheduler. + * + * @param handle The thread to set the priority for. + * @param prio The priority to set (@see enum thread_priority). + */ + void (*prio_set) (struct thread_handle *handle, enum thread_priority prio); + + /** + * Gets the current priority of the given thread. + * + * @param handle The thread to get the priority for. + */ + enum thread_priority (*prio_get) (struct thread_handle *handle); + + /** + * Tells the OS scheduler to yield the execution of the calling thread. + * + * @remark + * This will not "pause" the thread, it just allows the OS to spend + * the remaining time of the slice to another thread. + */ + void (*yield) (void); +}; -/** - * Creates a new Thread (with more creation options) - * - * @param entyPoint - entryProc, - * @param param - general purpose parameter, would be given as parameter to the thread's entry point - * @param szStack - stack Size in bytes - * @param prio - Priority of the Thread @ OS Scheduler.. - * - * @return not NULL if success - */ -rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio); - - -/** - * Destroys the given Thread immediately - * - * @note The Handle gets invalid after call! don't use it afterwards. - * - * @param handle - thread to destroy. - */ -void rathread_destroy(rAthread *handle); - - -/** - * Returns the thread handle of the thread calling this function - * - * @note this wont work @ programs main thread - * @note the underlying implementation might not perform very well, cache the value received! - * - * @return not NULL if success - */ -rAthread *rathread_self(void); - - -/** - * Returns own thread id (TID) - * - * @note this is an unique identifier for the calling thread, and - * depends on platform/ compiler, and may not be the systems Thread ID! - * - * @return -1 when fails, otherwise >= 0 - */ -int rathread_get_tid(void); - - -/** - * Waits for the given thread to terminate - * - * @param handle - thread to wait (join) for - * @param out_Exitcode - [OPTIONAL] - if given => Exitcode (value) of the given thread - if it's terminated - * - * @return true - if the given thread has been terminated. - */ -bool rathread_wait(rAthread *handle, void **out_exitCode); - - -/** - * Sets the given PRIORITY @ OS Task Scheduler - * - * @param handle - thread to set prio for - * @param rio - the priority (RAT_PRIO_LOW ... ) - */ -void rathread_prio_set(rAthread *handle, RATHREAD_PRIO prio); - - -/** - * Gets the current Prio of the given thread - * - * @param handle - the thread to get the prio for. - */ -RATHREAD_PRIO rathread_prio_get(rAthread *handle); - - -/** - * Tells the OS scheduler to yield the execution of the calling thread - * - * @note: this will not "pause" the thread, - * it just allows the OS to spend the remaining time - * of the slice to another thread. - */ -void rathread_yield(void); - -void rathread_init(void); -void rathread_final(void); +#ifdef HERCULES_CORE +void thread_defaults(void); #endif // HERCULES_CORE +HPShared struct thread_interface *thread; ///< Pointer to the thread interface. + #endif /* COMMON_THREAD_H */ diff --git a/src/config/core.h b/src/config/core.h index 09954e0cb..afd138a43 100644 --- a/src/config/core.h +++ b/src/config/core.h @@ -40,6 +40,17 @@ /// your map-server using more resources while this is active, comment the line #define SCRIPT_CALLFUNC_CHECK +/** + * Strip linebreaks from `mes` dialogs. + * + * Leave this line commented out to keep the hard line-breaks (`\r`) in the + * displayed `mes` dialogs (as in official servers). + * Uncomment it to strip the line-breaks and replace them with spaces, letting + * the client automatically wrap text in dialogs, depending on font size and + * dialog window size (may work better for clients using a non-standard font). + */ +//#define SCRIPT_MES_STRIP_LINEBREAK + /// Comment to disable Hercules' console_parse /// CONSOLE_INPUT allows you to type commands into the server's console, /// Disabling it saves one thread. diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c index 472cba3c9..b35ac13cb 100644 --- a/src/login/HPMlogin.c +++ b/src/login/HPMlogin.c @@ -35,9 +35,12 @@ #include "common/db.h" #include "common/des.h" #include "common/ers.h" +#include "common/md5calc.h" #include "common/memmgr.h" +#include "common/mutex.h" #include "common/mmo.h" #include "common/nullpo.h" +#include "common/random.h" #include "common/showmsg.h" #include "common/socket.h" #include "common/spinlock.h" diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 195a10233..2e128e8bf 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -606,9 +606,9 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc SQL->GetData(sql_handle, 7, &data, NULL); acc->unban_time = atol(data); SQL->GetData(sql_handle, 8, &data, NULL); acc->expiration_time = atol(data); SQL->GetData(sql_handle, 9, &data, NULL); acc->logincount = (unsigned int)strtoul(data, NULL, 10); - SQL->GetData(sql_handle, 10, &data, NULL); safestrncpy(acc->lastlogin, data, sizeof(acc->lastlogin)); + SQL->GetData(sql_handle, 10, &data, NULL); safestrncpy(acc->lastlogin, data != NULL ? data : "(never)", sizeof(acc->lastlogin)); SQL->GetData(sql_handle, 11, &data, NULL); safestrncpy(acc->last_ip, data, sizeof(acc->last_ip)); - SQL->GetData(sql_handle, 12, &data, NULL); safestrncpy(acc->birthdate, data, sizeof(acc->birthdate)); + SQL->GetData(sql_handle, 12, &data, NULL); safestrncpy(acc->birthdate, data != NULL ? data : "0000-00-00", sizeof(acc->birthdate)); SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data); SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode)); SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data); @@ -654,9 +654,15 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo || SQL_SUCCESS != SQL->StmtBindParam(stmt, 7, SQLDT_LONG, &acc->unban_time, sizeof(acc->unban_time)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 8, SQLDT_INT, &acc->expiration_time, sizeof(acc->expiration_time)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 9, SQLDT_UINT, &acc->logincount, sizeof(acc->logincount)) - || SQL_SUCCESS != SQL->StmtBindParam(stmt, 10, SQLDT_STRING, &acc->lastlogin, strlen(acc->lastlogin)) + || SQL_SUCCESS != (acc->lastlogin[0] < '1' || acc->lastlogin[0] > '9' ? + SQL->StmtBindParam(stmt, 10, SQLDT_NULL, NULL, 0) : + SQL->StmtBindParam(stmt, 10, SQLDT_STRING, &acc->lastlogin, strlen(acc->lastlogin)) + ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 11, SQLDT_STRING, &acc->last_ip, strlen(acc->last_ip)) - || SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_STRING, &acc->birthdate, strlen(acc->birthdate)) + || SQL_SUCCESS != (acc->birthdate[0] == '0' ? + SQL->StmtBindParam(stmt, 12, SQLDT_NULL, NULL, 0) : + SQL->StmtBindParam(stmt, 12, SQLDT_STRING, &acc->birthdate, strlen(acc->birthdate)) + ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_UCHAR, &acc->char_slots, sizeof(acc->char_slots)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_STRING, &acc->pincode, strlen(acc->pincode)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_LONG, &acc->pincode_change, sizeof(acc->pincode_change)) @@ -676,9 +682,15 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo || SQL_SUCCESS != SQL->StmtBindParam(stmt, 6, SQLDT_LONG, &acc->unban_time, sizeof(acc->unban_time)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 7, SQLDT_LONG, &acc->expiration_time, sizeof(acc->expiration_time)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 8, SQLDT_UINT, &acc->logincount, sizeof(acc->logincount)) - || SQL_SUCCESS != SQL->StmtBindParam(stmt, 9, SQLDT_STRING, &acc->lastlogin, strlen(acc->lastlogin)) + || SQL_SUCCESS != (acc->lastlogin[0] < '1' || acc->lastlogin[0] > '9' ? + SQL->StmtBindParam(stmt, 9, SQLDT_NULL, NULL, 0) : + SQL->StmtBindParam(stmt, 9, SQLDT_STRING, &acc->lastlogin, strlen(acc->lastlogin)) + ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 10, SQLDT_STRING, &acc->last_ip, strlen(acc->last_ip)) - || SQL_SUCCESS != SQL->StmtBindParam(stmt, 11, SQLDT_STRING, &acc->birthdate, strlen(acc->birthdate)) + || SQL_SUCCESS != (acc->birthdate[0] == '0' ? + SQL->StmtBindParam(stmt, 11, SQLDT_NULL, NULL, 0) : + SQL->StmtBindParam(stmt, 11, SQLDT_STRING, &acc->birthdate, strlen(acc->birthdate)) + ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_UCHAR, &acc->char_slots, sizeof(acc->char_slots)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_STRING, &acc->pincode, strlen(acc->pincode)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_LONG, &acc->pincode_change, sizeof(acc->pincode_change)) diff --git a/src/login/lclif.c b/src/login/lclif.c index 9515c5940..3ed257e85 100644 --- a/src/login/lclif.c +++ b/src/login/lclif.c @@ -86,7 +86,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) safestrncpy(sd->passwd, packet->password, PASSWD_LEN); if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); + md5->string(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; login->client_login(fd, sd); @@ -160,7 +160,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_da safestrncpy(sd->passwd, packet->password, PASSWD_LEN); if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); + md5->string(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; login->client_login(fd, sd); @@ -183,7 +183,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data safestrncpy(sd->passwd, packet->password, PASSWD_LEN); if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); + md5->string(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; login->client_login(fd, sd); @@ -209,7 +209,7 @@ enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_d safestrncpy(sd->passwd, packet->t1, min(tokenlen + 1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); + md5->string(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; login->client_login(fd, sd); @@ -222,7 +222,7 @@ enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data * { memset(sd->md5key, '\0', sizeof(sd->md5key)); sd->md5keylen = (uint16)(12 + rnd() % 4); - MD5_Salt(sd->md5keylen, sd->md5key); + md5->salt(sd->md5keylen, sd->md5key); lclif->coding_key(fd, sd); return PACKET_VALID; diff --git a/src/login/login.c b/src/login/login.c index d7c7321d8..7f5f78a4d 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -239,7 +239,7 @@ bool login_check_encrypted(const char* str1, const char* str2, const char* passw nullpo_ret(str2); nullpo_ret(passwd); safesnprintf(tmpstr, sizeof(tmpstr), "%s%s", str1, str2); - MD5_String(tmpstr, md5str); + md5->string(tmpstr, md5str); return (0==strcmp(passwd, md5str)); } @@ -1024,7 +1024,7 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con acc.sex = sex; safestrncpy(acc.email, "a@a.com", sizeof(acc.email)); acc.expiration_time = (login->config->start_limited_time != -1) ? time(NULL) + login->config->start_limited_time : 0; - safestrncpy(acc.lastlogin, "0000-00-00 00:00:00", sizeof(acc.lastlogin)); + safestrncpy(acc.lastlogin, "(never)", sizeof(acc.lastlogin)); safestrncpy(acc.last_ip, last_ip, sizeof(acc.last_ip)); safestrncpy(acc.birthdate, "0000-00-00", sizeof(acc.birthdate)); safestrncpy(acc.pincode, "\0", sizeof(acc.pincode)); @@ -1378,7 +1378,7 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const safestrncpy(sd->userid, RFIFOP(fd,2), NAME_LENGTH); safestrncpy(sd->passwd, RFIFOP(fd,26), NAME_LENGTH); if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); + md5->string(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; sd->version = login->config->client_version_to_connect; // hack to skip version check server_ip = ntohl(RFIFOL(fd,54)); @@ -1529,14 +1529,14 @@ int login_config_read(const char *cfgName) login->config->client_hash_check = config_switch(w2); else if(!strcmpi(w1, "client_hash")) { int group = 0; - char md5[33]; - memset(md5, '\0', 33); + char md5hash[33]; + memset(md5hash, '\0', 33); - if (sscanf(w2, "%d, %32s", &group, md5) == 2) { + if (sscanf(w2, "%d, %32s", &group, md5hash) == 2) { struct client_hash_node *nnode; CREATE(nnode, struct client_hash_node, 1); - if (strcmpi(md5, "disabled") == 0) { + if (strcmpi(md5hash, "disabled") == 0) { nnode->hash[0] = '\0'; } else { int i; @@ -1544,7 +1544,7 @@ int login_config_read(const char *cfgName) char buf[3]; unsigned int byte; - memcpy(buf, &md5[i], 2); + memcpy(buf, &md5hash[i], 2); buf[2] = 0; sscanf(buf, "%x", &byte); @@ -1671,6 +1671,19 @@ static CMDLINEARG(loginconfig) login->LOGIN_CONF_NAME = aStrdup(params); return true; } + +/** + * --run-once handler + * + * Causes the server to run its loop once, and shutdown. Useful for testing. + * @see cmdline->exec + */ +static CMDLINEARG(runonce) +{ + core->runflag = CORE_ST_STOP; + return true; +} + /** * --net-config handler * @@ -1688,6 +1701,7 @@ static CMDLINEARG(netconfig) */ void cmdline_args_init_local(void) { + CMDLINEARG_DEF2(run-once, runonce, "Closes server after loading (testing).", CMDLINE_OPT_NORMAL); CMDLINEARG_DEF2(login-config, loginconfig, "Alternative login-server configuration.", CMDLINE_OPT_PARAM); CMDLINEARG_DEF2(net-config, netconfig, "Alternative subnet configuration.", CMDLINE_OPT_PARAM); } diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 289375323..84544976a 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -31,10 +31,14 @@ #include "common/db.h" #include "common/des.h" #include "common/ers.h" +#include "common/grfio.h" +#include "common/md5calc.h" #include "common/memmgr.h" +#include "common/mutex.h" #include "common/mapindex.h" #include "common/mmo.h" #include "common/nullpo.h" +#include "common/random.h" #include "common/showmsg.h" #include "common/socket.h" #include "common/spinlock.h" diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 841cf855d..5b337e759 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -132,7 +132,6 @@ bool msg_config_read(const char *cfg_name, bool allow_override) { int msg_number; char line[1024], w1[1024], w2[1024]; FILE *fp; - static int called = 1; nullpo_retr(false, cfg_name); if ((fp = fopen(cfg_name, "r")) == NULL) { @@ -170,21 +169,6 @@ bool msg_config_read(const char *cfg_name, bool allow_override) { } fclose(fp); - if( ++called == 1 ) { //Original - if( script->lang_export_fp ) { - int i; - for(i = 0; i < MAX_MSG;i++) { - if( atcommand->msg_table[0][i] != NULL ) { - fprintf(script->lang_export_fp, "msgctxt \"messages.conf\"\n" - "msgid \"%s\"\n" - "msgstr \"\"\n", - atcommand->msg_table[0][i] - ); - } - } - } - } - return true; } @@ -266,22 +250,22 @@ ACMD(send) clif->message(fd, atcmd_output); return false; } - + if (len) { // show packet length safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, clif->packet(type)->len); // Packet 0x%x length: %d clif->message(fd, atcmd_output); return true; } - + len = clif->packet(type)->len; - + if (len == -1) { // dynamic packet len = SHRT_MAX-4; // maximum length off = 4; } - + WFIFOHEAD(sd->fd, len); WFIFOW(sd->fd,0)=TOW(type); @@ -482,11 +466,11 @@ ACMD(mapmove) { x = y = 0; //Invalid cell, use random spot. } if (map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { - clif->message(fd, msg_fd(fd,247)); + clif->message(fd, msg_fd(fd,247)); // You are not authorized to warp to this map. return false; } if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { - clif->message(fd, msg_fd(fd,248)); + clif->message(fd, msg_fd(fd,248)); // You are not authorized to warp from your current map. return false; } if (pc->setpos(sd, map_index, x, y, CLR_TELEPORT) != 0) { @@ -870,7 +854,7 @@ ACMD(storage) return false; if (storage->open(sd) == 1) { //Already open. - clif->message(fd, msg_fd(fd,250)); + clif->message(fd, msg_fd(fd,250)); // You have already opened your storage. Close it first. return false; } @@ -885,7 +869,7 @@ ACMD(storage) ACMD(guildstorage) { if (!sd->status.guild_id) { - clif->message(fd, msg_fd(fd,252)); + clif->message(fd, msg_fd(fd,252)); // You are not in a guild. return false; } @@ -893,12 +877,12 @@ ACMD(guildstorage) return false; if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) { - clif->message(fd, msg_fd(fd,250)); + clif->message(fd, msg_fd(fd,250)); // You have already opened your storage. Close it first. return false; } if (sd->state.storage_flag == STORAGE_FLAG_GUILD) { - clif->message(fd, msg_fd(fd,251)); + clif->message(fd, msg_fd(fd,251)); // You have already opened your guild storage. Close it first. return false; } @@ -1384,13 +1368,13 @@ ACMD(baselevelup) clif->message(fd, msg_fd(fd,47)); // Base level can't go any higher. return false; } // End Addition - if ((unsigned int)level > pc->maxbaselv(sd) || (unsigned int)level > pc->maxbaselv(sd) - sd->status.base_level) // fix positive overflow + if (level > pc->maxbaselv(sd) || level > pc->maxbaselv(sd) - sd->status.base_level) // fix positive overflow level = pc->maxbaselv(sd) - sd->status.base_level; for (i = 0; i < level; i++) status_point += pc->gets_status_point(sd->status.base_level + i); sd->status.status_point += status_point; - sd->status.base_level += (unsigned int)level; + sd->status.base_level += level; status_calc_pc(sd, SCO_FORCE); status_percent_heal(&sd->bl, 100, 100); clif->misceffect(&sd->bl, 0); @@ -1401,7 +1385,7 @@ ACMD(baselevelup) return false; } level*=-1; - if ((unsigned int)level >= sd->status.base_level) + if (level >= sd->status.base_level) level = sd->status.base_level-1; for (i = 0; i > -level; i--) status_point += pc->gets_status_point(sd->status.base_level + i - 1); @@ -1411,7 +1395,7 @@ ACMD(baselevelup) sd->status.status_point = 0; else sd->status.status_point -= status_point; - sd->status.base_level -= (unsigned int)level; + sd->status.base_level -= level; clif->message(fd, msg_fd(fd,22)); // Base level lowered. status_calc_pc(sd, SCO_FORCE); } @@ -1442,9 +1426,9 @@ ACMD(joblevelup) clif->message(fd, msg_fd(fd,23)); // Job level can't go any higher. return false; } - if ((unsigned int)level > pc->maxjoblv(sd) || (unsigned int)level > pc->maxjoblv(sd) - sd->status.job_level) // fix positive overflow + if (level > pc->maxjoblv(sd) || level > pc->maxjoblv(sd) - sd->status.job_level) // fix positive overflow level = pc->maxjoblv(sd) - sd->status.job_level; - sd->status.job_level += (unsigned int)level; + sd->status.job_level += level; sd->status.skill_point += level; clif->misceffect(&sd->bl, 1); clif->message(fd, msg_fd(fd,24)); // Job level raised. @@ -1454,9 +1438,9 @@ ACMD(joblevelup) return false; } level *=-1; - if ((unsigned int)level >= sd->status.job_level) // fix negative overflow + if (level >= sd->status.job_level) // fix negative overflow level = sd->status.job_level-1; - sd->status.job_level -= (unsigned int)level; + sd->status.job_level -= level; if (sd->status.skill_point < level) pc->resetskill(sd, PCRESETSKILL_NONE); //Reset skills since we need to subtract more points. if (sd->status.skill_point < level) @@ -2312,30 +2296,18 @@ ACMD(displaystatus) ACMD(statuspoint) { int point; - unsigned int new_status_point; + int new_status_point; if (!*message || (point = atoi(message)) == 0) { clif->message(fd, msg_fd(fd,1010)); // Please enter a number (usage: @stpoint <number of points>). return false; } - if(point < 0) - { - if(sd->status.status_point < (unsigned int)(-point)) - { - new_status_point = 0; - } - else - { - new_status_point = sd->status.status_point + point; - } - } - else if(UINT_MAX - sd->status.status_point < (unsigned int)point) - { - new_status_point = UINT_MAX; - } - else - { + if (point < 0 && sd->status.status_point + point < 0) { + new_status_point = 0; + } else if (point > 0 && (int64)sd->status.status_point + point > INT_MAX) { + new_status_point = INT_MAX; + } else { new_status_point = sd->status.status_point + point; } @@ -2360,30 +2332,18 @@ ACMD(statuspoint) ACMD(skillpoint) { int point; - unsigned int new_skill_point; + int new_skill_point; if (!*message || (point = atoi(message)) == 0) { clif->message(fd, msg_fd(fd,1011)); // Please enter a number (usage: @skpoint <number of points>). return false; } - if(point < 0) - { - if(sd->status.skill_point < (unsigned int)(-point)) - { - new_skill_point = 0; - } - else - { - new_skill_point = sd->status.skill_point + point; - } - } - else if(UINT_MAX - sd->status.skill_point < (unsigned int)point) - { - new_skill_point = UINT_MAX; - } - else - { + if (point < 0 && sd->status.skill_point + point < 0) { + new_skill_point = 0; + } else if (point > 0 && (int64)sd->status.skill_point + point > INT_MAX) { + new_skill_point = INT_MAX; + } else { new_skill_point = sd->status.skill_point + point; } @@ -3748,7 +3708,7 @@ ACMD(reloadscript) { * 1 = Show users in that map and their location * 2 = Shows NPCs in that map * 3 = Shows the chats in that map - TODO# add the missing mapflags e.g. adjust_skill_damage to display + * TODO# add the missing mapflags e.g. adjust_skill_damage to display *------------------------------------------*/ ACMD(mapinfo) { @@ -4153,8 +4113,9 @@ ACMD(repairall) count = 0; for (i = 0; i < MAX_INVENTORY; i++) { - if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) { - sd->status.inventory[i].attribute = 0; + if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { + sd->status.inventory[i].attribute |= ATTR_BROKEN; + sd->status.inventory[i].attribute ^= ATTR_BROKEN; clif->produce_effect(sd, 0, sd->status.inventory[i].nameid); count++; } @@ -9310,8 +9271,9 @@ ACMD(costume){ } /* for debugging purposes (so users can easily provide us with debug info) */ /* should be trashed as soon as its no longer necessary */ -ACMD(skdebug) { - safesnprintf(atcmd_output, sizeof(atcmd_output),"second: %u; third: %u", sd->sktree.second, sd->sktree.third); +ACMD(skdebug) +{ + safesnprintf(atcmd_output, sizeof(atcmd_output),"second: %d; third: %d", sd->sktree.second, sd->sktree.third); clif->message(fd,atcmd_output); safesnprintf(atcmd_output, sizeof(atcmd_output),"pc_calc_skilltree_normalize_job: %d",pc->calc_skilltree_normalize_job(sd)); clif->message(fd,atcmd_output); diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 0e7895825..ef8be7807 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -152,7 +152,8 @@ void atcommand_defaults(void); HPShared struct atcommand_interface *atcommand; /* stay here */ -#define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) __attribute__((nonnull (2, 3, 4, 5))); \ - static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) +#define ACMD(x) \ + static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) __attribute__((nonnull (2, 3, 4, 5))); \ + static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) #endif /* MAP_ATCOMMAND_H */ diff --git a/src/map/battle.c b/src/map/battle.c index 09b99aa05..79048457c 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2431,7 +2431,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block RE_LVL_DMOD(100); break; case LG_OVERBRAND_PLUSATK: - skillratio = 200 * skill_lv + rnd_value( 10, 100); + skillratio = 200 * skill_lv + rnd->value(10, 100); RE_LVL_DMOD(100); break; case LG_RAYOFGENESIS: @@ -3263,30 +3263,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam } } /* no data claims these settings affect anything other than players */ - if( damage && t_sd && bl->type == BL_PC ) { - switch( skill_id ) { - //case PA_PRESSURE: /* pressure also belongs to this list but it doesn't reach this area -- so don't worry about it */ - case HW_GRAVITATION: - case NJ_ZENYNAGE: - case KO_MUCHANAGE: - break; - default: - if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] - if (flag&BF_WEAPON) - damage = damage * map->list[bl->m].weapon_damage_rate / 100; - if (flag&BF_MAGIC) - damage = damage * map->list[bl->m].magic_damage_rate / 100; - if (flag&BF_MISC) - damage = damage * map->list[bl->m].misc_damage_rate / 100; - } else { //Normal attacks get reductions based on range. - if (flag & BF_SHORT) - damage = damage * map->list[bl->m].short_damage_rate / 100; - if (flag & BF_LONG) - damage = damage * map->list[bl->m].long_damage_rate / 100; - } - if(!damage) damage = 1; - break; - } + if (damage && t_sd && bl->type == BL_PC) { + damage = battle->calc_pc_damage(src, bl, d, damage, skill_id, skill_lv); } if(battle_config.skill_min_damage && damage > 0 && damage < div_) @@ -3331,6 +3309,37 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam return damage; } +int64 battle_calc_pc_damage(struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv) +{ + int flag = d->flag; + + switch (skill_id) { + //case PA_PRESSURE: /* pressure also belongs to this list but it doesn't reach this area -- so don't worry about it */ + case HW_GRAVITATION: + case NJ_ZENYNAGE: + case KO_MUCHANAGE: + break; + default: + if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] + if (flag & BF_WEAPON) + damage = damage * map->list[bl->m].weapon_damage_rate / 100; + if (flag & BF_MAGIC) + damage = damage * map->list[bl->m].magic_damage_rate / 100; + if (flag & BF_MISC) + damage = damage * map->list[bl->m].misc_damage_rate / 100; + } else { //Normal attacks get reductions based on range. + if (flag & BF_SHORT) + damage = damage * map->list[bl->m].short_damage_rate / 100; + if (flag & BF_LONG) + damage = damage * map->list[bl->m].long_damage_rate / 100; + } + if (!damage) + damage = 1; + break; + } + return damage; +} + /*========================================== * Calculates BG related damage adjustments. *------------------------------------------*/ @@ -6009,6 +6018,46 @@ int battle_damage_area(struct block_list *bl, va_list ap) { return 0; } + +bool battle_check_arrows(struct map_session_data *sd) +{ + int index = sd->equip_index[EQI_AMMO]; + if (index < 0) { + if (sd->weapontype1 > W_KATAR && sd->weapontype1 < W_HUUMA) + clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0); + else + clif->arrow_fail(sd, 0); + return false; + } + //Ammo check by Ishizu-chan + if (sd->inventory_data[index]) { + switch (sd->status.weapon) { + case W_BOW: + if (sd->inventory_data[index]->look != A_ARROW) { + clif->arrow_fail(sd, 0); + return false; + } + break; + case W_REVOLVER: + case W_RIFLE: + case W_GATLING: + case W_SHOTGUN: + if (sd->inventory_data[index]->look != A_BULLET) { + clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0); + return false; + } + break; + case W_GRENADE: + if (sd->inventory_data[index]->look != A_GRENADE) { + clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0); + return false; + } + break; + } + } + return true; +} + /*========================================== * Do a basic physical attack (call trough unit_attack_timer) *------------------------------------------*/ @@ -6046,39 +6095,8 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t sd->state.arrow_atk = (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)); if (sd->state.arrow_atk) { - int index = sd->equip_index[EQI_AMMO]; - if (index<0) { - if ( sd->weapontype1 > W_KATAR && sd->weapontype1 < W_HUUMA ) - clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0); - else - clif->arrow_fail(sd, 0); + if (battle->check_arrows(sd) == false) return ATK_NONE; - } - //Ammo check by Ishizu-chan - if (sd->inventory_data[index]) - switch (sd->status.weapon) { - case W_BOW: - if (sd->inventory_data[index]->look != A_ARROW) { - clif->arrow_fail(sd,0); - return ATK_NONE; - } - break; - case W_REVOLVER: - case W_RIFLE: - case W_GATLING: - case W_SHOTGUN: - if (sd->inventory_data[index]->look != A_BULLET) { - clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0); - return ATK_NONE; - } - break; - case W_GRENADE: - if (sd->inventory_data[index]->look != A_GRENADE) { - clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0); - return ATK_NONE; - } - break; - } } } if (sc && sc->count) { @@ -6260,17 +6278,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t sp = skill->get_sp(skill_id,skill_lv) * 2 / 3; if (status->charge(src, 0, sp)) { - switch (skill->get_casttype(skill_id)) { - case CAST_GROUND: - skill->castend_pos2(src, target->x, target->y, skill_id, skill_lv, tick, flag); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(src, target, skill_id, skill_lv, tick, flag); - break; - case CAST_DAMAGE: - skill->castend_damage_id(src, target, skill_id, skill_lv, tick, flag); - break; - } + skill->castend_type(skill->get_casttype(skill_id), src, target, skill_id, skill_lv, tick, flag); } } if (sd) { @@ -6316,19 +6324,8 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t sd->state.autocast = 1; skill->consume_requirement(sd,r_skill,r_lv,3); - switch( type ) { - case CAST_GROUND: - skill->castend_pos2(src, target->x, target->y, r_skill, r_lv, tick, flag); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(src, target, r_skill, r_lv, tick, flag); - break; - case CAST_DAMAGE: - skill->castend_damage_id(src, target, r_skill, r_lv, tick, flag); - break; - } + skill->castend_type(type, src, target, r_skill, r_lv, tick, flag); sd->state.autocast = 0; - sd->ud.canact_tick = tick + skill->delay_fix(src, r_skill, r_lv); clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, r_skill, r_lv), 0, 0, 1); } @@ -6777,9 +6774,9 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if ( (s_sd->class_&MAPID_UPPERMASK) == MAPID_NOVICE || (t_sd->class_&MAPID_UPPERMASK) == MAPID_NOVICE || - (int)s_sd->status.base_level < battle_config.pk_min_level || - (int)t_sd->status.base_level < battle_config.pk_min_level || - (battle_config.pk_level_range && abs((int)s_sd->status.base_level - (int)t_sd->status.base_level) > battle_config.pk_level_range) + s_sd->status.base_level < battle_config.pk_min_level || + t_sd->status.base_level < battle_config.pk_min_level || + (battle_config.pk_level_range && abs(s_sd->status.base_level - t_sd->status.base_level) > battle_config.pk_level_range) ) state &= ~BCT_ENEMY; } @@ -7250,6 +7247,7 @@ static const struct battle_data { { "min_body_style", &battle_config.min_body_style, 0, 0, SHRT_MAX, }, { "max_body_style", &battle_config.max_body_style, 4, 0, SHRT_MAX, }, { "save_body_style", &battle_config.save_body_style, 0, 0, 1, }, + { "player_warp_keep_direction", &battle_config.player_warp_keep_direction, 0, 0, 1, }, }; #ifndef STATS_OPT_OUT /** @@ -7602,9 +7600,11 @@ void battle_defaults(void) { battle->calc_attack = battle_calc_attack; battle->calc_damage = battle_calc_damage; + battle->calc_pc_damage = battle_calc_pc_damage; battle->calc_gvg_damage = battle_calc_gvg_damage; battle->calc_bg_damage = battle_calc_bg_damage; battle->weapon_attack = battle_weapon_attack; + battle->check_arrows = battle_check_arrows; battle->calc_weapon_attack = battle_calc_weapon_attack; battle->delay_damage = battle_delay_damage; battle->drain = battle_drain; diff --git a/src/map/battle.h b/src/map/battle.h index 49abdc730..1a23870e7 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -539,6 +539,9 @@ struct Battle_Config { // BodyStyle int min_body_style, max_body_style; int save_body_style; + + // Warp Face Direction + int player_warp_keep_direction; }; /* criteria for battle_config.idletime_critera */ @@ -587,12 +590,16 @@ struct battle_interface { struct Damage (*calc_attack) (int attack_type, struct block_list *bl, struct block_list *target, uint16 skill_id, uint16 skill_lv, int count); /* generic final damage calculation */ int64 (*calc_damage) (struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv); + /* pc special damage calculation */ + int64 (*calc_pc_damage) (struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv); /* gvg final damage calculation */ int64 (*calc_gvg_damage) (struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); /* battlegrounds final damage calculation */ int64 (*calc_bg_damage) (struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); /* normal weapon attack */ enum damage_lv (*weapon_attack) (struct block_list *bl, struct block_list *target, int64 tick, int flag); + /* check is equipped ammo and this ammo allowed */ + bool (*check_arrows) (struct map_session_data *sd); /* calculate weapon attack */ struct Damage (*calc_weapon_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag); /* delays damage or skills by a timer */ diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 3828a3c14..58a1f925f 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -100,7 +100,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha if( !pc_can_give_items(sd) ) {// custom: GM is not allowed to buy (give zeny) sd->buyingstore.slots = 0; - clif->message(sd->fd, msg_sd(sd,246)); + clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. clif->buyingstore_open_failed(sd, BUYINGSTORE_CREATE, 0); return; } @@ -222,7 +222,7 @@ void buyingstore_open(struct map_session_data* sd, int account_id) if( !pc_can_give_items(sd) ) {// custom: GM is not allowed to sell - clif->message(sd->fd, msg_sd(sd,246)); + clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. return; } @@ -261,7 +261,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int if( !pc_can_give_items(sd) ) {// custom: GM is not allowed to sell - clif->message(sd->fd, msg_sd(sd,246)); + clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0); return; } diff --git a/src/map/chat.c b/src/map/chat.c index df48e1f2c..145d44d1e 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -44,7 +44,7 @@ struct chat_interface *chat; /// Initializes a chatroom object (common functionality for both pc and npc chatrooms). /// Returns a chatroom object on success, or NULL on failure. -struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl) +struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int min_level, int max_level) { struct chat_data* cd; nullpo_retr(NULL, bl); @@ -62,8 +62,8 @@ struct chat_data* chat_createchat(struct block_list* bl, const char* title, cons cd->limit = min(limit, ARRAYLENGTH(cd->usersd)); cd->trigger = trigger; cd->zeny = zeny; - cd->minLvl = minLvl; - cd->maxLvl = maxLvl; + cd->min_level = min_level; + cd->max_level = max_level; memset(cd->usersd, 0, sizeof(cd->usersd)); cd->owner = bl; safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event)); @@ -106,8 +106,8 @@ bool chat_createpcchat(struct map_session_data* sd, const char* title, const cha } if( map->list[sd->bl.m].flag.nochat ) { - clif->message(sd->fd, msg_sd(sd,281)); - return false; //Can't create chatrooms on this map. + clif->message(sd->fd, msg_sd(sd,281)); // You can't create chat rooms in this map + return false; } if (map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y, CELL_CHKNOCHAT) ) { @@ -156,8 +156,8 @@ bool chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) { return false; } - if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl ) { - if(sd->status.base_level < cd->minLvl) + if (sd->status.base_level < cd->min_level || sd->status.base_level > cd->max_level) { + if(sd->status.base_level < cd->min_level) clif->joinchatfail(sd,5); // too low level else clif->joinchatfail(sd,6); // too high level @@ -375,7 +375,7 @@ bool chat_kickchat(struct map_session_data* sd, const char* kickusername) { /*========================================== * Creates a chat room for the npc *------------------------------------------*/ -bool chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl) +bool chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int min_level, int max_level) { struct chat_data* cd; nullpo_ret(nd); @@ -385,12 +385,12 @@ bool chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool return false; } - if( zeny > MAX_ZENY || maxLvl > MAX_LEVEL ) { + if (zeny > MAX_ZENY || max_level > MAX_LEVEL) { ShowError("chat_createnpcchat: npc '%s' has a required lvl or amount of zeny over the max limit!\n", nd->exname); return false; } - cd = chat->create(&nd->bl, title, "", limit, pub, trigger, ev, zeny, minLvl, maxLvl); + cd = chat->create(&nd->bl, title, "", limit, pub, trigger, ev, zeny, min_level, max_level); if( cd ) { nd->chat_id = cd->bl.id; diff --git a/src/map/chat.h b/src/map/chat.h index 59d61a46e..af43d9703 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -41,8 +41,8 @@ struct chat_data { uint8 limit; ///< join limit uint8 trigger; ///< number of users needed to trigger event uint32 zeny; ///< required zeny to join - uint32 minLvl; ///< minimum base level to join - uint32 maxLvl; ///< maximum base level allowed to join + int min_level; ///< minimum base level to join + int max_level; ///< maximum base level allowed to join struct map_session_data* usersd[MAX_CHAT_USERS]; struct block_list* owner; char npc_event[EVENT_NAME_LENGTH]; @@ -63,13 +63,13 @@ struct chat_interface { bool (*change_owner) (struct map_session_data* sd, const char* nextownername); bool (*change_status) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub); bool (*kick) (struct map_session_data* sd, const char* kickusername); - bool (*create_npc_chat) (struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); + bool (*create_npc_chat) (struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int min_level, int max_level); bool (*delete_npc_chat) (struct npc_data* nd); bool (*enable_event) (struct chat_data* cd); bool (*disable_event) (struct chat_data* cd); bool (*npc_kick_all) (struct chat_data* cd); bool (*trigger_event) (struct chat_data *cd); - struct chat_data* (*create) (struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); + struct chat_data* (*create) (struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int min_level, int max_level); }; #ifdef HERCULES_CORE diff --git a/src/map/chrif.c b/src/map/chrif.c index 52af1137e..d641c6dd3 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -236,11 +236,13 @@ void chrif_setpasswd(char *pwd) { // security check, prints warning if using default password void chrif_checkdefaultlogin(void) { +#ifndef BUILDBOT if (strcmp(chrif->userid, "s1")==0 && strcmp(chrif->passwd, "p1")==0) { ShowWarning("Using the default user/password s1/p1 is NOT RECOMMENDED.\n"); ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n"); ShowNotice("and then edit your user/password in conf/map-server.conf (or conf/import/map_conf.txt)\n"); } +#endif } // sets char-server's ip address @@ -997,9 +999,9 @@ void chrif_idbanned(int fd) { if(0<ret_status && ret_status<=9) clif->message(sd->fd, msg_sd(sd,411+ret_status)); // Message IDs (for search convenience): 412, 413, 414, 415, 416, 417, 418, 419, 420 else if(ret_status==100) - clif->message(sd->fd, msg_sd(sd,421)); + clif->message(sd->fd, msg_sd(sd,421)); // Your account has been totally erased. else - clif->message(sd->fd, msg_sd(sd,420)); //"Your account has not more authorized." + clif->message(sd->fd, msg_sd(sd,420)); //"Your account is not longer authorized." } else if (RFIFOB(fd,6) == 1) { // 1: ban time_t timestamp; char tmpstr[2048]; diff --git a/src/map/clif.c b/src/map/clif.c index 259bc7253..f73553b72 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -190,7 +190,7 @@ static inline void RFIFOPOS2(int fd, unsigned short pos, short* x0, short* y0, s #endif // 0 //To identify disguised characters. -static inline bool disguised(struct block_list* bl) +bool clif_isdisguised(struct block_list* bl) { struct map_session_data *sd = BL_CAST(BL_PC, bl); if (sd == NULL || sd->disguise == -1) @@ -265,24 +265,50 @@ uint32 clif_refresh_ip(void) return 0; } +unsigned char clif_bl_type(struct block_list *bl) +{ #if PACKETVER >= 20071106 -static inline unsigned char clif_bl_type(struct block_list *bl) { - nullpo_retr(0x1, bl); + struct view_data *vd; + nullpo_retr(CLUT_NPC, bl); + switch (bl->type) { - case BL_PC: return (disguised(bl) && !pc->db_checkid(status->get_viewdata(bl)->class_))? 0x1:0x0; //PC_TYPE - case BL_ITEM: return 0x2; //ITEM_TYPE - case BL_SKILL: return 0x3; //SKILL_TYPE - case BL_CHAT: return 0x4; //UNKNOWN_TYPE - case BL_MOB: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE - case BL_NPC: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x6; //NPC_EVT_TYPE - case BL_PET: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE - case BL_HOM: return 0x8; //NPC_HOM_TYPE - case BL_MER: return 0x9; //NPC_MERSOL_TYPE - case BL_ELEM: return 0xa; //NPC_ELEMENTAL_TYPE - default: return 0x1; //NPC_TYPE + case BL_PC: + vd = status->get_viewdata(bl); + nullpo_retr(CLUT_NPC, vd); + + if (clif->isdisguised(bl) && !pc->db_checkid(vd->class_)) + return CLUT_NPC; + return CLUT_PC; + case BL_ITEM: + return CLUT_ITEM; + case BL_SKILL: + return CLUT_SKILL; + case BL_CHAT: + return CLUT_UNKNOWN; + case BL_MOB: + vd = status->get_viewdata(bl); + nullpo_retr(CLUT_NPC, vd); + return pc->db_checkid(vd->class_) ? CLUT_PC : CLUT_MOB; + case BL_NPC: + vd = status->get_viewdata(bl); + nullpo_retr(CLUT_NPC, vd); + return pc->db_checkid(vd->class_) ? CLUT_PC : CLUT_EVENT; + case BL_PET: + vd = status->get_viewdata(bl); + nullpo_retr(CLUT_NPC, vd); + return pc->db_checkid(vd->class_) ? CLUT_PC : CLUT_PET; + case BL_HOM: + return CLUT_HOMNUCLUS; + case BL_MER: + return CLUT_MERCNARY; + case BL_ELEM: + return CLUT_ELEMENTAL; + default: + return CLUT_NPC; } -} #endif + return CLUT_UNKNOWN; +} /*========================================== * sub process of clif_send @@ -823,7 +849,7 @@ void clif_clearunit_area(struct block_list* bl, clr_type type) clif->send(buf, packet_len(0x80), bl, type == CLR_DEAD ? AREA : AREA_WOS); - if(disguised(bl)) { + if (clif->isdisguised(bl)) { WBUFL(buf,2) = -bl->id; clif->send(buf, packet_len(0x80), bl, SELF); } @@ -928,7 +954,7 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en p.PacketType = idle_unit2Type; #if PACKETVER >= 20071106 - p.objecttype = clif_bl_type(bl); + p.objecttype = clif->bl_type(bl); #endif p.GID = bl->id; p.speed = status->get_speed(bl); @@ -990,7 +1016,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.PacketType = idle_unitType; #if PACKETVER >= 20091103 p.PacketLength = sizeof(p); - p.objecttype = clif_bl_type(bl); + p.objecttype = clif->bl_type(bl); #endif #if PACKETVER >= 20131223 p.AID = bl->id; @@ -1054,7 +1080,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target); - if( disguised(bl) ) { + if (clif->isdisguised(bl)) { #if PACKETVER >= 20091103 p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; @@ -1079,7 +1105,7 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) { p.PacketType = spawn_unit2Type; #if PACKETVER >= 20071106 - p.objecttype = clif_bl_type(bl); + p.objecttype = clif->bl_type(bl); #endif p.GID = bl->id; p.speed = status->get_speed(bl); @@ -1132,7 +1158,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.PacketType = spawn_unitType; #if PACKETVER >= 20091103 p.PacketLength = sizeof(p); - p.objecttype = clif_bl_type(bl); + p.objecttype = clif->bl_type(bl); #endif #if PACKETVER >= 20131223 p.AID = bl->id; @@ -1192,7 +1218,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.body = vd->body_style; safestrncpy(p.name, clif->get_bl_name(bl), NAME_LENGTH); #endif - if( disguised(bl) ) { + if (clif->isdisguised(bl)) { nullpo_retv(sd); if( sd->status.class_ != sd->disguise ) clif->send(&p,sizeof(p),bl,target); @@ -1228,7 +1254,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.PacketLength = sizeof(p); #endif #if PACKETVER >= 20071106 - p.objecttype = clif_bl_type(bl); + p.objecttype = clif->bl_type(bl); #endif #if PACKETVER >= 20131223 p.AID = bl->id; @@ -1287,7 +1313,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target); - if( disguised(bl) ) { + if (clif->isdisguised(bl)) { #if PACKETVER >= 20091103 p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; @@ -1429,7 +1455,7 @@ bool clif_spawn(struct block_list *bl) if (sd->bg_id != 0 && map->list[sd->bl.m].flag.battleground) clif->sendbgemblem_area(sd); for (i = 0; i < sd->sc_display_count; i++) { - clif->sc_load(&sd->bl, sd->bl.id,AREA,status->dbs->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); + clif->sc_continue(&sd->bl, sd->bl.id,AREA,status->dbs->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); } if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0) clif->spiritcharm(sd); @@ -1756,7 +1782,7 @@ void clif_move(struct unit_data *ud) clif->send(buf, packet_len(0x86), bl, AREA_WOS); - if (disguised(bl)) { + if (clif->isdisguised(bl)) { WBUFL(buf,2)=-bl->id; clif->send(buf, packet_len(0x86), bl, SELF); } @@ -1849,7 +1875,7 @@ void clif_fixpos(struct block_list *bl) { WBUFW(buf,8) = bl->y; clif->send(buf, packet_len(0x88), bl, AREA); - if( disguised(bl) ) { + if (clif->isdisguised(bl)) { WBUFL(buf,2) = -bl->id; clif->send(buf, packet_len(0x88), bl, SELF); } @@ -1960,6 +1986,10 @@ void clif_selllist(struct map_session_data *sd) void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) { int fd, slen; +#ifdef SCRIPT_MES_STRIP_LINEBREAK + char *stripmes = NULL; + int i; +#endif nullpo_retv(sd); nullpo_retv(mes); @@ -1974,7 +2004,17 @@ void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) WFIFOW(fd,0) = 0xb4; WFIFOW(fd,2) = slen; WFIFOL(fd,4) = npcid; +#ifdef SCRIPT_MES_STRIP_LINEBREAK + stripmes = aStrdup(mes); + for (i = 0; stripmes[i] != '\0'; ++i) { + if (stripmes[i] == '\r') + stripmes[i] = ' '; + } + memcpy(WFIFOP(fd,8), stripmes, slen-8); + aFree(stripmes); +#else // ! SCRIPT_MES_STRIP_LINEBREAK memcpy(WFIFOP(fd,8), mes, slen-8); +#endif // SCRIPT_MES_STRIP_LINEBREAK WFIFOSET(fd,WFIFOW(fd,2)); } @@ -2365,7 +2405,7 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { p.nameid = sd->status.inventory[n].nameid; p.IsIdentified = sd->status.inventory[n].identify ? 1 : 0; - p.IsDamaged = sd->status.inventory[n].attribute ? 1 : 0; + p.IsDamaged = (sd->status.inventory[n].attribute & ATTR_BROKEN) != 0 ? 1 : 0; p.refiningLevel =sd->status.inventory[n].refine; clif->addcards2(&p.slot.card[0], &sd->status.inventory[n]); p.location = pc->equippoint(sd,n); @@ -2480,7 +2520,7 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct p->location = eqp_pos; p->WearState = i->equip; #if PACKETVER < 20120925 - p->IsDamaged = i->attribute ? 1 : 0; + p->IsDamaged = (i->attribute & ATTR_BROKEN) != 0 ? 1 : 0; #endif p->RefiningLevel = i->refine; @@ -2500,7 +2540,7 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct #if PACKETVER >= 20120925 p->Flag.IsIdentified = i->identify ? 1 : 0; - p->Flag.IsDamaged = i->attribute ? 1 : 0; + p->Flag.IsDamaged = (i->attribute & ATTR_BROKEN) != 0 ? 1 : 0; p->Flag.PlaceETCTab = i->favorite ? 1 : 0; p->Flag.SpareBits = 0; #endif @@ -3198,7 +3238,7 @@ void clif_changelook(struct block_list *bl,int type,int val) } // prevent leaking the presence of GM-hidden objects - if( sc && sc->option&OPTION_INVISIBLE && !disguised(bl) ) + if (sc && sc->option&OPTION_INVISIBLE && !clif->isdisguised(bl)) target = SELF; #if PACKETVER < 4 clif->sendlook(bl, bl->id, type, val, 0, target); @@ -3209,11 +3249,12 @@ void clif_changelook(struct block_list *bl,int type,int val) val = vd->weapon; val2 = vd->shield; } - if( disguised(bl) ) { + if (clif->isdisguised(bl)) { clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS); clif->sendlook(bl, -bl->id, type, val, val2, SELF); - } else + } else { clif->sendlook(bl, bl->id, type, val, val2, target); + } #endif } @@ -3494,15 +3535,16 @@ void clif_changeoption(struct block_list* bl) WBUFW(buf,8) = (sc) ? sc->opt2 : 0; WBUFL(buf,10) = (sc != NULL) ? sc->option : ((bl->type == BL_NPC) ? BL_UCCAST(BL_NPC, bl)->option : 0); WBUFB(buf,14) = (sd)? sd->status.karma : 0; - if(disguised(bl)) { + if (clif->isdisguised(bl)) { clif->send(buf,packet_len(0x229),bl,AREA_WOS); WBUFL(buf,2) = -bl->id; clif->send(buf,packet_len(0x229),bl,SELF); WBUFL(buf,2) = bl->id; WBUFL(buf,10) = OPTION_INVISIBLE; clif->send(buf,packet_len(0x229),bl,SELF); - } else + } else { clif->send(buf,packet_len(0x229),bl,AREA); + } #else WBUFW(buf,0) = 0x119; WBUFL(buf,2) = bl->id; @@ -3510,15 +3552,16 @@ void clif_changeoption(struct block_list* bl) WBUFW(buf,8) = (sc) ? sc->opt2 : 0; WBUFL(buf,10) = (sc != NULL) ? sc->option : ((bl->type == BL_NPC) ? BL_UCCAST(BL_NPC, bl)->option : 0); WBUFB(buf,12) = (sd)? sd->status.karma : 0; - if(disguised(bl)) { + if (clif->isdisguised(bl)) { clif->send(buf,packet_len(0x119),bl,AREA_WOS); WBUFL(buf,2) = -bl->id; clif->send(buf,packet_len(0x119),bl,SELF); WBUFL(buf,2) = bl->id; WBUFW(buf,10) = OPTION_INVISIBLE; clif->send(buf,packet_len(0x119),bl,SELF); - } else + } else { clif->send(buf,packet_len(0x119),bl,AREA); + } #endif } @@ -3536,15 +3579,16 @@ void clif_changeoption2(struct block_list* bl) { WBUFL(buf,6) = (sc != NULL) ? sc->option : ((bl->type == BL_NPC) ? BL_UCCAST(BL_NPC, bl)->option : 0); WBUFL(buf,10) = clif_setlevel(bl); WBUFL(buf,14) = (sc) ? sc->opt3 : 0; - if(disguised(bl)) { + if (clif->isdisguised(bl)) { clif->send(buf,packet_len(0x28a),bl,AREA_WOS); WBUFL(buf,2) = -bl->id; clif->send(buf,packet_len(0x28a),bl,SELF); WBUFL(buf,2) = bl->id; WBUFL(buf,6) = OPTION_INVISIBLE; clif->send(buf,packet_len(0x28a),bl,SELF); - } else + } else { clif->send(buf,packet_len(0x28a),bl,AREA); + } } /// Notifies the client about the result of an item use request. @@ -4142,7 +4186,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds clif->charm_single(sd->fd, dstsd); for( i = 0; i < dstsd->sc_display_count; i++ ) { - clif->sc_load(&sd->bl,dstsd->bl.id,SELF,status->dbs->IconChangeTable[dstsd->sc_display[i]->type],dstsd->sc_display[i]->val1,dstsd->sc_display[i]->val2,dstsd->sc_display[i]->val3); + clif->sc_continue(&sd->bl,dstsd->bl.id,SELF,status->dbs->IconChangeTable[dstsd->sc_display[i]->type],dstsd->sc_display[i]->val1,dstsd->sc_display[i]->val2,dstsd->sc_display[i]->val3); } if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting. (sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround @@ -4332,16 +4376,17 @@ int clif_damage(struct block_list* src, struct block_list* dst, int sdelay, int p.is_sp_damaged = 0; // TODO: IsSPDamage - Displays blue digits. #endif - if(disguised(dst)) { + if (clif->isdisguised(dst)) { clif->send(&p,sizeof(p),dst,AREA_WOS); p.targetGID = -dst->id; clif->send(&p,sizeof(p),dst,SELF); - } else + } else { clif->send(&p,sizeof(p),dst,AREA); + } - if(disguised(src)) { + if (clif->isdisguised(src)) { p.GID = -src->id; - if (disguised(dst)) + if (clif->isdisguised(dst)) p.targetGID = dst->id; if(damage > 0) p.damage = -1; @@ -4390,7 +4435,7 @@ void clif_sitting(struct block_list* bl) WBUFB(buf,26) = 2; clif->send(buf, packet_len(0x8a), bl, AREA); - if(disguised(bl)) { + if (clif->isdisguised(bl)) { WBUFL(buf, 2) = - bl->id; clif->send(buf, packet_len(0x8a), bl, SELF); } @@ -4409,7 +4454,7 @@ void clif_standing(struct block_list* bl) WBUFB(buf,26) = 3; clif->send(buf, packet_len(0x8a), bl, AREA); - if(disguised(bl)) { + if (clif->isdisguised(bl)) { WBUFL(buf, 2) = - bl->id; clif->send(buf, packet_len(0x8a), bl, SELF); } @@ -4886,7 +4931,7 @@ void clif_skillinfo(struct map_session_data *sd,int skill_id, int inf) /// is disposable: /// 0 = yellow chat text "[src name] will use skill [skill name]." /// 1 = no text -void clif_skillcasting(struct block_list* bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, int property, int casttime) +void clif_useskill(struct block_list* bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, uint16 skill_lv, int casttime) { #if PACKETVER < 20091124 const int cmd = 0x13e; @@ -4894,6 +4939,7 @@ void clif_skillcasting(struct block_list* bl, int src_id, int dst_id, int dst_x, const int cmd = 0x7fb; #endif unsigned char buf[32]; + int property = skill->get_ele(skill_id, skill_lv); WBUFW(buf,0) = cmd; WBUFL(buf,2) = src_id; @@ -4907,12 +4953,13 @@ void clif_skillcasting(struct block_list* bl, int src_id, int dst_id, int dst_x, WBUFB(buf,24) = 0; // isDisposable #endif - if (disguised(bl)) { + if (clif->isdisguised(bl)) { clif->send(buf,packet_len(cmd), bl, AREA_WOS); WBUFL(buf,2) = -src_id; clif->send(buf,packet_len(cmd), bl, SELF); - } else + } else { clif->send(buf,packet_len(cmd), bl, AREA); + } } /// Notifies clients in area, that an object canceled casting (ZC_DISPEL). @@ -5042,16 +5089,17 @@ int clif_skill_damage(struct block_list *src, struct block_list *dst, int64 tick WBUFW(buf, 26) = skill_lv; WBUFW(buf, 28) = div; WBUFB(buf, 30) = type; - if (disguised(dst)) { + if (clif->isdisguised(dst)) { clif->send(buf, packet_len(0x114), dst, AREA_WOS); WBUFL(buf, 8) = -dst->id; clif->send(buf, packet_len(0x114), dst, SELF); - } else + } else { clif->send(buf, packet_len(0x114), dst, AREA); + } - if (disguised(src)) { + if (clif->isdisguised(src)) { WBUFL(buf, 4) = -src->id; - if (disguised(dst)) + if (clif->isdisguised(dst)) WBUFL(buf, 8) = dst->id; if (damage > 0) WBUFW(buf, 24) = -1; @@ -5081,16 +5129,17 @@ int clif_skill_damage(struct block_list *src, struct block_list *dst, int64 tick #else WBUFB(buf, 32) = (type == BDT_SKILL) ? BDT_MULTIHIT : type; #endif - if (disguised(dst)) { + if (clif->isdisguised(dst)) { clif->send(buf, packet_len(0x1de), dst, AREA_WOS); WBUFL(buf,8)=-dst->id; clif->send(buf, packet_len(0x1de), dst, SELF); - } else + } else { clif->send(buf, packet_len(0x1de), dst, AREA); + } - if (disguised(src)) { + if (clif->isdisguised(src)) { WBUFL(buf, 4) = -src->id; - if (disguised(dst)) + if (clif->isdisguised(dst)) WBUFL(buf, 8) = dst->id; if (damage > 0) WBUFL(buf, 24) = -1; @@ -5139,15 +5188,15 @@ int clif_skill_damage2(struct block_list *src, struct block_list *dst, int64 tic WBUFW(buf,32)=div; WBUFB(buf,34)=type; clif->send(buf,packet_len(0x115),src,AREA); - if(disguised(src)) { + if (clif->isdisguised(src)) { WBUFL(buf,4)=-src->id; if(damage > 0) WBUFW(buf,28)=-1; clif->send(buf,packet_len(0x115),src,SELF); } - if (disguised(dst)) { + if (clif->isdisguised(dst)) { WBUFL(buf,8)=-dst->id; - if (disguised(src)) + if (clif->isdisguised(src)) WBUFL(buf,4)=src->id; else if(damage > 0) WBUFW(buf,28)=-1; @@ -5174,16 +5223,16 @@ int clif_skill_nodamage(struct block_list *src,struct block_list *dst,uint16 ski WBUFL(buf,10)=src?src->id:0; WBUFB(buf,14)=fail; - if (disguised(dst)) { + if (clif->isdisguised(dst)) { clif->send(buf,packet_len(0x11a),dst,AREA_WOS); WBUFL(buf,6)=-dst->id; clif->send(buf,packet_len(0x11a),dst,SELF); } else clif->send(buf,packet_len(0x11a),dst,AREA); - if(src && disguised(src)) { + if (src && clif->isdisguised(src)) { WBUFL(buf,10)=-src->id; - if (disguised(dst)) + if (clif->isdisguised(dst)) WBUFL(buf,6)=dst->id; clif->send(buf,packet_len(0x11a),src,SELF); } @@ -5205,12 +5254,13 @@ void clif_skill_poseffect(struct block_list *src, uint16 skill_id, int val, int WBUFW(buf,10)=x; WBUFW(buf,12)=y; WBUFL(buf,14)=(uint32)tick; - if(disguised(src)) { + if (clif->isdisguised(src)) { clif->send(buf,packet_len(0x117),src,AREA_WOS); WBUFL(buf,4)=-src->id; clif->send(buf,packet_len(0x117),src,SELF); - } else + } else { clif->send(buf,packet_len(0x117),src,AREA); + } } /// Presents a list of available warp destinations (ZC_WARPLIST). @@ -5682,7 +5732,7 @@ void clif_resurrection(struct block_list *bl,int type) WBUFW(buf,6)=0; clif->send(buf,packet_len(0x148),bl, type == 1 ? AREA : AREA_WOS); - if (disguised(bl)) { + if (clif->isdisguised(bl)) { struct map_session_data *sd = BL_UCAST(BL_PC, bl); if (sd->fontcolor) { WBUFL(buf,2)=-bl->id; @@ -5979,7 +6029,7 @@ void clif_item_repair_list(struct map_session_data *sd,struct map_session_data * WFIFOW(fd,0)=0x1fc; for (i = c = 0; i < MAX_INVENTORY; i++) { int nameid = dstsd->status.inventory[i].nameid; - if (nameid > 0 && dstsd->status.inventory[i].attribute != 0) { // && skill_can_repair(sd,nameid)) { + if (nameid > 0 && (dstsd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { // && skill_can_repair(sd,nameid)) { WFIFOW(fd,c*13+4) = i; WFIFOW(fd,c*13+6) = nameid; WFIFOB(fd,c*13+8) = dstsd->status.inventory[i].refine; @@ -6517,7 +6567,7 @@ void clif_party_inviteack(struct map_session_data* sd, const char* nick, int res #if PACKETVER < 20070904 if( result == 7 ) { - clif->message(fd, msg_sd(sd,3)); + clif->message(fd, msg_sd(sd,3)); // Character not found. return; } #endif @@ -8171,7 +8221,7 @@ void clif_specialeffect(struct block_list* bl, int type, enum send_target target clif->send(buf, packet_len(0x1f3), bl, target); - if (disguised(bl)) { + if (clif->isdisguised(bl)) { WBUFL(buf,2) = -bl->id; clif->send(buf, packet_len(0x1f3), bl, SELF); } @@ -8203,8 +8253,7 @@ void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, sen clif->send(buf, packet_len(0x284), bl, target); - if( disguised(bl) ) - { + if (clif->isdisguised(bl)) { WBUFL(buf,2) = -bl->id; clif->send(buf, packet_len(0x284), bl, SELF); } @@ -8352,7 +8401,7 @@ void clif_refresh(struct map_session_data *sd) mail->clear(sd); - if( disguised(&sd->bl) ) {/* refresh-da */ + if (clif->isdisguised(&sd->bl)) {/* refresh-da */ short disguise = sd->disguise; pc->disguise(sd, -1); pc->disguise(sd, disguise); @@ -8567,8 +8616,7 @@ void clif_slide(struct block_list *bl, int x, int y) WBUFW(buf, 8) = y; clif->send(buf, packet_len(0x1ff), bl, AREA); - if( disguised(bl) ) - { + if (clif->isdisguised(bl)) { WBUFL(buf,2) = -bl->id; clif->send(buf, packet_len(0x1ff), bl, SELF); } @@ -9500,7 +9548,8 @@ void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) { clif->clearunit_area(&sd->bl, CLR_DEAD); else { skill->usave_trigger(sd); - sd->ud.dir = 0;/* enforce north-facing (not visually, virtually) */ + if (battle_config.player_warp_keep_direction == 1) + clif->changed_dir(&sd->bl, SELF); // Visually updates player facing direction } // Trigger skill effects if you appear standing on them @@ -9740,7 +9789,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { // 'see people in GM hide' cheat detection #if 0 /* disabled due to false positives (network lag + request name of char that's about to hide = race condition) */ sc = status->get_sc(bl); - if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) && + if (sc && sc->option&OPTION_INVISIBLE && !clif->isdisguised(bl) && bl->type != BL_NPC && //Skip hidden NPCs which can be seen using Maya Purple pc_get_group_level(sd) < battle_config.hack_info_GM_level ) { @@ -9910,7 +9959,7 @@ void clif_changed_dir(struct block_list *bl, enum send_target target) clif->send(buf, packet_len(0x9c), bl, target); - if (disguised(bl)) { + if (clif->isdisguised(bl)) { WBUFL(buf,2) = -bl->id; WBUFW(buf,6) = 0; clif->send(buf, packet_len(0x9c), bl, SELF); @@ -10029,7 +10078,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, if( sd->sc.option&OPTION_COSTUME ) return; - if (!battle_config.sdelay_attack_enable && pc->checkskill(sd, SA_FREECAST) <= 0) { + if (!battle_config.sdelay_attack_enable && pc->checkskill(sd, SA_FREECAST) <= 0 && (skill->get_inf2(sd->ud.skill_id) & (INF2_FREE_CAST_REDUCED | INF2_FREE_CAST_NORMAL)) == 0) { if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) { clif->skill_fail(sd, 1, USESKILL_FAIL_SKILLINTERVAL, 0); return; @@ -10212,7 +10261,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) if (k < sd->channel_count || channel->join(chan, sd, "", true) == HCS_STATUS_OK) { channel->send(chan,sd,message); } else { - clif->message(fd, msg_fd(fd,1402)); + clif->message(fd, msg_fd(fd,1402)); //You're not in that channel, type '@join <#channel_name>' } return; } else if (strcmpi(&chname[1], channel->config->ally_name) == 0) { @@ -11153,7 +11202,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) sd->skillitem = sd->skillitemlv = 0; - if( skill_id >= GD_SKILLBASE ) { + if (skill_id >= GD_SKILLBASE && skill_id < GD_MAX) { if( sd->state.gmaster_flag ) skill_lv = guild->checkskill(sd->guild, skill_id); else @@ -11527,10 +11576,10 @@ void clif_parse_OneClick_ItemIdentify(int fd, struct map_session_data *sd) int cmd = RFIFOW(fd,0); short idx = RFIFOW(fd, packet_db[cmd].pos[0]) - 2; int n; - + if (idx < 0 || idx >= MAX_INVENTORY || sd->inventory_data[idx] == NULL || sd->status.inventory[idx].nameid <= 0) return; - + if ((n = pc->have_magnifier(sd) ) != INDEX_NOT_FOUND && pc->delitem(sd, n, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME) == 0) skill->identify(sd, idx); @@ -11807,7 +11856,7 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) if( map->list[sd->bl.m].flag.partylock ) { // Party locked. - clif->message(fd, msg_fd(fd,227)); + clif->message(fd, msg_fd(fd,227)); // Party modification is disabled in this map. return; } if( battle_config.basic_skill_check && pc->checkskill(sd,NV_BASIC) < 7 ) { @@ -11829,7 +11878,7 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) if( map->list[sd->bl.m].flag.partylock ) { // Party locked. - clif->message(fd, msg_fd(fd,227)); + clif->message(fd, msg_fd(fd,227)); // Party modification is disabled in this map. return; } if( battle_config.basic_skill_check && pc->checkskill(sd,NV_BASIC) < 7 ) { @@ -11849,7 +11898,7 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) { if(map->list[sd->bl.m].flag.partylock) { // Party locked. - clif->message(fd, msg_fd(fd,227)); + clif->message(fd, msg_fd(fd,227)); // Party modification is disabled in this map. return; } @@ -11873,7 +11922,7 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) if(map->list[sd->bl.m].flag.partylock) { // Party locked. - clif->message(fd, msg_fd(fd,227)); + clif->message(fd, msg_fd(fd,227)); // Party modification is disabled in this map. return; } @@ -11911,7 +11960,7 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd) __attribute__((n void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { if(map->list[sd->bl.m].flag.partylock) { // Party locked. - clif->message(fd, msg_fd(fd,227)); + clif->message(fd, msg_fd(fd,227)); // Party modification is disabled in this map. return; } party->leave(sd); @@ -11923,7 +11972,7 @@ void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) __attribu void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) { if(map->list[sd->bl.m].flag.partylock) { // Party locked. - clif->message(fd, msg_fd(fd,227)); + clif->message(fd, msg_fd(fd,227)); // Party modification is disabled in this map. return; } party->removemember(sd, RFIFOL(fd,2), RFIFOP(fd,6)); @@ -12704,8 +12753,7 @@ void clif_parse_CreateGuild(int fd,struct map_session_data *sd) safestrncpy(name, RFIFOP(fd,6), NAME_LENGTH); if(map->list[sd->bl.m].flag.guildlock) { - //Guild locked. - clif->message(fd, msg_fd(fd,228)); + clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } @@ -12831,7 +12879,8 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) { int header = 0, bitmap = 0, offbits = 0, palettesize = 0; nullpo_retr(false, emblem); - if( decode_zip(buf, &buf_len, emblem, emblem_len) != 0 || buf_len < BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE + if (grfio->decode_zip(buf, &buf_len, emblem, emblem_len) != 0 + || buf_len < BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE || RBUFW(buf,0) != 0x4d42 // BITMAPFILEHEADER.bfType (signature) || RBUFL(buf,2) != buf_len // BITMAPFILEHEADER.bfSize (file size) || RBUFL(buf,14) != BITMAPINFOHEADER_SIZE // BITMAPINFOHEADER.biSize (other headers are not supported) @@ -12980,8 +13029,7 @@ bool clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_sessi nullpo_retr(false, sd); nullpo_retr(false, t_sd); if ( map->list[sd->bl.m].flag.guildlock ) { - //Guild locked. - clif->message(fd, msg_fd(fd,228)); + clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return false; } @@ -13034,8 +13082,7 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd) __attribute__((no /// 0159 <guild id>.L <account id>.L <char id>.L <reason>.40B void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { if(map->list[sd->bl.m].flag.guildlock) { - //Guild locked. - clif->message(fd, msg_fd(fd,228)); + clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } if( sd->bg_id ) { @@ -13051,8 +13098,7 @@ void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) __attribute__ /// 015b <guild id>.L <account id>.L <char id>.L <reason>.40B void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) { if( map->list[sd->bl.m].flag.guildlock || sd->bg_id ) { - // Guild locked. - clif->message(fd, msg_fd(fd,228)); + clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } guild->expulsion(sd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOP(fd,14)); @@ -13093,8 +13139,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) { return; if(map->list[sd->bl.m].flag.guildlock) { - //Guild locked. - clif->message(fd, msg_fd(fd,228)); + clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } @@ -13131,8 +13176,7 @@ void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) { return; if(map->list[sd->bl.m].flag.guildlock) { - //Guild locked. - clif->message(fd, msg_fd(fd,228)); + clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } guild->delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6)); @@ -13148,8 +13192,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { return; if(map->list[sd->bl.m].flag.guildlock) { - //Guild locked. - clif->message(fd, msg_fd(fd,228)); + clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } @@ -13172,8 +13215,7 @@ void clif_parse_GuildBreak(int fd, struct map_session_data *sd) __attribute__((n /// field name and size is same as the one in CH_DELETE_CHAR. void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { if( map->list[sd->bl.m].flag.guildlock ) { - //Guild locked. - clif->message(fd, msg_fd(fd,228)); + clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } guild->dobreak(sd, RFIFOP(fd,2)); @@ -13887,7 +13929,7 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) // Friend doesn't exist (no player with this name) if (f_sd == NULL) { - clif->message(fd, msg_fd(fd,3)); + clif->message(fd, msg_fd(fd,3)); // "Character not found." return; } @@ -15232,7 +15274,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd) // Auction checks... if( sd->status.inventory[sd->auction.index].bound && !pc_can_give_bound_items(sd) ) { - clif->message(sd->fd, msg_sd(sd,293)); + clif->message(sd->fd, msg_sd(sd,293)); // This bound item cannot be traded to that character. clif->auction_message(fd, 2); // The auction has been canceled return; } @@ -15285,7 +15327,7 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd) int bid = RFIFOL(fd,6); if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish] - clif->message(sd->fd, msg_sd(sd,246)); + clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. return; } @@ -18297,7 +18339,7 @@ void clif_parse_RouletteOpen(int fd, struct map_session_data* sd) { struct packet_roulette_open_ack p; if( !battle_config.feature_roulette ) { - clif->message(fd,"Roulette is disabled"); + clif->message(fd, msg_fd(fd,82)); // Roulette is disabled return; } @@ -18320,7 +18362,7 @@ void clif_parse_RouletteInfo(int fd, struct map_session_data* sd) { unsigned short i, j, count = 0; if( !battle_config.feature_roulette ) { - clif->message(fd,"Roulette is disabled"); + clif->message(fd, msg_fd(fd,82)); // Roulette is disabled return; } @@ -18344,7 +18386,7 @@ void clif_parse_RouletteInfo(int fd, struct map_session_data* sd) { void clif_parse_RouletteClose(int fd, struct map_session_data* sd) __attribute__((nonnull (2))); void clif_parse_RouletteClose(int fd, struct map_session_data* sd) { if( !battle_config.feature_roulette ) { - clif->message(fd,"Roulette is disabled"); + clif->message(fd, msg_fd(fd,82)); // Roulette is disabled return; } @@ -18360,7 +18402,7 @@ void clif_parse_RouletteGenerate(int fd, struct map_session_data* sd) { short stage = sd->roulette.stage; if( !battle_config.feature_roulette ) { - clif->message(fd,"Roulette is disabled"); + clif->message(fd, msg_fd(fd,82)); // Roulette is disabled return; } @@ -18416,7 +18458,7 @@ void clif_parse_RouletteRecvItem(int fd, struct map_session_data* sd) { struct packet_roulette_itemrecv_ack p; if( !battle_config.feature_roulette ) { - clif->message(fd,"Roulette is disabled"); + clif->message(fd, msg_fd(fd,82)); // Roulette is disabled return; } @@ -19272,6 +19314,7 @@ void clif_defaults(void) { clif->autoshadowspell_list = clif_autoshadowspell_list; clif->skill_itemlistwindow = clif_skill_itemlistwindow; clif->sc_load = clif_status_change2; + clif->sc_continue = clif_status_change2; clif->sc_end = clif_status_change_end; clif->initialstatus = clif_initialstatus; clif->cooldown_list = clif_skill_cooldown_list; @@ -19305,7 +19348,7 @@ void clif_defaults(void) { clif->skill_poseffect = clif_skill_poseffect; clif->skill_estimation = clif_skill_estimation; clif->skill_warppoint = clif_skill_warppoint; - clif->skillcasting = clif_skillcasting; + clif->useskill = clif_useskill; clif->produce_effect = clif_produceeffect; clif->devotion = clif_devotion; clif->spiritball = clif_spiritball; @@ -19591,6 +19634,9 @@ void clif_defaults(void) { clif->ackmergeitems = clif_ackmergeitems; /* Cart Deco */ clif->selectcart = clif_selectcart; + /* */ + clif->isdisguised = clif_isdisguised; + clif->bl_type = clif_bl_type; /*------------------------ *- Parse Incoming Packet diff --git a/src/map/clif.h b/src/map/clif.h index 4d22fd4af..8b75a32f3 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -520,7 +520,7 @@ enum CLOSE_ROULETTE_ACK { /** * Reason for item deletion (clif->delitem) - */ + **/ enum delitem_reason { DELITEM_NORMAL = 0, /// Normal DELITEM_SKILLUSE = 1, /// Item used for a skill @@ -532,9 +532,9 @@ enum delitem_reason { DELITEM_ANALYSIS = 7, /// Consumed by Four Spirit Analysis (SO_EL_ANALYSIS) skill }; -/* -* Merge items reasons -*/ +/** + * Merge items reasons + **/ enum mergeitem_reason { MERGEITEM_SUCCESS = 0x0, @@ -543,6 +543,23 @@ enum mergeitem_reason { }; /** + * Clif Unit Type + **/ +enum clif_unittype { + CLUT_PC = 0x0, + CLUT_NPC = 0x1, + CLUT_ITEM = 0x2, + CLUT_SKILL = 0x3, + CLUT_UNKNOWN = 0x4, + CLUT_MOB = 0x5, + CLUT_EVENT = 0x6, + CLUT_PET = 0x7, + CLUT_HOMNUCLUS = 0x8, + CLUT_MERCNARY = 0x9, + CLUT_ELEMENTAL = 0xa, +}; + +/** * Structures **/ typedef void (*pFunc)(int, struct map_session_data *); //cant help but put it first @@ -563,8 +580,8 @@ struct cdelayed_damage { }; struct merge_item { - int16 position; - int16 nameid; + int16 position; + int16 nameid; }; /** @@ -774,6 +791,7 @@ struct clif_interface { int (*autoshadowspell_list) (struct map_session_data *sd); int (*skill_itemlistwindow) ( struct map_session_data *sd, uint16 skill_id, uint16 skill_lv ); void (*sc_load) (struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3); + void (*sc_continue) (struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3); void (*sc_end) (struct block_list *bl, int tid, enum send_target target, int type); void (*initialstatus) (struct map_session_data *sd); void (*cooldown_list) (int fd, struct skill_cd* cd); @@ -807,7 +825,7 @@ struct clif_interface { void (*skill_poseffect) (struct block_list *src, uint16 skill_id, int val, int x, int y, int64 tick); void (*skill_estimation) (struct map_session_data *sd,struct block_list *dst); void (*skill_warppoint) (struct map_session_data* sd, uint16 skill_id, uint16 skill_lv, unsigned short map1, unsigned short map2, unsigned short map3, unsigned short map4); - void (*skillcasting) (struct block_list* bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, int property, int casttime); + void (*useskill) (struct block_list* bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, uint16 skill_lv, int casttime); void (*produce_effect) (struct map_session_data* sd,int flag,int nameid); void (*devotion) (struct block_list *src, struct map_session_data *tsd); void (*spiritball) (struct block_list *bl); @@ -1091,7 +1109,9 @@ struct clif_interface { void (*cancelmergeitem) (int fd, struct map_session_data *sd); int (*comparemergeitem) (const void *a, const void *b); void (*ackmergeitems) (int fd, struct map_session_data *sd); - + /* */ + bool (*isdisguised) (struct block_list* bl); + unsigned char (*bl_type) (struct block_list *bl); /*------------------------ *- Parse Incoming Packet *------------------------*/ diff --git a/src/map/guild.c b/src/map/guild.c index 1929808ca..83afc9538 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -399,8 +399,11 @@ int guild_created(int account_id,int guild_id) { //struct guild *g; sd->status.guild_id=guild_id; clif->guild_created(sd,0); // Success - if(battle_config.guild_emperium_check) - pc->delitem(sd, pc->search_inventory(sd, ITEMID_EMPERIUM), 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME); //emperium consumption + if (battle_config.guild_emperium_check) { + int n = pc->search_inventory(sd, ITEMID_EMPERIUM); + if (n != INDEX_NOT_FOUND) + pc->delitem(sd, n, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME); //emperium consumption + } return 0; } @@ -413,20 +416,18 @@ int guild_request_info(int guild_id) //Information request with event int guild_npc_request_info(int guild_id,const char *event) { - if( guild->search(guild_id) ) - { - if( event && *event ) + if (guild->search(guild_id) != NULL) { + if (event != NULL && *event != '\0') npc->event_do(event); return 0; } - if( event && *event ) - { + if (event != NULL && *event != '\0') { struct eventlist *ev; struct DBData prev; - ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1); - memcpy(ev->name,event,strlen(event)); + CREATE(ev, struct eventlist, 1); + safestrncpy(ev->name, event, sizeof(ev->name)); //The one in the db (if present) becomes the next event from this. if (guild->infoevent_db->put(guild->infoevent_db, DB->i2key(guild_id), DB->ptr2data(ev), &prev)) ev->next = DB->data2ptr(&prev); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 66cce23e6..080a314b8 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -356,14 +356,14 @@ bool homunculus_levelup(struct homun_data *hd) { max = &hd->homunculusDB->gmax; min = &hd->homunculusDB->gmin; - growth_max_hp = rnd_value(min->HP, max->HP); - growth_max_sp = rnd_value(min->SP, max->SP); - growth_str = rnd_value(min->str, max->str); - growth_agi = rnd_value(min->agi, max->agi); - growth_vit = rnd_value(min->vit, max->vit); - growth_dex = rnd_value(min->dex, max->dex); - growth_int = rnd_value(min->int_,max->int_); - growth_luk = rnd_value(min->luk, max->luk); + growth_max_hp = rnd->value(min->HP, max->HP); + growth_max_sp = rnd->value(min->SP, max->SP); + growth_str = rnd->value(min->str, max->str); + growth_agi = rnd->value(min->agi, max->agi); + growth_vit = rnd->value(min->vit, max->vit); + growth_dex = rnd->value(min->dex, max->dex); + growth_int = rnd->value(min->int_,max->int_); + growth_luk = rnd->value(min->luk, max->luk); //Aegis discards the decimals in the stat growth values! growth_str-=growth_str%10; @@ -432,14 +432,14 @@ bool homunculus_evolve(struct homun_data *hd) { hom = &hd->homunculus; max = &hd->homunculusDB->emax; min = &hd->homunculusDB->emin; - hom->max_hp += rnd_value(min->HP, max->HP); - hom->max_sp += rnd_value(min->SP, max->SP); - hom->str += 10*rnd_value(min->str, max->str); - hom->agi += 10*rnd_value(min->agi, max->agi); - hom->vit += 10*rnd_value(min->vit, max->vit); - hom->int_+= 10*rnd_value(min->int_,max->int_); - hom->dex += 10*rnd_value(min->dex, max->dex); - hom->luk += 10*rnd_value(min->luk, max->luk); + hom->max_hp += rnd->value(min->HP, max->HP); + hom->max_sp += rnd->value(min->SP, max->SP); + hom->str += 10*rnd->value(min->str, max->str); + hom->agi += 10*rnd->value(min->agi, max->agi); + hom->vit += 10*rnd->value(min->vit, max->vit); + hom->int_+= 10*rnd->value(min->int_,max->int_); + hom->dex += 10*rnd->value(min->dex, max->dex); + hom->luk += 10*rnd->value(min->luk, max->luk); hom->intimacy = 500; unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); @@ -848,7 +848,7 @@ bool homunculus_call(struct map_session_data *sd) { nullpo_retr(false, sd); if (!sd->status.hom_id) //Create a new homun. - return homun->creation_request(sd, HM_CLASS_BASE + rnd_value(0, 7)); + return homun->creation_request(sd, HM_CLASS_BASE + rnd->value(0, 7)); // If homunc not yet loaded, load it if (!sd->hd) @@ -1075,14 +1075,14 @@ bool homunculus_shuffle(struct homun_data *hd) { //Evolved bonuses struct s_homunculus *hom = &hd->homunculus; struct h_stats *max = &hd->homunculusDB->emax, *min = &hd->homunculusDB->emin; - hom->max_hp += rnd_value(min->HP, max->HP); - hom->max_sp += rnd_value(min->SP, max->SP); - hom->str += 10*rnd_value(min->str, max->str); - hom->agi += 10*rnd_value(min->agi, max->agi); - hom->vit += 10*rnd_value(min->vit, max->vit); - hom->int_+= 10*rnd_value(min->int_,max->int_); - hom->dex += 10*rnd_value(min->dex, max->dex); - hom->luk += 10*rnd_value(min->luk, max->luk); + hom->max_hp += rnd->value(min->HP, max->HP); + hom->max_sp += rnd->value(min->SP, max->SP); + hom->str += 10*rnd->value(min->str, max->str); + hom->agi += 10*rnd->value(min->agi, max->agi); + hom->vit += 10*rnd->value(min->vit, max->vit); + hom->int_+= 10*rnd->value(min->int_,max->int_); + hom->dex += 10*rnd->value(min->dex, max->dex); + hom->luk += 10*rnd->value(min->luk, max->luk); } hd->homunculus.exp = exp; diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 5820ad2cf..d087588af 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -326,7 +326,7 @@ void irc_privmsg_ctcp(int fd, char *cmd, char *source, char *target, char *msg) snprintf(send_string, IRC_MESSAGE_LENGTH, "NOTICE %s :\001TIME %s\001",source_nick,temp); ircbot->send(send_string, false); } else if( strcmpi(cmd,"VERSION") == 0 ) { - snprintf(send_string, IRC_MESSAGE_LENGTH, "NOTICE %s :\001VERSION Hercules.ws IRC Bridge\001",source_nick); + snprintf(send_string, IRC_MESSAGE_LENGTH, "NOTICE %s :\001VERSION Herc.ws IRC Bridge\001",source_nick); ircbot->send(send_string, false); #ifdef IRCBOT_DEBUG } else { diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index f73426693..54f462e35 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -83,7 +83,7 @@ struct irc_bot_interface { * @see do_sockets */ int (*parse) (int fd); - + /** * Parse a received message from the irc server, and do the appropriate action * for the detected command @@ -135,7 +135,7 @@ struct irc_bot_interface { * @see timer_interface::do_timer */ int (*queue_timer) (int tid, int64 tick, int id, intptr_t data); - + /** * Decides if an IRC Command should be queued or not, based on the flood protection settings. * @@ -155,7 +155,7 @@ struct irc_bot_interface { * @param msg Message text */ void (*relay) (const char *name, const char *msg); - + /** * Handler for the PING IRC command (send back a PONG) * @see irc_bot_interface::parse_sub diff --git a/src/map/itemdb.c b/src/map/itemdb.c index c59f627cc..350697a08 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -342,7 +342,7 @@ const char* itemdb_typename(int type) return "Unknown Type"; } - /** +/** * Converts the JobID to the format used by map-server to check item * restriction as per job. * @@ -1658,7 +1658,7 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) { void itemdb_readdb_additional_fields(int itemid, struct config_setting_t *it, int n, const char *source) { - // do nothing. plugins can do own work + // do nothing. plugins can do own work } /** diff --git a/src/map/map.c b/src/map/map.c index 3a7d752c3..d6425b94e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -683,49 +683,95 @@ static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int ( x1 = min(x1, map->list[m].xs - 1); y1 = min(y1, map->list[m].ys - 1); - for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) { - for (bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) { - if (type&~BL_MOB) { - for (bl = map->list[m].block[bx + by * map->list[m].bxs]; bl != NULL; bl = bl->next) { - if (bl->type&type && bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1) { - if( map->bl_list_count >= map->bl_list_size ) - map_bl_list_expand(); - if (func) { - va_start(args, func); - if (func(bl, args)) { + { + const int x0b = x0 / BLOCK_SIZE; + const int x1b = x1 / BLOCK_SIZE; + const int y0b = y0 / BLOCK_SIZE; + const int y1b = y1 / BLOCK_SIZE; + const struct map_data *const listm = &map->list[m]; + const int bxs0 = listm->bxs; + + // duplication for better performance + if (func != NULL) { + if (type & ~BL_MOB) { + for (by = y0b; by <= y1b; by++) { + const int bxs = by * bxs0; + for (bx = x0b; bx <= x1b; bx++) { + for (bl = listm->block[bx + bxs]; bl != NULL; bl = bl->next) { + const int x = bl->x; + const int y = bl->y; + if (bl->type & type && x >= x0 && x <= x1 && y >= y0 && y <= y1) { + va_start(args, func); + if (func(bl, args)) { + if (map->bl_list_count >= map->bl_list_size) + map_bl_list_expand(); + map->bl_list[map->bl_list_count++] = bl; + found++; + } + va_end(args); + } + } + } + } + } + if (type & BL_MOB) { + for (by = y0b; by <= y1b; by++) { + const int bxs = by * bxs0; + for (bx = x0b; bx <= x1b; bx++) { + for (bl = listm->block_mob[bx + bxs]; bl != NULL; bl = bl->next) { + const int x = bl->x; + const int y = bl->y; + if (x >= x0 && x <= x1 && y >= y0 && y <= y1) { + va_start(args, func); + if (func(bl, args)) { + if (map->bl_list_count >= map->bl_list_size) + map_bl_list_expand(); + map->bl_list[map->bl_list_count++] = bl; + found++; + } + va_end(args); + } + } + } + } + } + } else { // func != NULL + if (type & ~BL_MOB) { + for (by = y0b; by <= y1b; by++) { + const int bxs = by * bxs0; + for (bx = x0b; bx <= x1b; bx++) { + for (bl = listm->block[bx + bxs]; bl != NULL; bl = bl->next) { + const int x = bl->x; + const int y = bl->y; + if (bl->type & type && x >= x0 && x <= x1 && y >= y0 && y <= y1) { + if (map->bl_list_count >= map->bl_list_size) + map_bl_list_expand(); map->bl_list[map->bl_list_count++] = bl; found++; } - va_end(args); - } else { - map->bl_list[map->bl_list_count++] = bl; - found++; } } } } - if (type&BL_MOB) { // TODO: fix this code duplication - for (bl = map->list[m].block_mob[bx + by * map->list[m].bxs]; bl != NULL; bl = bl->next) { - if (bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1) { - if( map->bl_list_count >= map->bl_list_size ) - map_bl_list_expand(); - if (func) { - va_start(args, func); - if (func(bl, args)) { + if (type & BL_MOB) { + for (by = y0b; by <= y1b; by++) { + const int bxs = by * bxs0; + for (bx = x0b; bx <= x1b; bx++) { + for (bl = listm->block_mob[bx + bxs]; bl != NULL; bl = bl->next) { + const int x = bl->x; + const int y = bl->y; + if (x >= x0 && x <= x1 && y >= y0 && y <= y1) { + if (map->bl_list_count >= map->bl_list_size) + map_bl_list_expand(); map->bl_list[map->bl_list_count++] = bl; found++; } - va_end(args); - } else { - map->bl_list[map->bl_list_count++] = bl; - found++; } } } } } } - return found; } @@ -2851,7 +2897,7 @@ void map_cellfromcache(struct map_data *m) { size = (unsigned long)info->xs*(unsigned long)info->ys; // TO-DO: Maybe handle the scenario, if the decoded buffer isn't the same size as expected? [Shinryo] - decode_zip(decode_buffer, &size, m->cellPos+sizeof(struct map_cache_map_info), info->len); + grfio->decode_zip(decode_buffer, &size, m->cellPos+sizeof(struct map_cache_map_info), info->len); CREATE(m->cell, struct mapcell, size); // Set cell properties @@ -3579,17 +3625,18 @@ void map_flags_init(void) { int map_waterheight(char* mapname) { char fn[256]; - char *rsw, *found; + char *rsw = NULL; + const char *found; nullpo_retr(NO_WATER, mapname); //Look up for the rsw snprintf(fn, sizeof(fn), "data\\%s.rsw", mapname); - if ( (found = grfio_find_file(fn)) ) + if ((found = grfio->find_file(fn))) safestrncpy(fn, found, sizeof(fn)); // replace with real name // read & convert fn - rsw = (char *) grfio_read (fn); + rsw = grfio_read(fn); if (rsw) { //Load water height from file int wh = (int) *(float*)(rsw+166); @@ -3613,7 +3660,7 @@ int map_readgat (struct map_data* m) nullpo_ret(m); sprintf(filename, "data\\%s.gat", m->name); - gat = (uint8 *) grfio_read(filename); + gat = grfio_read(filename); if (gat == NULL) return 0; @@ -5677,8 +5724,8 @@ int do_final(void) { map->map_db->destroy(map->map_db, map->db_final); mapindex->final(); - if(map->enable_grf) - grfio_final(); + if (map->enable_grf) + grfio->final(); db_destroy(map->id_db); db_destroy(map->pc_db); @@ -6002,22 +6049,6 @@ static CMDLINEARG(loadscript) } /** - * --generate-translations - * - * Creates "./generated_translations.pot" - * @see cmdline->exec - **/ -static CMDLINEARG(generatetranslations) { - script->lang_export_file = aStrdup("./generated_translations.pot"); - - if( !(script->lang_export_fp = fopen(script->lang_export_file,"wb")) ) { - ShowError("export-dialog: failed to open '%s' for writing\n",script->lang_export_file); - } - core->runflag = CORE_ST_STOP; - return true; -} - -/** * Defines the local command line arguments */ void cmdline_args_init_local(void) @@ -6033,7 +6064,6 @@ void cmdline_args_init_local(void) CMDLINEARG_DEF2(log-config, logconfig, "Alternative logging configuration.", CMDLINE_OPT_NORMAL|CMDLINE_OPT_PARAM); CMDLINEARG_DEF2(script-check, scriptcheck, "Doesn't run the server, only tests the scripts passed through --load-script.", CMDLINE_OPT_SILENT); CMDLINEARG_DEF2(load-script, loadscript, "Loads an additional script (can be repeated).", CMDLINE_OPT_NORMAL|CMDLINE_OPT_PARAM); - CMDLINEARG_DEF2(generate-translations, generatetranslations, "Creates './generated_translations.pot' file with all translateable strings from scripts, server terminates afterwards.", CMDLINE_OPT_NORMAL); } int do_init(int argc, char *argv[]) @@ -6079,7 +6109,9 @@ int do_init(int argc, char *argv[]) char ip_str[16]; sockt->ip2str(sockt->addr_[0], ip_str); +#ifndef BUILDBOT ShowWarning("Not all IP addresses in /conf/map-server.conf configured, auto-detecting...\n"); +#endif if (sockt->naddr_ == 0) ShowError("Unable to determine your IP address...\n"); @@ -6137,8 +6169,8 @@ int do_init(int argc, char *argv[]) } } - if(map->enable_grf) - grfio_init(map->GRF_PATH_FILENAME); + if (map->enable_grf) + grfio->init(map->GRF_PATH_FILENAME); map->readallmaps(); diff --git a/src/map/mob.c b/src/map/mob.c index 19fee52a5..bede7deed 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2337,11 +2337,6 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if(flag) { if(base_exp || job_exp) { if( md->dmglog[i].flag != MDLF_PET || battle_config.pet_attack_exp_to_master ) { -#ifdef RENEWAL_EXP - int rate = pc->level_penalty_mod(md->level - (tmpsd[i])->status.base_level, md->status.race, md->status.mode, 1); - base_exp = (unsigned int)cap_value(base_exp * rate / 100, 1, UINT_MAX); - job_exp = (unsigned int)cap_value(job_exp * rate / 100, 1, UINT_MAX); -#endif pc->gainexp(tmpsd[i], &md->bl, base_exp, job_exp, false); } } @@ -2410,7 +2405,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { drop_rate += (int)(0.5+drop_rate*status_get_luk(src)*battle_config.drops_by_luk2/10000.); } if (sd && battle_config.pk_mode && - (int)(md->level - sd->status.base_level) >= 20) + md->level - sd->status.base_level >= 20) drop_rate = (int)(drop_rate*1.25); // pk_mode increase drops if 20 level difference [Valaris] // Increase drop rate if user has SC_CASH_RECEIVEITEM diff --git a/src/map/npc.c b/src/map/npc.c index 86e9e5e7a..945a84957 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -62,17 +62,6 @@ struct npc_interface npc_s; struct npc_interface *npc; -static int npc_id=START_NPC_NUM; -static int npc_warp=0; -static int npc_shop=0; -static int npc_script=0; -static int npc_mob=0; -static int npc_delay_mob=0; -static int npc_cache_mob=0; - -static const char *npc_last_path; -static const char *npc_last_ref; -struct npc_path_data *npc_last_npd; //For holding the view data of npc classes. [Skotlex] static struct view_data npc_viewdb[MAX_NPC_CLASS]; @@ -132,15 +121,15 @@ bool npc_db_checkid(int id) /// Returns a new npc id that isn't being used in id_db. /// Fatal error if nothing is available. int npc_get_new_npc_id(void) { - if( npc_id >= START_NPC_NUM && !map->blid_exists(npc_id) ) - return npc_id++;// available + if (npc->npc_id >= START_NPC_NUM && !map->blid_exists(npc->npc_id)) + return npc->npc_id++;// available else {// find next id - int base_id = npc_id; - while( base_id != ++npc_id ) { - if( npc_id < START_NPC_NUM ) - npc_id = START_NPC_NUM; - if( !map->blid_exists(npc_id) ) - return npc_id++;// available + int base_id = npc->npc_id; + while (base_id != ++npc->npc_id) { + if (npc->npc_id < START_NPC_NUM) + npc->npc_id = START_NPC_NUM; + if (!map->blid_exists(npc->npc_id)) + return npc->npc_id++;// available } // full loop, nothing available ShowFatalError("npc_get_new_npc_id: All ids are taken. Exiting..."); @@ -2509,10 +2498,10 @@ const char *npc_retainpathreference(const char *filepath) struct npc_path_data * npd = NULL; nullpo_ret(filepath); - if (npc_last_path == filepath) { - if (npc_last_npd != NULL) - npc_last_npd->references++; - return npc_last_ref; + if (npc->npc_last_path == filepath) { + if (npc->npc_last_npd != NULL) + npc->npc_last_npd->references++; + return npc->npc_last_ref; } if ((npd = strdb_get(npc->path_db,filepath)) == NULL) { @@ -2527,9 +2516,9 @@ const char *npc_retainpathreference(const char *filepath) npd->references++; - npc_last_npd = npd; - npc_last_ref = npd->path; - npc_last_path = filepath; + npc->npc_last_npd = npd; + npc->npc_last_ref = npd->path; + npc->npc_last_path = filepath; return npd->path; } @@ -2545,7 +2534,7 @@ void npc_releasepathreference(const char *filepath) nullpo_retv(filepath); - if (filepath != npc_last_ref) { + if (filepath != npc->npc_last_ref) { npd = strdb_get(npc->path_db, filepath); } @@ -2785,7 +2774,7 @@ const char *npc_parse_warp(const char *w1, const char *w2, const char *w3, const nd->u.warp.y = to_y; nd->u.warp.xs = xs; nd->u.warp.ys = ys; - npc_warp++; + npc->npc_warp++; npc->add_to_location(nd); @@ -2930,7 +2919,7 @@ const char *npc_parse_shop(const char *w1, const char *w2, const char *w3, const npc->parsename(nd, w3, start, buffer, filepath); nd->path = npc->retainpathreference(filepath); - ++npc_shop; + ++npc->npc_shop; npc->add_to_location(nd); return strchr(start,'\n');// continue @@ -3136,7 +3125,7 @@ const char *npc_parse_script(const char *w1, const char *w2, const char *w3, con if( options&NPO_TRADER ) nd->u.scr.trader = true; nd->u.scr.shop = NULL; - ++npc_script; + ++npc->npc_script; npc->add_to_location(nd); //----------------------------------------- @@ -3206,7 +3195,7 @@ bool npc_duplicate_script_sub(struct npc_data *nd, const struct npc_data *snd, i nullpo_retr(false, nd); nullpo_retr(false, snd); - ++npc_script; + ++npc->npc_script; nd->u.scr.xs = xs; nd->u.scr.ys = ys; nd->u.scr.script = snd->u.scr.script; @@ -3253,7 +3242,7 @@ bool npc_duplicate_shop_sub(struct npc_data *nd, const struct npc_data *snd, int nullpo_retr(false, nd); nullpo_retr(false, snd); - ++npc_shop; + ++npc->npc_shop; nd->u.shop.shop_item = snd->u.shop.shop_item; nd->u.shop.count = snd->u.shop.count; @@ -3271,7 +3260,7 @@ bool npc_duplicate_warp_sub(struct npc_data *nd, const struct npc_data *snd, int nullpo_retr(false, nd); nullpo_retr(false, snd); - ++npc_warp; + ++npc->npc_warp; nd->u.warp.xs = xs; nd->u.warp.ys = ys; nd->u.warp.mapindex = snd->u.warp.mapindex; @@ -3770,7 +3759,7 @@ const char *npc_parse_function(const char *w1, const char *w2, const char *w3, c struct script_code *oldscript = (struct script_code*)DB->data2ptr(&old_data); ShowWarning("npc_parse_function: Overwriting user function [%s] in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer)); script->free_vars(oldscript->local.vars); - aFree(oldscript->script_buf); + VECTOR_CLEAR(oldscript->script_buf); aFree(oldscript); } @@ -3967,7 +3956,7 @@ const char *npc_parse_mob(const char *w1, const char *w2, const char *w3, const // spawn / cache the new mobs if( battle_config.dynamic_mobs && map->addmobtolist(data->m, data) >= 0 ) { data->state.dynamic = true; - npc_cache_mob += data->num; + npc->npc_cache_mob += data->num; // check if target map has players // (usually shouldn't occur when map server is just starting, @@ -3978,10 +3967,10 @@ const char *npc_parse_mob(const char *w1, const char *w2, const char *w3, const } else { data->state.dynamic = false; npc->parse_mob2(data); - npc_delay_mob += data->num; + npc->npc_delay_mob += data->num; } - npc_mob++; + npc->npc_mob++; return strchr(start,'\n');// continue } @@ -4778,12 +4767,12 @@ void npc_process_files( int npc_min ) { "\t-'"CL_WHITE"%d"CL_RESET"' Spawn sets\n" "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n" "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", - npc_id - npc_min, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); + npc->npc_id - npc_min, npc->npc_warp, npc->npc_shop, npc->npc_script, npc->npc_mob, npc->npc_cache_mob, npc->npc_delay_mob); } //Clear then reload npcs files int npc_reload(void) { - int npc_new_min = npc_id; + int npc_new_min = npc->npc_id; struct s_mapiterator* iter; struct block_list* bl; @@ -4799,9 +4788,9 @@ int npc_reload(void) { db_clear(npc->ev_db); npc->ev_label_db->clear(npc->ev_label_db, npc->ev_label_db_clear_sub); - npc_last_npd = NULL; - npc_last_path = NULL; - npc_last_ref = NULL; + npc->npc_last_npd = NULL; + npc->npc_last_path = NULL; + npc->npc_last_ref = NULL; //Remove all npcs/mobs. [Skotlex] iter = mapit_geteachiddb(); @@ -4841,8 +4830,8 @@ int npc_reload(void) { // clear mob spawn lookup index mob->clear_spawninfo(); - npc_warp = npc_shop = npc_script = 0; - npc_mob = npc_cache_mob = npc_delay_mob = 0; + npc->npc_warp = npc->npc_shop = npc->npc_script = 0; + npc->npc_mob = npc->npc_cache_mob = npc->npc_delay_mob = 0; // reset mapflags map->flags_init(); @@ -4982,9 +4971,9 @@ int do_init_npc(bool minimal) { npc->name_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH); npc->path_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0); - npc_last_npd = NULL; - npc_last_path = NULL; - npc_last_ref = NULL; + npc->npc_last_npd = NULL; + npc->npc_last_path = NULL; + npc->npc_last_ref = NULL; // Should be loaded before npc processing, otherwise labels could overwrite constant values // and lead to undefined behavior [Panikon] @@ -5013,12 +5002,6 @@ int do_init_npc(bool minimal) { timer->add_func_list(npc->timerevent,"npc_timerevent"); } - if( script->lang_export_fp ) { - ShowInfo("Lang exported to '%s'\n",script->lang_export_file); - fclose(script->lang_export_fp); - script->lang_export_fp = NULL; - } - // Init dummy NPC CREATE(npc->fake_nd, struct npc_data, 1); npc->fake_nd->bl.m = -1; @@ -5028,7 +5011,7 @@ int do_init_npc(bool minimal) { strcpy(npc->fake_nd->name,"FAKE_NPC"); memcpy(npc->fake_nd->exname, npc->fake_nd->name, 9); - npc_script++; + npc->npc_script++; npc->fake_nd->bl.type = BL_NPC; npc->fake_nd->subtype = SCRIPT; @@ -5042,6 +5025,17 @@ int do_init_npc(bool minimal) { void npc_defaults(void) { npc = &npc_s; + npc->npc_id = START_NPC_NUM; + npc->npc_warp = 0; + npc->npc_shop = 0; + npc->npc_script = 0; + npc->npc_mob = 0; + npc->npc_delay_mob = 0; + npc->npc_cache_mob = 0; + npc->npc_last_path = NULL; + npc->npc_last_ref = NULL; + npc->npc_last_npd = NULL; + npc->motd = NULL; npc->ev_db = NULL; npc->ev_label_db = NULL; diff --git a/src/map/npc.h b/src/map/npc.h index 8ee59e410..24ea9ea59 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -188,6 +188,16 @@ struct npc_interface { /* npc trader global data, for ease of transition between the script, cleared on every usage */ bool trader_ok; int trader_funds[2]; + int npc_id; + int npc_warp; + int npc_shop; + int npc_script; + int npc_mob; + int npc_delay_mob; + int npc_cache_mob; + const char *npc_last_path; + const char *npc_last_ref; + struct npc_path_data *npc_last_npd; /* */ int (*init) (bool minimal); int (*final) (void); diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 6726c65a9..4bd7d416d 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -100,6 +100,7 @@ struct pcre_interface *libpcre; */ void finalize_pcrematch_entry(struct pcrematch_entry* e) { + nullpo_retv(e); libpcre->free(e->pcre_); libpcre->free(e->pcre_extra_); aFree(e->pattern); @@ -111,7 +112,10 @@ void finalize_pcrematch_entry(struct pcrematch_entry* e) */ struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid) { struct pcrematch_set *pcreset; - struct npc_parse *npcParse = nd->chatdb; + struct npc_parse *npcParse; + + nullpo_retr(NULL, nd); + npcParse = nd->chatdb; if (npcParse == NULL) nd->chatdb = npcParse = (struct npc_parse *)aCalloc(sizeof(struct npc_parse), 1); @@ -151,7 +155,9 @@ struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid) { void activate_pcreset(struct npc_data* nd, int setid) { struct pcrematch_set *pcreset; - struct npc_parse *npcParse = nd->chatdb; + struct npc_parse *npcParse; + nullpo_retv(nd); + npcParse = nd->chatdb; if (npcParse == NULL) return; // Nothing to activate... pcreset = npcParse->inactive; @@ -184,7 +190,9 @@ void activate_pcreset(struct npc_data* nd, int setid) void deactivate_pcreset(struct npc_data* nd, int setid) { struct pcrematch_set *pcreset; - struct npc_parse *npcParse = nd->chatdb; + struct npc_parse *npcParse; + nullpo_retv(nd); + npcParse = nd->chatdb; if (npcParse == NULL) return; // Nothing to deactivate... if (setid == -1) { @@ -221,7 +229,9 @@ void delete_pcreset(struct npc_data* nd, int setid) { int active = 1; struct pcrematch_set *pcreset; - struct npc_parse *npcParse = nd->chatdb; + struct npc_parse *npcParse; + nullpo_retv(nd); + npcParse = nd->chatdb; if (npcParse == NULL) return; // Nothing to deactivate... pcreset = npcParse->active; @@ -269,8 +279,12 @@ void delete_pcreset(struct npc_data* nd, int setid) */ struct pcrematch_entry* create_pcrematch_entry(struct pcrematch_set* set) { - struct pcrematch_entry * e = (struct pcrematch_entry *) aCalloc(sizeof(struct pcrematch_entry), 1); - struct pcrematch_entry * last = set->head; + struct pcrematch_entry *e; + struct pcrematch_entry *last; + + nullpo_retr(NULL, set); + e = (struct pcrematch_entry *)aCalloc(sizeof(struct pcrematch_entry), 1); + last = set->head; // Normally we would have just stuck it at the end of the list but // this doesn't sink up with peoples usage pattern. They wanted @@ -303,6 +317,7 @@ void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, c struct pcrematch_set * s = npc_chat->lookup_pcreset(nd, setid); struct pcrematch_entry *e = npc_chat->create_pcrematch_entry(s); + nullpo_retv(e); e->pattern = aStrdup(pattern); e->label = aStrdup(label); e->pcre_ = libpcre->compile(pattern, PCRE_CASELESS, &err, &erroff, NULL); @@ -317,7 +332,10 @@ void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, c */ void npc_chat_finalize(struct npc_data* nd) { - struct npc_parse *npcParse = nd->chatdb; + struct npc_parse *npcParse; + + nullpo_retv(nd); + npcParse = nd->chatdb; if (npcParse == NULL) return; @@ -358,6 +376,8 @@ int npc_chat_sub(struct block_list* bl, va_list ap) len = va_arg(ap,int); sd = va_arg(ap,struct map_session_data *); + nullpo_ret(sd); + // iterate across all active sets for (pcreset = npcParse->active; pcreset != NULL; pcreset = pcreset->next) { @@ -373,7 +393,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap) // save out the matched strings for (i = 0; i < r; i++) { - char var[6], val[255]; + char var[12], val[255]; snprintf(var, sizeof(var), "$@p%i$", i); libpcre->copy_substring(msg, offsets, r, i, val, sizeof(val)); script->set_var(sd, var, val); diff --git a/src/map/party.c b/src/map/party.c index dbb7b6ae2..c471cceb9 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -58,6 +58,9 @@ struct party_interface *party; * Used when creating/adding people to a party. [Skotlex] *------------------------------------------*/ void party_fill_member(struct party_member* member, struct map_session_data* sd, unsigned int leader) { + nullpo_retv(member); + nullpo_retv(sd); + member->account_id = sd->status.account_id; member->char_id = sd->status.char_id; safestrncpy(member->name, sd->status.name, NAME_LENGTH); @@ -162,6 +165,9 @@ int party_create(struct map_session_data *sd, const char *name,int item,int item struct party_member leader; char tname[NAME_LENGTH]; + nullpo_retr(0, sd); + nullpo_retr(0, name); + safestrncpy(tname, name, NAME_LENGTH); trim(tname); @@ -228,6 +234,7 @@ int party_recv_noinfo(int party_id, int char_id) { void party_check_state(struct party_data *p) { int i; + nullpo_retv(p); memset(&p->state, 0, sizeof(p->state)); for (i = 0; i < MAX_PARTY; i ++) { if (!p->party.member[i].online) continue; //Those not online shouldn't apart to skill usage and all that. @@ -355,7 +362,7 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd) ARR_FIND(0, MAX_PARTY, i, p->data[i].sd == sd); if( i == MAX_PARTY || !p->party.member[i].leader ) { - clif->message(sd->fd, msg_sd(sd,282)); + clif->message(sd->fd, msg_sd(sd,282)); // You need to be a party leader to use this command. return 0; } @@ -407,6 +414,8 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag) { struct map_session_data* tsd; struct party_member member; + nullpo_retv(sd); + if( sd->party_invite != party_id ) {// forged sd->party_invite = 0; @@ -436,8 +445,11 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag) { //- Player must be authed/active and belong to a party before calling this method void party_member_joined(struct map_session_data *sd) { - struct party_data* p = party->search(sd->status.party_id); + struct party_data* p; int i; + + nullpo_retv(sd); + p = party->search(sd->status.party_id); if (!p) { party->request_info(sd->status.party_id, sd->status.char_id); return; @@ -536,6 +548,7 @@ int party_removemember(struct map_session_data* sd, int account_id, const char * if( !p->party.member[i].leader ) return 0; // only party leader may remove members + nullpo_retr(0, name); ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && strncmp(p->party.member[i].name,name,NAME_LENGTH) == 0 ); if( i == MAX_PARTY ) return 0; // no such char in party @@ -550,6 +563,7 @@ int party_leave(struct map_session_data *sd) struct party_data *p; int i; + nullpo_ret(sd); p = party->search(sd->status.party_id); if( p == NULL ) return 0; @@ -668,12 +682,12 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts return false; if (!tsd || tsd->status.party_id != sd->status.party_id) { - clif->message(sd->fd, msg_sd(sd,283)); + clif->message(sd->fd, msg_sd(sd,283)); // Target character must be online and in your current party. return false; } if( map->list[sd->bl.m].flag.partylock ) { - clif->message(sd->fd, msg_sd(sd,287)); + clif->message(sd->fd, msg_sd(sd,287)); // You cannot change party leaders in this map. return false; } @@ -685,8 +699,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts return false; //Shouldn't happen if (!p->party.member[mi].leader) { - //Need to be a party leader. - clif->message(sd->fd, msg_sd(sd,282)); + clif->message(sd->fd, msg_sd(sd,282)); // You need to be a party leader to use this command. return false; } @@ -743,6 +756,8 @@ void party_send_movemap(struct map_session_data *sd) { struct party_data *p; + nullpo_retv(sd); + if( sd->status.party_id==0 ) return; @@ -782,6 +797,8 @@ int party_send_logout(struct map_session_data *sd) struct party_data *p; int i; + nullpo_ret(sd); + if(!sd->status.party_id) return 0; @@ -800,9 +817,12 @@ int party_send_logout(struct map_session_data *sd) int party_send_message(struct map_session_data *sd, const char *mes) { - int len = (int)strlen(mes); + int len; nullpo_ret(sd); + nullpo_ret(mes); + + len = (int)strlen(mes); if (sd->status.party_id == 0) return 0; @@ -847,6 +867,8 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id return 0; //Unknown case? } + nullpo_ret(sd); + for(i=0;i<MAX_PARTY;i++){ if ((p_sd = p->data[i].sd) == NULL) continue; @@ -934,11 +956,9 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b { struct map_session_data* sd[MAX_PARTY]; unsigned int i, c; -#ifdef RENEWAL_EXP - unsigned int job_exp_bonus, base_exp_bonus; -#endif nullpo_ret(p); + nullpo_ret(src); // count the number of players eligible for exp sharing for (i = c = 0; i < MAX_PARTY; i++) { @@ -963,21 +983,7 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX); } -#ifdef RENEWAL_EXP - base_exp_bonus = base_exp; - job_exp_bonus = job_exp; -#endif - for (i = 0; i < c; i++) { -#ifdef RENEWAL_EXP - struct mob_data *md = BL_CAST(BL_MOB, src); - if (md != NULL && md->db->mexp == 0) { - int rate = pc->level_penalty_mod(md->level - (sd[i])->status.base_level, md->status.race, md->status.mode, 1); - - base_exp = (unsigned int)cap_value(base_exp_bonus * rate / 100, 1, UINT_MAX); - job_exp = (unsigned int)cap_value(job_exp_bonus * rate / 100, 1, UINT_MAX); - } -#endif pc->gainexp(sd[i], src, base_exp, job_exp, false); if (zeny) // zeny from mobs [Valaris] @@ -991,8 +997,12 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i { struct map_session_data *target = NULL; int i; + + nullpo_ret(item_data); + if (p && p->party.item&2 && (first_charid || !(battle_config.party_share_type&1))) { + nullpo_ret(sd); //item distribution to party members. if (battle_config.party_share_type&2) { //Round Robin @@ -1054,6 +1064,7 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i int party_send_dot_remove(struct map_session_data *sd) { + nullpo_ret(sd); if (sd->status.party_id) clif->party_xy_remove(sd); return 0; @@ -1069,6 +1080,7 @@ int party_sub_count(struct block_list *bl, va_list ap) nullpo_ret(bl); Assert_ret(bl->type == BL_PC); sd = BL_UCCAST(BL_PC, bl); + nullpo_ret(sd); if (sd->state.autotrade) return 0; @@ -1181,6 +1193,9 @@ void party_recruit_register(struct map_session_data *sd, short level, const char #ifdef PARTY_RECRUIT struct party_booking_ad_info *pb_ad; + nullpo_retv(sd); + nullpo_retv(notice); + pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); if( pb_ad == NULL ) @@ -1211,6 +1226,9 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi struct party_booking_ad_info *pb_ad; int i; + nullpo_retv(sd); + nullpo_retv(job); + pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); if( pb_ad == NULL ) { @@ -1244,6 +1262,7 @@ void party_recruit_update(struct map_session_data *sd, const char *notice) { #ifdef PARTY_RECRUIT struct party_booking_ad_info *pb_ad; + nullpo_retv(sd); pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); if( pb_ad == NULL ) @@ -1265,6 +1284,9 @@ void party_booking_update(struct map_session_data *sd, short* job) { int i; struct party_booking_ad_info *pb_ad; + nullpo_retv(sd); + nullpo_retv(job); + pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); if( pb_ad == NULL ) @@ -1291,6 +1313,7 @@ void party_recruit_search(struct map_session_data *sd, short level, short mapid, bool more_result = false; struct DBIterator *iter = db_iterator(party->booking_db); + nullpo_retv(sd); memset(result_list, 0, sizeof(result_list)); for( pb_ad = dbi_first(iter); dbi_exists(iter); pb_ad = dbi_next(iter) ) @@ -1322,6 +1345,8 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid, bool more_result = false; struct DBIterator *iter = db_iterator(party->booking_db); + nullpo_retv(sd); + memset(result_list, 0, sizeof(result_list)); for( pb_ad = dbi_first(iter); dbi_exists(iter); pb_ad = dbi_next(iter) ) { @@ -1357,6 +1382,8 @@ bool party_booking_delete(struct map_session_data *sd) { struct party_booking_ad_info* pb_ad; + nullpo_retr(false, sd); + if((pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id))!=NULL) { #ifdef PARTY_RECRUIT diff --git a/src/map/path.c b/src/map/path.c index 0df9708d8..f5e08d4df 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -89,6 +89,7 @@ int path_blownpos(struct block_list *bl, int16 m,int16 x0,int16 y0,int16 dx,int1 { struct map_data *md; + Assert_retr(-1, m >= 0 && m < map->count); if( !map->list[m].cell ) return -1; md = &map->list[m]; @@ -126,6 +127,8 @@ bool path_search_long(struct shootpath_data *spd,struct block_list *bl,int16 m,i struct map_data *md; struct shootpath_data s_spd; + Assert_retr(false, m >= 0 && m < map->count); + if( spd == NULL ) spd = &s_spd; // use dummy output variable @@ -258,6 +261,8 @@ bool path_search(struct walkpath_data *wpd, struct block_list *bl, int16 m, int1 struct map_data *md; struct walkpath_data s_wpd; + Assert_retr(false, m >= 0 && m < map->count); + if (wpd == NULL) wpd = &s_wpd; // use dummy output variable diff --git a/src/map/pc.c b/src/map/pc.c index 1c635e5cf..414b236d7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -81,8 +81,10 @@ struct pc_interface *pc; //Note that it does not do a validity check for speed purposes, where parsing //player input make sure to use a pc->db_checkid first! int pc_class2idx(int class_) { - if (class_ >= JOB_NOVICE_HIGH) - return class_- JOB_NOVICE_HIGH+JOB_MAX_BASIC; + if (class_ >= JOB_NOVICE_HIGH) { + class_ += - JOB_NOVICE_HIGH + JOB_MAX_BASIC; + } + Assert_ret(class_ >= 0 && class_ < CLASS_COUNT); return class_; } @@ -109,6 +111,7 @@ struct map_session_data* pc_get_dummy_sd(void) int pc_set_group(struct map_session_data *sd, int group_id) { GroupSettings *group = pcg->id2group(group_id); + nullpo_retr(1, sd); if (group == NULL) return 1; sd->group_id = group_id; @@ -121,6 +124,7 @@ int pc_set_group(struct map_session_data *sd, int group_id) */ bool pc_should_log_commands(struct map_session_data *sd) { + nullpo_retr(true, sd); return pcg->should_log_commands(sd->group); } @@ -141,7 +145,8 @@ int pc_invincible_timer(int tid, int64 tick, int id, intptr_t data) return 0; } -void pc_setinvincibletimer(struct map_session_data* sd, int val) { +void pc_setinvincibletimer(struct map_session_data* sd, int val) +{ nullpo_retv(sd); val += map->list[sd->bl.m].invincible_time_inc; @@ -466,6 +471,7 @@ int pc_inventory_rental_end(int tid, int64 tick, int id, intptr_t data) { int pc_inventory_rental_clear(struct map_session_data *sd) { + nullpo_ret(sd); if( sd->rental_timer != INVALID_TIMER ) { timer->delete(sd->rental_timer, pc->inventory_rental_end); @@ -476,7 +482,11 @@ int pc_inventory_rental_clear(struct map_session_data *sd) } /* assumes i is valid (from default areas where it is called, it is) */ void pc_rental_expire(struct map_session_data *sd, int i) { - short nameid = sd->status.inventory[i].nameid; + short nameid; + + nullpo_retv(sd); + Assert_retv(i >= 0 && i < MAX_INVENTORY); + nameid = sd->status.inventory[i].nameid; /* Soon to be dropped, we got plans to integrate it with item db */ switch( nameid ) { @@ -547,6 +557,7 @@ void pc_inventory_rentals(struct map_session_data *sd) int i, c = 0; int64 expire_tick, next_tick = INT64_MAX; + nullpo_retv(sd); for( i = 0; i < MAX_INVENTORY; i++ ) { // Check for Rentals on Inventory if( sd->status.inventory[i].nameid == 0 ) @@ -686,6 +697,7 @@ int pc_equippoint(struct map_session_data *sd,int n) int ep = 0; nullpo_ret(sd); + Assert_ret(n >= 0 && n < MAX_INVENTORY); if(!sd->inventory_data[n]) return 0; @@ -812,6 +824,7 @@ bool pc_isequipped(struct map_session_data *sd, int nameid) { int i, j; + nullpo_retr(false, sd); for (i = 0; i < EQI_MAX; i++) { int index = sd->equip_index[i]; if( index < 0 ) continue; @@ -891,6 +904,7 @@ bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, if( !pc->can_Adopt(p1_sd, p2_sd, b_sd) ) return false; + nullpo_retr(false, b_sd); // Preserve current job levels and progress joblevel = b_sd->status.job_level; jobexp = b_sd->status.job_exp; @@ -946,11 +960,11 @@ int pc_isequip(struct map_session_data *sd,int n) if(pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) return 1; - if (item->elv && sd->status.base_level < (unsigned int)item->elv) { + if (item->elv && sd->status.base_level < item->elv) { clif->msgtable(sd, MSG_ITEM_CANT_EQUIP_LVL); return 0; } - if (item->elvmax && sd->status.base_level > (unsigned int)item->elvmax) { + if (item->elvmax && sd->status.base_level > item->elvmax) { clif->msgtable(sd, MSG_ITEM_CANT_EQUIP_LVL); return 0; } @@ -1039,7 +1053,10 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim { int i; int64 tick = timer->gettick(); - uint32 ip = sockt->session[sd->fd]->client_addr; + uint32 ip; + + nullpo_retr(false, sd); + ip = sockt->session[sd->fd]->client_addr; sd->login_id2 = login_id2; @@ -1269,6 +1286,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim *------------------------------------------*/ void pc_authfail(struct map_session_data *sd) { + nullpo_retv(sd); clif->authfail_fd(sd->fd, 0); return; } @@ -1306,6 +1324,7 @@ int pc_reg_received(struct map_session_data *sd) { int i, idx = 0; + nullpo_ret(sd); sd->vars_ok = true; sd->change_level_2nd = pc_readglobalreg(sd,script->add_str("jobchange_level")); @@ -1564,7 +1583,7 @@ int pc_calc_skilltree(struct map_session_data *sd) break; } } - if (sd->status.job_level < pc->skill_tree[c][i].joblv) { + if (sd->status.job_level < (int)pc->skill_tree[c][i].joblv) { int jobid = pc->mapid2jobid(sd->class_, sd->status.sex); // need to get its own skilltree if (jobid > -1) { if (!pc->skill_tree[pc->class2idx(jobid)][i].inherited) @@ -1632,6 +1651,7 @@ void pc_check_skilltree(struct map_session_data *sd, int skill_id) if(battle_config.skillfree) return; //Function serves no purpose if this is set + nullpo_retv(sd); i = pc->calc_skilltree_normalize_job(sd); c = pc->mapid2jobid(i, sd->status.sex); if (c == -1) { //Unable to normalize job?? @@ -1667,7 +1687,7 @@ void pc_check_skilltree(struct map_session_data *sd, int skill_id) if (!satisfied) continue; - if (sd->status.job_level < pc->skill_tree[c][i].joblv) { + if (sd->status.job_level < (int)pc->skill_tree[c][i].joblv) { int jobid = pc->mapid2jobid(sd->class_, sd->status.sex); // need to get its own skilltree if (jobid > -1) { if (!pc->skill_tree[pc->class2idx(jobid)][i].inherited) @@ -1697,6 +1717,7 @@ void pc_check_skilltree(struct map_session_data *sd, int skill_id) int pc_clean_skilltree(struct map_session_data *sd) { int i; + nullpo_ret(sd); for (i = 0; i < MAX_SKILL; i++){ if (sd->status.skill[i].flag == SKILL_FLAG_TEMPORARY || sd->status.skill[i].flag == SKILL_FLAG_PLAGIARIZED) { sd->status.skill[i].id = 0; @@ -1714,8 +1735,10 @@ int pc_clean_skilltree(struct map_session_data *sd) int pc_calc_skilltree_normalize_job(struct map_session_data *sd) { int skill_point, novice_skills; - int c = sd->class_; + int c; + nullpo_ret(sd); + c = sd->class_; if (!battle_config.skillup_limit || pc_has_permission(sd, PC_PERM_ALL_SKILL)) return c; @@ -1733,28 +1756,25 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) else if ((sd->class_&JOBL_2) && (sd->class_&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) { // regenerate change_level_2nd - if (!sd->change_level_2nd) - { - if (sd->class_&JOBL_THIRD) - { + if (sd->change_level_2nd == 0) { + if (sd->class_&JOBL_THIRD) { // if neither 2nd nor 3rd jobchange levels are known, we have to assume a default for 2nd - if (!sd->change_level_3rd) + if (sd->change_level_3rd == 0) { sd->change_level_2nd = pc->max_level[pc->class2idx(pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1]; - else + } else { sd->change_level_2nd = 1 + skill_point + sd->status.skill_point - (sd->status.job_level - 1) - (sd->change_level_3rd - 1) - novice_skills; - } - else - { + } + } else { sd->change_level_2nd = 1 + skill_point + sd->status.skill_point - (sd->status.job_level - 1) - novice_skills; } - pc_setglobalreg (sd, script->add_str("jobchange_level"), sd->change_level_2nd); + pc_setglobalreg(sd, script->add_str("jobchange_level"), sd->change_level_2nd); } if (skill_point < novice_skills + (sd->change_level_2nd - 1)) { @@ -1762,12 +1782,12 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) sd->sktree.second = ( novice_skills + (sd->change_level_2nd - 1) ) - skill_point; } else if(sd->class_&JOBL_THIRD) { // limit 3rd class to 2nd class/trans job levels // regenerate change_level_3rd - if (!sd->change_level_3rd) { + if (sd->change_level_3rd == 0) { sd->change_level_3rd = 1 + skill_point + sd->status.skill_point - (sd->status.job_level - 1) - (sd->change_level_2nd - 1) - novice_skills; - pc_setglobalreg (sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); + pc_setglobalreg(sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); } if (skill_point < novice_skills + (sd->change_level_2nd - 1) + (sd->change_level_3rd - 1)) { @@ -1822,6 +1842,7 @@ int pc_updateweightstatus(struct map_session_data *sd) } int pc_disguise(struct map_session_data *sd, int class_) { + nullpo_ret(sd); if (class_ == -1 && sd->disguise == -1) return 0; if (class_ >= 0 && sd->disguise == class_) @@ -1881,6 +1902,8 @@ int pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, s if( !rate ) return 0; + nullpo_ret(spell); + Assert_ret(max <= 15); // autospell array size for( i = 0; i < max && spell[i].id; i++ ) { if( (spell[i].card_id == card_id || spell[i].rate < 0 || rate < 0) && spell[i].id == id && spell[i].lv == lv ) @@ -1917,6 +1940,8 @@ int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_ski if( !rate ) return 0; + nullpo_ret(spell); + Assert_ret(max <= 15); // autospell array size for( i = 0; i < max && spell[i].id; i++ ) { ; // each autospell works independently @@ -1952,6 +1977,8 @@ int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_ski int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, int16 rate, int16 arrow_rate, uint8 flag, uint16 duration) { int i; + + nullpo_ret(effect); if (!(flag&(ATF_SHORT|ATF_LONG))) flag|=ATF_SHORT|ATF_LONG; //Default range: both if (!(flag&(ATF_TARGET|ATF_SELF))) @@ -1981,6 +2008,8 @@ int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, int16 int pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill_id, unsigned char target) { int i; + + nullpo_ret(effect); for( i = 0; i < max && effect[i].skill; i++ ) { if( effect[i].id == id && effect[i].skill == skill_id && effect[i].target == target ) { effect[i].rate += rate; @@ -2001,6 +2030,7 @@ int pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_ int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int race_mask, int rate) { int i; + nullpo_ret(drop); //Apply config rate adjustment settings. if (rate >= 0) { //Absolute drop. if (battle_config.item_rate_adddrop != 100) @@ -2048,6 +2078,8 @@ int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short int pc_addautobonus(struct s_autobonus *bonus,char max,const char *bonus_script,short rate,unsigned int dur,short flag,const char *other_script,unsigned short pos,bool onskill) { int i; + nullpo_ret(bonus); + nullpo_ret(bonus_script); ARR_FIND(0, max, i, bonus[i].rate == 0); if( i == max ) { @@ -2084,6 +2116,7 @@ int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,c { int i; nullpo_ret(sd); + nullpo_ret(autobonus); for( i = 0; i < max; i++ ) { @@ -2155,6 +2188,7 @@ int pc_bonus_addele(struct map_session_data* sd, unsigned char ele, short rate, int i; struct weapon_data* wd; + nullpo_ret(sd); wd = (sd->state.lr_flag ? &sd->left_weapon : &sd->right_weapon); ARR_FIND(0, MAX_PC_BONUS, i, wd->addele2[i].rate == 0); @@ -2188,6 +2222,7 @@ int pc_bonus_subele(struct map_session_data* sd, unsigned char ele, short rate, { int i; + nullpo_ret(sd); ARR_FIND(0, MAX_PC_BONUS, i, sd->subele2[i].rate == 0); if (i == MAX_PC_BONUS) @@ -4093,7 +4128,7 @@ bool pc_can_insert_card_into(struct map_session_data* sd, int idx_card, int idx_ ARR_FIND( 0, sd->inventory_data[idx_equip]->slot, i, sd->status.inventory[idx_equip].card[i] == 0); if (i == sd->inventory_data[idx_equip]->slot) return false; // no free slots - return true; + return true; } /** @@ -4113,7 +4148,7 @@ bool pc_can_insert_card(struct map_session_data* sd, int idx_card) return false; // target card missing if (sd->inventory_data[idx_card]->type != IT_CARD) return false; // must be a card - return true; + return true; } /*========================================== @@ -4563,6 +4598,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type) { nullpo_retr(1, sd); + Assert_retr(1, n >= 0 && n < MAX_INVENTORY); if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL) return 1; @@ -4610,13 +4646,13 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) return 0; if( map->list[sd->bl.m].flag.nodrop ) { - clif->message (sd->fd, msg_sd(sd,271)); - return 0; //Can't drop items in nodrop mapflag maps. + clif->message (sd->fd, msg_sd(sd,271)); // You can't drop items in this map + return 0; } if( !pc->candrop(sd,&sd->status.inventory[n]) ) { - clif->message (sd->fd, msg_sd(sd,263)); + clif->message (sd->fd, msg_sd(sd,263)); // This item cannot be dropped. return 0; } @@ -4706,6 +4742,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) int nameid; nullpo_ret(sd); + Assert_ret(n >= 0 && n < MAX_INVENTORY); item = sd->inventory_data[n]; nameid = sd->status.inventory[n].nameid; @@ -4838,12 +4875,12 @@ int pc_isUseitem(struct map_session_data *sd,int n) if(item->sex != 2 && sd->status.sex != item->sex) return 0; //Required level check - if (item->elv && sd->status.base_level < (unsigned int)item->elv) { + if (item->elv && sd->status.base_level < item->elv) { clif->msgtable(sd, MSG_ITEM_CANT_USE_LVL); return 0; } - if (item->elvmax && sd->status.base_level > (unsigned int)item->elvmax) { + if (item->elvmax && sd->status.base_level > item->elvmax) { clif->msgtable(sd, MSG_ITEM_CANT_USE_LVL); return 0; } @@ -4892,6 +4929,7 @@ int pc_useitem(struct map_session_data *sd,int n) { bool removeItem = false; nullpo_ret(sd); + Assert_ret(n >= 0 && n < MAX_INVENTORY); if( sd->npc_id || sd->state.workinprogress&1 ){ /* TODO: add to clif->messages enum */ @@ -5059,7 +5097,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun if (!itemdb_cancartstore(item_data, pc_get_group_level(sd)) || (item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd))) { // Check item trade restrictions - clif->message (sd->fd, msg_sd(sd,264)); + clif->message (sd->fd, msg_sd(sd,264)); // This item cannot be stored. return 1;/* TODO: there is no official response to this? */ } @@ -5112,6 +5150,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type) { struct item_data * data; nullpo_retr(1, sd); + Assert_retr(1, n >= 0 && n < MAX_INVENTORY); if( sd->status.cart[n].nameid == 0 || sd->status.cart[n].amount < amount || !(data = itemdb->exists(sd->status.cart[n].nameid)) ) return 1; @@ -5170,6 +5209,7 @@ int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount) struct item* item_data; nullpo_retr(-1, sd); + Assert_retr(-1, idx >= 0 && idx < MAX_CART); item_data = &sd->status.cart[idx]; if( item_data->nameid == 0 || item_data->amount == 0 ) @@ -5204,9 +5244,12 @@ int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount) return flag; } -void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type type) { + +void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type type) +{ int i; + nullpo_retv(sd); switch( type ) { /* both restricted to inventory */ case IBT_PARTY: @@ -5534,6 +5577,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int npc->script_event(sd, NPCE_LOGOUT); //remove from map, THEN change x/y coordinates unit->remove_map_pc(sd,clrtype); + if (battle_config.player_warp_keep_direction == 0) + sd->ud.dir = 0; // makes character face north sd->mapindex = map_index; sd->bl.x=x; sd->bl.y=y; @@ -5564,6 +5609,9 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int vending->close(sd); } + if (battle_config.player_warp_keep_direction == 0) + sd->ud.dir = 0; // makes character face north + if(sd->bl.prev != NULL){ unit->remove_map_pc(sd,clrtype); clif->changemap(sd,m,x,y); // [MouseJstr] @@ -6440,6 +6488,7 @@ int pc_check_job_name(const char *name) { { "Rebellion", JOB_REBELLION }, }; + nullpo_retr(-1, name); len = ARRAYLENGTH(names); ARR_FIND(0, len, i, strcmpi(names[i].name, name) == 0); @@ -6506,6 +6555,7 @@ int pc_stop_following (struct map_session_data *sd) int pc_follow(struct map_session_data *sd,int target_id) { struct block_list *bl = map->id2bl(target_id); + nullpo_retr(1, sd); if (bl == NULL /*|| bl->type != BL_PC*/) return 1; if (sd->followtimer != INVALID_TIMER) @@ -6520,18 +6570,20 @@ int pc_follow(struct map_session_data *sd,int target_id) { int pc_checkbaselevelup(struct map_session_data *sd) { unsigned int next = pc->nextbaseexp(sd); + nullpo_ret(sd); if (!next || sd->status.base_exp < next) return 0; do { + int status_points = 0; sd->status.base_exp -= next; //Kyoki pointed out that the max overcarry exp is the exp needed for the previous level -1. [Skotlex] if(!battle_config.multi_level_up && sd->status.base_exp > next-1) sd->status.base_exp = next-1; - next = pc->gets_status_point(sd->status.base_level); - sd->status.base_level ++; - sd->status.status_point += next; + status_points = pc->gets_status_point(sd->status.base_level); + sd->status.base_level++; + sd->status.status_point += status_points; } while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next); @@ -6569,9 +6621,10 @@ int pc_checkbaselevelup(struct map_session_data *sd) { void pc_baselevelchanged(struct map_session_data *sd) { int i; + nullpo_retv(sd); for( i = 0; i < EQI_MAX; i++ ) { if( sd->equip_index[i] >= 0 ) { - if( sd->inventory_data[ sd->equip_index[i] ]->elvmax && sd->status.base_level > (unsigned int)sd->inventory_data[ sd->equip_index[i] ]->elvmax ) + if (sd->inventory_data[sd->equip_index[i]]->elvmax != 0 && sd->status.base_level > sd->inventory_data[ sd->equip_index[i] ]->elvmax) pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); } } @@ -6591,8 +6644,8 @@ int pc_checkjoblevelup(struct map_session_data *sd) if(!battle_config.multi_level_up && sd->status.job_exp > next-1) sd->status.job_exp = next-1; - sd->status.job_level ++; - sd->status.skill_point ++; + sd->status.job_level++; + sd->status.skill_point++; } while ((next=pc->nextjobexp(sd)) > 0 && sd->status.job_exp >= next); @@ -6613,34 +6666,72 @@ int pc_checkjoblevelup(struct map_session_data *sd) * Alters EXP based on self bonuses that do not get shared with the party **/ void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsigned int *job_exp, struct block_list *src) { - int bonus = 0; - struct status_data *st = status->get_status_data(src); + int buff_ratio = 0, buff_job_ratio = 0, race_ratio = 0, pk_ratio = 0; + int64 jexp, bexp; + + nullpo_retv(sd); + nullpo_retv(base_exp); + nullpo_retv(job_exp); + + jexp = *job_exp; + bexp = *base_exp; - if (sd->expaddrace[st->race]) - bonus += sd->expaddrace[st->race]; - bonus += sd->expaddrace[(st->mode&MD_BOSS) ? RC_BOSS : RC_NONBOSS]; + if (src != NULL) { + const struct status_data *st = status->get_status_data(src); - if (battle_config.pk_mode - && (int)(status->get_lv(src) - sd->status.base_level) >= 20) - bonus += 15; // pk_mode additional exp if monster >20 levels [Valaris] +#ifdef RENEWAL_EXP //should happen first before we caluclate any modifiers + if (src->type == BL_MOB) { + const struct mob_data *md = BL_UCAST(BL_MOB, src); + int re_mod; + re_mod = pc->level_penalty_mod(md->level - sd->status.base_level, md->status.race, md->status.mode, 1); + jexp = apply_percentrate64(jexp, re_mod, 100); + bexp = apply_percentrate64(bexp, re_mod, 100); + } +#endif - if (sd->sc.data[SC_CASH_PLUSEXP]) - bonus += sd->sc.data[SC_CASH_PLUSEXP]->val1; - if (sd->sc.data[SC_OVERLAPEXPUP]) - bonus += sd->sc.data[SC_OVERLAPEXPUP]->val1; + //Race modifier + if (sd->expaddrace[st->race]) + race_ratio += sd->expaddrace[st->race]; + race_ratio += sd->expaddrace[(st->mode&MD_BOSS) ? RC_BOSS : RC_NONBOSS]; + } - *base_exp = (unsigned int) cap_value(*base_exp + apply_percentrate64(*base_exp, bonus, 100), 1, UINT_MAX); + //PK modifier + /* this doesn't exist in Aegis, instead there's a CrazyKiller check which double all EXP from this point */ + if (battle_config.pk_mode && status->get_lv(src) - sd->status.base_level >= 20) + pk_ratio += 15; // pk_mode additional exp if monster >20 levels [Valaris] + + + //Buffs modifier + if (sd->sc.data[SC_CASH_PLUSEXP]) { + buff_job_ratio += sd->sc.data[SC_CASH_PLUSEXP]->val1; + buff_ratio += sd->sc.data[SC_CASH_PLUSEXP]->val1; + } + if (sd->sc.data[SC_OVERLAPEXPUP]) { + buff_job_ratio += sd->sc.data[SC_OVERLAPEXPUP]->val1; + buff_ratio += sd->sc.data[SC_OVERLAPEXPUP]->val1; + } if (sd->sc.data[SC_CASH_PLUSONLYJOBEXP]) - bonus += sd->sc.data[SC_CASH_PLUSONLYJOBEXP]->val1; + buff_job_ratio += sd->sc.data[SC_CASH_PLUSONLYJOBEXP]->val1; - *job_exp = (unsigned int) cap_value(*job_exp + apply_percentrate64(*job_exp, bonus, 100), 1, UINT_MAX); + //Applying Race and PK modifier First then Premium (Perment modifier) and finally buff modifier + jexp += apply_percentrate64(jexp, race_ratio, 100); + jexp += apply_percentrate64(jexp, pk_ratio, 100); + + bexp += apply_percentrate64(bexp, race_ratio, 100); + bexp += apply_percentrate64(bexp, pk_ratio, 100); - if (sd->status.mod_exp != 100) { - *base_exp = (unsigned int) cap_value(apply_percentrate64(*base_exp, sd->status.mod_exp, 100), 1, UINT_MAX); - *job_exp = (unsigned int) cap_value(apply_percentrate64(*job_exp, sd->status.mod_exp, 100), 1, UINT_MAX); + if (sd->status.mod_exp != 100) { + jexp = apply_percentrate64(jexp, sd->status.mod_exp, 100); + bexp = apply_percentrate64(bexp, sd->status.mod_exp, 100); } + + bexp += apply_percentrate64(bexp, buff_ratio, 100); + jexp += apply_percentrate64(jexp, buff_ratio + buff_job_ratio, 100); + + *job_exp = (unsigned int)cap_value(jexp, 1, UINT_MAX); + *base_exp = (unsigned int)cap_value(bexp, 1, UINT_MAX); } /** @@ -6654,24 +6745,25 @@ bool pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned in unsigned int nextb=0, nextj=0; nullpo_ret(sd); - if(sd->bl.prev == NULL || pc_isdead(sd)) + if (sd->bl.prev == NULL || pc_isdead(sd)) return false; - if(!battle_config.pvp_exp && map->list[sd->bl.m].flag.pvp) // [MouseJstr] + if (!battle_config.pvp_exp && map->list[sd->bl.m].flag.pvp) // [MouseJstr] return false; // no exp on pvp maps - if( pc_has_permission(sd,PC_PERM_DISABLE_EXP) ) + if (pc_has_permission(sd,PC_PERM_DISABLE_EXP)) return false; - if(sd->status.guild_id>0) - base_exp-=guild->payexp(sd,base_exp); + if (src) + pc->calcexp(sd, &base_exp, &job_exp, src); - if(src) pc->calcexp(sd, &base_exp, &job_exp, src); + if (sd->status.guild_id > 0) + base_exp -= guild->payexp(sd,base_exp); nextb = pc->nextbaseexp(sd); nextj = pc->nextjobexp(sd); - if(sd->state.showexp || battle_config.max_exp_gain_rate){ + if (sd->state.showexp || battle_config.max_exp_gain_rate) { if (nextb > 0) nextbp = (float) base_exp / (float) nextb; if (nextj > 0) @@ -6735,12 +6827,12 @@ bool pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned in /*========================================== * Returns max level for this character. *------------------------------------------*/ -unsigned int pc_maxbaselv(struct map_session_data *sd) +int pc_maxbaselv(const struct map_session_data *sd) { return pc->max_level[pc->class2idx(sd->status.class_)][0]; } -unsigned int pc_maxjoblv(struct map_session_data *sd) +int pc_maxjoblv(const struct map_session_data *sd) { return pc->max_level[pc->class2idx(sd->status.class_)][1]; } @@ -6750,20 +6842,20 @@ unsigned int pc_maxjoblv(struct map_session_data *sd) *------------------------------------------*/ //Base exp needed for next level. -unsigned int pc_nextbaseexp(struct map_session_data *sd) +unsigned int pc_nextbaseexp(const struct map_session_data *sd) { nullpo_ret(sd); - if(sd->status.base_level>=pc->maxbaselv(sd) || sd->status.base_level<=0) + if (sd->status.base_level >= pc->maxbaselv(sd) || sd->status.base_level <= 0) return 0; return pc->exp_table[pc->class2idx(sd->status.class_)][0][sd->status.base_level-1]; } //Base exp needed for this level. -unsigned int pc_thisbaseexp(struct map_session_data *sd) +unsigned int pc_thisbaseexp(const struct map_session_data *sd) { - if(sd->status.base_level>pc->maxbaselv(sd) || sd->status.base_level<=1) + if (sd->status.base_level > pc->maxbaselv(sd) || sd->status.base_level <= 1) return 0; return pc->exp_table[pc->class2idx(sd->status.class_)][0][sd->status.base_level-2]; @@ -6777,19 +6869,19 @@ unsigned int pc_thisbaseexp(struct map_session_data *sd) *------------------------------------------*/ //Job exp needed for next level. -unsigned int pc_nextjobexp(struct map_session_data *sd) +unsigned int pc_nextjobexp(const struct map_session_data *sd) { nullpo_ret(sd); - if(sd->status.job_level>=pc->maxjoblv(sd) || sd->status.job_level<=0) + if (sd->status.job_level >= pc->maxjoblv(sd) || sd->status.job_level <= 0) return 0; return pc->exp_table[pc->class2idx(sd->status.class_)][1][sd->status.job_level-1]; } //Job exp needed for this level. -unsigned int pc_thisjobexp(struct map_session_data *sd) +unsigned int pc_thisjobexp(const struct map_session_data *sd) { - if(sd->status.job_level>pc->maxjoblv(sd) || sd->status.job_level<=1) + if (sd->status.job_level > pc->maxjoblv(sd) || sd->status.job_level <= 1) return 0; return pc->exp_table[pc->class2idx(sd->status.class_)][1][sd->status.job_level-2]; } @@ -7040,9 +7132,9 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown clif->skillinfoblock(sd); } else if( battle_config.skillup_limit ){ - if (sd->sktree.second) + if (sd->sktree.second != 0) clif->msgtable_num(sd, MSG_SKILL_POINTS_LEFT_JOB1, sd->sktree.second); - else if (sd->sktree.third) + else if (sd->sktree.third != 0) clif->msgtable_num(sd, MSG_SKILL_POINTS_LEFT_JOB2, sd->sktree.third); else if (pc->calc_skillpoint(sd) < 9) /* TODO: official response? */ clif->messagecolor_self(sd->fd, COLOR_RED, "You need the basic skills"); @@ -7204,7 +7296,7 @@ int pc_resetstate(struct map_session_data* sd) // New statpoint table used here - Dexity if (sd->status.base_level > MAX_LEVEL) { //pc->statp[] goes out of bounds, can't reset! - ShowError("pc_resetstate: Can't reset stats of %d:%d, the base level (%u) is greater than the max level supported (%d)\n", + ShowError("pc_resetstate: Can't reset stats of %d:%d, the base level (%d) is greater than the max level supported (%d)\n", sd->status.account_id, sd->status.char_id, sd->status.base_level, MAX_LEVEL); return 0; } @@ -7628,7 +7720,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { if (md->target_id==sd->bl.id) mob->unlocktarget(md,tick); if (battle_config.mobs_level_up && md->status.hp - && (unsigned int)md->level < pc->maxbaselv(sd) + && md->level < pc->maxbaselv(sd) && !md->guardian_data && md->special_state.ai == AI_NONE// Guardians/summons should not level. [Skotlex] ) { // monster level up [Valaris] @@ -7875,6 +7967,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp) { + nullpo_retv(sd); if(hp) clif->updatestatus(sd,SP_HP); if(sp) clif->updatestatus(sd,SP_SP); @@ -7894,7 +7987,7 @@ void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp) { /*========================================== * script reading pc status registry *------------------------------------------*/ -int pc_readparam(struct map_session_data* sd,int type) +int pc_readparam(const struct map_session_data *sd, int type) { int val = 0; @@ -7952,7 +8045,7 @@ int pc_readparam(struct map_session_data* sd,int type) case SP_VARCASTRATE: #endif case SP_CASTRATE: - val = sd->castrate+=val; + val = sd->castrate; break; case SP_MAXHPRATE: val = sd->hprate; break; case SP_MAXSPRATE: val = sd->sprate; break; @@ -8052,15 +8145,15 @@ int pc_setparam(struct map_session_data *sd,int type,int val) switch(type){ case SP_BASELEVEL: - if ((unsigned int)val > pc->maxbaselv(sd)) //Capping to max + if (val > pc->maxbaselv(sd)) //Capping to max val = pc->maxbaselv(sd); - if ((unsigned int)val > sd->status.base_level) { + if (val > sd->status.base_level) { int stat = 0, i; - for (i = 0; i < (int)((unsigned int)val - sd->status.base_level); i++) + for (i = 0; i < val - sd->status.base_level; i++) stat += pc->gets_status_point(sd->status.base_level + i); sd->status.status_point += stat; } - sd->status.base_level = (unsigned int)val; + sd->status.base_level = val; sd->status.base_exp = 0; // clif->updatestatus(sd, SP_BASELEVEL); // Gets updated at the bottom clif->updatestatus(sd, SP_NEXTBASEEXP); @@ -8073,12 +8166,13 @@ int pc_setparam(struct map_session_data *sd,int type,int val) } break; case SP_JOBLEVEL: - if ((unsigned int)val >= sd->status.job_level) { - if ((unsigned int)val > pc->maxjoblv(sd)) val = pc->maxjoblv(sd); + if (val >= sd->status.job_level) { + if (val > pc->maxjoblv(sd)) + val = pc->maxjoblv(sd); sd->status.skill_point += val - sd->status.job_level; clif->updatestatus(sd, SP_SKILLPOINT); } - sd->status.job_level = (unsigned int)val; + sd->status.job_level = val; sd->status.job_exp = 0; // clif->updatestatus(sd, SP_JOBLEVEL); // Gets updated at the bottom clif->updatestatus(sd, SP_NEXTJOBEXP); @@ -8210,6 +8304,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) *------------------------------------------*/ void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, int type) { + nullpo_retv(sd); if (type) { if (hp) clif->heal(sd->fd,SP_HP,hp); @@ -8233,6 +8328,7 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp) { int bonus, tmp; + nullpo_ret(sd); if(hp) { int i; bonus = 100 + (sd->battle_status.vit<<1) @@ -8395,12 +8491,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) // changing from 1st to 2nd job if ((b_class&JOBL_2) && !(sd->class_&JOBL_2) && (b_class&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) { sd->change_level_2nd = sd->status.job_level; - pc_setglobalreg (sd, script->add_str("jobchange_level"), sd->change_level_2nd); + pc_setglobalreg(sd, script->add_str("jobchange_level"), sd->change_level_2nd); } // changing from 2nd to 3rd job else if((b_class&JOBL_THIRD) && !(sd->class_&JOBL_THIRD)) { sd->change_level_3rd = sd->status.job_level; - pc_setglobalreg (sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); + pc_setglobalreg(sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); } if(sd->cloneskill_id) { @@ -8803,6 +8899,7 @@ int pc_setcart(struct map_session_data *sd,int type) { **/ void pc_setfalcon(struct map_session_data *sd, bool flag) { + nullpo_retv(sd); if (flag) { if (pc->checkskill(sd,HT_FALCON) > 0) // add falcon if he have the skill pc->setoption(sd,sd->sc.option|OPTION_FALCON); @@ -8821,6 +8918,7 @@ void pc_setfalcon(struct map_session_data *sd, bool flag) **/ void pc_setridingpeco(struct map_session_data *sd, bool flag) { + nullpo_retv(sd); if (flag) { if (pc->checkskill(sd, KN_RIDING)) pc->setoption(sd, sd->sc.option|OPTION_RIDING); @@ -8839,6 +8937,7 @@ void pc_setridingpeco(struct map_session_data *sd, bool flag) **/ void pc_setmadogear(struct map_session_data *sd, bool flag) { + nullpo_retv(sd); if (flag) { if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) pc->setoption(sd, sd->sc.option|OPTION_MADOGEAR); @@ -8857,6 +8956,7 @@ void pc_setmadogear(struct map_session_data *sd, bool flag) **/ void pc_setridingdragon(struct map_session_data *sd, unsigned int type) { + nullpo_retv(sd); if (type&OPTION_DRAGON) { // Ensure only one dragon is set at a time. if (type&OPTION_DRAGON1) @@ -8889,6 +8989,7 @@ void pc_setridingdragon(struct map_session_data *sd, unsigned int type) **/ void pc_setridingwug(struct map_session_data *sd, bool flag) { + nullpo_retv(sd); if (flag) { if (pc->checkskill(sd, RA_WUGRIDER) > 0) pc->setoption(sd,sd->sc.option|OPTION_WUGRIDER); @@ -8956,6 +9057,7 @@ int pc_candrop(struct map_session_data *sd, struct item *item) * For '@type' variables (temporary numeric char reg) **/ int pc_readreg(struct map_session_data* sd, int64 reg) { + nullpo_ret(sd); return i64db_iget(sd->regs.vars, reg); } /** @@ -8964,6 +9066,7 @@ int pc_readreg(struct map_session_data* sd, int64 reg) { void pc_setreg(struct map_session_data* sd, int64 reg, int val) { unsigned int index = script_getvaridx(reg); + nullpo_retv(sd); if( val ) { i64db_iput(sd->regs.vars, reg, val); if( index ) @@ -8981,6 +9084,7 @@ void pc_setreg(struct map_session_data* sd, int64 reg, int val) { char* pc_readregstr(struct map_session_data* sd, int64 reg) { struct script_reg_str *p = NULL; + nullpo_retr(NULL, sd); p = i64db_get(sd->regs.vars, reg); return p ? p->value : NULL; @@ -8993,6 +9097,8 @@ void pc_setregstr(struct map_session_data* sd, int64 reg, const char* str) { unsigned int index = script_getvaridx(reg); struct DBData prev; + nullpo_retv(sd); + nullpo_retv(str); if( str[0] ) { p = ers_alloc(pc->str_reg_ers, struct script_reg_str); @@ -9028,6 +9134,7 @@ void pc_setregstr(struct map_session_data* sd, int64 reg, const char* str) { int pc_readregistry(struct map_session_data *sd, int64 reg) { struct script_reg_num *p = NULL; + nullpo_ret(sd); if (!sd->vars_ok) { ShowError("pc_readregistry: Trying to read reg %s before it's been loaded!\n", script->get_str(script_getvarid(reg))); //This really shouldn't happen, so it's possible the data was lost somewhere, we should request it again. @@ -9049,6 +9156,7 @@ int pc_readregistry(struct map_session_data *sd, int64 reg) { char* pc_readregistry_str(struct map_session_data *sd, int64 reg) { struct script_reg_str *p = NULL; + nullpo_retr(NULL, sd); if (!sd->vars_ok) { ShowError("pc_readregistry_str: Trying to read reg %s before it's been loaded!\n", script->get_str(script_getvarid(reg))); //This really shouldn't happen, so it's possible the data was lost somewhere, we should request it again. @@ -9072,6 +9180,7 @@ int pc_setregistry(struct map_session_data *sd, int64 reg, int val) { const char *regname = script->get_str( script_getvarid(reg) ); unsigned int index = script_getvaridx(reg); + nullpo_ret(sd); /* SAAD! those things should be stored elsewhere e.g. char ones in char table, the cash ones in account_data table! */ switch( regname[0] ) { default: //Char reg @@ -9147,6 +9256,8 @@ int pc_setregistry_str(struct map_session_data *sd, int64 reg, const char *val) const char *regname = script->get_str( script_getvarid(reg) ); unsigned int index = script_getvaridx(reg); + nullpo_ret(sd); + nullpo_ret(val); if ( !pc->reg_load && !sd->vars_ok ) { ShowError("pc_setregistry_str : refusing to set %s until vars are received.\n", regname); return 0; @@ -9224,6 +9335,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) { int i; nullpo_ret(sd); + nullpo_ret(name); ARR_FIND( 0, MAX_EVENTTIMER, i, sd->eventtimer[i] == INVALID_TIMER ); if( i == MAX_EVENTTIMER ) @@ -9244,6 +9356,7 @@ int pc_deleventtimer(struct map_session_data *sd,const char *name) int i; nullpo_ret(sd); + nullpo_ret(name); if (sd->eventcount <= 0) return 0; @@ -9312,6 +9425,8 @@ int pc_checkcombo(struct map_session_data *sd, struct item_data *data ) { int index, success = 0; struct pc_combos *combo; + nullpo_ret(sd); + nullpo_ret(data); for( i = 0; i < data->combos_count; i++ ) { /* ensure this isn't a duplicate combo */ @@ -9387,6 +9502,8 @@ int pc_checkcombo(struct map_session_data *sd, struct item_data *data ) { int pc_removecombo(struct map_session_data *sd, struct item_data *data ) { int i, retval = 0; + nullpo_ret(sd); + nullpo_ret(data); if( !sd->combos ) return 0;/* nothing to do here, player has no combos */ @@ -9431,6 +9548,7 @@ int pc_removecombo(struct map_session_data *sd, struct item_data *data ) { } int pc_load_combo(struct map_session_data *sd) { int i, ret = 0; + nullpo_ret(sd); for( i = 0; i < EQI_MAX; i++ ) { struct item_data *id = NULL; int idx = sd->equip_index[i]; @@ -9463,6 +9581,7 @@ int pc_load_combo(struct map_session_data *sd) { **/ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, int pos) { + nullpo_retv(sd); if ((!map_no_view(sd->bl.m,EQP_SHADOW_WEAPON) && pos & EQP_SHADOW_WEAPON) || (pos & EQP_HAND_R)) { if(id) @@ -9574,7 +9693,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) if(battle_config.battle_log) ShowInfo("equip %d(%d) %x:%x\n", sd->status.inventory[n].nameid, n, (unsigned int)(id ? id->equip : 0), (unsigned int)req_pos); - if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.inventory[n].attribute==1 ) { // [Valaris] + if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || (sd->status.inventory[n].attribute & ATTR_BROKEN) != 0 ) { // [Valaris] // FIXME: pc->isequip: equip level failure uses 2 instead of 0 clif->equipitemack(sd,n,0,EIA_FAIL); // fail return 0; @@ -9693,6 +9812,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) **/ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) { + nullpo_retv(sd); if (pos & EQP_HAND_R) { sd->weapontype1 = 0; sd->status.weapon = sd->weapontype2; @@ -10048,6 +10168,7 @@ int pc_calc_pvprank_sub(struct block_list *bl, va_list ap) int pc_calc_pvprank(struct map_session_data *sd) { int old; struct map_data *m; + nullpo_ret(sd); m=&map->list[sd->bl.m]; old=sd->pvp_rank; sd->pvp_rank=1; @@ -10202,6 +10323,7 @@ void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick) { int hp = 0, sp = 0; + nullpo_retv(sd); if( pc_isdead(sd) ) return; @@ -10235,6 +10357,7 @@ void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick) void pc_regen (struct map_session_data *sd, unsigned int diff_tick) { int hp = 0, sp = 0; + nullpo_retv(sd); if (sd->hp_regen.value) { sd->hp_regen.tick += diff_tick; while (sd->hp_regen.tick >= sd->hp_regen.rate) { @@ -10312,6 +10435,7 @@ int pc_autosave(int tid, int64 tick, int id, intptr_t data) { } int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { + nullpo_ret(sd); if (sd->state.night != map->night_flag && map->list[sd->bl.m].flag.nightenabled) { //Night/day state does not match. clif->status_change(&sd->bl, SI_SKE, map->night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex] sd->state.night = map->night_flag; @@ -10376,6 +10500,7 @@ void pc_overheat(struct map_session_data *sd, int val) { int heat = val, skill_lv, limit[] = { 10, 20, 28, 46, 66 }; + nullpo_retv(sd); if( !pc_ismadogear(sd) || sd->sc.data[SC_OVERHEAT] ) return; // already burning @@ -10401,6 +10526,7 @@ bool pc_isautolooting(struct map_session_data *sd, int nameid) { int i = 0; + nullpo_ret(sd); if (sd->state.autoloottype && sd->state.autoloottype&(1<<itemdb_type(nameid))) return true; @@ -10589,6 +10715,7 @@ int pc_split_str(char *str,char **val,int num) { int i; + nullpo_ret(val); for (i=0; i<num && str; i++){ val[i] = str; str = strchr(str,','); @@ -10601,6 +10728,7 @@ int pc_split_str(char *str,char **val,int num) int pc_split_atoi(char* str, int* val, char sep, int max) { int i,j; + nullpo_ret(val); for (i=0; i<max; i++) { if (!str) break; val[i] = atoi(str); @@ -10618,6 +10746,7 @@ int pc_split_atoui(char* str, unsigned int* val, char sep, int max) { static int warning=0; int i,j; + nullpo_ret(val); for (i=0; i<max; i++) { double f; if (!str) break; @@ -10870,6 +10999,7 @@ bool pc_readdb_levelpenalty(char* fields[], int columns, int current) { #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) int type, race, diff; + nullpo_retr(false, fields); type = atoi(fields[0]); race = atoi(fields[1]); diff = atoi(fields[2]); @@ -10920,7 +11050,7 @@ int pc_readdb(void) { while(fgets(line, sizeof(line), fp)) { int jobs[CLASS_COUNT], job_count, job, job_id; int type; - unsigned int ui,maxlv; + int maxlv; char *split[4]; if(line[0]=='/' && line[1]=='/') continue; @@ -10942,7 +11072,7 @@ int pc_readdb(void) { } maxlv = atoi(split[0]); if (maxlv > MAX_LEVEL) { - ShowWarning("pc_readdb: Specified max level %u for job %d is beyond server's limit (%d).\n ", maxlv, job_id, MAX_LEVEL); + ShowWarning("pc_readdb: Specified max level %d for job %d is beyond server's limit (%d).\n ", maxlv, job_id, MAX_LEVEL); maxlv = MAX_LEVEL; } count++; @@ -10953,15 +11083,15 @@ int pc_readdb(void) { //The reasoning behind the -2 is this... if the max level is 5, then the array //should look like this: //0: x, 1: x, 2: x: 3: x 4: 0 <- last valid value is at 3. - while ((ui = pc->max_level[job][type]) >= 2 && pc->exp_table[job][type][ui-2] <= 0) + while ((i = pc->max_level[job][type]) >= 2 && pc->exp_table[job][type][i-2] <= 0) pc->max_level[job][type]--; if (pc->max_level[job][type] < maxlv) { - ShowWarning("pc_readdb: Specified max %u for job %d, but that job's exp table only goes up to level %u.\n", maxlv, job_id, pc->max_level[job][type]); + ShowWarning("pc_readdb: Specified max %d for job %d, but that job's exp table only goes up to level %d.\n", maxlv, job_id, pc->max_level[job][type]); ShowInfo("Filling the missing values with the last exp entry.\n"); //Fill the requested values with the last entry. - ui = (pc->max_level[job][type] <= 2? 0: pc->max_level[job][type]-2); - for (; ui+2 < maxlv; ui++) - pc->exp_table[job][type][ui] = pc->exp_table[job][type][ui-1]; + i = (pc->max_level[job][type] <= 2 ? 0: pc->max_level[job][type]-2); + for (; i+2 < maxlv; i++) + pc->exp_table[job][type][i] = pc->exp_table[job][type][i-1]; pc->max_level[job][type] = maxlv; } //ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]); @@ -10974,7 +11104,7 @@ int pc_readdb(void) { job = pc->class2idx(job_id); memcpy(pc->exp_table[job][type], pc->exp_table[jobs[0]][type], sizeof(pc->exp_table[0][0])); pc->max_level[job][type] = maxlv; - //ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job_id, pc->max_level[job][type]); + //ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]); } } fclose(fp); @@ -11102,9 +11232,9 @@ void pc_validate_levels(void) { if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER) continue; //Classes that do not need exp tables. j = pc->class2idx(i); - if (!pc->max_level[j][0]) + if (pc->max_level[j][0] == 0) ShowWarning("Class %s (%d) does not has a base exp table.\n", pc->job_name(i), i); - if (!pc->max_level[j][1]) + if (pc->max_level[j][1] == 0) ShowWarning("Class %s (%d) does not has a job exp table.\n", pc->job_name(i), i); } } @@ -11113,6 +11243,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { int i,cursor = 0; struct item_cd* cd = NULL; + nullpo_retv(sd); if( load ) { if( !(cd = idb_get(pc->itemcd_db, sd->status.char_id)) ) { // no skill cooldown is associated with this character @@ -11144,7 +11275,10 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { } void pc_bank_deposit(struct map_session_data *sd, int money) { - unsigned int limit_check = money+sd->status.bank_vault; + unsigned int limit_check; + + nullpo_retv(sd); + limit_check = money + sd->status.bank_vault; if( money <= 0 || limit_check > MAX_BANK_ZENY ) { clif->bank_deposit(sd,BDA_OVERFLOW); @@ -11164,8 +11298,10 @@ void pc_bank_deposit(struct map_session_data *sd, int money) { } } void pc_bank_withdraw(struct map_session_data *sd, int money) { - unsigned int limit_check = money+sd->status.zeny; + unsigned int limit_check; + nullpo_retv(sd); + limit_check = money + sd->status.zeny; if (money <= 0) { clif->bank_withdraw(sd,BWA_UNKNOWN_ERROR); return; @@ -11189,6 +11325,7 @@ void pc_bank_withdraw(struct map_session_data *sd, int money) { } /* status change data arrived from char-server */ void pc_scdata_received(struct map_session_data *sd) { + nullpo_retv(sd); pc->inventory_rentals(sd); clif->show_modifiers(sd); @@ -11237,6 +11374,7 @@ int pc_global_expiration_timer(int tid, int64 tick, int id, intptr_t data) { return 0; } void pc_expire_check(struct map_session_data *sd) { + nullpo_retv(sd); /* ongoing timer */ if( sd->expiration_tid != INVALID_TIMER ) return; @@ -11294,6 +11432,7 @@ void pc_autotrade_start(struct map_session_data *sd) { int i; char *data; + nullpo_retv(sd); if (SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT `itemkey`,`amount`,`price` FROM `%s` WHERE `char_id` = '%d'",map->autotrade_data_db,sd->status.char_id)) Sql_ShowDebug(map->mysql_handle); @@ -11338,6 +11477,7 @@ void pc_autotrade_start(struct map_session_data *sd) { void pc_autotrade_update(struct map_session_data *sd, enum e_pc_autotrade_update_action action) { int i; + nullpo_retv(sd); /* either way, this goes down */ if( action != PAUC_START ) { if (SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'",map->autotrade_data_db,sd->status.char_id)) @@ -11391,6 +11531,7 @@ void pc_autotrade_prepare(struct map_session_data *sd) { char title[MESSAGE_SIZE]; unsigned char sex; + nullpo_retv(sd); CREATE(data, struct autotrade_vending, 1); memcpy(data->vending, sd->vending, sizeof(sd->vending)); @@ -11437,6 +11578,7 @@ void pc_autotrade_populate(struct map_session_data *sd) { struct autotrade_vending *data; int i, j, k, cursor = 0; + nullpo_retv(sd); if( !(data = idb_get(pc->at_db,sd->status.char_id)) ) return; @@ -11479,6 +11621,7 @@ void pc_autotrade_populate(struct map_session_data *sd) { int pc_autotrade_final(union DBKey key, struct DBData *data, va_list ap) { struct autotrade_vending* at_v = DB->data2ptr(data); + nullpo_ret(at_v); HPM->data_store_destroy(&at_v->hdata); return 0; } @@ -11527,6 +11670,7 @@ int pc_have_magnifier(struct map_session_data *sd) */ bool pc_process_chat_message(struct map_session_data *sd, const char *message) { + nullpo_retr(false, sd); if (atcommand->exec(sd->fd, sd, message, true)) { return false; } @@ -11561,6 +11705,8 @@ void pc_check_supernovice_call(struct map_session_data *sd, const char *message) unsigned int next = pc->nextbaseexp(sd); int percent = 0; + nullpo_retv(sd); + nullpo_retv(message); if ((sd->class_&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) return; if (next == 0) @@ -11968,6 +12114,6 @@ void pc_defaults(void) { pc->check_job_name = pc_check_job_name; pc->update_idle_time = pc_update_idle_time; - + pc->have_magnifier = pc_have_magnifier; } diff --git a/src/map/pc.h b/src/map/pc.h index 58f7a2266..df5416bc1 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -456,8 +456,8 @@ END_ZEROED_BLOCK; int eventtimer[MAX_EVENTTIMER]; unsigned short eventcount; // [celest] - unsigned char change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value] - unsigned char change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value] + int change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value] + int change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value] char fakename[NAME_LENGTH]; // fake names [Valaris] @@ -564,7 +564,7 @@ END_ZEROED_BLOCK; /* */ struct { - unsigned int second,third; + int second, third; } sktree; /** @@ -795,7 +795,7 @@ struct pc_interface { BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when status_defaults() is executed */ unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL]; - unsigned int max_level[CLASS_COUNT][2]; + int max_level[CLASS_COUNT][2]; unsigned int statp[MAX_LEVEL+1]; unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; /* */ @@ -909,15 +909,15 @@ END_ZEROED_BLOCK; /* End */ int (*follow) (struct map_session_data *sd, int target_id); // [MouseJstr] int (*stop_following) (struct map_session_data *sd); - unsigned int (*maxbaselv) (struct map_session_data *sd); - unsigned int (*maxjoblv) (struct map_session_data *sd); + int (*maxbaselv) (const struct map_session_data *sd); + int (*maxjoblv) (const struct map_session_data *sd); int (*checkbaselevelup) (struct map_session_data *sd); int (*checkjoblevelup) (struct map_session_data *sd); bool (*gainexp) (struct map_session_data *sd, struct block_list *src, unsigned int base_exp, unsigned int job_exp, bool is_quest); - unsigned int (*nextbaseexp) (struct map_session_data *sd); - unsigned int (*thisbaseexp) (struct map_session_data *sd); - unsigned int (*nextjobexp) (struct map_session_data *sd); - unsigned int (*thisjobexp) (struct map_session_data *sd); + unsigned int (*nextbaseexp) (const struct map_session_data *sd); + unsigned int (*thisbaseexp) (const struct map_session_data *sd); + unsigned int (*nextjobexp) (const struct map_session_data *sd); + unsigned int (*thisjobexp) (const struct map_session_data *sd); int (*gets_status_point) (int level); int (*need_status_point) (struct map_session_data *sd,int type,int val); int (*maxparameterincrease) (struct map_session_data* sd, int type); @@ -958,7 +958,7 @@ END_ZEROED_BLOCK; /* End */ int (*changelook) (struct map_session_data *sd,int type,int val); int (*equiplookall) (struct map_session_data *sd); - int (*readparam) (struct map_session_data *sd,int type); + int (*readparam) (const struct map_session_data *sd, int type); int (*setparam) (struct map_session_data *sd,int type,int val); int (*readreg) (struct map_session_data *sd, int64 reg); void (*setreg) (struct map_session_data *sd, int64 reg,int val); diff --git a/src/map/script.c b/src/map/script.c index 07b37571e..353d57a67 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -83,36 +83,18 @@ struct script_interface script_s; struct script_interface *script; -static inline int GETVALUE(const unsigned char* buf, int i) { - return (int)MakeDWord(MakeWord(buf[i], buf[i+1]), MakeWord(buf[i+2], 0)); -} -static inline void SETVALUE(unsigned char* buf, int i, int n) { - buf[i] = GetByte(n, 0); - buf[i+1] = GetByte(n, 1); - buf[i+2] = GetByte(n, 2); -} - -static inline void script_string_buf_ensure(struct script_string_buf *buf, size_t ensure) { - if( buf->pos+ensure >= buf->size ) { - do { - buf->size += 512; - } while ( buf->pos+ensure >= buf->size ); - RECREATE(buf->ptr, char, buf->size); - } -} - -static inline void script_string_buf_addb(struct script_string_buf *buf,uint8 b) { - if( buf->pos+1 >= buf->size ) { - buf->size += 512; - RECREATE(buf->ptr, char, buf->size); - } - buf->ptr[buf->pos++] = b; +static inline int GETVALUE(const struct script_buf *buf, int i) +{ + Assert_ret(VECTOR_LENGTH(*buf) > i + 2); + return (int)MakeDWord(MakeWord(VECTOR_INDEX(*buf, i), VECTOR_INDEX(*buf, i+1)), + MakeWord(VECTOR_INDEX(*buf, i+2), 0)); } - -static inline void script_string_buf_destroy(struct script_string_buf *buf) { - if( buf->ptr ) - aFree(buf->ptr); - memset(buf,0,sizeof(struct script_string_buf)); +static inline void SETVALUE(struct script_buf *buf, int i, int n) +{ + Assert_retv(VECTOR_LENGTH(*buf) > i + 2); + VECTOR_INDEX(*buf, i) = GetByte(n, 0); + VECTOR_INDEX(*buf, i+1) = GetByte(n, 1); + VECTOR_INDEX(*buf, i+2) = GetByte(n, 2); } const char* script_op2name(int op) { @@ -606,21 +588,26 @@ int script_add_str(const char* p) return script->str_num++; } -/// Appends 1 byte to the script buffer. +/** + * Appends 1 byte to the script buffer. + * + * @param a The byte to append. + */ void add_scriptb(int a) { - if( script->pos+1 >= script->size ) - { - script->size += SCRIPT_BLOCK_SIZE; - RECREATE(script->buf,unsigned char,script->size); - } - script->buf[script->pos++] = (uint8)(a); + VECTOR_ENSURE(script->buf, 1, SCRIPT_BLOCK_SIZE); + VECTOR_PUSH(script->buf, (uint8)a); } -/// Appends a c_op value to the script buffer. -/// The value is variable-length encoded into 8-bit blocks. -/// The encoding scheme is ( 01?????? )* 00??????, LSB first. -/// All blocks but the last hold 7 bits of data, topmost bit is always 1 (carries). +/** + * Appends a c_op value to the script buffer. + * + * The value is variable-length encoded into 8-bit blocks. + * The encoding scheme is ( 01?????? )* 00??????, LSB first. + * All blocks but the last hold 7 bits of data, topmost bit is always 1 (carries). + * + * @param a The value to append. + */ void add_scriptc(int a) { while( a >= 0x40 ) @@ -632,10 +619,15 @@ void add_scriptc(int a) script->addb(a); } -/// Appends an integer value to the script buffer. -/// The value is variable-length encoded into 8-bit blocks. -/// The encoding scheme is ( 11?????? )* 10??????, LSB first. -/// All blocks but the last hold 7 bits of data, topmost bit is always 1 (carries). +/** + * Appends an integer value to the script buffer. + * + * The value is variable-length encoded into 8-bit blocks. + * The encoding scheme is ( 11?????? )* 10??????, LSB first. + * All blocks but the last hold 7 bits of data, topmost bit is always 1 (carries). + * + * @param a The value to append. + */ void add_scripti(int a) { while( a >= 0x40 ) @@ -646,11 +638,11 @@ void add_scripti(int a) script->addb(a|0x80); } -/// Appends a script->str_data object (label/function/variable/integer) to the script buffer. - -/// -/// @param l The id of the script->str_data entry -// Maximum up to 16M +/** + * Appends a script->str_data object (label/function/variable/integer) to the script buffer. + * + * @param l The id of the script->str_data entry (Maximum up to 16M) + */ void add_scriptl(int l) { int backpatch = script->str_data[l].backpatch; @@ -667,7 +659,7 @@ void add_scriptl(int l) case C_USERFUNC: // Embedded data backpatch there is a possibility of label script->addc(C_NAME); - script->str_data[l].backpatch = script->pos; + script->str_data[l].backpatch = VECTOR_LENGTH(script->buf); script->addb(backpatch); script->addb(backpatch>>8); script->addb(backpatch>>16); @@ -705,9 +697,9 @@ void set_label(int l,int pos, const char* script_pos) script->str_data[l].type=(script->str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS); script->str_data[l].label=pos; for (i = script->str_data[l].backpatch; i >= 0 && i != 0x00ffffff; ) { - int next = GETVALUE(script->buf,i); - script->buf[i-1]=(script->str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS); - SETVALUE(script->buf,i,pos); + int next = GETVALUE(&script->buf, i); + VECTOR_INDEX(script->buf, i-1) = (script->str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS); + SETVALUE(&script->buf, i, pos); i = next; } } @@ -811,26 +803,25 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom) char *arg = NULL; char null_arg = '\0'; int func; - bool nested_call = false, macro = false; + bool macro = false; // is need add check for arg null pointer below? func = script->add_word(p); - if( script->str_data[func].type == C_FUNC ) { - /** only when unset (-1), valid values are >= 0 **/ - if( script->syntax.last_func == -1 ) - script->syntax.last_func = script->str_data[func].val; - else { //Nested function call - script->syntax.nested_call++; - nested_call = true; - - if( script->str_data[func].val == script->buildin_lang_macro_offset ) { + if (script->str_data[func].type == C_FUNC) { + script->syntax.nested_call++; + if (script->syntax.last_func != -1) { + if (script->str_data[func].val == script->buildin_lang_macro_offset) { script->syntax.lang_macro_active = true; macro = true; + } else if (script->str_data[func].val == script->buildin_lang_macro_fmtstring_offset) { + script->syntax.lang_macro_fmtstring_active = true; + macro = true; } } if( !macro ) { // buildin function + script->syntax.last_func = script->str_data[func].val; script->addl(func); script->addc(C_ARG); } @@ -919,18 +910,17 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom) disp_error_message("parse_callfunc: expected ')' to close argument list",p); ++p; - if( script->str_data[func].val == script->buildin_lang_macro_offset ) + if (script->str_data[func].val == script->buildin_lang_macro_offset) script->syntax.lang_macro_active = false; + else if (script->str_data[func].val == script->buildin_lang_macro_fmtstring_offset) + script->syntax.lang_macro_fmtstring_active = false; } - if( nested_call ) - script->syntax.nested_call--; - - if( !script->syntax.nested_call ) - script->syntax.last_func = -1; - - if( !macro ) + if (!macro) { + if (0 == --script->syntax.nested_call) + script->syntax.last_func = -1; script->addc(C_FUNC); + } return p; } @@ -942,7 +932,7 @@ void parse_nextline(bool first, const char* p) if( !first ) { script->addc(C_EOL); // mark end of line for stack cleanup - script->set_label(LABEL_NEXTLINE, script->pos, p); // fix up '-' labels + script->set_label(LABEL_NEXTLINE, VECTOR_LENGTH(script->buf), p); // fix up '-' labels } // initialize data for new '-' label fix up scheduling @@ -1066,6 +1056,8 @@ const char* parse_variable(const char* p) } // push the set function onto the stack + script->syntax.nested_call++; + script->syntax.last_func = script->str_data[script->buildin_set_ref].val; script->addl(script->buildin_set_ref); script->addc(C_ARG); @@ -1117,6 +1109,8 @@ const char* parse_variable(const char* p) // close the script by appending the function operator script->addc(C_FUNC); + if (--script->syntax.nested_call == 0) + script->syntax.last_func = -1; // push the buffer from the method return p; @@ -1159,13 +1153,19 @@ bool is_number(const char *p) { } /** + * Duplicates a script string into the script string list. * - **/ -int script_string_dup(char *str) { - size_t len = strlen(str); + * Grows the script string list as needed. + * + * @param str The string to insert. + * @return the string position in the script string list. + */ +int script_string_dup(char *str) +{ + int len = (int)strlen(str); int pos = script->string_list_pos; - while( pos+len+1 >= script->string_list_size ) { + while (pos+len+1 >= script->string_list_size) { script->string_list_size += (1024*1024)/2; RECREATE(script->string_list,char,script->string_list_size); } @@ -1179,231 +1179,194 @@ int script_string_dup(char *str) { /*========================================== * Analysis section *------------------------------------------*/ -const char* parse_simpleexpr(const char *p) +const char *parse_simpleexpr(const char *p) { p=script->skip_space(p); - if(*p==';' || *p==',') + if (*p == ';' || *p == ',') disp_error_message("parse_simpleexpr: unexpected end of expression",p); - if(*p=='(') { - int i = script->syntax.curly_count-1; - if (i >= 0 && script->syntax.curly[i].type == TYPE_ARGLIST) - ++script->syntax.curly[i].count; - p=script->parse_subexpr(p+1,-1); - p=script->skip_space(p); - if( (i=script->syntax.curly_count-1) >= 0 && script->syntax.curly[i].type == TYPE_ARGLIST - && script->syntax.curly[i].flag == ARGLIST_UNDEFINED && --script->syntax.curly[i].count == 0 - ) { - if( *p == ',' ) { - script->syntax.curly[i].flag = ARGLIST_PAREN; - return p; - } else { - script->syntax.curly[i].flag = ARGLIST_NO_PAREN; - } - } - if( *p != ')' ) - disp_error_message("parse_simpleexpr: unmatched ')'",p); - ++p; - } else if(is_number(p)) { - char *np; - long long lli; - while(*p == '0' && ISDIGIT(p[1])) p++; // Skip leading zeros, we don't support octal literals - lli=strtoll(p,&np,0); - if( lli < INT_MIN ) { - lli = INT_MIN; - script->disp_warning_message("parse_simpleexpr: underflow detected, capping value to INT_MIN",p); - } else if( lli > INT_MAX ) { - lli = INT_MAX; - script->disp_warning_message("parse_simpleexpr: overflow detected, capping value to INT_MAX",p); - } - script->addi((int)lli); // Cast is safe, as it's already been checked for overflows - p=np; - } else if(*p=='"') { - struct string_translation *st = NULL; - const char *start_point = p; - bool duplicate = true; - struct script_string_buf *sbuf = &script->parse_simpleexpr_str; - - do { - p++; - while( *p && *p != '"' ) { - if( (unsigned char)p[-1] <= 0x7e && *p == '\\' ) { - char buf[8]; - size_t len = sv->skip_escaped_c(p) - p; - size_t n = sv->unescape_c(buf, p, len); - if( n != 1 ) - ShowDebug("parse_simpleexpr: unexpected length %d after unescape (\"%.*s\" -> %.*s)\n", (int)n, (int)len, p, (int)n, buf); - p += len; - script_string_buf_addb(sbuf, *buf); - continue; - } else if( *p == '\n' ) { - disp_error_message("parse_simpleexpr: unexpected newline @ string",p); - } - script_string_buf_addb(sbuf, *p++); - } - if(!*p) - disp_error_message("parse_simpleexpr: unexpected end of file @ string",p); - p++; //'"' - p = script->skip_space(p); - } while( *p && *p == '"' ); - - script_string_buf_addb(sbuf, 0); - - if (!(script->syntax.translation_db && (st = strdb_get(script->syntax.translation_db, sbuf->ptr)) != NULL)) { - script->addc(C_STR); - - if( script->pos+sbuf->pos >= script->size ) { - do { - script->size += SCRIPT_BLOCK_SIZE; - } while( script->pos+sbuf->pos >= script->size ); - RECREATE(script->buf,unsigned char,script->size); - } + if (*p == '(') { + return script->parse_simpleexpr_paren(p); + } else if (is_number(p)) { + return script->parse_simpleexpr_number(p); + } else if(*p == '"') { + return script->parse_simpleexpr_string(p); + } else { + return script->parse_simpleexpr_name(p); + } +} - memcpy(script->buf+script->pos, sbuf->ptr, sbuf->pos); - script->pos += sbuf->pos; +const char *parse_simpleexpr_paren(const char *p) +{ + int i = script->syntax.curly_count - 1; + if (i >= 0 && script->syntax.curly[i].type == TYPE_ARGLIST) + ++script->syntax.curly[i].count; + p = script->parse_subexpr(p + 1, -1); + p = script->skip_space(p); + if ((i = script->syntax.curly_count - 1) >= 0 + && script->syntax.curly[i].type == TYPE_ARGLIST + && script->syntax.curly[i].flag == ARGLIST_UNDEFINED + && --script->syntax.curly[i].count == 0 + ) { + if (*p == ',') { + script->syntax.curly[i].flag = ARGLIST_PAREN; + return p; } else { - int expand = sizeof(int) + sizeof(uint8); - unsigned char j; - unsigned int st_cursor = 0; + script->syntax.curly[i].flag = ARGLIST_NO_PAREN; + } + } + if (*p != ')') + disp_error_message("parse_simpleexpr: unmatched ')'", p); - script->addc(C_LSTR); + return p + 1; +} - expand += (sizeof(char*) + sizeof(uint8)) * st->translations; +const char *parse_simpleexpr_number(const char *p) +{ + char *np = NULL; + long long lli; - while( script->pos+expand >= script->size ) { - script->size += SCRIPT_BLOCK_SIZE; - RECREATE(script->buf,unsigned char,script->size); - } + while (*p == '0' && ISDIGIT(p[1])) + p++; // Skip leading zeros, we don't support octal literals - *((int *)(&script->buf[script->pos])) = st->string_id; - *((uint8 *)(&script->buf[script->pos + sizeof(int)])) = st->translations; + lli = strtoll(p, &np, 0); + if (lli < INT_MIN) { + lli = INT_MIN; + script->disp_warning_message("parse_simpleexpr: underflow detected, capping value to INT_MIN", p); + } else if (lli > INT_MAX) { + lli = INT_MAX; + script->disp_warning_message("parse_simpleexpr: overflow detected, capping value to INT_MAX", p); + } + script->addi((int)lli); // Cast is safe, as it's already been checked for overflows - script->pos += sizeof(int) + sizeof(uint8); + return np; +} - for(j = 0; j < st->translations; j++) { - *((uint8 *)(&script->buf[script->pos])) = RBUFB(st->buf, st_cursor); - *((char **)(&script->buf[script->pos+sizeof(uint8)])) = &st->buf[st_cursor + sizeof(uint8)]; - script->pos += sizeof(char*) + sizeof(uint8); - st_cursor += sizeof(uint8); - while(st->buf[st_cursor++]); - st_cursor += sizeof(uint8); - } - } +const char *parse_simpleexpr_string(const char *p) +{ + const char *start_point = p; - /* When exporting we don't know what is a translation and what isn't */ - if( script->lang_export_fp && sbuf->pos > 1 ) {//sbuf->pos will always be at least 1 because of the '\0' - if( !script->syntax.strings ) { - script->syntax.strings = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA, 0); + do { + p++; + while (*p != '\0' && *p != '"') { + if ((unsigned char)p[-1] <= 0x7e && *p == '\\') { + char buf[8]; + size_t len = sv->skip_escaped_c(p) - p; + size_t n = sv->unescape_c(buf, p, len); + if (n != 1) + ShowDebug("parse_simpleexpr: unexpected length %d after unescape (\"%.*s\" -> %.*s)\n", (int)n, (int)len, p, (int)n, buf); + p += len; + VECTOR_ENSURE(script->parse_simpleexpr_strbuf, 1, 512); + VECTOR_PUSH(script->parse_simpleexpr_strbuf, buf[0]); + continue; } - - if( !strdb_exists(script->syntax.strings,sbuf->ptr) ) { - strdb_put(script->syntax.strings, sbuf->ptr, NULL); - duplicate = false; + if (*p == '\n') { + disp_error_message("parse_simpleexpr: unexpected newline @ string", p); } + VECTOR_ENSURE(script->parse_simpleexpr_strbuf, 1, 512); + VECTOR_PUSH(script->parse_simpleexpr_strbuf, *p++); } + if (*p == '\0') + disp_error_message("parse_simpleexpr: unexpected end of file @ string", p); + p++; //'"' + p = script->skip_space(p); + } while (*p != '\0' && *p == '"'); - if( script->lang_export_fp && !duplicate && - ( ( ( script->syntax.last_func == script->buildin_mes_offset || - script->syntax.last_func == script->buildin_select_offset ) && !script->syntax.nested_call - ) || script->syntax.lang_macro_active ) ) { - const char *line_start = start_point; - const char *line_end = start_point; - struct script_string_buf *lbuf = &script->lang_export_line_buf; - struct script_string_buf *ubuf = &script->lang_export_unescaped_buf; - size_t line_length, cursor; + VECTOR_ENSURE(script->parse_simpleexpr_strbuf, 1, 512); + VECTOR_PUSH(script->parse_simpleexpr_strbuf, '\0'); - while( line_start > script->parser_current_src ) { - if( *line_start != '\n' ) - line_start--; - else - break; - } + script->add_translatable_string(&script->parse_simpleexpr_strbuf, start_point); - while( *line_end != '\n' && *line_end != '\0' ) - line_end++; + VECTOR_TRUNCATE(script->parse_simpleexpr_strbuf); - line_length = (size_t)(line_end - line_start); - if( line_length > 0 ) { - script_string_buf_ensure(lbuf,line_length + 1); + return p; +} - memcpy(lbuf->ptr, line_start, line_length); - lbuf->pos = line_length; - script_string_buf_addb(lbuf, 0); +const char *parse_simpleexpr_name(const char *p) +{ + int l; + const char *pv = NULL; - normalize_name(lbuf->ptr, "\r\n\t "); - } + // label , register , function etc + if (script->skip_word(p) == p) + disp_error_message("parse_simpleexpr: unexpected character", p); - for(cursor = 0; cursor < sbuf->pos; cursor++) { - if( sbuf->ptr[cursor] == '"' ) - script_string_buf_addb(ubuf, '\\'); - script_string_buf_addb(ubuf, sbuf->ptr[cursor]); - } - script_string_buf_addb(ubuf, 0); - - fprintf(script->lang_export_fp, "#: %s\n" - "# %s\n" - "msgctxt \"%s\"\n" - "msgid \"%s\"\n" - "msgstr \"\"\n", - script->parser_current_file ? script->parser_current_file : "Unknown File", - lbuf->ptr, - script->parser_current_npc_name ? script->parser_current_npc_name : "Unknown NPC", - ubuf->ptr - ); - lbuf->pos = 0; - ubuf->pos = 0; + l = script->add_word(p); + if (script->str_data[l].type == C_FUNC || script->str_data[l].type == C_USERFUNC || script->str_data[l].type == C_USERFUNC_POS) { + return script->parse_callfunc(p,1,0); +#ifdef SCRIPT_CALLFUNC_CHECK + } else { + const char *name = script->get_str(l); + if (strdb_get(script->userfunc_db,name) != NULL) { + return script->parse_callfunc(p, 1, 1); } - sbuf->pos = 0; +#endif + } + + if ((pv = script->parse_variable(p)) != NULL) { + // successfully processed a variable assignment + return pv; + } + + if (script->str_data[l].type == C_INT && script->str_data[l].deprecated) { + disp_warning_message("This constant is deprecated and it will be removed in a future version. Please see the script documentation and constants.conf for an alternative.\n", p); + } + + p = script->skip_word(p); + if (*p == '[') { + // array(name[i] => getelementofarray(name,i) ) + script->addl(script->buildin_getelementofarray_ref); + script->addc(C_ARG); + script->addl(l); + + p = script->parse_subexpr(p + 1, -1); + p = script->skip_space(p); + if (*p != ']') + disp_error_message("parse_simpleexpr: unmatched ']'", p); + ++p; + script->addc(C_FUNC); } else { - int l; - const char* pv; + script->addl(l); + } - // label , register , function etc - if(script->skip_word(p)==p) - disp_error_message("parse_simpleexpr: unexpected character",p); + return p; +} - l=script->add_word(p); - if( script->str_data[l].type == C_FUNC || script->str_data[l].type == C_USERFUNC || script->str_data[l].type == C_USERFUNC_POS) { - return script->parse_callfunc(p,1,0); -#ifdef SCRIPT_CALLFUNC_CHECK - } else { - const char* name = script->get_str(l); - if( strdb_get(script->userfunc_db,name) != NULL ) { - return script->parse_callfunc(p,1,1); - } -#endif - } +void script_add_translatable_string(const struct script_string_buf *string, const char *start_point) +{ + struct string_translation *st = NULL; - if( (pv = script->parse_variable(p)) ) { - // successfully processed a variable assignment - return pv; - } + if (script->syntax.translation_db == NULL + || (st = strdb_get(script->syntax.translation_db, VECTOR_DATA(*string))) == NULL) { + script->addc(C_STR); - if (script->str_data[l].type == C_INT && script->str_data[l].deprecated) { - disp_warning_message("This constant is deprecated and it will be removed in a future version. Please see the script documentation and constants.conf for an alternative.\n", p); - } + VECTOR_ENSURE(script->buf, VECTOR_LENGTH(*string), SCRIPT_BLOCK_SIZE); - p=script->skip_word(p); - if( *p == '[' ) { - // array(name[i] => getelementofarray(name,i) ) - script->addl(script->buildin_getelementofarray_ref); - script->addc(C_ARG); - script->addl(l); + VECTOR_PUSHARRAY(script->buf, VECTOR_DATA(*string), VECTOR_LENGTH(*string)); + } else { + unsigned char u; + int st_cursor = 0; - p=script->parse_subexpr(p+1,-1); - p=script->skip_space(p); - if( *p != ']' ) - disp_error_message("parse_simpleexpr: unmatched ']'",p); - ++p; - script->addc(C_FUNC); - } else { - script->addl(l); - } + script->addc(C_LSTR); - } + VECTOR_ENSURE(script->buf, (int)(sizeof(st->string_id) + sizeof(st->translations)), SCRIPT_BLOCK_SIZE); + VECTOR_PUSHARRAY(script->buf, (void *)&st->string_id, sizeof(st->string_id)); + VECTOR_PUSHARRAY(script->buf, (void *)&st->translations, sizeof(st->translations)); - return p; + for (u = 0; u != st->translations; u++) { + struct string_translation_entry *entry = (void *)(st->buf+st_cursor); + char *stringptr = &entry->string[0]; + st_cursor += sizeof(*entry); + VECTOR_ENSURE(script->buf, (int)(sizeof(entry->lang_id) + sizeof(char *)), SCRIPT_BLOCK_SIZE); + VECTOR_PUSHARRAY(script->buf, (void *)&entry->lang_id, sizeof(entry->lang_id)); + VECTOR_PUSHARRAY(script->buf, (void *)&stringptr, sizeof(stringptr)); + st_cursor += sizeof(uint8); // FIXME: What are we skipping here? + while (st->buf[st_cursor++] != 0) + (void)0; // Skip string + st_cursor += sizeof(uint8); // FIXME: What are we skipping here? + } + } } /*========================================== @@ -1582,7 +1545,7 @@ const char* parse_curly_close(const char* p) // You are here labeled sprintf(label,"__SW%x_%x", (unsigned int)script->syntax.curly[pos].index, (unsigned int)script->syntax.curly[pos].count); l=script->add_str(label); - script->set_label(l,script->pos, p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); if(script->syntax.curly[pos].flag) { //Exists default @@ -1595,7 +1558,7 @@ const char* parse_curly_close(const char* p) // Label end sprintf(label,"__SW%x_FIN", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos, p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); linkdb_final(&script->syntax.curly[pos].case_label); // free the list of case label script->syntax.curly_count--; //Closing decision if, for , while @@ -1674,7 +1637,7 @@ const char* parse_syntax(const char* p) // You are here labeled sprintf(label,"__SW%x_%x", (unsigned int)script->syntax.curly[pos].index, (unsigned int)script->syntax.curly[pos].count); l=script->add_str(label); - script->set_label(l,script->pos, p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); } //Decision statement switch p = script->skip_space(p2); @@ -1714,7 +1677,7 @@ const char* parse_syntax(const char* p) // Label after the completion of FALLTHRU sprintf(label, "__SW%x_%xJ", (unsigned int)script->syntax.curly[pos].index, (unsigned int)script->syntax.curly[pos].count); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); } // check duplication of case label [Rayce] if(linkdb_search(&script->syntax.curly[pos].case_label, (void*)h64BPTRSIZE(v)) != NULL) @@ -1781,7 +1744,7 @@ const char* parse_syntax(const char* p) } sprintf(label, "__SW%x_%x", (unsigned int)script->syntax.curly[pos].index, (unsigned int)script->syntax.curly[pos].count); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); // Skip to the next link w/o condition sprintf(label, "goto __SW%x_%x;", (unsigned int)script->syntax.curly[pos].index, (unsigned int)script->syntax.curly[pos].count + 1); @@ -1792,7 +1755,7 @@ const char* parse_syntax(const char* p) // The default label sprintf(label, "__SW%x_DEF", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); script->syntax.curly[script->syntax.curly_count - 1].flag = 1; script->syntax.curly[pos].count++; @@ -1810,7 +1773,7 @@ const char* parse_syntax(const char* p) // Label of the (do) form here sprintf(label, "__DO%x_BGN", (unsigned int)script->syntax.curly[script->syntax.curly_count].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); script->syntax.curly_count++; return p; } @@ -1841,7 +1804,7 @@ const char* parse_syntax(const char* p) // Form the start of label decision sprintf(label, "__FR%x_J", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); p=script->skip_space(p); if(*p == ';') { @@ -1870,7 +1833,7 @@ const char* parse_syntax(const char* p) // Labels to form the next loop sprintf(label, "__FR%x_NXT", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); // Process the next time you enter the loop // A ')' last for; flag to be treated as' @@ -1889,7 +1852,7 @@ const char* parse_syntax(const char* p) // Loop start labeling sprintf(label, "__FR%x_BGN", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); return p; } else if( p2 - p == 8 && strncmp(p, "function", 8) == 0 ) { // internal script function @@ -1939,9 +1902,9 @@ const char* parse_syntax(const char* p) if( script->str_data[l].type == C_NOP || script->str_data[l].type == C_USERFUNC )// register only, if the name was not used by something else { script->str_data[l].type = C_USERFUNC; - script->set_label(l, script->pos, p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); if( script->parse_options&SCRIPT_USE_LABEL_DB ) - script->label_add(l,script->pos); + script->label_add(l, VECTOR_LENGTH(script->buf)); } else disp_error_message("parse_syntax:function: function name is invalid", func_name); @@ -2021,7 +1984,7 @@ const char* parse_syntax(const char* p) // Form the start of label decision sprintf(label, "__WL%x_NXT", (unsigned int)script->syntax.curly[script->syntax.curly_count].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); // Skip to the end point if the condition is false sprintf(label, "__WL%x_FIN", (unsigned int)script->syntax.curly[script->syntax.curly_count].index); @@ -2078,7 +2041,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag) // Put the label of the location sprintf(label, "__IF%x_%x", (unsigned int)script->syntax.curly[pos].index, (unsigned int)script->syntax.curly[pos].count); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); script->syntax.curly[pos].count++; p = script->skip_space(p); @@ -2116,7 +2079,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag) // Put the label of the final location sprintf(label, "__IF%x_FIN", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); if(script->syntax.curly[pos].flag == 1) { // Because the position of the pointer is the same if not else for this return bp; @@ -2129,7 +2092,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag) // (Come here continue) to form the label here sprintf(label, "__DO%x_NXT", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); } // Skip to the end point if the condition is false @@ -2164,7 +2127,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag) // Form label of the end point conditions sprintf(label, "__DO%x_FIN", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); p = script->skip_space(p); if(*p != ';') { disp_error_message("parse_syntax: need ';'",p); @@ -2186,7 +2149,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag) // End for labeling sprintf(label, "__FR%x_FIN", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); script->syntax.curly_count--; return p; } else if(script->syntax.curly[pos].type == TYPE_WHILE) { @@ -2202,7 +2165,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag) // End while labeling sprintf(label, "__WL%x_FIN", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); script->syntax.curly_count--; return p; } else if(script->syntax.curly[pos].type == TYPE_USERFUNC) { @@ -2215,7 +2178,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag) // Put the label of the location sprintf(label, "__FN%x_FIN", (unsigned int)script->syntax.curly[pos].index); l=script->add_str(label); - script->set_label(l,script->pos,p); + script->set_label(l, VECTOR_LENGTH(script->buf), p); script->syntax.curly_count--; return p; } else { @@ -2544,9 +2507,6 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o script->parse_cleanup_timer_id = timer->add(timer->gettick() + 10, script->parse_cleanup_timer, 0, 0); } - if( script->syntax.strings ) /* used only when generating translation file */ - db_destroy(script->syntax.strings); - memset(&script->syntax,0,sizeof(script->syntax)); script->syntax.last_func = -1;/* as valid values are >= 0 */ if( script->parser_current_npc_name ) { @@ -2556,11 +2516,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o script->syntax.translation_db = strdb_get(script->translation_db, script->parser_current_npc_name); } - if( !script->buf ) { - script->buf = (unsigned char *)aMalloc(SCRIPT_BLOCK_SIZE*sizeof(unsigned char)); - script->size = SCRIPT_BLOCK_SIZE; - } - script->pos=0; + VECTOR_TRUNCATE(script->buf); script->parse_nextline(true, NULL); // who called parse_script is responsible for clearing the database after using it, but just in case... lets clear it here @@ -2574,7 +2530,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o if( script->error_report ) script->error(src,file,line,script->error_msg,script->error_pos); aFree( script->error_msg ); - script->pos = 0; + VECTOR_TRUNCATE(script->buf); for(i=LABEL_START;i<script->str_num;i++) if(script->str_data[i].type == C_NOP) script->str_data[i].type = C_NAME; for(i=0; i<size; i++) @@ -2594,9 +2550,9 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o p=script->skip_space(p); if( options&SCRIPT_IGNORE_EXTERNAL_BRACKETS ) {// does not require brackets around the script - if( *p == '\0' && !(options&SCRIPT_RETURN_EMPTY_SCRIPT) ) - {// empty script and can return NULL - script->pos = 0; + if (*p == '\0' && !(options&SCRIPT_RETURN_EMPTY_SCRIPT)) { + // empty script and can return NULL + VECTOR_TRUNCATE(script->buf); #ifdef ENABLE_CASE_CHECK script->local_casecheck.clear(); script->parser_current_src = NULL; @@ -2614,9 +2570,9 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o if (retval) *retval = EXIT_FAILURE; } p = script->skip_space(p+1); - if( *p == '}' && !(options&SCRIPT_RETURN_EMPTY_SCRIPT) ) - {// empty script and can return NULL - script->pos = 0; + if (*p == '}' && !(options&SCRIPT_RETURN_EMPTY_SCRIPT)) { + // empty script and can return NULL + VECTOR_TRUNCATE(script->buf); #ifdef ENABLE_CASE_CHECK script->local_casecheck.clear(); script->parser_current_src = NULL; @@ -2648,9 +2604,9 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o tmpp=script->skip_space(script->skip_word(p)); if(*tmpp==':' && !(strncmp(p,"default:",8) == 0 && p + 7 == tmpp)) { i=script->add_word(p); - script->set_label(i,script->pos,p); + script->set_label(i, VECTOR_LENGTH(script->buf), p); if( script->parse_options&SCRIPT_USE_LABEL_DB ) - script->label_add(i,script->pos); + script->label_add(i, VECTOR_LENGTH(script->buf)); p=tmpp+1; p=script->skip_space(p); continue; @@ -2672,8 +2628,8 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o script->str_data[i].type=C_NAME; script->str_data[i].label=i; for (j = script->str_data[i].backpatch; j >= 0 && j != 0x00ffffff; ) { - int next = GETVALUE(script->buf,j); - SETVALUE(script->buf,j,i); + int next = GETVALUE(&script->buf, j); + SETVALUE(&script->buf, j, i); j = next; } } else if(script->str_data[i].type == C_USERFUNC) { @@ -2690,37 +2646,39 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o } #ifdef SCRIPT_DEBUG_DISP - for(i=0;i<script->pos;i++) { - if((i&15)==0) ShowMessage("%04x : ",i); - ShowMessage("%02x ",script->buf[i]); - if((i&15)==15) ShowMessage("\n"); + for (i = 0; i < VECTOR_LENGTH(script->buf); i++) { + if ((i&15) == 0) + ShowMessage("%04x : ",i); + ShowMessage("%02x ", VECTOR_INDEX(script->buf, i)); + if ((i&15) == 15) + ShowMessage("\n"); } ShowMessage("\n"); #endif #ifdef SCRIPT_DEBUG_DISASM i = 0; - while (i < script->pos) { - c_op op = script->get_com(script->buf, &i); + while (i < VECTOR_LENGTH(script->buf)) { + c_op op = script->get_com(&script->buf, &i); int j = i; // Note: i is modified in the line above. ShowMessage("%06x %s", i, script->op2name(op)); switch (op) { case C_INT: - ShowMessage(" %d", script->get_num(script->buf,&i)); + ShowMessage(" %d", script->get_num(&script->buf, &i)); break; case C_POS: - ShowMessage(" 0x%06x", *(int*)(script->buf+i)&0xffffff); + ShowMessage(" 0x%06x", *(int*)(&VECTOR_INDEX(script->buf, i))&0xffffff); i += 3; break; case C_NAME: - j = (*(int*)(script->buf+i)&0xffffff); + j = (*(int*)(&VECTOR_INDEX(script->buf, i))&0xffffff); ShowMessage(" %s", ( j == 0xffffff ) ? "?? unknown ??" : script->get_str(j)); i += 3; break; case C_STR: - j = (int)strlen((char*)script->buf + i); - ShowMessage(" %s", script->buf + i); + j = (int)strlen((char*)&VECTOR_INDEX(script->buf, i)); + ShowMessage(" %s", &VECTOR_INDEX(script->buf, i)); i += j+1; break; } @@ -2729,9 +2687,9 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o #endif CREATE(code,struct script_code,1); - code->script_buf = (unsigned char *)aMalloc(script->pos*sizeof(unsigned char)); - memcpy(code->script_buf, script->buf, script->pos); - code->script_size = script->pos; + VECTOR_INIT(code->script_buf); + VECTOR_ENSURE(code->script_buf, VECTOR_LENGTH(script->buf), 1); + VECTOR_PUSHARRAY(code->script_buf, VECTOR_DATA(script->buf), VECTOR_LENGTH(script->buf)); code->local.vars = NULL; code->local.arrays = NULL; #ifdef ENABLE_CASE_CHECK @@ -3624,7 +3582,7 @@ void script_free_code(struct script_code* code) script->free_vars(code->local.vars); if (code->local.arrays) code->local.arrays->destroy(code->local.arrays,script->array_free_db); - aFree(code->script_buf); + VECTOR_CLEAR(code->script_buf); aFree(code); } @@ -3749,32 +3707,32 @@ void script_add_pending_ref(struct script_state *st, struct reg_db *ref) { /*========================================== * Read command *------------------------------------------*/ -c_op get_com(unsigned char *scriptbuf,int *pos) +c_op get_com(const struct script_buf *scriptbuf, int *pos) { int i = 0, j = 0; - if(scriptbuf[*pos]>=0x80) { + if (VECTOR_INDEX(*scriptbuf, *pos) >= 0x80) { return C_INT; } - while(scriptbuf[*pos]>=0x40) { - i=scriptbuf[(*pos)++]<<j; + while (VECTOR_INDEX(*scriptbuf, *pos) >= 0x40) { + i = VECTOR_INDEX(*scriptbuf, (*pos)++) << j; j+=6; } - return (c_op)(i+(scriptbuf[(*pos)++]<<j)); + return (c_op)(i+(VECTOR_INDEX(*scriptbuf, (*pos)++)<<j)); } /*========================================== * Income figures *------------------------------------------*/ -int get_num(unsigned char *scriptbuf,int *pos) +int get_num(const struct script_buf *scriptbuf, int *pos) { int i,j; i=0; j=0; - while(scriptbuf[*pos]>=0xc0) { - i+=(scriptbuf[(*pos)++]&0x7f)<<j; + while (VECTOR_INDEX(*scriptbuf, *pos) >= 0xc0) { + i+= (VECTOR_INDEX(*scriptbuf, (*pos)++)&0x7f)<<j; j+=6; } - return i+((scriptbuf[(*pos)++]&0x7f)<<j); + return i+((VECTOR_INDEX(*scriptbuf, (*pos)++)&0x7f)<<j); } /// Ternary operators @@ -4084,10 +4042,17 @@ void op_1(struct script_state* st, int op) /// /// @param st Script state whose stack arguments should be inspected. /// @param func Built-in function for which the arguments are intended. -void script_check_buildin_argtype(struct script_state* st, int func) +bool script_check_buildin_argtype(struct script_state* st, int func) { int idx, invalid = 0; - char* sf = script->buildin[script->str_data[func].val]; + char* sf; + if (script->str_data[func].val < 0 || script->str_data[func].val >= script->buildin_count) { + ShowDebug("Function: %s\n", script->get_str(func)); + ShowError("Script data corruption detected!\n"); + script->reportsrc(st); + return false; + } + sf = script->buildin[script->str_data[func].val]; for (idx = 2; script_hasdata(st, idx); idx++) { struct script_data* data = script_getdata(st, idx); @@ -4158,6 +4123,7 @@ void script_check_buildin_argtype(struct script_state* st, int func) ShowDebug("Function: %s\n", script->get_str(func)); script->reportsrc(st); } + return true; } /// Executes a buildin command. @@ -4195,7 +4161,11 @@ int run_func(struct script_state *st) } if( script->config.warn_func_mismatch_argtypes ) { - script->check_buildin_argtype(st, func); + if (script->check_buildin_argtype(st, func) == false) + { + st->state = END; + return 1; + } } if(script->str_data[func].func) { @@ -4394,7 +4364,7 @@ void run_script_main(struct script_state *st) { st->state = RUN; while( st->state == RUN ) { - enum c_op c = script->get_com(st->script->script_buf,&st->pos); + enum c_op c = script->get_com(&st->script->script_buf, &st->pos); switch(c) { case C_EOL: if( stack->defsp > stack->sp ) @@ -4403,27 +4373,29 @@ void run_script_main(struct script_state *st) { script->pop_stack(st, stack->defsp, stack->sp);// pop unused stack data. (unused return value) break; case C_INT: - script->push_val(stack,C_INT,script->get_num(st->script->script_buf,&st->pos),NULL); + script->push_val(stack,C_INT,script->get_num(&st->script->script_buf, &st->pos), NULL); break; case C_POS: case C_NAME: - script->push_val(stack,c,GETVALUE(st->script->script_buf,st->pos),NULL); + script->push_val(stack,c,GETVALUE(&st->script->script_buf, st->pos), NULL); st->pos+=3; break; case C_ARG: script->push_val(stack,c,0,NULL); break; case C_STR: - script->push_conststr(stack, (const char *)(st->script->script_buf+st->pos)); - while(st->script->script_buf[st->pos++]); + script->push_conststr(stack, (const char *)&VECTOR_INDEX(st->script->script_buf, st->pos)); + while (VECTOR_INDEX(st->script->script_buf, st->pos++) != 0) + (void)0; // Skip string break; case C_LSTR: { - int string_id = *((int *)(&st->script->script_buf[st->pos])); - uint8 translations = *((uint8 *)(&st->script->script_buf[st->pos+sizeof(int)])); struct map_session_data *lsd = NULL; - - st->pos += sizeof(int) + sizeof(uint8); + uint8 translations = 0; + int string_id = *((int *)(&VECTOR_INDEX(st->script->script_buf, st->pos))); + st->pos += sizeof(string_id); + translations = *((uint8 *)(&VECTOR_INDEX(st->script->script_buf, st->pos))); + st->pos += sizeof(translations); if( (!st->rid || !(lsd = map->id2sd(st->rid)) || !lsd->lang_id) && !map->default_lang_id ) script->push_conststr(stack, script->string_list+string_id); @@ -4432,7 +4404,7 @@ void run_script_main(struct script_state *st) { int offset = st->pos; for(k = 0; k < translations; k++) { - uint8 lang_id = *(uint8 *)(&st->script->script_buf[offset]); + uint8 lang_id = *(uint8 *)(&VECTOR_INDEX(st->script->script_buf, offset)); offset += sizeof(uint8); if( lang_id == wlang_id ) break; @@ -4441,7 +4413,7 @@ void run_script_main(struct script_state *st) { if (k == translations) script->push_conststr(stack, script->string_list+string_id); else - script->push_conststr(stack, *(const char**)(&st->script->script_buf[offset]) ); + script->push_conststr(stack, *(const char**)(&VECTOR_INDEX(st->script->script_buf, offset))); } st->pos += ( ( sizeof(char*) + sizeof(uint8) ) * translations ); } @@ -4855,9 +4827,6 @@ void do_final_script(void) script->clear_translations(false); script->parser_clean_leftovers(); - - if( script->lang_export_file ) - aFree(script->lang_export_file); } /** @@ -4879,7 +4848,7 @@ void script_load_translations(void) { const char *config_filename = "db/translations.conf"; // FIXME hardcoded name struct config_setting_t *translations = NULL; int i, size; - uint32 total = 0; + int total = 0; uint8 lang_id = 0, k; if (map->minimal) // No translations in minimal mode @@ -4916,24 +4885,22 @@ void script_load_translations(void) { for(i = 0; i < size; i++) { const char *translation_file = libconfig->setting_get_string_elem(translations, i); - script->load_translation(translation_file, ++lang_id, &total); + total += script->load_translation(translation_file, ++lang_id); } libconfig->destroy(&translations_conf); - if( total ) { + if (total != 0) { struct DBIterator *main_iter; struct DBMap *string_db; struct string_translation *st = NULL; - uint32 j = 0; - CREATE(script->translation_buf, char *, total); - script->translation_buf_size = total; + VECTOR_ENSURE(script->translation_buf, total, 1); main_iter = db_iterator(script->translation_db); for (string_db = dbi_first(main_iter); dbi_exists(main_iter); string_db = dbi_next(main_iter)) { struct DBIterator *sub_iter = db_iterator(string_db); for (st = dbi_first(sub_iter); dbi_exists(sub_iter); st = dbi_next(sub_iter)) { - script->translation_buf[j++] = st->buf; + VECTOR_PUSH(script->translation_buf, st->buf); } dbi_destroy(sub_iter); } @@ -4955,145 +4922,256 @@ void script_load_translations(void) { } /** + * Generates a language name from a translation filename. * - **/ + * @param file The filename. + * @return The corresponding translation name. + */ const char *script_get_translation_file_name(const char *file) { - int i, len = (int)strlen(file), last_bar = -1, last_dot = -1; + const char *basename = NULL, *last_dot = NULL; - for(i = 0; i < len; i++) { - if( file[i] == '/' || file[i] == '\\' ) - last_bar = i; - else if ( file[i] == '.' ) - last_dot = i; + nullpo_retr("Unknown", file); + + basename = strrchr(file, '/');; +#ifdef WIN32 + { + const char *basename_windows = strrchr(file, '\\'); + if (basename_windows > basename) + basename = basename_windows; } +#endif // WIN32 + if (basename == NULL) + basename = file; + else + basename++; // Skip slash + Assert_retr("Unknown", *basename != '\0'); - if( last_bar != -1 || last_dot != -1 ) { + last_dot = strrchr(basename, '.'); + if (last_dot != NULL) { static char file_name[200]; - if( last_bar != -1 && last_dot < last_bar ) - last_dot = -1; - safestrncpy(file_name, file+(last_bar >= 0 ? last_bar+1 : 0), ( last_dot >= 0 ? ( last_bar >= 0 ? last_dot - last_bar : last_dot ) : sizeof(file_name) )); + if (last_dot == basename) + return basename + 1; + + safestrncpy(file_name, basename, last_dot - basename + 1); return file_name; } - return file; + return basename; } /** - * Parses a individual translation file - **/ -void script_load_translation(const char *file, uint8 lang_id, uint32 *total) { - uint32 translations = 0; + * Parses and adds a translated string to the translations database. + * + * @param file Translations file being parsed (for error messages). + * @param lang_id Language ID being parsed. + * @param msgctxt Message context (i.e. NPC name) + * @param msgid Message ID (source string) + * @param msgstr Translated message + * @return success state + * @retval true if a new string was added. + */ +bool script_load_translation_addstring(const char *file, uint8 lang_id, const char *msgctxt, const struct script_string_buf *msgid, const struct script_string_buf *msgstr) +{ + nullpo_retr(false, file); + nullpo_retr(false, msgctxt); + nullpo_retr(false, msgid); + nullpo_retr(false, msgstr); + + if (VECTOR_LENGTH(*msgid) <= 1) { + // Empty ID (i.e. header) to be ignored + return false; + } + + if (VECTOR_LENGTH(*msgstr) <= 1) { + // Empty (untranslated) string to be ignored + return false; + } + + if (msgctxt[0] == '\0') { + // Missing context + ShowWarning("script_load_translation: Missing context for msgid '%s' in '%s'. Skipping.\n", + VECTOR_DATA(*msgid), file); + return false; + } + + if (strcasecmp(msgctxt, "messages.conf") == 0) { + int i; + for (i = 0; i < MAX_MSG; i++) { + if (atcommand->msg_table[0][i] != NULL && strcmpi(atcommand->msg_table[0][i], VECTOR_DATA(*msgid)) == 0) { + if (atcommand->msg_table[lang_id][i] != NULL) + aFree(atcommand->msg_table[lang_id][i]); + atcommand->msg_table[lang_id][i] = aStrdup(VECTOR_DATA(*msgstr)); + break; + } + } + } else { + int msgstr_len = VECTOR_LENGTH(*msgstr); + int inner_len = 1 + msgstr_len + 1; //uint8 lang_id + msgstr_len + '\0' + struct string_translation *st = NULL; + struct DBMap *string_db; + + if ((string_db = strdb_get(script->translation_db, msgctxt)) == NULL) { + string_db = strdb_alloc(DB_OPT_DUP_KEY, 0); + strdb_put(script->translation_db, msgctxt, string_db); + } + + if ((st = strdb_get(string_db, VECTOR_DATA(*msgid))) == NULL) { + CREATE(st, struct string_translation, 1); + st->string_id = script->string_dup(VECTOR_DATA(*msgid)); + strdb_put(string_db, VECTOR_DATA(*msgid), st); + } + RECREATE(st->buf, uint8, st->len + inner_len); + + WBUFB(st->buf, st->len) = lang_id; + safestrncpy(WBUFP(st->buf, st->len + 1), VECTOR_DATA(*msgstr), msgstr_len + 1); + + st->translations++; + st->len += inner_len; + } + return true; +} + +/** + * Parses an individual translation file. + * + * @param file The filename to parse. + * @param lang_id The language identifier. + * @return The amount of strings loaded. + */ +int script_load_translation(const char *file, uint8 lang_id) +{ + int translations = 0; char line[1024]; char msgctxt[NAME_LENGTH*2+1] = { 0 }; - struct DBMap *string_db; - size_t i; FILE *fp; - struct script_string_buf msgid = { 0 }, msgstr = { 0 }; + int lineno = 0; + struct script_string_buf msgid, msgstr; - if( !(fp = fopen(file,"rb")) ) { + if ((fp = fopen(file,"rb")) == NULL) { ShowError("load_translation: failed to open '%s' for reading\n",file); - return; + return 0; } + VECTOR_INIT(msgid); + VECTOR_INIT(msgstr); + script->add_language(script->get_translation_file_name(file)); - if( lang_id >= atcommand->max_message_table ) + if (lang_id >= atcommand->max_message_table) atcommand->expand_message_table(); - while(fgets(line, sizeof(line), fp)) { - size_t len = strlen(line); + while (fgets(line, sizeof(line), fp) != NULL) { + int len = (int)strlen(line); + int i; + lineno++; - if( len <= 1 ) + if(len <= 1) continue; - if( line[0] == '#' ) + if (line[0] == '#') continue; - if( strncasecmp(line,"msgctxt \"", 9) == 0 ) { + if (VECTOR_LENGTH(msgid) > 0 && VECTOR_LENGTH(msgstr) > 0) { + if (line[0] == '"') { + // Continuation line + (void)VECTOR_POP(msgstr); // Pop final '\0' + for (i = 8; i < len - 2; i++) { + VECTOR_ENSURE(msgstr, 1, 512); + if (line[i] == '\\' && line[i+1] == '"') { + VECTOR_PUSH(msgstr, '"'); + i++; + } else { + VECTOR_PUSH(msgstr, line[i]); + } + } + VECTOR_ENSURE(msgstr, 1, 512); + VECTOR_PUSH(msgstr, '\0'); + continue; + } + + // Add string + if (script->load_translation_addstring(file, lang_id, msgctxt, &msgid, &msgstr)) + translations++; + + msgctxt[0] = '\0'; + VECTOR_TRUNCATE(msgid); + VECTOR_TRUNCATE(msgstr); + } + + if (strncasecmp(line,"msgctxt \"", 9) == 0) { int cursor = 0; msgctxt[0] = '\0'; - for(i = 9; i < len - 2; i++) { - if( line[i] == '\\' && line[i+1] == '"' ) { + for (i = 9; i < len - 2; i++) { + if (line[i] == '\\' && line[i+1] == '"') { msgctxt[cursor] = '"'; i++; - } else + } else { msgctxt[cursor] = line[i]; + } if (++cursor >= (int)sizeof(msgctxt) - 1) break; } msgctxt[cursor] = '\0'; - } else if ( strncasecmp(line, "msgid \"", 7) == 0 ) { - msgid.pos = 0; - for(i = 7; i < len - 2; i++) { - if( line[i] == '\\' && line[i+1] == '"' ) { - script_string_buf_addb(&msgid, '"'); - i++; - } else - script_string_buf_addb(&msgid, line[i]); - } - script_string_buf_addb(&msgid,0); - } else if ( len > 9 && line[9] != '"' && strncasecmp(line, "msgstr \"",8) == 0 ) { - msgstr.pos = 0; - for(i = 8; i < len - 2; i++) { - if( line[i] == '\\' && line[i+1] == '"' ) { - script_string_buf_addb(&msgstr, '"'); + + // New context, reset everything + VECTOR_TRUNCATE(msgid); + VECTOR_TRUNCATE(msgstr); + continue; + } + + if (strncasecmp(line, "msgid \"", 7) == 0) { + VECTOR_TRUNCATE(msgid); + for (i = 7; i < len - 2; i++) { + VECTOR_ENSURE(msgid, 1, 512); + if (line[i] == '\\' && line[i+1] == '"') { + VECTOR_PUSH(msgid, '"'); i++; - } else - script_string_buf_addb(&msgstr, line[i]); + } else { + VECTOR_PUSH(msgid, line[i]); + } } - script_string_buf_addb(&msgstr,0); - } - - if( msgctxt[0] && msgid.pos > 1 && msgstr.pos > 1 ) { - size_t msgstr_len = msgstr.pos; - unsigned int inner_len = 1 + (uint32)msgstr_len + 1; //uint8 lang_id + msgstr_len + '\0' + VECTOR_ENSURE(msgid, 1, 512); + VECTOR_PUSH(msgid, '\0'); - if( strcasecmp(msgctxt, "messages.conf") == 0 ) { - int k; - - for(k = 0; k < MAX_MSG; k++) { - if( atcommand->msg_table[0][k] && strcmpi(atcommand->msg_table[0][k],msgid.ptr) == 0 ) { - if( atcommand->msg_table[lang_id][k] ) - aFree(atcommand->msg_table[lang_id][k]); - atcommand->msg_table[lang_id][k] = aStrdup(msgstr.ptr); - break; - } - } - } else { - struct string_translation *st = NULL; + // New id, reset string if any + VECTOR_TRUNCATE(msgstr); + continue; + } - if( !( string_db = strdb_get(script->translation_db, msgctxt) ) ) { - string_db = strdb_alloc(DB_OPT_DUP_KEY, 0); - strdb_put(script->translation_db, msgctxt, string_db); + if (VECTOR_LENGTH(msgid) > 0 && strncasecmp(line, "msgstr \"", 8) == 0) { + VECTOR_TRUNCATE(msgstr); + for (i = 8; i < len - 2; i++) { + VECTOR_ENSURE(msgstr, 1, 512); + if (line[i] == '\\' && line[i+1] == '"') { + VECTOR_PUSH(msgstr, '"'); + i++; + } else { + VECTOR_PUSH(msgstr, line[i]); } + } + VECTOR_ENSURE(msgstr, 1, 512); + VECTOR_PUSH(msgstr, '\0'); - if( !(st = strdb_get(string_db, msgid.ptr) ) ) { - CREATE(st, struct string_translation, 1); - st->string_id = script->string_dup(msgid.ptr); - strdb_put(string_db, msgid.ptr, st); - } - RECREATE(st->buf, char, st->len + inner_len); + continue; + } - WBUFB(st->buf, st->len) = lang_id; - safestrncpy(WBUFP(st->buf, st->len + 1), msgstr.ptr, msgstr_len + 1); + ShowWarning("script_load_translation: Unexpected input at '%s' in file '%s' line %d. Skipping.\n", + line, file, lineno); + } - st->translations++; - st->len += inner_len; - } - msgctxt[0] = '\0'; - msgid.pos = msgstr.pos = 0; + // Add last string + if (VECTOR_LENGTH(msgid) > 0 && VECTOR_LENGTH(msgstr) > 0) { + if (script->load_translation_addstring(file, lang_id, msgctxt, &msgid, &msgstr)) translations++; - } } - *total += translations; - fclose(fp); - script_string_buf_destroy(&msgid); - script_string_buf_destroy(&msgstr); + VECTOR_CLEAR(msgid); + VECTOR_CLEAR(msgstr); - ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' translations in '"CL_WHITE"%s"CL_RESET"'.\n", translations, file); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' translations in '"CL_WHITE"%s"CL_RESET"'.\n", translations, file); + return translations; } /** @@ -5109,15 +5187,10 @@ void script_clear_translations(bool reload) { script->string_list_pos = 0; script->string_list_size = 0; - if( script->translation_buf ) { - for(i = 0; i < script->translation_buf_size; i++) { - aFree(script->translation_buf[i]); - } - aFree(script->translation_buf); + while (VECTOR_LENGTH(script->translation_buf) > 0) { + aFree(VECTOR_POP(script->translation_buf)); } - - script->translation_buf = NULL; - script->translation_buf_size = 0; + VECTOR_CLEAR(script->translation_buf); if( script->languages ) { for(i = 0; i < script->max_lang_id; i++) @@ -5159,26 +5232,16 @@ int script_translation_db_destroyer(union DBKey key, struct DBData *data, va_lis /** * **/ -void script_parser_clean_leftovers(void) { - if( script->buf ) - aFree(script->buf); - - script->buf = NULL; - script->size = 0; +void script_parser_clean_leftovers(void) +{ + VECTOR_CLEAR(script->buf); if( script->translation_db ) { script->translation_db->destroy(script->translation_db,script->translation_db_destroyer); script->translation_db = NULL; } - if( script->syntax.strings ) { /* used only when generating translation file */ - db_destroy(script->syntax.strings); - script->syntax.strings = NULL; - } - - script_string_buf_destroy(&script->parse_simpleexpr_str); - script_string_buf_destroy(&script->lang_export_line_buf); - script_string_buf_destroy(&script->lang_export_unescaped_buf); + VECTOR_CLEAR(script->parse_simpleexpr_strbuf); } /** @@ -5197,6 +5260,7 @@ int script_parse_cleanup_timer(int tid, int64 tick, int id, intptr_t data) { *------------------------------------------*/ void do_init_script(bool minimal) { script->parse_cleanup_timer_id = INVALID_TIMER; + VECTOR_INIT(script->parse_simpleexpr_strbuf); script->st_db = idb_alloc(DB_OPT_BASE); script->userfunc_db = strdb_alloc(DB_OPT_DUP_KEY,0); @@ -5283,6 +5347,232 @@ const char *script_getfuncname(struct script_state *st) { return NULL; } +/** + * Writes a string to a StringBuf by combining a format string and a set of + * arguments taken from the current script state (caller script function + * arguments). + * + * @param[in] st Script state (must have at least a string at index + * 'start'). + * @param[in] start Index of the format string argument. + * @param[out] out Output string buffer (managed by the caller, must be + * already initialized) + * @retval false if an error occurs. + */ +bool script_sprintf(struct script_state *st, int start, struct StringBuf *out) +{ + const char *format = NULL; + const char *p = NULL, *np = NULL; + char *buf = NULL; + int buf_len = 0; + int lastarg = start; + int argc = script_lastdata(st) + 1; + + Assert_retr(-1, start >= 2 && start <= argc); + Assert_retr(-1, script_hasdata(st, start)); + + p = format = script_getstr(st, start); + + /* + * format-string = "" / *(text / placeholder) + * placeholder = "%%" / "%n" / std-placeholder + * std-placeholder = "%" [pos-parameter] [flags] [width] [precision] [length] type + * pos-parameter = number "$" + * flags = *("-" / "+" / "0" / SP) + * width = number / ("*" [pos-parameter]) + * precision = "." (number / ("*" [pos-parameter])) + * length = "hh" / "h" / "l" / "ll" / "L" / "z" / "j" / "t" + * type = "d" / "i" / "u" / "f" / "F" / "e" / "E" / "g" / "G" / "x" / "X" / "o" / "s" / "c" / "p" / "a" / "A" + * number = digit-nonzero *DIGIT + * digit-nonzero = "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" + */ + + while ((np = strchr(p, '%')) != NULL) { + bool flag_plus = false, flag_minus = false, flag_zero = false, flag_space = false; + bool positional_arg = false; + int width = 0, nextarg = lastarg + 1, thisarg = nextarg; + + if (p != np) { + int len = (int)(np - p + 1); + if (buf_len < len) { + RECREATE(buf, char, len); + buf_len = len; + } + safestrncpy(buf, p, len); + StrBuf->AppendStr(out, buf); + } + + p = np; + np++; + + // placeholder = "%%" ; (special case) + if (*np == '%') { + StrBuf->AppendStr(out, "%"); + p = np + 1; + continue; + } + // placeholder = "%n" ; (ignored) + if (*np == 'n') { + ShowWarning("script_sprintf: Format %%n not supported! Skipping...\n"); + script->reportsrc(st); + lastarg = nextarg; + p = np + 1; + continue; + } + + // std-placeholder = "%" [pos-parameter] [flags] [width] [precision] [length] type + + // pos-parameter = number "$" + if (ISDIGIT(*np) && *np != '0') { + const char *pp = np; + while (ISDIGIT(*pp)) + pp++; + if (*pp == '$') { + thisarg = atoi(np) + start; + positional_arg = true; + np = pp + 1; + } + } + + if (thisarg >= argc) { + ShowError("buildin_sprintf: Not enough arguments passed!\n"); + if (buf != NULL) + aFree(buf); + return false; + } + + // flags = *("-" / "+" / "0" / SP) + while (true) { + if (*np == '-') { + flag_minus = true; + } else if (*np == '+') { + flag_plus = true; + } else if (*np == ' ') { + flag_space = true; + } else if (*np == '0') { + flag_zero = true; + } else { + break; + } + np++; + } + + // width = number / ("*" [pos-parameter]) + if (ISDIGIT(*np)) { + width = atoi(np); + while (ISDIGIT(*np)) + np++; + } else if (*np == '*') { + bool positional_widtharg = false; + int width_arg; + np++; + // pos-parameter = number "$" + if (ISDIGIT(*np) && *np != '0') { + const char *pp = np; + while (ISDIGIT(*pp)) + pp++; + if (*pp == '$') { + width_arg = atoi(np) + start; + positional_widtharg = true; + np = pp + 1; + } + } + if (!positional_widtharg) { + width_arg = nextarg; + nextarg++; + if (!positional_arg) + thisarg++; + } + + if (width_arg >= argc || thisarg >= argc) { + ShowError("buildin_sprintf: Not enough arguments passed!\n"); + if (buf != NULL) + aFree(buf); + return false; + } + width = script_getnum(st, width_arg); + } + + // precision = "." (number / ("*" [pos-parameter])) ; (not needed/implemented) + + // length = "hh" / "h" / "l" / "ll" / "L" / "z" / "j" / "t" ; (not needed/implemented) + + // type = "d" / "i" / "u" / "f" / "F" / "e" / "E" / "g" / "G" / "x" / "X" / "o" / "s" / "c" / "p" / "a" / "A" + if (buf_len < 16) { + RECREATE(buf, char, 16); + buf_len = 16; + } + { + int i = 0; + memset(buf, '\0', buf_len); + buf[i++] = '%'; + if (flag_minus) + buf[i++] = '-'; + if (flag_plus) + buf[i++] = '+'; + else if (flag_space) // ignored if '+' is specified + buf[i++] = ' '; + if (flag_zero) + buf[i++] = '0'; + if (width > 0) + safesnprintf(buf + i, buf_len - i - 1, "%d", width); + } + buf[(int)strlen(buf)] = *np; + switch (*np) { + case 'd': + case 'i': + case 'u': + case 'x': + case 'X': + case 'o': + // Piggyback printf + StrBuf->Printf(out, buf, script_getnum(st, thisarg)); + break; + case 's': + // Piggyback printf + StrBuf->Printf(out, buf, script_getstr(st, thisarg)); + break; + case 'c': + { + const char *str = script_getstr(st, thisarg); + // Piggyback printf + StrBuf->Printf(out, buf, str[0]); + } + break; + case 'f': + case 'F': + case 'e': + case 'E': + case 'g': + case 'G': + case 'p': + case 'a': + case 'A': + ShowWarning("buildin_sprintf: Format %%%c not supported! Skipping...\n", *np); + script->reportsrc(st); + lastarg = nextarg; + p = np + 1; + continue; + default: + ShowError("buildin_sprintf: Invalid format string.\n"); + if (buf != NULL) + aFree(buf); + return false; + } + lastarg = nextarg; + p = np + 1; + } + + // Append the remaining part + if (p != NULL) + StrBuf->AppendStr(out, p); + + if (buf != NULL) + aFree(buf); + + return true; +} + //----------------------------------------------------------------------------- // buildin functions // @@ -5298,20 +5588,42 @@ const char *script_getfuncname(struct script_state *st) { BUILDIN(mes) { struct map_session_data *sd = script->rid2sd(st); - if( sd == NULL ) + if (sd == NULL) return true; - if( !script_hasdata(st, 3) ) {// only a single line detected in the script - clif->scriptmes(sd, st->oid, script_getstr(st, 2)); - } else {// parse multiple lines as they exist - int i; + clif->scriptmes(sd, st->oid, script_getstr(st, 2)); - for( i = 2; script_hasdata(st, i); i++ ) { - // send the message to the client - clif->scriptmes(sd, st->oid, script_getstr(st, i)); - } + return true; +} + +/** + * Appends a message to the npc dialog, applying format string conversions (see + * sprintf). + * + * If a dialog doesn't exist yet, one is created. + * + * @code + * mes "<message>"; + * @endcode + */ +BUILDIN(mesf) +{ + struct map_session_data *sd = script->rid2sd(st); + struct StringBuf buf; + + if (sd == NULL) + return true; + + StrBuf->Init(&buf); + + if (!script_sprintf(st, 2, &buf)) { + StrBuf->Destroy(&buf); + return false; } + clif->scriptmes(sd, st->oid, StrBuf->Value(&buf)); + StrBuf->Destroy(&buf); + return true; } @@ -8387,7 +8699,7 @@ BUILDIN(getbrokenid) num=script_getnum(st,2); for(i=0; i<MAX_INVENTORY; i++) { - if(sd->status.inventory[i].attribute) { + if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { brokencounter++; if(num==brokencounter) { id=sd->status.inventory[i].nameid; @@ -8412,7 +8724,7 @@ BUILDIN(getbrokencount) return true; for (i = 0; i < MAX_INVENTORY; i++) { - if (sd->status.inventory[i].attribute) + if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) counter++; } @@ -8434,10 +8746,11 @@ BUILDIN(repair) num=script_getnum(st,2); for(i=0; i<MAX_INVENTORY; i++) { - if(sd->status.inventory[i].attribute) { + if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { repaircounter++; if(num==repaircounter) { - sd->status.inventory[i].attribute=0; + sd->status.inventory[i].attribute |= ATTR_BROKEN; + sd->status.inventory[i].attribute ^= ATTR_BROKEN; clif->equiplist(sd); clif->produce_effect(sd, 0, sd->status.inventory[i].nameid); clif->misceffect(&sd->bl, 3); @@ -8461,9 +8774,10 @@ BUILDIN(repairall) for(i = 0; i < MAX_INVENTORY; i++) { - if(sd->status.inventory[i].nameid && sd->status.inventory[i].attribute) + if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { - sd->status.inventory[i].attribute = 0; + sd->status.inventory[i].attribute |= ATTR_BROKEN; + sd->status.inventory[i].attribute ^= ATTR_BROKEN; clif->produce_effect(sd,0,sd->status.inventory[i].nameid); repaircounter++; } @@ -11614,8 +11928,8 @@ BUILDIN(getwaitingroomstate) case 32: script_pushint(st, (cd->users >= cd->limit)); break; case 33: script_pushint(st, (cd->users >= cd->trigger)); break; - case 34: script_pushint(st, cd->minLvl); break; - case 35: script_pushint(st, cd->maxLvl); break; + case 34: script_pushint(st, cd->min_level); break; + case 35: script_pushint(st, cd->max_level); break; case 36: script_pushint(st, cd->zeny); break; default: script_pushint(st, -1); break; } @@ -15242,130 +15556,19 @@ BUILDIN(implode) // Implements C sprintf, except format %n. The resulting string is // returned, instead of being saved in variable by reference. //------------------------------------------------------- -BUILDIN(sprintf) { - unsigned int argc = 0, arg = 0; - const char* format; - char* p; - char* q; - char* buf = NULL; - char* buf2 = NULL; - struct script_data* data; - size_t len, buf2_len = 0; - StringBuf final_buf; - - // Fetch init data - format = script_getstr(st, 2); - argc = script_lastdata(st)-2; - len = strlen(format); - - // Skip parsing, where no parsing is required. - if(len==0) { - script_pushconststr(st,""); - return true; - } - - // Pessimistic alloc - CREATE(buf, char, len+1); - - // Need not be parsed, just solve stuff like %%. - if(argc==0) { - memcpy(buf,format,len+1); - script_pushstrcopy(st, buf); - aFree(buf); - return true; - } - - safestrncpy(buf, format, len+1); - - // Issue sprintf for each parameter - StrBuf->Init(&final_buf); - q = buf; - while((p = strchr(q, '%'))!=NULL) { - if(p!=q) { - len = p-q+1; - if(buf2_len<len) { - RECREATE(buf2, char, len); - buf2_len = len; - } - safestrncpy(buf2, q, len); - StrBuf->AppendStr(&final_buf, buf2); - q = p; - } - p = q+1; - if(*p=='%') { // %% - StrBuf->AppendStr(&final_buf, "%"); - q+=2; - continue; - } - if(*p=='n') { // %n - ShowWarning("buildin_sprintf: Format %%n not supported! Skipping...\n"); - script->reportsrc(st); - q+=2; - continue; - } - if(arg>=argc) { - ShowError("buildin_sprintf: Not enough arguments passed!\n"); - aFree(buf); - if(buf2) aFree(buf2); - StrBuf->Destroy(&final_buf); - script_pushconststr(st,""); - return false; - } - if((p = strchr(q+1, '%'))==NULL) { - p = strchr(q, 0); // EOS - } - len = p-q+1; - if(buf2_len<len) { - RECREATE(buf2, char, len); - buf2_len = len; - } - safestrncpy(buf2, q, len); - q = p; - - // Note: This assumes the passed value being the correct - // type to the current format specifier. If not, the server - // probably crashes or returns anything else, than expected, - // but it would behave in normal code the same way so it's - // the scripter's responsibility. - data = script_getdata(st, arg+3); - if(data_isstring(data)) { // String - StrBuf->Printf(&final_buf, buf2, script_getstr(st, arg+3)); - } else if(data_isint(data)) { // Number - StrBuf->Printf(&final_buf, buf2, script_getnum(st, arg+3)); - } else if(data_isreference(data)) { // Variable - char* name = reference_getname(data); - if(name[strlen(name)-1]=='$') { // var Str - StrBuf->Printf(&final_buf, buf2, script_getstr(st, arg+3)); - } else { // var Int - StrBuf->Printf(&final_buf, buf2, script_getnum(st, arg+3)); - } - } else { // Unsupported type - ShowError("buildin_sprintf: Unknown argument type!\n"); - aFree(buf); - if(buf2) aFree(buf2); - StrBuf->Destroy(&final_buf); - script_pushconststr(st,""); - return false; - } - arg++; - } - - // Append anything left - if(*q) { - StrBuf->AppendStr(&final_buf, q); - } +BUILDIN(sprintf) +{ + struct StringBuf buf; + StrBuf->Init(&buf); - // Passed more, than needed - if(arg<argc) { - ShowWarning("buildin_sprintf: Unused arguments passed.\n"); - script->reportsrc(st); + if (!script_sprintf(st, 2, &buf)) { + StrBuf->Destroy(&buf); + script_pushconststr(st, ""); + return false; } - script_pushstrcopy(st, StrBuf->Value(&final_buf)); - - aFree(buf); - if(buf2) aFree(buf2); - StrBuf->Destroy(&final_buf); + script_pushstrcopy(st, StrBuf->Value(&buf)); + StrBuf->Destroy(&buf); return true; } @@ -15846,7 +16049,7 @@ BUILDIN(md5) tmpstr = script_getstr(st,2); md5str = (char *)aMalloc((32+1)*sizeof(char)); - MD5_String(tmpstr, md5str); + md5->string(tmpstr, md5str); script_pushstr(st, md5str); return true; } @@ -20214,8 +20417,10 @@ bool script_add_builtin(const struct script_function *buildin, bool override) { else if( strcmp(buildin->name, "callfunc") == 0 ) script->buildin_callfunc_ref = n; else if( strcmp(buildin->name, "getelementofarray") == 0 ) script->buildin_getelementofarray_ref = n; else if( strcmp(buildin->name, "mes") == 0 ) script->buildin_mes_offset = script->buildin_count; + else if( strcmp(buildin->name, "mesf") == 0 ) script->buildin_mesf_offset = script->buildin_count; else if( strcmp(buildin->name, "select") == 0 ) script->buildin_select_offset = script->buildin_count; else if( strcmp(buildin->name, "_") == 0 ) script->buildin_lang_macro_offset = script->buildin_count; + else if( strcmp(buildin->name, "_$") == 0 ) script->buildin_lang_macro_fmtstring_offset = script->buildin_count; offset = script->buildin_count; @@ -20309,7 +20514,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(__setr,"rv?"), // NPC interaction - BUILDIN_DEF(mes,"s*"), + BUILDIN_DEF(mes,"s"), + BUILDIN_DEF(mesf,"s*"), BUILDIN_DEF(next,""), BUILDIN_DEF(close,""), BUILDIN_DEF(close2,""), @@ -20821,6 +21027,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(showscript, "s?"), BUILDIN_DEF(mergeitem,""), BUILDIN_DEF(_,"s"), + BUILDIN_DEF2(_, "_$", "s"), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up @@ -21054,8 +21261,8 @@ void script_defaults(void) { script->label_count = 0; script->labels_size = 0; - script->buf = NULL; - script->pos = 0, script->size = 0; + VECTOR_INIT(script->buf); + VECTOR_INIT(script->translation_buf); script->parse_options = 0; script->buildin_set_ref = 0; @@ -21181,6 +21388,11 @@ void script_defaults(void) { script->parse_nextline = parse_nextline; script->parse_variable = parse_variable; script->parse_simpleexpr = parse_simpleexpr; + script->parse_simpleexpr_paren = parse_simpleexpr_paren; + script->parse_simpleexpr_number = parse_simpleexpr_number; + script->parse_simpleexpr_string = parse_simpleexpr_string; + script->parse_simpleexpr_name = parse_simpleexpr_name; + script->add_translatable_string = script_add_translatable_string; script->parse_expr = parse_expr; script->parse_line = parse_line; script->read_constdb = read_constdb; @@ -21300,6 +21512,7 @@ void script_defaults(void) { script->mapindexname2id = script_mapindexname2id; script->string_dup = script_string_dup; script->load_translations = script_load_translations; + script->load_translation_addstring = script_load_translation_addstring; script->load_translation = script_load_translation; script->translation_db_destroyer = script_translation_db_destroyer; script->clear_translations = script_clear_translations; diff --git a/src/map/script.h b/src/map/script.h index a1fbe31f0..86cb20226 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -394,11 +394,20 @@ struct script_data { struct reg_db *ref; ///< Reference to the scope's variables }; +/** + * A script string buffer, used to hold strings used by the script engine. + */ +VECTOR_STRUCT_DECL(script_string_buf, char); + +/** + * Script buffer, used to hold parsed script data. + */ +VECTOR_STRUCT_DECL(script_buf, unsigned char); + // Moved defsp from script_state to script_stack since // it must be saved when script state is RERUNLINE. [Eoe / jA 1094] struct script_code { - int script_size; - unsigned char *script_buf; + struct script_buf script_buf; struct reg_db local; ///< Local (npc) vars unsigned short instances; }; @@ -493,8 +502,8 @@ struct script_syntax_data { int index; // Number of the syntax used in the script int last_func; // buildin index of the last parsed function unsigned int nested_call; //Dont really know what to call this - bool lang_macro_active; - struct DBMap *strings; // string map parsed (used when exporting strings only) + bool lang_macro_active; // Used to generate translation strings + bool lang_macro_fmtstring_active; // Used to generate translation strings struct DBMap *translation_db; //non-null if this npc has any translated strings to be linked }; @@ -517,16 +526,16 @@ struct script_array { unsigned int *members;/* member list */ }; -struct script_string_buf { - char *ptr; - size_t pos,size; +struct string_translation_entry { + uint8 lang_id; + char string[]; }; struct string_translation { int string_id; uint8 translations; - unsigned int len; - char *buf; + int len; + uint8 *buf; // Array of struct string_translation_entry }; /** @@ -576,8 +585,7 @@ struct script_interface { /* */ /// temporary buffer for passing around compiled bytecode /// @see add_scriptb, set_label, parse_script - unsigned char* buf; - int pos, size; + struct script_buf buf; /* */ struct script_syntax_data syntax; /* */ @@ -611,26 +619,22 @@ struct script_interface { /* */ unsigned int *generic_ui_array; unsigned int generic_ui_array_size; - /* Set during startup when attempting to export the lang, unset after server initialization is over */ - FILE *lang_export_fp; - char *lang_export_file;/* for lang_export_fp */ /* set and unset on npc_parse_script */ const char *parser_current_npc_name; /* */ int buildin_mes_offset; + int buildin_mesf_offset; int buildin_select_offset; int buildin_lang_macro_offset; + int buildin_lang_macro_fmtstring_offset; /* */ struct DBMap *translation_db;/* npc_name => DBMap (strings) */ - char **translation_buf;/* */ - uint32 translation_buf_size; + VECTOR_DECL(uint8 *) translation_buf; /* */ char **languages; uint8 max_lang_id; /* */ - struct script_string_buf parse_simpleexpr_str; - struct script_string_buf lang_export_line_buf; - struct script_string_buf lang_export_unescaped_buf; + struct script_string_buf parse_simpleexpr_strbuf; /* */ int parse_cleanup_timer_id; /* */ @@ -706,8 +710,8 @@ struct script_interface { const char * (*parse_syntax_close) (const char *p); const char * (*parse_syntax_close_sub) (const char *p, int *flag); const char * (*parse_syntax) (const char *p); - c_op (*get_com) (unsigned char *scriptbuf, int *pos); - int (*get_num) (unsigned char *scriptbuf, int *pos); + c_op (*get_com) (const struct script_buf *scriptbuf, int *pos); + int (*get_num) (const struct script_buf *scriptbuf, int *pos); const char* (*op2name) (int op); void (*reportsrc) (struct script_state *st); void (*reportdata) (struct script_data *data); @@ -724,10 +728,15 @@ struct script_interface { int (*add_word) (const char *p); const char* (*parse_callfunc) (const char *p, int require_paren, int is_custom); void (*parse_nextline) (bool first, const char *p); - const char* (*parse_variable) (const char *p); - const char* (*parse_simpleexpr) (const char *p); - const char* (*parse_expr) (const char *p); - const char* (*parse_line) (const char *p); + const char *(*parse_variable) (const char *p); + const char *(*parse_simpleexpr) (const char *p); + const char *(*parse_simpleexpr_paren) (const char *p); + const char *(*parse_simpleexpr_number) (const char *p); + const char *(*parse_simpleexpr_string) (const char *p); + const char *(*parse_simpleexpr_name) (const char *p); + void (*add_translatable_string) (const struct script_string_buf *string, const char *start_point); + const char *(*parse_expr) (const char *p); + const char *(*parse_line) (const char *p); void (*read_constdb) (void); void (*constdb_comment) (const char *comment); void (*load_parameters) (void); @@ -749,7 +758,7 @@ struct script_interface { void (*op_2num) (struct script_state *st, int op, int i1, int i2); void (*op_2) (struct script_state *st, int op); void (*op_1) (struct script_state *st, int op); - void (*check_buildin_argtype) (struct script_state *st, int func); + bool (*check_buildin_argtype) (struct script_state *st, int func); void (*detach_state) (struct script_state *st, bool dequeue_event); int (*db_free_code_sub) (union DBKey key, struct DBData *data, va_list ap); void (*add_autobonus) (const char *autobonus); @@ -807,7 +816,8 @@ struct script_interface { unsigned short (*mapindexname2id) (struct script_state *st, const char* name); int (*string_dup) (char *str); void (*load_translations) (void); - void (*load_translation) (const char *file, uint8 lang_id, uint32 *total); + bool (*load_translation_addstring) (const char *file, uint8 lang_id, const char *msgctxt, const struct script_string_buf *msgid, const struct script_string_buf *msgstr); + int (*load_translation) (const char *file, uint8 lang_id); int (*translation_db_destroyer) (union DBKey key, struct DBData *data, va_list ap); void (*clear_translations) (bool reload); int (*parse_cleanup_timer) (int tid, int64 tick, int id, intptr_t data); diff --git a/src/map/skill.c b/src/map/skill.c index 51d0792e3..a7ed0b8f2 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -54,6 +54,7 @@ #include "common/strlib.h" #include "common/timer.h" #include "common/utils.h" +#include "common/conf.h" #include <math.h> #include <stdio.h> @@ -83,7 +84,8 @@ struct s_skill_dbs skilldbs; struct skill_interface *skill; //Since only mob-casted splash skills can hit ice-walls -static inline int splash_target(struct block_list* bl) { +int skill_splash_target(struct block_list* bl) +{ #ifndef RENEWAL return ( bl->type == BL_MOB ) ? BL_SKILL|BL_CHAR : BL_CHAR; #else // Some skills can now hit ground skills(traps, ice wall & etc.) @@ -579,11 +581,20 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) return 1; } break; - + default: + return skill->not_ok_unknown(skill_id, sd); } return (map->list[m].flag.noskill); } +int skill_notok_unknown(uint16 skill_id, struct map_session_data *sd) +{ + int16 m; + nullpo_retr (1, sd); + m = sd->bl.m; + return (map->list[m].flag.noskill); +} + int skillnotok_hom(uint16 skill_id, struct homun_data *hd) { uint16 idx = skill->get_index(skill_id); @@ -610,12 +621,20 @@ int skillnotok_hom(uint16 skill_id, struct homun_data *hd) if(hd->sc.data[SC_GOLDENE_FERSE]) return 1; break; + default: + return skill->not_ok_hom_unknown(skill_id, hd); } //Use master's criteria. return skill->not_ok(skill_id, hd->master); } +int skillnotok_hom_unknown(uint16 skill_id, struct homun_data *hd) +{ + //Use master's criteria. + return skill->not_ok(skill_id, hd->master); +} + int skillnotok_mercenary(uint16 skill_id, struct mercenary_data *md) { uint16 idx = skill->get_index(skill_id); @@ -1546,17 +1565,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 sd->state.autocast = 1; skill->consume_requirement(sd,temp,auto_skill_lv,1); skill->toggle_magicpower(src, temp); - switch (type) { - case CAST_GROUND: - skill->castend_pos2(src, tbl->x, tbl->y, temp, auto_skill_lv, tick, 0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(src, tbl, temp, auto_skill_lv, tick, 0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(src, tbl, temp, auto_skill_lv, tick, 0); - break; - } + skill->castend_type(type, src, tbl, temp, auto_skill_lv, tick, 0); sd->state.autocast = 0; //Set canact delay. [Skotlex] ud = unit->bl2ud(src); @@ -1684,11 +1693,7 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1 sd->state.autocast = 1; sd->autospell3[i].lock = true; skill->consume_requirement(sd,temp,skill_lv,1); - switch( type ) { - case CAST_GROUND: skill->castend_pos2(&sd->bl, tbl->x, tbl->y, temp, skill_lv, tick, 0); break; - case CAST_NODAMAGE: skill->castend_nodamage_id(&sd->bl, tbl, temp, skill_lv, tick, 0); break; - case CAST_DAMAGE: skill->castend_damage_id(&sd->bl, tbl, temp, skill_lv, tick, 0); break; - } + skill->castend_type(type, &sd->bl, tbl, temp, skill_lv, tick, 0); sd->autospell3[i].lock = false; sd->state.autocast = 0; } @@ -1898,17 +1903,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b dstsd->state.autocast = 1; skill->consume_requirement(dstsd,auto_skill_id,auto_skill_lv,1); - switch (type) { - case CAST_GROUND: - skill->castend_pos2(bl, tbl->x, tbl->y, auto_skill_id, auto_skill_lv, tick, 0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(bl, tbl, auto_skill_id, auto_skill_lv, tick, 0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(bl, tbl, auto_skill_id, auto_skill_lv, tick, 0); - break; - } + skill->castend_type(type, bl, tbl, auto_skill_id, auto_skill_lv, tick, 0); dstsd->state.autocast = 0; // Set canact delay. [Skotlex] ud = unit->bl2ud(bl); @@ -2005,7 +2000,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in if (sd) { for (i = 0; i < EQI_MAX; i++) { int j = sd->equip_index[i]; - if (j < 0 || sd->status.inventory[j].attribute == 1 || !sd->inventory_data[j]) + if (j < 0 || (sd->status.inventory[j].attribute & ATTR_BROKEN) != 0 || !sd->inventory_data[j]) continue; switch(i) { @@ -2031,7 +2026,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in continue; } if (flag) { - sd->status.inventory[j].attribute = 1; + sd->status.inventory[j].attribute |= ATTR_BROKEN; pc->unequipitem(sd, j, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); } } @@ -2068,12 +2063,12 @@ int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int return where?1:0; } /*========================================================================= - Used to knock back players, monsters, traps, etc - - 'count' is the number of squares to knock back - - 'direction' indicates the way OPPOSITE to the knockback direction (or -1 for default behavior) - - if 'flag&0x1', position update packets must not be sent. - - if 'flag&0x2', skill blown ignores players' special_state.no_knockback - -------------------------------------------------------------------------*/ + * Used to knock back players, monsters, traps, etc + * 'count' is the number of squares to knock back + * 'direction' indicates the way OPPOSITE to the knockback direction (or -1 for default behavior) + * if 'flag&0x1', position update packets must not be sent. + * if 'flag&0x2', skill blown ignores players' special_state.no_knockback + */ int skill_blown(struct block_list* src, struct block_list* target, int count, int8 dir, int flag) { int dx = 0, dy = 0; @@ -2890,11 +2885,11 @@ void skill_attack_display_unknown(int *attack_type, struct block_list* src, stru } int skill_attack_copy_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { - return *skill_id; + return *skill_id; } int skill_attack_dir_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { - return -1; + return -1; } void skill_attack_blow_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, int8 *dir) { @@ -3554,6 +3549,21 @@ int skill_reveal_trap(struct block_list *bl, va_list ap) return 0; } +void skill_castend_type(int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +{ + switch (type) { + case CAST_GROUND: + skill->castend_pos2(src, bl->x, bl->y, skill_id, skill_lv, tick, flag); + break; + case CAST_NODAMAGE: + skill->castend_nodamage_id(src, bl, skill_id, skill_lv, tick, flag); + break; + case CAST_DAMAGE: + skill->castend_damage_id(src, bl, skill_id, skill_lv, tick, flag); + break; + } +} + /*========================================== * * @@ -3744,7 +3754,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if (!(flag&1) && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_MONK) { //Becomes a splash attack when Soul Linked. map->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv),splash_target(src), + skill->get_splash(skill_id, skill_lv),skill->splash_target(src), src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id); } else @@ -3755,7 +3765,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 clif->skill_nodamage(src,bl,skill_id,skill_lv,1); skill->area_temp[1] = 0; map->foreachinrange(skill->attack_area, src, - skill->get_splash(skill_id, skill_lv), splash_target(src), + skill->get_splash(skill_id, skill_lv), skill->splash_target(src), BF_WEAPON, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); break; @@ -3791,7 +3801,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 //line of sight between caster and target. skill->area_temp[1] = bl->id; map->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, - skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), + skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), skill->splash_target(src), skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); break; @@ -3802,7 +3812,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 case NPC_THUNDERBREATH: skill->area_temp[1] = bl->id; map->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, - skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), + skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), skill->splash_target(src), skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); break; @@ -4005,7 +4015,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 skill->area_temp[0] = map->foreachinrange(skill->area_sub, bl, (skill_id == AS_SPLASHER)?1:skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count); // recursive invocation of skill->castend_damage_id() with flag|1 - map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); } break; @@ -4086,9 +4096,9 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 // Splash around target cell, but only cells inside area; we first have to check the area is not negative if((max(min_x,tx-1) <= min(max_x,tx+1)) && (max(min_y,ty-1) <= min(max_y,ty+1)) && - (map->foreachinarea(skill->area_sub, bl->m, max(min_x,tx-1), max(min_y,ty-1), min(max_x,tx+1), min(max_y,ty+1), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count))) { + (map->foreachinarea(skill->area_sub, bl->m, max(min_x,tx-1), max(min_y,ty-1), min(max_x,tx+1), min(max_y,ty+1), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count))) { // Recursive call - map->foreachinarea(skill->area_sub, bl->m, max(min_x,tx-1), max(min_y,ty-1), min(max_x,tx+1), min(max_y,ty+1), splash_target(src), src, skill_id, skill_lv, tick, (flag|BCT_ENEMY)+1, skill->castend_damage_id); + map->foreachinarea(skill->area_sub, bl->m, max(min_x,tx-1), max(min_y,ty-1), min(max_x,tx+1), min(max_y,ty+1), skill->splash_target(src), src, skill_id, skill_lv, tick, (flag|BCT_ENEMY)+1, skill->castend_damage_id); // Self-collision if(bl->x >= min_x && bl->x <= max_x && bl->y >= min_y && bl->y <= max_y) skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,(flag&0xFFF)>0?SD_ANIMATION:0); @@ -4489,18 +4499,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if( !skill->check_condition_castbegin(sd, spell_skill_id, spell_skill_lv) ) break; - switch( skill->get_casttype(spell_skill_id) ) { - case CAST_GROUND: - skill->castend_pos2(src, bl->x, bl->y, spell_skill_id, spell_skill_lv, tick, 0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(src, bl, spell_skill_id, spell_skill_lv, tick, 0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(src, bl, spell_skill_id, spell_skill_lv, tick, 0); - break; - } - + skill->castend_type(skill->get_casttype(spell_skill_id), src, bl, spell_skill_id, spell_skill_lv, tick, 0); sd->ud.canact_tick = tick + skill->delay_fix(src, spell_skill_id, spell_skill_lv); clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, spell_skill_id, spell_skill_lv), 0, 0, 0); @@ -4589,7 +4588,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 status_change_end(bl, SC_CLOAKING, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); // Need confirm it. } else { - map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL); if( sd ) pc->overheat(sd,1); } @@ -4607,7 +4606,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 // Destination area skill->area_temp[4] = x; skill->area_temp[5] = y; - map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); skill->addtimerskill(src,tick + 800,src->id,x,y,skill_id,skill_lv,0,flag); // To teleport Self clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,BDT_SKILL); } @@ -4666,7 +4665,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 status_change_end(bl, SC_HIDING, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); } else{ - map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL); } break; @@ -4803,7 +4802,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if(flag & 1) skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); else { - map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill->castend_damage_id); } break; @@ -4917,12 +4916,11 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { return 0; } - if( sd && ud->skilltimer != INVALID_TIMER && (pc->checkskill(sd,SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK) ) + if (sd && ud->skilltimer != INVALID_TIMER && (pc->checkskill(sd, SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK || (skill->get_inf2(ud->skill_id) & INF2_FREE_CAST_REDUCED) != 0)) {// restore original walk speed ud->skilltimer = INVALID_TIMER; status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD); } - ud->skilltimer = INVALID_TIMER; } @@ -5219,7 +5217,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { bool skill_castend_id_unknown(struct unit_data *ud, struct block_list *src, struct block_list *target) { - return false; + return false; } /*========================================== @@ -5455,7 +5453,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin heal_get_jobexp = heal_get_jobexp * battle_config.heal_exp / 100; if (heal_get_jobexp <= 0) heal_get_jobexp = 1; - pc->gainexp (sd, bl, 0, heal_get_jobexp, false); + pc->gainexp(sd, bl, 0, heal_get_jobexp, false); } } break; @@ -5531,7 +5529,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (jexp < 1) jexp = 1; } if(exp > 0 || jexp > 0) - pc->gainexp (sd, bl, exp, jexp, false); + pc->gainexp(sd, bl, exp, jexp, false); } } } @@ -6259,7 +6257,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin skill->area_temp[1] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); map->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv), splash_target(src), + skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id); status_change_end(src, SC_HIDING, INVALID_TIMER); @@ -6278,7 +6276,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int count = 0; skill->area_temp[1] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - count = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), + count = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); if( !count && ( skill_id == NC_AXETORNADO || skill_id == SR_SKYNETBLOW || skill_id == KO_HAPPOKUNAI ) ) clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL); @@ -6324,7 +6322,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src,bl,skill_id,skill_lv,1); skill->area_temp[1] = 0; map->foreachinrange(skill->attack_area, src, - skill->get_splash(skill_id, skill_lv), splash_target(src), + skill->get_splash(skill_id, skill_lv), skill->splash_target(src), BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); break; @@ -6338,7 +6336,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src, src, skill_id, -1, 1); map->delblock(src); //Required to prevent chain-self-destructions hitting back. map->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv), splash_target(src), + skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|targetmask, skill->castend_damage_id); map->addblock(src); @@ -6892,7 +6890,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 1; } if( skill_id == AM_BERSERKPITCHER ) { - if( dstsd && dstsd->status.base_level < (unsigned int)sd->inventory_data[i]->elv ) { + if (dstsd && dstsd->status.base_level < sd->inventory_data[i]->elv) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 1; @@ -8735,7 +8733,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int failure; if( (failure = sc_start2(src,bl,type,100,skill_lv,src->id,skill->get_time(skill_id,skill_lv))) ) { - map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);; + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),skill->splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);; clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,BDT_SKILL); if (sd) pc->overheat(sd,1); } @@ -8825,9 +8823,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (is_boss(bl)) break; joblvbonus = ( sd ? sd->status.job_level : 50 ); //First we set the success chance based on the caster's build which increases the chance. - rate = 10 * skill_lv + rnd_value( sstatus->dex / 12, sstatus->dex / 4 ) + joblvbonus + status->get_lv(src) / 10; + rate = 10 * skill_lv + rnd->value( sstatus->dex / 12, sstatus->dex / 4 ) + joblvbonus + status->get_lv(src) / 10; // We then reduce the success chance based on the target's build. - rate -= rnd_value( tstatus->agi / 6, tstatus->agi / 3 ) + tstatus->luk / 10 + ( dstsd ? (dstsd->max_weight / 10 - dstsd->weight / 10 ) / 100 : 0 ) + status->get_lv(bl) / 10; + rate -= rnd->value( tstatus->agi / 6, tstatus->agi / 3 ) + tstatus->luk / 10 + ( dstsd ? (dstsd->max_weight / 10 - dstsd->weight / 10 ) / 100 : 0 ) + status->get_lv(bl) / 10; //Finally we set the minimum success chance cap based on the caster's skill level and DEX. rate = cap_value( rate, skill_lv + sstatus->dex / 20, 100); clif->skill_nodamage(src,bl,skill_id,0,sc_start(src,bl,type,rate,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -9076,7 +9074,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src, bl, skill_id, skill_lv, sp ? 1:0); } else { clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, BDT_SKILL); - map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id); } break; @@ -9768,7 +9766,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } } else { skill->area_temp[2] = 0; - map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_nodamage_id); } break; @@ -9899,17 +9897,17 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin bool skill_castend_nodamage_id_dead_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { - return true; + return true; } bool skill_castend_nodamage_id_undead_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { - return true; + return true; } bool skill_castend_nodamage_id_mado_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { - return false; + return false; } bool skill_castend_nodamage_id_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) @@ -9947,7 +9945,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) return 0; } - if( sd && ud->skilltimer != INVALID_TIMER && ( pc->checkskill(sd,SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK ) ) + if (sd && ud->skilltimer != INVALID_TIMER && (pc->checkskill(sd, SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK || (skill->get_inf2(ud->skill_id) & INF2_FREE_CAST_REDUCED) != 0)) {// restore original walk speed ud->skilltimer = INVALID_TIMER; status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD); @@ -10083,7 +10081,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) } -static int check_npc_chaospanic(struct block_list *bl, va_list args) +int skill_check_npc_chaospanic(struct block_list *bl, va_list args) { const struct npc_data *nd = NULL; @@ -10097,7 +10095,8 @@ static int check_npc_chaospanic(struct block_list *bl, va_list args) return 1; } /* skill count without self */ -static int skill_count_wos(struct block_list *bl,va_list ap) { +int skill_count_wos(struct block_list *bl, va_list ap) +{ struct block_list* src = va_arg(ap, struct block_list*); if( src->id != bl->id ) { return 1; @@ -10339,7 +10338,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case SC_CHAOSPANIC: case SC_MAELSTROM: - if (sd && map->foreachinarea(&check_npc_chaospanic,src->m, x-3, y-3, x+3, y+3, BL_NPC) > 0 ) { + if (sd && map->foreachinarea(skill->check_npc_chaospanic, src->m, x-3, y-3, x+3, y+3, BL_NPC) > 0 ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -10481,7 +10480,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if( sc && sc->data[SC_BASILICA] ) status_change_end(src, SC_BASILICA, INVALID_TIMER); // Cancel Basilica else { // Create Basilica. Start SC on caster. Unit timer start SC on others. - if( map->foreachinrange(skill_count_wos, src, 2, BL_MOB|BL_PC, src) ) { + if( map->foreachinrange(skill->count_wos, src, 2, BL_MOB|BL_PC, src) ) { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); return 1; @@ -10746,7 +10745,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case RK_DRAGONBREATH: case RK_DRAGONBREATH_WATER: r = skill->get_splash(skill_id,skill_lv); - map->foreachinarea(skill->area_sub,src->m,x-r,y-r,x+r,y+r,splash_target(src), + map->foreachinarea(skill->area_sub,src->m,x-r,y-r,x+r,y+r,skill->splash_target(src), src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case WM_GREAT_ECHO: @@ -10768,7 +10767,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case SO_ARRULLO: r = skill->get_splash(skill_id,skill_lv); - map->foreachinarea(skill->area_sub,src->m,x-r,y-r,x+r,y+r,splash_target(src), + map->foreachinarea(skill->area_sub,src->m,x-r,y-r,x+r,y+r,skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); break; /** @@ -10883,7 +10882,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case LG_RAYOFGENESIS: if( status->charge(src,status_get_max_hp(src)*3*skill_lv / 100,0) ) { r = skill->get_splash(skill_id,skill_lv); - map->foreachinarea(skill->area_sub,src->m,x-r,y-r,x+r,y+r,splash_target(src), + map->foreachinarea(skill->area_sub,src->m,x-r,y-r,x+r,y+r,skill->splash_target(src), src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); } else if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); @@ -11883,7 +11882,8 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick return skill_id; } -void skill_unit_onplace_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) { +void skill_unit_onplace_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) +{ } /*========================================== @@ -12646,6 +12646,9 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 status->change_start(ss, bl, SC_BLIND, rnd() % 100 > sg->skill_lv * 10, sg->skill_lv, sg->skill_id, 0, 0, skill->get_time2(sg->skill_id, sg->skill_lv), SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); break; + default: + skill->unit_onplace_timer_unknown(src, bl, &tick); + break; } if (bl->type == BL_MOB && ss != bl) @@ -12653,6 +12656,11 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 return skill_id; } + +void skill_unit_onplace_timer_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) +{ +} + /*========================================== * Triggered when a char steps out of a skill cell *------------------------------------------*/ @@ -14063,22 +14071,22 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id int skill_check_condition_castbegin_off_unknown(struct status_change *sc, uint16 *skill_id) { - return -1; + return -1; } int skill_check_condition_castbegin_mount_unknown(struct status_change *sc, uint16 *skill_id) { - return 0; + return 0; } int skill_check_condition_castbegin_madogear_unknown(struct status_change *sc, uint16 *skill_id) { - return 0; + return 0; } int skill_check_condition_castbegin_unknown(struct status_change *sc, uint16 *skill_id) { - return -1; + return -1; } int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) { @@ -14701,12 +14709,12 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 bool skill_get_requirement_off_unknown(struct status_change *sc, uint16 *skill_id) { - return false; + return false; } bool skill_get_requirement_item_unknown(struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, uint16 *idx, int *i) { - return false; + return false; } void skill_get_requirement_unknown(struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, struct skill_condition *req) @@ -15222,7 +15230,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) { return; //Invalid index?? item = &target_sd->status.inventory[idx]; - if( item->nameid <= 0 || item->attribute == 0 ) + if( item->nameid <= 0 || (item->attribute & ATTR_BROKEN) == 0 ) return; //Again invalid item.... if( sd != target_sd && !battle->check_range(&sd->bl,&target_sd->bl, skill->get_range2(&sd->bl, sd->menuskill_id,sd->menuskill_val2) ) ){ @@ -15241,7 +15249,8 @@ void skill_repairweapon (struct map_session_data *sd, int idx) { clif->skill_nodamage(&sd->bl,&target_sd->bl,sd->menuskill_id,1,1); - item->attribute = 0;/* clear broken state */ + item->attribute |= ATTR_BROKEN; + item->attribute ^= ATTR_BROKEN; /* clear broken state */ clif->equiplist(target_sd); @@ -15312,7 +15321,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) if( sd->status.class_ == JOB_MECHANIC_T ) per += 100; else - per += 5 * ((signed int)sd->status.job_level - 50); + per += 5 * (sd->status.job_level - 50); pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_REFINE); // FIXME: is this the correct reason flag? if (per > rnd() % 1000) { @@ -16671,7 +16680,7 @@ int skill_unit_timer_sub(union DBKey key, struct DBData *data, va_list ap) case UNT_FEINTBOMB: { struct block_list *src = map->id2bl(group->src_id); if( src ) { - map->foreachinrange(skill->area_sub, &su->bl, su->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, &su->bl, su->range, skill->splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id); status_change_end(src, SC__FEINTBOMB_MASTER, INVALID_TIMER); } skill->delunit(su); @@ -18480,7 +18489,7 @@ void skill_init_unit_layout (void) } break; default: - ShowError("unknown unit layout at skill %d\n",i); + skill->init_unit_layout_unknown(i); break; } if (!skill->dbs->unit_layout[pos].count) @@ -18581,6 +18590,11 @@ void skill_init_unit_layout (void) } +void skill_init_unit_layout_unknown(int skill_idx) +{ + ShowError("unknown unit layout at skill %d\n", skill_idx); +} + int skill_block_check(struct block_list *bl, sc_type type , uint16 skill_id) { int inf = 0; struct status_change *sc = status->get_sc(bl); @@ -18799,220 +18813,6 @@ void skill_cooldown_load(struct map_session_data * sd) { } } -/*========================================== - * sub-function of DB reading. - * skill_db.txt - *------------------------------------------*/ -bool skill_parse_row_skilldb(char* split[], int columns, int current) { -// id,range,hit,inf,element,nk,splash,max,list_num,castcancel,cast_defence_rate,inf2,maxcount,skill_type,blow_count,name,description - uint16 skill_id = atoi(split[0]); - uint16 idx; - if( (skill_id >= GD_SKILLRANGEMIN && skill_id <= GD_SKILLRANGEMAX) - || (skill_id >= HM_SKILLRANGEMIN && skill_id <= HM_SKILLRANGEMAX) - || (skill_id >= MC_SKILLRANGEMIN && skill_id <= MC_SKILLRANGEMAX) - || (skill_id >= EL_SKILLRANGEMIN && skill_id <= EL_SKILLRANGEMAX) ) { - ShowWarning("skill_parse_row_skilldb: Skill id %d is forbidden (interferes with guild/homun/mercenary skill mapping)!\n", skill_id); - return false; - } - - idx = skill->get_index(skill_id); - if( !idx ) // invalid skill id - return false; - - skill->dbs->db[idx].nameid = skill_id; - skill->split_atoi(split[1],skill->dbs->db[idx].range); - skill->dbs->db[idx].hit = atoi(split[2]); - skill->dbs->db[idx].inf = atoi(split[3]); - skill->split_atoi(split[4],skill->dbs->db[idx].element); - skill->dbs->db[idx].nk = (int)strtol(split[5], NULL, 0); - skill->split_atoi(split[6],skill->dbs->db[idx].splash); - skill->dbs->db[idx].max = atoi(split[7]); - skill->split_atoi(split[8],skill->dbs->db[idx].num); - - if( strcmpi(split[9],"yes") == 0 ) - skill->dbs->db[idx].castcancel = 1; - else - skill->dbs->db[idx].castcancel = 0; - skill->dbs->db[idx].cast_def_rate = atoi(split[10]); - skill->dbs->db[idx].inf2 = (int)strtol(split[11], NULL, 0); - skill->split_atoi(split[12],skill->dbs->db[idx].maxcount); - if( strcmpi(split[13],"weapon") == 0 ) - skill->dbs->db[idx].skill_type = BF_WEAPON; - else if( strcmpi(split[13],"magic") == 0 ) - skill->dbs->db[idx].skill_type = BF_MAGIC; - else if( strcmpi(split[13],"misc") == 0 ) - skill->dbs->db[idx].skill_type = BF_MISC; - else - skill->dbs->db[idx].skill_type = 0; - skill->split_atoi(split[14],skill->dbs->db[idx].blewcount); - safestrncpy(skill->dbs->db[idx].name, trim(split[15]), sizeof(skill->dbs->db[idx].name)); - safestrncpy(skill->dbs->db[idx].desc, trim(split[16]), sizeof(skill->dbs->db[idx].desc)); - strdb_iput(skill->name2id_db, skill->dbs->db[idx].name, skill_id); - script->set_constant2(skill->dbs->db[idx].name, (int)skill_id, false, false); - - return true; -} - -bool skill_parse_row_requiredb(char* split[], int columns, int current) { -// skill_id,HPCost,MaxHPTrigger,SPCost,HPRateCost,SPRateCost,ZenyCost,RequiredWeapons,RequiredAmmoTypes,RequiredAmmoAmount,RequiredState,SpiritSphereCost,RequiredItemID1,RequiredItemAmount1,RequiredItemID2,RequiredItemAmount2,RequiredItemID3,RequiredItemAmount3,RequiredItemID4,RequiredItemAmount4,RequiredItemID5,RequiredItemAmount5,RequiredItemID6,RequiredItemAmount6,RequiredItemID7,RequiredItemAmount7,RequiredItemID8,RequiredItemAmount8,RequiredItemID9,RequiredItemAmount9,RequiredItemID10,RequiredItemAmount10 - char* p; - int j; - - uint16 skill_id = atoi(split[0]); - uint16 idx = skill->get_index(skill_id); - if( !idx ) // invalid skill id - return false; - - skill->split_atoi(split[1],skill->dbs->db[idx].hp); - skill->split_atoi(split[2],skill->dbs->db[idx].mhp); - skill->split_atoi(split[3],skill->dbs->db[idx].sp); - skill->split_atoi(split[4],skill->dbs->db[idx].hp_rate); - skill->split_atoi(split[5],skill->dbs->db[idx].sp_rate); - skill->split_atoi(split[6],skill->dbs->db[idx].zeny); - - //Which weapon type are required, see doc/item_db for types - p = split[7]; - for( j = 0; j < 32; j++ ) { - int l = atoi(p); - if( l == 99 ) { // Any weapon - skill->dbs->db[idx].weapon = 0; - break; - } else - skill->dbs->db[idx].weapon |= 1<<l; - p = strchr(p,':'); - if(!p) - break; - p++; - } - - //FIXME: document this - p = split[8]; - for( j = 0; j < 32; j++ ) { - int l = atoi(p); - if( l == 99 ) { // Any ammo type - skill->dbs->db[idx].ammo = 0xFFFFFFFF; - break; - } else if( l ) // 0 stands for no requirement - skill->dbs->db[idx].ammo |= 1<<l; - p = strchr(p,':'); - if( !p ) - break; - p++; - } - skill->split_atoi(split[9],skill->dbs->db[idx].ammo_qty); - - if( strcmpi(split[10],"hiding") == 0 ) skill->dbs->db[idx].state = ST_HIDING; - else if( strcmpi(split[10],"cloaking") == 0 ) skill->dbs->db[idx].state = ST_CLOAKING; - else if( strcmpi(split[10],"hidden") == 0 ) skill->dbs->db[idx].state = ST_HIDDEN; - else if( strcmpi(split[10],"riding") == 0 ) skill->dbs->db[idx].state = ST_RIDING; - else if( strcmpi(split[10],"falcon") == 0 ) skill->dbs->db[idx].state = ST_FALCON; - else if( strcmpi(split[10],"cart") == 0 ) skill->dbs->db[idx].state = ST_CART; - else if( strcmpi(split[10],"shield") == 0 ) skill->dbs->db[idx].state = ST_SHIELD; - else if( strcmpi(split[10],"sight") == 0 ) skill->dbs->db[idx].state = ST_SIGHT; - else if( strcmpi(split[10],"explosionspirits") == 0 ) skill->dbs->db[idx].state = ST_EXPLOSIONSPIRITS; - else if( strcmpi(split[10],"cartboost") == 0 ) skill->dbs->db[idx].state = ST_CARTBOOST; - else if( strcmpi(split[10],"recover_weight_rate") == 0 ) skill->dbs->db[idx].state = ST_RECOV_WEIGHT_RATE; - else if( strcmpi(split[10],"move_enable") == 0 ) skill->dbs->db[idx].state = ST_MOVE_ENABLE; - else if( strcmpi(split[10],"water") == 0 ) skill->dbs->db[idx].state = ST_WATER; - else if( strcmpi(split[10],"dragon") == 0 ) skill->dbs->db[idx].state = ST_RIDINGDRAGON; - else if( strcmpi(split[10],"warg") == 0 ) skill->dbs->db[idx].state = ST_WUG; - else if( strcmpi(split[10],"ridingwarg") == 0 ) skill->dbs->db[idx].state = ST_RIDINGWUG; - else if( strcmpi(split[10],"mado") == 0 ) skill->dbs->db[idx].state = ST_MADO; - else if( strcmpi(split[10],"elementalspirit") == 0 ) skill->dbs->db[idx].state = ST_ELEMENTALSPIRIT; - else if( strcmpi(split[10],"poisonweapon") == 0 ) skill->dbs->db[idx].state = ST_POISONINGWEAPON; - else if( strcmpi(split[10],"rollingcutter") == 0 ) skill->dbs->db[idx].state = ST_ROLLINGCUTTER; - else if( strcmpi(split[10],"mh_fighting") == 0 ) skill->dbs->db[idx].state = ST_MH_FIGHTING; - else if( strcmpi(split[10],"mh_grappling") == 0 ) skill->dbs->db[idx].state = ST_MH_GRAPPLING; - else if( strcmpi(split[10],"peco") == 0 ) skill->dbs->db[idx].state = ST_PECO; - /** - * Unknown or no state - **/ - else skill->dbs->db[idx].state = ST_NONE; - - skill->split_atoi(split[11],skill->dbs->db[idx].spiritball); - for( j = 0; j < MAX_SKILL_ITEM_REQUIRE; j++ ) { - skill->dbs->db[idx].itemid[j] = atoi(split[12+ 2*j]); - skill->dbs->db[idx].amount[j] = atoi(split[13+ 2*j]); - } - - return true; -} - -bool skill_parse_row_castdb(char* split[], int columns, int current) { -// skill_id,CastingTime,AfterCastActDelay,AfterCastWalkDelay,Duration1,Duration2 - uint16 skill_id = atoi(split[0]); - uint16 idx = skill->get_index(skill_id); - if( !idx ) // invalid skill id - return false; - - skill->split_atoi(split[1],skill->dbs->db[idx].cast); - skill->split_atoi(split[2],skill->dbs->db[idx].delay); - skill->split_atoi(split[3],skill->dbs->db[idx].walkdelay); - skill->split_atoi(split[4],skill->dbs->db[idx].upkeep_time); - skill->split_atoi(split[5],skill->dbs->db[idx].upkeep_time2); - skill->split_atoi(split[6],skill->dbs->db[idx].cooldown); -#ifdef RENEWAL_CAST - skill->split_atoi(split[7],skill->dbs->db[idx].fixed_cast); -#endif - return true; -} - -bool skill_parse_row_castnodexdb(char* split[], int columns, int current) { -// Skill id,Cast,Delay (optional) - uint16 skill_id = atoi(split[0]); - uint16 idx = skill->get_index(skill_id); - if( !idx ) // invalid skill id - return false; - - skill->split_atoi(split[1],skill->dbs->db[idx].castnodex); - if( split[2] ) // optional column - skill->split_atoi(split[2],skill->dbs->db[idx].delaynodex); - - return true; -} - -bool skill_parse_row_unitdb(char* split[], int columns, int current) { -// ID,unit ID,unit ID 2,layout,range,interval,target,flag - uint16 skill_id = atoi(split[0]); - uint16 idx = skill->get_index(skill_id); - if( !idx ) // invalid skill id - return false; - - skill->dbs->db[idx].unit_id[0] = (int)strtol(split[1],NULL,16); - skill->dbs->db[idx].unit_id[1] = (int)strtol(split[2],NULL,16); - skill->split_atoi(split[3],skill->dbs->db[idx].unit_layout_type); - skill->split_atoi(split[4],skill->dbs->db[idx].unit_range); - skill->dbs->db[idx].unit_interval = atoi(split[5]); - - if( strcmpi(split[6],"noenemy")==0 ) skill->dbs->db[idx].unit_target = BCT_NOENEMY; - else if( strcmpi(split[6],"friend")==0 ) skill->dbs->db[idx].unit_target = BCT_NOENEMY; - else if( strcmpi(split[6],"party")==0 ) skill->dbs->db[idx].unit_target = BCT_PARTY; - else if( strcmpi(split[6],"ally")==0 ) skill->dbs->db[idx].unit_target = BCT_PARTY|BCT_GUILD; - else if( strcmpi(split[6],"guild")==0 ) skill->dbs->db[idx].unit_target = BCT_GUILD; - else if( strcmpi(split[6],"all")==0 ) skill->dbs->db[idx].unit_target = BCT_ALL; - else if( strcmpi(split[6],"enemy")==0 ) skill->dbs->db[idx].unit_target = BCT_ENEMY; - else if( strcmpi(split[6],"self")==0 ) skill->dbs->db[idx].unit_target = BCT_SELF; - else if( strcmpi(split[6],"sameguild")==0 ) skill->dbs->db[idx].unit_target = BCT_GUILD|BCT_SAMEGUILD; - else if( strcmpi(split[6],"noone")==0 ) skill->dbs->db[idx].unit_target = BCT_NOONE; - else skill->dbs->db[idx].unit_target = (int)strtol(split[6],NULL,16); - - skill->dbs->db[idx].unit_flag = (int)strtol(split[7],NULL,16); - - if (skill->dbs->db[idx].unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy) - skill->dbs->db[idx].unit_target = BCT_NOENEMY; - - //By default, target just characters. - skill->dbs->db[idx].unit_target |= BL_CHAR; - if (skill->dbs->db[idx].unit_flag&UF_NOPC) - skill->dbs->db[idx].unit_target &= ~BL_PC; - if (skill->dbs->db[idx].unit_flag&UF_NOMOB) - skill->dbs->db[idx].unit_target &= ~BL_MOB; - if (skill->dbs->db[idx].unit_flag&UF_SKILL) - skill->dbs->db[idx].unit_target |= BL_SKILL; - - return true; -} - bool skill_parse_row_producedb(char* split[], int columns, int current) { // ProduceItemID,ItemLV,RequireSkill,Requireskill_lv,MaterialID1,MaterialAmount1,...... int x,y; @@ -19181,14 +18981,1297 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) { return true; } +#define skilldb_duplicate_warning(name, setting, skill) (ShowError("skill_read_skilldb: Duplicate entry '%s' in setting '%s' for Skill Id %d in '%s', skipping...\n", name, setting, skill, "db/"DBPATH"skill_db.conf")) +#define skilldb_invalid_error(name, setting, skill) (ShowError("skill_read_skilldb: Invalid entry '%s' in setting '%s' for Skill Id %d in '%s', skipping...\n", name, setting, skill, "db/"DBPATH"skill_db.conf")) + +/** + * Sets Level based configuration for skill groups from skill_db.conf [ Smokexyz/Hercules ] + * @param *conf pointer to config setting. + * @param *arr pointer to array to be set. + */ +void skill_config_set_level(struct config_setting_t *conf, int *arr) +{ + int i=0; + + if (config_setting_is_group(conf)) { + for (i=0; i<MAX_SKILL_LEVEL; i++) { + char level[5]; + sprintf(level, "Lv%d", i+1); + libconfig->setting_lookup_int(conf, level, &arr[i]); + } + } else if (config_setting_is_array(conf)) { + for (i=0; i<config_setting_length(conf) && i < MAX_SKILL_LEVEL; i++) { + arr[i] = libconfig->setting_get_int_elem(conf, i); + } + } else { + int val=libconfig->setting_get_int(conf); + for(i=0; i<MAX_SKILL_LEVEL; i++) { + arr[i] = val; + } + } +} + +/** + * Sets all values in a skill level array to a specified value [ Smokexyz/Hercules ] + * @param *arr pointer to array being parsed. + * @param value value being set for the array. + * @return (void) + */ +void skill_level_set_value(int *arr, int value) +{ + int i=0; + + for(i=0; i<MAX_SKILL_LEVEL; i++) { + arr[i] = value; + } +} + +void skill_validate_hittype(struct config_setting_t *conf, struct s_skill_db *sk) +{ + const char *type = NULL; + + if (libconfig->setting_lookup_string(conf, "Hit", &type)) { + if (strcmpi(type, "BDT_SKILL") == 0) { + sk->hit = BDT_SKILL; + } else if (strcmpi(type, "BDT_MULTIHIT") == 0) { + sk->hit = BDT_MULTIHIT; + } else if (strcmpi(type, "BDT_NORMAL") == 0) { + sk->hit = BDT_NORMAL; + } else { + skilldb_invalid_error(type, "Hit", sk->nameid); + return; + } + } +} + +/** + * Validates "SkillType" when reading skill_db.conf + * @param conf struct, pointer to skill configuration + * @param sk struct, pointer to s_skill_db + * @return (void) + */ +void skill_validate_skilltype(struct config_setting_t *conf, struct s_skill_db *sk) +{ + struct config_setting_t *t = NULL, *tt = NULL; + + if((t=libconfig->setting_get_member(conf, "SkillType")) && config_setting_is_group(t)) { + int j=0; + while ((tt = libconfig->setting_get_elem(t, j++))) { + const char *type = config_setting_name(tt); + bool on = libconfig->setting_get_bool_real(tt); + + if (strcmpi(type, "Enemy") == 0) { + if (on) { + sk->inf |= INF_ATTACK_SKILL; + } else { + sk->inf &= ~INF_ATTACK_SKILL; + } + } else if (strcmpi(type, "Place") == 0) { + if (on) { + sk->inf |= INF_GROUND_SKILL; + } else { + sk->inf &= ~INF_GROUND_SKILL; + } + } else if (strcmpi(type, "Self") == 0) { + if (on) { + sk->inf |= INF_SELF_SKILL; + } else { + sk->inf &= ~INF_SELF_SKILL; + } + } else if (strcmpi(type, "Friend") == 0) { + if (on) { + sk->inf |= INF_SUPPORT_SKILL; + } else { + sk->inf &= ~INF_SUPPORT_SKILL; + } + } else if (strcmpi(type, "Trap") == 0) { + if (on) { + sk->inf |= INF_TARGET_TRAP; + } else { + sk->inf &= ~INF_TARGET_TRAP; + } + } else if (strcmpi(type, "Passive") != 0) { + skilldb_invalid_error(type, config_setting_name(t), sk->nameid); + } + } + } +} + +/** + * Validates "SkillInfo" when reading skill_db.conf + * @param conf struct, pointer to skill configuration + * @param sk struct, pointer to s_skill_db + * @return (void) + */ +void skill_validate_skillinfo(struct config_setting_t *conf, struct s_skill_db *sk) +{ + struct config_setting_t *t = NULL, *tt = NULL; + + if ((t=libconfig->setting_get_member(conf, "SkillInfo")) && config_setting_is_group(t)) { + int j=0; + while ((tt = libconfig->setting_get_elem(t, j++))) { + const char *type = config_setting_name(tt); + bool on = libconfig->setting_get_bool_real(tt); + + if (strcmpi(type, "Quest") == 0) { + if (on) { + sk->inf2 |= INF2_QUEST_SKILL; + } else { + sk->inf2 &= ~INF2_QUEST_SKILL; + } + } else if (strcmpi(type, "NPC") == 0) { + if (on) { + sk->inf2 |= INF2_NPC_SKILL; + } else { + sk->inf2 &= ~INF2_NPC_SKILL; + } + } else if (strcmpi(type, "Wedding") == 0) { + if (on) { + sk->inf2 |= INF2_WEDDING_SKILL; + } else { + sk->inf2 &= ~INF2_WEDDING_SKILL; + } + } else if (strcmpi(type, "Spirit") == 0) { + if (on) { + sk->inf2 |= INF2_SPIRIT_SKILL; + } else { + sk->inf2 &= ~INF2_SPIRIT_SKILL; + } + } else if (strcmpi(type, "Guild") == 0) { + if (on) { + sk->inf2 |= INF2_GUILD_SKILL; + } else { + sk->inf2 &= ~INF2_GUILD_SKILL; + } + } else if (strcmpi(type, "Song") == 0) { + if (on) { + sk->inf2 |= INF2_SONG_DANCE; + } else { + sk->inf2 &= ~INF2_SONG_DANCE; + } + } else if (strcmpi(type, "Ensemble") == 0) { + if (on) { + sk->inf2 |= INF2_ENSEMBLE_SKILL; + } else { + sk->inf2 &= ~INF2_ENSEMBLE_SKILL; + } + } else if (strcmpi(type, "Trap") == 0) { + if (on) { + sk->inf2 |= INF2_TRAP; + } else { + sk->inf2 &= ~INF2_TRAP; + } + } else if (strcmpi(type, "TargetSelf") == 0) { + if (on) { + sk->inf2 |= INF2_TARGET_SELF; + } else { + sk->inf2 &= ~INF2_TARGET_SELF; + } + } else if (strcmpi(type, "NoCastSelf") == 0) { + if (on) { + sk->inf2 |= INF2_NO_TARGET_SELF; + } else { + sk->inf2 &= ~INF2_NO_TARGET_SELF; + } + } else if (strcmpi(type, "PartyOnly") == 0) { + if (on) { + sk->inf2 |= INF2_PARTY_ONLY; + } else { + sk->inf2 &= ~INF2_PARTY_ONLY; + } + } else if (strcmpi(type, "GuildOnly") == 0) { + if (on) { + sk->inf2 |= INF2_GUILD_ONLY; + } else { + sk->inf2 &= ~INF2_GUILD_ONLY; + } + } else if (strcmpi(type, "NoEnemy") == 0) { + if (on) { + sk->inf2 |= INF2_NO_ENEMY; + } else { + sk->inf2 &= ~INF2_NO_ENEMY; + } + } else if (strcmpi(type, "IgnoreLandProtector") == 0) { + if (on) { + sk->inf2 |= INF2_NOLP; + } else { + sk->inf2 &= ~INF2_NOLP; + } + } else if (strcmpi(type, "Chorus") == 0) { + if (on) { + sk->inf2 |= INF2_CHORUS_SKILL; + } else { + sk->inf2 &= ~INF2_CHORUS_SKILL; + } + } else if (strcmpi(type, "FreeCastNormal") == 0) { + if (on) { + sk->inf2 |= INF2_FREE_CAST_NORMAL; + } else { + sk->inf2 &= ~INF2_FREE_CAST_NORMAL; + } + } else if (strcmpi(type, "FreeCastReduced") == 0) { + if (on) { + sk->inf2 |= INF2_FREE_CAST_REDUCED; + } else { + sk->inf2 &= ~INF2_FREE_CAST_REDUCED; + } + } else if (strcmpi(type, "None") != 0) { + skilldb_invalid_error(type, config_setting_name(t), sk->nameid); + } + } + } +} + +/** + * Validates "AttackType" when reading skill_db.conf + * @param conf struct, pointer to skill configuration + * @param sk struct, pointer to s_skill_db + * @return (void) + */ +void skill_validate_attacktype(struct config_setting_t *conf, struct s_skill_db *sk) +{ + const char *type = NULL; + + if (libconfig->setting_lookup_string(conf, "AttackType", &type)) { + if (!strcmpi(type, "Weapon")) { + sk->skill_type = BF_WEAPON; + } else if (!strcmpi(type, "Magic")) { + sk->skill_type = BF_MAGIC; + } else if (!strcmpi(type, "Misc")) { + sk->skill_type = BF_MISC; + } else { + skilldb_invalid_error(type, "AttackType", sk->nameid); + return; + } + } +} + +/** + * Validates "Element" when reading skill_db.conf + * @param ele_t struct, pointer to skill configuration + * @param sk struct, pointer to s_skill_db + * @return (void) + */ +void skill_validate_element(struct config_setting_t *conf, struct s_skill_db *sk) +{ + const char *type = NULL; + struct config_setting_t *t = NULL; + + if ((t=libconfig->setting_get_member(conf, "Element")) && config_setting_is_group(t)) { + int j = 0; + char lv[5]; + + for (j=0; j < MAX_SKILL_LEVEL; j++) { + sprintf(lv, "Lv%d",j+1); + if (libconfig->setting_lookup_string(t, lv, &type)) { + if (strcmpi(type,"Ele_Weapon") == 0) + sk->element[j] = -1; + else if (strcmpi(type,"Ele_Endowed") == 0) + sk->element[j] = -2; + else if (strcmpi(type,"Ele_Random") == 0) + sk->element[j] = -3; + else if (!script->get_constant(type,&sk->element[j])) + skilldb_invalid_error(type, config_setting_name(conf), sk->nameid); + } + } + + } else if (libconfig->setting_lookup_string(conf, "Element", &type)) { + int ele = 0; + + if (strcmpi(type,"Ele_Weapon") == 0) + ele = -1; + else if (strcmpi(type,"Ele_Endowed") == 0) + ele = -2; + else if (strcmpi(type,"Ele_Random") == 0) + ele = -3; + else if (!script->get_constant(type, &ele)) { + skilldb_invalid_error(type, config_setting_name(conf), sk->nameid); + return; + } + + skill->level_set_value(sk->element, ele); + } +} + +/** + * Validates "DamageType" when reading skill_db.conf + * @param conf struct, pointer to skill configuration + * @param sk struct, pointer to s_skill_db + * @return (void) + */ +void skill_validate_damagetype(struct config_setting_t *conf, struct s_skill_db *sk) +{ + struct config_setting_t *t = NULL, *tt = NULL; + + if ((t=libconfig->setting_get_member(conf, "DamageType")) && config_setting_is_group(t)) { + int j=0; + while ((tt = libconfig->setting_get_elem(t, j++))) { + const char *type = config_setting_name(tt); + bool on = libconfig->setting_get_bool_real(tt); + + if (strcmpi(type, "NoDamage") == 0) { + if (on) { + sk->nk |= NK_NO_DAMAGE; + } else { + sk->nk &= ~NK_NO_DAMAGE; + } + } else if (strcmpi(type, "SplashArea") == 0) { + if (on) { + sk->nk |= NK_SPLASH_ONLY; + } else { + sk->nk &= ~NK_SPLASH_ONLY; + } + } else if (strcmpi(type, "SplitDamage") == 0) { + if (on) { + sk->nk |= NK_SPLASHSPLIT; + } else { + sk->nk &= ~NK_SPLASHSPLIT; + } + } else if (strcmpi(type, "IgnoreCards") == 0) { + if (on) { + sk->nk |= NK_NO_CARDFIX_ATK; + } else { + sk->nk &= ~NK_NO_CARDFIX_ATK; + } + } else if (strcmpi(type, "IgnoreElement") == 0) { + if (on) { + sk->nk |= NK_NO_ELEFIX; + } else { + sk->nk &= ~NK_NO_ELEFIX; + } + } else if (strcmpi(type, "IgnoreDefense") == 0) { + if (on) { + sk->nk |= NK_IGNORE_DEF; + } else { + sk->nk &= ~NK_IGNORE_DEF; + } + } else if (strcmpi(type, "IgnoreFlee") == 0) { + if (on) { + sk->nk |= NK_IGNORE_FLEE; + } else { + sk->nk &= ~NK_IGNORE_FLEE; + } + } else if (strcmpi(type, "IgnoreDefCards") == 0) { + if (on) { + sk->nk |= NK_NO_CARDFIX_DEF; + } else { + sk->nk &= ~NK_NO_CARDFIX_DEF; + } + } else { + skilldb_invalid_error(type, config_setting_name(t), sk->nameid); + } + } + } +} + +/** + * Validates "SkillCast/DelayOptions" when reading skill_db.conf + * @param conf struct, pointer to skill configuration + * @param sk struct, pointer to s_skill_db + * @param delay boolean, switch for cast/delay setting + * @return (void) + */ +void skill_validate_castnodex(struct config_setting_t *conf, struct s_skill_db *sk, bool delay) +{ + struct config_setting_t *t = NULL, *tt = NULL; + + if ((t=libconfig->setting_get_member(conf, delay?"SkillDelayOptions":"CastTimeOptions")) && config_setting_is_group(t)) { + int j = 0, tmpopt = 0; + while ((tt = libconfig->setting_get_elem(t, j++)) && j < 4) { + const char *type = config_setting_name(tt); + bool on = libconfig->setting_get_bool_real(tt); + + if (strcmpi(type, "IgnoreDex") == 0) { + if (on) { + tmpopt |= 1<<0; + } else { + tmpopt &= ~(1<<0); + } + } else if (strcmpi(type, "IgnoreStatusEffect") == 0) { + if (on) { + tmpopt |= 1<<1; + } else { + tmpopt &= ~(1<<1); + } + } else if (strcmpi(type, "IgnoreItemBonus") == 0) { + if (on) { + tmpopt |= 1<<2; + } else { + tmpopt &= ~(1<<2); + } + } else { + skilldb_invalid_error(type, config_setting_name(t), sk->nameid); + return; + } + + } + skill->level_set_value(delay?sk->delaynodex:sk->castnodex, tmpopt); + } +} + +/** + * Validates the "WeaponTypes" flag + * when parsing skill_db.conf + * @param *type const char, weapon type flag + * @param on boolean, switch for the flag + * @param *sk struct, pointer to s_skill_db + * @return void + */ +int skill_validate_weapontype_sub(const char *type, bool on, struct s_skill_db *sk ) +{ + if (strcmpi(type, "NoWeapon") == 0) { + if (on) { + sk->weapon |= 1<<W_FIST; + } else { + sk->weapon &= ~(1<<W_FIST); + } + } else if (strcmpi(type, "Daggers") == 0) { + if (on) { + sk->weapon |= 1<<W_DAGGER; + } else { + sk->weapon &= ~(1<<W_DAGGER); + } + } else if (strcmpi(type, "1HSwords") == 0) { + + if (on) { + sk->weapon |= 1<<W_1HSWORD; + } else { + sk->weapon &= ~(1<<W_1HSWORD); + } + } else if (strcmpi(type, "2HSwords") == 0) { + if (on) { + sk->weapon |= 1<<W_2HSWORD; + } else { + sk->weapon &= ~(1<<W_2HSWORD); + } + } else if (strcmpi(type, "1HSpears") == 0) { + if (on) { + sk->weapon |= 1<<W_1HSPEAR; + } else { + sk->weapon &= ~(1<<W_1HSPEAR); + } + } else if (strcmpi(type, "2HSpears") == 0) { + if (on) { + sk->weapon |= 1<<W_2HSPEAR; + } else { + sk->weapon &= ~(1<<W_2HSPEAR); + } + } else if (strcmpi(type, "1HAxes") == 0) { + if (on) { + sk->weapon |= 1<<W_1HAXE; + } else { + sk->weapon &= ~(1<<W_1HAXE); + } + } else if (strcmpi(type, "2HAxes") == 0) { + if (on) { + sk->weapon |= 1<<W_2HAXE; + } else { + sk->weapon &= ~(1<<W_2HAXE); + } + } else if (strcmpi(type, "Maces") == 0) { + if (on) { + sk->weapon |= 1<<W_MACE; + } else { + sk->weapon &= ~(1<<W_MACE); + } + } else if (strcmpi(type, "2HMaces") == 0) { + if (on) { + sk->weapon |= 1<<W_2HMACE; + } else { + sk->weapon &= ~(1<<W_2HMACE); + } + } else if (strcmpi(type, "Staves") == 0) { + if (on) { + sk->weapon |= 1<<W_STAFF; + } else { + sk->weapon &= ~(1<<W_STAFF); + } + } else if (strcmpi(type, "Bows") == 0) { + if (on) { + sk->weapon |= 1<<W_BOW; + } else { + sk->weapon &= ~(1<<W_BOW); + } + } else if (strcmpi(type, "Knuckles") == 0) { + if (on) { + sk->weapon |= 1<<W_KNUCKLE; + } else { + sk->weapon &= ~(1<<W_KNUCKLE); + } + } else if (strcmpi(type, "Instruments") == 0) { + if (on) { + sk->weapon |= 1<<W_MUSICAL; + } else { + sk->weapon &= ~(1<<W_MUSICAL); + } + } else if (strcmpi(type, "Whips") == 0) { + if (on) { + sk->weapon |= 1<<W_WHIP; + } else { + sk->weapon &= ~(1<<W_WHIP); + } + } else if (strcmpi(type, "Books") == 0) { + if (on) { + sk->weapon |= 1<<W_BOOK; + } else { + sk->weapon &= ~(1<<W_BOOK); + } + } else if (strcmpi(type, "Katars") == 0) { + if (on) { + sk->weapon |= 1<<W_KATAR; + } else { + sk->weapon &= ~(1<<W_KATAR); + } + } else if (strcmpi(type, "Revolvers") == 0) { + if (on) { + sk->weapon |= 1<<W_REVOLVER; + } else { + sk->weapon &= ~(1<<W_REVOLVER); + } + } else if (strcmpi(type, "Rifles") == 0) { + if (on) { + sk->weapon |= 1<<W_RIFLE; + } else { + sk->weapon &= ~(1<<W_RIFLE); + } + } else if (strcmpi(type, "GatlingGuns") == 0) { + if (on) { + sk->weapon |= 1<<W_GATLING; + } else { + sk->weapon &= ~(1<<W_GATLING); + } + } else if (strcmpi(type, "Shotguns") == 0) { + if (on) { + sk->weapon |= 1<<W_SHOTGUN; + } else { + sk->weapon &= ~(1<<W_SHOTGUN); + } + } else if (strcmpi(type, "GrenadeLaunchers") == 0) { + if (on) { + sk->weapon |= 1<<W_GRENADE; + } else { + sk->weapon &= ~(1<<W_GRENADE); + } + } else if (strcmpi(type, "FuumaShurikens") == 0) { + if (on) { + sk->weapon |= 1<<W_HUUMA; + } else { + sk->weapon &= ~(1<<W_HUUMA); + } + } else if (strcmpi(type, "2HStaves") == 0) { + if (on) { + sk->weapon |= 1<<W_2HSTAFF; + } else { + sk->weapon &= ~(1<<W_2HSTAFF); + } + } + /* MAX_SINGLE_WEAPON_TYPE excluded */ + else if (strcmpi(type, "DWDaggers") == 0) { + if (on) { + sk->weapon |= 1<<W_DOUBLE_DD; + } else { + sk->weapon &= ~(1<<W_DOUBLE_DD); + } + } else if (strcmpi(type, "DWSwords") == 0) { + if (on) { + sk->weapon |= 1<<W_DOUBLE_SS; + } else { + sk->weapon &= ~(1<<W_DOUBLE_SS); + } + } else if (strcmpi(type, "DWAxes") == 0) { + if (on) { + sk->weapon |= 1<<W_DOUBLE_AA; + } else { + sk->weapon &= ~(1<<W_DOUBLE_AA); + } + } else if (strcmpi(type, "DWDaggerSword") == 0) { + if (on) { + sk->weapon |= 1<<W_DOUBLE_DS; + } else { + sk->weapon &= ~(1<<W_DOUBLE_DS); + } + } else if (strcmpi(type, "DWDaggerAxe") == 0) { + if (on) { + sk->weapon |= 1<<W_DOUBLE_DA; + } else { + sk->weapon &= ~(1<<W_DOUBLE_DA); + } + } else if (strcmpi(type, "DWSwordAxe") == 0) { + if (on) { + sk->weapon |= 1<<W_DOUBLE_SA; + } else { + sk->weapon &= ~(1<<W_DOUBLE_SA); + } + } else if (strcmpi(type, "All") == 0) { + sk->weapon = 0; + } else { + ShowError("Item %d. Unknown weapon type %s\n", sk->nameid, type); + return 1; // invalid type + } + + return 0; +} + +/** + * Validates "WeaponTypes" + * when parsing skill_db.conf + * @param conf struct, pointer to the skill configuration + * @param sk struct, struct, pointer to s_skill_db + * @return (void) + */ +void skill_validate_weapontype(struct config_setting_t *conf, struct s_skill_db *sk) +{ + struct config_setting_t *tt = NULL; + const char *type = NULL; + + if ((tt = libconfig->setting_get_member(conf, "WeaponTypes")) && config_setting_is_group(tt)) { + int j = 0; + struct config_setting_t *wpt = NULL; + while ((wpt = libconfig->setting_get_elem(tt, j++)) != NULL) { + if (skill_validate_weapontype_sub(config_setting_name(wpt), libconfig->setting_get_bool_real(wpt), sk)) + skilldb_invalid_error(config_setting_name(wpt), config_setting_name(tt), sk->nameid); + } + } else if (libconfig->setting_lookup_string(conf, "WeaponTypes", &type)) { + if (skill_validate_weapontype_sub(type, true, sk)) + skilldb_invalid_error(type, "WeaponTypes", sk->nameid); + } +} + +/** + * Validates the "AmmoTypes" flag + * when parsing skill_db.conf + * @param type string, ammo type flag + * @param on boolean, switch for the flag + * @param sk struct, pointer to s_skill_db + * @return void + */ +int skill_validate_ammotype_sub(const char *type, bool on, struct s_skill_db *sk) +{ + if (strcmpi(type, "A_ARROW") == 0) { + if (on) { + sk->ammo |= 1<<A_ARROW; + } else { + sk->ammo &= ~(1<<A_ARROW); + } + } else if (strcmpi(type, "A_DAGGER") == 0) { + if (on) { + sk->ammo |= 1<<A_DAGGER; + } else { + sk->ammo &= ~(1<<A_DAGGER); + } + } else if (strcmpi(type, "A_BULLET") == 0) { + if (on) { + sk->ammo |= 1<<A_BULLET; + } else { + sk->ammo &= ~(1<<A_BULLET); + } + } else if (strcmpi(type, "A_SHELL") == 0) { + if (on) { + sk->ammo |= 1<<A_SHELL; + } else { + sk->ammo &= ~(1<<A_SHELL); + } + } else if (strcmpi(type, "A_GRENADE") == 0) { + if (on) { + sk->ammo |= 1<<A_GRENADE; + } else { + sk->ammo &= ~(1<<A_GRENADE); + } + } else if (strcmpi(type, "A_SHURIKEN") == 0) { + if (on) { + sk->ammo |= 1<<A_SHURIKEN; + } else { + sk->ammo &= ~(1<<A_SHURIKEN); + } + } else if (strcmpi(type, "A_KUNAI") == 0) { + if (on) { + sk->ammo |= 1<<A_KUNAI; + } else { + sk->ammo &= ~(1<<A_KUNAI); + } + } else if (strcmpi(type, "A_CANNONBALL") == 0) { + if (on) { + sk->ammo |= 1<<A_CANNONBALL; + } else { + sk->ammo &= ~(1<<A_CANNONBALL); + } + } else if (strcmpi(type, "A_THROWWEAPON") == 0) { + if (on) { + sk->ammo |= 1<<A_THROWWEAPON; + } else { + sk->ammo &= ~(1<<A_THROWWEAPON); + } + } else if (strcmpi(type, "All") == 0) { + if (on) { + sk->ammo = 0xFFFFFFFF; + } else { + sk->ammo = 0; + } + } else { + return 1; // Invalid Entry + } + + return 0; +} + +/** + * Validates the "AmmoTypes" flag + * when parsing skill_db.conf + * @param conf pointer to the skill configuration + * @param sk struct, pointer to s_skill_db + * @return void + */ +void skill_validate_ammotype(struct config_setting_t *conf, struct s_skill_db *sk) +{ + struct config_setting_t *tt = NULL; + const char *tstr = NULL; + + if ((tt = libconfig->setting_get_member(conf, "AmmoTypes")) && config_setting_is_group(tt)) { + int j = 0; + struct config_setting_t *amt = { 0 }; + while ((amt = libconfig->setting_get_elem(tt, j++))) { + if (skill_validate_ammotype_sub(config_setting_name(amt), libconfig->setting_get_bool_real(amt), sk)) + skilldb_invalid_error(config_setting_name(amt), config_setting_name(tt), sk->nameid); + } + } else if( libconfig->setting_lookup_string(conf, "AmmoTypes", &tstr)) { + if (skill_validate_ammotype_sub(tstr, true, sk)) + skilldb_invalid_error(tstr, "AmmoTypes", sk->nameid); + } +} + +/** + * Validates the "State" flag + * when parsing skill_db.conf + * @param conf struct, pointer to the skill configuration + * @param sk struct, pointer to s_skill_db + * @return void + */ +void skill_validate_state(struct config_setting_t *conf, struct s_skill_db *sk) +{ + const char *type = NULL; + + if (libconfig->setting_lookup_string(conf, "State", &type) && strcmpi(type,"None") != ST_NONE) { + if ( strcmpi(type,"Hiding") == 0 ) sk->state = ST_HIDING; + else if (strcmpi(type,"Cloaking") == 0 ) sk->state = ST_CLOAKING; + else if (strcmpi(type,"Hidden") == 0 ) sk->state = ST_HIDDEN; + else if (strcmpi(type,"Riding") == 0 ) sk->state = ST_RIDING; + else if (strcmpi(type,"Falcon") == 0 ) sk->state = ST_FALCON; + else if (strcmpi(type,"Cart") == 0 ) sk->state = ST_CART; + else if (strcmpi(type,"Shield") == 0 ) sk->state = ST_SHIELD; + else if (strcmpi(type,"Sight") == 0 ) sk->state = ST_SIGHT; + else if (strcmpi(type,"ExplosionSpirits") == 0 ) sk->state = ST_EXPLOSIONSPIRITS; + else if (strcmpi(type,"CartBoost") == 0 ) sk->state = ST_CARTBOOST; + else if (strcmpi(type,"NotOverWeight") == 0 ) sk->state = ST_RECOV_WEIGHT_RATE; + else if (strcmpi(type,"Moveable") == 0 ) sk->state = ST_MOVE_ENABLE; + else if (strcmpi(type,"InWater") == 0 ) sk->state = ST_WATER; + else if (strcmpi(type,"Dragon") == 0 ) sk->state = ST_RIDINGDRAGON; + else if (strcmpi(type,"Warg") == 0 ) sk->state = ST_WUG; + else if (strcmpi(type,"RidingWarg") == 0 ) sk->state = ST_RIDINGWUG; + else if (strcmpi(type,"MadoGear") == 0 ) sk->state = ST_MADO; + else if (strcmpi(type,"ElementalSpirit") == 0 ) sk->state = ST_ELEMENTALSPIRIT; + else if (strcmpi(type,"PoisonWeapon") == 0 ) sk->state = ST_POISONINGWEAPON; + else if (strcmpi(type,"RollingCutter") == 0 ) sk->state = ST_ROLLINGCUTTER; + else if (strcmpi(type,"MH_Fighting") == 0 ) sk->state = ST_MH_FIGHTING; + else if (strcmpi(type,"MH_Grappling") == 0 ) sk->state = ST_MH_GRAPPLING; + else if (strcmpi(type,"Peco") == 0 ) sk->state = ST_PECO; + else + skilldb_invalid_error(type, "State", sk->nameid); + } +} + +/** + * Validates the "Items" flag + * when parsing skill_db.conf + * @param conf struct, pointer to the skill configuration + * @param sk struct, pointer to s_skill_db + * @return void + */ +void skill_validate_item_requirements(struct config_setting_t *conf, struct s_skill_db *sk) +{ + struct config_setting_t *tt = NULL; + + if ((tt=libconfig->setting_get_member(conf, "Items")) && config_setting_is_group(conf)) { + int itx=-1; + struct config_setting_t *it; + + while((it=libconfig->setting_get_elem(tt, ++itx)) && itx < MAX_SKILL_ITEM_REQUIRE) { + const char *type = config_setting_name(it); + + if( type[0] == 'I' && type[1] == 'D' && itemdb->exists(atoi(type+2)) ) + sk->itemid[itx] = atoi(type+2); + else if(!script->get_constant(type, &sk->itemid[itx])) { + ShowWarning("skill_read_skilldb: Invalid required Item '%s' given for skill Id %d in '%s', skipping...\n",type, sk->nameid, DBPATH"skill_db.conf"); + continue; + } + + if (config_setting_is_group(it)) { + // TODO: Per-level item requirements are not implemented yet! + // We just take the first level for the time being (old txt behavior) + sk->amount[itx] = libconfig->setting_get_int_elem(it, 0); + } else { + sk->amount[itx] = libconfig->setting_get_int(it); + } + } + } +} + +/** + * Validates the "Unit > Target" flag + * when parsing skill_db.conf + * @param conf struct, pointer to the skill configuration + * @param sk struct, pointer to s_skill_db + * @return void + */ +void skill_validate_unit_target(struct config_setting_t *conf, struct s_skill_db *sk) +{ + const char *type = NULL; + + if(libconfig->setting_lookup_string(conf, "Target", &type)) { + + if(!strcmpi(type,"NotEnemy")) sk->unit_target = BCT_NOENEMY; + else if(!strcmpi(type,"NotParty")) sk->unit_target = BCT_NOPARTY; + else if (!strcmpi(type,"NotGuild")) sk->unit_target = BCT_NOGUILD; + else if(!strcmpi(type,"Friend")) sk->unit_target = BCT_NOENEMY; + else if(!strcmpi(type,"Party")) sk->unit_target = BCT_PARTY; + else if(!strcmpi(type,"Ally")) sk->unit_target = BCT_PARTY|BCT_GUILD; + else if(!strcmpi(type,"Guild")) sk->unit_target = BCT_GUILD; + else if(!strcmpi(type,"All")) sk->unit_target = BCT_ALL; + else if(!strcmpi(type,"Enemy")) sk->unit_target = BCT_ENEMY; + else if(!strcmpi(type,"Self")) sk->unit_target = BCT_SELF; + else if(!strcmpi(type,"SameGuild")) sk->unit_target = BCT_GUILD|BCT_SAMEGUILD; + } + + if (sk->unit_flag & UF_DEFNOTENEMY && battle_config.defnotenemy) + sk->unit_target = BCT_NOENEMY; + + //By default, target just characters. + sk->unit_target |= BL_CHAR; + + if (sk->unit_flag & UF_NOPC) + sk->unit_target &= ~BL_PC; + if (sk->unit_flag & UF_NOMOB) + sk->unit_target &= ~BL_MOB; + if (sk->unit_flag & UF_SKILL) + sk->unit_target |= BL_SKILL; +} + +/** + * Validates the "Unit > Flag" setting + * when parsing skill_db.conf + * @param type const char, name of the flag being parsed. + * @param on boolean, switch for flag setting + * @param sk struct, pointer to s_skill_db. + * @return (void) + */ +int skill_validate_unit_flag_sub(const char *type, bool on, struct s_skill_db *sk) +{ + if (strcmpi(type, "UF_DEFNOTENEMY") == 0) { + if (on) { + sk->unit_flag |= UF_DEFNOTENEMY; + } else { + sk->unit_flag &= ~UF_DEFNOTENEMY; + } + } else if (strcmpi(type, "UF_NOREITERATION") == 0) { + if (on) { + sk->unit_flag |= UF_NOREITERATION; + } else { + sk->unit_flag &= ~UF_NOREITERATION; + } + } else if (strcmpi(type, "UF_NOFOOTSET") == 0) { + if (on) { + sk->unit_flag |= UF_NOFOOTSET; + } else { + sk->unit_flag &= ~UF_NOFOOTSET; + } + } else if (strcmpi(type, "UF_NOOVERLAP") == 0) { + if (on) { + sk->unit_flag |= UF_NOOVERLAP; + } else { + sk->unit_flag &= ~UF_NOOVERLAP; + } + } else if (strcmpi(type, "UF_PATHCHECK") == 0) { + if (on) { + sk->unit_flag |= UF_PATHCHECK; + } else { + sk->unit_flag &= ~UF_PATHCHECK; + } + } else if (strcmpi(type, "UF_NOPC") == 0) { + if (on) { + sk->unit_flag |= UF_NOPC; + } else { + sk->unit_flag &= ~UF_NOPC; + } + } else if (strcmpi(type, "UF_NOMOB") == 0) { + if (on) { + sk->unit_flag |= UF_NOMOB; + } else { + sk->unit_flag &= ~UF_NOMOB; + } + } else if (strcmpi(type, "UF_SKILL") == 0) { + if (on) { + sk->unit_flag |= UF_SKILL; + } else { + sk->unit_flag &= ~UF_SKILL; + } + } else if (strcmpi(type, "UF_DANCE") == 0) { + if (on) { + sk->unit_flag |= UF_DANCE; + } else { + sk->unit_flag &= ~UF_DANCE; + } + } else if (strcmpi(type, "UF_ENSEMBLE") == 0) { + if (on) { + sk->unit_flag |= UF_ENSEMBLE; + } else { + sk->unit_flag &= ~UF_ENSEMBLE; + } + } else if (strcmpi(type, "UF_SONG") == 0) { + if (on) { + sk->unit_flag |= UF_SONG; + } else { + sk->unit_flag &= ~UF_SONG; + } + } else if (strcmpi(type, "UF_DUALMODE") == 0) { + if (on) { + sk->unit_flag |= UF_DUALMODE; + } else { + sk->unit_flag &= ~UF_DUALMODE; + } + } else if (strcmpi(type, "UF_RANGEDSINGLEUNIT") == 0) { + if (on) { + sk->unit_flag |= UF_RANGEDSINGLEUNIT; + } else { + sk->unit_flag &= ~UF_RANGEDSINGLEUNIT; + } + } else { + return 1; // Invalid Type + } + + return 0; +} + +/** + * Validate "Unit > Flag" setting + * when parsing skill_db.conf + * @param conf struct, pointer to the skill configuration + * @param sk struct, struct, pointer to s_skill_db + * @return (void) + */ +void skill_validate_unit_flag(struct config_setting_t *conf, struct s_skill_db *sk) +{ + struct config_setting_t *t = NULL; + + if ((t=libconfig->setting_get_member(conf, "Flag")) && config_setting_is_group(t)) { + int j=0; + struct config_setting_t *tt = NULL; + while ((tt = libconfig->setting_get_elem(t, j++))) { + const char *name = config_setting_name(tt); + + if (skill_validate_unit_flag_sub(name, libconfig->setting_get_bool_real(tt), sk)) + skilldb_invalid_error(name, config_setting_name(t), sk->nameid); + } + } +} +/** + * Validate additional field settings via plugins + * when parsing skill_db.conf + * @param conf struct, pointer to the skill configuration + * @param sk struct, struct, pointer to s_skill_db + * @return (void) + */ +void skill_validate_additional_fields(struct config_setting_t *conf, struct s_skill_db *sk) +{ + // Does nothing like a boss. *cough* plugins *cough* +} + +/** + * Validates a skill entry and adds it to the database. [ Smokexyz/Hercules ] + * @param sk contains skill data to be checked. + * @param *source filepath constant. + * @return boolean true on success. + */ +bool skill_validate_skilldb(struct s_skill_db *sk, const char *source) +{ + int idx = skill->get_index(sk->nameid); + + if (idx == 0) { + ShowWarning("skill_validate_skilldb: Invalid skill Id %d provided in '%s'! ... skipping\n", sk->nameid, source); + ShowInfo("It is possible that the skill Id is 0 or unavailable (interferes with guild/homun/mercenary skill mapping).\n"); + return false; + } else if (sk->max <= 0) { + ShowError("skill_validate_skilldb: Invalid Max Level %d specified for skill Id %d in '%s', skipping...\n", sk->max, sk->nameid, source); + return false; + } + + /* Direct assignment of temporary skill storage to skill db */ + skill->dbs->db[idx] = *sk; + /* Put skill name in name2id DB */ + strdb_iput(skill->name2id_db, skill->dbs->db[idx].name, skill->dbs->db[idx].nameid); + /* Set Name to Id script constants */ + script->set_constant2(skill->dbs->db[idx].name, (int)skill->dbs->db[idx].nameid, false, false); + + return true; +} + +/** + * Reads skill_db.conf from relative filepath and processes [ Smokexyz/Hercules ] + * entries into the skill database. + * @param filename contains the file path and name. + * @return boolean true on success + */ +bool skill_read_skilldb(const char *filename) +{ + struct config_t skilldb; + struct config_setting_t *sk, *conf; + char filepath[256]; + int count=0, index=0; + bool duplicate[MAX_SKILL] = {0}; + + nullpo_retr(false, filename); + + sprintf(filepath,"db/%s",filename); + + if (!libconfig->load_file(&skilldb, filepath)) { + return false; // Libconfig error report. + } + + // Possible Syntax error. + if ((sk=libconfig->setting_get_member(skilldb.root, "skill_db")) == NULL) { + ShowError("skill_read_skilldb: Skill DB could not be loaded, please check '%s'.\n", filepath); + libconfig->destroy(&skilldb); + return false; + } + + while ((conf = libconfig->setting_get_elem(sk,index++))) { + int idx=0, skill_id=0, temp=0; + struct config_setting_t *t = NULL, *tt = NULL; + struct s_skill_db tmp_db = { 0 }; + + /* Skill ID */ + if (!libconfig->setting_lookup_int(conf, "Id", &skill_id)) { + ShowError("skill_read_skilldb: Skill Id not specified for entry %d in '%s', skipping...\n", index, filepath ); + continue; + } + + tmp_db.nameid = skill_id; + + if((idx = skill->get_index(skill_id)) == 0) { + ShowError("skill_read_skilldb: Skill Id %d is out of range, or within a reserved range (for guild, homunculus, mercenary or elemental skills). skipping...\n", idx); + continue; + } + + if (duplicate[idx]) { + ShowWarning("skill_read_skilldb: Duplicate Skill Id %d in entry %d in '%s', skipping...\n", skill_id, index, filepath); + continue; + } + + /* Skill Name Constant */ + if (!libconfig->setting_lookup_mutable_string(conf, "Name", tmp_db.name, sizeof(tmp_db.name))) { + ShowError("skill_read_skilldb: Name not specified for skill Id %d in '%s', skipping...\n", skill_id, filepath); + continue; + } + + /* Skill Description */ + libconfig->setting_lookup_mutable_string(conf, "Description", tmp_db.desc, sizeof(tmp_db.desc)); + + /* Max Level */ + if (!libconfig->setting_lookup_int(conf, "MaxLevel", &temp)) { + ShowError("skill_read_skilldb: MaxLevel not specified for skill Id %d in '%s', skipping...\n", skill_id, filepath); + continue; + } else { + tmp_db.max = temp; + } + + /* Range */ + if ((t=libconfig->setting_get_member(conf, "Range"))) + skill->config_set_level(t, tmp_db.range); + + /* Hit Type */ + skill->validate_hittype(conf, &tmp_db); + + /* Skill Type */ + skill->validate_skilltype(conf, &tmp_db); + + /* Skill Info */ + skill->validate_skillinfo(conf, &tmp_db); + + /* Skill Attack Type */ + skill->validate_attacktype(conf, &tmp_db); + + /* Skill Element */ + skill->validate_element(conf, &tmp_db); + + /* Damage Type */ + skill->validate_damagetype(conf, &tmp_db); + + /* Splash Range */ + if ((t = libconfig->setting_get_member(conf, "SplashRange"))) + skill->config_set_level(t, tmp_db.splash); + + /* Number of Hits */ + if ((t = libconfig->setting_get_member(conf, "NumberOfHits")) && config_setting_is_group(t)) + skill->config_set_level(t, tmp_db.num); + else if ((libconfig->setting_lookup_int(conf, "NumberOfHits", &temp))) + skill->level_set_value(tmp_db.num, temp); + else + skill->level_set_value(tmp_db.num, 1); // Default 1 + + /* Interrupt Cast */ + if (libconfig->setting_lookup_bool(conf, "InterruptCast", &tmp_db.castcancel) == CONFIG_FALSE) + tmp_db.castcancel = 0; + + /* Cast Defense Rate */ + libconfig->setting_lookup_int(conf, "CastDefRate", &tmp_db.cast_def_rate); + + /* Skill Instances */ + if ((t = libconfig->setting_get_member(conf, "SkillInstances"))) + skill->config_set_level(t, tmp_db.maxcount); + + /* Knock-Back Tiles */ + if ((t = libconfig->setting_get_member(conf, "KnockBackTiles"))) + skill->config_set_level(t, tmp_db.blewcount); + /** + * Skill Cast / Delay data handling + */ + /* Cast Time */ + if ((t=libconfig->setting_get_member(conf, "CastTime"))) + skill->config_set_level(t, tmp_db.cast); + + /* After Cast Act Delay */ + if ((t=libconfig->setting_get_member(conf, "AfterCastActDelay"))) + skill->config_set_level(t, tmp_db.delay); + + /* After Cast Walk Delay */ + if ((t=libconfig->setting_get_member(conf, "AfterCastWalkDelay"))) + skill->config_set_level(t, tmp_db.walkdelay); + + /* Skill Data/Duration */ + if ((t=libconfig->setting_get_member(conf, "SkillData1"))) + skill->config_set_level(t, tmp_db.upkeep_time); + + /* Skill Data/Duration 2 */ + if ((t=libconfig->setting_get_member(conf, "SkillData2"))) + skill->config_set_level(t, tmp_db.upkeep_time2); + + /* Skill Cool Down */ + if ((t=libconfig->setting_get_member(conf, "CoolDown"))) + skill->config_set_level(t, tmp_db.cooldown); + +#ifdef RENEWAL_CAST + /* Fixed Casting Time */ + if ((t=libconfig->setting_get_member(conf, "FixedCastTime"))) + skill->config_set_level(t, tmp_db.fixed_cast); +#endif + /* Cast Time Options */ + skill->validate_castnodex(conf, &tmp_db, false); + skill->validate_castnodex(conf, &tmp_db, true); + + /** + * Skill Requirements data handling + */ + if ((t=libconfig->setting_get_member(conf, "Requirements")) && config_setting_is_group(t)) { + + /* HP Costs */ + if ((tt = libconfig->setting_get_member(t, "HPCost"))) + skill->config_set_level(tt, tmp_db.hp); + + /* Max HP Trigger */ + if ((tt = libconfig->setting_get_member(t, "MaxHPTrigger"))) + skill->config_set_level(tt, tmp_db.mhp); + + /* SP Cost */ + if ((tt = libconfig->setting_get_member(t, "SPCost"))) + skill->config_set_level(tt, tmp_db.sp); + + /* HP Rate */ + if ((tt = libconfig->setting_get_member(t, "HPRateCost"))) + skill->config_set_level(tt, tmp_db.hp_rate); + + /* SP Rate */ + if ((tt = libconfig->setting_get_member(t, "SPRateCost"))) + skill->config_set_level(tt, tmp_db.sp_rate); + + /* Zeny Cost */ + if ((tt = libconfig->setting_get_member(t, "ZenyCost"))) + skill->config_set_level(tt, tmp_db.zeny); + + /* Spirit Sphere Cost */ + if ((tt = libconfig->setting_get_member(t, "SpiritSphereCost"))) + skill->config_set_level(tt, tmp_db.spiritball); + + /* Weapon Types */ + skill->validate_weapontype(t, &tmp_db); + + /* Ammunition Types */ + skill->validate_ammotype(t, &tmp_db); + + /* Ammunition Amount */ + if ((tt = libconfig->setting_get_member(t, "AmmoAmount"))) + skill->config_set_level(tt, tmp_db.ammo_qty); + + /* State */ + skill->validate_state(t, &tmp_db); + + /* Spirit Sphere Cost */ + if ((tt = libconfig->setting_get_member(t, "SpiritSphereCost"))) + skill->config_set_level(tt, tmp_db.spiritball); + + /* Item Requirements and Amounts */ + skill->validate_item_requirements(t, &tmp_db); + } + + /** + * Skill Unit data handling + */ + if ((t=libconfig->setting_get_member(conf, "Unit")) && config_setting_is_group(t)) { + + /* Unit IDs [1,2] */ + if ((tt=libconfig->setting_get_member(t, "Id")) && config_setting_is_array(tt)) { + tmp_db.unit_id[0] = libconfig->setting_get_int_elem(tt, 0); + tmp_db.unit_id[1] = libconfig->setting_get_int_elem(tt, 1); + } else { + libconfig->setting_lookup_int(t, "Id", &tmp_db.unit_id[0]); + } + + /* Layout */ + if((tt=libconfig->setting_get_member(t, "Layout"))) + skill->config_set_level(tt, tmp_db.unit_layout_type); + + /* Range */ + if((tt=libconfig->setting_get_member(t, "Range"))) + skill->config_set_level(tt, tmp_db.unit_range); + + /* Interval */ + if(libconfig->setting_lookup_int(t, "Interval", &temp)) + tmp_db.unit_interval = temp; + + /* Flag */ + skill->validate_unit_flag(t, &tmp_db); + + /* Target */ + skill->validate_unit_target(t, &tmp_db); + } + + /* Additional Fields for Plugins */ + skill->validate_additional_fields(conf, &tmp_db); + + // Validate the skill entry, add it to the duplicate array and increment count on success. + if ((duplicate[idx] = skill->validate_skilldb(&tmp_db, filepath))) + count++; + } + + libconfig->destroy(&skilldb); + + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filepath); + + return true; +} + +#undef skilldb_duplicate_warning +#undef skilldb_invalid_error + /*=============================== * DB reading. - * skill_db.txt - * skill_require_db.txt - * skill_cast_db.txt - * skill_castnodex_db.txt - * skill_nocast_db.txt - * skill_unit_db.txt * produce_db.txt * create_arrow_db.txt * abra_db.txt @@ -19206,26 +20289,19 @@ void skill_readdb(bool minimal) { safestrncpy(skill->dbs->db[0].name, "UNKNOWN_SKILL", sizeof(skill->dbs->db[0].name)); safestrncpy(skill->dbs->db[0].desc, "Unknown Skill", sizeof(skill->dbs->db[0].desc)); + itemdb->name_constants(); // refresh ItemDB constants before loading of skills + #ifdef ENABLE_CASE_CHECK - script->parser_current_file = DBPATH"skill_db.txt"; + script->parser_current_file = DBPATH"skill_db.conf"; #endif // ENABLE_CASE_CHECK - sv->readdb(map->db_path, DBPATH"skill_db.txt", ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); + skill->read_skilldb(DBPATH"skill_db.conf"); #ifdef ENABLE_CASE_CHECK script->parser_current_file = NULL; #endif // ENABLE_CASE_CHECK if (minimal) return; - - sv->readdb(map->db_path, DBPATH"skill_require_db.txt", ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); -#ifdef RENEWAL_CAST - sv->readdb(map->db_path, "re/skill_cast_db.txt", ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); -#else - sv->readdb(map->db_path, "pre-re/skill_cast_db.txt", ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb); -#endif - sv->readdb(map->db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb); - sv->readdb(map->db_path, DBPATH"skill_unit_db.txt", ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb); - + skill->init_unit_layout(); sv->readdb(map->db_path, "produce_db.txt", ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb); sv->readdb(map->db_path, "create_arrow_db.txt", ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb); @@ -19405,6 +20481,7 @@ void skill_defaults(void) { skill->is_combo = skill_is_combo; skill->name2id = skill_name2id; skill->isammotype = skill_isammotype; + skill->castend_type = skill_castend_type; skill->castend_id = skill_castend_id; skill->castend_pos = skill_castend_pos; skill->castend_map = skill_castend_map; @@ -19450,7 +20527,9 @@ void skill_defaults(void) { skill->can_cloak = skill_can_cloak; skill->enchant_elemental_end = skill_enchant_elemental_end; skill->not_ok = skillnotok; + skill->not_ok_unknown = skill_notok_unknown; skill->not_ok_hom = skillnotok_hom; + skill->not_ok_hom_unknown = skillnotok_hom_unknown; skill->not_ok_mercenary = skillnotok_mercenary; skill->chastle_mob_changetarget = skill_chastle_mob_changetarget; skill->can_produce_mix = skill_can_produce_mix; @@ -19498,6 +20577,7 @@ void skill_defaults(void) { skill->sit_out = skill_sit_out; skill->unitsetmapcell = skill_unitsetmapcell; skill->unit_onplace_timer = skill_unit_onplace_timer; + skill->unit_onplace_timer_unknown = skill_unit_onplace_timer_unknown; skill->unit_effect = skill_unit_effect; skill->unit_timer_sub_onplace = skill_unit_timer_sub_onplace; skill->unit_move_sub = skill_unit_move_sub; @@ -19508,11 +20588,27 @@ void skill_defaults(void) { skill->unit_timer = skill_unit_timer; skill->unit_timer_sub = skill_unit_timer_sub; skill->init_unit_layout = skill_init_unit_layout; - skill->parse_row_skilldb = skill_parse_row_skilldb; - skill->parse_row_requiredb = skill_parse_row_requiredb; - skill->parse_row_castdb = skill_parse_row_castdb; - skill->parse_row_castnodexdb = skill_parse_row_castnodexdb; - skill->parse_row_unitdb = skill_parse_row_unitdb; + skill->init_unit_layout_unknown = skill_init_unit_layout_unknown; + /* Skill DB Libconfig */ + skill->validate_hittype = skill_validate_hittype; + skill->validate_attacktype = skill_validate_attacktype; + skill->validate_element = skill_validate_element; + skill->validate_skilltype = skill_validate_skilltype; + skill->validate_skillinfo = skill_validate_skillinfo; + skill->validate_damagetype = skill_validate_damagetype; + skill->validate_castnodex = skill_validate_castnodex; + skill->validate_weapontype = skill_validate_weapontype; + skill->validate_ammotype = skill_validate_ammotype; + skill->validate_state = skill_validate_state; + skill->validate_item_requirements = skill_validate_item_requirements; + skill->validate_unit_target = skill_validate_unit_target; + skill->validate_unit_flag = skill_validate_unit_flag; + skill->validate_additional_fields = skill_validate_additional_fields; + skill->validate_skilldb = skill_validate_skilldb; + skill->read_skilldb = skill_read_skilldb; + skill->config_set_level = skill_config_set_level; + skill->level_set_value = skill_level_set_value; + /* */ skill->parse_row_producedb = skill_parse_row_producedb; skill->parse_row_createarrowdb = skill_parse_row_createarrowdb; skill->parse_row_abradb = skill_parse_row_abradb; @@ -19569,4 +20665,7 @@ void skill_defaults(void) { skill->get_requirement_off_unknown = skill_get_requirement_off_unknown; skill->get_requirement_item_unknown = skill_get_requirement_item_unknown; skill->get_requirement_unknown = skill_get_requirement_unknown; + skill->splash_target = skill_splash_target; + skill->check_npc_chaospanic = skill_check_npc_chaospanic; + skill->count_wos = skill_count_wos; } diff --git a/src/map/skill.h b/src/map/skill.h index 35fddafa4..c37f9ec41 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -58,7 +58,7 @@ struct status_change_entry; #define MAX_SKILLUNITGROUP 25 #define MAX_SKILL_ITEM_REQUIRE 10 #define MAX_SKILLUNITGROUPTICKSET 25 -#define MAX_SKILL_NAME_LENGTH 30 +#define MAX_SKILL_NAME_LENGTH 32 // (Epoque:) To-do: replace this macro with some sort of skill tree check (rather than hard-coded skill names) #define skill_ischangesex(id) ( \ @@ -91,6 +91,7 @@ enum e_skill_inf { enum e_skill_nk { NK_NO_DAMAGE = 0x01, NK_SPLASH = 0x02|0x04, // 0x4 = splash & split + NK_SPLASH_ONLY = 0x02, NK_SPLASHSPLIT = 0x04, NK_NO_CARDFIX_ATK = 0x08, NK_NO_ELEFIX = 0x10, @@ -102,21 +103,23 @@ enum e_skill_nk { //A skill with 3 would be no damage + splash: area of effect. //Constants to identify a skill's inf2 value. enum e_skill_inf2 { - INF2_QUEST_SKILL = 0x0001, - INF2_NPC_SKILL = 0x0002, // NPC skills are those that players can't have in their skill tree. - INF2_WEDDING_SKILL = 0x0004, - INF2_SPIRIT_SKILL = 0x0008, - INF2_GUILD_SKILL = 0x0010, - INF2_SONG_DANCE = 0x0020, - INF2_ENSEMBLE_SKILL = 0x0040, - INF2_TRAP = 0x0080, - INF2_TARGET_SELF = 0x0100, // Refers to ground placed skills that will target the caster as well (like Grandcross) - INF2_NO_TARGET_SELF = 0x0200, - INF2_PARTY_ONLY = 0x0400, - INF2_GUILD_ONLY = 0x0800, - INF2_NO_ENEMY = 0x1000, - INF2_NOLP = 0x2000, // Spells that can ignore Land Protector - INF2_CHORUS_SKILL = 0x4000, // Chorus skill + INF2_QUEST_SKILL = 0x00001, + INF2_NPC_SKILL = 0x00002, // NPC skills are those that players can't have in their skill tree. + INF2_WEDDING_SKILL = 0x00004, + INF2_SPIRIT_SKILL = 0x00008, + INF2_GUILD_SKILL = 0x00010, + INF2_SONG_DANCE = 0x00020, + INF2_ENSEMBLE_SKILL = 0x00040, + INF2_TRAP = 0x00080, + INF2_TARGET_SELF = 0x00100, // Refers to ground placed skills that will target the caster as well (like Grandcross) + INF2_NO_TARGET_SELF = 0x00200, + INF2_PARTY_ONLY = 0x00400, + INF2_GUILD_ONLY = 0x00800, + INF2_NO_ENEMY = 0x01000, + INF2_NOLP = 0x02000, // Spells that can ignore Land Protector + INF2_CHORUS_SKILL = 0x04000, // Chorus skill + INF2_FREE_CAST_NORMAL = 0x08000, + INF2_FREE_CAST_REDUCED = 0x10000, }; @@ -1975,12 +1978,15 @@ struct skill_interface { bool (*can_cloak) (struct map_session_data *sd); int (*enchant_elemental_end) (struct block_list *bl, int type); int (*not_ok) (uint16 skill_id, struct map_session_data *sd); + int (*not_ok_unknown) (uint16 skill_id, struct map_session_data *sd); int (*not_ok_hom) (uint16 skill_id, struct homun_data *hd); + int (*not_ok_hom_unknown) (uint16 skill_id, struct homun_data *hd); int (*not_ok_mercenary) (uint16 skill_id, struct mercenary_data *md); int (*chastle_mob_changetarget) (struct block_list *bl,va_list ap); int (*can_produce_mix) ( struct map_session_data *sd, int nameid, int trigger, int qty); int (*produce_mix) ( struct map_session_data *sd, uint16 skill_id, int nameid, int slot1, int slot2, int slot3, int qty ); int (*arrow_create) ( struct map_session_data *sd,int nameid); + void (*castend_type) (int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); int (*castend_nodamage_id) (struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); int (*castend_damage_id) (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick,int flag); int (*castend_pos2) (struct block_list *src, int x, int y, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); @@ -2023,6 +2029,7 @@ struct skill_interface { int (*sit_out) (struct block_list *bl, va_list ap); void (*unitsetmapcell) (struct skill_unit *src, uint16 skill_id, uint16 skill_lv, cell_t cell, bool flag); int (*unit_onplace_timer) (struct skill_unit *src, struct block_list *bl, int64 tick); + void (*unit_onplace_timer_unknown) (struct skill_unit *src, struct block_list *bl, int64 *tick); int (*unit_effect) (struct block_list* bl, va_list ap); int (*unit_timer_sub_onplace) (struct block_list* bl, va_list ap); int (*unit_move_sub) (struct block_list* bl, va_list ap); @@ -2033,11 +2040,25 @@ struct skill_interface { int (*unit_timer) (int tid, int64 tick, int id, intptr_t data); int (*unit_timer_sub) (union DBKey key, struct DBData *data, va_list ap); void (*init_unit_layout) (void); - bool (*parse_row_skilldb) (char* split[], int columns, int current); - bool (*parse_row_requiredb) (char* split[], int columns, int current); - bool (*parse_row_castdb) (char* split[], int columns, int current); - bool (*parse_row_castnodexdb) (char* split[], int columns, int current); - bool (*parse_row_unitdb) (char* split[], int columns, int current); + void (*init_unit_layout_unknown) (int skill_idx); + void (*validate_hittype) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_skilltype) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_attacktype) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_element) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_skillinfo) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_damagetype) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_castnodex) (struct config_setting_t *conf, struct s_skill_db *sk, bool delay); + void (*validate_weapontype) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_ammotype) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_state) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_item_requirements) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_unit_target) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_unit_flag) (struct config_setting_t *conf, struct s_skill_db *sk); + void (*validate_additional_fields) (struct config_setting_t *conf, struct s_skill_db *sk); + bool (*validate_skilldb) (struct s_skill_db *skt, const char *source); + bool (*read_skilldb) (const char *filename); + void (*config_set_level) (struct config_setting_t *conf, int *arr); + void (*level_set_value) (int *arr, int value); bool (*parse_row_producedb) (char* split[], int columns, int current); bool (*parse_row_createarrowdb) (char* split[], int columns, int current); bool (*parse_row_abradb) (char* split[], int columns, int current); @@ -2100,6 +2121,9 @@ struct skill_interface { bool (*get_requirement_off_unknown) (struct status_change *sc, uint16 *skill_id); bool (*get_requirement_item_unknown) (struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, uint16 *idx, int *i); void (*get_requirement_unknown) (struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, struct skill_condition *req); + int (*splash_target) (struct block_list* bl); + int (*check_npc_chaospanic) (struct block_list *bl, va_list args); + int (*count_wos) (struct block_list *bl, va_list ap); }; #ifdef HERCULES_CORE diff --git a/src/map/status.c b/src/map/status.c index 34bfd06b5..9a76060c5 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -125,7 +125,8 @@ int status_type2relevant_bl_types(int type) return status->dbs->RelevantBLTypes[type]; } -static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) { +void status_set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) +{ uint16 idx; if( (idx = skill->get_index(skill_id)) == 0 ) { ShowError("set_sc: Unsupported skill id %d\n", skill_id); @@ -147,9 +148,9 @@ static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) { } void initChangeTables(void) { -#define add_sc(skill,sc) set_sc((skill),(sc),SI_BLANK,SCB_NONE) +#define add_sc(skill,sc) status->set_sc((skill),(sc),SI_BLANK,SCB_NONE) // indicates that the status displays a visual effect for the affected unit, and should be sent to the client for all supported units -#define set_sc_with_vfx(skill, sc, icon, flag) do { set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->dbs->RelevantBLTypes[(icon)] |= BL_SCEFFECT; } while(0) +#define set_sc_with_vfx(skill, sc, icon, flag) do { status->set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->dbs->RelevantBLTypes[(icon)] |= BL_SCEFFECT; } while(0) int i; @@ -167,83 +168,83 @@ void initChangeTables(void) { memset(status->dbs->DisplayType, 0, sizeof(status->dbs->DisplayType)); //First we define the skill for common ailments. These are used in skill_additional_effect through sc cards. [Skotlex] - set_sc( NPC_PETRIFYATTACK , SC_STONE , SI_BLANK , SCB_DEF_ELE|SCB_DEF|SCB_MDEF ); - set_sc( NPC_WIDEFREEZE , SC_FREEZE , SI_BLANK , SCB_DEF_ELE|SCB_DEF|SCB_MDEF ); - set_sc( NPC_STUNATTACK , SC_STUN , SI_BLANK , SCB_NONE ); - set_sc( NPC_SLEEPATTACK , SC_SLEEP , SI_BLANK , SCB_NONE ); - set_sc( NPC_POISON , SC_POISON , SI_BLANK , SCB_DEF2|SCB_REGEN ); - set_sc( NPC_CURSEATTACK , SC_CURSE , SI_BLANK , SCB_LUK|SCB_BATK|SCB_WATK|SCB_SPEED ); - set_sc( NPC_SILENCEATTACK , SC_SILENCE , SI_BLANK , SCB_NONE ); - set_sc( NPC_WIDECONFUSE , SC_CONFUSION , SI_BLANK , SCB_NONE ); - set_sc( NPC_BLINDATTACK , SC_BLIND , SI_BLANK , SCB_HIT|SCB_FLEE ); - set_sc( NPC_BLEEDING , SC_BLOODING , SI_BLOODING , SCB_REGEN ); - set_sc( NPC_POISON , SC_DPOISON , SI_BLANK , SCB_DEF2|SCB_REGEN ); + status->set_sc( NPC_PETRIFYATTACK , SC_STONE , SI_BLANK , SCB_DEF_ELE|SCB_DEF|SCB_MDEF ); + status->set_sc( NPC_WIDEFREEZE , SC_FREEZE , SI_BLANK , SCB_DEF_ELE|SCB_DEF|SCB_MDEF ); + status->set_sc( NPC_STUNATTACK , SC_STUN , SI_BLANK , SCB_NONE ); + status->set_sc( NPC_SLEEPATTACK , SC_SLEEP , SI_BLANK , SCB_NONE ); + status->set_sc( NPC_POISON , SC_POISON , SI_BLANK , SCB_DEF2|SCB_REGEN ); + status->set_sc( NPC_CURSEATTACK , SC_CURSE , SI_BLANK , SCB_LUK|SCB_BATK|SCB_WATK|SCB_SPEED ); + status->set_sc( NPC_SILENCEATTACK , SC_SILENCE , SI_BLANK , SCB_NONE ); + status->set_sc( NPC_WIDECONFUSE , SC_CONFUSION , SI_BLANK , SCB_NONE ); + status->set_sc( NPC_BLINDATTACK , SC_BLIND , SI_BLANK , SCB_HIT|SCB_FLEE ); + status->set_sc( NPC_BLEEDING , SC_BLOODING , SI_BLOODING , SCB_REGEN ); + status->set_sc( NPC_POISON , SC_DPOISON , SI_BLANK , SCB_DEF2|SCB_REGEN ); //The main status definitions add_sc( SM_BASH , SC_STUN ); - set_sc( SM_PROVOKE , SC_PROVOKE , SI_PROVOKE , SCB_DEF|SCB_DEF2|SCB_BATK|SCB_WATK ); + status->set_sc( SM_PROVOKE , SC_PROVOKE , SI_PROVOKE , SCB_DEF|SCB_DEF2|SCB_BATK|SCB_WATK ); add_sc( SM_MAGNUM , SC_SUB_WEAPONPROPERTY ); - set_sc( SM_ENDURE , SC_ENDURE , SI_ENDURE , SCB_MDEF|SCB_DSPD ); + status->set_sc( SM_ENDURE , SC_ENDURE , SI_ENDURE , SCB_MDEF|SCB_DSPD ); add_sc( MG_SIGHT , SC_SIGHT ); add_sc( MG_SAFETYWALL , SC_SAFETYWALL ); add_sc( MG_FROSTDIVER , SC_FREEZE ); add_sc( MG_STONECURSE , SC_STONE ); add_sc( AL_RUWACH , SC_RUWACH ); add_sc( AL_PNEUMA , SC_PNEUMA ); - set_sc( AL_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED ); - set_sc( AL_DECAGI , SC_DEC_AGI , SI_DEC_AGI , SCB_AGI|SCB_SPEED ); - set_sc( AL_CRUCIS , SC_CRUCIS , SI_CRUCIS , SCB_DEF ); - set_sc( AL_ANGELUS , SC_ANGELUS , SI_ANGELUS , SCB_DEF2 ); - set_sc( AL_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX ); - set_sc( AC_CONCENTRATION , SC_CONCENTRATION , SI_CONCENTRATION , SCB_AGI|SCB_DEX ); - set_sc( TF_HIDING , SC_HIDING , SI_HIDING , SCB_SPEED ); + status->set_sc( AL_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED ); + status->set_sc( AL_DECAGI , SC_DEC_AGI , SI_DEC_AGI , SCB_AGI|SCB_SPEED ); + status->set_sc( AL_CRUCIS , SC_CRUCIS , SI_CRUCIS , SCB_DEF ); + status->set_sc( AL_ANGELUS , SC_ANGELUS , SI_ANGELUS , SCB_DEF2 ); + status->set_sc( AL_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX ); + status->set_sc( AC_CONCENTRATION , SC_CONCENTRATION , SI_CONCENTRATION , SCB_AGI|SCB_DEX ); + status->set_sc( TF_HIDING , SC_HIDING , SI_HIDING , SCB_SPEED ); add_sc( TF_POISON , SC_POISON ); - set_sc( KN_TWOHANDQUICKEN , SC_TWOHANDQUICKEN , SI_TWOHANDQUICKEN , SCB_ASPD ); + status->set_sc( KN_TWOHANDQUICKEN , SC_TWOHANDQUICKEN , SI_TWOHANDQUICKEN , SCB_ASPD ); add_sc( KN_AUTOCOUNTER , SC_AUTOCOUNTER ); - set_sc( PR_IMPOSITIO , SC_IMPOSITIO , SI_IMPOSITIO , + status->set_sc( PR_IMPOSITIO , SC_IMPOSITIO , SI_IMPOSITIO , #ifdef RENEWAL SCB_NONE ); #else SCB_WATK ); #endif - set_sc( PR_SUFFRAGIUM , SC_SUFFRAGIUM , SI_SUFFRAGIUM , SCB_NONE ); - set_sc( PR_ASPERSIO , SC_ASPERSIO , SI_ASPERSIO , SCB_ATK_ELE ); - set_sc( PR_BENEDICTIO , SC_BENEDICTIO , SI_BENEDICTIO , SCB_DEF_ELE ); - set_sc( PR_SLOWPOISON , SC_SLOWPOISON , SI_SLOWPOISON , SCB_REGEN ); - set_sc( PR_KYRIE , SC_KYRIE , SI_KYRIE , SCB_NONE ); - set_sc( PR_MAGNIFICAT , SC_MAGNIFICAT , SI_MAGNIFICAT , SCB_REGEN ); - set_sc( PR_GLORIA , SC_GLORIA , SI_GLORIA , SCB_LUK ); + status->set_sc( PR_SUFFRAGIUM , SC_SUFFRAGIUM , SI_SUFFRAGIUM , SCB_NONE ); + status->set_sc( PR_ASPERSIO , SC_ASPERSIO , SI_ASPERSIO , SCB_ATK_ELE ); + status->set_sc( PR_BENEDICTIO , SC_BENEDICTIO , SI_BENEDICTIO , SCB_DEF_ELE ); + status->set_sc( PR_SLOWPOISON , SC_SLOWPOISON , SI_SLOWPOISON , SCB_REGEN ); + status->set_sc( PR_KYRIE , SC_KYRIE , SI_KYRIE , SCB_NONE ); + status->set_sc( PR_MAGNIFICAT , SC_MAGNIFICAT , SI_MAGNIFICAT , SCB_REGEN ); + status->set_sc( PR_GLORIA , SC_GLORIA , SI_GLORIA , SCB_LUK ); add_sc( PR_LEXDIVINA , SC_SILENCE ); - set_sc( PR_LEXAETERNA , SC_LEXAETERNA , SI_LEXAETERNA , SCB_NONE ); + status->set_sc( PR_LEXAETERNA , SC_LEXAETERNA , SI_LEXAETERNA , SCB_NONE ); add_sc( WZ_METEOR , SC_STUN ); add_sc( WZ_VERMILION , SC_BLIND ); add_sc( WZ_FROSTNOVA , SC_FREEZE ); add_sc( WZ_STORMGUST , SC_FREEZE ); - set_sc( WZ_QUAGMIRE , SC_QUAGMIRE , SI_QUAGMIRE , SCB_AGI|SCB_DEX|SCB_ASPD|SCB_SPEED ); - set_sc( BS_ADRENALINE , SC_ADRENALINE , SI_ADRENALINE , SCB_ASPD ); - set_sc( BS_WEAPONPERFECT , SC_WEAPONPERFECT , SI_WEAPONPERFECT, SCB_NONE ); - set_sc( BS_OVERTHRUST , SC_OVERTHRUST , SI_OVERTHRUST , SCB_NONE ); - set_sc( BS_MAXIMIZE , SC_MAXIMIZEPOWER , SI_MAXIMIZE , SCB_REGEN ); + status->set_sc( WZ_QUAGMIRE , SC_QUAGMIRE , SI_QUAGMIRE , SCB_AGI|SCB_DEX|SCB_ASPD|SCB_SPEED ); + status->set_sc( BS_ADRENALINE , SC_ADRENALINE , SI_ADRENALINE , SCB_ASPD ); + status->set_sc( BS_WEAPONPERFECT , SC_WEAPONPERFECT , SI_WEAPONPERFECT, SCB_NONE ); + status->set_sc( BS_OVERTHRUST , SC_OVERTHRUST , SI_OVERTHRUST , SCB_NONE ); + status->set_sc( BS_MAXIMIZE , SC_MAXIMIZEPOWER , SI_MAXIMIZE , SCB_REGEN ); add_sc( HT_LANDMINE , SC_STUN ); - set_sc( HT_ANKLESNARE , SC_ANKLESNARE , SI_ANKLESNARE , SCB_NONE ); + status->set_sc( HT_ANKLESNARE , SC_ANKLESNARE , SI_ANKLESNARE , SCB_NONE ); add_sc( HT_SANDMAN , SC_SLEEP ); add_sc( HT_FLASHER , SC_BLIND ); add_sc( HT_FREEZINGTRAP , SC_FREEZE ); - set_sc( AS_CLOAKING , SC_CLOAKING , SI_CLOAKING , SCB_CRI|SCB_SPEED ); + status->set_sc( AS_CLOAKING , SC_CLOAKING , SI_CLOAKING , SCB_CRI|SCB_SPEED ); add_sc( AS_SONICBLOW , SC_STUN ); - set_sc( AS_ENCHANTPOISON , SC_ENCHANTPOISON , SI_ENCHANTPOISON, SCB_ATK_ELE ); - set_sc( AS_POISONREACT , SC_POISONREACT , SI_POISONREACT , SCB_NONE ); + status->set_sc( AS_ENCHANTPOISON , SC_ENCHANTPOISON , SI_ENCHANTPOISON, SCB_ATK_ELE ); + status->set_sc( AS_POISONREACT , SC_POISONREACT , SI_POISONREACT , SCB_NONE ); add_sc( AS_VENOMDUST , SC_POISON ); add_sc( AS_SPLASHER , SC_SPLASHER ); - set_sc( NV_TRICKDEAD , SC_TRICKDEAD , SI_TRICKDEAD , SCB_REGEN ); - set_sc( SM_AUTOBERSERK , SC_AUTOBERSERK , SI_AUTOBERSERK , SCB_NONE ); + status->set_sc( NV_TRICKDEAD , SC_TRICKDEAD , SI_TRICKDEAD , SCB_REGEN ); + status->set_sc( SM_AUTOBERSERK , SC_AUTOBERSERK , SI_AUTOBERSERK , SCB_NONE ); add_sc( TF_SPRINKLESAND , SC_BLIND ); add_sc( TF_THROWSTONE , SC_STUN ); - set_sc( MC_LOUD , SC_SHOUT , SI_SHOUT , SCB_STR ); - set_sc( MG_ENERGYCOAT , SC_ENERGYCOAT , SI_ENERGYCOAT , SCB_NONE ); - set_sc( NPC_EMOTION , SC_MODECHANGE , SI_BLANK , SCB_MODE ); + status->set_sc( MC_LOUD , SC_SHOUT , SI_SHOUT , SCB_STR ); + status->set_sc( MG_ENERGYCOAT , SC_ENERGYCOAT , SI_ENERGYCOAT , SCB_NONE ); + status->set_sc( NPC_EMOTION , SC_MODECHANGE , SI_BLANK , SCB_MODE ); add_sc( NPC_EMOTION_ON , SC_MODECHANGE ); - set_sc( NPC_ATTRICHANGE , SC_ARMOR_PROPERTY , SI_ARMOR_PROPERTY , SCB_DEF_ELE ); + status->set_sc( NPC_ATTRICHANGE , SC_ARMOR_PROPERTY , SI_ARMOR_PROPERTY , SCB_DEF_ELE ); add_sc( NPC_CHANGEWATER , SC_ARMOR_PROPERTY ); add_sc( NPC_CHANGEGROUND , SC_ARMOR_PROPERTY ); add_sc( NPC_CHANGEFIRE , SC_ARMOR_PROPERTY ); @@ -260,184 +261,184 @@ void initChangeTables(void) { add_sc( NPC_CURSEATTACK , SC_CURSE ); add_sc( NPC_SLEEPATTACK , SC_SLEEP ); add_sc( NPC_MAGICALATTACK , SC_MAGICALATTACK ); - set_sc( NPC_KEEPING , SC_KEEPING , SI_BLANK , SCB_DEF ); + status->set_sc( NPC_KEEPING , SC_KEEPING , SI_BLANK , SCB_DEF ); add_sc( NPC_DARKBLESSING , SC_COMA ); - set_sc( NPC_BARRIER , SC_BARRIER , SI_BLANK , SCB_MDEF|SCB_DEF ); + status->set_sc( NPC_BARRIER , SC_BARRIER , SI_BLANK , SCB_MDEF|SCB_DEF ); add_sc( NPC_DEFENDER , SC_ARMOR ); add_sc( NPC_LICK , SC_STUN ); - set_sc( NPC_HALLUCINATION , SC_ILLUSION , SI_ILLUSION , SCB_NONE ); + status->set_sc( NPC_HALLUCINATION , SC_ILLUSION , SI_ILLUSION , SCB_NONE ); add_sc( NPC_REBIRTH , SC_REBIRTH ); add_sc( RG_RAID , SC_STUN ); #ifdef RENEWAL add_sc( RG_RAID , SC_RAID ); add_sc( RG_BACKSTAP , SC_STUN ); #endif - set_sc( RG_STRIPWEAPON , SC_NOEQUIPWEAPON , SI_NOEQUIPWEAPON , SCB_WATK ); - set_sc( RG_STRIPSHIELD , SC_NOEQUIPSHIELD , SI_NOEQUIPSHIELD , SCB_DEF ); - set_sc( RG_STRIPARMOR , SC_NOEQUIPARMOR , SI_NOEQUIPARMOR , SCB_VIT ); - set_sc( RG_STRIPHELM , SC_NOEQUIPHELM , SI_NOEQUIPHELM , SCB_INT ); + status->set_sc( RG_STRIPWEAPON , SC_NOEQUIPWEAPON , SI_NOEQUIPWEAPON , SCB_WATK ); + status->set_sc( RG_STRIPSHIELD , SC_NOEQUIPSHIELD , SI_NOEQUIPSHIELD , SCB_DEF ); + status->set_sc( RG_STRIPARMOR , SC_NOEQUIPARMOR , SI_NOEQUIPARMOR , SCB_VIT ); + status->set_sc( RG_STRIPHELM , SC_NOEQUIPHELM , SI_NOEQUIPHELM , SCB_INT ); add_sc( AM_ACIDTERROR , SC_BLOODING ); - set_sc( AM_CP_WEAPON , SC_PROTECTWEAPON , SI_PROTECTWEAPON , SCB_NONE ); - set_sc( AM_CP_SHIELD , SC_PROTECTSHIELD , SI_PROTECTSHIELD , SCB_NONE ); - set_sc( AM_CP_ARMOR , SC_PROTECTARMOR , SI_PROTECTARMOR , SCB_NONE ); - set_sc( AM_CP_HELM , SC_PROTECTHELM , SI_PROTECTHELM , SCB_NONE ); - set_sc( CR_AUTOGUARD , SC_AUTOGUARD , SI_AUTOGUARD , SCB_NONE ); + status->set_sc( AM_CP_WEAPON , SC_PROTECTWEAPON , SI_PROTECTWEAPON , SCB_NONE ); + status->set_sc( AM_CP_SHIELD , SC_PROTECTSHIELD , SI_PROTECTSHIELD , SCB_NONE ); + status->set_sc( AM_CP_ARMOR , SC_PROTECTARMOR , SI_PROTECTARMOR , SCB_NONE ); + status->set_sc( AM_CP_HELM , SC_PROTECTHELM , SI_PROTECTHELM , SCB_NONE ); + status->set_sc( CR_AUTOGUARD , SC_AUTOGUARD , SI_AUTOGUARD , SCB_NONE ); add_sc( CR_SHIELDCHARGE , SC_STUN ); - set_sc( CR_REFLECTSHIELD , SC_REFLECTSHIELD , SI_REFLECTSHIELD , SCB_NONE ); + status->set_sc( CR_REFLECTSHIELD , SC_REFLECTSHIELD , SI_REFLECTSHIELD , SCB_NONE ); add_sc( CR_HOLYCROSS , SC_BLIND ); add_sc( CR_GRANDCROSS , SC_BLIND ); add_sc( CR_DEVOTION , SC_DEVOTION ); - set_sc( CR_PROVIDENCE , SC_PROVIDENCE , SI_PROVIDENCE , SCB_ALL ); - set_sc( CR_DEFENDER , SC_DEFENDER , SI_DEFENDER , SCB_SPEED|SCB_ASPD ); - set_sc( CR_SPEARQUICKEN , SC_SPEARQUICKEN , SI_SPEARQUICKEN , SCB_ASPD|SCB_CRI|SCB_FLEE ); - set_sc( MO_STEELBODY , SC_STEELBODY , SI_STEELBODY , SCB_DEF|SCB_MDEF|SCB_ASPD|SCB_SPEED ); + status->set_sc( CR_PROVIDENCE , SC_PROVIDENCE , SI_PROVIDENCE , SCB_ALL ); + status->set_sc( CR_DEFENDER , SC_DEFENDER , SI_DEFENDER , SCB_SPEED|SCB_ASPD ); + status->set_sc( CR_SPEARQUICKEN , SC_SPEARQUICKEN , SI_SPEARQUICKEN , SCB_ASPD|SCB_CRI|SCB_FLEE ); + status->set_sc( MO_STEELBODY , SC_STEELBODY , SI_STEELBODY , SCB_DEF|SCB_MDEF|SCB_ASPD|SCB_SPEED ); add_sc( MO_BLADESTOP , SC_BLADESTOP_WAIT ); add_sc( MO_BLADESTOP , SC_BLADESTOP ); - set_sc( MO_EXPLOSIONSPIRITS , SC_EXPLOSIONSPIRITS, SI_EXPLOSIONSPIRITS, SCB_CRI|SCB_REGEN ); - set_sc( MO_EXTREMITYFIST , SC_EXTREMITYFIST , SI_BLANK , SCB_REGEN ); + status->set_sc( MO_EXPLOSIONSPIRITS , SC_EXPLOSIONSPIRITS, SI_EXPLOSIONSPIRITS, SCB_CRI|SCB_REGEN ); + status->set_sc( MO_EXTREMITYFIST , SC_EXTREMITYFIST , SI_BLANK , SCB_REGEN ); #ifdef RENEWAL - set_sc( MO_EXTREMITYFIST , SC_EXTREMITYFIST2 , SI_EXTREMITYFIST , SCB_NONE ); + status->set_sc( MO_EXTREMITYFIST , SC_EXTREMITYFIST2 , SI_EXTREMITYFIST , SCB_NONE ); #endif add_sc( SA_MAGICROD , SC_MAGICROD ); - set_sc( SA_AUTOSPELL , SC_AUTOSPELL , SI_AUTOSPELL , SCB_NONE ); - set_sc( SA_FLAMELAUNCHER , SC_PROPERTYFIRE , SI_PROPERTYFIRE , SCB_ATK_ELE ); - set_sc( SA_FROSTWEAPON , SC_PROPERTYWATER , SI_PROPERTYWATER , SCB_ATK_ELE ); - set_sc( SA_LIGHTNINGLOADER , SC_PROPERTYWIND , SI_PROPERTYWIND , SCB_ATK_ELE ); - set_sc( SA_SEISMICWEAPON , SC_PROPERTYGROUND , SI_PROPERTYGROUND , SCB_ATK_ELE ); - set_sc( SA_VOLCANO , SC_VOLCANO , SI_GROUNDMAGIC , SCB_WATK ); - set_sc( SA_DELUGE , SC_DELUGE , SI_GROUNDMAGIC , SCB_MAXHP ); - set_sc( SA_VIOLENTGALE , SC_VIOLENTGALE , SI_GROUNDMAGIC , SCB_FLEE ); + status->set_sc( SA_AUTOSPELL , SC_AUTOSPELL , SI_AUTOSPELL , SCB_NONE ); + status->set_sc( SA_FLAMELAUNCHER , SC_PROPERTYFIRE , SI_PROPERTYFIRE , SCB_ATK_ELE ); + status->set_sc( SA_FROSTWEAPON , SC_PROPERTYWATER , SI_PROPERTYWATER , SCB_ATK_ELE ); + status->set_sc( SA_LIGHTNINGLOADER , SC_PROPERTYWIND , SI_PROPERTYWIND , SCB_ATK_ELE ); + status->set_sc( SA_SEISMICWEAPON , SC_PROPERTYGROUND , SI_PROPERTYGROUND , SCB_ATK_ELE ); + status->set_sc( SA_VOLCANO , SC_VOLCANO , SI_GROUNDMAGIC , SCB_WATK ); + status->set_sc( SA_DELUGE , SC_DELUGE , SI_GROUNDMAGIC , SCB_MAXHP ); + status->set_sc( SA_VIOLENTGALE , SC_VIOLENTGALE , SI_GROUNDMAGIC , SCB_FLEE ); add_sc( SA_REVERSEORCISH , SC_ORCISH ); add_sc( SA_COMA , SC_COMA ); - set_sc( BD_ENCORE , SC_DANCING , SI_BLANK , SCB_SPEED|SCB_REGEN ); + status->set_sc( BD_ENCORE , SC_DANCING , SI_BLANK , SCB_SPEED|SCB_REGEN ); add_sc( BD_RICHMANKIM , SC_RICHMANKIM ); - set_sc( BD_ETERNALCHAOS , SC_ETERNALCHAOS , SI_BLANK , SCB_DEF2 ); - set_sc( BD_DRUMBATTLEFIELD , SC_DRUMBATTLE , SI_BLANK , SCB_WATK|SCB_DEF ); - set_sc( BD_RINGNIBELUNGEN , SC_NIBELUNGEN , SI_BLANK , SCB_WATK ); + status->set_sc( BD_ETERNALCHAOS , SC_ETERNALCHAOS , SI_BLANK , SCB_DEF2 ); + status->set_sc( BD_DRUMBATTLEFIELD , SC_DRUMBATTLE , SI_BLANK , SCB_WATK|SCB_DEF ); + status->set_sc( BD_RINGNIBELUNGEN , SC_NIBELUNGEN , SI_BLANK , SCB_WATK ); add_sc( BD_ROKISWEIL , SC_ROKISWEIL ); add_sc( BD_INTOABYSS , SC_INTOABYSS ); - set_sc( BD_SIEGFRIED , SC_SIEGFRIED , SI_BLANK , SCB_ALL ); + status->set_sc( BD_SIEGFRIED , SC_SIEGFRIED , SI_BLANK , SCB_ALL ); add_sc( BA_FROSTJOKER , SC_FREEZE ); - set_sc( BA_WHISTLE , SC_WHISTLE , SI_BLANK , SCB_FLEE|SCB_FLEE2 ); - set_sc( BA_ASSASSINCROSS , SC_ASSNCROS , SI_BLANK , SCB_ASPD ); + status->set_sc( BA_WHISTLE , SC_WHISTLE , SI_BLANK , SCB_FLEE|SCB_FLEE2 ); + status->set_sc( BA_ASSASSINCROSS , SC_ASSNCROS , SI_BLANK , SCB_ASPD ); add_sc( BA_POEMBRAGI , SC_POEMBRAGI ); - set_sc( BA_APPLEIDUN , SC_APPLEIDUN , SI_BLANK , SCB_MAXHP ); + status->set_sc( BA_APPLEIDUN , SC_APPLEIDUN , SI_BLANK , SCB_MAXHP ); add_sc( DC_SCREAM , SC_STUN ); - set_sc( DC_HUMMING , SC_HUMMING , SI_BLANK , SCB_HIT ); - set_sc( DC_DONTFORGETME , SC_DONTFORGETME , SI_BLANK , SCB_SPEED|SCB_ASPD ); - set_sc( DC_FORTUNEKISS , SC_FORTUNE , SI_BLANK , SCB_CRI ); - set_sc( DC_SERVICEFORYOU , SC_SERVICEFORYOU , SI_BLANK , SCB_ALL ); + status->set_sc( DC_HUMMING , SC_HUMMING , SI_BLANK , SCB_HIT ); + status->set_sc( DC_DONTFORGETME , SC_DONTFORGETME , SI_BLANK , SCB_SPEED|SCB_ASPD ); + status->set_sc( DC_FORTUNEKISS , SC_FORTUNE , SI_BLANK , SCB_CRI ); + status->set_sc( DC_SERVICEFORYOU , SC_SERVICEFORYOU , SI_BLANK , SCB_ALL ); add_sc( NPC_DARKCROSS , SC_BLIND ); add_sc( NPC_GRANDDARKNESS , SC_BLIND ); - set_sc( NPC_STOP , SC_STOP , SI_STOP , SCB_NONE ); - set_sc( NPC_WEAPONBRAKER , SC_BROKENWEAPON , SI_BROKENWEAPON , SCB_NONE ); - set_sc( NPC_ARMORBRAKE , SC_BROKENARMOR , SI_BROKENARMOR , SCB_NONE ); - set_sc( NPC_CHANGEUNDEAD , SC_PROPERTYUNDEAD , SI_PROPERTYUNDEAD , SCB_DEF_ELE ); - set_sc( NPC_POWERUP , SC_INCHITRATE , SI_BLANK , SCB_HIT ); - set_sc( NPC_AGIUP , SC_INCFLEERATE , SI_BLANK , SCB_FLEE ); + status->set_sc( NPC_STOP , SC_STOP , SI_STOP , SCB_NONE ); + status->set_sc( NPC_WEAPONBRAKER , SC_BROKENWEAPON , SI_BROKENWEAPON , SCB_NONE ); + status->set_sc( NPC_ARMORBRAKE , SC_BROKENARMOR , SI_BROKENARMOR , SCB_NONE ); + status->set_sc( NPC_CHANGEUNDEAD , SC_PROPERTYUNDEAD , SI_PROPERTYUNDEAD , SCB_DEF_ELE ); + status->set_sc( NPC_POWERUP , SC_INCHITRATE , SI_BLANK , SCB_HIT ); + status->set_sc( NPC_AGIUP , SC_INCFLEERATE , SI_BLANK , SCB_FLEE ); add_sc( NPC_INVISIBLE , SC_CLOAKING ); - set_sc( LK_AURABLADE , SC_AURABLADE , SI_AURABLADE , SCB_NONE ); - set_sc( LK_PARRYING , SC_PARRYING , SI_PARRYING , SCB_NONE ); + status->set_sc( LK_AURABLADE , SC_AURABLADE , SI_AURABLADE , SCB_NONE ); + status->set_sc( LK_PARRYING , SC_PARRYING , SI_PARRYING , SCB_NONE ); #ifndef RENEWAL - set_sc( LK_CONCENTRATION , SC_LKCONCENTRATION , SI_LKCONCENTRATION , SCB_BATK|SCB_WATK|SCB_HIT|SCB_DEF|SCB_DEF2); + status->set_sc( LK_CONCENTRATION , SC_LKCONCENTRATION , SI_LKCONCENTRATION , SCB_BATK|SCB_WATK|SCB_HIT|SCB_DEF|SCB_DEF2); #else - set_sc( LK_CONCENTRATION , SC_LKCONCENTRATION , SI_LKCONCENTRATION , SCB_HIT|SCB_DEF); + status->set_sc( LK_CONCENTRATION , SC_LKCONCENTRATION , SI_LKCONCENTRATION , SCB_HIT|SCB_DEF); #endif - set_sc( LK_TENSIONRELAX , SC_TENSIONRELAX , SI_TENSIONRELAX , SCB_REGEN ); - set_sc( LK_BERSERK , SC_BERSERK , SI_BERSERK , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2|SCB_FLEE|SCB_SPEED|SCB_ASPD|SCB_MAXHP|SCB_REGEN ); - set_sc( HP_ASSUMPTIO , SC_ASSUMPTIO , SI_ASSUMPTIO , SCB_NONE ); + status->set_sc( LK_TENSIONRELAX , SC_TENSIONRELAX , SI_TENSIONRELAX , SCB_REGEN ); + status->set_sc( LK_BERSERK , SC_BERSERK , SI_BERSERK , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2|SCB_FLEE|SCB_SPEED|SCB_ASPD|SCB_MAXHP|SCB_REGEN ); + status->set_sc( HP_ASSUMPTIO , SC_ASSUMPTIO , SI_ASSUMPTIO , SCB_NONE ); add_sc( HP_BASILICA , SC_BASILICA ); - set_sc( HW_MAGICPOWER , SC_MAGICPOWER , SI_MAGICPOWER , SCB_MATK ); + status->set_sc( HW_MAGICPOWER , SC_MAGICPOWER , SI_MAGICPOWER , SCB_MATK ); add_sc( PA_SACRIFICE , SC_SACRIFICE ); - set_sc( PA_GOSPEL , SC_GOSPEL , SI_BLANK , SCB_SPEED|SCB_ASPD ); + status->set_sc( PA_GOSPEL , SC_GOSPEL , SI_BLANK , SCB_SPEED|SCB_ASPD ); add_sc( PA_GOSPEL , SC_SCRESIST ); add_sc( CH_TIGERFIST , SC_STOP ); - set_sc( ASC_EDP , SC_EDP , SI_EDP , SCB_NONE ); - set_sc( SN_SIGHT , SC_TRUESIGHT , SI_TRUESIGHT , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK|SCB_CRI|SCB_HIT ); - set_sc( SN_WINDWALK , SC_WINDWALK , SI_WINDWALK , SCB_FLEE|SCB_SPEED ); - set_sc( WS_MELTDOWN , SC_MELTDOWN , SI_MELTDOWN , SCB_NONE ); - set_sc( WS_CARTBOOST , SC_CARTBOOST , SI_CARTBOOST , SCB_SPEED ); - set_sc( ST_CHASEWALK , SC_CHASEWALK , SI_BLANK , SCB_SPEED ); - set_sc( ST_REJECTSWORD , SC_SWORDREJECT , SI_SWORDREJECT , SCB_NONE ); + status->set_sc( ASC_EDP , SC_EDP , SI_EDP , SCB_NONE ); + status->set_sc( SN_SIGHT , SC_TRUESIGHT , SI_TRUESIGHT , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK|SCB_CRI|SCB_HIT ); + status->set_sc( SN_WINDWALK , SC_WINDWALK , SI_WINDWALK , SCB_FLEE|SCB_SPEED ); + status->set_sc( WS_MELTDOWN , SC_MELTDOWN , SI_MELTDOWN , SCB_NONE ); + status->set_sc( WS_CARTBOOST , SC_CARTBOOST , SI_CARTBOOST , SCB_SPEED ); + status->set_sc( ST_CHASEWALK , SC_CHASEWALK , SI_BLANK , SCB_SPEED ); + status->set_sc( ST_REJECTSWORD , SC_SWORDREJECT , SI_SWORDREJECT , SCB_NONE ); add_sc( ST_REJECTSWORD , SC_AUTOCOUNTER ); - set_sc( CG_MARIONETTE , SC_MARIONETTE_MASTER , SI_MARIONETTE_MASTER , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); - set_sc( CG_MARIONETTE , SC_MARIONETTE , SI_MARIONETTE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); + status->set_sc( CG_MARIONETTE , SC_MARIONETTE_MASTER , SI_MARIONETTE_MASTER , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); + status->set_sc( CG_MARIONETTE , SC_MARIONETTE , SI_MARIONETTE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); add_sc( LK_SPIRALPIERCE , SC_STOP ); add_sc( LK_HEADCRUSH , SC_BLOODING ); - set_sc( LK_JOINTBEAT , SC_JOINTBEAT , SI_JOINTBEAT , SCB_BATK|SCB_DEF2|SCB_SPEED|SCB_ASPD ); + status->set_sc( LK_JOINTBEAT , SC_JOINTBEAT , SI_JOINTBEAT , SCB_BATK|SCB_DEF2|SCB_SPEED|SCB_ASPD ); add_sc( HW_NAPALMVULCAN , SC_CURSE ); - set_sc( PF_MINDBREAKER , SC_MINDBREAKER , SI_BLANK , SCB_MATK|SCB_MDEF2 ); + status->set_sc( PF_MINDBREAKER , SC_MINDBREAKER , SI_BLANK , SCB_MATK|SCB_MDEF2 ); add_sc( PF_MEMORIZE , SC_MEMORIZE ); add_sc( PF_FOGWALL , SC_FOGWALL ); - set_sc( PF_SPIDERWEB , SC_SPIDERWEB , SI_BLANK , SCB_FLEE ); - set_sc( WE_BABY , SC_BABY , SI_PROTECTEXP , SCB_NONE ); - set_sc( TK_RUN , SC_RUN , SI_RUN , SCB_SPEED|SCB_DSPD ); - set_sc( TK_RUN , SC_STRUP , SI_STRUP , SCB_STR ); - set_sc( TK_READYSTORM , SC_STORMKICK_READY , SI_STORMKICK_ON , SCB_NONE ); - set_sc( TK_READYDOWN , SC_DOWNKICK_READY , SI_DOWNKICK_ON , SCB_NONE ); + status->set_sc( PF_SPIDERWEB , SC_SPIDERWEB , SI_BLANK , SCB_FLEE ); + status->set_sc( WE_BABY , SC_BABY , SI_PROTECTEXP , SCB_NONE ); + status->set_sc( TK_RUN , SC_RUN , SI_RUN , SCB_SPEED|SCB_DSPD ); + status->set_sc( TK_RUN , SC_STRUP , SI_STRUP , SCB_STR ); + status->set_sc( TK_READYSTORM , SC_STORMKICK_READY , SI_STORMKICK_ON , SCB_NONE ); + status->set_sc( TK_READYDOWN , SC_DOWNKICK_READY , SI_DOWNKICK_ON , SCB_NONE ); add_sc( TK_DOWNKICK , SC_STUN ); - set_sc( TK_READYTURN , SC_TURNKICK_READY , SI_TURNKICK_ON , SCB_NONE ); - set_sc( TK_READYCOUNTER , SC_COUNTERKICK_READY , SI_COUNTER_ON , SCB_NONE ); - set_sc( TK_DODGE , SC_DODGE_READY , SI_DODGE_ON , SCB_NONE ); - set_sc( TK_SPTIME , SC_EARTHSCROLL , SI_EARTHSCROLL , SCB_NONE ); + status->set_sc( TK_READYTURN , SC_TURNKICK_READY , SI_TURNKICK_ON , SCB_NONE ); + status->set_sc( TK_READYCOUNTER , SC_COUNTERKICK_READY , SI_COUNTER_ON , SCB_NONE ); + status->set_sc( TK_DODGE , SC_DODGE_READY , SI_DODGE_ON , SCB_NONE ); + status->set_sc( TK_SPTIME , SC_EARTHSCROLL , SI_EARTHSCROLL , SCB_NONE ); add_sc( TK_SEVENWIND , SC_TK_SEVENWIND ); - set_sc( TK_SEVENWIND , SC_PROPERTYTELEKINESIS , SI_PROPERTYTELEKINESIS , SCB_ATK_ELE ); - set_sc( TK_SEVENWIND , SC_PROPERTYDARK , SI_PROPERTYDARK , SCB_ATK_ELE ); - set_sc( SG_SUN_WARM , SC_WARM , SI_SG_SUN_WARM , SCB_NONE ); + status->set_sc( TK_SEVENWIND , SC_PROPERTYTELEKINESIS , SI_PROPERTYTELEKINESIS , SCB_ATK_ELE ); + status->set_sc( TK_SEVENWIND , SC_PROPERTYDARK , SI_PROPERTYDARK , SCB_ATK_ELE ); + status->set_sc( SG_SUN_WARM , SC_WARM , SI_SG_SUN_WARM , SCB_NONE ); add_sc( SG_MOON_WARM , SC_WARM ); add_sc( SG_STAR_WARM , SC_WARM ); - set_sc( SG_SUN_COMFORT , SC_SUN_COMFORT , SI_SUN_COMFORT , SCB_DEF2 ); - set_sc( SG_MOON_COMFORT , SC_MOON_COMFORT , SI_MOON_COMFORT , SCB_FLEE ); - set_sc( SG_STAR_COMFORT , SC_STAR_COMFORT , SI_STAR_COMFORT , SCB_ASPD ); + status->set_sc( SG_SUN_COMFORT , SC_SUN_COMFORT , SI_SUN_COMFORT , SCB_DEF2 ); + status->set_sc( SG_MOON_COMFORT , SC_MOON_COMFORT , SI_MOON_COMFORT , SCB_FLEE ); + status->set_sc( SG_STAR_COMFORT , SC_STAR_COMFORT , SI_STAR_COMFORT , SCB_ASPD ); add_sc( SG_FRIEND , SC_SKILLRATE_UP ); - set_sc( SG_KNOWLEDGE , SC_KNOWLEDGE , SI_BLANK , SCB_ALL ); - set_sc( SG_FUSION , SC_FUSION , SI_BLANK , SCB_SPEED ); - set_sc( BS_ADRENALINE2 , SC_ADRENALINE2 , SI_ADRENALINE2 , SCB_ASPD ); - set_sc( SL_KAIZEL , SC_KAIZEL , SI_KAIZEL , SCB_NONE ); - set_sc( SL_KAAHI , SC_KAAHI , SI_KAAHI , SCB_NONE ); - set_sc( SL_KAUPE , SC_KAUPE , SI_KAUPE , SCB_NONE ); - set_sc( SL_KAITE , SC_KAITE , SI_KAITE , SCB_NONE ); + status->set_sc( SG_KNOWLEDGE , SC_KNOWLEDGE , SI_BLANK , SCB_ALL ); + status->set_sc( SG_FUSION , SC_FUSION , SI_BLANK , SCB_SPEED ); + status->set_sc( BS_ADRENALINE2 , SC_ADRENALINE2 , SI_ADRENALINE2 , SCB_ASPD ); + status->set_sc( SL_KAIZEL , SC_KAIZEL , SI_KAIZEL , SCB_NONE ); + status->set_sc( SL_KAAHI , SC_KAAHI , SI_KAAHI , SCB_NONE ); + status->set_sc( SL_KAUPE , SC_KAUPE , SI_KAUPE , SCB_NONE ); + status->set_sc( SL_KAITE , SC_KAITE , SI_KAITE , SCB_NONE ); add_sc( SL_STUN , SC_STUN ); - set_sc( SL_SWOO , SC_SWOO , SI_BLANK , SCB_SPEED ); - set_sc( SL_SKE , SC_SKE , SI_BLANK , SCB_BATK|SCB_WATK|SCB_DEF|SCB_DEF2 ); - set_sc( SL_SKA , SC_SKA , SI_BLANK , SCB_DEF|SCB_MDEF|SCB_ASPD ); - set_sc( SL_SMA , SC_SMA_READY , SI_SMA_READY , SCB_NONE ); - set_sc( SM_SELFPROVOKE , SC_PROVOKE , SI_PROVOKE , SCB_DEF|SCB_DEF2|SCB_BATK|SCB_WATK ); - set_sc( ST_PRESERVE , SC_PRESERVE , SI_PRESERVE , SCB_NONE ); - set_sc( PF_DOUBLECASTING , SC_DOUBLECASTING , SI_DOUBLECASTING , SCB_NONE ); - set_sc( HW_GRAVITATION , SC_GRAVITATION , SI_BLANK , SCB_ASPD ); + status->set_sc( SL_SWOO , SC_SWOO , SI_BLANK , SCB_SPEED ); + status->set_sc( SL_SKE , SC_SKE , SI_BLANK , SCB_BATK|SCB_WATK|SCB_DEF|SCB_DEF2 ); + status->set_sc( SL_SKA , SC_SKA , SI_BLANK , SCB_DEF|SCB_MDEF|SCB_ASPD ); + status->set_sc( SL_SMA , SC_SMA_READY , SI_SMA_READY , SCB_NONE ); + status->set_sc( SM_SELFPROVOKE , SC_PROVOKE , SI_PROVOKE , SCB_DEF|SCB_DEF2|SCB_BATK|SCB_WATK ); + status->set_sc( ST_PRESERVE , SC_PRESERVE , SI_PRESERVE , SCB_NONE ); + status->set_sc( PF_DOUBLECASTING , SC_DOUBLECASTING , SI_DOUBLECASTING , SCB_NONE ); + status->set_sc( HW_GRAVITATION , SC_GRAVITATION , SI_BLANK , SCB_ASPD ); add_sc( WS_CARTTERMINATION , SC_STUN ); - set_sc( WS_OVERTHRUSTMAX , SC_OVERTHRUSTMAX , SI_OVERTHRUSTMAX , SCB_NONE ); - set_sc( CG_LONGINGFREEDOM , SC_LONGING , SI_BLANK , SCB_SPEED|SCB_ASPD ); + status->set_sc( WS_OVERTHRUSTMAX , SC_OVERTHRUSTMAX , SI_OVERTHRUSTMAX , SCB_NONE ); + status->set_sc( CG_LONGINGFREEDOM , SC_LONGING , SI_BLANK , SCB_SPEED|SCB_ASPD ); add_sc( CG_HERMODE , SC_HERMODE ); - set_sc( CG_TAROTCARD , SC_TAROTCARD , SI_TAROTCARD , SCB_NONE ); - set_sc( ITEM_ENCHANTARMS , SC_ENCHANTARMS , SI_BLANK , SCB_ATK_ELE ); - set_sc( SL_HIGH , SC_SOULLINK , SI_SOULLINK , SCB_ALL ); - set_sc( KN_ONEHAND , SC_ONEHANDQUICKEN , SI_ONEHANDQUICKEN , SCB_ASPD ); - set_sc( GS_FLING , SC_FLING , SI_BLANK , SCB_DEF|SCB_DEF2 ); + status->set_sc( CG_TAROTCARD , SC_TAROTCARD , SI_TAROTCARD , SCB_NONE ); + status->set_sc( ITEM_ENCHANTARMS , SC_ENCHANTARMS , SI_BLANK , SCB_ATK_ELE ); + status->set_sc( SL_HIGH , SC_SOULLINK , SI_SOULLINK , SCB_ALL ); + status->set_sc( KN_ONEHAND , SC_ONEHANDQUICKEN , SI_ONEHANDQUICKEN , SCB_ASPD ); + status->set_sc( GS_FLING , SC_FLING , SI_BLANK , SCB_DEF|SCB_DEF2 ); add_sc( GS_CRACKER , SC_STUN ); add_sc( GS_DISARM , SC_NOEQUIPWEAPON ); add_sc( GS_PIERCINGSHOT , SC_BLOODING ); - set_sc( GS_MADNESSCANCEL , SC_GS_MADNESSCANCEL , SI_GS_MADNESSCANCEL , SCB_ASPD + status->set_sc( GS_MADNESSCANCEL , SC_GS_MADNESSCANCEL , SI_GS_MADNESSCANCEL , SCB_ASPD #ifndef RENEWAL |SCB_BATK ); #else ); #endif - set_sc( GS_ADJUSTMENT , SC_GS_ADJUSTMENT , SI_GS_ADJUSTMENT , SCB_HIT|SCB_FLEE ); - set_sc( GS_INCREASING , SC_GS_ACCURACY , SI_GS_ACCURACY , SCB_AGI|SCB_DEX|SCB_HIT ); - set_sc( GS_GATLINGFEVER , SC_GS_GATLINGFEVER , SI_GS_GATLINGFEVER , SCB_FLEE|SCB_SPEED|SCB_ASPD + status->set_sc( GS_ADJUSTMENT , SC_GS_ADJUSTMENT , SI_GS_ADJUSTMENT , SCB_HIT|SCB_FLEE ); + status->set_sc( GS_INCREASING , SC_GS_ACCURACY , SI_GS_ACCURACY , SCB_AGI|SCB_DEX|SCB_HIT ); + status->set_sc( GS_GATLINGFEVER , SC_GS_GATLINGFEVER , SI_GS_GATLINGFEVER , SCB_FLEE|SCB_SPEED|SCB_ASPD #ifndef RENEWAL |SCB_BATK ); #else ); #endif - set_sc( NJ_TATAMIGAESHI , SC_NJ_TATAMIGAESHI , SI_BLANK , SCB_NONE ); - set_sc( NJ_SUITON , SC_NJ_SUITON , SI_NJ_SUITON , SCB_AGI|SCB_SPEED ); + status->set_sc( NJ_TATAMIGAESHI , SC_NJ_TATAMIGAESHI , SI_BLANK , SCB_NONE ); + status->set_sc( NJ_SUITON , SC_NJ_SUITON , SI_NJ_SUITON , SCB_AGI|SCB_SPEED ); add_sc( NJ_HYOUSYOURAKU , SC_FREEZE ); - set_sc( NJ_NEN , SC_NJ_NEN , SI_NJ_NEN , SCB_STR|SCB_INT ); - set_sc( NJ_UTSUSEMI , SC_NJ_UTSUSEMI , SI_NJ_UTSUSEMI , SCB_NONE ); - set_sc( NJ_BUNSINJYUTSU , SC_NJ_BUNSINJYUTSU , SI_NJ_BUNSINJYUTSU , SCB_DYE ); + status->set_sc( NJ_NEN , SC_NJ_NEN , SI_NJ_NEN , SCB_STR|SCB_INT ); + status->set_sc( NJ_UTSUSEMI , SC_NJ_UTSUSEMI , SI_NJ_UTSUSEMI , SCB_NONE ); + status->set_sc( NJ_BUNSINJYUTSU , SC_NJ_BUNSINJYUTSU , SI_NJ_BUNSINJYUTSU , SCB_DYE ); add_sc( NPC_ICEBREATH , SC_FREEZE ); add_sc( NPC_ACIDBREATH , SC_POISON ); @@ -451,201 +452,201 @@ void initChangeTables(void) { add_sc( NPC_WIDESIGHT , SC_SIGHT ); add_sc( NPC_EVILLAND , SC_BLIND ); add_sc( NPC_MAGICMIRROR , SC_MAGICMIRROR ); - set_sc( NPC_SLOWCAST , SC_SLOWCAST , SI_SLOWCAST , SCB_NONE ); - set_sc( NPC_CRITICALWOUND , SC_CRITICALWOUND , SI_CRITICALWOUND , SCB_NONE ); - set_sc( NPC_STONESKIN , SC_STONESKIN , SI_BLANK , SCB_DEF|SCB_MDEF ); + status->set_sc( NPC_SLOWCAST , SC_SLOWCAST , SI_SLOWCAST , SCB_NONE ); + status->set_sc( NPC_CRITICALWOUND , SC_CRITICALWOUND , SI_CRITICALWOUND , SCB_NONE ); + status->set_sc( NPC_STONESKIN , SC_STONESKIN , SI_BLANK , SCB_DEF|SCB_MDEF ); add_sc( NPC_ANTIMAGIC , SC_STONESKIN ); add_sc( NPC_WIDECURSE , SC_CURSE ); add_sc( NPC_WIDESTUN , SC_STUN ); - set_sc( NPC_HELLPOWER , SC_HELLPOWER , SI_HELLPOWER , SCB_NONE ); - set_sc( NPC_WIDEHELLDIGNITY , SC_HELLPOWER , SI_HELLPOWER , SCB_NONE ); - set_sc( NPC_INVINCIBLE , SC_INVINCIBLE , SI_INVINCIBLE , SCB_SPEED ); - set_sc( NPC_INVINCIBLEOFF , SC_INVINCIBLEOFF , SI_BLANK , SCB_SPEED ); + status->set_sc( NPC_HELLPOWER , SC_HELLPOWER , SI_HELLPOWER , SCB_NONE ); + status->set_sc( NPC_WIDEHELLDIGNITY , SC_HELLPOWER , SI_HELLPOWER , SCB_NONE ); + status->set_sc( NPC_INVINCIBLE , SC_INVINCIBLE , SI_INVINCIBLE , SCB_SPEED ); + status->set_sc( NPC_INVINCIBLEOFF , SC_INVINCIBLEOFF , SI_BLANK , SCB_SPEED ); - set_sc( CASH_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX ); - set_sc( CASH_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED ); - set_sc( CASH_ASSUMPTIO , SC_ASSUMPTIO , SI_ASSUMPTIO , SCB_NONE ); + status->set_sc( CASH_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX ); + status->set_sc( CASH_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED ); + status->set_sc( CASH_ASSUMPTIO , SC_ASSUMPTIO , SI_ASSUMPTIO , SCB_NONE ); - set_sc( ALL_PARTYFLEE , SC_PARTYFLEE , SI_PARTYFLEE , SCB_NONE ); - set_sc( ALL_ODINS_POWER , SC_ODINS_POWER , SI_ODINS_POWER , SCB_WATK | SCB_MATK | SCB_MDEF | SCB_DEF); + status->set_sc( ALL_PARTYFLEE , SC_PARTYFLEE , SI_PARTYFLEE , SCB_NONE ); + status->set_sc( ALL_ODINS_POWER , SC_ODINS_POWER , SI_ODINS_POWER , SCB_WATK | SCB_MATK | SCB_MDEF | SCB_DEF); - set_sc( CR_SHRINK , SC_CR_SHRINK , SI_CR_SHRINK , SCB_NONE ); - set_sc( RG_CLOSECONFINE , SC_RG_CCONFINE_S , SI_RG_CCONFINE_S , SCB_NONE ); - set_sc( RG_CLOSECONFINE , SC_RG_CCONFINE_M , SI_RG_CCONFINE_M , SCB_FLEE ); - set_sc( WZ_SIGHTBLASTER , SC_WZ_SIGHTBLASTER , SI_WZ_SIGHTBLASTER , SCB_NONE ); - set_sc( DC_WINKCHARM , SC_DC_WINKCHARM , SI_DC_WINKCHARM , SCB_NONE ); + status->set_sc( CR_SHRINK , SC_CR_SHRINK , SI_CR_SHRINK , SCB_NONE ); + status->set_sc( RG_CLOSECONFINE , SC_RG_CCONFINE_S , SI_RG_CCONFINE_S , SCB_NONE ); + status->set_sc( RG_CLOSECONFINE , SC_RG_CCONFINE_M , SI_RG_CCONFINE_M , SCB_FLEE ); + status->set_sc( WZ_SIGHTBLASTER , SC_WZ_SIGHTBLASTER , SI_WZ_SIGHTBLASTER , SCB_NONE ); + status->set_sc( DC_WINKCHARM , SC_DC_WINKCHARM , SI_DC_WINKCHARM , SCB_NONE ); add_sc( MO_BALKYOUNG , SC_STUN ); add_sc( SA_ELEMENTWATER , SC_ARMOR_PROPERTY ); add_sc( SA_ELEMENTFIRE , SC_ARMOR_PROPERTY ); add_sc( SA_ELEMENTGROUND , SC_ARMOR_PROPERTY ); add_sc( SA_ELEMENTWIND , SC_ARMOR_PROPERTY ); - set_sc( HLIF_AVOID , SC_HLIF_AVOID , SI_BLANK , SCB_SPEED ); - set_sc( HLIF_CHANGE , SC_HLIF_CHANGE , SI_BLANK , SCB_VIT|SCB_INT ); - set_sc( HFLI_FLEET , SC_HLIF_FLEET , SI_BLANK , SCB_ASPD|SCB_BATK|SCB_WATK ); - set_sc( HFLI_SPEED , SC_HLIF_SPEED , SI_BLANK , SCB_FLEE ); - set_sc( HAMI_DEFENCE , SC_HAMI_DEFENCE , SI_BLANK , SCB_DEF ); - set_sc( HAMI_BLOODLUST , SC_HAMI_BLOODLUST , SI_BLANK , SCB_BATK|SCB_WATK ); + status->set_sc( HLIF_AVOID , SC_HLIF_AVOID , SI_BLANK , SCB_SPEED ); + status->set_sc( HLIF_CHANGE , SC_HLIF_CHANGE , SI_BLANK , SCB_VIT|SCB_INT ); + status->set_sc( HFLI_FLEET , SC_HLIF_FLEET , SI_BLANK , SCB_ASPD|SCB_BATK|SCB_WATK ); + status->set_sc( HFLI_SPEED , SC_HLIF_SPEED , SI_BLANK , SCB_FLEE ); + status->set_sc( HAMI_DEFENCE , SC_HAMI_DEFENCE , SI_BLANK , SCB_DEF ); + status->set_sc( HAMI_BLOODLUST , SC_HAMI_BLOODLUST , SI_BLANK , SCB_BATK|SCB_WATK ); // Homunculus S - set_sc( MH_LIGHT_OF_REGENE , SC_LIGHT_OF_REGENE , SI_LIGHT_OF_REGENE , SCB_NONE ); - set_sc( MH_OVERED_BOOST , SC_OVERED_BOOST , SI_OVERED_BOOST , SCB_FLEE|SCB_ASPD|SCB_DEF ); + status->set_sc( MH_LIGHT_OF_REGENE , SC_LIGHT_OF_REGENE , SI_LIGHT_OF_REGENE , SCB_NONE ); + status->set_sc( MH_OVERED_BOOST , SC_OVERED_BOOST , SI_OVERED_BOOST , SCB_FLEE|SCB_ASPD|SCB_DEF ); add_sc(MH_STAHL_HORN, SC_STUN); - set_sc(MH_ANGRIFFS_MODUS, SC_ANGRIFFS_MODUS, SI_ANGRIFFS_MODUS, SCB_BATK | SCB_DEF | SCB_FLEE | SCB_MAXHP); - set_sc(MH_GOLDENE_FERSE, SC_GOLDENE_FERSE, SI_GOLDENE_FERSE, SCB_ASPD|SCB_MAXHP); + status->set_sc(MH_ANGRIFFS_MODUS, SC_ANGRIFFS_MODUS, SI_ANGRIFFS_MODUS, SCB_BATK | SCB_DEF | SCB_FLEE | SCB_MAXHP); + status->set_sc(MH_GOLDENE_FERSE, SC_GOLDENE_FERSE, SI_GOLDENE_FERSE, SCB_ASPD|SCB_MAXHP); add_sc( MH_STEINWAND, SC_SAFETYWALL ); - set_sc(MH_VOLCANIC_ASH, SC_VOLCANIC_ASH, SI_VOLCANIC_ASH, SCB_DEF|SCB_DEF2|SCB_HIT|SCB_BATK|SCB_FLEE); - set_sc(MH_GRANITIC_ARMOR, SC_GRANITIC_ARMOR, SI_GRANITIC_ARMOR, SCB_NONE); - set_sc(MH_MAGMA_FLOW, SC_MAGMA_FLOW, SI_MAGMA_FLOW, SCB_NONE); - set_sc(MH_PYROCLASTIC, SC_PYROCLASTIC, SI_PYROCLASTIC, SCB_BATK|SCB_ATK_ELE); + status->set_sc(MH_VOLCANIC_ASH, SC_VOLCANIC_ASH, SI_VOLCANIC_ASH, SCB_DEF|SCB_DEF2|SCB_HIT|SCB_BATK|SCB_FLEE); + status->set_sc(MH_GRANITIC_ARMOR, SC_GRANITIC_ARMOR, SI_GRANITIC_ARMOR, SCB_NONE); + status->set_sc(MH_MAGMA_FLOW, SC_MAGMA_FLOW, SI_MAGMA_FLOW, SCB_NONE); + status->set_sc(MH_PYROCLASTIC, SC_PYROCLASTIC, SI_PYROCLASTIC, SCB_BATK|SCB_ATK_ELE); add_sc(MH_LAVA_SLIDE, SC_BURNING); - set_sc(MH_NEEDLE_OF_PARALYZE, SC_NEEDLE_OF_PARALYZE, SI_NEEDLE_OF_PARALYZE, SCB_DEF2); + status->set_sc(MH_NEEDLE_OF_PARALYZE, SC_NEEDLE_OF_PARALYZE, SI_NEEDLE_OF_PARALYZE, SCB_DEF2); add_sc(MH_POISON_MIST, SC_BLIND); - set_sc(MH_PAIN_KILLER, SC_PAIN_KILLER, SI_PAIN_KILLER, SCB_ASPD); + status->set_sc(MH_PAIN_KILLER, SC_PAIN_KILLER, SI_PAIN_KILLER, SCB_ASPD); - set_sc( MH_SILENT_BREEZE , SC_SILENCE , SI_SILENT_BREEZE , SCB_NONE ); + status->set_sc( MH_SILENT_BREEZE , SC_SILENCE , SI_SILENT_BREEZE , SCB_NONE ); add_sc( MH_STYLE_CHANGE , SC_STYLE_CHANGE); - set_sc( MH_TINDER_BREAKER , SC_RG_CCONFINE_S , SI_RG_CCONFINE_S , SCB_NONE ); - set_sc( MH_TINDER_BREAKER , SC_RG_CCONFINE_M , SI_RG_CCONFINE_M , SCB_FLEE ); + status->set_sc( MH_TINDER_BREAKER , SC_RG_CCONFINE_S , SI_RG_CCONFINE_S , SCB_NONE ); + status->set_sc( MH_TINDER_BREAKER , SC_RG_CCONFINE_M , SI_RG_CCONFINE_M , SCB_FLEE ); add_sc( MER_CRASH , SC_STUN ); - set_sc( MER_PROVOKE , SC_PROVOKE , SI_PROVOKE , SCB_DEF|SCB_DEF2|SCB_BATK|SCB_WATK ); + status->set_sc( MER_PROVOKE , SC_PROVOKE , SI_PROVOKE , SCB_DEF|SCB_DEF2|SCB_BATK|SCB_WATK ); add_sc( MS_MAGNUM , SC_SUB_WEAPONPROPERTY ); add_sc( MER_SIGHT , SC_SIGHT ); - set_sc( MER_DECAGI , SC_DEC_AGI , SI_DEC_AGI , SCB_AGI|SCB_SPEED ); - set_sc( MER_MAGNIFICAT , SC_MAGNIFICAT , SI_MAGNIFICAT , SCB_REGEN ); + status->set_sc( MER_DECAGI , SC_DEC_AGI , SI_DEC_AGI , SCB_AGI|SCB_SPEED ); + status->set_sc( MER_MAGNIFICAT , SC_MAGNIFICAT , SI_MAGNIFICAT , SCB_REGEN ); add_sc( MER_LEXDIVINA , SC_SILENCE ); add_sc( MA_LANDMINE , SC_STUN ); add_sc( MA_SANDMAN , SC_SLEEP ); add_sc( MA_FREEZINGTRAP , SC_FREEZE ); - set_sc( MER_AUTOBERSERK , SC_AUTOBERSERK , SI_AUTOBERSERK , SCB_NONE ); - set_sc( ML_AUTOGUARD , SC_AUTOGUARD , SI_AUTOGUARD , SCB_NONE ); - set_sc( MS_REFLECTSHIELD , SC_REFLECTSHIELD , SI_REFLECTSHIELD , SCB_NONE ); - set_sc( ML_DEFENDER , SC_DEFENDER , SI_DEFENDER , SCB_SPEED|SCB_ASPD ); - set_sc( MS_PARRYING , SC_PARRYING , SI_PARRYING , SCB_NONE ); - set_sc( MS_BERSERK , SC_BERSERK , SI_BERSERK , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2|SCB_FLEE|SCB_SPEED|SCB_ASPD|SCB_MAXHP|SCB_REGEN ); + status->set_sc( MER_AUTOBERSERK , SC_AUTOBERSERK , SI_AUTOBERSERK , SCB_NONE ); + status->set_sc( ML_AUTOGUARD , SC_AUTOGUARD , SI_AUTOGUARD , SCB_NONE ); + status->set_sc( MS_REFLECTSHIELD , SC_REFLECTSHIELD , SI_REFLECTSHIELD , SCB_NONE ); + status->set_sc( ML_DEFENDER , SC_DEFENDER , SI_DEFENDER , SCB_SPEED|SCB_ASPD ); + status->set_sc( MS_PARRYING , SC_PARRYING , SI_PARRYING , SCB_NONE ); + status->set_sc( MS_BERSERK , SC_BERSERK , SI_BERSERK , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2|SCB_FLEE|SCB_SPEED|SCB_ASPD|SCB_MAXHP|SCB_REGEN ); add_sc( ML_SPIRALPIERCE , SC_STOP ); - set_sc( MER_QUICKEN , SC_MER_QUICKEN , SI_BLANK , SCB_ASPD ); + status->set_sc( MER_QUICKEN , SC_MER_QUICKEN , SI_BLANK , SCB_ASPD ); add_sc( ML_DEVOTION , SC_DEVOTION ); - set_sc( MER_KYRIE , SC_KYRIE , SI_KYRIE , SCB_NONE ); - set_sc( MER_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX ); - set_sc( MER_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED ); + status->set_sc( MER_KYRIE , SC_KYRIE , SI_KYRIE , SCB_NONE ); + status->set_sc( MER_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX ); + status->set_sc( MER_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED ); - set_sc( GD_LEADERSHIP , SC_LEADERSHIP , SI_BLANK , SCB_STR ); - set_sc( GD_GLORYWOUNDS , SC_GLORYWOUNDS , SI_BLANK , SCB_VIT ); - set_sc( GD_SOULCOLD , SC_SOULCOLD , SI_BLANK , SCB_AGI ); - set_sc( GD_HAWKEYES , SC_HAWKEYES , SI_BLANK , SCB_DEX ); + status->set_sc( GD_LEADERSHIP , SC_LEADERSHIP , SI_BLANK , SCB_STR ); + status->set_sc( GD_GLORYWOUNDS , SC_GLORYWOUNDS , SI_BLANK , SCB_VIT ); + status->set_sc( GD_SOULCOLD , SC_SOULCOLD , SI_BLANK , SCB_AGI ); + status->set_sc( GD_HAWKEYES , SC_HAWKEYES , SI_BLANK , SCB_DEX ); - set_sc( GD_BATTLEORDER , SC_GDSKILL_BATTLEORDER , SI_BLANK , SCB_STR|SCB_INT|SCB_DEX ); - set_sc( GD_REGENERATION , SC_GDSKILL_REGENERATION , SI_BLANK , SCB_REGEN ); + status->set_sc( GD_BATTLEORDER , SC_GDSKILL_BATTLEORDER , SI_BLANK , SCB_STR|SCB_INT|SCB_DEX ); + status->set_sc( GD_REGENERATION , SC_GDSKILL_REGENERATION , SI_BLANK , SCB_REGEN ); /** * Rune Knight **/ - set_sc( RK_ENCHANTBLADE , SC_ENCHANTBLADE , SI_ENCHANTBLADE , SCB_NONE ); - set_sc( RK_DRAGONHOWLING , SC_FEAR , SI_BLANK , SCB_FLEE|SCB_HIT ); - set_sc( RK_DEATHBOUND , SC_DEATHBOUND , SI_DEATHBOUND , SCB_NONE ); - set_sc( RK_WINDCUTTER , SC_FEAR , SI_BLANK , SCB_FLEE|SCB_HIT ); + status->set_sc( RK_ENCHANTBLADE , SC_ENCHANTBLADE , SI_ENCHANTBLADE , SCB_NONE ); + status->set_sc( RK_DRAGONHOWLING , SC_FEAR , SI_BLANK , SCB_FLEE|SCB_HIT ); + status->set_sc( RK_DEATHBOUND , SC_DEATHBOUND , SI_DEATHBOUND , SCB_NONE ); + status->set_sc( RK_WINDCUTTER , SC_FEAR , SI_BLANK , SCB_FLEE|SCB_HIT ); add_sc( RK_DRAGONBREATH , SC_BURNING ); - set_sc( RK_MILLENNIUMSHIELD , SC_MILLENNIUMSHIELD , SI_BLANK , SCB_NONE ); - set_sc( RK_REFRESH , SC_REFRESH , SI_REFRESH , SCB_NONE ); - set_sc( RK_GIANTGROWTH , SC_GIANTGROWTH , SI_GIANTGROWTH , SCB_STR ); - set_sc( RK_STONEHARDSKIN , SC_STONEHARDSKIN , SI_STONEHARDSKIN , SCB_NONE ); - set_sc( RK_VITALITYACTIVATION, SC_VITALITYACTIVATION, SI_VITALITYACTIVATION, SCB_REGEN ); - set_sc( RK_FIGHTINGSPIRIT , SC_FIGHTINGSPIRIT , SI_FIGHTINGSPIRIT , SCB_WATK|SCB_ASPD ); - set_sc( RK_ABUNDANCE , SC_ABUNDANCE , SI_ABUNDANCE , SCB_NONE ); - set_sc( RK_CRUSHSTRIKE , SC_CRUSHSTRIKE , SI_CRUSHSTRIKE , SCB_NONE ); + status->set_sc( RK_MILLENNIUMSHIELD , SC_MILLENNIUMSHIELD , SI_BLANK , SCB_NONE ); + status->set_sc( RK_REFRESH , SC_REFRESH , SI_REFRESH , SCB_NONE ); + status->set_sc( RK_GIANTGROWTH , SC_GIANTGROWTH , SI_GIANTGROWTH , SCB_STR ); + status->set_sc( RK_STONEHARDSKIN , SC_STONEHARDSKIN , SI_STONEHARDSKIN , SCB_NONE ); + status->set_sc( RK_VITALITYACTIVATION, SC_VITALITYACTIVATION, SI_VITALITYACTIVATION, SCB_REGEN ); + status->set_sc( RK_FIGHTINGSPIRIT , SC_FIGHTINGSPIRIT , SI_FIGHTINGSPIRIT , SCB_WATK|SCB_ASPD ); + status->set_sc( RK_ABUNDANCE , SC_ABUNDANCE , SI_ABUNDANCE , SCB_NONE ); + status->set_sc( RK_CRUSHSTRIKE , SC_CRUSHSTRIKE , SI_CRUSHSTRIKE , SCB_NONE ); add_sc( RK_DRAGONBREATH_WATER, SC_FROSTMISTY ); /** * GC Guillotine Cross **/ set_sc_with_vfx( GC_VENOMIMPRESS , SC_VENOMIMPRESS , SI_VENOMIMPRESS , SCB_NONE ); - set_sc( GC_POISONINGWEAPON , SC_POISONINGWEAPON , SI_POISONINGWEAPON , SCB_NONE ); - set_sc( GC_WEAPONBLOCKING , SC_WEAPONBLOCKING , SI_WEAPONBLOCKING , SCB_NONE ); - set_sc( GC_CLOAKINGEXCEED , SC_CLOAKINGEXCEED , SI_CLOAKINGEXCEED , SCB_SPEED ); - set_sc( GC_HALLUCINATIONWALK , SC_HALLUCINATIONWALK, SI_HALLUCINATIONWALK, SCB_FLEE ); - set_sc( GC_ROLLINGCUTTER , SC_ROLLINGCUTTER , SI_ROLLINGCUTTER , SCB_NONE ); + status->set_sc( GC_POISONINGWEAPON , SC_POISONINGWEAPON , SI_POISONINGWEAPON , SCB_NONE ); + status->set_sc( GC_WEAPONBLOCKING , SC_WEAPONBLOCKING , SI_WEAPONBLOCKING , SCB_NONE ); + status->set_sc( GC_CLOAKINGEXCEED , SC_CLOAKINGEXCEED , SI_CLOAKINGEXCEED , SCB_SPEED ); + status->set_sc( GC_HALLUCINATIONWALK , SC_HALLUCINATIONWALK, SI_HALLUCINATIONWALK, SCB_FLEE ); + status->set_sc( GC_ROLLINGCUTTER , SC_ROLLINGCUTTER , SI_ROLLINGCUTTER , SCB_NONE ); set_sc_with_vfx( GC_DARKCROW , SC_DARKCROW , SI_DARKCROW , SCB_NONE ); /** * Arch Bishop **/ - set_sc( AB_ADORAMUS , SC_ADORAMUS , SI_ADORAMUS , SCB_AGI|SCB_SPEED ); + status->set_sc( AB_ADORAMUS , SC_ADORAMUS , SI_ADORAMUS , SCB_AGI|SCB_SPEED ); add_sc( AB_CLEMENTIA , SC_BLESSING ); add_sc( AB_CANTO , SC_INC_AGI ); - set_sc( AB_EPICLESIS , SC_EPICLESIS , SI_EPICLESIS , SCB_MAXHP ); + status->set_sc( AB_EPICLESIS , SC_EPICLESIS , SI_EPICLESIS , SCB_MAXHP ); add_sc( AB_PRAEFATIO , SC_KYRIE ); set_sc_with_vfx( AB_ORATIO , SC_ORATIO , SI_ORATIO , SCB_NONE ); - set_sc( AB_LAUDAAGNUS , SC_LAUDAAGNUS , SI_LAUDAAGNUS , SCB_VIT ); - set_sc( AB_LAUDARAMUS , SC_LAUDARAMUS , SI_LAUDARAMUS , SCB_LUK ); - set_sc( AB_RENOVATIO , SC_RENOVATIO , SI_RENOVATIO , SCB_REGEN ); - set_sc( AB_EXPIATIO , SC_EXPIATIO , SI_EXPIATIO , SCB_ATK_ELE ); - set_sc( AB_DUPLELIGHT , SC_DUPLELIGHT , SI_DUPLELIGHT , SCB_NONE ); - set_sc( AB_SECRAMENT , SC_SECRAMENT , SI_SECRAMENT , SCB_NONE ); - set_sc( AB_OFFERTORIUM , SC_OFFERTORIUM , SI_OFFERTORIUM , SCB_NONE ); + status->set_sc( AB_LAUDAAGNUS , SC_LAUDAAGNUS , SI_LAUDAAGNUS , SCB_VIT ); + status->set_sc( AB_LAUDARAMUS , SC_LAUDARAMUS , SI_LAUDARAMUS , SCB_LUK ); + status->set_sc( AB_RENOVATIO , SC_RENOVATIO , SI_RENOVATIO , SCB_REGEN ); + status->set_sc( AB_EXPIATIO , SC_EXPIATIO , SI_EXPIATIO , SCB_ATK_ELE ); + status->set_sc( AB_DUPLELIGHT , SC_DUPLELIGHT , SI_DUPLELIGHT , SCB_NONE ); + status->set_sc( AB_SECRAMENT , SC_SECRAMENT , SI_SECRAMENT , SCB_NONE ); + status->set_sc( AB_OFFERTORIUM , SC_OFFERTORIUM , SI_OFFERTORIUM , SCB_NONE ); /** * Warlock **/ add_sc( WL_WHITEIMPRISON , SC_WHITEIMPRISON ); set_sc_with_vfx( WL_FROSTMISTY , SC_FROSTMISTY , SI_FROSTMISTY , SCB_ASPD|SCB_SPEED|SCB_DEF ); - set_sc( WL_MARSHOFABYSS , SC_MARSHOFABYSS , SI_MARSHOFABYSS , SCB_SPEED|SCB_FLEE|SCB_AGI|SCB_DEX ); - set_sc(WL_RECOGNIZEDSPELL , SC_RECOGNIZEDSPELL , SI_RECOGNIZEDSPELL , SCB_MATK); - set_sc( WL_STASIS , SC_STASIS , SI_STASIS , SCB_NONE ); - set_sc( WL_TELEKINESIS_INTENSE, SC_TELEKINESIS_INTENSE , SI_TELEKINESIS_INTENSE , SCB_MATK ); + status->set_sc( WL_MARSHOFABYSS , SC_MARSHOFABYSS , SI_MARSHOFABYSS , SCB_SPEED|SCB_FLEE|SCB_AGI|SCB_DEX ); + status->set_sc(WL_RECOGNIZEDSPELL , SC_RECOGNIZEDSPELL , SI_RECOGNIZEDSPELL , SCB_MATK); + status->set_sc( WL_STASIS , SC_STASIS , SI_STASIS , SCB_NONE ); + status->set_sc( WL_TELEKINESIS_INTENSE, SC_TELEKINESIS_INTENSE , SI_TELEKINESIS_INTENSE , SCB_MATK ); /** * Ranger **/ - set_sc( RA_FEARBREEZE , SC_FEARBREEZE , SI_FEARBREEZE , SCB_NONE ); - set_sc( RA_ELECTRICSHOCKER , SC_ELECTRICSHOCKER , SI_ELECTRICSHOCKER , SCB_NONE ); - set_sc( RA_WUGDASH , SC_WUGDASH , SI_WUGDASH , SCB_SPEED ); - set_sc( RA_CAMOUFLAGE , SC_CAMOUFLAGE , SI_CAMOUFLAGE , SCB_SPEED ); + status->set_sc( RA_FEARBREEZE , SC_FEARBREEZE , SI_FEARBREEZE , SCB_NONE ); + status->set_sc( RA_ELECTRICSHOCKER , SC_ELECTRICSHOCKER , SI_ELECTRICSHOCKER , SCB_NONE ); + status->set_sc( RA_WUGDASH , SC_WUGDASH , SI_WUGDASH , SCB_SPEED ); + status->set_sc( RA_CAMOUFLAGE , SC_CAMOUFLAGE , SI_CAMOUFLAGE , SCB_SPEED ); add_sc( RA_MAGENTATRAP , SC_ARMOR_PROPERTY ); add_sc( RA_COBALTTRAP , SC_ARMOR_PROPERTY ); add_sc( RA_MAIZETRAP , SC_ARMOR_PROPERTY ); add_sc( RA_VERDURETRAP , SC_ARMOR_PROPERTY ); add_sc( RA_FIRINGTRAP , SC_BURNING ); add_sc( RA_ICEBOUNDTRAP , SC_FROSTMISTY ); - set_sc( RA_UNLIMIT , SC_UNLIMIT , SI_UNLIMIT , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2 ); + status->set_sc( RA_UNLIMIT , SC_UNLIMIT , SI_UNLIMIT , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2 ); /** * Mechanic **/ - set_sc( NC_ACCELERATION , SC_ACCELERATION , SI_ACCELERATION , SCB_SPEED ); - set_sc( NC_HOVERING , SC_HOVERING , SI_HOVERING , SCB_SPEED ); - set_sc( NC_SHAPESHIFT , SC_SHAPESHIFT , SI_SHAPESHIFT , SCB_DEF_ELE ); - set_sc( NC_INFRAREDSCAN , SC_INFRAREDSCAN , SI_INFRAREDSCAN , SCB_FLEE ); - set_sc( NC_ANALYZE , SC_ANALYZE , SI_ANALYZE , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2 ); - set_sc( NC_MAGNETICFIELD , SC_MAGNETICFIELD , SI_MAGNETICFIELD , SCB_NONE ); - set_sc( NC_NEUTRALBARRIER , SC_NEUTRALBARRIER , SI_NEUTRALBARRIER , SCB_DEF|SCB_MDEF ); - set_sc( NC_STEALTHFIELD , SC_STEALTHFIELD , SI_STEALTHFIELD , SCB_NONE ); + status->set_sc( NC_ACCELERATION , SC_ACCELERATION , SI_ACCELERATION , SCB_SPEED ); + status->set_sc( NC_HOVERING , SC_HOVERING , SI_HOVERING , SCB_SPEED ); + status->set_sc( NC_SHAPESHIFT , SC_SHAPESHIFT , SI_SHAPESHIFT , SCB_DEF_ELE ); + status->set_sc( NC_INFRAREDSCAN , SC_INFRAREDSCAN , SI_INFRAREDSCAN , SCB_FLEE ); + status->set_sc( NC_ANALYZE , SC_ANALYZE , SI_ANALYZE , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2 ); + status->set_sc( NC_MAGNETICFIELD , SC_MAGNETICFIELD , SI_MAGNETICFIELD , SCB_NONE ); + status->set_sc( NC_NEUTRALBARRIER , SC_NEUTRALBARRIER , SI_NEUTRALBARRIER , SCB_DEF|SCB_MDEF ); + status->set_sc( NC_STEALTHFIELD , SC_STEALTHFIELD , SI_STEALTHFIELD , SCB_NONE ); /** * Royal Guard **/ - set_sc( LG_REFLECTDAMAGE , SC_LG_REFLECTDAMAGE , SI_LG_REFLECTDAMAGE, SCB_NONE ); - set_sc( LG_FORCEOFVANGUARD , SC_FORCEOFVANGUARD , SI_FORCEOFVANGUARD , SCB_MAXHP ); - set_sc( LG_EXEEDBREAK , SC_EXEEDBREAK , SI_EXEEDBREAK , SCB_NONE ); - set_sc( LG_PRESTIGE , SC_PRESTIGE , SI_PRESTIGE , SCB_DEF ); - set_sc( LG_BANDING , SC_BANDING , SI_BANDING , SCB_DEF2|SCB_WATK );// Renewal: atk2 & def2 - set_sc( LG_PIETY , SC_BENEDICTIO , SI_BENEDICTIO , SCB_DEF_ELE ); - set_sc( LG_EARTHDRIVE , SC_EARTHDRIVE , SI_EARTHDRIVE , SCB_DEF|SCB_ASPD ); - set_sc( LG_INSPIRATION , SC_INSPIRATION , SI_INSPIRATION , SCB_MAXHP|SCB_WATK|SCB_HIT|SCB_VIT|SCB_AGI|SCB_STR|SCB_DEX|SCB_INT|SCB_LUK); - set_sc( LG_KINGS_GRACE , SC_KINGS_GRACE , SI_KINGS_GRACE , SCB_NONE ); + status->set_sc( LG_REFLECTDAMAGE , SC_LG_REFLECTDAMAGE , SI_LG_REFLECTDAMAGE, SCB_NONE ); + status->set_sc( LG_FORCEOFVANGUARD , SC_FORCEOFVANGUARD , SI_FORCEOFVANGUARD , SCB_MAXHP ); + status->set_sc( LG_EXEEDBREAK , SC_EXEEDBREAK , SI_EXEEDBREAK , SCB_NONE ); + status->set_sc( LG_PRESTIGE , SC_PRESTIGE , SI_PRESTIGE , SCB_DEF ); + status->set_sc( LG_BANDING , SC_BANDING , SI_BANDING , SCB_DEF2|SCB_WATK );// Renewal: atk2 & def2 + status->set_sc( LG_PIETY , SC_BENEDICTIO , SI_BENEDICTIO , SCB_DEF_ELE ); + status->set_sc( LG_EARTHDRIVE , SC_EARTHDRIVE , SI_EARTHDRIVE , SCB_DEF|SCB_ASPD ); + status->set_sc( LG_INSPIRATION , SC_INSPIRATION , SI_INSPIRATION , SCB_MAXHP|SCB_WATK|SCB_HIT|SCB_VIT|SCB_AGI|SCB_STR|SCB_DEX|SCB_INT|SCB_LUK); + status->set_sc( LG_KINGS_GRACE , SC_KINGS_GRACE , SI_KINGS_GRACE , SCB_NONE ); /** * Shadow Chaser **/ - set_sc( SC_REPRODUCE , SC__REPRODUCE , SI_REPRODUCE , SCB_NONE ); - set_sc( SC_AUTOSHADOWSPELL , SC__AUTOSHADOWSPELL, SI_AUTOSHADOWSPELL , SCB_NONE ); - set_sc( SC_SHADOWFORM , SC__SHADOWFORM , SI_SHADOWFORM , SCB_NONE ); - set_sc( SC_BODYPAINT , SC__BODYPAINT , SI_BODYPAINT , SCB_ASPD ); - set_sc( SC_INVISIBILITY , SC__INVISIBILITY , SI_INVISIBILITY , SCB_ASPD|SCB_CRI|SCB_ATK_ELE ); - set_sc( SC_DEADLYINFECT , SC__DEADLYINFECT , SI_DEADLYINFECT , SCB_NONE ); - set_sc( SC_ENERVATION , SC__ENERVATION , SI_ENERVATION , SCB_BATK ); - set_sc( SC_GROOMY , SC__GROOMY , SI_GROOMY , SCB_ASPD|SCB_HIT|SCB_SPEED ); - set_sc( SC_IGNORANCE , SC__IGNORANCE , SI_IGNORANCE , SCB_NONE ); - set_sc( SC_LAZINESS , SC__LAZINESS , SI_LAZINESS , SCB_FLEE ); - set_sc( SC_UNLUCKY , SC__UNLUCKY , SI_UNLUCKY , SCB_CRI|SCB_FLEE2 ); - set_sc( SC_WEAKNESS , SC__WEAKNESS , SI_WEAKNESS , SCB_FLEE2|SCB_MAXHP ); - set_sc( SC_STRIPACCESSARY , SC__STRIPACCESSARY , SI_STRIPACCESSARY , SCB_DEX|SCB_INT|SCB_LUK ); + status->set_sc( SC_REPRODUCE , SC__REPRODUCE , SI_REPRODUCE , SCB_NONE ); + status->set_sc( SC_AUTOSHADOWSPELL , SC__AUTOSHADOWSPELL, SI_AUTOSHADOWSPELL , SCB_NONE ); + status->set_sc( SC_SHADOWFORM , SC__SHADOWFORM , SI_SHADOWFORM , SCB_NONE ); + status->set_sc( SC_BODYPAINT , SC__BODYPAINT , SI_BODYPAINT , SCB_ASPD ); + status->set_sc( SC_INVISIBILITY , SC__INVISIBILITY , SI_INVISIBILITY , SCB_ASPD|SCB_CRI|SCB_ATK_ELE ); + status->set_sc( SC_DEADLYINFECT , SC__DEADLYINFECT , SI_DEADLYINFECT , SCB_NONE ); + status->set_sc( SC_ENERVATION , SC__ENERVATION , SI_ENERVATION , SCB_BATK ); + status->set_sc( SC_GROOMY , SC__GROOMY , SI_GROOMY , SCB_ASPD|SCB_HIT|SCB_SPEED ); + status->set_sc( SC_IGNORANCE , SC__IGNORANCE , SI_IGNORANCE , SCB_NONE ); + status->set_sc( SC_LAZINESS , SC__LAZINESS , SI_LAZINESS , SCB_FLEE ); + status->set_sc( SC_UNLUCKY , SC__UNLUCKY , SI_UNLUCKY , SCB_CRI|SCB_FLEE2 ); + status->set_sc( SC_WEAKNESS , SC__WEAKNESS , SI_WEAKNESS , SCB_FLEE2|SCB_MAXHP ); + status->set_sc( SC_STRIPACCESSARY , SC__STRIPACCESSARY , SI_STRIPACCESSARY , SCB_DEX|SCB_INT|SCB_LUK ); set_sc_with_vfx( SC_MANHOLE , SC__MANHOLE , SI_MANHOLE , SCB_NONE ); add_sc( SC_CHAOSPANIC , SC__CHAOS ); add_sc( SC_MAELSTROM , SC__MAELSTROM ); @@ -656,113 +657,113 @@ void initChangeTables(void) { **/ add_sc( SR_DRAGONCOMBO , SC_STUN ); add_sc( SR_EARTHSHAKER , SC_STUN ); - set_sc( SR_FALLENEMPIRE , SC_FALLENEMPIRE , SI_FALLENEMPIRE , SCB_NONE ); - set_sc( SR_CRESCENTELBOW , SC_CRESCENTELBOW , SI_CRESCENTELBOW , SCB_NONE ); + status->set_sc( SR_FALLENEMPIRE , SC_FALLENEMPIRE , SI_FALLENEMPIRE , SCB_NONE ); + status->set_sc( SR_CRESCENTELBOW , SC_CRESCENTELBOW , SI_CRESCENTELBOW , SCB_NONE ); set_sc_with_vfx( SR_CURSEDCIRCLE , SC_CURSEDCIRCLE_TARGET, SI_CURSEDCIRCLE_TARGET , SCB_NONE ); - set_sc( SR_LIGHTNINGWALK , SC_LIGHTNINGWALK , SI_LIGHTNINGWALK , SCB_NONE ); - set_sc( SR_RAISINGDRAGON , SC_RAISINGDRAGON , SI_RAISINGDRAGON , SCB_REGEN|SCB_MAXHP|SCB_MAXSP ); - set_sc( SR_GENTLETOUCH_ENERGYGAIN, SC_GENTLETOUCH_ENERGYGAIN , SI_GENTLETOUCH_ENERGYGAIN, SCB_NONE ); - set_sc( SR_GENTLETOUCH_CHANGE , SC_GENTLETOUCH_CHANGE , SI_GENTLETOUCH_CHANGE , SCB_ASPD|SCB_MDEF|SCB_MAXHP ); - set_sc( SR_GENTLETOUCH_REVITALIZE, SC_GENTLETOUCH_REVITALIZE , SI_GENTLETOUCH_REVITALIZE, SCB_MAXHP|SCB_DEF2|SCB_REGEN ); - set_sc( SR_FLASHCOMBO , SC_FLASHCOMBO , SI_FLASHCOMBO , SCB_WATK ); + status->set_sc( SR_LIGHTNINGWALK , SC_LIGHTNINGWALK , SI_LIGHTNINGWALK , SCB_NONE ); + status->set_sc( SR_RAISINGDRAGON , SC_RAISINGDRAGON , SI_RAISINGDRAGON , SCB_REGEN|SCB_MAXHP|SCB_MAXSP ); + status->set_sc( SR_GENTLETOUCH_ENERGYGAIN, SC_GENTLETOUCH_ENERGYGAIN , SI_GENTLETOUCH_ENERGYGAIN, SCB_NONE ); + status->set_sc( SR_GENTLETOUCH_CHANGE , SC_GENTLETOUCH_CHANGE , SI_GENTLETOUCH_CHANGE , SCB_ASPD|SCB_MDEF|SCB_MAXHP ); + status->set_sc( SR_GENTLETOUCH_REVITALIZE, SC_GENTLETOUCH_REVITALIZE , SI_GENTLETOUCH_REVITALIZE, SCB_MAXHP|SCB_DEF2|SCB_REGEN ); + status->set_sc( SR_FLASHCOMBO , SC_FLASHCOMBO , SI_FLASHCOMBO , SCB_WATK ); /** * Wanderer / Minstrel **/ - set_sc( WA_SWING_DANCE , SC_SWING , SI_SWINGDANCE , SCB_SPEED|SCB_ASPD ); - set_sc( WA_SYMPHONY_OF_LOVER , SC_SYMPHONY_LOVE , SI_SYMPHONYOFLOVERS , SCB_MDEF ); - set_sc( WA_MOONLIT_SERENADE , SC_MOONLIT_SERENADE , SI_MOONLITSERENADE , SCB_MATK ); - set_sc( MI_RUSH_WINDMILL , SC_RUSH_WINDMILL , SI_RUSHWINDMILL , SCB_WATK ); - set_sc( MI_ECHOSONG , SC_ECHOSONG , SI_ECHOSONG , SCB_DEF2 ); - set_sc( MI_HARMONIZE , SC_HARMONIZE , SI_HARMONIZE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); + status->set_sc( WA_SWING_DANCE , SC_SWING , SI_SWINGDANCE , SCB_SPEED|SCB_ASPD ); + status->set_sc( WA_SYMPHONY_OF_LOVER , SC_SYMPHONY_LOVE , SI_SYMPHONYOFLOVERS , SCB_MDEF ); + status->set_sc( WA_MOONLIT_SERENADE , SC_MOONLIT_SERENADE , SI_MOONLITSERENADE , SCB_MATK ); + status->set_sc( MI_RUSH_WINDMILL , SC_RUSH_WINDMILL , SI_RUSHWINDMILL , SCB_WATK ); + status->set_sc( MI_ECHOSONG , SC_ECHOSONG , SI_ECHOSONG , SCB_DEF2 ); + status->set_sc( MI_HARMONIZE , SC_HARMONIZE , SI_HARMONIZE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); set_sc_with_vfx(WM_POEMOFNETHERWORLD, SC_NETHERWORLD , SI_NETHERWORLD , SCB_NONE); set_sc_with_vfx( WM_VOICEOFSIREN , SC_SIREN , SI_SIREN , SCB_NONE ); set_sc_with_vfx( WM_LULLABY_DEEPSLEEP , SC_DEEP_SLEEP , SI_DEEPSLEEP , SCB_NONE ); - set_sc( WM_SIRCLEOFNATURE , SC_SIRCLEOFNATURE , SI_SIRCLEOFNATURE , SCB_NONE ); - set_sc( WM_GLOOMYDAY , SC_GLOOMYDAY , SI_GLOOMYDAY , SCB_FLEE|SCB_ASPD ); - set_sc( WM_SONG_OF_MANA , SC_SONG_OF_MANA , SI_SONG_OF_MANA , SCB_NONE ); - set_sc( WM_DANCE_WITH_WUG , SC_DANCE_WITH_WUG , SI_DANCEWITHWUG , SCB_ASPD ); - set_sc( WM_SATURDAY_NIGHT_FEVER , SC_SATURDAY_NIGHT_FEVER , SI_SATURDAYNIGHTFEVER , SCB_BATK|SCB_DEF|SCB_FLEE|SCB_REGEN ); - set_sc( WM_LERADS_DEW , SC_LERADS_DEW , SI_LERADSDEW , SCB_MAXHP ); - set_sc( WM_MELODYOFSINK , SC_MELODYOFSINK , SI_MELODYOFSINK , SCB_INT ); - set_sc( WM_BEYOND_OF_WARCRY , SC_BEYOND_OF_WARCRY , SI_WARCRYOFBEYOND , SCB_STR|SCB_CRI|SCB_MAXHP ); - set_sc( WM_UNLIMITED_HUMMING_VOICE, SC_UNLIMITED_HUMMING_VOICE, SI_UNLIMITEDHUMMINGVOICE, SCB_NONE ); - set_sc( WM_FRIGG_SONG , SC_FRIGG_SONG , SI_FRIGG_SONG , SCB_MAXHP ); + status->set_sc( WM_SIRCLEOFNATURE , SC_SIRCLEOFNATURE , SI_SIRCLEOFNATURE , SCB_NONE ); + status->set_sc( WM_GLOOMYDAY , SC_GLOOMYDAY , SI_GLOOMYDAY , SCB_FLEE|SCB_ASPD ); + status->set_sc( WM_SONG_OF_MANA , SC_SONG_OF_MANA , SI_SONG_OF_MANA , SCB_NONE ); + status->set_sc( WM_DANCE_WITH_WUG , SC_DANCE_WITH_WUG , SI_DANCEWITHWUG , SCB_ASPD ); + status->set_sc( WM_SATURDAY_NIGHT_FEVER , SC_SATURDAY_NIGHT_FEVER , SI_SATURDAYNIGHTFEVER , SCB_BATK|SCB_DEF|SCB_FLEE|SCB_REGEN ); + status->set_sc( WM_LERADS_DEW , SC_LERADS_DEW , SI_LERADSDEW , SCB_MAXHP ); + status->set_sc( WM_MELODYOFSINK , SC_MELODYOFSINK , SI_MELODYOFSINK , SCB_INT ); + status->set_sc( WM_BEYOND_OF_WARCRY , SC_BEYOND_OF_WARCRY , SI_WARCRYOFBEYOND , SCB_STR|SCB_CRI|SCB_MAXHP ); + status->set_sc( WM_UNLIMITED_HUMMING_VOICE, SC_UNLIMITED_HUMMING_VOICE, SI_UNLIMITEDHUMMINGVOICE, SCB_NONE ); + status->set_sc( WM_FRIGG_SONG , SC_FRIGG_SONG , SI_FRIGG_SONG , SCB_MAXHP ); /** * Sorcerer **/ - set_sc( SO_FIREWALK , SC_PROPERTYWALK , SI_PROPERTYWALK , SCB_NONE ); - set_sc( SO_ELECTRICWALK , SC_PROPERTYWALK , SI_PROPERTYWALK , SCB_NONE ); - set_sc( SO_SPELLFIST , SC_SPELLFIST , SI_SPELLFIST , SCB_NONE ); + status->set_sc( SO_FIREWALK , SC_PROPERTYWALK , SI_PROPERTYWALK , SCB_NONE ); + status->set_sc( SO_ELECTRICWALK , SC_PROPERTYWALK , SI_PROPERTYWALK , SCB_NONE ); + status->set_sc( SO_SPELLFIST , SC_SPELLFIST , SI_SPELLFIST , SCB_NONE ); set_sc_with_vfx( SO_DIAMONDDUST , SC_COLD , SI_COLD , SCB_NONE ); // it does show the snow icon on mobs but doesn't affect it. - set_sc( SO_CLOUD_KILL , SC_POISON , SI_CLOUDKILL , SCB_NONE ); - set_sc( SO_STRIKING , SC_STRIKING , SI_STRIKING , SCB_WATK|SCB_CRI ); + status->set_sc( SO_CLOUD_KILL , SC_POISON , SI_CLOUDKILL , SCB_NONE ); + status->set_sc( SO_STRIKING , SC_STRIKING , SI_STRIKING , SCB_WATK|SCB_CRI ); add_sc( SO_WARMER , SC_WARMER ); // At the moment, no icon on officials - set_sc( SO_VACUUM_EXTREME , SC_VACUUM_EXTREME , SI_VACUUM_EXTREME , SCB_NONE ); - set_sc( SO_ARRULLO , SC_DEEP_SLEEP , SI_DEEPSLEEP , SCB_NONE ); - set_sc( SO_FIRE_INSIGNIA , SC_FIRE_INSIGNIA , SI_FIRE_INSIGNIA , SCB_MATK | SCB_BATK | SCB_WATK | SCB_ATK_ELE | SCB_REGEN ); - set_sc( SO_WATER_INSIGNIA , SC_WATER_INSIGNIA , SI_WATER_INSIGNIA , SCB_WATK | SCB_ATK_ELE | SCB_REGEN ); - set_sc( SO_WIND_INSIGNIA , SC_WIND_INSIGNIA , SI_WIND_INSIGNIA , SCB_WATK | SCB_ATK_ELE | SCB_REGEN ); - set_sc( SO_EARTH_INSIGNIA , SC_EARTH_INSIGNIA , SI_EARTH_INSIGNIA , SCB_MDEF|SCB_DEF|SCB_MAXHP|SCB_MAXSP|SCB_WATK | SCB_ATK_ELE | SCB_REGEN ); + status->set_sc( SO_VACUUM_EXTREME , SC_VACUUM_EXTREME , SI_VACUUM_EXTREME , SCB_NONE ); + status->set_sc( SO_ARRULLO , SC_DEEP_SLEEP , SI_DEEPSLEEP , SCB_NONE ); + status->set_sc( SO_FIRE_INSIGNIA , SC_FIRE_INSIGNIA , SI_FIRE_INSIGNIA , SCB_MATK | SCB_BATK | SCB_WATK | SCB_ATK_ELE | SCB_REGEN ); + status->set_sc( SO_WATER_INSIGNIA , SC_WATER_INSIGNIA , SI_WATER_INSIGNIA , SCB_WATK | SCB_ATK_ELE | SCB_REGEN ); + status->set_sc( SO_WIND_INSIGNIA , SC_WIND_INSIGNIA , SI_WIND_INSIGNIA , SCB_WATK | SCB_ATK_ELE | SCB_REGEN ); + status->set_sc( SO_EARTH_INSIGNIA , SC_EARTH_INSIGNIA , SI_EARTH_INSIGNIA , SCB_MDEF|SCB_DEF|SCB_MAXHP|SCB_MAXSP|SCB_WATK | SCB_ATK_ELE | SCB_REGEN ); add_sc( SO_ELEMENTAL_SHIELD , SC_SAFETYWALL ); /** * Genetic **/ - set_sc( GN_CARTBOOST , SC_GN_CARTBOOST, SI_CARTSBOOST , SCB_SPEED ); - set_sc( GN_THORNS_TRAP , SC_THORNS_TRAP , SI_THORNTRAP , SCB_NONE ); + status->set_sc( GN_CARTBOOST , SC_GN_CARTBOOST, SI_CARTSBOOST , SCB_SPEED ); + status->set_sc( GN_THORNS_TRAP , SC_THORNS_TRAP , SI_THORNTRAP , SCB_NONE ); set_sc_with_vfx( GN_BLOOD_SUCKER , SC_BLOOD_SUCKER , SI_BLOODSUCKER , SCB_NONE ); - set_sc( GN_WALLOFTHORN , SC_STOP , SI_BLANK , SCB_NONE ); - set_sc( GN_FIRE_EXPANSION_SMOKE_POWDER, SC_FIRE_EXPANSION_SMOKE_POWDER , SI_FIRE_EXPANSION_SMOKE_POWDER, SCB_NONE ); - set_sc( GN_FIRE_EXPANSION_TEAR_GAS , SC_FIRE_EXPANSION_TEAR_GAS , SI_FIRE_EXPANSION_TEAR_GAS , SCB_NONE ); - set_sc( GN_MANDRAGORA , SC_MANDRAGORA , SI_MANDRAGORA , SCB_INT ); + status->set_sc( GN_WALLOFTHORN , SC_STOP , SI_BLANK , SCB_NONE ); + status->set_sc( GN_FIRE_EXPANSION_SMOKE_POWDER, SC_FIRE_EXPANSION_SMOKE_POWDER , SI_FIRE_EXPANSION_SMOKE_POWDER, SCB_NONE ); + status->set_sc( GN_FIRE_EXPANSION_TEAR_GAS , SC_FIRE_EXPANSION_TEAR_GAS , SI_FIRE_EXPANSION_TEAR_GAS , SCB_NONE ); + status->set_sc( GN_MANDRAGORA , SC_MANDRAGORA , SI_MANDRAGORA , SCB_INT ); // Elemental Spirit summoner's 'side' status changes. - set_sc( EL_CIRCLE_OF_FIRE , SC_CIRCLE_OF_FIRE_OPTION, SI_CIRCLE_OF_FIRE_OPTION, SCB_NONE ); - set_sc( EL_FIRE_CLOAK , SC_FIRE_CLOAK_OPTION , SI_FIRE_CLOAK_OPTION , SCB_ALL ); - set_sc( EL_WATER_SCREEN , SC_WATER_SCREEN_OPTION , SI_WATER_SCREEN_OPTION , SCB_NONE ); - set_sc( EL_WATER_DROP , SC_WATER_DROP_OPTION , SI_WATER_DROP_OPTION , SCB_ALL ); - set_sc( EL_WATER_BARRIER , SC_WATER_BARRIER , SI_WATER_BARRIER , SCB_WATK|SCB_FLEE ); - set_sc( EL_WIND_STEP , SC_WIND_STEP_OPTION , SI_WIND_STEP_OPTION , SCB_SPEED|SCB_FLEE ); - set_sc( EL_WIND_CURTAIN , SC_WIND_CURTAIN_OPTION , SI_WIND_CURTAIN_OPTION , SCB_ALL ); - set_sc( EL_ZEPHYR , SC_ZEPHYR , SI_ZEPHYR , SCB_FLEE ); - set_sc( EL_SOLID_SKIN , SC_SOLID_SKIN_OPTION , SI_SOLID_SKIN_OPTION , SCB_DEF|SCB_MAXHP ); - set_sc( EL_STONE_SHIELD , SC_STONE_SHIELD_OPTION , SI_STONE_SHIELD_OPTION , SCB_ALL ); - set_sc( EL_POWER_OF_GAIA , SC_POWER_OF_GAIA , SI_POWER_OF_GAIA , SCB_MAXHP|SCB_DEF|SCB_SPEED ); - set_sc( EL_PYROTECHNIC , SC_PYROTECHNIC_OPTION , SI_PYROTECHNIC_OPTION , SCB_WATK ); - set_sc( EL_HEATER , SC_HEATER_OPTION , SI_HEATER_OPTION , SCB_WATK ); - set_sc( EL_TROPIC , SC_TROPIC_OPTION , SI_TROPIC_OPTION , SCB_WATK ); - set_sc( EL_AQUAPLAY , SC_AQUAPLAY_OPTION , SI_AQUAPLAY_OPTION , SCB_MATK ); - set_sc( EL_COOLER , SC_COOLER_OPTION , SI_COOLER_OPTION , SCB_MATK ); - set_sc( EL_CHILLY_AIR , SC_CHILLY_AIR_OPTION , SI_CHILLY_AIR_OPTION , SCB_MATK ); - set_sc( EL_GUST , SC_GUST_OPTION , SI_GUST_OPTION , SCB_ASPD ); - set_sc( EL_BLAST , SC_BLAST_OPTION , SI_BLAST_OPTION , SCB_ASPD ); - set_sc( EL_WILD_STORM , SC_WILD_STORM_OPTION , SI_WILD_STORM_OPTION , SCB_ASPD ); - set_sc( EL_PETROLOGY , SC_PETROLOGY_OPTION , SI_PETROLOGY_OPTION , SCB_MAXHP ); - set_sc( EL_CURSED_SOIL , SC_CURSED_SOIL_OPTION , SI_CURSED_SOIL_OPTION , SCB_MAXHP ); - set_sc( EL_UPHEAVAL , SC_UPHEAVAL_OPTION , SI_UPHEAVAL_OPTION , SCB_MAXHP ); - set_sc( EL_TIDAL_WEAPON , SC_TIDAL_WEAPON_OPTION , SI_TIDAL_WEAPON_OPTION , SCB_ALL ); - set_sc( EL_ROCK_CRUSHER , SC_ROCK_CRUSHER , SI_ROCK_CRUSHER , SCB_DEF ); - set_sc( EL_ROCK_CRUSHER_ATK, SC_ROCK_CRUSHER_ATK , SI_ROCK_CRUSHER_ATK , SCB_SPEED ); + status->set_sc( EL_CIRCLE_OF_FIRE , SC_CIRCLE_OF_FIRE_OPTION, SI_CIRCLE_OF_FIRE_OPTION, SCB_NONE ); + status->set_sc( EL_FIRE_CLOAK , SC_FIRE_CLOAK_OPTION , SI_FIRE_CLOAK_OPTION , SCB_ALL ); + status->set_sc( EL_WATER_SCREEN , SC_WATER_SCREEN_OPTION , SI_WATER_SCREEN_OPTION , SCB_NONE ); + status->set_sc( EL_WATER_DROP , SC_WATER_DROP_OPTION , SI_WATER_DROP_OPTION , SCB_ALL ); + status->set_sc( EL_WATER_BARRIER , SC_WATER_BARRIER , SI_WATER_BARRIER , SCB_WATK|SCB_FLEE ); + status->set_sc( EL_WIND_STEP , SC_WIND_STEP_OPTION , SI_WIND_STEP_OPTION , SCB_SPEED|SCB_FLEE ); + status->set_sc( EL_WIND_CURTAIN , SC_WIND_CURTAIN_OPTION , SI_WIND_CURTAIN_OPTION , SCB_ALL ); + status->set_sc( EL_ZEPHYR , SC_ZEPHYR , SI_ZEPHYR , SCB_FLEE ); + status->set_sc( EL_SOLID_SKIN , SC_SOLID_SKIN_OPTION , SI_SOLID_SKIN_OPTION , SCB_DEF|SCB_MAXHP ); + status->set_sc( EL_STONE_SHIELD , SC_STONE_SHIELD_OPTION , SI_STONE_SHIELD_OPTION , SCB_ALL ); + status->set_sc( EL_POWER_OF_GAIA , SC_POWER_OF_GAIA , SI_POWER_OF_GAIA , SCB_MAXHP|SCB_DEF|SCB_SPEED ); + status->set_sc( EL_PYROTECHNIC , SC_PYROTECHNIC_OPTION , SI_PYROTECHNIC_OPTION , SCB_WATK ); + status->set_sc( EL_HEATER , SC_HEATER_OPTION , SI_HEATER_OPTION , SCB_WATK ); + status->set_sc( EL_TROPIC , SC_TROPIC_OPTION , SI_TROPIC_OPTION , SCB_WATK ); + status->set_sc( EL_AQUAPLAY , SC_AQUAPLAY_OPTION , SI_AQUAPLAY_OPTION , SCB_MATK ); + status->set_sc( EL_COOLER , SC_COOLER_OPTION , SI_COOLER_OPTION , SCB_MATK ); + status->set_sc( EL_CHILLY_AIR , SC_CHILLY_AIR_OPTION , SI_CHILLY_AIR_OPTION , SCB_MATK ); + status->set_sc( EL_GUST , SC_GUST_OPTION , SI_GUST_OPTION , SCB_ASPD ); + status->set_sc( EL_BLAST , SC_BLAST_OPTION , SI_BLAST_OPTION , SCB_ASPD ); + status->set_sc( EL_WILD_STORM , SC_WILD_STORM_OPTION , SI_WILD_STORM_OPTION , SCB_ASPD ); + status->set_sc( EL_PETROLOGY , SC_PETROLOGY_OPTION , SI_PETROLOGY_OPTION , SCB_MAXHP ); + status->set_sc( EL_CURSED_SOIL , SC_CURSED_SOIL_OPTION , SI_CURSED_SOIL_OPTION , SCB_MAXHP ); + status->set_sc( EL_UPHEAVAL , SC_UPHEAVAL_OPTION , SI_UPHEAVAL_OPTION , SCB_MAXHP ); + status->set_sc( EL_TIDAL_WEAPON , SC_TIDAL_WEAPON_OPTION , SI_TIDAL_WEAPON_OPTION , SCB_ALL ); + status->set_sc( EL_ROCK_CRUSHER , SC_ROCK_CRUSHER , SI_ROCK_CRUSHER , SCB_DEF ); + status->set_sc( EL_ROCK_CRUSHER_ATK, SC_ROCK_CRUSHER_ATK , SI_ROCK_CRUSHER_ATK , SCB_SPEED ); add_sc( KO_YAMIKUMO , SC_HIDING ); set_sc_with_vfx( KO_JYUMONJIKIRI , SC_KO_JYUMONJIKIRI , SI_KO_JYUMONJIKIRI , SCB_NONE ); add_sc( KO_MAKIBISHI , SC_STUN ); - set_sc( KO_MEIKYOUSISUI , SC_MEIKYOUSISUI , SI_MEIKYOUSISUI , SCB_NONE ); - set_sc( KO_KYOUGAKU , SC_KYOUGAKU , SI_KYOUGAKU , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); + status->set_sc( KO_MEIKYOUSISUI , SC_MEIKYOUSISUI , SI_MEIKYOUSISUI , SCB_NONE ); + status->set_sc( KO_KYOUGAKU , SC_KYOUGAKU , SI_KYOUGAKU , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); add_sc( KO_JYUSATSU , SC_CURSE ); - set_sc( KO_ZENKAI , SC_ZENKAI , SI_ZENKAI , SCB_NONE ); - set_sc( KO_IZAYOI , SC_IZAYOI , SI_IZAYOI , SCB_MATK ); - set_sc( KG_KYOMU , SC_KYOMU , SI_KYOMU , SCB_NONE ); - set_sc( KG_KAGEMUSYA , SC_KAGEMUSYA , SI_KAGEMUSYA , SCB_NONE ); - set_sc( KG_KAGEHUMI , SC_KG_KAGEHUMI , SI_KG_KAGEHUMI , SCB_NONE ); - set_sc( OB_ZANGETSU , SC_ZANGETSU , SI_ZANGETSU , SCB_MATK|SCB_BATK ); + status->set_sc( KO_ZENKAI , SC_ZENKAI , SI_ZENKAI , SCB_NONE ); + status->set_sc( KO_IZAYOI , SC_IZAYOI , SI_IZAYOI , SCB_MATK ); + status->set_sc( KG_KYOMU , SC_KYOMU , SI_KYOMU , SCB_NONE ); + status->set_sc( KG_KAGEMUSYA , SC_KAGEMUSYA , SI_KAGEMUSYA , SCB_NONE ); + status->set_sc( KG_KAGEHUMI , SC_KG_KAGEHUMI , SI_KG_KAGEHUMI , SCB_NONE ); + status->set_sc( OB_ZANGETSU , SC_ZANGETSU , SI_ZANGETSU , SCB_MATK|SCB_BATK ); set_sc_with_vfx( OB_AKAITSUKI, SC_AKAITSUKI , SI_AKAITSUKI , SCB_NONE ); - set_sc( OB_OBOROGENSOU , SC_GENSOU , SI_GENSOU , SCB_NONE ); + status->set_sc( OB_OBOROGENSOU , SC_GENSOU , SI_GENSOU , SCB_NONE ); - set_sc( ALL_FULL_THROTTLE , SC_FULL_THROTTLE , SI_FULL_THROTTLE , SCB_SPEED|SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); + status->set_sc( ALL_FULL_THROTTLE , SC_FULL_THROTTLE , SI_FULL_THROTTLE , SCB_SPEED|SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); add_sc( ALL_REVERSEORCISH , SC_ORCISH ); - set_sc( ALL_ANGEL_PROTECT , SC_ANGEL_PROTECT , SI_ANGEL_PROTECT , SCB_REGEN ); + status->set_sc( ALL_ANGEL_PROTECT , SC_ANGEL_PROTECT , SI_ANGEL_PROTECT , SCB_REGEN ); add_sc( NPC_WIDEHEALTHFEAR , SC_FEAR ); add_sc( NPC_WIDEBODYBURNNING , SC_BURNING ); @@ -1169,46 +1170,6 @@ void initChangeTables(void) { status->dbs->ChangeFlagTable[SC_MAGICAL_FEATHER] |= SCB_NONE; status->dbs->ChangeFlagTable[SC_BLOSSOM_FLUTTERING] |= SCB_NONE; - /* status->dbs->DisplayType Table [Ind/Hercules] */ - status->dbs->DisplayType[SC_ALL_RIDING] = true; - status->dbs->DisplayType[SC_PUSH_CART] = true; - status->dbs->DisplayType[SC_SUMMON1] = true; - status->dbs->DisplayType[SC_SUMMON2] = true; - status->dbs->DisplayType[SC_SUMMON3] = true; - status->dbs->DisplayType[SC_SUMMON4] = true; - status->dbs->DisplayType[SC_SUMMON5] = true; - status->dbs->DisplayType[SC_CAMOUFLAGE] = true; - status->dbs->DisplayType[SC_DUPLELIGHT] = true; - status->dbs->DisplayType[SC_ORATIO] = true; - status->dbs->DisplayType[SC_FROSTMISTY] = true; - status->dbs->DisplayType[SC_VENOMIMPRESS] = true; - status->dbs->DisplayType[SC_HALLUCINATIONWALK] = true; - status->dbs->DisplayType[SC_ROLLINGCUTTER] = true; - status->dbs->DisplayType[SC_BANDING] = true; - status->dbs->DisplayType[SC_COLD] = true; - status->dbs->DisplayType[SC_DEEP_SLEEP] = true; - status->dbs->DisplayType[SC_CURSEDCIRCLE_ATKER] = true; - status->dbs->DisplayType[SC_CURSEDCIRCLE_TARGET] = true; - status->dbs->DisplayType[SC_BLOOD_SUCKER] = true; - status->dbs->DisplayType[SC__SHADOWFORM] = true; - status->dbs->DisplayType[SC_MONSTER_TRANSFORM] = true; - - // Costumes - status->dbs->DisplayType[SC_MOONSTAR] = true; - status->dbs->DisplayType[SC_SUPER_STAR] = true; - status->dbs->DisplayType[SC_STRANGELIGHTS] = true; - status->dbs->DisplayType[SC_DECORATION_OF_MUSIC] = true; - status->dbs->DisplayType[SC_LJOSALFAR] = true; - status->dbs->DisplayType[SC_MERMAID_LONGING] = true; - status->dbs->DisplayType[SC_HAT_EFFECT] = true; - status->dbs->DisplayType[SC_FLOWERSMOKE] = true; - status->dbs->DisplayType[SC_FSTONE] = true; - status->dbs->DisplayType[SC_HAPPINESS_STAR] = true; - status->dbs->DisplayType[SC_MAPLE_FALLS] = true; - status->dbs->DisplayType[SC_TIME_ACCESSORY] = true; - status->dbs->DisplayType[SC_MAGICAL_FEATHER] = true; - status->dbs->DisplayType[SC_BLOSSOM_FLUTTERING] = true; - if( !battle_config.display_hallucination ) //Disable Hallucination. status->dbs->IconChangeTable[SC_ILLUSION] = SI_BLANK; #undef add_sc @@ -1237,7 +1198,7 @@ void initDummyData(void) } //For copying a status_data structure from b to a, without overwriting current Hp and Sp -static inline void status_cpy(struct status_data* a, const struct status_data* b) +void status_copy(struct status_data *a, const struct status_data *b) { memcpy((void*)&a->max_hp, (const void*)&b->max_hp, sizeof(struct status_data)-(sizeof(a->hp)+sizeof(a->sp))); } @@ -2208,9 +2169,7 @@ int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt) if (battle_config.pet_lv_rate && pd->msd) { struct map_session_data *sd = pd->msd; - int lv; - - lv =sd->status.base_level*battle_config.pet_lv_rate/100; + int lv = sd->status.base_level * battle_config.pet_lv_rate / 100; if (lv < 0) lv = 1; if (lv != pd->pet.level || opt&SCO_FIRST) { @@ -2669,7 +2628,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { // Job bonuses index = pc->class2idx(sd->status.class_); - for(i=0;i<(int)sd->status.job_level && i<MAX_LEVEL;i++){ + for (i = 0; i < sd->status.job_level && i < MAX_LEVEL; i++) { if(!status->dbs->job_bonus[index][i]) continue; switch(status->dbs->job_bonus[index][i]) { @@ -3160,7 +3119,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { sd->left_weapon.addrace[RC_DEMON] += sc->data[SC_PHI_DEMON]->val1; } } - status_cpy(&sd->battle_status, bstatus); + status->copy(&sd->battle_status, bstatus); // ----- CLIENT-SIDE REFRESH ----- if(!sd->bl.prev) { @@ -3199,7 +3158,7 @@ int status_calc_mercenary_(struct mercenary_data *md, enum e_status_calc_opt opt } status->calc_misc(&md->bl, mstatus, md->db->lv); - status_cpy(&md->battle_status, mstatus); + status->copy(&md->battle_status, mstatus); return 0; } @@ -3237,7 +3196,7 @@ int status_calc_elemental_(struct elemental_data *ed, enum e_status_calc_opt opt memcpy(&ed->battle_status, estatus, sizeof(struct status_data)); } else { status->calc_misc(&ed->bl, estatus, 0); - status_cpy(&ed->battle_status, estatus); + status->copy(&ed->battle_status, estatus); } return 0; @@ -3274,7 +3233,7 @@ int status_calc_npc_(struct npc_data *nd, enum e_status_calc_opt opt) { nstatus->luk = nd->stat_point; status->calc_misc(&nd->bl, nstatus, nd->level); - status_cpy(&nd->status, nstatus); + status->copy(&nd->status, nstatus); return 0; } @@ -3360,7 +3319,7 @@ int status_calc_homunculus_(struct homun_data *hd, enum e_status_calc_opt opt) { status->calc_misc(&hd->bl, hstatus, hom->level); - status_cpy(&hd->battle_status, hstatus); + status->copy(&hd->battle_status, hstatus); return 1; } @@ -3540,7 +3499,7 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str #endif regen->rate.sp += 1; } - + if (sc->data[SC_GDSKILL_REGENERATION]) { const struct status_change_entry *sce = sc->data[SC_GDSKILL_REGENERATION]; if (!sce->val4) { @@ -3610,7 +3569,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { } if((!(bl->type&BL_REGEN)) && (!sc || !sc->count)) { //No difference. - status_cpy(st, bst); + status->copy(st, bst); return; } @@ -3927,8 +3886,16 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { #endif if ( st->aspd_rate != 1000 ) // absolute percentage modifier amotion = amotion * st->aspd_rate / 1000; - if ( sd && sd->ud.skilltimer != INVALID_TIMER && pc->checkskill(sd, SA_FREECAST) > 0 ) - amotion = amotion * 5 * (pc->checkskill(sd, SA_FREECAST) + 10) / 100; + if (sd && sd->ud.skilltimer != INVALID_TIMER) { + if (pc->checkskill(sd, SA_FREECAST) > 0) { + amotion = amotion * 5 * (pc->checkskill(sd, SA_FREECAST) + 10) / 100; + } else { + struct unit_data *ud = unit->bl2ud(bl); + if (ud && (skill->get_inf2(ud->skill_id) & INF2_FREE_CAST_REDUCED) != 0) { + amotion = amotion * 5 * (ud->skill_lv + 10) / 100; + } + } + } #ifdef RENEWAL_ASPD amotion += (max(0xc3 - amotion, 2) * (st->aspd_rate2 + status->calc_aspd(bl, sc, 2))) / 100; amotion = 10 * (200 - amotion) + sd->bonus.aspd_add; @@ -4300,10 +4267,15 @@ unsigned short status_base_atk(const struct block_list *bl, const struct status_ return cap_value(str, 0, USHRT_MAX); } -#ifndef RENEWAL -static inline unsigned short status_base_matk_min(const struct status_data *st) { return st->int_ + (st->int_ / 7)*(st->int_ / 7); } -#endif // not RENEWAL -static inline unsigned short status_base_matk_max(const struct status_data *st) { return st->int_ + (st->int_ / 5)*(st->int_ / 5); } +unsigned short status_base_matk_min(const struct status_data *st) +{ + return st->int_ + (st->int_ / 7) * (st->int_ / 7); +} + +unsigned short status_base_matk_max(const struct status_data *st) +{ + return st->int_ + (st->int_ / 5)*(st->int_ / 5); +} unsigned short status_base_matk(struct block_list *bl, const struct status_data *st, int level) { #ifdef RENEWAL @@ -4350,8 +4322,8 @@ void status_calc_misc(struct block_list *bl, struct status_data *st, int level) st->mdef2 += (int)(bl->type == BL_PC ? (st->int_ + ((float)level / 4) + ((float)(st->dex + st->vit) / 5)) : ((float)(st->int_ + level) / 4)); //(every 4 base level = +1 mdef) + (every 1 int = +1 mdef) + (every 5 dex = +1 mdef) + (every 5 vit = +1 mdef) } #else // not RENEWAL - st->matk_min = status_base_matk_min(st); - st->matk_max = status_base_matk_max(st); + st->matk_min = status->base_matk_min(st); + st->matk_max = status->base_matk_max(st); st->hit += level + st->dex; st->flee += level + st->agi; st->def2 += st->vit; @@ -4386,7 +4358,7 @@ void status_calc_misc(struct block_list *bl, struct status_data *st, int level) break; case BL_MER: #ifdef RENEWAL - st->matk_min = st->matk_max = status_base_matk_max(st); + st->matk_min = st->matk_max = status->base_matk_max(st); st->def2 = st->vit + level / 10 + st->vit / 5; st->mdef2 = level / 10 + st->int_ / 5; #endif @@ -5533,19 +5505,22 @@ signed short status_calc_mdef2(struct block_list *bl, struct status_change *sc, unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc, int speed) { struct map_session_data *sd = BL_CAST(BL_PC, bl); - int speed_rate; + int speed_rate = -1; if( sc == NULL || ( sd && sd->state.permanent_speed ) ) return (unsigned short)cap_value(speed,MIN_WALK_SPEED,MAX_WALK_SPEED); - if( sd && sd->ud.skilltimer != INVALID_TIMER && (pc->checkskill(sd,SA_FREECAST) > 0 || sd->ud.skill_id == LG_EXEEDBREAK) ) + if (sd && sd->ud.skilltimer != INVALID_TIMER) { - if( sd->ud.skill_id == LG_EXEEDBREAK ) + if (sd->ud.skill_id == LG_EXEEDBREAK) { speed_rate = 160 - 10 * sd->ud.skill_lv; - else + } else if ((skill->get_inf2(sd->ud.skill_id) & INF2_FREE_CAST_REDUCED) != 0) { + speed_rate = 175 - 5 * sd->ud.skill_lv; + } else if (pc->checkskill(sd, SA_FREECAST) > 0) { speed_rate = 175 - 5 * pc->checkskill(sd,SA_FREECAST); + } } - else + if (speed_rate == -1) { speed_rate = 100; @@ -7428,7 +7403,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t return 0; break; case SC_MAGNIFICAT: - if (sc->data[SC_OFFERTORIUM] || sc->option&OPTION_MADOGEAR) // Mado is immune to magnificat + if (sc->option&OPTION_MADOGEAR) // Mado is immune to magnificat return 0; break; case SC_ONEHANDQUICKEN: @@ -7631,10 +7606,6 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t if(sc->data[SC_HOVERING]) return 0; break; - case SC_OFFERTORIUM: - if (sc->data[SC_MAGNIFICAT]) - return 0; - break; } //Check for BOSS resistances @@ -7742,6 +7713,14 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t //Cancels Assumptio status_change_end(bl, SC_ASSUMPTIO, INVALID_TIMER); break; + case SC_MAGNIFICAT: + //Cancels Offertorium + status_change_end(bl, SC_OFFERTORIUM, INVALID_TIMER); + break; + case SC_OFFERTORIUM: + //Cancels Magnificat + status_change_end(bl, SC_MAGNIFICAT, INVALID_TIMER); + break; case SC_DELUGE: if (sc->data[SC_FOGWALL] && sc->data[SC_BLIND]) status_change_end(bl, SC_BLIND, INVALID_TIMER); @@ -11432,17 +11411,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { mushroom_skill_id = skill->dbs->magicmushroom_db[i].skill_id; } while (mushroom_skill_id == 0); - switch( skill->get_casttype(mushroom_skill_id) ) { // Magic Mushroom skills are buffs or area damage - case CAST_GROUND: - skill->castend_pos2(bl,bl->x,bl->y,mushroom_skill_id,1,tick,0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(bl,bl,mushroom_skill_id,1,tick,0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(bl,bl,mushroom_skill_id,1,tick,0); - break; - } + skill->castend_type(skill->get_casttype(mushroom_skill_id), bl, bl, mushroom_skill_id, 1, tick, 0); } clif->emotion(bl,E_HEH); @@ -12110,8 +12079,8 @@ void status_get_matk_sub(struct block_list *bl, int flag, unsigned short *matk_m } #else // not RENEWAL - *matk_min = status_base_matk_min(st) + (sd ? sd->bonus.ematk : 0); - *matk_max = status_base_matk_max(st) + (sd ? sd->bonus.ematk : 0); + *matk_min = status->base_matk_min(st) + (sd ? sd->bonus.ematk : 0); + *matk_max = status->base_matk_max(st) + (sd ? sd->bonus.ematk : 0); #endif if ( sd && sd->matk_rate != 100 ) { @@ -13000,6 +12969,10 @@ bool status_readdb_scconfig(char* fields[], int columns, int current) { } status->dbs->sc_conf[val] = (int)strtol(fields[1], NULL, 0); + if (status->dbs->sc_conf[val] & SC_VISIBLE) + { + status->dbs->DisplayType[val] = true; + } return true; } @@ -13230,4 +13203,10 @@ void status_defaults(void) { status->readdb_scconfig = status_readdb_scconfig; status->read_job_db = status_read_job_db; status->read_job_db_sub = status_read_job_db_sub; + status->set_sc = status_set_sc; + status->copy = status_copy; +#ifndef RENEWAL + status->base_matk_min = status_base_matk_min; +#endif // RENEWAL + status->base_matk_max = status_base_matk_max; } diff --git a/src/map/status.h b/src/map/status.h index 2b932b149..e4a326e88 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -64,7 +64,9 @@ enum refine_type { REFINE_TYPE_WEAPON2 = 2, REFINE_TYPE_WEAPON3 = 3, REFINE_TYPE_WEAPON4 = 4, +#ifndef REFINE_TYPE_MAX REFINE_TYPE_MAX = 5 +#endif }; /** @@ -72,14 +74,15 @@ enum refine_type { * @see db/sc_config.txt for more information **/ typedef enum sc_conf_type { - SC_NO_REM_DEATH = 0x01, - SC_NO_SAVE = 0x02, - SC_NO_DISPELL = 0x04, - SC_NO_CLEARANCE = 0x08, - SC_BUFF = 0x10, - SC_DEBUFF = 0x20, - SC_MADO_NO_RESET = 0x40, - SC_NO_CLEAR = 0x80, + SC_NO_REM_DEATH = 0x001, + SC_NO_SAVE = 0x002, + SC_NO_DISPELL = 0x004, + SC_NO_CLEARANCE = 0x008, + SC_BUFF = 0x010, + SC_DEBUFF = 0x020, + SC_MADO_NO_RESET = 0x040, + SC_NO_CLEAR = 0x080, + SC_VISIBLE = 0x100 } sc_conf_type; /** @@ -825,8 +828,9 @@ typedef enum sc_type { SC_M_LIFEPOTION, SC_G_LIFEPOTION, // 640 SC_MYSTICPOWDER, - +#ifndef SC_MAX SC_MAX, //Automatically updated max, used in for's to check we are within bounds. +#endif } sc_type; /// Official status change ids, used to display status icons in the client. @@ -1792,8 +1796,9 @@ enum si_type { //SI_EP16_2_BUFF_SS = 963, //SI_EP16_2_BUFF_SC = 964, //SI_EP16_2_BUFF_AC = 965, - +#ifndef SI_MAX SI_MAX, +#endif }; // JOINTBEAT stackable ailments @@ -2313,6 +2318,10 @@ struct status_interface { bool (*readdb_scconfig) (char *fields[], int columns, int current); void (*read_job_db) (void); void (*read_job_db_sub) (int idx, const char *name, struct config_setting_t *jdb); + void (*set_sc) (uint16 skill_id, sc_type sc, int icon, unsigned int flag); + void (*copy) (struct status_data *a, const struct status_data *b); + unsigned short (*base_matk_min) (const struct status_data *st); + unsigned short (*base_matk_max) (const struct status_data *st); }; #ifdef HERCULES_CORE diff --git a/src/map/storage.c b/src/map/storage.c index 91b37eb19..4272f9611 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -107,7 +107,7 @@ int storage_storageopen(struct map_session_data *sd) if( !pc_can_give_items(sd) ) { //check is this GM level is allowed to put items to storage - clif->message(sd->fd, msg_sd(sd,246)); + clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. return 1; } @@ -158,12 +158,12 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo if (!itemdb_canstore(item_data, pc_get_group_level(sd))) { //Check if item is storable. [Skotlex] - clif->message (sd->fd, msg_sd(sd,264)); + clif->message (sd->fd, msg_sd(sd,264)); // This item cannot be stored. return 1; } if( item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd) ) { - clif->message(sd->fd, msg_sd(sd,294)); + clif->message(sd->fd, msg_sd(sd,294)); // This bound item cannot be stored there. return 1; } @@ -407,7 +407,7 @@ int storage_guild_storageopen(struct map_session_data* sd) return 1; //Can't open both storages at a time. if( !pc_can_give_items(sd) ) { //check is this GM level can open guild storage and store items [Lupus] - clif->message(sd->fd, msg_sd(sd,246)); + clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. return 1; } @@ -456,12 +456,12 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto if (!itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time) { //Check if item is storable. [Skotlex] - clif->message (sd->fd, msg_sd(sd,264)); + clif->message (sd->fd, msg_sd(sd,264)); // This item cannot be stored. return 1; } if( item_data->bound && item_data->bound != IBT_GUILD && !pc_can_give_bound_items(sd) ) { - clif->message(sd->fd, msg_sd(sd,294)); + clif->message(sd->fd, msg_sd(sd,294)); // This bound item cannot be stored there. return 1; } diff --git a/src/map/trade.c b/src/map/trade.c index 6352c3a4d..d6bdd14e5 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -51,8 +51,8 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta nullpo_retv(sd); if (map->list[sd->bl.m].flag.notrade) { - clif->message (sd->fd, msg_sd(sd,272)); - return; //Can't trade in notrade mapflag maps. + clif->message (sd->fd, msg_sd(sd,272)); // You can't trade in this map + return; } if (target_sd == NULL || sd == target_sd) { @@ -90,7 +90,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta if (!pc_can_give_items(sd) || !pc_can_give_items(target_sd)) //check if both GMs are allowed to trade { - clif->message(sd->fd, msg_sd(sd,246)); + clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. clif->tradestart(sd, 2); // GM is not allowed to trade return; } @@ -372,14 +372,14 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) if( !itemdb_cantrade(item, src_lv, dst_lv) && //Can't trade (pc->get_partner(sd) != target_sd || !itemdb_canpartnertrade(item, src_lv, dst_lv)) ) //Can't partner-trade { - clif->message (sd->fd, msg_sd(sd,260)); + clif->message (sd->fd, msg_sd(sd,260)); // This item cannot be traded. clif->tradeitemok(sd, index+2, TIO_INDROCKS); return; } if( item->expire_time ) { // Rental System - clif->message (sd->fd, msg_sd(sd,260)); + clif->message (sd->fd, msg_sd(sd,260)); // This item cannot be traded. clif->tradeitemok(sd, index+2, TIO_INDROCKS); return; } @@ -388,7 +388,7 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) !( item->bound == IBT_GUILD && sd->status.guild_id == target_sd->status.guild_id ) && !( item->bound == IBT_PARTY && sd->status.party_id == target_sd->status.party_id ) && !pc_can_give_bound_items(sd) ) { - clif->message(sd->fd, msg_sd(sd,293)); + clif->message(sd->fd, msg_sd(sd,293)); // This bound item cannot be traded to that character. clif->tradeitemok(sd, index+2, TIO_INDROCKS); return; } diff --git a/src/map/unit.c b/src/map/unit.c index ac1e3e9b5..c52683444 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1053,8 +1053,10 @@ int unit_can_move(struct block_list *bl) { if (!ud) return 0; - if (ud->skilltimer != INVALID_TIMER && ud->skill_id != LG_EXEEDBREAK && (!sd || !pc->checkskill(sd, SA_FREECAST) || skill->get_inf2(ud->skill_id)&INF2_GUILD_SKILL)) + if (ud->skilltimer != INVALID_TIMER && ud->skill_id != LG_EXEEDBREAK && + (!sd || (!pc->checkskill(sd, SA_FREECAST) && (skill->get_inf2(ud->skill_id) & (INF2_GUILD_SKILL | INF2_FREE_CAST_REDUCED | INF2_FREE_CAST_NORMAL)) == 0))) { return 0; // prevent moving while casting + } if (DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) return 0; @@ -1574,7 +1576,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);// even though this is not how official works but this will do the trick. bugreport:6829 // in official this is triggered even if no cast time. - clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime); + clif->useskill(src, src->id, target_id, 0,0, skill_id, skill_lv, casttime); if( casttime > 0 || temp ) { if (sd != NULL && target->type == BL_MOB) { @@ -1629,7 +1631,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if (src->id != target->id) // self-targeted skills shouldn't show different direction unit->setdir(src, map->calc_dir(src, target->x, target->y)); ud->skilltimer = timer->add( tick+casttime, skill->castend_id, src->id, 0 ); - if( sd && (pc->checkskill(sd,SA_FREECAST) > 0 || skill_id == LG_EXEEDBREAK) ) + if (sd && (pc->checkskill(sd, SA_FREECAST) > 0 || skill_id == LG_EXEEDBREAK || (skill->get_inf2(ud->skill_id) & INF2_FREE_CAST_REDUCED) != 0)) status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD); } else skill->castend_id(ud->skilltimer,tick,src->id,0); @@ -1769,11 +1771,11 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS); // in official this is triggered even if no cast time. - clif->skillcasting(src, src->id, 0, skill_x, skill_y, skill_id, skill->get_ele(skill_id, skill_lv), casttime); + clif->useskill(src, src->id, 0, skill_x, skill_y, skill_id, skill_lv, casttime); if( casttime > 0 ) { unit->setdir(src, map->calc_dir(src, skill_x, skill_y)); ud->skilltimer = timer->add( tick+casttime, skill->castend_pos, src->id, 0 ); - if ( (sd && pc->checkskill(sd, SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK ) { + if ((sd && pc->checkskill(sd, SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK || (skill->get_inf2(ud->skill_id) & INF2_FREE_CAST_REDUCED) != 0) { status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD); } } else { @@ -2118,10 +2120,10 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) { return 0; } - if( ud->skilltimer != INVALID_TIMER && !(sd && pc->checkskill(sd,SA_FREECAST) > 0) ) + if (ud->skilltimer != INVALID_TIMER && !(sd && (pc->checkskill(sd, SA_FREECAST) > 0 || (skill->get_inf2(ud->skill_id) & (INF2_FREE_CAST_REDUCED | INF2_FREE_CAST_NORMAL)) != 0))) return 0; // can't attack while casting - if( !battle_config.sdelay_attack_enable && DIFF_TICK(ud->canact_tick,tick) > 0 && !(sd && pc->checkskill(sd,SA_FREECAST) > 0) ) + if (!battle_config.sdelay_attack_enable && DIFF_TICK(ud->canact_tick, tick) > 0 && !(sd && (pc->checkskill(sd, SA_FREECAST) > 0 || (skill->get_inf2(ud->skill_id) & (INF2_FREE_CAST_REDUCED | INF2_FREE_CAST_NORMAL)) != 0))) { // attacking when under cast delay has restrictions: if( tid == INVALID_TIMER ) { //requested attack. if(sd) clif->skill_fail(sd,1,USESKILL_FAIL_SKILLINTERVAL,0); @@ -2270,7 +2272,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) ud->skilltimer = INVALID_TIMER; - if( sd && pc->checkskill(sd,SA_FREECAST) > 0 ) + if (sd && (pc->checkskill(sd, SA_FREECAST) > 0 || (skill->get_inf2(ud->skill_id) & INF2_FREE_CAST_REDUCED) != 0)) status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD); if( sd ) { diff --git a/src/map/vending.c b/src/map/vending.c index e3a62bea7..0eb5e39e2 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -74,8 +74,7 @@ void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) { return; // not vending if (!pc_can_give_items(sd) || !pc_can_give_items(vsd)) { //check if both GMs are allowed to trade - // GM is not allowed to trade - clif->message(sd->fd, msg_sd(sd,246)); + clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. return; } @@ -276,7 +275,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, const || pc->cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity //NOTE: official server does not do any of the following checks! || !sd->status.cart[index].identify // unidentified item - || sd->status.cart[index].attribute == 1 // broken item + || (sd->status.cart[index].attribute & ATTR_BROKEN) != 0 // broken item || sd->status.cart[index].expire_time // It should not be in the cart but just in case || (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // can't trade bound items w/o permission || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c index 4fb7911c2..0b98ea99f 100644 --- a/src/plugins/HPMHooking.c +++ b/src/plugins/HPMHooking.c @@ -97,6 +97,7 @@ #include "map/storage.h" #include "map/trade.h" #include "map/unit.h" +#include "common/grfio.h" #include "common/mapindex.h" #else #define HPM_SERVER_TYPE SERVER_TYPE_UNKNOWN @@ -109,13 +110,18 @@ #include "common/conf.h" #include "common/console.h" #include "common/db.h" +#include "common/des.h" +#include "common/md5calc.h" #include "common/memmgr.h" +#include "common/mutex.h" #include "common/nullpo.h" +#include "common/random.h" #include "common/showmsg.h" #include "common/socket.h" #include "common/sql.h" #include "common/strlib.h" #include "common/sysinfo.h" +#include "common/thread.h" #include "common/timer.h" #include "common/utils.h" diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 4510bc3df..f10e868b7 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + #ifdef COMMON_UTILS_H /* HCache */ typedef void (*HPMHOOK_pre_HCache_init) (void); typedef void (*HPMHOOK_post_HCache_init) (void); @@ -112,12 +114,16 @@ typedef struct Damage (*HPMHOOK_pre_battle_calc_attack) (int *attack_type, struc typedef struct Damage (*HPMHOOK_post_battle_calc_attack) (struct Damage retVal___, int attack_type, struct block_list *bl, struct block_list *target, uint16 skill_id, uint16 skill_lv, int count); typedef int64 (*HPMHOOK_pre_battle_calc_damage) (struct block_list **src, struct block_list **bl, struct Damage **d, int64 *damage, uint16 *skill_id, uint16 *skill_lv); typedef int64 (*HPMHOOK_post_battle_calc_damage) (int64 retVal___, struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv); +typedef int64 (*HPMHOOK_pre_battle_calc_pc_damage) (struct block_list **src, struct block_list **bl, struct Damage **d, int64 *damage, uint16 *skill_id, uint16 *skill_lv); +typedef int64 (*HPMHOOK_post_battle_calc_pc_damage) (int64 retVal___, struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv); typedef int64 (*HPMHOOK_pre_battle_calc_gvg_damage) (struct block_list **src, struct block_list **bl, int64 *damage, int *div_, uint16 *skill_id, uint16 *skill_lv, int *flag); typedef int64 (*HPMHOOK_post_battle_calc_gvg_damage) (int64 retVal___, struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); typedef int64 (*HPMHOOK_pre_battle_calc_bg_damage) (struct block_list **src, struct block_list **bl, int64 *damage, int *div_, uint16 *skill_id, uint16 *skill_lv, int *flag); typedef int64 (*HPMHOOK_post_battle_calc_bg_damage) (int64 retVal___, struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); typedef enum damage_lv (*HPMHOOK_pre_battle_weapon_attack) (struct block_list **bl, struct block_list **target, int64 *tick, int *flag); typedef enum damage_lv (*HPMHOOK_post_battle_weapon_attack) (enum damage_lv retVal___, struct block_list *bl, struct block_list *target, int64 tick, int flag); +typedef bool (*HPMHOOK_pre_battle_check_arrows) (struct map_session_data **sd); +typedef bool (*HPMHOOK_post_battle_check_arrows) (bool retVal___, struct map_session_data *sd); typedef struct Damage (*HPMHOOK_pre_battle_calc_weapon_attack) (struct block_list **src, struct block_list **target, uint16 *skill_id, uint16 *skill_lv, int *wflag); typedef struct Damage (*HPMHOOK_post_battle_calc_weapon_attack) (struct Damage retVal___, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int wflag); typedef int (*HPMHOOK_pre_battle_delay_damage) (int64 *tick, int *amotion, struct block_list **src, struct block_list **target, int *attack_type, uint16 *skill_id, uint16 *skill_lv, int64 *damage, enum damage_lv *dmg_lv, int *ddelay, bool *additional_effects); @@ -672,8 +678,8 @@ typedef bool (*HPMHOOK_pre_chat_change_status) (struct map_session_data **sd, co typedef bool (*HPMHOOK_post_chat_change_status) (bool retVal___, struct map_session_data *sd, const char *title, const char *pass, int limit, bool pub); typedef bool (*HPMHOOK_pre_chat_kick) (struct map_session_data **sd, const char **kickusername); typedef bool (*HPMHOOK_post_chat_kick) (bool retVal___, struct map_session_data *sd, const char *kickusername); -typedef bool (*HPMHOOK_pre_chat_create_npc_chat) (struct npc_data **nd, const char **title, int *limit, bool *pub, int *trigger, const char **ev, int *zeny, int *minLvl, int *maxLvl); -typedef bool (*HPMHOOK_post_chat_create_npc_chat) (bool retVal___, struct npc_data *nd, const char *title, int limit, bool pub, int trigger, const char *ev, int zeny, int minLvl, int maxLvl); +typedef bool (*HPMHOOK_pre_chat_create_npc_chat) (struct npc_data **nd, const char **title, int *limit, bool *pub, int *trigger, const char **ev, int *zeny, int *min_level, int *max_level); +typedef bool (*HPMHOOK_post_chat_create_npc_chat) (bool retVal___, struct npc_data *nd, const char *title, int limit, bool pub, int trigger, const char *ev, int zeny, int min_level, int max_level); typedef bool (*HPMHOOK_pre_chat_delete_npc_chat) (struct npc_data **nd); typedef bool (*HPMHOOK_post_chat_delete_npc_chat) (bool retVal___, struct npc_data *nd); typedef bool (*HPMHOOK_pre_chat_enable_event) (struct chat_data **cd); @@ -684,8 +690,8 @@ typedef bool (*HPMHOOK_pre_chat_npc_kick_all) (struct chat_data **cd); typedef bool (*HPMHOOK_post_chat_npc_kick_all) (bool retVal___, struct chat_data *cd); typedef bool (*HPMHOOK_pre_chat_trigger_event) (struct chat_data **cd); typedef bool (*HPMHOOK_post_chat_trigger_event) (bool retVal___, struct chat_data *cd); -typedef struct chat_data* (*HPMHOOK_pre_chat_create) (struct block_list **bl, const char **title, const char **pass, int *limit, bool *pub, int *trigger, const char **ev, int *zeny, int *minLvl, int *maxLvl); -typedef struct chat_data* (*HPMHOOK_post_chat_create) (struct chat_data* retVal___, struct block_list *bl, const char *title, const char *pass, int limit, bool pub, int trigger, const char *ev, int zeny, int minLvl, int maxLvl); +typedef struct chat_data* (*HPMHOOK_pre_chat_create) (struct block_list **bl, const char **title, const char **pass, int *limit, bool *pub, int *trigger, const char **ev, int *zeny, int *min_level, int *max_level); +typedef struct chat_data* (*HPMHOOK_post_chat_create) (struct chat_data* retVal___, struct block_list *bl, const char *title, const char *pass, int limit, bool pub, int trigger, const char *ev, int zeny, int min_level, int max_level); #endif // MAP_CHAT_H #ifdef MAP_CHRIF_H /* chrif */ typedef void (*HPMHOOK_pre_chrif_init) (bool *minimal); @@ -1166,6 +1172,8 @@ typedef int (*HPMHOOK_pre_clif_skill_itemlistwindow) (struct map_session_data ** typedef int (*HPMHOOK_post_clif_skill_itemlistwindow) (int retVal___, struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); typedef void (*HPMHOOK_pre_clif_sc_load) (struct block_list **bl, int *tid, enum send_target *target, int *type, int *val1, int *val2, int *val3); typedef void (*HPMHOOK_post_clif_sc_load) (struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3); +typedef void (*HPMHOOK_pre_clif_sc_continue) (struct block_list **bl, int *tid, enum send_target *target, int *type, int *val1, int *val2, int *val3); +typedef void (*HPMHOOK_post_clif_sc_continue) (struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3); typedef void (*HPMHOOK_pre_clif_sc_end) (struct block_list **bl, int *tid, enum send_target *target, int *type); typedef void (*HPMHOOK_post_clif_sc_end) (struct block_list *bl, int tid, enum send_target target, int type); typedef void (*HPMHOOK_pre_clif_initialstatus) (struct map_session_data **sd); @@ -1228,8 +1236,8 @@ typedef void (*HPMHOOK_pre_clif_skill_estimation) (struct map_session_data **sd, typedef void (*HPMHOOK_post_clif_skill_estimation) (struct map_session_data *sd, struct block_list *dst); typedef void (*HPMHOOK_pre_clif_skill_warppoint) (struct map_session_data **sd, uint16 *skill_id, uint16 *skill_lv, unsigned short *map1, unsigned short *map2, unsigned short *map3, unsigned short *map4); typedef void (*HPMHOOK_post_clif_skill_warppoint) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, unsigned short map1, unsigned short map2, unsigned short map3, unsigned short map4); -typedef void (*HPMHOOK_pre_clif_skillcasting) (struct block_list **bl, int *src_id, int *dst_id, int *dst_x, int *dst_y, uint16 *skill_id, int *property, int *casttime); -typedef void (*HPMHOOK_post_clif_skillcasting) (struct block_list *bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, int property, int casttime); +typedef void (*HPMHOOK_pre_clif_useskill) (struct block_list **bl, int *src_id, int *dst_id, int *dst_x, int *dst_y, uint16 *skill_id, uint16 *skill_lv, int *casttime); +typedef void (*HPMHOOK_post_clif_useskill) (struct block_list *bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, uint16 skill_lv, int casttime); typedef void (*HPMHOOK_pre_clif_produce_effect) (struct map_session_data **sd, int *flag, int *nameid); typedef void (*HPMHOOK_post_clif_produce_effect) (struct map_session_data *sd, int flag, int nameid); typedef void (*HPMHOOK_pre_clif_devotion) (struct block_list **src, struct map_session_data **tsd); @@ -1724,6 +1732,10 @@ typedef int (*HPMHOOK_pre_clif_comparemergeitem) (const void **a, const void **b typedef int (*HPMHOOK_post_clif_comparemergeitem) (int retVal___, const void *a, const void *b); typedef void (*HPMHOOK_pre_clif_ackmergeitems) (int *fd, struct map_session_data **sd); typedef void (*HPMHOOK_post_clif_ackmergeitems) (int fd, struct map_session_data *sd); +typedef bool (*HPMHOOK_pre_clif_isdisguised) (struct block_list **bl); +typedef bool (*HPMHOOK_post_clif_isdisguised) (bool retVal___, struct block_list *bl); +typedef unsigned char (*HPMHOOK_pre_clif_bl_type) (struct block_list **bl); +typedef unsigned char (*HPMHOOK_post_clif_bl_type) (unsigned char retVal___, struct block_list *bl); typedef void (*HPMHOOK_pre_clif_pWantToConnection) (int *fd, struct map_session_data **sd); typedef void (*HPMHOOK_post_clif_pWantToConnection) (int fd, struct map_session_data *sd); typedef void (*HPMHOOK_pre_clif_pLoadEndAck) (int *fd, struct map_session_data **sd); @@ -2261,6 +2273,12 @@ typedef void (*HPMHOOK_post_DB_init) (void); typedef void (*HPMHOOK_pre_DB_final) (void); typedef void (*HPMHOOK_post_DB_final) (void); #endif // COMMON_DB_H +#ifdef COMMON_DES_H /* des */ +typedef void (*HPMHOOK_pre_des_decrypt_block) (struct des_bit64 **block); +typedef void (*HPMHOOK_post_des_decrypt_block) (struct des_bit64 *block); +typedef void (*HPMHOOK_pre_des_decrypt) (unsigned char **data, size_t *size); +typedef void (*HPMHOOK_post_des_decrypt) (unsigned char *data, size_t size); +#endif // COMMON_DES_H #ifdef MAP_DUEL_H /* duel */ typedef int (*HPMHOOK_pre_duel_create) (struct map_session_data **sd, const unsigned int *maxpl); typedef int (*HPMHOOK_post_duel_create) (int retVal___, struct map_session_data *sd, const unsigned int maxpl); @@ -2355,6 +2373,22 @@ typedef void (*HPMHOOK_post_geoip_final) (bool shutdown); typedef void (*HPMHOOK_pre_geoip_init) (void); typedef void (*HPMHOOK_post_geoip_init) (void); #endif // CHAR_GEOIP_H +#ifdef COMMON_GRFIO_H /* grfio */ +typedef void (*HPMHOOK_pre_grfio_init) (const char **fname); +typedef void (*HPMHOOK_post_grfio_init) (const char *fname); +typedef void (*HPMHOOK_pre_grfio_final) (void); +typedef void (*HPMHOOK_post_grfio_final) (void); +typedef void* (*HPMHOOK_pre_grfio_reads) (const char **fname, int **size); +typedef void* (*HPMHOOK_post_grfio_reads) (void* retVal___, const char *fname, int *size); +typedef const char* (*HPMHOOK_pre_grfio_find_file) (const char **fname); +typedef const char* (*HPMHOOK_post_grfio_find_file) (const char* retVal___, const char *fname); +typedef unsigned long (*HPMHOOK_pre_grfio_crc32) (const unsigned char **buf, unsigned int *len); +typedef unsigned long (*HPMHOOK_post_grfio_crc32) (unsigned long retVal___, const unsigned char *buf, unsigned int len); +typedef int (*HPMHOOK_pre_grfio_decode_zip) (void **dest, unsigned long **dest_len, const void **source, unsigned long *source_len); +typedef int (*HPMHOOK_post_grfio_decode_zip) (int retVal___, void *dest, unsigned long *dest_len, const void *source, unsigned long source_len); +typedef int (*HPMHOOK_pre_grfio_encode_zip) (void **dest, unsigned long **dest_len, const void **source, unsigned long *source_len); +typedef int (*HPMHOOK_post_grfio_encode_zip) (int retVal___, void *dest, unsigned long *dest_len, const void *source, unsigned long source_len); +#endif // COMMON_GRFIO_H #ifdef MAP_GUILD_H /* guild */ typedef void (*HPMHOOK_pre_guild_init) (bool *minimal); typedef void (*HPMHOOK_post_guild_init) (bool minimal); @@ -4417,6 +4451,14 @@ typedef void (*HPMHOOK_post_mapreg_reload) (void); typedef bool (*HPMHOOK_pre_mapreg_config_read) (const char **w1, const char **w2); typedef bool (*HPMHOOK_post_mapreg_config_read) (bool retVal___, const char *w1, const char *w2); #endif // MAP_MAPREG_H +#ifdef COMMON_MD5CALC_H /* md5 */ +typedef void (*HPMHOOK_pre_md5_string) (const char **string, char **output); +typedef void (*HPMHOOK_post_md5_string) (const char *string, char *output); +typedef void (*HPMHOOK_pre_md5_binary) (const char **string, unsigned char **output); +typedef void (*HPMHOOK_post_md5_binary) (const char *string, unsigned char *output); +typedef void (*HPMHOOK_pre_md5_salt) (int *len, char **output); +typedef void (*HPMHOOK_post_md5_salt) (int len, char *output); +#endif // COMMON_MD5CALC_H #ifdef MAP_MERCENARY_H /* mercenary */ typedef void (*HPMHOOK_pre_mercenary_init) (bool *minimal); typedef void (*HPMHOOK_post_mercenary_init) (bool minimal); @@ -4677,6 +4719,28 @@ typedef void (*HPMHOOK_post_mob_clear_spawninfo) (void); typedef void (*HPMHOOK_pre_mob_destroy_mob_db) (int *index); typedef void (*HPMHOOK_post_mob_destroy_mob_db) (int index); #endif // MAP_MOB_H +#ifdef COMMON_MUTEX_H /* mutex */ +typedef struct mutex_data* (*HPMHOOK_pre_mutex_create) (void); +typedef struct mutex_data* (*HPMHOOK_post_mutex_create) (struct mutex_data* retVal___); +typedef void (*HPMHOOK_pre_mutex_destroy) (struct mutex_data **m); +typedef void (*HPMHOOK_post_mutex_destroy) (struct mutex_data *m); +typedef void (*HPMHOOK_pre_mutex_lock) (struct mutex_data **m); +typedef void (*HPMHOOK_post_mutex_lock) (struct mutex_data *m); +typedef bool (*HPMHOOK_pre_mutex_trylock) (struct mutex_data **m); +typedef bool (*HPMHOOK_post_mutex_trylock) (bool retVal___, struct mutex_data *m); +typedef void (*HPMHOOK_pre_mutex_unlock) (struct mutex_data **m); +typedef void (*HPMHOOK_post_mutex_unlock) (struct mutex_data *m); +typedef struct cond_data* (*HPMHOOK_pre_mutex_cond_create) (void); +typedef struct cond_data* (*HPMHOOK_post_mutex_cond_create) (struct cond_data* retVal___); +typedef void (*HPMHOOK_pre_mutex_cond_destroy) (struct cond_data **c); +typedef void (*HPMHOOK_post_mutex_cond_destroy) (struct cond_data *c); +typedef void (*HPMHOOK_pre_mutex_cond_wait) (struct cond_data **c, struct mutex_data **m, sysint *timeout_ticks); +typedef void (*HPMHOOK_post_mutex_cond_wait) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks); +typedef void (*HPMHOOK_pre_mutex_cond_signal) (struct cond_data **c); +typedef void (*HPMHOOK_post_mutex_cond_signal) (struct cond_data *c); +typedef void (*HPMHOOK_pre_mutex_cond_broadcast) (struct cond_data **c); +typedef void (*HPMHOOK_post_mutex_cond_broadcast) (struct cond_data *c); +#endif // COMMON_MUTEX_H #ifdef MAP_NPC_H /* npc_chat */ typedef int (*HPMHOOK_pre_npc_chat_sub) (struct block_list **bl, va_list ap); typedef int (*HPMHOOK_post_npc_chat_sub) (int retVal___, struct block_list *bl, va_list ap); @@ -5202,24 +5266,24 @@ typedef int (*HPMHOOK_pre_pc_follow) (struct map_session_data **sd, int *target_ typedef int (*HPMHOOK_post_pc_follow) (int retVal___, struct map_session_data *sd, int target_id); typedef int (*HPMHOOK_pre_pc_stop_following) (struct map_session_data **sd); typedef int (*HPMHOOK_post_pc_stop_following) (int retVal___, struct map_session_data *sd); -typedef unsigned int (*HPMHOOK_pre_pc_maxbaselv) (struct map_session_data **sd); -typedef unsigned int (*HPMHOOK_post_pc_maxbaselv) (unsigned int retVal___, struct map_session_data *sd); -typedef unsigned int (*HPMHOOK_pre_pc_maxjoblv) (struct map_session_data **sd); -typedef unsigned int (*HPMHOOK_post_pc_maxjoblv) (unsigned int retVal___, struct map_session_data *sd); +typedef int (*HPMHOOK_pre_pc_maxbaselv) (const struct map_session_data **sd); +typedef int (*HPMHOOK_post_pc_maxbaselv) (int retVal___, const struct map_session_data *sd); +typedef int (*HPMHOOK_pre_pc_maxjoblv) (const struct map_session_data **sd); +typedef int (*HPMHOOK_post_pc_maxjoblv) (int retVal___, const struct map_session_data *sd); typedef int (*HPMHOOK_pre_pc_checkbaselevelup) (struct map_session_data **sd); typedef int (*HPMHOOK_post_pc_checkbaselevelup) (int retVal___, struct map_session_data *sd); typedef int (*HPMHOOK_pre_pc_checkjoblevelup) (struct map_session_data **sd); typedef int (*HPMHOOK_post_pc_checkjoblevelup) (int retVal___, struct map_session_data *sd); typedef bool (*HPMHOOK_pre_pc_gainexp) (struct map_session_data **sd, struct block_list **src, unsigned int *base_exp, unsigned int *job_exp, bool *is_quest); typedef bool (*HPMHOOK_post_pc_gainexp) (bool retVal___, struct map_session_data *sd, struct block_list *src, unsigned int base_exp, unsigned int job_exp, bool is_quest); -typedef unsigned int (*HPMHOOK_pre_pc_nextbaseexp) (struct map_session_data **sd); -typedef unsigned int (*HPMHOOK_post_pc_nextbaseexp) (unsigned int retVal___, struct map_session_data *sd); -typedef unsigned int (*HPMHOOK_pre_pc_thisbaseexp) (struct map_session_data **sd); -typedef unsigned int (*HPMHOOK_post_pc_thisbaseexp) (unsigned int retVal___, struct map_session_data *sd); -typedef unsigned int (*HPMHOOK_pre_pc_nextjobexp) (struct map_session_data **sd); -typedef unsigned int (*HPMHOOK_post_pc_nextjobexp) (unsigned int retVal___, struct map_session_data *sd); -typedef unsigned int (*HPMHOOK_pre_pc_thisjobexp) (struct map_session_data **sd); -typedef unsigned int (*HPMHOOK_post_pc_thisjobexp) (unsigned int retVal___, struct map_session_data *sd); +typedef unsigned int (*HPMHOOK_pre_pc_nextbaseexp) (const struct map_session_data **sd); +typedef unsigned int (*HPMHOOK_post_pc_nextbaseexp) (unsigned int retVal___, const struct map_session_data *sd); +typedef unsigned int (*HPMHOOK_pre_pc_thisbaseexp) (const struct map_session_data **sd); +typedef unsigned int (*HPMHOOK_post_pc_thisbaseexp) (unsigned int retVal___, const struct map_session_data *sd); +typedef unsigned int (*HPMHOOK_pre_pc_nextjobexp) (const struct map_session_data **sd); +typedef unsigned int (*HPMHOOK_post_pc_nextjobexp) (unsigned int retVal___, const struct map_session_data *sd); +typedef unsigned int (*HPMHOOK_pre_pc_thisjobexp) (const struct map_session_data **sd); +typedef unsigned int (*HPMHOOK_post_pc_thisjobexp) (unsigned int retVal___, const struct map_session_data *sd); typedef int (*HPMHOOK_pre_pc_gets_status_point) (int *level); typedef int (*HPMHOOK_post_pc_gets_status_point) (int retVal___, int level); typedef int (*HPMHOOK_pre_pc_need_status_point) (struct map_session_data **sd, int *type, int *val); @@ -5294,8 +5358,8 @@ typedef int (*HPMHOOK_pre_pc_changelook) (struct map_session_data **sd, int *typ typedef int (*HPMHOOK_post_pc_changelook) (int retVal___, struct map_session_data *sd, int type, int val); typedef int (*HPMHOOK_pre_pc_equiplookall) (struct map_session_data **sd); typedef int (*HPMHOOK_post_pc_equiplookall) (int retVal___, struct map_session_data *sd); -typedef int (*HPMHOOK_pre_pc_readparam) (struct map_session_data **sd, int *type); -typedef int (*HPMHOOK_post_pc_readparam) (int retVal___, struct map_session_data *sd, int type); +typedef int (*HPMHOOK_pre_pc_readparam) (const struct map_session_data **sd, int *type); +typedef int (*HPMHOOK_post_pc_readparam) (int retVal___, const struct map_session_data *sd, int type); typedef int (*HPMHOOK_pre_pc_setparam) (struct map_session_data **sd, int *type, int *val); typedef int (*HPMHOOK_post_pc_setparam) (int retVal___, struct map_session_data *sd, int type, int val); typedef int (*HPMHOOK_pre_pc_readreg) (struct map_session_data **sd, int64 *reg); @@ -5653,6 +5717,24 @@ typedef int (*HPMHOOK_post_quest_read_db) (int retVal___); typedef struct quest_db* (*HPMHOOK_pre_quest_read_db_sub) (struct config_setting_t **cs, int *n, const char **source); typedef struct quest_db* (*HPMHOOK_post_quest_read_db_sub) (struct quest_db* retVal___, struct config_setting_t *cs, int n, const char *source); #endif // MAP_QUEST_H +#ifdef COMMON_RANDOM_H /* rnd */ +typedef void (*HPMHOOK_pre_rnd_init) (void); +typedef void (*HPMHOOK_post_rnd_init) (void); +typedef void (*HPMHOOK_pre_rnd_final) (void); +typedef void (*HPMHOOK_post_rnd_final) (void); +typedef void (*HPMHOOK_pre_rnd_seed) (uint32 *seed); +typedef void (*HPMHOOK_post_rnd_seed) (uint32 seed); +typedef int32 (*HPMHOOK_pre_rnd_random) (void); +typedef int32 (*HPMHOOK_post_rnd_random) (int32 retVal___); +typedef uint32 (*HPMHOOK_pre_rnd_roll) (uint32 *dice_faces); +typedef uint32 (*HPMHOOK_post_rnd_roll) (uint32 retVal___, uint32 dice_faces); +typedef int32 (*HPMHOOK_pre_rnd_value) (int32 *min, int32 *max); +typedef int32 (*HPMHOOK_post_rnd_value) (int32 retVal___, int32 min, int32 max); +typedef double (*HPMHOOK_pre_rnd_uniform) (void); +typedef double (*HPMHOOK_post_rnd_uniform) (double retVal___); +typedef double (*HPMHOOK_pre_rnd_uniform53) (void); +typedef double (*HPMHOOK_post_rnd_uniform53) (double retVal___); +#endif // COMMON_RANDOM_H #ifdef MAP_SCRIPT_H /* script */ typedef void (*HPMHOOK_pre_script_init) (bool *minimal); typedef void (*HPMHOOK_post_script_init) (bool minimal); @@ -5790,10 +5872,10 @@ typedef const char* (*HPMHOOK_pre_script_parse_syntax_close_sub) (const char **p typedef const char* (*HPMHOOK_post_script_parse_syntax_close_sub) (const char* retVal___, const char *p, int *flag); typedef const char* (*HPMHOOK_pre_script_parse_syntax) (const char **p); typedef const char* (*HPMHOOK_post_script_parse_syntax) (const char* retVal___, const char *p); -typedef c_op (*HPMHOOK_pre_script_get_com) (unsigned char **scriptbuf, int **pos); -typedef c_op (*HPMHOOK_post_script_get_com) (c_op retVal___, unsigned char *scriptbuf, int *pos); -typedef int (*HPMHOOK_pre_script_get_num) (unsigned char **scriptbuf, int **pos); -typedef int (*HPMHOOK_post_script_get_num) (int retVal___, unsigned char *scriptbuf, int *pos); +typedef c_op (*HPMHOOK_pre_script_get_com) (const struct script_buf **scriptbuf, int **pos); +typedef c_op (*HPMHOOK_post_script_get_com) (c_op retVal___, const struct script_buf *scriptbuf, int *pos); +typedef int (*HPMHOOK_pre_script_get_num) (const struct script_buf **scriptbuf, int **pos); +typedef int (*HPMHOOK_post_script_get_num) (int retVal___, const struct script_buf *scriptbuf, int *pos); typedef const char* (*HPMHOOK_pre_script_op2name) (int *op); typedef const char* (*HPMHOOK_post_script_op2name) (const char* retVal___, int op); typedef void (*HPMHOOK_pre_script_reportsrc) (struct script_state **st); @@ -5830,6 +5912,16 @@ typedef const char* (*HPMHOOK_pre_script_parse_variable) (const char **p); typedef const char* (*HPMHOOK_post_script_parse_variable) (const char* retVal___, const char *p); typedef const char* (*HPMHOOK_pre_script_parse_simpleexpr) (const char **p); typedef const char* (*HPMHOOK_post_script_parse_simpleexpr) (const char* retVal___, const char *p); +typedef const char* (*HPMHOOK_pre_script_parse_simpleexpr_paren) (const char **p); +typedef const char* (*HPMHOOK_post_script_parse_simpleexpr_paren) (const char* retVal___, const char *p); +typedef const char* (*HPMHOOK_pre_script_parse_simpleexpr_number) (const char **p); +typedef const char* (*HPMHOOK_post_script_parse_simpleexpr_number) (const char* retVal___, const char *p); +typedef const char* (*HPMHOOK_pre_script_parse_simpleexpr_string) (const char **p); +typedef const char* (*HPMHOOK_post_script_parse_simpleexpr_string) (const char* retVal___, const char *p); +typedef const char* (*HPMHOOK_pre_script_parse_simpleexpr_name) (const char **p); +typedef const char* (*HPMHOOK_post_script_parse_simpleexpr_name) (const char* retVal___, const char *p); +typedef void (*HPMHOOK_pre_script_add_translatable_string) (const struct script_string_buf **string, const char **start_point); +typedef void (*HPMHOOK_post_script_add_translatable_string) (const struct script_string_buf *string, const char *start_point); typedef const char* (*HPMHOOK_pre_script_parse_expr) (const char **p); typedef const char* (*HPMHOOK_post_script_parse_expr) (const char* retVal___, const char *p); typedef const char* (*HPMHOOK_pre_script_parse_line) (const char **p); @@ -5876,8 +5968,8 @@ typedef void (*HPMHOOK_pre_script_op_2) (struct script_state **st, int *op); typedef void (*HPMHOOK_post_script_op_2) (struct script_state *st, int op); typedef void (*HPMHOOK_pre_script_op_1) (struct script_state **st, int *op); typedef void (*HPMHOOK_post_script_op_1) (struct script_state *st, int op); -typedef void (*HPMHOOK_pre_script_check_buildin_argtype) (struct script_state **st, int *func); -typedef void (*HPMHOOK_post_script_check_buildin_argtype) (struct script_state *st, int func); +typedef bool (*HPMHOOK_pre_script_check_buildin_argtype) (struct script_state **st, int *func); +typedef bool (*HPMHOOK_post_script_check_buildin_argtype) (bool retVal___, struct script_state *st, int func); typedef void (*HPMHOOK_pre_script_detach_state) (struct script_state **st, bool *dequeue_event); typedef void (*HPMHOOK_post_script_detach_state) (struct script_state *st, bool dequeue_event); typedef int (*HPMHOOK_pre_script_db_free_code_sub) (union DBKey *key, struct DBData **data, va_list ap); @@ -5972,8 +6064,10 @@ typedef int (*HPMHOOK_pre_script_string_dup) (char **str); typedef int (*HPMHOOK_post_script_string_dup) (int retVal___, char *str); typedef void (*HPMHOOK_pre_script_load_translations) (void); typedef void (*HPMHOOK_post_script_load_translations) (void); -typedef void (*HPMHOOK_pre_script_load_translation) (const char **file, uint8 *lang_id, uint32 **total); -typedef void (*HPMHOOK_post_script_load_translation) (const char *file, uint8 lang_id, uint32 *total); +typedef bool (*HPMHOOK_pre_script_load_translation_addstring) (const char **file, uint8 *lang_id, const char **msgctxt, const struct script_string_buf **msgid, const struct script_string_buf **msgstr); +typedef bool (*HPMHOOK_post_script_load_translation_addstring) (bool retVal___, const char *file, uint8 lang_id, const char *msgctxt, const struct script_string_buf *msgid, const struct script_string_buf *msgstr); +typedef int (*HPMHOOK_pre_script_load_translation) (const char **file, uint8 *lang_id); +typedef int (*HPMHOOK_post_script_load_translation) (int retVal___, const char *file, uint8 lang_id); typedef int (*HPMHOOK_pre_script_translation_db_destroyer) (union DBKey *key, struct DBData **data, va_list ap); typedef int (*HPMHOOK_post_script_translation_db_destroyer) (int retVal___, union DBKey key, struct DBData *data, va_list ap); typedef void (*HPMHOOK_pre_script_clear_translations) (bool *reload); @@ -6222,8 +6316,12 @@ typedef int (*HPMHOOK_pre_skill_enchant_elemental_end) (struct block_list **bl, typedef int (*HPMHOOK_post_skill_enchant_elemental_end) (int retVal___, struct block_list *bl, int type); typedef int (*HPMHOOK_pre_skill_not_ok) (uint16 *skill_id, struct map_session_data **sd); typedef int (*HPMHOOK_post_skill_not_ok) (int retVal___, uint16 skill_id, struct map_session_data *sd); +typedef int (*HPMHOOK_pre_skill_not_ok_unknown) (uint16 *skill_id, struct map_session_data **sd); +typedef int (*HPMHOOK_post_skill_not_ok_unknown) (int retVal___, uint16 skill_id, struct map_session_data *sd); typedef int (*HPMHOOK_pre_skill_not_ok_hom) (uint16 *skill_id, struct homun_data **hd); typedef int (*HPMHOOK_post_skill_not_ok_hom) (int retVal___, uint16 skill_id, struct homun_data *hd); +typedef int (*HPMHOOK_pre_skill_not_ok_hom_unknown) (uint16 *skill_id, struct homun_data **hd); +typedef int (*HPMHOOK_post_skill_not_ok_hom_unknown) (int retVal___, uint16 skill_id, struct homun_data *hd); typedef int (*HPMHOOK_pre_skill_not_ok_mercenary) (uint16 *skill_id, struct mercenary_data **md); typedef int (*HPMHOOK_post_skill_not_ok_mercenary) (int retVal___, uint16 skill_id, struct mercenary_data *md); typedef int (*HPMHOOK_pre_skill_chastle_mob_changetarget) (struct block_list **bl, va_list ap); @@ -6234,6 +6332,8 @@ typedef int (*HPMHOOK_pre_skill_produce_mix) (struct map_session_data **sd, uint typedef int (*HPMHOOK_post_skill_produce_mix) (int retVal___, struct map_session_data *sd, uint16 skill_id, int nameid, int slot1, int slot2, int slot3, int qty); typedef int (*HPMHOOK_pre_skill_arrow_create) (struct map_session_data **sd, int *nameid); typedef int (*HPMHOOK_post_skill_arrow_create) (int retVal___, struct map_session_data *sd, int nameid); +typedef void (*HPMHOOK_pre_skill_castend_type) (int *type, struct block_list **src, struct block_list **bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); +typedef void (*HPMHOOK_post_skill_castend_type) (int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); typedef int (*HPMHOOK_pre_skill_castend_nodamage_id) (struct block_list **src, struct block_list **bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); typedef int (*HPMHOOK_post_skill_castend_nodamage_id) (int retVal___, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); typedef int (*HPMHOOK_pre_skill_castend_damage_id) (struct block_list **src, struct block_list **bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); @@ -6318,6 +6418,8 @@ typedef void (*HPMHOOK_pre_skill_unitsetmapcell) (struct skill_unit **src, uint1 typedef void (*HPMHOOK_post_skill_unitsetmapcell) (struct skill_unit *src, uint16 skill_id, uint16 skill_lv, cell_t cell, bool flag); typedef int (*HPMHOOK_pre_skill_unit_onplace_timer) (struct skill_unit **src, struct block_list **bl, int64 *tick); typedef int (*HPMHOOK_post_skill_unit_onplace_timer) (int retVal___, struct skill_unit *src, struct block_list *bl, int64 tick); +typedef void (*HPMHOOK_pre_skill_unit_onplace_timer_unknown) (struct skill_unit **src, struct block_list **bl, int64 **tick); +typedef void (*HPMHOOK_post_skill_unit_onplace_timer_unknown) (struct skill_unit *src, struct block_list *bl, int64 *tick); typedef int (*HPMHOOK_pre_skill_unit_effect) (struct block_list **bl, va_list ap); typedef int (*HPMHOOK_post_skill_unit_effect) (int retVal___, struct block_list *bl, va_list ap); typedef int (*HPMHOOK_pre_skill_unit_timer_sub_onplace) (struct block_list **bl, va_list ap); @@ -6338,16 +6440,44 @@ typedef int (*HPMHOOK_pre_skill_unit_timer_sub) (union DBKey *key, struct DBData typedef int (*HPMHOOK_post_skill_unit_timer_sub) (int retVal___, union DBKey key, struct DBData *data, va_list ap); typedef void (*HPMHOOK_pre_skill_init_unit_layout) (void); typedef void (*HPMHOOK_post_skill_init_unit_layout) (void); -typedef bool (*HPMHOOK_pre_skill_parse_row_skilldb) (char **split[], int *columns, int *current); -typedef bool (*HPMHOOK_post_skill_parse_row_skilldb) (bool retVal___, char *split[], int columns, int current); -typedef bool (*HPMHOOK_pre_skill_parse_row_requiredb) (char **split[], int *columns, int *current); -typedef bool (*HPMHOOK_post_skill_parse_row_requiredb) (bool retVal___, char *split[], int columns, int current); -typedef bool (*HPMHOOK_pre_skill_parse_row_castdb) (char **split[], int *columns, int *current); -typedef bool (*HPMHOOK_post_skill_parse_row_castdb) (bool retVal___, char *split[], int columns, int current); -typedef bool (*HPMHOOK_pre_skill_parse_row_castnodexdb) (char **split[], int *columns, int *current); -typedef bool (*HPMHOOK_post_skill_parse_row_castnodexdb) (bool retVal___, char *split[], int columns, int current); -typedef bool (*HPMHOOK_pre_skill_parse_row_unitdb) (char **split[], int *columns, int *current); -typedef bool (*HPMHOOK_post_skill_parse_row_unitdb) (bool retVal___, char *split[], int columns, int current); +typedef void (*HPMHOOK_pre_skill_init_unit_layout_unknown) (int *skill_idx); +typedef void (*HPMHOOK_post_skill_init_unit_layout_unknown) (int skill_idx); +typedef void (*HPMHOOK_pre_skill_validate_hittype) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_hittype) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_skilltype) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_skilltype) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_attacktype) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_attacktype) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_element) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_element) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_skillinfo) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_skillinfo) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_damagetype) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_damagetype) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_castnodex) (struct config_setting_t **conf, struct s_skill_db **sk, bool *delay); +typedef void (*HPMHOOK_post_skill_validate_castnodex) (struct config_setting_t *conf, struct s_skill_db *sk, bool delay); +typedef void (*HPMHOOK_pre_skill_validate_weapontype) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_weapontype) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_ammotype) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_ammotype) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_state) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_state) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_item_requirements) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_item_requirements) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_unit_target) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_unit_target) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_unit_flag) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_unit_flag) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef void (*HPMHOOK_pre_skill_validate_additional_fields) (struct config_setting_t **conf, struct s_skill_db **sk); +typedef void (*HPMHOOK_post_skill_validate_additional_fields) (struct config_setting_t *conf, struct s_skill_db *sk); +typedef bool (*HPMHOOK_pre_skill_validate_skilldb) (struct s_skill_db **skt, const char **source); +typedef bool (*HPMHOOK_post_skill_validate_skilldb) (bool retVal___, struct s_skill_db *skt, const char *source); +typedef bool (*HPMHOOK_pre_skill_read_skilldb) (const char **filename); +typedef bool (*HPMHOOK_post_skill_read_skilldb) (bool retVal___, const char *filename); +typedef void (*HPMHOOK_pre_skill_config_set_level) (struct config_setting_t **conf, int **arr); +typedef void (*HPMHOOK_post_skill_config_set_level) (struct config_setting_t *conf, int *arr); +typedef void (*HPMHOOK_pre_skill_level_set_value) (int **arr, int *value); +typedef void (*HPMHOOK_post_skill_level_set_value) (int *arr, int value); typedef bool (*HPMHOOK_pre_skill_parse_row_producedb) (char **split[], int *columns, int *current); typedef bool (*HPMHOOK_post_skill_parse_row_producedb) (bool retVal___, char *split[], int columns, int current); typedef bool (*HPMHOOK_pre_skill_parse_row_createarrowdb) (char **split[], int *columns, int *current); @@ -6460,6 +6590,12 @@ typedef bool (*HPMHOOK_pre_skill_get_requirement_item_unknown) (struct status_ch typedef bool (*HPMHOOK_post_skill_get_requirement_item_unknown) (bool retVal___, struct status_change *sc, struct map_session_data *sd, uint16 *skill_id, uint16 *skill_lv, uint16 *idx, int *i); typedef void (*HPMHOOK_pre_skill_get_requirement_unknown) (struct status_change **sc, struct map_session_data **sd, uint16 **skill_id, uint16 **skill_lv, struct skill_condition **req); typedef void (*HPMHOOK_post_skill_get_requirement_unknown) (struct status_change *sc, struct map_session_data *sd, uint16 *skill_id, uint16 *skill_lv, struct skill_condition *req); +typedef int (*HPMHOOK_pre_skill_splash_target) (struct block_list **bl); +typedef int (*HPMHOOK_post_skill_splash_target) (int retVal___, struct block_list *bl); +typedef int (*HPMHOOK_pre_skill_check_npc_chaospanic) (struct block_list **bl, va_list args); +typedef int (*HPMHOOK_post_skill_check_npc_chaospanic) (int retVal___, struct block_list *bl, va_list args); +typedef int (*HPMHOOK_pre_skill_count_wos) (struct block_list **bl, va_list ap); +typedef int (*HPMHOOK_post_skill_count_wos) (int retVal___, struct block_list *bl, va_list ap); #endif // MAP_SKILL_H #ifdef COMMON_SOCKET_H /* sockt */ typedef void (*HPMHOOK_pre_sockt_init) (void); @@ -6810,6 +6946,14 @@ typedef void (*HPMHOOK_pre_status_read_job_db) (void); typedef void (*HPMHOOK_post_status_read_job_db) (void); typedef void (*HPMHOOK_pre_status_read_job_db_sub) (int *idx, const char **name, struct config_setting_t **jdb); typedef void (*HPMHOOK_post_status_read_job_db_sub) (int idx, const char *name, struct config_setting_t *jdb); +typedef void (*HPMHOOK_pre_status_set_sc) (uint16 *skill_id, sc_type *sc, int *icon, unsigned int *flag); +typedef void (*HPMHOOK_post_status_set_sc) (uint16 skill_id, sc_type sc, int icon, unsigned int flag); +typedef void (*HPMHOOK_pre_status_copy) (struct status_data **a, const struct status_data **b); +typedef void (*HPMHOOK_post_status_copy) (struct status_data *a, const struct status_data *b); +typedef unsigned short (*HPMHOOK_pre_status_base_matk_min) (const struct status_data **st); +typedef unsigned short (*HPMHOOK_post_status_base_matk_min) (unsigned short retVal___, const struct status_data *st); +typedef unsigned short (*HPMHOOK_pre_status_base_matk_max) (const struct status_data **st); +typedef unsigned short (*HPMHOOK_post_status_base_matk_max) (unsigned short retVal___, const struct status_data *st); #endif // MAP_STATUS_H #ifdef MAP_STORAGE_H /* storage */ typedef void (*HPMHOOK_pre_storage_reconnect) (void); @@ -6947,6 +7091,30 @@ typedef void (*HPMHOOK_post_sysinfo_init) (void); typedef void (*HPMHOOK_pre_sysinfo_final) (void); typedef void (*HPMHOOK_post_sysinfo_final) (void); #endif // COMMON_SYSINFO_H +#ifdef COMMON_THREAD_H /* thread */ +typedef void (*HPMHOOK_pre_thread_init) (void); +typedef void (*HPMHOOK_post_thread_init) (void); +typedef void (*HPMHOOK_pre_thread_final) (void); +typedef void (*HPMHOOK_post_thread_final) (void); +typedef struct thread_handle* (*HPMHOOK_pre_thread_create) (threadFunc *entry_point, void **param); +typedef struct thread_handle* (*HPMHOOK_post_thread_create) (struct thread_handle* retVal___, threadFunc entry_point, void *param); +typedef struct thread_handle* (*HPMHOOK_pre_thread_create_opt) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio); +typedef struct thread_handle* (*HPMHOOK_post_thread_create_opt) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); +typedef void (*HPMHOOK_pre_thread_destroy) (struct thread_handle **handle); +typedef void (*HPMHOOK_post_thread_destroy) (struct thread_handle *handle); +typedef struct thread_handle* (*HPMHOOK_pre_thread_self) (void); +typedef struct thread_handle* (*HPMHOOK_post_thread_self) (struct thread_handle* retVal___); +typedef int (*HPMHOOK_pre_thread_get_tid) (void); +typedef int (*HPMHOOK_post_thread_get_tid) (int retVal___); +typedef bool (*HPMHOOK_pre_thread_wait) (struct thread_handle **handle, void ***out_exit_code); +typedef bool (*HPMHOOK_post_thread_wait) (bool retVal___, struct thread_handle *handle, void **out_exit_code); +typedef void (*HPMHOOK_pre_thread_prio_set) (struct thread_handle **handle, enum thread_priority *prio); +typedef void (*HPMHOOK_post_thread_prio_set) (struct thread_handle *handle, enum thread_priority prio); +typedef enum thread_priority (*HPMHOOK_pre_thread_prio_get) (struct thread_handle **handle); +typedef enum thread_priority (*HPMHOOK_post_thread_prio_get) (enum thread_priority retVal___, struct thread_handle *handle); +typedef void (*HPMHOOK_pre_thread_yield) (void); +typedef void (*HPMHOOK_post_thread_yield) (void); +#endif // COMMON_THREAD_H #ifdef COMMON_TIMER_H /* timer */ typedef int64 (*HPMHOOK_pre_timer_gettick) (void); typedef int64 (*HPMHOOK_post_timer_gettick) (int64 retVal___); diff --git a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc index 7210920e5..f51ddcffc 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + struct { struct HPMHookPoint *HP_HCache_init_pre; struct HPMHookPoint *HP_HCache_init_post; @@ -406,6 +408,10 @@ struct { struct HPMHookPoint *HP_DB_init_post; struct HPMHookPoint *HP_DB_final_pre; struct HPMHookPoint *HP_DB_final_post; + struct HPMHookPoint *HP_des_decrypt_block_pre; + struct HPMHookPoint *HP_des_decrypt_block_post; + struct HPMHookPoint *HP_des_decrypt_pre; + struct HPMHookPoint *HP_des_decrypt_post; struct HPMHookPoint *HP_geoip_getcountry_pre; struct HPMHookPoint *HP_geoip_getcountry_post; struct HPMHookPoint *HP_geoip_final_pre; @@ -1150,6 +1156,32 @@ struct { struct HPMHookPoint *HP_mapindex_id2name_post; struct HPMHookPoint *HP_mapindex_check_default_pre; struct HPMHookPoint *HP_mapindex_check_default_post; + struct HPMHookPoint *HP_md5_string_pre; + struct HPMHookPoint *HP_md5_string_post; + struct HPMHookPoint *HP_md5_binary_pre; + struct HPMHookPoint *HP_md5_binary_post; + struct HPMHookPoint *HP_md5_salt_pre; + struct HPMHookPoint *HP_md5_salt_post; + struct HPMHookPoint *HP_mutex_create_pre; + struct HPMHookPoint *HP_mutex_create_post; + struct HPMHookPoint *HP_mutex_destroy_pre; + struct HPMHookPoint *HP_mutex_destroy_post; + struct HPMHookPoint *HP_mutex_lock_pre; + struct HPMHookPoint *HP_mutex_lock_post; + struct HPMHookPoint *HP_mutex_trylock_pre; + struct HPMHookPoint *HP_mutex_trylock_post; + struct HPMHookPoint *HP_mutex_unlock_pre; + struct HPMHookPoint *HP_mutex_unlock_post; + struct HPMHookPoint *HP_mutex_cond_create_pre; + struct HPMHookPoint *HP_mutex_cond_create_post; + struct HPMHookPoint *HP_mutex_cond_destroy_pre; + struct HPMHookPoint *HP_mutex_cond_destroy_post; + struct HPMHookPoint *HP_mutex_cond_wait_pre; + struct HPMHookPoint *HP_mutex_cond_wait_post; + struct HPMHookPoint *HP_mutex_cond_signal_pre; + struct HPMHookPoint *HP_mutex_cond_signal_post; + struct HPMHookPoint *HP_mutex_cond_broadcast_pre; + struct HPMHookPoint *HP_mutex_cond_broadcast_post; struct HPMHookPoint *HP_nullpo_assert_report_pre; struct HPMHookPoint *HP_nullpo_assert_report_post; struct HPMHookPoint *HP_pincode_handle_pre; @@ -1172,6 +1204,22 @@ struct { struct HPMHookPoint *HP_pincode_check_post; struct HPMHookPoint *HP_pincode_config_read_pre; struct HPMHookPoint *HP_pincode_config_read_post; + struct HPMHookPoint *HP_rnd_init_pre; + struct HPMHookPoint *HP_rnd_init_post; + struct HPMHookPoint *HP_rnd_final_pre; + struct HPMHookPoint *HP_rnd_final_post; + struct HPMHookPoint *HP_rnd_seed_pre; + struct HPMHookPoint *HP_rnd_seed_post; + struct HPMHookPoint *HP_rnd_random_pre; + struct HPMHookPoint *HP_rnd_random_post; + struct HPMHookPoint *HP_rnd_roll_pre; + struct HPMHookPoint *HP_rnd_roll_post; + struct HPMHookPoint *HP_rnd_value_pre; + struct HPMHookPoint *HP_rnd_value_post; + struct HPMHookPoint *HP_rnd_uniform_pre; + struct HPMHookPoint *HP_rnd_uniform_post; + struct HPMHookPoint *HP_rnd_uniform53_pre; + struct HPMHookPoint *HP_rnd_uniform53_post; struct HPMHookPoint *HP_showmsg_init_pre; struct HPMHookPoint *HP_showmsg_init_post; struct HPMHookPoint *HP_showmsg_final_pre; @@ -1400,6 +1448,28 @@ struct { struct HPMHookPoint *HP_sysinfo_init_post; struct HPMHookPoint *HP_sysinfo_final_pre; struct HPMHookPoint *HP_sysinfo_final_post; + struct HPMHookPoint *HP_thread_init_pre; + struct HPMHookPoint *HP_thread_init_post; + struct HPMHookPoint *HP_thread_final_pre; + struct HPMHookPoint *HP_thread_final_post; + struct HPMHookPoint *HP_thread_create_pre; + struct HPMHookPoint *HP_thread_create_post; + struct HPMHookPoint *HP_thread_create_opt_pre; + struct HPMHookPoint *HP_thread_create_opt_post; + struct HPMHookPoint *HP_thread_destroy_pre; + struct HPMHookPoint *HP_thread_destroy_post; + struct HPMHookPoint *HP_thread_self_pre; + struct HPMHookPoint *HP_thread_self_post; + struct HPMHookPoint *HP_thread_get_tid_pre; + struct HPMHookPoint *HP_thread_get_tid_post; + struct HPMHookPoint *HP_thread_wait_pre; + struct HPMHookPoint *HP_thread_wait_post; + struct HPMHookPoint *HP_thread_prio_set_pre; + struct HPMHookPoint *HP_thread_prio_set_post; + struct HPMHookPoint *HP_thread_prio_get_pre; + struct HPMHookPoint *HP_thread_prio_get_post; + struct HPMHookPoint *HP_thread_yield_pre; + struct HPMHookPoint *HP_thread_yield_post; struct HPMHookPoint *HP_timer_gettick_pre; struct HPMHookPoint *HP_timer_gettick_post; struct HPMHookPoint *HP_timer_gettick_nocache_pre; @@ -1811,6 +1881,10 @@ struct { int HP_DB_init_post; int HP_DB_final_pre; int HP_DB_final_post; + int HP_des_decrypt_block_pre; + int HP_des_decrypt_block_post; + int HP_des_decrypt_pre; + int HP_des_decrypt_post; int HP_geoip_getcountry_pre; int HP_geoip_getcountry_post; int HP_geoip_final_pre; @@ -2555,6 +2629,32 @@ struct { int HP_mapindex_id2name_post; int HP_mapindex_check_default_pre; int HP_mapindex_check_default_post; + int HP_md5_string_pre; + int HP_md5_string_post; + int HP_md5_binary_pre; + int HP_md5_binary_post; + int HP_md5_salt_pre; + int HP_md5_salt_post; + int HP_mutex_create_pre; + int HP_mutex_create_post; + int HP_mutex_destroy_pre; + int HP_mutex_destroy_post; + int HP_mutex_lock_pre; + int HP_mutex_lock_post; + int HP_mutex_trylock_pre; + int HP_mutex_trylock_post; + int HP_mutex_unlock_pre; + int HP_mutex_unlock_post; + int HP_mutex_cond_create_pre; + int HP_mutex_cond_create_post; + int HP_mutex_cond_destroy_pre; + int HP_mutex_cond_destroy_post; + int HP_mutex_cond_wait_pre; + int HP_mutex_cond_wait_post; + int HP_mutex_cond_signal_pre; + int HP_mutex_cond_signal_post; + int HP_mutex_cond_broadcast_pre; + int HP_mutex_cond_broadcast_post; int HP_nullpo_assert_report_pre; int HP_nullpo_assert_report_post; int HP_pincode_handle_pre; @@ -2577,6 +2677,22 @@ struct { int HP_pincode_check_post; int HP_pincode_config_read_pre; int HP_pincode_config_read_post; + int HP_rnd_init_pre; + int HP_rnd_init_post; + int HP_rnd_final_pre; + int HP_rnd_final_post; + int HP_rnd_seed_pre; + int HP_rnd_seed_post; + int HP_rnd_random_pre; + int HP_rnd_random_post; + int HP_rnd_roll_pre; + int HP_rnd_roll_post; + int HP_rnd_value_pre; + int HP_rnd_value_post; + int HP_rnd_uniform_pre; + int HP_rnd_uniform_post; + int HP_rnd_uniform53_pre; + int HP_rnd_uniform53_post; int HP_showmsg_init_pre; int HP_showmsg_init_post; int HP_showmsg_final_pre; @@ -2805,6 +2921,28 @@ struct { int HP_sysinfo_init_post; int HP_sysinfo_final_pre; int HP_sysinfo_final_post; + int HP_thread_init_pre; + int HP_thread_init_post; + int HP_thread_final_pre; + int HP_thread_final_post; + int HP_thread_create_pre; + int HP_thread_create_post; + int HP_thread_create_opt_pre; + int HP_thread_create_opt_post; + int HP_thread_destroy_pre; + int HP_thread_destroy_post; + int HP_thread_self_pre; + int HP_thread_self_post; + int HP_thread_get_tid_pre; + int HP_thread_get_tid_post; + int HP_thread_wait_pre; + int HP_thread_wait_post; + int HP_thread_prio_set_pre; + int HP_thread_prio_set_post; + int HP_thread_prio_get_pre; + int HP_thread_prio_get_post; + int HP_thread_yield_pre; + int HP_thread_yield_post; int HP_timer_gettick_pre; int HP_timer_gettick_post; int HP_timer_gettick_nocache_pre; @@ -2840,6 +2978,7 @@ struct { struct console_interface console; struct core_interface core; struct db_interface DB; + struct des_interface des; struct geoip_interface geoip; struct inter_auction_interface inter_auction; struct inter_elemental_interface inter_elemental; @@ -2857,8 +2996,11 @@ struct { struct malloc_interface iMalloc; struct mapif_interface mapif; struct mapindex_interface mapindex; + struct md5_interface md5; + struct mutex_interface mutex; struct nullpo_interface nullpo; struct pincode_interface pincode; + struct rnd_interface rnd; struct showmsg_interface showmsg; struct socket_interface sockt; struct sql_interface SQL; @@ -2866,5 +3008,6 @@ struct { struct strlib_interface strlib; struct sv_interface sv; struct sysinfo_interface sysinfo; + struct thread_interface thread; struct timer_interface timer; } source; diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc index daa54e969..4371cf81a 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + struct HookingPointData HookingPoints[] = { /* HCache_interface */ { HP_POP(HCache->init, HP_HCache_init) }, @@ -221,6 +223,9 @@ struct HookingPointData HookingPoints[] = { { HP_POP(DB->data2ptr, HP_DB_data2ptr) }, { HP_POP(DB->init, HP_DB_init) }, { HP_POP(DB->final, HP_DB_final) }, +/* des_interface */ + { HP_POP(des->decrypt_block, HP_des_decrypt_block) }, + { HP_POP(des->decrypt, HP_des_decrypt) }, /* geoip_interface */ { HP_POP(geoip->getcountry, HP_geoip_getcountry) }, { HP_POP(geoip->final, HP_geoip_final) }, @@ -610,6 +615,21 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapindex->name2id, HP_mapindex_name2id) }, { HP_POP(mapindex->id2name, HP_mapindex_id2name) }, { HP_POP(mapindex->check_default, HP_mapindex_check_default) }, +/* md5_interface */ + { HP_POP(md5->string, HP_md5_string) }, + { HP_POP(md5->binary, HP_md5_binary) }, + { HP_POP(md5->salt, HP_md5_salt) }, +/* mutex_interface */ + { HP_POP(mutex->create, HP_mutex_create) }, + { HP_POP(mutex->destroy, HP_mutex_destroy) }, + { HP_POP(mutex->lock, HP_mutex_lock) }, + { HP_POP(mutex->trylock, HP_mutex_trylock) }, + { HP_POP(mutex->unlock, HP_mutex_unlock) }, + { HP_POP(mutex->cond_create, HP_mutex_cond_create) }, + { HP_POP(mutex->cond_destroy, HP_mutex_cond_destroy) }, + { HP_POP(mutex->cond_wait, HP_mutex_cond_wait) }, + { HP_POP(mutex->cond_signal, HP_mutex_cond_signal) }, + { HP_POP(mutex->cond_broadcast, HP_mutex_cond_broadcast) }, /* nullpo_interface */ { HP_POP(nullpo->assert_report, HP_nullpo_assert_report) }, /* pincode_interface */ @@ -623,6 +643,15 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pincode->compare, HP_pincode_compare) }, { HP_POP(pincode->check, HP_pincode_check) }, { HP_POP(pincode->config_read, HP_pincode_config_read) }, +/* rnd_interface */ + { HP_POP(rnd->init, HP_rnd_init) }, + { HP_POP(rnd->final, HP_rnd_final) }, + { HP_POP(rnd->seed, HP_rnd_seed) }, + { HP_POP(rnd->random, HP_rnd_random) }, + { HP_POP(rnd->roll, HP_rnd_roll) }, + { HP_POP(rnd->value, HP_rnd_value) }, + { HP_POP(rnd->uniform, HP_rnd_uniform) }, + { HP_POP(rnd->uniform53, HP_rnd_uniform53) }, /* showmsg_interface */ { HP_POP(showmsg->init, HP_showmsg_init) }, { HP_POP(showmsg->final, HP_showmsg_final) }, @@ -744,6 +773,18 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, +/* thread_interface */ + { HP_POP(thread->init, HP_thread_init) }, + { HP_POP(thread->final, HP_thread_final) }, + { HP_POP(thread->create, HP_thread_create) }, + { HP_POP(thread->create_opt, HP_thread_create_opt) }, + { HP_POP(thread->destroy, HP_thread_destroy) }, + { HP_POP(thread->self, HP_thread_self) }, + { HP_POP(thread->get_tid, HP_thread_get_tid) }, + { HP_POP(thread->wait, HP_thread_wait) }, + { HP_POP(thread->prio_set, HP_thread_prio_set) }, + { HP_POP(thread->prio_get, HP_thread_prio_get) }, + { HP_POP(thread->yield, HP_thread_yield) }, /* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index df277f3d9..aecffbecd 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + /* HCache_interface */ void HP_HCache_init(void) { int hIndex = 0; @@ -5098,6 +5100,59 @@ void HP_DB_final(void) { } return; } +/* des_interface */ +void HP_des_decrypt_block(struct des_bit64 *block) { + int hIndex = 0; + if( HPMHooks.count.HP_des_decrypt_block_pre ) { + void (*preHookFunc) (struct des_bit64 **block); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_des_decrypt_block_pre[hIndex].func; + preHookFunc(&block); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.des.decrypt_block(block); + } + if( HPMHooks.count.HP_des_decrypt_block_post ) { + void (*postHookFunc) (struct des_bit64 *block); + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_des_decrypt_block_post[hIndex].func; + postHookFunc(block); + } + } + return; +} +void HP_des_decrypt(unsigned char *data, size_t size) { + int hIndex = 0; + if( HPMHooks.count.HP_des_decrypt_pre ) { + void (*preHookFunc) (unsigned char **data, size_t *size); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_des_decrypt_pre[hIndex].func; + preHookFunc(&data, &size); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.des.decrypt(data, size); + } + if( HPMHooks.count.HP_des_decrypt_post ) { + void (*postHookFunc) (unsigned char *data, size_t size); + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_des_decrypt_post[hIndex].func; + postHookFunc(data, size); + } + } + return; +} /* geoip_interface */ const char* HP_geoip_getcountry(uint32 ipnum) { int hIndex = 0; @@ -15065,6 +15120,349 @@ bool HP_mapindex_check_default(void) { } return retVal___; } +/* md5_interface */ +void HP_md5_string(const char *string, char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_string_pre ) { + void (*preHookFunc) (const char **string, char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_string_pre[hIndex].func; + preHookFunc(&string, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.string(string, output); + } + if( HPMHooks.count.HP_md5_string_post ) { + void (*postHookFunc) (const char *string, char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_string_post[hIndex].func; + postHookFunc(string, output); + } + } + return; +} +void HP_md5_binary(const char *string, unsigned char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_binary_pre ) { + void (*preHookFunc) (const char **string, unsigned char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func; + preHookFunc(&string, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.binary(string, output); + } + if( HPMHooks.count.HP_md5_binary_post ) { + void (*postHookFunc) (const char *string, unsigned char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func; + postHookFunc(string, output); + } + } + return; +} +void HP_md5_salt(int len, char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_salt_pre ) { + void (*preHookFunc) (int *len, char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_salt_pre[hIndex].func; + preHookFunc(&len, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.salt(len, output); + } + if( HPMHooks.count.HP_md5_salt_post ) { + void (*postHookFunc) (int len, char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_salt_post[hIndex].func; + postHookFunc(len, output); + } + } + return; +} +/* mutex_interface */ +struct mutex_data* HP_mutex_create(void) { + int hIndex = 0; + struct mutex_data* retVal___ = NULL; + if( HPMHooks.count.HP_mutex_create_pre ) { + struct mutex_data* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_create_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.create(); + } + if( HPMHooks.count.HP_mutex_create_post ) { + struct mutex_data* (*postHookFunc) (struct mutex_data* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +void HP_mutex_destroy(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_destroy_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_destroy_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.destroy(m); + } + if( HPMHooks.count.HP_mutex_destroy_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_destroy_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +void HP_mutex_lock(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_lock_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_lock_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.lock(m); + } + if( HPMHooks.count.HP_mutex_lock_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_lock_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +bool HP_mutex_trylock(struct mutex_data *m) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_mutex_trylock_pre ) { + bool (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_trylock_pre[hIndex].func; + retVal___ = preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.trylock(m); + } + if( HPMHooks.count.HP_mutex_trylock_post ) { + bool (*postHookFunc) (bool retVal___, struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_trylock_post[hIndex].func; + retVal___ = postHookFunc(retVal___, m); + } + } + return retVal___; +} +void HP_mutex_unlock(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_unlock_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_unlock_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.unlock(m); + } + if( HPMHooks.count.HP_mutex_unlock_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_unlock_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +struct cond_data* HP_mutex_cond_create(void) { + int hIndex = 0; + struct cond_data* retVal___ = NULL; + if( HPMHooks.count.HP_mutex_cond_create_pre ) { + struct cond_data* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_create_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.cond_create(); + } + if( HPMHooks.count.HP_mutex_cond_create_post ) { + struct cond_data* (*postHookFunc) (struct cond_data* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +void HP_mutex_cond_destroy(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_destroy_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_destroy_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_destroy(c); + } + if( HPMHooks.count.HP_mutex_cond_destroy_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_destroy_post[hIndex].func; + postHookFunc(c); + } + } + return; +} +void HP_mutex_cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_wait_pre ) { + void (*preHookFunc) (struct cond_data **c, struct mutex_data **m, sysint *timeout_ticks); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_wait_pre[hIndex].func; + preHookFunc(&c, &m, &timeout_ticks); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_wait(c, m, timeout_ticks); + } + if( HPMHooks.count.HP_mutex_cond_wait_post ) { + void (*postHookFunc) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_wait_post[hIndex].func; + postHookFunc(c, m, timeout_ticks); + } + } + return; +} +void HP_mutex_cond_signal(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_signal_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_signal_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_signal(c); + } + if( HPMHooks.count.HP_mutex_cond_signal_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_signal_post[hIndex].func; + postHookFunc(c); + } + } + return; +} +void HP_mutex_cond_broadcast(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_broadcast_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_broadcast(c); + } + if( HPMHooks.count.HP_mutex_cond_broadcast_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_post[hIndex].func; + postHookFunc(c); + } + } + return; +} /* nullpo_interface */ void HP_nullpo_assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) { int hIndex = 0; @@ -15355,6 +15753,220 @@ bool HP_pincode_config_read(char *w1, char *w2) { } return retVal___; } +/* rnd_interface */ +void HP_rnd_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.init(); + } + if( HPMHooks.count.HP_rnd_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.final(); + } + if( HPMHooks.count.HP_rnd_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_seed(uint32 seed) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_seed_pre ) { + void (*preHookFunc) (uint32 *seed); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func; + preHookFunc(&seed); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.seed(seed); + } + if( HPMHooks.count.HP_rnd_seed_post ) { + void (*postHookFunc) (uint32 seed); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func; + postHookFunc(seed); + } + } + return; +} +int32 HP_rnd_random(void) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_random_pre ) { + int32 (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.random(); + } + if( HPMHooks.count.HP_rnd_random_post ) { + int32 (*postHookFunc) (int32 retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +uint32 HP_rnd_roll(uint32 dice_faces) { + int hIndex = 0; + uint32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_roll_pre ) { + uint32 (*preHookFunc) (uint32 *dice_faces); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func; + retVal___ = preHookFunc(&dice_faces); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.roll(dice_faces); + } + if( HPMHooks.count.HP_rnd_roll_post ) { + uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func; + retVal___ = postHookFunc(retVal___, dice_faces); + } + } + return retVal___; +} +int32 HP_rnd_value(int32 min, int32 max) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_value_pre ) { + int32 (*preHookFunc) (int32 *min, int32 *max); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func; + retVal___ = preHookFunc(&min, &max); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.value(min, max); + } + if( HPMHooks.count.HP_rnd_value_post ) { + int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func; + retVal___ = postHookFunc(retVal___, min, max); + } + } + return retVal___; +} +double HP_rnd_uniform(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform(); + } + if( HPMHooks.count.HP_rnd_uniform_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +double HP_rnd_uniform53(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform53_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform53(); + } + if( HPMHooks.count.HP_rnd_uniform53_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} /* showmsg_interface */ void HP_showmsg_init(void) { int hIndex = 0; @@ -18438,6 +19050,299 @@ void HP_sysinfo_final(void) { } return; } +/* thread_interface */ +void HP_thread_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.init(); + } + if( HPMHooks.count.HP_thread_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_thread_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.final(); + } + if( HPMHooks.count.HP_thread_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create(entry_point, param); + } + if( HPMHooks.count.HP_thread_create_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param); + } + } + return retVal___; +} +struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_opt_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m, &stack_size, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio); + } + if( HPMHooks.count.HP_thread_create_opt_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio); + } + } + return retVal___; +} +void HP_thread_destroy(struct thread_handle *handle) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_destroy_pre ) { + void (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func; + preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.destroy(handle); + } + if( HPMHooks.count.HP_thread_destroy_post ) { + void (*postHookFunc) (struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func; + postHookFunc(handle); + } + } + return; +} +struct thread_handle* HP_thread_self(void) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_self_pre ) { + struct thread_handle* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.self(); + } + if( HPMHooks.count.HP_thread_self_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +int HP_thread_get_tid(void) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_thread_get_tid_pre ) { + int (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.get_tid(); + } + if( HPMHooks.count.HP_thread_get_tid_post ) { + int (*postHookFunc) (int retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_thread_wait_pre ) { + bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func; + retVal___ = preHookFunc(&handle, &out_exit_code); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code); + } + if( HPMHooks.count.HP_thread_wait_post ) { + bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle, out_exit_code); + } + } + return retVal___; +} +void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_prio_set_pre ) { + void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func; + preHookFunc(&handle, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.prio_set(handle, prio); + } + if( HPMHooks.count.HP_thread_prio_set_post ) { + void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func; + postHookFunc(handle, prio); + } + } + return; +} +enum thread_priority HP_thread_prio_get(struct thread_handle *handle) { + int hIndex = 0; + enum thread_priority retVal___ = THREADPRIO_NORMAL; + if( HPMHooks.count.HP_thread_prio_get_pre ) { + enum thread_priority (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func; + retVal___ = preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.prio_get(handle); + } + if( HPMHooks.count.HP_thread_prio_get_post ) { + enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle); + } + } + return retVal___; +} +void HP_thread_yield(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_yield_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.yield(); + } + if( HPMHooks.count.HP_thread_yield_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func; + postHookFunc(); + } + } + return; +} /* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_char.sources.inc b/src/plugins/HPMHooking/HPMHooking_char.sources.inc index d14117add..54ae8f030 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.sources.inc @@ -23,12 +23,15 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + memcpy(&HPMHooks.source.HCache, HCache, sizeof(struct HCache_interface)); memcpy(&HPMHooks.source.chr, chr, sizeof(struct char_interface)); memcpy(&HPMHooks.source.cmdline, cmdline, sizeof(struct cmdline_interface)); memcpy(&HPMHooks.source.console, console, sizeof(struct console_interface)); memcpy(&HPMHooks.source.core, core, sizeof(struct core_interface)); memcpy(&HPMHooks.source.DB, DB, sizeof(struct db_interface)); +memcpy(&HPMHooks.source.des, des, sizeof(struct des_interface)); memcpy(&HPMHooks.source.geoip, geoip, sizeof(struct geoip_interface)); memcpy(&HPMHooks.source.inter_auction, inter_auction, sizeof(struct inter_auction_interface)); memcpy(&HPMHooks.source.inter_elemental, inter_elemental, sizeof(struct inter_elemental_interface)); @@ -46,8 +49,11 @@ memcpy(&HPMHooks.source.loginif, loginif, sizeof(struct loginif_interface)); memcpy(&HPMHooks.source.iMalloc, iMalloc, sizeof(struct malloc_interface)); memcpy(&HPMHooks.source.mapif, mapif, sizeof(struct mapif_interface)); memcpy(&HPMHooks.source.mapindex, mapindex, sizeof(struct mapindex_interface)); +memcpy(&HPMHooks.source.md5, md5, sizeof(struct md5_interface)); +memcpy(&HPMHooks.source.mutex, mutex, sizeof(struct mutex_interface)); memcpy(&HPMHooks.source.nullpo, nullpo, sizeof(struct nullpo_interface)); memcpy(&HPMHooks.source.pincode, pincode, sizeof(struct pincode_interface)); +memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface)); memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface)); memcpy(&HPMHooks.source.sockt, sockt, sizeof(struct socket_interface)); memcpy(&HPMHooks.source.SQL, SQL, sizeof(struct sql_interface)); @@ -55,4 +61,5 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface)); memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface)); memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface)); memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface)); +memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface)); memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface)); diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index 88e4f51dd..b97b6ea7f 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + struct { struct HPMHookPoint *HP_HCache_init_pre; struct HPMHookPoint *HP_HCache_init_post; @@ -90,6 +92,10 @@ struct { struct HPMHookPoint *HP_DB_init_post; struct HPMHookPoint *HP_DB_final_pre; struct HPMHookPoint *HP_DB_final_post; + struct HPMHookPoint *HP_des_decrypt_block_pre; + struct HPMHookPoint *HP_des_decrypt_block_post; + struct HPMHookPoint *HP_des_decrypt_pre; + struct HPMHookPoint *HP_des_decrypt_post; struct HPMHookPoint *HP_lclif_init_pre; struct HPMHookPoint *HP_lclif_init_post; struct HPMHookPoint *HP_lclif_final_pre; @@ -398,8 +404,50 @@ struct { struct HPMHookPoint *HP_iMalloc_post_shutdown_post; struct HPMHookPoint *HP_iMalloc_init_messages_pre; struct HPMHookPoint *HP_iMalloc_init_messages_post; + struct HPMHookPoint *HP_md5_string_pre; + struct HPMHookPoint *HP_md5_string_post; + struct HPMHookPoint *HP_md5_binary_pre; + struct HPMHookPoint *HP_md5_binary_post; + struct HPMHookPoint *HP_md5_salt_pre; + struct HPMHookPoint *HP_md5_salt_post; + struct HPMHookPoint *HP_mutex_create_pre; + struct HPMHookPoint *HP_mutex_create_post; + struct HPMHookPoint *HP_mutex_destroy_pre; + struct HPMHookPoint *HP_mutex_destroy_post; + struct HPMHookPoint *HP_mutex_lock_pre; + struct HPMHookPoint *HP_mutex_lock_post; + struct HPMHookPoint *HP_mutex_trylock_pre; + struct HPMHookPoint *HP_mutex_trylock_post; + struct HPMHookPoint *HP_mutex_unlock_pre; + struct HPMHookPoint *HP_mutex_unlock_post; + struct HPMHookPoint *HP_mutex_cond_create_pre; + struct HPMHookPoint *HP_mutex_cond_create_post; + struct HPMHookPoint *HP_mutex_cond_destroy_pre; + struct HPMHookPoint *HP_mutex_cond_destroy_post; + struct HPMHookPoint *HP_mutex_cond_wait_pre; + struct HPMHookPoint *HP_mutex_cond_wait_post; + struct HPMHookPoint *HP_mutex_cond_signal_pre; + struct HPMHookPoint *HP_mutex_cond_signal_post; + struct HPMHookPoint *HP_mutex_cond_broadcast_pre; + struct HPMHookPoint *HP_mutex_cond_broadcast_post; struct HPMHookPoint *HP_nullpo_assert_report_pre; struct HPMHookPoint *HP_nullpo_assert_report_post; + struct HPMHookPoint *HP_rnd_init_pre; + struct HPMHookPoint *HP_rnd_init_post; + struct HPMHookPoint *HP_rnd_final_pre; + struct HPMHookPoint *HP_rnd_final_post; + struct HPMHookPoint *HP_rnd_seed_pre; + struct HPMHookPoint *HP_rnd_seed_post; + struct HPMHookPoint *HP_rnd_random_pre; + struct HPMHookPoint *HP_rnd_random_post; + struct HPMHookPoint *HP_rnd_roll_pre; + struct HPMHookPoint *HP_rnd_roll_post; + struct HPMHookPoint *HP_rnd_value_pre; + struct HPMHookPoint *HP_rnd_value_post; + struct HPMHookPoint *HP_rnd_uniform_pre; + struct HPMHookPoint *HP_rnd_uniform_post; + struct HPMHookPoint *HP_rnd_uniform53_pre; + struct HPMHookPoint *HP_rnd_uniform53_post; struct HPMHookPoint *HP_showmsg_init_pre; struct HPMHookPoint *HP_showmsg_init_post; struct HPMHookPoint *HP_showmsg_final_pre; @@ -628,6 +676,28 @@ struct { struct HPMHookPoint *HP_sysinfo_init_post; struct HPMHookPoint *HP_sysinfo_final_pre; struct HPMHookPoint *HP_sysinfo_final_post; + struct HPMHookPoint *HP_thread_init_pre; + struct HPMHookPoint *HP_thread_init_post; + struct HPMHookPoint *HP_thread_final_pre; + struct HPMHookPoint *HP_thread_final_post; + struct HPMHookPoint *HP_thread_create_pre; + struct HPMHookPoint *HP_thread_create_post; + struct HPMHookPoint *HP_thread_create_opt_pre; + struct HPMHookPoint *HP_thread_create_opt_post; + struct HPMHookPoint *HP_thread_destroy_pre; + struct HPMHookPoint *HP_thread_destroy_post; + struct HPMHookPoint *HP_thread_self_pre; + struct HPMHookPoint *HP_thread_self_post; + struct HPMHookPoint *HP_thread_get_tid_pre; + struct HPMHookPoint *HP_thread_get_tid_post; + struct HPMHookPoint *HP_thread_wait_pre; + struct HPMHookPoint *HP_thread_wait_post; + struct HPMHookPoint *HP_thread_prio_set_pre; + struct HPMHookPoint *HP_thread_prio_set_post; + struct HPMHookPoint *HP_thread_prio_get_pre; + struct HPMHookPoint *HP_thread_prio_get_post; + struct HPMHookPoint *HP_thread_yield_pre; + struct HPMHookPoint *HP_thread_yield_post; struct HPMHookPoint *HP_timer_gettick_pre; struct HPMHookPoint *HP_timer_gettick_post; struct HPMHookPoint *HP_timer_gettick_nocache_pre; @@ -723,6 +793,10 @@ struct { int HP_DB_init_post; int HP_DB_final_pre; int HP_DB_final_post; + int HP_des_decrypt_block_pre; + int HP_des_decrypt_block_post; + int HP_des_decrypt_pre; + int HP_des_decrypt_post; int HP_lclif_init_pre; int HP_lclif_init_post; int HP_lclif_final_pre; @@ -1031,8 +1105,50 @@ struct { int HP_iMalloc_post_shutdown_post; int HP_iMalloc_init_messages_pre; int HP_iMalloc_init_messages_post; + int HP_md5_string_pre; + int HP_md5_string_post; + int HP_md5_binary_pre; + int HP_md5_binary_post; + int HP_md5_salt_pre; + int HP_md5_salt_post; + int HP_mutex_create_pre; + int HP_mutex_create_post; + int HP_mutex_destroy_pre; + int HP_mutex_destroy_post; + int HP_mutex_lock_pre; + int HP_mutex_lock_post; + int HP_mutex_trylock_pre; + int HP_mutex_trylock_post; + int HP_mutex_unlock_pre; + int HP_mutex_unlock_post; + int HP_mutex_cond_create_pre; + int HP_mutex_cond_create_post; + int HP_mutex_cond_destroy_pre; + int HP_mutex_cond_destroy_post; + int HP_mutex_cond_wait_pre; + int HP_mutex_cond_wait_post; + int HP_mutex_cond_signal_pre; + int HP_mutex_cond_signal_post; + int HP_mutex_cond_broadcast_pre; + int HP_mutex_cond_broadcast_post; int HP_nullpo_assert_report_pre; int HP_nullpo_assert_report_post; + int HP_rnd_init_pre; + int HP_rnd_init_post; + int HP_rnd_final_pre; + int HP_rnd_final_post; + int HP_rnd_seed_pre; + int HP_rnd_seed_post; + int HP_rnd_random_pre; + int HP_rnd_random_post; + int HP_rnd_roll_pre; + int HP_rnd_roll_post; + int HP_rnd_value_pre; + int HP_rnd_value_post; + int HP_rnd_uniform_pre; + int HP_rnd_uniform_post; + int HP_rnd_uniform53_pre; + int HP_rnd_uniform53_post; int HP_showmsg_init_pre; int HP_showmsg_init_post; int HP_showmsg_final_pre; @@ -1261,6 +1377,28 @@ struct { int HP_sysinfo_init_post; int HP_sysinfo_final_pre; int HP_sysinfo_final_post; + int HP_thread_init_pre; + int HP_thread_init_post; + int HP_thread_final_pre; + int HP_thread_final_post; + int HP_thread_create_pre; + int HP_thread_create_post; + int HP_thread_create_opt_pre; + int HP_thread_create_opt_post; + int HP_thread_destroy_pre; + int HP_thread_destroy_post; + int HP_thread_self_pre; + int HP_thread_self_post; + int HP_thread_get_tid_pre; + int HP_thread_get_tid_post; + int HP_thread_wait_pre; + int HP_thread_wait_post; + int HP_thread_prio_set_pre; + int HP_thread_prio_set_post; + int HP_thread_prio_get_pre; + int HP_thread_prio_get_post; + int HP_thread_yield_pre; + int HP_thread_yield_post; int HP_timer_gettick_pre; int HP_timer_gettick_post; int HP_timer_gettick_nocache_pre; @@ -1295,12 +1433,16 @@ struct { struct console_interface console; struct core_interface core; struct db_interface DB; + struct des_interface des; struct lclif_interface lclif; struct lclif_interface_private PRIV__lclif; struct libconfig_interface libconfig; struct login_interface login; struct malloc_interface iMalloc; + struct md5_interface md5; + struct mutex_interface mutex; struct nullpo_interface nullpo; + struct rnd_interface rnd; struct showmsg_interface showmsg; struct socket_interface sockt; struct sql_interface SQL; @@ -1308,5 +1450,6 @@ struct { struct strlib_interface strlib; struct sv_interface sv; struct sysinfo_interface sysinfo; + struct thread_interface thread; struct timer_interface timer; } source; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index 21ca25355..2d3e37bc3 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + struct HookingPointData HookingPoints[] = { /* HCache_interface */ { HP_POP(HCache->init, HP_HCache_init) }, @@ -62,6 +64,9 @@ struct HookingPointData HookingPoints[] = { { HP_POP(DB->data2ptr, HP_DB_data2ptr) }, { HP_POP(DB->init, HP_DB_init) }, { HP_POP(DB->final, HP_DB_final) }, +/* des_interface */ + { HP_POP(des->decrypt_block, HP_des_decrypt_block) }, + { HP_POP(des->decrypt, HP_des_decrypt) }, /* lclif_interface */ { HP_POP(lclif->init, HP_lclif_init) }, { HP_POP(lclif->final, HP_lclif_final) }, @@ -221,8 +226,32 @@ struct HookingPointData HookingPoints[] = { { HP_POP(iMalloc->usage, HP_iMalloc_usage) }, { HP_POP(iMalloc->post_shutdown, HP_iMalloc_post_shutdown) }, { HP_POP(iMalloc->init_messages, HP_iMalloc_init_messages) }, +/* md5_interface */ + { HP_POP(md5->string, HP_md5_string) }, + { HP_POP(md5->binary, HP_md5_binary) }, + { HP_POP(md5->salt, HP_md5_salt) }, +/* mutex_interface */ + { HP_POP(mutex->create, HP_mutex_create) }, + { HP_POP(mutex->destroy, HP_mutex_destroy) }, + { HP_POP(mutex->lock, HP_mutex_lock) }, + { HP_POP(mutex->trylock, HP_mutex_trylock) }, + { HP_POP(mutex->unlock, HP_mutex_unlock) }, + { HP_POP(mutex->cond_create, HP_mutex_cond_create) }, + { HP_POP(mutex->cond_destroy, HP_mutex_cond_destroy) }, + { HP_POP(mutex->cond_wait, HP_mutex_cond_wait) }, + { HP_POP(mutex->cond_signal, HP_mutex_cond_signal) }, + { HP_POP(mutex->cond_broadcast, HP_mutex_cond_broadcast) }, /* nullpo_interface */ { HP_POP(nullpo->assert_report, HP_nullpo_assert_report) }, +/* rnd_interface */ + { HP_POP(rnd->init, HP_rnd_init) }, + { HP_POP(rnd->final, HP_rnd_final) }, + { HP_POP(rnd->seed, HP_rnd_seed) }, + { HP_POP(rnd->random, HP_rnd_random) }, + { HP_POP(rnd->roll, HP_rnd_roll) }, + { HP_POP(rnd->value, HP_rnd_value) }, + { HP_POP(rnd->uniform, HP_rnd_uniform) }, + { HP_POP(rnd->uniform53, HP_rnd_uniform53) }, /* showmsg_interface */ { HP_POP(showmsg->init, HP_showmsg_init) }, { HP_POP(showmsg->final, HP_showmsg_final) }, @@ -344,6 +373,18 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, +/* thread_interface */ + { HP_POP(thread->init, HP_thread_init) }, + { HP_POP(thread->final, HP_thread_final) }, + { HP_POP(thread->create, HP_thread_create) }, + { HP_POP(thread->create_opt, HP_thread_create_opt) }, + { HP_POP(thread->destroy, HP_thread_destroy) }, + { HP_POP(thread->self, HP_thread_self) }, + { HP_POP(thread->get_tid, HP_thread_get_tid) }, + { HP_POP(thread->wait, HP_thread_wait) }, + { HP_POP(thread->prio_set, HP_thread_prio_set) }, + { HP_POP(thread->prio_get, HP_thread_prio_get) }, + { HP_POP(thread->yield, HP_thread_yield) }, /* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index 3c31062b8..013a56104 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + /* HCache_interface */ void HP_HCache_init(void) { int hIndex = 0; @@ -909,6 +911,59 @@ void HP_DB_final(void) { } return; } +/* des_interface */ +void HP_des_decrypt_block(struct des_bit64 *block) { + int hIndex = 0; + if( HPMHooks.count.HP_des_decrypt_block_pre ) { + void (*preHookFunc) (struct des_bit64 **block); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_des_decrypt_block_pre[hIndex].func; + preHookFunc(&block); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.des.decrypt_block(block); + } + if( HPMHooks.count.HP_des_decrypt_block_post ) { + void (*postHookFunc) (struct des_bit64 *block); + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_des_decrypt_block_post[hIndex].func; + postHookFunc(block); + } + } + return; +} +void HP_des_decrypt(unsigned char *data, size_t size) { + int hIndex = 0; + if( HPMHooks.count.HP_des_decrypt_pre ) { + void (*preHookFunc) (unsigned char **data, size_t *size); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_des_decrypt_pre[hIndex].func; + preHookFunc(&data, &size); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.des.decrypt(data, size); + } + if( HPMHooks.count.HP_des_decrypt_post ) { + void (*postHookFunc) (unsigned char *data, size_t size); + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_des_decrypt_post[hIndex].func; + postHookFunc(data, size); + } + } + return; +} /* lclif_interface */ void HP_lclif_init(void) { int hIndex = 0; @@ -5034,6 +5089,349 @@ void HP_iMalloc_init_messages(void) { } return; } +/* md5_interface */ +void HP_md5_string(const char *string, char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_string_pre ) { + void (*preHookFunc) (const char **string, char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_string_pre[hIndex].func; + preHookFunc(&string, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.string(string, output); + } + if( HPMHooks.count.HP_md5_string_post ) { + void (*postHookFunc) (const char *string, char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_string_post[hIndex].func; + postHookFunc(string, output); + } + } + return; +} +void HP_md5_binary(const char *string, unsigned char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_binary_pre ) { + void (*preHookFunc) (const char **string, unsigned char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func; + preHookFunc(&string, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.binary(string, output); + } + if( HPMHooks.count.HP_md5_binary_post ) { + void (*postHookFunc) (const char *string, unsigned char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func; + postHookFunc(string, output); + } + } + return; +} +void HP_md5_salt(int len, char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_salt_pre ) { + void (*preHookFunc) (int *len, char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_salt_pre[hIndex].func; + preHookFunc(&len, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.salt(len, output); + } + if( HPMHooks.count.HP_md5_salt_post ) { + void (*postHookFunc) (int len, char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_salt_post[hIndex].func; + postHookFunc(len, output); + } + } + return; +} +/* mutex_interface */ +struct mutex_data* HP_mutex_create(void) { + int hIndex = 0; + struct mutex_data* retVal___ = NULL; + if( HPMHooks.count.HP_mutex_create_pre ) { + struct mutex_data* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_create_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.create(); + } + if( HPMHooks.count.HP_mutex_create_post ) { + struct mutex_data* (*postHookFunc) (struct mutex_data* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +void HP_mutex_destroy(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_destroy_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_destroy_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.destroy(m); + } + if( HPMHooks.count.HP_mutex_destroy_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_destroy_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +void HP_mutex_lock(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_lock_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_lock_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.lock(m); + } + if( HPMHooks.count.HP_mutex_lock_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_lock_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +bool HP_mutex_trylock(struct mutex_data *m) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_mutex_trylock_pre ) { + bool (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_trylock_pre[hIndex].func; + retVal___ = preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.trylock(m); + } + if( HPMHooks.count.HP_mutex_trylock_post ) { + bool (*postHookFunc) (bool retVal___, struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_trylock_post[hIndex].func; + retVal___ = postHookFunc(retVal___, m); + } + } + return retVal___; +} +void HP_mutex_unlock(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_unlock_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_unlock_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.unlock(m); + } + if( HPMHooks.count.HP_mutex_unlock_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_unlock_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +struct cond_data* HP_mutex_cond_create(void) { + int hIndex = 0; + struct cond_data* retVal___ = NULL; + if( HPMHooks.count.HP_mutex_cond_create_pre ) { + struct cond_data* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_create_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.cond_create(); + } + if( HPMHooks.count.HP_mutex_cond_create_post ) { + struct cond_data* (*postHookFunc) (struct cond_data* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +void HP_mutex_cond_destroy(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_destroy_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_destroy_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_destroy(c); + } + if( HPMHooks.count.HP_mutex_cond_destroy_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_destroy_post[hIndex].func; + postHookFunc(c); + } + } + return; +} +void HP_mutex_cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_wait_pre ) { + void (*preHookFunc) (struct cond_data **c, struct mutex_data **m, sysint *timeout_ticks); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_wait_pre[hIndex].func; + preHookFunc(&c, &m, &timeout_ticks); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_wait(c, m, timeout_ticks); + } + if( HPMHooks.count.HP_mutex_cond_wait_post ) { + void (*postHookFunc) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_wait_post[hIndex].func; + postHookFunc(c, m, timeout_ticks); + } + } + return; +} +void HP_mutex_cond_signal(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_signal_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_signal_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_signal(c); + } + if( HPMHooks.count.HP_mutex_cond_signal_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_signal_post[hIndex].func; + postHookFunc(c); + } + } + return; +} +void HP_mutex_cond_broadcast(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_broadcast_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_broadcast(c); + } + if( HPMHooks.count.HP_mutex_cond_broadcast_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_post[hIndex].func; + postHookFunc(c); + } + } + return; +} /* nullpo_interface */ void HP_nullpo_assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) { int hIndex = 0; @@ -5061,6 +5459,220 @@ void HP_nullpo_assert_report(const char *file, int line, const char *func, const } return; } +/* rnd_interface */ +void HP_rnd_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.init(); + } + if( HPMHooks.count.HP_rnd_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.final(); + } + if( HPMHooks.count.HP_rnd_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_seed(uint32 seed) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_seed_pre ) { + void (*preHookFunc) (uint32 *seed); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func; + preHookFunc(&seed); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.seed(seed); + } + if( HPMHooks.count.HP_rnd_seed_post ) { + void (*postHookFunc) (uint32 seed); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func; + postHookFunc(seed); + } + } + return; +} +int32 HP_rnd_random(void) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_random_pre ) { + int32 (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.random(); + } + if( HPMHooks.count.HP_rnd_random_post ) { + int32 (*postHookFunc) (int32 retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +uint32 HP_rnd_roll(uint32 dice_faces) { + int hIndex = 0; + uint32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_roll_pre ) { + uint32 (*preHookFunc) (uint32 *dice_faces); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func; + retVal___ = preHookFunc(&dice_faces); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.roll(dice_faces); + } + if( HPMHooks.count.HP_rnd_roll_post ) { + uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func; + retVal___ = postHookFunc(retVal___, dice_faces); + } + } + return retVal___; +} +int32 HP_rnd_value(int32 min, int32 max) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_value_pre ) { + int32 (*preHookFunc) (int32 *min, int32 *max); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func; + retVal___ = preHookFunc(&min, &max); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.value(min, max); + } + if( HPMHooks.count.HP_rnd_value_post ) { + int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func; + retVal___ = postHookFunc(retVal___, min, max); + } + } + return retVal___; +} +double HP_rnd_uniform(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform(); + } + if( HPMHooks.count.HP_rnd_uniform_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +double HP_rnd_uniform53(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform53_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform53(); + } + if( HPMHooks.count.HP_rnd_uniform53_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} /* showmsg_interface */ void HP_showmsg_init(void) { int hIndex = 0; @@ -8144,6 +8756,299 @@ void HP_sysinfo_final(void) { } return; } +/* thread_interface */ +void HP_thread_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.init(); + } + if( HPMHooks.count.HP_thread_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_thread_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.final(); + } + if( HPMHooks.count.HP_thread_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create(entry_point, param); + } + if( HPMHooks.count.HP_thread_create_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param); + } + } + return retVal___; +} +struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_opt_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m, &stack_size, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio); + } + if( HPMHooks.count.HP_thread_create_opt_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio); + } + } + return retVal___; +} +void HP_thread_destroy(struct thread_handle *handle) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_destroy_pre ) { + void (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func; + preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.destroy(handle); + } + if( HPMHooks.count.HP_thread_destroy_post ) { + void (*postHookFunc) (struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func; + postHookFunc(handle); + } + } + return; +} +struct thread_handle* HP_thread_self(void) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_self_pre ) { + struct thread_handle* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.self(); + } + if( HPMHooks.count.HP_thread_self_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +int HP_thread_get_tid(void) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_thread_get_tid_pre ) { + int (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.get_tid(); + } + if( HPMHooks.count.HP_thread_get_tid_post ) { + int (*postHookFunc) (int retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_thread_wait_pre ) { + bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func; + retVal___ = preHookFunc(&handle, &out_exit_code); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code); + } + if( HPMHooks.count.HP_thread_wait_post ) { + bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle, out_exit_code); + } + } + return retVal___; +} +void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_prio_set_pre ) { + void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func; + preHookFunc(&handle, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.prio_set(handle, prio); + } + if( HPMHooks.count.HP_thread_prio_set_post ) { + void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func; + postHookFunc(handle, prio); + } + } + return; +} +enum thread_priority HP_thread_prio_get(struct thread_handle *handle) { + int hIndex = 0; + enum thread_priority retVal___ = THREADPRIO_NORMAL; + if( HPMHooks.count.HP_thread_prio_get_pre ) { + enum thread_priority (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func; + retVal___ = preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.prio_get(handle); + } + if( HPMHooks.count.HP_thread_prio_get_post ) { + enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle); + } + } + return retVal___; +} +void HP_thread_yield(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_yield_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.yield(); + } + if( HPMHooks.count.HP_thread_yield_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func; + postHookFunc(); + } + } + return; +} /* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc index 1c1927619..6677a0c55 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc @@ -23,17 +23,23 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + memcpy(&HPMHooks.source.HCache, HCache, sizeof(struct HCache_interface)); memcpy(&HPMHooks.source.cmdline, cmdline, sizeof(struct cmdline_interface)); memcpy(&HPMHooks.source.console, console, sizeof(struct console_interface)); memcpy(&HPMHooks.source.core, core, sizeof(struct core_interface)); memcpy(&HPMHooks.source.DB, DB, sizeof(struct db_interface)); +memcpy(&HPMHooks.source.des, des, sizeof(struct des_interface)); memcpy(&HPMHooks.source.lclif, lclif, sizeof(struct lclif_interface)); memcpy(&HPMHooks.source.PRIV__lclif, lclif->p, sizeof(struct lclif_interface_private)); memcpy(&HPMHooks.source.libconfig, libconfig, sizeof(struct libconfig_interface)); memcpy(&HPMHooks.source.login, login, sizeof(struct login_interface)); memcpy(&HPMHooks.source.iMalloc, iMalloc, sizeof(struct malloc_interface)); +memcpy(&HPMHooks.source.md5, md5, sizeof(struct md5_interface)); +memcpy(&HPMHooks.source.mutex, mutex, sizeof(struct mutex_interface)); memcpy(&HPMHooks.source.nullpo, nullpo, sizeof(struct nullpo_interface)); +memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface)); memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface)); memcpy(&HPMHooks.source.sockt, sockt, sizeof(struct socket_interface)); memcpy(&HPMHooks.source.SQL, SQL, sizeof(struct sql_interface)); @@ -41,4 +47,5 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface)); memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface)); memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface)); memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface)); +memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface)); memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface)); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 1de0b6077..06c4acc50 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + struct { struct HPMHookPoint *HP_HCache_init_pre; struct HPMHookPoint *HP_HCache_init_post; @@ -108,12 +110,16 @@ struct { struct HPMHookPoint *HP_battle_calc_attack_post; struct HPMHookPoint *HP_battle_calc_damage_pre; struct HPMHookPoint *HP_battle_calc_damage_post; + struct HPMHookPoint *HP_battle_calc_pc_damage_pre; + struct HPMHookPoint *HP_battle_calc_pc_damage_post; struct HPMHookPoint *HP_battle_calc_gvg_damage_pre; struct HPMHookPoint *HP_battle_calc_gvg_damage_post; struct HPMHookPoint *HP_battle_calc_bg_damage_pre; struct HPMHookPoint *HP_battle_calc_bg_damage_post; struct HPMHookPoint *HP_battle_weapon_attack_pre; struct HPMHookPoint *HP_battle_weapon_attack_post; + struct HPMHookPoint *HP_battle_check_arrows_pre; + struct HPMHookPoint *HP_battle_check_arrows_post; struct HPMHookPoint *HP_battle_calc_weapon_attack_pre; struct HPMHookPoint *HP_battle_calc_weapon_attack_post; struct HPMHookPoint *HP_battle_delay_damage_pre; @@ -832,6 +838,8 @@ struct { struct HPMHookPoint *HP_clif_skill_itemlistwindow_post; struct HPMHookPoint *HP_clif_sc_load_pre; struct HPMHookPoint *HP_clif_sc_load_post; + struct HPMHookPoint *HP_clif_sc_continue_pre; + struct HPMHookPoint *HP_clif_sc_continue_post; struct HPMHookPoint *HP_clif_sc_end_pre; struct HPMHookPoint *HP_clif_sc_end_post; struct HPMHookPoint *HP_clif_initialstatus_pre; @@ -894,8 +902,8 @@ struct { struct HPMHookPoint *HP_clif_skill_estimation_post; struct HPMHookPoint *HP_clif_skill_warppoint_pre; struct HPMHookPoint *HP_clif_skill_warppoint_post; - struct HPMHookPoint *HP_clif_skillcasting_pre; - struct HPMHookPoint *HP_clif_skillcasting_post; + struct HPMHookPoint *HP_clif_useskill_pre; + struct HPMHookPoint *HP_clif_useskill_post; struct HPMHookPoint *HP_clif_produce_effect_pre; struct HPMHookPoint *HP_clif_produce_effect_post; struct HPMHookPoint *HP_clif_devotion_pre; @@ -1390,6 +1398,10 @@ struct { struct HPMHookPoint *HP_clif_comparemergeitem_post; struct HPMHookPoint *HP_clif_ackmergeitems_pre; struct HPMHookPoint *HP_clif_ackmergeitems_post; + struct HPMHookPoint *HP_clif_isdisguised_pre; + struct HPMHookPoint *HP_clif_isdisguised_post; + struct HPMHookPoint *HP_clif_bl_type_pre; + struct HPMHookPoint *HP_clif_bl_type_post; struct HPMHookPoint *HP_clif_pWantToConnection_pre; struct HPMHookPoint *HP_clif_pWantToConnection_post; struct HPMHookPoint *HP_clif_pLoadEndAck_pre; @@ -1918,6 +1930,10 @@ struct { struct HPMHookPoint *HP_DB_init_post; struct HPMHookPoint *HP_DB_final_pre; struct HPMHookPoint *HP_DB_final_post; + struct HPMHookPoint *HP_des_decrypt_block_pre; + struct HPMHookPoint *HP_des_decrypt_block_post; + struct HPMHookPoint *HP_des_decrypt_pre; + struct HPMHookPoint *HP_des_decrypt_post; struct HPMHookPoint *HP_duel_create_pre; struct HPMHookPoint *HP_duel_create_post; struct HPMHookPoint *HP_duel_invite_pre; @@ -2000,6 +2016,20 @@ struct { struct HPMHookPoint *HP_elemental_ai_timer_post; struct HPMHookPoint *HP_elemental_read_db_pre; struct HPMHookPoint *HP_elemental_read_db_post; + struct HPMHookPoint *HP_grfio_init_pre; + struct HPMHookPoint *HP_grfio_init_post; + struct HPMHookPoint *HP_grfio_final_pre; + struct HPMHookPoint *HP_grfio_final_post; + struct HPMHookPoint *HP_grfio_reads_pre; + struct HPMHookPoint *HP_grfio_reads_post; + struct HPMHookPoint *HP_grfio_find_file_pre; + struct HPMHookPoint *HP_grfio_find_file_post; + struct HPMHookPoint *HP_grfio_crc32_pre; + struct HPMHookPoint *HP_grfio_crc32_post; + struct HPMHookPoint *HP_grfio_decode_zip_pre; + struct HPMHookPoint *HP_grfio_decode_zip_post; + struct HPMHookPoint *HP_grfio_encode_zip_pre; + struct HPMHookPoint *HP_grfio_encode_zip_post; struct HPMHookPoint *HP_guild_init_pre; struct HPMHookPoint *HP_guild_init_post; struct HPMHookPoint *HP_guild_final_pre; @@ -3300,6 +3330,12 @@ struct { struct HPMHookPoint *HP_mapreg_reload_post; struct HPMHookPoint *HP_mapreg_config_read_pre; struct HPMHookPoint *HP_mapreg_config_read_post; + struct HPMHookPoint *HP_md5_string_pre; + struct HPMHookPoint *HP_md5_string_post; + struct HPMHookPoint *HP_md5_binary_pre; + struct HPMHookPoint *HP_md5_binary_post; + struct HPMHookPoint *HP_md5_salt_pre; + struct HPMHookPoint *HP_md5_salt_post; struct HPMHookPoint *HP_mercenary_init_pre; struct HPMHookPoint *HP_mercenary_init_post; struct HPMHookPoint *HP_mercenary_class_pre; @@ -3556,6 +3592,26 @@ struct { struct HPMHookPoint *HP_mob_clear_spawninfo_post; struct HPMHookPoint *HP_mob_destroy_mob_db_pre; struct HPMHookPoint *HP_mob_destroy_mob_db_post; + struct HPMHookPoint *HP_mutex_create_pre; + struct HPMHookPoint *HP_mutex_create_post; + struct HPMHookPoint *HP_mutex_destroy_pre; + struct HPMHookPoint *HP_mutex_destroy_post; + struct HPMHookPoint *HP_mutex_lock_pre; + struct HPMHookPoint *HP_mutex_lock_post; + struct HPMHookPoint *HP_mutex_trylock_pre; + struct HPMHookPoint *HP_mutex_trylock_post; + struct HPMHookPoint *HP_mutex_unlock_pre; + struct HPMHookPoint *HP_mutex_unlock_post; + struct HPMHookPoint *HP_mutex_cond_create_pre; + struct HPMHookPoint *HP_mutex_cond_create_post; + struct HPMHookPoint *HP_mutex_cond_destroy_pre; + struct HPMHookPoint *HP_mutex_cond_destroy_post; + struct HPMHookPoint *HP_mutex_cond_wait_pre; + struct HPMHookPoint *HP_mutex_cond_wait_post; + struct HPMHookPoint *HP_mutex_cond_signal_pre; + struct HPMHookPoint *HP_mutex_cond_signal_post; + struct HPMHookPoint *HP_mutex_cond_broadcast_pre; + struct HPMHookPoint *HP_mutex_cond_broadcast_post; struct HPMHookPoint *HP_npc_chat_sub_pre; struct HPMHookPoint *HP_npc_chat_sub_post; struct HPMHookPoint *HP_npc_chat_finalize_pre; @@ -4490,6 +4546,22 @@ struct { struct HPMHookPoint *HP_quest_read_db_post; struct HPMHookPoint *HP_quest_read_db_sub_pre; struct HPMHookPoint *HP_quest_read_db_sub_post; + struct HPMHookPoint *HP_rnd_init_pre; + struct HPMHookPoint *HP_rnd_init_post; + struct HPMHookPoint *HP_rnd_final_pre; + struct HPMHookPoint *HP_rnd_final_post; + struct HPMHookPoint *HP_rnd_seed_pre; + struct HPMHookPoint *HP_rnd_seed_post; + struct HPMHookPoint *HP_rnd_random_pre; + struct HPMHookPoint *HP_rnd_random_post; + struct HPMHookPoint *HP_rnd_roll_pre; + struct HPMHookPoint *HP_rnd_roll_post; + struct HPMHookPoint *HP_rnd_value_pre; + struct HPMHookPoint *HP_rnd_value_post; + struct HPMHookPoint *HP_rnd_uniform_pre; + struct HPMHookPoint *HP_rnd_uniform_post; + struct HPMHookPoint *HP_rnd_uniform53_pre; + struct HPMHookPoint *HP_rnd_uniform53_post; struct HPMHookPoint *HP_script_init_pre; struct HPMHookPoint *HP_script_init_post; struct HPMHookPoint *HP_script_final_pre; @@ -4666,6 +4738,16 @@ struct { struct HPMHookPoint *HP_script_parse_variable_post; struct HPMHookPoint *HP_script_parse_simpleexpr_pre; struct HPMHookPoint *HP_script_parse_simpleexpr_post; + struct HPMHookPoint *HP_script_parse_simpleexpr_paren_pre; + struct HPMHookPoint *HP_script_parse_simpleexpr_paren_post; + struct HPMHookPoint *HP_script_parse_simpleexpr_number_pre; + struct HPMHookPoint *HP_script_parse_simpleexpr_number_post; + struct HPMHookPoint *HP_script_parse_simpleexpr_string_pre; + struct HPMHookPoint *HP_script_parse_simpleexpr_string_post; + struct HPMHookPoint *HP_script_parse_simpleexpr_name_pre; + struct HPMHookPoint *HP_script_parse_simpleexpr_name_post; + struct HPMHookPoint *HP_script_add_translatable_string_pre; + struct HPMHookPoint *HP_script_add_translatable_string_post; struct HPMHookPoint *HP_script_parse_expr_pre; struct HPMHookPoint *HP_script_parse_expr_post; struct HPMHookPoint *HP_script_parse_line_pre; @@ -4808,6 +4890,8 @@ struct { struct HPMHookPoint *HP_script_string_dup_post; struct HPMHookPoint *HP_script_load_translations_pre; struct HPMHookPoint *HP_script_load_translations_post; + struct HPMHookPoint *HP_script_load_translation_addstring_pre; + struct HPMHookPoint *HP_script_load_translation_addstring_post; struct HPMHookPoint *HP_script_load_translation_pre; struct HPMHookPoint *HP_script_load_translation_post; struct HPMHookPoint *HP_script_translation_db_destroyer_pre; @@ -5052,8 +5136,12 @@ struct { struct HPMHookPoint *HP_skill_enchant_elemental_end_post; struct HPMHookPoint *HP_skill_not_ok_pre; struct HPMHookPoint *HP_skill_not_ok_post; + struct HPMHookPoint *HP_skill_not_ok_unknown_pre; + struct HPMHookPoint *HP_skill_not_ok_unknown_post; struct HPMHookPoint *HP_skill_not_ok_hom_pre; struct HPMHookPoint *HP_skill_not_ok_hom_post; + struct HPMHookPoint *HP_skill_not_ok_hom_unknown_pre; + struct HPMHookPoint *HP_skill_not_ok_hom_unknown_post; struct HPMHookPoint *HP_skill_not_ok_mercenary_pre; struct HPMHookPoint *HP_skill_not_ok_mercenary_post; struct HPMHookPoint *HP_skill_chastle_mob_changetarget_pre; @@ -5064,6 +5152,8 @@ struct { struct HPMHookPoint *HP_skill_produce_mix_post; struct HPMHookPoint *HP_skill_arrow_create_pre; struct HPMHookPoint *HP_skill_arrow_create_post; + struct HPMHookPoint *HP_skill_castend_type_pre; + struct HPMHookPoint *HP_skill_castend_type_post; struct HPMHookPoint *HP_skill_castend_nodamage_id_pre; struct HPMHookPoint *HP_skill_castend_nodamage_id_post; struct HPMHookPoint *HP_skill_castend_damage_id_pre; @@ -5148,6 +5238,8 @@ struct { struct HPMHookPoint *HP_skill_unitsetmapcell_post; struct HPMHookPoint *HP_skill_unit_onplace_timer_pre; struct HPMHookPoint *HP_skill_unit_onplace_timer_post; + struct HPMHookPoint *HP_skill_unit_onplace_timer_unknown_pre; + struct HPMHookPoint *HP_skill_unit_onplace_timer_unknown_post; struct HPMHookPoint *HP_skill_unit_effect_pre; struct HPMHookPoint *HP_skill_unit_effect_post; struct HPMHookPoint *HP_skill_unit_timer_sub_onplace_pre; @@ -5168,16 +5260,44 @@ struct { struct HPMHookPoint *HP_skill_unit_timer_sub_post; struct HPMHookPoint *HP_skill_init_unit_layout_pre; struct HPMHookPoint *HP_skill_init_unit_layout_post; - struct HPMHookPoint *HP_skill_parse_row_skilldb_pre; - struct HPMHookPoint *HP_skill_parse_row_skilldb_post; - struct HPMHookPoint *HP_skill_parse_row_requiredb_pre; - struct HPMHookPoint *HP_skill_parse_row_requiredb_post; - struct HPMHookPoint *HP_skill_parse_row_castdb_pre; - struct HPMHookPoint *HP_skill_parse_row_castdb_post; - struct HPMHookPoint *HP_skill_parse_row_castnodexdb_pre; - struct HPMHookPoint *HP_skill_parse_row_castnodexdb_post; - struct HPMHookPoint *HP_skill_parse_row_unitdb_pre; - struct HPMHookPoint *HP_skill_parse_row_unitdb_post; + struct HPMHookPoint *HP_skill_init_unit_layout_unknown_pre; + struct HPMHookPoint *HP_skill_init_unit_layout_unknown_post; + struct HPMHookPoint *HP_skill_validate_hittype_pre; + struct HPMHookPoint *HP_skill_validate_hittype_post; + struct HPMHookPoint *HP_skill_validate_skilltype_pre; + struct HPMHookPoint *HP_skill_validate_skilltype_post; + struct HPMHookPoint *HP_skill_validate_attacktype_pre; + struct HPMHookPoint *HP_skill_validate_attacktype_post; + struct HPMHookPoint *HP_skill_validate_element_pre; + struct HPMHookPoint *HP_skill_validate_element_post; + struct HPMHookPoint *HP_skill_validate_skillinfo_pre; + struct HPMHookPoint *HP_skill_validate_skillinfo_post; + struct HPMHookPoint *HP_skill_validate_damagetype_pre; + struct HPMHookPoint *HP_skill_validate_damagetype_post; + struct HPMHookPoint *HP_skill_validate_castnodex_pre; + struct HPMHookPoint *HP_skill_validate_castnodex_post; + struct HPMHookPoint *HP_skill_validate_weapontype_pre; + struct HPMHookPoint *HP_skill_validate_weapontype_post; + struct HPMHookPoint *HP_skill_validate_ammotype_pre; + struct HPMHookPoint *HP_skill_validate_ammotype_post; + struct HPMHookPoint *HP_skill_validate_state_pre; + struct HPMHookPoint *HP_skill_validate_state_post; + struct HPMHookPoint *HP_skill_validate_item_requirements_pre; + struct HPMHookPoint *HP_skill_validate_item_requirements_post; + struct HPMHookPoint *HP_skill_validate_unit_target_pre; + struct HPMHookPoint *HP_skill_validate_unit_target_post; + struct HPMHookPoint *HP_skill_validate_unit_flag_pre; + struct HPMHookPoint *HP_skill_validate_unit_flag_post; + struct HPMHookPoint *HP_skill_validate_additional_fields_pre; + struct HPMHookPoint *HP_skill_validate_additional_fields_post; + struct HPMHookPoint *HP_skill_validate_skilldb_pre; + struct HPMHookPoint *HP_skill_validate_skilldb_post; + struct HPMHookPoint *HP_skill_read_skilldb_pre; + struct HPMHookPoint *HP_skill_read_skilldb_post; + struct HPMHookPoint *HP_skill_config_set_level_pre; + struct HPMHookPoint *HP_skill_config_set_level_post; + struct HPMHookPoint *HP_skill_level_set_value_pre; + struct HPMHookPoint *HP_skill_level_set_value_post; struct HPMHookPoint *HP_skill_parse_row_producedb_pre; struct HPMHookPoint *HP_skill_parse_row_producedb_post; struct HPMHookPoint *HP_skill_parse_row_createarrowdb_pre; @@ -5290,6 +5410,12 @@ struct { struct HPMHookPoint *HP_skill_get_requirement_item_unknown_post; struct HPMHookPoint *HP_skill_get_requirement_unknown_pre; struct HPMHookPoint *HP_skill_get_requirement_unknown_post; + struct HPMHookPoint *HP_skill_splash_target_pre; + struct HPMHookPoint *HP_skill_splash_target_post; + struct HPMHookPoint *HP_skill_check_npc_chaospanic_pre; + struct HPMHookPoint *HP_skill_check_npc_chaospanic_post; + struct HPMHookPoint *HP_skill_count_wos_pre; + struct HPMHookPoint *HP_skill_count_wos_post; struct HPMHookPoint *HP_sockt_init_pre; struct HPMHookPoint *HP_sockt_init_post; struct HPMHookPoint *HP_sockt_final_pre; @@ -5634,6 +5760,14 @@ struct { struct HPMHookPoint *HP_status_read_job_db_post; struct HPMHookPoint *HP_status_read_job_db_sub_pre; struct HPMHookPoint *HP_status_read_job_db_sub_post; + struct HPMHookPoint *HP_status_set_sc_pre; + struct HPMHookPoint *HP_status_set_sc_post; + struct HPMHookPoint *HP_status_copy_pre; + struct HPMHookPoint *HP_status_copy_post; + struct HPMHookPoint *HP_status_base_matk_min_pre; + struct HPMHookPoint *HP_status_base_matk_min_post; + struct HPMHookPoint *HP_status_base_matk_max_pre; + struct HPMHookPoint *HP_status_base_matk_max_post; struct HPMHookPoint *HP_storage_reconnect_pre; struct HPMHookPoint *HP_storage_reconnect_post; struct HPMHookPoint *HP_storage_delitem_pre; @@ -5760,6 +5894,28 @@ struct { struct HPMHookPoint *HP_sysinfo_init_post; struct HPMHookPoint *HP_sysinfo_final_pre; struct HPMHookPoint *HP_sysinfo_final_post; + struct HPMHookPoint *HP_thread_init_pre; + struct HPMHookPoint *HP_thread_init_post; + struct HPMHookPoint *HP_thread_final_pre; + struct HPMHookPoint *HP_thread_final_post; + struct HPMHookPoint *HP_thread_create_pre; + struct HPMHookPoint *HP_thread_create_post; + struct HPMHookPoint *HP_thread_create_opt_pre; + struct HPMHookPoint *HP_thread_create_opt_post; + struct HPMHookPoint *HP_thread_destroy_pre; + struct HPMHookPoint *HP_thread_destroy_post; + struct HPMHookPoint *HP_thread_self_pre; + struct HPMHookPoint *HP_thread_self_post; + struct HPMHookPoint *HP_thread_get_tid_pre; + struct HPMHookPoint *HP_thread_get_tid_post; + struct HPMHookPoint *HP_thread_wait_pre; + struct HPMHookPoint *HP_thread_wait_post; + struct HPMHookPoint *HP_thread_prio_set_pre; + struct HPMHookPoint *HP_thread_prio_set_post; + struct HPMHookPoint *HP_thread_prio_get_pre; + struct HPMHookPoint *HP_thread_prio_get_post; + struct HPMHookPoint *HP_thread_yield_pre; + struct HPMHookPoint *HP_thread_yield_post; struct HPMHookPoint *HP_timer_gettick_pre; struct HPMHookPoint *HP_timer_gettick_post; struct HPMHookPoint *HP_timer_gettick_nocache_pre; @@ -6005,12 +6161,16 @@ struct { int HP_battle_calc_attack_post; int HP_battle_calc_damage_pre; int HP_battle_calc_damage_post; + int HP_battle_calc_pc_damage_pre; + int HP_battle_calc_pc_damage_post; int HP_battle_calc_gvg_damage_pre; int HP_battle_calc_gvg_damage_post; int HP_battle_calc_bg_damage_pre; int HP_battle_calc_bg_damage_post; int HP_battle_weapon_attack_pre; int HP_battle_weapon_attack_post; + int HP_battle_check_arrows_pre; + int HP_battle_check_arrows_post; int HP_battle_calc_weapon_attack_pre; int HP_battle_calc_weapon_attack_post; int HP_battle_delay_damage_pre; @@ -6729,6 +6889,8 @@ struct { int HP_clif_skill_itemlistwindow_post; int HP_clif_sc_load_pre; int HP_clif_sc_load_post; + int HP_clif_sc_continue_pre; + int HP_clif_sc_continue_post; int HP_clif_sc_end_pre; int HP_clif_sc_end_post; int HP_clif_initialstatus_pre; @@ -6791,8 +6953,8 @@ struct { int HP_clif_skill_estimation_post; int HP_clif_skill_warppoint_pre; int HP_clif_skill_warppoint_post; - int HP_clif_skillcasting_pre; - int HP_clif_skillcasting_post; + int HP_clif_useskill_pre; + int HP_clif_useskill_post; int HP_clif_produce_effect_pre; int HP_clif_produce_effect_post; int HP_clif_devotion_pre; @@ -7287,6 +7449,10 @@ struct { int HP_clif_comparemergeitem_post; int HP_clif_ackmergeitems_pre; int HP_clif_ackmergeitems_post; + int HP_clif_isdisguised_pre; + int HP_clif_isdisguised_post; + int HP_clif_bl_type_pre; + int HP_clif_bl_type_post; int HP_clif_pWantToConnection_pre; int HP_clif_pWantToConnection_post; int HP_clif_pLoadEndAck_pre; @@ -7815,6 +7981,10 @@ struct { int HP_DB_init_post; int HP_DB_final_pre; int HP_DB_final_post; + int HP_des_decrypt_block_pre; + int HP_des_decrypt_block_post; + int HP_des_decrypt_pre; + int HP_des_decrypt_post; int HP_duel_create_pre; int HP_duel_create_post; int HP_duel_invite_pre; @@ -7897,6 +8067,20 @@ struct { int HP_elemental_ai_timer_post; int HP_elemental_read_db_pre; int HP_elemental_read_db_post; + int HP_grfio_init_pre; + int HP_grfio_init_post; + int HP_grfio_final_pre; + int HP_grfio_final_post; + int HP_grfio_reads_pre; + int HP_grfio_reads_post; + int HP_grfio_find_file_pre; + int HP_grfio_find_file_post; + int HP_grfio_crc32_pre; + int HP_grfio_crc32_post; + int HP_grfio_decode_zip_pre; + int HP_grfio_decode_zip_post; + int HP_grfio_encode_zip_pre; + int HP_grfio_encode_zip_post; int HP_guild_init_pre; int HP_guild_init_post; int HP_guild_final_pre; @@ -9197,6 +9381,12 @@ struct { int HP_mapreg_reload_post; int HP_mapreg_config_read_pre; int HP_mapreg_config_read_post; + int HP_md5_string_pre; + int HP_md5_string_post; + int HP_md5_binary_pre; + int HP_md5_binary_post; + int HP_md5_salt_pre; + int HP_md5_salt_post; int HP_mercenary_init_pre; int HP_mercenary_init_post; int HP_mercenary_class_pre; @@ -9453,6 +9643,26 @@ struct { int HP_mob_clear_spawninfo_post; int HP_mob_destroy_mob_db_pre; int HP_mob_destroy_mob_db_post; + int HP_mutex_create_pre; + int HP_mutex_create_post; + int HP_mutex_destroy_pre; + int HP_mutex_destroy_post; + int HP_mutex_lock_pre; + int HP_mutex_lock_post; + int HP_mutex_trylock_pre; + int HP_mutex_trylock_post; + int HP_mutex_unlock_pre; + int HP_mutex_unlock_post; + int HP_mutex_cond_create_pre; + int HP_mutex_cond_create_post; + int HP_mutex_cond_destroy_pre; + int HP_mutex_cond_destroy_post; + int HP_mutex_cond_wait_pre; + int HP_mutex_cond_wait_post; + int HP_mutex_cond_signal_pre; + int HP_mutex_cond_signal_post; + int HP_mutex_cond_broadcast_pre; + int HP_mutex_cond_broadcast_post; int HP_npc_chat_sub_pre; int HP_npc_chat_sub_post; int HP_npc_chat_finalize_pre; @@ -10387,6 +10597,22 @@ struct { int HP_quest_read_db_post; int HP_quest_read_db_sub_pre; int HP_quest_read_db_sub_post; + int HP_rnd_init_pre; + int HP_rnd_init_post; + int HP_rnd_final_pre; + int HP_rnd_final_post; + int HP_rnd_seed_pre; + int HP_rnd_seed_post; + int HP_rnd_random_pre; + int HP_rnd_random_post; + int HP_rnd_roll_pre; + int HP_rnd_roll_post; + int HP_rnd_value_pre; + int HP_rnd_value_post; + int HP_rnd_uniform_pre; + int HP_rnd_uniform_post; + int HP_rnd_uniform53_pre; + int HP_rnd_uniform53_post; int HP_script_init_pre; int HP_script_init_post; int HP_script_final_pre; @@ -10563,6 +10789,16 @@ struct { int HP_script_parse_variable_post; int HP_script_parse_simpleexpr_pre; int HP_script_parse_simpleexpr_post; + int HP_script_parse_simpleexpr_paren_pre; + int HP_script_parse_simpleexpr_paren_post; + int HP_script_parse_simpleexpr_number_pre; + int HP_script_parse_simpleexpr_number_post; + int HP_script_parse_simpleexpr_string_pre; + int HP_script_parse_simpleexpr_string_post; + int HP_script_parse_simpleexpr_name_pre; + int HP_script_parse_simpleexpr_name_post; + int HP_script_add_translatable_string_pre; + int HP_script_add_translatable_string_post; int HP_script_parse_expr_pre; int HP_script_parse_expr_post; int HP_script_parse_line_pre; @@ -10705,6 +10941,8 @@ struct { int HP_script_string_dup_post; int HP_script_load_translations_pre; int HP_script_load_translations_post; + int HP_script_load_translation_addstring_pre; + int HP_script_load_translation_addstring_post; int HP_script_load_translation_pre; int HP_script_load_translation_post; int HP_script_translation_db_destroyer_pre; @@ -10949,8 +11187,12 @@ struct { int HP_skill_enchant_elemental_end_post; int HP_skill_not_ok_pre; int HP_skill_not_ok_post; + int HP_skill_not_ok_unknown_pre; + int HP_skill_not_ok_unknown_post; int HP_skill_not_ok_hom_pre; int HP_skill_not_ok_hom_post; + int HP_skill_not_ok_hom_unknown_pre; + int HP_skill_not_ok_hom_unknown_post; int HP_skill_not_ok_mercenary_pre; int HP_skill_not_ok_mercenary_post; int HP_skill_chastle_mob_changetarget_pre; @@ -10961,6 +11203,8 @@ struct { int HP_skill_produce_mix_post; int HP_skill_arrow_create_pre; int HP_skill_arrow_create_post; + int HP_skill_castend_type_pre; + int HP_skill_castend_type_post; int HP_skill_castend_nodamage_id_pre; int HP_skill_castend_nodamage_id_post; int HP_skill_castend_damage_id_pre; @@ -11045,6 +11289,8 @@ struct { int HP_skill_unitsetmapcell_post; int HP_skill_unit_onplace_timer_pre; int HP_skill_unit_onplace_timer_post; + int HP_skill_unit_onplace_timer_unknown_pre; + int HP_skill_unit_onplace_timer_unknown_post; int HP_skill_unit_effect_pre; int HP_skill_unit_effect_post; int HP_skill_unit_timer_sub_onplace_pre; @@ -11065,16 +11311,44 @@ struct { int HP_skill_unit_timer_sub_post; int HP_skill_init_unit_layout_pre; int HP_skill_init_unit_layout_post; - int HP_skill_parse_row_skilldb_pre; - int HP_skill_parse_row_skilldb_post; - int HP_skill_parse_row_requiredb_pre; - int HP_skill_parse_row_requiredb_post; - int HP_skill_parse_row_castdb_pre; - int HP_skill_parse_row_castdb_post; - int HP_skill_parse_row_castnodexdb_pre; - int HP_skill_parse_row_castnodexdb_post; - int HP_skill_parse_row_unitdb_pre; - int HP_skill_parse_row_unitdb_post; + int HP_skill_init_unit_layout_unknown_pre; + int HP_skill_init_unit_layout_unknown_post; + int HP_skill_validate_hittype_pre; + int HP_skill_validate_hittype_post; + int HP_skill_validate_skilltype_pre; + int HP_skill_validate_skilltype_post; + int HP_skill_validate_attacktype_pre; + int HP_skill_validate_attacktype_post; + int HP_skill_validate_element_pre; + int HP_skill_validate_element_post; + int HP_skill_validate_skillinfo_pre; + int HP_skill_validate_skillinfo_post; + int HP_skill_validate_damagetype_pre; + int HP_skill_validate_damagetype_post; + int HP_skill_validate_castnodex_pre; + int HP_skill_validate_castnodex_post; + int HP_skill_validate_weapontype_pre; + int HP_skill_validate_weapontype_post; + int HP_skill_validate_ammotype_pre; + int HP_skill_validate_ammotype_post; + int HP_skill_validate_state_pre; + int HP_skill_validate_state_post; + int HP_skill_validate_item_requirements_pre; + int HP_skill_validate_item_requirements_post; + int HP_skill_validate_unit_target_pre; + int HP_skill_validate_unit_target_post; + int HP_skill_validate_unit_flag_pre; + int HP_skill_validate_unit_flag_post; + int HP_skill_validate_additional_fields_pre; + int HP_skill_validate_additional_fields_post; + int HP_skill_validate_skilldb_pre; + int HP_skill_validate_skilldb_post; + int HP_skill_read_skilldb_pre; + int HP_skill_read_skilldb_post; + int HP_skill_config_set_level_pre; + int HP_skill_config_set_level_post; + int HP_skill_level_set_value_pre; + int HP_skill_level_set_value_post; int HP_skill_parse_row_producedb_pre; int HP_skill_parse_row_producedb_post; int HP_skill_parse_row_createarrowdb_pre; @@ -11187,6 +11461,12 @@ struct { int HP_skill_get_requirement_item_unknown_post; int HP_skill_get_requirement_unknown_pre; int HP_skill_get_requirement_unknown_post; + int HP_skill_splash_target_pre; + int HP_skill_splash_target_post; + int HP_skill_check_npc_chaospanic_pre; + int HP_skill_check_npc_chaospanic_post; + int HP_skill_count_wos_pre; + int HP_skill_count_wos_post; int HP_sockt_init_pre; int HP_sockt_init_post; int HP_sockt_final_pre; @@ -11531,6 +11811,14 @@ struct { int HP_status_read_job_db_post; int HP_status_read_job_db_sub_pre; int HP_status_read_job_db_sub_post; + int HP_status_set_sc_pre; + int HP_status_set_sc_post; + int HP_status_copy_pre; + int HP_status_copy_post; + int HP_status_base_matk_min_pre; + int HP_status_base_matk_min_post; + int HP_status_base_matk_max_pre; + int HP_status_base_matk_max_post; int HP_storage_reconnect_pre; int HP_storage_reconnect_post; int HP_storage_delitem_pre; @@ -11657,6 +11945,28 @@ struct { int HP_sysinfo_init_post; int HP_sysinfo_final_pre; int HP_sysinfo_final_post; + int HP_thread_init_pre; + int HP_thread_init_post; + int HP_thread_final_pre; + int HP_thread_final_post; + int HP_thread_create_pre; + int HP_thread_create_post; + int HP_thread_create_opt_pre; + int HP_thread_create_opt_post; + int HP_thread_destroy_pre; + int HP_thread_destroy_post; + int HP_thread_self_pre; + int HP_thread_self_post; + int HP_thread_get_tid_pre; + int HP_thread_get_tid_post; + int HP_thread_wait_pre; + int HP_thread_wait_post; + int HP_thread_prio_set_pre; + int HP_thread_prio_set_post; + int HP_thread_prio_get_pre; + int HP_thread_prio_get_post; + int HP_thread_yield_pre; + int HP_thread_yield_post; int HP_timer_gettick_pre; int HP_timer_gettick_post; int HP_timer_gettick_nocache_pre; @@ -11831,8 +12141,10 @@ struct { struct console_interface console; struct core_interface core; struct db_interface DB; + struct des_interface des; struct duel_interface duel; struct elemental_interface elemental; + struct grfio_interface grfio; struct guild_interface guild; struct guild_storage_interface gstorage; struct homunculus_interface homun; @@ -11848,8 +12160,10 @@ struct { struct mapindex_interface mapindex; struct mapit_interface mapit; struct mapreg_interface mapreg; + struct md5_interface md5; struct mercenary_interface mercenary; struct mob_interface mob; + struct mutex_interface mutex; struct npc_chat_interface npc_chat; struct npc_interface npc; struct nullpo_interface nullpo; @@ -11860,6 +12174,7 @@ struct { struct pcre_interface libpcre; struct pet_interface pet; struct quest_interface quest; + struct rnd_interface rnd; struct script_interface script; struct searchstore_interface searchstore; struct showmsg_interface showmsg; @@ -11872,6 +12187,7 @@ struct { struct strlib_interface strlib; struct sv_interface sv; struct sysinfo_interface sysinfo; + struct thread_interface thread; struct timer_interface timer; struct trade_interface trade; struct unit_interface unit; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index b18d11d66..2cef7f135 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + struct HookingPointData HookingPoints[] = { /* HCache_interface */ { HP_POP(HCache->init, HP_HCache_init) }, @@ -69,9 +71,11 @@ struct HookingPointData HookingPoints[] = { { HP_POP(battle->final, HP_battle_final) }, { HP_POP(battle->calc_attack, HP_battle_calc_attack) }, { HP_POP(battle->calc_damage, HP_battle_calc_damage) }, + { HP_POP(battle->calc_pc_damage, HP_battle_calc_pc_damage) }, { HP_POP(battle->calc_gvg_damage, HP_battle_calc_gvg_damage) }, { HP_POP(battle->calc_bg_damage, HP_battle_calc_bg_damage) }, { HP_POP(battle->weapon_attack, HP_battle_weapon_attack) }, + { HP_POP(battle->check_arrows, HP_battle_check_arrows) }, { HP_POP(battle->calc_weapon_attack, HP_battle_calc_weapon_attack) }, { HP_POP(battle->delay_damage, HP_battle_delay_damage) }, { HP_POP(battle->drain, HP_battle_drain) }, @@ -437,6 +441,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->autoshadowspell_list, HP_clif_autoshadowspell_list) }, { HP_POP(clif->skill_itemlistwindow, HP_clif_skill_itemlistwindow) }, { HP_POP(clif->sc_load, HP_clif_sc_load) }, + { HP_POP(clif->sc_continue, HP_clif_sc_continue) }, { HP_POP(clif->sc_end, HP_clif_sc_end) }, { HP_POP(clif->initialstatus, HP_clif_initialstatus) }, { HP_POP(clif->cooldown_list, HP_clif_cooldown_list) }, @@ -468,7 +473,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->skill_poseffect, HP_clif_skill_poseffect) }, { HP_POP(clif->skill_estimation, HP_clif_skill_estimation) }, { HP_POP(clif->skill_warppoint, HP_clif_skill_warppoint) }, - { HP_POP(clif->skillcasting, HP_clif_skillcasting) }, + { HP_POP(clif->useskill, HP_clif_useskill) }, { HP_POP(clif->produce_effect, HP_clif_produce_effect) }, { HP_POP(clif->devotion, HP_clif_devotion) }, { HP_POP(clif->spiritball, HP_clif_spiritball) }, @@ -716,6 +721,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->cancelmergeitem, HP_clif_cancelmergeitem) }, { HP_POP(clif->comparemergeitem, HP_clif_comparemergeitem) }, { HP_POP(clif->ackmergeitems, HP_clif_ackmergeitems) }, + { HP_POP(clif->isdisguised, HP_clif_isdisguised) }, + { HP_POP(clif->bl_type, HP_clif_bl_type) }, { HP_POP(clif->pWantToConnection, HP_clif_pWantToConnection) }, { HP_POP(clif->pLoadEndAck, HP_clif_pLoadEndAck) }, { HP_POP(clif->pTickSend, HP_clif_pTickSend) }, @@ -984,6 +991,9 @@ struct HookingPointData HookingPoints[] = { { HP_POP(DB->data2ptr, HP_DB_data2ptr) }, { HP_POP(DB->init, HP_DB_init) }, { HP_POP(DB->final, HP_DB_final) }, +/* des_interface */ + { HP_POP(des->decrypt_block, HP_des_decrypt_block) }, + { HP_POP(des->decrypt, HP_des_decrypt) }, /* duel_interface */ { HP_POP(duel->create, HP_duel_create) }, { HP_POP(duel->invite, HP_duel_invite) }, @@ -1027,6 +1037,14 @@ struct HookingPointData HookingPoints[] = { { HP_POP(elemental->ai_sub_foreachclient, HP_elemental_ai_sub_foreachclient) }, { HP_POP(elemental->ai_timer, HP_elemental_ai_timer) }, { HP_POP(elemental->read_db, HP_elemental_read_db) }, +/* grfio_interface */ + { HP_POP(grfio->init, HP_grfio_init) }, + { HP_POP(grfio->final, HP_grfio_final) }, + { HP_POP(grfio->reads, HP_grfio_reads) }, + { HP_POP(grfio->find_file, HP_grfio_find_file) }, + { HP_POP(grfio->crc32, HP_grfio_crc32) }, + { HP_POP(grfio->decode_zip, HP_grfio_decode_zip) }, + { HP_POP(grfio->encode_zip, HP_grfio_encode_zip) }, /* guild_interface */ { HP_POP(guild->init, HP_guild_init) }, { HP_POP(guild->final, HP_guild_final) }, @@ -1692,6 +1710,10 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapreg->destroyreg, HP_mapreg_destroyreg) }, { HP_POP(mapreg->reload, HP_mapreg_reload) }, { HP_POP(mapreg->config_read, HP_mapreg_config_read) }, +/* md5_interface */ + { HP_POP(md5->string, HP_md5_string) }, + { HP_POP(md5->binary, HP_md5_binary) }, + { HP_POP(md5->salt, HP_md5_salt) }, /* mercenary_interface */ { HP_POP(mercenary->init, HP_mercenary_init) }, { HP_POP(mercenary->class, HP_mercenary_class) }, @@ -1822,6 +1844,17 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mob->load, HP_mob_load) }, { HP_POP(mob->clear_spawninfo, HP_mob_clear_spawninfo) }, { HP_POP(mob->destroy_mob_db, HP_mob_destroy_mob_db) }, +/* mutex_interface */ + { HP_POP(mutex->create, HP_mutex_create) }, + { HP_POP(mutex->destroy, HP_mutex_destroy) }, + { HP_POP(mutex->lock, HP_mutex_lock) }, + { HP_POP(mutex->trylock, HP_mutex_trylock) }, + { HP_POP(mutex->unlock, HP_mutex_unlock) }, + { HP_POP(mutex->cond_create, HP_mutex_cond_create) }, + { HP_POP(mutex->cond_destroy, HP_mutex_cond_destroy) }, + { HP_POP(mutex->cond_wait, HP_mutex_cond_wait) }, + { HP_POP(mutex->cond_signal, HP_mutex_cond_signal) }, + { HP_POP(mutex->cond_broadcast, HP_mutex_cond_broadcast) }, /* npc_chat_interface */ { HP_POP(npc_chat->sub, HP_npc_chat_sub) }, { HP_POP(npc_chat->finalize, HP_npc_chat_finalize) }, @@ -2299,6 +2332,15 @@ struct HookingPointData HookingPoints[] = { { HP_POP(quest->clear, HP_quest_clear) }, { HP_POP(quest->read_db, HP_quest_read_db) }, { HP_POP(quest->read_db_sub, HP_quest_read_db_sub) }, +/* rnd_interface */ + { HP_POP(rnd->init, HP_rnd_init) }, + { HP_POP(rnd->final, HP_rnd_final) }, + { HP_POP(rnd->seed, HP_rnd_seed) }, + { HP_POP(rnd->random, HP_rnd_random) }, + { HP_POP(rnd->roll, HP_rnd_roll) }, + { HP_POP(rnd->value, HP_rnd_value) }, + { HP_POP(rnd->uniform, HP_rnd_uniform) }, + { HP_POP(rnd->uniform53, HP_rnd_uniform53) }, /* script_interface */ { HP_POP(script->init, HP_script_init) }, { HP_POP(script->final, HP_script_final) }, @@ -2388,6 +2430,11 @@ struct HookingPointData HookingPoints[] = { { HP_POP(script->parse_nextline, HP_script_parse_nextline) }, { HP_POP(script->parse_variable, HP_script_parse_variable) }, { HP_POP(script->parse_simpleexpr, HP_script_parse_simpleexpr) }, + { HP_POP(script->parse_simpleexpr_paren, HP_script_parse_simpleexpr_paren) }, + { HP_POP(script->parse_simpleexpr_number, HP_script_parse_simpleexpr_number) }, + { HP_POP(script->parse_simpleexpr_string, HP_script_parse_simpleexpr_string) }, + { HP_POP(script->parse_simpleexpr_name, HP_script_parse_simpleexpr_name) }, + { HP_POP(script->add_translatable_string, HP_script_add_translatable_string) }, { HP_POP(script->parse_expr, HP_script_parse_expr) }, { HP_POP(script->parse_line, HP_script_parse_line) }, { HP_POP(script->read_constdb, HP_script_read_constdb) }, @@ -2459,6 +2506,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(script->mapindexname2id, HP_script_mapindexname2id) }, { HP_POP(script->string_dup, HP_script_string_dup) }, { HP_POP(script->load_translations, HP_script_load_translations) }, + { HP_POP(script->load_translation_addstring, HP_script_load_translation_addstring) }, { HP_POP(script->load_translation, HP_script_load_translation) }, { HP_POP(script->translation_db_destroyer, HP_script_translation_db_destroyer) }, { HP_POP(script->clear_translations, HP_script_clear_translations) }, @@ -2584,12 +2632,15 @@ struct HookingPointData HookingPoints[] = { { HP_POP(skill->can_cloak, HP_skill_can_cloak) }, { HP_POP(skill->enchant_elemental_end, HP_skill_enchant_elemental_end) }, { HP_POP(skill->not_ok, HP_skill_not_ok) }, + { HP_POP(skill->not_ok_unknown, HP_skill_not_ok_unknown) }, { HP_POP(skill->not_ok_hom, HP_skill_not_ok_hom) }, + { HP_POP(skill->not_ok_hom_unknown, HP_skill_not_ok_hom_unknown) }, { HP_POP(skill->not_ok_mercenary, HP_skill_not_ok_mercenary) }, { HP_POP(skill->chastle_mob_changetarget, HP_skill_chastle_mob_changetarget) }, { HP_POP(skill->can_produce_mix, HP_skill_can_produce_mix) }, { HP_POP(skill->produce_mix, HP_skill_produce_mix) }, { HP_POP(skill->arrow_create, HP_skill_arrow_create) }, + { HP_POP(skill->castend_type, HP_skill_castend_type) }, { HP_POP(skill->castend_nodamage_id, HP_skill_castend_nodamage_id) }, { HP_POP(skill->castend_damage_id, HP_skill_castend_damage_id) }, { HP_POP(skill->castend_pos2, HP_skill_castend_pos2) }, @@ -2632,6 +2683,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(skill->sit_out, HP_skill_sit_out) }, { HP_POP(skill->unitsetmapcell, HP_skill_unitsetmapcell) }, { HP_POP(skill->unit_onplace_timer, HP_skill_unit_onplace_timer) }, + { HP_POP(skill->unit_onplace_timer_unknown, HP_skill_unit_onplace_timer_unknown) }, { HP_POP(skill->unit_effect, HP_skill_unit_effect) }, { HP_POP(skill->unit_timer_sub_onplace, HP_skill_unit_timer_sub_onplace) }, { HP_POP(skill->unit_move_sub, HP_skill_unit_move_sub) }, @@ -2642,11 +2694,25 @@ struct HookingPointData HookingPoints[] = { { HP_POP(skill->unit_timer, HP_skill_unit_timer) }, { HP_POP(skill->unit_timer_sub, HP_skill_unit_timer_sub) }, { HP_POP(skill->init_unit_layout, HP_skill_init_unit_layout) }, - { HP_POP(skill->parse_row_skilldb, HP_skill_parse_row_skilldb) }, - { HP_POP(skill->parse_row_requiredb, HP_skill_parse_row_requiredb) }, - { HP_POP(skill->parse_row_castdb, HP_skill_parse_row_castdb) }, - { HP_POP(skill->parse_row_castnodexdb, HP_skill_parse_row_castnodexdb) }, - { HP_POP(skill->parse_row_unitdb, HP_skill_parse_row_unitdb) }, + { HP_POP(skill->init_unit_layout_unknown, HP_skill_init_unit_layout_unknown) }, + { HP_POP(skill->validate_hittype, HP_skill_validate_hittype) }, + { HP_POP(skill->validate_skilltype, HP_skill_validate_skilltype) }, + { HP_POP(skill->validate_attacktype, HP_skill_validate_attacktype) }, + { HP_POP(skill->validate_element, HP_skill_validate_element) }, + { HP_POP(skill->validate_skillinfo, HP_skill_validate_skillinfo) }, + { HP_POP(skill->validate_damagetype, HP_skill_validate_damagetype) }, + { HP_POP(skill->validate_castnodex, HP_skill_validate_castnodex) }, + { HP_POP(skill->validate_weapontype, HP_skill_validate_weapontype) }, + { HP_POP(skill->validate_ammotype, HP_skill_validate_ammotype) }, + { HP_POP(skill->validate_state, HP_skill_validate_state) }, + { HP_POP(skill->validate_item_requirements, HP_skill_validate_item_requirements) }, + { HP_POP(skill->validate_unit_target, HP_skill_validate_unit_target) }, + { HP_POP(skill->validate_unit_flag, HP_skill_validate_unit_flag) }, + { HP_POP(skill->validate_additional_fields, HP_skill_validate_additional_fields) }, + { HP_POP(skill->validate_skilldb, HP_skill_validate_skilldb) }, + { HP_POP(skill->read_skilldb, HP_skill_read_skilldb) }, + { HP_POP(skill->config_set_level, HP_skill_config_set_level) }, + { HP_POP(skill->level_set_value, HP_skill_level_set_value) }, { HP_POP(skill->parse_row_producedb, HP_skill_parse_row_producedb) }, { HP_POP(skill->parse_row_createarrowdb, HP_skill_parse_row_createarrowdb) }, { HP_POP(skill->parse_row_abradb, HP_skill_parse_row_abradb) }, @@ -2703,6 +2769,9 @@ struct HookingPointData HookingPoints[] = { { HP_POP(skill->get_requirement_off_unknown, HP_skill_get_requirement_off_unknown) }, { HP_POP(skill->get_requirement_item_unknown, HP_skill_get_requirement_item_unknown) }, { HP_POP(skill->get_requirement_unknown, HP_skill_get_requirement_unknown) }, + { HP_POP(skill->splash_target, HP_skill_splash_target) }, + { HP_POP(skill->check_npc_chaospanic, HP_skill_check_npc_chaospanic) }, + { HP_POP(skill->count_wos, HP_skill_count_wos) }, /* socket_interface */ { HP_POP(sockt->init, HP_sockt_init) }, { HP_POP(sockt->final, HP_sockt_final) }, @@ -2878,6 +2947,10 @@ struct HookingPointData HookingPoints[] = { { HP_POP(status->readdb_scconfig, HP_status_readdb_scconfig) }, { HP_POP(status->read_job_db, HP_status_read_job_db) }, { HP_POP(status->read_job_db_sub, HP_status_read_job_db_sub) }, + { HP_POP(status->set_sc, HP_status_set_sc) }, + { HP_POP(status->copy, HP_status_copy) }, + { HP_POP(status->base_matk_min, HP_status_base_matk_min) }, + { HP_POP(status->base_matk_max, HP_status_base_matk_max) }, /* storage_interface */ { HP_POP(storage->reconnect, HP_storage_reconnect) }, { HP_POP(storage->delitem, HP_storage_delitem) }, @@ -2946,6 +3019,18 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, +/* thread_interface */ + { HP_POP(thread->init, HP_thread_init) }, + { HP_POP(thread->final, HP_thread_final) }, + { HP_POP(thread->create, HP_thread_create) }, + { HP_POP(thread->create_opt, HP_thread_create_opt) }, + { HP_POP(thread->destroy, HP_thread_destroy) }, + { HP_POP(thread->self, HP_thread_self) }, + { HP_POP(thread->get_tid, HP_thread_get_tid) }, + { HP_POP(thread->wait, HP_thread_wait) }, + { HP_POP(thread->prio_set, HP_thread_prio_set) }, + { HP_POP(thread->prio_get, HP_thread_prio_get) }, + { HP_POP(thread->yield, HP_thread_yield) }, /* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index ab2def6cd..8a343473c 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + /* HCache_interface */ void HP_HCache_init(void) { int hIndex = 0; @@ -1184,6 +1186,33 @@ int64 HP_battle_calc_damage(struct block_list *src, struct block_list *bl, struc } return retVal___; } +int64 HP_battle_calc_pc_damage(struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv) { + int hIndex = 0; + int64 retVal___ = 0; + if( HPMHooks.count.HP_battle_calc_pc_damage_pre ) { + int64 (*preHookFunc) (struct block_list **src, struct block_list **bl, struct Damage **d, int64 *damage, uint16 *skill_id, uint16 *skill_lv); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_battle_calc_pc_damage_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_battle_calc_pc_damage_pre[hIndex].func; + retVal___ = preHookFunc(&src, &bl, &d, &damage, &skill_id, &skill_lv); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.battle.calc_pc_damage(src, bl, d, damage, skill_id, skill_lv); + } + if( HPMHooks.count.HP_battle_calc_pc_damage_post ) { + int64 (*postHookFunc) (int64 retVal___, struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv); + for(hIndex = 0; hIndex < HPMHooks.count.HP_battle_calc_pc_damage_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_battle_calc_pc_damage_post[hIndex].func; + retVal___ = postHookFunc(retVal___, src, bl, d, damage, skill_id, skill_lv); + } + } + return retVal___; +} int64 HP_battle_calc_gvg_damage(struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag) { int hIndex = 0; int64 retVal___ = 0; @@ -1265,6 +1294,33 @@ enum damage_lv HP_battle_weapon_attack(struct block_list *bl, struct block_list } return retVal___; } +bool HP_battle_check_arrows(struct map_session_data *sd) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_battle_check_arrows_pre ) { + bool (*preHookFunc) (struct map_session_data **sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_battle_check_arrows_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_battle_check_arrows_pre[hIndex].func; + retVal___ = preHookFunc(&sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.battle.check_arrows(sd); + } + if( HPMHooks.count.HP_battle_check_arrows_post ) { + bool (*postHookFunc) (bool retVal___, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_battle_check_arrows_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_battle_check_arrows_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd); + } + } + return retVal___; +} struct Damage HP_battle_calc_weapon_attack(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int wflag) { int hIndex = 0; struct Damage retVal___ = { 0 }; @@ -4344,15 +4400,15 @@ bool HP_chat_kick(struct map_session_data *sd, const char *kickusername) { } return retVal___; } -bool HP_chat_create_npc_chat(struct npc_data *nd, const char *title, int limit, bool pub, int trigger, const char *ev, int zeny, int minLvl, int maxLvl) { +bool HP_chat_create_npc_chat(struct npc_data *nd, const char *title, int limit, bool pub, int trigger, const char *ev, int zeny, int min_level, int max_level) { int hIndex = 0; bool retVal___ = false; if( HPMHooks.count.HP_chat_create_npc_chat_pre ) { - bool (*preHookFunc) (struct npc_data **nd, const char **title, int *limit, bool *pub, int *trigger, const char **ev, int *zeny, int *minLvl, int *maxLvl); + bool (*preHookFunc) (struct npc_data **nd, const char **title, int *limit, bool *pub, int *trigger, const char **ev, int *zeny, int *min_level, int *max_level); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_chat_create_npc_chat_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_chat_create_npc_chat_pre[hIndex].func; - retVal___ = preHookFunc(&nd, &title, &limit, &pub, &trigger, &ev, &zeny, &minLvl, &maxLvl); + retVal___ = preHookFunc(&nd, &title, &limit, &pub, &trigger, &ev, &zeny, &min_level, &max_level); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -4360,13 +4416,13 @@ bool HP_chat_create_npc_chat(struct npc_data *nd, const char *title, int limit, } } { - retVal___ = HPMHooks.source.chat.create_npc_chat(nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl); + retVal___ = HPMHooks.source.chat.create_npc_chat(nd, title, limit, pub, trigger, ev, zeny, min_level, max_level); } if( HPMHooks.count.HP_chat_create_npc_chat_post ) { - bool (*postHookFunc) (bool retVal___, struct npc_data *nd, const char *title, int limit, bool pub, int trigger, const char *ev, int zeny, int minLvl, int maxLvl); + bool (*postHookFunc) (bool retVal___, struct npc_data *nd, const char *title, int limit, bool pub, int trigger, const char *ev, int zeny, int min_level, int max_level); for(hIndex = 0; hIndex < HPMHooks.count.HP_chat_create_npc_chat_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_chat_create_npc_chat_post[hIndex].func; - retVal___ = postHookFunc(retVal___, nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl); + retVal___ = postHookFunc(retVal___, nd, title, limit, pub, trigger, ev, zeny, min_level, max_level); } } return retVal___; @@ -4506,15 +4562,15 @@ bool HP_chat_trigger_event(struct chat_data *cd) { } return retVal___; } -struct chat_data* HP_chat_create(struct block_list *bl, const char *title, const char *pass, int limit, bool pub, int trigger, const char *ev, int zeny, int minLvl, int maxLvl) { +struct chat_data* HP_chat_create(struct block_list *bl, const char *title, const char *pass, int limit, bool pub, int trigger, const char *ev, int zeny, int min_level, int max_level) { int hIndex = 0; struct chat_data* retVal___ = NULL; if( HPMHooks.count.HP_chat_create_pre ) { - struct chat_data* (*preHookFunc) (struct block_list **bl, const char **title, const char **pass, int *limit, bool *pub, int *trigger, const char **ev, int *zeny, int *minLvl, int *maxLvl); + struct chat_data* (*preHookFunc) (struct block_list **bl, const char **title, const char **pass, int *limit, bool *pub, int *trigger, const char **ev, int *zeny, int *min_level, int *max_level); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_chat_create_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_chat_create_pre[hIndex].func; - retVal___ = preHookFunc(&bl, &title, &pass, &limit, &pub, &trigger, &ev, &zeny, &minLvl, &maxLvl); + retVal___ = preHookFunc(&bl, &title, &pass, &limit, &pub, &trigger, &ev, &zeny, &min_level, &max_level); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -4522,13 +4578,13 @@ struct chat_data* HP_chat_create(struct block_list *bl, const char *title, const } } { - retVal___ = HPMHooks.source.chat.create(bl, title, pass, limit, pub, trigger, ev, zeny, minLvl, maxLvl); + retVal___ = HPMHooks.source.chat.create(bl, title, pass, limit, pub, trigger, ev, zeny, min_level, max_level); } if( HPMHooks.count.HP_chat_create_post ) { - struct chat_data* (*postHookFunc) (struct chat_data* retVal___, struct block_list *bl, const char *title, const char *pass, int limit, bool pub, int trigger, const char *ev, int zeny, int minLvl, int maxLvl); + struct chat_data* (*postHookFunc) (struct chat_data* retVal___, struct block_list *bl, const char *title, const char *pass, int limit, bool pub, int trigger, const char *ev, int zeny, int min_level, int max_level); for(hIndex = 0; hIndex < HPMHooks.count.HP_chat_create_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_chat_create_post[hIndex].func; - retVal___ = postHookFunc(retVal___, bl, title, pass, limit, pub, trigger, ev, zeny, minLvl, maxLvl); + retVal___ = postHookFunc(retVal___, bl, title, pass, limit, pub, trigger, ev, zeny, min_level, max_level); } } return retVal___; @@ -10837,6 +10893,32 @@ void HP_clif_sc_load(struct block_list *bl, int tid, enum send_target target, in } return; } +void HP_clif_sc_continue(struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3) { + int hIndex = 0; + if( HPMHooks.count.HP_clif_sc_continue_pre ) { + void (*preHookFunc) (struct block_list **bl, int *tid, enum send_target *target, int *type, int *val1, int *val2, int *val3); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_sc_continue_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_sc_continue_pre[hIndex].func; + preHookFunc(&bl, &tid, &target, &type, &val1, &val2, &val3); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.sc_continue(bl, tid, target, type, val1, val2, val3); + } + if( HPMHooks.count.HP_clif_sc_continue_post ) { + void (*postHookFunc) (struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_sc_continue_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_sc_continue_post[hIndex].func; + postHookFunc(bl, tid, target, type, val1, val2, val3); + } + } + return; +} void HP_clif_sc_end(struct block_list *bl, int tid, enum send_target target, int type) { int hIndex = 0; if( HPMHooks.count.HP_clif_sc_end_pre ) { @@ -11646,14 +11728,14 @@ void HP_clif_skill_warppoint(struct map_session_data *sd, uint16 skill_id, uint1 } return; } -void HP_clif_skillcasting(struct block_list *bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, int property, int casttime) { +void HP_clif_useskill(struct block_list *bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, uint16 skill_lv, int casttime) { int hIndex = 0; - if( HPMHooks.count.HP_clif_skillcasting_pre ) { - void (*preHookFunc) (struct block_list **bl, int *src_id, int *dst_id, int *dst_x, int *dst_y, uint16 *skill_id, int *property, int *casttime); + if( HPMHooks.count.HP_clif_useskill_pre ) { + void (*preHookFunc) (struct block_list **bl, int *src_id, int *dst_id, int *dst_x, int *dst_y, uint16 *skill_id, uint16 *skill_lv, int *casttime); *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_skillcasting_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_clif_skillcasting_pre[hIndex].func; - preHookFunc(&bl, &src_id, &dst_id, &dst_x, &dst_y, &skill_id, &property, &casttime); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_useskill_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_useskill_pre[hIndex].func; + preHookFunc(&bl, &src_id, &dst_id, &dst_x, &dst_y, &skill_id, &skill_lv, &casttime); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -11661,13 +11743,13 @@ void HP_clif_skillcasting(struct block_list *bl, int src_id, int dst_id, int dst } } { - HPMHooks.source.clif.skillcasting(bl, src_id, dst_id, dst_x, dst_y, skill_id, property, casttime); + HPMHooks.source.clif.useskill(bl, src_id, dst_id, dst_x, dst_y, skill_id, skill_lv, casttime); } - if( HPMHooks.count.HP_clif_skillcasting_post ) { - void (*postHookFunc) (struct block_list *bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, int property, int casttime); - for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_skillcasting_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_clif_skillcasting_post[hIndex].func; - postHookFunc(bl, src_id, dst_id, dst_x, dst_y, skill_id, property, casttime); + if( HPMHooks.count.HP_clif_useskill_post ) { + void (*postHookFunc) (struct block_list *bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, uint16 skill_lv, int casttime); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_useskill_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_useskill_post[hIndex].func; + postHookFunc(bl, src_id, dst_id, dst_x, dst_y, skill_id, skill_lv, casttime); } } return; @@ -18110,6 +18192,60 @@ void HP_clif_ackmergeitems(int fd, struct map_session_data *sd) { } return; } +bool HP_clif_isdisguised(struct block_list *bl) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_clif_isdisguised_pre ) { + bool (*preHookFunc) (struct block_list **bl); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_isdisguised_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_isdisguised_pre[hIndex].func; + retVal___ = preHookFunc(&bl); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clif.isdisguised(bl); + } + if( HPMHooks.count.HP_clif_isdisguised_post ) { + bool (*postHookFunc) (bool retVal___, struct block_list *bl); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_isdisguised_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_isdisguised_post[hIndex].func; + retVal___ = postHookFunc(retVal___, bl); + } + } + return retVal___; +} +unsigned char HP_clif_bl_type(struct block_list *bl) { + int hIndex = 0; + unsigned char retVal___ = 0; + if( HPMHooks.count.HP_clif_bl_type_pre ) { + unsigned char (*preHookFunc) (struct block_list **bl); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_bl_type_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_bl_type_pre[hIndex].func; + retVal___ = preHookFunc(&bl); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.clif.bl_type(bl); + } + if( HPMHooks.count.HP_clif_bl_type_post ) { + unsigned char (*postHookFunc) (unsigned char retVal___, struct block_list *bl); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_bl_type_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_bl_type_post[hIndex].func; + retVal___ = postHookFunc(retVal___, bl); + } + } + return retVal___; +} void HP_clif_pWantToConnection(int fd, struct map_session_data *sd) { int hIndex = 0; if( HPMHooks.count.HP_clif_pWantToConnection_pre ) { @@ -25000,6 +25136,59 @@ void HP_DB_final(void) { } return; } +/* des_interface */ +void HP_des_decrypt_block(struct des_bit64 *block) { + int hIndex = 0; + if( HPMHooks.count.HP_des_decrypt_block_pre ) { + void (*preHookFunc) (struct des_bit64 **block); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_des_decrypt_block_pre[hIndex].func; + preHookFunc(&block); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.des.decrypt_block(block); + } + if( HPMHooks.count.HP_des_decrypt_block_post ) { + void (*postHookFunc) (struct des_bit64 *block); + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_des_decrypt_block_post[hIndex].func; + postHookFunc(block); + } + } + return; +} +void HP_des_decrypt(unsigned char *data, size_t size) { + int hIndex = 0; + if( HPMHooks.count.HP_des_decrypt_pre ) { + void (*preHookFunc) (unsigned char **data, size_t *size); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_des_decrypt_pre[hIndex].func; + preHookFunc(&data, &size); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.des.decrypt(data, size); + } + if( HPMHooks.count.HP_des_decrypt_post ) { + void (*postHookFunc) (unsigned char *data, size_t size); + for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_des_decrypt_post[hIndex].func; + postHookFunc(data, size); + } + } + return; +} /* duel_interface */ int HP_duel_create(struct map_session_data *sd, const unsigned int maxpl) { int hIndex = 0; @@ -26108,6 +26297,194 @@ int HP_elemental_read_db(void) { } return retVal___; } +/* grfio_interface */ +void HP_grfio_init(const char *fname) { + int hIndex = 0; + if( HPMHooks.count.HP_grfio_init_pre ) { + void (*preHookFunc) (const char **fname); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_grfio_init_pre[hIndex].func; + preHookFunc(&fname); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.grfio.init(fname); + } + if( HPMHooks.count.HP_grfio_init_post ) { + void (*postHookFunc) (const char *fname); + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_grfio_init_post[hIndex].func; + postHookFunc(fname); + } + } + return; +} +void HP_grfio_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_grfio_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_grfio_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.grfio.final(); + } + if( HPMHooks.count.HP_grfio_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_grfio_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void* HP_grfio_reads(const char *fname, int *size) { + int hIndex = 0; + void* retVal___ = NULL; + if( HPMHooks.count.HP_grfio_reads_pre ) { + void* (*preHookFunc) (const char **fname, int **size); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_reads_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_grfio_reads_pre[hIndex].func; + retVal___ = preHookFunc(&fname, &size); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.grfio.reads(fname, size); + } + if( HPMHooks.count.HP_grfio_reads_post ) { + void* (*postHookFunc) (void* retVal___, const char *fname, int *size); + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_reads_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_grfio_reads_post[hIndex].func; + retVal___ = postHookFunc(retVal___, fname, size); + } + } + return retVal___; +} +const char* HP_grfio_find_file(const char *fname) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_grfio_find_file_pre ) { + const char* (*preHookFunc) (const char **fname); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_find_file_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_grfio_find_file_pre[hIndex].func; + retVal___ = preHookFunc(&fname); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.grfio.find_file(fname); + } + if( HPMHooks.count.HP_grfio_find_file_post ) { + const char* (*postHookFunc) (const char* retVal___, const char *fname); + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_find_file_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_grfio_find_file_post[hIndex].func; + retVal___ = postHookFunc(retVal___, fname); + } + } + return retVal___; +} +unsigned long HP_grfio_crc32(const unsigned char *buf, unsigned int len) { + int hIndex = 0; + unsigned long retVal___ = 0; + if( HPMHooks.count.HP_grfio_crc32_pre ) { + unsigned long (*preHookFunc) (const unsigned char **buf, unsigned int *len); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_crc32_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_grfio_crc32_pre[hIndex].func; + retVal___ = preHookFunc(&buf, &len); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.grfio.crc32(buf, len); + } + if( HPMHooks.count.HP_grfio_crc32_post ) { + unsigned long (*postHookFunc) (unsigned long retVal___, const unsigned char *buf, unsigned int len); + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_crc32_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_grfio_crc32_post[hIndex].func; + retVal___ = postHookFunc(retVal___, buf, len); + } + } + return retVal___; +} +int HP_grfio_decode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_grfio_decode_zip_pre ) { + int (*preHookFunc) (void **dest, unsigned long **dest_len, const void **source, unsigned long *source_len); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_decode_zip_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_grfio_decode_zip_pre[hIndex].func; + retVal___ = preHookFunc(&dest, &dest_len, &source, &source_len); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.grfio.decode_zip(dest, dest_len, source, source_len); + } + if( HPMHooks.count.HP_grfio_decode_zip_post ) { + int (*postHookFunc) (int retVal___, void *dest, unsigned long *dest_len, const void *source, unsigned long source_len); + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_decode_zip_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_grfio_decode_zip_post[hIndex].func; + retVal___ = postHookFunc(retVal___, dest, dest_len, source, source_len); + } + } + return retVal___; +} +int HP_grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_grfio_encode_zip_pre ) { + int (*preHookFunc) (void **dest, unsigned long **dest_len, const void **source, unsigned long *source_len); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_encode_zip_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_grfio_encode_zip_pre[hIndex].func; + retVal___ = preHookFunc(&dest, &dest_len, &source, &source_len); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.grfio.encode_zip(dest, dest_len, source, source_len); + } + if( HPMHooks.count.HP_grfio_encode_zip_post ) { + int (*postHookFunc) (int retVal___, void *dest, unsigned long *dest_len, const void *source, unsigned long source_len); + for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_encode_zip_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_grfio_encode_zip_post[hIndex].func; + retVal___ = postHookFunc(retVal___, dest, dest_len, source, source_len); + } + } + return retVal___; +} /* guild_interface */ void HP_guild_init(bool minimal) { int hIndex = 0; @@ -43700,6 +44077,85 @@ bool HP_mapreg_config_read(const char *w1, const char *w2) { } return retVal___; } +/* md5_interface */ +void HP_md5_string(const char *string, char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_string_pre ) { + void (*preHookFunc) (const char **string, char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_string_pre[hIndex].func; + preHookFunc(&string, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.string(string, output); + } + if( HPMHooks.count.HP_md5_string_post ) { + void (*postHookFunc) (const char *string, char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_string_post[hIndex].func; + postHookFunc(string, output); + } + } + return; +} +void HP_md5_binary(const char *string, unsigned char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_binary_pre ) { + void (*preHookFunc) (const char **string, unsigned char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func; + preHookFunc(&string, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.binary(string, output); + } + if( HPMHooks.count.HP_md5_binary_post ) { + void (*postHookFunc) (const char *string, unsigned char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func; + postHookFunc(string, output); + } + } + return; +} +void HP_md5_salt(int len, char *output) { + int hIndex = 0; + if( HPMHooks.count.HP_md5_salt_pre ) { + void (*preHookFunc) (int *len, char **output); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_md5_salt_pre[hIndex].func; + preHookFunc(&len, &output); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.md5.salt(len, output); + } + if( HPMHooks.count.HP_md5_salt_post ) { + void (*postHookFunc) (int len, char *output); + for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_md5_salt_post[hIndex].func; + postHookFunc(len, output); + } + } + return; +} /* mercenary_interface */ void HP_mercenary_init(bool minimal) { int hIndex = 0; @@ -47225,6 +47681,270 @@ void HP_mob_destroy_mob_db(int index) { } return; } +/* mutex_interface */ +struct mutex_data* HP_mutex_create(void) { + int hIndex = 0; + struct mutex_data* retVal___ = NULL; + if( HPMHooks.count.HP_mutex_create_pre ) { + struct mutex_data* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_create_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.create(); + } + if( HPMHooks.count.HP_mutex_create_post ) { + struct mutex_data* (*postHookFunc) (struct mutex_data* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +void HP_mutex_destroy(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_destroy_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_destroy_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.destroy(m); + } + if( HPMHooks.count.HP_mutex_destroy_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_destroy_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +void HP_mutex_lock(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_lock_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_lock_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.lock(m); + } + if( HPMHooks.count.HP_mutex_lock_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_lock_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +bool HP_mutex_trylock(struct mutex_data *m) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_mutex_trylock_pre ) { + bool (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_trylock_pre[hIndex].func; + retVal___ = preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.trylock(m); + } + if( HPMHooks.count.HP_mutex_trylock_post ) { + bool (*postHookFunc) (bool retVal___, struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_trylock_post[hIndex].func; + retVal___ = postHookFunc(retVal___, m); + } + } + return retVal___; +} +void HP_mutex_unlock(struct mutex_data *m) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_unlock_pre ) { + void (*preHookFunc) (struct mutex_data **m); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_unlock_pre[hIndex].func; + preHookFunc(&m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.unlock(m); + } + if( HPMHooks.count.HP_mutex_unlock_post ) { + void (*postHookFunc) (struct mutex_data *m); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_unlock_post[hIndex].func; + postHookFunc(m); + } + } + return; +} +struct cond_data* HP_mutex_cond_create(void) { + int hIndex = 0; + struct cond_data* retVal___ = NULL; + if( HPMHooks.count.HP_mutex_cond_create_pre ) { + struct cond_data* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_create_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mutex.cond_create(); + } + if( HPMHooks.count.HP_mutex_cond_create_post ) { + struct cond_data* (*postHookFunc) (struct cond_data* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +void HP_mutex_cond_destroy(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_destroy_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_destroy_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_destroy(c); + } + if( HPMHooks.count.HP_mutex_cond_destroy_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_destroy_post[hIndex].func; + postHookFunc(c); + } + } + return; +} +void HP_mutex_cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_wait_pre ) { + void (*preHookFunc) (struct cond_data **c, struct mutex_data **m, sysint *timeout_ticks); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_wait_pre[hIndex].func; + preHookFunc(&c, &m, &timeout_ticks); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_wait(c, m, timeout_ticks); + } + if( HPMHooks.count.HP_mutex_cond_wait_post ) { + void (*postHookFunc) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_wait_post[hIndex].func; + postHookFunc(c, m, timeout_ticks); + } + } + return; +} +void HP_mutex_cond_signal(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_signal_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_signal_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_signal(c); + } + if( HPMHooks.count.HP_mutex_cond_signal_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_signal_post[hIndex].func; + postHookFunc(c); + } + } + return; +} +void HP_mutex_cond_broadcast(struct cond_data *c) { + int hIndex = 0; + if( HPMHooks.count.HP_mutex_cond_broadcast_pre ) { + void (*preHookFunc) (struct cond_data **c); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_pre[hIndex].func; + preHookFunc(&c); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.mutex.cond_broadcast(c); + } + if( HPMHooks.count.HP_mutex_cond_broadcast_post ) { + void (*postHookFunc) (struct cond_data *c); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_post[hIndex].func; + postHookFunc(c); + } + } + return; +} /* npc_chat_interface */ int HP_npc_chat_sub(struct block_list *bl, va_list ap) { int hIndex = 0; @@ -54182,11 +54902,11 @@ int HP_pc_stop_following(struct map_session_data *sd) { } return retVal___; } -unsigned int HP_pc_maxbaselv(struct map_session_data *sd) { +int HP_pc_maxbaselv(const struct map_session_data *sd) { int hIndex = 0; - unsigned int retVal___ = 0; + int retVal___ = 0; if( HPMHooks.count.HP_pc_maxbaselv_pre ) { - unsigned int (*preHookFunc) (struct map_session_data **sd); + int (*preHookFunc) (const struct map_session_data **sd); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_maxbaselv_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_pc_maxbaselv_pre[hIndex].func; @@ -54201,7 +54921,7 @@ unsigned int HP_pc_maxbaselv(struct map_session_data *sd) { retVal___ = HPMHooks.source.pc.maxbaselv(sd); } if( HPMHooks.count.HP_pc_maxbaselv_post ) { - unsigned int (*postHookFunc) (unsigned int retVal___, struct map_session_data *sd); + int (*postHookFunc) (int retVal___, const struct map_session_data *sd); for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_maxbaselv_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_pc_maxbaselv_post[hIndex].func; retVal___ = postHookFunc(retVal___, sd); @@ -54209,11 +54929,11 @@ unsigned int HP_pc_maxbaselv(struct map_session_data *sd) { } return retVal___; } -unsigned int HP_pc_maxjoblv(struct map_session_data *sd) { +int HP_pc_maxjoblv(const struct map_session_data *sd) { int hIndex = 0; - unsigned int retVal___ = 0; + int retVal___ = 0; if( HPMHooks.count.HP_pc_maxjoblv_pre ) { - unsigned int (*preHookFunc) (struct map_session_data **sd); + int (*preHookFunc) (const struct map_session_data **sd); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_maxjoblv_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_pc_maxjoblv_pre[hIndex].func; @@ -54228,7 +54948,7 @@ unsigned int HP_pc_maxjoblv(struct map_session_data *sd) { retVal___ = HPMHooks.source.pc.maxjoblv(sd); } if( HPMHooks.count.HP_pc_maxjoblv_post ) { - unsigned int (*postHookFunc) (unsigned int retVal___, struct map_session_data *sd); + int (*postHookFunc) (int retVal___, const struct map_session_data *sd); for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_maxjoblv_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_pc_maxjoblv_post[hIndex].func; retVal___ = postHookFunc(retVal___, sd); @@ -54317,11 +55037,11 @@ bool HP_pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned } return retVal___; } -unsigned int HP_pc_nextbaseexp(struct map_session_data *sd) { +unsigned int HP_pc_nextbaseexp(const struct map_session_data *sd) { int hIndex = 0; unsigned int retVal___ = 0; if( HPMHooks.count.HP_pc_nextbaseexp_pre ) { - unsigned int (*preHookFunc) (struct map_session_data **sd); + unsigned int (*preHookFunc) (const struct map_session_data **sd); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_nextbaseexp_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_pc_nextbaseexp_pre[hIndex].func; @@ -54336,7 +55056,7 @@ unsigned int HP_pc_nextbaseexp(struct map_session_data *sd) { retVal___ = HPMHooks.source.pc.nextbaseexp(sd); } if( HPMHooks.count.HP_pc_nextbaseexp_post ) { - unsigned int (*postHookFunc) (unsigned int retVal___, struct map_session_data *sd); + unsigned int (*postHookFunc) (unsigned int retVal___, const struct map_session_data *sd); for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_nextbaseexp_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_pc_nextbaseexp_post[hIndex].func; retVal___ = postHookFunc(retVal___, sd); @@ -54344,11 +55064,11 @@ unsigned int HP_pc_nextbaseexp(struct map_session_data *sd) { } return retVal___; } -unsigned int HP_pc_thisbaseexp(struct map_session_data *sd) { +unsigned int HP_pc_thisbaseexp(const struct map_session_data *sd) { int hIndex = 0; unsigned int retVal___ = 0; if( HPMHooks.count.HP_pc_thisbaseexp_pre ) { - unsigned int (*preHookFunc) (struct map_session_data **sd); + unsigned int (*preHookFunc) (const struct map_session_data **sd); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_thisbaseexp_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_pc_thisbaseexp_pre[hIndex].func; @@ -54363,7 +55083,7 @@ unsigned int HP_pc_thisbaseexp(struct map_session_data *sd) { retVal___ = HPMHooks.source.pc.thisbaseexp(sd); } if( HPMHooks.count.HP_pc_thisbaseexp_post ) { - unsigned int (*postHookFunc) (unsigned int retVal___, struct map_session_data *sd); + unsigned int (*postHookFunc) (unsigned int retVal___, const struct map_session_data *sd); for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_thisbaseexp_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_pc_thisbaseexp_post[hIndex].func; retVal___ = postHookFunc(retVal___, sd); @@ -54371,11 +55091,11 @@ unsigned int HP_pc_thisbaseexp(struct map_session_data *sd) { } return retVal___; } -unsigned int HP_pc_nextjobexp(struct map_session_data *sd) { +unsigned int HP_pc_nextjobexp(const struct map_session_data *sd) { int hIndex = 0; unsigned int retVal___ = 0; if( HPMHooks.count.HP_pc_nextjobexp_pre ) { - unsigned int (*preHookFunc) (struct map_session_data **sd); + unsigned int (*preHookFunc) (const struct map_session_data **sd); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_nextjobexp_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_pc_nextjobexp_pre[hIndex].func; @@ -54390,7 +55110,7 @@ unsigned int HP_pc_nextjobexp(struct map_session_data *sd) { retVal___ = HPMHooks.source.pc.nextjobexp(sd); } if( HPMHooks.count.HP_pc_nextjobexp_post ) { - unsigned int (*postHookFunc) (unsigned int retVal___, struct map_session_data *sd); + unsigned int (*postHookFunc) (unsigned int retVal___, const struct map_session_data *sd); for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_nextjobexp_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_pc_nextjobexp_post[hIndex].func; retVal___ = postHookFunc(retVal___, sd); @@ -54398,11 +55118,11 @@ unsigned int HP_pc_nextjobexp(struct map_session_data *sd) { } return retVal___; } -unsigned int HP_pc_thisjobexp(struct map_session_data *sd) { +unsigned int HP_pc_thisjobexp(const struct map_session_data *sd) { int hIndex = 0; unsigned int retVal___ = 0; if( HPMHooks.count.HP_pc_thisjobexp_pre ) { - unsigned int (*preHookFunc) (struct map_session_data **sd); + unsigned int (*preHookFunc) (const struct map_session_data **sd); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_thisjobexp_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_pc_thisjobexp_pre[hIndex].func; @@ -54417,7 +55137,7 @@ unsigned int HP_pc_thisjobexp(struct map_session_data *sd) { retVal___ = HPMHooks.source.pc.thisjobexp(sd); } if( HPMHooks.count.HP_pc_thisjobexp_post ) { - unsigned int (*postHookFunc) (unsigned int retVal___, struct map_session_data *sd); + unsigned int (*postHookFunc) (unsigned int retVal___, const struct map_session_data *sd); for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_thisjobexp_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_pc_thisjobexp_post[hIndex].func; retVal___ = postHookFunc(retVal___, sd); @@ -55414,11 +56134,11 @@ int HP_pc_equiplookall(struct map_session_data *sd) { } return retVal___; } -int HP_pc_readparam(struct map_session_data *sd, int type) { +int HP_pc_readparam(const struct map_session_data *sd, int type) { int hIndex = 0; int retVal___ = 0; if( HPMHooks.count.HP_pc_readparam_pre ) { - int (*preHookFunc) (struct map_session_data **sd, int *type); + int (*preHookFunc) (const struct map_session_data **sd, int *type); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_readparam_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_pc_readparam_pre[hIndex].func; @@ -55433,7 +56153,7 @@ int HP_pc_readparam(struct map_session_data *sd, int type) { retVal___ = HPMHooks.source.pc.readparam(sd, type); } if( HPMHooks.count.HP_pc_readparam_post ) { - int (*postHookFunc) (int retVal___, struct map_session_data *sd, int type); + int (*postHookFunc) (int retVal___, const struct map_session_data *sd, int type); for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_readparam_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_pc_readparam_post[hIndex].func; retVal___ = postHookFunc(retVal___, sd, type); @@ -59879,6 +60599,220 @@ struct quest_db* HP_quest_read_db_sub(struct config_setting_t *cs, int n, const } return retVal___; } +/* rnd_interface */ +void HP_rnd_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.init(); + } + if( HPMHooks.count.HP_rnd_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.final(); + } + if( HPMHooks.count.HP_rnd_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_rnd_seed(uint32 seed) { + int hIndex = 0; + if( HPMHooks.count.HP_rnd_seed_pre ) { + void (*preHookFunc) (uint32 *seed); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func; + preHookFunc(&seed); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.rnd.seed(seed); + } + if( HPMHooks.count.HP_rnd_seed_post ) { + void (*postHookFunc) (uint32 seed); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func; + postHookFunc(seed); + } + } + return; +} +int32 HP_rnd_random(void) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_random_pre ) { + int32 (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.random(); + } + if( HPMHooks.count.HP_rnd_random_post ) { + int32 (*postHookFunc) (int32 retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +uint32 HP_rnd_roll(uint32 dice_faces) { + int hIndex = 0; + uint32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_roll_pre ) { + uint32 (*preHookFunc) (uint32 *dice_faces); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func; + retVal___ = preHookFunc(&dice_faces); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.roll(dice_faces); + } + if( HPMHooks.count.HP_rnd_roll_post ) { + uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func; + retVal___ = postHookFunc(retVal___, dice_faces); + } + } + return retVal___; +} +int32 HP_rnd_value(int32 min, int32 max) { + int hIndex = 0; + int32 retVal___ = 0; + if( HPMHooks.count.HP_rnd_value_pre ) { + int32 (*preHookFunc) (int32 *min, int32 *max); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func; + retVal___ = preHookFunc(&min, &max); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.value(min, max); + } + if( HPMHooks.count.HP_rnd_value_post ) { + int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func; + retVal___ = postHookFunc(retVal___, min, max); + } + } + return retVal___; +} +double HP_rnd_uniform(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform(); + } + if( HPMHooks.count.HP_rnd_uniform_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +double HP_rnd_uniform53(void) { + int hIndex = 0; + double retVal___ = 0.; + if( HPMHooks.count.HP_rnd_uniform53_pre ) { + double (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.rnd.uniform53(); + } + if( HPMHooks.count.HP_rnd_uniform53_post ) { + double (*postHookFunc) (double retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} /* script_interface */ void HP_script_init(bool minimal) { int hIndex = 0; @@ -61692,11 +62626,11 @@ const char* HP_script_parse_syntax(const char *p) { } return retVal___; } -c_op HP_script_get_com(unsigned char *scriptbuf, int *pos) { +c_op HP_script_get_com(const struct script_buf *scriptbuf, int *pos) { int hIndex = 0; c_op retVal___ = C_NOP; if( HPMHooks.count.HP_script_get_com_pre ) { - c_op (*preHookFunc) (unsigned char **scriptbuf, int **pos); + c_op (*preHookFunc) (const struct script_buf **scriptbuf, int **pos); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_script_get_com_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_script_get_com_pre[hIndex].func; @@ -61711,7 +62645,7 @@ c_op HP_script_get_com(unsigned char *scriptbuf, int *pos) { retVal___ = HPMHooks.source.script.get_com(scriptbuf, pos); } if( HPMHooks.count.HP_script_get_com_post ) { - c_op (*postHookFunc) (c_op retVal___, unsigned char *scriptbuf, int *pos); + c_op (*postHookFunc) (c_op retVal___, const struct script_buf *scriptbuf, int *pos); for(hIndex = 0; hIndex < HPMHooks.count.HP_script_get_com_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_script_get_com_post[hIndex].func; retVal___ = postHookFunc(retVal___, scriptbuf, pos); @@ -61719,11 +62653,11 @@ c_op HP_script_get_com(unsigned char *scriptbuf, int *pos) { } return retVal___; } -int HP_script_get_num(unsigned char *scriptbuf, int *pos) { +int HP_script_get_num(const struct script_buf *scriptbuf, int *pos) { int hIndex = 0; int retVal___ = 0; if( HPMHooks.count.HP_script_get_num_pre ) { - int (*preHookFunc) (unsigned char **scriptbuf, int **pos); + int (*preHookFunc) (const struct script_buf **scriptbuf, int **pos); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_script_get_num_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_script_get_num_pre[hIndex].func; @@ -61738,7 +62672,7 @@ int HP_script_get_num(unsigned char *scriptbuf, int *pos) { retVal___ = HPMHooks.source.script.get_num(scriptbuf, pos); } if( HPMHooks.count.HP_script_get_num_post ) { - int (*postHookFunc) (int retVal___, unsigned char *scriptbuf, int *pos); + int (*postHookFunc) (int retVal___, const struct script_buf *scriptbuf, int *pos); for(hIndex = 0; hIndex < HPMHooks.count.HP_script_get_num_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_script_get_num_post[hIndex].func; retVal___ = postHookFunc(retVal___, scriptbuf, pos); @@ -62221,6 +63155,140 @@ const char* HP_script_parse_simpleexpr(const char *p) { } return retVal___; } +const char* HP_script_parse_simpleexpr_paren(const char *p) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_script_parse_simpleexpr_paren_pre ) { + const char* (*preHookFunc) (const char **p); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_parse_simpleexpr_paren_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_parse_simpleexpr_paren_pre[hIndex].func; + retVal___ = preHookFunc(&p); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.script.parse_simpleexpr_paren(p); + } + if( HPMHooks.count.HP_script_parse_simpleexpr_paren_post ) { + const char* (*postHookFunc) (const char* retVal___, const char *p); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_parse_simpleexpr_paren_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_parse_simpleexpr_paren_post[hIndex].func; + retVal___ = postHookFunc(retVal___, p); + } + } + return retVal___; +} +const char* HP_script_parse_simpleexpr_number(const char *p) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_script_parse_simpleexpr_number_pre ) { + const char* (*preHookFunc) (const char **p); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_parse_simpleexpr_number_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_parse_simpleexpr_number_pre[hIndex].func; + retVal___ = preHookFunc(&p); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.script.parse_simpleexpr_number(p); + } + if( HPMHooks.count.HP_script_parse_simpleexpr_number_post ) { + const char* (*postHookFunc) (const char* retVal___, const char *p); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_parse_simpleexpr_number_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_parse_simpleexpr_number_post[hIndex].func; + retVal___ = postHookFunc(retVal___, p); + } + } + return retVal___; +} +const char* HP_script_parse_simpleexpr_string(const char *p) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_script_parse_simpleexpr_string_pre ) { + const char* (*preHookFunc) (const char **p); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_parse_simpleexpr_string_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_parse_simpleexpr_string_pre[hIndex].func; + retVal___ = preHookFunc(&p); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.script.parse_simpleexpr_string(p); + } + if( HPMHooks.count.HP_script_parse_simpleexpr_string_post ) { + const char* (*postHookFunc) (const char* retVal___, const char *p); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_parse_simpleexpr_string_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_parse_simpleexpr_string_post[hIndex].func; + retVal___ = postHookFunc(retVal___, p); + } + } + return retVal___; +} +const char* HP_script_parse_simpleexpr_name(const char *p) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_script_parse_simpleexpr_name_pre ) { + const char* (*preHookFunc) (const char **p); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_parse_simpleexpr_name_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_parse_simpleexpr_name_pre[hIndex].func; + retVal___ = preHookFunc(&p); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.script.parse_simpleexpr_name(p); + } + if( HPMHooks.count.HP_script_parse_simpleexpr_name_post ) { + const char* (*postHookFunc) (const char* retVal___, const char *p); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_parse_simpleexpr_name_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_parse_simpleexpr_name_post[hIndex].func; + retVal___ = postHookFunc(retVal___, p); + } + } + return retVal___; +} +void HP_script_add_translatable_string(const struct script_string_buf *string, const char *start_point) { + int hIndex = 0; + if( HPMHooks.count.HP_script_add_translatable_string_pre ) { + void (*preHookFunc) (const struct script_string_buf **string, const char **start_point); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_add_translatable_string_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_add_translatable_string_pre[hIndex].func; + preHookFunc(&string, &start_point); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.script.add_translatable_string(string, start_point); + } + if( HPMHooks.count.HP_script_add_translatable_string_post ) { + void (*postHookFunc) (const struct script_string_buf *string, const char *start_point); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_add_translatable_string_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_add_translatable_string_post[hIndex].func; + postHookFunc(string, start_point); + } + } + return; +} const char* HP_script_parse_expr(const char *p) { int hIndex = 0; const char* retVal___ = NULL; @@ -62824,31 +63892,32 @@ void HP_script_op_1(struct script_state *st, int op) { } return; } -void HP_script_check_buildin_argtype(struct script_state *st, int func) { +bool HP_script_check_buildin_argtype(struct script_state *st, int func) { int hIndex = 0; + bool retVal___ = false; if( HPMHooks.count.HP_script_check_buildin_argtype_pre ) { - void (*preHookFunc) (struct script_state **st, int *func); + bool (*preHookFunc) (struct script_state **st, int *func); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_script_check_buildin_argtype_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_script_check_buildin_argtype_pre[hIndex].func; - preHookFunc(&st, &func); + retVal___ = preHookFunc(&st, &func); } if( *HPMforce_return ) { *HPMforce_return = false; - return; + return retVal___; } } { - HPMHooks.source.script.check_buildin_argtype(st, func); + retVal___ = HPMHooks.source.script.check_buildin_argtype(st, func); } if( HPMHooks.count.HP_script_check_buildin_argtype_post ) { - void (*postHookFunc) (struct script_state *st, int func); + bool (*postHookFunc) (bool retVal___, struct script_state *st, int func); for(hIndex = 0; hIndex < HPMHooks.count.HP_script_check_buildin_argtype_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_script_check_buildin_argtype_post[hIndex].func; - postHookFunc(st, func); + retVal___ = postHookFunc(retVal___, st, func); } } - return; + return retVal___; } void HP_script_detach_state(struct script_state *st, bool dequeue_event) { int hIndex = 0; @@ -64245,31 +65314,59 @@ void HP_script_load_translations(void) { } return; } -void HP_script_load_translation(const char *file, uint8 lang_id, uint32 *total) { +bool HP_script_load_translation_addstring(const char *file, uint8 lang_id, const char *msgctxt, const struct script_string_buf *msgid, const struct script_string_buf *msgstr) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_script_load_translation_addstring_pre ) { + bool (*preHookFunc) (const char **file, uint8 *lang_id, const char **msgctxt, const struct script_string_buf **msgid, const struct script_string_buf **msgstr); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_load_translation_addstring_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_load_translation_addstring_pre[hIndex].func; + retVal___ = preHookFunc(&file, &lang_id, &msgctxt, &msgid, &msgstr); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.script.load_translation_addstring(file, lang_id, msgctxt, msgid, msgstr); + } + if( HPMHooks.count.HP_script_load_translation_addstring_post ) { + bool (*postHookFunc) (bool retVal___, const char *file, uint8 lang_id, const char *msgctxt, const struct script_string_buf *msgid, const struct script_string_buf *msgstr); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_load_translation_addstring_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_load_translation_addstring_post[hIndex].func; + retVal___ = postHookFunc(retVal___, file, lang_id, msgctxt, msgid, msgstr); + } + } + return retVal___; +} +int HP_script_load_translation(const char *file, uint8 lang_id) { int hIndex = 0; + int retVal___ = 0; if( HPMHooks.count.HP_script_load_translation_pre ) { - void (*preHookFunc) (const char **file, uint8 *lang_id, uint32 **total); + int (*preHookFunc) (const char **file, uint8 *lang_id); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_script_load_translation_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_script_load_translation_pre[hIndex].func; - preHookFunc(&file, &lang_id, &total); + retVal___ = preHookFunc(&file, &lang_id); } if( *HPMforce_return ) { *HPMforce_return = false; - return; + return retVal___; } } { - HPMHooks.source.script.load_translation(file, lang_id, total); + retVal___ = HPMHooks.source.script.load_translation(file, lang_id); } if( HPMHooks.count.HP_script_load_translation_post ) { - void (*postHookFunc) (const char *file, uint8 lang_id, uint32 *total); + int (*postHookFunc) (int retVal___, const char *file, uint8 lang_id); for(hIndex = 0; hIndex < HPMHooks.count.HP_script_load_translation_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_script_load_translation_post[hIndex].func; - postHookFunc(file, lang_id, total); + retVal___ = postHookFunc(retVal___, file, lang_id); } } - return; + return retVal___; } int HP_script_translation_db_destroyer(union DBKey key, struct DBData *data, va_list ap) { int hIndex = 0; @@ -67538,6 +68635,33 @@ int HP_skill_not_ok(uint16 skill_id, struct map_session_data *sd) { } return retVal___; } +int HP_skill_not_ok_unknown(uint16 skill_id, struct map_session_data *sd) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_skill_not_ok_unknown_pre ) { + int (*preHookFunc) (uint16 *skill_id, struct map_session_data **sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_not_ok_unknown_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_not_ok_unknown_pre[hIndex].func; + retVal___ = preHookFunc(&skill_id, &sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.skill.not_ok_unknown(skill_id, sd); + } + if( HPMHooks.count.HP_skill_not_ok_unknown_post ) { + int (*postHookFunc) (int retVal___, uint16 skill_id, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_not_ok_unknown_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_not_ok_unknown_post[hIndex].func; + retVal___ = postHookFunc(retVal___, skill_id, sd); + } + } + return retVal___; +} int HP_skill_not_ok_hom(uint16 skill_id, struct homun_data *hd) { int hIndex = 0; int retVal___ = 0; @@ -67565,6 +68689,33 @@ int HP_skill_not_ok_hom(uint16 skill_id, struct homun_data *hd) { } return retVal___; } +int HP_skill_not_ok_hom_unknown(uint16 skill_id, struct homun_data *hd) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_skill_not_ok_hom_unknown_pre ) { + int (*preHookFunc) (uint16 *skill_id, struct homun_data **hd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_not_ok_hom_unknown_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_not_ok_hom_unknown_pre[hIndex].func; + retVal___ = preHookFunc(&skill_id, &hd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.skill.not_ok_hom_unknown(skill_id, hd); + } + if( HPMHooks.count.HP_skill_not_ok_hom_unknown_post ) { + int (*postHookFunc) (int retVal___, uint16 skill_id, struct homun_data *hd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_not_ok_hom_unknown_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_not_ok_hom_unknown_post[hIndex].func; + retVal___ = postHookFunc(retVal___, skill_id, hd); + } + } + return retVal___; +} int HP_skill_not_ok_mercenary(uint16 skill_id, struct mercenary_data *md) { int hIndex = 0; int retVal___ = 0; @@ -67706,6 +68857,32 @@ int HP_skill_arrow_create(struct map_session_data *sd, int nameid) { } return retVal___; } +void HP_skill_castend_type(int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_castend_type_pre ) { + void (*preHookFunc) (int *type, struct block_list **src, struct block_list **bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_castend_type_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_castend_type_pre[hIndex].func; + preHookFunc(&type, &src, &bl, &skill_id, &skill_lv, &tick, &flag); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.castend_type(type, src, bl, skill_id, skill_lv, tick, flag); + } + if( HPMHooks.count.HP_skill_castend_type_post ) { + void (*postHookFunc) (int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_castend_type_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_castend_type_post[hIndex].func; + postHookFunc(type, src, bl, skill_id, skill_lv, tick, flag); + } + } + return; +} int HP_skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { int hIndex = 0; int retVal___ = 0; @@ -68938,6 +70115,32 @@ int HP_skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, i } return retVal___; } +void HP_skill_unit_onplace_timer_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_unit_onplace_timer_unknown_pre ) { + void (*preHookFunc) (struct skill_unit **src, struct block_list **bl, int64 **tick); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_unit_onplace_timer_unknown_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_unit_onplace_timer_unknown_pre[hIndex].func; + preHookFunc(&src, &bl, &tick); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.unit_onplace_timer_unknown(src, bl, tick); + } + if( HPMHooks.count.HP_skill_unit_onplace_timer_unknown_post ) { + void (*postHookFunc) (struct skill_unit *src, struct block_list *bl, int64 *tick); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_unit_onplace_timer_unknown_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_unit_onplace_timer_unknown_post[hIndex].func; + postHookFunc(src, bl, tick); + } + } + return; +} int HP_skill_unit_effect(struct block_list *bl, va_list ap) { int hIndex = 0; int retVal___ = 0; @@ -69231,96 +70434,405 @@ void HP_skill_init_unit_layout(void) { } return; } -bool HP_skill_parse_row_skilldb(char *split[], int columns, int current) { +void HP_skill_init_unit_layout_unknown(int skill_idx) { int hIndex = 0; - bool retVal___ = false; - if( HPMHooks.count.HP_skill_parse_row_skilldb_pre ) { - bool (*preHookFunc) (char **split[], int *columns, int *current); + if( HPMHooks.count.HP_skill_init_unit_layout_unknown_pre ) { + void (*preHookFunc) (int *skill_idx); *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_skilldb_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_skill_parse_row_skilldb_pre[hIndex].func; - retVal___ = preHookFunc(&split, &columns, ¤t); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_init_unit_layout_unknown_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_init_unit_layout_unknown_pre[hIndex].func; + preHookFunc(&skill_idx); } if( *HPMforce_return ) { *HPMforce_return = false; - return retVal___; + return; } } { - retVal___ = HPMHooks.source.skill.parse_row_skilldb(split, columns, current); + HPMHooks.source.skill.init_unit_layout_unknown(skill_idx); } - if( HPMHooks.count.HP_skill_parse_row_skilldb_post ) { - bool (*postHookFunc) (bool retVal___, char *split[], int columns, int current); - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_skilldb_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_skill_parse_row_skilldb_post[hIndex].func; - retVal___ = postHookFunc(retVal___, split, columns, current); + if( HPMHooks.count.HP_skill_init_unit_layout_unknown_post ) { + void (*postHookFunc) (int skill_idx); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_init_unit_layout_unknown_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_init_unit_layout_unknown_post[hIndex].func; + postHookFunc(skill_idx); } } - return retVal___; + return; } -bool HP_skill_parse_row_requiredb(char *split[], int columns, int current) { +void HP_skill_validate_hittype(struct config_setting_t *conf, struct s_skill_db *sk) { int hIndex = 0; - bool retVal___ = false; - if( HPMHooks.count.HP_skill_parse_row_requiredb_pre ) { - bool (*preHookFunc) (char **split[], int *columns, int *current); + if( HPMHooks.count.HP_skill_validate_hittype_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_requiredb_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_skill_parse_row_requiredb_pre[hIndex].func; - retVal___ = preHookFunc(&split, &columns, ¤t); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_hittype_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_hittype_pre[hIndex].func; + preHookFunc(&conf, &sk); } if( *HPMforce_return ) { *HPMforce_return = false; - return retVal___; + return; } } { - retVal___ = HPMHooks.source.skill.parse_row_requiredb(split, columns, current); + HPMHooks.source.skill.validate_hittype(conf, sk); } - if( HPMHooks.count.HP_skill_parse_row_requiredb_post ) { - bool (*postHookFunc) (bool retVal___, char *split[], int columns, int current); - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_requiredb_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_skill_parse_row_requiredb_post[hIndex].func; - retVal___ = postHookFunc(retVal___, split, columns, current); + if( HPMHooks.count.HP_skill_validate_hittype_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_hittype_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_hittype_post[hIndex].func; + postHookFunc(conf, sk); } } - return retVal___; + return; } -bool HP_skill_parse_row_castdb(char *split[], int columns, int current) { +void HP_skill_validate_skilltype(struct config_setting_t *conf, struct s_skill_db *sk) { int hIndex = 0; - bool retVal___ = false; - if( HPMHooks.count.HP_skill_parse_row_castdb_pre ) { - bool (*preHookFunc) (char **split[], int *columns, int *current); + if( HPMHooks.count.HP_skill_validate_skilltype_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_castdb_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_skill_parse_row_castdb_pre[hIndex].func; - retVal___ = preHookFunc(&split, &columns, ¤t); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_skilltype_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_skilltype_pre[hIndex].func; + preHookFunc(&conf, &sk); } if( *HPMforce_return ) { *HPMforce_return = false; - return retVal___; + return; } } { - retVal___ = HPMHooks.source.skill.parse_row_castdb(split, columns, current); + HPMHooks.source.skill.validate_skilltype(conf, sk); } - if( HPMHooks.count.HP_skill_parse_row_castdb_post ) { - bool (*postHookFunc) (bool retVal___, char *split[], int columns, int current); - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_castdb_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_skill_parse_row_castdb_post[hIndex].func; - retVal___ = postHookFunc(retVal___, split, columns, current); + if( HPMHooks.count.HP_skill_validate_skilltype_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_skilltype_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_skilltype_post[hIndex].func; + postHookFunc(conf, sk); } } - return retVal___; + return; +} +void HP_skill_validate_attacktype(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_attacktype_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_attacktype_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_attacktype_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_attacktype(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_attacktype_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_attacktype_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_attacktype_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_element(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_element_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_element_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_element_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_element(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_element_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_element_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_element_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_skillinfo(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_skillinfo_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_skillinfo_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_skillinfo_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_skillinfo(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_skillinfo_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_skillinfo_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_skillinfo_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_damagetype(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_damagetype_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_damagetype_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_damagetype_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_damagetype(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_damagetype_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_damagetype_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_damagetype_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_castnodex(struct config_setting_t *conf, struct s_skill_db *sk, bool delay) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_castnodex_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk, bool *delay); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_castnodex_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_castnodex_pre[hIndex].func; + preHookFunc(&conf, &sk, &delay); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_castnodex(conf, sk, delay); + } + if( HPMHooks.count.HP_skill_validate_castnodex_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk, bool delay); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_castnodex_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_castnodex_post[hIndex].func; + postHookFunc(conf, sk, delay); + } + } + return; +} +void HP_skill_validate_weapontype(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_weapontype_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_weapontype_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_weapontype_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_weapontype(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_weapontype_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_weapontype_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_weapontype_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_ammotype(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_ammotype_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_ammotype_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_ammotype_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_ammotype(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_ammotype_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_ammotype_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_ammotype_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_state(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_state_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_state_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_state_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_state(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_state_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_state_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_state_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_item_requirements(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_item_requirements_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_item_requirements_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_item_requirements_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_item_requirements(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_item_requirements_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_item_requirements_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_item_requirements_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_unit_target(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_unit_target_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_unit_target_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_unit_target_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_unit_target(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_unit_target_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_unit_target_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_unit_target_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_unit_flag(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_unit_flag_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_unit_flag_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_unit_flag_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_unit_flag(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_unit_flag_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_unit_flag_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_unit_flag_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; +} +void HP_skill_validate_additional_fields(struct config_setting_t *conf, struct s_skill_db *sk) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_validate_additional_fields_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, struct s_skill_db **sk); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_additional_fields_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_additional_fields_pre[hIndex].func; + preHookFunc(&conf, &sk); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.validate_additional_fields(conf, sk); + } + if( HPMHooks.count.HP_skill_validate_additional_fields_post ) { + void (*postHookFunc) (struct config_setting_t *conf, struct s_skill_db *sk); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_additional_fields_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_additional_fields_post[hIndex].func; + postHookFunc(conf, sk); + } + } + return; } -bool HP_skill_parse_row_castnodexdb(char *split[], int columns, int current) { +bool HP_skill_validate_skilldb(struct s_skill_db *skt, const char *source) { int hIndex = 0; bool retVal___ = false; - if( HPMHooks.count.HP_skill_parse_row_castnodexdb_pre ) { - bool (*preHookFunc) (char **split[], int *columns, int *current); + if( HPMHooks.count.HP_skill_validate_skilldb_pre ) { + bool (*preHookFunc) (struct s_skill_db **skt, const char **source); *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_castnodexdb_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_skill_parse_row_castnodexdb_pre[hIndex].func; - retVal___ = preHookFunc(&split, &columns, ¤t); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_skilldb_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_validate_skilldb_pre[hIndex].func; + retVal___ = preHookFunc(&skt, &source); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -69328,26 +70840,26 @@ bool HP_skill_parse_row_castnodexdb(char *split[], int columns, int current) { } } { - retVal___ = HPMHooks.source.skill.parse_row_castnodexdb(split, columns, current); + retVal___ = HPMHooks.source.skill.validate_skilldb(skt, source); } - if( HPMHooks.count.HP_skill_parse_row_castnodexdb_post ) { - bool (*postHookFunc) (bool retVal___, char *split[], int columns, int current); - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_castnodexdb_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_skill_parse_row_castnodexdb_post[hIndex].func; - retVal___ = postHookFunc(retVal___, split, columns, current); + if( HPMHooks.count.HP_skill_validate_skilldb_post ) { + bool (*postHookFunc) (bool retVal___, struct s_skill_db *skt, const char *source); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_validate_skilldb_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_validate_skilldb_post[hIndex].func; + retVal___ = postHookFunc(retVal___, skt, source); } } return retVal___; } -bool HP_skill_parse_row_unitdb(char *split[], int columns, int current) { +bool HP_skill_read_skilldb(const char *filename) { int hIndex = 0; bool retVal___ = false; - if( HPMHooks.count.HP_skill_parse_row_unitdb_pre ) { - bool (*preHookFunc) (char **split[], int *columns, int *current); + if( HPMHooks.count.HP_skill_read_skilldb_pre ) { + bool (*preHookFunc) (const char **filename); *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_unitdb_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_skill_parse_row_unitdb_pre[hIndex].func; - retVal___ = preHookFunc(&split, &columns, ¤t); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_read_skilldb_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_read_skilldb_pre[hIndex].func; + retVal___ = preHookFunc(&filename); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -69355,17 +70867,69 @@ bool HP_skill_parse_row_unitdb(char *split[], int columns, int current) { } } { - retVal___ = HPMHooks.source.skill.parse_row_unitdb(split, columns, current); + retVal___ = HPMHooks.source.skill.read_skilldb(filename); } - if( HPMHooks.count.HP_skill_parse_row_unitdb_post ) { - bool (*postHookFunc) (bool retVal___, char *split[], int columns, int current); - for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_parse_row_unitdb_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_skill_parse_row_unitdb_post[hIndex].func; - retVal___ = postHookFunc(retVal___, split, columns, current); + if( HPMHooks.count.HP_skill_read_skilldb_post ) { + bool (*postHookFunc) (bool retVal___, const char *filename); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_read_skilldb_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_read_skilldb_post[hIndex].func; + retVal___ = postHookFunc(retVal___, filename); } } return retVal___; } +void HP_skill_config_set_level(struct config_setting_t *conf, int *arr) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_config_set_level_pre ) { + void (*preHookFunc) (struct config_setting_t **conf, int **arr); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_config_set_level_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_config_set_level_pre[hIndex].func; + preHookFunc(&conf, &arr); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.config_set_level(conf, arr); + } + if( HPMHooks.count.HP_skill_config_set_level_post ) { + void (*postHookFunc) (struct config_setting_t *conf, int *arr); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_config_set_level_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_config_set_level_post[hIndex].func; + postHookFunc(conf, arr); + } + } + return; +} +void HP_skill_level_set_value(int *arr, int value) { + int hIndex = 0; + if( HPMHooks.count.HP_skill_level_set_value_pre ) { + void (*preHookFunc) (int **arr, int *value); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_level_set_value_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_level_set_value_pre[hIndex].func; + preHookFunc(&arr, &value); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.skill.level_set_value(arr, value); + } + if( HPMHooks.count.HP_skill_level_set_value_post ) { + void (*postHookFunc) (int *arr, int value); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_level_set_value_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_level_set_value_post[hIndex].func; + postHookFunc(arr, value); + } + } + return; +} bool HP_skill_parse_row_producedb(char *split[], int columns, int current) { int hIndex = 0; bool retVal___ = false; @@ -70865,6 +72429,99 @@ void HP_skill_get_requirement_unknown(struct status_change *sc, struct map_sessi } return; } +int HP_skill_splash_target(struct block_list *bl) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_skill_splash_target_pre ) { + int (*preHookFunc) (struct block_list **bl); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_splash_target_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_splash_target_pre[hIndex].func; + retVal___ = preHookFunc(&bl); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.skill.splash_target(bl); + } + if( HPMHooks.count.HP_skill_splash_target_post ) { + int (*postHookFunc) (int retVal___, struct block_list *bl); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_splash_target_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_splash_target_post[hIndex].func; + retVal___ = postHookFunc(retVal___, bl); + } + } + return retVal___; +} +int HP_skill_check_npc_chaospanic(struct block_list *bl, va_list args) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_skill_check_npc_chaospanic_pre ) { + int (*preHookFunc) (struct block_list **bl, va_list args); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_check_npc_chaospanic_pre; hIndex++ ) { + va_list args___copy; va_copy(args___copy, args); + preHookFunc = HPMHooks.list.HP_skill_check_npc_chaospanic_pre[hIndex].func; + retVal___ = preHookFunc(&bl, args___copy); + va_end(args___copy); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + va_list args___copy; va_copy(args___copy, args); + retVal___ = HPMHooks.source.skill.check_npc_chaospanic(bl, args___copy); + va_end(args___copy); + } + if( HPMHooks.count.HP_skill_check_npc_chaospanic_post ) { + int (*postHookFunc) (int retVal___, struct block_list *bl, va_list args); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_check_npc_chaospanic_post; hIndex++ ) { + va_list args___copy; va_copy(args___copy, args); + postHookFunc = HPMHooks.list.HP_skill_check_npc_chaospanic_post[hIndex].func; + retVal___ = postHookFunc(retVal___, bl, args___copy); + va_end(args___copy); + } + } + return retVal___; +} +int HP_skill_count_wos(struct block_list *bl, va_list ap) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_skill_count_wos_pre ) { + int (*preHookFunc) (struct block_list **bl, va_list ap); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_count_wos_pre; hIndex++ ) { + va_list ap___copy; va_copy(ap___copy, ap); + preHookFunc = HPMHooks.list.HP_skill_count_wos_pre[hIndex].func; + retVal___ = preHookFunc(&bl, ap___copy); + va_end(ap___copy); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + va_list ap___copy; va_copy(ap___copy, ap); + retVal___ = HPMHooks.source.skill.count_wos(bl, ap___copy); + va_end(ap___copy); + } + if( HPMHooks.count.HP_skill_count_wos_post ) { + int (*postHookFunc) (int retVal___, struct block_list *bl, va_list ap); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_count_wos_post; hIndex++ ) { + va_list ap___copy; va_copy(ap___copy, ap); + postHookFunc = HPMHooks.list.HP_skill_count_wos_post[hIndex].func; + retVal___ = postHookFunc(retVal___, bl, ap___copy); + va_end(ap___copy); + } + } + return retVal___; +} /* socket_interface */ void HP_sockt_init(void) { int hIndex = 0; @@ -75504,6 +77161,112 @@ void HP_status_read_job_db_sub(int idx, const char *name, struct config_setting_ } return; } +void HP_status_set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) { + int hIndex = 0; + if( HPMHooks.count.HP_status_set_sc_pre ) { + void (*preHookFunc) (uint16 *skill_id, sc_type *sc, int *icon, unsigned int *flag); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_status_set_sc_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_status_set_sc_pre[hIndex].func; + preHookFunc(&skill_id, &sc, &icon, &flag); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.status.set_sc(skill_id, sc, icon, flag); + } + if( HPMHooks.count.HP_status_set_sc_post ) { + void (*postHookFunc) (uint16 skill_id, sc_type sc, int icon, unsigned int flag); + for(hIndex = 0; hIndex < HPMHooks.count.HP_status_set_sc_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_status_set_sc_post[hIndex].func; + postHookFunc(skill_id, sc, icon, flag); + } + } + return; +} +void HP_status_copy(struct status_data *a, const struct status_data *b) { + int hIndex = 0; + if( HPMHooks.count.HP_status_copy_pre ) { + void (*preHookFunc) (struct status_data **a, const struct status_data **b); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_status_copy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_status_copy_pre[hIndex].func; + preHookFunc(&a, &b); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.status.copy(a, b); + } + if( HPMHooks.count.HP_status_copy_post ) { + void (*postHookFunc) (struct status_data *a, const struct status_data *b); + for(hIndex = 0; hIndex < HPMHooks.count.HP_status_copy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_status_copy_post[hIndex].func; + postHookFunc(a, b); + } + } + return; +} +unsigned short HP_status_base_matk_min(const struct status_data *st) { + int hIndex = 0; + unsigned short retVal___ = 0; + if( HPMHooks.count.HP_status_base_matk_min_pre ) { + unsigned short (*preHookFunc) (const struct status_data **st); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_matk_min_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_status_base_matk_min_pre[hIndex].func; + retVal___ = preHookFunc(&st); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.status.base_matk_min(st); + } + if( HPMHooks.count.HP_status_base_matk_min_post ) { + unsigned short (*postHookFunc) (unsigned short retVal___, const struct status_data *st); + for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_matk_min_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_status_base_matk_min_post[hIndex].func; + retVal___ = postHookFunc(retVal___, st); + } + } + return retVal___; +} +unsigned short HP_status_base_matk_max(const struct status_data *st) { + int hIndex = 0; + unsigned short retVal___ = 0; + if( HPMHooks.count.HP_status_base_matk_max_pre ) { + unsigned short (*preHookFunc) (const struct status_data **st); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_matk_max_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_status_base_matk_max_pre[hIndex].func; + retVal___ = preHookFunc(&st); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.status.base_matk_max(st); + } + if( HPMHooks.count.HP_status_base_matk_max_post ) { + unsigned short (*postHookFunc) (unsigned short retVal___, const struct status_data *st); + for(hIndex = 0; hIndex < HPMHooks.count.HP_status_base_matk_max_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_status_base_matk_max_post[hIndex].func; + retVal___ = postHookFunc(retVal___, st); + } + } + return retVal___; +} /* storage_interface */ void HP_storage_reconnect(void) { int hIndex = 0; @@ -77211,6 +78974,299 @@ void HP_sysinfo_final(void) { } return; } +/* thread_interface */ +void HP_thread_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.init(); + } + if( HPMHooks.count.HP_thread_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_thread_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.final(); + } + if( HPMHooks.count.HP_thread_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create(entry_point, param); + } + if( HPMHooks.count.HP_thread_create_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param); + } + } + return retVal___; +} +struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_create_opt_pre ) { + struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func; + retVal___ = preHookFunc(&entry_point, ¶m, &stack_size, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio); + } + if( HPMHooks.count.HP_thread_create_opt_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio); + } + } + return retVal___; +} +void HP_thread_destroy(struct thread_handle *handle) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_destroy_pre ) { + void (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func; + preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.destroy(handle); + } + if( HPMHooks.count.HP_thread_destroy_post ) { + void (*postHookFunc) (struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func; + postHookFunc(handle); + } + } + return; +} +struct thread_handle* HP_thread_self(void) { + int hIndex = 0; + struct thread_handle* retVal___ = NULL; + if( HPMHooks.count.HP_thread_self_pre ) { + struct thread_handle* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.self(); + } + if( HPMHooks.count.HP_thread_self_post ) { + struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +int HP_thread_get_tid(void) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_thread_get_tid_pre ) { + int (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.get_tid(); + } + if( HPMHooks.count.HP_thread_get_tid_post ) { + int (*postHookFunc) (int retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} +bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_thread_wait_pre ) { + bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func; + retVal___ = preHookFunc(&handle, &out_exit_code); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code); + } + if( HPMHooks.count.HP_thread_wait_post ) { + bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle, out_exit_code); + } + } + return retVal___; +} +void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_prio_set_pre ) { + void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func; + preHookFunc(&handle, &prio); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.prio_set(handle, prio); + } + if( HPMHooks.count.HP_thread_prio_set_post ) { + void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func; + postHookFunc(handle, prio); + } + } + return; +} +enum thread_priority HP_thread_prio_get(struct thread_handle *handle) { + int hIndex = 0; + enum thread_priority retVal___ = THREADPRIO_NORMAL; + if( HPMHooks.count.HP_thread_prio_get_pre ) { + enum thread_priority (*preHookFunc) (struct thread_handle **handle); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func; + retVal___ = preHookFunc(&handle); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.thread.prio_get(handle); + } + if( HPMHooks.count.HP_thread_prio_get_post ) { + enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func; + retVal___ = postHookFunc(retVal___, handle); + } + } + return retVal___; +} +void HP_thread_yield(void) { + int hIndex = 0; + if( HPMHooks.count.HP_thread_yield_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.thread.yield(); + } + if( HPMHooks.count.HP_thread_yield_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func; + postHookFunc(); + } + } + return; +} /* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_map.sources.inc b/src/plugins/HPMHooking/HPMHooking_map.sources.inc index 1af35ab21..54861ed6f 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.sources.inc @@ -23,6 +23,8 @@ * as it will get overwritten. */ +/* GENERATED FILE DO NOT EDIT */ + memcpy(&HPMHooks.source.HCache, HCache, sizeof(struct HCache_interface)); memcpy(&HPMHooks.source.atcommand, atcommand, sizeof(struct atcommand_interface)); memcpy(&HPMHooks.source.battle, battle, sizeof(struct battle_interface)); @@ -36,8 +38,10 @@ memcpy(&HPMHooks.source.cmdline, cmdline, sizeof(struct cmdline_interface)); memcpy(&HPMHooks.source.console, console, sizeof(struct console_interface)); memcpy(&HPMHooks.source.core, core, sizeof(struct core_interface)); memcpy(&HPMHooks.source.DB, DB, sizeof(struct db_interface)); +memcpy(&HPMHooks.source.des, des, sizeof(struct des_interface)); memcpy(&HPMHooks.source.duel, duel, sizeof(struct duel_interface)); memcpy(&HPMHooks.source.elemental, elemental, sizeof(struct elemental_interface)); +memcpy(&HPMHooks.source.grfio, grfio, sizeof(struct grfio_interface)); memcpy(&HPMHooks.source.guild, guild, sizeof(struct guild_interface)); memcpy(&HPMHooks.source.gstorage, gstorage, sizeof(struct guild_storage_interface)); memcpy(&HPMHooks.source.homun, homun, sizeof(struct homunculus_interface)); @@ -53,8 +57,10 @@ memcpy(&HPMHooks.source.map, map, sizeof(struct map_interface)); memcpy(&HPMHooks.source.mapindex, mapindex, sizeof(struct mapindex_interface)); memcpy(&HPMHooks.source.mapit, mapit, sizeof(struct mapit_interface)); memcpy(&HPMHooks.source.mapreg, mapreg, sizeof(struct mapreg_interface)); +memcpy(&HPMHooks.source.md5, md5, sizeof(struct md5_interface)); memcpy(&HPMHooks.source.mercenary, mercenary, sizeof(struct mercenary_interface)); memcpy(&HPMHooks.source.mob, mob, sizeof(struct mob_interface)); +memcpy(&HPMHooks.source.mutex, mutex, sizeof(struct mutex_interface)); memcpy(&HPMHooks.source.npc_chat, npc_chat, sizeof(struct npc_chat_interface)); memcpy(&HPMHooks.source.npc, npc, sizeof(struct npc_interface)); memcpy(&HPMHooks.source.nullpo, nullpo, sizeof(struct nullpo_interface)); @@ -65,6 +71,7 @@ memcpy(&HPMHooks.source.pc, pc, sizeof(struct pc_interface)); memcpy(&HPMHooks.source.libpcre, libpcre, sizeof(struct pcre_interface)); memcpy(&HPMHooks.source.pet, pet, sizeof(struct pet_interface)); memcpy(&HPMHooks.source.quest, quest, sizeof(struct quest_interface)); +memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface)); memcpy(&HPMHooks.source.script, script, sizeof(struct script_interface)); memcpy(&HPMHooks.source.searchstore, searchstore, sizeof(struct searchstore_interface)); memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface)); @@ -77,6 +84,7 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface)); memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface)); memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface)); memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface)); +memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface)); memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface)); memcpy(&HPMHooks.source.trade, trade, sizeof(struct trade_interface)); memcpy(&HPMHooks.source.unit, unit, sizeof(struct unit_interface)); diff --git a/src/plugins/constdb2doc.c b/src/plugins/constdb2doc.c index cb0b82278..d211c46e2 100644 --- a/src/plugins/constdb2doc.c +++ b/src/plugins/constdb2doc.c @@ -177,7 +177,8 @@ void do_constdb2doc(void) constdb2doc_itemdb(); - fprintf(out_fp, "> End of list\n"); + fprintf(out_fp, "> End of list\n\n"); + fprintf(out_fp, "<!--GENERATED FILE DO NOT EDIT-->\n"); fclose(out_fp); } diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index 510a56e2c..af5ab99af 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -78,6 +78,7 @@ int (*mob_read_db_sub) (struct config_setting_t *it, int n, const char *source); */ void hstr(const char *str) { + nullpo_retv(str); if (strlen(str) > tosql.buf[3].len) { tosql.buf[3].len = tosql.buf[3].len + strlen(str) + 1000; RECREATE(tosql.buf[3].p,char,tosql.buf[3].len); @@ -117,7 +118,9 @@ void db2sql_fileheader(void) "-- NOTE: This file was auto-generated and should never be manually edited,\n" "-- as it will get overwritten. If you need to modify this file,\n" "-- please consider modifying the corresponding .conf file inside\n" - "-- the db folder, and then re-run the db2sql plugin.\n" + "-- the db folder, and then re-run the db2sql plugin.\n\n" + + "-- GENERATED FILE DO NOT EDIT --\n" "\n", year); } @@ -288,7 +291,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) } else { ui64 = UINT64_MAX; } - StrBuf->Printf(&buf, "'0x%"PRIX64"',", ui64); + StrBuf->Printf(&buf, "'%"PRIu64"',", ui64); // equip_upper if (libconfig->setting_lookup_int(entry, "Upper", &i32) && i32 >= 0) @@ -376,8 +379,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) } // script - if (it->script) { - libconfig->setting_lookup_string(entry, "Script", &bonus); + if (it->script && libconfig->setting_lookup_string(entry, "Script", &bonus)) { hstr(bonus); str = tosql.buf[3].p; if (strlen(str) > tosql.buf[0].len) { @@ -385,12 +387,13 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) RECREATE(tosql.buf[0].p,char,tosql.buf[0].len); } SQL->EscapeString(NULL, tosql.buf[0].p, str); + StrBuf->Printf(&buf, "'%s',", tosql.buf[0].p); + } else { + StrBuf->AppendStr(&buf, "'',"); } - StrBuf->Printf(&buf, "'%s',", it->script?tosql.buf[0].p:""); // equip_script - if (it->equip_script) { - libconfig->setting_lookup_string(entry, "OnEquipScript", &bonus); + if (it->equip_script && libconfig->setting_lookup_string(entry, "OnEquipScript", &bonus)) { hstr(bonus); str = tosql.buf[3].p; if (strlen(str) > tosql.buf[1].len) { @@ -398,12 +401,13 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) RECREATE(tosql.buf[1].p,char,tosql.buf[1].len); } SQL->EscapeString(NULL, tosql.buf[1].p, str); + StrBuf->Printf(&buf, "'%s',", tosql.buf[1].p); + } else { + StrBuf->AppendStr(&buf, "'',"); } - StrBuf->Printf(&buf, "'%s',", it->equip_script?tosql.buf[1].p:""); // unequip_script - if (it->unequip_script) { - libconfig->setting_lookup_string(entry, "OnUnequipScript", &bonus); + if (it->unequip_script && libconfig->setting_lookup_string(entry, "OnUnequipScript", &bonus)) { hstr(bonus); str = tosql.buf[3].p; if (strlen(str) > tosql.buf[2].len) { @@ -411,8 +415,10 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) RECREATE(tosql.buf[2].p,char,tosql.buf[2].len); } SQL->EscapeString(NULL, tosql.buf[2].p, str); + StrBuf->Printf(&buf, "'%s'", tosql.buf[2].p); + } else { + StrBuf->AppendStr(&buf, "''"); } - StrBuf->Printf(&buf, "'%s'", it->unequip_script?tosql.buf[2].p:""); fprintf(tosql.fp, "REPLACE INTO `%s` VALUES (%s);\n", tosql.db_name, StrBuf->Value(&buf)); @@ -619,7 +625,7 @@ int mobdb2sql_sub(struct config_setting_t *mobt, int n, const char *source) StrBuf->Printf(&buf, "%d,", md->status.def_ele + 20 * md->status.ele_lv); // Mode - StrBuf->Printf(&buf, "0x%X,", md->status.mode); + StrBuf->Printf(&buf, "%u,", md->status.mode); // Speed StrBuf->Printf(&buf, "%u,", md->status.speed); diff --git a/src/plugins/generate-translations.c b/src/plugins/generate-translations.c new file mode 100644 index 000000000..759e788a2 --- /dev/null +++ b/src/plugins/generate-translations.c @@ -0,0 +1,277 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2016 Hercules Dev Team + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "config/core.h" + +#include "common/hercules.h" +#include "common/cbasetypes.h" +#include "common/memmgr.h" +#include "common/showmsg.h" +#include "common/strlib.h" +#include "common/sysinfo.h" +#include "map/atcommand.h" +#include "map/map.h" +#include "map/script.h" + +#include "plugins/HPMHooking.h" +#include "common/HPMDataCheck.h" + +#include <stdio.h> +#include <stdlib.h> + +HPExport struct hplugin_info pinfo = { + "generate-translations", // Plugin name + SERVER_TYPE_MAP, // Which server types this plugin works with? + "0.1", // Plugin version + HPM_VERSION, // HPM Version (don't change, macro is automatically updated) +}; + +struct DBMap *translatable_strings; // string map parsed (used when exporting strings only) +/* Set during startup when attempting to export the lang, unset after server initialization is over */ +FILE *lang_export_fp; +char *lang_export_file;/* for lang_export_fp */ +struct script_string_buf lang_export_line_buf; +struct script_string_buf lang_export_escaped_buf; +int lang_export_stringcount; + +/// Whether the translations template generator will automatically run. +bool generating_translations = false; + +/** + * --generate-translations + * + * Creates "./generated_translations.pot" + * @see cmdline->exec + */ +CMDLINEARG(generatetranslations) +{ + lang_export_file = aStrdup("./generated_translations.pot"); + + if ((lang_export_fp = fopen(lang_export_file, "wb")) == NULL) { + ShowError("export-dialog: failed to open '%s' for writing\n", lang_export_file); + } else { + time_t t = time(NULL); + struct tm *lt = localtime(&t); + int year = lt->tm_year+1900; + char timestring[128] = ""; + strftime(timestring, sizeof(timestring), "%Y-%m-%d %H:%M:%S%z", lt); + fprintf(lang_export_fp, + "# This file is part of Hercules.\n" + "# http://herc.ws - http://github.com/HerculesWS/Hercules\n" + "#\n" + "# Copyright (C) 2013-%d Hercules Dev Team\n" + "#\n" + "# Hercules is free software: you can redistribute it and/or modify\n" + "# it under the terms of the GNU General Public License as published by\n" + "# the Free Software Foundation, either version 3 of the License, or\n" + "# (at your option) any later version.\n" + "#\n" + "# This program is distributed in the hope that it will be useful,\n" + "# but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "# GNU General Public License for more details.\n" + "#\n" + "# You should have received a copy of the GNU General Public License\n" + "# along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n" + + "#,fuzzy\n" + "msgid \"\"\n" + "msgstr \"\"\n" + "\"Project-Id-Version: %s\\n\"\n" + "\"Report-Msgid-Bugs-To: dev@herc.ws\\n\"\n" + "\"POT-Creation-Date: %s\\n\"\n" + "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n" + "\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n" + "\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n" + "\"Language: \\n\"\n" + "\"MIME-Version: 1.0\\n\"\n" + "\"Content-Type: text/plain; charset=ISO-8859-1\\n\"\n" + "\"Content-Transfer-Encoding: 8bit\\n\"\n\n", + year, sysinfo->vcsrevision_scripts(), timestring); + } + generating_translations = true; + return true; +} + +void script_add_translatable_string_posthook(const struct script_string_buf *string, const char *start_point) +{ + bool duplicate = true; + bool is_translatable_string = false; + bool is_translatable_fmtstring = false; + + if (!generating_translations || lang_export_fp == NULL) + return; + + /* When exporting we don't know what is a translation and what isn't */ + if (VECTOR_LENGTH(*string) > 1) { + // The length of *string will always be at least 1 because of the '\0' + if (translatable_strings == NULL) { + translatable_strings = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA, 0); + } + + if (!strdb_exists(translatable_strings, VECTOR_DATA(*string))) { + strdb_put(translatable_strings, VECTOR_DATA(*string), NULL); + duplicate = false; + } + } + + if (!duplicate) { + if (script->syntax.last_func == script->buildin_mes_offset + || script->syntax.last_func == script->buildin_select_offset + || script->syntax.lang_macro_active + ) { + is_translatable_string = true; + } else if (script->syntax.last_func == script->buildin_mesf_offset + || script->syntax.lang_macro_fmtstring_active + ) { + is_translatable_fmtstring = true; + } + } + + if (is_translatable_string || is_translatable_fmtstring) { + const char *line_start = start_point; + const char *line_end = start_point; + int line_length; + bool has_percent_sign = false; + + if (!is_translatable_fmtstring && strchr(VECTOR_DATA(*string), '%') != NULL) { + has_percent_sign = true; + } + + while (line_start > script->parser_current_src && *line_start != '\n') + line_start--; + + while (*line_end != '\n' && *line_end != '\0') + line_end++; + + line_length = (int)(line_end - line_start); + if (line_length > 0) { + VECTOR_ENSURE(lang_export_line_buf, line_length + 1, 512); + VECTOR_PUSHARRAY(lang_export_line_buf, line_start, line_length); + VECTOR_PUSH(lang_export_line_buf, '\0'); + + normalize_name(VECTOR_DATA(lang_export_line_buf), "\r\n\t "); // [!] Note: VECTOR_LENGTH() will lie. + } + + VECTOR_ENSURE(lang_export_escaped_buf, 4*VECTOR_LENGTH(*string)+1, 1); + VECTOR_LENGTH(lang_export_escaped_buf) = (int)sv->escape_c(VECTOR_DATA(lang_export_escaped_buf), + VECTOR_DATA(*string), + VECTOR_LENGTH(*string)-1, /* exclude null terminator */ + "\""); + VECTOR_PUSH(lang_export_escaped_buf, '\0'); + + fprintf(lang_export_fp, "\n#: %s\n" + "# %s\n" + "%s" + "msgctxt \"%s\"\n" + "msgid \"%s\"\n" + "msgstr \"\"\n", + script->parser_current_file ? script->parser_current_file : "Unknown File", + VECTOR_DATA(lang_export_line_buf), + is_translatable_fmtstring ? "#, c-format\n" : (has_percent_sign ? "#, no-c-format\n" : ""), + script->parser_current_npc_name ? script->parser_current_npc_name : "Unknown NPC", + VECTOR_DATA(lang_export_escaped_buf) + ); + lang_export_stringcount++; + VECTOR_TRUNCATE(lang_export_line_buf); + VECTOR_TRUNCATE(lang_export_escaped_buf); + } +} + +struct script_code *parse_script_prehook(const char **src, const char **file, int *line, int *options, int **retval) +{ + if (translatable_strings != NULL) { + db_destroy(translatable_strings); + translatable_strings = NULL; + } + return NULL; +} + +void script_parser_clean_leftovers_posthook(void) +{ + if (translatable_strings != NULL) { + db_destroy(translatable_strings); + translatable_strings = NULL; + } + + VECTOR_CLEAR(lang_export_line_buf); + VECTOR_CLEAR(lang_export_escaped_buf); +} + +bool msg_config_read_posthook(bool retVal, const char *cfg_name, bool allow_override) +{ + static int called = 1; + + if (!generating_translations || lang_export_fp == NULL) + return retVal; + + if (!retVal) + return retVal; + + if (++called == 1) { // Original + int i; + for (i = 0; i < MAX_MSG; i++) { + if (atcommand->msg_table[0][i] == NULL) + continue; + fprintf(lang_export_fp, "msgctxt \"messages.conf\"\n" + "msgid \"%s\"\n" + "msgstr \"\"\n", + atcommand->msg_table[0][i] + ); + lang_export_stringcount++; + } + } + + return retVal; +} + +HPExport void server_preinit(void) +{ + addArg("--generate-translations", false, generatetranslations, + "Creates './generated_translations.pot' file with all translateable strings from scripts, server terminates afterwards."); + VECTOR_INIT(lang_export_line_buf); + VECTOR_INIT(lang_export_escaped_buf); + addHookPost(script, add_translatable_string, script_add_translatable_string_posthook); + addHookPre(script, parse, parse_script_prehook); + addHookPost(script, parser_clean_leftovers, script_parser_clean_leftovers_posthook); + addHookPost(atcommand, msg_read, msg_config_read_posthook); + lang_export_stringcount = 0; +} + +HPExport void plugin_init(void) +{ +} + +HPExport void server_online(void) +{ + if (generating_translations && lang_export_fp != NULL) { + ShowInfo("Translations template exported to '%s' with %d strings.\n", lang_export_file, lang_export_stringcount); + fclose(lang_export_fp); + lang_export_fp = NULL; + } + core->runflag = CORE_ST_STOP; +} + +HPExport void plugin_final(void) +{ + if (lang_export_file != NULL) { + aFree(lang_export_file); + lang_export_file = NULL; + } +} diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c index 6ffc4eafc..34102a845 100644 --- a/src/test/test_spinlock.c +++ b/src/test/test_spinlock.c @@ -38,7 +38,7 @@ #define PERINC 100000 #define LOOPS 47 -static SPIN_LOCK lock; +static struct spin_lock lock; static unsigned int val = 0; static volatile int32 done_threads = 0; @@ -60,13 +60,14 @@ static void *worker(void *p){ return NULL; }//end: worker() -int do_init(int argc, char **argv){ - rAthread *t[THRC]; +int do_init(int argc, char **argv) +{ + struct thread_handle *t[THRC]; int j, i; int ok; ShowStatus("==========\n"); - ShowStatus("TEST: %u Runs, (%u Threads)\n", LOOPS, THRC); + ShowStatus("TEST: %d Runs, (%d Threads)\n", LOOPS, THRC); ShowStatus("This can take a while\n"); ShowStatus("\n\n"); @@ -78,13 +79,13 @@ int do_init(int argc, char **argv){ InitializeSpinLock(&lock); for(i =0; i < THRC; i++){ - t[i] = rathread_createEx( worker, NULL, 1024*512, RAT_PRIO_NORMAL); + t[i] = thread->create_opt(worker, NULL, 1024*512, THREADPRIO_NORMAL); } while(1){ if(InterlockedCompareExchange(&done_threads, THRC, THRC) == THRC) break; - rathread_yield(); + thread->yield(); } FinalizeSpinLock(&lock); diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index ec735e4e6..7bb2f4465 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -67,11 +67,6 @@ struct map_info { int32 len; }; - /************************************* - * Big-endian compatibility functions * - * Moved to utils.h * - *************************************/ - // Reads a map from GRF's GAT and RSW files int read_map(char *name, struct map_data *m) { @@ -82,13 +77,13 @@ int read_map(char *name, struct map_data *m) // Open map GAT sprintf(filename,"data\\%s.gat", name); - gat = (unsigned char *)grfio_read(filename); + gat = grfio_read(filename); if (gat == NULL) return 0; // Open map RSW sprintf(filename,"data\\%s.rsw", name); - rsw = (unsigned char *)grfio_read(filename); + rsw = grfio_read(filename); // Read water height if (rsw) { @@ -144,7 +139,7 @@ bool cache_map(char *name, struct map_data *m) len = (unsigned long)m->xs*(unsigned long)m->ys*2; write_buf = (unsigned char *)aMalloc(len); // Compress the cells and get the compressed length - encode_zip(write_buf, &len, m->cells, m->xs*m->ys); + grfio->encode_zip(write_buf, &len, m->cells, m->xs*m->ys); // Fill the map header safestrncpy(info.name, name, MAP_NAME_LENGTH); @@ -291,7 +286,7 @@ int do_init(int argc, char** argv) cmdline->exec(argc, argv, CMDLINE_OPT_NORMAL); ShowStatus("Initializing grfio with %s\n", grf_list_file); - grfio_init(grf_list_file); + grfio->init(grf_list_file); // Attempt to open the map cache file and force rebuild if not found ShowStatus("Opening map cache: %s\n", map_cache_file); @@ -365,7 +360,7 @@ int do_init(int argc, char** argv) fclose(map_cache_fp); ShowStatus("Finalizing grfio\n"); - grfio_final(); + grfio->final(); ShowInfo("%d maps now in cache\n", header.map_count); |