Promotion earning bug

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
I figured this out by narrowing it down to the two tables below.

This works:
Code:
<Unit_FreePromotions>
  <Row>
    <UnitType>UNIT_WARRIOR</UnitType>
    <PromotionType>PROMOTION_INVISIBLE_SUBMARINE</PromotionType>
  </Row>
</Unit_FreePromotions>
This does not:
Code:
<Policy_FreePromotions>
  <Row>
    <PolicyType>POLICY_HONOR</PolicyType>
    <PromotionType>PROMOTION_INVISIBLE_SUBMARINE</PromotionType>
  </Row>
</Policy_FreePromotions>
Both of these give the Invisible promotion correctly. However, if other promotions require Invisible, #1 works but not #2. The only explanation I can think of is a bug in the promotion-earning code. It seems like this is what happens:

  1. Check if the unit has the prerequisite promotion.
  2. Check if the prereq has CannotBeChosen=false and is in one of these tables:
    • UnitPromotions_UnitCombats
    • Unit_FreePromotions
  3. Recursively start at step 1 for the prereq's prereq.

This is unecessary design because if a unit has the prerequisite promotion, there's no need to check if it can have that promotion! :lol: The design also makes it easy to introduce bugs like forgetting to check Policy_FreePromotions. The better solution is to only do step 1; the other steps waste processing power and resulted in buggy code.
 
Back
Top Bottom