示例#1
0
int can_edit_zone(struct char_data *ch, zone_rnum rnum)
{
  /* no access if called with bad arguments */
  if (!ch->desc || IS_NPC(ch) || rnum == NOWHERE)
    return FALSE;

  /* always access if ch is high enough level */
  if (GET_LEVEL(ch) >= LVL_GRGOD)
    return (TRUE);
  
  /* always access if a player have helped build the zone in the first place */
  if (is_name(GET_NAME(ch), zone_table[rnum].builders))
    return (FALSE);
  
  /* no access if you haven't been assigned a zone */
  if (GET_OLC_ZONE(ch) == NOWHERE)
    return FALSE;

  /* no access if you're not at least LVL_BUILDER */
  if (GET_LEVEL(ch) < LVL_BUILDER)
    return FALSE;

  /* always access if you're assigned to this zone */
  if (real_zone(GET_OLC_ZONE(ch)) == rnum)
    return TRUE;

  return (FALSE);
}
示例#2
0
room_rnum castle_real_room(room_vnum roomoffset)
{
  zone_rnum zon;

  if ((zon = real_zone(Z_KINGS_C)) == NOWHERE)
    return NOWHERE;

  return real_room(zone_table[zon].bot + roomoffset);
}
示例#3
0
mob_vnum castle_virtual(mob_vnum offset)
{
  zone_rnum zon;

  if ((zon = real_zone(Z_KINGS_C)) == NOWHERE)
    return NOBODY;

  return zone_table[zon].bot + offset;
}
示例#4
0
/* Checks to see if a builder can modify the specified zone. Ch is the imm
 * requesting access to modify this zone. Rnum is the real number of the zone
 * attempted to be modified. Returns TRUE if the builder has access, otherwisei
 * FALSE. */
