mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-05 08:28:16 +07:00
Fixed rare thread crashes
This commit is contained in:
parent
c98a36c10f
commit
d748d489e2
@ -141,6 +141,8 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
||||
TileSetCache.loadTileSetConfigs()
|
||||
SkinCache.loadSkinConfigs()
|
||||
|
||||
val vanillaRuleset = RulesetCache.getVanillaRuleset()
|
||||
|
||||
if (settings.multiplayer.userId.isEmpty()) { // assign permanent user id
|
||||
settings.multiplayer.userId = UUID.randomUUID().toString()
|
||||
settings.save()
|
||||
@ -157,7 +159,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
||||
musicController.chooseTrack(suffixes = listOf(MusicMood.Menu, MusicMood.Ambient),
|
||||
flags = EnumSet.of(MusicTrackChooserFlags.SuffixMustMatch))
|
||||
|
||||
ImageGetter.ruleset = RulesetCache.getVanillaRuleset() // so that we can enter the map editor without having to load a game first
|
||||
ImageGetter.ruleset = vanillaRuleset // so that we can enter the map editor without having to load a game first
|
||||
|
||||
when {
|
||||
settings.isFreshlyCreated -> setAsRootScreen(LanguagePickerScreen())
|
||||
@ -381,7 +383,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
||||
override fun pause() {
|
||||
val curGameInfo = gameInfo
|
||||
if (curGameInfo != null) files.requestAutoSave(curGameInfo)
|
||||
musicController.pause()
|
||||
if (::musicController.isInitialized) musicController.pause()
|
||||
super.pause()
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.unciv.ui.audio
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Files.FileType
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.audio.Music
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.metadata.GameSettings
|
||||
import com.unciv.logic.multiplayer.storage.DropBox
|
||||
import com.unciv.models.metadata.GameSettings
|
||||
import com.unciv.utils.Log
|
||||
import com.unciv.utils.debug
|
||||
import java.util.*
|
||||
@ -418,9 +418,10 @@ class MusicController {
|
||||
*/
|
||||
fun pause(speedFactor: Float = 1f) {
|
||||
debug("MusicTrackController.pause called")
|
||||
if ((state != ControllerState.Playing && state != ControllerState.PlaySingle) || current == null) return
|
||||
val controller = current
|
||||
if ((state != ControllerState.Playing && state != ControllerState.PlaySingle) || controller == null) return
|
||||
val fadingStep = defaultFadingStep * speedFactor.coerceIn(0.001f..1000f)
|
||||
current!!.startFade(MusicTrackController.State.FadeOut, fadingStep)
|
||||
controller.startFade(MusicTrackController.State.FadeOut, fadingStep)
|
||||
if (next?.state == MusicTrackController.State.FadeIn)
|
||||
next!!.startFade(MusicTrackController.State.FadeOut)
|
||||
state = ControllerState.Pause
|
||||
|
@ -173,9 +173,7 @@ object SoundPlayer {
|
||||
if (initialDelay > 0 || resource.play(volume) == -1L) {
|
||||
Concurrency.run("DelayedSound") {
|
||||
delay(initialDelay.toLong())
|
||||
while (resource.play(volume) == -1L) {
|
||||
delay(20L)
|
||||
}
|
||||
while (resource.play(volume) == -1L) delay(20L)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user