Re: [CODE] The Mapsnippet

From: Francis Hotchkiss (
Date: 11/11/98

   I saw what you are trying to do and thought I might help.
I wrote a very small map code that does what you want( just
maps the sectors of each room, and it's surrounding....) .

  What my code does is: (examples are in pseudo-code)
    -creates an array x by y,
    -finds the center of that array,
    -takes the sector type number of the room that the character
     is in and runs it through a const char string.

     Here's a rough example of what I mean, it assumes 4 sectors
     exist(forest, road, hill, swamp):
       #define MAP_WIDTH 5
       #define MAP_HIEGHT 5
       char map_chars[MAP_ROOMS][4]; (4 chars to allow for an easy-color
       const char *sector_symbols[] = { "+", ".", "^", "*" };
       int map_rnums[MAP_ROOMS], i;
       for(i = 0, i < MAP_ROOMS, i++) {
         map_rnums[i] = 0;
         map_chars[i] = '\0';
       map_rnum[17] = IN_ROOM(ch)
       sprintf(map_chars[17], sector_symbols[SECTOR(map_rnum[17])]);
       map_rnum[17 - MAP_WIDTH] = EXIT(ch, 0)->to_room;
       map_rnum[17 + 1] = EXIT(ch, 1)->to_room;
       map_rnum[17 + MAP_WIDTH] = EXIT(ch, 2)->to_room;
       map_rnum[17 - 1] = EXIT(ch, 3)->to_room;

     -then it maps the sectors for those values, goes through those rooms,
      retrieves the values for the next room and so on.....

   The whole thing can be put into a couple of functions that call each
a couple of for() loops makes this a lot easier......). This birds-eye view
"wilderness" map is in a file around 300 lines long in case you wanted to

Anyways, I hope this helps :)

Head Coder and Co-Owner of GatewayMUD
( port 5000)

> From: Christoffer Lundberg <>
> To:
> Subject:  [CODE] The Mapsnippet
> Date: Wednesday, November 11, 1998 10:08 AM
> I have checked the mapsnip.txt file from the ftp site,
> and I think it is a bit unnecessary to do all those map-
> drawings. I was only thinking of a simple code that
> finds the SECT from each adjoining room, and then translates
> them into symbols. Then it will go to those room's adjoining
> rooms and find their SECT too. I have only figured out how
> to read the adjoining rooms to the room you are in, not to
> the adjoining rooms' adjoined rooms (sounds complicated?).
> Can I really write like this ?:
> switch (SECT(EXIT(ch, EXIT(ch, 0)->to_room)->to_room)) {
> Doesn't this take the SECT from the room to the north of
> the character, and the same room again. I am looking for
> some function that can sort of count the "door" as the
> room to the north, not the room ch is in.
>   With "door" I mean that the function looks like this:
> #define EXIT(ch, door) (blah blah blah.........)
> Well, in that #define, the door is taken from ch->in_room, but
> I want it to be EXIT->to_room or something. Hmm, this was
> not as easy to explain as I thought. Well, hope you get the
> point.
> >Christoffer
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      | |
>      +------------------------------------------------------------+

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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