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