Can anyone give some python help plz?

Bad Player

Deity
Joined
Oct 31, 2005
Messages
3,534
Location
(Bris)Vegas!
OK so after working on this for a while (with help from a few ppl!!!) I have encountered a stumbling block... I figured a new thread might attract more attention and also be a lot less confusing than the old thread which had much preliminary work in it.

The program is designed to save the cities of a map and then load them on the next map. Thus, if you destroy one city on a map, when you load the (possibly expanded size) map in the next scenario, that city is remembered as being destroyed. The same applies if a nation conquers a city. This program remembers things such as what buildings are in the city, how many people, how much culture, etc. I've had to divide it into multiple posts because of size.

This goes inside the ffh2 eventmanager.py file. It saves the data to 2 files. I did this and then tried to load it (by commenting out this part of the program of course) onto a new map. I checked it is trying to load onto grass/plains.
Spoiler :

Code:
	def onGameEnd(self, argsList):
		'Called at the End of the game'
		print("Game is ending")

                ToSurvivingLeadersFile = open('D:\SurvivingLeadersFile', 'w')
                SurvivingLeadersList = []
                for iPlayer in range(gc.getMAX_PLAYERS()):
                        if gc.getPlayer(iPlayer).isAlive():
                                pLoopPlayer = gc.getPlayer(iPlayer)
                                iPlayerNum = iPlayer
                                iLeader = pLoopPlayer.getLeaderType()
                                iCiv = pLoopPlayer.getCivilizationType()
                                iTeam = pLoopPlayer.getTeam()
                                SurvivingLeadersList.append( [iPlayerNum, iLeader, iCiv, iTeam] )


                pickle.dump(SurvivingLeadersList, ToSurvivingLeadersFile)                
                ToSurvivingLeadersFile.close()


                ToFirstCityMapFile = open('D:\FirstCityMapFile', 'w')
                CityInfoList = []
                #this line calls gc.getMAX_PLAYERS() which is an SDK function.
                #iPlayerNum should be the same for each civ in both data files.  Here's to hoping!
                for iPlayer in range(gc.getMAX_PLAYERS()):
                        apCityList = PyPlayer(iPlayer).getCityList()
                        for pCity in apCityList:
                            iPlayerNum = iPlayer
                            CityInfoList.append(iPlayerNum)
                            eCityName = pCity.getName()
                            #What is the correct prefix for CityName.  I used 'e' but that's probably wrong.
                            CityInfoList.append(eCityName)
                            iX = pCity.getX()
                            CityInfoList.append(iX)
                            iY = pCity.getY()
                            CityInfoList.append(iY)
                            iPop = pCity.getPopulation()
                            CityInfoList.append(iPop)
                            iCulture = pCity.getCulture()
                            CityInfoList.append(iCulture)
                            iBuildingNumValue = 0
#                            #BTS only while loop.
#				for iBuildingValue in range(gc.getNumBuildingInfos()):
#					CityInfoList.append(pCity.getNumRealBuilding(iBuildingNumValue))
#                            CityInfoList.append('endcity')


                pickle.dump(CityInfoList, ToFirstCityMapFile)                
                ToFirstCityMapFile.close()
		return
 
Inside Eventmanager.py, this loads the saved files (it replaces the civs/leaders and cities onto a blank/new map).:

