Fix multiplayer presentation and Fishnet synchronization
This commit is contained in:
parent
31d459b3a7
commit
2045d8e288
19 changed files with 748 additions and 41 deletions
|
|
@ -181,7 +181,7 @@ func _run() -> void:
|
|||
var invalid_state: Dictionary = valid_state.duplicate(true)
|
||||
invalid_state["display_scale"] = 1000.0
|
||||
assert(not NetworkFishShowcaseProtocol.validate_state(invalid_state))
|
||||
assert(NetworkProtocol.PROTOCOL_VERSION == 3)
|
||||
assert(NetworkProtocol.PROTOCOL_VERSION == 4)
|
||||
assert(NetworkProtocol.ENET_CHANNEL_COUNT == 10)
|
||||
assert(
|
||||
NetworkProtocol.FISH_QUALITY_CAPABILITY
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func _run() -> void:
|
|||
_validate_mail_round_trip()
|
||||
_validate_collection_mastery()
|
||||
_validate_version_four_migration()
|
||||
assert(NetworkProtocol.PROTOCOL_VERSION == 3)
|
||||
assert(NetworkProtocol.PROTOCOL_VERSION == 4)
|
||||
assert(NetworkProtocol.ENET_CHANNEL_COUNT == 10)
|
||||
assert(NetworkProtocol.FISH_QUALITY_CAPABILITY == "fish_quality_v1")
|
||||
print("Fish quality validation: PASS")
|
||||
|
|
|
|||
|
|
@ -147,12 +147,6 @@ func _run_host() -> void:
|
|||
await process_frame
|
||||
assert(remote_animation_player.current_animation == &"retract_sit")
|
||||
|
||||
var completion_deadline: int = Time.get_ticks_msec() + 12000
|
||||
while (
|
||||
Time.get_ticks_msec() < completion_deadline
|
||||
and session.get_authenticated_peer_ids().size() == 2
|
||||
):
|
||||
await process_frame
|
||||
print("Fishing multiplayer host validation: PASS")
|
||||
session.disconnect_session("")
|
||||
main.queue_free()
|
||||
|
|
@ -337,7 +331,14 @@ func _run_client() -> void:
|
|||
while Time.get_ticks_msec() < host_observation_deadline:
|
||||
await process_frame
|
||||
print("Fishing multiplayer client validation: PASS")
|
||||
session.disconnect_session("")
|
||||
var host_completion_deadline: int = Time.get_ticks_msec() + 10000
|
||||
while (
|
||||
Time.get_ticks_msec() < host_completion_deadline
|
||||
and session.is_joined_client()
|
||||
):
|
||||
await process_frame
|
||||
if session.is_joined_client():
|
||||
session.disconnect_session("")
|
||||
main.queue_free()
|
||||
for _frame: int in 4:
|
||||
await process_frame
|
||||
|
|
|
|||
|
|
@ -87,6 +87,20 @@ func _run_client() -> void:
|
|||
assert(not jobs.get_plan_id().is_empty())
|
||||
assert(jobs.get_daily_jobs().size() == JobCatalog.DAILY_JOB_COUNT)
|
||||
assert(jobs.get_forecast().size() == JobCatalog.WEATHER_SEGMENT_COUNT)
|
||||
var preserved_plan_id: String = jobs.get_plan_id()
|
||||
jobs.clear_remote_board()
|
||||
assert(not jobs.has_active_board())
|
||||
assert(jobs.get_plan_id() == preserved_plan_id)
|
||||
var retry_deadline: int = Time.get_ticks_msec() + 5000
|
||||
while (
|
||||
Time.get_ticks_msec() < retry_deadline
|
||||
and not jobs.has_active_board()
|
||||
):
|
||||
await process_frame
|
||||
assert(jobs.has_active_board())
|
||||
assert(jobs.get_plan_id() == preserved_plan_id)
|
||||
assert(jobs.get_daily_jobs().size() == JobCatalog.DAILY_JOB_COUNT)
|
||||
assert(jobs.get_forecast().size() == JobCatalog.WEATHER_SEGMENT_COUNT)
|
||||
assert(weather.get_daily_plan_id().is_empty())
|
||||
var game_ui := main.get_node("%GameUI") as GameUI
|
||||
var player_menu := game_ui.get("_player_menu") as PlayerMenu
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ func _run() -> void:
|
|||
(player_menu.get_node("%NavigationCluster") as Control).get_child_count()
|
||||
== 7
|
||||
)
|
||||
await _validate_unavailable_fishnet_layout()
|
||||
|
||||
var wallet_before: int = player.wallet.get_balance()
|
||||
var experience_before: int = player.experience.get_total_experience()
|
||||
|
|
@ -162,6 +163,24 @@ func _run() -> void:
|
|||
var pause_menu := game_ui.get_pause_menu()
|
||||
var join_page := pause_menu.get_node("%JoinGamePage") as JoinGamePage
|
||||
assert(join_page != null)
|
||||
pause_menu.show()
|
||||
join_page.set_status("Connection timed out.")
|
||||
join_page.show()
|
||||
join_page.call(
|
||||
"_on_discovery_status_changed", "2 public rooms found", false
|
||||
)
|
||||
var join_status := join_page.get_node("%Status") as Label
|
||||
assert(join_status.text == "Could not reach the server.")
|
||||
join_page.hide()
|
||||
join_page.call("_set_mode", JoinGamePage.Mode.DIRECT)
|
||||
join_page.call("_set_mode", JoinGamePage.Mode.DISCOVER)
|
||||
join_page.show()
|
||||
join_page.call(
|
||||
"_on_discovery_status_changed", "2 public rooms found", false
|
||||
)
|
||||
assert(join_status.text == "2 public rooms found")
|
||||
join_page.close_page()
|
||||
pause_menu.hide()
|
||||
join_page.call("_refresh")
|
||||
var session_summary := (
|
||||
join_page.get_node("%SessionSummary") as Label
|
||||
|
|
@ -191,10 +210,37 @@ func _run() -> void:
|
|||
main.queue_free()
|
||||
for _frame: int in 4:
|
||||
await process_frame
|
||||
await create_timer(0.1).timeout
|
||||
print("Job system validation: PASS")
|
||||
quit()
|
||||
|
||||
|
||||
func _validate_unavailable_fishnet_layout() -> void:
|
||||
var unavailable_page := TheNetPage.new()
|
||||
unavailable_page.size = Vector2(1280.0, 720.0)
|
||||
root.add_child(unavailable_page)
|
||||
for _frame: int in 3:
|
||||
await process_frame
|
||||
unavailable_page.call("_refresh_forecast", true)
|
||||
await process_frame
|
||||
var forecast_list := unavailable_page.get("_forecast_list") as HBoxContainer
|
||||
assert(forecast_list != null)
|
||||
assert(forecast_list.size.x >= 272.0)
|
||||
assert(forecast_list.size.y <= 66.0)
|
||||
assert(forecast_list.get_child_count() == 1)
|
||||
var placeholder := forecast_list.get_child(0) as Label
|
||||
assert(placeholder != null)
|
||||
assert(placeholder.size.x >= 252.0)
|
||||
assert(placeholder.size.y <= 66.0)
|
||||
assert(placeholder.autowrap_mode == TextServer.AUTOWRAP_OFF)
|
||||
var tabs := unavailable_page.get("_tabs") as HBoxContainer
|
||||
assert(tabs != null)
|
||||
assert(tabs.position.y + tabs.size.y < UtilityPageStyle.LAPTOP_RECT.end.y)
|
||||
unavailable_page.queue_free()
|
||||
for _frame: int in 2:
|
||||
await process_frame
|
||||
|
||||
|
||||
func _validate_weather_guarantees(board: Dictionary) -> void:
|
||||
var jobs: Array = board.get("jobs", [])
|
||||
var schedule: Array = board.get("weather_schedule", [])
|
||||
|
|
|
|||
163
tests/movement_multiplayer_validation.gd
Normal file
163
tests/movement_multiplayer_validation.gd
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
extends SceneTree
|
||||
|
||||
const MainScene: PackedScene = preload("res://main/main.tscn")
|
||||
const TEST_PORT: int = 18141
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var arguments: PackedStringArray = OS.get_cmdline_user_args()
|
||||
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)
|
||||
|
||||
|
||||
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
|
||||
assert(session.start_private_host(TEST_PORT))
|
||||
assert(save_manager.initialize_new_game())
|
||||
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)
|
||||
var player := main.get("_player") as Player
|
||||
player.configure_network_remote(true)
|
||||
player.apply_authoritative_network_input(_movement_input(1, true))
|
||||
await create_timer(2.5).timeout
|
||||
player.apply_authoritative_network_input(_movement_input(2, false))
|
||||
await create_timer(2.5).timeout
|
||||
player.apply_authoritative_network_input(_movement_input(3, false, false))
|
||||
var disconnect_deadline: int = Time.get_ticks_msec() + 8000
|
||||
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
|
||||
var host_avatar: Player = spawn_service.get_avatar(1)
|
||||
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
|
||||
var saw_animation_advance: bool = false
|
||||
var saw_dust: bool = false
|
||||
var previous_animation: StringName = &""
|
||||
var previous_animation_position: float = -1.0
|
||||
var observation_deadline: int = Time.get_ticks_msec() + 7000
|
||||
while Time.get_ticks_msec() < observation_deadline:
|
||||
await process_frame
|
||||
var current_animation: StringName = animation_player.current_animation
|
||||
saw_running = saw_running or current_animation.begins_with("running")
|
||||
saw_walking = saw_walking or current_animation.begins_with("walking")
|
||||
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
|
||||
if saw_running and saw_walking and saw_animation_advance and saw_dust:
|
||||
break
|
||||
assert(saw_running)
|
||||
assert(saw_walking)
|
||||
assert(saw_animation_advance)
|
||||
assert(saw_dust)
|
||||
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,
|
||||
) -> Dictionary:
|
||||
return {
|
||||
"sequence": sequence,
|
||||
"axis": [0.0, -1.0] if moving else [0.0, 0.0],
|
||||
"camera_yaw": 0.0,
|
||||
"jump": false,
|
||||
"sprint": sprinting,
|
||||
"sneak": false,
|
||||
"slow_walk": false,
|
||||
"sitting": false,
|
||||
"casting": false,
|
||||
"animation_action": (
|
||||
NetworkPlayerAnimationProtocol.make_action_state()
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
1
tests/movement_multiplayer_validation.gd.uid
Normal file
1
tests/movement_multiplayer_validation.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dlpu5lwb2pges
|
||||
49
tests/network_player_animation_protocol_validation.gd
Normal file
49
tests/network_player_animation_protocol_validation.gd
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
extends SceneTree
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var idle := NetworkPlayerAnimationProtocol.make_state(
|
||||
NetworkPlayerAnimationProtocol.LOCOMOTION_IDLE,
|
||||
true,
|
||||
)
|
||||
assert(NetworkPlayerAnimationProtocol.validate_state(idle))
|
||||
var emote := NetworkPlayerAnimationProtocol.make_state(
|
||||
NetworkPlayerAnimationProtocol.LOCOMOTION_RUNNING,
|
||||
false,
|
||||
&"wave_hello",
|
||||
17,
|
||||
1.25,
|
||||
)
|
||||
assert(NetworkPlayerAnimationProtocol.validate_state(emote))
|
||||
var future_locomotion := NetworkPlayerAnimationProtocol.make_state(
|
||||
&"swimming_fast",
|
||||
false,
|
||||
)
|
||||
assert(NetworkPlayerAnimationProtocol.validate_state(future_locomotion))
|
||||
var extra_future_field: Dictionary = emote.duplicate(true)
|
||||
extra_future_field["future_layer"] = {"id": "umbrella"}
|
||||
assert(NetworkPlayerAnimationProtocol.validate_state(extra_future_field))
|
||||
|
||||
var invalid_action: Dictionary = emote.duplicate(true)
|
||||
invalid_action["action"] = {
|
||||
"id": "../unsafe",
|
||||
"sequence": 17,
|
||||
"elapsed": 1.25,
|
||||
}
|
||||
assert(not NetworkPlayerAnimationProtocol.validate_state(invalid_action))
|
||||
var invalid_sequence: Dictionary = emote.duplicate(true)
|
||||
invalid_sequence["action"] = {
|
||||
"id": "wave_hello",
|
||||
"sequence": -1,
|
||||
"elapsed": 1.25,
|
||||
}
|
||||
assert(not NetworkPlayerAnimationProtocol.validate_state(invalid_sequence))
|
||||
var invalid_elapsed: Dictionary = emote.duplicate(true)
|
||||
invalid_elapsed["action"] = {
|
||||
"id": "wave_hello",
|
||||
"sequence": 17,
|
||||
"elapsed": INF,
|
||||
}
|
||||
assert(not NetworkPlayerAnimationProtocol.validate_state(invalid_elapsed))
|
||||
print("Network player animation protocol validation: PASS")
|
||||
quit()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cjgelp62dkykn
|
||||
Loading…
Add table
Add a link
Reference in a new issue