mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Hopefully mitigated some weird crashes
This commit is contained in:
parent
ec7a898d64
commit
8e900a2503
@ -357,8 +357,10 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTilegroupsForSelectedUnit(unit: MapUnit, playerViewableTilePositions: HashSet<Vector2>) {
|
private fun updateTilegroupsForSelectedUnit(unit: MapUnit, playerViewableTilePositions: HashSet<Vector2>) {
|
||||||
|
val tileGroup = tileGroups[unit.getTile()]
|
||||||
tileGroups[unit.getTile()]!!.selectUnit(unit)
|
if (tileGroup == null) return // Entirely unclear when this happens, but this seems to happen since version 520 (3.12.9)
|
||||||
|
// so maybe has to do with the construction list being asyc?
|
||||||
|
tileGroup.selectUnit(unit)
|
||||||
|
|
||||||
val isAirUnit = unit.type.isAirUnit()
|
val isAirUnit = unit.type.isAirUnit()
|
||||||
val tilesInMoveRange =
|
val tilesInMoveRange =
|
||||||
|
@ -37,6 +37,7 @@ import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
|||||||
import com.unciv.ui.worldscreen.unit.UnitTable
|
import com.unciv.ui.worldscreen.unit.UnitTable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
import kotlin.concurrent.timer
|
||||||
|
|
||||||
class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||||
val gameInfo = game.gameInfo
|
val gameInfo = game.gameInfo
|
||||||
@ -145,13 +146,11 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
if (gameInfo.gameParameters.isOnlineMultiplayer && !isPlayersTurn) {
|
if (gameInfo.gameParameters.isOnlineMultiplayer && !isPlayersTurn) {
|
||||||
// restart the timer
|
// restart the timer
|
||||||
stopMultiPlayerRefresher()
|
stopMultiPlayerRefresher()
|
||||||
|
|
||||||
// isDaemon = true, in order to not block the app closing
|
// isDaemon = true, in order to not block the app closing
|
||||||
multiPlayerRefresher = Timer("multiPlayerRefresh", true).apply {
|
// DO NOT use Timer() since this seems to (maybe?) translate to com.badlogic.gdx.utils.Timer? Not sure about this.
|
||||||
schedule(object : TimerTask() { //todo maybe not use timer for web request, from timer docs "Timer tasks should complete quickly."
|
multiPlayerRefresher = timer("multiPlayerRefresh", true, period = 10000) {
|
||||||
override fun run() {
|
loadLatestMultiplayerState()
|
||||||
loadLatestMultiplayerState()
|
|
||||||
}
|
|
||||||
}, 0, 10000) // 10 seconds
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +248,6 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
return
|
return
|
||||||
} else { //else we found it is the player's turn again, turn off polling and load turn
|
} else { //else we found it is the player's turn again, turn off polling and load turn
|
||||||
stopMultiPlayerRefresher()
|
stopMultiPlayerRefresher()
|
||||||
|
|
||||||
latestGame.isUpToDate = true
|
latestGame.isUpToDate = true
|
||||||
Gdx.app.postRunnable { game.loadGame(latestGame) }
|
Gdx.app.postRunnable { game.loadGame(latestGame) }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user