void CvCity::doProduction(bool bAllowNoProduction)
{
/************************************************************************************************/
/* Afforess Start 12/21/09 */
/* */
/* */
/************************************************************************************************/
if (GC.getUSE_CAN_DO_PRODUCTION_CALLBACK())
{
if (Cy::call<bool>(PYGameModule, "doProduction", Cy::Args() << this))
{
return;
}
}
/************************************************************************************************/
/* Afforess END */
/************************************************************************************************/
if (!isHuman() || isProductionAutomated())
{
// Koshling - with the unit contracting system we only build units to contractual
// orders (apart from a few emergency cases) and we should not change from building
// them due to new techs etc
if (!isProduction() || isProductionProcess() || (AI_isChooseProductionDirty() && !isProductionUnit()))
{
AI_chooseProduction();
}
}
if (!bAllowNoProduction && !isProduction())
{
return;
}
if (isProductionProcess())
{
/************************************************************************************************/
/* UNOFFICIAL_PATCH 12/07/09 denev & jdog5000 */
/* */
/* Bugfix, Odd behavior */
/************************************************************************************************/
if (m_bPopProductionProcess)
{
popOrder(0, false, true);
m_bPopProductionProcess = false;
}
/************************************************************************************************/
/* UNOFFICIAL_PATCH END */
/************************************************************************************************/
return;
}
if (isDisorder())
{
return;
}
if (isProduction())
{
changeProduction(getCurrentProductionDifference(false, true));
setOverflowProduction(0);
setFeatureProduction(0);
/************************************************************************************************/
/* Afforess Multiple Production Mod 08/23/09 */
/* */
/* */
/************************************************************************************************/
setBuiltFoodProducedUnit(isFoodProduction());
clearLostProduction();
int iOverflowProductionModified = 0;
while (isProduction() && productionLeft() <= iOverflowProductionModified)
{
changeProduction(iOverflowProductionModified);
setOverflowProduction(0);
popOrder(0, true, true);
if (!isHuman() && !isProduction())
{
AI_chooseProduction();
}
//to eliminate pre-build exploits for all Wonders and all Projects
if (isProductionWonder() || isProductionProject())
{
break;
}
//to eliminate pre-build exploits for Settlers and Workers
if (isFoodProduction() && !isBuiltFoodProducedUnit())
{
break;
}
if (isProductionProcess())
{
break;
}
//fix production which floods from overflow capacity to next queue item if it exists
if (isProduction() && m_iLostProductionBase > 0)
{
changeProduction(getExtraProductionDifference(m_iLostProductionBase));
clearLostProduction();
}
iOverflowProductionModified = getOverflowProductionDifference();
}
if (m_iGoldFromLostProduction > 0)
{
MEMORY_TRACK_EXEMPT();
CvWString szBuffer = gDLL->getText("TXT_KEY_MISC_LOST_PROD_CONVERTED", getNameKey(), m_iLostProductionModified, m_iGoldFromLostProduction);
AddDLLMessage(getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_WONDERGOLD", MESSAGE_TYPE_MINOR_EVENT, GC.getCommerceInfo(COMMERCE_GOLD).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), getX_INLINE(), getY_INLINE(), true, true);
GET_PLAYER(getOwnerINLINE()).changeGold(m_iGoldFromLostProduction);
clearLostProduction();
}
/************************************************************************************************/
/* Afforess Multiple Production Mod END */
/************************************************************************************************/
}
else
{
changeOverflowProduction(getCurrentProductionDifference(false, false), getProductionModifier());
}
}