18 Jun, 2006, Justice wrote in the 1st comment:
Votes: 0
After fielding a few questions on my ranged search snippet… I've decided that I need to write up some better documentation.

Until then, anyone who is using it and has questions should post them here. I'll use any such feedback when updating the documentation.
18 Jun, 2006, Justice wrote in the 2nd comment:
Votes: 0
So… I was asked if my LOS search goes around corners and passes through doors… in regard to the minimap example.

The short answer is…
For the minimap's LOS, no to both.

The long answer is…
The LOS search does not go around corners.
If you want the search to go around corners, use the BFS search.

All three searches have a boolean option allowing it to pass through doors.
The BFS and LOS search have an additional option allowing them to go up/down.
None of the searches may use the "somewhere" direction.
19 Jun, 2006, Justice wrote in the 3rd comment:
Votes: 0
For my own amusement… I wrote an updated minimap for the search snippet. Don't think it's worth it's own snippet… nor an update to the existing one (until I can update the help documentation)… so I'm posting it here.

In search.c:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* 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);
}
}


In search.h:
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;
}
};


And of course, don't forget to register do_minimap in mud.h
19 Jun, 2006, Justice wrote in the 4th comment:
Votes: 0
Found an issue in my ranged search snippet… this deals with the C++ conversion required.

#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


This relates to a thread in the SMAUGFUSS forum:
http://www.smaugmuds.org/index.php?a=top...
0.0/4