guards in place for when scoreboard_host.txt is not present
This commit is contained in:
parent
6a68e025ea
commit
94ed6c6c68
3 changed files with 11 additions and 5 deletions
|
@ -35,9 +35,10 @@ class ScoreEntry:
|
|||
|
||||
func _ready() -> void:
|
||||
var file = File.new()
|
||||
file.open("res://scoreboard_host.txt", File.READ)
|
||||
server_host = file.get_line()
|
||||
file.close()
|
||||
var result = file.open("res://scoreboard_host.txt", File.READ)
|
||||
if result == OK:
|
||||
server_host = file.get_line()
|
||||
file.close()
|
||||
|
||||
http = HTTPRequest.new()
|
||||
http.download_chunk_size = 4096
|
||||
|
|
|
@ -77,7 +77,7 @@ func _on_AnimationPlayer_animation_finished(anim_name):
|
|||
else:
|
||||
Game.change_map(LevelData.levels[Game.current_level].scene)
|
||||
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")
|
||||
else:
|
||||
Fade.fade_out(Options.transition_speed_secs)
|
||||
|
|
|
@ -77,6 +77,12 @@ func _refresh_scores() -> 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")
|
||||
if ScoreBoard.errored:
|
||||
#TODO: failure indication
|
||||
|
@ -86,7 +92,6 @@ func _load_scores(level: String) -> void:
|
|||
_sorting_dict = result
|
||||
players.sort_custom(self, "_sort_scores")
|
||||
|
||||
loaded_scores[level] = {}
|
||||
for p in players:
|
||||
loaded_scores[level][p] = result[p]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue