Skip to content

Commit 46ea987

Browse files
committed
xrEProps/EditorChooseEvents.h: range-based for usage, errors fixes
1 parent 4fa07eb commit 46ea987

File tree

2 files changed

+60
-94
lines changed

2 files changed

+60
-94
lines changed

src/editors/xrEProps/ChoseForm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "mxPlacemnt.hpp"
2020
#include "ElXPThemedControl.hpp"
2121
#include "Gradient.hpp"
22-
#include "ChooseTypes.H"
22+
#include "xrCore/ChooseTypes.H"
2323

2424
//---------------------------------------------------------------------------
2525
// refs

src/editors/xrEProps/EditorChooseEvents.h

Lines changed: 59 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef EditorChooseEventsH
22
#define EditorChooseEventsH
33

4-
#include "ChooseTypes.h"
4+
#include "xrCore/ChooseTypes.h"
55
#include "Layers/xrRender/SkeletonAnimated.h"
66
#include "Layers/xrRender/ResourceManager.h"
77

@@ -15,12 +15,11 @@ namespace ChoseEvents
1515
void __stdcall FillEntity(ChooseItemVec& items, void* param)
1616
{
1717
//. AppendItem (RPOINT_CHOOSE_NAME);
18-
CInifile::Root const& data = pSettings->sections();
19-
for (CInifile::RootCIt it = data.begin(); it != data.end(); it++)
18+
for (auto& it : pSettings->sections())
2019
{
21-
LPCSTR val;
22-
if ((*it)->line_exist("$spawn", &val))
23-
items.push_back(SChooseItem(*(*it)->Name, ""));
20+
pcstr val;
21+
if (it->line_exist("$spawn", &val))
22+
items.push_back(SChooseItem(it->Name.c_str(), ""));
2423
}
2524
}
2625
//---------------------------------------------------------------------------
@@ -42,10 +41,8 @@ void __stdcall FillSoundSource(ChooseItemVec& items, void* param)
4241
FS_FileSet lst;
4342
if (SndLib->GetGameSounds(lst))
4443
{
45-
FS_FileSetIt it = lst.begin();
46-
FS_FileSetIt _E = lst.end();
47-
for (; it != _E; it++)
48-
items.push_back(SChooseItem(it->name.c_str(), ""));
44+
for (auto& it : lst)
45+
items.push_back(SChooseItem(it.name.c_str(), ""));
4946
}
5047
}
5148
//---------------------------------------------------------------------------
@@ -54,10 +51,8 @@ void __stdcall FillSoundEnv(ChooseItemVec& items, void* param)
5451
AStringVec lst;
5552
if (SndLib->GetSoundEnvs(lst))
5653
{
57-
AStringIt it = lst.begin();
58-
AStringIt _E = lst.end();
59-
for (; it != _E; it++)
60-
items.push_back(SChooseItem(it->c_str(), ""));
54+
for (auto& it : lst)
55+
items.push_back(SChooseItem(it.c_str(), ""));
6156
}
6257
}
6358
//---------------------------------------------------------------------------
@@ -66,10 +61,8 @@ void __stdcall FillObject(ChooseItemVec& items, void* param)
6661
FS_FileSet lst;
6762
if (Lib.GetObjects(lst))
6863
{
69-
FS_FileSetIt it = lst.begin();
70-
FS_FileSetIt _E = lst.end();
71-
for (; it != _E; it++)
72-
items.push_back(SChooseItem(it->name.c_str(), ""));
64+
for (auto& it : lst)
65+
items.push_back(SChooseItem(it.name.c_str(), ""));
7366
}
7467
}
7568
void __stdcall SelectObject(SChooseItem* item, PropItemVec& info_items)
@@ -92,10 +85,8 @@ void __stdcall FillGroup(ChooseItemVec& items, void* param)
9285
FS_FileSet lst;
9386
if (FS.file_list(lst, _groups_, FS_ListFiles | FS_ClampExt, "*.group"))
9487
{
95-
FS_FileSetIt it = lst.begin();
96-
FS_FileSetIt _E = lst.end();
97-
for (; it != _E; it++)
98-
items.push_back(SChooseItem(it->name.c_str(), ""));
88+
for (auto& it : lst)
89+
items.push_back(SChooseItem(it.name.c_str(), ""));
9990
}
10091
}
10192
void __stdcall SelectGroup(SChooseItem* item, PropItemVec& info_items)
@@ -118,10 +109,8 @@ void __stdcall FillVisual(ChooseItemVec& items, void* param)
118109
FS_FileSet lst;
119110
if (FS.file_list(lst, _game_meshes_, FS_ListFiles | FS_ClampExt, "*.ogf"))
120111
{
121-
FS_FileSetIt it = lst.begin();
122-
FS_FileSetIt _E = lst.end();
123-
for (; it != _E; it++)
124-
items.push_back(SChooseItem(it->name.c_str(), ""));
112+
for (auto& it : lst)
113+
items.push_back(SChooseItem(it.name.c_str(), ""));
125114
}
126115
}
127116
void __stdcall SelectVisual(SChooseItem* item, PropItemVec& info_items)
@@ -155,10 +144,8 @@ void __stdcall FillGameObjectMots(ChooseItemVec& items, void* param)
155144
FS_FileSet lst;
156145
if (FS.file_list(lst, _game_meshes_, FS_ListFiles | FS_ClampExt, "*.omf"))
157146
{
158-
FS_FileSetIt it = lst.begin();
159-
FS_FileSetIt _E = lst.end();
160-
for (; it != _E; it++)
161-
items.push_back(SChooseItem(it->name.c_str(), ""));
147+
for (auto& it : lst)
148+
items.push_back(SChooseItem(it.name.c_str(), ""));
162149
}
163150
}
164151
void __stdcall SelectGameObjectMots(SChooseItem* item, PropItemVec& info_items) {}
@@ -168,20 +155,16 @@ void __stdcall FillGameAnim(ChooseItemVec& items, void* param)
168155
FS_FileSet lst;
169156
if (FS.file_list(lst, "$game_anims$", FS_ListFiles, "*.anm,*.anms"))
170157
{
171-
FS_FileSetIt it = lst.begin();
172-
FS_FileSetIt _E = lst.end();
173-
for (; it != _E; it++)
174-
items.push_back(SChooseItem(it->name.c_str(), ""));
158+
for (auto& it : lst)
159+
160+
items.push_back(SChooseItem(it.name.c_str(), ""));
175161
}
176162
}
177163
//---------------------------------------------------------------------------
178164
void __stdcall FillLAnim(ChooseItemVec& items, void* param)
179165
{
180-
LAItemVec& lst = LALib.Objects();
181-
LAItemIt it = lst.begin();
182-
LAItemIt _E = lst.end();
183-
for (; it != _E; it++)
184-
items.push_back(SChooseItem(*(*it)->cName, ""));
166+
for (auto& it : LALib.Objects())
167+
items.push_back(SChooseItem((*it)->cName.c_str(), ""));
185168
}
186169
void __stdcall DrawLAnim(LPCSTR name, HDC hdc, const Irect& r)
187170
{
@@ -197,33 +180,28 @@ void __stdcall DrawLAnim(LPCSTR name, HDC hdc, const Irect& r)
197180
//---------------------------------------------------------------------------
198181
void __stdcall FillEShader(ChooseItemVec& items, void* param)
199182
{
200-
CResourceManager::map_Blender& blenders = EDevice.Resources->_GetBlenders();
201-
CResourceManager::map_BlenderIt _S = blenders.begin();
202-
CResourceManager::map_BlenderIt _E = blenders.end();
203-
for (; _S != _E; _S++)
204-
items.push_back(SChooseItem(_S->first, ""));
183+
for (auto& it : EDevice.Resources->_GetBlenders())
184+
items.push_back(SChooseItem(it.first, ""));
205185
}
206186
//---------------------------------------------------------------------------
207187
void __stdcall FillCShader(ChooseItemVec& items, void* param)
208188
{
209-
Shader_xrLCVec& shaders = EDevice.ShaderXRLC.Library();
210-
Shader_xrLCIt _F = shaders.begin();
211-
Shader_xrLCIt _E = shaders.end();
212-
for (; _F != _E; _F++)
213-
items.push_back(SChooseItem(_F->Name, ""));
189+
for (auto& it : EDevice.ShaderXRLC.Library())
190+
items.push_back(SChooseItem(it.Name, ""));
214191
}
215192
//---------------------------------------------------------------------------
216193
void __stdcall FillPE(ChooseItemVec& items, void* param)
217194
{
218-
for (PS::PEDIt E = ::Render->PSLibrary.FirstPED(); E != ::Render->PSLibrary.LastPED(); E++)
195+
for (PS::PEDIt E = GEnv.Render->PSLibrary.FirstPED(); E != GEnv.Render->PSLibrary.LastPED(); ++E)
219196
items.push_back(SChooseItem(*(*E)->m_Name, "EFFECT"));
220197
}
221198
//---------------------------------------------------------------------------
222199
void __stdcall FillParticles(ChooseItemVec& items, void* param)
223200
{
224-
for (PS::PEDIt E = ::Render->PSLibrary.FirstPED(); E != ::Render->PSLibrary.LastPED(); E++)
201+
for (PS::PEDIt E = GEnv.Render->PSLibrary.FirstPED(); E != GEnv.Render->PSLibrary.LastPED(); ++E)
225202
items.push_back(SChooseItem(*(*E)->m_Name, "EFFECT"));
226-
for (PS::PGDIt G = ::Render->PSLibrary.FirstPGD(); G != ::Render->PSLibrary.LastPGD(); G++)
203+
204+
for (PS::PGDIt G = GEnv.Render->PSLibrary.FirstPGD(); G != GEnv.Render->PSLibrary.LastPGD(); ++G)
227205
items.push_back(SChooseItem(*(*G)->m_Name, "GROUP"));
228206
}
229207

@@ -232,14 +210,12 @@ void __stdcall SelectPE(SChooseItem* item, PropItemVec& info_items)
232210
string64 str;
233211
u32 i = 0;
234212
PHelper().CreateCaption(info_items, "", "used in groups");
235-
for (PS::PGDIt G = ::Render->PSLibrary.FirstPGD(); G != ::Render->PSLibrary.LastPGD(); ++G)
213+
for (PS::PGDIt G = GEnv.Render->PSLibrary.FirstPGD(); G != GEnv.Render->PSLibrary.LastPGD(); ++G)
236214
{
237215
PS::CPGDef* def = (*G);
238-
PS::CPGDef::EffectIt pe_it = def->m_Effects.begin();
239-
PS::CPGDef::EffectIt pe_it_e = def->m_Effects.end();
240-
for (; pe_it != pe_it_e; ++pe_it)
216+
for (auto& pe_it : def->m_Effects)
241217
{
242-
if ((*pe_it)->m_EffectName == item->name)
218+
if (pe_it->m_EffectName == item->name)
243219
{
244220
xr_sprintf(str, sizeof(str), "%d", ++i);
245221
PHelper().CreateCaption(info_items, str, def->m_Name);
@@ -253,17 +229,15 @@ void __stdcall SelectPG(SChooseItem* item, PropItemVec& info_items)
253229
string64 str;
254230
u32 i = 0;
255231
PHelper().CreateCaption(info_items, "", "using effects");
256-
for (PS::PGDIt G = ::Render->PSLibrary.FirstPGD(); G != ::Render->PSLibrary.LastPGD(); G++)
232+
for (PS::PGDIt G = GEnv.Render->PSLibrary.FirstPGD(); G != GEnv.Render->PSLibrary.LastPGD(); ++G)
257233
{
258234
PS::CPGDef* def = (*G);
259235
if (def->m_Name == item->name)
260236
{
261-
PS::CPGDef::EffectIt pe_it = def->m_Effects.begin();
262-
PS::CPGDef::EffectIt pe_it_e = def->m_Effects.end();
263-
for (; pe_it != pe_it_e; ++pe_it)
237+
for (auto& pe_it : def->m_Effects)
264238
{
265239
xr_sprintf(str, sizeof(str), "%d", ++i);
266-
PHelper().CreateCaption(info_items, str, (*pe_it)->m_EffectName);
240+
PHelper().CreateCaption(info_items, str, pe_it->m_EffectName);
267241
}
268242
break;
269243
}
@@ -276,10 +250,9 @@ void __stdcall FillTexture(ChooseItemVec& items, void* param)
276250
FS_FileSet lst;
277251
if (ImageLib.GetTextures(lst))
278252
{
279-
FS_FileSetIt it = lst.begin();
280-
FS_FileSetIt _E = lst.end();
281-
for (; it != _E; it++)
282-
items.push_back(SChooseItem(it->name.c_str(), ""));
253+
for (auto& it : lst)
254+
255+
items.push_back(SChooseItem(it.name.c_str(), ""));
283256
}
284257
}
285258

@@ -300,10 +273,9 @@ void __stdcall FillTextureRaw(ChooseItemVec& items, void* param)
300273
FS_FileSet lst;
301274
if (ImageLib.GetTexturesRaw(lst))
302275
{
303-
FS_FileSetIt it = lst.begin();
304-
FS_FileSetIt _E = lst.end();
305-
for (; it != _E; it++)
306-
items.push_back(SChooseItem(it->name.c_str(), ""));
276+
for (auto& it : lst)
277+
278+
items.push_back(SChooseItem(it.name.c_str(), ""));
307279
}
308280
}
309281

@@ -350,54 +322,48 @@ void __stdcall FillGameMaterial(ChooseItemVec& items, void* param)
350322

351323
void __stdcall FillSkeletonAnims(ChooseItemVec& items, void* param)
352324
{
353-
IRenderVisual* V = ::Render->model_Create((LPCSTR)param);
325+
IRenderVisual* V = GEnv.Render->model_Create((LPCSTR)param);
354326
if (PKinematicsAnimated(V))
355327
{
356328
u32 cnt = PKinematicsAnimated(V)->LL_MotionsSlotCount();
357329
for (u32 k = 0; k < cnt; k++)
358330
{
359-
accel_map* ll_motions = PKinematicsAnimated(V)->LL_Motions(k);
360-
accel_map::iterator _I, _E;
361-
_I = ll_motions->begin();
362-
_E = ll_motions->end();
363-
for (; _I != _E; ++_I)
331+
for (auto& it : PKinematicsAnimated(V)->LL_Motions(k))
364332
{
365-
bool bFound = false;
366-
for (ChooseItemVecIt it = items.begin(); it != items.end(); it++)
367-
if (it->name == _I->first)
333+
bool found = false;
334+
for (auto& it2 : items)
335+
{
336+
if (it2.name == it.first)
368337
{
369-
bFound = true;
338+
found = true;
370339
break;
371340
}
372-
if (!bFound)
373-
items.push_back(SChooseItem(*_I->first, ""));
341+
}
342+
if (!found)
343+
items.push_back(SChooseItem(it.first.c_str(), ""));
374344
}
375345
}
376346
}
377-
::Render->model_Delete(V);
347+
GEnv.Render->model_Delete(V);
378348
}
379349

380350
void __stdcall FillSkeletonBones(ChooseItemVec& items, void* param)
381351
{
382-
IRenderVisual* V = ::Render->model_Create((LPCSTR)param);
352+
IRenderVisual* V = GEnv.Render->model_Create((LPCSTR)param);
383353
if (PKinematics(V))
384354
{
385-
CKinematicsAnimated::accel* ll_bones = PKinematics(V)->LL_Bones();
386-
CKinematicsAnimated::accel::iterator _I, _E;
387-
_I = ll_bones->begin();
388-
_E = ll_bones->end();
389-
for (; _I != _E; ++_I)
390-
items.push_back(SChooseItem(*_I->first, ""));
355+
for (auto& it : *PKinematics(V)->LL_Bones())
356+
items.push_back(SChooseItem(it.first.c_str(), ""));
391357
}
392-
::Render->model_Delete(V);
358+
GEnv.Render->model_Delete(V);
393359
}
394360

395361
void __stdcall FillSkeletonBonesObject(ChooseItemVec& items, void* param)
396362
{
397363
CEditableObject* eo = (CEditableObject*)param;
398364

399-
BoneIt _I = eo->FirstBone();
400-
BoneIt _E = eo->LastBone();
365+
auto _I = eo->FirstBone();
366+
auto _E = eo->LastBone();
401367
for (; _I != _E; ++_I)
402368
{
403369
items.push_back(SChooseItem((*_I)->Name().c_str(), ""));

0 commit comments

Comments
 (0)