HELP with merging my mod and BUG!!!

The Capo

godless Heathen
Joined
Jan 29, 2001
Messages
9,302
Location
Washington, DC
Hey everyone, I am trying to merge my mod and BUG and EmperorFool has informed me that I might have to write some python code in order to get the SDToolkit to work with NextWar (which is the base for my mod). I was wondering if anyone had any prior experience with doing this or if they think they would be able to help me?

I know that is a pretty general question, but I am relatively certain I can handle the rest of the merging on my own, this is the only thing I am unsure about.

Thanks in advance for any help. :goodjob:
 
The issue is that Next War's CvEventManager sticks a Python list into CvGame's script data, but BUG uses SdToolkit to store a bunch of objects in that same place. NW needs to be modified to use SdToolkit.
 
The issue is that Next War's CvEventManager sticks a Python list into CvGame's script data, but BUG uses SdToolkit to store a bunch of objects in that same place. NW needs to be modified to use SdToolkit.

Yeah, what he said.

Unfortunately I have practically no knowlege of that kind of stuff, so if anyone could help me out, even in the slightest way, it would be greatly appreciated.
 
Okay, because of the PN i've looked at the NextWar python code, and i don't see a good reason, why you could not just get rid of it.
NW python controls:
- Arcology destruction/placing of destroyed arcology
- Not being able to build lower arcology levels
- Deleting old arcology stages in a city (all more or less cosmetic)
- World destruction because of massive nuking
- And the problem, which EF refers to: Depletion of resources.

If noting is essential for you, you just should go without the NW python, and maybe merge the first 3 points later in the BUG python.
 
I think only the fourth (nukes) point is controlled using the script data list I was talking about. It's not all the Python code that needs to be rewritten--just the part that deals with get/setScripData() calls.
 
Okay, because of the PN i've looked at the NextWar python code, and i don't see a good reason, why you could not just get rid of it.
NW python controls:
- Arcology destruction/placing of destroyed arcology
- Not being able to build lower arcology levels
- Deleting old arcology stages in a city (all more or less cosmetic)
- World destruction because of massive nuking
- And the problem, which EF refers to: Depletion of resources.

If noting is essential for you, you just should go without the NW python, and maybe merge the first 3 points later in the BUG python.

Are you sure I can just get rid of that stuff without causing a problem? I mean the people who are helping me with the mod did request Next War as part of it. And to be honest I haven't really played Next War other than with my mod, so I am not entirely familiar with what those things do precisely.

But, just to get this straight; are you telling me I could ignore the Next War Event thing and use the regular SdToolkit without any issues?

I think only the fourth (nukes) point is controlled using the script data list I was talking about. It's not all the Python code that needs to be rewritten--just the part that deals with get/setScripData() calls.

Now I am a little more confused. Sorry, and thank you guys for putting up with my lack of knowlege. But I was under the impression that I had to merge these two files together, but that doesn't seem to be the case. Are you suggesting that I could simply delete the python in the NW file taht deals with/has setScriptData()?
 
The CvEventManager in NW has some extra functions that differ from or aren't in BTS's CvEventManager. Most of those need to be moved to a new module using BUG's method of adding event handlers. A couple deal with script data and nukes and need to be either a) left out or b) rewritten to use SdToolkit instead of get/setScriptData().
 
The CvEventManager in NW has some extra functions that differ from or aren't in BTS's CvEventManager. Most of those need to be moved to a new module using BUG's method of adding event handlers. A couple deal with script data and nukes and need to be either a) left out or b) rewritten to use SdToolkit instead of get/setScriptData().

But if I wanted to maintain everything that comes with Next War I have to rewrite them to use the SdToolkit rather than the get/setScriptData() thing/function/whatever?

I suppose I'll take a look at it and see what it looks like, so I basically have to search for everything in the CvEventManager file that refers to "..."ScriptData(), and then change those?
 
I know I have said this, but I don't really know much about python at all really, so if I copied the wrong things (i.e. too much or not enough let me know). This is all of the stuff I found that say ScriptData() or something of that nature:

Code:
	def onGameStart(self, argsList):
		'Called at the start of the game'

		self.initScriptData()
		
		# Are we using the scenario file? If so, then show the backstory popup
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
					szTitle = u"<font=4b>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TITLE", ()) + u"</font>"
					szBody = u"<font=3>" + localText.getText("TXT_KEY_NEXT_WAR_BACKSTORY_TEXT", ()) + u"</font>"
					popupInfo.setText(szTitle + u"\n\n" + szBody)
					popupInfo.addPopup(iPlayer)
		if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setText(u"showDawnOfMan")
					popupInfo.addPopup(iPlayer)
		else:
			CyInterface().setSoundSelectionReady(true)

		if gc.getGame().isPbem():
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
					popupInfo.setOption1(true)
					popupInfo.addPopup(iPlayer)

