More stability improvements
This commit is contained in:
@@ -7,6 +7,8 @@ import core.game.world.map.Location
|
|||||||
import core.game.world.map.RegionManager
|
import core.game.world.map.RegionManager
|
||||||
import core.game.world.map.path.Pathfinder
|
import core.game.world.map.path.Pathfinder
|
||||||
import core.tools.RandomFunction
|
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.GATE_ENTRIES
|
||||||
import rs09.game.content.activity.pestcontrol.PestControlHelper.getMyPestControlSession1
|
import rs09.game.content.activity.pestcontrol.PestControlHelper.getMyPestControlSession1
|
||||||
import rs09.game.world.GameWorld
|
import rs09.game.world.GameWorld
|
||||||
@@ -100,7 +102,7 @@ class CombatState(val bot: PestControlTestBot) {
|
|||||||
|
|
||||||
fun randomWalkTo(loc: Location, radius: Int) {
|
fun randomWalkTo(loc: Location, radius: Int) {
|
||||||
if(!bot.walkingQueue.isMoving) {
|
if(!bot.walkingQueue.isMoving) {
|
||||||
Executors.newSingleThreadExecutor().execute {
|
GlobalScope.launch {
|
||||||
var newloc = loc.transform(RandomFunction.random(radius, -radius),
|
var newloc = loc.transform(RandomFunction.random(radius, -radius),
|
||||||
RandomFunction.random(radius, -radius), 0)
|
RandomFunction.random(radius, -radius), 0)
|
||||||
walkToIterator(newloc)
|
walkToIterator(newloc)
|
||||||
|
|||||||
+3
-1
@@ -7,6 +7,8 @@ import core.game.world.map.Location
|
|||||||
import core.game.world.map.RegionManager
|
import core.game.world.map.RegionManager
|
||||||
import core.game.world.map.path.Pathfinder
|
import core.game.world.map.path.Pathfinder
|
||||||
import core.tools.RandomFunction
|
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.GATE_ENTRIES
|
||||||
import rs09.game.content.activity.pestcontrol.PestControlHelper.getMyPestControlSession2
|
import rs09.game.content.activity.pestcontrol.PestControlHelper.getMyPestControlSession2
|
||||||
import rs09.game.world.GameWorld
|
import rs09.game.world.GameWorld
|
||||||
@@ -99,7 +101,7 @@ class CombatStateIntermediate(val bot: PestControlTestBot2) {
|
|||||||
|
|
||||||
fun randomWalkTo(loc: Location, radius: Int) {
|
fun randomWalkTo(loc: Location, radius: Int) {
|
||||||
if(!bot.walkingQueue.isMoving) {
|
if(!bot.walkingQueue.isMoving) {
|
||||||
Executors.newSingleThreadExecutor().execute {
|
GlobalScope.launch {
|
||||||
Thread.currentThread().name = "RandomWalkToIteratorBot"
|
Thread.currentThread().name = "RandomWalkToIteratorBot"
|
||||||
var newloc = loc.transform(RandomFunction.random(radius, -radius),
|
var newloc = loc.transform(RandomFunction.random(radius, -radius),
|
||||||
RandomFunction.random(radius, -radius), 0)
|
RandomFunction.random(radius, -radius), 0)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import core.game.world.repository.InitializingNodeList
|
|||||||
import core.net.packet.PacketRepository
|
import core.net.packet.PacketRepository
|
||||||
import core.net.packet.context.PlayerContext
|
import core.net.packet.context.PlayerContext
|
||||||
import core.net.packet.out.ClearMinimapFlag
|
import core.net.packet.out.ClearMinimapFlag
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import rs09.game.world.repository.Repository
|
import rs09.game.world.repository.Repository
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
@@ -58,7 +60,7 @@ class UpdateSequence
|
|||||||
fun run() {
|
fun run() {
|
||||||
val latch = CountDownLatch(renderablePlayers.size)
|
val latch = CountDownLatch(renderablePlayers.size)
|
||||||
playersList!!.forEach(Consumer { player: Player ->
|
playersList!!.forEach(Consumer { player: Player ->
|
||||||
EXECUTOR.execute {
|
GlobalScope.launch {
|
||||||
try {
|
try {
|
||||||
player.update()
|
player.update()
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
@@ -89,7 +91,6 @@ class UpdateSequence
|
|||||||
* Terminates the update sequence.
|
* Terminates the update sequence.
|
||||||
*/
|
*/
|
||||||
fun terminate() {
|
fun terminate() {
|
||||||
EXECUTOR.shutdown()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -103,11 +104,5 @@ class UpdateSequence
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
val renderablePlayers = InitializingNodeList<Player>()
|
val renderablePlayers = InitializingNodeList<Player>()
|
||||||
|
|
||||||
/**
|
|
||||||
* The executor used.
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
private val EXECUTOR = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user