* Create a region. It does not activate it. */
| 76 | * Create a region. It does not activate it. |
| 77 | */ |
| 78 | NhRegion * |
| 79 | create_region(NhRect *rects, int nrect) |
| 80 | { |
| 81 | int i; |
| 82 | NhRegion *reg; |
| 83 | |
| 84 | reg = (NhRegion *) alloc(sizeof(NhRegion)); |
| 85 | (void) memset((genericptr_t) reg, 0, sizeof(NhRegion)); |
| 86 | /* Determines bounding box */ |
| 87 | if (nrect > 0) { |
| 88 | reg->bounding_box = rects[0]; |
| 89 | } else { |
| 90 | reg->bounding_box.lx = COLNO; |
| 91 | reg->bounding_box.ly = ROWNO; |
| 92 | reg->bounding_box.hx = 0; /* 1 */ |
| 93 | reg->bounding_box.hy = 0; |
| 94 | } |
| 95 | reg->nrects = nrect; |
| 96 | reg->rects = (nrect > 0) ? (NhRect *) alloc(nrect * sizeof (NhRect)) : 0; |
| 97 | for (i = 0; i < nrect; i++) { |
| 98 | if (rects[i].lx < reg->bounding_box.lx) |
| 99 | reg->bounding_box.lx = rects[i].lx; |
| 100 | if (rects[i].ly < reg->bounding_box.ly) |
| 101 | reg->bounding_box.ly = rects[i].ly; |
| 102 | if (rects[i].hx > reg->bounding_box.hx) |
| 103 | reg->bounding_box.hx = rects[i].hx; |
| 104 | if (rects[i].hy > reg->bounding_box.hy) |
| 105 | reg->bounding_box.hy = rects[i].hy; |
| 106 | reg->rects[i] = rects[i]; |
| 107 | } |
| 108 | reg->ttl = -1L; /* Defaults */ |
| 109 | reg->attach_2_u = FALSE; |
| 110 | reg->attach_2_m = 0; |
| 111 | /* reg->attach_2_o = NULL; */ |
| 112 | reg->enter_msg = (const char *) 0; |
| 113 | reg->leave_msg = (const char *) 0; |
| 114 | reg->expire_f = NO_CALLBACK; |
| 115 | reg->enter_f = NO_CALLBACK; |
| 116 | reg->can_enter_f = NO_CALLBACK; |
| 117 | reg->leave_f = NO_CALLBACK; |
| 118 | reg->can_leave_f = NO_CALLBACK; |
| 119 | reg->inside_f = NO_CALLBACK; |
| 120 | clear_hero_inside(reg); |
| 121 | clear_heros_fault(reg); |
| 122 | reg->n_monst = 0; |
| 123 | reg->max_monst = 0; |
| 124 | reg->monsters = (unsigned *) 0; |
| 125 | reg->arg = cg.zeroany; |
| 126 | return reg; |
| 127 | } |
| 128 | |
| 129 | /* |
| 130 | * Add rectangle to region. |
no test coverage detected