Skip to content

Commit 1ec95fb

Browse files
committed
Add hard limit of 1 minute to load beatmap in multiplayer
This prevents a buggy version from indefinitely stalling a multiplayer room because they are loading the beatmap for so long. Realistically, 1 minute is already plenty - most of loading's heavy work is done in the background, so this should be fine.
1 parent fdfd607 commit 1ec95fb

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/com/osudroid/ui/v2/GameLoaderScene.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
2727

2828
private var lastTimeTouched = System.currentTimeMillis()
2929
private var isStarting = false
30+
private var multiplayerLoadElapsed = 0f
3031

3132
private val dimBox: UIBox
3233
private val mainContainer: UIContainer
@@ -202,6 +203,20 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
202203

203204
if (!isStarting) {
204205

206+
if (Multiplayer.isMultiplayer && !gameScene.isReadyToStart) {
207+
multiplayerLoadElapsed += deltaTimeSec
208+
209+
if (multiplayerLoadElapsed >= MULTIPLAYER_LOAD_TIMEOUT_SEC) {
210+
ToastLogger.showText(
211+
"You have been moved back as you took too long to load the beatmap.",
212+
true
213+
)
214+
215+
cancel()
216+
return
217+
}
218+
}
219+
205220
if (gameScene.isReadyToStart) {
206221

207222
// Multiplayer will skip the minimum timeout if it's ready to start.
@@ -403,5 +418,7 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
403418
companion object {
404419
private var beatmapCardCollapsed = false
405420
private var settingsCardCollapsed = false
421+
422+
private const val MULTIPLAYER_LOAD_TIMEOUT_SEC = 60f
406423
}
407424
}

0 commit comments

Comments
 (0)