Spoiler :

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

		...

        	unpickledLeadersFile = open('D:\SurvivingLeadersFile', 'r')
        	unpickledLeadersFileList = pickle.load(unpickledLeadersFile)
 
 
        	unpickledCityFile = open('D:\FirstCityMapFile','r')
        	unpickledCityFileList = pickle.load(unpickledCityFile)

                unpickledCityFileListValue = 0                                          
 
                for iLeaderCivCounter in range(len(unpickledLeadersFileList)):
                        iPlayerNum, iLeader, iCiv, iTeam = unpickledLeadersFileList[iLeaderCivCounter]
                        print 'iLeaderCivCounter =', iLeaderCivCounter
			print 'iPlayerNum =', iPlayerNum
			print 'iLeader =', iLeader
			print 'iCiv =', iCiv
			print 'iTeam =', iTeam
			# This adds non-barbarian players to the game.
			if iLeaderCivCounter < len(unpickledLeadersFileList)-1:
                        	CyGame().addPlayerAdvanced(iLeaderCivCounter, iTeam, iLeader, iCiv)
                        #FFH2 only method (addPlayerAdvanced)
                        # This retrieves the variables iPlayerNum, eCityName, iX, iY, iPop, iCulture, EndofCityTag

                        iTempiPlayerNum = iPlayerNum
                        while iTempiPlayerNum == iPlayerNum and unpickledCityFileListValue < len(unpickledCityFileList):
                                iPlayerNum = unpickledCityFileList[unpickledCityFileListValue]
                                print 'unpickledCityFileListValue =', unpickledCityFileListValue
                                print 'len(unpickledCityFileList) =', len(unpickledCityFileList)
                                print 'iTempiPlayerNum =', iTempiPlayerNum
                                print 'iPlayerNum =', iPlayerNum
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                eCityName = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1                             
                                iX = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                iY = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                iPop = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                iCulture = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                #Retrieve specialists in city here
                                #Retrieve religions in city here
                                #Retrieve buildings here
                                EndofCityTag = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                print 'unpickledCityFileListValue =', unpickledCityFileListValue
                                if iTempiPlayerNum == iPlayerNum:
                                        if iPlayerNum == 35:
                                                print 'Got to barb initcity'
                                                pPlayer = gc.getPlayer(35)
                                                pCity = pPlayer.initCity(iX,iY)
                                                pCity.setName(eCityName,False)
                                                pCity.setPopulation(iPop)
                                                pCity.setCulture(35,iCulture,True)
                                                iPlayerNum = unpickledCityFileList[unpickledCityFileListValue]
                                        else:
                                                print 'Got to regular initcity'
                                                print 'iTempiPlayerNum =', iTempiPlayerNum
                                                pPlayer = gc.getPlayer(iLeaderCivCounter)
                                                print 'iX =', iX
                                                print 'iY =', iY
                                                # RuntimeError: unidentifiable c++ exception (initcity line) but the debug log looks fine...
                                                pCity = pPlayer.initCity(iX,iY)
                                                pCity.setName(eCityName,False)
                                                pCity.setPopulation(iPop)
                                                pCity.setCulture(iLeaderCivCounter,iCulture,True)
                                                iPlayerNum = unpickledCityFileList[unpickledCityFileListValue]
 
        	unpickledLeadersFile.close()
        	unpickledCityFile.close()


The print lines are used to print the information to the debug log file (see 2 posts below).
 
I will highlight what I think are the important bits in blue but I will put all of the PythonDbg.log file in these following posts (the blue is in the last post but these posts show the whole debug file).
Spoiler :

Code:
Initializing Python
1. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\email
2. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\encodings
3. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx
4. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\build
5. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\lib
6. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale
7. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\py
8. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\tools
9. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\lib\colourchooser
10. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\lib\editor
11. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\lib\floatcanvas
12. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\lib\masked
13. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\lib\mixins
14. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\lib\ogl
15. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\af
16. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\ca
17. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\cs
18. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\da
19. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\de
20. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\el
21. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\es
22. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\eu
23. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\fi
24. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\fr
25. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\hi
26. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\hu
27. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\id
28. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\it
29. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\ja
30. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\lv
31. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\nb
32. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\nl
33. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\pl
34. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\pt_BR
35. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\ru
36. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\sl
37. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\sv
38. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\tr
39. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\uk
40. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\zh_CN
41. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\zh_TW
42. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\af\LC_MESSAGES
43. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\ca\LC_MESSAGES
44. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\cs\LC_MESSAGES
45. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\da\LC_MESSAGES
46. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\de\LC_MESSAGES
47. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\el\LC_MESSAGES
48. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\es\LC_MESSAGES
49. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\eu\LC_MESSAGES
50. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\fi\LC_MESSAGES
51. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\fr\LC_MESSAGES
52. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\hi\LC_MESSAGES
53. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\hu\LC_MESSAGES
54. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\id\LC_MESSAGES
55. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\it\LC_MESSAGES
56. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\ja\LC_MESSAGES
57. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\lv\LC_MESSAGES
58. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\nb\LC_MESSAGES
59. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\nl\LC_MESSAGES
60. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\pl\LC_MESSAGES
61. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\pt_BR\LC_MESSAGES
62. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\ru\LC_MESSAGES
63. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\sl\LC_MESSAGES
64. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\sv\LC_MESSAGES
65. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\tr\LC_MESSAGES
66. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\uk\LC_MESSAGES
67. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\zh_CN\LC_MESSAGES
68. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\locale\zh_TW\LC_MESSAGES
69. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\py\tests
70. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\tools\XRCed
71. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM\wx\tools\XRCed\src-images
72. Using Python sys path: ..\WARLORDS\ASSETS\PYTHON\SYSTEM
sys.path =
 
