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

Function ReadLightmapChunk

Descent3/LoadLevel.cpp:2758–2874  ·  view source on GitHub ↗

Reads info about our lightmaps

Source from the content-addressed store, hash-verified

2756
2757// Reads info about our lightmaps
2758void ReadLightmapChunk(CFILE *fp, int version) {
2759 // Don't read lightmaps for dedicated server
2760 if (Dedicated_server) {
2761 Num_lightmap_infos_read = 0; // I don't think this will be used, but clear it just in case
2762 return;
2763 }
2764
2765 int nummaps;
2766 int i, t;
2767 uint16_t *ded_dummy_data = NULL;
2768
2769 if (Dedicated_server) {
2770 ded_dummy_data = (uint16_t *)mem_malloc(128 * 128 * 2);
2771 ASSERT(ded_dummy_data);
2772 }
2773
2774 nummaps = cf_ReadInt(fp);
2775 Num_lightmap_infos_read = nummaps;
2776 ASSERT(nummaps < MAX_LIGHTMAP_INFOS);
2777
2778 for (i = 0; i < nummaps; i++) {
2779
2780 if ((i % 10) == 0) {
2781 LoadLevelProgress(LOAD_PROGRESS_LOADING_LEVEL,
2782 (filelen) ? (float)chunk_start + (chunk_size / nummaps) / (float)filelen : 0.0f,
2783 CHUNK_LIGHTMAPS);
2784 }
2785 int w, h, lmi;
2786 uint8_t type;
2787
2788 w = cf_ReadInt(fp);
2789 h = cf_ReadInt(fp);
2790 type = cf_ReadByte(fp);
2791
2792 if (!Dedicated_server) {
2793 lmi = AllocLightmapInfo(w, h, type);
2794 ASSERT(lmi != BAD_LMI_INDEX);
2795 LightmapInfoRemap[i] = lmi;
2796 }
2797
2798 if (version <= 38) {
2799 LightmapInfo[lmi].xspacing = (float)cf_ReadByte(fp);
2800 LightmapInfo[lmi].yspacing = (float)cf_ReadByte(fp);
2801 } else if (version < 66) {
2802 LightmapInfo[lmi].xspacing = cf_ReadFloat(fp);
2803 LightmapInfo[lmi].yspacing = cf_ReadFloat(fp);
2804 } else {
2805 int x, y;
2806
2807 x = cf_ReadByte(fp);
2808 y = cf_ReadByte(fp);
2809
2810 if (!Dedicated_server) {
2811 LightmapInfo[lmi].xspacing = x;
2812 LightmapInfo[lmi].yspacing = y;
2813 }
2814 }
2815 vector v;

Callers 1

LoadLevelFunction · 0.85

Calls 9

cf_ReadIntFunction · 0.85
LoadLevelProgressFunction · 0.85
cf_ReadByteFunction · 0.85
AllocLightmapInfoFunction · 0.85
cf_ReadFloatFunction · 0.85
lm_dataFunction · 0.85
cf_ReadShortFunction · 0.85
ReadCompressionShortFunction · 0.85
GR_RGB16Function · 0.85

Tested by

no test coverage detected