fix github issue #1070 - Minetown achievement

Issue reported by vultur-cadens:  arriving on the Mine Town level
via falling or level teleport won't register the "entered Minetown"
achievement if hero doesn't arrive inside a room.

Reorder some code in check_special_room() so that town entry will be
tested before the early return if no room entry has occurred.  This
adds 'level.flags.has_town' to make the town test be cheaper when
the hero hasn't attained the achievement yet and is wandering around
the mines.

Fixes #1070
This commit is contained in:
PatR
2023-07-06 13:18:19 -07:00
parent 2bba306348
commit 60a3263a85
6 changed files with 40 additions and 13 deletions
+8 -3
View File
@@ -524,6 +524,7 @@ void
fixup_special(void)
{
lev_region *r = gl.lregions;
s_level *sp;
struct d_level lev;
int x, y;
struct mkroom *croom;
@@ -547,8 +548,7 @@ fixup_special(void)
lev = u.uz;
lev.dlevel = atoi(r->rname.str);
} else {
s_level *sp = find_level(r->rname.str);
sp = find_level(r->rname.str);
lev = sp->dlevel;
}
/*FALLTHRU*/
@@ -648,6 +648,9 @@ fixup_special(void)
stolen_booty();
}
if ((sp = Is_special(&u.uz)) != 0 && sp->flags.town) /* Mine Town */
gl.level.flags.has_town = 1;
if (gl.lregions)
free((genericptr_t) gl.lregions), gl.lregions = 0;
gn.num_lregions = 0;
@@ -1076,6 +1079,7 @@ makemaz(const char *s)
/* SPLEVTYPE format is "level-choice,level-choice"... */
if (wizard && *protofile && sp && sp->rndlevs) {
char *ep = getenv("SPLEVTYPE"); /* not nh_getenv */
if (ep) {
/* strrchr always succeeds due to code in prior block */
int len = (int) ((strrchr(protofile, '-') - protofile) + 1);
@@ -1083,6 +1087,7 @@ makemaz(const char *s)
while (ep && *ep) {
if (!strncmp(ep, protofile, len)) {
int pick = atoi(ep + len);
/* use choice only if valid */
if (pick > 0 && pick <= (int) sp->rndlevs)
Sprintf(protofile + len, "%d", pick);
@@ -1109,7 +1114,7 @@ makemaz(const char *s)
impossible("Couldn't load \"%s\" - making a maze.", protofile);
}
gl.level.flags.is_maze_lev = TRUE;
gl.level.flags.is_maze_lev = 1;
gl.level.flags.corrmaze = !rn2(3);
if (!Invocation_lev(&u.uz) && rn2(2)) {