['..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\email', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\encodings', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\build', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\lib', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\py', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\tools', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\lib\\colourchooser', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\lib\\editor', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\lib\\floatcanvas', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\lib\\masked', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\lib\\mixins', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\lib\\ogl', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\af', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\ca', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\cs', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\da', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\de', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\el', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\es', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\eu', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\fi', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\fr', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\hi', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\hu', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\id', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\it', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\ja', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\lv', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\nb', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\nl', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\pl', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\pt_BR', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\ru', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\sl', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\sv', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\tr', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\uk', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\zh_CN', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\zh_TW', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\af\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\ca\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\cs\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\da\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\de\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\el\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\es\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\eu\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\fi\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\fr\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\hi\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\hu\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\id\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\it\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\ja\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\lv\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\nb\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\nl\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\pl\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\pt_BR\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\ru\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\sl\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\sv\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\tr\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\uk\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\zh_CN\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\locale\\zh_TW\\LC_MESSAGES', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\py\\tests', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\tools\\XRCed', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM\\wx\\tools\\XRCed\\src-images', '..\\WARLORDS\\ASSETS\\PYTHON\\SYSTEM']


sys.modules =
 
{'zipimport': <module 'zipimport' (built-in)>, 'signal': <module 'signal' (built-in)>, '__builtin__': <module '__builtin__' (built-in)>, 'sys': <module 'sys' (built-in)>, '__main__': <module '__main__' (built-in)>, 'exceptions': <module 'exceptions' (built-in)>, 'CvPythonExtensions': <module 'CvPythonExtensions' (built-in)>}


sys.builtin_module_names =
 
('CvPythonExtensions', '__builtin__', '__main__', '_bisect', '_codecs', '_codecs_cn', '_codecs_hk', '_codecs_iso2022', '_codecs_jp', '_codecs_kr', '_codecs_tw', '_csv', '_heapq', '_hotshot', '_locale', '_multibytecodec', '_random', '_sre', '_subprocess', '_symtable', '_weakref', '_winreg', 'array', 'audioop', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'collections', 'datetime', 'errno', 'exceptions', 'gc', 'imageop', 'imp', 'itertools', 'marshal', 'math', 'md5', 'mmap', 'msvcrt', 'nt', 'operator', 'parser', 'regex', 'rgbimg', 'sha', 'signal', 'strop', 'struct', 'sys', 'thread', 'time', 'xxsubtype', 'zipimport')
 
Spoiler :

