Catch attempting to tick uninitialized wombs

This commit is contained in:
lutepickle 2022-09-09 09:38:16 -07:00
parent 0e8c025429
commit 003f5d6d29
2 changed files with 13 additions and 0 deletions

Binary file not shown.

View File

@ -72,6 +72,7 @@ namespace RJW_Menstruation
public Stage curStage = Stage.Follicular;
public int curStageHrs = 0;
public bool loaded = false;
public bool initError = false;
public int ovarypower = -100000;
public int eggstack = 0;
public bool DoCleanWomb = false;
@ -610,6 +611,13 @@ namespace RJW_Menstruation
// If an exception makes it out, RW will remove the hediff, so catch it here
try
{
// Initialize immediately if needed, but if there's an error, then don't spam it every tick
if (!loaded && !initError)
{
Log.Warning($"{Pawn}'s womb is ticking, but was not initialized first");
Initialize();
}
if (
!Pawn.IsHashIntervalTick(tickInterval) ||
!ShouldSimulate()
@ -618,6 +626,8 @@ namespace RJW_Menstruation
return;
}
if (initError) Log.Warning($"Attempting to process {Pawn}'s womb uninitialized");
if (Pregnancy != null && curStage != Stage.Pregnant)
{
Log.Warning($"{Pawn}'s womb has a pregnancy, but was not in the pregnant stage");
@ -994,6 +1004,7 @@ namespace RJW_Menstruation
public void Initialize()
{
initError = true;
Props = (CompProperties_Menstruation)props;
if (Props.infertile)
@ -1001,6 +1012,7 @@ namespace RJW_Menstruation
if (cums == null) cums = new List<Cum>();
curStage = Stage.None;
loaded = true;
initError = false;
return;
}
@ -1028,6 +1040,7 @@ namespace RJW_Menstruation
//Log.Message(Pawn.Label + " - Initialized menstruation comp");
loaded = true;
initError = false;
}
protected virtual float RaceCyclesPerYear()