{"action":"closed","issue":{"url":"https://api.github.com/repos/chrsmith/bwapi/issues/398","labels_url":"https://api.github.com/repos/chrsmith/bwapi/issues/398/labels{/name}","comments_url":"https://api.github.com/repos/chrsmith/bwapi/issues/398/comments","events_url":"https://api.github.com/repos/chrsmith/bwapi/issues/398/events","html_url":"https://github.com/chrsmith/bwapi/issues/398","id":59189781,"number":398,"title":"canUpgrade(Unit* unit, UpgradeType type) returns false incorrectly for Zerg","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chrsmith/bwapi/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/bwapi/labels/Component-Logic","name":"Component-Logic","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/bwapi/labels/Priority-High","name":"Priority-High","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/bwapi/labels/Type-Defect","name":"Type-Defect","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/bwapi/labels/Usability","name":"Usability","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-27T04:53:26Z","updated_at":"2015-02-27T04:53:26Z","closed_at":"2015-02-27T04:53:26Z","body":"```\nWhat steps will reproduce the problem?\n1. Build one evolution chamber\n2. Upgrade to Carapace level 1\n3. Upgrade to Lair\n4. Build Queen's Nest and begin to upgrade to Hive\n5. --> Broodwar->canUpgrade(unit, UpgradeTypes::Zerg_Carapace) returns false\n6. Wait until Hive completes\n7. --> Broodwar->canUpgrade(unit, UpgradeTypes::Zerg_Carapace) still returns \nfalse\n\nThere are two problems here, and they both lie within the if-statement in \nTemplates.h:393. \n\nFirstly, this only checks for _completed_ Hatcheries, Lairs, and Hives. If you \nhave a Lair that is upgrading to a Hive, it will not be credited because it is \nnot completed. Using !self->allUnitCount(...) for Lairs and Hives in the \nHatchery if-block and the same for Hives in the Lair if-block should be \nsufficient.\n\nThe second problem is that if you DO pass the previous test (step 6-7 above), \nit will continue through the else-if chain and eventually reach the final test, \nwhich will cause a false return if you do not have the exact building (Lair for \na level 2 upgrade).\n```\n\nOriginal issue reported on code.google.com by `douglas....@gmail.com` on 7 Aug 2011 at 8:10"}}