Code:
1. Using moduleSearchDirs: python\entrypoints\
2. Using moduleSearchDirs: python\screens\
3. Using moduleSearchDirs: python\pywb\
4. Using moduleSearchDirs: python\
5. Using moduleSearchDirs: python\pitboss\
6. Using moduleSearchDirs: python\pyhelper\
7. Using moduleSearchDirs: python\pyunit\
8. Using moduleSearchDirs: python\_debugtools\
9. Using moduleSearchDirs: 
EntryPoint module:cvrandomeventinterface
EntryPoint module:cvspellinterface
EntryPoint module:cvscreensinterface
EntryPoint module:cvpopupinterface
EntryPoint module:cvtranslator
EntryPoint module:cvgameinterface
EntryPoint module:cvoptionsscreencallbackinterface
EntryPoint module:cvwbinterface
EntryPoint module:pbmain
EntryPoint module:cvappinterface
EntryPoint module:rainforest
EntryPoint module:terra
EntryPoint module:donut
EntryPoint module:big_and_small
EntryPoint module:boreal
EntryPoint module:medium_and_small
EntryPoint module:global_highlands
EntryPoint module:hemispheres
EntryPoint module:arboria
EntryPoint module:highlands
EntryPoint module:cvgameinterfacefile
EntryPoint module:cvmapscriptinterface
EntryPoint module:islands
EntryPoint module:great_plains
EntryPoint module:continents
EntryPoint module:fantasy_realm
EntryPoint module:archipelago
EntryPoint module:wheel
EntryPoint module:lakes
EntryPoint module:tilted_axis
EntryPoint module:inland_sea
EntryPoint module:mirror
EntryPoint module:fractal
EntryPoint module:oasis
EntryPoint module:pangaea
EntryPoint module:hub
EntryPoint module:balanced
EntryPoint module:maze
EntryPoint module:custom_continents
EntryPoint module:shuffle
EntryPoint module:ring
EntryPoint module:team_battleground
EntryPoint module:cvunitcontrolinterface
EntryPoint module:cvdiplomacyinterface
EntryPoint module:cvdebuginterface
EntryPoint module:cvscreenutilsinterface
EntryPoint module:cveventinterface
EntryPoint module:ice_age
load_module CvEventInterface

load_module CvUtil

load_module traceback

load_module CvEventManager

load_module CvScreensInterface

load_module CvMainInterface

load_module ScreenInput

load_module CvScreenEnums

load_module time

load_module CvDomesticAdvisor

load_module CvTechChooser

load_module CvForeignAdvisor

load_module math

load_module CvExoticForeignAdvisor

load_module IconGrid

load_module DomPyHelpers

load_module PyHelpers

load_module TechTree

load_module re

load_module CvMilitaryAdvisor

load_module CvFinanceAdvisor

load_module CvReligionScreen

load_module CustomFunctions

load_module Popup

load_module CvCorporationScreen

load_module CvCivicsScreen

load_module string

load_module CvVictoryScreen

load_module CvEspionageAdvisor

load_module CvOptionsScreen

load_module CvReplayScreen

load_module CvHallOfFameScreen

load_module CvDanQuayle

load_module CvGameUtils

load_module CvUnVictoryScreen

load_module CvDawnOfMan

load_module CvTechSplashScreen

load_module CvTopCivs

load_module random

load_module CvInfoScreen

load_module CvIntroMovieScreen

load_module CvVictoryMovieScreen

load_module CvWonderMovieScreen

load_module CvEraMovieScreen

load_module CvSpaceShipScreen

load_module CvPediaMain

load_module CvPediaScreen

load_module CvScreen

load_module CvPediaTech

load_module CvPediaUnit

load_module CvPediaBuilding

load_module CvPediaPromotion

load_module CvPediaUnitChart

load_module CvPediaBonus

load_module CvPediaTerrain

load_module CvPediaFeature

load_module CvPediaImprovement

load_module CvPediaCivic

load_module CvPediaCivilization

load_module CvPediaLeader

load_module CvPediaSpecialist

load_module CvPediaHistory

load_module CvPediaProject

load_module CvPediaReligion

load_module CvPediaSpell

load_module CvPediaCorporation

load_module CvWorldBuilderScreen

load_module CvWorldBuilderDiplomacyScreen

load_module CvDebugTools

load_module CvDebugInfoScreen

load_module CvMapGeneratorUtil

load_module CvGFCScreen

load_module CvPopupInterface

load_module CvScreenUtilsInterface

load_module CvScreenUtils

init-ing world builder screen

load_module CvWBPopups

load_module CvCameraControls

load_module CvAdvisorUtils

load_module pickle
 
Spoiler :

Code:
PY:OnInit
load_module CvAppInterface

load_module Archipelago

load_module Balanced

load_module Continents

load_module Custom_Continents

load_module Fantasy_Realm

load_module Fractal

load_module Great_Plains

load_module Highlands

load_module Hub

load_module Ice_Age

load_module Inland_Sea

load_module Islands

load_module Lakes

load_module Maze

load_module Mirror

load_module Oasis

load_module Pangaea

load_module Ring

load_module Shuffle

