Discussion in 'Civ4 - Modding Tutorials & Reference' started by Asaf, Dec 29, 2010.
I think I found my mistake.
Care to share?
I tried many things at once so I'm not sure what it is. But I think it was pretty basic, so I get even a little embarrassed .
The final path to CvGameCoreDLL folder in makefile-vars shall include CvGameCoreDLL.dll
My game crashed to desktop and I tried to run a debug dll.
This time, the game crashed also while loading the debug dll (trying to load a savegame done immediately before).
Here is the end of the output:
First-chance exception at 0x76c6fc56 in Civ4BeyondSword.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0011f3bc..
First-chance exception at 0x76c6fc56 in Civ4BeyondSword.exe: 0x0000071A: The remote procedure call was cancelled.
'Civ4BeyondSword.exe': Unloaded 'C:\Windows\System32\wtsapi32.dll'
The thread 'Miles Stream' (0x5e0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x6b0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x404) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x788) has exited with code 0 (0x0).
'Civ4BeyondSword.exe': Unloaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Miles\win32\mssmp3.asi'
'Civ4BeyondSword.exe': Unloaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Miles\win32\mssvoice.asi'
'Civ4BeyondSword.exe': Unloaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Miles\win32\mssdolby.flt'
'Civ4BeyondSword.exe': Unloaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Miles\win32\mssds3d.flt'
'Civ4BeyondSword.exe': Unloaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Miles\win32\mssdsp.flt'
'Civ4BeyondSword.exe': Unloaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Miles\win32\msseax.flt'
'Civ4BeyondSword.exe': Unloaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Miles\win32\msssrs.flt'
The thread 'Miles Timer' (0x17c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x6fc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x128) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x7a4) has exited with code 0 (0x0).
The program ' Civ4BeyondSword.exe: Native' has exited with code 0 (0x0).
What can be done about it? What is the next file to load after xml\GameInfo/CIV4EspionageMissionInfo.xml or is there a problem with this file? (not changed since 15 months!).
Or is this output insufficient to draw any conclusion and I should try to load a previous savegame?
Thank you for any advice.
CIV4EspionageMissionInfo is the last file, so the problem is probably not in the XML loading.
I have no idea what the problem is.
Did you use the debugger or just a debug DLL? Because if the crash breaks into the debugger it can give you much more information.
Thanks Asaf for your answer.
I guess I used the debugger (MS Visual C++ 2008 Express Edition).
Which files could be useful then and where can I find them?
OK, I found it.
It was Python. I had the 'stupid' idea to try to reestablish the Partisans Event. Initially, it has an iWeight of -2 in the EventTriggerInfos.xml file (I don't understand what a value of -2 does actually) but I changed it to 50 and noticed that it happened several times in the game already, giving strange results like pointing to a supposedly razed city in the middle of the ocean!
Since the event is already loaded in the savegame I replaced all related Python codes and the game continues, giving me a message that this Event happened somewhere in another country.
Nevertheless, I'm still interested in knowing what to do when your game crashes in the debugger.
Not that it has anything to do with compiling the DLL, but the Partisans event is supposed to have a weight of -2. That is the value it should have for it to work properly.
That -2 means that it is never triggered via the random event engine (a -1 means it is automatically triggered the instant the criteria are met; in theory a 0 should be the same as a -2; values over 0 will mean it is randomly triggered which will make it happen at times other than when a city has been razed at randomly selected locations where there are probably not any cities). The Partisans event, as designed, is not triggered via the random event engine. It is triggered "manually" in Python in the onCityRazed event handler in CvEventManager.py. It is the classic example of a non-random "random" event.
Thank You God-Emperor for the explanation.
For some reason I thought that this event was not working properly and decided to change it after having read a message on it (I have modded my game to stay much longer in the Antiquity and in the Middle-Ages so I don't always reach Renaissance).
Now I know...
Edit (for the readers): because you need Emancipation for this event to be triggered.
I'm trying to follow your step-by-step guide. I'm using VS2010 since I have that already installed (I have a MSDN-AA license), but that's the only change. However, I'm having some problems:
1. VS2010 doesn't use the Makefile. If I understand correctly, the dll needs to be compiled with the 2003 compiler to be compatible, right? Where do I tell VS2010 to use the Makefile?
2. If I run nmake by hand, I get the following error:
C:\Users\<myusername>\Documents\Visual Studio 2010\Projects\CvGameCoreDLL>"\Prog
ram Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\bin\cl.exe" /n
ologo /MD /Zi /Od /D_DEBUG /RTC1 /Fp"Debug\CvGameCoreDLL.pch" /GR /Gy /W3 /EHsc
/Gd /Gm- /DWIN32 /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /Yu"CvGameCoreDLL.
h" /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files (x86)\Microsoft
Visual C++ Toolkit 2003/include" /I"C:\Program Files (x86)\WindowsSDK/Include"
/I"C:\Program Files (x86)\WindowsSDK/Include/mfc" /I"C:\Program Files (x86)\Fira
xis Games\Civilization IV\Beyond the Sword\CvGameCoreDLL\Boost-1.32.0/include" /
I"C:\Program Files (x86)\Firaxis Games\Civilization IV\Beyond the Sword\CvGameCo
reDLL\Python24/include" /YcCvGameCoreDLL.h /Fo"Debug\_precompile.obj" /c _precom
C:\Program Files (x86)\WindowsSDK\include\specstrings.h(9) : fatal error C1083:
Cannot open include file: 'sal.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual C++ Toolkit
2003\bin\cl.exe"' : return code '0x2'
Any ideas? Except for VS2010, I used only the downloads from this thread.
I've got it working on VS2010 express.
Primary switch to throw is (once you have a project):
Project -> Properties (Alt + F7) -> Configuration Properties -> Configuration Type: Makefile
Also Configuration Properties -> Nmake -> Make sure your command line build all / rebuild all etc. make sense.
I can put together some screenshots for you in a couple of hours if you want.
Great. That solves not only problem #1, but also #2 (don't know why, it simply works not now) Thanks!
I had actually found the Configuration Properties dialog, just not that setting...
Thanks Sareln! I've added your (credited and linked) explanation to the opening post. I hope you don't mind
Ok, next problem
When running the debug dll from Visual Studio, I get the following error:
DLL Load:C:\Users\<myusername>\Documents\My Games\Beyond the Sword\Mods\MyMod\Assets\CvGameCoreDLL.dll
'Civ4BeyondSword.exe': Loaded 'C:\Users\<myusername>\Documents\My Games\Beyond the Sword\MODS\mymod\Assets\CvGameCoreDLL.dll', Symbols loaded.
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
I'm lost - any ideas?
Where in the code does it break? (You should be able to see a complete callstack)
It breaks in the constructor of CvXMLLoadUtility (CvXMLLoadUtility.cpp, line 68), which get's called directly from Civ4BeyondTheSword.exe, so not much to see in the call stack.
Which reminds me: I only have the dll in my mods directory - do I need something else? Currenty I'm just trying to build an unchanged BTS as a start.
I assume you're using the original BTS files?
Is it in debug or release?
Can you attach your makefile?
Can you post the full call stack anyway?
The dll should be inside the Assets folder in your mod's folder.
I'm using the files you posted in this thread - so yes, this should be the original BTS files
What I described above is debug. Release doesn't work either: "Unhandled exception at 0x779f15de in Civ4BeyondSword.exe: 0xC0000005: Access violation reading location 0x00000000."
It's unmodified (except for the first few lines) from this thread - but I'll attach it anyways.
I'll make some screenshot.
Yes, I know. I was just wondering: Do I need any more files?
Thanks you so far - I hope, you can shed some light on what I'm doing wrong.
Are you sure your BTS is updated to 3.19?
No, you don't. an INI file will be created, if I'm not mistaken.
Yes, I am.
Ok, so that's not the problem, either
Separate names with a comma.