New dynamic region abstraction, consumed in construction
This commit is contained in:
@@ -41,55 +41,9 @@ class MajorUpdateWorker {
|
||||
Thread.sleep(600L)
|
||||
while(true){
|
||||
val start = System.currentTimeMillis()
|
||||
val rmlist = ArrayList<Pulse>()
|
||||
val list = ArrayList(GameWorld.Pulser.TASKS)
|
||||
Server.heartbeat()
|
||||
|
||||
GlobalScope.launch {
|
||||
//run our pulses
|
||||
for (pulse in list) {
|
||||
val b = System.currentTimeMillis()
|
||||
if (pulse == null || pulse.update()) rmlist.add(pulse)
|
||||
|
||||
val time = System.currentTimeMillis() - b
|
||||
|
||||
if (time >= 100) {
|
||||
if (pulse is GeneralBotCreator.BotScriptPulse) {
|
||||
SystemLogger.logWarn("CRITICALLY Long Botscript Tick: ${pulse.botScript.javaClass.name} - $time ms")
|
||||
} else {
|
||||
SystemLogger.logWarn("CRITICALLY long running pulse: ${pulse.javaClass.name} - $time ms")
|
||||
}
|
||||
} else if (time >= 30) {
|
||||
if (pulse is GeneralBotCreator.BotScriptPulse) {
|
||||
SystemLogger.logWarn("Long Botscript Tick: ${pulse.botScript.javaClass.name} - $time ms")
|
||||
} else {
|
||||
SystemLogger.logWarn("Long Running Pulse: ${pulse.javaClass.name} - $time ms")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//remove all null or finished pulses from the list
|
||||
rmlist.forEach {
|
||||
if (GameWorld.Pulser.TASKS.contains(it)) GameWorld.Pulser.TASKS.remove(it)
|
||||
}
|
||||
|
||||
rmlist.clear()
|
||||
//perform our update sequence where we write masks, etc
|
||||
try {
|
||||
sequence.start()
|
||||
sequence.run()
|
||||
sequence.end()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
//increment global ticks variable
|
||||
GameWorld.pulse()
|
||||
//disconnect all players waiting to be disconnected
|
||||
Repository.disconnectionQueue.update()
|
||||
GameWorld.tickListeners.forEach { it.tick() }
|
||||
//tick all manager plugins
|
||||
Managers.tick()
|
||||
}
|
||||
GlobalScope.launch { handleTickActions() }
|
||||
|
||||
//Handle daily restart if enabled
|
||||
if(sdf.format(Date()).toInt() == 0){
|
||||
@@ -123,6 +77,54 @@ class MajorUpdateWorker {
|
||||
}
|
||||
}
|
||||
|
||||
fun handleTickActions() {
|
||||
val rmlist = ArrayList<Pulse>()
|
||||
val list = ArrayList(GameWorld.Pulser.TASKS)
|
||||
//run our pulses
|
||||
for (pulse in list) {
|
||||
val b = System.currentTimeMillis()
|
||||
if (pulse == null || pulse.update()) rmlist.add(pulse)
|
||||
|
||||
val time = System.currentTimeMillis() - b
|
||||
|
||||
if (time >= 100) {
|
||||
if (pulse is GeneralBotCreator.BotScriptPulse) {
|
||||
SystemLogger.logWarn("CRITICALLY Long Botscript Tick: ${pulse.botScript.javaClass.name} - $time ms")
|
||||
} else {
|
||||
SystemLogger.logWarn("CRITICALLY long running pulse: ${pulse.javaClass.name} - $time ms")
|
||||
}
|
||||
} else if (time >= 30) {
|
||||
if (pulse is GeneralBotCreator.BotScriptPulse) {
|
||||
SystemLogger.logWarn("Long Botscript Tick: ${pulse.botScript.javaClass.name} - $time ms")
|
||||
} else {
|
||||
SystemLogger.logWarn("Long Running Pulse: ${pulse.javaClass.name} - $time ms")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//remove all null or finished pulses from the list
|
||||
rmlist.forEach {
|
||||
if (GameWorld.Pulser.TASKS.contains(it)) GameWorld.Pulser.TASKS.remove(it)
|
||||
}
|
||||
|
||||
rmlist.clear()
|
||||
//perform our update sequence where we write masks, etc
|
||||
try {
|
||||
sequence.start()
|
||||
sequence.run()
|
||||
sequence.end()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
//increment global ticks variable
|
||||
GameWorld.pulse()
|
||||
//disconnect all players waiting to be disconnected
|
||||
Repository.disconnectionQueue.update()
|
||||
GameWorld.tickListeners.forEach { it.tick() }
|
||||
//tick all manager plugins
|
||||
Managers.tick()
|
||||
}
|
||||
|
||||
fun start() {
|
||||
if(!started){
|
||||
worker.start()
|
||||
|
||||
Reference in New Issue
Block a user