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

Function clone_region

src/region.c:226–254  ·  view source on GitHub ↗

* Clone (make a standalone copy) the region. */

Source from the content-addressed store, hash-verified

224 * Clone (make a standalone copy) the region.
225 */
226NhRegion *
227clone_region(NhRegion *reg)
228{
229 NhRegion *ret_reg;
230 unsigned *m_id_list;
231 short i;
232
233 ret_reg = create_region(reg->rects, reg->nrects);
234 ret_reg->ttl = reg->ttl;
235 ret_reg->attach_2_u = reg->attach_2_u;
236 ret_reg->attach_2_m = reg->attach_2_m;
237 /* ret_reg->attach_2_o = reg->attach_2_o; */
238 ret_reg->expire_f = reg->expire_f;
239 ret_reg->enter_f = reg->enter_f;
240 ret_reg->can_enter_f = reg->can_enter_f;
241 ret_reg->leave_f = reg->leave_f;
242 ret_reg->can_leave_f = reg->can_leave_f;
243 ret_reg->player_flags = reg->player_flags; /* set/clear_hero_inside,&c*/
244 ret_reg->n_monst = reg->n_monst;
245 ret_reg->max_monst = reg->max_monst;
246 if (reg->max_monst > 0) {
247 m_id_list = (unsigned *) alloc(reg->max_monst * sizeof (unsigned));
248 for (i = 0; i < reg->max_monst; ++i)
249 m_id_list[i] = reg->monsters[i];
250 } else
251 m_id_list = (unsigned *) 0;
252 ret_reg->monsters = m_id_list;
253 return ret_reg;
254}
255
256#endif /*0*/
257#endif /* !SFCTOOL */

Callers

nothing calls this directly

Calls 2

create_regionFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected