Skip to main content

runec/
pointer.rs

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