Map Script Compatibility with Mac Warlords

I've finished a version of the script that should be Mac compatible . Here

If someone can tell me if that's work ( for single player and multiplayer with windows players also ?) , that would be great ! :)

Big thanks to AlanH for this adaptation !

Tcho !
 
I just loaded the scripts up in Warlords for Mac and opened the Custom Game options for each. where the map options loaded up OK, I launched a game, but only with one set of options, so I didn't check that the different options are all operational.

Here are the results:

Archipelago: OK
Chess: OK
Continents: OK
Custom Continents: OK, but I got the following error when I hit Escape and Exit to Main Menu:
Code:
Traceback (most recent call last):

  File "Sto_Custom_Continents_2_991", line 4008, in getCustomMapOptionDescAt

TypeError: list indices must be integers
ERR: Python function getCustomMapOptionDescAt failed, module Sto_Custom_Continents_2_991
Fractal Crash to Desktop. Python error log:
Code:
Traceback (most recent call last):

  File "Sto_Fractal_2_991", line 3202, in getCustomMapOptionDescAt

TypeError: list indices must be integers
ERR: Python function getCustomMapOptionDescAt failed, module Sto_Fractal_2_991
Hub: OK
Lakes: OK
Pangaea: OK
Terra Crash to desktop. Python error log:
Code:
Traceback (most recent call last):

  File "Sto_Terra_2_991", line 3626, in getCustomMapOptionDescAt

TypeError: list indices must be integers
ERR: Python function getCustomMapOptionDescAt failed, module Sto_Terra_2_991

I haven't investigated further. Please let me know if you need any more debugging data.
 
Thanks for all ... i don't undersstand yet what is the problem since i've tested every map and all seems to work with windows . I will check that soon to see is there is something in common or if this is simply a bug .

Tcho !
 
It looks like a single problem to me. Presumably the first argument to the function getCustomMapOptionDescAt() is not being passed, or is invalid. Maybe Windows survives this and the Mac Python v2.3 fails.

I've just tried a retest with Fractal, and it didn't crash! So I'm afraid it appears to be intermittent.
 
this is all in :

Code:
        ibutret=idbutton[iOption]

idbutton is recognized as a list so no problem with it . it seems that iOption is invalid .

Can you add this line in "def getNumCustomMapOptionValues(argsList)" :

Code:
	[iOption] = argsList
	print " iOption : "+repr(argsList)

and check when you have the bug ?


Edit : Very important detail : Something else, the errors occure only when you launch the map , during map generation ?? if yes , can you tell me what the previous function where i call "getNumCustomMapOptionValues"

... I've just check if this can be an encoding error ( thinking of that because not occur every time , but this seems not to make bug with all languages and windows ) .

Tcho !

edit : Sto_terra_2_991 is very close to the one you post in this thread ... just the test added between MAC / Windows
 
The errors occur when I select the map type in the Custom Game options screen. But, as I said above, it's intermittent. I tried editing the Fractal map script to add your debug print line and it didn't fail. I selected another of your map types and it was still OK. I selected your Hub script, which was OK before, and it crashed with the same error.

I'm going to do some more testing, checking to see if it happens with standard scripts as well. If so, I may have to reinstall the software. I don't want to send you on a wild goose chase if it's my system that's corrupt.
 
If this occur when you select the map , arglist is send by civ IV ... so that's wreid . Do you select some option with the default <random> option ... but i don't think there is a diferrence with windows that's stupid !

I'm curious to know what iOption cause this problem .

Tcho!
 
I tried about twenty or thirty selections of the various standard map scripts, and it didn't crash. I then tried the Sto scripts, and by switching between them a few times I was able to reproduce the crash.

I edited two of the scripts (Fractal and Continents) to add the debug print command as requested. I also deleted the Sto_Maps_DefaultMapOptions.cfg file, just in case this was corrupted, and then ran again. This time I switched between the two edited scripts, and it crashed after a few changes of script selection. The error was the same as above:

Code:
Traceback (most recent call last):

  File "Sto_Fractal_2_991", line 3203, in getCustomMapOptionDescAt

TypeError: list indices must be integers
ERR: Python function getCustomMapOptionDescAt failed, module Sto_Fractal_2_991

Attached is the PythonDbg.log file from this run. It's too long to include inline the post.

I notice that it only gets as far as iOption = 59 in the last sequence. I think this is simply because the debug log was not flushed to disk before the crash. The crash report from the application gives the following stack trace indicating that the crash occurred in Python while it was writing error info out:

