Fill in chunk length when done writing
| 4475 | |
| 4476 | // Fill in chunk length when done writing |
| 4477 | void 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 | |
| 4496 | void WriteTerrainHeightChunk(CFILE *fp) { |
| 4497 | int i; |
no test coverage detected