Code:
	def onBeginGameTurn(self, argsList):
		'Called at the beginning of the end of each turn'
		iGameTurn = argsList[0]
		CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			if iGameTurn!=0:
				if iGameTurn%2 == 0:
					self.doCheckDepletion()

Code:
	def initScriptData(self):
		
		# Set default script data manually since we need defaults for all values in the array before any functions can be called on them
		iDefaultNumNukesFired = 0
		
		aScriptData = [iDefaultNumNukesFired]
		gc.getGame().setScriptData(pickle.dumps(aScriptData))
		
	def getGameNumNukes(self):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		iNumNukes = aszScriptData[0]		 # Num Nukes Fired is 0th element
		return iNumNukes
	def setGameNumNukes(self, iValue):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		aszScriptData[0] = iValue
		gc.getGame().setScriptData(pickle.dumps(aszScriptData))
		
		self.checkNukeStuff(aszScriptData[0])
		
	def changeGameNumNukes(self, iChange):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		aszScriptData[0] = aszScriptData[0] + iChange
		gc.getGame().setScriptData(pickle.dumps(aszScriptData))
		
		self.checkNukeStuff(aszScriptData[0])
		
	def checkNukeStuff(self, iNumNukes):
		
		print("iNumNukes")
		print(iNumNukes)
		print("g_iNumNukesGameOver")
		print(g_iNumNukesGameOver)
		
		# Amount of nukes matches Warning message
		if (CyMap().plot(0,0).getScriptData() == "Scenario"):
			if (iNumNukes == g_iNumNukesWarningMessage):
				self.addPopup("", localText.getText("TXT_KEY_ROUND_THREE_NUKE_WARNING", ()))

I checked it a couple of times and I THINK that is all of the stuff that refers to the ScriptData() thing. I'll post the differences in Commagno's CvEventManager file to show the differences.
 
Sorry for the triple post, I just want to make it easier to follow. These are the differences between the NW CvEventManager.py and Commagno's.

This is in Commagno's but NOT in the regular NW version:

Code:
# BUG - Next War Merge - start
import SdToolkit
SD_MOD_ID = "NextWar"
SD_NUKES_ID = "NumNukes"
# BUG - Next War Merge - end

Code:
# BUG - Next War Merge - start
		# convert old script data list to SdToolkit for old saves
		data = gc.getGame().getScriptData()
		if isinstance(data, list):
			CvUtil.pyPrint('converting script data: %s' % data)
			iNukes = list[0]
			gc.getGame().setScriptData("")
			SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iNukes)
# BUG - Next War Merge - end

Those two were present in the Commagno version but not in the NW version at all. The next difference is actually different code. This is the code from Next War's CvEventManager.py:

Code:
	def initScriptData(self):
		
		# Set default script data manually since we need defaults for all values in the array before any functions can be called on them
		iDefaultNumNukesFired = 0
		
		aScriptData = [iDefaultNumNukesFired]
		gc.getGame().setScriptData(pickle.dumps(aScriptData))
		
	def getGameNumNukes(self):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		iNumNukes = aszScriptData[0]		 # Num Nukes Fired is 0th element
		return iNumNukes
	def setGameNumNukes(self, iValue):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		aszScriptData[0] = iValue
		gc.getGame().setScriptData(pickle.dumps(aszScriptData))
		
		self.checkNukeStuff(aszScriptData[0])
		
	def changeGameNumNukes(self, iChange):
		aszScriptData = pickle.loads(gc.getGame().getScriptData())
		aszScriptData[0] = aszScriptData[0] + iChange
		gc.getGame().setScriptData(pickle.dumps(aszScriptData))
		
		self.checkNukeStuff(aszScriptData[0])

And this is what Commagno has instead:

Code:
# BUG - Next War Merge - start
	def initScriptData(self):
		
		# Set default script data manually since we need defaults for all values in the array before any functions can be called on them
		iDefaultNumNukesFired = 0
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iDefaultNumNukesFired)
		
	def getGameNumNukes(self):
		return SdToolkit.sdGetGlobal(SD_MOD_ID, SD_NUKES_ID)

	def setGameNumNukes(self, iValue):
		SdToolkit.sdSetGlobal(SD_MOD_ID, SD_NUKES_ID, iValue)
		self.checkNukeStuff(iValue)
		
	def changeGameNumNukes(self, iChange):
		self.setGameNumNukes(self.getGameNumNukes() + iChange)
# BUG - Next War Merge - end

That appears to be it. Now, I know you mentioned before that Commagno's is for an older version of BUG, I was just wondering if this code will still work?

Just to make everything clear; the first two cells of code in this post are what is in Commagno's and NOT in the NextWar version, these last two are have first Next War's code and then the code Commagno replaced it with. I hope this makes sense. And I'm really sorry to bug you guys with this (no pun intended), but this might as well be written in Klingon to me. :crazyeye:
 
That last post is exactly what you need. Do not change the ones that reference CyMap().plot(0,0).getScriptData(). Just merge in Cammagno's changes and you should be okay. I forgot that Cammagno changed CvEventManager directly. BUG does not change this file, so you should be okay to take Cammagno's as is.
 
