Skip to content

Commit

Permalink
Replace DEFINE_* macro with inplace type alias (Part 2)
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 ece7b6f commit 892f9ff
Show file tree
Hide file tree
Showing 40 changed files with 325 additions and 369 deletions.
2 changes: 1 addition & 1 deletion src/xrAICore/Navigation/game_graph_space.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ struct STerrainPlace
svector<_LOCATION_ID, LOCATION_TYPE_COUNT> tMask;
};

DEFINE_VECTOR(STerrainPlace, TERRAIN_VECTOR, TERRAIN_IT);
using TERRAIN_VECTOR = xr_vector<STerrainPlace>;
}
4 changes: 2 additions & 2 deletions src/xrEngine/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ void CStats::OnRender()
{
CSound_stats_ext snd_stat_ext;
::Sound->statistic(0, &snd_stat_ext);
CSound_stats_ext::item_vec_it _I = snd_stat_ext.items.begin();
CSound_stats_ext::item_vec_it _E = snd_stat_ext.items.end();
auto _I = snd_stat_ext.items.begin();
auto _E = snd_stat_ext.items.end();
for (; _I != _E; _I++)
{
const CSound_stats_ext::SItem& item = *_I;
Expand Down
4 changes: 2 additions & 2 deletions src/xrEngine/editor_environment_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ void manager::load_weathers()
m_weathers->load();

// sorting weather envs
EnvsMapIt _I = WeatherCycles.begin();
EnvsMapIt _E = WeatherCycles.end();
auto _I = WeatherCycles.begin();
auto _E = WeatherCycles.end();
for (; _I != _E; _I++)
{
R_ASSERT3(_I->second.size() > 1, "Environment in weather must >=2", *_I->first);
Expand Down
6 changes: 3 additions & 3 deletions src/xrEngine/xr_collide_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void CCF_Skeleton::SElement::center(Fvector& center) const
bool pred_find_elem(const CCF_Skeleton::SElement& E, u16 elem) { return E.elem_id < elem; }
bool CCF_Skeleton::_ElementCenter(u16 elem_id, Fvector& e_center)
{
ElementVecIt it = std::lower_bound(elements.begin(), elements.end(), elem_id, pred_find_elem);
auto it = std::lower_bound(elements.begin(), elements.end(), elem_id, pred_find_elem);
if (it->elem_id == elem_id)
{
it->center(e_center);
Expand Down Expand Up @@ -132,7 +132,7 @@ void CCF_Skeleton::BuildState()
}
}

for (ElementVecIt I = elements.begin(); I != elements.end(); I++)
for (auto I = elements.begin(); I != elements.end(); I++)
{
if (!I->valid())
continue;
Expand Down Expand Up @@ -241,7 +241,7 @@ BOOL CCF_Skeleton::_RayQuery(const collide::ray_defs& Q, collide::rq_results& R)
}

BOOL bHIT = FALSE;
for (ElementVecIt I = elements.begin(); I != elements.end(); I++)
for (auto I = elements.begin(); I != elements.end(); I++)
{
if (!I->valid())
continue;
Expand Down
6 changes: 1 addition & 5 deletions src/xrEngine/xr_collide_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class ENGINE_API ICollisionForm
IGameObject* owner; // владелец
u32 dwQueryID;

protected:
Fbox bv_box; // (Local) BBox объекта
Fsphere bv_sphere; // (Local) Sphere
private:
Expand Down Expand Up @@ -134,13 +133,12 @@ class ENGINE_API CCF_Skeleton : public ICollisionForm
u16 type;
u16 elem_id;

public:
SElement() : elem_id(u16(-1)), type(0) {}
SElement(u16 id, u16 t) : elem_id(id), type(t) {}
BOOL valid() const { return (elem_id != (u16(-1))) && (type != 0); }
void center(Fvector& center) const;
};
DEFINE_VECTOR(SElement, ElementVec, ElementVecIt);
using ElementVec = xr_vector<SElement>;

private:
u64 vis_mask;
Expand Down Expand Up @@ -169,7 +167,6 @@ class ENGINE_API CCF_Skeleton : public ICollisionForm

class ENGINE_API CCF_EventBox : public ICollisionForm
{
private:
Fplane Planes[6];

public:
Expand Down Expand Up @@ -200,7 +197,6 @@ class ENGINE_API CCF_Shape : public ICollisionForm
};
xr_vector<shape_def> shapes;

public:
CCF_Shape(IGameObject* _owner);

virtual BOOL _RayQuery(const collide::ray_defs& Q, collide::rq_results& R);
Expand Down
16 changes: 8 additions & 8 deletions src/xrEngine/xr_efflensflare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ void CLensFlareDescriptor::OnDeviceCreate()
// shaders
m_Gradient.m_pRender->CreateShader(*m_Gradient.shader, *m_Gradient.texture);
m_Source.m_pRender->CreateShader(*m_Source.shader, *m_Source.texture);
for (FlareIt it = m_Flares.begin(); it != m_Flares.end(); it++)
for (auto it = m_Flares.begin(); it != m_Flares.end(); it++)
it->m_pRender->CreateShader(*it->shader, *it->texture);
/*
m_Gradient.hShader = CreateShader (*m_Gradient.texture,*m_Gradient.shader);
m_Source.hShader = CreateShader (*m_Source.texture,*m_Source.shader);
for (FlareIt it=m_Flares.begin(); it!=m_Flares.end(); it++) it->hShader = CreateShader(*it->texture,*it->shader);
for (auto it=m_Flares.begin(); it!=m_Flares.end(); it++) it->hShader = CreateShader(*it->texture,*it->shader);
*/
}

Expand All @@ -134,12 +134,12 @@ void CLensFlareDescriptor::OnDeviceDestroy()
// shaders
m_Gradient.m_pRender->DestroyShader();
m_Source.m_pRender->DestroyShader();
for (FlareIt it = m_Flares.begin(); it != m_Flares.end(); it++)
for (auto it = m_Flares.begin(); it != m_Flares.end(); it++)
it->m_pRender->DestroyShader();
/*
m_Gradient.hShader.destroy ();
m_Source.hShader.destroy ();
for (FlareIt it=m_Flares.begin(); it!=m_Flares.end(); it++) it->hShader.destroy();
for (auto it=m_Flares.begin(); it!=m_Flares.end(); it++) it->hShader.destroy();
*/
}

Expand Down Expand Up @@ -552,7 +552,7 @@ void CLensFlare::Render(BOOL bSun, BOOL bFlares, BOOL bGradient)
vecDx.normalize (vecAxis);
vecDy.crossproduct (vecDx, vecDir);
if (m_Current->m_Flags.is(CLensFlareDescriptor::flFlare)){
for (CLensFlareDescriptor::FlareIt it=m_Current->m_Flares.begin(); it!=m_Current->m_Flares.end(); it++){
for (CLensFlareDescriptor::auto it=m_Current->m_Flares.begin(); it!=m_Current->m_Flares.end(); it++){
CLensFlareDescriptor::SFlare& F = *it;
vec.mul (vecAxis, F.fPosition);
vec.add (vecCenter);
Expand Down Expand Up @@ -608,7 +608,7 @@ shared_str CLensFlare::AppendDef(CEnvironment& environment, CInifile* pIni, LPCS
{
if (!sect || (0 == sect[0]))
return "";
for (LensFlareDescIt it = m_Palette.begin(); it != m_Palette.end(); it++)
for (auto it = m_Palette.begin(); it != m_Palette.end(); it++)
if (0 == xr_strcmp(*(*it)->section, sect))
return sect;

Expand All @@ -623,14 +623,14 @@ void CLensFlare::OnDeviceCreate()
m_pRender->OnDeviceCreate();

// palette
for (LensFlareDescIt it = m_Palette.begin(); it != m_Palette.end(); it++)
for (auto it = m_Palette.begin(); it != m_Palette.end(); it++)
(*it)->OnDeviceCreate();
}

void CLensFlare::OnDeviceDestroy()
{
// palette
for (LensFlareDescIt it = m_Palette.begin(); it != m_Palette.end(); it++)
for (auto it = m_Palette.begin(); it != m_Palette.end(); it++)
(*it)->OnDeviceDestroy();

// VS
Expand Down
4 changes: 3 additions & 1 deletion src/xrEngine/xr_efflensflare.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ class ENGINE_API CLensFlareDescriptor
// ref_shader hShader;
SFlare() { fOpacity = fRadius = fPosition = 0; }
};

struct SSource : public SFlare
{
BOOL ignore_color;
};
DEFINE_VECTOR(SFlare, FlareVec, FlareIt);
using FlareVec = xr_vector<SFlare>;

FlareVec m_Flares;

enum
Expand Down
22 changes: 14 additions & 8 deletions src/xrParticles/particle_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ struct PARTICLES_API ParticleAction
virtual void Load(IReader& F) = 0;
virtual void Save(IWriter& F) = 0;
};
DEFINE_VECTOR(ParticleAction*, PAVec, PAVecIt);
using PAVec = xr_vector<ParticleAction*>;
using PAVecIt = PAVec::iterator;

class ParticleActions
{
PAVec actions;
Expand All @@ -34,23 +36,27 @@ class ParticleActions
m_bLocked = false;
}
~ParticleActions() { clear(); }
IC void clear()

void clear()
{
R_ASSERT(!m_bLocked);
for (PAVecIt it = actions.begin(); it != actions.end(); it++)
xr_delete(*it);
actions.clear();
}
IC void append(ParticleAction* pa)

void append(ParticleAction* pa)
{
R_ASSERT(!m_bLocked);
actions.push_back(pa);
}
IC bool empty() { return actions.empty(); }
IC PAVecIt begin() { return actions.begin(); }
IC PAVecIt end() { return actions.end(); }
IC int size() { return actions.size(); }
IC void resize(int cnt)

bool empty() { return actions.empty(); }
PAVecIt begin() { return actions.begin(); }
PAVecIt end() { return actions.end(); }
int size() { return actions.size(); }

void resize(int cnt)
{
R_ASSERT(!m_bLocked);
actions.resize(cnt);
Expand Down
4 changes: 2 additions & 2 deletions src/xrParticles/particle_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class CParticleManager : public IParticleManager
{
// These are static because all threads access the same effects.
// All accesses to these should be locked.
DEFINE_VECTOR(ParticleEffect*, ParticleEffectVec, ParticleEffectVecIt);
DEFINE_VECTOR(ParticleActions*, ParticleActionsVec, ParticleActionsVecIt);
using ParticleEffectVec = xr_vector<ParticleEffect*>;
using ParticleActionsVec = xr_vector<ParticleActions*>;
ParticleEffectVec effect_vec;
ParticleActionsVec m_alist_vec;

Expand Down
4 changes: 3 additions & 1 deletion src/xrPhysics/PHActorCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ struct TPHCharacterRestrictor : public SPHCharacterRestrictor
}
}
};
DEFINE_VECTOR(SPHCharacterRestrictor*, RESRICTORS_V, RESTRICTOR_I);
using RESRICTORS_V = xr_vector<SPHCharacterRestrictor*>;
using RESTRICTOR_I = RESRICTORS_V::iterator;

// typedef SPHCharacterRestrictor* RESRICTORS_V[2];
// typedef SPHCharacterRestrictor** RESTRICTOR_I;
IC RESTRICTOR_I begin(RESRICTORS_V& v)
Expand Down
6 changes: 3 additions & 3 deletions src/xrPhysics/PHDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class CShellSplitInfo;

typedef std::pair<CPhysicsShell*, u16> shell_root;

DEFINE_VECTOR(CPHElement*, ELEMENT_STORAGE, ELEMENT_I)
using ELEMENT_STORAGE = xr_vector<CPHElement*>;
typedef xr_vector<CPHElement*>::const_iterator ELEMENT_CI;
DEFINE_VECTOR(CPHJoint*, JOINT_STORAGE, JOINT_I)
DEFINE_VECTOR(shell_root, PHSHELL_PAIR_VECTOR, SHELL_PAIR_I)
using JOINT_STORAGE = xr_vector<CPHJoint*>;
using PHSHELL_PAIR_VECTOR = xr_vector<shell_root>;
typedef xr_vector<shell_root>::reverse_iterator SHELL_PAIR_RI;

typedef xr_vector<CPHElement*>::reverse_iterator ELEMENT_RI;
Expand Down
4 changes: 2 additions & 2 deletions src/xrPhysics/PHFracture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CPHFracturesHolder::~CPHFracturesHolder()
}
void CPHFracturesHolder::ApplyImpactsToElement(CPHElement* E)
{
PH_IMPACT_I i = m_impacts.begin(), e = m_impacts.end();
auto i = m_impacts.begin(), e = m_impacts.end();
BOOL ac_state = E->isActive();
// E->bActive=true;
E->m_flags.set(CPHElement::flActive, TRUE);
Expand Down Expand Up @@ -423,7 +423,7 @@ bool CPHFracture::Update(CPHElement* element)
}
}

PH_IMPACT_I i_i = impacts.begin(), i_e = impacts.end();
auto i_i = impacts.begin(), i_e = impacts.end();
for (; i_i != i_e; i_i++)
{
u16 geom = i_i->geom;
Expand Down
21 changes: 11 additions & 10 deletions src/xrPhysics/PHFracture.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class CPHFracture;
class CPHElement;

DEFINE_VECTOR(dJointFeedback, CFEEDBACK_STORAGE, CFEEDBACK_I)
using CFEEDBACK_STORAGE = xr_vector<dJointFeedback>;

IC void sub_diapasones(u16& from1, u16& to1, const u16& from0, const u16& to0);

Expand All @@ -20,10 +20,11 @@ class CShellSplitInfo
friend class CPHFracturesHolder;
friend class CPHShellSplitterHolder;
friend class CPHElement;
IC bool HaveElements() { return m_end_el_num != m_start_el_num; }
IC bool HaveJoints() { return m_start_jt_num != m_end_jt_num; }
bool HaveElements() { return m_end_el_num != m_start_el_num; }
bool HaveJoints() { return m_start_jt_num != m_end_jt_num; }

public:
IC void sub_diapasone(const CShellSplitInfo& sub)
void sub_diapasone(const CShellSplitInfo& sub)
{
sub_diapasones(m_start_el_num, m_end_el_num, sub.m_start_el_num, sub.m_end_el_num);
sub_diapasones(m_start_jt_num, m_end_jt_num, sub.m_start_jt_num, sub.m_end_jt_num);
Expand Down Expand Up @@ -57,7 +58,7 @@ class CPHFracture : public CShellSplitInfo

public:
bool Update(CPHElement* element);
IC bool Breaked() { return m_breaked; }
bool Breaked() { return m_breaked; }
void SetMassParts(const dMass& first, const dMass& second);
void MassSetZerro();
void MassAddToFirst(const dMass& m);
Expand All @@ -71,11 +72,11 @@ class CPHFracture : public CShellSplitInfo
void MassUnsplitFromFirstToSecond(const dMass& m);
};

DEFINE_VECTOR(CPHFracture, FRACTURE_STORAGE, FRACTURE_I)
typedef std::pair<CPHElement*, CShellSplitInfo> element_fracture;
typedef xr_vector<element_fracture>::reverse_iterator ELEMENT_PAIR_RI;
typedef xr_vector<CPHFracture>::reverse_iterator FRACTURE_RI;
DEFINE_VECTOR(element_fracture, ELEMENT_PAIR_VECTOR, ELEMENT_PAIR_I)
using FRACTURE_STORAGE = xr_vector<CPHFracture>;
using FRACTURE_I = FRACTURE_STORAGE::iterator;
using FRACTURE_RI = FRACTURE_STORAGE::reverse_iterator;
using element_fracture = std::pair<CPHElement*, CShellSplitInfo>;
using ELEMENT_PAIR_VECTOR = xr_vector<element_fracture>;

class CPHFracturesHolder // stored in CPHElement
{
Expand Down
6 changes: 4 additions & 2 deletions src/xrPhysics/PHGeometryOwner.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include "Geometry.h"
#include "xrEngine/GameMtlLib.h"

DEFINE_VECTOR(CODEGeom*, GEOM_STORAGE, GEOM_I)
typedef xr_vector<CODEGeom*>::const_iterator GEOM_CI;
using GEOM_STORAGE = xr_vector<CODEGeom*>;
using GEOM_I = GEOM_STORAGE::iterator;
using GEOM_CI = GEOM_STORAGE::const_iterator;

struct SBoneShape;
class IKinematics;

Expand Down
2 changes: 1 addition & 1 deletion src/xrPhysics/PHImpact.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ struct SPHImpact
geom = root_geom;
}
};
DEFINE_VECTOR(SPHImpact, PH_IMPACT_STORAGE, PH_IMPACT_I)
using PH_IMPACT_STORAGE = xr_vector<SPHImpact>;

#endif
22 changes: 13 additions & 9 deletions src/xrPhysics/PHMoveStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ class CPHPositionsPairs
public:
CPHPositionsPairs(GEOM_I i) { geom = i; }
void Positions(const Fvector*& p0, const Fvector*& p1);
IC CPHPositionsPairs& operator++()

CPHPositionsPairs& operator++()
{
++geom;
return *this;
}
IC dGeomID dGeom() { return (*geom)->geometry_transform(); }
IC CPHPositionsPairs& operator++(int)

dGeomID dGeom() { return (*geom)->geometry_transform(); }

CPHPositionsPairs& operator++(int)
{
geom++;
return *this;
}
IC CPHPositionsPairs& operator=(const CPHPositionsPairs& right) { geom = right.geom; }
IC bool operator==(const CPHPositionsPairs& right) const { return geom == right.geom; }
IC bool operator!=(const CPHPositionsPairs& right) const { return geom != right.geom; }

CPHPositionsPairs& operator=(const CPHPositionsPairs& right) { geom = right.geom; }
bool operator==(const CPHPositionsPairs& right) const { return geom == right.geom; }
bool operator!=(const CPHPositionsPairs& right) const { return geom != right.geom; }
};

class CPHMoveStorage
Expand All @@ -32,9 +36,9 @@ class CPHMoveStorage

public:
typedef CPHPositionsPairs iterator;
IC iterator begin() { return CPHPositionsPairs(m_trace_geometries.begin()); }
IC iterator end() { return CPHPositionsPairs(m_trace_geometries.end()); }
IC bool empty() const { return m_trace_geometries.empty(); }
iterator begin() { return CPHPositionsPairs(m_trace_geometries.begin()); }
iterator end() { return CPHPositionsPairs(m_trace_geometries.end()); }
bool empty() const { return m_trace_geometries.empty(); }
void add(CODEGeom* g) { m_trace_geometries.push_back(g); }
void clear() { m_trace_geometries.clear(); }
};
Expand Down
Loading

0 comments on commit 892f9ff

Please sign in to comment.