1
0
forked from 0ad/0ad

Fix compile error introduced in 968e55704a

Change the ternary to a lambda.
Add braces around the while loop body introduced in 50cbe24cc5.

Refs: 968e55704a, 50cbe24cc5

Accepted By: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5176
This was SVN commit r27914.
This commit is contained in:
phosit 2023-11-05 17:59:42 +00:00
parent 2c6e7a590f
commit b38aa7d6dd

View File

@ -678,16 +678,24 @@ static void RunGameOrAtlas(const PS::span<const char* const> argv)
else if (!InitNonVisual(args)) else if (!InitNonVisual(args))
g_Shutdown = ShutdownType::Quit; g_Shutdown = ShutdownType::Quit;
std::optional<RL::Interface> rlInterface{g_Shutdown == ShutdownType::None ? // MSVC doesn't support copy elision in ternary expressions. So we use a lambda instead.
CreateRLInterface(args) : std::nullopt}; std::optional<RL::Interface> rlInterface{[&]() -> std::optional<RL::Interface>
{
if (g_Shutdown == ShutdownType::None)
return CreateRLInterface(args);
else
return std::nullopt;
}()};
while (g_Shutdown == ShutdownType::None) while (g_Shutdown == ShutdownType::None)
{
if (isVisual) if (isVisual)
Frame(rlInterface ? &*rlInterface : nullptr); Frame(rlInterface ? &*rlInterface : nullptr);
else if(rlInterface) else if(rlInterface)
rlInterface->TryApplyMessage(); rlInterface->TryApplyMessage();
else else
NonVisualFrame(); NonVisualFrame();
}
// Do not install mods again in case of restart (typically from the mod selector) // Do not install mods again in case of restart (typically from the mod selector)
modsToInstall.clear(); modsToInstall.clear();