MCPcopy Create free account
hub / github.com/NetHack/NetHack / litter_getpos

Function litter_getpos

src/shk.c:4590–4615  ·  view source on GitHub ↗

find eligible spots to move items from a gap in a shop's wall that is being repaired; this guarantees that items will end up inside shkp's shop (possibly in the "free spot" or even in doorway or an adjacent wall gap), but if they are in a gap in a wall shared by two shops they might have started in the other shop */

Source from the content-addressed store, hash-verified

4588 wall gap), but if they are in a gap in a wall shared by two shops
4589 they might have started in the other shop */
4590staticfn uint8
4591litter_getpos(
4592 uint8 *litter, /* array of 9 uint8's */
4593 coordxy x, coordxy y,
4594 struct monst *shkp)
4595{
4596 int i, ix, iy;
4597 uint8 k = 0; /* number of adjacent shop spots */
4598
4599 (void) memset((genericptr_t) litter, 0, 9 * sizeof *litter);
4600
4601 if (svl.level.objects[x][y] && !IS_ROOM(levl[x][y].typ)) {
4602 for (i = 0; i < 9; i++) {
4603 ix = x + horiz(i);
4604 iy = y + vert(i);
4605 if (i == 4 || !isok(ix, iy) || !ZAP_POS(levl[ix][iy].typ))
4606 continue;
4607 litter[i] = LITTER_OPEN;
4608 if (inside_shop(ix, iy) == ESHK(shkp)->shoproom) {
4609 litter[i] |= LITTER_INSHOP;
4610 ++k;
4611 }
4612 }
4613 }
4614 return k;
4615}
4616
4617/* move items from a gap in a shop's wall that is being repaired;
4618 litter[] guarantees that items will end up inside shkp's shop, but

Callers 1

repair_damageFunction · 0.85

Calls 2

isokFunction · 0.85
inside_shopFunction · 0.85

Tested by

no test coverage detected