Baffling "Could not get new name" Error in Several Mods

Started by Basker_ville, May 24, 2022, 05:05:23 PM

Previous topic - Next topic


Back in 2016 there was a forum post titled: "Could not get new name" endless loop in Vanilla. It was posted here in Mod Bugs but was found to be a vanilla issue. Has this bug reared its ugly head again?

In the parameters of vanilla RimWorld I couldn't replicate this error, but the problem sometimes arises when mods use custom RulePackDefs referenced in CultureDefs or PawnKindDefs. Is this an underlying vanilla issue or a shared mod error?

After a certain buffer number of spawns, when a PawnKindDef is spawned which references a nameMaker/nameMakerFemale (via PawnKindDef) or a pawnNameMaker/pawnNameMakerFemale (via CultureDef), a red error appears in the console. Consecutive spawns past that present more red errors. The first line of the stack trace for one example reads:

Could not get new name (first rule pack: VFEC_NamerPersonClassicalFemale)

Despite the error, the pawn IS named correctly. The trouble is the barrage of red errors in the console.

To replicate:
0. Use either Qux's "Faction Samurai" or "Vanilla Factions Expanded - Classical"
1. Start New Game
2. Debug mode
3. Execute raid with faction...
4. Any of the Roman or Samurai factions (x10000 points)

After that bulk of spawns, this "buffer" will either be almost or slightly overcome. After repeating step 4, the console will be absolutely flooded with red errors.

Full StackTrace (of one VFEC example):

HugsLib Log (after doing step 4 twice):

This error presents itself in several mods: "Vanilla Factions Expanded - Classical" and "Faction Samurai" are two examples, and it's a problem I myself ran into while making a mod. While VFEC and Faction Samurai use CultureDefs to name their units, I tried using CultureDefs, PawnKindDefs, and "Humanoid Alien Race" AlienRace.ThingDefs. I experienced the same issue as the two aforementioned mods with Culture and PawnKind Defs, but the race-based nameGenerator worked as expected with no such error.

Other Notes:
  • The buffer of spawns before any errors are generated. Generally one 10000 pt raid will slightly overcome the buffer, and it can also be overcome by individually spawning pawns. Adding more names in the string text file does not seem to affect this, but when I tried giving a PawnKindDef just one unique name, that PawnKindDef produced an error after just one spawn. Then after adding thousands of more entries to that file, that PawnKindDef still produced an error after only one spawn. Whatever size the buffer, errors don't occur until it is overcome, and then errors occur after every new spawn.
  • While rarely a pawn spawns with the wrong name, the pawn will almost always spawn with the correct name despite this error message.
  • Sometimes this error occurs multiple times per spawn.
  • The error log frequently refers to RulePackDefs for previously spawned units rather than for the unit that was just spawned. I was able to notice this point in my own unreleased mod with a variety of custom PawnKindDefs and RulePackDefs.

One example with VFEC's Central Republic:
First x10000 pt raid
   0 errors out of 108 new pawns
Second x10000 pt raid
   190 errors out of 178 new pawns

"Vanilla Factions Expanded - Vikings" after 15 x10000 point raids does NOT present this error. VFEV just uses pawnNameMaker through a CultureDef to name its units, unlike Faction Samurai and VFEC which use both pawnNameMaker and pawnNameMakerFemale. However, when I tried commenting out VFEC's pawnNameMakerFemale, the very first x10000 point raid uncharacteristically generated 78 red errors out of 174 spawns.

Name Generation - Referring to RulePackDefs:
   CultureDefs use <pawnNameMaker> and <pawnNameMakerFemale>
   PawnKindDefs use <nameMaker> and <nameMakerFemale>
   Races use <nameGenerator> and <nameGeneratorFemale>
*Many mods use <nameGenerator> in Humanoid Alien Races to generate names without this issue.

Normally it would take a long amount of time to hit the spawn buffer, so it's difficult to test this error without using debug mode commands. Has anyone using these mods with a long-running save file experienced this error?