Fix selection "random" grow direction, and other code cleanup

Noticed that when I set a selection to grow in a random direction, it
instead grew in all directions, which is not what I wanted. Turns out
the -1 random dir ended up being passed straight to the code which
checks bitmasks, without any form of randomizing among directions.

So this adds code to do that, and defines W_RANDOM as -1 rather than
using a magic number. In the process I also noticed that specifying
"random" as the wall for a door in a room made it rerandomize the
direction every iteration of its loop, essentially rolling two rn2(4)s
and only proceeding if they matched. That was pointless so I cleaned it
up a bit.

Also added safety checks in the form of an impossible for des.corridor()
being called with "random" as either walldir, because this is not
implemented currently.

And lastly, I noticed that create_secret_door was entirely unused
(secret door creation is handled in create_door), so I deleted it.

The only behavior change caused by this is that the Valkyrie quest lava
pools will be a little smaller, which is the only place grow is
currently used. If it's desired to keep them the same, that should be
changed to "all".
This commit is contained in:
copperwater
2022-03-14 20:54:23 -04:00
committed by Pasi Kallinen
parent 1483778e96
commit cc04bf9d8f
4 changed files with 32 additions and 61 deletions

View File

@@ -507,7 +507,7 @@ l_selection_grow(lua_State *L)
{
int argc = lua_gettop(L);
const char *const growdirs[] = { "all", "random", "north", "west", "east", "south", NULL };
const int growdirs2i[] = { W_ANY, -1, W_NORTH, W_WEST, W_EAST, W_SOUTH, 0 };
const int growdirs2i[] = { W_ANY, W_RANDOM, W_NORTH, W_WEST, W_EAST, W_SOUTH, 0 };
struct selectionvar *sel = l_selection_check(L, 1);
int dir = growdirs2i[luaL_checkoption(L, 2, "all", growdirs)];