load_module Team_Battleground

load_module Terra

load_module Tilted_Axis

load_module Wheel

load_module Arboria

load_module Big_and_Small

load_module Boreal

load_module Donut

load_module Global_Highlands

load_module Hemispheres

load_module Medium_and_Small

load_module Rainforest

load_module CvWBInterface

load_module CvWBDesc

load_module array

PY:loadDesc:C:\Users\User\Documents\My Games\Beyond the Sword\Saves\WorldBuilder\testmaptiny, curDir:D:\2K Games\Firaxis Games\Sid Meier's Civilization 4 Complete\Beyond the Sword
Reading game desc

Reading teams desc

reading team 0

reading team 1

reading team 2

reading team 3

reading team 4

reading team 5

reading team 6

reading team 7

reading team 8

reading team 9

reading team 10

reading team 11

reading team 12

reading team 13

reading team 14

reading team 15

reading team 16

reading team 17

reading team 18

reading team 19

reading team 20

reading team 21

reading team 22

reading team 23

reading team 24

reading team 25

reading team 26

reading team 27

reading team 28

reading team 29

reading team 30

reading team 31

reading team 32

reading team 33

reading team 34

Reading players desc

Reading map desc

Reading/creating 384 plot descs

Reading/creating 0 sign descs

WB read done
 
Spoiler :

Code:
[COLOR="Blue"]
PY:Player 0's alive status set to: 1
PY:Player 1's alive status set to: 1
PY:Player 2's alive status set to: 1
PY:Player 35's alive status set to: 1[/COLOR]
map rebuild. gridw=24, gridh=16
preapply plots

map apply - recalc areas/regions

apply plots

apply signs

Randomize Resources

WB apply done

load_module CvGameInterface

load_module CvGameInterfaceFile

load_module encodings

load_module encodings.latin_1

8500 - gold

8501 - research

8502 - culture

8503 - espionage

8483 - food

8484 - production

8485 - commerce

8550 - fellowship of leaves

8551 - fellowship of leaves

8552 - order

8553 - order

8554 - octopus overlords

8555 - octopus overlords

8556 - runes of kilmorph

8557 - runes of kilmorph

8558 - ashen veil

8559 - ashen veil

8560 - empyrean

8561 - empyrean

8562 - council of esus

8563 - council of esus

3 SCREEN TURNED ON

99 SCREEN TURNED ON

load_module encodings.raw_unicode_escape

load_module encodings.string_escape
[COLOR="Blue"]
iLeaderCivCounter =
 
0

iPlayerNum =
 
0

iLeader =
 
27

iCiv =
 
12

iTeam =
 
0

PY:Player 0's alive status set to: 1
unpickledCityFileListValue =
 
0

len(unpickledCityFileList) =
 
21

iTempiPlayerNum =
 
0

iPlayerNum =
 
0

unpickledCityFileListValue =
 
7

Got to regular initcity

iTempiPlayerNum =
 
0

iX =
 
8

iY =
 
13

iLeaderCivCounter =
 
1

iPlayerNum =
 
1

iLeader =
 
25

iCiv =
 
11

iTeam =
 
1

PY:Player 1's alive status set to: 1
unpickledCityFileListValue =
 
7

len(unpickledCityFileList) =
 
21

iTempiPlayerNum =
 
1

iPlayerNum =
 
1

unpickledCityFileListValue =
 
14

Got to regular initcity

iTempiPlayerNum =
 
1

iX =
 
11

iY =
 
3

iLeaderCivCounter =
 
2

iPlayerNum =
 
2

iLeader =
 
30

iCiv =
 
14

iTeam =
 
2

PY:Player 2's alive status set to: 1
unpickledCityFileListValue =
 
14

len(unpickledCityFileList) =
 
21

iTempiPlayerNum =
 
2

iPlayerNum =
 
2

unpickledCityFileListValue =
 
21

Got to regular initcity

iTempiPlayerNum =
 
2

iX =
 
21

iY =
 
13[/COLOR]

PY:saveDesc:C:\Users\User\Documents\My Games\Beyond the Sword\Saves\WorldBuilder\WBQuickSave, curDir:D:\2K Games\Firaxis Games\Sid Meier's Civilization 4 Complete\Beyond the Sword
WBSave done

