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:
1 parent
ab338b0696
commit
56e9fe66d3
18 files changed
+281
-162
No files matched your search
+2
-3
@@ -17,10 +17,9 @@ func _ready() -> void:
|
||||
visible = false
|
||||
|
||||
|
||||
func show_winner(winning_player_id: int) -> void:
|
||||
func show_winner(winner: PlayerObject) -> void:
|
||||
visible = true
|
||||
# Set winner info
|
||||
var winner: PlayerObject = Settings.player_array[winning_player_id]
|
||||
winner_label.text = winner.player_name + " won with " + str(winner.player_score) + \
|
||||
" points!!"
|
||||
winner_picture.texture = winner.character
|
||||
@@ -41,7 +40,7 @@ func show_winner(winning_player_id: int) -> void:
|
||||
|
||||
var placing: int = 2
|
||||
for player: PlayerObject in sorted_players:
|
||||
if player.id == winning_player_id:
|
||||
if player == winner:
|
||||
continue # Skip the winner, already shown above
|
||||
var label: Label = Label.new()
|
||||
label.text = str(placing) + ". " + player.player_name + " - " + \
|
||||
|
||||
Reference in new issue
Block a user