lilijreey / bwapi

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

canUpgrade(Unit* unit, UpgradeType type) returns false incorrectly for Zerg #398

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Build one evolution chamber
2. Upgrade to Carapace level 1
3. Upgrade to Lair
4. Build Queen's Nest and begin to upgrade to Hive
5. --> Broodwar->canUpgrade(unit, UpgradeTypes::Zerg_Carapace) returns false
6. Wait until Hive completes
7. --> Broodwar->canUpgrade(unit, UpgradeTypes::Zerg_Carapace) still returns 
false

There are two problems here, and they both lie within the if-statement in 
Templates.h:393. 

Firstly, this only checks for _completed_ Hatcheries, Lairs, and Hives. If you 
have a Lair that is upgrading to a Hive, it will not be credited because it is 
not completed. Using !self->allUnitCount(...) for Lairs and Hives in the 
Hatchery if-block and the same for Hives in the Lair if-block should be 
sufficient.

The second problem is that if you DO pass the previous test (step 6-7 above), 
it will continue through the else-if chain and eventually reach the final test, 
which will cause a false return if you do not have the exact building (Lair for 
a level 2 upgrade).

Original issue reported on code.google.com by douglas....@gmail.com on 7 Aug 2011 at 8:10

GoogleCodeExporter commented 9 years ago
I'm pretty sure the check for completed Hatcheries, Lairs, and Hives is 
correct. The issue was people complained about morphing Zerg buildings being 
completed, so that behaviour was altered for BWAPI and the check was not 
correctly updated to reflect this.

Fixed this in r3834.

I'm not sure what you mean in the second problem, since if the first problem is 
fixed then that shouldn't happen.

Original comment by AHeinerm on 7 Aug 2011 at 7:24

GoogleCodeExporter commented 9 years ago
Consider 1 Hive, 1 Evolution Chamber, and Zerg Carapace 1 already upgraded.

If you are checking for Carapace 2,
- The first if statement is false, as it does not require a Hatchery
- The second if statement is false, as though it requires a Lair, you do have 
one of the required buildings
- At this point, it keeps going
- The third if statement is false, as it does not require a Spire
- The fourth if statement is TRUE, as you do not have any Lairs, and it returns 
with Insufficient_Tech

Original comment by douglas....@gmail.com on 7 Aug 2011 at 8:05

GoogleCodeExporter commented 9 years ago
How about r3835?

Original comment by AHeinerm on 8 Aug 2011 at 4:08

GoogleCodeExporter commented 9 years ago
Issue 419 has been merged into this issue.

Original comment by AHeinerm on 21 Nov 2011 at 12:46