Skip to content

Commit

Permalink
Resolves a potential crash from Howling Mine (rathena#8147)
Browse files Browse the repository at this point in the history
* Fixes rathena#8146.
* Minor cleanups to ensure the Howling Mine status is active before accessing.
Thanks to @LadyNanuia!
Co-authored-by: Lemongrass3110 <[email protected]>
  • Loading branch information
aleos89 authored May 6, 2024
1 parent ffbbb94 commit 8546f9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/map/skill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6943,14 +6943,15 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
}
// Triggered by RL_FLICKER
if (sd && sd->flicker && tsc && tsc->getSCE(SC_H_MINE) && tsc->getSCE(SC_H_MINE)->val2 == src->id) {
if (sd && sd->flicker) {
// Splash damage around it!
map_foreachinrange(skill_area_sub, bl, skill_get_splash(skill_id, skill_lv), BL_CHAR|BL_SKILL,
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill_castend_damage_id);
flag |= 1; // Don't consume requirement
tsc->getSCE(SC_H_MINE)->val3 = 1; // Mark the SC end because not expired
status_change_end(bl, SC_H_MINE);
sc_start4(src, bl, SC_BURNING, 10 * skill_lv, skill_lv, 1000, src->id, 0, skill_get_time2(skill_id,skill_lv));
if (tsc &&tsc->getSCE(SC_H_MINE) && tsc->getSCE(SC_H_MINE)->val2 == src->id) {
status_change_end(bl, SC_H_MINE);
sc_start4(src, bl, SC_BURNING, 10 * skill_lv, skill_lv, 1000, src->id, 0, skill_get_time2(skill_id,skill_lv));
}
}
}
else
Expand Down
12 changes: 7 additions & 5 deletions src/map/status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13682,22 +13682,24 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
}
break;
case SC_H_MINE:
{
// Drop the material from target if expired
struct item it;
// Only drop the material from target if expired naturally
if( tid != INVALID_TIMER ){
map_session_data *caster = nullptr;

if (sce->val3 || status_isdead(bl) || !(caster = map_id2sd(sce->val2)))
if (status_isdead(bl) || !(caster = map_id2sd(sce->val2)))
break;

std::shared_ptr<s_skill_db> skill = skill_db.find(RL_H_MINE);

if (!item_db.exists(skill->require.itemid[0]))
break;
memset(&it, 0, sizeof(it));

struct item it = {};

it.nameid = skill->require.itemid[0];
it.amount = max(skill->require.amount[0],1);
it.identify = 1;

map_addflooritem(&it, it.amount, bl->m,bl->x, bl->y, caster->status.char_id, 0, 0, 4, 0);
}
break;
Expand Down

0 comments on commit 8546f9f

Please sign in to comment.