Decomp fix for CStateManager::BuildDynamicLightListForWorld

This commit is contained in:
Henrique Gemignani Passos Lima 2022-11-28 19:11:11 +02:00
parent 058194429e
commit 9b407bd131
No known key found for this signature in database
GPG Key ID: E224F951761145F8
2 changed files with 14 additions and 0 deletions

View File

@ -534,6 +534,8 @@ void CStateManager::BuildDynamicLightListForWorld() {
} }
x8e0_dynamicLights.clear(); x8e0_dynamicLights.clear();
x8e0_dynamicLights.reserve(GetLightObjectList().size());
for (const CEntity* ent : GetLightObjectList()) { for (const CEntity* ent : GetLightObjectList()) {
const auto& light = static_cast<const CGameLight&>(*ent); const auto& light = static_cast<const CGameLight&>(*ent);
if (light.GetActive()) { if (light.GetActive()) {
@ -543,7 +545,18 @@ void CStateManager::BuildDynamicLightListForWorld() {
} }
} }
} }
std::sort(x8e0_dynamicLights.begin(), x8e0_dynamicLights.end(), [](const CLight& a, const CLight& b) {
if (b.GetPriority() > a.GetPriority()) {
return true;
} else if (b.GetPriority() == a.GetPriority()) {
return a.GetIntensity() > b.GetIntensity();
} else {
return false;
}
});
} }
void CStateManager::DrawDebugStuff() const { void CStateManager::DrawDebugStuff() const {
if (com_developer != nullptr && !com_developer->toBoolean()) { if (com_developer != nullptr && !com_developer->toBoolean()) {
return; return;

View File

@ -90,6 +90,7 @@ public:
ELightType GetType() const { return x1c_type; } ELightType GetType() const { return x1c_type; }
u32 GetId() const { return x40_lightId; } u32 GetId() const { return x40_lightId; }
u32 GetPriority() const { return x3c_priority; }
float GetIntensity() const; float GetIntensity() const;
float GetRadius() const; float GetRadius() const;
const zeus::CColor& GetColor() const { return x18_color; } const zeus::CColor& GetColor() const { return x18_color; }