🗲 Crashes 🗲
NullReferenceException
Message: Object reference not set to an instance of an object.
Source: SandBox
GetSuitableSpear - PrepareGuardAgentDataFromGarrison - TakeGuardAgentFromGarrisonTroopList - CreateStandGuardWithSpear
I'm getting this crash whenever I take a settlement with my custom culture and try to go to Lord's hall or dungeon
REASON: Custom culture guards entries in spgenericcharacters.xml (sandbox folder) need to go in spnpcharacters.xml in your mod's folder
Source: TaleWorlds.CampaignSystem
CampaignObjectManager - InitializeCachedData - InitializeOnNewGame - OnInitialize - DoLoadingForGameType
REASON: Settlement bound="Settlement.town_CR4" pointed to the non-existing settlement in settlements.xml
GetHeroesForEffectiveRelation - ApplyInternal - CreateRebelPartyAndClan - StartRebellionEvent - DailyTickSettlement
REASON: ?
BuildWorkshopForHeroAtGameStart - BuildWorkshopsAtGameStart - OnNewGameCreatedPartialFollowUp
REASON: Used non-existant equipment set for NPCCharacter: <EquipmentSet id="npc_gentry_equipment_sturgia"/>
GetBodyProperties - GetCharacterCode - set_Character - set_Troop - PartyCharacterVM - InitializePartyList
REASON: Used non-existant BodyProperty for NPCCharacter
DefaultMapDistanceModel - GetDistance
REASON1: Wrongly assigned Settlement, Kingdom without a settlement. Attach dnSpy, it will show faction.FactionMidSettlement == null. Fix your XML.
REASON2: Problems with Navmesh. Inaccessible settlements. Old/mismatching settlements_distance_cache.bin - fix navmesh, regenerate settlements_distance_cache.bin
Once I loaded Lemmy's map together with mine and got this crash ¯\_(ツ)_/¯
CampaignObjectManager.InitializeCachedData()
REASON: settlements.xml error - I accidently deleted one settlement and village had no bounded castle (crash on settlement.OwnerClan.OnBoundVillageAdded(settlement.Village);). This was on new game start.
If nothing helps, use this patch:
[HarmonyPatch(typeof(DefaultMapDistanceModel))]
[HarmonyPatch("GetDistance")]
[HarmonyPatch(new Type[] { typeof(Settlement), typeof(Settlement) })]
public class DefaultMapDistanceModel_GetDistance_Patch
{
static bool Prefix(Settlement fromSettlement, Settlement toSettlement, ref float __result)
{
if (fromSettlement == null || toSettlement == null)
{
__result = 0f;
return false;
}
return true;
}
}
DefaultMapDistanceModel - GetDistance - VillageGoodProductionCampaignBehavior - DistributeInitialItemsToTowns - OnNewGameCreatedPartialFollowUp
REASON: it happens when a village is too far away from a city (even if the village belongs to a castle) but there is a script to fix that
SOLUTION: : The problem solved by having to make a town closer to the castle, and raise the trade bound system to 4000 (more info)
SpawnNotablesIfNeeded - NotablesCampaignBehavior - DailyTickSettlement
REASON: Some type of notable is missing for some culture. I was missing RuralNotable
Set in <notable_and_wanderer_templates> in culture XML
CalculateAverageWage - DoLoadingForGameType - DoLoadingForGameManager
REASON: ??? (maybe something related to party templates with non-existant troop IDs, but not confirmed)
CharacterObject - GetSkillValue - DefaultPartyMoraleModel - GetMoraleEffectsFromSkill - GetEffectivePartyMorale
REASON: used not existant troop ID in the <MBPartyTemplate id="villager_CUSTOM_CULTURE_template">
HINT: Check Encyclopedia-Troops if necessary troop is actually in the game.
DefaultPartyWageModel - GetTotalWage - MobileParty - get_TotalWage - get_LimitedPartySize - CalculateGarrisonChangeInternal
REASON: Troop ID used in partyTemplates.xml refers to a non-existing troop ID in the trooptree.
SetInitialValuesFromCharacter - CreateNewHero - CreateSpecialHero - CreateMinorFactionHeroFromTemplate - SpawnMinorFactionHeroes - OnNewGameCreated
REASON1: spclans.xslt and custom_spclans.xml were in a separate folder for spclans, but missing empty spclans.xml file
REASON2: for Lord NPCCharacter used EquipmentSet instead of EquipmentRoster
HeroCreator - CreateNewHero - CreateSpecialHero - CreateMinorFactionHeroFromTemplate - SpawnMinorFactionHeroes - OnNewGameCreated
REASON: error in <minor_faction_character_templates>, I used name= instead of id=
HeroCreator - CreateNewHero - FindRandomInternal - CreateNewHero - CreateSpecialHero
REASON: error in XSLT by assigning a culture to a hero
SiegeTowerSpawner - AssignParameters - SpawnerEntityMissionHelper - OnPreInit
On starting the scene.
REASON: name property for siege_tower entity:
ArrangeDestructedMeshes - SetUpScene - AfterStart - FinishMissionLoading
REASON: siege engine can't find which wall segment to attack. Tag is missing. Commented out in xscene:
DestructableComponent - OnInit
The scene was working on L1 Summer/Winter/Sprint, crashing on L1/Fall and on all L2/L3
REASON: entity with DestructableComponent had debris_holder with season_mask="253". Removing the season_mask solved the crash:
BackstoryCampaignBehavior - OnNewGameCreated
REASON: commented out some native hard-coded lord/settlement
Check in BackstoryCampaignBehavior.OnNewGameCreated
Fix with Harmony to skip this native code:
InitialChildGenerationCampaignBehavior - OnNewGameCreatedPartialFollowUp - InvokeList - OnNewGameCreated
REASON: Missing male or female lord of one of the cultures. Both male and female lords should be present for each culture to pass this function at the game creation.
CreateNewHero - CreateSpecialHero - OnNewGameCreatedPartialFollowUp - InitialChildGenerationCampaignBehavior
REASON: Hero present, lord not present, lord used in a clan definition as owner
REASON2: wrong id in <xsl:template match="Settlement[@id='village_EN1_3']/@culture">
DefaultMapDistanceModel - GetDistance - UpdateFriendshipAndEnemies
REASON 1: Lord/hero without a proper clan (clan not created/deleted)
REASON 2: Incorrect load order when launching game, e.g. Lemmy's map was loaded after a mod using it.
Kingdom - OnNewGameCreated - InvokeList - OnNewGameCreated
REASON: Deleted hero/lord, the 'owner' of the Kingdom
CalculateDailyProductionAmount - GetWerehouseCapacity - TickProductions - OnNewGameCreatedPartialFollowUp
REASON: assigned a settlement to non-existant clan
REASON2: error in defining minor_clan, I had label_color="FF7264D16" (one digit too much in the color code)
REASON3: error in defining a clan, had NaN in banner_key="11.141.19.1836.1836.768.788.1.0.NaN.510...., wrong/duplicate Faction id=
NameGenerator - CalculateNameScore - SelectNameIndex - GenerateHeroFirstName - CreateSpecialHero - InitialChildGenerationCampaignBehavior - OnNewGameCreatedPartialFollowUp
REASON: Clan's owner was non-existant Lord
DefaultMapDistanceModel - GetClosestSettlementForNavigationMesh - GetDistance - FindNearestSettlement - TryToAssignTradeBoundForVillage - UpdateTradeBounds
REASON: saved a Main_map when game was open, xscene file gone, map gone. Game started with vanilla Main_map with custom settlements.xml
AgingCampaignBehavior - OnHeroComesOfAge - InvokeList - DailyTickHero
REASON: error/missing sandboxcore_equipment_sets.xml for the hero's culture. Hero turned 18
TournamentGames - TournamentMatch - AddParticipant - TournamentBehavior - FillParticipants
REASON: RBM Tournament expects local culture troops in the settlement for the Tournament. Troops were not implemented for that culture.
Clan - OnFortificationAdded - PreAfterLoad
REASON: Old save loaded on a new map with new settlements not present in the old save
GangLeaderNeedsToOffloadStolenGoodsIssueBehavior - ConditionsHold - OnCheckForIssue - IssuesCampaignBehavior - CreateAnIssueForSettlementNotables
REASON: It's seems it is related to the mission NotableWantsDaughterFound. When it ends the GangLeader is spawned in the village where this mission was originated. This GangLeader then is used for this OffloadStolenGoods mission check and that results in the crash. Seems like native bug. I patched the crashing method with the check if village notable is not GangLeader.
ApplySimulatedHitRewardToSelectedTroop - SimulateSingleHit - SimulateBattleForRound
Crash in CharacterObject.get_FirstBattleEquipment
REASON: troop with all <EquipmentRoster civilian="true">, without <EquipmentRoster>
Source: MonoMod.Utils
GauntletMovie - LoadMovie_Patch0 - Load - LoadMovie
REASON: Movie XML file not present. (deleted/wrong name/path?)
LordConversationsCampaignBehavior - conversation_wanderer_introduction_on_condition - RunCondition
REASON: No native settlement town_ES4 in the game.
GetEffectiveDailyExperience - DefaultPartyTrainingModel - OnDailyTickParty
REASON: melee_elite_militia_troop in culture.xml was set to non-existant troop ID
ArgumentNullException
Message: Value cannot be null. Parameter name: source
Source: System.Core
CreateHeroAtOccupation
REASON: in CUSTOM_culture.xml commented out one name:
also commented out one basic_mercenary_troops:SortedList.Add - AiVisitSettlementBehavior - FindSettlementsToVisitWithDistances - AiHourlyTick
Message: An entry with the same key already exists
REASON: had <Village> with the same id in the settlements.xml (not Settlement id but Village id with the _comp_!)
Simple bash script to check for 'Village id' duplicates:
#!/bin/bash
# Define the XML file path
XML_FILE="settlements.xml"
# Check if the file exists
if [[ ! -f "$XML_FILE" ]]; then
echo "File $XML_FILE does not exist."
exit 1
fi
# Extract id attributes from Village elements
ids=$(xmllint --xpath '//Village/@id' "$XML_FILE" 2>/dev/null | grep -o 'id="[^"]*"' | sed 's/id=//g' | tr -d '"')
# Check if xmllint failed
if [[ $? -ne 0 ]]; then
echo "Error processing the XML file."
exit 1
fi
# Find duplicate ids
duplicate_ids=$(echo "$ids" | sort | uniq -d)
# Display the duplicate ids
if [[ -n "$duplicate_ids" ]]; then
echo "Duplicate Village ids found:"
for id in $duplicate_ids; do
count=$(echo "$ids" | grep -c "^$id$")
echo "id: $id, Count: $count"
done
else
echo "No duplicate Village ids found."
fi
Linq.Enumerable.Any - Extensions.IsEmpty - NameGenerator - GetNameListForCulture - GenerateHeroFirstName
REASON: error in the culture xml file
InvalidOperationException
Message: The XmlReader state should be Interactive.
Source: System.Xml.Linq
ReadContentFrom - Load - ToXDocument - MergeTwoXmls - CreateMergedXmlFile
REASON: error in the XML file, example:
- missing opening tag <Items>
- wrong closing tag <Items/> vs </Items>
- CUSTOM_settlements.xml completely empty
- etc
Message: Sequence contains no matching element
Source: System.Core
Enumerable.First - InitializeCaravanOnCreation - CreateCaravanParty - CreateParty - CreateCaravanParty
REASON: CUSTOM_culture notable Merchant was expecting CaravanGuard with the same culture: character.Culture == mobileParty.Party.Owner.Culture
Single - CharacterCreationCultureStageVM - SortCultureList - CharacterCreationCultureStageView
REASON: Native culture is removed or is made is_main_culture=true
IndexOutOfRangeException
Message: Index was outside the bounds of the array.
Source: TaleWorlds.CampaignSystem
DefaultMapWeatherModel - GetWeatherEventInPosition - WeatherAudioTick - TickVisuals
REASON: Marked 'Use Dynamic Weather Effects' without the a flowmap. Maybe map is not a square. Maybe flowmap is not 1024x1024.
Source: TaleWorlds.CampaignSystem
OnNewGameCreated
REASON1: Lord (NPCCharacter) id mismatch with hero id, no lord for the heroe, "Hero." missed with hero id
REASON2: 2 lords with the same id
REASON3: Comments in spkingdoms.xml :D
REASON4: NPCCharacter age="9.9" (not int) in lords.xml
AccessViolationException
Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source: TaleWorlds.MountAndBlade
MapScene - GetNavigationMeshCenterPosition - DefaultMapDistanceModel - GetClosestSettlementForNavigationMesh - GetDistance - CalculatePartyInfluenceCost - CalculateTotalInfluenceCost
REASON: settlement not covered by Navmesh
REASON2: hole in the Navmesh
REASON3: outdated Settlements Distance Cache. Delete/regenerate it
hunharibo: looks like a navmesh issue. Either a face with inverted normals or a concave quad or a face that is not connected to anything
FinalizeMission - EndMissionInternal - CheckMissionEnd - OnTick
Crash was on the exit out from the mission.
REASON: xscene contained one entity, and commenting it out stopped the crash, no idea why/how, there are more similar entities in the scene:
<game_entity name="aserai_grandbazaar_wall" old_prefab_name="" occlusion_body_name="bo_occ_aserai_grandbazaar_wall">
<transform position="-73.488, 137.875, 0.924" rotation_euler="0.000, 0.000, 1.571" scale="0.470, 0.150, 0.000"/>
<physics shape="bo_aserai_grandbazaar_wall"/>
<components>
<meta_mesh_component name="aserai_grandbazaar_wall">
<mesh name="aserai_grandbazaar_wall" material="adobe_wall_white"/>
</meta_mesh_component>
</components>
</game_entity>
Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
InvokeMethod - Invoke - CreateInstanceImpl - CreateInstance - CreateScreen
REASON: map xscene settlement ID mismatch with settlements.xml settlement ID. settlements.xml has a settlement with ID, which is not present in the xscene file
... GetEncyclopediaPageInstance - SetEncyclopediaPage - GauntletMapEncyclopediaView - ExecuteLink
Crash by pressing on the lord's image in the Encyclopedia.
REASON: Lord's spause is deleted, but reference to it in the heroes.xml remains for the main lord. Eg: spouse="Hero.lord_4_2"
TypeInitializationException
Source: TaleWorlds.CampaignSystem
CalculateBaseSpeed - CalculateSpeedForPartyUnified
More info here
System.Xml.Xsl.XslTransformException
Message: Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added.
Source: System.Data.SqlXml
XmlQueryOutput - ThrowInvalidStateError
REASON: tried to change non-existant attribute with XSLT
Message: Unexpected token '=' in the expression.
XslCompiledTransform - LoadInternal - ApplyXslt - CreateMergedXmlFile - GetMergedXmlForManaged - LoadXML - InitializeSandboxXMLs
REASON: Translation line in the xslt, like {=skalvians}Skalvians. Move this to XML
CTD without any message
CTD - Crash To Desktop
On new game start
REASON: non-existant troop refferenced in party_templates.xml <PartyTemplateStack ... />
On mission start
Error log last line: Selected formations being cleared.
REASON: this entity was commented out in the xscene:
xml
<game_entity name="icon_camera" old_prefab_name="icon_camera" mobility="1">
On entering scene
REASON: scene does not exist
REASON2: error in the scene's xscene file
When entering settlement
REASON: Bad troop id: villager_danish vs danish_villager
Others
GetBodyProperties - LocationCharacter - CreateMercenary - AddLocationCharacters - AddMercenaryCharacterToTavern
In CUSTOM_culture.xml error in defining caravan guards:
HarmonyLib.PatchClassProcessor.ReportException() - Patch()
When loading the game with DnSpy attached, make sure to disable the BannerColorPersistence in the load order.