fix(multiplayer): enforce ranked tier enum

This commit is contained in:
Josh Creek
2026-09-01 22:39:06 +01:00
parent c580e46125
commit dac414274e
3 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -29,7 +29,7 @@ func apply(payload: Dictionary) -> bool:
var next_volatility := float(payload["volatility"])
var next_games := int(payload["ranked_games"])
var next_tier := String(payload["tier"])
if not is_finite(next_rating) or not is_finite(next_rd) or not is_finite(next_volatility) or not _valid_nonnegative_integer(payload["ranked_games"]) or next_rating < 0.0 or next_rd < 0.0 or next_volatility < 0.0 or next_games < 0 or next_tier.is_empty():
if not is_finite(next_rating) or not is_finite(next_rd) or not is_finite(next_volatility) or not _valid_nonnegative_integer(payload["ranked_games"]) or next_rating < 0.0 or next_rd < 0.0 or next_volatility < 0.0 or next_games < 0 or not _valid_tier(next_tier):
return _reject("Profile response contains invalid values")
rating = next_rating
rd = next_rd
@@ -77,6 +77,10 @@ static func _valid_nonnegative_integer(value: Variant) -> bool:
return false
static func _valid_tier(value: String) -> bool:
return value in ["PROVISIONAL", "BRONZE", "SILVER", "GOLD", "PLATINUM", "DIAMOND"]
func set_error(reason: String) -> void:
available = false
error_message = reason