google-code-export / bwapi-mono-bridge

Automatically exported from code.google.com/p/bwapi-mono-bridge
0 stars 0 forks source link

UnitType problems #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Comparing two different units' types with each other always returns false.
For example for any two not identical units a,b:

a.getType() == b.getType() will be false.

Even if both units are of the same type.

Setup:
bwapi-mono-bridge_3.3b
BWAPI_Beta_3.3

Probably irrelevant information:
Windows XP professional
MSVS 2010 ultimate ( also the source of the screenshot )
C#4.0
______________________________________________________

Because it also involves UnitType here is a question:

When storing a reference to a unit's type

( let X be a unit, UnitType store = X.getType(); )

will the object for "store" also change when the unit's type changes? I fear 
each unit has its own instance of UnitType. Due to changing types when a unit 
is cancelled from a queue to "Unknown" i need to store the previous type and 
cannot tell whether i need to use a copyconstructor or simply save the 
reference.

PS: Not yet writing a complete wrapper for UnitType, hope it will be 
unnecessary.

PPS: Thank you very much for writing the mono-bridge. It is extremely helpful 
being able to write in C# rather than c++.

Original issue reported on code.google.com by KGSmaila...@googlemail.com on 3 Jan 2011 at 7:04

Attachments:

GoogleCodeExporter commented 9 years ago
hrm, could be the .equals() function may need overriding since it might be 
comparing references. I'll look into it.

Original comment by dpershouse@gmail.com on 5 Jan 2011 at 9:03

GoogleCodeExporter commented 9 years ago
You should compare the IDs as integers.
a.getType().getID() == b.getType().getID()

Original comment by AHeinerm on 6 Jan 2011 at 12:44

GoogleCodeExporter commented 9 years ago

Original comment by dpershouse@gmail.com on 28 Apr 2011 at 8:27