Skip to main content

runec/
pointer.rs

1use std::collections::HashMap;
2use std::fmt;
3use std::sync::OnceLock;
4
5/// The pointer types tracked by the script pointer checker.
6///
7/// Each variant maps to a bit position in [`PointerSet`] and has a display
8/// name matching the reference TypeScript implementation.
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10#[repr(u8)]
11pub enum PointerType {
12    ActivePlayer = 0,
13    ActivePlayer2 = 1,
14    PActivePlayer = 2,
15    PActivePlayer2 = 3,
16    ActiveNpc = 4,
17    ActiveNpc2 = 5,
18    ActiveLoc = 6,
19    ActiveLoc2 = 7,
20    ActiveObj = 8,
21    ActiveObj2 = 9,
22    FindPlayer = 10,
23    FindNpc = 11,
24    FindLoc = 12,
25    FindObj = 13,
26    FindDb = 14,
27    LastCom = 15,
28    LastInt = 16,
29    LastItem = 17,
30    LastSlot = 18,
31    LastTargetslot = 19,
32    LastUseitem = 20,
33    LastUseslot = 21,
34    ActiveComponent = 22,
35    ActiveComponent2 = 23,
36    ActiveController = 24,
37    ActiveController2 = 25,
38    ActiveRegion = 26,
39    ActiveRegion2 = 27,
40}
41
42impl PointerType {
43    pub const COUNT: usize = 28;
44
45    pub const ALL: [PointerType; Self::COUNT] = [
46        PointerType::ActivePlayer,
47        PointerType::ActivePlayer2,
48        PointerType::PActivePlayer,
49        PointerType::PActivePlayer2,
50        PointerType::ActiveNpc,
51        PointerType::ActiveNpc2,
52        PointerType::ActiveLoc,
53        PointerType::ActiveLoc2,
54        PointerType::ActiveObj,
55        PointerType::ActiveObj2,
56        PointerType::FindPlayer,
57        PointerType::FindNpc,
58        PointerType::FindLoc,
59        PointerType::FindObj,
60        PointerType::FindDb,
61        PointerType::LastCom,
62        PointerType::LastInt,
63        PointerType::LastItem,
64        PointerType::LastSlot,
65        PointerType::LastTargetslot,
66        PointerType::LastUseitem,
67        PointerType::LastUseslot,
68        PointerType::ActiveComponent,
69        PointerType::ActiveComponent2,
70        PointerType::ActiveController,
71        PointerType::ActiveController2,
72        PointerType::ActiveRegion,
73        PointerType::ActiveRegion2,
74    ];
75
76    /// The representation string used in diagnostics, matching the TS reference.
77    pub fn representation(self) -> &'static str {
78        match self {
79            PointerType::ActivePlayer => "active_player",
80            PointerType::ActivePlayer2 => ".active_player",
81            PointerType::PActivePlayer => "p_active_player",
82            PointerType::PActivePlayer2 => ".p_active_player",
83            PointerType::ActiveNpc => "active_npc",
84            PointerType::ActiveNpc2 => ".active_npc",
85            PointerType::ActiveLoc => "active_loc",
86            PointerType::ActiveLoc2 => ".active_loc",
87            PointerType::ActiveObj => "active_obj",
88            PointerType::ActiveObj2 => ".active_obj",
89            PointerType::FindPlayer => "find_player",
90            PointerType::FindNpc => "find_npc",
91            PointerType::FindLoc => "find_loc",
92            PointerType::FindObj => "find_obj",
93            PointerType::FindDb => "find_db",
94            PointerType::LastCom => "last_com",
95            PointerType::LastInt => "last_int",
96            PointerType::LastItem => "last_item",
97            PointerType::LastSlot => "last_slot",
98            PointerType::LastTargetslot => "last_targetslot",
99            PointerType::LastUseitem => "last_useitem",
100            PointerType::LastUseslot => "last_useslot",
101            PointerType::ActiveComponent => "active_component",
102            PointerType::ActiveComponent2 => ".active_component",
103            PointerType::ActiveController => "active_controller",
104            PointerType::ActiveController2 => ".active_controller",
105            PointerType::ActiveRegion => "active_region",
106            PointerType::ActiveRegion2 => ".active_region",
107        }
108    }
109
110    pub fn index(self) -> usize {
111        self as usize
112    }
113
114    /// Look up a pointer type by its lowercase name (e.g. "active_player",
115    /// ".active_player", "p_active_player").
116    pub fn from_name(name: &str) -> Option<PointerType> {
117        let lower = name.to_lowercase();
118        Self::ALL
119            .iter()
120            .find(|&&ptr| ptr.representation() == lower)
121            .copied()
122    }
123}
124
125impl fmt::Display for PointerType {
126    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
127        f.write_str(self.representation())
128    }
129}
130
131// ---------------------------------------------------------------------------
132// PointerSet: bitmask for efficient pointer set operations
133// ---------------------------------------------------------------------------
134
135#[derive(Clone, Copy, Default, PartialEq, Eq, Debug)]
136pub struct PointerSet(u32);
137
138impl PointerSet {
139    pub fn new() -> Self {
140        PointerSet(0)
141    }
142
143    /// A set containing every pointer type.
144    pub fn all() -> Self {
145        PointerSet((1u32 << PointerType::COUNT) - 1)
146    }
147
148    pub fn insert(&mut self, ptr: PointerType) {
149        self.0 |= 1u32 << ptr.index();
150    }
151
152    pub fn remove(&mut self, ptr: PointerType) {
153        self.0 &= !(1u32 << ptr.index());
154    }
155
156    pub fn contains(self, ptr: PointerType) -> bool {
157        (self.0 & (1u32 << ptr.index())) != 0
158    }
159
160    pub fn union(self, other: PointerSet) -> PointerSet {
161        PointerSet(self.0 | other.0)
162    }
163
164    pub fn is_empty(self) -> bool {
165        self.0 == 0
166    }
167
168    pub fn iter(self) -> PointerSetIter {
169        PointerSetIter { bits: self.0 }
170    }
171}
172
173pub struct PointerSetIter {
174    bits: u32,
175}
176
177impl Iterator for PointerSetIter {
178    type Item = PointerType;
179
180    fn next(&mut self) -> Option<Self::Item> {
181        if self.bits == 0 {
182            return None;
183        }
184        let idx = self.bits.trailing_zeros() as usize;
185        self.bits &= self.bits - 1; // clear lowest bit
186        if idx < PointerType::COUNT {
187            Some(PointerType::ALL[idx])
188        } else {
189            None
190        }
191    }
192}
193
194impl FromIterator<PointerType> for PointerSet {
195    fn from_iter<T: IntoIterator<Item = PointerType>>(iter: T) -> Self {
196        let mut set = PointerSet::new();
197        for ptr in iter {
198            set.insert(ptr);
199        }
200        set
201    }
202}
203
204// ---------------------------------------------------------------------------
205// PointerHolder — describes a command's pointer requirements
206// ---------------------------------------------------------------------------
207
208#[derive(Clone, Debug, Default)]
209pub struct PointerHolder {
210    pub required: PointerSet,
211    pub set: PointerSet,
212    pub conditional_set: bool,
213    pub corrupted: PointerSet,
214    pub may_suspend: bool,
215}
216
217// ---------------------------------------------------------------------------
218// trigger_pointers — which pointers a trigger type initializes
219// ---------------------------------------------------------------------------
220
221/// Returns the set of pointers that are initialized when a script with the
222/// given trigger type begins execution. Matches `ServerTriggerType.ts`.
223pub fn trigger_pointers(trigger: &str) -> PointerSet {
224    use PointerType::*;
225
226    let ptrs: &[PointerType] = match trigger {
227        // proc and label get ALL pointers (they inherit from caller)
228        "proc" | "label" => return PointerSet::all(),
229
230        // debugproc gets only active_player (console command context)
231        "debugproc" => &[ActivePlayer],
232
233        // Player-NPC approach/operate triggers
234        "apnpc1" | "apnpc2" | "apnpc3" | "apnpc4" | "apnpc5" => {
235            &[ActivePlayer, PActivePlayer, ActiveNpc]
236        }
237        "apnpcu" => &[
238            ActivePlayer,
239            PActivePlayer,
240            LastUseitem,
241            LastUseslot,
242            ActiveNpc,
243        ],
244        "apnpct" => &[ActivePlayer, PActivePlayer, ActiveNpc],
245        "opnpc1" | "opnpc2" | "opnpc3" | "opnpc4" | "opnpc5" => {
246            &[ActivePlayer, PActivePlayer, ActiveNpc]
247        }
248        "opnpcu" => &[
249            ActivePlayer,
250            PActivePlayer,
251            LastUseitem,
252            LastUseslot,
253            ActiveNpc,
254        ],
255        "opnpct" => &[ActivePlayer, PActivePlayer, ActiveNpc],
256
257        // AI NPC triggers (NPC vs NPC)
258        "ai_apnpc1" | "ai_apnpc2" | "ai_apnpc3" | "ai_apnpc4" | "ai_apnpc5" => {
259            &[ActiveNpc, ActiveNpc2]
260        }
261        "ai_opnpc1" | "ai_opnpc2" | "ai_opnpc3" | "ai_opnpc4" | "ai_opnpc5" => {
262            &[ActiveNpc, ActiveNpc2]
263        }
264
265        // Player-Obj approach/operate triggers
266        "apobj1" | "apobj2" | "apobj3" | "apobj4" | "apobj5" => {
267            &[ActivePlayer, PActivePlayer, ActiveObj]
268        }
269        "apobju" => &[
270            ActivePlayer,
271            PActivePlayer,
272            LastUseitem,
273            LastUseslot,
274            ActiveObj,
275        ],
276        "apobjt" => &[ActivePlayer, PActivePlayer, ActiveObj],
277        "opobj1" | "opobj2" | "opobj3" | "opobj4" | "opobj5" => {
278            &[ActivePlayer, PActivePlayer, ActiveObj]
279        }
280        "opobju" => &[
281            ActivePlayer,
282            PActivePlayer,
283            LastUseitem,
284            LastUseslot,
285            ActiveObj,
286        ],
287        "opobjt" => &[ActivePlayer, PActivePlayer, ActiveObj],
288
289        // AI Obj triggers (NPC vs obj)
290        "ai_apobj1" | "ai_apobj2" | "ai_apobj3" | "ai_apobj4" | "ai_apobj5" => {
291            &[ActiveNpc, ActiveObj]
292        }
293        "ai_opobj1" | "ai_opobj2" | "ai_opobj3" | "ai_opobj4" | "ai_opobj5" => {
294            &[ActiveNpc, ActiveObj]
295        }
296
297        // Player-Loc approach/operate triggers
298        "aploc1" | "aploc2" | "aploc3" | "aploc4" | "aploc5" => {
299            &[ActivePlayer, PActivePlayer, ActiveLoc]
300        }
301        "aplocu" => &[
302            ActivePlayer,
303            PActivePlayer,
304            LastUseitem,
305            LastUseslot,
306            ActiveLoc,
307        ],
308        "aploct" => &[ActivePlayer, PActivePlayer, ActiveLoc],
309        "oploc1" | "oploc2" | "oploc3" | "oploc4" | "oploc5" => {
310            &[ActivePlayer, PActivePlayer, ActiveLoc]
311        }
312        "oplocu" => &[
313            ActivePlayer,
314            PActivePlayer,
315            LastUseitem,
316            LastUseslot,
317            ActiveLoc,
318        ],
319        "oploct" => &[ActivePlayer, PActivePlayer, ActiveLoc],
320
321        // AI Loc triggers (NPC vs loc)
322        "ai_aploc1" | "ai_aploc2" | "ai_aploc3" | "ai_aploc4" | "ai_aploc5" => {
323            &[ActiveNpc, ActiveLoc]
324        }
325        "ai_oploc1" | "ai_oploc2" | "ai_oploc3" | "ai_oploc4" | "ai_oploc5" => {
326            &[ActiveNpc, ActiveLoc]
327        }
328
329        // Player-Player approach/operate triggers
330        "applayer1" | "applayer2" | "applayer3" | "applayer4" | "applayer5" => {
331            &[ActivePlayer, PActivePlayer, ActivePlayer2]
332        }
333        "applayeru" => &[
334            ActivePlayer,
335            PActivePlayer,
336            LastUseitem,
337            LastUseslot,
338            ActivePlayer2,
339        ],
340        "applayert" => &[ActivePlayer, PActivePlayer, ActivePlayer2],
341        "opplayer1" | "opplayer2" | "opplayer3" | "opplayer4" | "opplayer5" => {
342            &[ActivePlayer, PActivePlayer, ActivePlayer2]
343        }
344        "opplayeru" => &[
345            ActivePlayer,
346            PActivePlayer,
347            LastUseitem,
348            LastUseslot,
349            ActivePlayer2,
350        ],
351        "opplayert" => &[ActivePlayer, PActivePlayer, ActivePlayer2],
352
353        // AI Player triggers (NPC vs player)
354        "ai_applayer1" | "ai_applayer2" | "ai_applayer3" | "ai_applayer4" | "ai_applayer5" => {
355            &[ActiveNpc, ActivePlayer]
356        }
357        "ai_opplayer1" | "ai_opplayer2" | "ai_opplayer3" | "ai_opplayer4" | "ai_opplayer5" => {
358            &[ActiveNpc, ActivePlayer]
359        }
360
361        // Queue trigger
362        "queue" => &[ActivePlayer, PActivePlayer],
363
364        // AI queue triggers
365        "ai_queue1" | "ai_queue2" | "ai_queue3" | "ai_queue4" | "ai_queue5" | "ai_queue6"
366        | "ai_queue7" | "ai_queue8" | "ai_queue9" | "ai_queue10" | "ai_queue11" | "ai_queue12"
367        | "ai_queue13" | "ai_queue14" | "ai_queue15" | "ai_queue16" | "ai_queue17"
368        | "ai_queue18" | "ai_queue19" | "ai_queue20" => &[ActiveNpc, LastInt],
369
370        // Soft timer (player context only)
371        "softtimer" => &[ActivePlayer],
372
373        // Timer (player + protected)
374        "timer" => &[ActivePlayer, PActivePlayer],
375
376        // AI timer (NPC context)
377        "ai_timer" => &[ActiveNpc],
378
379        // Held item triggers
380        "opheld1" | "opheld2" | "opheld3" | "opheld4" | "opheld5" => {
381            &[ActivePlayer, PActivePlayer, LastItem, LastSlot]
382        }
383        "opheldu" => &[
384            ActivePlayer,
385            PActivePlayer,
386            LastItem,
387            LastSlot,
388            LastUseitem,
389            LastUseslot,
390        ],
391        "opheldt" => &[ActivePlayer, PActivePlayer, LastItem, LastSlot],
392
393        // Interface button trigger
394        "if_button" => &[ActivePlayer, LastCom],
395
396        // Interface close trigger
397        "if_close" => &[ActivePlayer],
398
399        // Inventory button triggers
400        "inv_button1" | "inv_button2" | "inv_button3" | "inv_button4" | "inv_button5" => {
401            &[ActivePlayer, LastItem, LastSlot]
402        }
403        // Also accept if_button1..5 aliases
404        "if_button1" | "if_button2" | "if_button3" | "if_button4" | "if_button5" => {
405            &[ActivePlayer, LastItem, LastSlot]
406        }
407        "inv_buttond" | "if_buttond" => &[ActivePlayer, LastSlot, LastTargetslot],
408        // Rev-647: inventory item ops 6-10. Only the if_button spelling extends
409        // to 6-10 (inv_button is the 225 family, capped at 5). Content uses these
410        // + the `p_opheld(op, inv, slot)` command.
411        "if_button6" | "if_button7" | "if_button8" | "if_button9" | "if_button10" => {
412            &[ActivePlayer, LastItem, LastSlot]
413        }
414
415        // Walk trigger
416        "walktrigger" => &[ActivePlayer, PActivePlayer],
417
418        // Global triggers
419        "login" | "logout" | "tutorial" | "switch_window_mode" => &[ActivePlayer, PActivePlayer],
420        "advancestat" | "changestat" => &[ActivePlayer, PActivePlayer],
421        "mapzone" | "mapzoneexit" | "zone" | "zoneexit" => &[ActivePlayer, PActivePlayer],
422        "area" | "areaexit" => &[ActivePlayer, PActivePlayer],
423
424        // AI lifecycle triggers
425        "ai_spawn" | "ai_despawn" => &[ActiveNpc],
426
427        // AI walktrigger
428        "ai_walktrigger" => &[ActiveNpc],
429
430        // A controller is an npc with no body: one queue (its int in last_int)
431        // and a timer.
432        "ai_conqueue" => &[ActiveController, LastInt],
433        "ai_contimer" => &[ActiveController],
434        // `controller_queue*` runs a named one with its own args.
435        "controller_queue" => &[ActiveController],
436        // `npc_queue*` runs a named one with its own args.
437        "npc_queue" => &[ActiveNpc],
438
439        // Unknown trigger — no pointers initialized
440        _ => return PointerSet::new(),
441    };
442
443    ptrs.iter().copied().collect()
444}
445
446// ---------------------------------------------------------------------------
447// command_pointers — pointer requirements for every engine command
448// ---------------------------------------------------------------------------
449
450/// Builds the full mapping from command name to its pointer requirements.
451///
452/// Both primary and secondary (`.` prefixed) variants are generated as
453/// separate entries. The keys use lowercase command names matching the
454/// SymbolRegistry command map.
455///
456/// Transcribed from `ScriptOpcodePointers.ts`.
457pub fn command_pointers() -> HashMap<String, PointerHolder> {
458    default_command_pointers().clone()
459}
460
461pub(crate) fn default_command_pointers() -> &'static HashMap<String, PointerHolder> {
462    static POINTERS: OnceLock<HashMap<String, PointerHolder>> = OnceLock::new();
463    POINTERS.get_or_init(build_command_pointers)
464}
465
466fn build_command_pointers() -> HashMap<String, PointerHolder> {
467    use PointerType::*;
468
469    let mut map = HashMap::new();
470
471    // Helper closures to reduce boilerplate
472    let mut add = |name: &str,
473                   require: &[PointerType],
474                   set: &[PointerType],
475                   corrupt: &[PointerType],
476                   require2: &[PointerType],
477                   set2: &[PointerType],
478                   corrupt2: &[PointerType],
479                   conditional: bool| {
480        // Primary entry
481        let holder = PointerHolder {
482            required: require.iter().copied().collect(),
483            set: set.iter().copied().collect(),
484            corrupted: corrupt.iter().copied().collect(),
485            conditional_set: conditional,
486            may_suspend: false,
487        };
488        map.insert(name.to_lowercase(), holder);
489
490        // Secondary entry (dot-prefixed) if any require2/set2/corrupt2 are specified
491        if !require2.is_empty() || !set2.is_empty() || !corrupt2.is_empty() {
492            let holder2 = PointerHolder {
493                required: require2.iter().copied().collect(),
494                set: set2.iter().copied().collect(),
495                corrupted: corrupt2.iter().copied().collect(),
496                conditional_set: conditional,
497                may_suspend: false,
498            };
499            map.insert(format!(".{}", name.to_lowercase()), holder2);
500        }
501    };
502
503    // The POINTER_GROUP_FIND shorthand
504    let find_group: &[PointerType] = &[FindPlayer, FindNpc, FindLoc, FindObj, FindDb];
505    // Corruption set for p_delay / p_arrivedelay style commands:
506    // everything except active is assumed corrupted
507    let delay_corrupt: Vec<PointerType> = {
508        let mut v: Vec<PointerType> = find_group.to_vec();
509        v.extend_from_slice(&[
510            LastCom,
511            LastInt,
512            LastItem,
513            LastSlot,
514            LastTargetslot,
515            LastUseitem,
516            LastUseslot,
517        ]);
518        v
519    };
520
521    // -----------------------------------------------------------------------
522    // Player ops
523    // -----------------------------------------------------------------------
524    add(
525        "allowdesign",
526        &[ActivePlayer],
527        &[],
528        &[],
529        &[],
530        &[],
531        &[],
532        false,
533    );
534    add(
535        "anim",
536        &[ActivePlayer],
537        &[],
538        &[],
539        &[ActivePlayer2],
540        &[],
541        &[],
542        false,
543    );
544    add(
545        "readyanim",
546        &[ActivePlayer],
547        &[],
548        &[],
549        &[ActivePlayer2],
550        &[],
551        &[],
552        false,
553    );
554    add(
555        "runanim",
556        &[ActivePlayer],
557        &[],
558        &[],
559        &[ActivePlayer2],
560        &[],
561        &[],
562        false,
563    );
564    add(
565        "turnanim",
566        &[ActivePlayer],
567        &[],
568        &[],
569        &[ActivePlayer2],
570        &[],
571        &[],
572        false,
573    );
574    add(
575        "walkanim_b",
576        &[ActivePlayer],
577        &[],
578        &[],
579        &[ActivePlayer2],
580        &[],
581        &[],
582        false,
583    );
584    add(
585        "walkanim",
586        &[ActivePlayer],
587        &[],
588        &[],
589        &[ActivePlayer2],
590        &[],
591        &[],
592        false,
593    );
594    add(
595        "walkanim_l",
596        &[ActivePlayer],
597        &[],
598        &[],
599        &[ActivePlayer2],
600        &[],
601        &[],
602        false,
603    );
604    add(
605        "walkanim_r",
606        &[ActivePlayer],
607        &[],
608        &[],
609        &[ActivePlayer2],
610        &[],
611        &[],
612        false,
613    );
614    add(
615        "buildappearance",
616        &[ActivePlayer],
617        &[],
618        &[],
619        &[ActivePlayer2],
620        &[],
621        &[],
622        false,
623    );
624    add(
625        "busy",
626        &[ActivePlayer],
627        &[],
628        &[],
629        &[ActivePlayer2],
630        &[],
631        &[],
632        false,
633    );
634    add(
635        "busy2",
636        &[ActivePlayer],
637        &[],
638        &[],
639        &[ActivePlayer2],
640        &[],
641        &[],
642        false,
643    );
644    add(
645        "cam_lookat",
646        &[ActivePlayer],
647        &[],
648        &[],
649        &[ActivePlayer2],
650        &[],
651        &[],
652        false,
653    );
654    add(
655        "cam_moveto",
656        &[ActivePlayer],
657        &[],
658        &[],
659        &[ActivePlayer2],
660        &[],
661        &[],
662        false,
663    );
664    add(
665        "cam_reset",
666        &[ActivePlayer],
667        &[],
668        &[],
669        &[ActivePlayer2],
670        &[],
671        &[],
672        false,
673    );
674    add(
675        "cam_shake",
676        &[ActivePlayer],
677        &[],
678        &[],
679        &[ActivePlayer2],
680        &[],
681        &[],
682        false,
683    );
684    add(
685        "clearqueue",
686        &[ActivePlayer],
687        &[],
688        &[],
689        &[ActivePlayer2],
690        &[],
691        &[],
692        false,
693    );
694    add(
695        "clearsofttimer",
696        &[ActivePlayer],
697        &[],
698        &[],
699        &[ActivePlayer2],
700        &[],
701        &[],
702        false,
703    );
704    add(
705        "cleartimer",
706        &[ActivePlayer],
707        &[],
708        &[],
709        &[ActivePlayer2],
710        &[],
711        &[],
712        false,
713    );
714    add(
715        "gettimer",
716        &[ActivePlayer],
717        &[],
718        &[],
719        &[ActivePlayer2],
720        &[],
721        &[],
722        false,
723    );
724    add(
725        "coord",
726        &[ActivePlayer],
727        &[],
728        &[],
729        &[ActivePlayer2],
730        &[],
731        &[],
732        false,
733    );
734    add(
735        "damage",
736        &[ActivePlayer],
737        &[],
738        &[],
739        &[ActivePlayer2],
740        &[],
741        &[],
742        false,
743    );
744    add(
745        "displayname",
746        &[ActivePlayer],
747        &[],
748        &[],
749        &[ActivePlayer2],
750        &[],
751        &[],
752        false,
753    );
754    add(
755        "facesquare",
756        &[ActivePlayer],
757        &[],
758        &[],
759        &[ActivePlayer2],
760        &[],
761        &[],
762        false,
763    );
764    add(
765        "finduid",
766        &[],
767        &[ActivePlayer],
768        &[PActivePlayer],
769        &[],
770        &[ActivePlayer2],
771        &[PActivePlayer2],
772        true,
773    );
774    add(
775        "gender",
776        &[ActivePlayer],
777        &[],
778        &[],
779        &[ActivePlayer2],
780        &[],
781        &[],
782        false,
783    );
784    add(
785        "getqueue",
786        &[ActivePlayer],
787        &[],
788        &[],
789        &[ActivePlayer2],
790        &[],
791        &[],
792        false,
793    );
794    add(
795        "stat_advance",
796        &[ActivePlayer],
797        &[],
798        &[],
799        &[],
800        &[],
801        &[],
802        false,
803    );
804    add(
805        "headicons_get",
806        &[ActivePlayer],
807        &[],
808        &[],
809        &[ActivePlayer2],
810        &[],
811        &[],
812        false,
813    );
814    add(
815        "headicons_set",
816        &[ActivePlayer],
817        &[],
818        &[],
819        &[ActivePlayer2],
820        &[],
821        &[],
822        false,
823    );
824    add(
825        "healenergy",
826        &[ActivePlayer],
827        &[],
828        &[],
829        &[ActivePlayer2],
830        &[],
831        &[],
832        false,
833    );
834    add(
835        "hint_coord",
836        &[ActivePlayer],
837        &[],
838        &[],
839        &[],
840        &[],
841        &[],
842        false,
843    );
844    add(
845        "hint_npc",
846        &[ActivePlayer, ActiveNpc],
847        &[],
848        &[],
849        &[],
850        &[],
851        &[],
852        false,
853    );
854    add(
855        "hint_pl",
856        &[ActivePlayer, ActivePlayer2],
857        &[],
858        &[],
859        &[ActivePlayer2, ActivePlayer],
860        &[],
861        &[],
862        false,
863    );
864    add(
865        "hint_stop",
866        &[ActivePlayer],
867        &[],
868        &[],
869        &[ActivePlayer2],
870        &[],
871        &[],
872        false,
873    );
874    add("huntall", &[], &[FindPlayer], &[], &[], &[], &[], false);
875    add(
876        "huntnext",
877        &[FindPlayer],
878        &[ActivePlayer],
879        &[],
880        &[FindPlayer],
881        &[ActivePlayer2],
882        &[],
883        true,
884    );
885    add(
886        "npc_hunt",
887        &[],
888        &[ActiveNpc],
889        &[],
890        &[],
891        &[ActiveNpc2],
892        &[],
893        false,
894    );
895    add("npc_huntall", &[], &[FindNpc], &[], &[], &[], &[], false);
896    add(
897        "npc_hasop",
898        &[ActiveNpc],
899        &[],
900        &[],
901        &[ActiveNpc2],
902        &[],
903        &[],
904        false,
905    );
906    add(
907        "if_close",
908        &[ActivePlayer],
909        &[],
910        &[],
911        &[ActivePlayer2],
912        &[],
913        &[],
914        false,
915    );
916    add("tut_close", &[ActivePlayer], &[], &[], &[], &[], &[], false);
917    add(
918        "if_openchat",
919        &[ActivePlayer],
920        &[],
921        &[],
922        &[ActivePlayer2],
923        &[],
924        &[],
925        false,
926    );
927    add("tut_open", &[ActivePlayer], &[], &[], &[], &[], &[], false);
928    // 2004scape (rev 225) names this command `if_openmain`. Rev 647 renamed it
929    // to `if_opentop` (since `if_openmain` is reserved for opening a modal in
930    // the main viewport). Both names get the same pointer rules so the compiler
931    // accepts content from either revision.
932    add(
933        "if_openmain",
934        &[ActivePlayer],
935        &[],
936        &[],
937        &[ActivePlayer2],
938        &[],
939        &[],
940        false,
941    );
942    add(
943        "if_opentop",
944        &[ActivePlayer],
945        &[],
946        &[],
947        &[ActivePlayer2],
948        &[],
949        &[],
950        false,
951    );
952    add(
953        "if_openmain_side",
954        &[ActivePlayer],
955        &[],
956        &[],
957        &[ActivePlayer2],
958        &[],
959        &[],
960        false,
961    );
962    add(
963        "if_openoverlay",
964        &[ActivePlayer],
965        &[],
966        &[],
967        &[ActivePlayer2],
968        &[],
969        &[],
970        false,
971    );
972    add(
973        "if_openside",
974        &[ActivePlayer],
975        &[],
976        &[],
977        &[],
978        &[],
979        &[],
980        false,
981    );
982    add(
983        "if_setanim",
984        &[ActivePlayer],
985        &[],
986        &[],
987        &[ActivePlayer2],
988        &[],
989        &[],
990        false,
991    );
992    add(
993        "if_setcolour",
994        &[ActivePlayer],
995        &[],
996        &[],
997        &[],
998        &[],
999        &[],
1000        false,
1001    );
1002    add(
1003        "if_sethide",
1004        &[ActivePlayer],
1005        &[],
1006        &[],
1007        &[ActivePlayer2],
1008        &[],
1009        &[],
1010        false,
1011    );
1012    add(
1013        "if_setmodel",
1014        &[ActivePlayer],
1015        &[],
1016        &[],
1017        &[],
1018        &[],
1019        &[],
1020        false,
1021    );
1022    add(
1023        "if_setnpchead",
1024        &[ActivePlayer],
1025        &[],
1026        &[],
1027        &[],
1028        &[],
1029        &[],
1030        false,
1031    );
1032    add(
1033        "if_setobject",
1034        &[ActivePlayer],
1035        &[],
1036        &[],
1037        &[ActivePlayer2],
1038        &[],
1039        &[],
1040        false,
1041    );
1042    add(
1043        "if_setplayerhead",
1044        &[ActivePlayer],
1045        &[],
1046        &[],
1047        &[],
1048        &[],
1049        &[],
1050        false,
1051    );
1052    add(
1053        "if_setposition",
1054        &[ActivePlayer],
1055        &[],
1056        &[],
1057        &[ActivePlayer2],
1058        &[],
1059        &[],
1060        false,
1061    );
1062    add(
1063        "if_addresumebutton",
1064        &[ActivePlayer],
1065        &[],
1066        &[],
1067        &[],
1068        &[],
1069        &[],
1070        false,
1071    );
1072    add(
1073        "if_settab",
1074        &[ActivePlayer],
1075        &[],
1076        &[],
1077        &[ActivePlayer2],
1078        &[],
1079        &[],
1080        false,
1081    );
1082    add(
1083        "if_settabactive",
1084        &[ActivePlayer],
1085        &[],
1086        &[],
1087        &[ActivePlayer2],
1088        &[],
1089        &[],
1090        false,
1091    );
1092    add("tut_flash", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1093    add(
1094        "if_settext",
1095        &[ActivePlayer],
1096        &[],
1097        &[],
1098        &[ActivePlayer2],
1099        &[],
1100        &[],
1101        false,
1102    );
1103    add(
1104        "last_login_info",
1105        &[ActivePlayer],
1106        &[],
1107        &[],
1108        &[],
1109        &[],
1110        &[],
1111        false,
1112    );
1113    add("last_com", &[LastCom], &[], &[], &[], &[], &[], false);
1114    add("last_int", &[LastInt], &[], &[], &[], &[], &[], false);
1115    add("last_item", &[LastItem], &[], &[], &[], &[], &[], false);
1116    add("last_slot", &[LastSlot], &[], &[], &[], &[], &[], false);
1117    add(
1118        "last_targetslot",
1119        &[LastTargetslot],
1120        &[],
1121        &[],
1122        &[],
1123        &[],
1124        &[],
1125        false,
1126    );
1127    add(
1128        "last_useitem",
1129        &[LastUseitem],
1130        &[],
1131        &[],
1132        &[],
1133        &[],
1134        &[],
1135        false,
1136    );
1137    add(
1138        "last_useslot",
1139        &[LastUseslot],
1140        &[],
1141        &[],
1142        &[],
1143        &[],
1144        &[],
1145        false,
1146    );
1147    add(
1148        "longqueue",
1149        &[ActivePlayer],
1150        &[],
1151        &[],
1152        &[ActivePlayer2],
1153        &[],
1154        &[],
1155        false,
1156    );
1157    add(
1158        "longqueue*",
1159        &[ActivePlayer],
1160        &[],
1161        &[],
1162        &[ActivePlayer2],
1163        &[],
1164        &[],
1165        false,
1166    );
1167    add("lowmem", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1168    add(
1169        "mes",
1170        &[ActivePlayer],
1171        &[],
1172        &[],
1173        &[ActivePlayer2],
1174        &[],
1175        &[],
1176        false,
1177    );
1178    add(
1179        "midi_jingle",
1180        &[ActivePlayer],
1181        &[],
1182        &[],
1183        &[ActivePlayer2],
1184        &[],
1185        &[],
1186        false,
1187    );
1188    add("midi_song", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1189    add(
1190        "minimap_toggle",
1191        &[ActivePlayer],
1192        &[],
1193        &[],
1194        &[ActivePlayer2],
1195        &[],
1196        &[],
1197        false,
1198    );
1199    add(
1200        "name",
1201        &[ActivePlayer],
1202        &[],
1203        &[],
1204        &[ActivePlayer2],
1205        &[],
1206        &[],
1207        false,
1208    );
1209    add(
1210        "p_aprange",
1211        &[PActivePlayer],
1212        &[],
1213        &[],
1214        &[],
1215        &[],
1216        &[],
1217        false,
1218    );
1219    add(
1220        "p_arrivedelay",
1221        &[PActivePlayer],
1222        &[],
1223        &delay_corrupt,
1224        &[],
1225        &[],
1226        &[],
1227        false,
1228    );
1229    {
1230        // p_countdialog: sets last_int, corrupts everything except active + last_int
1231        let mut corrupt = delay_corrupt.clone();
1232        corrupt.retain(|p| *p != LastInt);
1233        add(
1234            "p_countdialog",
1235            &[PActivePlayer],
1236            &[LastInt],
1237            &corrupt,
1238            &[],
1239            &[],
1240            &[],
1241            false,
1242        );
1243    }
1244    add(
1245        "p_delay",
1246        &[PActivePlayer],
1247        &[],
1248        &delay_corrupt,
1249        &[PActivePlayer2],
1250        &[],
1251        &delay_corrupt,
1252        false,
1253    );
1254    add(
1255        "p_exactmove",
1256        &[PActivePlayer],
1257        &[],
1258        &[],
1259        &[],
1260        &[],
1261        &[],
1262        false,
1263    );
1264    for name in [
1265        "p_namedialog",
1266        "p_stringdialog",
1267        "p_setdisplayname",
1268        "p_get_suggestion",
1269        "p_next_suggestions",
1270        "p_prev_suggestions",
1271        "p_request_more_suggestions",
1272        "p_rest",
1273        "p_temprun",
1274    ] {
1275        add(name, &[PActivePlayer], &[], &[], &[], &[], &[], false);
1276    }
1277    add(
1278        "p_finduid",
1279        &[],
1280        &[PActivePlayer, ActivePlayer],
1281        &[],
1282        &[],
1283        &[PActivePlayer2, ActivePlayer2],
1284        &[],
1285        true,
1286    );
1287    add(
1288        "p_locmerge",
1289        &[PActivePlayer],
1290        &[],
1291        &[],
1292        &[],
1293        &[],
1294        &[],
1295        false,
1296    );
1297    add("p_logout", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1298    add(
1299        "p_preventlogout",
1300        &[PActivePlayer],
1301        &[],
1302        &[],
1303        &[PActivePlayer2],
1304        &[],
1305        &[],
1306        false,
1307    );
1308    add("p_opheld", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1309    add(
1310        "p_oploc",
1311        &[PActivePlayer, ActiveLoc],
1312        &[],
1313        &[],
1314        &[],
1315        &[],
1316        &[],
1317        false,
1318    );
1319    add(
1320        "p_opnpc",
1321        &[PActivePlayer, ActiveNpc],
1322        &[],
1323        &[],
1324        &[],
1325        &[],
1326        &[],
1327        false,
1328    );
1329    add(
1330        "p_opnpct",
1331        &[PActivePlayer, ActiveNpc],
1332        &[],
1333        &[],
1334        &[],
1335        &[],
1336        &[],
1337        false,
1338    );
1339    add(
1340        "p_opobj",
1341        &[PActivePlayer, ActiveObj],
1342        &[],
1343        &[],
1344        &[],
1345        &[],
1346        &[],
1347        false,
1348    );
1349    add(
1350        "p_opplayer",
1351        &[PActivePlayer, ActivePlayer2],
1352        &[],
1353        &[],
1354        &[PActivePlayer2, ActivePlayer],
1355        &[],
1356        &[],
1357        false,
1358    );
1359    add(
1360        "p_opplayert",
1361        &[PActivePlayer, ActivePlayer2],
1362        &[],
1363        &[],
1364        &[PActivePlayer2, ActivePlayer],
1365        &[],
1366        &[],
1367        false,
1368    );
1369    {
1370        // p_pausebutton: sets last_com, corrupts everything except active + last_com
1371        let mut corrupt = delay_corrupt.clone();
1372        corrupt.retain(|p| *p != LastCom);
1373        add(
1374            "p_pausebutton",
1375            &[PActivePlayer],
1376            &[LastCom],
1377            &corrupt,
1378            &[PActivePlayer2],
1379            &[LastCom],
1380            &corrupt,
1381            false,
1382        );
1383    }
1384    add(
1385        "p_stopaction",
1386        &[PActivePlayer],
1387        &[],
1388        &[],
1389        &[PActivePlayer2],
1390        &[],
1391        &[],
1392        false,
1393    );
1394    add(
1395        "p_clearpendingaction",
1396        &[PActivePlayer],
1397        &[],
1398        &[],
1399        &[PActivePlayer2],
1400        &[],
1401        &[],
1402        false,
1403    );
1404    add(
1405        "p_telejump",
1406        &[PActivePlayer],
1407        &[],
1408        &[],
1409        &[PActivePlayer2],
1410        &[],
1411        &[],
1412        false,
1413    );
1414    add(
1415        "p_teleport",
1416        &[PActivePlayer],
1417        &[],
1418        &[],
1419        &[PActivePlayer2],
1420        &[],
1421        &[],
1422        false,
1423    );
1424    add(
1425        "p_walk",
1426        &[PActivePlayer],
1427        &[],
1428        &[],
1429        &[PActivePlayer2],
1430        &[],
1431        &[],
1432        false,
1433    );
1434    add(
1435        "projanim_pl",
1436        &[ActivePlayer],
1437        &[],
1438        &[],
1439        &[ActivePlayer2],
1440        &[],
1441        &[],
1442        false,
1443    );
1444    add(
1445        "queue",
1446        &[ActivePlayer],
1447        &[],
1448        &[],
1449        &[ActivePlayer2],
1450        &[],
1451        &[],
1452        false,
1453    );
1454    add(
1455        "queue*",
1456        &[ActivePlayer],
1457        &[],
1458        &[],
1459        &[ActivePlayer2],
1460        &[],
1461        &[],
1462        false,
1463    );
1464    add(
1465        "say",
1466        &[ActivePlayer],
1467        &[],
1468        &[],
1469        &[ActivePlayer2],
1470        &[],
1471        &[],
1472        false,
1473    );
1474    add("setidkit", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1475    add(
1476        "walktrigger",
1477        &[ActivePlayer],
1478        &[],
1479        &[],
1480        &[ActivePlayer2],
1481        &[],
1482        &[],
1483        false,
1484    );
1485    add(
1486        "getwalktrigger",
1487        &[ActivePlayer],
1488        &[],
1489        &[],
1490        &[ActivePlayer2],
1491        &[],
1492        &[],
1493        false,
1494    );
1495    add(
1496        "settimer",
1497        &[ActivePlayer],
1498        &[],
1499        &[],
1500        &[ActivePlayer2],
1501        &[],
1502        &[],
1503        false,
1504    );
1505    add(
1506        "softtimer",
1507        &[ActivePlayer],
1508        &[],
1509        &[],
1510        &[ActivePlayer2],
1511        &[],
1512        &[],
1513        false,
1514    );
1515    add(
1516        "sound_synth",
1517        &[ActivePlayer],
1518        &[],
1519        &[],
1520        &[ActivePlayer2],
1521        &[],
1522        &[],
1523        false,
1524    );
1525    add(
1526        "spotanim_pl",
1527        &[ActivePlayer],
1528        &[],
1529        &[],
1530        &[ActivePlayer2],
1531        &[],
1532        &[],
1533        false,
1534    );
1535    add(
1536        "staffmodlevel",
1537        &[ActivePlayer],
1538        &[],
1539        &[],
1540        &[ActivePlayer2],
1541        &[],
1542        &[],
1543        false,
1544    );
1545    add(
1546        "stat",
1547        &[ActivePlayer],
1548        &[],
1549        &[],
1550        &[ActivePlayer2],
1551        &[],
1552        &[],
1553        false,
1554    );
1555    add(
1556        "stat_add",
1557        &[ActivePlayer],
1558        &[],
1559        &[],
1560        &[ActivePlayer2],
1561        &[],
1562        &[],
1563        false,
1564    );
1565    add(
1566        "stat_base",
1567        &[ActivePlayer],
1568        &[],
1569        &[],
1570        &[ActivePlayer2],
1571        &[],
1572        &[],
1573        false,
1574    );
1575    add(
1576        "stat_heal",
1577        &[ActivePlayer],
1578        &[],
1579        &[],
1580        &[ActivePlayer2],
1581        &[],
1582        &[],
1583        false,
1584    );
1585    add(
1586        "stat_sub",
1587        &[ActivePlayer],
1588        &[],
1589        &[],
1590        &[ActivePlayer2],
1591        &[],
1592        &[],
1593        false,
1594    );
1595    add(
1596        "stat_boost",
1597        &[ActivePlayer],
1598        &[],
1599        &[],
1600        &[ActivePlayer2],
1601        &[],
1602        &[],
1603        false,
1604    );
1605    add(
1606        "stat_drain",
1607        &[ActivePlayer],
1608        &[],
1609        &[],
1610        &[ActivePlayer2],
1611        &[],
1612        &[],
1613        false,
1614    );
1615    add(
1616        "stat_random",
1617        &[ActivePlayer],
1618        &[],
1619        &[],
1620        &[ActivePlayer2],
1621        &[],
1622        &[],
1623        false,
1624    );
1625    add(
1626        "uid",
1627        &[ActivePlayer],
1628        &[],
1629        &[],
1630        &[ActivePlayer2],
1631        &[],
1632        &[],
1633        false,
1634    );
1635    add(
1636        "weakqueue",
1637        &[ActivePlayer],
1638        &[],
1639        &[],
1640        &[ActivePlayer2],
1641        &[],
1642        &[],
1643        false,
1644    );
1645    add(
1646        "weakqueue*",
1647        &[ActivePlayer],
1648        &[],
1649        &[],
1650        &[ActivePlayer2],
1651        &[],
1652        &[],
1653        false,
1654    );
1655    add(
1656        "findhero",
1657        &[ActivePlayer],
1658        &[ActivePlayer2],
1659        &[],
1660        &[ActivePlayer2],
1661        &[ActivePlayer2],
1662        &[],
1663        true,
1664    );
1665    add(
1666        "both_heropoints",
1667        &[ActivePlayer, ActivePlayer2],
1668        &[],
1669        &[],
1670        &[ActivePlayer2, ActivePlayer],
1671        &[],
1672        &[],
1673        false,
1674    );
1675    add(
1676        "setgender",
1677        &[PActivePlayer],
1678        &[],
1679        &[],
1680        &[],
1681        &[],
1682        &[],
1683        false,
1684    );
1685    add(
1686        "setidkcolour",
1687        &[PActivePlayer],
1688        &[],
1689        &[],
1690        &[],
1691        &[],
1692        &[],
1693        false,
1694    );
1695    add(
1696        "p_animprotect",
1697        &[PActivePlayer],
1698        &[],
1699        &[],
1700        &[PActivePlayer2],
1701        &[],
1702        &[],
1703        false,
1704    );
1705    add(
1706        "runenergy",
1707        &[ActivePlayer],
1708        &[],
1709        &[],
1710        &[ActivePlayer2],
1711        &[],
1712        &[],
1713        false,
1714    );
1715    add(
1716        "weight",
1717        &[PActivePlayer],
1718        &[],
1719        &[],
1720        &[PActivePlayer2],
1721        &[],
1722        &[],
1723        false,
1724    );
1725    add(
1726        "p_run",
1727        &[PActivePlayer],
1728        &[],
1729        &[],
1730        &[PActivePlayer2],
1731        &[],
1732        &[],
1733        false,
1734    );
1735    add(
1736        "if_setscrollpos",
1737        &[ActivePlayer],
1738        &[],
1739        &[],
1740        &[],
1741        &[],
1742        &[],
1743        false,
1744    );
1745    add(
1746        "if_movesub",
1747        &[ActivePlayer],
1748        &[],
1749        &[],
1750        &[],
1751        &[],
1752        &[],
1753        false,
1754    );
1755    add(
1756        "set_player_op",
1757        &[ActivePlayer],
1758        &[],
1759        &[],
1760        &[],
1761        &[],
1762        &[],
1763        false,
1764    );
1765    add(
1766        "set_skill_level",
1767        &[ActivePlayer],
1768        &[],
1769        &[],
1770        &[ActivePlayer2],
1771        &[],
1772        &[],
1773        false,
1774    );
1775    add(
1776        "strongqueue",
1777        &[ActivePlayer],
1778        &[],
1779        &[],
1780        &[ActivePlayer2],
1781        &[],
1782        &[],
1783        false,
1784    );
1785    add(
1786        "strongqueue*",
1787        &[ActivePlayer],
1788        &[],
1789        &[],
1790        &[ActivePlayer2],
1791        &[],
1792        &[],
1793        false,
1794    );
1795
1796    for name in [
1797        "afk_event",
1798        "applydesign",
1799        "buffer_full",
1800        "getwindowmode",
1801        "hint_coord_slot",
1802        "hint_stop_slot",
1803        "if_closesub",
1804        "if_opensub",
1805        "if_opentop_mode",
1806        "if_setgraphic",
1807        "if_setrecol",
1808        "if_setresumebuttons",
1809        "loc_prefetch",
1810        "lowmemory",
1811        "music_playjingle",
1812        "music_playsong",
1813        "p_projanim_halfsq",
1814        "p_transmogrify",
1815        "playermember",
1816        "runclientscript",
1817        "runclientscriptvararg",
1818        "session_log",
1819        "setskincolour",
1820        "stat_total",
1821        "wealth_event",
1822    ] {
1823        add(name, &[ActivePlayer], &[], &[], &[], &[], &[], false);
1824    }
1825    // 647 compiles `queue*` and the other `*` queues as `queuevararg` and so on.
1826    for name in [
1827        "bas_readyanim",
1828        "bas_running",
1829        "bas_turnonspot",
1830        "bas_walk_b",
1831        "bas_walk_f",
1832        "bas_walk_l",
1833        "bas_walk_r",
1834        "if_setevents",
1835        "longqueuevararg",
1836        "queuevararg",
1837        "strongqueuevararg",
1838        "weakqueuevararg",
1839    ] {
1840        add(
1841            name,
1842            &[ActivePlayer],
1843            &[],
1844            &[],
1845            &[ActivePlayer2],
1846            &[],
1847            &[],
1848            false,
1849        );
1850    }
1851    add(
1852        "hint_player",
1853        &[ActivePlayer, ActivePlayer2],
1854        &[],
1855        &[],
1856        &[ActivePlayer2, ActivePlayer],
1857        &[],
1858        &[],
1859        false,
1860    );
1861    add(
1862        "last_targetcom",
1863        &[LastTargetslot],
1864        &[],
1865        &[],
1866        &[],
1867        &[],
1868        &[],
1869        false,
1870    );
1871    add(
1872        "player_findallzone",
1873        &[],
1874        &[FindPlayer],
1875        &[],
1876        &[],
1877        &[],
1878        &[],
1879        false,
1880    );
1881    add(
1882        "player_findnext",
1883        &[FindPlayer],
1884        &[ActivePlayer],
1885        &[],
1886        &[FindPlayer],
1887        &[ActivePlayer2],
1888        &[],
1889        true,
1890    );
1891
1892    // -----------------------------------------------------------------------
1893    // NPC ops
1894    // -----------------------------------------------------------------------
1895    add(
1896        "npc_add",
1897        &[],
1898        &[ActiveNpc],
1899        &[],
1900        &[],
1901        &[ActiveNpc2],
1902        &[],
1903        false,
1904    );
1905    add(
1906        "npc_anim",
1907        &[ActiveNpc],
1908        &[],
1909        &[],
1910        &[ActiveNpc2],
1911        &[],
1912        &[],
1913        false,
1914    );
1915    add(
1916        "npc_basestat",
1917        &[ActiveNpc],
1918        &[],
1919        &[],
1920        &[ActiveNpc2],
1921        &[],
1922        &[],
1923        false,
1924    );
1925    add(
1926        "npc_category",
1927        &[ActiveNpc],
1928        &[],
1929        &[],
1930        &[ActiveNpc2],
1931        &[],
1932        &[],
1933        false,
1934    );
1935    add(
1936        "npc_changetype",
1937        &[ActiveNpc],
1938        &[],
1939        &[],
1940        &[ActiveNpc2],
1941        &[],
1942        &[],
1943        false,
1944    );
1945    add(
1946        "npc_changetype_keepall",
1947        &[ActiveNpc],
1948        &[],
1949        &[],
1950        &[ActiveNpc2],
1951        &[],
1952        &[],
1953        false,
1954    );
1955    add(
1956        "npc_coord",
1957        &[ActiveNpc],
1958        &[],
1959        &[],
1960        &[ActiveNpc2],
1961        &[],
1962        &[],
1963        false,
1964    );
1965    add(
1966        "npc_damage",
1967        &[ActiveNpc],
1968        &[],
1969        &[],
1970        &[ActiveNpc2],
1971        &[],
1972        &[],
1973        false,
1974    );
1975    add(
1976        "npc_del",
1977        &[ActiveNpc],
1978        &[],
1979        &[],
1980        &[ActiveNpc2],
1981        &[],
1982        &[],
1983        false,
1984    );
1985    {
1986        // npc_delay: corrupts p_active_player, p_active_player2, find_*, last_*
1987        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
1988        corrupt.extend_from_slice(find_group);
1989        corrupt.extend_from_slice(&[
1990            LastCom,
1991            LastInt,
1992            LastItem,
1993            LastSlot,
1994            LastTargetslot,
1995            LastUseitem,
1996            LastUseslot,
1997        ]);
1998        add(
1999            "npc_delay",
2000            &[ActiveNpc],
2001            &[],
2002            &corrupt,
2003            &[ActiveNpc2],
2004            &[],
2005            &[],
2006            false,
2007        );
2008    }
2009    add(
2010        "npc_facesquare",
2011        &[ActiveNpc],
2012        &[],
2013        &[],
2014        &[ActiveNpc2],
2015        &[],
2016        &[],
2017        false,
2018    );
2019    add(
2020        "npc_find",
2021        &[],
2022        &[ActiveNpc],
2023        &[],
2024        &[],
2025        &[ActiveNpc2],
2026        &[],
2027        true,
2028    );
2029    add(
2030        "npc_findcat",
2031        &[],
2032        &[ActiveNpc],
2033        &[],
2034        &[],
2035        &[ActiveNpc2],
2036        &[],
2037        true,
2038    );
2039    add(
2040        "npc_findallany",
2041        &[],
2042        &[FindNpc],
2043        &[],
2044        &[],
2045        &[FindNpc],
2046        &[],
2047        false,
2048    );
2049    add(
2050        "npc_findall",
2051        &[],
2052        &[FindNpc],
2053        &[],
2054        &[],
2055        &[FindNpc],
2056        &[],
2057        false,
2058    );
2059    add(
2060        "npc_findallzone",
2061        &[],
2062        &[FindNpc],
2063        &[],
2064        &[],
2065        &[],
2066        &[],
2067        false,
2068    );
2069    add(
2070        "npc_findnext",
2071        &[FindNpc],
2072        &[ActiveNpc],
2073        &[],
2074        &[FindNpc],
2075        &[ActiveNpc2],
2076        &[],
2077        true,
2078    );
2079    add(
2080        "npc_findexact",
2081        &[],
2082        &[ActiveNpc],
2083        &[],
2084        &[],
2085        &[ActiveNpc2],
2086        &[],
2087        true,
2088    );
2089    add(
2090        "npc_findhero",
2091        &[ActiveNpc],
2092        &[ActivePlayer],
2093        &[],
2094        &[ActiveNpc2],
2095        &[ActivePlayer2],
2096        &[],
2097        true,
2098    );
2099    add(
2100        "npc_finduid",
2101        &[],
2102        &[ActiveNpc],
2103        &[],
2104        &[],
2105        &[ActiveNpc2],
2106        &[],
2107        true,
2108    );
2109    add(
2110        "npc_getmode",
2111        &[ActiveNpc],
2112        &[],
2113        &[],
2114        &[ActiveNpc2],
2115        &[],
2116        &[],
2117        false,
2118    );
2119    add(
2120        "npc_heropoints",
2121        &[ActiveNpc, ActivePlayer],
2122        &[],
2123        &[],
2124        &[],
2125        &[],
2126        &[],
2127        false,
2128    );
2129    add(
2130        "npc_name",
2131        &[ActiveNpc],
2132        &[],
2133        &[],
2134        &[ActiveNpc2],
2135        &[],
2136        &[],
2137        false,
2138    );
2139    add(
2140        "npc_param",
2141        &[ActiveNpc],
2142        &[],
2143        &[],
2144        &[ActiveNpc2],
2145        &[],
2146        &[],
2147        false,
2148    );
2149    add(
2150        "npc_queue",
2151        &[ActiveNpc],
2152        &[],
2153        &[],
2154        &[ActiveNpc2],
2155        &[],
2156        &[],
2157        false,
2158    );
2159    add(
2160        "npc_queuevararg",
2161        &[ActiveNpc],
2162        &[],
2163        &[],
2164        &[ActiveNpc2],
2165        &[],
2166        &[],
2167        false,
2168    );
2169    add(
2170        "npc_range",
2171        &[ActiveNpc],
2172        &[],
2173        &[],
2174        &[ActiveNpc2],
2175        &[],
2176        &[],
2177        false,
2178    );
2179    add(
2180        "npc_say",
2181        &[ActiveNpc],
2182        &[],
2183        &[],
2184        &[ActiveNpc2],
2185        &[],
2186        &[],
2187        false,
2188    );
2189    add(
2190        "npc_sethunt",
2191        &[ActiveNpc],
2192        &[],
2193        &[],
2194        &[ActiveNpc2],
2195        &[],
2196        &[],
2197        false,
2198    );
2199    add(
2200        "npc_sethuntmode",
2201        &[ActiveNpc],
2202        &[],
2203        &[],
2204        &[ActiveNpc2],
2205        &[],
2206        &[],
2207        false,
2208    );
2209    add(
2210        "npc_setmode",
2211        &[ActiveNpc],
2212        &[],
2213        &[],
2214        &[ActiveNpc2],
2215        &[],
2216        &[],
2217        false,
2218    );
2219    add(
2220        "npc_walktrigger",
2221        &[ActiveNpc],
2222        &[],
2223        &[],
2224        &[ActiveNpc2],
2225        &[],
2226        &[],
2227        false,
2228    );
2229    add(
2230        "npc_settimer",
2231        &[ActiveNpc],
2232        &[],
2233        &[],
2234        &[ActiveNpc2],
2235        &[],
2236        &[],
2237        false,
2238    );
2239    add(
2240        "npc_stat",
2241        &[ActiveNpc],
2242        &[],
2243        &[],
2244        &[ActiveNpc2],
2245        &[],
2246        &[],
2247        false,
2248    );
2249    add(
2250        "npc_statadd",
2251        &[ActiveNpc],
2252        &[],
2253        &[],
2254        &[ActiveNpc2],
2255        &[],
2256        &[],
2257        false,
2258    );
2259    add(
2260        "npc_statheal",
2261        &[ActiveNpc],
2262        &[],
2263        &[],
2264        &[ActiveNpc2],
2265        &[],
2266        &[],
2267        false,
2268    );
2269    add(
2270        "npc_statsub",
2271        &[ActiveNpc],
2272        &[],
2273        &[],
2274        &[ActiveNpc2],
2275        &[],
2276        &[],
2277        false,
2278    );
2279    add(
2280        "npc_tele",
2281        &[ActiveNpc],
2282        &[],
2283        &[],
2284        &[ActiveNpc2],
2285        &[],
2286        &[],
2287        false,
2288    );
2289    add(
2290        "npc_type",
2291        &[ActiveNpc],
2292        &[],
2293        &[],
2294        &[ActiveNpc2],
2295        &[],
2296        &[],
2297        false,
2298    );
2299    add(
2300        "npc_uid",
2301        &[ActiveNpc],
2302        &[],
2303        &[],
2304        &[ActiveNpc2],
2305        &[],
2306        &[],
2307        false,
2308    );
2309    add(
2310        "projanim_npc",
2311        &[ActiveNpc],
2312        &[],
2313        &[],
2314        &[ActiveNpc2],
2315        &[],
2316        &[],
2317        false,
2318    );
2319    add(
2320        "spotanim_npc",
2321        &[ActiveNpc],
2322        &[],
2323        &[],
2324        &[ActiveNpc2],
2325        &[],
2326        &[],
2327        false,
2328    );
2329    add(
2330        "npc_walk",
2331        &[ActiveNpc],
2332        &[],
2333        &[],
2334        &[ActiveNpc2],
2335        &[],
2336        &[],
2337        false,
2338    );
2339    add(
2340        "npc_attackrange",
2341        &[ActiveNpc],
2342        &[],
2343        &[],
2344        &[ActiveNpc2],
2345        &[],
2346        &[],
2347        false,
2348    );
2349    {
2350        // npc_arrivedelay: same corruption set as npc_delay
2351        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
2352        corrupt.extend_from_slice(find_group);
2353        corrupt.extend_from_slice(&[
2354            LastCom,
2355            LastInt,
2356            LastItem,
2357            LastSlot,
2358            LastTargetslot,
2359            LastUseitem,
2360            LastUseslot,
2361        ]);
2362        add(
2363            "npc_arrivedelay",
2364            &[ActiveNpc],
2365            &[],
2366            &corrupt,
2367            &[ActiveNpc2],
2368            &[],
2369            &[],
2370            false,
2371        );
2372    }
2373    add(
2374        "npc_inrange",
2375        &[ActiveNpc],
2376        &[],
2377        &[],
2378        &[ActiveNpc2],
2379        &[],
2380        &[],
2381        false,
2382    );
2383
2384    add(
2385        "npc_destination",
2386        &[ActiveNpc],
2387        &[],
2388        &[],
2389        &[ActiveNpc2],
2390        &[],
2391        &[],
2392        false,
2393    );
2394    add(
2395        "npc_huntnext",
2396        &[FindNpc],
2397        &[ActiveNpc],
2398        &[],
2399        &[FindNpc],
2400        &[ActiveNpc2],
2401        &[],
2402        true,
2403    );
2404    add(
2405        "npc_projanim_halfsq",
2406        &[ActiveNpc],
2407        &[],
2408        &[],
2409        &[],
2410        &[],
2411        &[],
2412        false,
2413    );
2414
2415    // -----------------------------------------------------------------------
2416    // Loc ops
2417    // -----------------------------------------------------------------------
2418    add(
2419        "loc_add",
2420        &[],
2421        &[ActiveLoc],
2422        &[],
2423        &[],
2424        &[ActiveLoc2],
2425        &[],
2426        false,
2427    );
2428    add(
2429        "loc_angle",
2430        &[ActiveLoc],
2431        &[],
2432        &[],
2433        &[ActiveLoc2],
2434        &[],
2435        &[],
2436        false,
2437    );
2438    add(
2439        "loc_anim",
2440        &[ActiveLoc],
2441        &[],
2442        &[],
2443        &[ActiveLoc2],
2444        &[],
2445        &[],
2446        false,
2447    );
2448    add(
2449        "loc_category",
2450        &[ActiveLoc],
2451        &[],
2452        &[],
2453        &[ActiveLoc2],
2454        &[],
2455        &[],
2456        false,
2457    );
2458    add(
2459        "loc_change",
2460        &[ActiveLoc],
2461        &[],
2462        &[],
2463        &[ActiveLoc2],
2464        &[],
2465        &[],
2466        false,
2467    );
2468    add(
2469        "loc_coord",
2470        &[ActiveLoc],
2471        &[],
2472        &[],
2473        &[ActiveLoc2],
2474        &[],
2475        &[],
2476        false,
2477    );
2478    add(
2479        "loc_del",
2480        &[ActiveLoc],
2481        &[],
2482        &[],
2483        &[ActiveLoc2],
2484        &[],
2485        &[],
2486        false,
2487    );
2488    add(
2489        "loc_find",
2490        &[],
2491        &[ActiveLoc],
2492        &[],
2493        &[],
2494        &[ActiveLoc2],
2495        &[],
2496        true,
2497    );
2498    add(
2499        "loc_findallzone",
2500        &[],
2501        &[FindLoc],
2502        &[],
2503        &[],
2504        &[FindLoc],
2505        &[],
2506        false,
2507    );
2508    add(
2509        "loc_findnext",
2510        &[FindLoc],
2511        &[ActiveLoc],
2512        &[],
2513        &[FindLoc],
2514        &[ActiveLoc2],
2515        &[],
2516        true,
2517    );
2518    add(
2519        "loc_name",
2520        &[ActiveLoc],
2521        &[],
2522        &[],
2523        &[ActiveLoc2],
2524        &[],
2525        &[],
2526        false,
2527    );
2528    add(
2529        "loc_param",
2530        &[ActiveLoc],
2531        &[],
2532        &[],
2533        &[ActiveLoc2],
2534        &[],
2535        &[],
2536        false,
2537    );
2538    add(
2539        "loc_shape",
2540        &[ActiveLoc],
2541        &[],
2542        &[],
2543        &[ActiveLoc2],
2544        &[],
2545        &[],
2546        false,
2547    );
2548    add(
2549        "loc_type",
2550        &[ActiveLoc],
2551        &[],
2552        &[],
2553        &[ActiveLoc2],
2554        &[],
2555        &[],
2556        false,
2557    );
2558
2559    add("loc_merge", &[ActiveLoc], &[], &[], &[], &[], &[], false);
2560
2561    // -----------------------------------------------------------------------
2562    // Obj ops
2563    // -----------------------------------------------------------------------
2564    add(
2565        "obj_add",
2566        &[ActivePlayer],
2567        &[ActiveObj],
2568        &[],
2569        &[ActivePlayer2],
2570        &[ActiveObj2],
2571        &[],
2572        false,
2573    );
2574    add(
2575        "obj_addall",
2576        &[],
2577        &[ActiveObj],
2578        &[],
2579        &[],
2580        &[ActiveObj2],
2581        &[],
2582        false,
2583    );
2584    add(
2585        "obj_coord",
2586        &[ActiveObj],
2587        &[],
2588        &[],
2589        &[ActiveObj2],
2590        &[],
2591        &[],
2592        false,
2593    );
2594    add(
2595        "obj_count",
2596        &[ActiveObj],
2597        &[],
2598        &[],
2599        &[ActiveObj2],
2600        &[],
2601        &[],
2602        false,
2603    );
2604    add(
2605        "obj_del",
2606        &[ActiveObj],
2607        &[],
2608        &[],
2609        &[ActiveObj2],
2610        &[],
2611        &[],
2612        false,
2613    );
2614    add(
2615        "obj_name",
2616        &[ActiveObj],
2617        &[],
2618        &[],
2619        &[ActiveObj2],
2620        &[],
2621        &[],
2622        false,
2623    );
2624    add(
2625        "obj_param",
2626        &[ActiveObj],
2627        &[],
2628        &[],
2629        &[ActiveObj2],
2630        &[],
2631        &[],
2632        false,
2633    );
2634    add(
2635        "obj_getvar",
2636        &[ActiveObj],
2637        &[],
2638        &[],
2639        &[ActiveObj2],
2640        &[],
2641        &[],
2642        false,
2643    );
2644    add(
2645        "obj_setvar",
2646        &[ActiveObj],
2647        &[],
2648        &[],
2649        &[ActiveObj2],
2650        &[],
2651        &[],
2652        false,
2653    );
2654    add(
2655        "obj_takeitem",
2656        &[ActiveObj, ActivePlayer],
2657        &[],
2658        &[],
2659        &[ActiveObj2, ActivePlayer2],
2660        &[],
2661        &[],
2662        false,
2663    );
2664    add(
2665        "obj_type",
2666        &[ActiveObj],
2667        &[],
2668        &[],
2669        &[ActiveObj2],
2670        &[],
2671        &[],
2672        false,
2673    );
2674    add(
2675        "obj_find",
2676        &[],
2677        &[ActiveObj],
2678        &[],
2679        &[],
2680        &[ActiveObj2],
2681        &[],
2682        false,
2683    );
2684    add(
2685        "obj_findallzone",
2686        &[],
2687        &[FindObj],
2688        &[],
2689        &[],
2690        &[FindObj],
2691        &[],
2692        false,
2693    );
2694    add(
2695        "obj_findnext",
2696        &[FindObj],
2697        &[ActiveObj],
2698        &[],
2699        &[FindObj],
2700        &[ActiveObj2],
2701        &[],
2702        true,
2703    );
2704
2705    // -----------------------------------------------------------------------
2706    // Inventory ops
2707    // -----------------------------------------------------------------------
2708    add(
2709        "inv_add",
2710        &[ActivePlayer],
2711        &[],
2712        &[],
2713        &[ActivePlayer2],
2714        &[],
2715        &[],
2716        false,
2717    );
2718    add(
2719        "inv_changeslot",
2720        &[ActivePlayer],
2721        &[],
2722        &[],
2723        &[ActivePlayer2],
2724        &[],
2725        &[],
2726        false,
2727    );
2728    add(
2729        "inv_clear",
2730        &[ActivePlayer],
2731        &[],
2732        &[],
2733        &[ActivePlayer2],
2734        &[],
2735        &[],
2736        false,
2737    );
2738    add(
2739        "inv_del",
2740        &[ActivePlayer],
2741        &[],
2742        &[],
2743        &[ActivePlayer2],
2744        &[],
2745        &[],
2746        false,
2747    );
2748    add(
2749        "inv_delslot",
2750        &[ActivePlayer],
2751        &[],
2752        &[],
2753        &[ActivePlayer2],
2754        &[],
2755        &[],
2756        false,
2757    );
2758    add(
2759        "inv_dropitem",
2760        &[ActivePlayer],
2761        &[ActiveObj],
2762        &[],
2763        &[ActivePlayer2],
2764        &[ActiveObj2],
2765        &[],
2766        false,
2767    );
2768    add(
2769        "inv_dropitem_delayed",
2770        &[ActivePlayer],
2771        &[ActiveObj],
2772        &[],
2773        &[ActivePlayer2],
2774        &[ActiveObj2],
2775        &[],
2776        false,
2777    );
2778    add(
2779        "inv_dropslot",
2780        &[ActivePlayer],
2781        &[ActiveObj],
2782        &[],
2783        &[ActivePlayer2],
2784        &[ActiveObj2],
2785        &[],
2786        false,
2787    );
2788    add(
2789        "inv_freespace",
2790        &[ActivePlayer],
2791        &[],
2792        &[],
2793        &[ActivePlayer2],
2794        &[],
2795        &[],
2796        false,
2797    );
2798    add(
2799        "inv_getnum",
2800        &[ActivePlayer],
2801        &[],
2802        &[],
2803        &[ActivePlayer2],
2804        &[],
2805        &[],
2806        false,
2807    );
2808    add(
2809        "inv_getobj",
2810        &[ActivePlayer],
2811        &[],
2812        &[],
2813        &[ActivePlayer2],
2814        &[],
2815        &[],
2816        false,
2817    );
2818    add(
2819        "inv_getvar",
2820        &[ActivePlayer],
2821        &[],
2822        &[],
2823        &[ActivePlayer2],
2824        &[],
2825        &[],
2826        false,
2827    );
2828    add(
2829        "inv_itemspace",
2830        &[ActivePlayer],
2831        &[],
2832        &[],
2833        &[ActivePlayer2],
2834        &[],
2835        &[],
2836        false,
2837    );
2838    add(
2839        "inv_itemspace2",
2840        &[ActivePlayer],
2841        &[],
2842        &[],
2843        &[ActivePlayer2],
2844        &[],
2845        &[],
2846        false,
2847    );
2848    add(
2849        "inv_movefromslot",
2850        &[ActivePlayer],
2851        &[],
2852        &[],
2853        &[ActivePlayer2],
2854        &[],
2855        &[],
2856        false,
2857    );
2858    add(
2859        "inv_movetoslot",
2860        &[ActivePlayer],
2861        &[],
2862        &[],
2863        &[ActivePlayer2],
2864        &[],
2865        &[],
2866        false,
2867    );
2868    add(
2869        "both_moveinv",
2870        &[ActivePlayer, ActivePlayer2],
2871        &[],
2872        &[],
2873        &[ActivePlayer2, ActivePlayer],
2874        &[],
2875        &[],
2876        false,
2877    );
2878    add(
2879        "inv_moveitem",
2880        &[ActivePlayer],
2881        &[],
2882        &[],
2883        &[ActivePlayer2],
2884        &[],
2885        &[],
2886        false,
2887    );
2888    add(
2889        "inv_moveitem_cert",
2890        &[ActivePlayer],
2891        &[],
2892        &[],
2893        &[ActivePlayer2],
2894        &[],
2895        &[],
2896        false,
2897    );
2898    add(
2899        "inv_moveitem_uncert",
2900        &[ActivePlayer],
2901        &[],
2902        &[],
2903        &[ActivePlayer2],
2904        &[],
2905        &[],
2906        false,
2907    );
2908    add(
2909        "inv_setslot",
2910        &[ActivePlayer],
2911        &[],
2912        &[],
2913        &[ActivePlayer2],
2914        &[],
2915        &[],
2916        false,
2917    );
2918    add(
2919        "inv_setvar",
2920        &[ActivePlayer],
2921        &[],
2922        &[],
2923        &[ActivePlayer2],
2924        &[],
2925        &[],
2926        false,
2927    );
2928    add(
2929        "inv_total",
2930        &[ActivePlayer],
2931        &[],
2932        &[],
2933        &[ActivePlayer2],
2934        &[],
2935        &[],
2936        false,
2937    );
2938    add(
2939        "inv_totalcat",
2940        &[ActivePlayer],
2941        &[],
2942        &[],
2943        &[ActivePlayer2],
2944        &[],
2945        &[],
2946        false,
2947    );
2948    add(
2949        "inv_transmit",
2950        &[ActivePlayer],
2951        &[],
2952        &[],
2953        &[ActivePlayer2],
2954        &[],
2955        &[],
2956        false,
2957    );
2958    add(
2959        "invother_transmit",
2960        &[ActivePlayer, ActivePlayer2],
2961        &[],
2962        &[],
2963        &[ActivePlayer2, ActivePlayer],
2964        &[],
2965        &[],
2966        false,
2967    );
2968    add(
2969        "inv_stoptransmit",
2970        &[ActivePlayer],
2971        &[],
2972        &[],
2973        &[ActivePlayer2],
2974        &[],
2975        &[],
2976        false,
2977    );
2978    add(
2979        "both_dropslot",
2980        &[ActivePlayer, ActivePlayer2],
2981        &[],
2982        &[],
2983        &[ActivePlayer2, ActivePlayer],
2984        &[],
2985        &[],
2986        false,
2987    );
2988    add(
2989        "inv_dropall",
2990        &[ActivePlayer],
2991        &[],
2992        &[],
2993        &[ActivePlayer2],
2994        &[],
2995        &[],
2996        false,
2997    );
2998    add(
2999        "inv_totalparam",
3000        &[ActivePlayer],
3001        &[],
3002        &[],
3003        &[ActivePlayer2],
3004        &[],
3005        &[],
3006        false,
3007    );
3008    add(
3009        "inv_totalparam_stack",
3010        &[ActivePlayer],
3011        &[],
3012        &[],
3013        &[ActivePlayer2],
3014        &[],
3015        &[],
3016        false,
3017    );
3018
3019    // -----------------------------------------------------------------------
3020    // String ops
3021    // -----------------------------------------------------------------------
3022    add(
3023        "text_gender",
3024        &[ActivePlayer],
3025        &[],
3026        &[],
3027        &[ActivePlayer2],
3028        &[],
3029        &[],
3030        false,
3031    );
3032
3033    // -----------------------------------------------------------------------
3034    // Controller ops
3035    // -----------------------------------------------------------------------
3036    for name in [
3037        "controller_coord",
3038        "controller_queue",
3039        "controller_queuevararg",
3040        "controller_settimer",
3041    ] {
3042        add(
3043            name,
3044            &[ActiveController],
3045            &[],
3046            &[],
3047            &[ActiveController2],
3048            &[],
3049            &[],
3050            false,
3051        );
3052    }
3053    add(
3054        "controller_del",
3055        &[ActiveController],
3056        &[],
3057        &[ActiveController],
3058        &[ActiveController2],
3059        &[],
3060        &[ActiveController2],
3061        false,
3062    );
3063    add(
3064        "controller_add",
3065        &[],
3066        &[ActiveController],
3067        &[],
3068        &[],
3069        &[ActiveController2],
3070        &[],
3071        false,
3072    );
3073    add(
3074        "controller_findexact",
3075        &[],
3076        &[ActiveController],
3077        &[],
3078        &[],
3079        &[ActiveController2],
3080        &[],
3081        true,
3082    );
3083
3084    // -----------------------------------------------------------------------
3085    // Region ops: a region (instance) the script created or found
3086    // -----------------------------------------------------------------------
3087    for name in [
3088        "region_getcoord",
3089        "region_set",
3090        "region_uid",
3091        "region_setexitcoord",
3092    ] {
3093        add(
3094            name,
3095            &[ActiveRegion],
3096            &[],
3097            &[],
3098            &[ActiveRegion2],
3099            &[],
3100            &[],
3101            false,
3102        );
3103    }
3104    add(
3105        "region_create",
3106        &[],
3107        &[ActiveRegion],
3108        &[],
3109        &[],
3110        &[ActiveRegion2],
3111        &[],
3112        false,
3113    );
3114    for name in ["region_findbycoord", "region_findbyuid"] {
3115        add(
3116            name,
3117            &[],
3118            &[ActiveRegion],
3119            &[],
3120            &[],
3121            &[ActiveRegion2],
3122            &[],
3123            true,
3124        );
3125    }
3126
3127    // -----------------------------------------------------------------------
3128    // DB ops
3129    // -----------------------------------------------------------------------
3130    add("db_findnext", &[FindDb], &[], &[], &[], &[], &[], false);
3131    add("db_find", &[], &[FindDb], &[], &[], &[], &[], false);
3132    add("db_find_refine", &[FindDb], &[], &[], &[], &[], &[], false);
3133    add("db_listall", &[], &[FindDb], &[], &[], &[], &[], false);
3134    add(
3135        "db_listall_with_count",
3136        &[],
3137        &[FindDb],
3138        &[],
3139        &[],
3140        &[],
3141        &[],
3142        false,
3143    );
3144
3145    // Suspension is part of the command contract, independent of pointer corruption.
3146    for name in [
3147        "world_delay",
3148        "p_arrivedelay",
3149        "p_countdialog",
3150        "p_stringdialog",
3151        "p_setdisplayname",
3152        "p_delay",
3153        "p_pausebutton",
3154        "npc_arrivedelay",
3155        "npc_delay",
3156        "test_tick",
3157        "wait_for",
3158    ] {
3159        map.entry(name.into()).or_default().may_suspend = true;
3160        if let Some(secondary) = map.get_mut(&format!(".{name}")) {
3161            secondary.may_suspend = true;
3162        }
3163    }
3164    map
3165}