Adding exits to bpl15 [by Peter Ajamian]
Snippet Posted Saturday, August 28th @ 07:30:35 AM, by George Greer in the Rooms dept.
Peter Ajamian writes, "The following is a snippet I did to source which is not stock. While the directions are general enough to apply to just about any bpl15 source (I have even gotten it to work on a bpl14 source), you may have to tweak with things some in order to get it to work. If you have problems implementing the snippet send me an email and I'll be glad to help you in any way I can..."

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"
};

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    */  OUT,
 /* Out   */  IN
};


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 IN             10
#define OUT            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...

      slen += sprintf(buf + slen, "%c ", LOWER(*dirs[door]));

 - and replace it with...

      slen += sprintf(buf + slen, "%s ", abbr_dirs[door]);

 - In ACMD(do_exits) find...

        sprintf(buf2, "%-5s - [%5d] %s\r\n", dirs[door],

 - and replace it with...

        sprintf(buf2, "%-5s - [%9d] %s\r\n", dirs[door],

 - also find...

        sprintf(buf2, "%-5s - ", dirs[door]);

 - and replace it with...

        sprintf(buf2, "%-9s - ", dirs[door]);

 - 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 (note do NOT try to optimize this by making it a single if statement with the two comparisons joined by ||)...

    /* did the char type 'look ?' */
    else if ((look_type = search_block(arg, dirs, FALSE)) >= 0)
      look_in_direction(ch, look_type);
    else if ((look_type = search_block(arg, abbr_dirs, FALSE)) >= 0)
      look_in_direction(ch, look_type);


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 two lines (re-indent the lines after as appropriate, do NOT try to optimize by using a single if statement)...

    if ((door = search_block(dir, dirs, FALSE)) == -1) /* Partial Match */
      if ((door = search_block(dir, abbr_dirs, FALSE)) == -1) {


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 (again, do NOT optimize)...

  if ((exit_num = search_block(arg1, dirs, FALSE)) < 0)
    if ((exit_num = search_block(arg1, abbr_dirs, FALSE)) < 0) {


********** Do the following if you have Oasis OLC installed...***********
This is based on the version of Oasis OLC that comes with DG-Scripts pl7a...

In redit.c:

 - In the function redit_disp_menu find...

  sprintf(buf,
#if defined(CLEAR_SCREEN)
          "^[[H^[[J"
#endif
          "-- 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...

  sprintf(buf,
#if defined(CLEAR_SCREEN)
          "^[[H^[[J"
#endif
          "-- 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%d\r\n"
          "%s6%s) Exit east      : %s%6d  %sC%s) Exit northeast : %s%d\r\n"
          "%s7%s) Exit south     : %s%6d  %sD%s) Exit southeast : %s%d\r\n"
          "%s8%s) Exit west      : %s%6d  %sE%s) Exit southwest : %s%d\r\n"
          "%s9%s) Exit up        : %s%6d  %sF%s) Exit in        : %s%d\r\n"
          "%sA%s) Exit down      : %s%6d  %sG%s) Exit out       : %s%d\r\n"
          "%sH%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[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,
          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[IN] && room->dir_option[IN]->to_room != -1 ?
          world[room->dir_option[IN]->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[OUT] && room->dir_option[OUT]->to_room != -1 ?
          world[room->dir_option[OUT]->to_room].number : -1,
          grn, nrm,
          grn, nrm, cyn, room->proto_script?"Set.":"Not Set.",
          grn, nrm
          );

 - 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) = IN;
      redit_disp_exit_menu(d);
      break;
    case 'g':
    case 'G':
      OLC_VAL(d) = OUT;
      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.
       */


********** Do the following if you have DG-Scripts installed...***********
Based on DG-Scripts pl7a...

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)) == -1)
      if ((dir = search_block(direction, abbr_dirs, FALSE)) == -1) {


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)) == -1)
      if ((dir = search_block(direction, abbr_dirs, FALSE)) == -1) {

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)) == -1)
      if ((dir = search_block(direction, abbr_dirs, FALSE)) == -1) {


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[IN])
          sprintbit(r->dir_option[IN]->exit_info ,exit_bits, str);
        else
          *str = '\0';
      } else if (!str_cmp(field, "out")) {
        if (r->dir_option[OUT])
          sprintbit(r->dir_option[OUT]->exit_info ,exit_bits, str);
        else
          *str = '\0';


In dg_triggers.c:

 - In the function greet_mtrigger find...

  int rev_dir[] = { SOUTH, WEST, NORTH, EAST, DOWN, UP };

 - and replace it with...

  extern int rev_dir[];

In the function enter_wtrigger find...

  int rev_dir[] = { SOUTH, WEST, NORTH, EAST, DOWN, UP };

 - and replace it with...

  extern int rev_dir[];


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 the source for the following key words and looking in that vicinity to make
further changes...

dirs NORTH north NUM_OF_DIRS rev_dir SCMD_NORTH

Regards,

Peter



<< Object Surprise! Mob appears and attacks player! [by John Melvin III] | Reply | View as text | Flattened | FTP Uploads 1999/08/29 >>

 


Related Links
  Peter Ajamian
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.
 
 


Email address
by Peter Ajamian (peter@pajamian.dhs.org) on Saturday, August 12th @ 12:54:26 PM
http://
The email address shown for this snippet is no longer valid, if you wish to contact me regarding this snippet please send email to peter@pajamian.dhs.org.

Regards, Peter

[ Reply to this comment ]

Small change for "Look In"
by Peter Ajamian (peter@pajamian.dhs.org) on Wednesday, September 27th @ 10:58:44 PM
http://
Date: Wed, 27 Sep 2000 22:48:12 -0700
From: Peter Ajamian
To: Circle Discussion List
Subject: Re: [CIRCLE] [CODE] A small patch to Peter Ajamian's multi-exit code

Adam Scriven wrote:
>
> I installed Peter Ajamian's wonderful multi-exit code,

::grins::, why thank you ;-)

> but it omits one thing.
> When you type "look ", it works OK for everything but IN,

Ahh yes, I encountered the same problem myself a while after patching it
to my own MUD. I must've forgotten to include it in the snippet.
Anyways, I won't bother to post my solution because it is almost
identical to the one you came up with. Great work and thanks!

> So here's the minor change that I made:
>
> In act.informative.c, in the function do_look, look for:
> else if (is_abbrev(arg, "in"))
> look_in_obj(ch, arg2);
>
> and change it to:
> else if ((is_abbrev(arg, "in")) && (*arg2))
> look_in_obj(ch, arg2);
>
> What this little piece of code does is look for the existance of a 2nd
> argument (bag, sack, crate, whatever) and if that exists, "look into" it.
> But if it doesn't exist, it gets passed onto the next section of code, which
> is the "look " code.

Regards, Peter

[ Reply to this comment ]

Using this snippet under MSVC++ 6.0
by Scott Davis (bobum@pipeline.com) on Wednesday, December 6th @ 12:24:54 PM
http://
Seems that the macros defind as "IN" and "OUT" in this snippet are already being used by MSVC in another .h file as I found out when I got 92 warnings about it after compilation. To remedy this, I just changed every instance of IN and OUT noted in this snippet to MYIN and MYOUT.

0 warning & 0 errors
Thanks!
[ Reply to this comment ]

New Directions Snippet
by Peter Ajamian (peter@pajamian.dhs.org) on Thursday, March 29th @ 01:21:49 AM
http://
This snippet has been superseded. Please refer to the new one posted on the CircleMUD ftp site at ftp://ftp.circlemud.org/pub/CircleMUD/contrib/snippets/rooms/exits.txt

Regards, Peter

[ Reply to this comment ]