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

Function levregion_add

src/sp_lev.c:5370–5402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5368RESTORE_WARNING_UNREACHABLE_CODE
5369
5370staticfn void
5371levregion_add(lev_region *lregion)
5372{
5373 if (!lregion->in_islev) {
5374 get_location(&lregion->inarea.x1, &lregion->inarea.y1, ANY_LOC,
5375 (struct mkroom *) 0);
5376 get_location(&lregion->inarea.x2, &lregion->inarea.y2, ANY_LOC,
5377 (struct mkroom *) 0);
5378 }
5379
5380 if (!lregion->del_islev) {
5381 get_location(&lregion->delarea.x1, &lregion->delarea.y1,
5382 ANY_LOC, (struct mkroom *) 0);
5383 get_location(&lregion->delarea.x2, &lregion->delarea.y2,
5384 ANY_LOC, (struct mkroom *) 0);
5385 }
5386 if (gn.num_lregions) {
5387 /* realloc the lregion space to add the new one */
5388 lev_region *newl = (lev_region *) alloc(
5389 sizeof (lev_region) * (unsigned) (1 + gn.num_lregions));
5390
5391 (void) memcpy((genericptr_t) (newl), (genericptr_t) gl.lregions,
5392 sizeof (lev_region) * gn.num_lregions);
5393 Free(gl.lregions);
5394 gn.num_lregions++;
5395 gl.lregions = newl;
5396 } else {
5397 gn.num_lregions = 1;
5398 gl.lregions = (lev_region *) alloc(sizeof (lev_region));
5399 }
5400 (void) memcpy(&gl.lregions[gn.num_lregions - 1], lregion,
5401 sizeof (lev_region));
5402}
5403
5404/* get params from topmost lua hash:
5405 - region = {x1,y1,x2,y2}

Callers 2

lspo_teleport_regionFunction · 0.85
lspo_levregionFunction · 0.85

Calls 2

get_locationFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected