From 4276ed731d6ae982964ee67ed9f5f0cd010ce27c Mon Sep 17 00:00:00 2001 From: Ceikry Date: Tue, 29 Aug 2023 01:29:09 +0000 Subject: [PATCH] Corrected some inauthenticities in the script processor Soft queued scripts no longer remove weak scripts Soft queued scripts now delay logout until processed --- .../core/game/interaction/ScriptProcessor.kt | 32 ++++++++----------- .../core/game/node/entity/player/Player.java | 3 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Server/src/main/core/game/interaction/ScriptProcessor.kt b/Server/src/main/core/game/interaction/ScriptProcessor.kt index 5ccd0e446..ec6da95a4 100644 --- a/Server/src/main/core/game/interaction/ScriptProcessor.kt +++ b/Server/src/main/core/game/interaction/ScriptProcessor.kt @@ -94,21 +94,10 @@ class ScriptProcessor(val entity: Entity) { var strongInQueue = false var softInQueue = false var anyExecuted = false - for (i in 0 until queue.size) { - val script = queue[i] - if (script is QueuedScript && script.strength == QueueStrength.STRONG) - strongInQueue = true - if (script is QueuedUseWith && script.strength == QueueStrength.STRONG) - strongInQueue = true - if (script is QueuedScript && script.strength == QueueStrength.SOFT) - softInQueue = true - if (script is QueuedUseWith && script.strength == QueueStrength.SOFT) - softInQueue = true - } + strongInQueue = hasTypeInQueue(QueueStrength.STRONG) + softInQueue = hasTypeInQueue(QueueStrength.SOFT) - if (softInQueue) { - removeWeakScripts() - removeNormalScripts() + if (softInQueue || strongInQueue) { if (entity is Player) { entity.interfaceManager.close() entity.interfaceManager.closeChatbox() @@ -118,11 +107,6 @@ class ScriptProcessor(val entity: Entity) { if (strongInQueue) { removeWeakScripts() - if (entity is Player) { - entity.interfaceManager.close() - entity.interfaceManager.closeChatbox() - entity.dialogueInterpreter.close() - } } val toRemove = ArrayList>() @@ -315,4 +299,14 @@ class ScriptProcessor(val entity: Entity) { private fun getActiveInteraction() : Script<*>? { return opScript ?: apScript } + + fun hasTypeInQueue (type: QueueStrength) : Boolean { + for (script in queue) { + if (script is QueuedScript && script.strength == type) + return true + else if (script is QueuedUseWith && script.strength == type) + return true + } + return false + } } diff --git a/Server/src/main/core/game/node/entity/player/Player.java b/Server/src/main/core/game/node/entity/player/Player.java index b64dbc6df..f0edca232 100644 --- a/Server/src/main/core/game/node/entity/player/Player.java +++ b/Server/src/main/core/game/node/entity/player/Player.java @@ -12,6 +12,7 @@ import core.game.container.impl.InventoryListener; import core.game.dialogue.DialogueInterpreter; import core.game.interaction.InteractPlugin; import core.game.interaction.InteractionListeners; +import core.game.interaction.QueueStrength; import core.game.node.entity.Entity; import core.game.node.entity.combat.BattleState; import core.game.node.entity.combat.CombatStyle; @@ -954,7 +955,7 @@ public class Player extends Entity { * @return {@code True} if so. */ public boolean allowRemoval() { - return !(inCombat() || getSkills().getLifepoints() < 1 || DeathTask.isDead(this) || isTeleporting()); + return !(inCombat() || getSkills().getLifepoints() < 1 || DeathTask.isDead(this) || isTeleporting() || scripts.hasTypeInQueue(QueueStrength.SOFT)); } /**