fix(multiplayer): submit allocated match results

This commit is contained in:
Josh Creek
2026-09-03 21:24:07 +01:00
parent 759dbe2b65
commit 8507472635
7 changed files with 169 additions and 5 deletions
+15
View File
@@ -19,6 +19,8 @@ signal player_state_changed(peer_id: int, team: int, ready: bool)
signal rejected(reason: String) # client-side only: the server refused our hello
signal welcomed() # client-side only: our hello was accepted
signal server_shutdown(reason: String) # client-side notification before planned close
signal result_submission_accepted
signal result_submission_retrying(http_code: int)
const TEAM_COUNT := 2
const RECONNECT_GRACE_SECONDS := 60.0
@@ -68,6 +70,7 @@ var _join_authorisation_context: Dictionary = {}
var _join_signing_key := PackedByteArray()
var _connection_lease_claim := Callable()
var _connection_lease_disconnect := Callable()
var _result_submit := Callable()
# Test hook (tests/match_net_smoke.gd): set false before connecting to
# suppress the automatic real hello, so a test can send a deliberately
@@ -109,6 +112,7 @@ func _on_shutting_down() -> void:
_join_signing_key = PackedByteArray()
_connection_lease_claim = Callable()
_connection_lease_disconnect = Callable()
_result_submit = Callable()
require_join_authorisation = false
admissions_open = true
@@ -443,6 +447,17 @@ func configure_connection_lease_callbacks(claim: Callable, disconnect: Callable)
_connection_lease_disconnect = disconnect
func configure_result_submission(callback: Callable) -> void:
_result_submit = callback
func submit_authoritative_result(score: Dictionary) -> bool:
if not _result_submit.is_valid() or not score.has(0) or not score.has(1):
return false
_result_submit.call(int(score[0]), int(score[1]))
return true
func _claim_join_authorisation(token: String, peer_id: int) -> int:
var expected_generation := _available_join_generation(token)
if expected_generation < 0: