guards in place for when scoreboard_host.txt is not present

This commit is contained in:
Haze Weathers 2024-12-03 16:08:33 -05:00
parent 6a68e025ea
commit 94ed6c6c68
3 changed files with 11 additions and 5 deletions

View file

@ -35,7 +35,8 @@ class ScoreEntry:
func _ready() -> void: func _ready() -> void:
var file = File.new() var file = File.new()
file.open("res://scoreboard_host.txt", File.READ) var result = file.open("res://scoreboard_host.txt", File.READ)
if result == OK:
server_host = file.get_line() server_host = file.get_line()
file.close() file.close()

View file

@ -77,7 +77,7 @@ func _on_AnimationPlayer_animation_finished(anim_name):
else: else:
Game.change_map(LevelData.levels[Game.current_level].scene) Game.change_map(LevelData.levels[Game.current_level].scene)
return return
if Game.final_score > Game.old_high_score and not Debug.is_cheating: if Game.final_score > Game.old_high_score and not Debug.is_cheating and not ScoreBoard.server_host.empty():
animation_player.play("submit_score_popup") animation_player.play("submit_score_popup")
else: else:
Fade.fade_out(Options.transition_speed_secs) Fade.fade_out(Options.transition_speed_secs)

View file

@ -77,6 +77,12 @@ func _refresh_scores() -> void:
func _load_scores(level: String) -> void: func _load_scores(level: String) -> void:
loaded_scores[level] = {}
if ScoreBoard.server_host.empty():
yield(get_tree(), "idle_frame")
return
var result: Dictionary = yield(ScoreBoard.get_scores(level), "completed") var result: Dictionary = yield(ScoreBoard.get_scores(level), "completed")
if ScoreBoard.errored: if ScoreBoard.errored:
#TODO: failure indication #TODO: failure indication
@ -86,7 +92,6 @@ func _load_scores(level: String) -> void:
_sorting_dict = result _sorting_dict = result
players.sort_custom(self, "_sort_scores") players.sort_custom(self, "_sort_scores")
loaded_scores[level] = {}
for p in players: for p in players:
loaded_scores[level][p] = result[p] loaded_scores[level][p] = result[p]