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

Function repairable_damage

src/shk.c:4451–4487  ·  view source on GitHub ↗

is damage dam repairable by shopkeeper shkp? */

Source from the content-addressed store, hash-verified

4449
4450/* is damage dam repairable by shopkeeper shkp? */
4451staticfn boolean
4452repairable_damage(struct damage *dam, struct monst *shkp)
4453{
4454 coordxy x, y;
4455 struct trap *ttmp;
4456 struct monst *mtmp;
4457
4458 if (!dam || shk_impaired(shkp))
4459 return FALSE;
4460
4461 x = dam->place.x;
4462 y = dam->place.y;
4463
4464 /* too soon to fix it? */
4465 if ((svm.moves - dam->when) < REPAIR_DELAY)
4466 return FALSE;
4467 /* is it a wall? don't fix if anyone is in the way */
4468 if (!IS_ROOM(dam->typ)) {
4469 if ((u_at(x, y) && !Passes_walls)
4470 || (x == shkp->mx && y == shkp->my)
4471 || ((mtmp = m_at(x, y)) != 0 && !passes_walls(mtmp->data)))
4472 return FALSE;
4473 }
4474 /* is it a trap? don't fix if hero or monster is in it */
4475 ttmp = t_at(x, y);
4476 if (ttmp) {
4477 if (u_at(x, y))
4478 return FALSE;
4479 if ((mtmp = m_at(x,y)) != 0 && mtmp->mtrapped)
4480 return FALSE;
4481 }
4482 /* does it belong to shkp? */
4483 if (!strchr(in_rooms(x, y, SHOPBASE), ESHK(shkp)->shoproom))
4484 return FALSE;
4485
4486 return TRUE;
4487}
4488
4489/* find any damage shopkeeper shkp could repair. returns NULL is none found */
4490staticfn struct damage *

Callers 2

find_damageFunction · 0.85
repair_damageFunction · 0.85

Calls 3

shk_impairedFunction · 0.85
t_atFunction · 0.85
in_roomsFunction · 0.85

Tested by

no test coverage detected