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

View File

@@ -3069,11 +3069,10 @@ in_rooms(register coordxy x, register coordxy y, register int typewanted)
boolean
in_town(coordxy x, coordxy y)
{
s_level *slev = Is_special(&u.uz);
register struct mkroom *sroom;
boolean has_subrooms = FALSE;
if (!slev || !slev->flags.town)
if (!gl.level.flags.has_town)
return FALSE;
/*
@@ -3140,15 +3139,27 @@ check_special_room(boolean newlev)
if (*u.ushops0)
u_left_shop(u.ushops_left, newlev);
if (!*u.uentered && !*u.ushops_entered) /* implied by newlev */
return; /* no entrance messages necessary */
if (!gc.context.achieveo.minetn_reached
/*
* Check for attaining 'entered Mine Town' achievement.
* Most of the Mine Town variations have the town in one large room
* containing a bunch of subrooms; we check for entering that large
* room. However, two of the variations cover the whole level rather
* than include a room with subrooms. We need to check for town entry
* before the possible early return for not having entered a room in
* case we have arrived in the town but have not entered any room.
*
* TODO: change the minetn variants which don't include any town
* boundary to have such.
*/
if (gl.level.flags.has_town && !gc.context.achieveo.minetn_reached
&& In_mines(&u.uz) && in_town(u.ux, u.uy)) {
record_achievement(ACH_TOWN);
gc.context.achieveo.minetn_reached = TRUE;
}
if (!*u.uentered && !*u.ushops_entered) /* implied by newlev */
return; /* no entrance messages necessary */
/* Did we just enter a shop? */
if (*u.ushops_entered)
u_entered_shop(u.ushops_entered);