Skip to content

Commit ece7b6f

Browse files
committed
Replace DEFINE_* macro with inplace type alias (Part 1)
Thank to Im-Dex. From commit: Im-dex/xray-162@9107297
1 parent 9b82b37 commit ece7b6f

File tree

103 files changed

+536
-499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+536
-499
lines changed

src/Layers/xrRender/ColorMapManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void ColorMapManager::UpdateTexture(const shared_str& strTexName, int iTex)
2222

2323
if (strTexName.size())
2424
{
25-
map_TexIt I = m_TexCache.find(strTexName);
25+
auto I = m_TexCache.find(strTexName);
2626
if (I != m_TexCache.end())
2727
{
2828
ID3DBaseTexture* e0 = I->second->surface_get();

src/Layers/xrRender/ColorMapManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ColorMapManager
2121
bool operator()(const shared_str& x, const shared_str& y) const { return x < y; }
2222
};
2323

24-
DEFINE_MAP_PRED(shared_str, ref_texture, map_Tex, map_TexIt, str_pred);
24+
using map_Tex = xr_map<shared_str, ref_texture, str_pred>;
2525

2626
ref_texture m_CMap[2];
2727
shared_str m_strCMap[2];

src/Layers/xrRender/D3DUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static const WORD identboxindiceswire[identboxindexwirecount] = {
9797

9898
#define SIGN(x) ((x < 0) ? -1 : 1)
9999

100-
DEFINE_VECTOR(FVF::L, FLvertexVec, FLvertexIt)
100+
using FLvertexVec = xr_vector<FVF::L>;
101101

102102
static FLvertexVec m_GridPoints;
103103

@@ -1381,7 +1381,7 @@ void CDrawUtilities::DrawGrid()
13811381
u32 vBase;
13821382
// fill VB
13831383
FVF::L* pv = (FVF::L*)Stream->Lock(m_GridPoints.size(), vs_L->vb_stride, vBase);
1384-
for (FLvertexIt v_it = m_GridPoints.begin(); v_it != m_GridPoints.end(); v_it++, pv++)
1384+
for (auto v_it = m_GridPoints.begin(); v_it != m_GridPoints.end(); v_it++, pv++)
13851385
pv->set(*v_it);
13861386
Stream->Unlock(m_GridPoints.size(), vs_L->vb_stride);
13871387
// Render it as triangle list

src/Layers/xrRender/DetailManager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class ECORE_API CDetailManager
4949
Fvector c_rgb;
5050
#endif
5151
};
52-
DEFINE_VECTOR(SlotItem*, SlotItemVec, SlotItemVecIt);
52+
53+
using SlotItemVec = xr_vector<SlotItem*>;
54+
5355
struct SlotPart
5456
{ //
5557
u32 id; // ID модельки

src/Layers/xrRender/DetailManager_VS.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ void CDetailManager::hw_Render_dump(ref_constant x_array, u32 var_id, u32 lod_id
266266
for (; _vI != _vE; _vI++)
267267
{
268268
SlotItemVec* items = *_vI;
269-
SlotItemVecIt _iI = items->begin();
270-
SlotItemVecIt _iE = items->end();
269+
auto _iI = items->begin();
270+
auto _iE = items->end();
271271
for (; _iI != _iE; _iI++)
272272
{
273273
SlotItem& Instance = **_iI;

src/Layers/xrRender/FSkinned.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ void CSkeletonX_ext::_FillVerticesHW4W(const Fmatrix& view, CSkeletonWallmark& w
11471147
{
11481148
vertHW_1W* vertices;
11491149
CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY));
1150-
for (CBoneData::FacesVecIt it = faces.begin(); it != faces.end(); it++)
1150+
for (auto it = faces.begin(); it != faces.end(); it++)
11511151
{
11521152
Fvector p[3];
11531153
u32 idx = (*it) * 3;
@@ -1188,7 +1188,7 @@ void CSkeletonX_ext::_FillVerticesHW4W(const Fmatrix& view, CSkeletonWallmark& w
11881188
vertHW_2W* vertices;
11891189
CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY));
11901190

1191-
for (CBoneData::FacesVecIt it = faces.begin(); it != faces.end(); ++it)
1191+
for (auto it = faces.begin(); it != faces.end(); ++it)
11921192
{
11931193
Fvector p[3];
11941194
u32 idx = (*it) * 3;
@@ -1362,7 +1362,7 @@ template <typename vertex_buffer_type>
13621362
void TEnumBoneVertices(
13631363
vertex_buffer_type vertices, u16* indices, CBoneData::FacesVec& faces, SEnumVerticesCallback& C)
13641364
{
1365-
for (CBoneData::FacesVecIt it = faces.begin(); it != faces.end(); it++)
1365+
for (auto it = faces.begin(); it != faces.end(); it++)
13661366
{
13671367
u32 idx = (*it) * 3;
13681368
for (u32 k = 0; k < 3; k++)

src/Layers/xrRender/PSLibrary.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
namespace PS
1010
{
1111
class CPEDef;
12-
DEFINE_VECTOR(CPEDef*, PEDVec, PEDIt);
12+
using PEDVec = xr_vector<CPEDef*>;
13+
using PEDIt = PEDVec::iterator;
1314

1415
class CPGDef;
15-
DEFINE_VECTOR(CPGDef*, PGDVec, PGDIt);
16+
using PGDVec = xr_vector<CPGDef*>;
17+
using PGDIt = PGDVec::iterator;
18+
1619
} // namespace PS
1720

1821
class ECORE_API CPSLibrary : public particles_systems::library_interface

src/Layers/xrRender/ParticleEffectDef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct Particle;
1010
struct ParticleEffect;
1111
struct PAHeader;
1212
struct ParticleAction;
13-
DEFINE_VECTOR(ParticleAction*, PAVec, PAVecIt);
13+
using PAVec = xr_vector<ParticleAction*>;
1414
}
1515
struct EParticleAction;
1616

src/Layers/xrRender/ParticleGroup.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CPGDef::CPGDef()
2222

2323
CPGDef::~CPGDef()
2424
{
25-
for (EffectIt it = m_Effects.begin(); it != m_Effects.end(); it++)
25+
for (auto it = m_Effects.begin(); it != m_Effects.end(); it++)
2626
xr_delete(*it);
2727
m_Effects.clear();
2828
}
@@ -70,7 +70,7 @@ BOOL CPGDef::Load(IReader& F)
7070
if (F.find_chunk(PGD_CHUNK_EFFECTS))
7171
{
7272
m_Effects.resize(F.r_u32());
73-
for (EffectIt it = m_Effects.begin(); it != m_Effects.end(); it++)
73+
for (auto it = m_Effects.begin(); it != m_Effects.end(); it++)
7474
{
7575
*it = new SEffect();
7676
F.r_stringZ((*it)->m_EffectName);
@@ -97,7 +97,7 @@ BOOL CPGDef::Load2(CInifile& ini)
9797

9898
u32 counter = 0;
9999
string256 buff;
100-
for (EffectIt it = m_Effects.begin(); it != m_Effects.end(); ++it, ++counter)
100+
for (auto it = m_Effects.begin(); it != m_Effects.end(); ++it, ++counter)
101101
{
102102
*it = new SEffect();
103103

@@ -130,7 +130,7 @@ void CPGDef::Save(IWriter& F)
130130

131131
F.open_chunk(PGD_CHUNK_EFFECTS);
132132
F.w_u32(m_Effects.size());
133-
for (EffectIt it = m_Effects.begin(); it != m_Effects.end(); it++)
133+
for (auto it = m_Effects.begin(); it != m_Effects.end(); it++)
134134
{
135135
F.w_stringZ((*it)->m_EffectName);
136136
F.w_stringZ((*it)->m_OnPlayChildName);
@@ -157,7 +157,7 @@ void CPGDef::Save2(CInifile& ini)
157157

158158
u32 counter = 0;
159159
string256 buff;
160-
for (EffectIt it = m_Effects.begin(); it != m_Effects.end(); ++it, ++counter)
160+
for (auto it = m_Effects.begin(); it != m_Effects.end(); ++it, ++counter)
161161
{
162162
xr_sprintf(buff, sizeof(buff), "effect_%04d", counter);
163163

@@ -183,7 +183,7 @@ void CParticleGroup::SItem::Clear()
183183
{
184184
VisualVec visuals;
185185
GetVisuals(visuals);
186-
for (VisualVecIt it = visuals.begin(); it != visuals.end(); it++)
186+
for (auto it = visuals.begin(); it != visuals.end(); it++)
187187
{
188188
// GlobalEnv.Render->model_Delete(*it);
189189
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
@@ -273,23 +273,23 @@ void CParticleGroup::SItem::Stop(BOOL def_stop)
273273
CParticleEffect* E = static_cast<CParticleEffect*>(_effect);
274274
if (E)
275275
E->Stop(def_stop);
276-
VisualVecIt it;
277-
for (it = _children_related.begin(); it != _children_related.end(); it++)
276+
277+
for (auto it = _children_related.begin(); it != _children_related.end(); it++)
278278
static_cast<CParticleEffect*>(*it)->Stop(def_stop);
279-
for (it = _children_free.begin(); it != _children_free.end(); it++)
279+
for (auto it = _children_free.begin(); it != _children_free.end(); it++)
280280
static_cast<CParticleEffect*>(*it)->Stop(def_stop);
281281

282282
// and delete if !deffered
283283
if (!def_stop)
284284
{
285-
for (it = _children_related.begin(); it != _children_related.end(); it++)
285+
for (auto it = _children_related.begin(); it != _children_related.end(); it++)
286286
{
287287
// GlobalEnv.Render->model_Delete(*it);
288288
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
289289
GlobalEnv.Render->model_Delete(pVisual);
290290
*it = nullptr;
291291
}
292-
for (it = _children_free.begin(); it != _children_free.end(); it++)
292+
for (auto it = _children_free.begin(); it != _children_free.end(); it++)
293293
{
294294
// GlobalEnv.Render->model_Delete(*it);
295295
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
@@ -384,10 +384,10 @@ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox&
384384
}
385385
}
386386
}
387-
VisualVecIt it;
387+
388388
if (!_children_related.empty())
389389
{
390-
for (it = _children_related.begin(); it != _children_related.end(); it++)
390+
for (auto it = _children_related.begin(); it != _children_related.end(); it++)
391391
{
392392
CParticleEffect* E = static_cast<CParticleEffect*>(*it);
393393
if (E)
@@ -412,7 +412,7 @@ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox&
412412
if (!_children_free.empty())
413413
{
414414
u32 rem_cnt = 0;
415-
for (it = _children_free.begin(); it != _children_free.end(); it++)
415+
for (auto it = _children_free.begin(); it != _children_free.end(); it++)
416416
{
417417
CParticleEffect* E = static_cast<CParticleEffect*>(*it);
418418
if (E)
@@ -437,7 +437,7 @@ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox&
437437
// remove if stopped
438438
if (rem_cnt)
439439
{
440-
VisualVecIt new_end = std::remove_if(_children_free.begin(), _children_free.end(), zero_vis_pred());
440+
auto new_end = std::remove_if(_children_free.begin(), _children_free.end(), zero_vis_pred());
441441
_children_free.erase(new_end, _children_free.end());
442442
}
443443
}
@@ -447,22 +447,22 @@ void CParticleGroup::SItem::OnDeviceCreate()
447447
{
448448
VisualVec visuals;
449449
GetVisuals(visuals);
450-
for (VisualVecIt it = visuals.begin(); it != visuals.end(); it++)
450+
for (auto it = visuals.begin(); it != visuals.end(); it++)
451451
static_cast<CParticleEffect*>(*it)->OnDeviceCreate();
452452
}
453453
void CParticleGroup::SItem::OnDeviceDestroy()
454454
{
455455
VisualVec visuals;
456456
GetVisuals(visuals);
457-
for (VisualVecIt it = visuals.begin(); it != visuals.end(); it++)
457+
for (auto it = visuals.begin(); it != visuals.end(); it++)
458458
static_cast<CParticleEffect*>(*it)->OnDeviceDestroy();
459459
}
460460
u32 CParticleGroup::SItem::ParticlesCount()
461461
{
462462
u32 p_count = 0;
463463
VisualVec visuals;
464464
GetVisuals(visuals);
465-
for (VisualVecIt it = visuals.begin(); it != visuals.end(); it++)
465+
for (auto it = visuals.begin(); it != visuals.end(); it++)
466466
p_count += static_cast<CParticleEffect*>(*it)->ParticlesCount();
467467
return p_count;
468468
}
@@ -478,7 +478,7 @@ CParticleGroup::CParticleGroup()
478478

479479
CParticleGroup::~CParticleGroup()
480480
{
481-
// Msg ("!!! destoy PG");
481+
// Msg ("!!! destroy PG");
482482
for (u32 i = 0; i < items.size(); i++)
483483
items[i].Clear();
484484
items.clear();
@@ -517,7 +517,7 @@ void CParticleGroup::OnFrame(u32 u_dt)
517517
bool bPlaying = false;
518518
Fbox box;
519519
box.invalidate();
520-
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
520+
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
521521
i_it->OnFrame(u_dt, *m_Def->m_Effects[i_it - items.begin()], box, bPlaying);
522522

523523
if (m_RT_Flags.is(flRT_DefferedStop) && !bPlaying)
@@ -541,15 +541,15 @@ void CParticleGroup::OnFrame(u32 u_dt)
541541
void CParticleGroup::UpdateParent(const Fmatrix& m, const Fvector& velocity, BOOL bXFORM)
542542
{
543543
m_InitialPosition = m.c;
544-
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
544+
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
545545
i_it->UpdateParent(m, velocity, bXFORM);
546546
}
547547

548548
BOOL CParticleGroup::Compile(CPGDef* def)
549549
{
550550
m_Def = def;
551551
// destroy existing
552-
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
552+
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
553553
i_it->Clear();
554554
items.clear();
555555
// create new
@@ -583,33 +583,33 @@ void CParticleGroup::Stop(BOOL bDefferedStop)
583583
{
584584
m_RT_Flags.set(flRT_Playing, FALSE);
585585
}
586-
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
586+
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
587587
i_it->Stop(bDefferedStop);
588588
}
589589

590590
void CParticleGroup::OnDeviceCreate()
591591
{
592-
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
592+
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
593593
i_it->OnDeviceCreate();
594594
}
595595

596596
void CParticleGroup::OnDeviceDestroy()
597597
{
598-
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
598+
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
599599
i_it->OnDeviceDestroy();
600600
}
601601

602602
u32 CParticleGroup::ParticlesCount()
603603
{
604604
int p_count = 0;
605-
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
605+
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
606606
p_count += i_it->ParticlesCount();
607607
return p_count;
608608
}
609609

610610
void CParticleGroup::SetHudMode(BOOL b)
611611
{
612-
for (SItemVecIt i_it = items.begin(); i_it != items.end(); ++i_it)
612+
for (auto i_it = items.begin(); i_it != items.end(); ++i_it)
613613
{
614614
CParticleEffect* E = static_cast<CParticleEffect*>(i_it->_effect);
615615
E->SetHudMode(b);
@@ -623,6 +623,5 @@ BOOL CParticleGroup::GetHudMode()
623623
CParticleEffect* E = static_cast<CParticleEffect*>(items[0]._effect);
624624
return E->GetHudMode();
625625
}
626-
else
627-
return FALSE;
626+
return false;
628627
}

src/Layers/xrRender/ParticleGroup.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class ECORE_API CPGDef
4242
BOOL Equal(const SEffect&);
4343
#endif
4444
};
45-
DEFINE_VECTOR(SEffect*, EffectVec, EffectIt);
45+
46+
using EffectVec = xr_vector<SEffect*>;
4647
EffectVec m_Effects;
4748
#ifdef _EDITOR
4849
// change Equal if variables changed
@@ -78,7 +79,7 @@ class ECORE_API CParticleGroup : public dxParticleCustom
7879
Fvector m_InitialPosition;
7980

8081
public:
81-
DEFINE_VECTOR(dxRender_Visual*, VisualVec, VisualVecIt);
82+
using VisualVec = xr_vector<dxRender_Visual*>;
8283
struct SItem
8384
{
8485
dxRender_Visual* _effect;
@@ -113,7 +114,7 @@ class ECORE_API CParticleGroup : public dxParticleCustom
113114
void Play();
114115
void Stop(BOOL def_stop);
115116
};
116-
DEFINE_VECTOR(SItem, SItemVec, SItemVecIt)
117+
using SItemVec = xr_vector<SItem>;
117118
SItemVec items;
118119

119120
public:

0 commit comments

Comments
 (0)