--- src/dungeon.c.orig Sat Jan 4 20:17:20 2003 +++ src/dungeon.c Tue Mar 4 18:23:47 2003 @@ -4794,6 +4794,10 @@ /* Redraw stuff (if needed) */ if (p_ptr->window) window_stuff(); + /* Hack -- mark current wilderness location as known */ + if (!p_ptr->wild_mode && dun_level == 0) + wild_map[p_ptr->wilderness_y][p_ptr->wilderness_x].known = TRUE; + /* Place the cursor on the player */ move_cursor_relative(py, px); --- src/externs.h.orig Fri Feb 21 09:56:26 2003 +++ src/externs.h Tue Mar 4 18:23:47 2003 @@ -897,6 +897,7 @@ extern void safe_setuid_grab(void); extern s16b tokenize(char *buf, s16b num, char **tokens, char delim1, char delim2); extern void display_player(int mode); +extern cptr describe_player_location(); extern errr file_character(cptr name, bool full); extern errr process_pref_file_aux(char *buf); extern errr process_pref_file(cptr name); --- src/files.c.orig Tue Dec 31 21:09:34 2002 +++ src/files.c Tue Mar 4 18:27:24 2003 @@ -3049,6 +3049,94 @@ } /* + * Utility function; should probably be in some other file... + * + * Describe the player's location -- either by dungeon level, town, or in + * wilderness with landmark reference. + */ +cptr describe_player_location() +{ + static char desc[80]; + int pwx = (p_ptr->wild_mode ? px : p_ptr->wilderness_x); + int pwy = (p_ptr->wild_mode ? py : p_ptr->wilderness_y); + int feat = wild_map[pwy][pwx].feat; + + if (dungeon_type != DUNGEON_WILDERNESS && dun_level > 0) + sprintf(desc, "on level %d of %s", dun_level, d_info[dungeon_type].name + d_name); + else if (wf_info[feat].terrain_idx == TERRAIN_TOWN) + sprintf(desc, "in the town of %s", wf_info[feat].name + wf_name); + else if (wf_info[feat].entrance) + sprintf(desc, "near %s", wf_info[feat].name + wf_name); + else + { + /* + * The complicated case. Find the nearest known landmark, + * and describe our position relative to that. Note that + * we may not even have any known landmarks (for instance, + * a Lost Soul character just after escaping the Halls of + * Mandos). + */ + int landmark = 0, lwx = 0, lwy = 0; + int l_dist = -1; + int i; + + for (i = 0; i < max_wf_idx; i++) + { + int wx = wf_info[i].wild_x; + int wy = wf_info[i].wild_y; + int dist; + + /* Skip if not a landmark */ + if (!wf_info[i].entrance) continue; + + /* Skip if we haven't seen it */ + if (!wild_map[wy][wx].known) continue; + + dist = distance(wy, wx, pwy, pwx); + if (dist < l_dist || l_dist < 0) + { + landmark = i; + l_dist = dist; + lwx = wx; + lwy = wy; + } + } + + if (!landmark) + sprintf(desc, "in %s", wf_info[feat].text + wf_text); + else if (pwx == lwx && pwy == lwy) + /* Paranoia; this should have been caught above */ + sprintf(desc, "near %s", wf_info[feat].name + wf_name); + else + { + /* + * We split the circle into eight equal octants of + * size pi/4 radians; the "east" octant, for + * instance, is defined as due east plus or minus + * pi/8 radians. Now sin(pi/8) ~= 0.3826 ~= 31/81, + * so we check |dx|/|dy| and |dy|/|dx| against that + * ratio to determine which octant we're in. + */ + int dx = pwx - lwx; + int dy = pwy - lwy; + cptr ns = (dy > 0 ? "south" : "north"); + cptr ew = (dx > 0 ? "east" : "west"); + + dx = (dx < 0 ? -dx : dx); + dy = (dy < 0 ? -dy : dy); + if (dy * 81 < dx * 31) ns = ""; + if (dx * 81 < dy * 31) ew = ""; + + sprintf(desc, "in %s %s%s of %s", + wf_info[feat].text + wf_text, ns, ew, + wf_info[landmark].name + wf_name); + } + } + + return desc; +} + +/* * Helper function for file_character * * Prints the big ugly grid @@ -3335,6 +3423,11 @@ else fprintf(fff, "\n Arena Levels: OFF"); + if (ironman_rooms) + fprintf(fff, "\n Iron-man Rooms: ON"); + else + fprintf(fff, "\n Iron-man Rooms: OFF"); + if (seed_dungeon) fprintf(fff, "\n Persistent Dungeons: ON"); else @@ -3359,11 +3452,14 @@ { char desc[80]; monster_race_desc(desc, p_ptr->body_monster, 0); - fprintf(fff, "\n Your body was %s.", desc); + fprintf(fff, "\n Your body %s %s.", (death ? "was" : "is"), desc); - if (p_ptr->tim_mimic) fprintf(fff, "\n Your were disguised into a %s.", p_ptr->mimic_name); + if (p_ptr->tim_mimic) fprintf(fff, "\n You %s disguised into a %s.", (death ? "were" : "are"), p_ptr->mimic_name); } + /* Where we are, if we're alive */ + if (!death) fprintf(fff, "\n You are currently %s.", describe_player_location()); + /* Date */ { char buf2[20]; @@ -3374,9 +3470,11 @@ get_month_name(bst(DAY, START_DAY * 10), wizard, FALSE), buf2); strnfmt(buf2, 20, get_day(bst(YEAR, turn) + START_YEAR)); - fprintf(fff, "\n You ended your adventure the %s of the %s year of the third age.", + fprintf(fff, "\n %s the %s of the %s year of the third age.", + (death ? "You ended your adventure" : "It is currently"), get_month_name(bst(DAY, turn), wizard, FALSE), buf2); - fprintf(fff, "\n It now is %ld day%s that you are adventuring.", + fprintf(fff, + (death ? "\n Your adventure lasted %d day%s." : "\n It now is %ld day%s that you are adventuring."), days, (days == 1) ? "" : "s"); } --- src/init1.c.orig Fri Feb 21 09:56:27 2003 +++ src/init1.c Tue Mar 4 18:23:47 2003 @@ -10728,6 +10728,18 @@ { if (1 != sscanf(s + x, "%c", &i)) return (1); wild_map[y][x].feat = wildc2i[(int)i]; + + /* + * If this is a town/dungeon entrance, note + * its coordinates. (Have to check for + * duplicate Morias...) + */ + if (wf_info[wildc2i[(int)i]].entrance && + wf_info[wildc2i[(int)i]].wild_x == 0) + { + wf_info[wildc2i[(int)i]].wild_x = x; + wf_info[wildc2i[(int)i]].wild_y = y; + } } (*yval)++; --- src/spells2.c.orig Sun Mar 2 20:52:12 2003 +++ src/spells2.c Tue Mar 4 18:23:47 2003 @@ -668,9 +668,10 @@ if (death) { - static char buf[150]; + static char buf[250]; - sprintf(buf, "You are dead, killed by %s.", died_from); + sprintf(buf, "You are dead, killed by %s %s.", + died_from, describe_player_location()); info[i++] = buf; } --- src/types.h.orig Sat Jan 4 20:17:21 2003 +++ src/types.h Tue Mar 4 18:23:47 2003 @@ -1868,6 +1868,8 @@ u32b name; /* Name (offset) */ u32b text; /* Text (offset) */ u16b entrance; /* Which town is there(<1000 i's a town, >=1000 it a dungeon) */ + s32b wild_x; /* Map coordinates (backed out while parsing map) */ + s32b wild_y; byte road; /* Flags of road */ int level; /* Difficulty level */ u32b flags1; /* Some flags */