From 877cf5401ec482efa7ef13ba36f4c4d96834e09c Mon Sep 17 00:00:00 2001 From: Shaun Date: Thu, 14 Mar 2024 09:17:10 +0200 Subject: [PATCH] bug #2022: Fixed charge and fireblast stuns becoming permanent during logout --- src/server/components/spellbook.js | 5 +++++ src/server/config/spells/spellCharge.js | 11 ++++++++++- src/server/config/spells/spellFireblast.js | 11 ++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/server/components/spellbook.js b/src/server/components/spellbook.js index e746211b..6c2e5d3f 100644 --- a/src/server/components/spellbook.js +++ b/src/server/components/spellbook.js @@ -507,6 +507,11 @@ module.exports = { }, destroy: function () { + this.callbacks.forEach(c => { + if (c.destroyCallback) + c.destroyCallback(); + }); + this.spells.forEach(s => { if (s.destroy) s.destroy(); diff --git a/src/server/config/spells/spellCharge.js b/src/server/config/spells/spellCharge.js index 25d8f3e6..2d65f904 100644 --- a/src/server/config/spells/spellCharge.js +++ b/src/server/config/spells/spellCharge.js @@ -85,10 +85,15 @@ module.exports = { }, -1); } - this.queueCallback(this.reachDestination.bind(this, target, targetPos, targetEffect, selfEffect), ttl - 50); + this.queueCallback( + this.reachDestination.bind(this, target, targetPos, targetEffect, selfEffect), + ttl - 50, + this.destroyEffectOnTarget.bind(this, target, targetEffect) + ); return true; }, + reachDestination: function (target, targetPos, targetEffect, selfEffect) { if (this.obj.destroyed) return; @@ -141,6 +146,10 @@ module.exports = { this.obj.spellbook.spells[this.castOnEnd].cast(); }, + destroyEffectOnTarget: function (target, targetEffect) { + target.effects.removeEffect(targetEffect.id); + }, + isTileValid: function (physics, fromX, fromY, toX, toY) { if (physics.isTileBlocking(toX, toY)) return false; diff --git a/src/server/config/spells/spellFireblast.js b/src/server/config/spells/spellFireblast.js index 36eb785e..cfd60f19 100644 --- a/src/server/config/spells/spellFireblast.js +++ b/src/server/config/spells/spellFireblast.js @@ -145,7 +145,12 @@ module.exports = { }] }); - this.queueCallback(this.endEffect.bind(this, m, targetPos, targetEffect), ttl, null, m); + this.queueCallback( + this.endEffect.bind(this, m, targetPos, targetEffect), + ttl, + this.destroyEffectOnTarget.bind(this, m, targetEffect), + m + ); } } } @@ -200,5 +205,9 @@ module.exports = { spell: this }; target.fireEvent('afterPositionChange', moveEvent); + }, + + destroyEffectOnTarget: function (target, targetEffect) { + target.effects.removeEffect(targetEffect.id); } };