Move server calls to MusicServerClient and give players stable ids

Server requests move out of Settings into a new MusicServerClient
autoload with one function per endpoint. It sends requests through a
swappable HttpTransport so tests can fake the server, and it frees its
HTTPRequest nodes after use.

Players now have a UUID that never changes. Their position in
Settings.player_array is only used for the Alt+<number> keybinds.
Previously the position doubled as the id, so removing a player made
points and wins land on the wrong player, and could delete another
player's point from a song.

Also fixes:
- format_time showed 59.6 seconds as "00:60"
- searches containing regex characters such as "Q*bert" broke search
- SongObject and PlayerObject were Nodes that were never freed; they
  are now RefCounted
- search matching is split out of the UI code into find_matches()
This commit is contained in:
Sansan committed 2026-10-06 08:32:55 +02:00
1 parent ab338b0696
commit 56e9fe66d3
18 files changed
+281 -162

No files matched your search

+7 -6
View File
@@ -40,7 +40,7 @@ func song_is_answered(song_no: int = currently_playing_song) -> void:
song_object_array[song_no].is_answered = true
if Settings.add_to_stats:
print("add to stats: ", song_no)
Settings.make_put_request("/music/played?song="+str(song_no))
MusicServerClient.mark_song_played(song_no)
func add_to_playlist(new_song_object: SongObject) -> void:
song_object_array.append(new_song_object)
@@ -76,15 +76,16 @@ func get_current_soundtrack_title() -> String:
func get_current_song_title() -> String:
return song_object_array[currently_playing_song].get_song_title()
func add_point(player_id: int) -> void:
func add_point(player_id: String) -> void:
song_object_array[currently_playing_song].add_point(player_id)
func remove_point(player_id: int) -> void:
func remove_point(player_id: String) -> void:
song_object_array[currently_playing_song].remove_point(player_id)
func remove_player_from_list(player_to_remove: int) -> void:
for song_list_object: SongObject in song_object_array:
song_object_array[song_list_object.song_number].players_given_point.remove_at(song_object_array[song_list_object.song_number].players_given_point.find(player_to_remove))
## Removes a player's points from every song.
func remove_player_from_list(player_id: String) -> void:
for song_object: SongObject in song_object_array:
song_object.remove_point(player_id)
func get_song(song_no: int) -> AudioStream:
return song_object_array[song_no].song