Skip to content

Commit

Permalink
Replace DEFINE_* macro with inplace type alias (Part 1)
Browse files Browse the repository at this point in the history
Thank to Im-Dex.
From commit:
Im-dex/xray-162@9107297
  • Loading branch information
Xottab-DUTY committed Aug 10, 2017
1 parent 9b82b37 commit ece7b6f
Show file tree
Hide file tree
Showing 103 changed files with 536 additions and 499 deletions.
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ColorMapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void ColorMapManager::UpdateTexture(const shared_str& strTexName, int iTex)

if (strTexName.size())
{
map_TexIt I = m_TexCache.find(strTexName);
auto I = m_TexCache.find(strTexName);
if (I != m_TexCache.end())
{
ID3DBaseTexture* e0 = I->second->surface_get();
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ColorMapManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ColorMapManager
bool operator()(const shared_str& x, const shared_str& y) const { return x < y; }
};

DEFINE_MAP_PRED(shared_str, ref_texture, map_Tex, map_TexIt, str_pred);
using map_Tex = xr_map<shared_str, ref_texture, str_pred>;

ref_texture m_CMap[2];
shared_str m_strCMap[2];
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/D3DUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static const WORD identboxindiceswire[identboxindexwirecount] = {

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

DEFINE_VECTOR(FVF::L, FLvertexVec, FLvertexIt)
using FLvertexVec = xr_vector<FVF::L>;

static FLvertexVec m_GridPoints;

Expand Down Expand Up @@ -1381,7 +1381,7 @@ void CDrawUtilities::DrawGrid()
u32 vBase;
// fill VB
FVF::L* pv = (FVF::L*)Stream->Lock(m_GridPoints.size(), vs_L->vb_stride, vBase);
for (FLvertexIt v_it = m_GridPoints.begin(); v_it != m_GridPoints.end(); v_it++, pv++)
for (auto v_it = m_GridPoints.begin(); v_it != m_GridPoints.end(); v_it++, pv++)
pv->set(*v_it);
Stream->Unlock(m_GridPoints.size(), vs_L->vb_stride);
// Render it as triangle list
Expand Down
4 changes: 3 additions & 1 deletion src/Layers/xrRender/DetailManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class ECORE_API CDetailManager
Fvector c_rgb;
#endif
};
DEFINE_VECTOR(SlotItem*, SlotItemVec, SlotItemVecIt);

using SlotItemVec = xr_vector<SlotItem*>;

struct SlotPart
{ //
u32 id; // ID модельки
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/DetailManager_VS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ void CDetailManager::hw_Render_dump(ref_constant x_array, u32 var_id, u32 lod_id
for (; _vI != _vE; _vI++)
{
SlotItemVec* items = *_vI;
SlotItemVecIt _iI = items->begin();
SlotItemVecIt _iE = items->end();
auto _iI = items->begin();
auto _iE = items->end();
for (; _iI != _iE; _iI++)
{
SlotItem& Instance = **_iI;
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRender/FSkinned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ void CSkeletonX_ext::_FillVerticesHW4W(const Fmatrix& view, CSkeletonWallmark& w
{
vertHW_1W* vertices;
CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY));
for (CBoneData::FacesVecIt it = faces.begin(); it != faces.end(); it++)
for (auto it = faces.begin(); it != faces.end(); it++)
{
Fvector p[3];
u32 idx = (*it) * 3;
Expand Down Expand Up @@ -1188,7 +1188,7 @@ void CSkeletonX_ext::_FillVerticesHW4W(const Fmatrix& view, CSkeletonWallmark& w
vertHW_2W* vertices;
CHK_DX(V->p_rm_Vertices->Lock(V->vBase, V->vCount, (void**)&vertices, D3DLOCK_READONLY));

for (CBoneData::FacesVecIt it = faces.begin(); it != faces.end(); ++it)
for (auto it = faces.begin(); it != faces.end(); ++it)
{
Fvector p[3];
u32 idx = (*it) * 3;
Expand Down Expand Up @@ -1362,7 +1362,7 @@ template <typename vertex_buffer_type>
void TEnumBoneVertices(
vertex_buffer_type vertices, u16* indices, CBoneData::FacesVec& faces, SEnumVerticesCallback& C)
{
for (CBoneData::FacesVecIt it = faces.begin(); it != faces.end(); it++)
for (auto it = faces.begin(); it != faces.end(); it++)
{
u32 idx = (*it) * 3;
for (u32 k = 0; k < 3; k++)
Expand Down
7 changes: 5 additions & 2 deletions src/Layers/xrRender/PSLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
namespace PS
{
class CPEDef;
DEFINE_VECTOR(CPEDef*, PEDVec, PEDIt);
using PEDVec = xr_vector<CPEDef*>;
using PEDIt = PEDVec::iterator;

class CPGDef;
DEFINE_VECTOR(CPGDef*, PGDVec, PGDIt);
using PGDVec = xr_vector<CPGDef*>;
using PGDIt = PGDVec::iterator;

} // namespace PS

class ECORE_API CPSLibrary : public particles_systems::library_interface
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ParticleEffectDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct Particle;
struct ParticleEffect;
struct PAHeader;
struct ParticleAction;
DEFINE_VECTOR(ParticleAction*, PAVec, PAVecIt);
using PAVec = xr_vector<ParticleAction*>;
}
struct EParticleAction;

Expand Down
57 changes: 28 additions & 29 deletions src/Layers/xrRender/ParticleGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CPGDef::CPGDef()

CPGDef::~CPGDef()
{
for (EffectIt it = m_Effects.begin(); it != m_Effects.end(); it++)
for (auto it = m_Effects.begin(); it != m_Effects.end(); it++)
xr_delete(*it);
m_Effects.clear();
}
Expand Down Expand Up @@ -70,7 +70,7 @@ BOOL CPGDef::Load(IReader& F)
if (F.find_chunk(PGD_CHUNK_EFFECTS))
{
m_Effects.resize(F.r_u32());
for (EffectIt it = m_Effects.begin(); it != m_Effects.end(); it++)
for (auto it = m_Effects.begin(); it != m_Effects.end(); it++)
{
*it = new SEffect();
F.r_stringZ((*it)->m_EffectName);
Expand All @@ -97,7 +97,7 @@ BOOL CPGDef::Load2(CInifile& ini)

u32 counter = 0;
string256 buff;
for (EffectIt it = m_Effects.begin(); it != m_Effects.end(); ++it, ++counter)
for (auto it = m_Effects.begin(); it != m_Effects.end(); ++it, ++counter)
{
*it = new SEffect();

Expand Down Expand Up @@ -130,7 +130,7 @@ void CPGDef::Save(IWriter& F)

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

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

Expand All @@ -183,7 +183,7 @@ void CParticleGroup::SItem::Clear()
{
VisualVec visuals;
GetVisuals(visuals);
for (VisualVecIt it = visuals.begin(); it != visuals.end(); it++)
for (auto it = visuals.begin(); it != visuals.end(); it++)
{
// GlobalEnv.Render->model_Delete(*it);
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
Expand Down Expand Up @@ -273,23 +273,23 @@ void CParticleGroup::SItem::Stop(BOOL def_stop)
CParticleEffect* E = static_cast<CParticleEffect*>(_effect);
if (E)
E->Stop(def_stop);
VisualVecIt it;
for (it = _children_related.begin(); it != _children_related.end(); it++)

for (auto it = _children_related.begin(); it != _children_related.end(); it++)
static_cast<CParticleEffect*>(*it)->Stop(def_stop);
for (it = _children_free.begin(); it != _children_free.end(); it++)
for (auto it = _children_free.begin(); it != _children_free.end(); it++)
static_cast<CParticleEffect*>(*it)->Stop(def_stop);

// and delete if !deffered
if (!def_stop)
{
for (it = _children_related.begin(); it != _children_related.end(); it++)
for (auto it = _children_related.begin(); it != _children_related.end(); it++)
{
// GlobalEnv.Render->model_Delete(*it);
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
GlobalEnv.Render->model_Delete(pVisual);
*it = nullptr;
}
for (it = _children_free.begin(); it != _children_free.end(); it++)
for (auto it = _children_free.begin(); it != _children_free.end(); it++)
{
// GlobalEnv.Render->model_Delete(*it);
IRenderVisual* pVisual = smart_cast<IRenderVisual*>(*it);
Expand Down Expand Up @@ -384,10 +384,10 @@ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox&
}
}
}
VisualVecIt it;

if (!_children_related.empty())
{
for (it = _children_related.begin(); it != _children_related.end(); it++)
for (auto it = _children_related.begin(); it != _children_related.end(); it++)
{
CParticleEffect* E = static_cast<CParticleEffect*>(*it);
if (E)
Expand All @@ -412,7 +412,7 @@ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox&
if (!_children_free.empty())
{
u32 rem_cnt = 0;
for (it = _children_free.begin(); it != _children_free.end(); it++)
for (auto it = _children_free.begin(); it != _children_free.end(); it++)
{
CParticleEffect* E = static_cast<CParticleEffect*>(*it);
if (E)
Expand All @@ -437,7 +437,7 @@ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox&
// remove if stopped
if (rem_cnt)
{
VisualVecIt new_end = std::remove_if(_children_free.begin(), _children_free.end(), zero_vis_pred());
auto new_end = std::remove_if(_children_free.begin(), _children_free.end(), zero_vis_pred());
_children_free.erase(new_end, _children_free.end());
}
}
Expand All @@ -447,22 +447,22 @@ void CParticleGroup::SItem::OnDeviceCreate()
{
VisualVec visuals;
GetVisuals(visuals);
for (VisualVecIt it = visuals.begin(); it != visuals.end(); it++)
for (auto it = visuals.begin(); it != visuals.end(); it++)
static_cast<CParticleEffect*>(*it)->OnDeviceCreate();
}
void CParticleGroup::SItem::OnDeviceDestroy()
{
VisualVec visuals;
GetVisuals(visuals);
for (VisualVecIt it = visuals.begin(); it != visuals.end(); it++)
for (auto it = visuals.begin(); it != visuals.end(); it++)
static_cast<CParticleEffect*>(*it)->OnDeviceDestroy();
}
u32 CParticleGroup::SItem::ParticlesCount()
{
u32 p_count = 0;
VisualVec visuals;
GetVisuals(visuals);
for (VisualVecIt it = visuals.begin(); it != visuals.end(); it++)
for (auto it = visuals.begin(); it != visuals.end(); it++)
p_count += static_cast<CParticleEffect*>(*it)->ParticlesCount();
return p_count;
}
Expand All @@ -478,7 +478,7 @@ CParticleGroup::CParticleGroup()

CParticleGroup::~CParticleGroup()
{
// Msg ("!!! destoy PG");
// Msg ("!!! destroy PG");
for (u32 i = 0; i < items.size(); i++)
items[i].Clear();
items.clear();
Expand Down Expand Up @@ -517,7 +517,7 @@ void CParticleGroup::OnFrame(u32 u_dt)
bool bPlaying = false;
Fbox box;
box.invalidate();
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
i_it->OnFrame(u_dt, *m_Def->m_Effects[i_it - items.begin()], box, bPlaying);

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

BOOL CParticleGroup::Compile(CPGDef* def)
{
m_Def = def;
// destroy existing
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
i_it->Clear();
items.clear();
// create new
Expand Down Expand Up @@ -583,33 +583,33 @@ void CParticleGroup::Stop(BOOL bDefferedStop)
{
m_RT_Flags.set(flRT_Playing, FALSE);
}
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
i_it->Stop(bDefferedStop);
}

void CParticleGroup::OnDeviceCreate()
{
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
i_it->OnDeviceCreate();
}

void CParticleGroup::OnDeviceDestroy()
{
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
i_it->OnDeviceDestroy();
}

u32 CParticleGroup::ParticlesCount()
{
int p_count = 0;
for (SItemVecIt i_it = items.begin(); i_it != items.end(); i_it++)
for (auto i_it = items.begin(); i_it != items.end(); i_it++)
p_count += i_it->ParticlesCount();
return p_count;
}

void CParticleGroup::SetHudMode(BOOL b)
{
for (SItemVecIt i_it = items.begin(); i_it != items.end(); ++i_it)
for (auto i_it = items.begin(); i_it != items.end(); ++i_it)
{
CParticleEffect* E = static_cast<CParticleEffect*>(i_it->_effect);
E->SetHudMode(b);
Expand All @@ -623,6 +623,5 @@ BOOL CParticleGroup::GetHudMode()
CParticleEffect* E = static_cast<CParticleEffect*>(items[0]._effect);
return E->GetHudMode();
}
else
return FALSE;
return false;
}
7 changes: 4 additions & 3 deletions src/Layers/xrRender/ParticleGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class ECORE_API CPGDef
BOOL Equal(const SEffect&);
#endif
};
DEFINE_VECTOR(SEffect*, EffectVec, EffectIt);

using EffectVec = xr_vector<SEffect*>;
EffectVec m_Effects;
#ifdef _EDITOR
// change Equal if variables changed
Expand Down Expand Up @@ -78,7 +79,7 @@ class ECORE_API CParticleGroup : public dxParticleCustom
Fvector m_InitialPosition;

public:
DEFINE_VECTOR(dxRender_Visual*, VisualVec, VisualVecIt);
using VisualVec = xr_vector<dxRender_Visual*>;
struct SItem
{
dxRender_Visual* _effect;
Expand Down Expand Up @@ -113,7 +114,7 @@ class ECORE_API CParticleGroup : public dxParticleCustom
void Play();
void Stop(BOOL def_stop);
};
DEFINE_VECTOR(SItem, SItemVec, SItemVecIt)
using SItemVec = xr_vector<SItem>;
SItemVec items;

public:
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void CResourceManager::DeferredUpload()
{
if (!RDEVICE.b_is_Ready)
return;
for (map_TextureIt t = m_textures.begin(); t != m_textures.end(); t++)
for (auto t = m_textures.begin(); t != m_textures.end(); t++)
{
t->second->Load();
}
Expand All @@ -380,7 +380,7 @@ void CResourceManager::DeferredUpload()
void CResourceManager::DeferredUnload ()
{
if (!RDEVICE.b_is_Ready) return;
for (map_TextureIt t=m_textures.begin(); t!=m_textures.end(); t++)
for (auto t=m_textures.begin(); t!=m_textures.end(); t++)
t->second->Unload();
}
*/
Expand Down
Loading

0 comments on commit ece7b6f

Please sign in to comment.