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