MCPcopy Index your code
hub / github.com/NetHack/NetHack / add_damage

Function add_damage

src/shk.c:4398–4437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4396}
4397
4398void
4399add_damage(
4400 coordxy x,
4401 coordxy y,
4402 long cost)
4403{
4404 struct damage *tmp_dam;
4405 char *shops;
4406
4407 if (IS_DOOR(levl[x][y].typ)) {
4408 struct monst *mtmp;
4409
4410 /* Don't schedule for repair unless it's a real shop entrance */
4411 for (shops = in_rooms(x, y, SHOPBASE); *shops; shops++)
4412 if ((mtmp = shop_keeper(*shops)) != 0
4413 && x == ESHK(mtmp)->shd.x && y == ESHK(mtmp)->shd.y)
4414 break;
4415 if (!*shops)
4416 return;
4417 }
4418 for (tmp_dam = svl.level.damagelist; tmp_dam; tmp_dam = tmp_dam->next)
4419 if (tmp_dam->place.x == x && tmp_dam->place.y == y) {
4420 tmp_dam->cost += cost;
4421 tmp_dam->when = svm.moves; /* needed by pay_for_damage() */
4422 return;
4423 }
4424 tmp_dam = (struct damage *) alloc((unsigned) sizeof *tmp_dam);
4425 (void) memset((genericptr_t) tmp_dam, 0, sizeof *tmp_dam);
4426 tmp_dam->when = svm.moves;
4427 tmp_dam->place.x = x;
4428 tmp_dam->place.y = y;
4429 tmp_dam->cost = cost;
4430 tmp_dam->typ = levl[x][y].typ;
4431 tmp_dam->flags = levl[x][y].flags;
4432 tmp_dam->next = svl.level.damagelist;
4433 svl.level.damagelist = tmp_dam;
4434 /* If player saw damage, display walls post-repair as walls, not stone */
4435 if (cansee(x, y))
4436 levl[x][y].seenv = SVALL;
4437}
4438
4439/* is shopkeeper impaired, so they cannot act? */
4440staticfn boolean

Callers 15

still_chewingFunction · 0.85
digFunction · 0.85
digactualholeFunction · 0.85
use_pick_axe2Function · 0.85
mdig_tunnelFunction · 0.85
zap_digFunction · 0.85
picklockFunction · 0.85
doopen_indirFunction · 0.85
doorlockFunction · 0.85
do_earthquakeFunction · 0.85
dospinwebFunction · 0.85
maketrapFunction · 0.85

Calls 3

in_roomsFunction · 0.85
shop_keeperFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected