-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathact_wiz.cpp
executable file
·7972 lines (6782 loc) · 201 KB
/
act_wiz.cpp
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
/****************************************************************************
* [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | \\._.// *
* -----------------------------------------------------------| (0...0) *
* SMAUG 1.0 (C) 1994, 1995, 1996 by Derek Snider | ).:.( *
* -----------------------------------------------------------| {o o} *
* SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, | / ' ' \ *
* Scryn, Rennard, Swordbearer, Gorog, Grishnakh and Tricops |~'~.VxvxV.~'~*
* ------------------------------------------------------------------------ *
* Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* ------------------------------------------------------------------------ *
* Wizard/god command module *
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <time.h>
#ifdef unix
#include <unistd.h>
#include <crypt.h>
#endif
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include "mud.h"
#include "mxp.h"
#include "World.h"
#include "connection.h"
#include "connection_manager.h"
#include "object.h"
#include "utility_objs.hpp"
#include "commands.h"
#include "db_public.h"
#include "paths.const.h"
#include "ScentController.h"
#include "Scent.h"
// STL includes
#include <algorithm>
#include <iostream>
#include <sstream>
#define RESTORE_INTERVAL 21600
const char * const save_flag[] =
{ "death", "kill", "passwd", "drop", "put", "give", "auto", "zap",
"auction", "get", "receive", "idle", "backup", "r13", "r14", "r15", "r16",
"r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27",
"r28", "r29", "r30", "r31" };
/* from comm.c */
//bool write_to_descriptor ( int desc, char *txt, int length ) ;
/*
* Local functions.
*/
ROOM_INDEX_DATA * find_location ( CHAR_DATA *ch, char *arg ) ;
void save_banlist ( void ) ;
void close_area ( AREA_DATA *pArea ) ;
int get_color (const char *argument); /* function proto */
AREA_DATA *get_area_obj( OBJ_INDEX_DATA * pObjIndex );
AREA_DATA *get_area_mob( MOB_INDEX_DATA * pMobIndex );
/*
* Global variables.
*/
char reboot_time[50];
time_t secNewBoot_time_t;
extern struct tm new_boot_struct;
extern OBJ_INDEX_DATA *obj_index_hash[MAX_KEY_HASH];
extern ROOM_INDEX_DATA * room_index_hash[MAX_KEY_HASH];
extern MOB_INDEX_DATA *mob_index_hash[MAX_KEY_HASH];
/*
KSILYAN'S TOY
just a test toy thing.
*/
void do_ksilyantoy(CHAR_DATA *ch, const char* argument)
{
//ch->sendText("\e[1;1H");
//ch->sendText("Hello\n\r");
/*Object * obj;
obj = get_obj_list( ch, argument, ch->first_carrying );
if ( !obj )
obj = get_obj_list( ch, argument, ch->GetInRoom()->first_content );
if ( !obj )
{
ch->sendText("No such object.\n\r");
return;
}
ch->sendText( MasterDatabase->ShowObject(obj) );*/
/*class MyEvent : public Event
{
public:
MyEvent (const int iTime,
const string sMsg,
Character * ch,
const bool bRepeat = false,
const long iSequence = 0)
: Event (iTime, bRepeat, iSequence),
m_sMsg (sMsg), m_ch(ch)
{ };
virtual void OnEvent (void)
{
m_ch->sendText(m_sMsg);
};
private:
const string m_sMsg;
Character * m_ch;
}; // end of class myevent_A
MyEvent * event = new MyEvent (5000,
"hello there!",
ch,
false
);
gTheWorld->AddEvent(event);*/
/*list<SocketGeneral*>::iterator itor;
list<SocketGeneral*> localList;
//localList.push_back(*(gConnectionManager->GetSocketsBegin()));
//localList.push_front(*(gConnectionManager->GetSocketsBegin()++));
localList.insert (localList.end(), gConnectionManager->GetSocketsBegin(), gConnectionManager->GetSocketsEnd());
for (itor = gConnectionManager->GetSocketsBegin(); itor != gConnectionManager->GetSocketsEnd(); itor++)
{
bool result = listContains(localList, (*itor));
ch_printf(ch, "For descriptor %d, the answer is: ", (*itor)->GetDescriptor());
if (result)
ch->sendText("True\n");
else
ch->sendText("False\n");
}*/
/*send_to_char("\e[1z", ch);
send_to_char("<FRAME Name=\"Status\" Height=\"20c\" Floating>\n", ch);
send_to_char("\e[1z", ch);
send_to_char("<send href=\"say Hello\">Hello!</send>\n\r", ch);
send_to_char("\e[1z", ch);
send_to_char("<DEST Status>Hello!!!</DEST>\n\r", ch);
send_to_char("\e[1z", ch);
send_to_char("<IMG tessle.gif>\n", ch);
send_to_char("\e[1z", ch);
send_to_char("<FRAME Status REDIRECT>Hello there.<FRAME _previous REDIRECT>\n", ch);*/
ch->sendText(MXPTAG("font face='Times New Roman'") "Hello!" MXPTAG("/font") MXPTAG("font color=red") MXPTAG("B") "YO" MXPTAG("/B") MXPTAG("/font") "\r\n");
}
// AIYAN - SCENT SYSTEM - 27/03/05
void do_scentedit(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
argument = one_argument(argument, arg );
if ( arg[0] == '\0' )
{
send_to_char("Syntax: ScentEdit <List/View/Edit/Create/Save/Delete>\n\r", ch);
return;
}
// Display all scents - welcome to Hacksville, population me
if ( !str_cmp( arg, "list" ) )
{
list<Scent*>::iterator it;
if ( ScentController::instance()->firstScent() == ScentController::instance()->lastScent() )
{
send_to_char("No scents found.\n\r", ch);
return;
}
send_to_char("\n\rCurrent Scents: \n\r", ch);
for ( it = ScentController::instance()->firstScent(); it != ScentController::instance()->lastScent(); ++it )
{
ch_printf(ch, "%d) %s\n\r", (*it)->getID(), (*it)->getName().c_str());
}
return;
}
if ( !str_cmp( arg, "view" ) )
{
Scent *TempScent = NULL;
if ( argument[0] == '\0' )
{
send_to_char("Syntax: Scent view <ID>\n\r", ch);
return;
}
if ( !is_number(argument) )
{
send_to_char("Scent view argument must be numeric.\n\r", ch);
return;
}
int scentID = atoi(argument);
if (( TempScent = ScentController::instance()->findScent(scentID)) == NULL )
{
send_to_char("No scent with that ID.\n\r", ch);
return;
}
ch_printf(ch, "\n\rScent Data\n\r");
ch_printf(ch, "Scent ID: %d\nScent Name: %s\nScent Description: %s\n\r", TempScent->getID(), TempScent->getName().c_str(), TempScent->getDescription().c_str());
return;
}
if ( !str_cmp( arg, "edit" ) )
{
argument = one_argument(argument, arg);
Scent *editScent = NULL;
if ( arg[0] == '\0' )
{
send_to_char("Syntax: Scent Edit <ID> <Name/Desc> <Text>\n\r", ch);
return;
}
if ( !is_number(arg) )
{
send_to_char("ID must be numeric.\n\r", ch);
return;
}
int scentID = atoi(arg);
if (( editScent = ScentController::instance()->findScent(scentID)) == NULL )
{
send_to_char("No scent with that ID.\n\r", ch);
return;
}
argument = one_argument(argument, arg2);
if ( arg2[0] == '\0' )
{
send_to_char("Edit name or desc?\n\r", ch);
return;
}
if ( !str_cmp( arg2, "name" ) )
{
editScent->setName(argument);
send_to_char("Scent name set.\n\r", ch);
return;
}
if ( !str_cmp( arg2, "desc" ) )
{
editScent->setDescription(argument);
send_to_char("Scent description set.\n\r", ch);
return;
}
return;
}
if ( !str_cmp( arg, "create" ) )
{
argument = one_argument(argument, arg);
argument = one_argument(argument, arg2);
if ( arg[0] == '\0' )
{
send_to_char("Syntax: ScentEdit create <ID> <Name> <Description>\n\r", ch);
return;
}
if ( arg2[0] == '\0' )
{
send_to_char("Syntax: ScentEdit Create ID <Name> <Description>\n\r", ch);
return;
}
if ( argument[0] == '\0' )
{
send_to_char("Syntax: ScentEdit Create ID Name <Description>\n\r", ch);
return;
}
if ( !is_number(arg) )
{
send_to_char("ID must be numberic.\n\r", ch);
return;
}
int scentID = atoi(arg);
if ( ScentController::instance()->findScent(scentID) != NULL )
{
send_to_char("A scent with that ID already exists.\n\r", ch);
return;
}
Scent *NewScent = new Scent(scentID, arg2, argument);
ScentController::instance()->addScent(NewScent);
send_to_char("Scent added.\n\r", ch);
return;
}
if ( !str_cmp( arg, "delete" ) )
{
Scent * deleteScent = NULL;
if ( argument[0] == '\0' )
{
send_to_char("Syntax: ScentEdit Delete <ID>\n\r", ch);
return;
}
if ( !is_number(argument ) )
{
send_to_char("ID must be numeric.\n\r", ch);
return;
}
int scentID = atoi(argument);
if (( deleteScent = ScentController::instance()->findScent(scentID)) == NULL )
{
send_to_char("No such scent with that ID.\n\r", ch);
return;
}
ScentController::instance()->deleteScent(deleteScent);
send_to_char("Scent deleted.\n\r", ch);
}
if ( !str_cmp( arg, "save" ) )
{
send_to_char("Saving scents\n\r", ch);
ScentController::instance()->saveScents();
return;
}
return;
}
int get_saveflag( const char *name )
{
unsigned int x;
for ( x = 0; x < sizeof(save_flag) / sizeof(save_flag[0]); x++ )
if ( !str_cmp( name, save_flag[x] ) )
return x;
return -1;
}
void do_wizhelp(CHAR_DATA *ch, const char* argument)
{
CMDTYPE * cmd;
char cmdprefix[MAX_INPUT_LENGTH] = "\0";
int col, hash;
int low = 0, high = 0;
if ( !argument || argument[0] == '\0' )
{
low = LEVEL_HERO_MIN;
high = get_trust(ch);
}
else
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
argument = one_argument(argument, arg1);
argument = one_argument(argument, arg2);
if ( is_number(arg1) ) {
low = atoi(arg1);
high = low;
} else {
low = LEVEL_HERO_MIN;
high = get_trust(ch);
strcpy(cmdprefix, arg1);
}
if ( cmdprefix[0] == '\0' && is_number(arg2) ) {
high = atoi(arg2);
}
if ( high > get_trust(ch) ) {
high = get_trust(ch);
}
if ( low < LEVEL_HERO_MIN ) {
low = LEVEL_HERO_MIN;
}
if ( high < LEVEL_HERO_MIN ) {
high = get_trust(ch);
}
}
col = 0;
set_pager_color( AT_IMMORT, ch );
ch_printf(ch, "Immortal commands available from level %d to level %d.\r\n", low, high);
if ( cmdprefix[0] != '\0' ) {
ch_printf(ch, "Only listing commands that start with '%s'.\r\n",
cmdprefix);
}
set_pager_color( AT_PLAIN, ch );
size_t maxLength = 1;
// Do a first pass to get the highest width
for ( hash = 0; hash < 126; hash++ ) {
for ( cmd = command_hash[hash]; cmd; cmd = cmd->next ) {
if ( cmd->level >= low
&& cmd->level <= high )
{
if ( cmdprefix[0] != '\0'
&& str_prefix(cmdprefix, cmd->name) ) {
continue;
}
maxLength = max(strlen(cmd->name), maxLength);
}
}
}
// Now, print with that width
int numCols = 80/maxLength;
char formatStr[20];
sprintf(formatStr, "%%-%lus ", maxLength);
for ( hash = 0; hash < 126; hash++ ) {
for ( cmd = command_hash[hash]; cmd; cmd = cmd->next ) {
if ( cmd->level >= low
&& cmd->level <= high )
{
if ( cmdprefix[0] != '\0'
&& str_prefix(cmdprefix, cmd->name) ) {
continue;
}
pager_printf( ch, formatStr, cmd->name );
if ( ++col % numCols == 0 )
send_to_pager( "\n\r", ch );
}
}
}
if ( col % numCols != 0 )
send_to_pager( "\n\r", ch );
return;
}
void do_restrict(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
sh_int level, hash;
CMDTYPE *cmd;
bool found;
found = FALSE;
argument = one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Restrict which command?\n\r", ch );
return;
}
argument = one_argument ( argument, arg2 );
if ( arg2[0] == '\0' )
level = get_trust( ch );
else
level = atoi( arg2 );
level = UMAX( UMIN( get_trust( ch ), level ), 0 );
hash = arg[0] % 126;
for ( cmd = command_hash[hash]; cmd; cmd = cmd->next )
{
if ( !str_prefix( arg, cmd->name )
&& cmd->level <= get_trust( ch ) )
{
found = TRUE;
break;
}
}
if ( found )
{
if ( !str_prefix( arg2, "show" ) )
{
sprintf(buf, "%s show", cmd->name);
do_cedit(ch, buf);
/* ch_printf( ch, "%s is at level %d.\n\r", cmd->name, cmd->level );*/
return;
}
cmd->level = level;
ch_printf( ch, "You restrict %s to level %d\n\r",
cmd->name, level );
sprintf( buf, "%s restricting %s to level %d",
ch->getName().c_str(), cmd->name, level );
log_string( buf );
}
else
send_to_char( "You may not restrict that command.\n\r", ch );
return;
}
/*
* Check if the name prefix uniquely identifies a char descriptor
*/
CHAR_DATA *get_waiting_desc( CHAR_DATA *ch, char *name )
{
CHAR_DATA *ret_char;
static unsigned int number_of_hits;
number_of_hits = 0;
itorSocketId itor;
for ( itor = gTheWorld->GetBeginConnection(); itor != gTheWorld->GetEndConnection(); itor++ )
{
// we know that the world's player connection list only holds player connections IDs,
// so we can safely cast it to PlayerConnection*
PlayerConnection * d = (PlayerConnection *) SocketMap[*itor];
if ( d->GetCharacter() && (!str_prefix( name, d->GetCharacter()->getName().c_str() )) &&
IS_WAITING_FOR_AUTH(d->GetCharacter()) )
{
if ( ++number_of_hits > 1 )
{
ch_printf( ch, "%s does not uniquely identify a char.\n\r", name );
return NULL;
}
ret_char = d->GetCharacter(); /* return current char on exit */
}
}
if ( number_of_hits==1 )
return ret_char;
else
{
send_to_char( "No one like that waiting for authorization.\n\r", ch );
return NULL;
}
}
void do_authorize(CHAR_DATA *ch, const char* argument)
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
CHAR_DATA *victim;
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if ( arg1[0] == '\0' )
{
send_to_char( "Usage: authorize <player> <yes|name|no/deny>\n\r", ch );
send_to_char( "Pending authorizations:\n\r", ch );
send_to_char( " Chosen Character Name\n\r", ch );
send_to_char( "---------------------------------------------\n\r", ch );
itorSocketId itor;
for ( itor = gTheWorld->GetBeginConnection(); itor != gTheWorld->GetEndConnection(); itor++ )
{
// we know that the world's player connection list only holds player connections IDs,
// so we can safely cast it to PlayerConnection*
PlayerConnection * d = (PlayerConnection *) SocketMap[*itor];
if ( (victim = d->GetCharacter()) != NULL && IS_WAITING_FOR_AUTH(victim) )
ch_printf( ch, " %s@%s new %s %s...\n\r",
victim->getName().c_str(),
victim->GetConnection()->GetHost(),
race_table[victim->race].race_name,
class_table[victim->Class]->whoName_.c_str() );
}
return;
}
victim = get_waiting_desc( ch, arg1 );
if ( victim == NULL )
return;
if ( arg2[0]=='\0' || !str_cmp( arg2,"accept" ) || !str_cmp( arg2,"yes" ))
{
victim->pcdata->auth_state = 3;
victim->pcdata->authedBy_ = ch->getName();
sprintf( buf, "%s authorized %s", ch->getName().c_str(),
victim->getName().c_str() );
to_channel( buf, CHANNEL_MONITOR, "Monitor", ch->level );
ch_printf( ch, "You have authorized %s.\n\r", victim->getName().c_str());
/* Below sends a message to player when name is accepted - Brittany */
ch_printf( victim, /* B */
"The MUD Administrators have accepted the name %s.\n\r" /* B */
"You will be authorized to enter the Realms at the end of " /* B */
"this area.\n\r",victim->getName().c_str()); /* B */
return;
}
else if ( !str_cmp( arg2, "no" ) || !str_cmp( arg2, "deny" ) )
{
send_to_char( "You have been denied access.\n\r", victim);
sprintf( buf, "%s denied authorization to %s", ch->getName().c_str(),
victim->getName().c_str() );
to_channel( buf, CHANNEL_MONITOR, "Monitor", ch->level );
ch_printf( ch, "You have denied %s.\n\r", victim->getName().c_str());
do_quit(victim, "");
}
else if ( !str_cmp( arg2, "name" ) || !str_cmp(arg2, "n" ) )
{
victim->pcdata->auth_state = 2;
sprintf( buf, "%s has denied %s's name", ch->getName().c_str(),
victim->getName().c_str() );
to_channel( buf, CHANNEL_MONITOR, "Monitor", ch->level );
ch_printf (victim,
"The MUD Administrators have found the name %s "
"to be unacceptable.\n\r"
"You may choose a new name when you reach " /* B */
"the end of this area.\n\r" /* B */
"The name you choose must be medieval and original.\n\r"
"No titles, descriptive words, or names close to any existing "
"Immortal's name.\n\r", victim->getName().c_str());
ch_printf( ch, "You requested %s change names.\n\r", victim->getName().c_str());
return;
}
else
{
send_to_char("Invalid argument.\n\r", ch);
return;
}
}
void do_bamfin(CHAR_DATA *ch, const char* argument)
{
if ( !IS_NPC(ch) )
{
if ( !strstr(argument, "$n") ) {
send_to_char("You must include the ever important $n character!\n",
ch);
return;
}
ch->pcdata->bamfIn_ = SmashTilde(argument);
send_to_char( "Ok.\n\r", ch );
}
return;
}
void do_bamfout(CHAR_DATA *ch, const char* argument)
{
if ( !IS_NPC(ch) )
{
if ( !strstr(argument, "$n") ) {
send_to_char("You must include the ever important $n character!\n",
ch);
return;
}
ch->pcdata->bamfOut_ = SmashTilde(argument);
send_to_char( "Ok.\n\r", ch );
}
return;
}
void do_rank(CHAR_DATA *ch, const char* argument)
{
if ( IS_NPC(ch) )
return;
if ( !argument || argument[0] == '\0' )
{
send_to_char( "Usage: rank <string>.\n\r", ch );
send_to_char( " or: rank none.\n\r", ch );
return;
}
argument = smash_tilde_static( argument );
if ( !str_cmp( argument, "none" ) )
ch->pcdata->rank_ = "";
else
ch->pcdata->rank_ = argument;
send_to_char( "Ok.\n\r", ch );
return;
}
void do_retire(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Retire whom?\n\r", ch );
return;
}
if ( ( victim = get_char_world( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( IS_NPC(victim) )
{
send_to_char( "Not on NPC's.\n\r", ch );
return;
}
if ( get_trust( victim ) >= get_trust( ch ) )
{
send_to_char( "You failed.\n\r", ch );
return;
}
if ( victim->level < LEVEL_WANDERER )
{
send_to_char( "The minimum level for retirement is savior.\n\r", ch );
return;
}
if ( IS_RETIRED( victim ) )
{
REMOVE_BIT( victim->pcdata->flags, PCFLAG_RETIRED );
ch_printf( ch, "%s returns from retirement.\n\r", victim->getName().c_str() );
ch_printf( victim, "%s brings you back from retirement.\n\r", ch->getName().c_str() );
}
else
{
SET_BIT( victim->pcdata->flags, PCFLAG_RETIRED );
ch_printf( ch, "%s is now a retired immortal.\n\r", victim->getName().c_str() );
ch_printf( victim, "Courtesy of %s, you are now a retired immortal.\n\r", ch->getName().c_str() );
}
return;
}
void do_deny(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Deny whom?\n\r", ch );
return;
}
if ( ( victim = get_char_world( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( IS_NPC(victim) )
{
send_to_char( "Not on NPC's.\n\r", ch );
return;
}
if ( get_trust( victim ) >= get_trust( ch ) )
{
send_to_char( "You failed.\n\r", ch );
return;
}
SET_BIT(victim->act, PLR_DENY);
send_to_char( "You are denied access!\n\r", victim );
send_to_char( "OK.\n\r", ch );
do_quit( victim, "" );
return;
}
void do_disconnect(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Disconnect whom?\n\r", ch );
return;
}
if ( ( victim = get_char_world( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( victim->GetConnection() == NULL )
{
act( AT_PLAIN, "$N doesn't have a descriptor.", ch, NULL, victim, TO_CHAR );
return;
}
if ( get_trust(ch) <= get_trust( victim ) )
{
send_to_char( "They might not like that...\n\r", ch );
return;
}
itorSocketId itor;
for ( itor = gTheWorld->GetBeginConnection(); itor != gTheWorld->GetEndConnection(); itor++ )
{
// we know that the world's player connection list only holds player connections IDs,
// so we can safely cast it to PlayerConnection*
PlayerConnection * d = (PlayerConnection *) SocketMap[*itor];
if ( d == victim->GetConnection() )
{
gConnectionManager->RemoveSocket(d, false);
send_to_char( "Ok.\n\r", ch );
return;
}
}
bug( "Do_disconnect: *** desc not found ***.", 0 );
send_to_char( "Descriptor not found!\n\r", ch );
return;
}
/*
* Force a level one player to quit. Gorog
*/
void do_fquit(CHAR_DATA *ch, const char* argument)
{
CHAR_DATA *victim;
char arg1[MAX_INPUT_LENGTH];
argument = one_argument( argument, arg1 );
if ( arg1[0] == '\0' )
{
send_to_char( "Force whom to quit?\n\r", ch );
return;
}
if ( !( victim = get_char_world( ch, arg1 ) ) )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
send_to_char( "The MUD administrators force you to quit\n\r", victim );
do_quit (victim, "");
send_to_char( "Ok.\n\r", ch );
return;
}
void do_forceclose(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
int desc;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Usage: forceclose <descriptor#>\n\r", ch );
return;
}
desc = atoi( arg );
itorSocketId itor;
for ( itor = gConnectionManager->GetSocketsBegin(); itor != gConnectionManager->GetSocketsEnd(); itor++ )
{
// we know that the world's player connection list only holds player connections IDs,
// so we can safely cast it to PlayerConnection*
SocketGeneral * socket = SocketMap[*itor];
if ( socket->GetDescriptor() == desc )
{
gConnectionManager->RemoveSocket(socket, false);
send_to_char( "Ok.\n\r", ch );
return;
}
}
send_to_char( "Not found!\n\r", ch );
return;
}
void do_pardon(CHAR_DATA *ch, const char* argument)
{
send_to_char( "This is useless now.\r\n", ch);
return;
}
void echo_to_all( sh_int AT_COLOR, const char *argument, sh_int tar )
{
if ( !argument || argument[0] == '\0' )
return;
itorSocketId itor;
for ( itor = gTheWorld->GetBeginConnection(); itor != gTheWorld->GetEndConnection(); itor++ )
{
// we know that the world's player connection list only holds player connections IDs,
// so we can safely cast it to PlayerConnection*
PlayerConnection * d = (PlayerConnection *) SocketMap[*itor];
/* Added showing echoes to players who are editing, so they won't
miss out on important info like upcoming reboots. --Narn */
if ( d->ConnectedState == CON_PLAYING || d->ConnectedState == CON_EDITING )
{
/* This one is kinda useless except for switched.. */
if ( tar == ECHOTAR_PC && IS_NPC(d->GetCharacter()) )
continue;
else if ( tar == ECHOTAR_IMM && !IS_IMMORTAL(d->GetCharacter()) )
continue;
set_char_color( AT_COLOR, d->GetCharacter() );
send_to_char( argument, d->GetCharacter() );
send_to_char( "\n\r", d->GetCharacter() );
}
}
return;
}
void do_echo(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
sh_int color;
int target;
const char *parg;
if ( IS_SET(ch->act, PLR_NO_EMOTE) )
{
send_to_char( "You are noemoted and can not echo.\n\r", ch );
return;
}
if ( argument[0] == '\0' )
{
send_to_char( "Echo what?\n\r", ch );