Advertisement
Civilization Fanatics' Center  

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Project & Mod Development > Civ4 - Unofficial Patches

Reply
 
Thread Tools
Old Apr 01, 2010, 01:18 AM   #1
NotSoGood
Emperor
 
NotSoGood's Avatar
 
Join Date: Jan 2009
Location: Finland
Posts: 1,077
Bug in military unit production modifier

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
	return std::max(0, iMultiplier);
/**Original code end**/
	return iMultiplier;
/*************************************************************************************************/
/**BugFixForNegativeUnitProductionBonus                   END                                   **/
/*************************************************************************************************/
}
__________________
1st Champion of the Somnium League!
19th and 20th Century mod Download
NotSoGood is offline   Reply With Quote
Old Apr 04, 2010, 10:58 AM   #2
jdog5000
Revolutionary
 
jdog5000's Avatar
 
Join Date: Nov 2003
Location: California
Posts: 2,596
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.
jdog5000 is offline   Reply With Quote
Old May 13, 2010, 03:27 AM   #3
Fuyu
Emperor
 
Fuyu's Avatar
 
Join Date: Nov 2009
Location: Austria
Posts: 1,149
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).

Last edited by Fuyu; May 13, 2010 at 03:31 AM.
Fuyu is offline   Reply With Quote
Old May 14, 2010, 09:41 PM   #4
Minor Annoyance
Emperor
 
Minor Annoyance's Avatar
 
Join Date: Jun 2007
Location: Hamilton, Ontario
Posts: 1,339
I've noticed another AI thing that doesn't read negatives well. Representative gives in the largest cities, but if you give something in the largest cities the AI seems to still think it's positive and the AI would favour that civic.
Minor Annoyance is offline   Reply With Quote
Old May 14, 2010, 11:12 PM   #5
Fuyu
Emperor
 
Fuyu's Avatar
 
Join Date: Nov 2009
Location: Austria
Posts: 1,149
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.
Fuyu is offline   Reply With Quote
Old May 15, 2010, 09:58 AM   #6
Minor Annoyance
Emperor
 
Minor Annoyance's Avatar
 
Join Date: Jun 2007
Location: Hamilton, Ontario
Posts: 1,339
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?
Minor Annoyance is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Project & Mod Development > Civ4 - Unofficial Patches > Bug in military unit production modifier

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to have production modifier only affect buildings? jefmart1 Civ4 - Creation & Customization 6 Nov 08, 2008 05:22 AM
Checking Military Unit Production (Quick Q) agoodfella Civ4 - General Discussions 3 May 12, 2007 03:18 PM
Bonus Production Modifier in UnitInfos GRM7584 Civ4 - Creation & Customization 17 Apr 18, 2007 11:27 AM
Is "our mutual military assistance" diplomatic modifier too weak? marioflag Civ4 - General Discussions 15 Apr 24, 2006 09:36 AM
Proposal: Add 10x modifier to unit stats OmniMower Civ3 - Creation & Customization 14 Sep 05, 2002 11:38 AM


Advertisement

All times are GMT -6. The time now is 02:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
This site is copyright Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR