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

Fix for not finding BP mods and lua mods if there are unicode characters in game path #657

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DeadMor0z
Copy link

@DeadMor0z DeadMor0z commented Sep 18, 2024

Description

Fixes #495, #335

While it is possible to workaround those issues, by setting ModsFolderPath to directory without unicode characters, this doesn't solve a problem with loading BP mods from Content\Paks\LogicMods folder, which is still inside path with unicode character and does not have relevant settings to bypass this issue.
Also forcing users to make additional configuration makes using mods more diffucult.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Problem occured, while working on mod for "The Lord of the Rings Return to Moria™" game (note that unicode symbol at the end). After applying a fix - all mods load correctly, lua and BP.

Checklist

All changes are small and pretty self-explanatory. They are mostly one-liners and have no additional code.
The only real additions are:

  1. wrapper function for fopen (wfopen) to make number of changes to LuaRaw as small as possible.
  2. conversion of GetModuleFileNameW result to utf-8 in setprogdir (LuaRaw, loadlib.c)

Please delete options that are not relevant. Update the list as the PR progresses.

Screenshots (if appropriate)

Additional context

Add any other context about the pull request here.

@DeadMor0z DeadMor0z changed the title Fix for not finding BP mods and lua mods if there are unicode characer in game path Fix for not finding BP mods and lua mods if there are unicode characers in game path Sep 18, 2024
@DeadMor0z DeadMor0z changed the title Fix for not finding BP mods and lua mods if there are unicode characers in game path Fix for not finding BP mods and lua mods if there are unicode characters in game path Sep 19, 2024
@UE4SS
Copy link
Collaborator

UE4SS commented Sep 21, 2024

Unrelated to this PR, but it shows a problem elsewhere.
The PR action doesn't work when users don't provide the UEPseudo token.
I'm assuming it has to do with the UEPSEUDO_PAT token in the workflow file:

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: recursive # Clone the submodule so we can query xmake on the entire project.
          token: ${{ secrets.UEPSEUDO_PAT }}

@narknon
Copy link
Collaborator

narknon commented Sep 26, 2024

I tried something similar in the past and had issues with certain code in lua mods not loading correctly. Did you load all default mods without issue?

I'm not a huge fan of changing base lua at all, because that means this code has to be migrated if we go to LuaJIT or any other lua variations. Not sure if there's an alternative.

@narknon
Copy link
Collaborator

narknon commented Sep 26, 2024

Not sure if there's anything in here that may be useful: https://github.com/Tencent/UnLua/tree/master

@DeadMor0z
Copy link
Author

I tried something similar in the past and had issues with certain code in lua mods not loading correctly. Did you load all default mods without issue?

I'm not a huge fan of changing base lua at all, because that means this code has to be migrated if we go to LuaJIT or any other lua variations. Not sure if there's an alternative.

Yes, all default mods were loaded correctly. Base lua had to be changed because: 1. it uses GetModuleNameA to get executable path, to correctly build path and cpath environment variables. Since this function returns an ascii string - path with unicode characters will be invalid in this case. 2 - it uses fopen to check and open lua files, which takes ascii string as path parameter, so any file with unicode character in pathname will not be found or open.

@DeadMor0z
Copy link
Author

I tried something similar in the past and had issues with certain code in lua mods not loading correctly. Did you load all default mods without issue?

I'm not a huge fan of changing base lua at all, because that means this code has to be migrated if we go to LuaJIT or any other lua variations. Not sure if there's an alternative.

No, it only needs to be migrated if you go to new lua variation which does not support unicode characters in pathnames. Anyway, base lua changes are pretty straightforward, nothing extraordinary there, amount of changes is very low and can be done in a 5-10 minutes at most.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG - Release] Lua mods don't load when game directory has a unicode character
3 participants