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        "mes_typed",
1269        &[ActivePlayer],
1270        &[],
1271        &[],
1272        &[ActivePlayer2],
1273        &[],
1274        &[],
1275        false,
1276    );
1277    add(
1278        "midi_jingle",
1279        &[ActivePlayer],
1280        &[],
1281        &[],
1282        &[ActivePlayer2],
1283        &[],
1284        &[],
1285        false,
1286    );
1287    add("midi_song", &[ActivePlayer], &[], &[], &[], &[], &[], false);
1288    add(
1289        "minimap_toggle",
1290        &[ActivePlayer],
1291        &[],
1292        &[],
1293        &[ActivePlayer2],
1294        &[],
1295        &[],
1296        false,
1297    );
1298    add(
1299        "name",
1300        &[ActivePlayer],
1301        &[],
1302        &[],
1303        &[ActivePlayer2],
1304        &[],
1305        &[],
1306        false,
1307    );
1308    add(
1309        "p_aprange",
1310        &[PActivePlayer],
1311        &[],
1312        &[],
1313        &[],
1314        &[],
1315        &[],
1316        false,
1317    );
1318    for name in ["p_arrivedelay", "p_loaddelay"] {
1319        add(
1320            name,
1321            &[PActivePlayer],
1322            &[],
1323            &delay_corrupt,
1324            &[],
1325            &[],
1326            &[],
1327            false,
1328        );
1329    }
1330    {
1331        // p_countdialog: sets last_int, corrupts everything except active + last_int.
1332        // 647's obj and colour (hsl) dialogs answer in last_int too.
1333        let mut corrupt = delay_corrupt.clone();
1334        corrupt.retain(|p| *p != LastInt);
1335        for name in ["p_countdialog", "p_objdialog", "p_hsldialog"] {
1336            add(
1337                name,
1338                &[PActivePlayer],
1339                &[LastInt],
1340                &corrupt,
1341                &[],
1342                &[],
1343                &[],
1344                false,
1345            );
1346        }
1347    }
1348    add(
1349        "p_delay",
1350        &[PActivePlayer],
1351        &[],
1352        &delay_corrupt,
1353        &[PActivePlayer2],
1354        &[],
1355        &delay_corrupt,
1356        false,
1357    );
1358    add(
1359        "p_exactmove",
1360        &[PActivePlayer],
1361        &[],
1362        &[],
1363        &[],
1364        &[],
1365        &[],
1366        false,
1367    );
1368    {
1369        // p_stringdialog: sets last_string, as p_countdialog sets last_int. 647's
1370        // name and clan-forum quick find code dialogs answer in last_string too.
1371        let mut corrupt = delay_corrupt.clone();
1372        corrupt.retain(|p| *p != LastString);
1373        for name in ["p_stringdialog", "p_namedialog", "p_clanforumqfcdialog"] {
1374            add(
1375                name,
1376                &[PActivePlayer],
1377                &[LastString],
1378                &corrupt,
1379                &[],
1380                &[],
1381                &[],
1382                false,
1383            );
1384        }
1385        // p_setdisplayname: sets last_int (the outcome) and last_string (the name)
1386        corrupt.retain(|p| *p != LastInt);
1387        add(
1388            "p_setdisplayname",
1389            &[PActivePlayer],
1390            &[LastInt, LastString],
1391            &corrupt,
1392            &[],
1393            &[],
1394            &[],
1395            false,
1396        );
1397    }
1398    for name in [
1399        "p_get_suggestion",
1400        "p_next_suggestions",
1401        "p_prev_suggestions",
1402        "p_request_more_suggestions",
1403        "p_rest",
1404        "p_temprun",
1405    ] {
1406        add(name, &[PActivePlayer], &[], &[], &[], &[], &[], false);
1407    }
1408    add(
1409        "p_finduid",
1410        &[],
1411        &[PActivePlayer, ActivePlayer],
1412        &[],
1413        &[],
1414        &[PActivePlayer2, ActivePlayer2],
1415        &[],
1416        true,
1417    );
1418    add(
1419        "p_locmerge",
1420        &[PActivePlayer, ActiveLoc],
1421        &[],
1422        &[],
1423        &[],
1424        &[],
1425        &[],
1426        false,
1427    );
1428    add("p_logout", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1429    add(
1430        "p_preventlogout",
1431        &[PActivePlayer],
1432        &[],
1433        &[],
1434        &[PActivePlayer2],
1435        &[],
1436        &[],
1437        false,
1438    );
1439    add("p_opheld", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1440    add(
1441        "p_oploc",
1442        &[PActivePlayer, ActiveLoc],
1443        &[],
1444        &[],
1445        &[PActivePlayer2, ActiveLoc],
1446        &[],
1447        &[],
1448        false,
1449    );
1450    add(
1451        "p_opnpc",
1452        &[PActivePlayer, ActiveNpc],
1453        &[],
1454        &[],
1455        &[],
1456        &[],
1457        &[],
1458        false,
1459    );
1460    add(
1461        "p_opnpct",
1462        &[PActivePlayer, ActiveNpc],
1463        &[],
1464        &[],
1465        &[],
1466        &[],
1467        &[],
1468        false,
1469    );
1470    add(
1471        "p_opobj",
1472        &[PActivePlayer, ActiveObj],
1473        &[],
1474        &[],
1475        &[PActivePlayer2, ActiveObj],
1476        &[],
1477        &[],
1478        false,
1479    );
1480    add(
1481        "p_opplayer",
1482        &[PActivePlayer, ActivePlayer2],
1483        &[],
1484        &[],
1485        &[PActivePlayer2, ActivePlayer],
1486        &[],
1487        &[],
1488        false,
1489    );
1490    add(
1491        "p_opplayert",
1492        &[PActivePlayer, ActivePlayer2],
1493        &[],
1494        &[],
1495        &[PActivePlayer2, ActivePlayer],
1496        &[],
1497        &[],
1498        false,
1499    );
1500    {
1501        // p_pausebutton: sets last_com, corrupts everything except active + last_com
1502        let mut corrupt = delay_corrupt.clone();
1503        corrupt.retain(|p| *p != LastCom);
1504        add(
1505            "p_pausebutton",
1506            &[PActivePlayer],
1507            &[LastCom],
1508            &corrupt,
1509            &[PActivePlayer2],
1510            &[LastCom],
1511            &corrupt,
1512            false,
1513        );
1514    }
1515    add(
1516        "p_stopaction",
1517        &[PActivePlayer],
1518        &[],
1519        &[],
1520        &[PActivePlayer2],
1521        &[],
1522        &[],
1523        false,
1524    );
1525    add(
1526        "p_clearpendingaction",
1527        &[PActivePlayer],
1528        &[],
1529        &[],
1530        &[PActivePlayer2],
1531        &[],
1532        &[],
1533        false,
1534    );
1535    add(
1536        "p_telejump",
1537        &[PActivePlayer],
1538        &[],
1539        &[],
1540        &[PActivePlayer2],
1541        &[],
1542        &[],
1543        false,
1544    );
1545    add(
1546        "p_teleport",
1547        &[PActivePlayer],
1548        &[],
1549        &[],
1550        &[PActivePlayer2],
1551        &[],
1552        &[],
1553        false,
1554    );
1555    add(
1556        "p_walk",
1557        &[PActivePlayer],
1558        &[],
1559        &[],
1560        &[PActivePlayer2],
1561        &[],
1562        &[],
1563        false,
1564    );
1565    add(
1566        "projanim_pl",
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        "queue*",
1587        &[ActivePlayer],
1588        &[],
1589        &[],
1590        &[ActivePlayer2],
1591        &[],
1592        &[],
1593        false,
1594    );
1595    add(
1596        "say",
1597        &[ActivePlayer],
1598        &[],
1599        &[],
1600        &[ActivePlayer2],
1601        &[],
1602        &[],
1603        false,
1604    );
1605    add("setidkit", &[PActivePlayer], &[], &[], &[], &[], &[], false);
1606    add(
1607        "walktrigger",
1608        &[ActivePlayer],
1609        &[],
1610        &[],
1611        &[ActivePlayer2],
1612        &[],
1613        &[],
1614        false,
1615    );
1616    add(
1617        "getwalktrigger",
1618        &[ActivePlayer],
1619        &[],
1620        &[],
1621        &[ActivePlayer2],
1622        &[],
1623        &[],
1624        false,
1625    );
1626    add(
1627        "settimer",
1628        &[ActivePlayer],
1629        &[],
1630        &[],
1631        &[ActivePlayer2],
1632        &[],
1633        &[],
1634        false,
1635    );
1636    add(
1637        "softtimer",
1638        &[ActivePlayer],
1639        &[],
1640        &[],
1641        &[ActivePlayer2],
1642        &[],
1643        &[],
1644        false,
1645    );
1646    add(
1647        "sound_synth",
1648        &[ActivePlayer],
1649        &[],
1650        &[],
1651        &[ActivePlayer2],
1652        &[],
1653        &[],
1654        false,
1655    );
1656    add(
1657        "spotanim_pl",
1658        &[ActivePlayer],
1659        &[],
1660        &[],
1661        &[ActivePlayer2],
1662        &[],
1663        &[],
1664        false,
1665    );
1666    add(
1667        "staffmodlevel",
1668        &[ActivePlayer],
1669        &[],
1670        &[],
1671        &[ActivePlayer2],
1672        &[],
1673        &[],
1674        false,
1675    );
1676    add(
1677        "stat",
1678        &[ActivePlayer],
1679        &[],
1680        &[],
1681        &[ActivePlayer2],
1682        &[],
1683        &[],
1684        false,
1685    );
1686    add(
1687        "stat_add",
1688        &[ActivePlayer],
1689        &[],
1690        &[],
1691        &[ActivePlayer2],
1692        &[],
1693        &[],
1694        false,
1695    );
1696    add(
1697        "stat_base",
1698        &[ActivePlayer],
1699        &[],
1700        &[],
1701        &[ActivePlayer2],
1702        &[],
1703        &[],
1704        false,
1705    );
1706    add(
1707        "stat_heal",
1708        &[ActivePlayer],
1709        &[],
1710        &[],
1711        &[ActivePlayer2],
1712        &[],
1713        &[],
1714        false,
1715    );
1716    add(
1717        "stat_sub",
1718        &[ActivePlayer],
1719        &[],
1720        &[],
1721        &[ActivePlayer2],
1722        &[],
1723        &[],
1724        false,
1725    );
1726    add(
1727        "stat_boost",
1728        &[ActivePlayer],
1729        &[],
1730        &[],
1731        &[ActivePlayer2],
1732        &[],
1733        &[],
1734        false,
1735    );
1736    add(
1737        "stat_drain",
1738        &[ActivePlayer],
1739        &[],
1740        &[],
1741        &[ActivePlayer2],
1742        &[],
1743        &[],
1744        false,
1745    );
1746    add(
1747        "stat_random",
1748        &[ActivePlayer],
1749        &[],
1750        &[],
1751        &[ActivePlayer2],
1752        &[],
1753        &[],
1754        false,
1755    );
1756    add(
1757        "uid",
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        "weakqueue*",
1778        &[ActivePlayer],
1779        &[],
1780        &[],
1781        &[ActivePlayer2],
1782        &[],
1783        &[],
1784        false,
1785    );
1786    add(
1787        "findhero",
1788        &[ActivePlayer],
1789        &[ActivePlayer2],
1790        &[PActivePlayer2],
1791        &[ActivePlayer2],
1792        &[ActivePlayer2],
1793        &[PActivePlayer2],
1794        true,
1795    );
1796    add(
1797        "both_heropoints",
1798        &[ActivePlayer, ActivePlayer2],
1799        &[],
1800        &[],
1801        &[ActivePlayer2, ActivePlayer],
1802        &[],
1803        &[],
1804        false,
1805    );
1806    add(
1807        "setgender",
1808        &[PActivePlayer],
1809        &[],
1810        &[],
1811        &[],
1812        &[],
1813        &[],
1814        false,
1815    );
1816    add(
1817        "setidkcolour",
1818        &[PActivePlayer],
1819        &[],
1820        &[],
1821        &[],
1822        &[],
1823        &[],
1824        false,
1825    );
1826    add(
1827        "p_animprotect",
1828        &[PActivePlayer],
1829        &[],
1830        &[],
1831        &[PActivePlayer2],
1832        &[],
1833        &[],
1834        false,
1835    );
1836    add(
1837        "runenergy",
1838        &[ActivePlayer],
1839        &[],
1840        &[],
1841        &[ActivePlayer2],
1842        &[],
1843        &[],
1844        false,
1845    );
1846    add(
1847        "weight",
1848        &[PActivePlayer],
1849        &[],
1850        &[],
1851        &[PActivePlayer2],
1852        &[],
1853        &[],
1854        false,
1855    );
1856    add(
1857        "p_run",
1858        &[PActivePlayer],
1859        &[],
1860        &[],
1861        &[PActivePlayer2],
1862        &[],
1863        &[],
1864        false,
1865    );
1866    add(
1867        "if_setscrollpos",
1868        &[ActivePlayer],
1869        &[],
1870        &[],
1871        &[],
1872        &[],
1873        &[],
1874        false,
1875    );
1876    add(
1877        "if_movesub",
1878        &[ActivePlayer],
1879        &[],
1880        &[],
1881        &[],
1882        &[],
1883        &[],
1884        false,
1885    );
1886    add(
1887        "set_player_op",
1888        &[ActivePlayer],
1889        &[],
1890        &[],
1891        &[],
1892        &[],
1893        &[],
1894        false,
1895    );
1896    add(
1897        "set_skill_level",
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    add(
1917        "strongqueue*",
1918        &[ActivePlayer],
1919        &[],
1920        &[],
1921        &[ActivePlayer2],
1922        &[],
1923        &[],
1924        false,
1925    );
1926
1927    for name in [
1928        "afk_event",
1929        "applydesign",
1930        "buffer_full",
1931        "getwindowmode",
1932        "hint_coord_slot",
1933        "hint_stop_slot",
1934        "if_closesub",
1935        "if_opensub",
1936        "if_opentop_mode",
1937        "if_setgraphic",
1938        "if_setrecol",
1939        "if_setresumebuttons",
1940        "loc_prefetch",
1941        "lowmemory",
1942        "music_playjingle",
1943        "music_playsong",
1944        "p_projanim_halfsq",
1945        "p_transmogrify",
1946        "playermember",
1947        "runclientscript",
1948        "runclientscriptvararg",
1949        "session_log",
1950        "setskincolour",
1951        "sound_speech_volume",
1952        "sound_speech_stop",
1953        "stat_total",
1954        "wealth_event",
1955    ] {
1956        add(name, &[ActivePlayer], &[], &[], &[], &[], &[], false);
1957    }
1958    // 647 compiles `queue*` and the other `*` queues as `queuevararg` and so on.
1959    for name in [
1960        "bas_readyanim",
1961        "bas_running",
1962        "bas_turnonspot",
1963        "bas_walk_b",
1964        "bas_walk_f",
1965        "bas_walk_l",
1966        "bas_walk_r",
1967        "if_setevents",
1968        "longqueuevararg",
1969        "queuevararg",
1970        "strongqueuevararg",
1971        "weakqueuevararg",
1972    ] {
1973        add(
1974            name,
1975            &[ActivePlayer],
1976            &[],
1977            &[],
1978            &[ActivePlayer2],
1979            &[],
1980            &[],
1981            false,
1982        );
1983    }
1984    add(
1985        "hint_player",
1986        &[ActivePlayer, ActivePlayer2],
1987        &[],
1988        &[],
1989        &[ActivePlayer2, ActivePlayer],
1990        &[],
1991        &[],
1992        false,
1993    );
1994    add(
1995        "last_targetcom",
1996        &[ActivePlayer, LastTargetslot],
1997        &[],
1998        &[],
1999        &[],
2000        &[],
2001        &[],
2002        false,
2003    );
2004    add(
2005        "player_findallzone",
2006        &[],
2007        &[FindPlayer],
2008        &[],
2009        &[],
2010        &[],
2011        &[],
2012        false,
2013    );
2014    add(
2015        "player_findnext",
2016        &[FindPlayer],
2017        &[ActivePlayer],
2018        &[PActivePlayer],
2019        &[FindPlayer],
2020        &[ActivePlayer2],
2021        &[PActivePlayer2],
2022        true,
2023    );
2024
2025    // -----------------------------------------------------------------------
2026    // NPC ops
2027    // -----------------------------------------------------------------------
2028    add(
2029        "npc_add",
2030        &[],
2031        &[ActiveNpc],
2032        &[],
2033        &[],
2034        &[ActiveNpc2],
2035        &[],
2036        false,
2037    );
2038    add(
2039        "npc_anim",
2040        &[ActiveNpc],
2041        &[],
2042        &[],
2043        &[ActiveNpc2],
2044        &[],
2045        &[],
2046        false,
2047    );
2048    add(
2049        "npc_basestat",
2050        &[ActiveNpc],
2051        &[],
2052        &[],
2053        &[ActiveNpc2],
2054        &[],
2055        &[],
2056        false,
2057    );
2058    add(
2059        "npc_category",
2060        &[ActiveNpc],
2061        &[],
2062        &[],
2063        &[ActiveNpc2],
2064        &[],
2065        &[],
2066        false,
2067    );
2068    add(
2069        "npc_changetype",
2070        &[ActiveNpc],
2071        &[],
2072        &[],
2073        &[ActiveNpc2],
2074        &[],
2075        &[],
2076        false,
2077    );
2078    add(
2079        "npc_changetype_keepall",
2080        &[ActiveNpc],
2081        &[],
2082        &[],
2083        &[ActiveNpc2],
2084        &[],
2085        &[],
2086        false,
2087    );
2088    add(
2089        "npc_coord",
2090        &[ActiveNpc],
2091        &[],
2092        &[],
2093        &[ActiveNpc2],
2094        &[],
2095        &[],
2096        false,
2097    );
2098    add(
2099        "npc_damage",
2100        &[ActiveNpc],
2101        &[],
2102        &[],
2103        &[ActiveNpc2],
2104        &[],
2105        &[],
2106        false,
2107    );
2108    add(
2109        "npc_del",
2110        &[ActiveNpc],
2111        &[],
2112        &[],
2113        &[ActiveNpc2],
2114        &[],
2115        &[],
2116        false,
2117    );
2118    {
2119        // npc_delay: corrupts p_active_player, p_active_player2, find_*, last_*
2120        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
2121        corrupt.extend_from_slice(find_group);
2122        corrupt.extend_from_slice(&[
2123            LastCom,
2124            LastInt,
2125            LastItem,
2126            LastSlot,
2127            LastTargetslot,
2128            LastUseitem,
2129            LastUseslot,
2130            LastString,
2131            LastCoord,
2132        ]);
2133        add(
2134            "npc_delay",
2135            &[ActiveNpc],
2136            &[],
2137            &corrupt,
2138            &[ActiveNpc2],
2139            &[],
2140            &corrupt,
2141            false,
2142        );
2143    }
2144    add(
2145        "npc_facesquare",
2146        &[ActiveNpc],
2147        &[],
2148        &[],
2149        &[ActiveNpc2],
2150        &[],
2151        &[],
2152        false,
2153    );
2154    add(
2155        "npc_find",
2156        &[],
2157        &[ActiveNpc],
2158        &[],
2159        &[],
2160        &[ActiveNpc2],
2161        &[],
2162        true,
2163    );
2164    add(
2165        "npc_findcat",
2166        &[],
2167        &[ActiveNpc],
2168        &[],
2169        &[],
2170        &[ActiveNpc2],
2171        &[],
2172        true,
2173    );
2174    add(
2175        "npc_findallany",
2176        &[],
2177        &[FindNpc],
2178        &[],
2179        &[],
2180        &[FindNpc],
2181        &[],
2182        false,
2183    );
2184    add(
2185        "npc_findall",
2186        &[],
2187        &[FindNpc],
2188        &[],
2189        &[],
2190        &[FindNpc],
2191        &[],
2192        false,
2193    );
2194    add(
2195        "npc_findallzone",
2196        &[],
2197        &[FindNpc],
2198        &[],
2199        &[],
2200        &[],
2201        &[],
2202        false,
2203    );
2204    add(
2205        "npc_findnext",
2206        &[FindNpc],
2207        &[ActiveNpc],
2208        &[],
2209        &[FindNpc],
2210        &[ActiveNpc2],
2211        &[],
2212        true,
2213    );
2214    add(
2215        "npc_findexact",
2216        &[],
2217        &[ActiveNpc],
2218        &[],
2219        &[],
2220        &[ActiveNpc2],
2221        &[],
2222        true,
2223    );
2224    add(
2225        "npc_findhero",
2226        &[ActiveNpc],
2227        &[ActivePlayer],
2228        &[PActivePlayer],
2229        &[ActiveNpc2],
2230        &[ActivePlayer2],
2231        &[PActivePlayer2],
2232        true,
2233    );
2234    add(
2235        "npc_finduid",
2236        &[],
2237        &[ActiveNpc],
2238        &[],
2239        &[],
2240        &[ActiveNpc2],
2241        &[],
2242        true,
2243    );
2244    add(
2245        "npc_getmode",
2246        &[ActiveNpc],
2247        &[],
2248        &[],
2249        &[ActiveNpc2],
2250        &[],
2251        &[],
2252        false,
2253    );
2254    add(
2255        "npc_heropoints",
2256        &[ActiveNpc, ActivePlayer],
2257        &[],
2258        &[],
2259        &[ActiveNpc2, ActivePlayer, ActivePlayer2],
2260        &[],
2261        &[],
2262        false,
2263    );
2264    add(
2265        "npc_name",
2266        &[ActiveNpc],
2267        &[],
2268        &[],
2269        &[ActiveNpc2],
2270        &[],
2271        &[],
2272        false,
2273    );
2274    add(
2275        "npc_param",
2276        &[ActiveNpc],
2277        &[],
2278        &[],
2279        &[ActiveNpc2],
2280        &[],
2281        &[],
2282        false,
2283    );
2284    add(
2285        "npc_queue",
2286        &[ActiveNpc],
2287        &[],
2288        &[],
2289        &[ActiveNpc2],
2290        &[],
2291        &[],
2292        false,
2293    );
2294    add(
2295        "npc_queuevararg",
2296        &[ActiveNpc],
2297        &[],
2298        &[],
2299        &[ActiveNpc2],
2300        &[],
2301        &[],
2302        false,
2303    );
2304    add(
2305        "npc_range",
2306        &[ActiveNpc],
2307        &[],
2308        &[],
2309        &[ActiveNpc2],
2310        &[],
2311        &[],
2312        false,
2313    );
2314    add(
2315        "npc_say",
2316        &[ActiveNpc],
2317        &[],
2318        &[],
2319        &[ActiveNpc2],
2320        &[],
2321        &[],
2322        false,
2323    );
2324    add(
2325        "npc_sethunt",
2326        &[ActiveNpc],
2327        &[],
2328        &[],
2329        &[ActiveNpc2],
2330        &[],
2331        &[],
2332        false,
2333    );
2334    add(
2335        "npc_sethuntmode",
2336        &[ActiveNpc],
2337        &[],
2338        &[],
2339        &[ActiveNpc2],
2340        &[],
2341        &[],
2342        false,
2343    );
2344    add(
2345        "npc_setmode",
2346        &[ActiveNpc],
2347        &[],
2348        &[],
2349        &[ActiveNpc2],
2350        &[],
2351        &[],
2352        false,
2353    );
2354    add(
2355        "npc_walktrigger",
2356        &[ActiveNpc],
2357        &[],
2358        &[],
2359        &[ActiveNpc2],
2360        &[],
2361        &[],
2362        false,
2363    );
2364    add(
2365        "npc_settimer",
2366        &[ActiveNpc],
2367        &[],
2368        &[],
2369        &[ActiveNpc2],
2370        &[],
2371        &[],
2372        false,
2373    );
2374    add(
2375        "npc_stat",
2376        &[ActiveNpc],
2377        &[],
2378        &[],
2379        &[ActiveNpc2],
2380        &[],
2381        &[],
2382        false,
2383    );
2384    add(
2385        "npc_statadd",
2386        &[ActiveNpc],
2387        &[],
2388        &[],
2389        &[ActiveNpc2],
2390        &[],
2391        &[],
2392        false,
2393    );
2394    add(
2395        "npc_statheal",
2396        &[ActiveNpc],
2397        &[],
2398        &[],
2399        &[ActiveNpc2],
2400        &[],
2401        &[],
2402        false,
2403    );
2404    add(
2405        "npc_statsub",
2406        &[ActiveNpc],
2407        &[],
2408        &[],
2409        &[ActiveNpc2],
2410        &[],
2411        &[],
2412        false,
2413    );
2414    add(
2415        "npc_tele",
2416        &[ActiveNpc],
2417        &[],
2418        &[],
2419        &[ActiveNpc2],
2420        &[],
2421        &[],
2422        false,
2423    );
2424    add(
2425        "npc_type",
2426        &[ActiveNpc],
2427        &[],
2428        &[],
2429        &[ActiveNpc2],
2430        &[],
2431        &[],
2432        false,
2433    );
2434    add(
2435        "npc_uid",
2436        &[ActiveNpc],
2437        &[],
2438        &[],
2439        &[ActiveNpc2],
2440        &[],
2441        &[],
2442        false,
2443    );
2444    add(
2445        "projanim_npc",
2446        &[ActiveNpc],
2447        &[],
2448        &[],
2449        &[ActiveNpc2],
2450        &[],
2451        &[],
2452        false,
2453    );
2454    add(
2455        "spotanim_npc",
2456        &[ActiveNpc],
2457        &[],
2458        &[],
2459        &[ActiveNpc2],
2460        &[],
2461        &[],
2462        false,
2463    );
2464    add(
2465        "npc_walk",
2466        &[ActiveNpc],
2467        &[],
2468        &[],
2469        &[ActiveNpc2],
2470        &[],
2471        &[],
2472        false,
2473    );
2474    // 647: the npc's twin of p_run (walks two tiles a tick while on).
2475    add(
2476        "npc_run",
2477        &[ActiveNpc],
2478        &[],
2479        &[],
2480        &[ActiveNpc2],
2481        &[],
2482        &[],
2483        false,
2484    );
2485    add(
2486        "npc_attackrange",
2487        &[ActiveNpc],
2488        &[],
2489        &[],
2490        &[ActiveNpc2],
2491        &[],
2492        &[],
2493        false,
2494    );
2495    {
2496        // npc_arrivedelay: same corruption set as npc_delay
2497        let mut corrupt: Vec<PointerType> = vec![PActivePlayer, PActivePlayer2];
2498        corrupt.extend_from_slice(find_group);
2499        corrupt.extend_from_slice(&[
2500            LastCom,
2501            LastInt,
2502            LastItem,
2503            LastSlot,
2504            LastTargetslot,
2505            LastUseitem,
2506            LastUseslot,
2507            LastString,
2508            LastCoord,
2509        ]);
2510        add(
2511            "npc_arrivedelay",
2512            &[ActiveNpc],
2513            &[],
2514            &corrupt,
2515            &[ActiveNpc2],
2516            &[],
2517            &[],
2518            false,
2519        );
2520    }
2521    add(
2522        "npc_inrange",
2523        &[ActiveNpc],
2524        &[],
2525        &[],
2526        &[ActiveNpc2],
2527        &[],
2528        &[],
2529        false,
2530    );
2531
2532    add(
2533        "npc_destination",
2534        &[ActiveNpc],
2535        &[],
2536        &[],
2537        &[ActiveNpc2],
2538        &[],
2539        &[],
2540        false,
2541    );
2542    add(
2543        "npc_huntnext",
2544        &[FindNpc],
2545        &[ActiveNpc],
2546        &[],
2547        &[FindNpc],
2548        &[ActiveNpc2],
2549        &[],
2550        true,
2551    );
2552    add(
2553        "npc_projanim_halfsq",
2554        &[ActiveNpc],
2555        &[],
2556        &[],
2557        &[],
2558        &[],
2559        &[],
2560        false,
2561    );
2562
2563    // -----------------------------------------------------------------------
2564    // Loc ops
2565    // -----------------------------------------------------------------------
2566    add(
2567        "loc_add",
2568        &[],
2569        &[ActiveLoc],
2570        &[],
2571        &[],
2572        &[ActiveLoc2],
2573        &[],
2574        false,
2575    );
2576    add(
2577        "loc_angle",
2578        &[ActiveLoc],
2579        &[],
2580        &[],
2581        &[ActiveLoc2],
2582        &[],
2583        &[],
2584        false,
2585    );
2586    add(
2587        "loc_anim",
2588        &[ActiveLoc],
2589        &[],
2590        &[],
2591        &[ActiveLoc2],
2592        &[],
2593        &[],
2594        false,
2595    );
2596    add(
2597        "loc_category",
2598        &[ActiveLoc],
2599        &[],
2600        &[],
2601        &[ActiveLoc2],
2602        &[],
2603        &[],
2604        false,
2605    );
2606    add(
2607        "loc_change",
2608        &[ActiveLoc],
2609        &[],
2610        &[],
2611        &[ActiveLoc2],
2612        &[],
2613        &[],
2614        false,
2615    );
2616    add(
2617        "loc_coord",
2618        &[ActiveLoc],
2619        &[],
2620        &[],
2621        &[ActiveLoc2],
2622        &[],
2623        &[],
2624        false,
2625    );
2626    add(
2627        "loc_del",
2628        &[ActiveLoc],
2629        &[],
2630        &[],
2631        &[ActiveLoc2],
2632        &[],
2633        &[],
2634        false,
2635    );
2636    add(
2637        "loc_find",
2638        &[],
2639        &[ActiveLoc],
2640        &[],
2641        &[],
2642        &[ActiveLoc2],
2643        &[],
2644        true,
2645    );
2646    add(
2647        "loc_findallzone",
2648        &[],
2649        &[FindLoc],
2650        &[],
2651        &[],
2652        &[FindLoc],
2653        &[],
2654        false,
2655    );
2656    add(
2657        "loc_findnext",
2658        &[FindLoc],
2659        &[ActiveLoc],
2660        &[],
2661        &[FindLoc],
2662        &[ActiveLoc2],
2663        &[],
2664        true,
2665    );
2666    add(
2667        "loc_name",
2668        &[ActiveLoc],
2669        &[],
2670        &[],
2671        &[ActiveLoc2],
2672        &[],
2673        &[],
2674        false,
2675    );
2676    add(
2677        "loc_param",
2678        &[ActiveLoc],
2679        &[],
2680        &[],
2681        &[ActiveLoc2],
2682        &[],
2683        &[],
2684        false,
2685    );
2686    add(
2687        "loc_shape",
2688        &[ActiveLoc],
2689        &[],
2690        &[],
2691        &[ActiveLoc2],
2692        &[],
2693        &[],
2694        false,
2695    );
2696    add(
2697        "loc_type",
2698        &[ActiveLoc],
2699        &[],
2700        &[],
2701        &[ActiveLoc2],
2702        &[],
2703        &[],
2704        false,
2705    );
2706
2707    add("loc_merge", &[ActiveLoc], &[], &[], &[], &[], &[], false);
2708
2709    // -----------------------------------------------------------------------
2710    // Obj ops
2711    // -----------------------------------------------------------------------
2712    add(
2713        "obj_add",
2714        &[ActivePlayer],
2715        &[ActiveObj],
2716        &[],
2717        &[ActivePlayer2],
2718        &[ActiveObj2],
2719        &[],
2720        false,
2721    );
2722    add(
2723        "obj_addall",
2724        &[],
2725        &[ActiveObj],
2726        &[],
2727        &[],
2728        &[ActiveObj2],
2729        &[],
2730        false,
2731    );
2732    add(
2733        "obj_coord",
2734        &[ActiveObj],
2735        &[],
2736        &[],
2737        &[ActiveObj2],
2738        &[],
2739        &[],
2740        false,
2741    );
2742    add(
2743        "obj_count",
2744        &[ActiveObj],
2745        &[],
2746        &[],
2747        &[ActiveObj2],
2748        &[],
2749        &[],
2750        false,
2751    );
2752    add(
2753        "obj_del",
2754        &[ActiveObj],
2755        &[],
2756        &[],
2757        &[ActiveObj2],
2758        &[],
2759        &[],
2760        false,
2761    );
2762    add(
2763        "obj_name",
2764        &[ActiveObj],
2765        &[],
2766        &[],
2767        &[ActiveObj2],
2768        &[],
2769        &[],
2770        false,
2771    );
2772    add(
2773        "obj_param",
2774        &[ActiveObj],
2775        &[],
2776        &[],
2777        &[ActiveObj2],
2778        &[],
2779        &[],
2780        false,
2781    );
2782    add(
2783        "obj_getvar",
2784        &[ActiveObj],
2785        &[],
2786        &[],
2787        &[ActiveObj2],
2788        &[],
2789        &[],
2790        false,
2791    );
2792    add(
2793        "obj_setvar",
2794        &[ActiveObj],
2795        &[],
2796        &[],
2797        &[ActiveObj2],
2798        &[],
2799        &[],
2800        false,
2801    );
2802    add(
2803        "obj_takeitem",
2804        &[ActiveObj, ActivePlayer],
2805        &[],
2806        &[],
2807        &[ActiveObj2, ActivePlayer2],
2808        &[],
2809        &[],
2810        false,
2811    );
2812    add(
2813        "obj_type",
2814        &[ActiveObj],
2815        &[],
2816        &[],
2817        &[ActiveObj2],
2818        &[],
2819        &[],
2820        false,
2821    );
2822    add(
2823        "obj_find",
2824        &[],
2825        &[ActiveObj],
2826        &[],
2827        &[],
2828        &[ActiveObj2],
2829        &[],
2830        true,
2831    );
2832    add(
2833        "obj_findallzone",
2834        &[],
2835        &[FindObj],
2836        &[],
2837        &[],
2838        &[FindObj],
2839        &[],
2840        false,
2841    );
2842    add(
2843        "obj_findnext",
2844        &[FindObj],
2845        &[ActiveObj],
2846        &[],
2847        &[FindObj],
2848        &[ActiveObj2],
2849        &[],
2850        true,
2851    );
2852
2853    // -----------------------------------------------------------------------
2854    // Inventory ops
2855    // -----------------------------------------------------------------------
2856    add(
2857        "inv_add",
2858        &[ActivePlayer],
2859        &[],
2860        &[],
2861        &[ActivePlayer2],
2862        &[],
2863        &[],
2864        false,
2865    );
2866    add(
2867        "inv_changeslot",
2868        &[ActivePlayer],
2869        &[],
2870        &[],
2871        &[ActivePlayer2],
2872        &[],
2873        &[],
2874        false,
2875    );
2876    add(
2877        "inv_clear",
2878        &[ActivePlayer],
2879        &[],
2880        &[],
2881        &[ActivePlayer2],
2882        &[],
2883        &[],
2884        false,
2885    );
2886    add(
2887        "inv_del",
2888        &[ActivePlayer],
2889        &[],
2890        &[],
2891        &[ActivePlayer2],
2892        &[],
2893        &[],
2894        false,
2895    );
2896    add(
2897        "inv_delslot",
2898        &[ActivePlayer],
2899        &[],
2900        &[],
2901        &[ActivePlayer2],
2902        &[],
2903        &[],
2904        false,
2905    );
2906    add(
2907        "inv_dropitem",
2908        &[ActivePlayer],
2909        &[ActiveObj],
2910        &[],
2911        &[ActivePlayer2],
2912        &[ActiveObj2],
2913        &[],
2914        false,
2915    );
2916    add(
2917        "inv_dropitem_delayed",
2918        &[ActivePlayer],
2919        &[ActiveObj],
2920        &[],
2921        &[ActivePlayer2],
2922        &[ActiveObj2],
2923        &[],
2924        false,
2925    );
2926    add(
2927        "inv_dropslot",
2928        &[ActivePlayer],
2929        &[ActiveObj],
2930        &[],
2931        &[ActivePlayer2],
2932        &[ActiveObj2],
2933        &[],
2934        false,
2935    );
2936    add(
2937        "inv_freespace",
2938        &[ActivePlayer],
2939        &[],
2940        &[],
2941        &[ActivePlayer2],
2942        &[],
2943        &[],
2944        false,
2945    );
2946    add(
2947        "inv_getnum",
2948        &[ActivePlayer],
2949        &[],
2950        &[],
2951        &[ActivePlayer2],
2952        &[],
2953        &[],
2954        false,
2955    );
2956    add(
2957        "inv_getobj",
2958        &[ActivePlayer],
2959        &[],
2960        &[],
2961        &[ActivePlayer2],
2962        &[],
2963        &[],
2964        false,
2965    );
2966    add(
2967        "inv_getvar",
2968        &[ActivePlayer],
2969        &[],
2970        &[],
2971        &[ActivePlayer2],
2972        &[],
2973        &[],
2974        false,
2975    );
2976    add(
2977        "inv_itemspace",
2978        &[ActivePlayer],
2979        &[],
2980        &[],
2981        &[ActivePlayer2],
2982        &[],
2983        &[],
2984        false,
2985    );
2986    add(
2987        "inv_itemspace2",
2988        &[ActivePlayer],
2989        &[],
2990        &[],
2991        &[ActivePlayer2],
2992        &[],
2993        &[],
2994        false,
2995    );
2996    add(
2997        "inv_movefromslot",
2998        &[ActivePlayer],
2999        &[],
3000        &[],
3001        &[ActivePlayer2],
3002        &[],
3003        &[],
3004        false,
3005    );
3006    add(
3007        "inv_movetoslot",
3008        &[ActivePlayer],
3009        &[],
3010        &[],
3011        &[ActivePlayer2],
3012        &[],
3013        &[],
3014        false,
3015    );
3016    add(
3017        "both_moveinv",
3018        &[ActivePlayer, ActivePlayer2],
3019        &[],
3020        &[],
3021        &[ActivePlayer2, ActivePlayer],
3022        &[],
3023        &[],
3024        false,
3025    );
3026    add(
3027        "inv_moveitem",
3028        &[ActivePlayer],
3029        &[],
3030        &[],
3031        &[ActivePlayer2],
3032        &[],
3033        &[],
3034        false,
3035    );
3036    add(
3037        "inv_moveitem_cert",
3038        &[ActivePlayer],
3039        &[],
3040        &[],
3041        &[ActivePlayer2],
3042        &[],
3043        &[],
3044        false,
3045    );
3046    add(
3047        "inv_moveitem_uncert",
3048        &[ActivePlayer],
3049        &[],
3050        &[],
3051        &[ActivePlayer2],
3052        &[],
3053        &[],
3054        false,
3055    );
3056    add(
3057        "inv_setslot",
3058        &[ActivePlayer],
3059        &[],
3060        &[],
3061        &[ActivePlayer2],
3062        &[],
3063        &[],
3064        false,
3065    );
3066    add(
3067        "inv_setvar",
3068        &[ActivePlayer],
3069        &[],
3070        &[],
3071        &[ActivePlayer2],
3072        &[],
3073        &[],
3074        false,
3075    );
3076    add(
3077        "inv_total",
3078        &[ActivePlayer],
3079        &[],
3080        &[],
3081        &[ActivePlayer2],
3082        &[],
3083        &[],
3084        false,
3085    );
3086    add(
3087        "inv_totalcat",
3088        &[ActivePlayer],
3089        &[],
3090        &[],
3091        &[ActivePlayer2],
3092        &[],
3093        &[],
3094        false,
3095    );
3096    add(
3097        "inv_transmit",
3098        &[ActivePlayer],
3099        &[],
3100        &[],
3101        &[ActivePlayer2],
3102        &[],
3103        &[],
3104        false,
3105    );
3106    add(
3107        "invother_transmit",
3108        &[ActivePlayer, ActivePlayer2],
3109        &[],
3110        &[],
3111        &[ActivePlayer2, ActivePlayer],
3112        &[],
3113        &[],
3114        false,
3115    );
3116    add(
3117        "inv_stoptransmit",
3118        &[ActivePlayer],
3119        &[],
3120        &[],
3121        &[ActivePlayer2],
3122        &[],
3123        &[],
3124        false,
3125    );
3126    add(
3127        "both_dropslot",
3128        &[ActivePlayer, ActivePlayer2],
3129        &[],
3130        &[],
3131        &[ActivePlayer2, ActivePlayer],
3132        &[],
3133        &[],
3134        false,
3135    );
3136    add(
3137        "inv_dropall",
3138        &[ActivePlayer],
3139        &[],
3140        &[],
3141        &[ActivePlayer2],
3142        &[],
3143        &[],
3144        false,
3145    );
3146    add(
3147        "inv_totalparam",
3148        &[ActivePlayer],
3149        &[],
3150        &[],
3151        &[ActivePlayer2],
3152        &[],
3153        &[],
3154        false,
3155    );
3156    add(
3157        "inv_totalparam_stack",
3158        &[ActivePlayer],
3159        &[],
3160        &[],
3161        &[ActivePlayer2],
3162        &[],
3163        &[],
3164        false,
3165    );
3166
3167    // -----------------------------------------------------------------------
3168    // String ops
3169    // -----------------------------------------------------------------------
3170    add(
3171        "text_gender",
3172        &[ActivePlayer],
3173        &[],
3174        &[],
3175        &[ActivePlayer2],
3176        &[],
3177        &[],
3178        false,
3179    );
3180
3181    // -----------------------------------------------------------------------
3182    // Controller ops
3183    // -----------------------------------------------------------------------
3184    for name in [
3185        "controller_coord",
3186        "controller_queue",
3187        "controller_queuevararg",
3188        "controller_settimer",
3189    ] {
3190        add(
3191            name,
3192            &[ActiveController],
3193            &[],
3194            &[],
3195            &[ActiveController2],
3196            &[],
3197            &[],
3198            false,
3199        );
3200    }
3201    add(
3202        "controller_del",
3203        &[ActiveController],
3204        &[],
3205        &[ActiveController],
3206        &[ActiveController2],
3207        &[],
3208        &[ActiveController2],
3209        false,
3210    );
3211    add(
3212        "controller_add",
3213        &[],
3214        &[ActiveController],
3215        &[],
3216        &[],
3217        &[ActiveController2],
3218        &[],
3219        false,
3220    );
3221    add(
3222        "controller_findexact",
3223        &[],
3224        &[ActiveController],
3225        &[],
3226        &[],
3227        &[ActiveController2],
3228        &[],
3229        true,
3230    );
3231
3232    // -----------------------------------------------------------------------
3233    // Region ops: a region (instance) the script created or found
3234    // -----------------------------------------------------------------------
3235    for name in [
3236        "region_getcoord",
3237        "region_set",
3238        "region_uid",
3239        "region_setexitcoord",
3240    ] {
3241        add(
3242            name,
3243            &[ActiveRegion],
3244            &[],
3245            &[],
3246            &[ActiveRegion2],
3247            &[],
3248            &[],
3249            false,
3250        );
3251    }
3252    add(
3253        "region_create",
3254        &[],
3255        &[ActiveRegion],
3256        &[],
3257        &[],
3258        &[ActiveRegion2],
3259        &[],
3260        false,
3261    );
3262    for name in ["region_findbycoord", "region_findbyuid"] {
3263        add(
3264            name,
3265            &[],
3266            &[ActiveRegion],
3267            &[],
3268            &[],
3269            &[ActiveRegion2],
3270            &[],
3271            true,
3272        );
3273    }
3274
3275    // -----------------------------------------------------------------------
3276    // DB ops
3277    // -----------------------------------------------------------------------
3278    add("db_findnext", &[FindDb], &[], &[], &[], &[], &[], false);
3279    add("db_find", &[], &[FindDb], &[], &[], &[], &[], false);
3280    add("db_find_refine", &[FindDb], &[], &[], &[], &[], &[], false);
3281    add("db_listall", &[], &[FindDb], &[], &[], &[], &[], false);
3282    add(
3283        "db_listall_with_count",
3284        &[],
3285        &[FindDb],
3286        &[],
3287        &[],
3288        &[],
3289        &[],
3290        false,
3291    );
3292
3293    add(
3294        "world_delay",
3295        &[],
3296        &[],
3297        &[PActivePlayer, PActivePlayer2],
3298        &[],
3299        &[],
3300        &[PActivePlayer, PActivePlayer2],
3301        false,
3302    );
3303
3304    // Suspension is part of the command contract, independent of pointer corruption.
3305    for name in [
3306        "world_delay",
3307        "p_arrivedelay",
3308        "p_loaddelay",
3309        "p_countdialog",
3310        "p_stringdialog",
3311        "p_namedialog",
3312        "p_objdialog",
3313        "p_hsldialog",
3314        "p_clanforumqfcdialog",
3315        "p_setdisplayname",
3316        "p_delay",
3317        "p_pausebutton",
3318        "npc_arrivedelay",
3319        "npc_delay",
3320        "test_tick",
3321        "wait_for",
3322    ] {
3323        map.entry(name.into()).or_default().may_suspend = true;
3324        if let Some(secondary) = map.get_mut(&format!(".{name}")) {
3325            secondary.may_suspend = true;
3326        }
3327    }
3328    map
3329}