02 Jan, 2008, Remcon wrote in the 1st comment:
Votes: 0
Ok, just to be doing it created something to go through and get a map of the area your currently in and just wanted to see if anyone had some suggestions/ways of making it work alot better.
mapper.c file
#include <stdio.h>
#include "h/mud.h"

char dismap[26][26];
int mapx;
int mapy;

typedef struct map_data MAP_DATA;
struct map_data
{
MAP_DATA *next, *prev;
int vnum;
};

MAP_DATA *first_dis_map, *last_dis_map;

MAP_DATA *find_map( ROOM_INDEX_DATA *room )
{
MAP_DATA *map;

for( map = first_dis_map; map; map = map->next )
if( map->vnum == room->vnum )
return map;
return NULL;
}

MAP_DATA *add_map( ROOM_INDEX_DATA *room )
{
MAP_DATA *map;

if( ( map = find_map( room ) ) )
return NULL;
CREATE( map, MAP_DATA, 1 );
map->vnum = room->vnum;
LINK( map, first_dis_map, last_dis_map, next, prev );
return map;
}

void map_exits( ROOM_INDEX_DATA *room, bool check )
{
ROOM_INDEX_DATA *uroom;
EXIT_DATA *pexit;
int smapx, smapy;
MAP_DATA *map;
bool nstop = true;

/* New rooms return data while existing returns NULL */
if( !( map = add_map( room ) ) )
return;
for( pexit = room->first_exit; pexit; pexit = pexit->next )
{
if( !( uroom = pexit->to_room ) )
continue;
smapx = mapx;
smapy = mapy;
if( pexit->vdir == DIR_NORTHWEST && mapx > 1 && mapy > 1 )
{
dismap[–mapx][–mapy] = '\\';
dismap[–mapx][–mapy] = '#';
nstop = false;
}
if( pexit->vdir == DIR_NORTH && mapx > 1 )
{
dismap[–mapx][mapy] = '|';
dismap[–mapx][mapy] = '#';
nstop = false;
}
if( pexit->vdir == DIR_NORTHEAST && mapx < 24 && mapy < 24 )
{
dismap[–mapx][++mapy] = '/';
dismap[–mapx][++mapy] = '#';
nstop = false;
}
if( pexit->vdir == DIR_EAST && mapy < 24 )
{
dismap[mapx][++mapy] = '-';
dismap[mapx][++mapy] = '#';
nstop = false;
}
if( pexit->vdir == DIR_WEST && mapy > 1 )
{
dismap[mapx][–mapy] = '-';
dismap[mapx][–mapy] = '#';
nstop = false;
}
if( pexit->vdir == DIR_SOUTHWEST && mapx < 24 && mapy > 1 )
{
dismap[++mapx][–mapy] = '/';
dismap[++mapx][–mapy] = '#';
nstop = false;
}
if( pexit->vdir == DIR_SOUTH && mapx < 24 )
{
dismap[++mapx][mapy] = '|';
dismap[++mapx][mapy] = '#';
nstop = false;
}
if( pexit->vdir == DIR_SOUTHEAST && mapx < 24 && mapy < 24 )
{
dismap[++mapx][++mapy] = '\\';
dismap[++mapx][++mapy] = '#';
nstop = false;
}
if( !nstop ) /* Doesn't call it unless it should continue */
map_exits( uroom, true );
mapx = smapx;
mapy = smapy;
}
}

void show_map( CHAR_DATA *ch )
{
int x, y;

for( x = 0; x < 26; x++ )
{
for( y = 0; y < 26; y++ )
ch_printf( ch, "%c", dismap[x][y] );
send_to_char( "\r\n", ch );
}
}

void free_map( void )
{
int x, y;
MAP_DATA *map, *map_next;

for( x = 0; x < 26; x++ )
for( y = 0; y < 26; y++ )
dismap[x][y] = ' ';
for( map = first_dis_map; map; map = map_next )
{
map_next = map->next;
UNLINK( map, first_dis_map, last_dis_map, next, prev );
DISPOSE( map );
}
}

CMDF( do_testmap )
{
if( !ch || !ch->in_room )
return;
mapx = 13;
mapy = 13;
free_map( );
map_exits( ch->in_room, false );
dismap[13][13] = '@';
show_map( ch );
free_map( );
}

Output on the mud when testmap is used and I'm in the square (where the @ is)
#            
|
#-#-#-#-#-#-#-#-#
| | |
# # #
| | |
# # # #
| | | |
# #-#-# # #-# #
| \|/ |
#-#-#-#-#-@-#-#-#-#-#
| | |
# #-#-# # #-#-# #
| | | | | | | | |
#-#-#-#-#-#-#-#-#
| | | | | | |
#-#-#-#-#-#-#-# #
| | | | | | |
#-#-#-#-#-#-#-#-#
|
#

actual way the area is
#
|
#-#-#-#-#-#-#-#-#
| | |
# # #
| | |
# # # #
| | | |
# #-#-# # #-# #
| \|/ |
#-#-#-#-#-@-#-#-#-#-#
| | |
# #-#-# # #-#-# #
| | | | | | | | |
#-#-#-#-#-#-#-#-#
| | | | | | |
| # | #-#-# |
| | |
#-#-#-#-#-# #
| | |
| # # | # # |
| | | | | | |
#-#-#-#-#-#-#-#-#
|
#

Just thought I'd see if anyone knows of a way to get it all correct or anything. Notice that it doesn't take into account up/down yet and it just mixes up the rooms since i haven't decided on a good way yet of handling it to make it handle everything correctly. On the bright side took only a little bit of changes to get it to show correctly so it did help out on making the map some lol :)
02 Jan, 2008, Conner wrote in the 2nd comment:
Votes: 0
What we really need is a freestanding program that can directly read in the area files folder and output maps (ascii, ansi, or a common image format) at the area and world levels that can be inclusive for administrative planning purposes as well as a bit less revealing for posting to a web site or forum for the benefit of players.
02 Jan, 2008, syn wrote in the 3rd comment:
Votes: 0
For that reason the mapper system I use is immortal only. Players cannot get the mini map like that, and the imms have it for planning and logistical reasons only.

-Syn
02 Jan, 2008, Remcon wrote in the 4th comment:
Votes: 0
Yea that is immortal only or well for now 2nd highest permission is required to use it :)
06 Jan, 2008, David Haley wrote in the 5th comment:
Votes: 0
I think the problem is incredibly difficult unless you make some assumptions about how your area is laid out. If you assume that things are basically "logical" with the occasional exit stretch (as you have), you could probably just apply stretch where necessary. For instance, you have one case where going down from one row and up from the row below doesn't land you in the same place; so you'd need to introduce filler there. I haven't really thought at all about how to implement such a thing, though. But, in general, I think this is an extremely difficult problem to solve, especially if you need to start invoking a layout engine to deal with funky cross-over of exits and stuff. (You could try outputting the room graph to dot and see what it does with it. That should be very easy to do automatically.)
0.0/5