NonStateReligionCommerce display issue

Opera

Deity
Joined
Sep 21, 2008
Messages
4,643
Hi there :)

I took my code from Legends of Revolution; it's used to allow a player with a certain trait to still get the commerces from non-state religions in her empire. It actually works but it doesn't show up in the religion screen, even though there's this modification (between the comments) in CvGameTextMgr::setReligionHelpCity :
Code:
	if (eStateReligion == eReligion || eStateReligion == NO_RELIGION
/*************************************************************************************************/
/** NonStateReligionCommerce            Opera (from Legends of Revolution)  21.09.09            **/
/*************************************************************************************************/
        || (GET_PLAYER(pCity->getOwnerINLINE()).isNonStateReligionCommerce())
/*************************************************************************************************/
/** NonStateReligionCommerce            END                                                     **/
/*************************************************************************************************/
        || bForceState)
	{
		for (i = 0; i < NUM_COMMERCE_TYPES; i++)
		{
			iCommerce = GC.getReligionInfo(eReligion).getStateReligionCommerce((CommerceTypes)i);

			if (pCity->isHolyCity(eReligion))
			{
				iCommerce += GC.getReligionInfo(eReligion).getHolyCityCommerce((CommerceTypes)i);
			}

			if (iCommerce != 0)
			{
				if (bHandled)
				{
					szBuffer.append(L", ");
				}

				szTempBuffer.Format(L"%s%d%c", iCommerce > 0 ? "+" : "", iCommerce, GC.getCommerceInfo((CommerceTypes)i).getChar());
				szBuffer.append(szTempBuffer);
				bHandled = true;
			}
		}
	}
I don't really get why it's not working. FYI, a similar check is run in CvCity to allow the commerces to be added and it works, but here, it doesn't.

Edit: Nevermind, I think I found what was wrong. I guess it's because when you have a state religion, it is automatically selected when you enter the screen, so the python only draws the commerces for this religion. But it's annoying as it seems like the trait isn't working...

I guess I would have to tweak this part of CvReligionScreen.py:
Code:
			if (iLinkReligion == -1):
				bFirst = True
				for iI in range(len(lReligions)):
					szTempBuffer = CyGameTextMgr().getReligionHelpCity(lReligions[iI], pLoopCity.GetCy(), False, False, False, True)
					if (szTempBuffer):
						if (not bFirst):
							szCityName += u", "
						szCityName += szTempBuffer
						bFirst = False
			else:
				szCityName += CyGameTextMgr().getReligionHelpCity(iLinkReligion, pLoopCity.GetCy(), False, False, True, False)
So that it still loops over all religions... Any idea about how to write this bit?
 
Can't you just check the same CvPlayer attribute, assuming you've exposed it to Python?

Code:
if (iLinkReligion == -1 [B]or gc.getPlayer(pLoopCity.getOwner()).isNonStateReligionCommerce()[/B]):
 
Actually, it's more or less what I just did. But I needed a tweak to make it so happiness and benefits from state religion appeared:
Code:
			if (iLinkReligion == -1) [b]or (gc.getPlayer(self.iActivePlayer).isNonStateReligionCommerce())[/b]: ## Modified by Opera
				bFirst = True
				for iI in range(len(lReligions)):
					[b]if (iLinkReligion > -1):
						if (lReligions[iI] == iLinkReligion):
							szTempBuffer = CyGameTextMgr().getReligionHelpCity(iLinkReligion, pLoopCity.GetCy(), False, False, True, False)
						else:[/b]
							szTempBuffer = CyGameTextMgr().getReligionHelpCity(lReligions[iI], pLoopCity.GetCy(), False, False, False, True)
					else:
						szTempBuffer = CyGameTextMgr().getReligionHelpCity(lReligions[iI], pLoopCity.GetCy(), False, False, False, True)
					if (szTempBuffer):
						if (not bFirst):
							szCityName += u", "
						szCityName += szTempBuffer
						bFirst = False
			else:
				szCityName += CyGameTextMgr().getReligionHelpCity(iLinkReligion, pLoopCity.GetCy(), False, False, True, False)
Seems to work nicely :)
 
Could you upload the source files you changed from LoR on this with your altered code commented so I can add this display to LoR? I didn't even think about the religious screen, but now that you've brought it to my attention I should fix it, especially since you've already done the hard work :)
 
I zipped and attached them to this post.

I included CvGameTxtMgr.cpp and CyPlayer.cpp, .h and CyPlayerInterface2.cpp; I don't remember if you had exposed CvPlayer::isNonStateReligionCommerce() or if I had to do it... I also included CvReligionScreen.py; you can find my changes either by searching "Opera" or "NonStateReligionCommerce". There's one uncommented change but it comes from your mod, so you should be fine with it. The most important changes are in the .py file and, come to think of it, I don't think I've anything different in CvGameTxtMgr.cpp for displaying this... :lol:
 

Attachments

  • NonState Religion Commerce Display.zip
    111.5 KB · Views: 30
Thanks for checking out and improving Legends of Revolution. I will update my custom dll with your code along with the Lead from Behind modcomp in the next update of LoR. :)
 
Top Bottom