-
Notifications
You must be signed in to change notification settings - Fork 73
/
interpreter.c
1800 lines (1555 loc) · 67 KB
/
interpreter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**************************************************************************
* File: interpreter.c Part of tbaMUD *
* Usage: Parse user commands, search for specials, call ACMD functions. *
* *
* All rights reserved. See license for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "db.h"
#include "spells.h"
#include "handler.h"
#include "mail.h"
#include "screen.h"
#include "genolc.h"
#include "oasis.h"
#include "improved-edit.h"
#include "dg_scripts.h"
#include "constants.h"
#include "act.h" /* ACMDs located within the act*.c files */
#include "ban.h"
#include "class.h"
#include "graph.h"
#include "hedit.h"
#include "house.h"
#include "config.h"
#include "modify.h" /* for do_skillset... */
#include "quest.h"
#include "asciimap.h"
#include "prefedit.h"
#include "ibt.h"
#include "mud_event.h"
/* local (file scope) functions */
static int perform_dupe_check(struct descriptor_data *d);
static struct alias_data *find_alias(struct alias_data *alias_list, char *str);
static void perform_complex_alias(struct txt_q *input_q, char *orig, struct alias_data *a);
static int _parse_name(char *arg, char *name);
static bool perform_new_char_dupe_check(struct descriptor_data *d);
/* sort_commands utility */
static int sort_commands_helper(const void *a, const void *b);
/* globals defined here, used here and elsewhere */
int *cmd_sort_info = NULL;
struct command_info *complete_cmd_info;
/* This is the Master Command List. You can put new commands in, take commands
* out, change the order they appear in, etc. You can adjust the "priority"
* of commands simply by changing the order they appear in the command list.
* (For example, if you want "as" to mean "assist" instead of "ask", just put
* "assist" above "ask" in the Master Command List. In general, utility
* commands such as "at" should have high priority; infrequently used and
* dangerously destructive commands should have low priority. */
cpp_extern const struct command_info cmd_info[] = {
{ "RESERVED", "", 0, 0, 0, 0 }, /* this must be first -- for specprocs */
/* directions must come before other commands but after RESERVED */
{ "north" , "n" , POS_STANDING, do_move , 0, SCMD_NORTH },
{ "east" , "e" , POS_STANDING, do_move , 0, SCMD_EAST },
{ "south" , "s" , POS_STANDING, do_move , 0, SCMD_SOUTH },
{ "west" , "w" , POS_STANDING, do_move , 0, SCMD_WEST },
{ "up" , "u" , POS_STANDING, do_move , 0, SCMD_UP },
{ "down" , "d" , POS_STANDING, do_move , 0, SCMD_DOWN },
{ "northwest", "northw" , POS_STANDING, do_move , 0, SCMD_NW },
{ "nw" , "nw" , POS_STANDING, do_move , 0, SCMD_NW },
{ "northeast", "northe" , POS_STANDING, do_move , 0, SCMD_NE },
{ "ne" , "ne" , POS_STANDING, do_move , 0, SCMD_NE },
{ "southeast", "southe" , POS_STANDING, do_move , 0, SCMD_SE },
{ "se" , "se" , POS_STANDING, do_move , 0, SCMD_SE },
{ "southwest", "southw" , POS_STANDING, do_move , 0, SCMD_SW },
{ "sw" , "sw" , POS_STANDING, do_move , 0, SCMD_SW },
/* now, the main list */
{ "at" , "at" , POS_DEAD , do_at , LVL_IMMORT, 0 },
{ "advance" , "adv" , POS_DEAD , do_advance , LVL_GRGOD, 0 },
{ "aedit" , "aed" , POS_DEAD , do_oasis_aedit, LVL_GOD, 0 },
{ "alias" , "ali" , POS_DEAD , do_alias , 0, 0 },
{ "afk" , "afk" , POS_DEAD , do_gen_tog , 0, SCMD_AFK },
{ "areas" , "are" , POS_DEAD , do_areas , 0, 0 },
{ "assist" , "as" , POS_FIGHTING, do_assist , 1, 0 },
{ "ask" , "ask" , POS_RESTING , do_spec_comm, 0, SCMD_ASK },
{ "astat" , "ast" , POS_DEAD , do_astat , 0, 0 },
{ "attach" , "attach" , POS_DEAD , do_attach , LVL_BUILDER, 0 },
{ "auction" , "auc" , POS_SLEEPING, do_gen_comm , 0, SCMD_AUCTION },
{ "autoexits" , "autoex" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOEXIT },
{ "autoassist","autoass" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOASSIST },
{ "autodoor" , "autodoor", POS_DEAD , do_gen_tog , 0, SCMD_AUTODOOR },
{ "autogold" , "autogold", POS_DEAD , do_gen_tog , 0, SCMD_AUTOGOLD },
{ "autokey" , "autokey" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOKEY },
{ "autoloot" , "autoloot", POS_DEAD , do_gen_tog , 0, SCMD_AUTOLOOT },
{ "automap" , "automap" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOMAP },
{ "autosac" , "autosac" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOSAC },
{ "autosplit", "autospl" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOSPLIT },
{ "backstab" , "ba" , POS_STANDING, do_backstab , 1, 0 },
{ "ban" , "ban" , POS_DEAD , do_ban , LVL_GRGOD, 0 },
{ "bandage" , "band" , POS_RESTING , do_bandage , 1, 0 },
{ "balance" , "bal" , POS_STANDING, do_not_here , 1, 0 },
{ "bash" , "bas" , POS_FIGHTING, do_bash , 1, 0 },
{ "brief" , "br" , POS_DEAD , do_gen_tog , 0, SCMD_BRIEF },
{ "buildwalk", "buildwalk", POS_STANDING, do_gen_tog , LVL_BUILDER, SCMD_BUILDWALK },
{ "buy" , "bu" , POS_STANDING, do_not_here , 0, 0 },
{ "bug" , "bug" , POS_DEAD , do_ibt , 0, SCMD_BUG },
{ "cast" , "c" , POS_SITTING , do_cast , 1, 0 },
{ "cedit" , "cedit" , POS_DEAD , do_oasis_cedit, LVL_IMPL, 0 },
{ "changelog", "cha" , POS_DEAD , do_changelog, LVL_IMPL, 0 },
{ "check" , "ch" , POS_STANDING, do_not_here , 1, 0 },
{ "checkload", "checkl" , POS_DEAD , do_checkloadstatus, LVL_GOD, 0 },
{ "close" , "cl" , POS_SITTING , do_gen_door , 0, SCMD_CLOSE },
{ "clear" , "cle" , POS_DEAD , do_gen_ps , 0, SCMD_CLEAR },
{ "cls" , "cls" , POS_DEAD , do_gen_ps , 0, SCMD_CLEAR },
{ "consider" , "con" , POS_RESTING , do_consider , 0, 0 },
{ "commands" , "com" , POS_DEAD , do_commands , 0, SCMD_COMMANDS },
{ "compact" , "comp" , POS_DEAD , do_gen_tog , 0, SCMD_COMPACT },
{ "copyover" , "copyover", POS_DEAD , do_copyover , LVL_GRGOD, 0 },
{ "credits" , "cred" , POS_DEAD , do_gen_ps , 0, SCMD_CREDITS },
{ "date" , "da" , POS_DEAD , do_date , LVL_IMMORT, SCMD_DATE },
{ "dc" , "dc" , POS_DEAD , do_dc , LVL_GOD, 0 },
{ "deposit" , "depo" , POS_STANDING, do_not_here , 1, 0 },
{ "detach" , "detach" , POS_DEAD , do_detach , LVL_BUILDER, 0 },
{ "diagnose" , "diag" , POS_RESTING , do_diagnose , 0, 0 },
{ "dig" , "dig" , POS_DEAD , do_dig , LVL_BUILDER, 0 },
{ "display" , "disp" , POS_DEAD , do_display , 0, 0 },
{ "donate" , "don" , POS_RESTING , do_drop , 0, SCMD_DONATE },
{ "drink" , "dri" , POS_RESTING , do_drink , 0, SCMD_DRINK },
{ "drop" , "dro" , POS_RESTING , do_drop , 0, SCMD_DROP },
{ "eat" , "ea" , POS_RESTING , do_eat , 0, SCMD_EAT },
{ "echo" , "ec" , POS_SLEEPING, do_echo , LVL_IMMORT, SCMD_ECHO },
{ "emote" , "em" , POS_RESTING , do_echo , 0, SCMD_EMOTE },
{ ":" , ":" , POS_RESTING, do_echo , 1, SCMD_EMOTE },
{ "enter" , "ent" , POS_STANDING, do_enter , 0, 0 },
{ "equipment", "eq" , POS_SLEEPING, do_equipment, 0, 0 },
{ "exits" , "ex" , POS_RESTING , do_exits , 0, 0 },
{ "examine" , "exa" , POS_SITTING , do_examine , 0, 0 },
{ "export" , "export" , POS_DEAD , do_export_zone, LVL_IMPL, 0 },
{ "force" , "force" , POS_SLEEPING, do_force , LVL_GOD, 0 },
{ "fill" , "fil" , POS_STANDING, do_pour , 0, SCMD_FILL },
{ "file" , "file" , POS_SLEEPING, do_file , LVL_GOD, 0 },
{ "flee" , "fl" , POS_FIGHTING, do_flee , 1, 0 },
{ "follow" , "fol" , POS_RESTING , do_follow , 0, 0 },
{ "freeze" , "freeze" , POS_DEAD , do_wizutil , LVL_GRGOD, SCMD_FREEZE },
{ "get" , "g" , POS_RESTING , do_get , 0, 0 },
{ "gecho" , "gecho" , POS_DEAD , do_gecho , LVL_GOD, 0 },
{ "gemote" , "gem" , POS_SLEEPING, do_gen_comm , 0, SCMD_GEMOTE },
{ "give" , "giv" , POS_RESTING , do_give , 0, 0 },
{ "goto" , "go" , POS_SLEEPING, do_goto , LVL_IMMORT, 0 },
{ "gold" , "gol" , POS_RESTING , do_gold , 0, 0 },
{ "gossip" , "gos" , POS_SLEEPING, do_gen_comm , 0, SCMD_GOSSIP },
{ "group" , "gr" , POS_RESTING , do_group , 1, 0 },
{ "grab" , "grab" , POS_RESTING , do_grab , 0, 0 },
{ "grats" , "grat" , POS_SLEEPING, do_gen_comm , 0, SCMD_GRATZ },
{ "gsay" , "gsay" , POS_SLEEPING, do_gsay , 0, 0 },
{ "gtell" , "gt" , POS_SLEEPING, do_gsay , 0, 0 },
{ "help" , "h" , POS_DEAD , do_help , 0, 0 },
{ "happyhour", "ha" , POS_DEAD , do_happyhour, 0, 0 },
{ "hedit" , "hedit" , POS_DEAD , do_oasis_hedit, LVL_GOD , 0 },
{ "helpcheck", "helpch" , POS_DEAD , do_helpcheck, LVL_GOD, 0 },
{ "hide" , "hi" , POS_RESTING , do_hide , 1, 0 },
{ "hindex" , "hind" , POS_DEAD , do_hindex , 0, 0 },
{ "handbook" , "handb" , POS_DEAD , do_gen_ps , LVL_IMMORT, SCMD_HANDBOOK },
{ "hcontrol" , "hcontrol", POS_DEAD , do_hcontrol , LVL_GRGOD, 0 },
{ "history" , "history" , POS_DEAD , do_history, 0, 0},
{ "hit" , "hit" , POS_FIGHTING, do_hit , 0, SCMD_HIT },
{ "hold" , "hold" , POS_RESTING , do_grab , 1, 0 },
{ "holler" , "holler" , POS_RESTING , do_gen_comm , 1, SCMD_HOLLER },
{ "holylight", "holy" , POS_DEAD , do_gen_tog , LVL_IMMORT, SCMD_HOLYLIGHT },
{ "house" , "house" , POS_RESTING , do_house , 0, 0 },
{ "inventory", "i" , POS_DEAD , do_inventory, 0, 0 },
{ "identify" , "id" , POS_STANDING, do_not_here , 1, 0 },
{ "idea" , "ide" , POS_DEAD , do_ibt , 0, SCMD_IDEA },
{ "imotd" , "imo" , POS_DEAD , do_gen_ps , LVL_IMMORT, SCMD_IMOTD },
{ "immlist" , "imm" , POS_DEAD , do_gen_ps , 0, SCMD_IMMLIST },
{ "info" , "info" , POS_SLEEPING, do_gen_ps , 0, SCMD_INFO },
{ "invis" , "invi" , POS_DEAD , do_invis , LVL_IMMORT, 0 },
{ "junk" , "j" , POS_RESTING , do_drop , 0, SCMD_JUNK },
{ "kill" , "k" , POS_FIGHTING, do_kill , 0, 0 },
{ "kick" , "ki" , POS_FIGHTING, do_kick , 1, 0 },
{ "look" , "l" , POS_RESTING , do_look , 0, SCMD_LOOK },
{ "last" , "last" , POS_DEAD , do_last , LVL_GOD, 0 },
{ "leave" , "lea" , POS_STANDING, do_leave , 0, 0 },
{ "levels" , "lev" , POS_DEAD , do_levels , 0, 0 },
{ "list" , "lis" , POS_STANDING, do_not_here , 0, 0 },
{ "links" , "lin" , POS_STANDING, do_links , LVL_GOD, 0 },
{ "lock" , "loc" , POS_SITTING , do_gen_door , 0, SCMD_LOCK },
{ "load" , "load" , POS_DEAD , do_load , LVL_BUILDER, 0 },
{ "motd" , "motd" , POS_DEAD , do_gen_ps , 0, SCMD_MOTD },
{ "mail" , "mail" , POS_STANDING, do_not_here , 1, 0 },
{ "map" , "map" , POS_STANDING, do_map , 1, 0 },
{ "medit" , "med" , POS_DEAD , do_oasis_medit, LVL_BUILDER, 0 },
{ "mlist" , "mlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_MLIST },
{ "mcopy" , "mcopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_MEDIT },
{ "msgedit" , "msgedit" , POS_DEAD , do_msgedit, LVL_GOD, 0 },
{ "mute" , "mute" , POS_DEAD , do_wizutil , LVL_GOD, SCMD_MUTE },
{ "news" , "news" , POS_SLEEPING, do_gen_ps , 0, SCMD_NEWS },
{ "noauction", "noauction",POS_DEAD , do_gen_tog , 0, SCMD_NOAUCTION },
{ "nogossip" , "nogossip", POS_DEAD , do_gen_tog , 0, SCMD_NOGOSSIP },
{ "nograts" , "nograts" , POS_DEAD , do_gen_tog , 0, SCMD_NOGRATZ },
{ "nohassle" , "nohassle", POS_DEAD , do_gen_tog , LVL_IMMORT, SCMD_NOHASSLE },
{ "norepeat" , "norepeat", POS_DEAD , do_gen_tog , 0, SCMD_NOREPEAT },
{ "noshout" , "noshout" , POS_SLEEPING, do_gen_tog , 1, SCMD_NOSHOUT },
{ "nosummon" , "nosummon", POS_DEAD , do_gen_tog , 1, SCMD_NOSUMMON },
{ "notell" , "notell" , POS_DEAD , do_gen_tog , 1, SCMD_NOTELL },
{ "notitle" , "notitle" , POS_DEAD , do_wizutil , LVL_GOD, SCMD_NOTITLE },
{ "nowiz" , "nowiz" , POS_DEAD , do_gen_tog , LVL_IMMORT, SCMD_NOWIZ },
{ "open" , "o" , POS_SITTING , do_gen_door , 0, SCMD_OPEN },
{ "order" , "ord" , POS_RESTING , do_order , 1, 0 },
{ "offer" , "off" , POS_STANDING, do_not_here , 1, 0 },
{ "olc" , "olc" , POS_DEAD , do_show_save_list, LVL_BUILDER, 0 },
{ "olist" , "olist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_OLIST },
{ "oedit" , "oedit" , POS_DEAD , do_oasis_oedit, LVL_BUILDER, 0 },
{ "oset" , "oset" , POS_DEAD , do_oset, LVL_BUILDER, 0 },
{ "ocopy" , "ocopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_OEDIT },
{ "put" , "p" , POS_RESTING , do_put , 0, 0 },
{ "peace" , "pe" , POS_DEAD , do_peace , LVL_BUILDER, 0 },
{ "pick" , "pi" , POS_STANDING, do_gen_door , 1, SCMD_PICK },
{ "practice" , "pr" , POS_RESTING , do_practice , 1, 0 },
{ "page" , "pag" , POS_DEAD , do_page , 1, 0 },
{ "pardon" , "pardon" , POS_DEAD , do_wizutil , LVL_GOD, SCMD_PARDON },
{ "plist" , "plist" , POS_DEAD , do_plist , LVL_GOD, 0 },
{ "policy" , "pol" , POS_DEAD , do_gen_ps , 0, SCMD_POLICIES },
{ "pour" , "pour" , POS_STANDING, do_pour , 0, SCMD_POUR },
{ "prompt" , "pro" , POS_DEAD , do_display , 0, 0 },
{ "prefedit" , "pre" , POS_DEAD , do_oasis_prefedit , 0, 0 },
{ "purge" , "purge" , POS_DEAD , do_purge , LVL_BUILDER, 0 },
{ "qedit" , "qedit" , POS_DEAD , do_oasis_qedit, LVL_BUILDER, 0 },
{ "qlist" , "qlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_QLIST },
{ "quaff" , "qua" , POS_RESTING , do_use , 0, SCMD_QUAFF },
{ "qecho" , "qec" , POS_DEAD , do_qcomm , LVL_GOD, SCMD_QECHO },
{ "quest" , "que" , POS_DEAD , do_quest , 0, 0 },
{ "qui" , "qui" , POS_DEAD , do_quit , 0, 0 },
{ "quit" , "quit" , POS_DEAD , do_quit , 0, SCMD_QUIT },
{ "qsay" , "qsay" , POS_RESTING , do_qcomm , 0, SCMD_QSAY },
{ "reply" , "r" , POS_SLEEPING, do_reply , 0, 0 },
{ "rest" , "res" , POS_RESTING , do_rest , 0, 0 },
{ "read" , "rea" , POS_RESTING , do_look , 0, SCMD_READ },
{ "reload" , "reload" , POS_DEAD , do_reboot , LVL_IMPL, 0 },
{ "recite" , "reci" , POS_RESTING , do_use , 0, SCMD_RECITE },
{ "receive" , "rece" , POS_STANDING, do_not_here , 1, 0 },
{ "recent" , "recent" , POS_DEAD , do_recent , LVL_IMMORT, 0 },
{ "remove" , "rem" , POS_RESTING , do_remove , 0, 0 },
{ "rent" , "rent" , POS_STANDING, do_not_here , 1, 0 },
{ "report" , "repo" , POS_RESTING , do_report , 0, 0 },
{ "reroll" , "rero" , POS_DEAD , do_wizutil , LVL_GRGOD, SCMD_REROLL },
{ "rescue" , "resc" , POS_FIGHTING, do_rescue , 1, 0 },
{ "restore" , "resto" , POS_DEAD , do_restore , LVL_GOD, 0 },
{ "return" , "retu" , POS_DEAD , do_return , 0, 0 },
{ "redit" , "redit" , POS_DEAD , do_oasis_redit, LVL_BUILDER, 0 },
{ "rlist" , "rlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_RLIST },
{ "rcopy" , "rcopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_REDIT },
{ "roomflags", "roomflags", POS_DEAD , do_gen_tog , LVL_IMMORT, SCMD_SHOWVNUMS },
{ "sacrifice", "sac" , POS_RESTING , do_sac , 0, 0 },
{ "say" , "s" , POS_RESTING , do_say , 0, 0 },
{ "score" , "sc" , POS_DEAD , do_score , 0, 0 },
{ "scan" , "sca" , POS_RESTING , do_scan , 0, 0 },
{ "scopy" , "scopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_SEDIT },
{ "sit" , "si" , POS_RESTING , do_sit , 0, 0 },
{ "'" , "'" , POS_RESTING , do_say , 0, 0 },
{ "save" , "sav" , POS_SLEEPING, do_save , 0, 0 },
{ "saveall" , "saveall" , POS_DEAD , do_saveall , LVL_BUILDER, 0},
{ "sell" , "sell" , POS_STANDING, do_not_here , 0, 0 },
{ "sedit" , "sedit" , POS_DEAD , do_oasis_sedit, LVL_BUILDER, 0 },
{ "send" , "send" , POS_SLEEPING, do_send , LVL_GOD, 0 },
{ "set" , "set" , POS_DEAD , do_set , LVL_IMMORT, 0 },
{ "shout" , "sho" , POS_RESTING , do_gen_comm , 0, SCMD_SHOUT },
{ "show" , "show" , POS_DEAD , do_show , LVL_IMMORT, 0 },
{ "shutdow" , "shutdow" , POS_DEAD , do_shutdown , LVL_IMPL, 0 },
{ "shutdown" , "shutdown", POS_DEAD , do_shutdown , LVL_IMPL, SCMD_SHUTDOWN },
{ "sip" , "sip" , POS_RESTING , do_drink , 0, SCMD_SIP },
{ "skillset" , "skillset", POS_SLEEPING, do_skillset , LVL_GRGOD, 0 },
{ "sleep" , "sl" , POS_SLEEPING, do_sleep , 0, 0 },
{ "slist" , "slist" , POS_SLEEPING, do_oasis_list, LVL_BUILDER, SCMD_OASIS_SLIST },
{ "sneak" , "sneak" , POS_STANDING, do_sneak , 1, 0 },
{ "snoop" , "snoop" , POS_DEAD , do_snoop , LVL_GOD, 0 },
{ "socials" , "socials" , POS_DEAD , do_commands , 0, SCMD_SOCIALS },
{ "split" , "split" , POS_SITTING , do_split , 1, 0 },
{ "stand" , "st" , POS_RESTING , do_stand , 0, 0 },
{ "stat" , "stat" , POS_DEAD , do_stat , LVL_IMMORT, 0 },
{ "steal" , "ste" , POS_STANDING, do_steal , 1, 0 },
{ "switch" , "switch" , POS_DEAD , do_switch , LVL_GOD, 0 },
{ "tell" , "t" , POS_DEAD , do_tell , 0, 0 },
{ "take" , "ta" , POS_RESTING , do_get , 0, 0 },
{ "taste" , "tas" , POS_RESTING , do_eat , 0, SCMD_TASTE },
{ "teleport" , "tele" , POS_DEAD , do_teleport , LVL_BUILDER, 0 },
{ "tedit" , "tedit" , POS_DEAD , do_tedit , LVL_GOD, 0 }, /* XXX: Oasisify */
{ "thaw" , "thaw" , POS_DEAD , do_wizutil , LVL_GRGOD, SCMD_THAW },
{ "title" , "title" , POS_DEAD , do_title , 0, 0 },
{ "time" , "time" , POS_DEAD , do_time , 0, 0 },
{ "toggle" , "toggle" , POS_DEAD , do_toggle , 0, 0 },
{ "track" , "track" , POS_STANDING, do_track , 0, 0 },
{ "transfer" , "transfer", POS_SLEEPING, do_trans , LVL_GOD, 0 },
{ "trigedit" , "trigedit", POS_DEAD , do_oasis_trigedit, LVL_BUILDER, 0 },
{ "typo" , "typo" , POS_DEAD , do_ibt , 0, SCMD_TYPO },
{ "tlist" , "tlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_TLIST },
{ "tcopy" , "tcopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_TRIGEDIT },
{ "tstat" , "tstat" , POS_DEAD , do_tstat , LVL_BUILDER, 0 },
{ "unlock" , "unlock" , POS_SITTING , do_gen_door , 0, SCMD_UNLOCK },
{ "unban" , "unban" , POS_DEAD , do_unban , LVL_GRGOD, 0 },
{ "unaffect" , "unaffect", POS_DEAD , do_wizutil , LVL_GOD, SCMD_UNAFFECT },
{ "unfollow" , "unf" , POS_RESTING , do_unfollow , 0, 0 },
{ "uptime" , "uptime" , POS_DEAD , do_date , LVL_GOD, SCMD_UPTIME },
{ "use" , "use" , POS_SITTING , do_use , 1, SCMD_USE },
{ "users" , "users" , POS_DEAD , do_users , LVL_GOD, 0 },
{ "value" , "val" , POS_STANDING, do_not_here , 0, 0 },
{ "version" , "ver" , POS_DEAD , do_gen_ps , 0, SCMD_VERSION },
{ "visible" , "vis" , POS_RESTING , do_visible , 1, 0 },
{ "vnum" , "vnum" , POS_DEAD , do_vnum , LVL_IMMORT, 0 },
{ "vstat" , "vstat" , POS_DEAD , do_vstat , LVL_IMMORT, 0 },
{ "vdelete" , "vdelete" , POS_DEAD , do_vdelete , LVL_BUILDER, 0 },
{ "wake" , "wake" , POS_SLEEPING, do_wake , 0, 0 },
{ "wear" , "wea" , POS_RESTING , do_wear , 0, 0 },
{ "weather" , "weather" , POS_RESTING , do_weather , 0, 0 },
{ "who" , "wh" , POS_DEAD , do_who , 0, 0 },
{ "whois" , "whoi" , POS_DEAD , do_whois , 0, 0 },
{ "whoami" , "whoami" , POS_DEAD , do_gen_ps , 0, SCMD_WHOAMI },
{ "where" , "where" , POS_RESTING , do_where , 1, 0 },
{ "whirlwind", "whirl" , POS_FIGHTING, do_whirlwind, 0, 0 },
{ "whisper" , "whisper" , POS_RESTING , do_spec_comm, 0, SCMD_WHISPER },
{ "wield" , "wie" , POS_RESTING , do_wield , 0, 0 },
{ "withdraw" , "withdraw", POS_STANDING, do_not_here , 1, 0 },
{ "wiznet" , "wiz" , POS_DEAD , do_wiznet , LVL_IMMORT, 0 },
{ ";" , ";" , POS_DEAD , do_wiznet , LVL_IMMORT, 0 },
{ "wizhelp" , "wizhelp" , POS_DEAD , do_wizhelp , LVL_IMMORT, 0 },
{ "wizlist" , "wizlist" , POS_DEAD , do_gen_ps , 0, SCMD_WIZLIST },
{ "wizupdate", "wizupde" , POS_DEAD , do_wizupdate, LVL_GRGOD, 0 },
{ "wizlock" , "wizlock" , POS_DEAD , do_wizlock , LVL_IMPL, 0 },
{ "write" , "write" , POS_STANDING, do_write , 1, 0 },
{ "zoneresets", "zoner" , POS_DEAD , do_gen_tog , LVL_IMPL, SCMD_ZONERESETS },
{ "zreset" , "zreset" , POS_DEAD , do_zreset , LVL_BUILDER, 0 },
{ "zedit" , "zedit" , POS_DEAD , do_oasis_zedit, LVL_BUILDER, 0 },
{ "zlist" , "zlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_ZLIST },
{ "zlock" , "zlock" , POS_DEAD , do_zlock , LVL_GOD, 0 },
{ "zunlock" , "zunlock" , POS_DEAD , do_zunlock , LVL_GOD, 0 },
{ "zcheck" , "zcheck" , POS_DEAD , do_zcheck , LVL_BUILDER, 0 },
{ "zpurge" , "zpurge" , POS_DEAD , do_zpurge , LVL_BUILDER, 0 },
{ "\n", "zzzzzzz", 0, 0, 0, 0 } }; /* this must be last */
/* Thanks to Melzaren for this change to allow DG Scripts to be attachable
*to player's while still disallowing them to manually use the DG-Commands. */
static const struct mob_script_command_t mob_script_commands[] = {
/* DG trigger commands. minimum_level should be set to -1. */
{ "masound" , do_masound , 0 },
{ "mkill" , do_mkill , 0 },
{ "mjunk" , do_mjunk , 0 },
{ "mdamage" , do_mdamage , 0 },
{ "mdoor" , do_mdoor , 0 },
{ "mecho" , do_mecho , 0 },
{ "mrecho" , do_mrecho , 0 },
{ "mechoaround", do_mechoaround , 0 },
{ "msend" , do_msend , 0 },
{ "mload" , do_mload , 0 },
{ "mpurge" , do_mpurge , 0 },
{ "mgoto" , do_mgoto , 0 },
{ "mat" , do_mat , 0 },
{ "mteleport", do_mteleport, 0 },
{ "mforce" , do_mforce , 0 },
{ "mhunt" , do_mhunt , 0 },
{ "mremember", do_mremember, 0 },
{ "mforget" , do_mforget , 0 },
{ "mtransform", do_mtransform , 0 },
{ "mzoneecho", do_mzoneecho, 0 },
{ "mfollow" , do_mfollow , 0 },
{ "mlog" , do_mlog , 0 },
{ "\n" , do_not_here , 0 } };
int script_command_interpreter(struct char_data *ch, char *arg) {
/* DG trigger commands */
int i;
char first_arg[MAX_INPUT_LENGTH];
char *line;
skip_spaces(&arg);
if (!*arg)
return 0;
line = any_one_arg(arg, first_arg);
for (i = 0; *mob_script_commands[i].command_name != '\n'; i++)
if (!str_cmp(first_arg, mob_script_commands[i].command_name))
break; // NB - only allow full matches.
if (*mob_script_commands[i].command_name == '\n')
return 0; // no matching commands.
/* Poiner to the command? */
((*mob_script_commands[i].command_pointer) (ch, line, 0,
mob_script_commands[i].subcmd));
return 1; // We took care of execution. Let caller know.
}
static const char *fill[] =
{
"in",
"from",
"with",
"the",
"on",
"at",
"to",
"\n"
};
static const char *reserved[] =
{
"a",
"an",
"self",
"me",
"all",
"room",
"someone",
"something",
"\n"
};
static int sort_commands_helper(const void *a, const void *b)
{
return strcmp(complete_cmd_info[*(const int *)a].sort_as,
complete_cmd_info[*(const int *)b].sort_as);
}
void sort_commands(void)
{
int a, num_of_cmds = 0;
while (complete_cmd_info[num_of_cmds].command[0] != '\n')
num_of_cmds++;
num_of_cmds++; /* \n */
CREATE(cmd_sort_info, int, num_of_cmds);
for (a = 0; a < num_of_cmds; a++)
cmd_sort_info[a] = a;
/* Don't sort the RESERVED or \n entries. */
qsort(cmd_sort_info + 1, num_of_cmds - 2, sizeof(int), sort_commands_helper);
}
/* This is the actual command interpreter called from game_loop() in comm.c
* It makes sure you are the proper level and position to execute the command,
* then calls the appropriate function. */
void command_interpreter(struct char_data *ch, char *argument)
{
int cmd, length;
char *line;
char arg[MAX_INPUT_LENGTH];
REMOVE_BIT_AR(AFF_FLAGS(ch), AFF_HIDE);
/* just drop to next line for hitting CR */
skip_spaces(&argument);
if (!*argument)
return;
/* special case to handle one-character, non-alphanumeric commands; requested
* by many people so "'hi" or ";godnet test" is possible. Patch sent by Eric
* Green and Stefan Wasilewski. */
if (!isalpha(*argument)) {
arg[0] = argument[0];
arg[1] = '\0';
line = argument + 1;
} else
line = any_one_arg(argument, arg);
/* Since all command triggers check for valid_dg_target before acting, the levelcheck
* here has been removed. Otherwise, find the command. */
{
int cont; /* continue the command checks */
cont = command_wtrigger(ch, arg, line); /* any world triggers ? */
if (!cont) cont = command_mtrigger(ch, arg, line); /* any mobile triggers ? */
if (!cont) cont = command_otrigger(ch, arg, line); /* any object triggers ? */
if (cont) return; /* yes, command trigger took over */
}
/* Allow IMPLs to switch into mobs to test the commands. */
if (IS_NPC(ch) && ch->desc && GET_LEVEL(ch->desc->original) >= LVL_IMPL) {
if (script_command_interpreter(ch, argument))
return;
}
for (length = strlen(arg), cmd = 0; *complete_cmd_info[cmd].command != '\n'; cmd++)
if(complete_cmd_info[cmd].command_pointer != do_action &&
!strncmp(complete_cmd_info[cmd].command, arg, length))
if (GET_LEVEL(ch) >= complete_cmd_info[cmd].minimum_level)
break;
/* it's not a 'real' command, so it's a social */
if(*complete_cmd_info[cmd].command == '\n')
for (length = strlen(arg), cmd = 0; *complete_cmd_info[cmd].command != '\n'; cmd++)
if (complete_cmd_info[cmd].command_pointer == do_action &&
!strncmp(complete_cmd_info[cmd].command, arg, length))
if (GET_LEVEL(ch) >= complete_cmd_info[cmd].minimum_level)
break;
if (*complete_cmd_info[cmd].command == '\n') {
int found = 0;
send_to_char(ch, "%s", CONFIG_HUH);
for (cmd = 0; *cmd_info[cmd].command != '\n'; cmd++)
{
if (*arg != *cmd_info[cmd].command || cmd_info[cmd].minimum_level > GET_LEVEL(ch))
continue;
/* Only apply levenshtein counts if the command is not a trigger command. */
if ( (levenshtein_distance(arg, cmd_info[cmd].command) <= 2) &&
(cmd_info[cmd].minimum_level >= 0) )
{
if (!found)
{
send_to_char(ch, "\r\nDid you mean:\r\n");
found = 1;
}
send_to_char(ch, " %s\r\n", cmd_info[cmd].command);
}
}
}
else if (!IS_NPC(ch) && PLR_FLAGGED(ch, PLR_FROZEN) && GET_LEVEL(ch) < LVL_IMPL)
send_to_char(ch, "You try, but the mind-numbing cold prevents you...\r\n");
else if (complete_cmd_info[cmd].command_pointer == NULL)
send_to_char(ch, "Sorry, that command hasn't been implemented yet.\r\n");
else if (IS_NPC(ch) && complete_cmd_info[cmd].minimum_level >= LVL_IMMORT)
send_to_char(ch, "You can't use immortal commands while switched.\r\n");
else if (GET_POS(ch) < complete_cmd_info[cmd].minimum_position)
switch (GET_POS(ch)) {
case POS_DEAD:
send_to_char(ch, "Lie still; you are DEAD!!! :-(\r\n");
break;
case POS_INCAP:
case POS_MORTALLYW:
send_to_char(ch, "You are in a pretty bad shape, unable to do anything!\r\n");
break;
case POS_STUNNED:
send_to_char(ch, "All you can do right now is think about the stars!\r\n");
break;
case POS_SLEEPING:
send_to_char(ch, "In your dreams, or what?\r\n");
break;
case POS_RESTING:
send_to_char(ch, "Nah... You feel too relaxed to do that..\r\n");
break;
case POS_SITTING:
send_to_char(ch, "Maybe you should get on your feet first?\r\n");
break;
case POS_FIGHTING:
send_to_char(ch, "No way! You're fighting for your life!\r\n");
break;
} else if (no_specials || !special(ch, cmd, line))
((*complete_cmd_info[cmd].command_pointer) (ch, line, cmd, complete_cmd_info[cmd].subcmd));
}
/* Routines to handle aliasing. */
static struct alias_data *find_alias(struct alias_data *alias_list, char *str)
{
while (alias_list != NULL) {
if (*str == *alias_list->alias) /* hey, every little bit counts :-) */
if (!strcmp(str, alias_list->alias))
return (alias_list);
alias_list = alias_list->next;
}
return (NULL);
}
void free_alias(struct alias_data *a)
{
if (a->alias)
free(a->alias);
if (a->replacement)
free(a->replacement);
free(a);
}
/* The interface to the outside world: do_alias */
ACMD(do_alias)
{
char arg[MAX_INPUT_LENGTH];
char *repl;
struct alias_data *a, *temp;
if (IS_NPC(ch))
return;
repl = any_one_arg(argument, arg);
if (!*arg) { /* no argument specified -- list currently defined aliases */
send_to_char(ch, "Currently defined aliases:\r\n");
if ((a = GET_ALIASES(ch)) == NULL)
send_to_char(ch, " None.\r\n");
else {
while (a != NULL) {
send_to_char(ch, "%-15s %s\r\n", a->alias, a->replacement);
a = a->next;
}
}
} else { /* otherwise, add or remove aliases */
/* is this an alias we've already defined? */
if ((a = find_alias(GET_ALIASES(ch), arg)) != NULL) {
REMOVE_FROM_LIST(a, GET_ALIASES(ch), next);
free_alias(a);
}
/* if no replacement string is specified, assume we want to delete */
if (!*repl) {
if (a == NULL)
send_to_char(ch, "No such alias.\r\n");
else
send_to_char(ch, "Alias deleted.\r\n");
} else { /* otherwise, either add or redefine an alias */
if (!str_cmp(arg, "alias")) {
send_to_char(ch, "You can't alias 'alias'.\r\n");
return;
}
CREATE(a, struct alias_data, 1);
a->alias = strdup(arg);
delete_doubledollar(repl);
a->replacement = strdup(repl);
if (strchr(repl, ALIAS_SEP_CHAR) || strchr(repl, ALIAS_VAR_CHAR))
a->type = ALIAS_COMPLEX;
else
a->type = ALIAS_SIMPLE;
a->next = GET_ALIASES(ch);
GET_ALIASES(ch) = a;
save_char(ch);
send_to_char(ch, "Alias ready.\r\n");
}
}
}
/* Valid numeric replacements are only $1 .. $9 (makes parsing a little easier,
* and it's not that much of a limitation anyway.) Also valid is "$*", which
* stands for the entire original line after the alias. ";" is used to delimit
* commands. */
#define NUM_TOKENS 9
static void perform_complex_alias(struct txt_q *input_q, char *orig, struct alias_data *a)
{
struct txt_q temp_queue;
char *tokens[NUM_TOKENS], *temp, *write_point;
char buf2[MAX_RAW_INPUT_LENGTH], buf[MAX_RAW_INPUT_LENGTH]; /* raw? */
int num_of_tokens = 0, num;
/* First, parse the original string */
strcpy(buf2, orig); /* strcpy: OK (orig:MAX_INPUT_LENGTH < buf2:MAX_RAW_INPUT_LENGTH) */
temp = strtok(buf2, " ");
while (temp != NULL && num_of_tokens < NUM_TOKENS) {
tokens[num_of_tokens++] = temp;
temp = strtok(NULL, " ");
}
/* initialize */
write_point = buf;
temp_queue.head = temp_queue.tail = NULL;
/* now parse the alias */
for (temp = a->replacement; *temp; temp++) {
if (*temp == ALIAS_SEP_CHAR) {
*write_point = '\0';
buf[MAX_INPUT_LENGTH - 1] = '\0';
write_to_q(buf, &temp_queue, 1);
write_point = buf;
} else if (*temp == ALIAS_VAR_CHAR) {
temp++;
if ((num = *temp - '1') < num_of_tokens && num >= 0) {
strcpy(write_point, tokens[num]); /* strcpy: OK */
write_point += strlen(tokens[num]);
} else if (*temp == ALIAS_GLOB_CHAR) {
skip_spaces(&orig);
strcpy(write_point, orig); /* strcpy: OK */
write_point += strlen(orig);
} else if ((*(write_point++) = *temp) == '$') /* redouble $ for act safety */
*(write_point++) = '$';
} else
*(write_point++) = *temp;
}
*write_point = '\0';
buf[MAX_INPUT_LENGTH - 1] = '\0';
write_to_q(buf, &temp_queue, 1);
/* push our temp_queue on to the _front_ of the input queue */
if (input_q->head == NULL)
*input_q = temp_queue;
else {
temp_queue.tail->next = input_q->head;
input_q->head = temp_queue.head;
}
}
/* Given a character and a string, perform alias replacement on it.
* Return values:
* 0: String was modified in place; call command_interpreter immediately.
* 1: String was _not_ modified in place; rather, the expanded aliases
* have been placed at the front of the character's input queue. */
int perform_alias(struct descriptor_data *d, char *orig, size_t maxlen)
{
char first_arg[MAX_INPUT_LENGTH], *ptr;
struct alias_data *a, *tmp;
/* Mobs don't have alaises. */
if (IS_NPC(d->character))
return (0);
/* bail out immediately if the guy doesn't have any aliases */
if ((tmp = GET_ALIASES(d->character)) == NULL)
return (0);
/* find the alias we're supposed to match */
ptr = any_one_arg(orig, first_arg);
/* bail out if it's null */
if (!*first_arg)
return (0);
/* if the first arg is not an alias, return without doing anything */
if ((a = find_alias(tmp, first_arg)) == NULL)
return (0);
if (a->type == ALIAS_SIMPLE) {
strlcpy(orig, a->replacement, maxlen);
return (0);
} else {
perform_complex_alias(&d->input, ptr, a);
return (1);
}
}
/* Various other parsing utilities. */
/* Searches an array of strings for a target string. "exact" can be 0 or non-0,
* depending on whether or not the match must be exact for it to be returned.
* Returns -1 if not found; 0..n otherwise. Array must be terminated with a
* '\n' so it knows to stop searching. */
int search_block(char *arg, const char **list, int exact)
{
int i, l;
/* We used to have \r as the first character on certain array items to
* prevent the explicit choice of that point. It seems a bit silly to
* dump control characters into arrays to prevent that, so we'll just
* check in here to see if the first character of the argument is '!',
* and if so, just blindly return a '-1' for not found. - ae. */
if (*arg == '!')
return (-1);
/* Make into lower case, and get length of string */
for (l = 0; *(arg + l); l++)
*(arg + l) = LOWER(*(arg + l));
if (exact) {
for (i = 0; **(list + i) != '\n'; i++)
if (!strcmp(arg, *(list + i)))
return (i);
} else {
if (!l)
l = 1; /* Avoid "" to match the first available
* string */
for (i = 0; **(list + i) != '\n'; i++)
if (!strncmp(arg, *(list + i), l))
return (i);
}
return (-1);
}
int is_number(const char *str)
{
if(*str == '-')
str++;
if(!*str)
return (0);
while (*str)
if (!isdigit(*(str++)))
return (0);
return (1);
}
/* Function to skip over the leading spaces of a string. */
void skip_spaces(char **string)
{
for (; **string && **string != '\t' && isspace(**string); (*string)++);
}
/* Given a string, change all instances of double dollar signs ($$) to single
* dollar signs ($). When strings come in, all $'s are changed to $$'s to
* avoid having users be able to crash the system if the inputted string is
* eventually sent to act(). If you are using user input to produce screen
* output AND YOU ARE SURE IT WILL NOT BE SENT THROUGH THE act() FUNCTION
* (i.e., do_gecho, do_title, but NOT do_say), you can call
* delete_doubledollar() to make the output look correct.
* Modifies the string in-place. */
char *delete_doubledollar(char *string)
{
char *ddread, *ddwrite;
/* If the string has no dollar signs, return immediately */
if ((ddwrite = strchr(string, '$')) == NULL)
return (string);
/* Start from the location of the first dollar sign */
ddread = ddwrite;
while (*ddread) /* Until we reach the end of the string... */
if ((*(ddwrite++) = *(ddread++)) == '$') /* copy one char */
if (*ddread == '$')
ddread++; /* skip if we saw 2 $'s in a row */
*ddwrite = '\0';
return (string);
}
int fill_word(char *argument)
{
return (search_block(argument, fill, TRUE) >= 0);
}
int reserved_word(char *argument)
{
return (search_block(argument, reserved, TRUE) >= 0);
}
/* Copy the first non-fill-word, space-delimited argument of 'argument'
* to 'first_arg'; return a pointer to the remainder of the string. */
char *one_argument(char *argument, char *first_arg)
{
char *begin = first_arg;
if (!argument) {
log("SYSERR: one_argument received a NULL pointer!");
*first_arg = '\0';
return (NULL);
}
do {
skip_spaces(&argument);
first_arg = begin;
while (*argument && !isspace(*argument)) {
*(first_arg++) = LOWER(*argument);
argument++;
}
*first_arg = '\0';
} while (fill_word(begin));
return (argument);
}
/* one_word is like any_one_arg, except that words in quotes ("") are
* considered one word. No longer ignores fill words. -dak */
char *one_word(char *argument, char *first_arg)
{
skip_spaces(&argument);
if (*argument == '\"') {
argument++;
while (*argument && *argument != '\"') {
*(first_arg++) = LOWER(*argument);
argument++;
}
argument++;
} else {
while (*argument && !isspace(*argument)) {
*(first_arg++) = LOWER(*argument);
argument++;
}
}
*first_arg = '\0';
return (argument);
}
/* Same as one_argument except that it doesn't ignore fill words. */
char *any_one_arg(char *argument, char *first_arg)
{
skip_spaces(&argument);
while (*argument && !isspace(*argument)) {
*(first_arg++) = LOWER(*argument);
argument++;
}
*first_arg = '\0';
return (argument);
}
/* Same as one_argument except that it takes two args and returns the rest;
* ignores fill words */
char *two_arguments(char *argument, char *first_arg, char *second_arg)
{
return (one_argument(one_argument(argument, first_arg), second_arg)); /* :-) */
}
/* Determine if a given string is an abbreviation of another.
* Returns 1 if arg1 is an abbreviation of arg2. */
int is_abbrev(const char *arg1, const char *arg2)
{
if (!*arg1)
return (0);
for (; *arg1 && *arg2; arg1++, arg2++)
if (LOWER(*arg1) != LOWER(*arg2))
return (0);
if (!*arg1)
return (1);
else
return (0);
}
/* Return first space-delimited token in arg1; remainder of string in arg2.
* NOTE: Requires sizeof(arg2) >= sizeof(string) */
void half_chop(char *string, char *arg1, char *arg2)
{
char *temp;
temp = any_one_arg(string, arg1);
skip_spaces(&temp);
strcpy(arg2, temp); /* strcpy: OK (documentation) */
}
/* Used in specprocs, mostly. (Exactly) matches "command" to cmd number */
int find_command(const char *command)
{
int cmd;
for (cmd = 0; *complete_cmd_info[cmd].command != '\n'; cmd++)
if (!strcmp(complete_cmd_info[cmd].command, command))
return (cmd);
return (-1);
}
int special(struct char_data *ch, int cmd, char *arg)
{
struct obj_data *i;
struct char_data *k;
int j;
/* special in room? */
if (GET_ROOM_SPEC(IN_ROOM(ch)) != NULL)
if (GET_ROOM_SPEC(IN_ROOM(ch)) (ch, world + IN_ROOM(ch), cmd, arg))
return (1);
/* special in equipment list? */
for (j = 0; j < NUM_WEARS; j++)
if (GET_EQ(ch, j) && GET_OBJ_SPEC(GET_EQ(ch, j)) != NULL)
if (GET_OBJ_SPEC(GET_EQ(ch, j)) (ch, GET_EQ(ch, j), cmd, arg))
return (1);
/* special in inventory? */
for (i = ch->carrying; i; i = i->next_content)
if (GET_OBJ_SPEC(i) != NULL)
if (GET_OBJ_SPEC(i) (ch, i, cmd, arg))
return (1);
/* special in mobile present? */
for (k = world[IN_ROOM(ch)].people; k; k = k->next_in_room)
if (!MOB_FLAGGED(k, MOB_NOTDEADYET))
if (GET_MOB_SPEC(k) && GET_MOB_SPEC(k) (ch, k, cmd, arg))
return (1);