Questions on the DLL

@crashes: In most cases caused by missing artDefines entries. Can you compile a debug dll? Would probably help.

Since you are not a programmer, explaining the debugging process may be the wrong solution. Can you remove one change from your python, to make the crash stop? Then you know this change introduced the crash. Let's start from there rather than explaining the concept of debugging a C++ program.

Also, it may be worthwhile to check your artDefine filenames. If you have only added one or two, check manually. When crashes suddenly appear without changing the sdk, this is usually the reason. If you have added a lot, you may find civchecker helpful to automatically check all the art paths.
 
Since you are not a programmer, explaining the debugging process may be the wrong solution. Can you remove one change from your python, to make the crash stop? Then you know this change introduced the crash. Let's start from there rather than explaining the concept of debugging a C++ program.

According to the beginning of the thread, he does try to make changes to the C++ code, so even if he's not an experienced programmer debugging can only help him.
 
Try the link I gave you earlier (post #8).
If you have any questions - I'll try to answer.

I followed the instructions in your post, but when I click 'Start Debugging' it says 'This project is out of date: CvGameCoreDLL. Would you like to build?' If I click yes it starts to build, but doesn't do anything since I already built a debug version and then brings up the following (if I click no it brings up the following right away): 'Debugging information for 'Civ4BeyondSword.exe' cannot be found or does not match. Symbols not loaded. Do you want to continue debugging?' If I click yes, a Beyond the Sword error window comes up and says 'A debugger has been detected. Unload the debugger and try again.' I click OK, and this comes up in Visual C++

Spoiler :
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Civ4BeyondSword.exe'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\boost_python-vc71-mt-1_32.dll', Binary was not built with debug information.
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\python24.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\shell32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll'
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\msvcr71.dll'
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\msvcp71.dll'
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\zlib1.dll', Binary was not built with debug information.
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\binkw32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\winmm.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\ole32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\d3dx9_33.dll'
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mss32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\hapdbg.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\dsound.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\shimeng.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\serwvdrv.dll'
'Civ4BeyondSword.exe': Unloaded 'C:\WINDOWS\system32\serwvdrv.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\serwvdrv.dll'
'Civ4BeyondSword.exe': Unloaded 'C:\WINDOWS\system32\serwvdrv.dll'
'Civ4BeyondSword.exe': Unloaded 'C:\WINDOWS\system32\shimeng.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\apphelp.dll'
'Civ4BeyondSword.exe': Loaded 'C:\Documents and Settings\Owner\Local Settings\Temp\~e5.0001.dir.0000\~df394b.tmp'
'Civ4BeyondSword.exe': Loaded 'C:\Documents and Settings\Owner\Local Settings\Temp\~e5.0001.dir.0000\DrvMgt.dll', Binary was not built with debug information.
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\ntmarta.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\samlib.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll'
'Civ4BeyondSword.exe': Unloaded 'C:\Documents and Settings\Owner\Local Settings\Temp\~e5.0001.dir.0000\DrvMgt.dll'
'Civ4BeyondSword.exe': Loaded 'C:\Documents and Settings\Owner\Local Settings\Temp\~e5.0001.dir.0000\~de1d50.tmp', Binary was not built with debug information.
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\msctf.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\InetCntrl\PopupKil\popuphuk.dll'
'Civ4BeyondSword.exe': Loaded 'C:\WINDOWS\system32\mslbui.dll'
The program '[3972] Civ4BeyondSword.exe: Native' has exited with code 1 (0x1).


What am I doing wrong?
 
There are 3 things there:

This project is out of date: CvGameCoreDLL. Would you like to rebuild?
This means you have made changes in the code since the last time you compiled. Generally speaking, you always want to answer yes to this question, and I think there should be an option to do so (a checkbox or something).
It is important that you make sure to copy the Debug DLL after you build it to the Mod folder, otherwise it will not be loaded.
(There is a way to do so automatically after you build the project, in the project properties -> post build events).

Debugging information for 'Civ4BeyondSword.exe' cannot be found or does not match. Symbols not loaded. Do you want to continue debugging?
Again, you always want to answer 'yes' to this question. This means that the exe itself is not a debug exe, so you won't be able to debug its code. Since you don't intend to, there's no problem.

'A debugger has been detected. Unload the debugger and try again.
Now this is weird. This means that for some reason your copy of BTS protects itself from being debugged. I've never had this issue with BTS.
Which OS are you using? Do you use steam for BTS (not sure it's relevant, but maybe steam adds some protection)?
Has anyone else ever come across this?
 
This project is out of date: CvGameCoreDLL. Would you like to rebuild?
This means you have made changes in the code since the last time you compiled. Generally speaking, you always want to answer yes to this question, and I think there should be an option to do so (a checkbox or something).
It is important that you make sure to copy the Debug DLL after you build it to the Mod folder, otherwise it will not be loaded.
(There is a way to do so automatically after you build the project, in the project properties -> post build events).

That's the wierd thing, because I haven't made any changes since I compiled last. I also copied the debug DLL to Mods/Techs Add Commerce/Assets.

'A debugger has been detected. Unload the debugger and try again.
Now this is weird. This means that for some reason your copy of BTS protects itself from being debugged. I've never had this issue with BTS.
Which OS are you using? Do you use steam for BTS (not sure it's relevant, but maybe steam adds some protection)?

I am using Windows XP, and no I am not using steam.

Is it possible that I set something up wrong and the debugger is trying to debug BtS itself and not my mod, and that is why it says the debug DLL is out of date, and also (maybe) that it blocks the debugger?
 
When you are debugging you need to also comy over that huge CvGameCore.pdb file as well as the debug dll itself.
 
When you are debugging you need to also comy over that huge CvGameCore.pdb file as well as the debug dll itself.

Into my mod's Assets folder? If so, I already did that as well.
 
That's the wierd thing, because I haven't made any changes since I compiled last. I also copied the debug DLL to Mods/Techs Add Commerce/Assets.

Try doing a full rebuild. Maybe that will solve this problem

I am using Windows XP, and no I am not using steam.

Is it possible that I set something up wrong and the debugger is trying to deubug BtS itself and not my mod, and that is why it says the debug DLL is out of date, and also (maybe) that it blocks the debugger?

The debugger debugs the process, so it does not differentiate between debugging the mod or BTS in that sense. It will simply not show any code for the BTS exe itself.
So I doubt it has anything to do with settings.

I'm not sure how to solve this problem - but you may be able to bypass it:
Assuming you get the error message right at start up of the process, you can run BTS with your mod from outside Visual Studio, and then after a few seconds, in the Visual Studio, attach to this process (I hope it's possible in VS express): Debug menu -> Attach to process -> select BeyondTheSword.exe -> Attach.

This error message seems to appear even when not using a debugger sometimes, but I'm not sure it's relevant here.
 
When you are debugging you need to also comy over that huge CvGameCore.pdb file as well as the debug dll itself.

I don't think so.
And in any case, it will not cause the 'debugger detected' error.
 
I've never seen those errors. Here are basic instructions on how to debug though:

1)Compile the Debug Dll (using Refar's instructions)
2)Copy the DLL and pdb file into your mod's assets folder
3)While MVS has your project loaded start Civ4 with your mod loaded. Then in the Debug drop down menu select "Attach to Process"
4)A list of processes running on your computer will pop up, select the Civ4 exe one and select OK
 
I tried debugging using the Attach to Process button and it works fine. I'm not sure why the other method wouldn't work.

Anyways, when my game crashes it brings up the following error in Visual C++

Spoiler :
Unhandled exception at 0x004e12a2 in Civ4BeyondSword.exe: 0xC0000005: Access violation reading location 0x00000000.


next to the closing brace of this function in CvInitCore.cpp:

Code:
bool CvInitCore::getOption(GameOptionTypes eIndex) const
{
	FASSERT_BOUNDS(0, NUM_GAMEOPTION_TYPES, eIndex, "CvInitCore::getOption");
	if ( checkBounds(eIndex, 0, NUM_GAMEOPTION_TYPES) )
	{
		return m_abOptions[eIndex];
	}
	else
	{
		return false;
	}
}

EDIT: It also appears that, in my stupidity, I changed the value of eTech in the debugger. I didn't realize this would affect the code, I thought it would just change it for the duration of the debug. From what I can gather, it changes eTech at a certain point in CvGameTextMgr.cpp, but only for a certain time until it changes back. I know this because it adds +1 Trade Routes per City to my mouseover of the tech in the tech tree. How can I undo this?
 
Check CvEnums.h and CyEnumsInterface.cpp and ensure that the game options agree with GameOptionInfos.xml
 
When you get the location of the exception, you can also check for the value of eIndex (either hover over it or check in the locals/autos/watch tab).

It should help you understand the problem better.
It's probably something along the lines of what phungus420 said.

EDIT: It also appears that, in my stupidity, I changed the value of eTech in the debugger. I didn't realize this would affect the code, I thought it would just change it for the duration of the debug. From what I can gather, it changes eTech at a certain point in CvGameTextMgr.cpp, but only for a certain time until it changes back. I know this because it adds +1 Trade Routes per City to my mouseover of the tech in the tech tree. How can I undo this?

When you edit the value in the debugger it changes the value in the specific place in memory. It will remain for the duration of the session or until the code itself changes this value.
 
Check CvEnums.h and CyEnumsInterface.cpp and ensure that the game options agree with GameOptionInfos.xml

The only things I added to CvEnums and CyEnumsInterface was to add widgets, so the game options shouldn't have changed, correct? (I didn't edit GameOptionsInfos.xml)
 
