diff --git a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatState.kt b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatState.kt index 0adf3c315..a56fc69f0 100644 --- a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatState.kt +++ b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatState.kt @@ -7,6 +7,8 @@ import core.game.world.map.Location import core.game.world.map.RegionManager import core.game.world.map.path.Pathfinder import core.tools.RandomFunction +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import rs09.game.content.activity.pestcontrol.PestControlHelper.GATE_ENTRIES import rs09.game.content.activity.pestcontrol.PestControlHelper.getMyPestControlSession1 import rs09.game.world.GameWorld @@ -100,7 +102,7 @@ class CombatState(val bot: PestControlTestBot) { fun randomWalkTo(loc: Location, radius: Int) { if(!bot.walkingQueue.isMoving) { - Executors.newSingleThreadExecutor().execute { + GlobalScope.launch { var newloc = loc.transform(RandomFunction.random(radius, -radius), RandomFunction.random(radius, -radius), 0) walkToIterator(newloc) diff --git a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatStateIntermediate.kt b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatStateIntermediate.kt index 509090075..70243a700 100644 --- a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatStateIntermediate.kt +++ b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatStateIntermediate.kt @@ -7,6 +7,8 @@ import core.game.world.map.Location import core.game.world.map.RegionManager import core.game.world.map.path.Pathfinder import core.tools.RandomFunction +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import rs09.game.content.activity.pestcontrol.PestControlHelper.GATE_ENTRIES import rs09.game.content.activity.pestcontrol.PestControlHelper.getMyPestControlSession2 import rs09.game.world.GameWorld @@ -99,7 +101,7 @@ class CombatStateIntermediate(val bot: PestControlTestBot2) { fun randomWalkTo(loc: Location, radius: Int) { if(!bot.walkingQueue.isMoving) { - Executors.newSingleThreadExecutor().execute { + GlobalScope.launch { Thread.currentThread().name = "RandomWalkToIteratorBot" var newloc = loc.transform(RandomFunction.random(radius, -radius), RandomFunction.random(radius, -radius), 0) diff --git a/Server/src/main/kotlin/rs09/game/world/update/UpdateSequence.kt b/Server/src/main/kotlin/rs09/game/world/update/UpdateSequence.kt index 5d13af290..4a16fef80 100644 --- a/Server/src/main/kotlin/rs09/game/world/update/UpdateSequence.kt +++ b/Server/src/main/kotlin/rs09/game/world/update/UpdateSequence.kt @@ -8,6 +8,8 @@ import core.game.world.repository.InitializingNodeList import core.net.packet.PacketRepository import core.net.packet.context.PlayerContext import core.net.packet.out.ClearMinimapFlag +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import rs09.game.world.repository.Repository import java.util.concurrent.CountDownLatch import java.util.concurrent.Executors @@ -58,7 +60,7 @@ class UpdateSequence fun run() { val latch = CountDownLatch(renderablePlayers.size) playersList!!.forEach(Consumer { player: Player -> - EXECUTOR.execute { + GlobalScope.launch { try { player.update() } catch (t: Throwable) { @@ -89,7 +91,6 @@ class UpdateSequence * Terminates the update sequence. */ fun terminate() { - EXECUTOR.shutdown() } companion object { @@ -103,11 +104,5 @@ class UpdateSequence @JvmStatic val renderablePlayers = InitializingNodeList() - /** - * The executor used. - */ - @JvmStatic - private val EXECUTOR = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) - } } \ No newline at end of file