/***************************************************************************** * do_redit * * entry level function into the room editor *****************************************************************************/ void do_redit(struct char_data *ch, const char *argument) { struct room_index_data *room; char arg[MAX_STRING_LENGTH]; if (IS_NPC(ch)) return; argument = one_argument(argument, arg); room = ch->in_room; if (!str_cmp(arg, "reset")) { /* redit reset */ if (!IS_BUILDER(ch, room->area)) { send_to_char("Insufficient security to edit rooms.\n\r", ch); return; } reset_room(room); send_to_char("Room reset.\n\r", ch); return; } else { if (!str_cmp(arg, "create")) { /* redit create <vnum> */ if (argument[0] == '\0' || parse_int(argument) == 0) { send_to_char("Syntax: edit room create [vnum]\n\r", ch); return; } if (redit_create(ch, argument)) { ch->desc->editor = ED_ROOM; char_from_room(ch); char_to_room(ch, ch->desc->ed_data); SET_BIT(((struct room_index_data *)ch->desc->ed_data)->area->area_flags, AREA_CHANGED); } return; } else if (!str_cmp(arg, "clone")) { if (argument[0] == '\0') { send_to_char("Syntax: edit room clone [new vnum] [existing vnum]\n\r", ch); return; } if (redit_create(ch, argument)) { argument = one_argument(argument, arg); ch->desc->editor = ED_ROOM; char_from_room(ch); char_to_room(ch, ch->desc->ed_data); SET_BIT(((struct room_index_data *)ch->desc->ed_data)->area->area_flags, AREA_CHANGED); redit_clone(ch, argument); } return; } else if (!IS_NULLSTR(arg)) { /* redit <vnum> */ room = get_room_index(parse_int(arg)); if (!room) { send_to_char("REdit : room does not exist.\n\r", ch); return; } if (!IS_BUILDER(ch, room->area)) { send_to_char("REdit : insufficient security to edit rooms.\n\r", ch); return; } char_from_room(ch); char_to_room(ch, room); } } if (!IS_BUILDER(ch, room->area)) { send_to_char("REdit : Insufficient security to edit rooms.\n\r", ch); return; } ch->desc->ed_data = (void *)room; ch->desc->editor = ED_ROOM; return; }
/*************************************************************************** * change_exit * * change the values of an exit ***************************************************************************/ static bool change_exit(struct char_data *ch, const char *argument, int door) { struct room_index_data *room; char command[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH]; int value; EDIT_ROOM(ch, room); /* set the exit flags - needs full argument */ if ((value = flag_value(exit_flags, argument)) != NO_FLAG) { struct room_index_data *pToRoom; int rev; if (!room->exit[door]) { send_to_char("Exit does not exist.\n\r", ch); return false; } /* this room */ TOGGLE_BIT(room->exit[door]->rs_flags, value); room->exit[door]->exit_info = room->exit[door]->rs_flags; /* connected room */ pToRoom = room->exit[door]->u1.to_room; rev = rev_dir[door]; if (pToRoom->exit[rev] != NULL) { pToRoom->exit[rev]->rs_flags = room->exit[door]->rs_flags; pToRoom->exit[rev]->exit_info = room->exit[door]->exit_info; } send_to_char("Exit flag toggled.\n\r", ch); return true; } /* parse the arguments */ argument = one_argument(argument, command); one_argument(argument, arg); if (command[0] == '\0' && argument[0] == '\0') { move_char(ch, door, true); return false; } if (command[0] == '?') { show_help(ch->desc, "OLC_EXIT", NULL); return false; } if (!str_cmp(command, "delete")) { struct room_index_data *pToRoom; int rev; if (!room->exit[door]) { send_to_char("REdit: Cannot delete a null exit.\n\r", ch); return false; } /* remove ToRoom exit */ rev = rev_dir[door]; pToRoom = room->exit[door]->u1.to_room; if (pToRoom->exit[rev]) { free_exit(pToRoom->exit[rev]); pToRoom->exit[rev] = NULL; } /* remove this exit */ free_exit(room->exit[door]); room->exit[door] = NULL; send_to_char("Exit unlinked.\n\r", ch); return true; } if (!str_cmp(command, "link")) { struct exit_data *pExit; struct room_index_data *toRoom; if (arg[0] == '\0' || !is_number(arg)) { send_to_char("Syntax: [direction] link [vnum]\n\r", ch); return false; } value = parse_int(arg); if (!(toRoom = get_room_index(value))) { send_to_char("REdit: Cannot link to non-existant room.\n\r", ch); return false; } if (!IS_BUILDER(ch, toRoom->area)) { send_to_char("REdit: Cannot link to that area.\n\r", ch); return false; } if (toRoom->exit[rev_dir[door]]) { send_to_char("REdit: Remote side's exit already exists.\n\r", ch); return false; } if (!room->exit[door]) room->exit[door] = new_exit(); room->exit[door]->u1.to_room = toRoom; room->exit[door]->orig_door = door; door = rev_dir[door]; pExit = new_exit(); pExit->u1.to_room = room; pExit->orig_door = door; toRoom->exit[door] = pExit; send_to_char("Two-way link established.\n\r", ch); return true; } if (!str_cmp(command, "dig")) { char buf[MAX_STRING_LENGTH]; if (arg[0] == '\0' || !is_number(arg)) { send_to_char("Syntax: [direction] dig <vnum>\n\r", ch); return false; } redit_create(ch, arg); sprintf(buf, "link %s", arg); change_exit(ch, buf, door); return true; } if (!str_cmp(command, "room")) { struct room_index_data *toRoom; if (arg[0] == '\0' || !is_number(arg)) { send_to_char("Syntax: [direction] room [vnum]\n\r", ch); return false; } value = parse_int(arg); if (!(toRoom = get_room_index(value))) { send_to_char("REdit: Cannot link to non-existant room.\n\r", ch); return false; } if (!room->exit[door]) room->exit[door] = new_exit(); room->exit[door]->u1.to_room = toRoom; room->exit[door]->orig_door = door; send_to_char("One-way link established.\n\r", ch); return true; } if (!str_cmp(command, "key")) { struct objectprototype *key; if (arg[0] == '\0' || !is_number(arg)) { send_to_char("Syntax: [direction] key [vnum]\n\r", ch); return false; } if (!room->exit[door]) { send_to_char("Exit does not exist.\n\r", ch); return false; } value = parse_int(arg); if (!(key = objectprototype_getbyvnum(value))) { send_to_char("REdit: Key doesn't exist.\n\r", ch); return false; } if (key->item_type != ITEM_KEY) { send_to_char("REdit: Object is not a key.\n\r", ch); return false; } room->exit[door]->key = value; send_to_char("Exit key set.\n\r", ch); return true; } if (!str_cmp(command, "name")) { if (arg[0] == '\0') { send_to_char("Syntax: [direction] name [string]\n\r", ch); send_to_char(" [direction] name none\n\r", ch); return false; } if (!room->exit[door]) { send_to_char("Exit does not exist.\n\r", ch); return false; } free_string(room->exit[door]->keyword); if (str_cmp(arg, "none")) room->exit[door]->keyword = str_dup(arg); else room->exit[door]->keyword = str_dup(""); send_to_char("Exit name set.\n\r", ch); return true; } if (!str_prefix(command, "description")) { if (arg[0] == '\0') { if (!room->exit[door]) { send_to_char("Exit does not exist.\n\r", ch); return false; } string_append(ch, &room->exit[door]->description); return true; } send_to_char("Syntax: [direction] desc\n\r", ch); return false; } return false; }
/* Entry point for editing room_index_data. */ void do_redit (CHAR_DATA * ch, char *argument) { ROOM_INDEX_DATA *pRoom; char arg1[MAX_STRING_LENGTH]; if (IS_NPC (ch)) return; argument = one_argument (argument, arg1); pRoom = ch->in_room; if (!str_cmp (arg1, "reset")) { /* redit reset */ if (!IS_BUILDER (ch, pRoom->area)) { send_to_char ("Insufficient security to modify room.\n\r", ch); return; } reset_room (pRoom); send_to_char ("Room reset.\n\r", ch); return; } else if (!str_cmp (arg1, "create")) { /* redit create <vnum> */ if (argument[0] == '\0' || atoi (argument) == 0) { send_to_char ("Syntax: edit room create [vnum]\n\r", ch); return; } if (redit_create (ch, argument)) { /* pEdit == nuevo cuarto */ ch->desc->editor = ED_ROOM; char_from_room (ch); char_to_room (ch, ch->desc->pEdit); SET_BIT (((ROOM_INDEX_DATA *) ch->desc->pEdit)->area->area_flags, AREA_CHANGED); } return; } else if (!IS_NULLSTR (arg1)) { /* redit <vnum> */ pRoom = get_room_index (atoi (arg1)); if (!pRoom) { send_to_char ("REdit : Nonexistant room.\n\r", ch); return; } if (!IS_BUILDER (ch, pRoom->area)) { send_to_char ("REdit : Insufficient security to modify room.\n\r", ch); return; } char_from_room (ch); char_to_room (ch, pRoom); } if (!IS_BUILDER (ch, pRoom->area)) { send_to_char ("REdit : Insufficient security to modify room.\n\r", ch); return; } ch->desc->pEdit = (void *) pRoom; ch->desc->editor = ED_ROOM; return; }