CGameArea: Eliminate implicit sign conversions in Validate()

This commit is contained in:
Lioncash 2020-04-23 02:52:22 -04:00
parent 419d40051d
commit df3aed75fe
3 changed files with 17 additions and 14 deletions

View File

@ -18,7 +18,7 @@ class CPVSAreaSet {
const u8* x1c_lightLeaves;
CPVSVisOctree x20_octree;
CPVSVisSet _GetLightSet(u32 lightIdx) const {
CPVSVisSet _GetLightSet(size_t lightIdx) const {
CPVSVisSet ret;
ret.SetFromMemory(x20_octree.GetNumObjects(), x20_octree.GetNumLights(), x1c_lightLeaves + x10_leafSize * lightIdx);
return ret;
@ -31,10 +31,10 @@ public:
u32 Get1stLightIndex(u32 lightIdx) const { return x0_numFeatures + x8_num2ndLights + lightIdx; }
u32 Get2ndLightIndex(u32 lightIdx) const { return x0_numFeatures + lightIdx; }
bool Has2ndLayerLights() const { return x8_num2ndLights != 0; }
u32 GetEntityIdByIndex(int idx) const { return x18_entityIndex[idx]; }
u32 GetEntityIdByIndex(size_t idx) const { return x18_entityIndex[idx]; }
const CPVSVisOctree& GetVisOctree() const { return x20_octree; }
CPVSVisSet Get1stLightSet(u32 lightIdx) const { return _GetLightSet(x8_num2ndLights + lightIdx); }
CPVSVisSet Get2ndLightSet(u32 lightIdx) const { return _GetLightSet(lightIdx); }
CPVSVisSet Get1stLightSet(size_t lightIdx) const { return _GetLightSet(x8_num2ndLights + lightIdx); }
CPVSVisSet Get2ndLightSet(size_t lightIdx) const { return _GetLightSet(lightIdx); }
};
} // namespace urde

View File

@ -862,16 +862,19 @@ void CGameArea::Validate(CStateManager& mgr) {
LoadScriptObjects(mgr);
CPVSAreaSet* pvs = x12c_postConstructed->xa0_pvs.get();
const CPVSAreaSet* pvs = x12c_postConstructed->xa0_pvs.get();
if (pvs && x12c_postConstructed->x1108_29_pvsHasActors) {
for (int i = 0; i < pvs->GetNumActors(); ++i) {
TEditorId entId = pvs->GetEntityIdByIndex(i) | (x4_selfIdx << 16);
TUniqueId id = mgr.GetIdForScript(entId);
if (id != kInvalidUniqueId) {
CPostConstructed::MapEntry& ent = x12c_postConstructed->xa8_pvsEntityMap[id.Value()];
ent.x0_id = i + (pvs->GetNumFeatures() - pvs->GetNumActors());
ent.x4_uid = id;
for (size_t i = 0; i < pvs->GetNumActors(); ++i) {
const TEditorId entId = pvs->GetEntityIdByIndex(i) | (x4_selfIdx << 16);
const TUniqueId id = mgr.GetIdForScript(entId);
if (id == kInvalidUniqueId) {
continue;
}
CPostConstructed::MapEntry& ent = x12c_postConstructed->xa8_pvsEntityMap[id.Value()];
ent.x0_id = static_cast<s16>(i + (pvs->GetNumFeatures() - pvs->GetNumActors()));
ent.x4_uid = id;
}
}

View File

@ -331,10 +331,10 @@ public:
s16 LookupPVSID(TUniqueId id) const;
const CPVSAreaSet* GetAreaVisSet() const { return GetPostConstructed()->xa0_pvs.get(); }
u32 Get1stPVSLightFeature(u32 lightIdx) const {
return GetAreaVisSet() ? GetAreaVisSet()->Get1stLightIndex(lightIdx) : -1;
return GetAreaVisSet() ? GetAreaVisSet()->Get1stLightIndex(lightIdx) : UINT32_MAX;
}
u32 Get2ndPVSLightFeature(u32 lightIdx) const {
return GetAreaVisSet() ? GetAreaVisSet()->Get2ndLightIndex(lightIdx) : -1;
return GetAreaVisSet() ? GetAreaVisSet()->Get2ndLightIndex(lightIdx) : UINT32_MAX;
}
const zeus::CTransform& GetTransform() const { return xc_transform; }