mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 05:41:11 +07:00
Fix multiplayer sometimes duplicating games (#6999)
* Fix multiplayer sometimes duplicating games * Fix test compilation
This commit is contained in:
@ -264,12 +264,10 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
||||
init {
|
||||
// We can't use Gdx.files since that is only initialized within a com.badlogic.gdx.backends.android.AndroidApplication.
|
||||
// Worker instances may be stopped & recreated by the Android WorkManager, so no AndroidApplication and thus no Gdx.files available
|
||||
val files = DefaultAndroidFiles(applicationContext.assets, ContextWrapper(applicationContext), false)
|
||||
val files = DefaultAndroidFiles(applicationContext.assets, ContextWrapper(applicationContext), true)
|
||||
// GDX's AndroidFileHandle uses Gdx.files internally, so we need to set that to our new instance
|
||||
Gdx.files = files
|
||||
val externalFilesDirForAndroid = applicationContext.getExternalFilesDir(null)?.path
|
||||
Log.d(LOG_TAG, "Creating new GameSaver with externalFilesDir=[${externalFilesDirForAndroid}]")
|
||||
gameSaver = GameSaver(files, null, externalFilesDirForAndroid)
|
||||
gameSaver = GameSaver(files, null, true)
|
||||
}
|
||||
|
||||
override fun doWork(): Result = runBlocking {
|
||||
|
@ -30,7 +30,9 @@ Sources for Info about current orientation in case need:
|
||||
if (activity.requestedOrientation != orientation) activity.requestedOrientation = orientation
|
||||
}
|
||||
|
||||
override fun getExternalFilesDir(): String? {
|
||||
return activity.getExternalFilesDir(null)?.path
|
||||
}
|
||||
/**
|
||||
* On Android, local is some android-internal data directory which may or may not be accessible by the user.
|
||||
* External is probably on an SD-card or similar which is always accessible by the user.
|
||||
*/
|
||||
override fun shouldPreferExternalStorage(): Boolean = true
|
||||
}
|
||||
|
Reference in New Issue
Block a user