Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug / Contribution] Mapping folders ~fix #178

Closed
guiseiz opened this issue Jun 26, 2023 · 7 comments · Fixed by #201
Closed

[Bug / Contribution] Mapping folders ~fix #178

guiseiz opened this issue Jun 26, 2023 · 7 comments · Fixed by #201
Labels
bug Something isn't working

Comments

@guiseiz
Copy link

guiseiz commented Jun 26, 2023

Issue
A lot of players faces don't show up when you press 'preserve'
Screenshot 2023-06-26 at 10 58 36 AM

I noticed that this was because the mapping of the asset to folder was wrong

<record from="Asian/Caucasian551" to="graphics/pictures/person/2002179270/portrait"/>
<record from="Seasian/Asian2324" to="graphics/pictures/person/2002174975/portrait"/>

👆 here the it's trying to find Asian2324.png in a Seasian folder and it wont find it -so the image returns blank

--

i have a quick script that

  • reads every record and sees if the asset name == the folder name (ie asian/asiannnn.png)
  • if it isn't it, changes it to be the same
  • then saves a new fixed config file

--

i've been using this python script locally with the terminal
CleanShot 2023-06-26 at 15 41 15

but i don't know how to push it live - i keep running into issues with netlify

https://magical-torte-c64a84.netlify.app/
👆 the script doesnt seem to run when i deploy it :( maybe someone knows how to fix it

here's the source code in case someone knows how to work with servers :P
newganfix.zip


👇 here's the script file to run locally

import re
import random

# Define maximum assets for each folder
folder_max_assets = {
    'EECA': 15999,
    'African': 11999,
    'Asian': 3999,
    'Caucasian': 15999,
    'Central European': 17999,
    'Italmed': 12999,
    'MENA': 5999,
    'MESA': 1991,
    'SAMed': 3999,
    'Scandinavian': 7999,
    'Seasian': 3999,
    'South American': 11999,
    'SpanMed': 7999,
    'YugoGreek': 9999
}

# Open config.xml file -- change this to be whatever file you're wanting changed -- and check if the the ethnicity thats before the '/' matches what's after. 

def correct_asset_names():
    with open('config.xml', 'r') as file:
        lines = file.readlines()

    with open('corrected_config.xml', 'w') as file:
        for line in lines:
            match = re.search(r'from="([^"]+)/([^"]+)"', line)
            if match:
                folder = match.group(1)
                asset = match.group(2)

                # Correct assets in other folders
                if folder in folder_max_assets:
                    asset_match = re.match(r'([a-zA-Z\s]+)(\d+)', asset) # This line has changed
                    if asset_match:
                        asset_name = asset_match.group(1)
                        asset_number = int(asset_match.group(2))
                        if asset_name != folder or asset_number > folder_max_assets[folder]:
                            asset_name = folder
                            asset_number = random.randint(1, folder_max_assets[folder])
                            line = line.replace(match.group(0), f'from="{folder}/{asset_name}{asset_number}"') # This line has changed
            file.write(line)

if __name__ == "__main__":
    correct_asset_names()

instructions

  • unzip
  • move your broken config.xml to this folder
  • open terminal
  • in terminal : navigate to the folder you've unzipped
  • in terminal : type python script.py (or python3 script.py)
  • it should automatically create a corrected_config.xml
  • replace the config.xml in newgan with this new one (remember to rename it config.xml)
@guiseiz guiseiz added the bug Something isn't working label Jun 26, 2023
@034georgie
Copy link

I'm getting this bug a lot more often now - not familiar with python beyond just basic editing (copy pasting) some code in Atom, and other fix we can do by modifying possibly the mapper.py file?

@034georgie
Copy link

034georgie commented Nov 29, 2023

Quick note - noticed that this mapping issue only happens when using the preserve option.

@nevemlaci
Copy link

@034georgie You might want to upload that code as a repo to your github profile and share it so people can easily access it in the future and even help contribute to it if they feel like it:)

@034georgie
Copy link

@nevemlaci - sorry, as mentioned, I'm not too familiar with the code. Just rudimentary copy-pasting of existing pull requests into my own mapper.py to fix some issues. I just wanted to flag that whatever is causing this bug might have something to do with how the preserve function is coded, but I don't know how to fix it.

@nevemlaci
Copy link

@034georgie You could still upload it to github so others can help with bugs that could be present via PRs. :)

@Maradonna90
Copy link
Owner

might be similar to #84

@guiseiz
Copy link
Author

guiseiz commented Jan 8, 2024

@034georgie You might want to upload that code as a repo to your github profile and share it so people can easily access it in the future and even help contribute to it if they feel like it:)

i think your comment was meant to be adressed to me. fixed now it seems :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants