Code
24342void CvUnit::AI_promote()24343{24344 VALIDATE_OBJECT24345 PromotionTypes eBestPromotion;24346 int iValue;24347 int iBestValue;24348 int iI;2434924350 iBestValue = 0;24351 eBestPromotion = NO_PROMOTION;2435224353 for(iI = 0; iI < GC.getNumPromotionInfos(); iI++)24354 {24355 const PromotionTypes ePromotion(static_cast<PromotionTypes>(iI));2435624357 if(canPromote(ePromotion, -1))24358 {24359 iValue = AI_promotionValue(ePromotion);24360 if(GC.getLogging() && GC.getAILogging())24361 {24362 CvPromotionEntry* pkPromotionEntry = GC.getPromotionInfo(ePromotion);24363 const char* szPromotionDesc = (pkPromotionEntry != NULL)? pkPromotionEntry->GetDescription() : "Unknown Promotion";2436424365 CvString szMsg;24366 szMsg.Format("Promotion, %s, For %s, Value: %d, Damage: %d",24367 szPromotionDesc, getName().GetCString(), iValue, getDamage());24368#if defined(MOD_BUGFIX_USE_GETTERS)24369 GET_MY_PLAYER().GetTacticalAI()->LogTacticalMessage(szMsg, true /*bSkipLogDominanceZone*/);24370#else24371 GET_PLAYER(m_eOwner).GetTacticalAI()->LogTacticalMessage(szMsg, true /*bSkipLogDominanceZone*/);24372#endif24373 }2437424375 if(iValue > iBestValue)24376 {24377 iBestValue = iValue;24378 eBestPromotion = ePromotion;24379 }24380 }24381 }2438224383 if(eBestPromotion != NO_PROMOTION)24384 {24385 promote(eBestPromotion, -1);24386 AI_promote();2438724388 if(GC.getLogging() && GC.getAILogging())24389 {24390 CvString szMsg;24391 szMsg.Format("Promotion, %s, Received by %s, X: %d, Y: %d, Damage: %d",24392 GC.getPromotionInfo(eBestPromotion)->GetDescription(), getName().GetCString(), getX(), getY(), getDamage());24393#if defined(MOD_BUGFIX_USE_GETTERS)24394 GET_MY_PLAYER().GetTacticalAI()->LogTacticalMessage(szMsg, true /*bSkipLogDominanceZone*/);24395#else24396 GET_PLAYER(m_eOwner).GetTacticalAI()->LogTacticalMessage(szMsg, true /*bSkipLogDominanceZone*/);24397#endif24398 }24399 }24400}