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

Function EndChunk

Descent3/LoadLevel.cpp:4477–4494  ·  view source on GitHub ↗

Fill in chunk length when done writing

Source from the content-addressed store, hash-verified

4475
4476// Fill in chunk length when done writing
4477void EndChunk(CFILE *ofile, int chunk_start_pos) {
4478 int save_pos = cftell(ofile);
4479 int len = save_pos - chunk_start_pos;
4480
4481 // pad the chunk if necessary to make multiple of four bytes
4482 while (len & 3) {
4483 cf_WriteByte(ofile, 0);
4484 len++;
4485 save_pos++;
4486 }
4487
4488 // seek back to len field and fill in value
4489 cfseek(ofile, chunk_start_pos, SEEK_SET);
4490 cf_WriteInt(ofile, len); // write chunk length
4491
4492 // go back to end of file
4493 cfseek(ofile, save_pos, SEEK_SET);
4494}
4495
4496void WriteTerrainHeightChunk(CFILE *fp) {
4497 int i;

Callers 15

WriteTerrainHeightChunkFunction · 0.85
WriteGamePathsChunkFunction · 0.85
WriteOverrideSoundChunkFunction · 0.85
WriteFFTMChunkFunction · 0.85
WriteBNodeChunkFunction · 0.85
WriteBOAChunkFunction · 0.85
WriteRoomAABBChunkFunction · 0.85
WriteMatcenChunkFunction · 0.85
WriteALifeChunkFunction · 0.85
WriteLevelGoalsChunkFunction · 0.85
WriteTerrainTmapChunkFunction · 0.85

Calls 4

cftellFunction · 0.85
cf_WriteByteFunction · 0.85
cfseekFunction · 0.85
cf_WriteIntFunction · 0.85

Tested by

no test coverage detected