PY:OnPreSave
Game is ending


Now there were 3 civs in the save file, each with their capital city (I retired on turn 2): the amurites (me), the hippus, and the balseraphs. So the save files have dain, tasunke??, and keelyn and 3 capital cities.

If you want to try it, just copy the saving part into your FFH2 eventmanager.py file and then remove/comment out it before trying to load it with the loading part of the program (again copy-paste to your eventmanager.py file). Note that it will create the 2 files in D drive (you can easily change that to C drive if you want).
 
This looks great, can't wait to try it out, but...

what exactly did you need help with?
 
I'm trying to work out why it crashes at the end (check out the end of the last spoiler)... It CTD's when it should have just loaded all the saved civs and cities.

BTW I forgot to mention - you need to run EITHER the save (first) or the load (second) by commenting out the non-used part. It's designed for use in sequential scenarios.

I'm on holidays so I have only limited time to keep on with it... But I need this for my pirates campaign :(
 
Just out of curiousity, have you dug into the DLL files at all to see how they handle savegames natively?

If I understand what you are trying to do, it looks like you are trying to capture only the civ identity, leader, and existing city infos -- and then pass them on to the next scenario, right? I seem to recall that a lot of that stuff is header information in the savegame files -- right before it gets into the plot by plot descriptions.

I have been struggling with a similar question, but didn't get very far. Your python experience is way advanced beyond mine, but you seem to be on the right track.
 
Could anyone please help me create a e.g. capria-bannor city at the part marked in blue? This is the part of event manager that loads the saved civs and cities. I want to see if it's the loop or the initCity command causing the CTD.

btw LM I would have no idea about dll stuff. I just did a tutorial on python and got good help from some guys. :)

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

		...

        	unpickledLeadersFile = open('D:\SurvivingLeadersFile', 'r')
        	unpickledLeadersFileList = pickle.load(unpickledLeadersFile)
 
 
        	unpickledCityFile = open('D:\FirstCityMapFile','r')
        	unpickledCityFileList = pickle.load(unpickledCityFile)

                unpickledCityFileListValue = 0                                          
 
                for iLeaderCivCounter in range(len(unpickledLeadersFileList)):
                        iPlayerNum, iLeader, iCiv, iTeam = unpickledLeadersFileList[iLeaderCivCounter]
                        print 'iLeaderCivCounter =', iLeaderCivCounter
			print 'iPlayerNum =', iPlayerNum
			print 'iLeader =', iLeader
			print 'iCiv =', iCiv
			print 'iTeam =', iTeam
			# This adds non-barbarian players to the game.
			if iLeaderCivCounter < len(unpickledLeadersFileList)-1:
                        	CyGame().addPlayerAdvanced(iLeaderCivCounter, iTeam, iLeader, iCiv)
                        #FFH2 only method (addPlayerAdvanced)
                        # This retrieves the variables iPlayerNum, eCityName, iX, iY, iPop, iCulture, EndofCityTag

                        iTempiPlayerNum = iPlayerNum
                        while iTempiPlayerNum == iPlayerNum and unpickledCityFileListValue < len(unpickledCityFileList):
                                iPlayerNum = unpickledCityFileList[unpickledCityFileListValue]
                                print 'unpickledCityFileListValue =', unpickledCityFileListValue
                                print 'len(unpickledCityFileList) =', len(unpickledCityFileList)
                                print 'iTempiPlayerNum =', iTempiPlayerNum
                                print 'iPlayerNum =', iPlayerNum
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                eCityName = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1                             
                                iX = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                iY = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                iPop = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                iCulture = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                #Retrieve specialists in city here
                                #Retrieve religions in city here
                                #Retrieve buildings here
                                EndofCityTag = unpickledCityFileList[unpickledCityFileListValue]
                                unpickledCityFileListValue = unpickledCityFileListValue + 1
                                print 'unpickledCityFileListValue =', unpickledCityFileListValue
                                if iTempiPlayerNum == iPlayerNum:
                                        if iPlayerNum == 35:
                                                print 'Got to barb initcity'
                                                pPlayer = gc.getPlayer(35)
                                                pCity = pPlayer.initCity(iX,iY)
                                                pCity.setName(eCityName,False)
                                                pCity.setPopulation(iPop)
                                                pCity.setCulture(35,iCulture,True)
                                                iPlayerNum = unpickledCityFileList[unpickledCityFileListValue]
                                        else:
                                                print 'Got to regular initcity'
                                                print 'iTempiPlayerNum =', iTempiPlayerNum
                                                pPlayer = gc.getPlayer(iLeaderCivCounter)
                                                print 'iX =', iX
                                                print 'iY =', iY
                                                # RuntimeError: unidentifiable c++ exception (initcity line) but the debug log looks fine...
