In episode 1 of New Game 2, around 9:40, there is a shot of the code that Nene has written:
Here is it in text form with the comments translated:
// the calculation of damage when attacked
void DestructibleActor::ReceiveDamage(float sourceDamage)
{
// apply debuffs
auto resolvedDamage = sourceDamage;
for (const auto& debuf:m_debufs)
{
resolvedDamage = debuf.ApplyToDamage(resolvedDamage);
m_currentHealth -= resolvedDamage
if (m_currentHealth <= 0.f)
{
m_currentHealth = 0.f;
DestroyMe();
}
}
}
After the shot, Umiko, pointing at the for loop, said that the reason why the code crashed is that there is an infinite loop.
I don't really know C++ so I'm not sure whether what she is saying is true.
From what I can see, the for loop is just iterating through the debufs that the Actor currently has. Unless the Actor has an infinite amount of debufs, I don't think it can possibly become an infinite loop.
But I'm not sure because the only reason that there is a shot of the code is that they wanted to put an easter egg here, right? We would have just gotten a shot of the back of the laptop and heard Umiko saying "Oh you've got an infinite loop there". The fact that they actually showed some code makes me think that somehow the code is an easter egg of some sort.
Will the code actually create an infinite loop?