CMapWorldInfo: Remove use of const_cast

Same behavior, but explicitly marks the member variables as mutable.
This is fine given they act as an underlying cache and don't directly
alter the behavior of the interface.
This commit is contained in:
Lioncash 2020-04-05 06:30:23 -04:00
parent 2755f3f4f8
commit 42c560b9df
1 changed files with 4 additions and 4 deletions

View File

@ -59,8 +59,8 @@ bool CMapWorldInfo::IsDoorVisited(TEditorId eid) const { return x28_visitedDoors
bool CMapWorldInfo::IsAreaVisited(TAreaId aid) const {
if (u32(aid) + 1 > x0_visitedAreasAllocated) {
const_cast<CMapWorldInfo&>(*this).x4_visitedAreas.resize((u32(aid) + 32) / 32);
const_cast<CMapWorldInfo&>(*this).x0_visitedAreasAllocated = u32(aid) + 1;
x4_visitedAreas.resize((u32(aid) + 32) / 32);
x0_visitedAreasAllocated = u32(aid) + 1;
}
return ((x4_visitedAreas[aid / 32] >> (aid % 32)) & 1) != 0;
}
@ -80,8 +80,8 @@ void CMapWorldInfo::SetAreaVisited(TAreaId aid, bool visited) {
bool CMapWorldInfo::IsMapped(TAreaId aid) const {
if (u32(aid) + 1 > x14_mappedAreasAllocated) {
const_cast<CMapWorldInfo&>(*this).x18_mappedAreas.resize((u32(aid) + 32) / 32);
const_cast<CMapWorldInfo&>(*this).x14_mappedAreasAllocated = u32(aid) + 1;
x18_mappedAreas.resize((u32(aid) + 32) / 32);
x14_mappedAreasAllocated = u32(aid) + 1;
}
return ((x18_mappedAreas[aid / 32] >> (aid % 32)) & 1) != 0;
}