Skip to main content

runec/
pointer.rs

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