When you edit the value in the debugger it changes the value in the specific place in memory. It will remain for the duration of the session or until the code itself changes this value.

What do you mean by 'the duration of the session'? The extra line always appears now, even if I use a release DLL.
 
You changed a value in the debugger during one session, then you exited that session. If you are seeing some different behavior in the game, it has nothing to do with that change in one debugger session. The different behavior must be due to some other file change you made, for example in the C++, or xml, or python.
 
You changed a value in the debugger during one session, then you exited that session. If you are seeing some different behavior in the game, it has nothing to do with that change in one debugger session. The different behavior must be due to some other file change you made, for example in the C++, or xml, or python.

Yeah...I'm not sure how I didn't realize that.

I made a few changes and now at the points where my mod used to crash, it no longer does. Now when I click the buttons that would formerly make it crash, the buttons do nothing. I keep clicking them, but they never do anything. What could cause this?
 
Do you have python exceptions turned on? When a python call fails and python exceptions are off, it "looks like" nothing happened. Add print statements at the places where you expect your function to be called. Perhaps it is getting part way through the functions you expect to be called. Knowing where the calling sequence stops, based on your print statements, at least narrows down the search.
 
Do you have python exceptions turned on? When a python call fails and python exceptions are off, it "looks like" nothing happened.

I do have python exceptions turned on, and there is no error that appears.

Add print statements at the places where you expect your function to be called. Perhaps it is getting part way through the functions you expect to be called. Knowing where the calling sequence stops, based on your print statements, at least narrows down the search.

This is the part I don't understand, because the buttons that don't do anything don't occur where I changed the code. Then again, I don't know much about python so this may be irrelevant.
 
Back
Top Bottom