1
0
forked from mirrors/0ad

Prevent invalid GetEntityState GuiInterface calls

As long as there's no entity under the cursor, 11 calls were made per
tick with an undefined entity ID, which are now caught.

In general, an "entity state" can very well be null if the passed ID
is undefined, invalid or no entity with the ID exists (anymore). This
last case is only noticed by the GuiInterface and currently used to
detect destroyed entities.
This commit is contained in:
Vantha
2025-12-31 17:32:34 +01:00
committed by Vantha
parent ba2351611c
commit bb31e6b6b1
@@ -197,8 +197,15 @@ function GetMultipleEntityStates(ents)
return entityStates;
}
/**
* Get the current state of a given entity. The data is pulled from the simulation.
* The state is null, if the ID is undefined, invalid or no entity with the ID exists (anymore).
*/
function GetEntityState(entId)
{
if (!entId || entId == INVALID_ENTITY)
return null;
if (!g_EntityStates[entId])
{
const entityState = Engine.GuiInterfaceCall("GetEntityState", entId);