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

Function fix_shop_damage

src/shk.c:4849–4874  ·  view source on GitHub ↗

normally repair is done when a shopkeeper moves, but we also try to catch up for lost time when reloading a previously visited level */

Source from the content-addressed store, hash-verified

4847/* normally repair is done when a shopkeeper moves, but we also try to
4848 catch up for lost time when reloading a previously visited level */
4849void
4850fix_shop_damage(void)
4851{
4852 struct monst *shkp;
4853 struct damage *damg, *nextdamg;
4854
4855 /* if this level has no shop damage, there's nothing to do */
4856 if (!svl.level.damagelist)
4857 return;
4858
4859 /* go through all shopkeepers on the level */
4860 for (shkp = next_shkp(fmon, FALSE); shkp;
4861 shkp = next_shkp(shkp->nmon, FALSE)) {
4862 /* if this shopkeeper isn't in his shop or can't move, skip */
4863 if (shk_impaired(shkp))
4864 continue;
4865 /* go through all damage data trying to have this shopkeeper
4866 fix it; repair_damage() will only make repairs for damage
4867 matching shop controlled by specified shopkeeper */
4868 for (damg = svl.level.damagelist; damg; damg = nextdamg) {
4869 nextdamg = damg->next;
4870 if (repair_damage(shkp, damg, TRUE))
4871 discard_damage_struct(damg);
4872 }
4873 }
4874}
4875
4876/*
4877 * shk_move: return 1: moved 0: didn't -1: let m_move do it -2: died

Callers 3

getbonesFunction · 0.85
moveloop_preambleFunction · 0.85
goto_levelFunction · 0.85

Calls 4

next_shkpFunction · 0.85
shk_impairedFunction · 0.85
repair_damageFunction · 0.85
discard_damage_structFunction · 0.85

Tested by

no test coverage detected