You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess the code is copied from BWMirror, which only compares the ids to determine equality.
This is rather bad for BWAPI4J where a type change also results in a new Unit object with the same id.
If, for example used as a Map key the following code or similar might be used:
for (Entry<Unit,Something> u: Units.entrySet()) {
...u.getKey().getPosition().getDistance(u.getValue().goal)...
Now, getKey will always return the initial unit, for example a larva... but now it's a zergling! The position of the larva will never be updated and thus this usage is in vain.
I think the equals method should include the unit type too at the very least. Opinions?
The text was updated successfully, but these errors were encountered:
@JasperGeurtz True, but I think that's "safe". The main problem here is the types that actually change classes. Some code could hold references and not detect that the instance is invalid.
I guess the code is copied from BWMirror, which only compares the
id
s to determine equality.This is rather bad for BWAPI4J where a type change also results in a new
Unit
object with the same id.If, for example used as a
Map
key the following code or similar might be used:Now,
getKey
will always return the initial unit, for example a larva... but now it's a zergling! The position of the larva will never be updated and thus this usage is in vain.I think the
equals
method should include the unit type too at the very least. Opinions?The text was updated successfully, but these errors were encountered: