RimWorld

RimWorld

Vanilla Outposts Expanded: Additional Outposts
This topic has been locked
Imperator 17 Dec, 2022 @ 10:48am
Troubleshooting Custom Factions and Prisoners
I think there are room for improvements in the code for generating prisoners (e.g. from the Prison and Border Outpost) in games that have custom factions. It sounds like your selection criteria in the LINQ query may be skipping factions in some scenarios and there is likely also room for for adding error handling and a fallback method. We likely can find a short putt to fix the issue by modifying the LINQ query.

I worked on compatibility patches for Empire x Save Our Ship 2 and Rim War in 1.3. I think I can show you how to fix this if you share the source code with me. Do you have a git hub page I can submit to?
< >
Showing 1-5 of 5 comments
[Zerg03] MrHydralisk  [developer] 17 Dec, 2022 @ 4:44pm 
Tbh, I pretty new to git, so I'm not very familiar with it yet. Since part of code that causing issue is quite small and self-sufficient, so it should be fine just sending it here. Will it be enough this way?
Last edited by [Zerg03] MrHydralisk; 17 Dec, 2022 @ 4:55pm
[Zerg03] MrHydralisk  [developer] 17 Dec, 2022 @ 4:47pm 
First it trying to get all hostile factions that have humanlike type:
List<Faction> hostileFactions = Find.FactionManager.AllFactionsVisibleInViewOrder.Where((Faction f) => !f.temporary && !f.IsPlayer && f.PlayerRelationKind == FactionRelationKind.Hostile && f.def.humanlikeFaction).ToList();
Then it generating pawn from one of this factions:
Pawn prisoner = PawnGenerator.GeneratePawn(PawnKindDefOf.Villager, hostileFactions.ElementAt(Rand.Range(0, hostileFactions.Count())));
Your error seems to be caused somewhere inside LINQ, which should be fine from what I understand, since it all vanilla fields.
Imperator 18 Dec, 2022 @ 12:28am 
I would say that if you sent me the source code I could compile it and test it with my mod set using additional logging to isolate where exactly the error is produced. Do you want help setting up a github project where you are marked as the code author?
Imperator 18 Dec, 2022 @ 12:31am 
Without seeing more I can't even say for certain that the problem is certainly that the issue comes from the linq expression. I believe you, but it reasonably could be an if statement or something one level above that otherwise causes hostileFactions to be null. I am honestly inclined to believe that someone else's custom faction is just made incorrectly and lacks what would be a normal field, but my aim is to find out for sure.
[Zerg03] MrHydralisk  [developer] 23 Dec, 2022 @ 6:17am 
Fixed
Last edited by [Zerg03] MrHydralisk; 25 Dec, 2022 @ 2:09am
< >
Showing 1-5 of 5 comments
Per page: 1530 50