/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mini-Map
*/
void do_minimap( CHAR_DATA * ch, char *argument )
{
srch_minimap<3> cb;
char arg[MAX_INPUT_LENGTH];
char buf[MAX_INPUT_LENGTH];
dir_types dir;
int y;
argument = one_argument(argument, arg);
cb.start_room(ch->in_room);
if (!str_cmp(arg, "BFS"))
{
send_to_char("Using BFS Search:\r\n", ch);
search_BFS::search(ch->in_room, &cb, cb.search_dist(), false);
}
else if (!str_cmp(arg, "DIR"))
{
send_to_char("Using DIR Search:\r\n", ch);
dir = (dir_types)get_dir(argument);
search_DIR::search(ch->in_room, &cb, dir, cb.map_dist(), false);
}
else
{
send_to_char("Using LOS Search:\r\n", ch);
search_LOS::search(ch->in_room, &cb, cb.map_dist(), false);
}
for (y = (cb.map_size()-1); y > -1; y–)
{
cb.output_row0(buf, y);
ch_printf(ch, "%s\r\n", buf);
}
}
template<int DIST>
class srch_minimap : public search_callback
{
public:
ROOM_INDEX_DATA *visited[((DIST*2)+1)][((DIST*2)+1)];
int MAPSIZE;
srch_minimap(void)
{
int x,y;
MAPSIZE = ((DIST*2)+1);
for (x=0; x<MAPSIZE; x++)
for (y=0; y<MAPSIZE; y++)
visited[x][y] = NULL;
}
int map_dist()
{
return DIST;
}
int map_size()
{
return MAPSIZE;
}
int search_dist()
{
return ((DIST*2)-1);
}
void start_room(ROOM_INDEX_DATA *room)
{
visited[DIST][DIST] = room;
}
virtual bool search(search_frame *frame)
{
int x,y;
// No "Z" movement allowed
if (frame->offset.z)
return false;
// Localize
x = frame->offset.x;
y = frame->offset.y;
// X/Y constraints
if (x > DIST || x < -DIST)
return false;
if (y > DIST || y < -DIST)
return false;
// Normalize (0 to 4 instead of -2 to 2)
x += DIST;
y += DIST;
// Visited
if (visited[x][y])
return false;
// Update
visited[x][y] = frame->target;
return false;
}
void output_row0(char *buf, int y)
{
int x;
ROOM_INDEX_DATA *room;
buf[0] = '\0';
strcat(buf, "|");
for (x = 0; x < MAPSIZE; x++)
{
// Not visited
if (!(room = visited[x][y]))
{
strcat(buf, " ");
continue;
}
// Sector Type (color)
switch(room->sector_type)
{
default:
strcat(buf, "&w");
break;
case SECT_FIELD:
strcat(buf, "&G");
break;
case SECT_FOREST:
case SECT_SWAMP:
strcat(buf, "&g");
break;
case SECT_HILLS:
strcat(buf, "&Y");
break;
case SECT_MOUNTAIN:
strcat(buf, "&p");
break;
case SECT_WATER_SWIM:
case SECT_WATER_NOSWIM:
strcat(buf, "&B");
break;
case SECT_UNDERWATER:
case SECT_OCEANFLOOR:
strcat(buf, "&b");
break;
case SECT_AIR:
strcat(buf, "&c");
break;
case SECT_DESERT:
strcat(buf, "&O");
break;
case SECT_LAVA:
strcat(buf, "&R");
break;
}
// Occupied? (symbol)
if (x == DIST && y == DIST)
strcat(buf, "@");
else if (room->first_person)
strcat(buf, "*");
else
strcat(buf, ".");
}
strcat(buf, "&w|");
return;
}
};
#define DECLARE_DO_FUN(fun) extern "C" void (fun)( char_data *ch, char *argument )
#define DECLARE_SPEC_FUN( fun ) extern "C" SPEC_FUN fun
#define DECLARE_SPELL_FUN( fun ) extern "C" SPELL_FUN fun
Until then, anyone who is using it and has questions should post them here. I'll use any such feedback when updating the documentation.