* Add rectangle to region. */
| 130 | * Add rectangle to region. |
| 131 | */ |
| 132 | void |
| 133 | add_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 |
no test coverage detected