• Civilization 7 has been announced. For more info please check the forum here .

BUG + Limited Religions modcomp giving 2 religions

ono-neko

Prince
Joined
Oct 4, 2005
Messages
441
Location
SEA, Earth (+7 GMT)
Basically I am combining BUG mod and Limited Religion modcomp to the mod I'e been working on. However, I am hitting a wall where when I discover a tech, I am being given the religion that comes with that tech, as well as, being asked to choose another religion. Basically I got 2 religions with one tech. This only happens when BUG mod is added. The tests I've been doing:
  • Game with only Limited Religion mod comp
    Everything works fine
  • Game with my mod + Limited Religion mod comp
    Everything works fine
  • Game with BUG mod + Limited Religion mod comp
    I got the religion of the tech I discovered, as well as being asked to choose for another religion, resulting in receiving 2 religions
  • Game with my mod + BUG mod + Limited Religion mod comp
    I got the religion of the tech I discovered, as well as being asked to choose for another religion, resulting in receiving 2 religions
I am wondering if anyone has had this kind of problem before and may have any hint/suggestion at what I should be looking for.

Thanks!
 
check your event manager - sounds like some event is firing twice
 
right - and I would suspect that the onTechAcq event is firing twice.
 
Ok, I've been racking my brain on this issue for sometimes, and I have no clue what to look for.

Basically, the only changes I've made in CvEventManager.py are by adding the following lines near the beginning (snippet from Limited Religion's changes):
Code:
import LimitedReligions


# for C++ compatibility
false=False
true=True

Then, added additional lines into onTechAquired event (not adding a new one, but modified the existing one), so it looks like this:
Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		# Limited Religions		
		game = CyGame()
		pPlayer = gc.getPlayer(iPlayer)
		FoundRel = False
		
		#CyInterface().addImmediateMessage("onTechAcquired", "")		
		if iPlayer > -1:
			# Is this a religious Tech?
			if LimitedReligions.isReligiousTech(iTechType):
				# Is the game option selected for Limited Religions?
				if LimitedReligions.isOC_LIMITED_RELIGIONS():
					# Skip dead players and Barbarions
					if pPlayer.isAlive() and not pPlayer.isBarbarian():
						# Must not already have a Holy City
						if ( LimitedReligions.OwnsHolyCity(iPlayer) < 2 ):
							# Loop through all religions
							for iSlot in range(gc.getNumReligionInfos()):
								# Does the player have the prerequisite tech for this religion slot?
								if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getReligionInfo(iSlot).getTechPrereq()):
									# Must be at least one religion slot available
									if not game.isReligionSlotTaken(iSlot):
										# The number of religious techs discovered must be greater than total religions founded.
										if LimitedReligions.RelTechsGreaterThanReligions:
											# PreConditions are met to found a religion.
											# If the active player is Human
											if iPlayer == gc.getGame().getActivePlayer() and pPlayer.isHuman:
												# Choose religions option on?												
												if game.isOption(GameOptionTypes.GAMEOPTION_PICK_RELIGION):
													# If Autoplay is running, Let the game pick the religion.
													if( game.getAIAutoPlay() > 0 ):
														FoundRel = True
														break
														
													else:
														#Display the popup to pick a religion
														#CyInterface().addImmediateMessage("Pick Religion", "")
														LimitedReligions.doPickReligionPopup(iPlayer, iSlot)
														break
														
												else:
													# Not Playing Choose Religions, So let the game pick the religion.
													#CyInterface().addImmediateMessage("C", "")
													FoundRel = True
													break
											
											else:												
												# Not Human, So let the game pick the religion.
												#CyInterface().addImmediateMessage("Found a Religion", "")
												FoundRel = True
												break
							
							if FoundRel:
								# Get Civ's Favorite religion or random pick if favorite religion is not available.
								#iNewReligion = LimitedReligions.AI_chooseReligion(iPlayer)
								#if iNewReligion != -1:
									# Found the religion.
									#CyInterface().addImmediateMessage("Found Favorite Religion", "")
								#	pPlayer.foundReligion(iNewReligion, iSlot, True)
								if game.isOption(GameOptionTypes.GAMEOPTION_PICK_RELIGION):
									# Get Civ's Favorite religion or random pick if favorite religion is not available.
									iNewReligion = LimitedReligions.AI_chooseReligion(iPlayer)
									if iNewReligion != -1:
										# Found the religion.
										#CyInterface().addImmediateMessage("Found Favorite Religion", "")
										pPlayer.foundReligion(iNewReligion, iSlot, True)
								else:
									for i in range(gc.getNumReligionInfos()):
										if gc.getReligionInfo(i).getTechPrereq() == iTechType:
											if not gc.getGame().isReligionFounded(i):
												# Found the religion.
												#CyInterface().addImmediateMessage("Found Prerequisit Religion", "")
												pPlayer.foundReligion(i,i,True)
# End Limited Religions Mod
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not gc.getGame().isNetworkMultiPlayer()) and (iPlayer == gc.getGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)
				
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

The modcomp comes with LimitedReligions.py, which I've copied over as well.

So, I am not sure why by modifying onTechAcquired event can makes it firing twice. I even searched every python files to see if there's another onTechAcquired event, but found none, at least nothing relevant (there's one in contrib/autologEventManager.py as part of BUG, but as far as I know, it's not doing whatever I think it's doing, but only logging the event into log files).

Any help would be appreciated.
 
I did another test game, and I checked the PythonDbg.log file closely and found the following:
Code:
00:59:33 DEBUG: BugEventManager - event techAcquired: (1, 0, 0, 1)
00:59:33 DEBUG: BugEventManager - event religionFounded: (4, 0)
00:59:33 DEBUG: BugEventManager - event religionSpread: (4, 0, <CvPythonExtensions.CyCity object at 0x0F263688>)
...
...
...
00:59:41 DEBUG: BugEventManager - event religionFounded: (3, 0)
00:59:41 DEBUG: BugEventManager - event religionSpread: (3, 0, <CvPythonExtensions.CyCity object at 0x1A082848>)

So, it looks like the techAcquired event is only called once. However, the religionFounded was called twice. Now I am getting confused, as I don't think I've even made any changes at all on that event (or there's no line of code that I added anywhere that called that event).
 
what was the issue - always good to know the solution in case it happens again somewhere else.
 
OrionVeteran has two version of the modcomp, Standard and WoC. I was using Stanrdard one, which itself, works fine; only after merged into BUG mod, I ran into the issues I mentioned in OP. OrionVeteran took a look at my issues, and suggested to use the WoC version instead of the Standard version, and that one works flawlessly. You can follow the discussion at his modcomp thread. As to why the Standard didn't work as it suppose to, I am quite unsure about it; but OrionVeteran confirmed the issue.
 
to answer the original question, the reason you get two religions founded is because the gameutils function
Code:
def doHolyCity():

	return True
has to be set to True. False is the default.

See my limited religion mod in my sig which I just converted to BUG.
 
Top Bottom