• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.

Bad Allocation bug

Ferocca

Warlord
Joined
Nov 21, 2011
Messages
179
I was about to release my mod after testing, but there suddenly was a bug - when loading a save, the game exits with a 'bad allocation' error message. The strange thing is that as long as you don't load anything, everything works perfectly.

I have a backup of my source files from before the bug. The bug must be caused by my newest code; which allows hurrying projects IF you have a building in your city that enables project hurrying. Everything works when it comes to project hurrying as well. The DLL builds without any warnings (or errors of course). That's why it's a mystery to me why it causes a bug, but the exact same DLL without this new component does not have this loading bug.

When I use a DebugDLL, it refers me to place that makes it even more of a mystery to me:

In CvCity.ccp:
pStream->Read(MAX_TEAMS, m_abEspionageVisibility);

I did not change anything regarding m_abEspionageVisibility.

Does anyone know what could have caused this? If you need more information it of course is no problem for me to provide it.
 
Somewhere your read and write commands aren't matching up, so when you try to load a saved game, things get out of whack and it crashes. The point of the crash is not necessarily the point of the error.
 
Thanks for the reply; I also thought this tip would guide me to the fix but it in fact did not change anything. I don't see any other 'disorder' in the write and read commands. I placed all write and read commands regarding the new boolean I added (bHurryProjects) after another building-boolean (bBuildingOnlyHealthy) so I wouldn't place them at different places.
 
I don't have the '&' on pStream->Write, only on pStream->Read.
That's how it's supposed to be right?

EDIT: I only checked this in the CvInfos.cpp/.h, but this mistake had indeed been made in CvCity.cpp/.h!
Thanks a lot, it's fixed now! I will upload the mod soon now (thanks to you guys).
 
Back
Top Bottom