Warning hunt

This commit is contained in:
JonShard
2026-08-09 14:04:49 +02:00
parent 9cdf72dc47
commit 513ad23e09
10 changed files with 41 additions and 40 deletions
+3 -3
View File
@@ -18,7 +18,7 @@ var _pickable: XRToolsPickable
# RigidBody3D default of STATIC) — captured once so it can be restored when # RigidBody3D default of STATIC) — captured once so it can be restored when
# this peer regains ownership, instead of getting stuck on whatever # this peer regains ownership, instead of getting stuck on whatever
# apply_held_state() last forced it to while non-authority. # apply_held_state() last forced it to while non-authority.
var _original_freeze_mode: int var _original_freeze_mode: RigidBody3D.FreezeMode
# Same idea for the pickable's authored `enabled` flag, which the non-authority # Same idea for the pickable's authored `enabled` flag, which the non-authority
# branch of apply_held_state() clears while someone else is holding the item. # branch of apply_held_state() clears while someone else is holding the item.
@@ -71,7 +71,7 @@ func _set_net_held_by(value: int) -> void:
func apply_held_state() -> void: func apply_held_state() -> void:
if not _pickable: if not _pickable:
return return
if not NetworkManager.is_online() or is_multiplayer_authority(): if not NetworkManager.is_online() or (is_inside_tree() and is_multiplayer_authority()) :
_grab_race_logged = false _grab_race_logged = false
# We own this item's simulation (offline, loose+server, or currently # We own this item's simulation (offline, loose+server, or currently
# holding it). If it's not actively in our own hand right now, make # holding it). If it's not actively in our own hand right now, make
@@ -205,5 +205,5 @@ func _holder_desc() -> String:
return "hand(%s)" % by.get_path() return "hand(%s)" % by.get_path()
if by is XRToolsSnapZone: if by is XRToolsSnapZone:
var station := by.get_parent() var station := by.get_parent()
return "zone(%s)" % (station.name if station else str(by.get_path())) return "zone(%s)" % (str(station.name) if station else str(by.get_path()))
return "other(%s: %s)" % [by.get_class(), by.get_path()] return "other(%s: %s)" % [by.get_class(), by.get_path()]
+1 -1
View File
@@ -331,7 +331,7 @@ func _try_snap_into_station(item: Node) -> void:
var by: Node = null var by: Node = null
if item.has_method("get_picked_up_by"): if item.has_method("get_picked_up_by"):
by = item.get_picked_up_by() by = item.get_picked_up_by()
log_line("skipped snapping %s: already held by %s (grab-race guard)" % [item.name, by.get_path() if by else "?"]) log_line("skipped snapping %s: already held by %s (grab-race guard)" % [item.name, str(by.get_path()) if by else "?"])
return return
for zone in _station_snap_zones(): for zone in _station_snap_zones():
if is_instance_valid(zone.picked_up_object): if is_instance_valid(zone.picked_up_object):
+2 -2
View File
@@ -151,5 +151,5 @@ static func get_items_old() -> Array[Dictionary]:
return items return items
static func _item(scene: String, name: String, pos: Vector3) -> Dictionary: static func _item(scene: String, item_name: String, pos: Vector3) -> Dictionary:
return {"scene": scene, "name": name, "xform": Transform3D(Basis(), pos), "props": {}} return {"scene": scene, "name": item_name, "xform": Transform3D(Basis(), pos), "props": {}}
+2 -2
View File
@@ -40,8 +40,8 @@ func _ready() -> void:
# Enable the trigger only while snapped into a snap zone (not hand-held). # Enable the trigger only while snapped into a snap zone (not hand-held).
func _on_item_picked_up(_item: Node3D) -> void: func _on_item_picked_up(_item: Node3D) -> void:
var by := _pickable.get_picked_up_by() var by := _pickable.get_picked_up_by()
var snapped: bool = by != null and by.has_method("is_xr_class") and by.is_xr_class("XRToolsSnapZone") var is_snapped: bool = by != null and by.has_method("is_xr_class") and by.is_xr_class("XRToolsSnapZone")
set_deferred("monitoring", snapped) set_deferred("monitoring", is_snapped)
func _on_item_dropped(_item: Node3D) -> void: func _on_item_dropped(_item: Node3D) -> void:
set_deferred("monitoring", false) set_deferred("monitoring", false)
-3
View File
@@ -54,9 +54,6 @@ properties/1/replication_mode = 1
properties/2/path = NodePath(".:rotation") properties/2/path = NodePath(".:rotation")
properties/2/spawn = false properties/2/spawn = false
properties/2/replication_mode = 1 properties/2/replication_mode = 1
properties/3/path = NodePath("..:moving")
properties/3/spawn = false
properties/3/replication_mode = 1
[node name="StationMovement" type="Node3D" unique_id=946873975 node_paths=PackedStringArray("move_handle", "move_ghost")] [node name="StationMovement" type="Node3D" unique_id=946873975 node_paths=PackedStringArray("move_handle", "move_ghost")]
script = ExtResource("1_ldy6a") script = ExtResource("1_ldy6a")
+1 -1
View File
@@ -10,7 +10,7 @@ func _ready() -> void:
push_error("Item dispenser is missing a reference to its snap zone child") push_error("Item dispenser is missing a reference to its snap zone child")
func _process(delta: float) -> void: func _process(_delta: float) -> void:
if not NetworkManager.owns_world(): if not NetworkManager.owns_world():
return return
#if snap_zone.picked_up_object: # Player picked up this station #if snap_zone.picked_up_object: # Player picked up this station
+1 -1
View File
@@ -1,6 +1,6 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://cmia50cfqxxo4"] [gd_resource type="StandardMaterial3D" format=3 uid="uid://cmia50cfqxxo4"]
[ext_resource type="Texture2D" uid="uid://eqp04wybmg" path="res://Textures/devTex.svg" id="1_3jxsn"] [ext_resource type="Texture2D" uid="uid://eqp04wybmg" path="res://textures/devTex.svg" id="1_3jxsn"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0gbf8"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0gbf8"]
transparency = 1 transparency = 1
+1 -2
View File
@@ -60,7 +60,6 @@ func _set_poke_enabled_for_controller(controller_node: XRController3D, value: bo
# For some reason, this is called every frame the button is down. So we need our own timer. # For some reason, this is called every frame the button is down. So we need our own timer.
func _on_controller_button_pressed(button_name: String) -> void: func _on_controller_button_pressed(button_name: String) -> void:
print("Shop _on_controller_button_pressed, button: ", button_name)
var now := Time.get_ticks_msec() / 1000.0 var now := Time.get_ticks_msec() / 1000.0
if now - _last_toggle_time < INPUT_TOGGLE_COOLDOWN: if now - _last_toggle_time < INPUT_TOGGLE_COOLDOWN:
return return
@@ -76,7 +75,7 @@ func _on_other_controller_button_pressed(button_name: String) -> void:
enabled = false enabled = false
func _on_station_bought(instance) -> void: func _on_station_bought(_instance) -> void:
enabled = false enabled = false
+5
View File
@@ -1,7 +1,12 @@
extends Node extends Node
@warning_ignore("unused_signal")
signal game_over signal game_over
@warning_ignore("unused_signal")
signal restart_game signal restart_game
@warning_ignore("unused_signal")
signal game_state_changed(new_state: GameManager.GameState) signal game_state_changed(new_state: GameManager.GameState)
@warning_ignore("unused_signal")
signal station_bought(instance: Node3D) signal station_bought(instance: Node3D)
@warning_ignore("unused_signal")
signal request_customer_spawn() signal request_customer_spawn()
+25 -25
View File
@@ -176,10 +176,10 @@ var _despawn_timers_seen := {}
# Items live either baked in the scene root or, once spawned at runtime, under # Items live either baked in the scene root or, once spawned at runtime, under
# WorldContent. Look in both. # WorldContent. Look in both.
func _find(name: String) -> Node3D: func _find(node_name: String) -> Node3D:
var n := _world.get_node_or_null(name) var n := _world.get_node_or_null(node_name)
if not n: if not n:
n = _world.get_node_or_null("WorldContent/" + name) n = _world.get_node_or_null("WorldContent/" + node_name)
return n as Node3D return n as Node3D
@@ -965,10 +965,10 @@ func _snapshot() -> Dictionary:
for child in root.get_children(): for child in root.get_children():
if child is XRToolsPickable and not child.is_queued_for_deletion(): if child is XRToolsPickable and not child.is_queued_for_deletion():
out[str(child.name)] = _describe(child) out[str(child.name)] = _describe(child)
for name in WATCHED_STATIONS: for station_name in WATCHED_STATIONS:
var station := _find(name) var station := _find(station_name)
if station: if station:
out["station:" + name] = _describe_station(station) out["station:" + station_name] = _describe_station(station)
return out return out
@@ -1016,37 +1016,37 @@ func _fetch_client_snapshot() -> Dictionary:
# Compare the server's view with the client's, returning a list of differences. # Compare the server's view with the client's, returning a list of differences.
func _compare(server: Dictionary, client: Dictionary) -> Array[String]: func _compare(server: Dictionary, client: Dictionary) -> Array[String]:
var problems: Array[String] = [] var problems: Array[String] = []
for name in server: for entity_name in server:
if not client.has(name): if not client.has(entity_name):
problems.append("'%s' exists on the server but NOT on the client" % name) problems.append("'%s' exists on the server but NOT on the client" % entity_name)
for name in client: for entity_name in client:
if not server.has(name): if not server.has(entity_name):
problems.append("'%s' exists on the client but NOT on the server (ghost copy)" % name) problems.append("'%s' exists on the client but NOT on the server (ghost copy)" % entity_name)
for name in server: for entity_name in server:
if not client.has(name): if not client.has(entity_name):
continue continue
var s: Dictionary = server[name] var s: Dictionary = server[entity_name]
var c: Dictionary = client[name] var c: Dictionary = client[entity_name]
# Stations are compared on their displayed state, not a position. # Stations are compared on their displayed state, not a position.
if s.has("pos") and c.has("pos"): if s.has("pos") and c.has("pos"):
var dist: float = (s["pos"] as Vector3).distance_to(c["pos"]) var dist: float = (s["pos"] as Vector3).distance_to(c["pos"])
if dist > SYNC_POS_TOLERANCE: if dist > SYNC_POS_TOLERANCE:
problems.append("%s is %.3fm apart (server %s vs client %s)" % [name, dist, s["pos"], c["pos"]]) problems.append("%s is %.3fm apart (server %s vs client %s)" % [entity_name, dist, s["pos"], c["pos"]])
for key in s: for key in s:
# "_" keys are per-peer diagnostics, not things that must match. # "_" keys are per-peer diagnostics, not things that must match.
if key == "pos" or key.begins_with("_"): if key == "pos" or key.begins_with("_"):
continue continue
if s[key] != c[key]: if s[key] != c[key]:
problems.append("%s.%s: server=%s client=%s" % [name, key, s[key], c[key]]) problems.append("%s.%s: server=%s client=%s" % [entity_name, key, s[key], c[key]])
# Absolute invariants, checked per peer. A cross-peer diff can't catch a # Absolute invariants, checked per peer. A cross-peer diff can't catch a
# fault that happens identically on both sides. # fault that happens identically on both sides.
for peer_name in ["server", "client"]: for peer_name in ["server", "client"]:
var snap: Dictionary = server if peer_name == "server" else client var snap: Dictionary = server if peer_name == "server" else client
for name in snap: for entity_name in snap:
var d: Dictionary = snap[name] var d: Dictionary = snap[entity_name]
if d.has("visuals_attached") and not d["visuals_attached"]: if d.has("visuals_attached") and not d["visuals_attached"]:
problems.append("on the %s, %s's food has come off the plate (%.3fm from it, limit %.2f)" problems.append("on the %s, %s's food has come off the plate (%.3fm from it, limit %.2f)"
% [peer_name, name, d.get("_visual_offset", -1.0), MAX_VISUAL_OFFSET]) % [peer_name, entity_name, d.get("_visual_offset", -1.0), MAX_VISUAL_OFFSET])
return problems return problems
@@ -1368,17 +1368,17 @@ func _assert_debug_camera() -> void:
func _check_framing() -> void: func _check_framing() -> void:
var size := get_viewport().get_visible_rect().size var size := get_viewport().get_visible_rect().size
var offscreen: Array[String] = [] var offscreen: Array[String] = []
for name in ["Counter2", "Counter", "Hob", "Sink", "DirtStation", "Plate"]: for station_name in ["Counter2", "Counter", "Hob", "Sink", "DirtStation", "Plate"]:
var n := _find(name) var n := _find(station_name)
if not n: if not n:
continue continue
var p := _debug_cam.unproject_position(n.global_position) var p := _debug_cam.unproject_position(n.global_position)
var frac := Vector2(p.x / size.x, p.y / size.y) var frac := Vector2(p.x / size.x, p.y / size.y)
var on := not _debug_cam.is_position_behind(n.global_position) \ var on := not _debug_cam.is_position_behind(n.global_position) \
and frac.x > 0.02 and frac.x < 0.98 and frac.y > 0.02 and frac.y < 0.98 and frac.x > 0.02 and frac.x < 0.98 and frac.y > 0.02 and frac.y < 0.98
_log(" framing: %-12s at %.2f,%.2f of frame%s" % [name, frac.x, frac.y, "" if on else " <-- OFF SCREEN"]) _log(" framing: %-12s at %.2f,%.2f of frame%s" % [station_name, frac.x, frac.y, "" if on else " <-- OFF SCREEN"])
if not on: if not on:
offscreen.append(name) offscreen.append(station_name)
if offscreen.is_empty(): if offscreen.is_empty():
_log(" framing: all test objects are in view") _log(" framing: all test objects are in view")
else: else: