diff options
author | shennetsind <ind@henn.et> | 2014-03-22 17:07:13 -0300 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2014-03-22 17:07:13 -0300 |
commit | 2b4d6abbc5baddc2207e73f0b84c7e6c73e271a4 (patch) | |
tree | e8d15f8f4a252cda88f3e3173f366ff9881edc4c /src | |
parent | 9ea7b143192568a259aa6e7e223420e8d5762b9e (diff) | |
parent | d097f2c4b4a31885c6b04f5868563e1f48414192 (diff) | |
download | hercules-2b4d6abbc5baddc2207e73f0b84c7e6c73e271a4.tar.gz hercules-2b4d6abbc5baddc2207e73f0b84c7e6c73e271a4.tar.bz2 hercules-2b4d6abbc5baddc2207e73f0b84c7e6c73e271a4.tar.xz hercules-2b4d6abbc5baddc2207e73f0b84c7e6c73e271a4.zip |
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 47 | ||||
-rw-r--r-- | src/common/db.c | 2 | ||||
-rw-r--r-- | src/map/battle.c | 5 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/skill.c | 88 | ||||
-rw-r--r-- | src/map/skill.h | 1 | ||||
-rw-r--r-- | src/map/unit.c | 8 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.HookingPoints.inc | 3 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Hooks.inc | 85 |
10 files changed, 197 insertions, 56 deletions
diff --git a/src/char/char.c b/src/char/char.c index bf19a0012..0769067fd 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -125,6 +125,8 @@ int char_del_delay = 86400; int log_char = 1; // loggin char or not [devil] int log_inter = 1; // loggin inter or not [devil] +int char_aegis_delete = 0; // Verify if char is in guild/party or char and reacts as Aegis does (doesn't allow deletion), see char_delete2_req for more information + // Advanced subnet check [LuzZza] struct s_subnet { uint32 mask; @@ -3854,6 +3856,7 @@ int lan_subnetcheck(uint32 ip) } +/// Answers to deletion request (HC_DELETE_CHAR3_RESERVED) /// @param result /// 0 (0x718): An unknown error has occurred. /// 1: none/success @@ -3919,7 +3922,7 @@ void char_delete2_cancel_ack(int fd, int char_id, uint32 result) static void char_delete2_req(int fd, struct char_session_data* sd) {// CH: <0827>.W <char id>.L - int char_id, i; + int char_id, party_id, guild_id, i; char* data; time_t delete_date; @@ -3946,22 +3949,34 @@ static void char_delete2_req(int fd, struct char_session_data* sd) return; } -/* - // Aegis imposes these checks probably to avoid dead member - // entries in guilds/parties, otherwise they are not required. - // TODO: Figure out how these are enforced during waiting. - if( guild_id ) - {// character in guild - char_delete2_ack(fd, char_id, 4, 0); - return; - } + // This check is imposed by Aegis to avoid dead entries in databases + // _it is not needed_ as we clear data properly + // see issue: 7338 + if( char_aegis_delete ) + { + if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `party_id`, `guild_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) + || SQL_SUCCESS != SQL->NextRow(sql_handle) + ) + { + Sql_ShowDebug(sql_handle); + char_delete2_ack(fd, char_id, 3, 0); + return; + } + SQL->GetData(sql_handle, 0, &data, NULL); party_id = atoi(data); + SQL->GetData(sql_handle, 1, &data, NULL); guild_id = atoi(data); - if( party_id ) - {// character in party - char_delete2_ack(fd, char_id, 5, 0); - return; + if( guild_id ) + { + char_delete2_ack(fd, char_id, 4, 0); + return; + } + + if( party_id ) + { + char_delete2_ack(fd, char_id, 5, 0); + return; + } } -*/ // success delete_date = time(NULL)+char_del_delay; @@ -5258,6 +5273,8 @@ int char_config_read(const char* cfgName) char_del_level = atoi(w2); } else if (strcmpi(w1, "char_del_delay") == 0) { char_del_delay = atoi(w2); + } else if (strcmpi(w1, "char_aegis_delete") == 0) { + char_aegis_delete = atoi(w2); } else if(strcmpi(w1,"db_path")==0) { safestrncpy(db_path, w2, sizeof(db_path)); } else if (strcmpi(w1, "fame_list_alchemist") == 0) { diff --git a/src/common/db.c b/src/common/db.c index 8c15c0feb..8d6b08815 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -1846,6 +1846,8 @@ static DBData* db_obj_ensure(DBMap* self, DBKey key, DBCreateData create, ...) * @protected * @see #db_malloc_dbn(void) * @see DBMap#put + * FIXME: If this method fails shouldn't it return another value? + * Other functions rely on this to know if they were able to put something [Panikon] */ static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data) { diff --git a/src/map/battle.c b/src/map/battle.c index 91db3202c..6836aa016 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3750,7 +3750,10 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * md.damage = 0; if (tsd) md.damage>>=1; #endif - if (md.damage < 0 || md.damage > INT_MAX>>1) + // Some monsters have totaldef higher than md.damage in some cases, leading to md.damage < 0 + if( md.damage < 0 ) + md.damage = 0; + if( md.damage > INT_MAX>>1 ) //Overflow prevention, will anyone whine if I cap it to a few billion? //Not capped to INT_MAX to give some room for further damage increase. md.damage = INT_MAX>>1; diff --git a/src/map/pc.c b/src/map/pc.c index a231d7226..d9b7ea7e1 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2705,9 +2705,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { break; case SP_ADD_VARIABLECAST: if(sd->state.lr_flag != 2) - sd->bonus.add_varcast += val; - break; #endif case SP_ADD_MONSTER_DROP_CHAINITEM: diff --git a/src/map/skill.c b/src/map/skill.c index 5b4b79283..4e64f39f2 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -760,15 +760,15 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 // Chance to trigger Taekwon kicks [Dralnu] if(sc && !sc->data[SC_COMBOATTACK]) { if(sc->data[SC_STORMKICK_READY] && - sc_start(NULL,src,SC_COMBOATTACK, 15, TK_STORMKICK, + sc_start(src,src,SC_COMBOATTACK, 15, TK_STORMKICK, (2000 - 4*sstatus->agi - 2*sstatus->dex))) ; //Stance triggered else if(sc->data[SC_DOWNKICK_READY] && - sc_start(NULL,src,SC_COMBOATTACK, 15, TK_DOWNKICK, + sc_start(src,src,SC_COMBOATTACK, 15, TK_DOWNKICK, (2000 - 4*sstatus->agi - 2*sstatus->dex))) ; //Stance triggered else if(sc->data[SC_TURNKICK_READY] && - sc_start(NULL,src,SC_COMBOATTACK, 15, TK_TURNKICK, + sc_start(src,src,SC_COMBOATTACK, 15, TK_TURNKICK, (2000 - 4*sstatus->agi - 2*sstatus->dex))) ; //Stance triggered else if (sc->data[SC_COUNTERKICK_READY]) { //additional chance from SG_FRIEND [Komurka] @@ -777,7 +777,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 rate += rate*sc->data[SC_SKILLRATE_UP]->val2/100; status_change_end(src, SC_SKILLRATE_UP, INVALID_TIMER); } - sc_start2(NULL, src, SC_COMBOATTACK, rate, TK_COUNTER, bl->id, + sc_start2(src, src, SC_COMBOATTACK, rate, TK_COUNTER, bl->id, (2000 - 4*sstatus->agi - 2*sstatus->dex)); } } @@ -2054,8 +2054,11 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in } -//Checks if 'bl' should reflect back a spell cast by 'src'. -//type is the type of magic attack: 0: indirect (aoe), 1: direct (targetted) +// Checks if 'bl' should reflect back a spell cast by 'src'. +// type is the type of magic attack: 0: indirect (aoe), 1: direct (targetted) +// In case of success returns type of reflection, otherwise 0 +// 1 - Regular reflection (Maya) +// 2 - SL_KAITE reflection int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type) { struct status_change *sc = status->get_sc(bl); struct map_session_data* sd = BL_CAST(BL_PC, bl); @@ -2197,7 +2200,15 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr * Official Magic Reflection Behavior : damage reflected depends on gears caster wears, not target **/ #if MAGIC_REFLECTION_TYPE - if( dmg.dmg_lv != ATK_MISS ){ //Wiz SL cancelled and consumed fragment + + #if defined(DISABLE_RENEWAL) + // issue:6415 in pre-renewal Kaite reflected the entire damage received + // regardless of caster's equipament (Aegis 11.1) + if( dmg.dmg_lv != ATK_MISS && type == 1 ) //Wiz SL cancelled and consumed fragment + #else + if( dmg.dmg_lv != ATK_MISS ) //Wiz SL cancelled and consumed fragment + #endif + { short s_ele = skill->get_ele(skill_id, skill_lv); if (s_ele == -1) // the skill takes the weapon's element @@ -2218,10 +2229,9 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr status_change_end(bl, SC_ENERGYCOAT, INVALID_TIMER); //Reduction: 6% + 6% every 20% dmg.damage -= dmg.damage * (6 * (1+per)) / 100; - } - + } } - #endif + #endif /* MAGIC_REFLECTION_TYPE */ } if(sc && sc->data[SC_MAGICROD] && src == dsrc) { int sp = skill->get_sp(skill_id,skill_lv); @@ -12495,6 +12505,35 @@ int skill_isammotype (struct map_session_data *sd, int skill_id) ); } +/** + * Checks whether a skill can be used in combos or not + **/ +bool skill_is_combo( int skill_id ) +{ + switch( skill_id ) + { + case MO_CHAINCOMBO: + case MO_COMBOFINISH: + case CH_TIGERFIST: + case CH_CHAINCRUSH: + case MO_EXTREMITYFIST: + case TK_TURNKICK: + case TK_STORMKICK: + case TK_DOWNKICK: + case TK_COUNTER: + case TK_JUMPKICK: + case HT_POWER: + case GC_COUNTERSLASH: + case GC_WEAPONCRUSH: + case SR_FALLENEMPIRE: + case SR_DRAGONCOMBO: + case SR_TIGERCANNON: + case SR_GATEOFHELL: + return true; + } + return false; +} + int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) { struct status_data *st; struct status_change *sc; @@ -13388,29 +13427,11 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; } - if( sd->sc.data[SC_COMBOATTACK] ) { - switch( skill_id ) { - case MO_CHAINCOMBO: - case MO_COMBOFINISH: - case CH_TIGERFIST: - case CH_CHAINCRUSH: - case MO_EXTREMITYFIST: - case TK_TURNKICK: - case TK_STORMKICK: - case TK_DOWNKICK: - case TK_COUNTER: - case TK_JUMPKICK: - case HT_POWER: - case GC_COUNTERSLASH: - case GC_WEAPONCRUSH: - case SR_FALLENEMPIRE: - case SR_DRAGONCOMBO: - case SR_TIGERCANNON: - case SR_GATEOFHELL: - break; - default: return 0; - } - } + // There's no need to check if the skill is part of a combo if it's + // already been checked before, see unit_skilluse_id2 [Panikon] + // Note that if this check is readded part of issue:8047 will reapear! + //if( sd->sc.data[SC_COMBOATTACK] && !skill->is_combo(skill_id ) ) + // return 0; return 1; } @@ -18466,6 +18487,7 @@ void skill_defaults(void) { skill->chk = skill_chk; skill->get_casttype = skill_get_casttype; skill->get_casttype2 = skill_get_casttype2; + skill->is_combo = skill_is_combo; skill->name2id = skill_name2id; skill->isammotype = skill_isammotype; skill->castend_id = skill_castend_id; diff --git a/src/map/skill.h b/src/map/skill.h index 13d34d267..dda310bd4 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1870,6 +1870,7 @@ struct skill_interface { /* whether its CAST_GROUND, CAST_DAMAGE or CAST_NODAMAGE */ int (*get_casttype) (uint16 skill_id); int (*get_casttype2) (uint16 index); + bool (*is_combo) (int skill_id); int (*name2id) (const char* name); int (*isammotype) (struct map_session_data *sd, int skill_id); int (*castend_id) (int tid, int64 tick, int id, intptr_t data); diff --git a/src/map/unit.c b/src/map/unit.c index 5dd63879f..39fff0eab 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1092,8 +1092,12 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui sc = NULL; //Unneeded //temp: used to signal combo-skills right now. - if (sc && sc->data[SC_COMBOATTACK] && (sc->data[SC_COMBOATTACK]->val1 == skill_id || - (sd?skill->check_condition_castbegin(sd,skill_id,skill_lv):0) )) { + if (sc && sc->data[SC_COMBOATTACK] + && skill->is_combo(skill_id) + && (sc->data[SC_COMBOATTACK]->val1 == skill_id + || ( sd?skill->check_condition_castbegin(sd,skill_id,skill_lv):0 ) + ) + ) { if (sc->data[SC_COMBOATTACK]->val2) target_id = sc->data[SC_COMBOATTACK]->val2; else diff --git a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc index 4f37743f6..3827f3e84 100644 --- a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc @@ -219,6 +219,10 @@ struct { struct HPMHookPoint *HP_bg_send_xy_timer_sub_post; struct HPMHookPoint *HP_bg_send_xy_timer_pre; struct HPMHookPoint *HP_bg_send_xy_timer_post; + struct HPMHookPoint *HP_bg_afk_timer_pre; + struct HPMHookPoint *HP_bg_afk_timer_post; + struct HPMHookPoint *HP_bg_str2teamtype_pre; + struct HPMHookPoint *HP_bg_str2teamtype_post; struct HPMHookPoint *HP_bg_config_read_pre; struct HPMHookPoint *HP_bg_config_read_post; struct HPMHookPoint *HP_buyingstore_setup_pre; @@ -4399,6 +4403,8 @@ struct { struct HPMHookPoint *HP_skill_get_casttype_post; struct HPMHookPoint *HP_skill_get_casttype2_pre; struct HPMHookPoint *HP_skill_get_casttype2_post; + struct HPMHookPoint *HP_skill_is_combo_pre; + struct HPMHookPoint *HP_skill_is_combo_post; struct HPMHookPoint *HP_skill_name2id_pre; struct HPMHookPoint *HP_skill_name2id_post; struct HPMHookPoint *HP_skill_isammotype_pre; @@ -5252,6 +5258,10 @@ struct { int HP_bg_send_xy_timer_sub_post; int HP_bg_send_xy_timer_pre; int HP_bg_send_xy_timer_post; + int HP_bg_afk_timer_pre; + int HP_bg_afk_timer_post; + int HP_bg_str2teamtype_pre; + int HP_bg_str2teamtype_post; int HP_bg_config_read_pre; int HP_bg_config_read_post; int HP_buyingstore_setup_pre; @@ -9432,6 +9442,8 @@ struct { int HP_skill_get_casttype_post; int HP_skill_get_casttype2_pre; int HP_skill_get_casttype2_post; + int HP_skill_is_combo_pre; + int HP_skill_is_combo_post; int HP_skill_name2id_pre; int HP_skill_name2id_post; int HP_skill_isammotype_pre; diff --git a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc index dd8c603d3..8693f6b0f 100644 --- a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc @@ -115,6 +115,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(bg->send_message, HP_bg_send_message) }, { HP_POP(bg->send_xy_timer_sub, HP_bg_send_xy_timer_sub) }, { HP_POP(bg->send_xy_timer, HP_bg_send_xy_timer) }, + { HP_POP(bg->afk_timer, HP_bg_afk_timer) }, + { HP_POP(bg->str2teamtype, HP_bg_str2teamtype) }, { HP_POP(bg->config_read, HP_bg_config_read) }, /* buyingstore */ { HP_POP(buyingstore->setup, HP_buyingstore_setup) }, @@ -2235,6 +2237,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(skill->chk, HP_skill_chk) }, { HP_POP(skill->get_casttype, HP_skill_get_casttype) }, { HP_POP(skill->get_casttype2, HP_skill_get_casttype2) }, + { HP_POP(skill->is_combo, HP_skill_is_combo) }, { HP_POP(skill->name2id, HP_skill_name2id) }, { HP_POP(skill->isammotype, HP_skill_isammotype) }, { HP_POP(skill->castend_id, HP_skill_castend_id) }, diff --git a/src/plugins/HPMHooking/HPMHooking.Hooks.inc b/src/plugins/HPMHooking/HPMHooking.Hooks.inc index 396b241b0..f0932f518 100644 --- a/src/plugins/HPMHooking/HPMHooking.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking.Hooks.inc @@ -2648,11 +2648,11 @@ bool HP_bg_team_join(int bg_id, struct map_session_data *sd) { } return retVal___; } -int HP_bg_team_leave(struct map_session_data *sd, int flag) { +int HP_bg_team_leave(struct map_session_data *sd, enum bg_team_leave_type flag) { int hIndex = 0; int retVal___ = 0; if( HPMHooks.count.HP_bg_team_leave_pre ) { - int (*preHookFunc) (struct map_session_data *sd, int *flag); + int (*preHookFunc) (struct map_session_data *sd, enum bg_team_leave_type *flag); for(hIndex = 0; hIndex < HPMHooks.count.HP_bg_team_leave_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_bg_team_leave_pre[hIndex].func; retVal___ = preHookFunc(sd, &flag); @@ -2666,7 +2666,7 @@ int HP_bg_team_leave(struct map_session_data *sd, int flag) { retVal___ = HPMHooks.source.bg.team_leave(sd, flag); } if( HPMHooks.count.HP_bg_team_leave_post ) { - int (*postHookFunc) (int retVal___, struct map_session_data *sd, int *flag); + int (*postHookFunc) (int retVal___, struct map_session_data *sd, enum bg_team_leave_type *flag); for(hIndex = 0; hIndex < HPMHooks.count.HP_bg_team_leave_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_bg_team_leave_post[hIndex].func; retVal___ = postHookFunc(retVal___, sd, &flag); @@ -2836,6 +2836,59 @@ int HP_bg_send_xy_timer(int tid, int64 tick, int id, intptr_t data) { } return retVal___; } +int HP_bg_afk_timer(int tid, int64 tick, int id, intptr_t data) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_bg_afk_timer_pre ) { + int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); + for(hIndex = 0; hIndex < HPMHooks.count.HP_bg_afk_timer_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_bg_afk_timer_pre[hIndex].func; + retVal___ = preHookFunc(&tid, &tick, &id, &data); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.bg.afk_timer(tid, tick, id, data); + } + if( HPMHooks.count.HP_bg_afk_timer_post ) { + int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data); + for(hIndex = 0; hIndex < HPMHooks.count.HP_bg_afk_timer_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_bg_afk_timer_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data); + } + } + return retVal___; +} +enum bg_queue_types HP_bg_str2teamtype(const char *str) { +/* Unknown return type 'enum bg_queue_types'. Initializing to '0'. */ + int hIndex = 0; + enum bg_queue_types retVal___ = 0; + if( HPMHooks.count.HP_bg_str2teamtype_pre ) { + enum bg_queue_types (*preHookFunc) (const char *str); + for(hIndex = 0; hIndex < HPMHooks.count.HP_bg_str2teamtype_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_bg_str2teamtype_pre[hIndex].func; + retVal___ = preHookFunc(str); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.bg.str2teamtype(str); + } + if( HPMHooks.count.HP_bg_str2teamtype_post ) { + enum bg_queue_types (*postHookFunc) (enum bg_queue_types retVal___, const char *str); + for(hIndex = 0; hIndex < HPMHooks.count.HP_bg_str2teamtype_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_bg_str2teamtype_post[hIndex].func; + retVal___ = postHookFunc(retVal___, str); + } + } + return retVal___; +} void HP_bg_config_read(void) { int hIndex = 0; if( HPMHooks.count.HP_bg_config_read_pre ) { @@ -56841,6 +56894,32 @@ int HP_skill_get_casttype2(uint16 index) { } return retVal___; } +bool HP_skill_is_combo(int skill_id) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_skill_is_combo_pre ) { + bool (*preHookFunc) (int *skill_id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_is_combo_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_skill_is_combo_pre[hIndex].func; + retVal___ = preHookFunc(&skill_id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.skill.is_combo(skill_id); + } + if( HPMHooks.count.HP_skill_is_combo_post ) { + bool (*postHookFunc) (bool retVal___, int *skill_id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_skill_is_combo_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_skill_is_combo_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &skill_id); + } + } + return retVal___; +} int HP_skill_name2id(const char *name) { int hIndex = 0; int retVal___ = 0; |