Ignore Show answer when no song is playing

Before the first song played, currently_playing_song is -1, so pressing
Show answer marked the last song in the list as answered. That is the
preloaded song, so its title was shown as soon as it started playing,
and played?song=-1 was sent to the server. With an empty playlist it
crashed.
This commit is contained in:
Sansan committed 2026-10-05 21:09:38 +02:00
1 parent 6fdd7a2b76
commit 05655cf81c
3 files changed
+32

No files matched your search

+3
View File
@@ -36,6 +36,9 @@ func set_last_played_answered() -> void:
song_object_array[latest_played_song].is_answered = true
func song_is_answered(song_no: int = currently_playing_song) -> void:
# Nothing is playing yet (-1); a negative index would answer the last, unplayed song
if song_no < 0 || song_no >= song_object_array.size():
return
print("show_answer_pressed song_object: ", song_object_array[song_no]._to_string())
song_object_array[song_no].is_answered = true
if Settings.add_to_stats: