MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / WriteRoom

Function WriteRoom

Descent3/LoadLevel.cpp:4386–4463  ·  view source on GitHub ↗

Writes a room to a disk file Parameters: ofile - file to write to rp - room to write Returns: 1 if written ok, else 0

Source from the content-addressed store, hash-verified

4384// rp - room to write
4385// Returns: 1 if written ok, else 0
4386int WriteRoom(CFILE *ofile, room *rp) {
4387 int i;
4388
4389 // Write counts
4390 cf_WriteInt(ofile, rp->num_verts);
4391 cf_WriteInt(ofile, rp->num_faces);
4392 cf_WriteInt(ofile, rp->num_portals);
4393
4394 // Write name
4395 cf_WriteString(ofile, rp->name ? rp->name : "");
4396
4397 // Write out the path point
4398 cf_WriteVector(ofile, &rp->path_pnt);
4399
4400 // Write verts
4401 for (i = 0; i < rp->num_verts; i++) {
4402 cf_WriteVector(ofile, &rp->verts[i]);
4403 }
4404
4405 // Write faces
4406 for (i = 0; i < rp->num_faces; i++)
4407 WriteFace(ofile, &rp->faces[i]);
4408
4409 // Write portals
4410 for (i = 0; i < rp->num_portals; i++)
4411 WritePortal(ofile, &rp->portals[i]);
4412
4413 // Write rest of data
4414 cf_WriteInt(ofile, rp->flags);
4415
4416 // Write pulse time
4417 cf_WriteByte(ofile, rp->pulse_time);
4418 cf_WriteByte(ofile, rp->pulse_offset);
4419
4420 // Write mirrored face
4421 cf_WriteShort(ofile, rp->mirror_face);
4422
4423 // Save doorway data if this room has a door
4424 if (rp->flags & RF_DOOR) {
4425 doorway *dp = rp->doorway_data;
4426
4427 cf_WriteByte(ofile, dp->flags);
4428 cf_WriteByte(ofile, dp->keys_needed);
4429 cf_WriteInt(ofile, dp->doornum);
4430 cf_WriteFloat(ofile, dp->position);
4431 }
4432
4433 if (!rp->volume_lights)
4434 cf_WriteByte(ofile, 0);
4435 else {
4436 cf_WriteByte(ofile, 1);
4437 int w = rp->volume_width;
4438 int h = rp->volume_height;
4439 int d = rp->volume_depth;
4440
4441 cf_WriteInt(ofile, w);
4442 cf_WriteInt(ofile, h);
4443 cf_WriteInt(ofile, d);

Callers 2

SaveGroupFunction · 0.85
SaveLevelFunction · 0.85

Calls 9

cf_WriteIntFunction · 0.85
cf_WriteStringFunction · 0.85
WriteFaceFunction · 0.85
WritePortalFunction · 0.85
cf_WriteByteFunction · 0.85
cf_WriteShortFunction · 0.85
cf_WriteFloatFunction · 0.85
CheckToWriteCompressByteFunction · 0.85
AmbientSoundPatternNameFunction · 0.85

Tested by

no test coverage detected