const_cast refactor

This commit is contained in:
Jack Andersen 2016-08-28 18:22:54 -10:00
parent e2f342d107
commit 0aaeed2aeb
15 changed files with 26 additions and 30 deletions

View File

@ -496,11 +496,7 @@ size_t ANIM::ANIM2::binarySize(size_t __isz) const
WordBitmap keyBmp;
for (atUint32 frame : frames)
{
while (keyBmp.getBit(frame))
++frame;
keyBmp.setBit(frame);
}
__isz = head.binarySize(__isz);
__isz = keyBmp.binarySize(__isz);

View File

@ -665,7 +665,7 @@ bool ProjectResourceFactoryBase::CanBuild(const urde::SObjectTag& tag)
const urde::SObjectTag* ProjectResourceFactoryBase::GetResourceIdByName(const char* name) const
{
std::unique_lock<std::mutex> lk(((ProjectResourceFactoryBase*)this)->m_backgroundIndexMutex);
std::unique_lock<std::mutex> lk(const_cast<ProjectResourceFactoryBase*>(this)->m_backgroundIndexMutex);
auto search = m_catalogNameToTag.find(name);
if (search == m_catalogNameToTag.end())
{
@ -690,7 +690,7 @@ const urde::SObjectTag* ProjectResourceFactoryBase::GetResourceIdByName(const ch
FourCC ProjectResourceFactoryBase::GetResourceTypeById(ResId id) const
{
std::unique_lock<std::mutex> lk(((ProjectResourceFactoryBase*)this)->m_backgroundIndexMutex);
std::unique_lock<std::mutex> lk(const_cast<ProjectResourceFactoryBase*>(this)->m_backgroundIndexMutex);
SObjectTag searchTag = {FourCC(), id};
auto search = m_tagToPath.find(searchTag);
if (search == m_tagToPath.end())

View File

@ -154,7 +154,7 @@ void CResLoader::AsyncIdlePakLoading()
bool CResLoader::FindResource(u32 id) const
{
for (const std::unique_ptr<CPakFile>& file : x1c_pakLoadedList)
if (((CResLoader*)this)->CacheFromPak(*file, id))
if (const_cast<CResLoader*>(this)->CacheFromPak(*file, id))
return true;
return false;
}

View File

@ -180,7 +180,7 @@ public:
}
const IObj* GetObj() const
{
return ((CToken*)this)->GetObj();
return const_cast<CToken*>(this)->GetObj();
}
CToken& operator=(const CToken& other)
{
@ -273,7 +273,7 @@ public:
}
const T* GetObj() const
{
return ((TToken<T>*)this)->GetObj();
return const_cast<TToken<T>*>(this)->GetObj();
}
T* operator->() {return GetObj();}
const T* operator->() const {return GetObj();}
@ -298,7 +298,7 @@ public:
}
const T* GetObj() const
{
return ((TCachedToken<T>*)this)->GetObj();
return const_cast<TCachedToken<T>*>(this)->GetObj();
}
T* operator->() {return GetObj();}
const T* operator->() const {return GetObj();}

View File

@ -111,11 +111,11 @@ CCharacterFactory::CreateCharacter(int charIdx, bool loop,
CVParamTransfer charParm(new TObjOwnerParam<const CCharacterInfo*>(&charInfo));
TToken<CSkinnedModel> skinnedModel =
((CCharacterFactory*)this)->x70_cacheResPool.GetObj({FourCC(), charInfo.GetModelId()}, charParm);
const_cast<CCharacterFactory*>(this)->x70_cacheResPool.GetObj({FourCC(), charInfo.GetModelId()}, charParm);
rstl::optional_object<TToken<CMorphableSkinnedModel>> iceModel;
if (charInfo.GetIceModelId() && charInfo.GetIceSkinRulesId())
iceModel.emplace(((CCharacterFactory*)this)->x70_cacheResPool.GetObj({FourCC(1), charInfo.GetIceModelId()}, charParm));
iceModel.emplace(const_cast<CCharacterFactory*>(this)->x70_cacheResPool.GetObj({FourCC(1), charInfo.GetIceModelId()}, charParm));
return std::make_unique<CAnimData>(x68_selfId, charInfo, defaultAnim, charIdx, loop,
x14_charLayoutInfoDB[charIdx], skinnedModel,

View File

@ -309,7 +309,7 @@ void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform&
if ((x14_25_sortThermal && which == EWhichModel::Thermal) ||
x10_animData || !x1c_normalModel || drawFlags.m_blendMode > 2)
{
((CModelData*)this)->x14_24_renderSorted = false;
const_cast<CModelData*>(this)->x14_24_renderSorted = false;
return;
}
@ -324,7 +324,7 @@ void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform&
model->DrawUnsortedParts(drawFlags);
// Set ambient to white
CGraphics::DisableAllLights();
((CModelData*)this)->x14_24_renderSorted = true;
const_cast<CModelData*>(this)->x14_24_renderSorted = true;
}
void CModelData::Render(EWhichModel which, const zeus::CTransform& xf,
@ -365,7 +365,7 @@ void CModelData::Render(EWhichModel which, const zeus::CTransform& xf,
// Set ambient to white
CGraphics::DisableAllLights();
((CModelData*)this)->x14_24_renderSorted = false;
const_cast<CModelData*>(this)->x14_24_renderSorted = false;
}
}

View File

@ -29,11 +29,11 @@ float CLight::GetIntensity() const
{
if (x4c_24_intensityDirty)
{
((CLight*)this)->x4c_24_intensityDirty = false;
const_cast<CLight*>(this)->x4c_24_intensityDirty = false;
float coef = 1.f;
if (x1c_type == ELightType::Custom)
coef = x30_angleC;
((CLight*)this)->x48_cachedIntensity =
const_cast<CLight*>(this)->x48_cachedIntensity =
coef * std::max(x18_color.r, std::max(x18_color.g, x18_color.b));
}
return x48_cachedIntensity;

View File

@ -101,8 +101,8 @@ public:
{
if (x4c_25_radiusDirty)
{
((CLight*)this)->x44_cachedRadius = CalculateLightRadius();
((CLight*)this)->x4c_25_radiusDirty = false;
const_cast<CLight*>(this)->x44_cachedRadius = CalculateLightRadius();
const_cast<CLight*>(this)->x4c_25_radiusDirty = false;
}
return x44_cachedRadius;
}

View File

@ -254,9 +254,9 @@ bool CBooModel::TryLockTextures() const
}
if (allLoad)
((CBooModel*)this)->BuildGfxToken();
const_cast<CBooModel*>(this)->BuildGfxToken();
((CBooModel*)this)->x40_24_texturesLoaded = allLoad;
const_cast<CBooModel*>(this)->x40_24_texturesLoaded = allLoad;
}
return x40_24_texturesLoaded;
}
@ -265,7 +265,7 @@ void CBooModel::UnlockTextures() const
{
for (TCachedToken<CTexture>& tex : *x1c_textures)
tex.Unlock();
((CBooModel*)this)->x40_24_texturesLoaded = false;
const_cast<CBooModel*>(this)->x40_24_texturesLoaded = false;
}
void CBooModel::DrawAlphaSurfaces(const CModelFlags& flags) const

View File

@ -402,7 +402,7 @@ bool CGuiFrame::GetIsFinishedLoading() const
continue;
return false;
}
((CGuiFrame*)this)->xbc_24_loaded = true;
const_cast<CGuiFrame*>(this)->xbc_24_loaded = true;
return true;
}

