Reads info about our lightmaps
| 2659 | |
| 2660 | // Reads info about our lightmaps |
| 2661 | void ReadNewLightmapChunk(CFILE *fp, int version) { |
| 2662 | int nummaps; |
| 2663 | int i; |
| 2664 | |
| 2665 | // Don't read lightmaps for dedicated server |
| 2666 | if (Dedicated_server) { |
| 2667 | Num_lightmap_infos_read = 0; // I don't think this will be used, but clear it just in case |
| 2668 | return; |
| 2669 | } |
| 2670 | |
| 2671 | uint16_t *lightmap_remap = (uint16_t *)mem_malloc(MAX_LIGHTMAPS * sizeof(uint16_t)); |
| 2672 | |
| 2673 | nummaps = cf_ReadInt(fp); |
| 2674 | |
| 2675 | mprintf(0, "Reading %d unique lightmaps\n", nummaps); |
| 2676 | |
| 2677 | for (i = 0; i < nummaps; i++) { |
| 2678 | int w, h; |
| 2679 | if (nummaps >= 5) { |
| 2680 | if ((i % (nummaps / 5)) == 0) { |
| 2681 | LoadLevelProgress(LOAD_PROGRESS_LOADING_LEVEL, |
| 2682 | (filelen) ? (float)(chunk_start + ((((chunk_size) / nummaps) * i) / 2)) / (float)filelen |
| 2683 | : 0.0f, |
| 2684 | CHUNK_LIGHTMAPS); |
| 2685 | } |
| 2686 | } |
| 2687 | w = cf_ReadShort(fp); |
| 2688 | h = cf_ReadShort(fp); |
| 2689 | |
| 2690 | int lm_handle = lm_AllocLightmap(w, h); |
| 2691 | |
| 2692 | lightmap_remap[i] = lm_handle; |
| 2693 | uint16_t *data = (uint16_t *)lm_data(lm_handle); |
| 2694 | ReadCompressionShort(fp, data, w * h); |
| 2695 | } |
| 2696 | |
| 2697 | nummaps = cf_ReadInt(fp); |
| 2698 | |
| 2699 | Num_lightmap_infos_read = nummaps; |
| 2700 | ASSERT(nummaps < MAX_LIGHTMAP_INFOS); |
| 2701 | |
| 2702 | for (i = 0; i < nummaps; i++) { |
| 2703 | int w, h, lmi; |
| 2704 | uint8_t type; |
| 2705 | if (nummaps >= 50) { |
| 2706 | if ((i % (nummaps / 50)) == 0) { |
| 2707 | LoadLevelProgress(LOAD_PROGRESS_LOADING_LEVEL, |
| 2708 | (filelen) ? (float)(chunk_start + (chunk_size / 2) + (((chunk_size / 2) / nummaps) * i)) / |
| 2709 | (float)filelen |
| 2710 | : 0.0f, |
| 2711 | CHUNK_LIGHTMAPS); |
| 2712 | } |
| 2713 | } |
| 2714 | int remap_handle = cf_ReadShort(fp); |
| 2715 | w = cf_ReadShort(fp); |
| 2716 | h = cf_ReadShort(fp); |
| 2717 | type = cf_ReadByte(fp); |
| 2718 |
no test coverage detected