2026-08-13 21:58:43 -04:00
|
|
|
extends SceneTree
|
|
|
|
|
|
|
|
|
|
const MainScene: PackedScene = preload("res://main/main.tscn")
|
2026-08-14 22:12:13 -04:00
|
|
|
const PlayerScene: PackedScene = preload("res://player/player.tscn")
|
2026-08-17 21:43:57 -04:00
|
|
|
const TEST_PORT: int = 18171
|
2026-08-13 21:58:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
|
|
|
|
call_deferred("_run")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _run() -> void:
|
2026-08-14 22:12:13 -04:00
|
|
|
await _validate_latency_smoothing()
|
2026-08-13 21:58:43 -04:00
|
|
|
var arguments: PackedStringArray = OS.get_cmdline_user_args()
|
2026-08-14 22:12:13 -04:00
|
|
|
if arguments.has("unit"):
|
|
|
|
|
print("Movement latency smoothing validation: PASS")
|
|
|
|
|
quit()
|
|
|
|
|
return
|
2026-08-13 21:58:43 -04:00
|
|
|
if arguments.has("host"):
|
|
|
|
|
await _run_host()
|
|
|
|
|
return
|
|
|
|
|
if arguments.has("client"):
|
|
|
|
|
await _run_client()
|
|
|
|
|
return
|
|
|
|
|
push_error("Movement multiplayer validation needs host or client mode.")
|
|
|
|
|
quit(1)
|
|
|
|
|
|
|
|
|
|
|
2026-08-14 22:12:13 -04:00
|
|
|
func _validate_latency_smoothing() -> void:
|
|
|
|
|
var avatar := PlayerScene.instantiate() as Player
|
|
|
|
|
root.add_child(avatar)
|
|
|
|
|
await process_frame
|
|
|
|
|
avatar.set_process(false)
|
|
|
|
|
avatar.set_physics_process(false)
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
_validate_compact_input_encoding()
|
2026-08-15 20:05:26 -04:00
|
|
|
_validate_compact_snapshot_encoding()
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
_validate_compact_animation_encoding()
|
|
|
|
|
_validate_animation_action_ordering(avatar)
|
2026-08-15 20:05:26 -04:00
|
|
|
_validate_transit_estimation()
|
2026-08-25 00:12:11 -04:00
|
|
|
await _validate_remote_snapshot_smoothing(avatar)
|
2026-08-24 10:36:17 -04:00
|
|
|
_validate_remote_locomotion_playback_recovery(avatar)
|
2026-08-15 20:05:26 -04:00
|
|
|
_validate_reliable_jump_intent(avatar)
|
2026-08-24 10:36:17 -04:00
|
|
|
_validate_airborne_sitting(avatar)
|
2026-08-15 20:05:26 -04:00
|
|
|
_validate_stale_input_expiry(avatar)
|
|
|
|
|
avatar.queue_free()
|
|
|
|
|
await process_frame
|
|
|
|
|
|
|
|
|
|
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
func _validate_compact_input_encoding() -> void:
|
|
|
|
|
var input: Dictionary = _movement_input(
|
|
|
|
|
12,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
&"strike",
|
|
|
|
|
4,
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
var encoded: Array = NetworkSession._encode_movement_input(input)
|
|
|
|
|
assert(encoded.size() == NetworkSession.MOVEMENT_INPUT_FIELD_COUNT)
|
|
|
|
|
assert(var_to_bytes(encoded).size() < var_to_bytes(input).size())
|
|
|
|
|
assert(NetworkSession._decode_movement_input(encoded) == input)
|
|
|
|
|
assert(NetworkSession._decode_movement_input(encoded.slice(0, 3)).is_empty())
|
|
|
|
|
var unknown_flags: Array = encoded.duplicate()
|
|
|
|
|
unknown_flags[3] = 1 << 12
|
|
|
|
|
assert(NetworkSession._decode_movement_input(unknown_flags).is_empty())
|
|
|
|
|
|
|
|
|
|
|
2026-08-15 20:05:26 -04:00
|
|
|
func _validate_compact_snapshot_encoding() -> void:
|
2026-08-14 22:12:13 -04:00
|
|
|
var moving_snapshot: Dictionary = _network_snapshot(
|
|
|
|
|
Vector3.ZERO,
|
|
|
|
|
Vector3(4.5, 0.0, 0.0),
|
|
|
|
|
1,
|
|
|
|
|
)
|
|
|
|
|
assert(NetworkSession.MOVEMENT_SNAPSHOT_BATCH_SIZE == 8)
|
2026-08-23 23:04:14 -04:00
|
|
|
assert(NetworkSession.OWNER_SNAPSHOT_DIVISOR == 3)
|
2026-08-14 22:12:13 -04:00
|
|
|
var encoded_snapshots: Array = []
|
|
|
|
|
for _peer: int in NetworkSession.MOVEMENT_SNAPSHOT_BATCH_SIZE:
|
|
|
|
|
encoded_snapshots.append(
|
|
|
|
|
NetworkSession._encode_movement_snapshot(moving_snapshot)
|
|
|
|
|
)
|
|
|
|
|
assert(var_to_bytes(encoded_snapshots).size() < 1200)
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
var expected_snapshot: Dictionary = moving_snapshot.duplicate(true)
|
|
|
|
|
expected_snapshot.erase("animation_state")
|
|
|
|
|
assert(
|
|
|
|
|
NetworkSession._decode_movement_snapshot(encoded_snapshots[0])
|
|
|
|
|
== expected_snapshot
|
|
|
|
|
)
|
2026-08-14 22:12:13 -04:00
|
|
|
assert(
|
|
|
|
|
NetworkSession._decode_movement_snapshot(
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
encoded_snapshots[0].slice(0, 4)
|
|
|
|
|
).is_empty()
|
|
|
|
|
)
|
|
|
|
|
var invalid_snapshot_flags: Array = encoded_snapshots[0].duplicate()
|
|
|
|
|
invalid_snapshot_flags[5] = 1 << 12
|
|
|
|
|
assert(
|
|
|
|
|
NetworkSession._decode_movement_snapshot(
|
|
|
|
|
invalid_snapshot_flags
|
|
|
|
|
).is_empty()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _validate_compact_animation_encoding() -> void:
|
|
|
|
|
var paused_state := NetworkPlayerAnimationProtocol.make_state(
|
|
|
|
|
NetworkPlayerAnimationProtocol.LOCOMOTION_IDLE,
|
|
|
|
|
true,
|
|
|
|
|
&"strike",
|
|
|
|
|
7,
|
|
|
|
|
0.5,
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
var encoded: Array = NetworkSession._encode_movement_animation(
|
|
|
|
|
2,
|
|
|
|
|
paused_state,
|
|
|
|
|
)
|
|
|
|
|
assert(encoded.size() == NetworkSession.MOVEMENT_ANIMATION_FIELD_COUNT)
|
|
|
|
|
var decoded: Dictionary = NetworkSession._decode_movement_animation(encoded)
|
|
|
|
|
assert(int(decoded.get("peer_id", 0)) == 2)
|
|
|
|
|
assert(Dictionary(decoded.get("state", {})) == paused_state)
|
|
|
|
|
var advanced_state: Dictionary = paused_state.duplicate(true)
|
|
|
|
|
advanced_state["action"]["elapsed"] = 0.75
|
|
|
|
|
assert(
|
|
|
|
|
NetworkSession._movement_animation_signature(advanced_state)
|
|
|
|
|
== NetworkSession._movement_animation_signature(paused_state)
|
|
|
|
|
)
|
|
|
|
|
var action: Dictionary = paused_state["action"]
|
|
|
|
|
var encoded_action: Array = (
|
|
|
|
|
NetworkSession._encode_movement_animation_action(action, true)
|
|
|
|
|
)
|
|
|
|
|
assert(
|
|
|
|
|
encoded_action.size()
|
|
|
|
|
== NetworkSession.MOVEMENT_ANIMATION_ACTION_FIELD_COUNT
|
|
|
|
|
)
|
|
|
|
|
var decoded_action: Dictionary = (
|
|
|
|
|
NetworkSession._decode_movement_animation_action(encoded_action)
|
|
|
|
|
)
|
|
|
|
|
assert(Dictionary(decoded_action.get("action", {})) == action)
|
|
|
|
|
assert(bool(decoded_action.get("sitting", false)))
|
|
|
|
|
assert(
|
|
|
|
|
NetworkSession._decode_movement_animation_action(
|
|
|
|
|
encoded_action.slice(0, 2)
|
|
|
|
|
).is_empty()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2026-08-24 10:36:17 -04:00
|
|
|
func _validate_airborne_sitting(avatar: Player) -> void:
|
|
|
|
|
avatar.reset_network_movement_state()
|
2026-08-25 00:12:11 -04:00
|
|
|
avatar.set_local_control(true)
|
2026-08-24 10:36:17 -04:00
|
|
|
avatar.set("_sit_after_landing", true)
|
|
|
|
|
assert(avatar.get_network_sitting_intent())
|
|
|
|
|
assert(not avatar.get_network_sitting_state())
|
|
|
|
|
assert(not bool(avatar.make_network_snapshot(2)["sitting"]))
|
|
|
|
|
assert(bool(avatar.capture_network_input(1)["sitting"]))
|
2026-08-25 00:12:11 -04:00
|
|
|
avatar.call("_queue_local_network_jump_intent")
|
|
|
|
|
var jumping_input: Dictionary = avatar.capture_network_input(2)
|
|
|
|
|
assert(bool(jumping_input["jump"]))
|
|
|
|
|
assert(not bool(jumping_input["sitting"]))
|
|
|
|
|
avatar.call("_cancel_sitting_for_jump")
|
|
|
|
|
assert(not bool(avatar.get("_sit_after_landing")))
|
|
|
|
|
assert(bool(avatar.get("_sitting_intent_pending")))
|
|
|
|
|
avatar.reset_network_movement_state()
|
2026-08-24 10:36:17 -04:00
|
|
|
|
|
|
|
|
# Even a malformed or stale reconciliation that marks an airborne avatar as
|
|
|
|
|
# seated must not bypass gravity and freeze it in place.
|
|
|
|
|
avatar.set("_sit_after_landing", false)
|
|
|
|
|
avatar.call("_set_sitting", true)
|
|
|
|
|
avatar.velocity = Vector3(0.0, 4.0, 0.0)
|
|
|
|
|
avatar.call("_simulate_movement_physics", 0.1)
|
|
|
|
|
assert(not avatar.is_sitting())
|
|
|
|
|
assert(bool(avatar.get("_sit_after_landing")))
|
|
|
|
|
assert(avatar.velocity.y < 4.0)
|
|
|
|
|
avatar.reset_network_movement_state()
|
|
|
|
|
|
|
|
|
|
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
func _validate_animation_action_ordering(avatar: Player) -> void:
|
|
|
|
|
var draw := NetworkPlayerAnimationProtocol.make_action_state(
|
|
|
|
|
&"draw", 5, 0.2
|
|
|
|
|
)
|
|
|
|
|
avatar.apply_authoritative_network_animation_action(draw)
|
|
|
|
|
assert(StringName(str(avatar.get("_animation_action_id"))) == &"draw")
|
|
|
|
|
var cleared := NetworkPlayerAnimationProtocol.make_action_state(
|
|
|
|
|
&"", 6, 0.0
|
|
|
|
|
)
|
|
|
|
|
avatar.apply_authoritative_network_animation_action(cleared)
|
|
|
|
|
assert(StringName(str(avatar.get("_animation_action_id"))).is_empty())
|
|
|
|
|
avatar.apply_authoritative_network_animation_action(draw)
|
|
|
|
|
assert(StringName(str(avatar.get("_animation_action_id"))).is_empty())
|
|
|
|
|
avatar.apply_authoritative_network_animation_action(
|
|
|
|
|
NetworkPlayerAnimationProtocol.make_action_state(&"strike", 6, 0.0)
|
2026-08-14 22:12:13 -04:00
|
|
|
)
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
assert(StringName(str(avatar.get("_animation_action_id"))).is_empty())
|
|
|
|
|
var strike := NetworkPlayerAnimationProtocol.make_action_state(
|
|
|
|
|
&"strike", 7, 0.2
|
|
|
|
|
)
|
|
|
|
|
avatar.apply_authoritative_network_animation_action(strike)
|
|
|
|
|
avatar.apply_authoritative_network_animation_action(
|
|
|
|
|
NetworkPlayerAnimationProtocol.make_action_state(
|
|
|
|
|
&"strike", 8, 0.4, true
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
avatar.apply_authoritative_network_animation_action(strike)
|
|
|
|
|
assert(bool(avatar.get("_animation_action_paused")))
|
|
|
|
|
avatar.apply_authoritative_network_animation_action(
|
|
|
|
|
NetworkPlayerAnimationProtocol.make_action_state(&"", 9, 0.0)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
avatar.configure_network_remote(false)
|
|
|
|
|
avatar.apply_network_animation_state(
|
2026-08-17 21:43:57 -04:00
|
|
|
NetworkPlayerAnimationProtocol.make_state(
|
|
|
|
|
NetworkPlayerAnimationProtocol.LOCOMOTION_IDLE,
|
|
|
|
|
true,
|
|
|
|
|
&"strike",
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
9,
|
|
|
|
|
0.4,
|
2026-08-17 21:43:57 -04:00
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
)
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
avatar.apply_network_animation_state(
|
|
|
|
|
NetworkPlayerAnimationProtocol.make_state(
|
|
|
|
|
NetworkPlayerAnimationProtocol.LOCOMOTION_WALKING,
|
|
|
|
|
true,
|
|
|
|
|
&"draw",
|
|
|
|
|
8,
|
|
|
|
|
0.1,
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
assert(
|
|
|
|
|
StringName(str(avatar.get("_network_target_animation_action_id")))
|
|
|
|
|
== &"strike"
|
2026-08-17 21:43:57 -04:00
|
|
|
)
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
avatar.apply_network_animation_state(
|
|
|
|
|
NetworkPlayerAnimationProtocol.make_state(
|
|
|
|
|
NetworkPlayerAnimationProtocol.LOCOMOTION_IDLE,
|
|
|
|
|
true,
|
|
|
|
|
&"",
|
|
|
|
|
10,
|
|
|
|
|
)
|
2026-08-17 21:43:57 -04:00
|
|
|
)
|
2026-08-14 22:12:13 -04:00
|
|
|
|
2026-08-15 20:05:26 -04:00
|
|
|
|
|
|
|
|
func _validate_transit_estimation() -> void:
|
|
|
|
|
assert(is_equal_approx(
|
|
|
|
|
Player.resolve_local_prediction_transit_seconds(
|
|
|
|
|
10,
|
|
|
|
|
16,
|
|
|
|
|
1.0 / 30.0,
|
|
|
|
|
0.075,
|
|
|
|
|
),
|
|
|
|
|
0.075,
|
|
|
|
|
))
|
|
|
|
|
# Six outstanding 30 Hz inputs span about 200 ms round trip. The fallback
|
|
|
|
|
# must use only the approximately 100 ms one-way half of that gap.
|
|
|
|
|
assert(is_equal_approx(
|
|
|
|
|
Player.resolve_local_prediction_transit_seconds(
|
|
|
|
|
10,
|
|
|
|
|
16,
|
|
|
|
|
1.0 / 30.0,
|
|
|
|
|
-1.0,
|
|
|
|
|
),
|
|
|
|
|
0.1,
|
|
|
|
|
))
|
|
|
|
|
assert(is_equal_approx(
|
|
|
|
|
Player.resolve_local_prediction_transit_seconds(
|
|
|
|
|
1,
|
|
|
|
|
100,
|
|
|
|
|
1.0 / 30.0,
|
|
|
|
|
-1.0,
|
|
|
|
|
),
|
|
|
|
|
Player.LOCAL_PREDICTION_EXTRAPOLATION_LIMIT_SECONDS,
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _validate_remote_snapshot_smoothing(avatar: Player) -> void:
|
2026-08-14 22:12:13 -04:00
|
|
|
avatar.configure_network_remote(false)
|
2026-08-15 20:05:26 -04:00
|
|
|
var moving_snapshot: Dictionary = _network_snapshot(
|
|
|
|
|
Vector3.ZERO,
|
|
|
|
|
Vector3(4.5, 0.0, 0.0),
|
|
|
|
|
1,
|
|
|
|
|
)
|
|
|
|
|
avatar.push_network_snapshot(moving_snapshot, 0.1)
|
|
|
|
|
assert(is_equal_approx(avatar.global_position.x, 0.45))
|
|
|
|
|
assert(is_equal_approx(
|
|
|
|
|
float(avatar.get("_network_target_position").x),
|
|
|
|
|
0.45,
|
|
|
|
|
))
|
|
|
|
|
avatar.call("_update_network_interpolation", 0.12)
|
|
|
|
|
var before_delayed_snapshot: Vector3 = avatar.global_position
|
|
|
|
|
var delayed_snapshot: Dictionary = _network_snapshot(
|
|
|
|
|
Vector3(0.54, 0.0, 0.0),
|
|
|
|
|
Vector3(4.5, 0.0, 0.0),
|
|
|
|
|
2,
|
|
|
|
|
)
|
|
|
|
|
avatar.push_network_snapshot(delayed_snapshot, 0.1)
|
|
|
|
|
# Snapshot receipt updates the target without teleporting a presented
|
|
|
|
|
# remote avatar, even after a jittered packet interval.
|
|
|
|
|
assert(avatar.global_position == before_delayed_snapshot)
|
|
|
|
|
assert(float(avatar.get("_network_snapshot_jitter")) > 0.0)
|
|
|
|
|
avatar.call("_update_network_interpolation", 1.0 / 60.0)
|
|
|
|
|
assert(
|
|
|
|
|
avatar.global_position.distance_to(before_delayed_snapshot) < 0.12
|
|
|
|
|
)
|
|
|
|
|
# Simulate a burst of dropped snapshots. Extrapolation must stop at the
|
|
|
|
|
# tight limit instead of allowing the remote avatar to run indefinitely.
|
|
|
|
|
for _step: int in 20:
|
|
|
|
|
avatar.call("_update_network_interpolation", 1.0 / 30.0)
|
|
|
|
|
assert(is_equal_approx(
|
|
|
|
|
float(avatar.get("_network_snapshot_age")),
|
|
|
|
|
Player.NETWORK_EXTRAPOLATION_LIMIT_SECONDS,
|
|
|
|
|
))
|
|
|
|
|
var maximum_extrapolated_x: float = (
|
|
|
|
|
0.54
|
|
|
|
|
+ 4.5 * (0.1 + Player.NETWORK_EXTRAPOLATION_LIMIT_SECONDS)
|
|
|
|
|
)
|
|
|
|
|
assert(avatar.global_position.x <= maximum_extrapolated_x + 0.1)
|
|
|
|
|
|
2026-08-25 00:12:11 -04:00
|
|
|
# Reconciliation only applies after both simulations report a grounded body.
|
|
|
|
|
# Give the unit avatar a real floor so this exercises the production path.
|
|
|
|
|
var floor := StaticBody3D.new()
|
|
|
|
|
floor.collision_layer = 1
|
|
|
|
|
floor.collision_mask = 0
|
|
|
|
|
floor.position = Vector3(0.0, -0.1, 0.0)
|
|
|
|
|
var floor_shape := CollisionShape3D.new()
|
|
|
|
|
var floor_box := BoxShape3D.new()
|
|
|
|
|
floor_box.size = Vector3(100.0, 0.2, 100.0)
|
|
|
|
|
floor_shape.shape = floor_box
|
|
|
|
|
floor.add_child(floor_shape)
|
|
|
|
|
root.add_child(floor)
|
|
|
|
|
await physics_frame
|
2026-08-15 20:05:26 -04:00
|
|
|
avatar.set_local_control(true)
|
|
|
|
|
avatar.global_position = Vector3(0.8, 0.0, 0.0)
|
2026-08-25 00:12:11 -04:00
|
|
|
avatar.velocity = Vector3.DOWN
|
|
|
|
|
avatar.move_and_slide()
|
|
|
|
|
assert(avatar.is_on_floor())
|
2026-08-14 22:12:13 -04:00
|
|
|
avatar.apply_local_prediction_correction(
|
|
|
|
|
moving_snapshot,
|
2026-08-23 23:04:14 -04:00
|
|
|
2,
|
|
|
|
|
1.0 / 30.0,
|
|
|
|
|
0.1,
|
|
|
|
|
0.1,
|
|
|
|
|
)
|
|
|
|
|
# Ordinary host/client disagreement is expected while a packet is in flight.
|
|
|
|
|
# It must never tug the locally controlled body or camera around.
|
|
|
|
|
assert(is_equal_approx(avatar.global_position.x, 0.8))
|
|
|
|
|
assert(
|
|
|
|
|
int(avatar.get("_local_prediction_soft_corrections")) == 0
|
|
|
|
|
)
|
|
|
|
|
assert(
|
|
|
|
|
int(avatar.get("_local_prediction_hard_corrections")) == 0
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# A larger but still plausible mismatch must persist across multiple audits
|
|
|
|
|
# before a small correction is allowed. Preserve both visible character and
|
|
|
|
|
# camera positions while the collision body catches up.
|
|
|
|
|
avatar.global_position = Vector3(3.0, 0.0, 0.0)
|
|
|
|
|
var visual_position: Vector3 = avatar.get_node("Visuals").global_position
|
|
|
|
|
var camera_position: Vector3 = avatar.get_node("CameraYaw").global_position
|
|
|
|
|
var drift_snapshot: Dictionary = _network_snapshot(
|
|
|
|
|
Vector3.ZERO,
|
|
|
|
|
Vector3.ZERO,
|
|
|
|
|
20,
|
|
|
|
|
)
|
|
|
|
|
for _audit: int in 3:
|
|
|
|
|
avatar.apply_local_prediction_correction(
|
|
|
|
|
drift_snapshot,
|
|
|
|
|
20,
|
|
|
|
|
1.0 / 30.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0.1,
|
|
|
|
|
)
|
|
|
|
|
assert(is_equal_approx(avatar.global_position.x, 3.0))
|
|
|
|
|
avatar.apply_local_prediction_correction(
|
|
|
|
|
drift_snapshot,
|
|
|
|
|
20,
|
|
|
|
|
1.0 / 30.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0.1,
|
|
|
|
|
)
|
|
|
|
|
assert(avatar.global_position.x < 3.0)
|
|
|
|
|
assert(avatar.global_position.x >= 2.85 - 0.001)
|
|
|
|
|
assert(avatar.get_node("Visuals").global_position == visual_position)
|
|
|
|
|
assert(avatar.get_node("CameraYaw").global_position == camera_position)
|
|
|
|
|
assert(
|
|
|
|
|
int(avatar.get("_local_prediction_soft_corrections")) == 1
|
|
|
|
|
)
|
|
|
|
|
|
2026-08-25 00:12:11 -04:00
|
|
|
# Host and client jump timing naturally differs. An airborne authoritative
|
|
|
|
|
# snapshot must not drag the local capsule sideways or down before landing.
|
|
|
|
|
avatar.global_position = Vector3(3.0, 0.0, 0.0)
|
|
|
|
|
avatar.velocity = Vector3(0.0, 1.0, 0.0)
|
|
|
|
|
var airborne_snapshot: Dictionary = drift_snapshot.duplicate(true)
|
|
|
|
|
airborne_snapshot["grounded"] = false
|
|
|
|
|
for _audit: int in 6:
|
|
|
|
|
avatar.apply_local_prediction_correction(
|
|
|
|
|
airborne_snapshot,
|
|
|
|
|
20,
|
|
|
|
|
1.0 / 30.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0.1,
|
|
|
|
|
)
|
|
|
|
|
assert(avatar.global_position.is_equal_approx(Vector3(3.0, 0.0, 0.0)))
|
|
|
|
|
assert(int(avatar.get("_local_prediction_soft_corrections")) == 1)
|
|
|
|
|
avatar.velocity = Vector3.ZERO
|
|
|
|
|
|
|
|
|
|
# The local body may reach its apex after the host has already landed. The
|
|
|
|
|
# local airborne state still owns presentation and must not be pulled toward
|
|
|
|
|
# the host until it has landed too.
|
|
|
|
|
avatar.global_position = Vector3(3.0, 2.0, 0.0)
|
|
|
|
|
avatar.velocity = Vector3.ZERO
|
|
|
|
|
avatar.move_and_slide()
|
|
|
|
|
assert(not avatar.is_on_floor())
|
|
|
|
|
for _audit: int in 6:
|
|
|
|
|
avatar.apply_local_prediction_correction(
|
|
|
|
|
drift_snapshot,
|
|
|
|
|
20,
|
|
|
|
|
1.0 / 30.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0.1,
|
|
|
|
|
)
|
|
|
|
|
assert(avatar.global_position.is_equal_approx(Vector3(3.0, 2.0, 0.0)))
|
|
|
|
|
assert(int(avatar.get("_local_prediction_soft_corrections")) == 1)
|
|
|
|
|
|
2026-08-23 23:04:14 -04:00
|
|
|
# Genuine divergence still recovers immediately, as do the separate reliable
|
|
|
|
|
# teleport and water-recovery paths used by gameplay transitions.
|
|
|
|
|
avatar.global_position = Vector3(10.0, 0.0, 0.0)
|
|
|
|
|
avatar.apply_local_prediction_correction(
|
|
|
|
|
drift_snapshot,
|
|
|
|
|
20,
|
2026-08-14 22:12:13 -04:00
|
|
|
1.0 / 30.0,
|
2026-08-23 23:04:14 -04:00
|
|
|
0.0,
|
|
|
|
|
0.1,
|
|
|
|
|
)
|
|
|
|
|
assert(avatar.global_position == Vector3.ZERO)
|
|
|
|
|
assert(
|
|
|
|
|
int(avatar.get("_local_prediction_hard_corrections")) == 1
|
2026-08-14 22:12:13 -04:00
|
|
|
)
|
2026-08-15 20:05:26 -04:00
|
|
|
|
2026-08-25 00:12:11 -04:00
|
|
|
# Soft reconciliation must respect the same terrain collision as ordinary
|
|
|
|
|
# player movement instead of phasing the capsule through a solid obstacle.
|
|
|
|
|
var blocker := StaticBody3D.new()
|
|
|
|
|
blocker.collision_layer = 1
|
|
|
|
|
blocker.collision_mask = 0
|
|
|
|
|
blocker.position = Vector3(1.0, 1.0, 0.0)
|
|
|
|
|
var blocker_shape := CollisionShape3D.new()
|
|
|
|
|
var blocker_box := BoxShape3D.new()
|
|
|
|
|
blocker_box.size = Vector3(0.2, 4.0, 4.0)
|
|
|
|
|
blocker_shape.shape = blocker_box
|
|
|
|
|
blocker.add_child(blocker_shape)
|
|
|
|
|
root.add_child(blocker)
|
|
|
|
|
await physics_frame
|
|
|
|
|
avatar.global_position = Vector3.ZERO
|
|
|
|
|
avatar.velocity = Vector3.ZERO
|
|
|
|
|
avatar.call("_clear_local_reconciliation_offsets")
|
|
|
|
|
var blocked_visual_position: Vector3 = (
|
|
|
|
|
avatar.get_node("Visuals") as Node3D
|
|
|
|
|
).global_position
|
|
|
|
|
var blocked_camera_position: Vector3 = (
|
|
|
|
|
avatar.get_node("CameraYaw") as Node3D
|
|
|
|
|
).global_position
|
|
|
|
|
assert(bool(avatar.call(
|
|
|
|
|
"_apply_camera_safe_local_correction",
|
|
|
|
|
Vector3(2.0, 0.0, 0.0),
|
|
|
|
|
)))
|
|
|
|
|
assert(avatar.global_position.x > 0.0 and avatar.global_position.x < 0.6)
|
|
|
|
|
assert(
|
|
|
|
|
(avatar.get_node("Visuals") as Node3D).global_position
|
|
|
|
|
== blocked_visual_position
|
|
|
|
|
)
|
|
|
|
|
assert(
|
|
|
|
|
(avatar.get_node("CameraYaw") as Node3D).global_position
|
|
|
|
|
== blocked_camera_position
|
|
|
|
|
)
|
|
|
|
|
blocker.queue_free()
|
|
|
|
|
floor.queue_free()
|
|
|
|
|
await physics_frame
|
|
|
|
|
|
2026-08-15 20:05:26 -04:00
|
|
|
|
2026-08-24 10:36:17 -04:00
|
|
|
func _validate_remote_locomotion_playback_recovery(avatar: Player) -> void:
|
|
|
|
|
avatar.configure_network_remote(false)
|
|
|
|
|
avatar.push_network_snapshot(
|
|
|
|
|
_network_snapshot(Vector3.ZERO, Vector3(4.5, 0.0, 0.0), 21)
|
|
|
|
|
)
|
|
|
|
|
avatar.call("_update_character_animation")
|
|
|
|
|
var animation_player := avatar.get_node(
|
|
|
|
|
"Visuals/CharacterRig/AnimationPlayer"
|
|
|
|
|
) as AnimationPlayer
|
|
|
|
|
assert(animation_player.assigned_animation == &"running")
|
|
|
|
|
assert(animation_player.is_playing())
|
|
|
|
|
|
|
|
|
|
# Reproduce issue #111: locomotion replication still says RUNNING (and the
|
|
|
|
|
# dust therefore still emits), but the rig playback has fallen idle. The
|
|
|
|
|
# local presentation pass must repair that state without another packet.
|
|
|
|
|
animation_player.stop()
|
|
|
|
|
assert(not animation_player.is_playing())
|
|
|
|
|
assert(
|
|
|
|
|
int(avatar.get("_network_target_locomotion_state"))
|
|
|
|
|
== Player.LocomotionState.RUNNING
|
|
|
|
|
)
|
|
|
|
|
avatar.call("_update_character_animation")
|
|
|
|
|
assert(animation_player.assigned_animation == &"running")
|
|
|
|
|
assert(animation_player.is_playing())
|
|
|
|
|
|
|
|
|
|
|
2026-08-15 20:05:26 -04:00
|
|
|
func _validate_reliable_jump_intent(avatar: Player) -> void:
|
|
|
|
|
avatar.set_local_control(true)
|
|
|
|
|
avatar.call("_queue_local_network_jump_intent")
|
|
|
|
|
var first: Dictionary = avatar.capture_network_input(20)
|
|
|
|
|
var repeated: Dictionary = avatar.capture_network_input(21)
|
|
|
|
|
assert(bool(first["jump"]))
|
|
|
|
|
assert(bool(repeated["jump"]))
|
|
|
|
|
assert(int(avatar.get("_local_network_jump_intent_sequence")) == 20)
|
|
|
|
|
avatar.apply_local_prediction_correction(
|
|
|
|
|
_network_snapshot(avatar.global_position, Vector3.ZERO, 20),
|
2026-08-23 23:04:14 -04:00
|
|
|
20,
|
2026-08-15 20:05:26 -04:00
|
|
|
1.0 / 30.0,
|
2026-08-23 23:04:14 -04:00
|
|
|
0.0,
|
|
|
|
|
0.1,
|
2026-08-15 20:05:26 -04:00
|
|
|
)
|
|
|
|
|
assert(not bool(avatar.capture_network_input(22)["jump"]))
|
|
|
|
|
|
|
|
|
|
avatar.configure_network_remote(true)
|
|
|
|
|
var first_host_jump: Dictionary = _movement_input(30, false, false)
|
|
|
|
|
first_host_jump["jump"] = true
|
|
|
|
|
avatar.apply_authoritative_network_input(first_host_jump)
|
|
|
|
|
assert(bool(avatar.get("_network_jump_pending")))
|
|
|
|
|
avatar.set("_network_jump_pending", false)
|
|
|
|
|
var repeated_host_jump: Dictionary = _movement_input(31, false, false)
|
|
|
|
|
repeated_host_jump["jump"] = true
|
|
|
|
|
avatar.apply_authoritative_network_input(repeated_host_jump)
|
|
|
|
|
assert(not bool(avatar.get("_network_jump_pending")))
|
|
|
|
|
avatar.apply_authoritative_network_input(
|
|
|
|
|
_movement_input(32, false, false)
|
|
|
|
|
)
|
|
|
|
|
var next_host_jump: Dictionary = _movement_input(33, false, false)
|
|
|
|
|
next_host_jump["jump"] = true
|
|
|
|
|
avatar.apply_authoritative_network_input(next_host_jump)
|
|
|
|
|
assert(bool(avatar.get("_network_jump_pending")))
|
|
|
|
|
avatar.reset_network_movement_state()
|
|
|
|
|
assert(not bool(avatar.get("_network_jump_pending")))
|
|
|
|
|
assert(not bool(avatar.get("_local_network_jump_intent_pending")))
|
|
|
|
|
assert(int(avatar.get("_last_network_input_sequence")) == 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _validate_stale_input_expiry(avatar: Player) -> void:
|
|
|
|
|
avatar.configure_network_remote(true)
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
var high_latency_timeout := (
|
|
|
|
|
Player.resolve_network_input_stale_timeout_seconds(400)
|
|
|
|
|
)
|
|
|
|
|
assert(high_latency_timeout > Player.NETWORK_INPUT_STALE_TIMEOUT_SECONDS)
|
|
|
|
|
avatar.apply_authoritative_network_input(
|
|
|
|
|
_movement_input(40, true),
|
|
|
|
|
high_latency_timeout,
|
|
|
|
|
)
|
2026-08-15 20:05:26 -04:00
|
|
|
assert((avatar.get("_network_axis") as Vector2).length_squared() > 0.0)
|
|
|
|
|
avatar.call(
|
|
|
|
|
"_update_network_input_freshness",
|
|
|
|
|
Player.NETWORK_INPUT_STALE_TIMEOUT_SECONDS + 0.01,
|
|
|
|
|
)
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
assert(not bool(avatar.get("_network_input_stale")))
|
|
|
|
|
avatar.call(
|
|
|
|
|
"_update_network_input_freshness",
|
|
|
|
|
high_latency_timeout,
|
|
|
|
|
)
|
2026-08-15 20:05:26 -04:00
|
|
|
assert((avatar.get("_network_axis") as Vector2) == Vector2.ZERO)
|
|
|
|
|
assert(not bool(avatar.get("_network_sprint")))
|
|
|
|
|
assert(bool(avatar.get("_network_input_stale")))
|
|
|
|
|
avatar.apply_authoritative_network_input(_movement_input(41, false))
|
|
|
|
|
assert(not bool(avatar.get("_network_input_stale")))
|
|
|
|
|
assert((avatar.get("_network_axis") as Vector2).length_squared() > 0.0)
|
2026-08-14 22:12:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _network_snapshot(
|
|
|
|
|
position: Vector3,
|
|
|
|
|
velocity: Vector3,
|
|
|
|
|
acknowledged_input: int,
|
|
|
|
|
) -> Dictionary:
|
|
|
|
|
return {
|
|
|
|
|
"peer_id": 2,
|
|
|
|
|
"acknowledged_input": acknowledged_input,
|
|
|
|
|
"position": [position.x, position.y, position.z],
|
|
|
|
|
"velocity": [velocity.x, velocity.y, velocity.z],
|
|
|
|
|
"visual_yaw": 0.0,
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
"grounded": true,
|
2026-08-14 22:12:13 -04:00
|
|
|
"animation_state": NetworkPlayerAnimationProtocol.make_state(
|
|
|
|
|
NetworkPlayerAnimationProtocol.LOCOMOTION_RUNNING,
|
|
|
|
|
true,
|
|
|
|
|
),
|
|
|
|
|
"sitting": false,
|
|
|
|
|
"casting": false,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2026-08-13 21:58:43 -04:00
|
|
|
func _run_host() -> void:
|
|
|
|
|
var main: Node = await _create_initialized_main()
|
|
|
|
|
var session := main.get_node("%NetworkSession") as NetworkSession
|
|
|
|
|
var save_manager := main.get("_save_manager") as PlayerSaveManager
|
2026-08-30 23:52:25 -04:00
|
|
|
assert(bool(main.call(
|
|
|
|
|
"_apply_world",
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
WorldLayout.STARTER_ISLAND,
|
|
|
|
|
NetworkProtocol.DEFAULT_WORLD_SEED,
|
2026-08-30 23:52:25 -04:00
|
|
|
true,
|
|
|
|
|
)))
|
|
|
|
|
assert(bool(main.call(
|
|
|
|
|
"_prepare_host_world",
|
|
|
|
|
WorldLayout.STARTER_ISLAND,
|
|
|
|
|
NetworkProtocol.DEFAULT_WORLD_SEED,
|
|
|
|
|
)))
|
feat: expand progression and multiplayer systems
Add named save slots, progression import/export, and a unified play flow. Add live friend requests, presence, invitations, and relationship controls without durable discovery-server social storage. Advance the network protocol with isolated channels, movement reconciliation, late-join recovery, fishing replication, and animation synchronization. Preserve per-species catch totals, refine generated-world startup and water recovery, and complete the related input and interface improvements.
2026-08-23 20:48:38 -04:00
|
|
|
assert(save_manager.initialize_new_game(
|
|
|
|
|
NetworkProtocol.DEFAULT_WORLD_SEED,
|
|
|
|
|
WorldLayout.STARTER_ISLAND,
|
|
|
|
|
))
|
2026-08-30 23:52:25 -04:00
|
|
|
assert(session.start_private_host(TEST_PORT))
|
2026-08-13 21:58:43 -04:00
|
|
|
main.call("_enter_gameplay")
|
|
|
|
|
for _frame: int in 4:
|
|
|
|
|
await physics_frame
|
|
|
|
|
assert(session.set_host_open(true))
|
|
|
|
|
var remote_peer_id: int = await _wait_for_remote_peer(session)
|
|
|
|
|
assert(remote_peer_id > 1)
|
2026-08-17 21:43:57 -04:00
|
|
|
# Authentication completes before the client has necessarily created and
|
|
|
|
|
# begun observing the host avatar. Give its gameplay scene a bounded moment
|
|
|
|
|
# to settle before emitting the one-shot locomotion/action sequence.
|
2026-08-18 21:59:34 -04:00
|
|
|
await create_timer(3.0).timeout
|
2026-08-13 21:58:43 -04:00
|
|
|
var player := main.get("_player") as Player
|
2026-08-30 23:52:25 -04:00
|
|
|
var world := main.get_node("TestWorld") as TestWorld
|
2026-08-13 21:58:43 -04:00
|
|
|
player.configure_network_remote(true)
|
2026-08-30 23:52:25 -04:00
|
|
|
await _reset_locomotion_test_position(player, session, world)
|
|
|
|
|
var input_sequence: int = 1
|
|
|
|
|
input_sequence = await _sustain_locomotion_input(
|
|
|
|
|
player, input_sequence, 1.5, true
|
2026-08-17 17:50:30 -04:00
|
|
|
)
|
2026-08-30 23:52:25 -04:00
|
|
|
await _reset_locomotion_test_position(player, session, world)
|
|
|
|
|
input_sequence = await _sustain_locomotion_input(
|
|
|
|
|
player, input_sequence, 1.5, false
|
|
|
|
|
)
|
|
|
|
|
await _reset_locomotion_test_position(player, session, world)
|
|
|
|
|
input_sequence = await _sustain_locomotion_input(
|
|
|
|
|
player, input_sequence, 1.5, false, true, true
|
|
|
|
|
)
|
|
|
|
|
input_sequence = await _sustain_locomotion_input(
|
|
|
|
|
player, input_sequence, 1.5, false, false, true
|
2026-08-17 17:50:30 -04:00
|
|
|
)
|
|
|
|
|
player.apply_authoritative_network_input(
|
2026-08-30 23:52:25 -04:00
|
|
|
_movement_input(input_sequence, false, false, true, &"draw", 1)
|
2026-08-17 17:50:30 -04:00
|
|
|
)
|
2026-08-30 23:52:25 -04:00
|
|
|
input_sequence += 1
|
2026-08-17 17:50:30 -04:00
|
|
|
await create_timer(1.0).timeout
|
|
|
|
|
player.apply_authoritative_network_input(
|
2026-08-30 23:52:25 -04:00
|
|
|
_movement_input(
|
|
|
|
|
input_sequence, false, false, true, &"strike", 2, true
|
|
|
|
|
)
|
2026-08-17 17:50:30 -04:00
|
|
|
)
|
2026-08-30 23:52:25 -04:00
|
|
|
input_sequence += 1
|
2026-08-17 21:43:57 -04:00
|
|
|
await create_timer(2.0).timeout
|
2026-08-17 17:50:30 -04:00
|
|
|
player.apply_authoritative_network_input(
|
2026-08-30 23:52:25 -04:00
|
|
|
_movement_input(input_sequence, false, false, false, &"", 3)
|
2026-08-17 17:50:30 -04:00
|
|
|
)
|
2026-08-30 23:52:25 -04:00
|
|
|
var disconnect_deadline: int = Time.get_ticks_msec() + 15000
|
2026-08-13 21:58:43 -04:00
|
|
|
while (
|
|
|
|
|
Time.get_ticks_msec() < disconnect_deadline
|
|
|
|
|
and session.is_authenticated_peer(remote_peer_id)
|
|
|
|
|
):
|
|
|
|
|
await process_frame
|
|
|
|
|
assert(not session.is_authenticated_peer(remote_peer_id))
|
|
|
|
|
print("Movement multiplayer host validation: PASS")
|
|
|
|
|
session.disconnect_session("")
|
|
|
|
|
main.queue_free()
|
|
|
|
|
for _frame: int in 4:
|
|
|
|
|
await process_frame
|
|
|
|
|
await create_timer(0.1).timeout
|
|
|
|
|
quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _run_client() -> void:
|
|
|
|
|
var main: Node = await _create_initialized_main()
|
|
|
|
|
main.call(
|
|
|
|
|
"_on_title_join_game_requested",
|
|
|
|
|
"127.0.0.1:%d" % TEST_PORT,
|
|
|
|
|
)
|
|
|
|
|
var session := main.get_node("%NetworkSession") as NetworkSession
|
|
|
|
|
var join_deadline: int = Time.get_ticks_msec() + 20000
|
|
|
|
|
while Time.get_ticks_msec() < join_deadline:
|
|
|
|
|
await process_frame
|
|
|
|
|
if session.state == NetworkSession.State.VERIFYING_SERVER_IDENTITY:
|
|
|
|
|
main.call("_confirm_server_trust")
|
|
|
|
|
if session.is_joined_client() and bool(main.get("_gameplay_started")):
|
|
|
|
|
break
|
|
|
|
|
assert(session.is_joined_client())
|
|
|
|
|
var spawn_service := main.get_node(
|
|
|
|
|
"%PlayerSpawnService"
|
|
|
|
|
) as PlayerSpawnService
|
2026-08-17 21:43:57 -04:00
|
|
|
var host_avatar: Player = await _wait_for_avatar(spawn_service, 1)
|
2026-08-13 21:58:43 -04:00
|
|
|
assert(host_avatar != null)
|
|
|
|
|
var animation_player := host_avatar.get_node(
|
|
|
|
|
"Visuals/CharacterRig/AnimationPlayer"
|
|
|
|
|
) as AnimationPlayer
|
|
|
|
|
var sprint_dust := host_avatar.get_node("%SprintDust") as SprintDustTrail
|
|
|
|
|
var saw_running: bool = false
|
|
|
|
|
var saw_walking: bool = false
|
2026-08-17 17:50:30 -04:00
|
|
|
var saw_sneaking: bool = false
|
|
|
|
|
var saw_idle_sneak: bool = false
|
|
|
|
|
var saw_net_draw: bool = false
|
|
|
|
|
var saw_net_strike: bool = false
|
2026-08-17 21:43:57 -04:00
|
|
|
var saw_net_strike_paused: bool = false
|
2026-08-13 21:58:43 -04:00
|
|
|
var saw_animation_advance: bool = false
|
|
|
|
|
var saw_dust: bool = false
|
2026-08-30 23:52:25 -04:00
|
|
|
var observed_animations: Dictionary = {}
|
|
|
|
|
var observed_locomotion_states: Dictionary = {}
|
|
|
|
|
var maximum_sneak_speed: float = 0.0
|
2026-08-13 21:58:43 -04:00
|
|
|
var previous_animation: StringName = &""
|
|
|
|
|
var previous_animation_position: float = -1.0
|
2026-08-30 23:52:25 -04:00
|
|
|
var observation_deadline: int = Time.get_ticks_msec() + 22000
|
2026-08-13 21:58:43 -04:00
|
|
|
while Time.get_ticks_msec() < observation_deadline:
|
|
|
|
|
await process_frame
|
|
|
|
|
var current_animation: StringName = animation_player.current_animation
|
2026-08-30 23:52:25 -04:00
|
|
|
observed_animations[current_animation] = true
|
|
|
|
|
var target_locomotion_state: int = int(host_avatar.get(
|
|
|
|
|
"_network_target_locomotion_state"
|
|
|
|
|
))
|
|
|
|
|
observed_locomotion_states[target_locomotion_state] = true
|
|
|
|
|
if target_locomotion_state == Player.LocomotionState.SNEAKING:
|
|
|
|
|
maximum_sneak_speed = maxf(
|
|
|
|
|
maximum_sneak_speed,
|
|
|
|
|
Vector2(
|
|
|
|
|
host_avatar.velocity.x, host_avatar.velocity.z
|
|
|
|
|
).length(),
|
|
|
|
|
)
|
2026-08-13 21:58:43 -04:00
|
|
|
saw_running = saw_running or current_animation.begins_with("running")
|
|
|
|
|
saw_walking = saw_walking or current_animation.begins_with("walking")
|
2026-08-17 17:50:30 -04:00
|
|
|
saw_sneaking = saw_sneaking or current_animation == &"sneaking"
|
|
|
|
|
saw_idle_sneak = saw_idle_sneak or current_animation == &"idle_sneak"
|
|
|
|
|
saw_net_draw = saw_net_draw or current_animation == &"draw"
|
2026-08-17 21:43:57 -04:00
|
|
|
saw_net_strike = (
|
|
|
|
|
saw_net_strike
|
|
|
|
|
or current_animation == &"strike"
|
|
|
|
|
or animation_player.assigned_animation == &"strike"
|
|
|
|
|
)
|
|
|
|
|
saw_net_strike_paused = (
|
|
|
|
|
saw_net_strike_paused
|
|
|
|
|
or bool(host_avatar.get(
|
|
|
|
|
"_network_target_animation_action_paused"
|
|
|
|
|
))
|
|
|
|
|
)
|
2026-08-13 21:58:43 -04:00
|
|
|
var current_position: float = (
|
|
|
|
|
animation_player.current_animation_position
|
|
|
|
|
)
|
|
|
|
|
if (
|
|
|
|
|
current_animation == previous_animation
|
|
|
|
|
and previous_animation_position >= 0.0
|
|
|
|
|
and absf(current_position - previous_animation_position) > 0.001
|
|
|
|
|
):
|
|
|
|
|
saw_animation_advance = true
|
|
|
|
|
previous_animation = current_animation
|
|
|
|
|
previous_animation_position = current_position
|
|
|
|
|
saw_dust = saw_dust or sprint_dust.get_active_puff_count() > 0
|
2026-08-17 17:50:30 -04:00
|
|
|
if (
|
|
|
|
|
saw_running
|
|
|
|
|
and saw_walking
|
|
|
|
|
and saw_sneaking
|
|
|
|
|
and saw_idle_sneak
|
|
|
|
|
and saw_net_draw
|
|
|
|
|
and saw_net_strike
|
2026-08-17 21:43:57 -04:00
|
|
|
and saw_net_strike_paused
|
2026-08-17 17:50:30 -04:00
|
|
|
and saw_animation_advance
|
|
|
|
|
and saw_dust
|
2026-08-17 21:43:57 -04:00
|
|
|
):
|
|
|
|
|
break
|
2026-08-30 23:52:25 -04:00
|
|
|
var missing_observations: Array[String] = []
|
|
|
|
|
if not saw_running:
|
|
|
|
|
missing_observations.append("running")
|
|
|
|
|
if not saw_walking:
|
|
|
|
|
missing_observations.append("walking")
|
|
|
|
|
if not saw_sneaking:
|
|
|
|
|
missing_observations.append("sneaking")
|
|
|
|
|
if not saw_idle_sneak:
|
|
|
|
|
missing_observations.append("idle_sneak")
|
|
|
|
|
if not saw_net_draw:
|
|
|
|
|
missing_observations.append("net_draw")
|
|
|
|
|
if not saw_net_strike:
|
|
|
|
|
missing_observations.append("net_strike")
|
|
|
|
|
if not saw_net_strike_paused:
|
|
|
|
|
missing_observations.append("net_strike_paused")
|
|
|
|
|
if not saw_animation_advance:
|
|
|
|
|
missing_observations.append("animation_advance")
|
|
|
|
|
if not saw_dust:
|
|
|
|
|
missing_observations.append("sprint_dust")
|
|
|
|
|
if not missing_observations.is_empty():
|
|
|
|
|
push_error(
|
|
|
|
|
(
|
|
|
|
|
"Missing movement observations %s; observed animations: %s; "
|
|
|
|
|
+ "locomotion states: %s; maximum sneak speed: %.3f"
|
|
|
|
|
) % [
|
|
|
|
|
missing_observations,
|
|
|
|
|
observed_animations.keys(),
|
|
|
|
|
observed_locomotion_states.keys(),
|
|
|
|
|
maximum_sneak_speed,
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
session.disconnect_session("")
|
|
|
|
|
main.queue_free()
|
|
|
|
|
for _frame: int in 4:
|
|
|
|
|
await process_frame
|
|
|
|
|
await create_timer(0.1).timeout
|
|
|
|
|
quit(1)
|
|
|
|
|
return
|
2026-08-13 21:58:43 -04:00
|
|
|
print("Movement multiplayer client validation: PASS")
|
|
|
|
|
session.disconnect_session("")
|
|
|
|
|
main.queue_free()
|
|
|
|
|
for _frame: int in 4:
|
|
|
|
|
await process_frame
|
|
|
|
|
await create_timer(0.1).timeout
|
|
|
|
|
quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _movement_input(
|
|
|
|
|
sequence: int,
|
|
|
|
|
sprinting: bool,
|
|
|
|
|
moving: bool = true,
|
2026-08-17 17:50:30 -04:00
|
|
|
sneaking: bool = false,
|
|
|
|
|
action_id: StringName = &"",
|
|
|
|
|
action_sequence: int = 0,
|
2026-08-17 21:43:57 -04:00
|
|
|
action_paused: bool = false,
|
2026-08-13 21:58:43 -04:00
|
|
|
) -> Dictionary:
|
|
|
|
|
return {
|
|
|
|
|
"sequence": sequence,
|
|
|
|
|
"axis": [0.0, -1.0] if moving else [0.0, 0.0],
|
|
|
|
|
"camera_yaw": 0.0,
|
|
|
|
|
"jump": false,
|
|
|
|
|
"sprint": sprinting,
|
2026-08-17 17:50:30 -04:00
|
|
|
"sneak": sneaking,
|
2026-08-13 21:58:43 -04:00
|
|
|
"slow_walk": false,
|
|
|
|
|
"sitting": false,
|
|
|
|
|
"casting": false,
|
2026-08-17 17:50:30 -04:00
|
|
|
"animation_action": NetworkPlayerAnimationProtocol.make_action_state(
|
|
|
|
|
action_id,
|
|
|
|
|
action_sequence,
|
2026-08-17 21:43:57 -04:00
|
|
|
0.0,
|
|
|
|
|
action_paused,
|
2026-08-13 21:58:43 -04:00
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2026-08-30 23:52:25 -04:00
|
|
|
func _sustain_locomotion_input(
|
|
|
|
|
player: Player,
|
|
|
|
|
starting_sequence: int,
|
|
|
|
|
duration_seconds: float,
|
|
|
|
|
sprinting: bool,
|
|
|
|
|
moving: bool = true,
|
|
|
|
|
sneaking: bool = false,
|
|
|
|
|
) -> int:
|
|
|
|
|
var sequence: int = starting_sequence
|
|
|
|
|
var deadline: int = (
|
|
|
|
|
Time.get_ticks_msec() + roundi(duration_seconds * 1000.0)
|
|
|
|
|
)
|
|
|
|
|
while Time.get_ticks_msec() < deadline:
|
|
|
|
|
player.apply_authoritative_network_input(
|
|
|
|
|
_movement_input(sequence, sprinting, moving, sneaking)
|
|
|
|
|
)
|
|
|
|
|
sequence += 1
|
|
|
|
|
await create_timer(0.1).timeout
|
|
|
|
|
return sequence
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _reset_locomotion_test_position(
|
|
|
|
|
player: Player,
|
|
|
|
|
session: NetworkSession,
|
|
|
|
|
world: TestWorld,
|
|
|
|
|
) -> void:
|
|
|
|
|
player.velocity = Vector3.ZERO
|
|
|
|
|
player.global_transform = world.get_player_spawn_transform()
|
|
|
|
|
session.publish_authoritative_teleport(1)
|
|
|
|
|
for _frame: int in 4:
|
|
|
|
|
await physics_frame
|
|
|
|
|
|
|
|
|
|
|
2026-08-13 21:58:43 -04:00
|
|
|
func _create_initialized_main() -> Node:
|
|
|
|
|
root.size = Vector2i(1280, 720)
|
|
|
|
|
var main: Node = MainScene.instantiate()
|
|
|
|
|
root.add_child(main)
|
|
|
|
|
for _frame: int in 4:
|
|
|
|
|
await process_frame
|
|
|
|
|
if not bool(main.get("_application_initialized")):
|
|
|
|
|
main.call("_activate_selected_data_path", "", true)
|
|
|
|
|
for _frame: int in 8:
|
|
|
|
|
await process_frame
|
|
|
|
|
assert(bool(main.get("_application_initialized")))
|
|
|
|
|
return main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _wait_for_remote_peer(session: NetworkSession) -> int:
|
|
|
|
|
var deadline: int = Time.get_ticks_msec() + 20000
|
|
|
|
|
while Time.get_ticks_msec() < deadline:
|
|
|
|
|
await process_frame
|
|
|
|
|
for peer_id: int in session.get_authenticated_peer_ids():
|
|
|
|
|
if peer_id != session.get_local_peer_id():
|
|
|
|
|
return peer_id
|
|
|
|
|
return 0
|
2026-08-17 21:43:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _wait_for_avatar(
|
|
|
|
|
spawn_service: PlayerSpawnService,
|
|
|
|
|
peer_id: int,
|
|
|
|
|
) -> Player:
|
|
|
|
|
var deadline: int = Time.get_ticks_msec() + 8000
|
|
|
|
|
while Time.get_ticks_msec() < deadline:
|
|
|
|
|
await process_frame
|
|
|
|
|
var avatar := spawn_service.get_avatar(peer_id) as Player
|
|
|
|
|
if avatar != null:
|
|
|
|
|
return avatar
|
|
|
|
|
return null
|