Skip to content

Commit

Permalink
Only convert I:R character DNA for characters that aren't purged (#2231)
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Sep 25, 2024
1 parent 710073e commit 6fe2c86
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
6 changes: 1 addition & 5 deletions ImperatorToCK3/CK3/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public string? DeathReason {

public IDictionary<string, string> PrisonerIds { get; } = new Dictionary<string, string>(); // <prisoner id, imprisonment type>

public DNA? DNA { get; private set; }
public DNA? DNA { get; set; }

public Imperator.Characters.Character? ImperatorCharacter { get; set; }

Expand Down Expand Up @@ -406,10 +406,6 @@ ISet<string> unlocalizedImperatorNames
}

Female = ImperatorCharacter.Female;

if (ImperatorCharacter.PortraitData is not null) {
DNA = dnaFactory.GenerateDNA(ImperatorCharacter, ImperatorCharacter.PortraitData);
}

// Determine valid (not dropped in province mappings) "source I:R province" and "source CK3 province"
// to be used by religion mapper. Don't give up without a fight.
Expand Down
15 changes: 15 additions & 0 deletions ImperatorToCK3/CK3/Characters/CharacterCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using ImperatorToCK3.CommonUtils;
using ImperatorToCK3.CommonUtils.Map;
using ImperatorToCK3.Imperator.Armies;
using ImperatorToCK3.Imperator.Characters;
using ImperatorToCK3.Mappers.Culture;
using ImperatorToCK3.Mappers.DeathReason;
using ImperatorToCK3.Mappers.Nickname;
Expand Down Expand Up @@ -667,4 +668,18 @@ Configuration config

Logger.IncrementProgress();
}

public void ConvertImperatorCharacterDNA(DNAFactory dnaFactory) {
Logger.Info("Converting Imperator character DNA to CK3...");
foreach (var character in this) {
if (character.ImperatorCharacter is null) {
continue;
}

PortraitData? portraitData = character.ImperatorCharacter.PortraitData;
if (portraitData is not null) {
character.DNA = dnaFactory.GenerateDNA(character.ImperatorCharacter, portraitData);
}
}
}
}
3 changes: 3 additions & 0 deletions ImperatorToCK3/CK3/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ public World(Imperator.World impWorld, Configuration config, Thread? irCoaExtrac

Characters.RemoveEmployerIdFromLandedCharacters(LandedTitles, CorrectedDate);
Characters.PurgeUnneededCharacters(LandedTitles, Dynasties, DynastyHouses, config.CK3BookmarkDate);
// We could convert Imperator character DNA while importing the characters.
// But that'd be wasteful, because some of them are purged. So, we do it now.
Characters.ConvertImperatorCharacterDNA(dnaFactory);

// After the purging of unneeded characters, we should clean up the title history.
LandedTitles.CleanUpHistory(Characters, config.CK3BookmarkDate);
Expand Down

0 comments on commit 6fe2c86

Please sign in to comment.