View File

@ -65,7 +65,7 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
zeus::CColor geomCol = xb4_;
geomCol.a *= parms.x0_alphaMod;
((CGuiTextPane*)this)->x114_textSupport.SetGeometryColor(geomCol);
const_cast<CGuiTextPane*>(this)->x114_textSupport.SetGeometryColor(geomCol);
CGraphics::SetDepthWriteMode(xf6_31_depthTest, ERglEnum::LEqual, xf7_24_depthWrite);
@ -91,7 +91,7 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
x114_textSupport.Render();
((CGuiTextPane*)this)->x114_textSupport.SetGeometryColor
const_cast<CGuiTextPane*>(this)->x114_textSupport.SetGeometryColor
(geomCol * zeus::CColor(geomCol.a, geomCol.a, geomCol.a, 1.f));
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One,
ERglBlendFactor::One, ERglLogicOp::Clear);

View File

@ -151,7 +151,7 @@ void CTextRenderBuffer::SetPrimitiveOpacity(int idx, float opacity)
void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const
{
((CTextRenderBuffer*)this)->CommitResources();
const_cast<CTextRenderBuffer*>(this)->CommitResources();
BooUniform uniforms = {CGraphics::GetPerspectiveProjectionMatrix(true) *
CGraphics::g_GXModelView.toMatrix4f(), col};

View File

@ -176,9 +176,9 @@ bool CIESampleAndHold::GetValue(int frame, int& valOut) const
xc_waitFramesMin->GetValue(frame, b);
x10_waitFramesMax->GetValue(frame, c);
/* const-correctness, who needs it? */
((CIESampleAndHold*)this)->x8_nextSampleFrame = CRandom16::GetRandomNumber()->Range(b, c) + frame;
const_cast<CIESampleAndHold*>(this)->x8_nextSampleFrame = CRandom16::GetRandomNumber()->Range(b, c) + frame;
x4_sampleSource->GetValue(frame, valOut);
((CIESampleAndHold*)this)->x14_holdVal = valOut;
const_cast<CIESampleAndHold*>(this)->x14_holdVal = valOut;
}
else
valOut = x14_holdVal;

View File

@ -227,7 +227,7 @@ ResId CWorld::IGetSaveWorldAssetId() const
const CMapWorld* CWorld::IGetMapWorld() const
{
return ((CWorld*)this)->GetMapWorld();
return const_cast<CWorld*>(this)->GetMapWorld();
}
CMapWorld* CWorld::IMapWorld()

2
hecl

@ -1 +1 @@
Subproject commit 2a4b0cd21c56c6a4b558f68bbb91c5e2b9c41bc5
Subproject commit f325c438d1aa629de2af004ebb595db362895dd1