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