Browse Source

Fixes an issue with status timers being destroyed (#4885)

* Fixes #4856.
* Follow up to d1f8c8c and 652d77e.
* A missing break from an old commit along with a refactor in code resulted in a "valid" fall through and breaking status change timers.
* Also fixes a potential crash with Book of Creating Star.
Thanks to @OptimusM, @technoken, @sader1992, @mazvi, and @akiyamamio16 for helping debug!
Aleos 5 years ago
parent
commit
9794aa2b80
2 changed files with 8 additions and 8 deletions
  1. 1 0
      src/map/skill.cpp
  2. 7 8
      src/map/status.cpp

+ 1 - 0
src/map/skill.cpp

@@ -19078,6 +19078,7 @@ int skill_delunitgroup_(struct skill_unit_group *group, const char* file, int li
 					status_change_end(target, SC_SPIDERWEB, INVALID_TIMER);
 			}
 		}
+			break;
 		case SG_SUN_WARM:
 		case SG_MOON_WARM:
 		case SG_STAR_WARM:

+ 7 - 8
src/map/status.cpp

@@ -14622,17 +14622,16 @@ TIMER_FUNC(status_change_timer){
 		break;
 	case SC_CREATINGSTAR:
 		if (--(sce->val4) >= 0) { // Needed to check who the caster is and what AoE is giving the status.
-			struct block_list *star_caster = map_id2bl(sce->val2), *star_aoe = map_id2bl(sce->val3);
+			struct block_list *star_caster = map_id2bl(sce->val2);
+			struct skill_unit *star_aoe = (struct skill_unit *)map_id2bl(sce->val3);
 
-			if (!star_caster || status_isdead(star_caster) || star_caster->m != bl->m)
+			if (star_caster == nullptr || status_isdead(star_caster) || star_caster->m != bl->m || star_aoe == nullptr)
 				break;
 
-			map_freeblock_lock();
-			if (star_aoe)
-				skill_attack(BF_WEAPON,star_caster,star_aoe,bl,SJ_BOOKOFCREATINGSTAR,sce->val1,tick,0);
-			if (sc->data[type])
-				sc_timer_next(500 + tick);
-			map_freeblock_unlock();
+			sc_timer_next(500 + tick);
+
+			// Attack after timer to prevent errors
+			skill_attack(BF_WEAPON, star_caster, &star_aoe->bl, bl, SJ_BOOKOFCREATINGSTAR, sce->val1, tick, 0);
 			return 0;
 		}
 		break;