Guide to crashes
The purpose of this guide is to explain what is causing the various types of crashes to desktop (CTD) in mods and provide some advice on how to fix them.
Before I begin I would like to point out that the best way to resolve a crash is to add the following line to your mod's .cfg file.
Code:
[log]
to = logs/system.log.txt
level = * error
This will give you a log report which contains basic information about the crash.
Code:
[log]
to = logs/system.log.txt
level=*script* trace
This will give you a log report which contains more information about the crash.
Code:
[log]
to = logs/system.log.txt
level = ai.ltgd trace
This will give you a log report which contains information about what the AI was doing when the crash occurred.
Code:
[log]
to = logs/system.log.txt
level=*script* trace
This will give you a log report which contains the most information about the crash, though it's hard to read.
Always check the error log in the 'Medieval II Total War\logs' folder to find out which file is causing problems (default location 'C:\Program Files\SEGA\Medieval II Total War\logs'). The error is usually at the bottom of the error log as they're the last thing it records before it crashes. Though some errors are recorded part way through the error log; such as a missing skeleton, a missing mount, and a building gap.
If you think a file is causing problem change its name and see if this fixes the problem (if M2TW can't find a file it reverts to the default version). If this fixes the problem then you know this file is faulty.
Common abbreviations:
EBD: export_descr_buildings.txt
EBU: export_descr_unit.txt
Mod CTD and without starting
CTD on startup
Q: When you start the mod you get a black screen and the mod CTDs.
A: There is an erronous entry in the data\unit_models\battle_models.modeldb; normally a reference to an non-existant mesh or texture, an entry has the wrong number, you've got the formatting for one of your entried wrong, or the number at the top is for too many entries. You won't recieve any help in the log for this so you'll have to check your entries manually.
The easiest way to find the error is to reduce the number of entries at until the mod starts to load (it'll usually crash and say it can't find an entry in the error log). Keep increasing the number of entries until the mod stops loading and you'll have found your problem entry.
CTD on startup vRAM
Q: When you start the mod you get a black screen and the mod CTDs. The logs say you lack enough vRAM.
A: There is a texture with an incorrect path. This is usually a texture for a unit on the campaign map, not the battlemap. Check that all the paths are correct in the data\descr_model_strat.txt file.
Black screen CTD
Q: When you start the mod you get a black screen and it it will not disappear unit you hit the 'return' key. Often it's replaced with a black version of the intro.
A: This normally occurs when you sound system has been disabled. You can re-enable it by clicking on the 'Control Panel', then 'Administrative Tools', then 'Services', then scroll down in the pop-up until you find 'Windows Audio'. Starting this should fix this problem (if not reboot your computer).
Mod loads, then CTD without starting
Loading CTD
Q: The game starts to load, then CTD.
A: This usually occurs because an entry can't be found in the 'data\export_descr_buildings.txt' or 'data\export_descr_unit.txt'. The log files should tell you which unit or building is missing.
Loading CTD after adding a new building
Q: The game starts to load, then CTD.
A: If the description for the building is missing in the 'data/text/export_buildings.txt' the mod won't load and the missing building won't be listed. The best way to find the missing building is to use the 'level=*script* trace' to find the last building that was processed and check the 'data\export_descr_buildings.txt' to see which building came after it.
Loading game CTD, with Insufficient video memory error message
Q: The game starts to load, then CTD and error log says there is 'Insufficient video memory'.
A: This is normally caused when you tell M2TW to look for an image file that doesn't exist. The two files most likely to cause this error are the data/unit_models/battle_models.modeldb and data/descr_model_strat.txt. Check both to ensure that all the image paths (eg models_strat/textures/southern_ambasador_papacy.tga) lead to an image file (.tga or .texture) and the spelling is correct.
This error will also occur if one of the entries in the data/descr_model_strat.txt does not assign the default .tga to its .cas file. The default .tga file is different for each .cas file. For example the 'Spanish_Viceroy.CAS' requires the 'spanish_Viceroy_spain.tga' to be assigned to one of its entries, and the 'mesoamerican_king.cas' requires the 'mesoamerican_king_mayans.tga' to be assigned to one of its entries.
For example, the following will produce an 'Insufficient video memory' error because the 'mesoamerican_king_mayans.tga' has not been assigned to the 'mesoamerican_king.cas'.
Code:
type mesoamerican_king
skeleton strat_named_with_army
scale 0.7
indiv_range 40
texture aztecs, models_strat/textures/mesoamerican_king_aztecs.tga
texture mayans, models_strat/textures/mesoamerican_king_aztecs.tga
texture tlaxcalans, models_strat/textures/mesoamerican_king_tlaxcalans.tga
texture tarascans, models_strat/textures/mesoamerican_king_tarascans.tga
texture slave, models_strat/textures/mesoamerican_king_aztecs.tga
model_flexi_m models_strat/mesoamerican_king.CAS, max
shadow_model_flexi models_strat/shadow_sword.CAS, max
But this one will work because the 'mesoamerican_king_mayans.tga' has been assigned to the 'mesoamerican_king.cas'.
Code:
type mesoamerican_king
skeleton strat_named_with_army
scale 0.7
indiv_range 40
texture aztecs, models_strat/textures/mesoamerican_king_aztecs.tga
texture mayans, models_strat/textures/mesoamerican_king_mayans.tga
texture tlaxcalans, models_strat/textures/mesoamerican_king_tlaxcalans.tga
texture tarascans, models_strat/textures/mesoamerican_king_tarascans.tga
texture slave, models_strat/textures/mesoamerican_king_aztecs.tga
model_flexi_m models_strat/mesoamerican_king.CAS, max
shadow_model_flexi models_strat/shadow_sword.CAS, max
CTD after removing regions
Q: After removed most of the regions the mod CTDs. The error message just says the mod has crashed.
A: M2TW requires a mininium of regions of regions (unsure how few), so try adding some more. Also you have to delete the data\world\maps\base\map.rwm file everytime you alter the data\world\maps\base\map_regions.tga file.
CTD after adding a lot of regions
Q: After adding a lot of new regions the mod CTDs. The error message just says the mod has crashed.
A: M2TW cannot have more than 199 regions and 1 sea, so try deleting some. Also you have to delete the data\world\maps\base\map.rwm file everytime you alter the data\world\maps\base\map_regions.tga file.
CTD after editing some regions, no map.rwm
Q: After moding the map_regions.tga file, deleting the map.rwm, and selecting a faction the mod CTDs without generating a new map.rwm file. The error message just says the mod has crashed.
A: This is caused by one of the following.
1) One or more regions does not have a black pixel representing a settlement.
2) One or more regions by the sea does not have a white pixel representing a port.
3) One or more of the pixels is the wrong colour, causing M2TW to treat it as a new region without a settlement.
4) One or more regions has the black pixel touching mutiple regions (it must be located inside only one region).
To resolve the first 3 you need to ensure all the pixels are the correct colour (even a small variation that is invisible to the human eye will cause the mod to crash). To resolve the 4th problem you need to move the black pixel.
CTD after adding some regions, map.rwm generated
Q: After moding the map_regions.tga file, deleting the map.rwm, and selecting a faction the mod CTDs but generates a new and complete map.rwm file. The error message just says the mod has crashed.
A: This can be caused by:
1) The RGB (Red Green Blue) colour of a region does not matching the colour in the data\world\maps\campaign\custom\origin\descr_regions.txt (usually the problem). Fixing the incorrect entry will solve this problem.
2) The settlement in the region is in an inaccessable area eg in a forest or up a mountain. Move the black pixel elsewhere.
3) Some graphics programs cannot generate map_regions.tga files that M2TW will accept. I had this problem when I edited the map_regions.tga file using Photoshop Elements 4.0 but not when I switched to Gimp.
Mod CTD during game
Loading or during game CTD, with no error message
Q: The game CTD and error log just says the mod has crashed.
A: This is normally caused by one of the files in the data/text folder not containing all the required information. It's often the data/text/expanded.txt but not always.
Faction selection CTD, missing region
Q: The mod crashes CTDs when you try to play as a specific faction, error message says a province is missing.
A: There are 4 files that deal with provinces:
data\text\imperial_campaign_regions_and_settlement_names.txt
data\world\maps\base\descr_regions.txt
data\world\maps\campaign\imperial_campaign\descr_strat.txt
data\world\maps\campaign\imperial_campaign\descr_win_conditions.txt
The make sure the missing province appears in the first three of these and that the missing province is spelled correctly in all of them.
Unit crash
Q: Game crashes when you try to get the information about a unit or when you go to battle with a particular unit.
A: The data\export_descr_unit.txt info for that unit contains an error. Make sure the tabs and spaces are in the right place, information is not missing or duplicated, and that the 'soldier' line refers to a an actual unit (try not to change this).
Building crash
Q: Game crashes at the start when you click the recruit on the recruit option of a settlement.
A: Either this settlement starts with a building this faction cannot have (this only causes a crash at the start of the game) or there's an error in the data\export_descr_buildings.txt file regarding one of the settlement's buildings.
5th turn crash
Q: The game crashes at the end of the fifth turn / start of the fifth turn.
A: I actually had this error, it's not a joke. This error is caused by the following trait in the data\export_descr_character_traits.txt file.
Code:
;------------------------------------------
Trait ReligionStarter
Characters family
Hidden
Level General_Religion
Description General_Religion_desc
EffectsDescription General_Religion_effects_desc
Threshold 1
Effect Piety 3
;------------------------------------------
Trying to exclude one of the cultures caused the game to crash at the end of the fourth turn. Excluding other hidden traits can also cause crashes.
20th turn crash
Q: The game crashes during the AI's turn at about turn 20 and the error log just says the mod has crashed.
A: I had this error and it took me a long time to fix it. This error occurred because I increased the number of children allowed in the 'data/descr_campaign_db.xml' file. When the AI's family had more than 4 children the mod crashed.
Start of turn crash
Q: The game crashes at the start of your turn.
A: This can be caused by an event that is in the 'data\world\maps\campaign\imperial_campaign\campaign_script.txt' or 'data\world\maps\campaign\imperial_campaign\descr_events.txt' (default locations 'C:\Program Files\SEGA\Medieval II Total War\data\world\maps\campaign\imperial_campaign') but is not listed in the 'data/text/historic_events.txt' file. Adding this event to the 'data/text/historic_events.txt' will fix this error (this file is case sensitive).
Game crashes during the AI's turn
Q: The game crashes during the AI's turn and the error log just says the mod has crashed.
A: There are several possible causes:
1) The trigger for a trait is incorrectly written. I once had this problem when the trigger's 'WhenToTest' was 'GeneralAssaultsGeneral', rather than 'PostBattle'. You can test this by deleting the triggers of all your traits in the 'data/export_descr_ancillaries.txt' and 'data/export_descr_character_traits.txt' files (create backups before doing this) and loading the mod to see if the crash stops.
2) A culture has a trait excluded but the corrisponding 'antitrait' is not excluded. This causes a problem when a general or agent switches from a trait to its antitrait (due to a loss or gain of skill points).
3) The mod will also crash if an agent without a name gets an Epithet. This can be fixed by changing the agent's name in the 'data\world\maps\campaign\imperial_campaign\descr_strat.txt' and restarting the mod so it uses the new name.
Other errors that don't cause CTD
Building gap at the end of the export_descr_buildings.txt
Q: The error log says there is a building gap but the line number of the error is for the bottom of the 'data/export_descr_buildings.txt' .
Code:
00:41:51.734 [script.err] [error] Script Error in mods/conquest/data/export_descr_buildings.txt, at line 9078, column 2
Building DB error - faction aztecs has gap in building prior to stone_wall
00:41:51.750 [script.err] [error] Script Error in mods/conquest/data/export_descr_buildings.txt, at line 9078, column 2
Building DB error - faction aztecs has gap in building prior to large_stone_wall
00:41:51.750 [script.err] [error] Script Error in mods/conquest/data/export_descr_buildings.txt, at line 9078, column 2
Building DB error - faction aztecs has gap in building prior to huge_stone_wall
00:41:51.750 [data.invalid] [error] Target building level not allowed: Inca Empire, castle -> large_town, core_castle_building[2](castle) -> core_building[1](wooden_wall)
00:41:51.750 [data.invalid] [error] Target building level not allowed: Inca Empire, fortress -> city, core_castle_building[2](castle) -> core_building[1](wooden_wall)
00:41:51.750 [data.invalid] [error] Target building level not allowed: Inca Empire, citadel -> city, core_castle_building[2](castle) -> core_building[1](wooden_wall)
A: If a faction or culture is not listed at an early level of a building tree but is listed at a later level this generate an error. Unfortunately the error log states that the error is at the end of the 'data/export_descr_buildings.txt' instead of the correct line.
A: The easiest way to fix this error is to search the 'data/export_descr_buildings.txt' for the first building the error log lists (in this case 'stone_wall') and check the building level before it (in this case the 'wooden_wall' level of the 'core_building' building tree).
Code:
wooden_wall city requires factions { northern_european, middle_eastern, eastern_european, southern_european, }
As the faction listed in the error log is the aztecs by adding them to this building level I can fix this error.
Code:
wooden_wall city requires factions { northern_european, aztecs, mesoamerican, middle_eastern, eastern_european, southern_european, }
Missing Skeleton
Q: The error log says that a skeleton is missing for a secondary weapon.
Code:
01:07:29.687 [script.err] [error] Script Error in mods/conquest/data/export_descr_unit.txt, at line 3149, column 1
Missing skeleton for secondary weapon in model type 'magyar_swordsmen', used by unit 'Hungarian Crossbowmen'.
A: The is error means that you've assigned a one weapon 'soldier' model to a two weapon unit in the 'data/export_descr_unit.txt'. The soldier models are listed at the end of every unit entry in the 'data/unit_models/battle_models.modeldb' and can give a unit one weapon or two (cavalry and missile units usually have two weapons, while melee infantry usually only has one).
To fix this error find the problem unit ('Hungarian Crossbowmen' in this example) and change their 'soldier' line to another unit.
For example this entry:
Code:
type Hungarian Crossbowmen
dictionary Hungarian_Crossbowmen ; Crossbowmen
category infantry
class skirmish
voice_type Light
accent East_European
banner faction main_missile
banner holy crusade
soldier magyar_swordsmen, 48, 0, 0.8
Is edited so the 'soldier' used is now 'Crossbowmen', rather than a 'magyar_swordsmen'.
Code:
type Hungarian Crossbowmen
dictionary Hungarian_Crossbowmen ; Crossbowmen
category infantry
class skirmish
voice_type Light
accent East_European
banner faction main_missile
banner holy crusade
soldier Crossbowmen, 48, 0, 0.8
Other
Additional information on crashes and how to solve them is appreciated.