Code:
Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
0   <<00000000>> 	0x00000000 0 + 0
1   org.python.python              	0x97e1adf1 PySys_WriteStderr + 333
2   org.python.python              	0x97dca6b7 PyDict_New + 1220
3   org.python.python              	0x97dcaa88 PyDict_SetItem + 219
4   org.python.python              	0x97dccb39 PyDict_SetItemString + 68
5   org.python.python              	0x97e19780 PySys_SetObject + 90
6   org.python.python              	0x97e17bd5 PyErr_PrintEx + 164
7   org.python.python              	0x97e17e25 PyErr_Print + 18
8   com.aspyr.civ4warlords         	0x0054fd04 FPythonMgr::CheckForPythonError() + 20
9   com.aspyr.civ4warlords         	0x0055155a FPythonMgr::ICallFunction(_object*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, _object*, _object**) const + 132
10  com.aspyr.civ4warlords         	0x00551688 FPythonMgr::ICallFunction(_object*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, _object*, FStringW*) const + 58
11  com.aspyr.civ4warlords         	0x005519a7 FPythonMgr::CallFunction(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, _object*, FStringW*) const + 175
12  com.aspyr.civ4warlords         	0x000ee4eb CyPythonMgr::callFunction(FStringA const&, FStringA const&, void*, FStringW*) + 177
13  com.aspyr.civ4warlords         	0x00149669 CvStagingScreen::refreshCustomMapOptions() + 1061
14  com.aspyr.civ4warlords         	0x0014890b CvStagingScreen::handleGameSettingsMessage(NetInitInfo*) + 427
15  com.aspyr.civ4warlords         	0x001485c5 CvStagingScreen::handleNetMessage(FNetMessage*) + 435
16  com.aspyr.civ4warlords         	0x0014373b CvMenuManager::handleNetworkMessages() + 77
17  com.aspyr.civ4warlords         	0x00143779 CvMenuManager::update() + 19
18  com.aspyr.civ4warlords         	0x00144eea CvMenuManager::setupGame() + 1562
19  com.aspyr.civ4warlords         	0x0006462f CvApp::InitGame() + 3045
20  com.aspyr.civ4warlords         	0x0005f612 CvApp::Init(HINSTANCE__*, char const*) + 1814
21  com.aspyr.civ4warlords         	0x000f185f WinMain + 33
 

Attachments

Pfff ... i don't understand the second part . But with the log file , the map is well initializated at least one time . Perhaps should you make a test only with your terra_script to see if a problem occure , and remove the new maps . I've not change a lot of thing : only that :

Spoiler :
Code:
if (sys.platform == 'darwin'):
	import sets
	def set(arg):
		return sets.Set(arg)
else:
        import _winreg

uncomment :

Code:
def regRead(registry, path, field):
    pathKey = _winreg.OpenKey(registry, path)
    try:
        fieldValue = _winreg.QueryValueEx(pathKey, field)
        return fieldValue[0]
    finally:
        pathKey.Close()

Code:
def civFilePath():
        if (sys.platform == 'darwin'):
                try:
                        userFolder = os.path.join(os.environ['HOME'], "Documents")
                        civFolder = "Civilization IV"
                        if (os.path.basename(os.getcwd()) == "Warlords"):
                                civFolder = "Civilization IV Warlords"
                        finalFolder = os.path.join(userFolder, civFolder)
                        return finalFolder
                except:
                        return ""
        else:
                try:
                        userFolder = regRead(_winreg.HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders","Personal")
                        civFolder = os.path.basename(regRead(_winreg.HKEY_LOCAL_MACHINE,"Software\\Firaxis Games\\Sid Meier's Civilization 4","INSTALLDIR"))
                        finalFolder =  os.path.join(os.path.join(userFolder, "My Games"), civFolder)
                        return finalFolder
                except:
                        return ""

If the old map work perfectly , i will make a second file like your terra_script to see if the problem occure from the multiple map . Else I will upload 2 version Mac / Windows

Tcho!
 
Here a second map script like your terra script . Exept the changes in the previous post and the changes into the afterGeneration() , there is nothing else ?

Tcho !
 
I think this is a bug in Python. I can make it happen by changing selected map script using the version I had before, so it isn't anything to do with the way you have implemented the changes for the Mac.
 
Thanks for all :) . So i will let the map scripts like this , since i can't find the problem ... and you are surely a very good python programmer , so if you can't found what can cause the problem , i don't know what to rewrite . A little last question , did the bug occure one time when you start civ4 , and select a map ( with a previous sto map intialized ) ? ( i know it's impossible to test that , but perhaps you've noticed if the bug occure everytimes when you multiselect a map more than 2 times ) . if yes , i can post a note to explain that you must restart civ4 everytime you launch a map for Mac . If not , i will explain that there is a problem and that the scripts don't work all time .

A little more thing , if you play with these scripts and notice the same bug when generating the map , please tell me ... that could be a track , since i also call this function in beforeGeneration() .

Tcho !
 
A little idea . Perhaps you can have the iOption passed on value using :

Code:
sys.stdout.write(" iOption : "+repr(arglist)+"\n")

instead of print ?

In fact , when reading the log file again ... there is a big problem , you should not be able to read the map any one time because if you have tested "print repr(arglist)" :

there should be a list like : (0,0) ; (0,1) etc and there is (0,) ; (1,) ; (2,) ... i think about that because i was thinking to replace iOption with a global variable and notice that there is no iSelection ... more than wreid that you can get a map any one time .

Tcho !
 
I'll maybe have a look at that, but I don't like the fact that it's intermittent. I feel that makes it a low level system error in the Python interpreter, not one that can be fixed in the application level code.

Yes, I think the problem has generally occurred after a Sto map has already been initialised. But it would be very inconvenient to have to quit each time you change the map script selection.

BTW I'm not really a Python programmer at all. :)
 
there should be a list like : (0,0) ; (0,1) etc and there is (0,) ; (1,) ; (2,) ... i think about that because i was thinking to replace iOption with a global variable and notice that there is no iSelection ... more than wreid that you can get a map any one time .

If fact , the log file stop at getNumCustomMapOptionValues() ... :blush:

Edit : i will let the scripts like this for the moment . But even if there is a low system error ( not of my understanding ) , i will try to rewrite the script using a global value to replace arglist .
 
Do you think that using a special encoding for the script may cause the problem ? I will also make a test file tomorrow removing all non english langages and :

Code:
# -*- coding: iso-8859-1 -*-

Tcho !
 
I just tried a different experiment. I changed fdebug() to return False in the Sto_Fractal map, so that it would not output any debug text. I then switched between the Sto_Fractal map and the other standard map types. I was very careful to avoid selecting any other Sto script, although there are a couple of others in teh PublicMaps folder. After several menu changes the software crashed. And the PythonErr.log listing showed output from the Sto_Terra script. So it seems the Terra script is being called even if I don't select that script?

EDIT. Ignore that. I need to do the test again :blush:

Correction. The error still occurred in the Sto_Fractal script at the same place. I need to suppress the other print operations as well, I guess.
 
I'm a bit confused about the indenting in your code. I thought Python needed consistent indenting, but I see some lines indented with four spaces and others with eight - for example:

Code:
def getNumCustomMapOptionValues(argsList):
        global language
        global listressmenu
        global listunitsmenu
        global listtechsmenu
        global listtraitsmenu
	idbutton=getidbutton()
	[iOption] = argsList

Shouldn't all the lines after the function def line be at the same indentation level of eight spaces?

Also, there seem to be a mix of tabs and spaces for indentation. Does Python allow them to be mixed?
 
??? No , python don't accept space or different identation if i remember well with my hard beginning . But there is 2 tab = 8 space everywhere . I see no identation with 4 spaces :confused: . when i write code , i don't use tab but keybord shortcut to indent and unindent . And i think this may automaticaly cause a bug on initialization . Do you find some ? In the example , there is 8 spaces = 2 * tab .

edit : yes your right just in the last function there is four space identation . but that do not cause problem . i've seen other script (original with 8 or 16 space identation ) . But the mix of space and tab create a bug i think (not hidden).
 
Here a test file where i've removed all non ASCII character and coding . If you can test that after removing all other Sto_scripts ( the codec module is loaded if there is any other sto_scripts ) . This is the only thing i made that is not "" common "" , with a little hope ...

Tcho !

Edit : if this don't work , i will retabify all the script , but i'm almost sure that if there is mistake , that automaticaly create a bug .
Edit : i don't think that the debug tool might be in cause .because the error is clear : this is civ4 that call a bad value entry . So there must be something in initialization that create the bug ... nothing to do with debug !? ??
 
Top Bottom