Disable static value evaluation for visible expression when optimizations are turned off

This commit is contained in:
Jan
2022-01-01 16:59:27 +01:00
parent 64a1e4c176
commit 2df12e101e
2 changed files with 18 additions and 9 deletions

View File

@ -493,10 +493,23 @@ namespace IW4
if (expression == nullptr)
return nullptr;
if (expression->IsStatic())
bool isStatic;
bool isTruthy;
if(m_disable_optimizations)
{
const auto staticValue = expression->Evaluate();
if (staticValue.IsTruthy())
const auto* staticValue = dynamic_cast<const SimpleExpressionValue*>(expression);
isStatic = staticValue != nullptr;
isTruthy = isStatic && staticValue->IsTruthy();
}
else
{
isStatic = expression->IsStatic();
isTruthy = isStatic && expression->Evaluate().IsTruthy();
}
if (isStatic)
{
if (isTruthy)
window->dynamicFlags[0] |= WINDOW_FLAG_VISIBLE;
return nullptr;
}