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

Function del_light_source

src/light.c:98–138  ·  view source on GitHub ↗

Find and delete a light source. Assumes at most one light source is attached to an object at a time. */

Source from the content-addressed store, hash-verified

96/* Find and delete a light source.
97 Assumes at most one light source is attached to an object at a time. */
98void
99del_light_source(int type, anything *id)
100{
101 light_source *curr;
102 anything tmp_id;
103
104 tmp_id = cg.zeroany;
105 /* need to be prepared for dealing a with light source which
106 has only been partially restored during a level change
107 (in particular: chameleon vs prot. from shape changers) */
108 switch (type) {
109 case LS_NONE:
110 impossible("del_light_source:type=none");
111 tmp_id.a_uint = 0;
112 break;
113 case LS_OBJECT:
114 tmp_id.a_uint = id->a_obj ? id->a_obj->o_id : 0;
115 break;
116 case LS_MONSTER:
117 tmp_id.a_uint = id->a_monst->m_id;
118 break;
119 default:
120 tmp_id.a_uint = 0;
121 break;
122 }
123
124 /* find the light source from its id */
125 for (curr = gl.light_base; curr; curr = curr->next) {
126 if (curr->type != type)
127 continue;
128 if (curr->id.a_obj
129 == ((curr->flags & LSF_NEEDS_FIXUP) ? tmp_id.a_obj : id->a_obj))
130 break;
131 }
132 if (curr) {
133 delete_ls(curr);
134 } else {
135 impossible("del_light_source: not found type=%d, id=%s", type,
136 fmt_ptr((genericptr_t) id->a_obj));
137 }
138}
139
140/* remove a light source from the light_base list and free it */
141staticfn void

Callers 11

slimed_to_deathFunction · 0.85
end_burnFunction · 0.85
cleanup_burnFunction · 0.85
polyselfFunction · 0.85
rehumanizeFunction · 0.85
discard_migrationsFunction · 0.85
replmonFunction · 0.85
m_detachFunction · 0.85
newchamFunction · 0.85
dealloc_objFunction · 0.85
create_monsterFunction · 0.85

Calls 3

delete_lsFunction · 0.85
fmt_ptrFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected