Writes a face to a disk file Parameters: ofile - file to write to fp - face to write Returns: 1 if written ok, else 0
| 4277 | // fp - face to write |
| 4278 | // Returns: 1 if written ok, else 0 |
| 4279 | int WriteFace(CFILE *ofile, face *fp) { |
| 4280 | int i; |
| 4281 | |
| 4282 | // Write number of verts |
| 4283 | cf_WriteByte(ofile, fp->num_verts); |
| 4284 | |
| 4285 | // Verts |
| 4286 | for (i = 0; i < fp->num_verts; i++) |
| 4287 | cf_WriteShort(ofile, fp->face_verts[i]); |
| 4288 | |
| 4289 | // uvls |
| 4290 | fp->flags &= ~FF_VERTEX_ALPHA; |
| 4291 | |
| 4292 | for (i = 0; i < fp->num_verts; i++) { |
| 4293 | cf_WriteFloat(ofile, fp->face_uvls[i].u); |
| 4294 | cf_WriteFloat(ofile, fp->face_uvls[i].v); |
| 4295 | cf_WriteByte(ofile, fp->face_uvls[i].alpha); |
| 4296 | |
| 4297 | if (fp->face_uvls[i].alpha != 255) |
| 4298 | fp->flags |= FF_VERTEX_ALPHA; |
| 4299 | } |
| 4300 | |
| 4301 | // Other stuff |
| 4302 | if ((fp->flags & FF_LIGHTMAP) && |
| 4303 | (fp->lmi_handle == BAD_LMI_INDEX || LightmapInfoRemap[fp->lmi_handle] == BAD_LMI_INDEX)) { |
| 4304 | fp->flags &= ~FF_LIGHTMAP; |
| 4305 | mprintf(0, "Almost saved a bogus lightmap!\n"); |
| 4306 | } |
| 4307 | |
| 4308 | cf_WriteShort(ofile, fp->flags); |
| 4309 | cf_WriteByte(ofile, fp->portal_num); |
| 4310 | cf_WriteShort(ofile, fp->tmap); |
| 4311 | |
| 4312 | if (fp->flags & FF_LIGHTMAP) { |
| 4313 | // Write UV2's |
| 4314 | |
| 4315 | ASSERT(LightmapInfoRemap[fp->lmi_handle] != BAD_LMI_INDEX); |
| 4316 | cf_WriteShort(ofile, (uint16_t)LightmapInfoRemap[fp->lmi_handle]); |
| 4317 | |
| 4318 | for (i = 0; i < fp->num_verts; i++) { |
| 4319 | cf_WriteFloat(ofile, fp->face_uvls[i].u2); |
| 4320 | cf_WriteFloat(ofile, fp->face_uvls[i].v2); |
| 4321 | } |
| 4322 | } |
| 4323 | |
| 4324 | if (fp->light_multiple == 186) { |
| 4325 | fp->light_multiple = 4; // Get Jason, I'm looking for this bug! Its safe to go past it, but I'm just on the lookout |
| 4326 | mprintf(0, "Bogus light multiple detected...bashing!\n"); |
| 4327 | } |
| 4328 | |
| 4329 | cf_WriteByte(ofile, fp->light_multiple); |
| 4330 | |
| 4331 | if (fp->special_handle != BAD_SPECIAL_FACE_INDEX) { |
| 4332 | // Write out special face stuff |
| 4333 | uint8_t smooth = 0; |
| 4334 | cf_WriteByte(ofile, 1); |
| 4335 | cf_WriteByte(ofile, SpecialFaces[fp->special_handle].type); |
| 4336 | cf_WriteByte(ofile, 4); |
no test coverage detected