int can_edit_zone(struct char_data *ch, zone_rnum rnum)
{
  /* no access if called with bad arguments */
  if (!ch->desc || IS_NPC(ch) || rnum == NOWHERE)
    return FALSE;

  /* If zone is flagged NOBUILD, then No-one can edit it (use zunlock to open it) */
  if (rnum != HEDIT_PERMISSION && rnum != AEDIT_PERMISSION && ZONE_FLAGGED(rnum, ZONE_NOBUILD) )
    return FALSE;

  if (GET_OLC_ZONE(ch) == ALL_PERMISSION)
    return TRUE;

  if (GET_OLC_ZONE(ch) == HEDIT_PERMISSION && rnum == HEDIT_PERMISSION)
    return TRUE;

  if (GET_OLC_ZONE(ch) == AEDIT_PERMISSION && rnum == AEDIT_PERMISSION)
    return TRUE;

  /* always access if ch is high enough level */
  if (GET_ADMLEVEL(ch) >= ADMLVL_GRGOD)
    return (TRUE);

  /* always access if a player helped build the zone in the first place */
  if (rnum != HEDIT_PERMISSION && rnum != AEDIT_PERMISSION)
    if (is_name(GET_NAME(ch), zone_table[rnum].builders))
      return (TRUE);

  /* no access if you haven't been assigned a zone */
  if (GET_OLC_ZONE(ch) == NOWHERE) {
    return FALSE;
  }

  /* no access if you're not at least LVL_BUILDER */
  if (GET_ADMLEVEL(ch) < ADMLVL_BUILDER)
    return FALSE;

  /* always access if you're assigned to this zone */
  if (real_zone(GET_OLC_ZONE(ch)) == rnum)
    return TRUE;

  return (FALSE);
}
示例#5
0
文件: medit.c 项目: axanon/tbamud
static void medit_save_to_disk(zone_vnum foo)
{
  save_mobiles(real_zone(foo));
}
示例#6
0
void write_mobs_to_disk(int zone)
{
    int counter, realcounter;
    FILE *fp;
    struct char_data *mob;
    zone = real_zone(zone);
    int i;

    // ideally, this would just fill a VTable with vals...maybe one day

    sprintf(buf, "%s/%d.mob", MOB_PREFIX, zone_table[zone].number);
    fp = fopen(buf, "w+");

    /* start running through all mobiles in this zone */
    for (counter = zone_table[zone].number * 100;
            counter <= zone_table[zone].top;
            counter++) {
        /* write mobile to disk */
        realcounter = real_mobile(counter);

        if (realcounter >= 0) {
            mob = mob_proto+realcounter;
            if (!strcmp("an unfinished mob", GET_NAME(mob)))
                continue;
            fprintf(fp, "#%ld\n", GET_MOB_VNUM(mob));

            fprintf(fp,
                    "Keywords:\t%s\n"
                    "Name:\t%s\n"
                    "RoomDesc:$\n%s\n~\n",
                    mob->player.physical_text.keywords?
                    mob->player.physical_text.keywords : "mob unnamed",
                    mob->player.physical_text.name?
                    mob->player.physical_text.name : "An unnamed mob",
                    cleanup(buf2, mob->player.physical_text.room_desc?
                            mob->player.physical_text.room_desc : "An unnamed mob is here."));
            fprintf(fp, "LookDesc:$\n%s~\n",
                    cleanup(buf2,
                            mob->player.physical_text.look_desc?
                            mob->player.physical_text.look_desc
                            : "An unnamed mob is here."));

            if (mob->mob_specials.arrive)
                fprintf(fp, "ArriveMsg:\t%s\n", mob->mob_specials.arrive);
            if (mob->mob_specials.leave)
                fprintf(fp, "LeaveMsg:\t%s\n", mob->mob_specials.leave);

            fprintf(fp,
                    "MobFlags:\t%s\n"
                    "AffFlags:\t%s\n"
                    "Race:\t%s\n"
                    "Gender:\t%s\n",
                    MOB_FLAGS(mob).ToString(),
                    AFF_FLAGS(mob).ToString(),
                    npc_classes[(int)mob->player.race],
                    genders[(int)mob->player.sex]);

            if (mob->char_specials.position != POS_STANDING)
                fprintf(fp, "Position:\t%s\n",
                        position_types[(int)mob->char_specials.position]);
            if (mob->mob_specials.default_pos)
                fprintf(fp, "DefaultPos:\t%s\n",
                        position_types[(int)mob->mob_specials.default_pos]);

            if (mob->mob_specials.attack_type != TYPE_HIT)
                fprintf(fp, "AttackType:\t%s\n",
                        attack_types[mob->mob_specials.attack_type-TYPE_HIT]);

            fprintf(fp,
                    "[ATTRIBUTES]\n"
                    "\tBod:\t%d\n"
                    "\tQui:\t%d\n"
                    "\tStr:\t%d\n"
                    "\tCha:\t%d\n"
                    "\tInt:\t%d\n"
                    "\tWil:\t%d\n"
                    "\tMag:\t%d\n",
                    GET_REAL_BOD(mob), GET_REAL_QUI(mob), GET_REAL_STR(mob),
                    GET_REAL_CHA(mob), GET_REAL_INT(mob), GET_REAL_WIL(mob),
                    mob->real_abils.mag / 100);
            fprintf(fp,
                    "[POINTS]\n"
                    "\tHeight:\t%d\n"
                    "\tWeight:\t%d\n",
                    mob->player.height, mob->player.weight);

            if (GET_LEVEL(mob) > 0)
                fprintf(fp, "\tLevel:\t%d\n", GET_LEVEL(mob));
            if (int(GET_MAX_PHYSICAL(mob) / 100) != 10)
                fprintf(fp, "\tMaxPhys:\t%d\n", int(GET_MAX_PHYSICAL(mob) / 100));
            if (int(GET_MAX_MENTAL(mob) / 100) != 10)
                fprintf(fp, "\tMaxMent:\t%d\n", int(GET_MAX_MENTAL(mob) / 100));
            if (GET_BALLISTIC(mob) > 0)
                fprintf(fp, "\tBallistic:\t%d\n", GET_BALLISTIC(mob));
            if (GET_IMPACT(mob) > 0)
                fprintf(fp, "\tImpact:\t%d\n", GET_IMPACT(mob));
            if (GET_NUYEN(mob) > 0)
                fprintf(fp, "\tCash:\t%d\n", GET_NUYEN(mob));
            if (GET_BANK(mob) > 0)
                fprintf(fp, "\tBank:\t%d\n", GET_BANK(mob));
            if (GET_KARMA(mob) > 0)
                fprintf(fp, "\tKarma:\t%d\n", GET_KARMA(mob));
            fprintf(fp, "[SKILLS]\n");

            for (i = 0; i <= 8; i = i +2)
                if (mob->mob_specials.mob_skills[i])
                    fprintf(fp, "\t%s:\t%d\n", skills[mob->mob_specials.mob_skills[i]].name,
                            mob->mob_specials.mob_skills[i+1]);



            fprintf(fp, "BREAK\n");
        } // close if statement
    } // close for loop

    fprintf(fp, "END\n");
    fclose(fp);

    write_index_file("mob");
}
示例#7
0
// MAIN LOOP!
void zedit_parse(struct descriptor_data *d, char *arg)
{
    int number, i = 0, zone;

    switch (d->edit_mode)
    {
    case ZEDIT_CONFIRM_EDIT_DATA:
        switch (*arg) {
        case 'y':
        case 'Y':
            d->edit_zon = new zone_data;
            // we do need to zero it out since we are accessing its elements
            memset((char *) ZON, 0, sizeof(struct zone_data));

            *d->edit_zon = zone_table[d->edit_number];
            if (zone_table[d->edit_number].name)
                d->edit_zon->name = str_dup(zone_table[d->edit_number].name);
            zedit_disp_data_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", d->character);
            send_to_char("Do you wish to edit the data?\r\n", d->character);
            break;
        }
        break;
    case ZEDIT_CONFIRM_CREATE_DATA:
        switch (*arg) {
        case 'y':
        case 'Y':
            d->edit_zon = new zone_data;
            // we do need to zero it out since we are accessing its elements
            memset((char *) ZON, 0, sizeof(struct zone_data));

            // set a few vars
            ZON->name = str_dup("an unfinished zone");
            ZON->number = CH->player_specials->saved.zonenum;
            ZON->top = ZON->number * 100 + 99;
            zedit_disp_data_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", d->character);
            send_to_char("Do you wish to edit the data?\r\n", d->character);
            break;
        }
        break;
    case ZEDIT_CONFIRM_SAVEDATA:
        switch (*arg) {
            int zone_num;
        case 'y':
        case 'Y':
            zone_num = real_zone(ZON->number);
            sprintf(buf,"%s wrote new zcmd %ld in zone %d",
                    GET_CHAR_NAME(d->character), d->edit_number, zone_table[zone_num].number);
            mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            // first we insert into memory
            if (zone_num > -1) { // ie, it already exists
                ZON->cmd = zone_table[zone_num].cmd;
                delete [] zone_table[zone_num].name;
                zone_table[zone_num] = *ZON;
            } else { // here we got to add a new spot
                int counter;
                int found = 0;
                struct zone_data *new_z_table;
                // create new table + 2
                new_z_table = new struct zone_data[top_of_zone_table + 2];

                for (counter = 0; counter < top_of_zone_table + 1; counter++) {
                    if (!found) {
                        if (zone_table[counter].number > CH->player_specials->saved.zonenum) {
                            new_z_table[counter] = *(ZON);
                            found = 1;
                            new_z_table[counter + 1] = zone_table[counter];
                        } else
                            new_z_table[counter] = zone_table[counter];
                    } else
                        new_z_table[counter + 1] = zone_table[counter];
                }
                if (!found)
                    new_z_table[top_of_zone_table + 1] = *(ZON);
                top_of_zone_table++;
                delete [] zone_table;
                zone_table = new_z_table;
            }
            write_zone_to_disk(ZONENUM);
            write_index_file("zon");
            d->edit_mode = 0;
            delete ZON;
            ZON = NULL;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            STATE(d) = CON_PLAYING;
            send_to_char("Done.\r\n", d->character);

            break; // end of 'y' case in confirm savestring
        case 'n':
        case 'N':
            if (ZON) {
                if (ZON->name)
                    delete [] ZON->name;
                delete ZON;
            }
            STATE(d) = CON_PLAYING;
            ZON = NULL;
            d->edit_number = 0;
            PLR_FLAGS(CH).RemoveBit(PLR_EDITING);
            break; // end of 'n' case in confirm savestring
        default:
            send_to_char("Please enter yes or no.\r\n"
                         "Do you wish to save this zone internally?\r\n", CH);
            break;
        }
        break; // end of confirm savestring

    case ZEDIT_CONFIRM_ADD_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            COM->command = '*';
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to add a command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_CONFIRM_INSERT_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            COM->command = '*';
            // so it knows to insert if they decide to save
            d->edit_number2 = TRUE;
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to insert a command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_CONFIRM_EDIT_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            *COM = zone_table[real_zone(ZONENUM)].cmd[d->edit_number];
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to edit the command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_DATA_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            send_to_char("Do you wish to save this zone internally?\r\n", CH);
            d->edit_mode = ZEDIT_CONFIRM_SAVEDATA;
            break;
        case '1':
            send_to_char("Enter zone name: ", CH);
            d->edit_mode = ZEDIT_ZONE_NAME;
            break;
        case '2':
            send_to_char("Enter top of zone: ", CH);
            d->edit_mode = ZEDIT_TOP_OF_ZONE;
            break;
        case '3':
            send_to_char("Lifespan (in ticks between resets): ", CH);
            d->edit_mode = ZEDIT_LIFESPAN;
            break;
        case '4':
            CLS(CH);
            send_to_char("1) Don't reset\r\n"
                         "2) Reset only if no PCs are in the zone\r\n"
                         "3) Always reset\r\n"
                         "0) Quit\r\n"
                         "Enter reset mode: ", CH);
            d->edit_mode = ZEDIT_RESET_MODE;
            break;
        case '5':
            send_to_char("Zone security (1 (none) - 15 (paranoid)):\r\n", CH);
            d->edit_mode = ZEDIT_SECURITY;
            break;
        case '6':
            send_to_char("0) Seattle\r\n"
                         "1) Portland\r\n"
                         "Enter juridiction: ", CH);
            d->edit_mode = ZEDIT_JURID;
            break;
        case '7':
            if (!access_level(CH, LVL_VICEPRES)) {
                send_to_char("That's not a valid choice.\r\n", CH);
                return;
            }
            send_to_char("Enter ID list seperated by spaces:\r\n", CH);
            d->edit_mode = ZEDIT_ID_LIST;
            break;
        case '8':
            if (!access_level(CH, LVL_VICEPRES)) {
                send_to_char("That's not a valid choice.\r\n", CH);
                return;
            }
            send_to_char("Zone is connected (1 - yes, 0 - no)? ", CH);
            d->edit_mode = ZEDIT_CONNECTED;
            break;
        default:
            send_to_char("That's not a valid choice.\r\n", CH);
            zedit_disp_data_menu(d);
            break;
        }
        break;

    case ZEDIT_COMMAND_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            send_to_char("Do you wish to save this zone command internally?\r\n", CH);
            d->edit_mode = ZEDIT_CONFIRM_SAVECMDS;
            break;
        case '1':
            zedit_disp_type_cmd(d);
            d->edit_mode = ZEDIT_CMD_TYPE;
            break;
        case '2':
            send_to_char("\r\n1) Always\r\n2) If last\r\nEnter your selection: ",
                         CH);
            d->edit_mode = ZEDIT_IF_FLAG_CMD;
            break;
        case '3':
            switch (COM->command) {
            case 'M':
            case 'S':
                send_to_char("\r\nEnter virtual number of mob: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            case 'H':
            case 'U':
            case 'I':
            case 'O':
            case 'P':
            case 'E':
            case 'G':
            case 'R':
            case 'N':
            case 'C':
                send_to_char("\r\nEnter virtual number of obj: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            case 'D':
                zedit_disp_direction_menu(d);
                d->edit_mode = ZEDIT_DIRECTION_OF_DOOR;
                break;
            case 'V':
                send_to_char("\r\nEnter virtual number of vehicle: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        case '4':
            switch (COM->command) {
            case 'M':
            case 'S':
            case 'U':
            case 'I':
            case 'O':
            case 'P':
            case 'E':
            case 'N':
            case 'G':
            case 'H':
            case 'V':
                send_to_char("Enter max allowed to exist in game: ", CH);
                d->edit_mode = ZEDIT_ARG2;
                break;
            case 'R':
            case 'D':
                send_to_char("Enter the room number: ", CH);
                d->edit_mode = ZEDIT_REMOVE_ROOM;
                break;
            case 'C':
                send_to_char(" 0) Cyberware\r\n 1) Bioware\r\nEnter location to place obj: ", CH);
                d->edit_mode = ZEDIT_ARG2;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        case '5':
            switch (COM->command) {
            case 'M':
            case 'O':
            case 'V':
                send_to_char("Enter the room number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'H':
                send_to_char("Enter the host number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'P':
                send_to_char("Enter the object number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'E':
                zedit_disp_wear_menu(d);
                d->edit_mode = ZEDIT_WEAR;
                break;
            case 'D':
                zedit_disp_state_menu(d);
                d->edit_mode = ZEDIT_DOOR_STATE;
                break;
            case 'N':
                send_to_char("Enter total number to give mob: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        }
        break;

    case ZEDIT_CONFIRM_SAVECMDS:
        int zone_num, top_of_cmds;
        switch (*arg) {
        case 'y':
        case 'Y':
            zone_num = real_zone(ZONENUM);
            top_of_cmds = zone_table[zone_num].num_cmds;
            sprintf(buf,"%s wrote new zcmd %ld in zone %d",
                    GET_CHAR_NAME(d->character), d->edit_number, zone_table[zone_num].number);
            mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            // first, determine if you are adding or replacing
            if (d->edit_number < top_of_cmds) {
                if (!d->edit_number2)
                    zone_table[zone_num].cmd[d->edit_number] = *(COM);
                else {
                    int counter;
                    struct reset_com *new_cmds;
                    new_cmds = new struct reset_com[top_of_cmds + 1];
                    if (top_of_cmds > 1) {
                        // first count your way up
                        for (counter = 0; counter < d->edit_number; counter++)
                            new_cmds[counter] = zone_table[zone_num].cmd[counter];
                        for (counter = top_of_cmds; counter > d->edit_number;
                                counter--)
                            new_cmds[counter] = zone_table[zone_num].cmd[counter-1];
                        new_cmds[d->edit_number] = *(COM);
                        zone_table[zone_num].num_cmds++;
                        delete [] zone_table[zone_num].cmd;
                        zone_table[zone_num].cmd = new_cmds;
                    } else {
                        new_cmds[1] = zone_table[zone_num].cmd[0];
                        new_cmds[0] = *(COM);
                        zone_table[zone_num].num_cmds++;
                        if (zone_table[zone_num].cmd)
                            delete [] zone_table[zone_num].cmd;
                        zone_table[zone_num].cmd = new_cmds;
                    }
                }
            } else {
                int counter;
                struct reset_com *new_cmds;
                // create a new set of commands, with 1 extra spot
                new_cmds = new struct reset_com[top_of_cmds + 1];
                // we know it is always going in at the end, so we copy the old 1st
                if (top_of_cmds > 0) { // you have to do this in case there are 0 cmds
                    for (counter = 0; counter < top_of_cmds; counter++)
                        new_cmds[counter] = zone_table[zone_num].cmd[counter];
                    // tada, here it goes now, do not increase counter, for loop
                    new_cmds[counter] = *(COM);          // already did!
                    zone_table[zone_num].num_cmds++;
                    delete [] zone_table[zone_num].cmd;
                    zone_table[zone_num].cmd = new_cmds;
                } else {
                    new_cmds[0] = *(COM);
                    zone_table[zone_num].num_cmds++;
                    if (zone_table[zone_num].cmd)
                        delete [] zone_table[zone_num].cmd;
                    zone_table[zone_num].cmd = new_cmds;
                }
            } // end else
            write_zone_to_disk(ZONENUM);
            d->edit_mode = 0;
            delete COM;
            COM = NULL;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            STATE(d) = CON_PLAYING;
            send_to_char("Done.\r\n", d->character);
            break; // for 'y' case
        case 'n':
        case 'N':
            if (COM)
                delete COM;
            STATE(d) = CON_PLAYING;
            COM = NULL;
            d->edit_number = 0;
            PLR_FLAGS(CH).RemoveBit(PLR_EDITING);
            break; // for 'n' case
        default:
            send_to_char("That's not a valid choice.\r\n", CH);
            send_to_char("Do you wish to save this zone command internally?\r\n", CH);
            break;
        } // for switch in confirm save cmds
        break; // for ZEDIT_CONFIRM_SAVECMDS

    case ZEDIT_ARG3:
        number = atoi(arg);
        switch (COM->command) {
        case 'H':
            COM->arg3 = MAX(0, real_host(number));
            break;
        case 'M':
        case 'V':
        case 'O':
            COM->arg3 = MAX(0, real_room(number));
            if (!access_level(CH, LVL_ADMIN) && !(number >= (ZONENUM * 100) &&
                                                  number <= zone_table[real_zone(ZONENUM)].top))
                COM->arg3 = 0;
            break;
        case 'P':
            COM->arg3 = MAX(0, real_object(number));
            if (!access_level(CH, LVL_ADMIN) && (number < 600 || number > 699)) {
                for (zone = 0; zone <= top_of_zone_table; zone++)
                    if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                        break;
                if (zone <= top_of_zone_table) {
                    for (i = 0; i < 5; i++)
                        if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                            break;
                } else
                    i = 5;
            }
            if (i >= 5)
                COM->arg3 = 0;
            break;
        case 'N':
            COM->arg3 = MIN(25, MAX(0, number));
            break;
        }
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_DOOR_STATE:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            zedit_disp_state_menu(d);
            return;
        } else if (number != 0)
            COM->arg3 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_WEAR:
        number = atoi(arg);
        if ((number < 0) || (number > (NUM_WEARS - 1))) {
            zedit_disp_wear_menu(d);
            return;
        } else if (number != 0)
            COM->arg3 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_REMOVE_ROOM:
        number = atoi(arg);
        COM->arg1 = MAX(0, real_room(number));
        if (!access_level(CH, LVL_ADMIN) && !(number >= (ZONENUM * 100) &&
                                              number <= zone_table[real_zone(ZONENUM)].top))
            COM->arg1 = 0;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_ARG2:
        number = atoi(arg);
        if (COM->command == 'C' && (number < 0 || number > 1)) {
            send_to_char("Value must be either 0 (cyberware) or 1 (bioware).\r\n"
                         "Enter location to place obj: ", CH);
            return;
        } else if ((number < -1) || (number > 1000)) {
            send_to_char("Value must be between -1 and 1000.\r\n"
                         "Enter max allowed to exist in game: ", CH);
            return;
        }
        COM->arg2 = number;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_DIRECTION_OF_DOOR:
        number = atoi(arg);
        if (number < 0 || number > 10) {
            zedit_disp_direction_menu(d);
            return;
        } else if (number != 0)
            COM->arg2 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_ARG1:
        number = atoi(arg);
        if (COM->command == 'V') {
            COM->arg1 = MAX(0, real_vehicle(number));
        } else {
            if (COM->command == 'M' || COM->command == 'S') {
                COM->arg1 = MAX(0, real_mobile(number));
                if (!access_level(CH, LVL_ADMIN)) {
                    for (zone = 0; zone <= top_of_zone_table; zone++)
                        if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                            break;
                    if (zone <= top_of_zone_table) {
                        for (i = 0; i < 5; i++)
                            if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                                break;
                    } else
                        i = 5;
                }
                if (i >= 5)
                    COM->arg1 = 0;
            } else {
                if (COM->command == 'R')
                    COM->arg2 = MAX(0, real_object(number));
                else
                    COM->arg1 = MAX(0, real_object(number));
                if (!access_level(CH, LVL_ADMIN) && (number < 300 || number > 699 || (number > 499 && number < 600))) {
                    for (zone = 0; zone <= top_of_zone_table; zone++)
                        if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                            break;
                    if (zone <= top_of_zone_table) {
                        for (i = 0; i < 5; i++)
                            if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                                break;
                    } else
                        i = 5;
                }
                if (i >= 5) {
                    if (COM->command == 'R')
                        COM->arg2 = 0;
                    else
                        COM->arg1 = 0;
                }
            }
        }
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_CMD_TYPE:
        number = atoi(arg);
        if ((number < 0) || (number > 9) && *arg != 'n') {
            zedit_disp_type_cmd(d);
            send_to_char("\r\nInvalid selection.  Please try again: ", CH);
            return;
        } else {
            COM->command = get_real_type(arg);
            if ((COM->command == 'E') || (COM->command == 'G') ||
                    (COM->command == 'P') || (COM->command == 'N') || (COM->command == 'C'))
                COM->if_flag = 1;
            else
                COM->if_flag = 0;
            COM->arg1 = 0;
            COM->arg2 = 0;
            COM->arg3 = 0;
        }

        zedit_disp_command_menu(d);
        break;

    case ZEDIT_IF_FLAG_CMD:
        number = atoi(arg);
        if ((number < 1) || (number > 2)) {
            send_to_char("Invalid selection.\r\n1) Always\r\n2) If last\r\n"
                         "Enter your selection: ", CH);
        } else {
            COM->if_flag = COM->if_flag;
            zedit_disp_command_menu(d);
        }
        break;

    case ZEDIT_ZONE_NAME:
        if (ZON->name)
            delete [] ZON->name;
        ZON->name = str_dup(arg);
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_SECURITY:
        number = atoi(arg);
        if (number < 1 || number > 15) {
            send_to_char("Security rating must range from 1 to 15.\r\nZone security: ", CH);
            return;
        }
        ZON->security = number;
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_ID_LIST: {
        int t[5] = {0, 0, 0, 0, 0};
        if (sscanf(arg, "%d %d %d %d %d\n", &t[0], &t[1], &t[2], &t[3], &t[4]) == 5) {
            ZON->editor_ids[0] = t[0];
            ZON->editor_ids[1] = t[1];
            ZON->editor_ids[2] = t[2];
            ZON->editor_ids[3] = t[3];
            ZON->editor_ids[4] = t[4];
        }
        zedit_disp_data_menu(d);
    }
    break;
    case ZEDIT_CONNECTED:
        number = atoi(arg);
        if (number != 0 && number != 1) {
            send_to_char("Value must be 0 or 1!  Zone is connected? ", CH);
            return;
        }

        sprintf(arg, "%s set zone %d to connected %d (was %d)",
                GET_CHAR_NAME( CH ), ZON->number, number, ZON->connected );
        mudlog(arg, CH, LOG_WIZLOG, TRUE);

        ZON->connected = number;
        zedit_disp_data_menu(d);
        break;
    case ZEDIT_TOP_OF_ZONE:
        number = atoi(arg);
        if ((d->edit_number == top_of_zone_table) || (d->edit_number == -1))
            if ((number < ZON->number * 100) || (number > (ZON->number * 100 + 499))) {
                send_to_char(CH, "Value must range from %d to %d\r\n", ZON->number * 100,
                             (ZON->number * 100 + 499));
                send_to_char("Enter top of zone: ", CH);
                return;
            } else
                ZON->top = number;
        else if ((number < ZON->number * 100) ||
                 (number > zone_table[d->edit_number + 1].number * 100 - 1)) {
            send_to_char(CH, "Value must range from %d to %d\r\n", ZON->number * 100,
                         zone_table[d->edit_number + 1].number * 100 - 1);
            send_to_char("Enter top of zone: ", CH);
            return;
        } else
            ZON->top = number;
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_LIFESPAN:
        number = atoi(arg);
        if ((number < 0) || (number > 1440)) {
            send_to_char("Value must range from 0 to 1440\r\n", CH);
            send_to_char("Lifespan (in ticks between resets): ", CH);
        } else {
            ZON->lifespan = number;
            zedit_disp_data_menu(d);
        }
        break;

    case ZEDIT_RESET_MODE:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            send_to_char("Invalid choice.  Please enter from 0 to 3.\r\n", CH);
            send_to_char("Enter reset mode: ", CH);
            return;
        } else if (number != 0)
            ZON->reset_mode = number - 1;
        zedit_disp_data_menu(d);
        break;
    case ZEDIT_JURID:
        number = atoi(arg);
        if (number < 0 || number > 3) {
            send_to_char("Invalid choice.  Please enter from 0 to 1.\r\n", CH);
            send_to_char("Enter Juridiction: ", CH);
            return;
        } else
            ZON->juridiction = number;
        zedit_disp_data_menu(d);
        break;
    }
}
示例#8
0
void write_zone_to_disk(int vnum)
{

    int zonenum = real_zone(vnum);

    if (zonenum < 0) {
        mudlog("Attempted to write Non-Existent zone!", NULL, LOG_SYSLOG, TRUE);
        return;
    }

    FILE  *fp;
    int i;

    sprintf(buf, "%s/%d.zon", ZON_PREFIX, vnum);
    fp = fopen(buf, "w+");

    // write it out!
    fprintf(fp, "#%d\n", vnum);
    fprintf(fp, "%s~\n", ZONE.name);
    fprintf(fp, "%d %d %d %d %d %d\n", ZONE.top, ZONE.lifespan, ZONE.reset_mode, ZONE.security, ZONE.connected, ZONE.juridiction);
    fprintf(fp, "%d %d %d %d %d\n", ZONE.editor_ids[0], ZONE.editor_ids[1],
            ZONE.editor_ids[2], ZONE.editor_ids[3], ZONE.editor_ids[4]);
    for (i = 0; i < ZONE.num_cmds; ++i) {
        switch (ZONE.cmd[i].command) {
        case 'M':
            fprintf(fp, "%c %d %ld %d %ld\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    MOB(Zcmd.arg1),
                    Zcmd.arg2,
                    ROOM(Zcmd.arg3));
            break;
        case 'V':
            fprintf(fp, "%c %d %ld %d %ld\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    VEH(Zcmd.arg1),
                    Zcmd.arg2,
                    ROOM(Zcmd.arg3));

            break;
        case 'S':
            fprintf(fp, "%c %d %ld %d\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    MOB(Zcmd.arg1),
                    Zcmd.arg2);
            break;
        case 'U':
            fprintf(fp, "%c %d %ld %d\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    OBJ(Zcmd.arg1),
                    Zcmd.arg2);
            break;
        case 'I':
            fprintf(fp, "%c %d %ld %d\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    OBJ(Zcmd.arg1),
                    Zcmd.arg2);
            break;
        case 'O':
            fprintf(fp, "%c %d %ld %d %ld\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    OBJ(Zcmd.arg1),
                    Zcmd.arg2,
                    ROOM(Zcmd.arg3));
            break;
        case 'H':
            fprintf(fp, "%c %d %ld %d %ld\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    OBJ(Zcmd.arg1),
                    Zcmd.arg2,
                    HOST(Zcmd.arg3));
            break;
        case 'P':
            fprintf(fp, "%c %d %ld %d %ld\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    OBJ(Zcmd.arg1),
                    Zcmd.arg2,
                    OBJ(Zcmd.arg3));
            break;
        case 'D':
            fprintf(fp, "%c %d %ld %d %d\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    ROOM(Zcmd.arg1),
                    Zcmd.arg2,
                    Zcmd.arg3);
            break;
        case 'E':
            fprintf(fp, "L %d %ld %d %d\n",
                    Zcmd.if_flag,
                    OBJ(Zcmd.arg1),
                    Zcmd.arg2,
                    Zcmd.arg3);
            break;
        case 'N':
            fprintf(fp, "%c %d %ld %d %d\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    OBJ(Zcmd.arg1),
                    Zcmd.arg2,
                    Zcmd.arg3);
            break;
        case 'G':
        case 'C':
            fprintf(fp, "%c %d %ld %d\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    OBJ(Zcmd.arg1),
                    Zcmd.arg2);
            break;
        case 'R':
            fprintf(fp, "%c %d %ld %ld\n",
                    Zcmd.command,
                    Zcmd.if_flag,
                    ROOM(Zcmd.arg1),
                    OBJ(Zcmd.arg2));
            break;
        }
    }
    fprintf(fp, "$\n");
    fclose(fp);
}
示例#9
0
/* Prints all of the zone information for the selected zone. */
void print_zone(struct char_data *ch, zone_vnum vnum)
{
  zone_rnum rnum;
  int size_rooms, size_objects, size_mobiles, size_quests, size_shops, size_trigs, i, largest_table;
  room_vnum top, bottom;
  char buf[MAX_STRING_LENGTH];

  if ((rnum = real_zone(vnum)) == NOWHERE) {
    send_to_char(ch, "Zone #%d does not exist in the database.\r\n", vnum);
    return;
  }

  /* Locate the largest of the three, top_of_world, top_of_mobt, or top_of_objt. */
  if (top_of_world >= top_of_objt && top_of_world >= top_of_mobt)
    largest_table = top_of_world;
  else if (top_of_objt >= top_of_mobt && top_of_objt >= top_of_world)
    largest_table = top_of_objt;
  else
    largest_table = top_of_mobt;

  /* Initialize some of the variables. */
  size_rooms   = 0;
  size_objects = 0;
  size_mobiles = 0;
  size_shops   = 0;
  size_trigs   = 0;
  size_quests  = 0;
  top          = zone_table[rnum].top;
  bottom       = zone_table[rnum].bot;

  for (i = 0; i <= largest_table; i++) {
    if (i <= top_of_world)
      if (world[i].zone == rnum)
        size_rooms++;

    if (i <= top_of_objt)
      if (obj_index[i].vnum >= bottom && obj_index[i].vnum <= top)
        size_objects++;

    if (i <= top_of_mobt)
      if (mob_index[i].vnum >= bottom && mob_index[i].vnum <= top)
        size_mobiles++;
  }
  for (i = 0; i<= top_shop; i++)
    if (SHOP_NUM(i) >= bottom && SHOP_NUM(i) <= top)
      size_shops++;

  for (i = 0; i < top_of_trigt; i++)
    if (trig_index[i]->vnum >= bottom && trig_index[i]->vnum <= top)
      size_trigs++;

  size_quests = count_quests(bottom, top);
  sprintbitarray(zone_table[rnum].zone_flags, zone_bits, ZN_ARRAY_MAX, buf);

  /* Display all of the zone information at once. */
  send_to_char(ch,
    "%sVirtual Number = %s%d\r\n"
    "%sName of zone   = %s%s\r\n"
    "%sBuilders       = %s%s\r\n"
    "%sLifespan       = %s%d\r\n"
    "%sAge            = %s%d\r\n"
    "%sBottom of Zone = %s%d\r\n"
    "%sTop of Zone    = %s%d\r\n"
    "%sReset Mode     = %s%s\r\n"
    "%sZone Flags     = %s%s\r\n"
    "%sMin Level      = %s%d\r\n"
    "%sMax Level      = %s%d\r\n"
    "%sSize\r\n"
    "%s   Rooms       = %s%d\r\n"
    "%s   Objects     = %s%d\r\n"
    "%s   Mobiles     = %s%d\r\n"
    "%s   Shops       = %s%d\r\n"
    "%s   Triggers    = %s%d\r\n"
    "%s   Quests      = %s%d%s\r\n",
    QGRN, QCYN, zone_table[rnum].number,
    QGRN, QCYN, zone_table[rnum].name,
    QGRN, QCYN, zone_table[rnum].builders,
    QGRN, QCYN, zone_table[rnum].lifespan,
    QGRN, QCYN, zone_table[rnum].age,
    QGRN, QCYN, zone_table[rnum].bot,
    QGRN, QCYN, zone_table[rnum].top,
    QGRN, QCYN, zone_table[rnum].reset_mode ? ((zone_table[rnum].reset_mode == 1) ?
    "Reset when no players are in zone." : "Normal reset.") : "Never reset",
    QGRN, QCYN, buf, 
    QGRN, QCYN, zone_table[rnum].min_level, 
    QGRN, QCYN, zone_table[rnum].max_level,
    QGRN,
    QGRN, QCYN, size_rooms,
    QGRN, QCYN, size_objects,
    QGRN, QCYN, size_mobiles,
    QGRN, QCYN, size_shops,
    QGRN, QCYN, size_trigs,
    QGRN, QCYN, size_quests, QNRM);
}
示例#10
0
zone_rnum create_new_zone(zone_vnum vzone_num, room_vnum bottom, room_vnum top, const char **error)
{
  FILE *fp;
  struct zone_data *zone;
  int i;
  zone_rnum rznum;
  char buf[MAX_STRING_LENGTH];

#if CIRCLE_UNSIGNED_INDEX
  if (vzone_num == NOWHERE) {
#else
  if (vzone_num < 0) {
#endif
    *error = "You can't make negative zones.\r\n";
    return NOWHERE;
  } else if (bottom > top) {
    *error = "Bottom room cannot be greater than top room.\r\n";
    return NOWHERE;
  }

#if _CIRCLEMUD < CIRCLEMUD_VERSION(3,0,21)
  /*
   * New with bpl19, the OLC interface should decide whether
   * to allow overlap before calling this function. There
   * are more complicated rules for that but it's not covered
   * here.
   */
  if (vzone_num > 326) {
    *error = "326 is the highest zone allowed.\r\n";
    return NOWHERE;
  }

  /*
   * Make sure the zone does not exist.
   */
  room = vzone_num * 100; /* Old CircleMUD 100-zones. */
  for (i = 0; i <= top_of_zone_table; i++)
    if (genolc_zone_bottom(i) <= room && zone_table[i].top >= room) {
      *error = "A zone already covers that area.\r\n";
      return NOWHERE;
    }
#else
  for (i = 0; i < top_of_zone_table; i++)
    if (zone_table[i].number == vzone_num) {
      *error = "That virtual zone already exists.\r\n";
      return NOWHERE;
     }
#endif

  /*
   * Create the zone file.
   */
  snprintf(buf, sizeof(buf), "%s%d.zon", ZON_PREFIX, vzone_num);
  if (!(fp = fopen(buf, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new zone file.");
    *error = "Could not write zone file.\r\n";
    return NOWHERE;
  }
#if _CIRCLEMUD >= CIRCLEMUD_VERSION(3,0,21)
  /* File format changed. */
  fprintf(fp, "#%d\nNone~\nNew Zone~\n%d %d 30 2\nS\n$\n", vzone_num, bottom, top);
#else
  fprintf(fp, "#%d\nNew Zone~\n%d 30 2\nS\n$\n", vzone_num, (vzone_num * 100) + 99);
#endif
  fclose(fp);

  /*
   * Create the room file.
   */
  snprintf(buf, sizeof(buf), "%s%d.wld", WLD_PREFIX, vzone_num);
  if (!(fp = fopen(buf, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new world file.");
    *error = "Could not write world file.\r\n";
    return NOWHERE;
  }
  fprintf(fp, "#%d\nThe Beginning~\nNot much here.\n~\n%d 0 0\nS\n$\n", bottom, vzone_num);
  fclose(fp);

  /*
   * Create the mobile file.
   */
  snprintf(buf, sizeof(buf), "%s%d.mob", MOB_PREFIX, vzone_num);
  if (!(fp = fopen(buf, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new mob file.");
    *error = "Could not write mobile file.\r\n";
    return NOWHERE;
  }
  fprintf(fp, "$\n");
  fclose(fp);

  /*
   * Create the object file.
   */
  snprintf(buf, sizeof(buf), "%s%d.obj", OBJ_PREFIX, vzone_num);
  if (!(fp = fopen(buf, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new obj file.");
    *error = "Could not write object file.\r\n";
    return NOWHERE;
  }
  fprintf(fp, "$\n");
  fclose(fp);

  /*
   * Create the shop file.
   */
  snprintf(buf, sizeof(buf), "%s%d.shp", SHP_PREFIX, vzone_num);
  if (!(fp = fopen(buf, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new shop file.");
    *error = "Could not write shop file.\r\n";
    return NOWHERE;
  }
  fprintf(fp, "$~\n");
  fclose(fp);

  /*
   * Create the trigger file.
   */
  snprintf(buf, sizeof(buf), "%s%d.trg", TRG_PREFIX, vzone_num);
  if (!(fp = fopen(buf, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new trigger file");
    *error = "Could not write trigger file.\r\n";
    return NOWHERE;
  }
  fprintf(fp, "$~\n");
  fclose(fp);

  /*
   * Create Gld file .
   */
  snprintf(buf, sizeof(buf), "%s/%i.gld", GLD_PREFIX, vzone_num);
  if (!(fp = fopen(buf, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new guild file");
    *error = "Could not write guild file.\r\n";
    return NOWHERE;
  }
  fprintf(fp, "$~\n");
  fclose(fp);

  /*
   * Update index files.
   */
  create_world_index(vzone_num, "zon");
  create_world_index(vzone_num, "wld");
  create_world_index(vzone_num, "mob");
  create_world_index(vzone_num, "obj");
  create_world_index(vzone_num, "shp");
  create_world_index(vzone_num, "trg");
  create_world_index(vzone_num, "gld");
  
  /*
   * Make a new zone in memory. This was the source of all the zedit new
   * crashes reported to the CircleMUD list. It was happily overwriting
   * the stack.  This new loop by Andrew Helm fixes that problem and is
   * more understandable at the same time.
   *
   * The variable is 'top_of_zone_table_table + 2' because we need record 0
   * through top_of_zone (top_of_zone_table + 1 items) and a new one which
   * makes it top_of_zone_table + 2 elements large.
   */
  RECREATE(zone_table, struct zone_data, top_of_zone_table + 2);
  zone_table[top_of_zone_table + 1].number = 32000;

  if (vzone_num > zone_table[top_of_zone_table].number)
    rznum = top_of_zone_table + 1;
  else {
    int j, room;
    for (i = top_of_zone_table + 1; i > 0 && vzone_num < zone_table[i - 1].number; i--) {
      zone_table[i] = zone_table[i - 1];
      for (j = zone_table[i].bot; j <= zone_table[i].top; j++)
        if ((room = real_room(j)) != NOWHERE)
          world[room].zone++;
    } 
    rznum = i;
  }
  zone = &zone_table[rznum];

  /*
   * Ok, insert the new zone here.
   */  
  zone->name = strdup("New Zone");
  zone->number = vzone_num;
  zone->builders = strdup("None");
#if _CIRCLEMUD >= CIRCLEMUD_VERSION(3,0,21)
  zone->bot = bottom;
  zone->top = top;
#else
  zone->top = (vzone_num * 100) + 99;
#endif
  zone->lifespan = 30;
  zone->age = 0;
  zone->reset_mode = 2;
  zone->zone_flags[0] = 0;
  zone->zone_flags[1] = 0;
  zone->zone_flags[2] = 0;
  zone->zone_flags[3] = 0;
  zone->min_level = 0;
  zone->max_level = LVL_IMPL;
  /*
   * No zone commands, just terminate it with an 'S'
   */
  CREATE(zone->cmd, struct reset_com, 1);
  zone->cmd[0].command = 'S';

  top_of_zone_table++;

  for (i = top_of_world; i > 0; i--)
    if (world[i].zone < real_zone(rznum))
      break;
    else
      world[i].zone = real_zone_by_thing(GET_ROOM_VNUM(i)); 

  add_to_save_list(zone->number, SL_ZON);
  return rznum;
}

/*-------------------------------------------------------------------*/

void create_world_index(int znum, const char *type)
{
  FILE *newfile, *oldfile;
  char new_name[32], old_name[32], *prefix;
  int num, found = FALSE;
  char buf[MAX_STRING_LENGTH];
  char buf1[MAX_STRING_LENGTH];

  switch (*type) {
  case 'z':
    prefix = ZON_PREFIX;
    break;
  case 'w':
    prefix = WLD_PREFIX;
    break;
  case 'o':
    prefix = OBJ_PREFIX;
    break;
  case 'm':
    prefix = MOB_PREFIX;
    break;
  case 's':
    prefix = SHP_PREFIX;
    break;
  case 't':
    prefix = TRG_PREFIX;
    break;
  case 'g':
    prefix = GLD_PREFIX;
    break;
  default:
    /*
     * Caller messed up  
     */
    return;
  }

  snprintf(old_name, sizeof(old_name), "%s/index", prefix);
  snprintf(new_name, sizeof(new_name), "%s/newindex", prefix);

  if (!(oldfile = fopen(old_name, "r"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Failed to open %s.", old_name);
    return;
  } else if (!(newfile = fopen(new_name, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Failed to open %s.", new_name);
    fclose(oldfile);
    return;
  }

  /*
   * Index contents must be in order: search through the old file for the
   * right place, insert the new file, then copy the rest over. 
   */
  snprintf(buf1, sizeof(buf1), "%d.%s", znum, type);
  while (get_line(oldfile, buf)) {
    if (*buf == '$') {
      /*
       * The following used to add a blank line, thanks to Brian Taylor for the fix... (Mythran)
       */
      fprintf(newfile, "%s", (!found ? strncat(buf1, "\n$\n", sizeof(buf1)-1) : "$\n"));
      break;
    } else if (!found) {
      sscanf(buf, "%d", &num);
      if (num == znum) {
        found = TRUE;
      } else if (num > znum) {
	found = TRUE;
	fprintf(newfile, "%s\n", buf1);
      }
    }
    fprintf(newfile, "%s\n", buf);
  }

  fclose(newfile);
  fclose(oldfile);
  /*
   * Out with the old, in with the new.
   */
  remove(old_name);
  rename(new_name, old_name);
}