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

Function add_rect_to_reg

src/region.c:132–155  ·  view source on GitHub ↗

* Add rectangle to region. */

Source from the content-addressed store, hash-verified

130 * Add rectangle to region.
131 */
132void
133add_rect_to_reg(NhRegion *reg, NhRect *rect)
134{
135 NhRect *tmp_rect;
136
137 tmp_rect = (NhRect *) alloc((reg->nrects + 1) * sizeof (NhRect));
138 if (reg->nrects > 0) {
139 (void) memcpy((genericptr_t) tmp_rect, (genericptr_t) reg->rects,
140 reg->nrects * sizeof (NhRect));
141 free((genericptr_t) reg->rects);
142 }
143 tmp_rect[reg->nrects] = *rect;
144 reg->nrects++;
145 reg->rects = tmp_rect;
146 /* Update bounding box if needed */
147 if (reg->bounding_box.lx > rect->lx)
148 reg->bounding_box.lx = rect->lx;
149 if (reg->bounding_box.ly > rect->ly)
150 reg->bounding_box.ly = rect->ly;
151 if (reg->bounding_box.hx < rect->hx)
152 reg->bounding_box.hx = rect->hx;
153 if (reg->bounding_box.hy < rect->hy)
154 reg->bounding_box.hy = rect->hy;
155}
156
157/*
158 * Add a monster to the region

Callers 4

create_msg_regionFunction · 0.85
create_force_fieldFunction · 0.85
create_gas_cloudFunction · 0.85

Calls 1

allocFunction · 0.70

Tested by

no test coverage detected