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

Function check_map_spot

src/detect.c:261–309  ·  view source on GitHub ↗

Check whether the location has an outdated object displayed on it. */

Source from the content-addressed store, hash-verified

259
260/* Check whether the location has an outdated object displayed on it. */
261staticfn boolean
262check_map_spot(coordxy x, coordxy y, char oclass, unsigned material)
263{
264 int glyph;
265 struct obj *otmp;
266 struct monst *mtmp;
267
268 glyph = glyph_at(x, y);
269 if (glyph_is_object(glyph)) {
270 /* there's some object shown here */
271 if (oclass == ALL_CLASSES) {
272 return !(svl.level.objects[x][y] /* stale if nothing here */
273 || ((mtmp = m_at(x, y)) != 0 && mtmp->minvent));
274 } else {
275 if (material
276 && objects[glyph_to_obj(glyph)].oc_material == material) {
277 /* object shown here is of interest because material matches */
278 for (otmp = svl.level.objects[x][y]; otmp;
279 otmp = otmp->nexthere)
280 if (o_material(otmp, GOLD))
281 return FALSE;
282 /* didn't find it; perhaps a monster is carrying it */
283 if ((mtmp = m_at(x, y)) != 0) {
284 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
285 if (o_material(otmp, GOLD))
286 return FALSE;
287 }
288 /* detection indicates removal of this object from the map */
289 return TRUE;
290 }
291 if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) {
292 /* obj shown here is of interest because its class matches */
293 for (otmp = svl.level.objects[x][y]; otmp;
294 otmp = otmp->nexthere)
295 if (o_in(otmp, oclass))
296 return FALSE;
297 /* didn't find it; perhaps a monster is carrying it */
298 if ((mtmp = m_at(x, y)) != 0) {
299 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
300 if (o_in(otmp, oclass))
301 return FALSE;
302 }
303 /* detection indicates removal of this object from the map */
304 return TRUE;
305 }
306 }
307 }
308 return FALSE;
309}
310
311/*
312 * When doing detection, remove stale data from the map display (corpses

Callers 1

clear_stale_mapFunction · 0.85

Calls 3

glyph_atFunction · 0.85
o_materialFunction · 0.85
o_inFunction · 0.85

Tested by

no test coverage detected