Author Topic: [bug/suggestion] Check for identical soldier names when spawning new soldiers?  (Read 63 times)

Online psavola

  • Commander
  • *****
  • Posts: 832
    • View Profile
When spawning a soldier (e.g. through hiring or manufacturing), apparently OXCE does not check if the soldier with an identical name already exists. Should it?

I came across this with XCF rat training, when two consecutive rats "manufactured" were both named Toblerone. I suppose this problem is more likely to occur with those agent types which don't have firstname and lastname, but rather just a single name, leading to a higher chance of clashes.

Not a big deal, but maybe it would be worth considering if OXCE should try to randomize the name again if there already exists a soldier of that name in any of the bases. Of course, this could lead to follow-up question: should this be attempted just once or as long as there is a clash. In theory it could happen that you completely run out of the name pool, leading to a new issue. I suppose this would call for trying just once or appending something to the new in case of a clash to avoid the problem.

If this not deemed an issue, the player could just rename them manually if this feels bothersome.
« Last Edit: Today at 09:24:27 am by psavola »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
OXCE does check if a soldier with identical name already exists.
It tries 10 times to find a new name, same as OXC and OG.

https://github.com/MeridianOXC/OpenXcom/blob/oxce-plus/src/Mod/Mod.cpp#L4998

Online psavola

  • Commander
  • *****
  • Posts: 832
    • View Profile
Thanks for info. This is strange. Looking at the save, I can confirm that I do indeed have (or had, the other just died after I had written the message) a rat named "Toblerone" with id=37 and another rat named "Toblerone" with id=39. I don't rename units so my initial observation must have been true.

I am using Kozinsky's XCF stat strings, but I doubt that should affect this as the name does not change, only its representation.

I'm not sure if there is any way to debug this afterwards, but I'm attaching a save just in case for reference.