边缘世界 RimWorld

边缘世界 RimWorld

生物科技异种拓展 - 腐鲛种
NullReferenceException
Bug report:
Your mod Biotech Xenotype Expanded – Rotfish is causing a NullReferenceException in Pawn_AgeTracker.get_ChildAgingMultiplier.
The Rotfish_Library.Patch_ChildAgingMultiplier.PostFix assumes that the ___pawn argument is never null. However, in some situations (e.g., during initialization or for world pawns such as traders), ___pawn can be null, which causes the game to throw an exception every tick.

Suggested fix:
Add a null check for ___pawn in the PostFix before using it. This will prevent the NullReferenceException and stop the error spam in the log.

Error excerpt:
System.NullReferenceException: Object reference not set to an instance of an object
at Rotfish_Library.Patch_ChildAgingMultiplier.PostFix(Single& __result, Pawn ___pawn)
at Verse.Pawn_AgeTracker.get_ChildAgingMultiplier()
< >
正在显示第 1 - 1 条,共 1 条留言
oldnewone 8 月 8 日 上午 10:27 
I don't know how to code. This is from gpt 5.0:

NullReferenceException in Patch_ChildAgingMultiplier.PostFix because ___pawn.genes can be null (e.g. for world pawns / trader crew). The postfix checks Humanlike but doesn’t guard against a missing gene tracker.

Suggested change:
Add a null/biotech guard before calling HasGene:
[HarmonyPostfix]

static void PostFix(ref float __result, Pawn ___pawn)
{
if (___pawn != null
&& ___pawn.RaceProps?.Humanlike == true
&& ModsConfig.BiotechActive
&& ___pawn.genes != null)
{
if (___pawn.genes.HasGene(RF_GeneDefOf.RF_EfficientReproduction))
__result *= 2f;
}
}
Anyway thanks for mod.
< >
正在显示第 1 - 1 条,共 1 条留言
每页显示数: 1530 50