Skip to content

Commit 81c1c30

Browse files
authored
fix: Clear property config on process_authority() (#507)
Fixes #495
1 parent 27b46ee commit 81c1c30

File tree

7 files changed

+40
-10
lines changed

7 files changed

+40
-10
lines changed

addons/netfox.extras/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="netfox.extras"
44
description="Game-specific utilities for Netfox"
55
author="Tamas Galffy and contributors"
6-
version="1.32.2"
6+
version="1.32.3"
77
script="netfox-extras.gd"

addons/netfox.internals/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="netfox.internals"
44
description="Shared internals for netfox addons"
55
author="Tamas Galffy and contributors"
6-
version="1.32.2"
6+
version="1.32.3"
77
script="plugin.gd"

addons/netfox.noray/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="netfox.noray"
44
description="Bulletproof your connectivity with noray integration for netfox"
55
author="Tamas Galffy and contributors"
6-
version="1.32.2"
6+
version="1.32.3"
77
script="netfox-noray.gd"

addons/netfox/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="netfox"
44
description="Shared internals for netfox addons"
55
author="Tamas Galffy and contributors"
6-
version="1.32.2"
6+
version="1.32.3"
77
script="netfox.gd"

addons/netfox/properties/property-config.gd

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ var _auth_properties: Dictionary = {} # Peer (int) to owned properties (Array[Pr
66

77
var local_peer_id: int
88

9+
func clear() -> void:
10+
_properties.clear()
11+
_auth_properties.clear()
12+
913
func set_properties(p_properties: Array[PropertyEntry]) -> void:
14+
clear()
1015
_properties.assign(p_properties)
11-
_auth_properties.clear()
1216

1317
func set_properties_from_paths(property_paths: Array[String], property_cache: PropertyCache) -> void:
14-
_properties.clear()
18+
clear()
1519
for path in property_paths:
1620
_properties.append(property_cache.get_entry(path))
1721

test/netfox/properties/property-config.test.gd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,25 @@ func suite():
3232
expect_empty(config.get_properties_owned_by(LOCAL_PEER))
3333
)
3434

35+
test("should get remote owned properties after ownership change", func():
36+
var properties := SnapshotFixtures.state_properties()
37+
var cache := PropertyCache.new(remote_node)
38+
var config := _PropertyConfig.new()
39+
config.set_properties_from_paths(SnapshotFixtures.state_properties(), cache)
40+
config.local_peer_id = LOCAL_PEER
41+
42+
expect_empty(config.get_owned_properties())
43+
44+
# Update ownership
45+
remote_node.set_multiplayer_authority(1)
46+
config.set_properties_from_paths(SnapshotFixtures.state_properties(), cache)
47+
48+
# Convert to a list of property paths for easier comparison
49+
var owned_properties := config.get_owned_properties()\
50+
.map(func(it): return str(it))
51+
expect_equal(owned_properties, properties)
52+
)
53+
3554
on_finish.connect(func():
3655
local_node.queue_free()
3756
remote_node.queue_free()

test/snapshot-fixtures.gd

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ static func state_snapshot(p_position: Vector3 = Vector3.ONE) -> _PropertySnapsh
88
":health": 100.
99
})
1010

11+
static func state_properties() -> Array[String]:
12+
var result: Array[String] = [
13+
":position",
14+
":velocity",
15+
":health"
16+
]
17+
return result
18+
1119
static func state_propery_entries(root_node: Node) -> Array[PropertyEntry]:
1220
var result: Array[PropertyEntry] = []
13-
result.append(PropertyEntry.parse(root_node, ":position"))
14-
result.append(PropertyEntry.parse(root_node, ":velocity"))
15-
result.append(PropertyEntry.parse(root_node, ":health"))
16-
21+
result.assign(state_properties().map(func(path):
22+
return PropertyEntry.parse(root_node, path)
23+
))
1724
return result
1825

1926
static func state_node() -> StateNode:

0 commit comments

Comments
 (0)