While debugging a crash in Realism Invictus SVN, I found that it was caused by Better BtS AI.
RI stacktrace:
I found out that the code causing it are these lines in CvPlayerAI.cpp (starting at line 1930 of http://civ4betterai.svn.sourceforge...reDLL/CvPlayerAI.cpp?revision=597&view=markup):
As you can see, logBBAI tries to access pCity->getName(). pCity is already deleted; the previous line removes it from the memory after a lot of operations. Therefore, the game crashes in getName() since pCity does not exist anymore. Inverting both lines did the trick for Realism Invictus.
I was not able to test if this crash happens in vanilla Better BtS AI because I could not figure out how to build it with the sln project included in the svn repository, but since that part of the code seems like a unmodified copy I'm guessing that it does, and maybe you want to check it.
RI stacktrace:
Code:
msvcp71.dll!7c3b3f84()
CvGameCoreDLL.dll!CvWString::CvWString() + 0x46 Bytes C++
CvGameCoreDLL.dll!CvCity::getName() + 0x26 Bytes C++
CvGameCoreDLL.dll!CvPlayerAI::AI_conquerCity() + 0xa19 Bytes C++
CvGameCoreDLL.dll!CvGame::isOption() + 0x16 Bytes C++
CvGameCoreDLL.dll!CvPlayer::acquireCity() + 0x191b Bytes C++
CvGameCoreDLL.dll!CvUnit::setXY() + 0xab6 Bytes C++
CvGameCoreDLL.dll!CvUnit::move() + 0xdc Bytes C++
CvGameCoreDLL.dll!CvSelectionGroup::groupMove() + 0xff Bytes C++
CvGameCoreDLL.dll!CvUnit::updateCombat() + 0x106d Bytes C++
CvGameCoreDLL.dll!CvUnit::attack() + 0x16 Bytes C++
CvGameCoreDLL.dll!CvSelectionGroup::groupAttack() + 0x3dd Bytes C++
CvGameCoreDLL.dll!__wcsicmp() + 0x44c66 Bytes C++
CvGameCoreDLL.dll!FFreeListTrashArray<CvUnitAI>::getAt() + 0x37 Bytes C++
CvGameCoreDLL.dll!CvUnit::isCombat() + 0x16 Bytes C++
CvGameCoreDLL.dll!CvSelectionGroup::isBusy() + 0x3e Bytes C++
CvGameCoreDLL.dll!CvSelectionGroup::startMission() + 0x7b2 Bytes C++
CvGameCoreDLL.dll!CvSelectionGroup::insertAtEndMissionQueue() + 0x35 Bytes C++
CvGameCoreDLL.dll!CvSelectionGroup::pushMission() + 0x10d Bytes C++
CvGameCoreDLL.dll!CvUnitAI::AI_cityAttack() + 0x25a Bytes C++
CvGameCoreDLL.dll!CvUnitAI::AI_attackMove() + 0x4fa Bytes C++
CvGameCoreDLL.dll!CvUnitAI::AI_update() + 0x4ac Bytes C++
CvGameCoreDLL.dll!CvSelectionGroupAI::AI_update() + 0x1ea Bytes C++
CvGameCoreDLL.dll!CvPlayerAI::AI_unitUpdate() + 0x27a Bytes C++
CvGameCoreDLL.dll!CvGame::updateMoves() + 0x95 Bytes C++
CvGameCoreDLL.dll!CvGame::update() + 0x360 Bytes C++
Civ4BeyondSword.exe!00415321()
I found out that the code causing it are these lines in CvPlayerAI.cpp (starting at line 1930 of http://civ4betterai.svn.sourceforge...reDLL/CvPlayerAI.cpp?revision=597&view=markup):
Code:
if( bRaze )
{
pCity->doTask(TASK_RAZE);
logBBAI(" Player %d (%S) decides to to raze city %S!!!", getID(), getCivilizationDescription(0), pCity->getName().GetCString() );
}
As you can see, logBBAI tries to access pCity->getName(). pCity is already deleted; the previous line removes it from the memory after a lot of operations. Therefore, the game crashes in getName() since pCity does not exist anymore. Inverting both lines did the trick for Realism Invictus.
I was not able to test if this crash happens in vanilla Better BtS AI because I could not figure out how to build it with the sln project included in the svn repository, but since that part of the code seems like a unmodified copy I'm guessing that it does, and maybe you want to check it.