Bug in military unit production modifier

NotSoGood

Emperor
Joined
Jan 25, 2009
Messages
1,077
Location
Finland
There was found a bug in int CvCity::getProductionModifier(UnitTypes eUnit). It appears when you're running a civic which gives you negative military unit production bonus. It simply ingnores it and gives you assert failure if running a debug dll.
A simple fix: we change the function to return the iMultiplier.
Code:
int CvCity::getProductionModifier(UnitTypes eUnit) const
{
	int iI;

	int iMultiplier = GET_PLAYER(getOwnerINLINE()).getProductionModifier(eUnit);

	iMultiplier += getDomainProductionModifier((DomainTypes)(GC.getUnitInfo(eUnit).getDomainType()));

	if (GC.getUnitInfo(eUnit).isMilitaryProduction())
	{
		iMultiplier += getMilitaryProductionModifier();
	}

	for (iI = 0; iI < GC.getNumBonusInfos(); iI++)
	{
		if (hasBonus((BonusTypes)iI))
		{
			iMultiplier += GC.getUnitInfo(eUnit).getBonusProductionModifier(iI);
		}
	}

	if (GET_PLAYER(getOwnerINLINE()).getStateReligion() != NO_RELIGION)
	{
		if (isHasReligion(GET_PLAYER(getOwnerINLINE()).getStateReligion()))
		{
			iMultiplier += GET_PLAYER(getOwnerINLINE()).getStateReligionUnitProductionModifier();
		}
	}

/*************************************************************************************************/
/**BugFixForNegativeUnitProductionBonus     01/04/10                              NotSoGood     **/
/**																								**/
/**                                                                                             **/
/*************************************************************************************************/
/**Original code start
	[COLOR="Blue"]return std::max(0, iMultiplier);[/COLOR]
/**Original code end**/
	[COLOR="Red"]return iMultiplier;[/COLOR]
/*************************************************************************************************/
/**BugFixForNegativeUnitProductionBonus                   END                                   **/
/*************************************************************************************************/
}
 
Hmmm ... yes, we definitely do want to allow negative modifiers for mods I would think. I wonder why Firaxis has blocked this? There are probably other functions with similar set ups.

Maybe we could allow modifiers from -50 on up ... -100 might cause divide by 0 issues in the code.
 
That really does not look like a bug but like a design choice - you simply can't go below 100% production.
That said, no production modifier was ever meant to be negative (just as no maintainance modifiers were meant to be positive, but that's s different story), the AI won't notice that multiple smaller reductions can really hurt output when combined, and would be very prone to hurt itself badly with this - which is why you set the limit to -50 I guess. Still, the only acceptable limits would be -100 or -99 (everything goes, just avoid dividing by 0) or 0 (by design no negative total multipliers).
 
I've noticed another AI thing that doesn't read negatives well. Representative gives :) in the largest cities, but if you give something :mad: in the largest cities the AI seems to still think it's positive and the AI would favour that civic.
 
The AI is bad at negatives everywhere, since most stuff had only positive effects in the unmodded game. And as I said, I believe that was a deliberate choice (to make it easier for the human players too), not just an oversight or unused opportunity.
 
I don't see why they would deliberately make it so mods would have confused AI and how that makes it easier for the human player. Also, I don't know how it would even happen that way. Why allow for negatives and then have the AI ignore them and think they're positives?
 
Top Bottom