[COLOR="Blue"]                                                pCity = pGermanic.initCity(5,5)
                                # I want this to create a city for Capria at location 5,5 so that I can debug this loop.  In Greekworld mod for vanilla
                                # civ 4 this line works but the mod defines (from WBS it says - I don't understand that) iGermanic = 9 and 
				# pGermanic = gc.getPlayer(iGermanic).
                                [/COLOR]
#                                                pCity = pPlayer.initCity(iX,iY)
#                                                pCity.setName(eCityName,False)
#                                                pCity.setPopulation(iPop)
#                                                pCity.setCulture(iLeaderCivCounter,iCulture,True)
#                                                iPlayerNum = unpickledCityFileList[unpickledCityFileListValue]

 
        	unpickledLeadersFile.close()
        	unpickledCityFile.close()
 
Try placing "pGermanic = gc.getPlayer(0)" right before the line "pCity = pGermanic.initCity(5,5)". I'm guessing wildly, mind you. If you want a specific player replace the 0 with that players index. Also, I'm assuming there is a player 0. I think that's a safe bet, but I could be wrong.

The mod you're speaking of probably knows that player 9 is germany and thus the line:
"pGermanic = gc.getPlayer(iGermanic)" retrieves that player from the global context.

Oh, and of course if this works you'll probably try to place more than one city at 5,5, and I have no idea what that will do.
 
I'm trying to use code (which worked) in the other mod I tampered with to help me understand python and then use a FFH2 leader.

The line pCity = pGermanic.initCity(5,5) worked in the Greekworld mod because I think things were already defined by the mod - it already stated that iGermanic = 9 and also that pGermanic = gc.getPlayer(iGermanic) .

For this program I am writing here I want to add a 'test city' in that loop to discover what is going wrong (causing CTD's). So I want to add a 'test city' for the leader Capria of the Bannor.

There will be no adding a German city to an FFH game or anything like that! Again, it's just code that I showed to work in the other mod (the x,y was different also).
-------------------------

So I can look up a player's index number in the excel maybe??? - I'll look when I get home. If all leaders have an index number pre-defined then maybe (from what you seem to be saying) I can write:
pCapria = gc.getPlayer(9)*
pCity = pCapria.initCity(5,5)

Does that look ok to you??

*assume Capria's predefined number is 9
 
I think the player index is different from game to game, i.e. in one game Capria can be player 0, in another she isn't even present.

That's why I suggested using player 0, whoever that might be. Another approach would be looking through the players until you find Capria.

Something along the lines of:
Code:
iCapria = gc.getInfoTypeForString('LEADER_CAPRIA')
pCapria = [player for player in PyHelpers.PyGame().getCivPlayerList() if player.getLeaderType() == iCapria][0]

That code will of course fail badly if Capria isn't in the game. Or I made a mistake. And it doesn't care about what civ she leads.
 
As I recall, in a single player game, player 0 is always the Human. Player (last) is always the barbarians. In FfH last is 35 I think.



The reason they could use 5 to mean germanic was probably because it is a scenario, and not a random/epic game. Could you choose who your opponents would be (run Custom Game) or could you just choose from a list who you would be?


Anyway, to find a specific leader you'd have to do a loop over all players active in the game and check if any of them match the leader you want to be working on.


Of course, if you are planning to run straight from one scenario to another, then you personally define what the player numbers are when you create each scenario. Probably they are numbers 0 to 35 running straight from top to bottom in the Custom Game screen.
 
Back
Top Bottom