Allocates memory for a polygon Returns pointer to polygon
| 160 | // Allocates memory for a polygon |
| 161 | // Returns pointer to polygon |
| 162 | bsppolygon *NewPolygon(int roomnum, int facenum, int numverts) { |
| 163 | bsppolygon *newpoly; |
| 164 | vector *verts; |
| 165 | |
| 166 | newpoly = (bsppolygon *)mem_malloc(sizeof(bsppolygon)); |
| 167 | |
| 168 | if (newpoly == NULL) { |
| 169 | mprintf(0, "NewPolygon: Couldn't allocate polygon\n"); |
| 170 | return NULL; |
| 171 | } |
| 172 | |
| 173 | verts = (vector *)mem_malloc(sizeof(vector) * numverts); |
| 174 | ASSERT(verts != NULL); |
| 175 | |
| 176 | newpoly->nv = numverts; |
| 177 | newpoly->verts = verts; |
| 178 | |
| 179 | newpoly->roomnum = roomnum; |
| 180 | newpoly->facenum = facenum; |
| 181 | newpoly->color = ps_rand() * ps_rand(); |
| 182 | |
| 183 | return newpoly; |
| 184 | } |
| 185 | |
| 186 | // Saves and BSP node to an open file and recurses with the nodes children |
| 187 | void SaveBSPNode(CFILE *outfile, bspnode *node) { |
no test coverage detected