-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathclan.c
executable file
·3722 lines (3312 loc) · 102 KB
/
clan.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
/****************************************************************************
* Realms of Luminari
* File: clan.c
* Usage: most of the clan code, the editing/save/load are in clan_edit
* Header: clan.h
* Authors: Jamdog (ported to Luminari by Bakarus and Zusuk)
****************************************************************************/
#ifndef __CLAN_C__
#define __CLAN_C__
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "db.h"
#include "interpreter.h"
#include "handler.h"
#include "screen.h"
#include "improved-edit.h"
#include "spells.h" /* find skill, etc */
#include "clan.h"
#include "mudlim.h"
/* Global Variables used by clans */
struct clan_data *clan_list = NULL;
struct claim_data *claim_list = NULL;
int num_of_clans = 0;
/* Clan privileges. Each of these is assigned a minimum rank */
const char *const clan_priv_names[] = {
"Award", /**< 'clan award' command */
"Claim", /**< 'clan claim' command */
"Balance", /**< 'clans bank balance */
"Demote", /**< 'clan demote' command */
"Deposit", /**< 'clan deposit' command */
"Edit", /**< 'clan edit' command */
"Enrol", /**< 'clan enrol' command */
"Expel", /**< 'clan expel' command */
"Owner", /**< 'clan owner' command */
"Promote", /**< 'clan promote' command */
"Where", /**< 'clan where' command */
"Withdraw", /**< 'clan withdraw' command */
"Set-Ally", /**< Set clan Allied-With clan (in OLC) */
"Set-Appfee", /**< Set clan Application fee (in OLC) */
"Set-Applvl", /**< Set clan Application level (in OLC) */
"Set-Desc", /**< Set clan Description (in OLC) */
"Set-Tax", /**< Set clan Tax Rate (in OLC) */
"Set-Ranks", /**< Set clan ranks and rank names (in OLC) */
"Set-Title", /**< Set clan title (name) (in OLC) */
"Set-War", /**< Set clan At-War-With clan (in OLC) */
"Set-Privs", /**< Set clan privilege ranks (in OLC) */
"\n"};
const struct clan_cmds clan_commands[] = {
{"apply", CP_ALL, LVL_GRSTAFF, do_clanapply,
"%sclan apply <clan> %s- %sRequest to join a clan%s\r\n"},
{"award", CP_AWARD, LVL_IMPL, do_clanaward,
"%sclan award <player> <num> %s- %sAward CP to player (costs 10 "
"coins per CP from clan bank)%s\r\n"},
{"claim", CP_CLAIM, LVL_GRSTAFF, do_clanclaim,
"%sclan claim %s- %sTry to claim your current "
"zone for your clan%s\r\n"},
{"balance", CP_BALANCE, LVL_IMPL, do_clanbalance,
"%sclan balance %s- %sChecks the balance of the "
"clan bank%s\r\n"},
{"create", CP_NONE, LVL_IMPL, do_clancreate,
"%sclan create <plr> <name> %s- %sCreate a new clan, and set "
"a leader \tw(IMP-Only!)%s\r\n"},
{"demote", CP_DEMOTE, LVL_GRSTAFF, do_clandemote,
"%sclan demote <player> %s- %sReduce a clan member's clan "
"rank%s\r\n"},
{"deposit", CP_DEPOSIT, LVL_GRSTAFF, do_clandeposit,
"%sclan deposit <amount> %s- %sDeposit gold into clan "
"bank%s\r\n"},
{"destroy", CP_NONE, LVL_IMPL, do_clandestroy,
"%sclan destroy <clan> %s- %sRemove a clan from the clan list"
" \tw(IMP-Only!)%s\r\n"},
{"edit", CP_CLANEDIT, LVL_GRSTAFF, do_clanedit,
"%sclan edit %s- %sEdit clan settings in "
"an OLC%s\r\n"},
{"enrol", CP_ENROL, LVL_GRSTAFF, do_clanenrol,
"%sclan enrol [player] %s- %sList requests or enrol a "
"pending player%s\r\n"},
{"expel", CP_EXPEL, LVL_GRSTAFF, do_clanexpel,
"%sclan expel <player> %s- %sKick a player out of the "
"clan%s\r\n"},
{"info", CP_ALL, LVL_IMMORT, do_claninfo,
"%sclan info [clan] %s- %sInfo about all clans, or a "
"single clan%s\r\n"},
{"list", CP_ALL, LVL_IMMORT, do_claninfo,
"%sclan list %s- %sList all clans or a single specified clan "
"(same as clan info)%s\r\n"},
{"owner", CP_OWNER, LVL_GRSTAFF, do_clanowner,
"%sclan owner <player> %s- %sChange ownership of the "
"clan%s\r\n"},
{"promote", CP_PROMOTE, LVL_GRSTAFF, do_clanpromote,
"%sclan promote <player> %s- %sIncrease a clan member's clan"
" rank%s\r\n"},
{"status", CP_ALL, LVL_IMMORT, do_clanstatus,
"%sclan status %s- %sShows your current clan "
"status%s\r\n"},
{"where", CP_WHERE, LVL_IMMORT, do_clanwhere,
"%sclan where %s- %sShows the location of online "
"clan members%s\r\n"},
{"who", CP_ALL, LVL_IMMORT, do_clanlist,
"%sclan who %s- %sList all members of your clan "
"(same as clan list)%s\r\n"},
{"withdraw", CP_WITHDRAW, LVL_GRSTAFF, do_clanwithdraw,
"%sclan withdraw <amount> %s- %sWithdraw gold from clan "
"bank%s\r\n"},
{"unclaim", CP_NONE, LVL_IMPL, do_clanunclaim,
"%sclan unclaim <zone> %s- %sRemove all claims over a "
"specified zone \tw(IMP-Only)%s\r\n"},
{"\n", 0, 0, 0, "\n"}};
/****************************************************************************
Start basic clan utility functions
***************************************************************************/
/*
int find_clan_by_id(int idnum) {
int i;
for (i = 0; i < num_of_clans; i++)
if (idnum == clan_list[i].id)
return i;
return -1;
}
*/
clan_rnum real_clan(clan_vnum c)
{
int i;
for (i = 0; i < num_of_clans; i++)
if (clan_list[i].vnum == c)
return i;
return NO_CLAN;
}
clan_rnum get_clan_by_name(const char *c_n)
{
int i, v;
// char buf[MAX_STRING_LENGTH] = {'\0'};
/* Look for exact match */
for (i = 0; i < num_of_clans; i++)
{
if (is_abbrev(c_n, clan_list[i].clan_name))
return i;
}
/* Strip color codes and look again */
// for (i=0; i<num_of_clans; i++) {
// snprintf(buf, sizeof(buf), "%s", clan_list[i].clan_name);
// if (is_abbrev(c_n, buf))
// return i;
// }
/* Still not found, so let's look for the VNUM */
if ((v = atoi(c_n)) > 0)
{
for (i = 0; i < num_of_clans; i++)
{
if (clan_list[i].vnum == v)
return i;
}
}
/* Give up! */
return NO_CLAN;
}
int count_clan_members(clan_rnum c)
{
int i, count = 0;
for (i = 0; i <= top_of_p_table; i++)
{
if (player_table[i].clan == clan_list[c].vnum)
count++;
}
return count;
}
int count_clan_power(clan_rnum c)
{
int i, count = 0;
/* Add together the levels of all clan members */
for (i = 0; i <= top_of_p_table; i++)
{
if (player_table[i].clan == clan_list[c].vnum)
count += player_table[i].level;
}
return count;
}
/* Return the vnum of the clan in the list with the highest VNUM */
clan_vnum highest_clan_vnum(void)
{
int i;
clan_vnum hi = 0;
for (i = 0; i < num_of_clans; i++)
{
if (clan_list[i].vnum > hi)
hi = clan_list[i].vnum;
}
return (hi);
}
/* Add a new clan to the clan list - use current string pointers */
bool add_clan(struct clan_data *this_clan)
{
struct clan_data *temp_list;
int i = 0;
/* Validate the clan data and VNUM */
if (!this_clan)
return FALSE;
if (this_clan->vnum == NO_CLAN)
return FALSE;
/* Does clan already exist? */
if (real_clan(this_clan->vnum) != NO_CLAN)
return FALSE;
/* Create a new list */
CREATE(temp_list, struct clan_data, num_of_clans + 1);
/* Copy the old list data */
if (clan_list)
{
for (i = 0; i < num_of_clans; i++)
{
copy_clan_data(&(temp_list[i]), &(clan_list[i]));
}
}
/* Add the new one */
copy_clan_data(&(temp_list[i]), this_clan);
/* Free the old list and set the temp as the new one */
free(clan_list);
clan_list = temp_list;
num_of_clans++;
return TRUE;
}
/* Totally remove a clan from the clan list -does NOT disband the clan first */
bool remove_clan(clan_vnum c_v)
{
struct clan_data *temp_list = NULL;
clan_rnum c_n;
int i = 0;
bool found = FALSE;
/* Validate the clan data and VNUM */
if (!clan_list || num_of_clans == 0)
return FALSE;
/* Does clan exist? */
if ((c_n = real_clan(c_v)) == NO_CLAN)
return FALSE;
if (num_of_clans == 1)
{
free_clan_list();
}
else
{
/* Create a new list */
CREATE(temp_list, struct clan_data, num_of_clans - 1);
/* Copy the old list data */
if (clan_list)
{
for (i = 0; i < num_of_clans; i++)
{
if (!(found))
{
if (i == c_n)
{
found = TRUE; /* Skip this one and set found flag */
}
else
{
copy_clan_data(&(temp_list[i]), &(clan_list[i]));
}
}
else
{
copy_clan_data(&(temp_list[i - 1]), &(clan_list[i]));
}
}
}
/* Free only the string data in the old list used by the removed clan */
if (clan_list[c_n].clan_name)
free(clan_list[c_n].clan_name);
for (i = 0; i < MAX_CLANRANKS; i++)
if (clan_list[c_n].rank_name[i])
free(clan_list[c_n].rank_name[i]);
/* Free the old list and set the temp as the new one */
free(clan_list);
clan_list = temp_list;
num_of_clans--;
}
return TRUE;
}
/* Free a single clan - should NOT be used for clans in the clan list */
void free_clan(struct clan_data *c)
{
int i;
if (c->clan_name)
free(c->clan_name);
for (i = 0; i < MAX_CLANRANKS; i++)
if (c->rank_name[i])
free(c->rank_name[i]);
free(c);
}
/* Remove ALL clans from the MUD, freeing all memory used by the clan list */
void free_clan_list(void)
{
struct clan_data *c;
int i, j;
/* Free all re-usable memory used in clan structs */
for (i = 0; i < num_of_clans; i++)
{
c = &(clan_list[i]); /* Just makes this easier to read! */
if (c->clan_name)
free(c->clan_name);
for (j = 0; j < MAX_CLANRANKS; j++)
if (c->rank_name[j])
free(c->rank_name[j]);
}
/* Then free the whole list */
free(clan_list);
clan_list = NULL;
num_of_clans = 0;
}
/* set_clan - sets a player's clan (but not clan rank) */
bool set_clan(struct char_data *ch, clan_vnum c_v)
{
clan_rnum c_n;
int p_i;
if (!ch)
return FALSE;
if ((c_n = real_clan(c_v)) == NO_CLAN)
return FALSE;
GET_CLAN(ch) = clan_list[c_n].vnum;
save_char(ch, 0);
if ((p_i = get_ptable_by_name(GET_NAME(ch))) < 0)
{
log("SYSERR: Unable to get player_table index for %s in set_clan",
GET_NAME(ch));
return FALSE;
}
else
{
player_table[p_i].clan = clan_list[c_n].vnum;
save_player_index();
}
return TRUE;
}
/* Is 'ch' allowed to edit the specified clan (by vnum) */
bool can_edit_clan(struct char_data *ch, clan_vnum c)
{
clan_rnum cn;
/* Validate data */
if (!ch)
return FALSE;
if (IS_NPC(ch))
return FALSE;
if ((cn = real_clan(c)) == NO_CLAN)
return FALSE;
/* IMPLementors can ALWAYS edit any clan */
if (GET_LEVEL(ch) == LVL_IMPL)
return TRUE;
/* Non-imps can ONLY edit their own clan */
if (GET_CLAN(ch) != c)
return FALSE;
/* Clan leader can always edit their clan */
if (is_a_clan_leader(ch))
return TRUE;
/* Only fully-enrolled clan members have permissions */
if (GET_CLANRANK(ch) == NO_CLANRANK)
return FALSE;
/* Check the clan permissions */
if (GET_CLANRANK(ch) >= CLAN_PRIV(cn, CP_CLANEDIT))
return FALSE;
/* All checks passed! */
return TRUE;
}
/* Copies a clan's information. NOTE: Copies string POINTERS, not strings */
void copy_clan_data(struct clan_data *to_clan, struct clan_data *from_clan)
{
int i;
if (!to_clan || !from_clan)
return;
to_clan->vnum = from_clan->vnum;
to_clan->clan_name = from_clan->clan_name; /* Yes, String pointer! */
to_clan->description = from_clan->description; /* Yes, String pointer! */
to_clan->leader = from_clan->leader;
to_clan->ranks = from_clan->ranks;
to_clan->applev = from_clan->applev;
to_clan->appfee = from_clan->appfee;
to_clan->taxrate = from_clan->taxrate;
for (i = 0; i < MAX_CLANS; i++)
{
to_clan->allies[i] = from_clan->allies[i];
to_clan->at_war[i] = from_clan->at_war[i];
}
to_clan->treasure = from_clan->treasure;
to_clan->pk_win = from_clan->pk_win;
to_clan->pk_lose = from_clan->pk_lose;
to_clan->hall = from_clan->hall;
to_clan->abrev = from_clan->abrev; /* Yes, String pointer! */
for (i = 0; i < MAX_CLANRANKS; i++)
/* Yes, String pointers! */
to_clan->rank_name[i] = from_clan->rank_name[i];
for (i = 0; i < NUM_CLAN_PRIVS; i++)
to_clan->privilege[i] = from_clan->privilege[i];
}
/* Maybe should be free_clan(), but this doesn't re-arrange the clan_list */
void free_single_clan_data(struct clan_data *c)
{
int i;
/* Free allocated string data */
if ((c)->clan_name)
free((c)->clan_name);
if ((c)->abrev)
free((c)->abrev);
if ((c)->description)
free((c)->description);
for (i = 0; i < MAX_CLANRANKS; i++)
if ((c)->rank_name[i])
free((c)->rank_name[i]);
free(c);
}
/* Automatically appoint a new clan leader from the highest ranking officers */
bool auto_appoint_new_clan_leader(clan_rnum c_n)
{
struct char_data *new_l, *v;
long new_l_id = NOBODY;
int i, rk_num, max_rk;
bool loaded = FALSE;
/* Verify c_n */
if (c_n >= num_of_clans)
return FALSE;
/* Set the max rank as lowest possible rank */
max_rk = clan_list[c_n].ranks;
for (i = 0; i <= top_of_p_table; i++)
{
if (player_table[i].clan == clan_list[c_n].vnum)
{
if ((v = is_playing(player_table[i].name)) != NULL)
{
/* If they are playing, no need to load the pfile to get data */
rk_num = GET_CLANRANK(v) - 1;
if (rk_num < 0)
rk_num = (clan_list[c_n].ranks);
if (rk_num < max_rk)
{
max_rk = rk_num;
new_l_id = player_table[i].id;
}
}
else
{
/* They are NOT playing, we need to load this pfile to find the rank */
v = new_char();
if (load_char(player_table[i].name, v) < 0)
{
free_char(v);
continue;
}
rk_num = GET_CLANRANK(v) - 1;
if (rk_num < 0)
rk_num = (clan_list[c_n].ranks);
if (rk_num < max_rk)
{
max_rk = rk_num;
new_l_id = player_table[i].id;
}
free_char(v);
}
}
}
/* Check that we now know the ID of the new leader */
if (new_l_id == NOBODY)
return (FALSE);
/* Load the new leader's pfile again if required */
if ((new_l = is_playing(player_table[new_l_id].name)) == NULL)
{
new_l = new_char();
if (load_char(player_table[new_l_id].name, new_l) < 0)
{
free_char(new_l);
log("SYSERR: Unable to load pfile (%s) to set as leader of '%s' clan.",
player_table[new_l_id].name, clan_list[c_n].clan_name);
return (FALSE);
}
loaded = TRUE;
}
GET_CLANRANK(new_l) = 1; /* Set to top rank */
clan_list[c_n].leader = GET_IDNUM(new_l); /* Set clan leader */
save_clans();
log("(CLAN) %s auto-appointed as new clan leader for '%s'", GET_NAME(new_l),
clan_list[c_n].clan_name);
if (loaded)
{
save_char(new_l, 0);
free_char(new_l);
}
else
{
send_to_char(new_l, "You have been promoted to Clan Leader!\r\n");
send_to_char(new_l, "'%s' is now YOUR clan!\r\n",
clan_list[c_n].clan_name);
}
return (TRUE);
}
/* Returns TRUE is the player is the leader of any clan */
bool is_a_clan_leader(struct char_data *ch)
{
int i;
for (i = 0; i < num_of_clans; i++)
{
if (clan_list[i].leader == GET_IDNUM(ch))
{
return TRUE;
}
}
return FALSE;
}
/* Sets all a clan's values to 0 or NULL.
* NOTE: strings should be free'd BEFORE calling */
void clear_clan_vals(struct clan_data *cl)
{
int i;
cl->applev = 0;
cl->appfee = 0;
cl->taxrate = 0;
cl->hall = 0;
cl->treasure = 0;
cl->war_timer = 0;
for (i = 0; i < MAX_CLANS; i++)
{
cl->allies[i] = 0;
cl->at_war[i] = 0;
}
cl->pk_win = 0;
cl->pk_lose = 0;
cl->clan_name = NULL;
cl->description = NULL;
cl->abrev = NULL;
for (i = 0; i < MAX_CLANRANKS; i++)
cl->rank_name[i] = NULL;
for (i = 0; i < NUM_CLAN_PRIVS; i++)
cl->privilege[i] = 0;
}
/****************************************************************************
End utility functions, Start ACMDC()
***************************************************************************/
/* entry point for clans */
ACMD(do_clan)
{
clan_rnum clan;
int rank, i;
char clan_cmd[MAX_INPUT_LENGTH] = {'\0'};
const char *args;
clan = real_clan(GET_CLAN(ch));
rank = GET_CLANRANK(ch);
if (!argument || !*argument)
{
send_to_char(ch, "*Note, a staff member needs to set up new clans.\r\n");
if ((clan == NO_CLAN) && (GET_LEVEL(ch) < LVL_IMMORT))
{
send_to_char(ch, "You are not a member of any clan!\r\n");
send_to_char(ch, "Use %sclan apply <clan>%s to join one.\r\n",
QCYN, QNRM);
}
else if ((rank == NO_CLANRANK) && (GET_LEVEL(ch) < LVL_IMMORT))
{
send_to_char(ch, "You are awaiting approval for a clan!\r\n");
send_to_char(ch, "Use %sclan apply <clan>%s to change your choice.\r\n",
QCYN, QNRM);
}
send_to_char(ch, "Available clan commands:\r\n");
for (i = 0; *clan_commands[i].command && *clan_commands[i].command != '\n';
i++)
{
if ((CC_PRIV(i) == CP_NONE) && (GET_LEVEL(ch) < CC_ILEV(i)))
continue;
if ((CC_PRIV(i) != CP_ALL) && (clan == NO_CLAN) &&
(GET_LEVEL(ch) < CC_ILEV(i)))
continue;
/* Flagged accessible for all players */
if ((CC_PRIV(i) == CP_ALL) ||
/* Meets minimum imm level for the command */
(GET_LEVEL(ch) >= CC_ILEV(i)) ||
/* Meets minimum rank for this clan priv */
(clan != NO_CLAN && rank >= CLAN_PRIV(clan, CC_PRIV(i))))
send_to_char(ch, CC_TEXT(i), QCYN, QNRM, QYEL, QNRM);
}
}
else
{
args = one_argument(argument, clan_cmd, sizeof(clan_cmd));
for (i = 0; *CC_CMD(i) && *CC_CMD(i) != '\n'; i++)
{
if (is_abbrev(clan_cmd, CC_CMD(i)))
{
if ((CC_PRIV(i) == CP_NONE) && (CC_ILEV(i) != LVL_IMPL) &&
(GET_LEVEL(ch) < CC_ILEV(i)))
{
continue;
}
else if ((CC_PRIV(i) == CP_NONE) && (CC_ILEV(i) == LVL_IMPL) &&
(GET_LEVEL(ch) < CC_ILEV(i)))
{
continue;
}
else if ((CC_PRIV(i) != CP_ALL) && (clan == NO_CLAN) &&
(GET_LEVEL(ch) < CC_ILEV(i)))
{
continue;
/* Flagged accessible for all players */
}
else if ((CC_PRIV(i) == CP_ALL) ||
/* Meets minimum imm level for the command */
(GET_LEVEL(ch) >= CC_ILEV(i)) ||
/* Meets minimum rank for this clan priv */
(clan != NO_CLAN && rank >= CLAN_PRIV(clan, CC_PRIV(i))))
{
((CC_FUNC(i))(ch, args, cmd, subcmd));
return;
}
}
}
send_to_char(ch, "Unknown clan command.\r\n");
}
}
/* clan apply command */
ACMD(do_clanapply)
{
clan_rnum c_n;
if (!argument || !(*argument))
{
send_to_char(ch, "Usage: %sclan apply <clan>%s\r\n", QYEL, QNRM);
return;
}
if (GET_LEVEL(ch) >= LVL_IMMORT)
{
send_to_char(ch, "Gods cannot apply for any clan.\r\n");
return;
}
if (GET_CLANRANK(ch) > NO_CLANRANK)
{
send_to_char(ch, "You already belong to a clan!\r\n");
return;
}
if ((c_n = get_clan_by_name(argument)) == NO_CLAN)
{
send_to_char(ch, "Unknown clan.\r\n");
send_to_char(ch, "Usage: %sclan apply <clan>%s (see 'clan info' "
"list)\r\n",
QYEL, QNRM);
return;
}
if (GET_LEVEL(ch) < clan_list[c_n].applev)
{
send_to_char(ch, "You are not mighty enough to apply to this clan.\r\n");
return;
}
if (GET_GOLD(ch) < clan_list[c_n].appfee)
{
send_to_char(ch, "You cannot afford the application fee!\r\n");
return;
}
/* Application is allowed - take application fee */
decrease_gold(ch, clan_list[c_n].appfee);
clan_list[c_n].treasure += clan_list[c_n].appfee;
save_clans();
/* Set player as in the clan with no clan rank (pending) */
set_clan(ch, clan_list[c_n].vnum);
GET_CLANRANK(ch) = NO_CLANRANK;
send_to_char(ch, "You've applied to clan '%s%s'\r\n"
"In order to be admitted into the clan you will need your application to be approved with a clan member of a certain rank.\r\n"
"If there are no active clan leaders playing, please request a staff member to admit you into the clan.\r\n",
clan_list[c_n].clan_name, QNRM);
return;
}
/* clan award command */
ACMD(do_clanaward)
{
char plr[MAX_INPUT_LENGTH] = {'\0'}, ncp[MAX_INPUT_LENGTH] = {'\0'};
struct char_data *l;
long num_cp;
clan_rnum c_r;
/* These checks are already made, but duplicated here just in case */
if ((!IS_IN_CLAN(ch)) || (GET_CLANRANK(ch) == NO_CLANRANK))
{
send_to_char(ch, "You aren't even in a clan!\r\n");
return;
}
if (!check_clanpriv(ch, CP_AWARD))
{
send_to_char(ch, "You don't have sufficient access to award"
" clan points!\r\n");
return;
}
two_arguments(argument, plr, sizeof(plr), ncp, sizeof(ncp));
if (!*plr || !*ncp)
{
send_to_char(ch, "Usage: %sclan award <player> <num>%s\r\n", QYEL, QNRM);
send_to_char(ch, "Example: clan award Vash 10\r\n");
send_to_char(ch, "Note: Deducts 10 DD per clanpoint awarded from the"
" clan's bank.\r\n");
return;
}
if ((l = get_player_vis(ch, plr, NULL, FIND_CHAR_WORLD)) == NULL)
{
send_to_char(ch, "Usage: %sclan award <player> <num>%s\r\n", QYEL, QNRM);
send_to_char(ch, "Example: clan award Vash 10\r\n");
send_to_char(ch, "Note: Deducts 10 DD per clanpoint awarded from the"
" clan's bank.\r\n");
send_to_char(ch, " Player must be online!\r\n");
return;
}
if ((c_r = real_clan(GET_CLAN(ch))) == NO_CLAN)
{
send_to_char(ch, "Sorry, unable to award clanpoints at this time!\r\n");
log("SYSERR: %s has invalid clan ID (%d) in do_clanaward", GET_NAME(ch),
GET_CLAN(ch));
return;
}
if ((num_cp = atol(ncp)) < 1)
{
send_to_char(ch, "Invalid number of clanpoints!\r\n");
return;
}
if ((num_cp * 10) > CLAN_BANK(c_r))
{
send_to_char(ch, "Your clan bank doesn't have enough Double Dollars!\r\n");
return;
}
GET_CLANPOINTS(l) += num_cp;
CLAN_BANK(c_r) -= (num_cp * 10);
send_to_char(l, "%sCLAN: You have been awarded %s%ld%s clan points!%s\r\n",
CCMAG(l, C_NRM), CBYEL(l, C_NRM), num_cp, CCMAG(l, C_NRM), CCNRM(l, C_NRM));
send_to_char(ch, "%s has been awarded %s%ld%s clan points!\r\n",
GET_NAME(l), QBYEL, num_cp, QNRM);
send_to_char(ch, "%s%s%s Double Dollars has been taken from the "
"clan bank!\r\n",
QBYEL, add_commas(num_cp * 10), QNRM);
}
/* clan claim command */
ACMD(do_clanclaim)
{
zone_vnum zv;
zone_rnum zr;
zr = GET_ROOM_ZONE(IN_ROOM(ch));
zv = zone_table[(zr)].number; /* Players current zone vnum */
if (GET_CLAN(ch) == 0 || GET_CLAN(ch) == NO_CLAN)
{
send_to_char(ch, "Only clan members can claim zones for their clan.\r\n");
return;
}
if (GET_CLANRANK(ch) == NO_CLANRANK)
{
send_to_char(ch, "You can't claim zones until your clan application "
"is approved.\r\n");
return;
}
if (!check_clanpriv(ch, CP_CLAIM))
{
send_to_char(ch, "You don't have sufficient access to claim zones!\r\n");
return;
}
if (get_owning_clan(zv) == GET_CLAN(ch))
{
if (get_claimant_id(zv) == GET_IDNUM(ch))
send_to_char(ch, "You have already claimed this area for "
"your clan!\r\n");
else
send_to_char(ch, "This area already belongs to your clan!\r\n");
return;
}
if (ZONE_FLAGGED(zr, ZONE_NOCLAIM))
{
send_to_char(ch, "This area cannot be claimed!\r\n");
return;
}
if (get_popularity(zv, GET_CLAN(ch)) < CONFIG_MIN_POP_TO_CLAIM)
{
send_to_char(ch, "The locals reject your claim. Seems your clan isn't"
" popular here.\r\n");
return;
}
log("%s claiming zone %d: Current Clan=%d, New Clan=%d",
GET_NAME(ch), zv, get_owning_clan(zv), GET_CLAN(ch));
if (add_claim_by_char(ch, zv) != NULL)
{
send_to_char(ch, "The locals rejoice and welcome your clans claim.\r\n");
mudlog(NRM, LVL_IMMORT, TRUE, "(CLAN) %s has claimed %s [%d] for %s [%d]",
GET_NAME(ch), zone_table[real_zone(zv)].name, zv,
clan_list[real_clan(GET_CLAN(ch))].clan_name, GET_CLAN(ch));
game_info("\tC%s has been claimed by %s!\r\n",
zone_table[real_zone(zv)].name,
clan_list[real_clan(GET_CLAN(ch))].clan_name);
save_claims();
}
else
{
send_to_char(ch, "Sorry, your claim failed.\r\n");
mudlog(NRM, LVL_IMMORT, TRUE, "(CLAN) %s has FAILED to claim %s [%d]"
" for %s [%d]",
GET_NAME(ch), zone_table[real_zone(zv)].name, zv,
clan_list[real_clan(GET_CLAN(ch))].clan_name, GET_CLAN(ch));
}
}
/* clan create (IMP) command */
ACMD(do_clancreate)
{
char c_n[MAX_INPUT_LENGTH] = {'\0'}, c_l[MAX_INPUT_LENGTH] = {'\0'};
struct char_data *l;
struct clan_data new_clan;
int i, v;
half_chop_c(argument, c_l, sizeof(c_l), c_n, sizeof(c_n));
if (!*c_l || !*c_n)
{
send_to_char(ch, "Usage: %sclan create <clan leader> <clan name>%s\r\n",
QYEL, QNRM);
send_to_char(ch, "Example: clan create Jamdog Jamdog's Army\r\n");
return;
}
if ((l = get_player_vis(ch, c_l, NULL, FIND_CHAR_WORLD)) == NULL)
{
send_to_char(ch, "Clan leader '%s' not found! The player MUST be "
"online!\r\n",
c_l);
send_to_char(ch, "Usage: %sclan create <clan leader> <clan name>%s\r\n",
QYEL, QNRM);
return;
}
if (GET_LEVEL(l) >= LVL_IMMORT)
{
send_to_char(ch, "Immortals cannot be clan members!\r\n");
return;
}
/* Truncate the clan name if too long */
if (strlen(c_n) > MAX_CLAN_NAME)
c_n[MAX_CLAN_NAME] = '\x0';
v = highest_clan_vnum() + 1;
new_clan.vnum = v;
new_clan.clan_name = strdup(c_n);
new_clan.leader = GET_IDNUM(l);
new_clan.ranks = 6;
for (i = 0; i < MAX_CLANRANKS; i++)
new_clan.rank_name[i] = NULL;
new_clan.rank_name[5] = strdup("Recruit");
new_clan.rank_name[4] = strdup("Member");
new_clan.rank_name[3] = strdup("Lord");
new_clan.rank_name[2] = strdup("Baron");
new_clan.rank_name[1] = strdup("Count");
new_clan.rank_name[0] = strdup("Duke");
/* All default values for the new clan */
new_clan.applev = 5;
new_clan.appfee = 0;
new_clan.taxrate = 0;
new_clan.pk_win = 0;
new_clan.pk_lose = 0;
new_clan.hall = 0;
new_clan.treasure = 0;
for (i = 0; i < MAX_CLANS; i++)
{
new_clan.allies[i] = NO_CLAN;
new_clan.at_war[i] = NO_CLAN;
}
new_clan.description = NULL;
new_clan.abrev = NULL;
for (i = 0; i < NUM_CLAN_PRIVS; i++)
new_clan.privilege[i] = 1; /* All privs set to top rank */
/* Special case privs */
/* Leader-Only: Award clanpoints */
new_clan.privilege[CP_AWARD] = RANK_LEADERONLY;
/* Leader-Only: Change Owner */
new_clan.privilege[CP_OWNER] = RANK_LEADERONLY;
/* Leader-Only: Edit clan using OLC */
new_clan.privilege[CP_CLANEDIT] = RANK_LEADERONLY;
/* Leader-Only: Set ranks and titles */
new_clan.privilege[CP_RANKS] = RANK_LEADERONLY;
/* Leader-Only: Set clan name */
new_clan.privilege[CP_TITLE] = RANK_LEADERONLY;
/* Leader-Only: Set clan description */
new_clan.privilege[CP_DESC] = RANK_LEADERONLY;
/* Leader-Only: Set clan privs */