C4TimeMilliseconds: fixed comparison & stopped reloading shaders every frame

Imagine lhs being 0 and rhs being more than int32_t can handle. And then imagine subtracting them and casting them to int32_t.
That's what happened e.g. in void C4ShaderCall::Start() when ScriptShader.LastUpdate was 0. This caused the shaders to reload every frame;
at least when in the main menu. This lead to serious lagging (of the cursor) for me.

Note that the subtraction operator in C4TimeMilliseconds.cpp has a similar issue. This might need a fix or at least high awareness by users. Maybe an assert or something.

PS: Who thought that doing the comparison with a subtraction was a good idea? This is not assembler :I
install-platforms
David Dormagen 2017-08-15 09:58:04 +02:00
parent 8d1aa0c0c2
commit 6fa13d8717
1 changed files with 1 additions and 1 deletions

View File

@ -84,7 +84,7 @@ bool operator<( const C4TimeMilliseconds& lhs, const C4TimeMilliseconds& rhs )
{
return lhs.inf < rhs.inf;
}
return int32_t(lhs.time - rhs.time) < 0;
return lhs.time < rhs.time;
}
int32_t operator-(const C4TimeMilliseconds& lhs, const C4TimeMilliseconds& rhs)