Skip to content

Commit

Permalink
More cleaning/decoupling. Some 'override' added. Fixed up stricmp -> …
Browse files Browse the repository at this point in the history
…_stricmp & co.

Replace _stricmp & co. to instead use xr_-prepended function names in the code, and select impl. from a header depending on compiler used.
Tagged up CKinematics with 'override' where appropriate.
Removed a bunch of compiler warnings (unused function arguments, re-defining variable name in function (sometimes with different type even)).
Moved a few Lock instances in a class to be Lock* (compile-time complexity reduction).
Xottab_DUTY: removed some include guards
  • Loading branch information
tamlin-mike authored and Xottab-DUTY committed Jan 29, 2018
1 parent d7578ee commit 0c0834b
Show file tree
Hide file tree
Showing 194 changed files with 662 additions and 586 deletions.
18 changes: 18 additions & 0 deletions src/Common/Compiler.inl
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@
#define XR_NOEXCEPT noexcept
#define XR_NOEXCEPT_OP(x) noexcept(x)
#endif

#ifdef _MSC_VER
// We use xr_* instead of defining e.g. strupr => _strupr, since the macro definition could
// come before the std. header file declaring it, and thereby renaming that one too.
#define xr_strupr _strupr
#define xr_strlwr _strlwr
#define xr_stricmp _stricmp
#define xr_strcmpi _strcmpi
#define xr_unlink _unlink
#define xr_itoa _itoa
#else
#define xr_strupr strupr
#define xr_strlwr strlwr
#define xr_stricmp stricmp
#define xr_strcmpi strcmpi
#define xr_unlink unlink
#define xr_itoa itoa
#endif
6 changes: 3 additions & 3 deletions src/Layers/xrRender/AnimationKeyCalculate.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ IC void Dequantize(CKey& K, const CBlend& BD, const CMotion& M)
// rotation
if (M.test_flag(flRKeyAbsent))
{
const CKeyQR* K = &M._keysR[0];
QR2Quat(*K, D->Q);
const CKeyQR* K2 = &M._keysR[0];
QR2Quat(*K2, D->Q);
}
else
{
Expand Down Expand Up @@ -394,7 +394,7 @@ IC void MixAdd(CKey& Result, const CKey* R, const float* BA, int b_count)
MixinAdd(Result, R, BA, b_count);
}
IC void process_single_channel(
CKey& Result, const animation::channel_def& ch, const CKey* R, const CBlend* const BA[MAX_BLENDED], int b_count)
CKey& Result, const animation::channel_def& /*ch*/, const CKey* R, const CBlend* const BA[MAX_BLENDED], int b_count)
{
MixInterlerp(Result, R, BA, b_count);
VERIFY(_valid(Result.T));
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Blender_Recorder_R2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void CBlender_Compile::r_Pass(LPCSTR _vs, LPCSTR _ps, bool bFog, BOOL bZtest, BO
ctable.merge(&vs->constants);

// Last Stage - disable
if (0 == _stricmp(_ps, "null"))
if (0 == xr_stricmp(_ps, "null"))
{
RS.SetTSS(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
RS.SetTSS(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
Expand Down
36 changes: 20 additions & 16 deletions src/Layers/xrRender/D3DUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,19 @@ void CDrawUtilities::DrawEntity(u32 clr, ref_shader s)
// fill VB
_VertexStream* Stream = &RCache.Vertex;
u32 vBase;
FVF::L* pv = (FVF::L*)Stream->Lock(5, vs_L->vb_stride, vBase);
pv->set(0.f, 0.f, 0.f, clr);
pv++;
pv->set(0.f, 1.f, 0.f, clr);
pv++;
pv->set(0.f, 1.f, .5f, clr);
pv++;
pv->set(0.f, .5f, .5f, clr);
pv++;
pv->set(0.f, .5f, 0.f, clr);
pv++;
{
FVF::L* pv = (FVF::L*)Stream->Lock(5, vs_L->vb_stride, vBase);
pv->set(0.f, 0.f, 0.f, clr);
pv++;
pv->set(0.f, 1.f, 0.f, clr);
pv++;
pv->set(0.f, 1.f, .5f, clr);
pv++;
pv->set(0.f, .5f, .5f, clr);
pv++;
pv->set(0.f, .5f, 0.f, clr);
pv++;
}
Stream->Unlock(5, vs_L->vb_stride);
// render flagshtok
DU_DRAW_SH(RImplementation.m_WireShader);
Expand Down Expand Up @@ -441,11 +443,13 @@ void CDrawUtilities::DrawFlag(
// fill VB
_VertexStream* Stream = &RCache.Vertex;
u32 vBase;
FVF::L* pv = (FVF::L*)Stream->Lock(2, vs_L->vb_stride, vBase);
pv->set(p, clr);
pv++;
pv->set(p.x, p.y + height, p.z, clr);
pv++;
{
FVF::L* pv = (FVF::L*)Stream->Lock(2, vs_L->vb_stride, vBase);
pv->set(p, clr);
pv++;
pv->set(p.x, p.y + height, p.z, clr);
pv++;
}
Stream->Unlock(2, vs_L->vb_stride);
// and Render it as triangle list
DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/DetailManager_VS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void CDetailManager::hw_Render()
hw_Render_dump(&*hwc_s_array, 0, 1, c_hdr);
}

void CDetailManager::hw_Render_dump(ref_constant x_array, u32 var_id, u32 lod_id, u32 c_offset)
void CDetailManager::hw_Render_dump(ref_constant x_array, u32 var_id, u32 lod_id, u32 /*c_offset*/)
{
RImplementation.BasicStats.DetailCount = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/FHierrarhyVisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void FHierrarhyVisual::Load(const char* N, IReader* data, u32 dwFlags)
xr_strcpy(short_name, N);
if (strext(short_name))
*strext(short_name) = 0;
strconcat(sizeof(name_load), name_load, short_name, ":", _itoa(count, num, 10));
strconcat(sizeof(name_load), name_load, short_name, ":", xr_itoa(count, num, 10));
children.push_back((dxRender_Visual*)GEnv.Render->model_CreateChild(name_load, O));
O->close();
O = OBJ->open_chunk(count);
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRender/HOM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ void CHOM::Render_DB(CFrustum& base)
stats.VisibleTriangleCount++;
u32 pixels = 0;
int limit = int(P->size()) - 1;
for (int v = 1; v < limit; v++)
for (int v2 = 1; v2 < limit; v2++)
{
m_xform.transform(T.raster[0], (*P)[0]);
m_xform.transform(T.raster[1], (*P)[v + 0]);
m_xform.transform(T.raster[2], (*P)[v + 1]);
m_xform.transform(T.raster[1], (*P)[v2 + 0]);
m_xform.transform(T.raster[2], (*P)[v2 + 1]);
pixels += Raster.rasterize(&T);
}
if (0 == pixels)
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ struct _uniq_mode
{
_uniq_mode(LPCSTR v) : _val(v) {}
LPCSTR _val;
bool operator()(LPCSTR _other) { return !_stricmp(_val, _other); }
bool operator()(LPCSTR _other) { return !xr_stricmp(_val, _other); }
};

#ifndef _EDITOR
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/ModelPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ dxRender_Visual* CModelPool::Create(const char* name, IReader* data)
string_path low_name;
VERIFY(xr_strlen(name) < sizeof(low_name));
xr_strcpy(low_name, name);
_strlwr(low_name);
xd_strlwr(low_name);
if (strext(low_name))
*strext(low_name) = 0;
// Msg ("-CREATE %s",low_name);
Expand Down Expand Up @@ -266,7 +266,7 @@ dxRender_Visual* CModelPool::CreateChild(LPCSTR name, IReader* data)
string256 low_name;
VERIFY(xr_strlen(name) < 256);
xr_strcpy(low_name, name);
_strlwr(low_name);
xd_strlwr(low_name);
if (strext(low_name))
*strext(low_name) = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/Layers/xrRender/NvTriStrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ void GenerateStrips(const u16* in_indices, const s32 in_numIndices, xr_vector<Pr
// put data in format that the stripifier likes
WordVec tempIndices;
tempIndices.resize(in_numIndices);
int i;
for (i = 0; i < in_numIndices; i++)
for (int i = 0; i < in_numIndices; i++)
tempIndices[i] = in_indices[i];
NvStripInfoVec tempStrips;
NvFaceInfoVec tempFaces;
Expand Down
12 changes: 6 additions & 6 deletions src/Layers/xrRender/PSLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ void CPSLibrary::Remove(const char* nm)
}
else
{
PS::PGDIt it = FindPGDIt(nm);
if (it != m_PGDs.end())
PS::PGDIt it2 = FindPGDIt(nm);
if (it2 != m_PGDs.end())
{
xr_delete(*it);
m_PGDs.erase(it);
xr_delete(*it2);
m_PGDs.erase(it2);
}
}
}
Expand Down Expand Up @@ -153,7 +153,7 @@ bool CPSLibrary::Load2()
#endif

xr_sprintf(_path, sizeof(_path), "%s%s", p_path, p_name);
if (0 == _stricmp(p_ext, ".pe"))
if (0 == xr_stricmp(p_ext, ".pe"))
{
PS::CPEDef* def = new PS::CPEDef();
def->m_Name = _path;
Expand All @@ -162,7 +162,7 @@ bool CPSLibrary::Load2()
else
xr_delete(def);
}
else if (0 == _stricmp(p_ext, ".pg"))
else if (0 == xr_stricmp(p_ext, ".pg"))
{
PS::CPGDef* def = new PS::CPGDef();
def->m_Name = _path;
Expand Down
14 changes: 7 additions & 7 deletions src/Layers/xrRender/ParticleGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,20 +352,20 @@ struct zero_vis_pred
};
void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox& box, bool& bPlaying)
{
CParticleEffect* E = static_cast<CParticleEffect*>(_effect);
if (E)
CParticleEffect* E1 = static_cast<CParticleEffect*>(_effect);
if (E1)
{
E->OnFrame(u_dt);
if (E->IsPlaying())
E1->OnFrame(u_dt);
if (E1->IsPlaying())
{
bPlaying = true;
if (E->vis.box.is_valid())
box.merge(E->vis.box);
if (E1->vis.box.is_valid())
box.merge(E1->vis.box);
if (def.m_Flags.is(CPGDef::SEffect::flOnPlayChild) && def.m_OnPlayChildName.size())
{
PAPI::Particle* particles;
u32 p_cnt;
PAPI::ParticleManager()->GetParticles(E->GetHandleEffect(), particles, p_cnt);
PAPI::ParticleManager()->GetParticles(E1->GetHandleEffect(), particles, p_cnt);
VERIFY(p_cnt == _children_related.size());
if (p_cnt)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ParticleGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ECORE_API CParticleGroup : public dxParticleCustom
virtual ~CParticleGroup();
virtual void OnFrame(u32 dt);

virtual void Copy(dxRender_Visual* pFrom) { FATAL("Can't duplicate particle system - NOT IMPLEMENTED"); }
virtual void Copy(dxRender_Visual* /*pFrom*/) { FATAL("Can't duplicate particle system - NOT IMPLEMENTED"); }
virtual void OnDeviceCreate();
virtual void OnDeviceDestroy();

Expand Down
15 changes: 9 additions & 6 deletions src/Layers/xrRender/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ void fix_texture_name(LPSTR fn)
{
LPSTR _ext = strext(fn);
if (_ext &&
(0==_stricmp(_ext, ".tga") ||
0==_stricmp(_ext, ".dds") ||
0==_stricmp(_ext, ".bmp") ||
0==_stricmp(_ext, ".ogm")))
(0==xr_stricmp(_ext, ".tga") ||
0==xr_stricmp(_ext, ".dds") ||
0==xr_stricmp(_ext, ".bmp") ||
0==xr_stricmp(_ext, ".ogm")))
*_ext = 0;
}
*/
Expand Down Expand Up @@ -121,7 +121,7 @@ void CResourceManager::_ParseList(sh_list& dest, LPCSTR names)
{
// flush
N.push_back(0);
_strlwr(N.begin());
xd_strlwr(N.begin());

fix_texture_name(N.begin());
//. andy if (strext(N.begin())) *strext(N.begin())=0;
Expand All @@ -138,7 +138,7 @@ void CResourceManager::_ParseList(sh_list& dest, LPCSTR names)
{
// flush
N.push_back(0);
_strlwr(N.begin());
xd_strlwr(N.begin());

fix_texture_name(N.begin());
//. andy if (strext(N.begin())) *strext(N.begin())=0;
Expand Down Expand Up @@ -186,12 +186,15 @@ Shader* CResourceManager::_cpp_Create(
C.bEditor = FALSE;
C.bDetail = FALSE;
#ifdef _EDITOR
<<<<<<< HEAD
if (!C.BT)
{
ELog.Msg(mtError, "Can't find shader '%s'", s_shader);
return 0;
}
C.bEditor = TRUE;
#else
UNUSED(s_shader);
#endif

// Parse names
Expand Down
12 changes: 6 additions & 6 deletions src/Layers/xrRender/ResourceManager_Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ SVS* CResourceManager::_CreateVS(LPCSTR _name)
SVS* _vs = new SVS();
_vs->dwFlags |= xr_resource_flagged::RF_REGISTERED;
m_vs.insert(std::make_pair(_vs->set_name(name), _vs));
if (0 == _stricmp(_name, "null"))
if (0 == xr_stricmp(_name, "null"))
{
_vs->vs = nullptr;
return _vs;
Expand Down Expand Up @@ -266,7 +266,7 @@ SPS* CResourceManager::_CreatePS(LPCSTR name)
SPS* _ps = new SPS();
_ps->dwFlags |= xr_resource_flagged::RF_REGISTERED;
m_ps.insert(std::make_pair(_ps->set_name(name), _ps));
if (0 == _stricmp(name, "null"))
if (0 == xr_stricmp(name, "null"))
{
_ps->ps = nullptr;
return _ps;
Expand Down Expand Up @@ -558,7 +558,7 @@ void CResourceManager::DBG_VerifyTextures()
CMatrix* CResourceManager::_CreateMatrix(LPCSTR Name)
{
R_ASSERT(Name && Name[0]);
if (0 == _stricmp(Name, "$null"))
if (0 == xr_stricmp(Name, "$null"))
return nullptr;

LPSTR N = LPSTR(Name);
Expand Down Expand Up @@ -596,7 +596,7 @@ void CResourceManager::ED_UpdateMatrix(LPCSTR Name, CMatrix* data)
CConstant* CResourceManager::_CreateConstant(LPCSTR Name)
{
R_ASSERT(Name && Name[0]);
if (0 == _stricmp(Name, "$null"))
if (0 == xr_stricmp(Name, "$null"))
return nullptr;

LPSTR N = LPSTR(Name);
Expand Down Expand Up @@ -784,7 +784,7 @@ SVS* CResourceManager::_CreateVS(LPCSTR _name)
SVS* _vs = new SVS();
_vs->dwFlags |= xr_resource_flagged::RF_REGISTERED;
m_vs.insert(std::make_pair(_vs->set_name(name), _vs));
if (0 == _stricmp(_name, "null"))
if (0 == xr_stricmp(_name, "null"))
{
_vs->vs = NULL;
return _vs;
Expand Down Expand Up @@ -906,7 +906,7 @@ SPS* CResourceManager::_CreatePS(LPCSTR name)
SPS* _ps = new SPS();
_ps->dwFlags |= xr_resource_flagged::RF_REGISTERED;
m_ps.insert(std::make_pair(_ps->set_name(name), _ps));
if (0 == _stricmp(name, "null"))
if (0 == xr_stricmp(name, "null"))
{
_ps->ps = NULL;
return _ps;
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/SH_Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void CTexture::Load()

flags.bUser = false;
flags.MemoryUsage = 0;
if (0 == _stricmp(*cName, "$null"))
if (0 == xr_stricmp(*cName, "$null"))
return;
if (nullptr != strstr(*cName, "$user$"))
{
Expand Down Expand Up @@ -242,7 +242,7 @@ void CTexture::Load()

flags.seqCycles = FALSE;
_fs->r_string(buffer, sizeof(buffer));
if (0 == _stricmp(buffer, "cycled"))
if (0 == xr_stricmp(buffer, "cycled"))
{
flags.seqCycles = TRUE;
_fs->r_string(buffer, sizeof(buffer));
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ShaderResourceTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ inline T* CResourceManager::CreateShader(const char* name)

sh->dwFlags |= xr_resource_flagged::RF_REGISTERED;
sh_map.insert(std::make_pair(sh->set_name(name), sh));
if (0 == _stricmp(name, "null"))
if (0 == xr_stricmp(name, "null"))
{
sh->sh = NULL;
return sh;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/SkeletonAnimated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ u16 CKinematicsAnimated::LL_PartID(LPCSTR B)
CPartDef& P = (*m_Partition)[id];
if (nullptr == P.Name)
continue;
if (0 == _stricmp(B, *P.Name))
if (0 == xr_stricmp(B, *P.Name))
return id;
}
return BI_NONE;
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/SkeletonCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void CKinematics::Load(const char* N, IReader* data, u32 dwFlags)
// Bone
u16 ID = u16(bones->size());
data->r_stringZ(buf, sizeof(buf));
_strlwr(buf);
xr_strlwr(buf);
CBoneData* pBone = CreateBoneData(ID);
pBone->name = shared_str(buf);
pBone->child_faces.resize(children.size());
Expand All @@ -247,7 +247,7 @@ void CKinematics::Load(const char* N, IReader* data, u32 dwFlags)

// It's parent
data->r_stringZ(buf, sizeof(buf));
_strlwr(buf);
xr_strlwr(buf);
L_parents.push_back(buf);

data->r(&pBone->obb, sizeof(Fobb));
Expand Down
Loading

0 comments on commit 0c0834b

Please sign in to comment.