Document name: Updated Diagonal Exits Snippet version 2.0 Created by: Peter Ajamian Date: March 26, 2001 Updated by: Gerald Florence on February 4, 2003 This document and any code contained herein is copyright 1999, 2000, 2001 by Peter Ajamian. You are free to use it and redistribute it and even modify it provided this copyright notice is not altered and provided that I am given credit in in appropriate manner. Also, I would appreciate hearing from you if you do decide to use this snippet although it is not required that you contact me. This is an updated version of the old snippet which is entitled, "Adding exits to bpl15 [by Peter Ajamian]". The old snippet can (currently) be found here: http://developer.circlemud.org/1999/08/28/0728258.shtml This snippet last known to work with CircleMUD 3.0 bpl 14 - 18 (will probably work with earlier releases and also most likely work with later ones with relatively few modifications). It has been almost 19 months since I originally submitted this snippet and rather than post a comment to the original with the latest update I decided to refresh it completely and post it anew. Version 2.0 contains all of the commented changes and bugfixes (with appropriate credits) from the old snippet. This code in the Oasis OLC portion of this snippet has been updated to test for DG Scripts pl5a and later automatically. If you have a version DG Scripts prior to pl5a You will either have to add a #define for DG_SCRIPT_VERSION, or replace each instance of #ifdef DG_SCRIPT_VERSION with #if 1. There is a slight complication when adding directions such as northwest, southeast, etc. You have to account for two possible commands being entered, the player may enter northwest, or (s)he may just enter nw. This accountability adds a significant amount of extra coding to add these directions. In constants.c: - find the entry for const char *dirs[] and add the following to the end of the list (right before the "\n" entry)... "northwest", "northeast", "southeast", "southwest", "in", "out", - directly following the char *dirs[] entry create a new array as follows... const char *abbr_dirs[] = { "n", "e", "s", "w", "u", "d", "nw", "ne", "se", "sw", "in", "out", "\n" }; Thanks to Scott Davis for pointing out that MSVC has already defined the macros IN and OUT, we're changing to INDIR and OUTDIR instead. - find the array int rev_dir[] delete the whole thing and replace it with the following... int rev_dir[] = { /* North */ SOUTH, /* East */ WEST, /* South */ NORTH, /* West */ EAST, /* Up */ DOWN, /* Down */ UP, /* NW */ SOUTHEAST, /* NE */ SOUTHWEST, /* SE */ NORTHWEST, /* SW */ NORTHEAST, /* In */ OUTDIR, /* Out */ INDIR }; In constants.h: - find the following line... extern const char *dirs[]; - immediately following it add... extern const char *abbr_dirs[]; In structs.h: - Find the #defines for NORTH, SOUTH, etc... and add the following after DOWN... #define NORTHWEST 6 #define NORTHEAST 7 #define SOUTHEAST 8 #define SOUTHWEST 9 #define INDIR 10 #define OUTDIR 11 - find the following line... #define NUM_OF_DIRS 6 /* number of directions in a room (nsewud) */ - and change it to... #define NUM_OF_DIRS 12 /* number of directions in a room (nsewud) */ In interpreter.h: - find the #defines for SCMD_NORTH, SCMD_SOUTH, etc. After SCMD_DOWN add the following... #define SCMD_NW 7 #define SCMD_NE 8 #define SCMD_SE 9 #define SCMD_SW 10 #define SCMD_IN 11 #define SCMD_OUT 12 In interpreter.c: - find the entries for "north", "south", etc. in the command table. After the entry for "down" add the following... { "northwest", POS_STANDING, do_move , 0, SCMD_NW }, { "nw" , POS_STANDING, do_move , 0, SCMD_NW }, { "northeast", POS_STANDING, do_move , 0, SCMD_NE }, { "ne" , POS_STANDING, do_move , 0, SCMD_NE }, { "southeast", POS_STANDING, do_move , 0, SCMD_SE }, { "se" , POS_STANDING, do_move , 0, SCMD_SE }, { "southwest", POS_STANDING, do_move , 0, SCMD_SW }, { "sw" , POS_STANDING, do_move , 0, SCMD_SW }, { "in" , POS_STANDING, do_move , 0, SCMD_IN }, { "out" , POS_STANDING, do_move , 0, SCMD_OUT }, in act.informative.c: - In the function do_auto_exits find the following line... send_to_char(ch, "%c ", LOWER(*dirs[door])); - and replace it with... send_to_char(ch, "%c ", abbr_dirs[door])); - In ACMD(do_exits) find... send_to_char(ch, "%-5s - [%5d] %s\r\n", dirs[door], GET_ROOM_VNUM(EXIT(ch, door)->to_room), world[EXIT(ch, door)->to_room].name); - and replace it with... send_to_char(ch, "%-5s - [%9d] %s\r\n", dirs[door], GET_ROOM_VNUM(EXIT(ch, door)->to_room), world[EXIT(ch, door)->to_room].name); - also find... send_to_char(ch, "%-5s - %s\r\n", dirs[door], IS_DARK(EXIT(ch, door)->to_room) && !CAN_SEE_IN_DARK(ch) ? "Too dark to tell." : world[EXIT(ch, door)->to_room].name); - and replace it with... send_to_char(ch, "%-9s - %s\r\n", dirs[door], IS_DARK(EXIT(ch, door)->to_room) && !CAN_SEE_IN_DARK(ch) ? "Too dark to tell." : world[EXIT(ch, door)->to_room].name); - In ACMD(do_look) find... /* did the char type 'look ?' */ else if ((look_type = search_block(arg, dirs, FALSE)) >= 0) look_in_direction(ch, look_type); - and replace it with the following... /* did the char type 'look ?' */ else if ((look_type = search_block(arg, dirs, FALSE)) >= 0 || (look_type = search_block(arg, abbr_dirs, FALSE)) >= 0) look_in_direction(ch, look_type); Thanks to Adam Scriven for the following: - also find... else if (is_abbrev(arg, "in")) - and replace it with... else if ((is_abbrev(arg, "in")) && (*arg2)) In act.movement.c: - In the function find_door find... if ((door = search_block(dir, dirs, FALSE)) == -1) { /* Partial Match */ - and replace it with the following... if ((door = search_block(dir, dirs, FALSE)) < 0 && (door = search_block(dir, abbr_dirs, FALSE)) < 0) { /* Partial Match */ In house.c: - In the function hcontrol_build_house find... if ((exit_num = search_block(arg1, dirs, FALSE)) < 0) { - and replace it with the following lines... if ((exit_num = search_block(arg1, dirs, FALSE)) < 0 && (exit_num = search_block(arg1, abbr_dirs, FALSE)) < 0) { ***************************************************************** * STOP HERE if you do not have Oasis OLC installed. * ***************************************************************** In redit.c: - In the function redit_disp_menu find the following block "-- Room number : [%s%d%s] Room zone: [%s%d%s]\r\n" "%s1%s) Name : %s%s\r\n" "%s2%s) Description :\r\n%s%s" "%s3%s) Room flags : %s%s\r\n" "%s4%s) Sector type : %s%s\r\n" "%s5%s) Exit north : %s%d\r\n" "%s6%s) Exit east : %s%d\r\n" "%s7%s) Exit south : %s%d\r\n" "%s8%s) Exit west : %s%d\r\n" "%s9%s) Exit up : %s%d\r\n" "%sA%s) Exit down : %s%d\r\n" "%sB%s) Extra descriptions menu\r\n" "%sS%s) Script : %s%s\r\n" "%sQ%s) Quit\r\n" "Enter choice : ", cyn, OLC_NUM(d), nrm, cyn, zone_table[OLC_ZNUM(d)].number, nrm, grn, nrm, yel, room->name, grn, nrm, yel, room->description, grn, nrm, cyn, buf1, grn, nrm, cyn, buf2, grn, nrm, cyn, room->dir_option[NORTH] && room->dir_option[NORTH]->to_room != -1 ? world[room->dir_option[NORTH]->to_room].number : -1, grn, nrm, cyn, room->dir_option[EAST] && room->dir_option[EAST]->to_room != -1 ? world[room->dir_option[EAST]->to_room].number : -1, grn, nrm, cyn, room->dir_option[SOUTH] && room->dir_option[SOUTH]->to_room != -1 ? world[room->dir_option[SOUTH]->to_room].number : -1, grn, nrm, cyn, room->dir_option[WEST] && room->dir_option[WEST]->to_room != -1 ? world[room->dir_option[WEST]->to_room].number : -1, grn, nrm, cyn, room->dir_option[UP] && room->dir_option[UP]->to_room != -1 ? world[room->dir_option[UP]->to_room].number : -1, grn, nrm, cyn, room->dir_option[DOWN] && room->dir_option[DOWN]->to_room != -1 ? world[room->dir_option[DOWN]->to_room].number : -1, grn, nrm, grn, nrm, cyn, room->proto_script?"Set.":"Not Set.", grn, nrm ); - and replace the whole mess with... write_to_output(d, "-- Room number : [%s%d%s] Room zone: [%s%d%s]\r\n" "%s1%s) Name : %s%s\r\n" "%s2%s) Description :\r\n%s%s" "%s3%s) Room flags : %s%s\r\n" "%s4%s) Sector type : %s%s\r\n" "%s5%s) Exit north : [%s%6d], %sB%s) Exit northwest : [%s%6d]\r\n" "%s6%s) Exit east : [%s%6d], %sC%s) Exit northeast : [%s%6d]\r\n" "%s7%s) Exit south : [%s%6d], %sD%s) Exit southeast : [%s%6d]\r\n", cyn, OLC_NUM(d), nrm, cyn, zone_table[OLC_ZNUM(d)].number, nrm, grn, nrm, yel, room->name, grn, nrm, yel, room->description, grn, nrm, cyn, rbitbuf, grn, nrm, cyn, sbitbuf, grn, nrm, cyn, room->dir_option[NORTH] && room->dir_option[NORTH]->to_room != -1 ? world[room->dir_option[NORTH]->to_room].number : -1, grn, nrm, cyn, room->dir_option[NORTHWEST] && room->dir_option[NORTHWEST]->to_room != -1 ? world[room->dir_option[NORTHWEST]->to_room].number : -1, grn, nrm, cyn, room->dir_option[EAST] && room->dir_option[EAST]->to_room != -1 ? world[room->dir_option[EAST]->to_room].number : -1, grn, nrm, cyn, room->dir_option[NORTHEAST] && room->dir_option[NORTHEAST]->to_room != -1 ? world[room->dir_option[NORTHEAST]->to_room].number : -1, grn, nrm, cyn, room->dir_option[SOUTH] && room->dir_option[SOUTH]->to_room != -1 ? world[room->dir_option[SOUTH]->to_room].number : -1, grn, nrm, cyn, room->dir_option[SOUTHEAST] && room->dir_option[SOUTHEAST]->to_room != -1 ? world[room->dir_option[SOUTHEAST]->to_room].number : -1 ); write_to_output(d, "%s8%s) Exit west : [%s%6d], %sE%s) Exit southwest : [%s%6d]\r\n" "%s9%s) Exit up : [%s%6d], %sF%s) Exit in : [%s%6d]\r\n" "%sA%s) Exit down : [%s%6d], %sG%s) Exit out : [%s%6d]\r\n" "%sB%s) Extra descriptions menu\r\n" "%sS%s) Script : %s%s\r\n" "%sQ%s) Quit\r\n" "Enter choice : ", grn, nrm, cyn, room->dir_option[WEST] && room->dir_option[WEST]->to_room != -1 ? world[room->dir_option[WEST]->to_room].number : -1, grn, nrm, cyn, room->dir_option[SOUTHWEST] && room->dir_option[SOUTHWEST]->to_room!= -1 ? world[room->dir_option[SOUTHWEST]->to_room].number : -1, grn, nrm, cyn, room->dir_option[UP] && room->dir_option[UP]->to_room != -1 ? world[room->dir_option[UP]->to_room].number : -1, grn, nrm, cyn, room->dir_option[INDIR] && room->dir_option[INDIR]->to_room != -1 ? world[room->dir_option[INDIR]->to_room].number : -1, grn, nrm, cyn, room->dir_option[DOWN] && room->dir_option[DOWN]->to_room != -1 ? world[room->dir_option[DOWN]->to_room].number : -1, grn, nrm, cyn, room->dir_option[OUTDIR] && room->dir_option[OUTDIR]->to_room != -1 ? world[room->dir_option[OUTDIR]->to_room].number : -1, grn, nrm, grn, nrm, cyn, room->proto_script?"Set.":"Not Set.", grn, nrm); CAVEAT: Don't mess the above up. It took me a while to figure out what I was doing and had commas and messed up parameters. Having a procedure this huge is really ghastly but at the moment, I don't know a better way to deal with it. I did break it up in half compared with the original author's procedure. - in the function redit_parse find the following... case 'a': case 'A': OLC_VAL(d) = DOWN; redit_disp_exit_menu(d); break; - and directly following it add... case 'b': case 'B': OLC_VAL(d) = NORTHWEST; redit_disp_exit_menu(d); break; case 'c': case 'C': OLC_VAL(d) = NORTHEAST; redit_disp_exit_menu(d); break; case 'd': case 'D': OLC_VAL(d) = SOUTHEAST; redit_disp_exit_menu(d); break; case 'e': case 'E': OLC_VAL(d) = SOUTHWEST; redit_disp_exit_menu(d); break; case 'f': case 'F': OLC_VAL(d) = INDIR; redit_disp_exit_menu(d); break; case 'g': case 'G': OLC_VAL(d) = OUTDIR; redit_disp_exit_menu(d); break; - also find the following... case 'b': case 'B': /* * If the extra description doesn't exist. */ - and replace it with... case 'h': case 'H': /* * If the extra description doesn't exist. */ ***************************************************************** * STOP HERE if you do not have DG Scripts installed. * ***************************************************************** In dg_mobcmd.c: - Find the following line... extern const char *dirs[]; - directly following it add... extern const char *abbr_dirs[]; - In ACMD(do_mdoor) find... if ((dir = search_block(direction, dirs, FALSE)) == -1) { - and replace it with... if ((dir = search_block(direction, dirs, FALSE)) < 0 && (dir = search_block(direction, abbr_dirs, FALSE)) < 0) { In dg_objcmd.c: - find the following line... extern const char *dirs[]; - and following it add... extern const char *abbr_dirs[]; - In OCMD(do_odoor) find... if ((dir = search_block(direction, dirs, FALSE)) == -1) { - and replace it with... if ((dir = search_block(direction, dirs, FALSE)) < 0 && (dir = search_block(direction, abbr_dirs, FALSE)) < 0) { In dg_wldcmd.c: - find the following line... extern const char *dirs[]; - and following it add... extern const char *abbr_dirs[]; - In WCMD(do_wdoor) find... if ((dir = search_block(direction, dirs, FALSE)) == -1) { - and replace it with the following... if ((dir = search_block(direction, dirs, FALSE)) < 0 && (dir = search_block(direction, abbr_dirs, FALSE)) < 0) { In dg_scripts.c: - In the function find_replacement find... } else if (!str_cmp(field, "down")) { if (r->dir_option[DOWN]) sprintbit(r->dir_option[DOWN]->exit_info ,exit_bits, str); else *str = '\0'; - immediately following it add... } else if ((!str_cmp(field, "northwest")) || (!str_cmp(field, "nw"))) { if (r->dir_option[NORTHWEST]) sprintbit(r->dir_option[NORTHWEST]->exit_info ,exit_bits, str); else *str = 0; } else if ((!str_cmp(field, "northeast")) || (!str_cmp(field, "ne"))) { if (r->dir_option[NORTHEAST]) sprintbit(r->dir_option[NORTHEAST]->exit_info ,exit_bits, str); else *str = 0; } else if ((!str_cmp(field, "southeast")) || (!str_cmp(field, "se"))) { if (r->dir_option[SOUTHEAST]) sprintbit(r->dir_option[SOUTHEAST]->exit_info ,exit_bits, str); else *str = 0; } else if ((!str_cmp(field, "southwest")) || (!str_cmp(field, "sw"))) { if (r->dir_option[SOUTHWEST]) sprintbit(r->dir_option[SOUTHWEST]->exit_info ,exit_bits, str); else *str = 0; } else if (!str_cmp(field, "in")) { if (r->dir_option[INDIR]) sprintbit(r->dir_option[INDIR]->exit_info ,exit_bits, str); else *str = 0; } else if (!str_cmp(field, "out")) { if (r->dir_option[OUTDIR]) sprintbit(r->dir_option[OUTDIR]->exit_info ,exit_bits, str); else *str = 0; AFAIK those are all the places that need to be changed in order to make the additonal directions work, but in case I left something out or you have other patches in your code that need to be changed, try grepping (with -i) the source for the following keywords and looking in that vicinity to make further changes... dirs north rev_dir Regards, Peter Allanon of Rhu-Dina'ar http://rhudin.newvisiongames.net rhudin.newvisiongames.net port 7777