Visual C++ Runtime Error when Loading Mod saved game

CivWarGamer

Warlord
Joined
Oct 16, 2011
Messages
130
I get this error only when I try to load a saved game from my mod SPQR Rise of Rome.

runtime-visualc-runtime-error.png
 
This could be a clue. I noticed an option in Steam to validate Civ5 cache files and this was the result.

spqr-rise-of-rome-runtime-error.png
 
I found the root of my problem. I had deleted certain Promotions and that's what caused the crash on loads.
 
It's generally not a good idea to delete any table entries where the table has a

Code:
<Column name="ID" type="integer" primarykey="true" autoincrement="true"/>

column, as that leaves a "hole" in the table and quite a lot of the core game code assumes it can do

Code:
for i = 0, i <= #GameInfo.Promotions do
...
end

(or the C++ equivalent)

and that "blows up big time" when it hits the hole

Some tables (UnitClasses, Units, BuildingClasses, Buildings, possibly others) have had the code "corrected" for this behaviour in various patches so rows can be deleted from these tables, but in this case you'll definately want to use the <DeleteMissingReferences> "magic" tag - see http://forums.2kgames.com/showthread.php?109603-DeleteMissingReferences-Correct-Syntax-Example
 
Interesting, yeah, that makes sense.
 
I get this every time I load a saved mod game too, although I don't recall deleting anything bad.

This workaround works for me (and I have been using it for over a year now): start up CIV V. Start a new game with your desired mod(s). As soon as the game opens, go back to the main menu and load your saved modded game, and it will work!
 
It's generally not a good idea to delete any table entries where the table has a

Code:
<Column name="ID" type="integer" primarykey="true" autoincrement="true"/>

column, as that leaves a "hole" in the table and quite a lot of the core game code assumes it can do

Code:
for i = 0, i <= #GameInfo.Promotions do
...
end

(or the C++ equivalent)

and that "blows up big time" when it hits the hole

Some tables (UnitClasses, Units, BuildingClasses, Buildings, possibly others) have had the code "corrected" for this behaviour in various patches so rows can be deleted from these tables, but in this case you'll definately want to use the <DeleteMissingReferences> "magic" tag - see http://forums.2kgames.com/showthread.php?109603-DeleteMissingReferences-Correct-Syntax-Example

Deleting elements is almost essential in total conversion mods, and quite easy to do correctly (once the problem above was identified). You just have to add a bit of SQL code to renumber all the rows from zero after your deletes/adds. See here or download my Éa mod pre-alpha (just look at the end of any SQL file). It works quite well. I don't even bother to try to remember which tables need this and which don't. Just apply it any time you do a delete.

Edit: The only downside to the above is if you are running a scenario that adds stuff before your mod runs ... then changing IDs can be a problem. (That's why deleting is probably only a good idea if you are deleting wholesale for a total conversion.)


On the particular crash you had: I have had the same crash where a clear and obvious syntax error in table construction (clear and obvious once I found it) caused this crash with loaded games, but not with new games. I don't think it was the syntax error per se, but rather messed up tables that leads to the crash. But it surprised me that this would be a silent error with new game and then that crash with a game load.
 
Back
Top Bottom