vegapnk / Cumpilation

Fluid-Based RJW-Mechanics
GNU Affero General Public License v3.0
1 stars 1 forks source link

Overflowing Cumflation can cause Crash #8

Closed vegapnk closed 1 month ago

vegapnk commented 1 month ago
The overflowing cumflation seems to cause rimworld to crash almost immediately

Hmm I can't seem to replicate it in my minimal mod list tho, must be an interaction with another mod I have
[[ uses performance optimizer and rocketman]]

JobDriver

Later:

Just a small update.  I temporarily solved the crash issue I had by turning off cumflation in the mod settings.  It really seems to be caused by overflowing cum in a small closed room filled with cum filth.  It seems like it might be related to the filth spawning?

Current Running Idea: It tries to spawn filth at places where it can't.

vegapnk commented 1 month ago

More Info:

I stripped the mod list down to the very basics.  I learned something new.  The crash only occurs if they can still stand afterward.  I used a custom mod to remove the pain and movement debuffs in my game that put them on the floor.  For this test though I ended up giving her go-juice so she didn't drop and then it predictably crashed.

The JobDriver tick errors occured the times she did drop from pain/movement after sex when it didn't crash.

And a Log: https://pastebin.com/ZtNmSbB0

With this error:

Exception in JobDriver tick for pawn Lynx driver=JobDriver_BestialityForFemale (toilIndex=5)
System.NullReferenceException: Object reference not set to an instance of an object
[Ref 4BD8D97F]
 at rjw.SexUtility.reduce_rest (Verse.Pawn pawn, System.Single x) [0x00018] in <36fdf7cfc73c41228e347ef9cdc14d0d>:0 
 at rjw.JobDriver_BestialityForFemale+<>c__DisplayClass3_0.<MakeNewToils>b__13 () [0x000bf] in <36fdf7cfc73c41228e347ef9cdc14d0d>:0 
 at Verse.AI.JobDriver.DriverTick () [0x00117] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0  
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Exception in JobDriver tick for pawn Lynx driver=JobDriver_BestialityForFemale (toilIndex=5)
System.NullReferenceException: Object reference not set to an instance of an object
[Ref 4BD8D97F] Duplicate stacktrace, see ref for original 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Exception in JobDriver tick for pawn Lynx driver=JobDriver_BestialityForFemale (toilIndex=5)
System.NullReferenceException: Object reference not set to an instance of an object
[Ref 4BD8D97F] Duplicate stacktrace, see ref for original 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)
[[...]]
vegapnk commented 1 month ago

I could not reproduce, but I got some more information:

I used a small closed and roofed room with a double sleeping spot.  
Female pawn, large animal that outputs 700ml+, had to use go-juice to 
keep her on her feet then just spammed vaginal.

I still got the test save sitting around.  I used the following dlc/mods.

Prepatcher
Harmony
Core
Better Log - Fix your errors
Royalty
Ideology
Biotech
Anomaly
HugsLib
RimSaves
Character Editor
RimJobWorld
Cumpilation
vegapnk commented 1 month ago

I got some more errors:

<color=#00FFFFFF>SOS2: </color>Map-14-PlayerHome<color=#00FF00FF> Ship </color>1 Attached cells: 1
Exception in JobDriver tick for pawn Perfection driver=JobDriver_OverflowingCumflation (toilIndex=0) driver.job=(Cumpilation_OverflowingCumflation (Job_33676947) A = Thing_Human3955965 Giver = ThinkNode_QueuedJob [workGiverDef: null])
System.StackOverflowException: The requested operation caused a stack overflow.
[Ref 235AD2E6]
 at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
 at <0x23bf97d0bf0 + 0x0004a> <unknown method>
 at <0x23bf97d0b70 + 0x00032> <unknown method>
 at Cumpilation.Cumflation.JobDriver_OverflowingCumflation.GetRandomNearbyPosition (System.Int32 maxDistance) [0x00000] in <59f6c4056e6f4708a47ba91679f74dbb>:0

This is very likely the reason for the game-crashes that usually don't have an error.

It came from Jigglyproff and he also has a (good) theory:

IntVec3 offset = 
    orientation * (new Random()).Next(0, maxDistance);

In the JobDriver

this random seed doesn't seem to change fast enough, 
meaning if a fast computer gets enough clock cycles in this recursive function
 will just keep trying the same impossible cell, calling itself with another offset works
alternatively just make it wait but idk

And this suggested fix:

    Random random = new Random();            
    IntVec3 filthPosition = GetRandomNearbyPosition(random, maxDistance);

    FilthMaker.TryMakeFilth(filthPosition, pawn.Map, chosenFluid.fluid.filth);
}

private IntVec3 GetRandomNearbyPosition(Random random, int maxDistance = 3)
{
    if (random is null)
    {
        throw new ArgumentNullException(nameof(random));
    }

    ModLog.Error($"{pawn} tries to find position with distance {maxDistance}.");
    IntVec3 offset = orientation * random.Next(0, maxDistance);
    IntVec3 positionCandidate = pawn.PositionHeld + offset;
    // Quick Check whether the cell is in the room, not to spawn through walls etc. 
    if (pawn.GetRoom().ContainsCell(positionCandidate))
        return positionCandidate;
    else
        ModLog.Error($"Got random position candidate {positionCandidate}.");
        return GetRandomNearbyPosition(random, maxDistance);
}
using the same Random instance and only calling next() on it again usually results in actually random values

This is a super interesting bug to be honest. I believe also that this "random" optimization might be related to performance fish, because I cannot see the normal game being smart enough to do this.

vegapnk commented 1 month ago

I also got this save-file: Testing.zip

vegapnk commented 1 month ago

This was very funky. Well done RJW Community and Vegapnk!