• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Masternachos

the Affable
67 Badges
Jun 10, 2010
1.262
772
  • Crusader Kings II
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • Cities: Skylines Deluxe Edition
  • Europa Universalis IV: Mare Nostrum
  • Victoria: Revolutions
  • Europa Universalis IV: Rights of Man
  • Stellaris: Megacorp
  • Crusader Kings II: Conclave
  • Stellaris: Distant Stars
  • Cities: Skylines - Campus
  • Stellaris: Galaxy Edition
  • Crusader Kings II: Holy Fury
  • Crusader Kings II: Reapers Due
  • Crusader Kings II: Way of Life
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Crusader Kings II: Monks and Mystics
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Cities: Skylines - Parklife
  • Stellaris: Lithoids
  • Cities: Skylines - Green Cities
  • Stellaris: Ancient Relics
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV
  • Europa Universalis IV: Dharma
  • Stellaris: Necroids
  • Europa Universalis III Complete
  • Europa Universalis III Complete
  • Europa Universalis IV: Res Publica
  • Victoria 2
  • 500k Club
  • Crusader Kings III
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Common Sense
  • Stellaris: Federations
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
I'm wondering if someone has developed a program or figured out a trick to quickly find what Character ID numbers aren't being used in a mod. Because right now the only way I can think of is to manually type each possible number into the folder search to see if something comes up.

...I now realize that "unused CharIDs" could potentially be infinite (I know CharIDs of more than 10 digits can cause problems, but they can still exist, right?), so it would be best to have a way to limit the search (say, Only look for unused CharIDs between X and Y).
 
Here is a Python script I wrote to find the highest character ID in use:

Code:
import sys
import os
import string

highest_char_id = 0

for filename in os.listdir(sys.argv[1]):
    with open(os.path.join(sys.argv[1], filename)) as file:
        for line in file:
            char_id = ''
            for char in line:
                if char in string.digits:
                    char_id += char
                else:
                    break
            if len(char_id) == 0:
                continue
            if int(char_id) > highest_char_id:
                highest_char_id = int(char_id)
                
print('Highest character ID:', highest_char_id)

Run it as <script>.py <path to history/characters/ folder>.
 
For reference; it's safe to use character ids starting from 276 000, dynasty ids between 13 500 and 999 999 (for some reason it skips over almost a million ids there), and after 1 071 000.
 
Here is a Python script I wrote to find the highest character ID in use:

Code:
import sys
import os
import string

highest_char_id = 0

for filename in os.listdir(sys.argv[1]):
    with open(os.path.join(sys.argv[1], filename)) as file:
        for line in file:
            char_id = ''
            for char in line:
                if char in string.digits:
                    char_id += char
                else:
                    break
            if len(char_id) == 0:
                continue
            if int(char_id) > highest_char_id:
                highest_char_id = int(char_id)
               
print('Highest character ID:', highest_char_id)

Run it as <script>.py <path to history/characters/ folder>.
Not quite what I was looking for; but basically confirms my suspicion that what I AM looking for is impossible, so this is still very useful.
Thank you!
 
Not quite what I was looking for; but basically confirms my suspicion that what I AM looking for is impossible, so this is still very useful.
Thank you!
Oh, it would not be impossible to get a list of every single unused character/dynasty ID at all; just a bit inconvenient. It makes more sense to define the bounds of the ranges of used/unused ids, e.g. "Every ID over 500 is free", rather than listing all of them, e.g. "Free IDs: 500, 501, 502, 503..." because the first method is easier to write down and gives the exact same information.