|
1 | 1 | #include "stdafx.h" |
2 | | -#pragma hdrstop |
| 2 | + |
| 3 | +#include <tbb/parallel_for_each.h> |
| 4 | + |
3 | 5 | #include "TextureDescrManager.h" |
4 | 6 | #include "ETextureParams.h" |
5 | 7 |
|
@@ -28,27 +30,25 @@ void CTextureDescrMngr::LoadTHM(LPCSTR initial) |
28 | 30 | { |
29 | 31 | FS_FileSet flist; |
30 | 32 | FS.file_list(flist, initial, FS_ListFiles, "*.thm"); |
31 | | -#ifdef DEBUG |
32 | | - Msg("count of .thm files=%d", flist.size()); |
33 | | -#endif // #ifdef DEBUG |
34 | | - auto It = flist.begin(); |
35 | | - auto It_e = flist.end(); |
36 | | - STextureParams tp; |
37 | | - string_path fn; |
38 | | - for (; It != It_e; ++It) |
| 33 | +#ifndef MASTER_GOLD |
| 34 | + Msg("%s, count of .thm files: %d", __FUNCTION__, flist.size()); |
| 35 | +#endif |
| 36 | + |
| 37 | + tbb::parallel_for_each(flist, [&](auto& it) |
39 | 38 | { |
40 | | -#ifdef DEBUG |
| 39 | +#if 0//def DEBUG // XXX: make it as an option |
41 | 40 | //Alundaio: Print list of *.thm to find bad .thms! |
42 | | - Msg("%s", (*It).name.c_str()); |
| 41 | + Msg("%s", it.name.c_str()); |
43 | 42 | #endif |
44 | | - FS.update_path(fn, initial, (*It).name.c_str()); |
| 43 | + string_path fn; |
| 44 | + FS.update_path(fn, initial, it.name.c_str()); |
45 | 45 | IReader* F = FS.r_open(fn); |
46 | | - xr_strcpy(fn, (*It).name.c_str()); |
| 46 | + xr_strcpy(fn, it.name.c_str()); |
47 | 47 | fix_texture_thm_name(fn); |
48 | 48 |
|
49 | 49 | R_ASSERT(F->find_chunk(THM_CHUNK_TYPE)); |
50 | 50 | F->r_u32(); |
51 | | - tp.Clear(); |
| 51 | + STextureParams tp; |
52 | 52 | tp.Load(*F); |
53 | 53 | FS.r_close(F); |
54 | 54 | if (STextureParams::ttImage == tp.type || STextureParams::ttTerrain == tp.type || |
@@ -95,43 +95,38 @@ void CTextureDescrMngr::LoadTHM(LPCSTR initial) |
95 | 95 | desc.m_spec->m_use_steep_parallax = true; |
96 | 96 | } |
97 | 97 | } |
98 | | - } |
| 98 | + }); |
99 | 99 | } |
100 | 100 |
|
101 | 101 | void CTextureDescrMngr::Load() |
102 | 102 | { |
103 | | -#ifdef DEBUG |
104 | | - CTimer TT; |
105 | | - TT.Start(); |
| 103 | +#ifndef MASTER_GOLD |
| 104 | + CTimer timer; |
| 105 | + timer.Start(); |
106 | 106 | #endif // #ifdef DEBUG |
107 | 107 |
|
108 | 108 | LoadTHM("$game_textures$"); |
109 | 109 | LoadTHM("$level$"); |
110 | 110 |
|
111 | | -#ifdef DEBUG |
112 | | - Msg("load time=%d ms", TT.GetElapsed_ms()); |
113 | | -#endif // #ifdef DEBUG |
| 111 | +#ifndef MASTER_GOLD |
| 112 | + Msg("%s, .thm loading time: %d ms", __FUNCTION__, timer.GetElapsed_ms()); |
| 113 | +#endif |
114 | 114 | } |
115 | 115 |
|
116 | 116 | void CTextureDescrMngr::UnLoad() |
117 | 117 | { |
118 | | - map_TD::iterator I = m_texture_details.begin(); |
119 | | - map_TD::iterator E = m_texture_details.end(); |
120 | | - for (; I != E; ++I) |
| 118 | + for (auto& it : m_texture_details) |
121 | 119 | { |
122 | | - xr_delete(I->second.m_assoc); |
123 | | - xr_delete(I->second.m_spec); |
| 120 | + xr_delete(it.second.m_assoc); |
| 121 | + xr_delete(it.second.m_spec); |
124 | 122 | } |
125 | 123 | m_texture_details.clear(); |
126 | 124 | } |
127 | 125 |
|
128 | 126 | CTextureDescrMngr::~CTextureDescrMngr() |
129 | 127 | { |
130 | | - map_CS::iterator I = m_detail_scalers.begin(); |
131 | | - map_CS::iterator E = m_detail_scalers.end(); |
132 | | - |
133 | | - for (; I != E; ++I) |
134 | | - xr_delete(I->second); |
| 128 | + for (auto& it : m_detail_scalers) |
| 129 | + xr_delete(it.second); |
135 | 130 |
|
136 | 131 | m_detail_scalers.clear(); |
137 | 132 | } |
|
0 commit comments