nmarshall commited on
Commit
c1edef6
·
1 Parent(s): 04c387a

gameplay: track area portal connectivity

Browse files
crates/urt-gameplay/src/area_portals.rs ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //! Runtime area connectivity with balanced portal references.
2
+ use crate::native_policy::Error;
3
+ use std::collections::BTreeMap;
4
+
5
+ pub struct AreaPortals {
6
+ references: BTreeMap<(usize, usize), u32>,
7
+ labels: Vec<usize>,
8
+ }
9
+
10
+ impl AreaPortals {
11
+ pub fn new(area_count: usize) -> Self {
12
+ Self {
13
+ references: BTreeMap::new(),
14
+ labels: (1..=area_count).collect(),
15
+ }
16
+ }
17
+
18
+ pub fn labels(&self) -> &[usize] {
19
+ &self.labels
20
+ }
21
+
22
+ pub fn connected(&self, a: usize, b: usize) -> Result<bool, Error> {
23
+ let a = self.labels.get(a).ok_or(Error::InvalidIndex)?;
24
+ let b = self.labels.get(b).ok_or(Error::InvalidIndex)?;
25
+ Ok(a == b)
26
+ }
27
+
28
+ pub fn reference_count(&self, a: usize, b: usize) -> Result<u32, Error> {
29
+ self.validate_pair(a, b)?;
30
+ Ok(self
31
+ .references
32
+ .get(&(a.min(b), a.max(b)))
33
+ .copied()
34
+ .unwrap_or(0))
35
+ }
36
+
37
+ /// Open or close one reference. As in the native matrix, a self-portal
38
+ /// contributes twice to its diagonal cell. A missing area is ignored.
39
+ pub fn adjust(&mut self, a: Option<usize>, b: Option<usize>, open: bool) -> Result<(), Error> {
40
+ let Some((a, b)) = a.zip(b) else {
41
+ return Ok(());
42
+ };
43
+ let before = self.reference_count(a, b)?;
44
+ let weight = if a == b { 2 } else { 1 };
45
+ let after = if open {
46
+ before
47
+ .checked_add(weight)
48
+ .filter(|value| *value <= i32::MAX as u32)
49
+ } else {
50
+ before.checked_sub(weight)
51
+ }
52
+ .ok_or(Error::InvalidInput)?;
53
+ let key = (a.min(b), a.max(b));
54
+ if after == 0 {
55
+ self.references.remove(&key);
56
+ } else {
57
+ self.references.insert(key, after);
58
+ }
59
+ if a != b && (before == 0 || after == 0) {
60
+ self.relabel();
61
+ }
62
+ Ok(())
63
+ }
64
+
65
+ fn validate_pair(&self, a: usize, b: usize) -> Result<(), Error> {
66
+ if a.max(b) >= self.labels.len() {
67
+ return Err(Error::InvalidIndex);
68
+ }
69
+ Ok(())
70
+ }
71
+
72
+ fn relabel(&mut self) {
73
+ let mut edges = vec![Vec::new(); self.labels.len()];
74
+ for &(a, b) in self.references.keys() {
75
+ if a != b {
76
+ edges[a].push(b);
77
+ edges[b].push(a);
78
+ }
79
+ }
80
+ self.labels.fill(0);
81
+ let mut component = 0;
82
+ let mut pending = Vec::new();
83
+ for root in 0..self.labels.len() {
84
+ if self.labels[root] != 0 {
85
+ continue;
86
+ }
87
+ component += 1;
88
+ self.labels[root] = component;
89
+ pending.push(root);
90
+ while let Some(area) = pending.pop() {
91
+ for &neighbor in &edges[area] {
92
+ if self.labels[neighbor] == 0 {
93
+ self.labels[neighbor] = component;
94
+ pending.push(neighbor);
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
crates/urt-gameplay/src/bin/urt-area-portals.rs ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ use urt_gameplay::area_portals::AreaPortals;
2
+
3
+ fn main() {
4
+ let mut args = std::env::args()
5
+ .skip(1)
6
+ .map(|value| value.parse::<usize>().unwrap());
7
+ let areas = args.next().unwrap();
8
+ let steps = args.collect::<Vec<_>>();
9
+ let mut portals = AreaPortals::new(areas);
10
+ print!("[");
11
+ for (index, step) in steps.chunks_exact(3).enumerate() {
12
+ if index != 0 {
13
+ print!(",");
14
+ }
15
+ let area = |value| (value != u32::MAX as usize).then_some(value);
16
+ let update = portals.adjust(area(step[0]), area(step[1]), step[2] != 0);
17
+ let counts = (0..areas)
18
+ .flat_map(|a| (0..areas).map(move |b| (a, b)))
19
+ .map(|(a, b)| portals.reference_count(a, b).unwrap())
20
+ .collect::<Vec<_>>();
21
+ let error = update
22
+ .err()
23
+ .map(|error| format!(r#""{error:?}""#))
24
+ .unwrap_or("null".into());
25
+ print!(
26
+ r#"{{"labels":{:?},"matrix":{counts:?},"error":{error}}}"#,
27
+ portals.labels()
28
+ );
29
+ }
30
+ println!("]");
31
+ }
crates/urt-gameplay/src/lib.rs CHANGED
@@ -205,3 +205,5 @@ pub mod effect_feedback;
205
  pub mod location_feedback;
206
 
207
  pub mod spatial_index;
 
 
 
205
  pub mod location_feedback;
206
 
207
  pub mod spatial_index;
208
+
209
+ pub mod area_portals;
docs/FINDINGS.md CHANGED
@@ -2069,3 +2069,5 @@ RE-1034–1043 batch validation passed:2,018 Python tests,339 Rust tests,146 det
2069
  - Location trigger selection can use linked-slot box queries while preserving the caller's cache and fallback list behavior. [Linked location lookup](research/RUST_LINKED_LOCATION.md).
2070
 
2071
  - The Rust BSP reader supplies map-derived leaves and packed cluster visibility, with absent areas and clusters retained from on-disk sentinels. [BSP visibility parity](research/RUST_BSP_VISIBILITY.md).
 
 
 
2069
  - Location trigger selection can use linked-slot box queries while preserving the caller's cache and fallback list behavior. [Linked location lookup](research/RUST_LINKED_LOCATION.md).
2070
 
2071
  - The Rust BSP reader supplies map-derived leaves and packed cluster visibility, with absent areas and clusters retained from on-disk sentinels. [BSP visibility parity](research/RUST_BSP_VISIBILITY.md).
2072
+
2073
+ - The Rust area graph retains connectivity until the last portal reference is closed. [Area portal parity](research/RUST_AREA_PORTALS.md).
docs/PROVISIONAL_TODO.md CHANGED
@@ -2131,3 +2131,5 @@ RE-974–983 completed routing, command rewrite, inactivity, movement-parameter
2131
  - [x] RE-1061 Connect location box queries to the Rust linked-slot index ([evidence](research/RUST_LINKED_LOCATION.md)).
2132
 
2133
  - [x] RE-1062 Decode IBSP point leaves and cluster visibility for Rust spatial queries ([evidence](research/RUST_BSP_VISIBILITY.md)).
 
 
 
2131
  - [x] RE-1061 Connect location box queries to the Rust linked-slot index ([evidence](research/RUST_LINKED_LOCATION.md)).
2132
 
2133
  - [x] RE-1062 Decode IBSP point leaves and cluster visibility for Rust spatial queries ([evidence](research/RUST_BSP_VISIBILITY.md)).
2134
+
2135
+ - [x] RE-1063 Port linked area connectivity and balanced portal reference updates ([evidence](research/RUST_AREA_PORTALS.md)).
docs/RESEARCH_LEDGER.md CHANGED
@@ -2923,3 +2923,7 @@ The Rust location selector now accepts linked slot candidates from its spatial i
2923
  ## 2026-11-25 — RE-1062 Decode IBSP point leaves and cluster visibility for Rust spatial queries
2924
 
2925
  The Rust asset reader consumes the collision tree and visibility row data from three shipped BSP maps. Fifty-four point leaves and 972 directed cluster lookups match the independent reader. See [BSP visibility parity](research/RUST_BSP_VISIBILITY.md).
 
 
 
 
 
2923
  ## 2026-11-25 — RE-1062 Decode IBSP point leaves and cluster visibility for Rust spatial queries
2924
 
2925
  The Rust asset reader consumes the collision tree and visibility row data from three shipped BSP maps. Fifty-four point leaves and 972 directed cluster lookups match the independent reader. See [BSP visibility parity](research/RUST_BSP_VISIBILITY.md).
2926
+
2927
+ ## 2026-11-25 — RE-1063 Port linked area connectivity and balanced portal reference updates
2928
+
2929
+ Rust matches all 18 traced portal updates, including repeated opens, self-pairs and removal of the last connecting edge. See [area portal parity](research/RUST_AREA_PORTALS.md).
docs/research/README.md CHANGED
@@ -1697,3 +1697,5 @@ The extension collector adds five focused tests for native tail calls, command-r
1697
  - [Location lookup over linked slots](RUST_LINKED_LOCATION.md)
1698
 
1699
  - [IBSP point leaves and cluster visibility in Rust](RUST_BSP_VISIBILITY.md)
 
 
 
1697
  - [Location lookup over linked slots](RUST_LINKED_LOCATION.md)
1698
 
1699
  - [IBSP point leaves and cluster visibility in Rust](RUST_BSP_VISIBILITY.md)
1700
+
1701
+ - [Rust area portal connectivity](RUST_AREA_PORTALS.md)
docs/research/RUST_AREA_PORTALS.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Rust area portal connectivity
2
+
3
+ `AreaPortals` keeps one reference counter for each undirected pair. Added references preserve connectivity until the last close. A self-portal contributes twice to its diagonal counter and leaves connectivity intact. Missing areas are ignored. An unmatched close or an out-of-range index rejects before mutating state.
4
+
5
+ Connectivity labels are rebuilt in ascending area order when a new edge opens or the last reference closes. The [parity report](rust-area-portals.json) reproduces the counters and labels across all 18 portal updates traced in the two native engines, including repeated opens and chain splits. Rust exposes stable connectivity labels for the current graph. Native flood epoch stamps and actual portal ownership remain outside this API.
docs/research/rust-area-portals.json ADDED
@@ -0,0 +1,1034 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "limits": "Valid symmetric native portal sequences plus typed Rust boundary cases. Native epoch words are not part of this API.",
3
+ "probes": [
4
+ {
5
+ "engine": "linux--Quake3-UrT-Ded.x86_64",
6
+ "rust": [
7
+ {
8
+ "error": null,
9
+ "labels": [
10
+ 1,
11
+ 1,
12
+ 2,
13
+ 3
14
+ ],
15
+ "matrix": [
16
+ 0,
17
+ 1,
18
+ 0,
19
+ 0,
20
+ 1,
21
+ 0,
22
+ 0,
23
+ 0,
24
+ 0,
25
+ 0,
26
+ 0,
27
+ 0,
28
+ 0,
29
+ 0,
30
+ 0,
31
+ 0
32
+ ]
33
+ },
34
+ {
35
+ "error": null,
36
+ "labels": [
37
+ 1,
38
+ 1,
39
+ 2,
40
+ 3
41
+ ],
42
+ "matrix": [
43
+ 0,
44
+ 2,
45
+ 0,
46
+ 0,
47
+ 2,
48
+ 0,
49
+ 0,
50
+ 0,
51
+ 0,
52
+ 0,
53
+ 0,
54
+ 0,
55
+ 0,
56
+ 0,
57
+ 0,
58
+ 0
59
+ ]
60
+ },
61
+ {
62
+ "error": null,
63
+ "labels": [
64
+ 1,
65
+ 1,
66
+ 2,
67
+ 3
68
+ ],
69
+ "matrix": [
70
+ 0,
71
+ 1,
72
+ 0,
73
+ 0,
74
+ 1,
75
+ 0,
76
+ 0,
77
+ 0,
78
+ 0,
79
+ 0,
80
+ 0,
81
+ 0,
82
+ 0,
83
+ 0,
84
+ 0,
85
+ 0
86
+ ]
87
+ },
88
+ {
89
+ "error": null,
90
+ "labels": [
91
+ 1,
92
+ 1,
93
+ 1,
94
+ 2
95
+ ],
96
+ "matrix": [
97
+ 0,
98
+ 1,
99
+ 0,
100
+ 0,
101
+ 1,
102
+ 0,
103
+ 1,
104
+ 0,
105
+ 0,
106
+ 1,
107
+ 0,
108
+ 0,
109
+ 0,
110
+ 0,
111
+ 0,
112
+ 0
113
+ ]
114
+ },
115
+ {
116
+ "error": null,
117
+ "labels": [
118
+ 1,
119
+ 1,
120
+ 1,
121
+ 1
122
+ ],
123
+ "matrix": [
124
+ 0,
125
+ 1,
126
+ 0,
127
+ 0,
128
+ 1,
129
+ 0,
130
+ 1,
131
+ 0,
132
+ 0,
133
+ 1,
134
+ 0,
135
+ 1,
136
+ 0,
137
+ 0,
138
+ 1,
139
+ 0
140
+ ]
141
+ },
142
+ {
143
+ "error": null,
144
+ "labels": [
145
+ 1,
146
+ 2,
147
+ 2,
148
+ 2
149
+ ],
150
+ "matrix": [
151
+ 0,
152
+ 0,
153
+ 0,
154
+ 0,
155
+ 0,
156
+ 0,
157
+ 1,
158
+ 0,
159
+ 0,
160
+ 1,
161
+ 0,
162
+ 1,
163
+ 0,
164
+ 0,
165
+ 1,
166
+ 0
167
+ ]
168
+ },
169
+ {
170
+ "error": null,
171
+ "labels": [
172
+ 1,
173
+ 2,
174
+ 2,
175
+ 3
176
+ ],
177
+ "matrix": [
178
+ 0,
179
+ 0,
180
+ 0,
181
+ 0,
182
+ 0,
183
+ 0,
184
+ 1,
185
+ 0,
186
+ 0,
187
+ 1,
188
+ 0,
189
+ 0,
190
+ 0,
191
+ 0,
192
+ 0,
193
+ 0
194
+ ]
195
+ },
196
+ {
197
+ "error": null,
198
+ "labels": [
199
+ 1,
200
+ 2,
201
+ 2,
202
+ 3
203
+ ],
204
+ "matrix": [
205
+ 2,
206
+ 0,
207
+ 0,
208
+ 0,
209
+ 0,
210
+ 0,
211
+ 1,
212
+ 0,
213
+ 0,
214
+ 1,
215
+ 0,
216
+ 0,
217
+ 0,
218
+ 0,
219
+ 0,
220
+ 0
221
+ ]
222
+ },
223
+ {
224
+ "error": null,
225
+ "labels": [
226
+ 1,
227
+ 2,
228
+ 2,
229
+ 3
230
+ ],
231
+ "matrix": [
232
+ 0,
233
+ 0,
234
+ 0,
235
+ 0,
236
+ 0,
237
+ 0,
238
+ 1,
239
+ 0,
240
+ 0,
241
+ 1,
242
+ 0,
243
+ 0,
244
+ 0,
245
+ 0,
246
+ 0,
247
+ 0
248
+ ]
249
+ }
250
+ ],
251
+ "source": [
252
+ {
253
+ "error": null,
254
+ "labels": [
255
+ 1,
256
+ 1,
257
+ 2,
258
+ 3
259
+ ],
260
+ "matrix": [
261
+ 0,
262
+ 1,
263
+ 0,
264
+ 0,
265
+ 1,
266
+ 0,
267
+ 0,
268
+ 0,
269
+ 0,
270
+ 0,
271
+ 0,
272
+ 0,
273
+ 0,
274
+ 0,
275
+ 0,
276
+ 0
277
+ ]
278
+ },
279
+ {
280
+ "error": null,
281
+ "labels": [
282
+ 1,
283
+ 1,
284
+ 2,
285
+ 3
286
+ ],
287
+ "matrix": [
288
+ 0,
289
+ 2,
290
+ 0,
291
+ 0,
292
+ 2,
293
+ 0,
294
+ 0,
295
+ 0,
296
+ 0,
297
+ 0,
298
+ 0,
299
+ 0,
300
+ 0,
301
+ 0,
302
+ 0,
303
+ 0
304
+ ]
305
+ },
306
+ {
307
+ "error": null,
308
+ "labels": [
309
+ 1,
310
+ 1,
311
+ 2,
312
+ 3
313
+ ],
314
+ "matrix": [
315
+ 0,
316
+ 1,
317
+ 0,
318
+ 0,
319
+ 1,
320
+ 0,
321
+ 0,
322
+ 0,
323
+ 0,
324
+ 0,
325
+ 0,
326
+ 0,
327
+ 0,
328
+ 0,
329
+ 0,
330
+ 0
331
+ ]
332
+ },
333
+ {
334
+ "error": null,
335
+ "labels": [
336
+ 1,
337
+ 1,
338
+ 1,
339
+ 2
340
+ ],
341
+ "matrix": [
342
+ 0,
343
+ 1,
344
+ 0,
345
+ 0,
346
+ 1,
347
+ 0,
348
+ 1,
349
+ 0,
350
+ 0,
351
+ 1,
352
+ 0,
353
+ 0,
354
+ 0,
355
+ 0,
356
+ 0,
357
+ 0
358
+ ]
359
+ },
360
+ {
361
+ "error": null,
362
+ "labels": [
363
+ 1,
364
+ 1,
365
+ 1,
366
+ 1
367
+ ],
368
+ "matrix": [
369
+ 0,
370
+ 1,
371
+ 0,
372
+ 0,
373
+ 1,
374
+ 0,
375
+ 1,
376
+ 0,
377
+ 0,
378
+ 1,
379
+ 0,
380
+ 1,
381
+ 0,
382
+ 0,
383
+ 1,
384
+ 0
385
+ ]
386
+ },
387
+ {
388
+ "error": null,
389
+ "labels": [
390
+ 1,
391
+ 2,
392
+ 2,
393
+ 2
394
+ ],
395
+ "matrix": [
396
+ 0,
397
+ 0,
398
+ 0,
399
+ 0,
400
+ 0,
401
+ 0,
402
+ 1,
403
+ 0,
404
+ 0,
405
+ 1,
406
+ 0,
407
+ 1,
408
+ 0,
409
+ 0,
410
+ 1,
411
+ 0
412
+ ]
413
+ },
414
+ {
415
+ "error": null,
416
+ "labels": [
417
+ 1,
418
+ 2,
419
+ 2,
420
+ 3
421
+ ],
422
+ "matrix": [
423
+ 0,
424
+ 0,
425
+ 0,
426
+ 0,
427
+ 0,
428
+ 0,
429
+ 1,
430
+ 0,
431
+ 0,
432
+ 1,
433
+ 0,
434
+ 0,
435
+ 0,
436
+ 0,
437
+ 0,
438
+ 0
439
+ ]
440
+ },
441
+ {
442
+ "error": null,
443
+ "labels": [
444
+ 1,
445
+ 2,
446
+ 2,
447
+ 3
448
+ ],
449
+ "matrix": [
450
+ 2,
451
+ 0,
452
+ 0,
453
+ 0,
454
+ 0,
455
+ 0,
456
+ 1,
457
+ 0,
458
+ 0,
459
+ 1,
460
+ 0,
461
+ 0,
462
+ 0,
463
+ 0,
464
+ 0,
465
+ 0
466
+ ]
467
+ },
468
+ {
469
+ "error": null,
470
+ "labels": [
471
+ 1,
472
+ 2,
473
+ 2,
474
+ 3
475
+ ],
476
+ "matrix": [
477
+ 0,
478
+ 0,
479
+ 0,
480
+ 0,
481
+ 0,
482
+ 0,
483
+ 1,
484
+ 0,
485
+ 0,
486
+ 1,
487
+ 0,
488
+ 0,
489
+ 0,
490
+ 0,
491
+ 0,
492
+ 0
493
+ ]
494
+ }
495
+ ]
496
+ },
497
+ {
498
+ "engine": "linux--Quake3-UrT.x86_64",
499
+ "rust": [
500
+ {
501
+ "error": null,
502
+ "labels": [
503
+ 1,
504
+ 1,
505
+ 2,
506
+ 3
507
+ ],
508
+ "matrix": [
509
+ 0,
510
+ 1,
511
+ 0,
512
+ 0,
513
+ 1,
514
+ 0,
515
+ 0,
516
+ 0,
517
+ 0,
518
+ 0,
519
+ 0,
520
+ 0,
521
+ 0,
522
+ 0,
523
+ 0,
524
+ 0
525
+ ]
526
+ },
527
+ {
528
+ "error": null,
529
+ "labels": [
530
+ 1,
531
+ 1,
532
+ 2,
533
+ 3
534
+ ],
535
+ "matrix": [
536
+ 0,
537
+ 2,
538
+ 0,
539
+ 0,
540
+ 2,
541
+ 0,
542
+ 0,
543
+ 0,
544
+ 0,
545
+ 0,
546
+ 0,
547
+ 0,
548
+ 0,
549
+ 0,
550
+ 0,
551
+ 0
552
+ ]
553
+ },
554
+ {
555
+ "error": null,
556
+ "labels": [
557
+ 1,
558
+ 1,
559
+ 2,
560
+ 3
561
+ ],
562
+ "matrix": [
563
+ 0,
564
+ 1,
565
+ 0,
566
+ 0,
567
+ 1,
568
+ 0,
569
+ 0,
570
+ 0,
571
+ 0,
572
+ 0,
573
+ 0,
574
+ 0,
575
+ 0,
576
+ 0,
577
+ 0,
578
+ 0
579
+ ]
580
+ },
581
+ {
582
+ "error": null,
583
+ "labels": [
584
+ 1,
585
+ 1,
586
+ 1,
587
+ 2
588
+ ],
589
+ "matrix": [
590
+ 0,
591
+ 1,
592
+ 0,
593
+ 0,
594
+ 1,
595
+ 0,
596
+ 1,
597
+ 0,
598
+ 0,
599
+ 1,
600
+ 0,
601
+ 0,
602
+ 0,
603
+ 0,
604
+ 0,
605
+ 0
606
+ ]
607
+ },
608
+ {
609
+ "error": null,
610
+ "labels": [
611
+ 1,
612
+ 1,
613
+ 1,
614
+ 1
615
+ ],
616
+ "matrix": [
617
+ 0,
618
+ 1,
619
+ 0,
620
+ 0,
621
+ 1,
622
+ 0,
623
+ 1,
624
+ 0,
625
+ 0,
626
+ 1,
627
+ 0,
628
+ 1,
629
+ 0,
630
+ 0,
631
+ 1,
632
+ 0
633
+ ]
634
+ },
635
+ {
636
+ "error": null,
637
+ "labels": [
638
+ 1,
639
+ 2,
640
+ 2,
641
+ 2
642
+ ],
643
+ "matrix": [
644
+ 0,
645
+ 0,
646
+ 0,
647
+ 0,
648
+ 0,
649
+ 0,
650
+ 1,
651
+ 0,
652
+ 0,
653
+ 1,
654
+ 0,
655
+ 1,
656
+ 0,
657
+ 0,
658
+ 1,
659
+ 0
660
+ ]
661
+ },
662
+ {
663
+ "error": null,
664
+ "labels": [
665
+ 1,
666
+ 2,
667
+ 2,
668
+ 3
669
+ ],
670
+ "matrix": [
671
+ 0,
672
+ 0,
673
+ 0,
674
+ 0,
675
+ 0,
676
+ 0,
677
+ 1,
678
+ 0,
679
+ 0,
680
+ 1,
681
+ 0,
682
+ 0,
683
+ 0,
684
+ 0,
685
+ 0,
686
+ 0
687
+ ]
688
+ },
689
+ {
690
+ "error": null,
691
+ "labels": [
692
+ 1,
693
+ 2,
694
+ 2,
695
+ 3
696
+ ],
697
+ "matrix": [
698
+ 2,
699
+ 0,
700
+ 0,
701
+ 0,
702
+ 0,
703
+ 0,
704
+ 1,
705
+ 0,
706
+ 0,
707
+ 1,
708
+ 0,
709
+ 0,
710
+ 0,
711
+ 0,
712
+ 0,
713
+ 0
714
+ ]
715
+ },
716
+ {
717
+ "error": null,
718
+ "labels": [
719
+ 1,
720
+ 2,
721
+ 2,
722
+ 3
723
+ ],
724
+ "matrix": [
725
+ 0,
726
+ 0,
727
+ 0,
728
+ 0,
729
+ 0,
730
+ 0,
731
+ 1,
732
+ 0,
733
+ 0,
734
+ 1,
735
+ 0,
736
+ 0,
737
+ 0,
738
+ 0,
739
+ 0,
740
+ 0
741
+ ]
742
+ }
743
+ ],
744
+ "source": [
745
+ {
746
+ "error": null,
747
+ "labels": [
748
+ 1,
749
+ 1,
750
+ 2,
751
+ 3
752
+ ],
753
+ "matrix": [
754
+ 0,
755
+ 1,
756
+ 0,
757
+ 0,
758
+ 1,
759
+ 0,
760
+ 0,
761
+ 0,
762
+ 0,
763
+ 0,
764
+ 0,
765
+ 0,
766
+ 0,
767
+ 0,
768
+ 0,
769
+ 0
770
+ ]
771
+ },
772
+ {
773
+ "error": null,
774
+ "labels": [
775
+ 1,
776
+ 1,
777
+ 2,
778
+ 3
779
+ ],
780
+ "matrix": [
781
+ 0,
782
+ 2,
783
+ 0,
784
+ 0,
785
+ 2,
786
+ 0,
787
+ 0,
788
+ 0,
789
+ 0,
790
+ 0,
791
+ 0,
792
+ 0,
793
+ 0,
794
+ 0,
795
+ 0,
796
+ 0
797
+ ]
798
+ },
799
+ {
800
+ "error": null,
801
+ "labels": [
802
+ 1,
803
+ 1,
804
+ 2,
805
+ 3
806
+ ],
807
+ "matrix": [
808
+ 0,
809
+ 1,
810
+ 0,
811
+ 0,
812
+ 1,
813
+ 0,
814
+ 0,
815
+ 0,
816
+ 0,
817
+ 0,
818
+ 0,
819
+ 0,
820
+ 0,
821
+ 0,
822
+ 0,
823
+ 0
824
+ ]
825
+ },
826
+ {
827
+ "error": null,
828
+ "labels": [
829
+ 1,
830
+ 1,
831
+ 1,
832
+ 2
833
+ ],
834
+ "matrix": [
835
+ 0,
836
+ 1,
837
+ 0,
838
+ 0,
839
+ 1,
840
+ 0,
841
+ 1,
842
+ 0,
843
+ 0,
844
+ 1,
845
+ 0,
846
+ 0,
847
+ 0,
848
+ 0,
849
+ 0,
850
+ 0
851
+ ]
852
+ },
853
+ {
854
+ "error": null,
855
+ "labels": [
856
+ 1,
857
+ 1,
858
+ 1,
859
+ 1
860
+ ],
861
+ "matrix": [
862
+ 0,
863
+ 1,
864
+ 0,
865
+ 0,
866
+ 1,
867
+ 0,
868
+ 1,
869
+ 0,
870
+ 0,
871
+ 1,
872
+ 0,
873
+ 1,
874
+ 0,
875
+ 0,
876
+ 1,
877
+ 0
878
+ ]
879
+ },
880
+ {
881
+ "error": null,
882
+ "labels": [
883
+ 1,
884
+ 2,
885
+ 2,
886
+ 2
887
+ ],
888
+ "matrix": [
889
+ 0,
890
+ 0,
891
+ 0,
892
+ 0,
893
+ 0,
894
+ 0,
895
+ 1,
896
+ 0,
897
+ 0,
898
+ 1,
899
+ 0,
900
+ 1,
901
+ 0,
902
+ 0,
903
+ 1,
904
+ 0
905
+ ]
906
+ },
907
+ {
908
+ "error": null,
909
+ "labels": [
910
+ 1,
911
+ 2,
912
+ 2,
913
+ 3
914
+ ],
915
+ "matrix": [
916
+ 0,
917
+ 0,
918
+ 0,
919
+ 0,
920
+ 0,
921
+ 0,
922
+ 1,
923
+ 0,
924
+ 0,
925
+ 1,
926
+ 0,
927
+ 0,
928
+ 0,
929
+ 0,
930
+ 0,
931
+ 0
932
+ ]
933
+ },
934
+ {
935
+ "error": null,
936
+ "labels": [
937
+ 1,
938
+ 2,
939
+ 2,
940
+ 3
941
+ ],
942
+ "matrix": [
943
+ 2,
944
+ 0,
945
+ 0,
946
+ 0,
947
+ 0,
948
+ 0,
949
+ 1,
950
+ 0,
951
+ 0,
952
+ 1,
953
+ 0,
954
+ 0,
955
+ 0,
956
+ 0,
957
+ 0,
958
+ 0
959
+ ]
960
+ },
961
+ {
962
+ "error": null,
963
+ "labels": [
964
+ 1,
965
+ 2,
966
+ 2,
967
+ 3
968
+ ],
969
+ "matrix": [
970
+ 0,
971
+ 0,
972
+ 0,
973
+ 0,
974
+ 0,
975
+ 0,
976
+ 1,
977
+ 0,
978
+ 0,
979
+ 1,
980
+ 0,
981
+ 0,
982
+ 0,
983
+ 0,
984
+ 0,
985
+ 0
986
+ ]
987
+ }
988
+ ]
989
+ }
990
+ ],
991
+ "source_report": "docs/research/area-flooding.json",
992
+ "source_report_sha256": "68606c4d5878a7ec8f9cd8fc3f2ce601887a6b3c365e46e3a0403a09f5ac7307",
993
+ "typed_edges": [
994
+ {
995
+ "error": "InvalidInput",
996
+ "labels": [
997
+ 1,
998
+ 2
999
+ ],
1000
+ "matrix": [
1001
+ 0,
1002
+ 0,
1003
+ 0,
1004
+ 0
1005
+ ]
1006
+ },
1007
+ {
1008
+ "error": "InvalidIndex",
1009
+ "labels": [
1010
+ 1,
1011
+ 2
1012
+ ],
1013
+ "matrix": [
1014
+ 0,
1015
+ 0,
1016
+ 0,
1017
+ 0
1018
+ ]
1019
+ },
1020
+ {
1021
+ "error": null,
1022
+ "labels": [
1023
+ 1,
1024
+ 2
1025
+ ],
1026
+ "matrix": [
1027
+ 0,
1028
+ 0,
1029
+ 0,
1030
+ 0
1031
+ ]
1032
+ }
1033
+ ]
1034
+ }
scripts/analyze_rust_area_portals.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Replay paired source portal sequences through the Rust connectivity service."""
2
+ import hashlib
3
+ import json
4
+ import os
5
+ import subprocess
6
+ from pathlib import Path
7
+
8
+ from analyze_qvm import write_json
9
+
10
+
11
+ def replay(binary, areas, steps):
12
+ args = [str(binary), str(areas), *(str(i & 0xffffffff) for step in steps for i in step)]
13
+ return json.loads(subprocess.run(args, check=True, capture_output=True, text=True).stdout)
14
+
15
+
16
+ def main():
17
+ subprocess.run(['cargo', 'build', '--offline', '-p', 'urt-gameplay', '--bin',
18
+ 'urt-area-portals'], check=True)
19
+ binary = Path(os.environ.get('CARGO_TARGET_DIR', 'target')) / 'debug' / 'urt-area-portals'
20
+ source = Path('docs/research/area-flooding.json')
21
+ data = source.read_bytes()
22
+ probes = []
23
+ for engine, body in json.loads(data)['native'].items():
24
+ steps = body['portal_sequence']
25
+ expected = [dict(labels=row['labels'], matrix=row['matrix_words'], error=None) for row in steps]
26
+ rust = replay(binary, 4, [(r['area1'], r['area2'], r['open_word']) for r in steps])
27
+ probes.append(dict(engine=engine, source=expected, rust=rust))
28
+ edges = replay(binary, 2, [(0, 1, 0), (2, 1, 1), (0xffffffff, 1, 1)])
29
+ write_json(Path('docs/research/rust-area-portals.json'), {
30
+ 'source_report': str(source), 'source_report_sha256': hashlib.sha256(data).hexdigest(),
31
+ 'probes': probes, 'typed_edges': edges,
32
+ 'limits': 'Valid symmetric native portal sequences plus typed Rust boundary cases. Native epoch words are not part of this API.',
33
+ })
34
+
35
+
36
+ if __name__ == '__main__':
37
+ main()
scripts/test_rust_area_portals.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ import json
3
+ import unittest
4
+ from pathlib import Path
5
+
6
+
7
+ class AreaPortalTests(unittest.TestCase):
8
+ def test_source_sequences_and_safe_invalid_updates(self):
9
+ report = json.loads(Path('docs/research/rust-area-portals.json').read_text())
10
+ sha = hashlib.sha256(Path(report['source_report']).read_bytes()).hexdigest()
11
+ self.assertEqual(report['source_report_sha256'], sha)
12
+ self.assertEqual(len(report['probes']), 2)
13
+ for row in report['probes']:
14
+ with self.subTest(engine=row['engine']):
15
+ self.assertEqual(len(row['source']), 9)
16
+ self.assertEqual(row['rust'], row['source'])
17
+ self.assertEqual(report['typed_edges'], [
18
+ dict(labels=[1, 2], matrix=[0, 0, 0, 0], error=error)
19
+ for error in ('InvalidInput', 'InvalidIndex', None)
20
+ ])
21
+
22
+
23
+ if __name__ == '__main__':
24
+ unittest.main()
xtask/checks.tsv CHANGED
@@ -4910,3 +4910,12 @@ edge crates/urt-assets/src/bin/urt-bsp-visibility.rs scripts/analyze_rust_bsp_vi
4910
  edge assets/extracted/zUrT43_004.pk3/members/000006/maps/ut4_tombs.bsp scripts/analyze_rust_bsp_visibility.py
4911
  edge assets/extracted/zUrT43_004.pk3/members/000016/maps/ut4_uptown.bsp scripts/analyze_rust_bsp_visibility.py
4912
  edge assets/extracted/zUrT43_021.pk3/members/000002/maps/ut4_paris.bsp scripts/analyze_rust_bsp_visibility.py
 
 
 
 
 
 
 
 
 
 
4910
  edge assets/extracted/zUrT43_004.pk3/members/000006/maps/ut4_tombs.bsp scripts/analyze_rust_bsp_visibility.py
4911
  edge assets/extracted/zUrT43_004.pk3/members/000016/maps/ut4_uptown.bsp scripts/analyze_rust_bsp_visibility.py
4912
  edge assets/extracted/zUrT43_021.pk3/members/000002/maps/ut4_paris.bsp scripts/analyze_rust_bsp_visibility.py
4913
+ report scripts/analyze_rust_area_portals.py docs/research/rust-area-portals.json
4914
+ edge docs/research/rust-area-portals.json scripts/test_rust_area_portals.py
4915
+ edge docs/research/area-flooding.json scripts/analyze_rust_area_portals.py
4916
+ group rust-area-portals scripts/analyze_rust_area_portals.py
4917
+ group rust-area-portals scripts/test_area_flooding.py
4918
+ group gameplay scripts/analyze_rust_area_portals.py
4919
+ edge crates/urt-gameplay/src/area_portals.rs scripts/analyze_rust_area_portals.py
4920
+ edge crates/urt-gameplay/src/bin/urt-area-portals.rs scripts/analyze_rust_area_portals.py
4921
+ edge crates/urt-gameplay/src/area_portals.rs scripts/analyze_rust_health_impulse.py