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

Function ReadCompressionShort

Descent3/LoadLevel.cpp:2398–2430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2396}
2397
2398void ReadCompressionShort(CFILE *fp, uint16_t *vals, int total) {
2399 int count = 0;
2400
2401 uint8_t compressed = cf_ReadByte(fp);
2402
2403 if (compressed == 0) {
2404 for (int i = 0; i < total; i++)
2405 vals[i] = cf_ReadShort(fp);
2406
2407 return;
2408 }
2409
2410 while (count != total) {
2411 ASSERT(count < total);
2412 uint8_t command = cf_ReadByte(fp);
2413
2414 if (command == 0) // next byte is raw
2415 {
2416 uint16_t height = cf_ReadShort(fp);
2417
2418 vals[count] = height;
2419 count++;
2420 } else if (command >= 2 && command <= 250) // next pixel is run of pixels
2421 {
2422 uint16_t height = cf_ReadShort(fp);
2423 for (int k = 0; k < command; k++) {
2424 vals[count] = height;
2425 count++;
2426 }
2427 } else
2428 Int3(); // bad compression run
2429 }
2430}
2431
2432// Reads a room from a disk file
2433// Parameters: ifile - file to read from

Callers 3

ReadNewLightmapChunkFunction · 0.85
ReadLightmapChunkFunction · 0.85
ReadTerrainTmapFlagChunkFunction · 0.85

Calls 2

cf_ReadByteFunction · 0.85
cf_ReadShortFunction · 0.85

Tested by

no test coverage detected