Skip to content

Failed to find Verse.ThingDef named Cumpilation_Samenstein #47

Description

@AlessandroContu

Description

When Semen Processor (winderig.processor) is active, the LoadFolders.xml excludes 1.6/Mods/Not-Semen-Processor, so the ThingDef Cumpilation_Samenstein is not loaded.
However, the Harmony patch Patch_AllowedStuffsFor_noCumRuins still runs and calls:
DefDatabase.GetNamed("Cumpilation_Samenstein")

This causes the error:
Failed to find Verse.ThingDef named Cumpilation_Samenstein

What should happen instead:
The patch should not error if the def is not loaded due to conditional LoadFolders.
The def lookup should be silent or conditional.
Using GetNamedSilentFail (and optionally supporting CM_Samenstein) fixes the issue.

To Reproduce

Enable Cumpilation
Enable Semen Processor (packageID: winderig.processor)
Start RimWorld

Observe error during loading / long events

Error Message
Failed to find Verse.ThingDef named Cumpilation_Samenstein. There are XXXXX defs of this type loaded.
Verse.DefDatabase`1<Verse.ThingDef>:GetNamed
Cumpilation.Patch_AllowedStuffsFor_noCumRuins:Postfix

Additional context

Relevant line in LoadFolders.xml:

  • 1.6/Mods/Not-Semen-Processor
  • When winderig.processor is active, Cumpilation_Samenstein is not loaded, but the Harmony patch still tries to access it.

    Suggested fix

    Replace hard lookup with silent lookup and support both defs:

    Patch_AllowedStuffsFor_noCumRuins

    static IEnumerable Postfix(IEnumerable values)
    {
    var bannedA = DefDatabase.GetNamedSilentFail("Cumpilation_Samenstein");
    var bannedB = DefDatabase.GetNamedSilentFail("CM_Samenstein");

    foreach (var v in values)
        if ((bannedA == null || v != bannedA) && (bannedB == null || v != bannedB))
            yield return v;
    

    }

    Alternatively, conditionally disable the patch when the folder is not loaded.

    if (ModsConfig.IsActive("winderig.processor"))
    return values;

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      No labels
      No labels

      Projects

      No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions