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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user