mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
fix(multiplayer): validate client revisions
This commit is contained in:
@@ -419,9 +419,9 @@ func _handle_websocket_packet(packet: PackedByteArray) -> void:
|
||||
static func _valid_websocket_event(event: Dictionary) -> bool:
|
||||
if not event.has("event") or not event["event"] is String or String(event["event"]).is_empty():
|
||||
return false
|
||||
if not event.has("revision") or not (event["revision"] is int or event["revision"] is float):
|
||||
if not event.has("revision") or not _valid_revision(event["revision"]):
|
||||
return false
|
||||
if int(event["revision"]) < 0 or not event.has("resource_id") or not event["resource_id"] is String or String(event["resource_id"]).is_empty():
|
||||
if not event.has("resource_id") or not event["resource_id"] is String or String(event["resource_id"]).is_empty():
|
||||
return false
|
||||
if not event.has("occurred_at") or not event["occurred_at"] is String or String(event["occurred_at"]).is_empty():
|
||||
return false
|
||||
@@ -437,6 +437,14 @@ static func _valid_websocket_event(event: Dictionary) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
static func _valid_revision(value: Variant) -> bool:
|
||||
if value is int:
|
||||
return int(value) >= 0
|
||||
if value is float:
|
||||
return is_finite(float(value)) and float(value) >= 0.0 and float(value) == floor(float(value))
|
||||
return false
|
||||
|
||||
|
||||
func _on_resync_required(resource_id: String) -> void:
|
||||
if not _operation.is_empty():
|
||||
_pending_resync_resource_id = resource_id
|
||||
|
||||
Reference in New Issue
Block a user