1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Bug in military unit production modifier

Discussion in 'Civ4 - Unofficial Patches' started by NotSoGood, Apr 1, 2010.

  1. NotSoGood

    NotSoGood Chieftain

    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                                   **/
    /*************************************************************************************************/
    }
     
  2. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    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.
     
  3. Fuyu

    Fuyu Chieftain

    Joined:
    Nov 5, 2009
    Messages:
    1,220
    Location:
    Austria
    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).
     
  4. Minor Annoyance

    Minor Annoyance Chieftain

    Joined:
    Jun 27, 2007
    Messages:
    2,247
    Gender:
    Male
    Location:
    Hamilton, Ontario
    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.
     
  5. Fuyu

    Fuyu Chieftain

    Joined:
    Nov 5, 2009
    Messages:
    1,220
    Location:
    Austria
    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.
     
  6. Minor Annoyance

    Minor Annoyance Chieftain

    Joined:
    Jun 27, 2007
    Messages:
    2,247
    Gender:
    Male
    Location:
    Hamilton, Ontario
    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?
     

Share This Page