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