Skip to main content

runec/
pointer.rs

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