[CODE] More Zones for Builders

From: Søren P. Skou (serces@MUD.DK)
Date: 09/11/97


First of all.. (usual disclaimer) whatever you do, it is definately
*NOT* my fault. Take backups of your code, mud whatever.. If this code
is responsible for tearing mud apart, don't come blame me. If it does
anything remotely near success, *clap* you did a good job. All I can
say is, at MY place it works! :) It really does.. :)

To allow more Zones for your builders, please note, this will
destroy your playerfile, But use a converter, and you can keep
it. (I have done that, no problemo.. :)

In structs.h

near #define MAX_OBJ_AFFECT insert :
#define MAX_OLC_ZONES   5 /* USED FOR PLAYER FILES!! DO NOT CHANGE!! */
Still in structs.h, find struct_player_special_data_saved,
find the olc_zone entry and change it to :
int olc_zone[MAX_OLC_ZONES];

In olc.h
find  GET_OLC_ZONE(c) ((c)->player_specials->saved.olc_zone)
and change it to
GET_OLC_ZONE(c, number) ((c)->player_specias->saved.olc_zone[number])
In act.wizard.c
find the do_set command
add int zone_num = 0, zone_found = 0; somewhere in the declarations..
next find the olc setter (In my version it's  case 48)
Might be something different in yours
The whole thing looks like this :
case 48:
 GET_OLC_ZONE(vict) = value;
 break;
now change that to
case 48:
 if (value < 1) {
  send_to_char("Daft, try with a real number my friend!", ch)
  return;
 }
 for (zone_num = 0; zone_num < MAX_OLC_ZONES;zone_num++)
  if (GET_OLC_ZONE(vict, zone_num) == value) zone_found = 1;
 if (zone_found == 1) { /* We found the bugger */
  sprintf(buf, "%s has allready that zone set.\r\n", GET_NAME(vict));
  send_to_char(buf, ch);
  return;
 } else { /* Okay, we didn't find the zone anyway */
  GET_OLC_ZONE(vict, 3) = GET_OLC_ZONE(vict, 2);
  GET_OLC_ZONE(vict, 2) = GET_OLC_ZONE(vict, 1);
  GET_OLC_ZONE(vict, 1) = GET_OLC_ZONE(vict, 0);
  GET_OLC_ZONE(vict, 0) = value;
 }
 break;

In the lines leading up to ACMD(do_set) is a couple of defines
find them (#define NUMBER 2) and add #define DUAL_NUM 3
now in the definitions of ACMD(do_set) find
int on = 0, off = 0, value = 0;
and change it to
int on = 0, off = 0, value = 0, value1 = 0;
to the end of the definitions you add :
char val_arg1[MAX_INPUT_LENGTH];

somewhere down in the code (In my code it's like 2469) find these lines
:
half_chop(buf, field, buf);
strcpy(val_arg, buf);
change it to :
 half_chop(buf, field, buf);
 if (strcmp(buf, " ")) {
  strcpy(val_arg, buf);
 } else {
  half_chop(buf, val_arg, buf);
  strcpy(val_arg1, buf);
 }

somewhere later in the code you will find this
} else if (fields[l].type == NUMBER) {
  value = atoi(val_arg);
 }
right after you add :
else if (fields[l].type == DUAL_NUM) {
 value = atoi(val_arg);
 value1 = atoi(val_arg1);
}

In the do_set command find the fields[]  the one containing
{ "olc",        LVL_IMPL, PC, NUMBER}, and so on
just before { "\n"   add :
{ "rezone",     LVL_IMPL, PC, DUAL_NUM},
now find the FIRST free case you can, of course again, this number
might be totally different from mine, (which is 52) so you will have
to change the case number accordingly.

  case 52:
   zone_found = 0;
//   First some sanity checks! Not really needed, but nice to have!
   if (value < 1 || value1 < 1 || value == value1) {
    send_to_char("Usage: set <victim> rezone <oldzone> <newzone>\r\n",
ch);
    return;
   }
   for (zone_num = 0;zone_num < MAX_OLC_ZONES;zone_num++) {
    if (GET_OLC_ZONE(ch, zone_num) == value) {
     GET_OLC_ZONE(ch, zone_num) = value1;
     zone_found = 1;
    }
   }
   if (zone_found != 1) {
    sprintf(buf, "%s does not have zone %d\r\n", GET_NAME(vict), value);
    send_to_char(buf, ch);
   }
  break;
Okay, now we have both set zone and set rezone, maybe a show olc_zones
would be nice. Oh well, Might as well whip that one up while I'm at it

find the ACMD(do_show), and add

int pl_zones = 0;

and

{ "olczones", LVL_IMPL},
to the fields[].

now find the matching case, In my case (pun *NOT* intended) it's 13.
put in this :
  case 13:
   if (load_char(value, &vbuf) < 0) {
    send_to_char("There is definately no such player.\r\n", ch);
    return;
   }
   sprintf(buf, "%s has permission to edit these zones.\r\n",
GET_NAME(vict));
   send_to_char(buf, ch);

   for (pl_zones = 0; pl_zones < MAX_OLC_ZONES;pl_zones++) {
    sprintf(buf, "OLC %d : $d.\r\n", pl_zones, GET_OLC_ZONE(vict,
pl_zones));
    send_to_char(buf, ch);
   }
  break;

In OLC.C there is a little check you need to redo. it looks like this :
if ((GET_LEVEL(ch) < LVL_IMPL) &&
    (zone_table[OLC_ZNUM(d)].number != GET_OLC_ZONE(ch)))
Change that to
  if ((GET_LEVEL(ch) < LVL_IMPL) &&
      (zone_table[OLC_ZNUM(d)].number != GET_OLC_ZONE(ch, 0) ||
       zone_table[OLC_ZNUM(d)].number != GET_OLC_ZONE(ch, 1) ||
       zone_table[OLC_ZNUM(d)].number != GET_OLC_ZONE(ch, 2) ||
       zone_table[OLC_ZNUM(d)].number != GET_OLC_ZONE(ch, 3) ||
       zone_table[OLC_ZNUM(d)].number != GET_OLC_ZONE(ch, 4)))

/Serces


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST