git issue #1467 - selection.match() boundaries

Issue reported by copperwater:
| a = selection.match(some_mapfrag);
| b = selection.match(another_mapfrag);
| c = a + b;
Instead of being a union of all the points that match either mapfrag,
the resulting selection c is empty.

[Report included a choice of two possible fixes.]
I put both in, without adequate testing of either one.

I didn't hit any problems with the existing special levels but didn't
try many theme rooms.

Closes #1467
This commit is contained in:
PatR
2026-01-30 14:17:53 -08:00
parent f7b3337ae1
commit deec8317ce
2 changed files with 18 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 nhlua.c $NHDT-Date: 1737545957 2025/01/22 03:39:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.64 $ */
/* NetHack 3.7 nhlua.c $NHDT-Date: 1769840272 2026/01/30 22:17:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.69 $ */
/* Copyright (c) 2018 by Pasi Kallinen */
/* NetHack may be freely redistributed. See license for details. */
@@ -710,6 +710,10 @@ l_selection_match(lua_State *L)
for (x = 1; x < sel->wid; x++)
selection_setpoint(x, y, sel, mapfrag_match(mf, x,y) ? 1 : 0);
/* unless the (0, 1) coordinate is a match, this would wind up with a
selection with lx=COLNO, hx=0, etc, so fix the boundaries */
selection_recalc_bounds(sel);
mapfrag_free(&mf);
return 1;