-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd-page.muf
3100 lines (2652 loc) · 84.2 KB
/
cmd-page.muf
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
@program cmd-page
1 99999 d
1 i
( MUFpage Copyright 4/15/91 by Fuzzball Software )
( foxen@netcom.com )
( )
( This code is released under the GNU Public Licence. )
( )
( CONFIGURATION )
( Restrict guests from paging anyone but a wizard )
$def RESTRICTWIZ
( Allow multi-player summons )
( $def MULTISUMMON )
( Restrict guests from multi-page )
$def RESTRICTMULT
( Encrypt lastpage[d/dgroup/er/ers] props )
( $def ENCRYPTPROPS )
( Encryption key for lastpaged props and #mail, where applicable )
$def KEY "encryption key"
( The action of #mail, PAGEMAIL or LIBMAIL or NONE )
$define MAILTYPE LIBMAIL $enddef
( END OF CONFIGURATION )
$ifdef MAILTYPE=LIBMAIL
$include $lib/mail
$else
$ifndef MAILTYPE=NONE
$ifndef MAILTYPE=PAGEMAIL
$echo "Warning: Invalid or no mailtype assigned, assuming none."
$def MAILTYPE NONE
$endif
$endif
$endif
$def VERSION "MUFpage v3.00 by Revar"
$def UPDATED "Updated 3/16/00"
$def descr_idle descrcon conidle
: oproploc ( dbref -- dbref' )
dup "_proploc" getpropstr
dup if
dup "#" 1 strncmp not if
1 strcut swap pop
then
atoi dbref
dup ok? if
dup owner 3 pick
dbcmp if swap then
then
pop
else pop
then
;
: myproploc ( -- dbref)
me @ oproploc
;
: tell (string -- )
me @ swap notify
;
: fillspace
swap strlen -
" " ( 40 spaces )
dup strcat ( 80 spaces now )
swap strcut pop
;
$def strip-leadspaces striplead
$def strip-trailspaces striptail
( mail encryption stuff )
( Crypto ver 1: Very stupid encryption system. )
: transpose (char -- char')
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890_"
over instr dup if
swap pop 1 -
"wG8D kBQzWm4gbRXHOqaZiJPtUTN2pu6M0VjFlK3sdS9oYe5A_7IE1cnLvfyCrhx"
swap strcut 1 strcut pop swap pop
else
pop
then
;
: encrypt (string -- string')
"" swap begin
dup while
100 strcut "" rot
begin
dup while
1 strcut swap transpose
rot swap strcat swap
repeat pop
rot swap strcat swap
repeat pop
;
( Crypto ver 2: better encryption. But slower. )
: asc (stringchar -- int)
dup if
" 1234567890-=!@#$%&*()_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:zxcvbnm,./ZXCVBNM<>?\"`~\\|^"
swap instr 1 - exit
then pop 0
;
: chr (int -- strchar)
" 1234567890-=!@#$%&*()_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:zxcvbnm,./ZXCVBNM<>?\"`~\\|^"
swap strcut 1 strcut pop swap pop
;
: cypher (key chars -- chars')
1 strcut asc swap asc
over 89 > over 89 > or if chr swap chr strcat swap pop exit then
dup 10 / 10 *
4 pick 10 + rot 10 % - 10 %
rot dup 10 / 10 *
5 rotate 10 + rot 10 % - 10 %
4 rotate + chr -3 rotate + chr strcat
;
: crypt2 (key string -- string')
swap 9 % 100 + "" rot
begin dup while
2 strcut 4 pick rot cypher
rot swap strcat swap
repeat pop swap pop
;
( Crypto ver 3: Faster inserver FB5 encryption )
: encrypt3 (key string -- string')
swap intostr KEY over strcat strcat strencrypt
;
: decrypt3 (key string -- string')
swap intostr KEY over strcat strcat strdecrypt
;
( Encryption dispatchers )
$ifdef ENCRYPTPROPS
: pencrypt ( i s -- s )
dup not if swap pop exit then
$ifdef __version>Muck2.2fb5.46
encrypt3 "!" swap strcat
$else
crypt2 "*" swap strcat
$endif
;
$else
$def pencrypt swap pop
$endif
: pdecrypt ( i s -- s )
dup not if swap pop exit then
dup 1 strcut pop "*!" swap instr
dup 1 = if pop 1 strcut swap pop crypt2 exit then
$ifdef __version>Muck2.2fb5.46
dup 2 = if pop 1 strcut swap pop decrypt3 exit then
$endif
pop swap pop
;
$ifdef MAILTYPE=PAGEMAIL
: mencrypt ( i s -- s )
dup not if swap pop exit then
$ifdef __version>Muck2.2fb5.46
encrypt3 "E" swap strcat
$else
crypt2 "D" swap strcat
$endif
;
: mdecrypt ( i s -- s )
dup not if swap pop exit then
dup 1 strcut pop "CDE" swap instr
dup 1 = if pop 1 strcut swap pop swap pop encrypt exit then
dup 2 = if pop 1 strcut swap pop crypt2 exit then
$ifdef __version>Muck2.2fb5.46
dup 3 = if pop 1 strcut swap pop decrypt3 exit then
$endif
pop swap pop
;
$endif
(
Gazer's Sort routines
Shell Sort
Takes [ x1 x2 x3 ... xn n -- x1' x2' x3' ... xn' n ]
)
: CmpStrCaseInsensAsc stringcmp 0 > ;
: SortIncLoop ( <strings*n> n cmp inc --- <strings*n> n )
begin
dup 0 > while ( while inc > 0 )
dup 1 + ( for i := inc + 1 to n )
begin
dup 5 pick <= while ( for i := inc + 1 to n )
over over swap - ( j := i - inc )
begin
dup 0 > while ( while j > 0 )
dup 5 + pick ( get A[j] )
over 5 pick + 6 + pick ( get A[j+inc] )
6 pick execute if ( do comparison )
dup 5 + pick ( swap: get A[j] )
over 5 pick + 6 + pick ( get A[j+inc] )
3 pick 6 + put ( put into A[j] )
over 5 pick + 5 + put ( put into A[j+inc] )
3 pick - ( j := j - inc )
else
break then ( break out if we don't swap )
repeat pop
1 + ( while j > 0 )
repeat pop
2 /
repeat pop pop
;
: Sort ( <strings*n> n )
'CmpStrCaseInsensAsc
over 2 / SortIncLoop
;
( End Gazer's Sort routines )
: sort-stringwords (str -- str')
strip
dup " " instr if
" " explode sort
begin dup 1 > while
1 - swap " " strcat rot strcat swap
repeat pop
strip
then
;
: fake_format? (default string -- string' TRUE )
( or -- default FALSE )
"%n" me @ name subst
dup "%n" instr not if
"%n " swap strcat
then
dup "%n whispers, \"%m\"" stringcmp not
over "%n whispers \"%m\"" stringcmp not or
over "%n shouts, \"%m\"" stringcmp not or
over "%n shouts \"%m\"" stringcmp not or
over "%n %m" stringcmp not or if
pop 0
else
swap pop 1
then
;
( *** routines to get and set properties *** )
: setpropstr (dbref propname value -- )
dup not if
pop 0 setprop
else
0 addprop
then
;
: envprop envpropstr swap pop ;
: search-prop (propname -- str)
myproploc over getpropstr
dup not if
me @ location
rot envprop
then
swap pop
;
: getprop (playerdbref propname -- str)
over oproploc over getpropstr
dup not if
pop swap over envprop
dup not if
pop trigger @ swap getpropstr
else swap pop
then
else rot rot pop pop
then
;
( *** BEGIN PERSONAL PROPS *** )
: getignorestr (playerdbref -- ignorestr)
trigger @ getlink "ignore#"
rot int intostr
strcat getpropstr
;
: setignorestr (ignorestr playerdbref -- )
int intostr trigger @
getlink "ignore#" rot
strcat rot setpropstr
;
: getprioritystr (playerdbref -- prioritystr)
trigger @ getlink "priority#"
rot int intostr
strcat getpropstr
;
: setprioritystr (prioritystr playerdbref -- )
int intostr trigger @
getlink "priority#" rot
strcat rot setpropstr
;
: getlastpager (playerdbref -- string)
dup int swap oproploc "_page/lastpager" getpropstr pdecrypt
;
: setlastpager (string playerdbref -- )
dup oproploc swap int rot pencrypt
"_page/lastpager" swap setpropstr
;
: getlastpagers (playerdbref -- string)
dup int swap oproploc "_page/lastpagers" getpropstr pdecrypt
;
: setlastpagers (string playerdbref -- )
dup oproploc swap int rot pencrypt
"_page/lastpagers" swap setpropstr
;
: getlastpaged (playerdbref -- string)
dup int swap oproploc "_page/lastpaged" getpropstr pdecrypt
;
: setlastpaged (string playerdbref -- )
dup oproploc swap int rot pencrypt
"_page/lastpaged" swap setpropstr
;
: getlastpagedgroup (playerdbref -- string)
dup int swap oproploc "_page/lastpagedgroup" getpropstr pdecrypt
;
: setlastpagedgroup (string playerdbref -- )
dup oproploc swap int rot pencrypt
"_page/lastpagedgroup" swap setpropstr
;
: set_page_standard (valstr -- )
myproploc "_page/standard?" rot setpropstr
;
: page_standard? (playerdbref -- bool)
oproploc "_page/standard?" getpropstr
dup "yes" stringcmp not if pop 2 exit then
"prepend" stringcmp not if 1 exit then
0
;
: set_page_echo (valstr -- )
myproploc "_page/echo?" rot setpropstr
;
: page_echo? ( -- bool)
myproploc "_page/echo?" getpropstr
"no" stringcmp not not
;
: set_page_inform (valstr -- )
myproploc "_page/inform?" rot setpropstr
;
: page_inform? (playerdbref -- bool)
oproploc "_page/inform?" getpropstr
"yes" stringcmp not
;
: get-curr-format ( -- formatname )
myproploc "_page/curr_format" getpropstr
dup not if pop "page" then
;
: set-curr-format ( formatname -- )
myproploc "_page/curr_format" rot setpropstr
;
: set-format-prop ( playerdbref formatname format -- )
rot oproploc rot "_page/formats/f-" swap strcat rot setpropstr
;
: get-format-prop ( playerdbref formatname -- format )
"_page/formats/f-" swap strcat over swap getprop
dup not if pop "_page/formats/f-page" getprop else swap pop then
dup not if pop "You page, \"%m\" to %n." then
;
: set-oformat-prop ( playerdbref formatname format -- )
rot oproploc rot "_page/formats/o-" swap strcat rot setpropstr
;
: get-oformat-prop ( playerdbref formatname -- format )
"_page/formats/o-" swap strcat over swap getprop
dup not if pop "_page/formats/o-page" getprop else swap pop then
"%n pages, \"%m\" to %t." swap dup if fake_format? then pop
;
: get_opose ( -- oposeformat)
myproploc "_page/formats/o-pose" over swap getprop
dup not if pop "_page/formats/o-page" getprop else swap pop then
"In a page-pose to %t, %n %m" swap dup if fake_format? then pop
;
: set-standard (stdformat playerdbref -- )
oproploc "_page/stdf" rot setpropstr
;
: get-standard (playerdbref -- stdformat)
oproploc "_page/stdf" getpropstr
dup not if pop "%n pages: %m" "_page/stdf" trigger @ swap getpropstr dup if swap then pop then
"<loc>" "%l" subst
;
: set-prepend (prepformat playerdbref -- )
oproploc "_page/prepf" rot setpropstr
;
: get-prepend (playerdbref -- prepformat)
oproploc "_page/prepf" getpropstr
dup not if pop "%n pages: " "_page/prepf" trigger @ swap getpropstr dup if swap then pop then
"<loc>" "%l" subst
;
$ifdef MAILTYPE=PAGEMAIL
: get-forward (playerdbref -- string)
oproploc "_page/forward" getpropstr
;
: set-forward (string -- )
myproploc "_page/forward" rot setpropstr
;
: mail-count (playerdbref -- count)
oproploc dup "_page/mail#" getpropstr atoi
swap "page-mail#" getpropstr atoi +
;
: mail-get (playerdbref -- message)
dup dup mail-count swap oproploc
"_page/mail" "#/" strcat 3 pick intostr strcat
over over getpropstr dup not if
pop dup "#/" rinstr 1 - strcut
2 strcut swap pop strcat
over over getpropstr
then
-5 rotate 0 setprop
1 - intostr swap oproploc
"_page/mail" "#" strcat rot setpropstr
;
: mail-add (playerdbref message -- )
over mail-count 1 + intostr
3 pick oproploc "_page/mail" "#" strcat 3 pick setpropstr
rot oproploc "_page/mail" "#/" strcat rot strcat rot setpropstr
;
: mail-erase-loop (proploc count -- proploc count)
dup not if exit then
over mail-get dup " " split pop
1 strcut swap pop atoi dbref
me @ dbcmp not if
rot rot 1 - mail-erase-loop
else
pop exit
then
over 4 rotate mail-add
;
: mail-erase (playerdbref -- erased?)
dup mail-count mail-erase-loop swap pop
;
$endif
: get-lastversion ( -- versionstr)
myproploc "_page/lastversion" getpropstr dup if exit then
pop myproploc "_page_lastversion" getpropstr
;
: verstr-parse (versionstr -- versionint)
" " split swap pop dup not if pop 0 exit then
" " split pop dup not if pop 0 exit then
1 strcut swap pop "." split
atoi swap atoi 100 * +
;
: set-lastversion (versionstr -- )
myproploc "_page/lastversion" rot setpropstr
;
: get-multimax (playerdbref -- int)
oproploc "_page/multimax" getpropstr
atoi dup not if pop 8888 then
;
: set-multimax (int playerdbref -- )
oproploc "_page/multimax"
rot intostr setpropstr
;
: get-sleepmsg (dbref -- string)
oproploc "_page/sleepmsg" getpropstr
;
: set-sleepmsg (string dbref -- )
oproploc "_page/sleepmsg" rot setpropstr
;
: get-havenmsg (dbref -- string)
oproploc "_page/havenmsg" getpropstr
;
: set-havenmsg (string dbref -- )
oproploc "_page/havenmsg" rot setpropstr
;
: get-ignoremsg (dbref -- string)
oproploc "_page/ignoremsg" getpropstr
;
: set-ignoremsg (string dbref -- )
oproploc "_page/ignoremsg" rot setpropstr
;
: get-idlemsg (dbref -- string)
oproploc "_page/idlemsg" getpropstr
;
: set-idlemsg (string dbref -- )
oproploc "_page/idlemsg" rot setpropstr
;
: get-idletime (dbref -- int)
oproploc "_page/idletime" getpropval
dup not if pop 600 then
;
: set-idletime (int dbref -- )
oproploc "_page/idletime" rot setprop
;
: get-awaymsg (dbref -- string)
oproploc "_page/awaymsg" getpropstr
;
: set-awaymsg (string dbref -- )
oproploc "_page/awaymsg" rot setpropstr
;
( change proploc )
: update-prop (dbref oldprop newprop -- )
3 pick 3 pick getpropstr
dup not if pop pop pop pop exit then
4 pick 4 rotate 0 setprop
setpropstr
;
$ifdef MAILTYPE=PAGEMAIL
: update-mail (dbref -- )
dup dup "page-mail#" getpropstr atoi
begin
dup while
over "page-mail#/"
3 pick intostr strcat
over over getpropstr not if
pop "page-mail"
4 pick intostr strcat
then
"_page/mail#/" 4 pick intostr strcat update-prop
1 -
repeat pop pop
"page-mail#" "_page/mail#" update-prop
;
$endif
: update-aliases (dbref -- )
dup dup "Aliases" getpropstr
begin
dup while
" " split swap
3 pick "Alias-" 3 pick strcat
"_page/alias/a-" 4 rotate strcat
update-prop
repeat pop pop
"Aliases" "_page/aliases" update-prop
;
: do-update-props (versionint -- )
dup 300 < if
dup 235 <= if
myproploc
dup "lastpager" "_page/lastpager" update-prop
dup "lastpagers" "_page/lastpagers" update-prop
dup "lastpaged" "_page/lastpaged" update-prop
dup "lastpagedgroup" "_page/lastpagedgroup" update-prop
dup "_page_standard?" "_page/standard?" update-prop
dup "_page_echo?" "_page/echo?" update-prop
dup "_page_inform?" "_page/inform?" update-prop
dup "_page_curr_format" "_page/curr_format" update-prop
dup "_page" "_page/formats/f-page" update-prop
dup "_opage" "_page/formats/o-page" update-prop
dup "_pose" "_page/formats/f-pose" update-prop
dup "_opose" "_page/formats/o-pose" update-prop
dup "_page_lastversion" "_page/lastversion" update-prop
dup "_page_prepf" "_page/prepf" update-prop
dup "_page_stdf" "_page/stdf" update-prop
dup "_page_sleepmsg" "_page/sleepmsg" update-prop
dup "_page_havenmsg" "_page/havenmsg" update-prop
dup "_page_ignoremsg" "_page/ignoremsg" update-prop
$ifdef MAILTYPE=PAGEMAIL
dup "_page_forward" "_page/forward" update-prop
dup update-mail
$endif
pop
then
dup 240 <= if
myproploc update-aliases
then
then
pop
;
: update-galiases ( -- )
trigger @ getlink dup dup "GlobalAliases" getpropstr
trigger @ getlink "_page/galiases" getpropstr " " strcat over strcat
strip sort-stringwords trigger @ getlink "GlobalAliases" rot setprop
begin
dup while
" " split swap
3 pick "AliasGlobal-" 3 pick strcat
"_page/galias/g-" 4 pick strcat
update-prop
3 pick "GlobalOwn-" 3 pick strcat
"_page/galiasown/g-" 4 rotate strcat
update-prop
repeat pop pop
"GlobalAliases" "_page/galiases" update-prop
;
( change proploc )
: move-prop (dbref newdbref str -- )
3 pick over getprop
4 rotate 3 pick 0 setprop
setprop
;
$ifdef MAILTYPE=PAGEMAIL
: move-mail (dbref newdbref count -- )
begin
dup while
3 pick 3 pick "_page/mail#/"
4 pick intostr strcat
3 pick over getpropstr not if
pop "_page/mail"
4 pick intostr strcat
then
move-prop
1 -
repeat pop pop pop
;
$endif
: move-aliases (dbref newdbref aliases -- )
begin
dup while
" " split swap
4 pick 4 pick "_page/alias/a-"
4 rotate strcat
move-prop
repeat pop pop pop
;
: do-proplock-set (str -- )
strip match dup not if
"page #proploc: I don't know what object you mean!"
tell pop exit
then dup #-2 dbcmp if
"page #proploc: I don't know _which_ object you mean!"
tell pop exit
then dup owner me @ dbcmp not if
"page #proploc: You don't own that object!"
tell pop exit
then myproploc swap
dup int intostr me @ "_proploc" rot setpropstr
over over "_page/lastpager" move-prop
over over "_page/lastpagers" move-prop
over over "_page/lastpaged" move-prop
over over "_page/lastpagedgroup" move-prop
over over "_page/standard?" move-prop
over over "_page/echo?" move-prop
over over "_page/inform?" move-prop
over over "_page/curr_format" move-prop
over over "_page/formats/f-page" move-prop
over over "_page/formats/o-page" move-prop
over over "_page/formats/f-pose" move-prop
over over "_page/formats/o-pose" move-prop
over over "_page/lastversion" move-prop
over over "_page/prepf" move-prop
over over "_page/stdf" move-prop
over over "_page/away" move-prop
over over "_page/sleepmsg" move-prop
over over "_page/havenmsg" move-prop
over over "_page/ignoremsg" move-prop
over over "_page/idlemsg" move-prop
over over "_page/idletime" move-prop
over over "_page/awaymsg" move-prop
$ifdef MAILTYPE=PAGEMAIL
over over "_page/forward" move-prop
over "_page/mail#" getpropstr atoi
3 pick 3 pick rot move-mail
over over "_page/mail#" move-prop
$endif
over "_page/aliases" getpropstr
3 pick 3 pick rot move-aliases
over over "_page/aliases" move-prop
"Properties now stored on \""
swap name strcat "\"" strcat tell
;
( *** END PERSONAL PROPS *** )
: get-g-aliases ( -- aliasesstr)
trigger @ getlink "_page/galiases" getpropstr
;
: set-g-aliases (aliasesstr -- )
sort-stringwords
trigger @ getlink "_page/galiases" rot setpropstr
;
: set-p-aliases (aliasesstr -- )
sort-stringwords
myproploc "_page/aliases" rot setpropstr
;
: get-p-aliases ( -- aliasesstr)
myproploc "_page/aliases" getpropstr dup if exit then
pop trigger @ getlink me @ int intostr
"Aliases" strcat getpropstr
dup set-p-aliases
trigger @ getlink me @ int intostr
"Aliases" strcat 0 setprop
;
: set-personal-alias (aliasname aliasstr -- )
swap tolower dup strlen
10 > if 10 strcut pop then
swap get-p-aliases
" " swap over strcat strcat
over if
dup 4 pick " " swap over strcat strcat
instr not if
" " strcat 3 pick strcat
then
"Personal alias set." tell
else
3 pick " " swap over strcat strcat
split " " swap strcat strcat strip
"Personal alias cleared." tell
then
strip set-p-aliases
"_page/alias/a-" rot strcat
myproploc swap rot setpropstr
;
: get-personal-alias (aliasname playerdbref -- aliasstr)
over over oproploc "_page/alias/a-" rot strcat getpropstr
dup if rot rot pop pop exit then
pop over over int intostr "Alias" swap strcat
"-" strcat swap strcat
trigger @ getlink swap over over getpropstr
dup not if pop pop pop pop pop "" exit then
rot rot 0 setprop
swap pop over swap set-personal-alias
;
: get-global-alias (aliasname -- aliasstr)
trigger @ getlink "_page/galias/g-"
rot strcat getpropstr
;
: set-global-alias (aliasname aliasstr -- )
over get-global-alias
me @ "w" flag? not and
me @ trigger @ getlink owner dbcmp not and
"_page/galiasown/g-" 4 pick strcat
trigger @ getlink swap getpropstr
me @ int intostr stringcmp and if
"Permission denied." tell
pop pop exit
then
(aliasname aliasstr)
dup not if
"_page/galiasown/g-" 3 pick strcat
trigger @ getlink swap 0 setprop
then
(aliasname aliasstr)
swap tolower dup strlen
10 > if 10 strcut pop then
swap get-g-aliases
" " swap over strcat strcat
over if
dup 4 pick " " swap over strcat strcat
instr not if " " strcat 3 pick strcat then
"Global alias set." tell
else
3 pick " " swap over strcat strcat
split " " swap strcat strcat strip
"Global alias cleared." tell
then
strip set-g-aliases
"_page/galiasown/g-" 3 pick strcat
trigger @ getlink swap
me @ int intostr setpropstr
"_page/galias/g-" rot strcat
trigger @ getlink swap rot setpropstr
;
: get-alias (aliasname playerdbref -- aliasstr)
over swap get-personal-alias
dup not if
pop get-global-alias
else swap pop
then
;
( Line 888. )
( *** END PROPS ON PROG *** )
: getday ( -- int)
systime dup 86400 % 86400 + time 60 * + 60 * + - 86400 % - 86400 /
;
: setday ( int -- )
#0 "day" "" 4 pick addprop
trigger @ getlink "day" rot "" swap addprop
;
: gettime ( -- int )
time 60 * + 60 * +
;
: get-timestr ( -- timestr)
"%I:%M%p" systime timefmt tolower
dup "0" 1 strncmp not if
1 strcut swap pop
then
;
: get-timestr24h ( -- timestr)
"%H:%M" systime timefmt
;
( *** end of routines for getting and setting properties *** )
( alias listing stuff )
: list-personal-aliases ( - )
" Personal Aliases List" tell
"Alias Name -- Alias Expansion" tell
"---------- --------------------------------------------------" tell
me @ get-p-aliases sort-stringwords
begin
dup while
" " split swap dup 4 pick get-personal-alias
" -- " swap strcat over 10 fillspace swap strcat
strcat tell
repeat pop pop
;
: list-global-aliases ( - )
" Global Aliases List" tell
"Alias Name -- Alias Expansion" tell
"---------- --------------------------------------------------" tell
get-g-aliases sort-stringwords
begin
dup while
" " split swap dup get-global-alias
" -- " swap strcat over 10 fillspace swap strcat
strcat tell
repeat pop
;
: list-matching-aliases (namestr -- )
foreground "Aliases containing the name \"" over strcat "\"" strcat tell
"Alias Name -- Alias Expansion" tell
"---------- --------------------------------------------------" tell
tolower get-g-aliases " " strcat get-p-aliases strcat sort-stringwords
begin
dup while
" " split swap dup me @ get-alias
" -- " swap strcat over 10 fillspace swap strcat strcat
dup " " swap over strcat strcat tolower
4 pick " " swap over strcat strcat
instr not if pop else tell then
repeat pop
;
( misc simple routines )
: single-space (s -- s') (strips all multiple spaces down to a single space)
begin
dup " " instr while
" " " " subst
repeat
;
: comma-format (string -- formattedstring)
strip single-space
", " " " subst
dup ", " rinstr dup if
1 - strcut 2 strcut
swap pop " and "
swap strcat strcat
else pop
then
;
: stringmatch? (str cmpstr #charsmin-- bool)