Ok. Got the first part to work. But when I attempted to
expand the map from just the adjacent rooms, the MUD
crashes whenever I look at a room (*eeek*).
Here is the code. I haven't found anything by debug.
#define MAP_WIDTH 5
#define MAP_HEIGHT 5
#define MAP_ROOMS (MAP_WIDTH * MAP_HEIGHT)
void show_map(struct char_data *ch)
{
char map_chars[MAP_ROOMS][5];
int map_rnum[MAP_ROOMS], i;
const char *sector_symbols[] = {
"&c#&n",
"&w.&n",
"&gT&n",
"&y^&n",
"&K^&n",
"&c~&n",
"&B~&n",
"&b~&n",
"&K.&n",
"&R*&n"
};
for (i = 0; i < MAP_ROOMS; i++) {
map_rnum[i] = 0;
sprintf(map_chars[i], "&n");
}
map_rnum[17] = IN_ROOM(ch);
if (CAN_GO(ch, 0)) {
map_rnum[17 - MAP_WIDTH] = EXIT(ch, 0)->to_room;
sprintf(map_chars[17-MAP_WIDTH],
sector_symbols[SECT(map_rnum[17-MAP_WIDTH])]);
if (CAN_GO2(EXIT(ch, 0)->to_room, 0)) {
map_rnum[17 - 6] = EXIT2(EXIT(ch, 0)->to_room, 0)->to_room;
sprintf(map_chars[17-6], sector_symbols[SECT(map_rnum[17-6])]);
}
}
if (CAN_GO(ch, 1)) {
map_rnum[17 + 1] = EXIT(ch, 1)->to_room;
sprintf(map_chars[17+1], sector_symbols[SECT(map_rnum[17+1])]);
if (CAN_GO2(EXIT(ch, 1)->to_room, 1)) {
map_rnum[17 + 2] = EXIT2(EXIT(ch, 1)->to_room, 1)->to_room;
sprintf(map_chars[17+2], sector_symbols[SECT(map_rnum[17+2])]);
}
}
if (CAN_GO(ch, 2)) {
map_rnum[17 + MAP_WIDTH] = EXIT(ch, 2)->to_room;
sprintf(map_chars[17+MAP_WIDTH],
sector_symbols[SECT(map_rnum[17+MAP_WIDTH])]);
if (CAN_GO2(EXIT(ch, 2)->to_room, 2)) {
map_rnum[17 + 6] = EXIT2(EXIT(ch, 2)->to_room, 2)->to_room;
sprintf(map_chars[17+6], sector_symbols[SECT(map_rnum[17+6])]);
}
}
if (CAN_GO(ch, 3)) {
map_rnum[17 - 1] = EXIT(ch, 3)->to_room;
sprintf(map_chars[17-1], sector_symbols[SECT(map_rnum[17-1])]);
if (CAN_GO2(EXIT(ch, 3)->to_room, 3)) {
map_rnum[17 - 2] = EXIT2(EXIT(ch, 3)->to_room, 3)->to_room;
sprintf(map_chars[17-2], sector_symbols[SECT(map_rnum[17-2])]);
}
}
sprintf(buf, "
&y===&rMAP&y===&n
%s
%s
%s%s&&%s%s
%s
%s
&y=========&n\r\n\r\n",
CAN_GO2(EXIT(ch, 0)->to_room, 0) ? map_chars[17-6] : " ",
CAN_GO(ch, 0) ? map_chars[17-MAP_WIDTH] : " ",
CAN_GO2(EXIT(ch, 3)->to_room, 3) ? map_chars[17-2] : " ",
CAN_GO(ch, 3) ? map_chars[17-1] : " ",
CAN_GO(ch, 1) ? map_chars[17+1] : " ",
CAN_GO2(EXIT(ch, 1)->to_room, 1) ? map_chars[17+2] : " ",
CAN_GO(ch, 2) ? map_chars[17+MAP_WIDTH] : " ",
CAN_GO2(EXIT(ch, 2)->to_room, 2) ? map_chars[17+6] : " ");
send_to_char(buf, ch);
}
But I like to thank Francis for sharing the base with me.
>Christoffer
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST