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

Function WriteTerrainTmapChunk

Descent3/LoadLevel.cpp:4848–4876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4846}
4847
4848void WriteTerrainTmapChunk(CFILE *fp) {
4849 int i;
4850
4851 uint8_t *byte_vals = (uint8_t *)mem_malloc(TERRAIN_DEPTH * TERRAIN_WIDTH);
4852 uint16_t *short_vals = (uint16_t *)mem_malloc(2 * TERRAIN_DEPTH * TERRAIN_WIDTH);
4853
4854 int start_pos;
4855 start_pos = StartChunk(fp, CHUNK_TERRAIN_TMAPS_FLAGS);
4856
4857 // Tmap 1s
4858 for (i = 0; i < TERRAIN_TEX_DEPTH * TERRAIN_TEX_WIDTH; i++)
4859 short_vals[i] = Terrain_tex_seg[i].tex_index;
4860 CheckToWriteCompressShort(fp, short_vals, TERRAIN_TEX_DEPTH * TERRAIN_TEX_WIDTH);
4861
4862 // Rotators
4863 for (i = 0; i < TERRAIN_TEX_DEPTH * TERRAIN_TEX_WIDTH; i++)
4864 byte_vals[i] = Terrain_tex_seg[i].rotation;
4865 CheckToWriteCompressByte(fp, byte_vals, TERRAIN_TEX_DEPTH * TERRAIN_TEX_WIDTH);
4866
4867 // flags
4868 for (i = 0; i < TERRAIN_DEPTH * TERRAIN_WIDTH; i++)
4869 byte_vals[i] = Terrain_seg[i].flags;
4870 CheckToWriteCompressByte(fp, byte_vals, TERRAIN_DEPTH * TERRAIN_WIDTH);
4871
4872 mem_free(byte_vals);
4873 mem_free(short_vals);
4874
4875 EndChunk(fp, start_pos);
4876}
4877
4878void WriteTerrainChunks(CFILE *outfile) {
4879 WriteTerrainHeightChunk(outfile);

Callers 1

WriteTerrainChunksFunction · 0.85

Calls 4

StartChunkFunction · 0.85
CheckToWriteCompressByteFunction · 0.85
EndChunkFunction · 0.85

Tested by

no test coverage detected