negative civic unit production bonus

NotSoGood

Emperor
Joined
Jan 25, 2009
Messages
1,077
Location
Finland
I was testing how civic production modifiers work and got an error message when hovering over it in city screen. It's in the first screenshot. The second shows how it displays unproper values. I was running a civic with -75% military unit production. I haven't changed anything in the function that shows this so is it possible that even the orginal game has this problem or is it even meant to have negative production bonuses?

EDIT: Did someone someday somewhere release a debug dll for BTS? It could be better to test with it so we can remove my own mod from the reasons.
 
The second shows how it displays unproper values.

:confused: the values on the image seem right to me.
Edit: Ups, didn't see the total production :blush:.

EDIT: Did someone someday somewhere release a debug dll for BTS? It could be better to test with it so we can remove my own mod from the reasons.

Phungus has uploaded a 50 civs debug dll somewhere, but i'm not exactly sure, where he put it.
 
25% + 50% - 75% = 0%
9 + 27 = 36
0% x 36 = 0
36 + 0 = 36

Edit: Ah, the hover is correct but the City Screen is incorrect. The latter value is pulled from the CyCity object IIRC and not calculated in the Python. It probably doesn't like negative values. Check CvCity::getYieldRate(YieldTypes)
 
Phungus has uploaded a 50 civs debug dll somewhere, but i'm not exactly sure, where he put it.
I couldn't find it so PMed him.

Edit: Ah, the hover is correct but the City Screen is incorrect. The latter value is pulled from the CyCity object IIRC and not calculated in the Python. It probably doesn't like negative values. Check CvCity::getYieldRate(YieldTypes)

So the hover info is written in dll but the city screen is controlled by python so the value is taken differently. Where the city screen is drawn so I can compare how they are calculated? CvMainInterface?
 
Yes, the City Screen displays the value in CvMainInterface, but I'm pretty sure (99%) that it is displaying whatever comes from the DLL call getYieldRate(). This means that the DLL is incorrectly calculating the city's yield rate in that function but doing the correct calculation in the hover text. If you hit end turn, how many :hammers: get added to the item being built?
 
I did some calculations. When the base production was 16 :hammers: and production modifier was +10% in total (25% + 50% - 65%), so acording to the hover text production was 17 :hammers:. The production showed by the city screen was 28 :hammers:
The unit had already 33 :hammers: and the next turn it had 61 :hammers: (33 + 28 = 61). I tested it with positive modifiers and they seem to work so only the negative one won't. I also tested this with the normal BTS, and it worked exactly like this.
So the hover text calculations aren't the same as the hammers added to unit.

But why it doesn't work is mystery to me. But I found an interesting part when folowing the assert. I went from getCurrentProductionDifference(false, !bIsProcess) to getProductionModifier(UnitTypes eUnit).
Spoiler :
Code:
int CvCity::getProductionModifier(UnitTypes eUnit) const
{
	int iI;

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

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

[COLOR="Red"]	if (GC.getUnitInfo(eUnit).isMilitaryProduction())
	{
		iMultiplier += getMilitaryProductionModifier();
	}[/COLOR]
	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();
		}
	}

[COLOR="red"]	return std::max(0, iMultiplier);[/COLOR]
}
There if the MilitaryProductionModifier is negative number and there are no other modifiers, it returns 0 not the negative one. But other than that I have no idea what might be the critical point where it fails.
 
You should maybe look into the single functions which return the multiplier (getMilitaryProductionModifier(), etc) to see, what datatypes they use.
Maybe they use unsigned integers, which would probably lead to this result.
(this is just guessing, i have no experience with the SDK)
 
It seems to be a general theme of the game. Instead of having a negative you have a positive bad value. For example, Forge is +1 :yuck: instead of -1 :health:.
 
If that's what it shows for the anger display, I'll change that as well. A negative number there is misleading.
 
For BULL? Or is that possible in python for BUG?

I think you're talking about the :mad: next to the Production Bar on the City Screen. If so, then yes I can fix that in BUG. If not, you gotta be more clear.
 
Back
Top Bottom