artemis-odb
artemis-odb copied to clipboard
[BUG] Null check needed in EntityProcessingSystem
I have found that a crash will sometimes occur without a null check in processSystem.
The code should be the following:
for (int i = 0, s = entities.size(); s > i; i++) { if (array[i] != null) process((Entity) array[i]); }
public abstract class EntityProcessingSystem extends EntitySystem {
/**
* Creates a new EntityProcessingSystem.
* @param aspect
* the aspect to match entities
*/
public EntityProcessingSystem(Aspect.Builder aspect) {
super(aspect);
}
public EntityProcessingSystem() {
}
/**
* Process a entity this system is interested in.
* @param e
* the entity to process
*/
protected abstract void process(Entity e);
/** @inheritDoc */
@Override
protected final void processSystem() {
Bag<Entity> entities = getEntities();
Object[] array = entities.getData();
for (int i = 0, s = entities.size(); s > i; i++) {
process((Entity) array[i]);
}
}
}