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