-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccounts.cpp
executable file
·811 lines (656 loc) · 21.1 KB
/
accounts.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
/* Account Code for Smaug */
#include <stdlib.h>
#include <string.h>
#ifdef unix
#include <crypt.h>
#endif
#include "character.h"
#include "connection.h"
#include "connection_manager.h"
#include "paths.const.h"
#include "java_iterator.hpp"
#include <sstream>
#include <iterator>
const char * const account_flags [] =
{
"banned", "canmplay", "immortal", "logged", "noautoallow", "waiting", "notify", "canwho"
};
void load_account_banlist (void);
ACCOUNT_BAN_DATA* first_account_ban;
ACCOUNT_BAN_DATA* last_account_ban;
unsigned visflg(unsigned flags)
{
return(flags & ~(ACCOUNT_NOTIFY | ACCOUNT_CANWHO));
}
void do_autologin(Character * ch, const char* argument)
{
PlayerConnection * d = ch->GetConnection();
if ( !d )
{
ch->sendText("You have no connection!\r\n");
return;
}
if ( !d->Account )
{
ch->sendText("Your connection has no account!\r\n");
return;
}
d->Account->autoLoginName_ = argument;
ch->sendText("Will now automatically log in to " + string(argument) + ".\r\n");
write_account_data(d->Account);
}
void do_accounts(Character * ch, const char* argument)
{
char cmd[MAX_INPUT_LENGTH];
if ( !argument || argument[0] == '\0' ) {
send_to_char("Usage: accounts <command> <arguments>\r\n\r\n", ch);
send_to_char("Where <command> is one of the following:\r\n\r\n", ch);
ch_printf(ch, "\t%10s %10s %10s %10s\r\n", "connected", "ban", "banned", "waiting");
ch_printf(ch, "\t%10s %10s %10s %10s\r\n", "approve", "deny", "show", "set");
return;
}
argument = one_argument(argument, cmd);
if ( !str_prefix(cmd, "connected") ) {
ACCOUNT_DATA* act;
ch_printf(ch, "%-40s | %-3s | %-30s\r\n", "Email", "Num", "Flags");
ch_printf(ch, "-----------------------------------------+-----+-------------------------------\n");
for ( act = first_account; act; act = act->next ) {
ch_printf(ch, "%-40s | %3d | %s\r\n",
act->email, act->iref, flag_string(visflg(act->flags), account_flags));
}
return;
} else if ( !str_prefix(cmd, "banned") ) {
ACCOUNT_BAN_DATA* pban;
ACCOUNT_DATA* pact;
Character * vch;
if ( argument[0] != '\0' ) {
char target[MAX_INPUT_LENGTH];
argument = one_argument(argument, target);
if ( NULL != (pact = load_account_data(target)) ) {
SET_BIT(pact->flags, ACCOUNT_BANNED);
write_account_data(pact);
free_account_data(pact);
send_to_char("Account banned.\r\n", ch);
return;
} else if ( NULL != (vch = get_char_world(ch, target)) ) {
int x,y;
if ( IS_NPC(vch) ) {
send_to_char("You can not ban NPCs.\r\n", ch);
return;
}
if ( !vch->pcdata->email[0] ) {
send_to_char("That character doesn't seem to have an account to ban!\r\n", ch);
return;
}
if ( !(pact = load_account_data(vch->pcdata->email) ) ) {
send_to_char("Could not load that character's account data!\r\n", ch);
return;
}
SET_BIT(pact->flags, ACCOUNT_BANNED);
write_account_data(pact);
vch->sendText("Your account has been banned from this MUD.\r\n", false);
quitting_char = vch;
save_char_obj(vch);
saving_char = NULL;
extract_char(vch, TRUE);
for ( x = 0; x < MAX_WEAR; x++ )
for ( y = 0; y < MAX_LAYERS; y++ )
save_equipment[x][y] = NULL;
send_to_char("Player account banned. Player disconnected.\r\n", ch);
return;
} else {
for ( pban = first_account_ban; pban; pban = pban->next ) {
if ( !str_cmp(target, pban->address) ) {
send_to_char("But, that address is already banned!\r\n", ch);
return;
}
}
if ( argument[0] == '\0' ) {
send_to_char("Usage: accounts ban <account> <banned|noautoallow>\r\n", ch);
return;
}
CREATE(pban, ACCOUNT_BAN_DATA, 1);
LINK(pban, first_account_ban, last_account_ban, next, prev);
pban->address = str_dup(target);
pban->secBanTime= secCurrentTime;
if ( !str_prefix(argument, "banned") ) {
SET_BIT(pban->flags, ACCOUNT_BANNED);
} else {
SET_BIT(pban->flags, ACCOUNT_NOAUTOALLOW);
}
save_account_banlist();
send_to_char("Address banned.\r\n", ch);
return;
}
} else { /* no argument -- show banned accounts */
int bnum;
send_to_pager("Banned/Watched accounts:\r\n", ch);
send_to_pager("[ #] Time Address Flags\r\n", ch);
send_to_pager("---- ------------------------ ------------------------ ----------\r\n", ch);
for ( pban = first_account_ban, bnum = 1; pban; pban = pban->next, bnum++ ) {
if ( IS_SET(pban->flags, ACCOUNT_WAITING) ) {
continue; /* don't show waiting accounts under the ban list */
}
strncpy(cmd, ctime(&pban->secBanTime), 24);
cmd[24] = '\0';
pager_printf(ch, "[%2d] %-24s %24s %s\r\n", bnum,
cmd, pban->address, flag_string(visflg(pban->flags), account_flags));
}
return;
}
} else if ( !str_prefix(cmd, "allow" ) ) {
int num = -1;
int bnum;
ACCOUNT_BAN_DATA* pban;
if ( argument[0] == '\0' ) {
send_to_char("Remove which address from the account ban list?\r\n", ch);
return;
}
if ( is_number(argument) ) {
num = atoi(argument);
}
for ( pban = first_account_ban, bnum = 1; pban; pban = pban->next, bnum++ ) {
if ( num == bnum || !str_cmp(argument, pban->address) ) {
UNLINK(pban, first_account_ban, last_account_ban, next, prev);
STRFREE(pban->address);
DISPOSE(pban);
save_account_banlist();
send_to_char("Address no longer banned.\r\n", ch);
return;
}
}
if ( num >= bnum ) {
send_to_char("Invalid number.\r\n", ch);
return;
}
send_to_char("Address not banned, is it?\r\n", ch);
return;
} else if ( !str_prefix(cmd, "show") ) {
ACCOUNT_DATA* act;
NoteData* pnote;
int vnum;
Character * vch;
if ( !argument || argument[0] == '\0' ) {
do_accounts(ch, "connected");
return;
}
vch = get_char_world(ch, argument);
act = NULL;
if ( vch )
{
if ( (vch->GetConnection()) && !IS_NPC(vch) ) {
act = load_account_data(vch->GetConnection()->Account->email);
} else {
if (vch->pcdata)
act = load_account_data(vch->pcdata->email);
}
}
else
{
act = load_account_data(argument);
}
if ( !act ) {
send_to_char("No such account found.\r\n", ch);
return;
}
ch_printf(ch, "Information for account %s:\r\n", act->email);
ch_printf(ch, "\r\n");
ch_printf(ch, " Email: %s\r\n", act->email );
ch_printf(ch, " Created On: %s", ctime(&act->secCreatedDate));
ch_printf(ch, " Characters: %s\r\n", act->characters);
ch_printf(ch, " Char History:");
Iterator<std::string> it = MakeIterator(act->allCharacters_);
while (it.hasNext()) {
ch_printf(ch, " %s", it.next().c_str());
}
ch_printf(ch,"\r\n");
ch_printf(ch, " Flags: %d (%s)\r\n", visflg(act->flags), flag_string(visflg(act->flags), account_flags ));
ch_printf(ch, " Instances: %d\r\n", act->iref-1 ); /* -1, 'cause we loaded another one */
ch_printf(ch, " Autologin: %s.\r\n", act->autoLoginName_.c_str() ); /* -1, 'cause we loaded another one */
if ( act->comments ) {
ch_printf(ch, "\r\nComments:\r\n");
vnum = 0;
for ( pnote = act->comments; pnote; pnote = pnote->next ) {
++vnum;
ch_printf(ch, "%2d) %-10s [%s] %s\r\n",
vnum,
pnote->sender_.c_str(),
pnote->date,
pnote->subject);
}
}
free_account_data(act);
} else if ( !str_prefix(cmd, "set" ) ) {
ACCOUNT_DATA* pact;
Character * vch;
char address[MAX_INPUT_LENGTH];
char cmd[MAX_INPUT_LENGTH];
if ( !argument || argument[0] == '\0' ) {
send_to_char("Usage: accounts set <account> flags <flags>\r\n", ch);
return;
}
argument = one_argument(argument, address);
vch = get_char_world(ch, address);
if ( vch && vch->GetConnection()->Account ) {
strcpy(address, vch->GetConnection()->Account->email );
}
if ( !(pact = load_account_data(address)) ) {
send_to_char("No such account.\r\n", ch);
return;
}
if ( !argument || argument[0] == '\0' ) {
do_accounts(ch, "set");
free_account_data(pact);
}
argument = one_argument(argument, cmd);
if ( str_prefix("flags", cmd) ) { /* flags is the only valid option atm */
do_accounts(ch, "set");
free_account_data(pact);
return;
}
while ( argument[0] != '\0' ) {
char flag[MAX_INPUT_LENGTH];
int value;
char prefix;
argument = one_argument(argument, flag);
if ( flag[0] && (flag[0] == '-' || flag[0] == '+' ) ) {
char *a = flag; char* b = a;
++b; prefix = *a;
while((*a++ = *b++));
}
value = get_accountflag(flag);
if ( value < 0 || value > 31 ) {
ch_printf(ch, "Unknown account flag: %s\r\n", flag);
} else {
if ( prefix == '-' ) {
REMOVE_BIT(pact->flags, 1<<value);
} else if ( prefix == '+' ) {
SET_BIT(pact->flags, 1<<value);
} else {
TOGGLE_BIT(pact->flags, 1<<value);
}
}
}
write_account_data(pact);
free_account_data(pact);
send_to_char("Done.\r\n", ch);
return;
} else if ( !str_prefix(cmd, "waiting" ) ) {
ACCOUNT_BAN_DATA* pban;
int bnum;
send_to_pager("Waiting accounts:\r\n", ch);
send_to_pager("[ #] Time Address \r\n", ch);
send_to_pager("---- ------------------------ ------------------------\r\n", ch);
for ( pban = first_account_ban, bnum = 1; pban; pban = pban->next ) {
if ( !IS_SET(pban->flags, ACCOUNT_WAITING) ) {
continue; /* only show waiting accounts */
}
strncpy(cmd, ctime(&pban->secBanTime), 24);
cmd[24] = '\0';
pager_printf(ch, "[%2d] %-24s %24s\r\n", bnum,
cmd, pban->address);
bnum++;
}
return;
} else if ( !str_prefix(cmd, "allow") ) {
ACCOUNT_BAN_DATA *pban;
int num = -1;
int bnum;
if ( !argument || argument[0] == '\0' ) {
send_to_char("Allow which banned account?\r\n", ch);
return;
}
if ( is_number(argument) ) {
num = atoi(argument);
}
for ( bnum = 1, pban = first_account_ban; pban; pban = pban->next ) {
if ( IS_SET(pban->flags, ACCOUNT_WAITING) ) {
continue;
}
if ( bnum == num || !str_cmp(argument, pban->address) ) {
UNLINK(pban, first_account_ban, last_account_ban, next, prev);
save_account_banlist();
}
STRFREE(pban->address);
DISPOSE(pban);
send_to_char("Address unbanned.\r\n", ch);
break;
}
} else if ( !str_prefix(cmd, "approve") ) {
ACCOUNT_DATA *pact;
ACCOUNT_BAN_DATA *pban;
char email[MAX_INPUT_LENGTH];
char pword[8];
int num = -1;
int bnum;
if ( !argument || argument[0] == '\0' ) {
send_to_char("Approve which waiting account?\r\n", ch);
return;
}
if ( is_number(argument) ) {
num = atoi(argument);
}
for ( bnum = 1, pban = first_account_ban; pban; pban = pban->next ) {
if ( !IS_SET(pban->flags, ACCOUNT_WAITING) ) {
continue;
}
if ( bnum == num || !str_cmp(argument, pban->address) ) {
UNLINK(pban, first_account_ban, last_account_ban, next, prev);
save_account_banlist();
break;
}
bnum++;
}
if ( !pban ) {
if ( is_number(argument) ) {
send_to_char("Invalid waiting number.\r\n", ch);
return;
} else {
strcpy(email, argument);
}
} else {
strcpy(email, pban->address);
STRFREE(pban->address);
DISPOSE(pban);
}
if ( (pact = load_account_data(email)) != NULL ) {
send_to_char("Woah! Baby! That account already, like, exists!\r\n", ch);
free_account_data(pact);
return;
}
pact = new Account;
pact->email = STRALLOC(email);
strncpy(pword, random_password(), 8);
pword[7] = '\0';
pact->password_ = crypt(pword, random_password());
pact->characters = STRALLOC("");
pact->secCreatedDate = time(0);
pact->flags = 0;
pact->iref = 1;
/* EVIL HACK */
/* mail_account_password wants a descriptor, both for the account */
/* and to send failure messages to */
/* so we give it both AND DISPOSE OF THEM */
// adjusted by Ksilyan...
ACCOUNT_DATA * oldAccount = ch->GetConnection()->Account;
ch->GetConnection()->Account = pact;
if ( !mail_account_password(ch->GetConnection(), pword, NEW_ACCOUNT_FILE) ) {
send_to_char("Weird case. Email failed. You're screwed.\r\n", ch);
free_account_data(pact);
ch->GetConnection()->Account = oldAccount;
return;
}
write_account_data(pact);
free_account_data(pact);
ch->GetConnection()->Account = oldAccount;
send_to_char("Address authorized. Account created. Player mailed.\r\n", ch);
return;
} else if ( !str_prefix(cmd, "deny") ) {
ACCOUNT_BAN_DATA *pban;
ACCOUNT_DATA *pact;
char email[MAX_INPUT_LENGTH];
int bnum;
int num = -1;
if ( !argument || argument[0] == '\0' ) {
send_to_char("Deny which waiting account?\r\n", ch);
return;
}
if ( is_number(argument) ) {
num = atoi(argument);
}
for ( bnum = 1, pban = first_account_ban; pban; pban = pban->next ) {
if ( !IS_SET(pban->flags, ACCOUNT_WAITING) ) {
continue;
}
if ( bnum == num || !str_cmp(argument, pban->address) ) {
UNLINK(pban, first_account_ban, last_account_ban, next, prev);
save_account_banlist();
break;
}
bnum++;
}
if ( !pban ) {
if ( is_number(argument) ) {
send_to_char("Invalid waiting number.\r\n", ch);
return;
} else {
send_to_char("That email address is not awaiting approval.\r\n", ch);
return;
}
} else {
strcpy(email, pban->address);
STRFREE(pban->address);
DISPOSE(pban);
}
/* EVIL HACK */
/* mail_account_password wants a descriptor, both for the account */
/* and to send failure messages to */
/* so we give it both AND DISPOSE OF THEM */
pact->email = email;
ACCOUNT_DATA * oldAccount = ch->GetConnection()->Account;
ch->GetConnection()->Account = pact;
if ( !mail_account_password(ch->GetConnection(), NULL, ACCOUNT_REJECTED_FILE) ) {
send_to_char("Weird case. Email failed. You're screwed.\r\n", ch);
delete pact;
ch->GetConnection()->Account = oldAccount;
return;
}
delete pact;
ch->GetConnection()->Account = oldAccount;
send_to_char("Account denied. Player emailed.\r\n", ch);
return;
} else {
do_accounts(ch, "");
}
}
void save_account_banlist( void )
{
ACCOUNT_BAN_DATA* pban;
FILE* fp;
fclose(fpReserve);
if ( !(fp = fopen(SYSTEM_DIR ACCOUNT_BAN_LIST, "w" )) ) {
bug("save_account_banlist: Cannot open " ACCOUNT_BAN_LIST, 0);
perror(ACCOUNT_BAN_LIST);
fpReserve = fopen(NULL_FILE, "r");
return;
}
for ( pban = first_account_ban; pban; pban = pban->next )
fprintf(fp, "%d %s~~%ld\n", pban->flags, pban->address, pban->secBanTime);
fprintf(fp, "-1\n");
fclose(fp);
fpReserve = fopen(NULL_FILE, "r");
return;
}
void load_account_banlist( void )
{
ACCOUNT_BAN_DATA* pban;
FILE* fp;
char letter;
int flags;
if ( !(fp = fopen(SYSTEM_DIR ACCOUNT_BAN_LIST, "r" )) )
return;
for ( ; ; ) {
if ( feof(fp) ) {
bug("load_account_banlist: no -1 found.");
fclose(fp);
return;
}
flags = fread_number(fp);
if ( flags == -1 ) {
fclose(fp);
return;
}
CREATE(pban, ACCOUNT_BAN_DATA, 1);
pban->flags = flags;
pban->address = fread_string_nohash(fp);
if ( (letter = fread_letter(fp)) == '~' )
pban->secBanTime = fread_number(fp);
else
{
ungetc(letter, fp);
pban->secBanTime= -1;
}
LINK(pban, first_account_ban, last_account_ban, next, prev);
}
}
int get_accountflag( const char*flag) {
int x;
for ( x = 0; x < MAX_ACCOUNT_FLAGS; x++ ) {
if ( !str_cmp(flag, account_flags[x] ) ) {
return x;
}
}
return -1;
}
void write_account_data(ACCOUNT_DATA* act)
{
FILE *fp;
char fname[MAX_STRING_LENGTH];
char buf[MAX_STRING_LENGTH];
sprintf(fname, "%s/%s", ACCOUNTS_DIR, strlower(act->email));
if ( !(fp = fopen(fname, "w")) ) {
sprintf(buf, "write_account_data: cannot open %s for write", fname);
bug(buf);
return;
}
fprintf(fp, "Password %s~\r\n", act->password_.c_str());
fprintf(fp, "ForumPassword %s~\n\r", (act->forumPassword_.length() > 0
? act->forumPassword_.c_str()
: act->password_.c_str()) );
fprintf(fp, "Flags %d\r\n", act->flags );
fprintf(fp, "Characters %s~\r\n", act->characters );
fprintf(fp, "AllCharacters ");
Iterator<std::string> it = MakeIterator(act->allCharacters_);
while (it.hasNext())
{
fprintf(fp, " %s", it.next().c_str());
}
fprintf(fp, "~\r\n");
fprintf(fp, "Email %s~\r\n", act->email );
fprintf(fp, "CreatedDate %ld\r\n", act->secCreatedDate);
if ( act->autoLoginName_.length() > 0 )
fprintf(fp, "AutoLogin %s~\r\n", act->autoLoginName_.c_str() );
fprintf(fp, "\r\n");
fwrite_comments(act, fp);
fprintf(fp, "End\r\n");
fclose(fp);
return;
}
/* Dispose of an account data if iref == 0 */
void free_account_data(ACCOUNT_DATA* act) {
if ( !act ) {
return;
}
if ( --act->iref > 0 ) {
return;
}
UNLINK(act, first_account, last_account, next, prev);
delete act;
}
Account::Account()
{
this->flags = 0;
this->secCreatedDate = 0;
this->comments = NULL;
}
Account::~Account()
{
STRFREE(this->email);
STRFREE(this->characters);
}
/*
* Load an account file and return a structure describing it
*/
ACCOUNT_DATA* load_account_data(const char* address)
{
FILE *fp;
char fname[MAX_STRING_LENGTH];
ACCOUNT_DATA* act;
bool fMatch;
char buf[MAX_STRING_LENGTH];
const char *word;
/* Don't load another copy */
if ( (act = find_account_data(address)) ) {
act->iref++;
return act;
}
if (!address)
{
sprintf(buf, "We're having trouble with an account data! ACK!");
log_string(buf);
return NULL;
}
if(address[0]=='\0')
return NULL;
sprintf(fname, "%s/%s", ACCOUNTS_DIR, strlower(address));
if ( !(fp = fopen(fname, "r")) ) {
return NULL;
}
act = new Account();
for ( ;; ) {
word = feof(fp) ? "End" : fread_word(fp);
fMatch = FALSE;
switch ( UPPER(word[0]) ) {
case '#':
if ( !str_cmp(word, "#COMMENT") ) {
fread_to_eol(fp);
fread_comment(act, fp);
fMatch = TRUE;
}
break;
case '*':
fMatch = TRUE;
fread_to_eol(fp);
break;
case 'P':
KEY("Password", act->password_, fread_string_noheap(fp));
break;
case 'F':
KEY("Flags", act->flags, fread_number(fp));
KEY("ForumPassword", act->forumPassword_, fread_string_noheap(fp));
break;
case 'A':
if (!str_cmp(word, "AllCharacters"))
{
std::string allChars = fread_string_noheap(fp);
std::istringstream is(allChars);
act->allCharacters_ = std::set<std::string>(std::istream_iterator<std::string>(is), std::istream_iterator<std::string>());
fMatch = true;
break;
}
KEY("AutoLogin", act->autoLoginName_, fread_string_noheap(fp));
break;
case 'C':
KEY("Characters", act->characters, fread_string(fp));
KEY("CreatedDate", act->secCreatedDate, fread_number(fp));
break;
case 'E':
KEY("Email", act->email, fread_string(fp));
if ( !str_cmp(word, "End") ) {
if ( !act->characters ) act->characters = STRALLOC("");
if ( !act->email ) act->email = STRALLOC("");
if ( act->forumPassword_.length() == 0 ) {
act->forumPassword_ = act->password_;
}
if ( act->secCreatedDate == 0 ) act->secCreatedDate = time(0);
}
act->iref = 1;
fclose(fp);
LINK(act, first_account, last_account, next, prev);
return act;
}
if ( !fMatch ) {
sprintf(buf, "load_account_data: no match: %s", word);
bug(buf, 0);
}
}
}
ACCOUNT_DATA* get_account(Character *ch, const char* argument)
{
Character * vch;
if ( (vch = get_char_world(ch, argument)) && vch->GetConnection() && vch->GetConnection()->Account ) {
vch->GetConnection()->Account->iref++;
return vch->GetConnection()->Account;
}
return load_account_data(argument);
}