Well, Ripple01 helped me merge the mod, however I seem to have run into an issue and I wanted to know if you guys (or Ripple who I will direct here as well) could help me diagnose what I did wrong, or what is causing this to happen.

Since I don't know what file specifically is wrong I'll just post a few images that might help you guys diagnose the problems and what should be done. First I got this Assert Failure message at the start of the game:

attachment.php


The next problem I noticed was at the very start of the game. You will see that those extra buttons at the bottom of the screen aren't there first (they are still supposed to be there right?), secondly it says "BUGOptions - cannot locate settings folder" around six times"

Spoiler :
attachment.php


Not only did that message remain on the screen, but when there was a cultural expansion of my capital there was no event notice, nor was there any for any other thing that occured (religions being founded, techs being discovered etc.), it also looks like there is some type of text-overlap in the bottom corner where the score is:

Spoiler :
attachment.php


I may have merged this incorrectly, Ripple may have given me the wrong files (although I doubt that, as it seems he has successfully played it a few times), so I am asking which files you think would cause this to occur. Sorry to bug you all again. :sad:
 
That assert is something wrong with your XML, unrelated to BUG, but keep in mind that you will get assert failures with the stock BTS XML files when running a debug DLL that you can simply ignore.

You need a folder called UserSettings in your mod's folder. This should solve the BugOptions problems. This folder is where you put the CustDomAdv folder with its .txt file inside.

Ruff's been doing some work on the main interface's plot list code, but the PLE filter buttons should still show up if you have them enabled (on by default IIRC).
 
That assert is something wrong with your XML, unrelated to BUG, but keep in mind that you will get assert failures with the stock BTS XML files when running a debug DLL that you can simply ignore.

You need a folder called UserSettings in your mod's folder. This should solve the BugOptions problems. This folder is where you put the CustDomAdv folder with its .txt file inside.

Ruff's been doing some work on the main interface's plot list code, but the PLE filter buttons should still show up if you have them enabled (on by default IIRC).

Thanks, I'll take a look at this and try it out once I try to merge again. I took the opportunity to start working on a couple of LHs, but I'm pretty much finished with them so I can get back to trying to merge this in again.
 
I have a quick question about that UserSettings folder that hopefully EmperorFool or anyone else who reads this can help me out with.

Do I just put that folder right in the mod's folder? So if it is called DiplomacyII, I'd put it in ..../Mods/DiplomacyII/UserSettings/

Then I appear to have two CustDomAdv files, they are both XML files. One is called CustDomAdv_CIV4GameText.xml and the other is CustDomAdv Options.xml

They are both in the Assets/XML folder. Is that right or is that wrong? It sounds wrong from what you are saying.
 
Do I just put that folder right in the mod's folder? So if it is called DiplomacyII, I'd put it in ..../Mods/DiplomacyII/UserSettings/

Yes, this is where the INI files will be stored and where you should put the CustDomAdv folder which contains CustDomAdv.txt.

Then I appear to have two CustDomAdv files, they are both XML files. One is called CustDomAdv_CIV4GameText.xml and the other is CustDomAdv Options.xml

They are both in the Assets/XML folder.

That is correct. Those files are not user settings. The first one is the translated text strings used to display on the window itself, and the second defines the options used by BUG. The actual settings the user has chosen on the BUG Options screen are stored in CustDomAdv.ini in the UserSettings folder, and the page/column layout the user has created are stored in UserSettings/CustDomAdv/CustDomAdv.txt.
 
Alright, I got all of that in order (I think), but I still have issues again. This time they are different. It may just be a matter of my inability to merge the files together properly. I may have screwed up on the "patch" ripple01 provided me (he's helping me with this too), but here is what happened. First I have attached an image which shows a couple of graphical errors I think occured. The circle above the action buttons is the missing buttons that I believe are supposed to show up. The smaller circle refers to what looks like some sort of text overlap, this isn't that great an image of it, but I posted one previously that shows the same type of overlap.

After I ended my first turn and started the second turn I got some error message in the alert section and then a plethora of python exception pop-ups. Here is what it said in the alert section (I don't know the official name, but I am referring to the space underneath the tech progress bar):

"Error in BeginPlayerTurn event handler <function on BeginPlayerTurn at 0x16517670>"

Then I got the following pop-ups:
  • TypeError: list indices must be integers
  • File "SdToolKit", line 110, in sdModSave
  • File "SpyUtil", line 116, in store
  • File "SpyUtil", line 135, in onBeginPlayerTurn
  • File "BugEventManager", line 350, in_handleDefaultEvent
  • Traceback (most recent call last):

Again, I may have mistakenly copied over a file, or I may have mistakenly failed to copy over a file. So that might be it. But I figured since you are familiar with this mod you might be able to tell me what file that might be.

EDIT: I also got a CTD when I selected the BUG Help menu thing in the options screen.
 
Back
Top Bottom