qsniyg / ksp_stuff

GNU General Public License v3.0
9 stars 4 forks source link

ModOrganizer.ini gamePath starts with @ByteArray, breaking the script #31

Closed smirgol closed 3 years ago

smirgol commented 3 years ago

I don't know why, but the gamePath line in my ModOrganizer 2 INI looks like this: gamePath=@ByteArray(K:\\media\\Speedy\\Spiele\\01_Steam\\steamapps\\common\\Skyrim Special Edition)

This breaks the script, as later on, when looking for that installation, it's trying to resolve a path that contains @ByteArray, which always returns that there is no such path.

My hack is to clean the variable after it has been read from the ModOrganizer.ini:

Custom function to clean a string.

def clean_string_var(var):
    # remove "@ByteArray()
    var = re.sub(r"^@ByteArray\(", "", var)
    var = re.sub(r"\)$", "", var)
    return var

This is the modified function that reads the ModOrganizer.ini:

def get_game_from_moroot(variables):
    moini = os.path.join(variables["mo_gameroot"], "ModOrganizer.ini")

    config = configparser.ConfigParser()
    config.read(moini)

    # here is the custom cleanup
    config["General"]["gamePath"] = clean_string_var(config["General"]["gamePath"])

After adding that, it runs just fine. No clue if my regex is fail-proof, I rarely do something with python, but for me it works. :)

qsniyg commented 3 years ago

Could you see if https://github.com/qsniyg/ksp_stuff/commit/29d06c0362d37210172bf4a62c364913cfb5acfe fixes it? I haven't tested it.

By the way, is there a reason you're using this instead of just MO2 itself? Theoretically it should work fine under wine 5.0+ (I've used it under 5.18 iirc without issue)

jarrard commented 3 years ago

Yes MO2 should work just fine, however you will find sporadically that versions of wine/staging will fail to work with fully, this includes script extender. I found ProtonGE-5.0-9 or something to work best compatibility wise whereas newer versions have issues introduced that could break certain functions of MO2 or ScriptExtenders.

qsniyg commented 3 years ago

@jarrard I sent in a patch for skse64: https://source.winehq.org/patches/data/194530, it got dropped without a reply (I'm guessing Julliard has reservations about it, but I'm not sure what they are), but it does work fine for me.

jarrard commented 3 years ago

Guess you would need to ask what went wrong. Also its possible the newer versions of wine fixed the issue? I haven't done much testing.

Some patches get rejected because they don't like how its done, such as hacking something that could break other things.

Have you tested SKSE64 with Wine5.20 and 5.21? and staging versions?

smirgol commented 3 years ago

Could you see if 29d06c0 fixes it? I haven't tested it.

By the way, is there a reason you're using this instead of just MO2 itself? Theoretically it should work fine under wine 5.0+ (I've used it under 5.18 iirc without issue)

Aye, this fixed it for me, thank you very much! :)

I'm using proton (5.13) to run the game (from steam) and figured it might be a good idea to use the existing proton prefix to install MO2 in that prefix as well and also run it with proton, so the prefix doesn't get re-initialized all the time due to using different wine/proton versions. Not absolutely sure if this is a good idea or not, but I thought I should give it a try.

MO2 does not symlink the mods into the game that way and I thought I might need this script to make it work. Which it does, although, I've tried it with a single game interface mod (SkyUI) and it takes about three seconds to open the inventory (which is modified by the mod) - not sure if it is because of the symlinking or some other things.

Edit: Yes it is slow because of the linking. When I copy the files directly into place, the inventory opens up instantly. That's really unfortunate. I just want something to manage the tons of mods I'm going to add but somehow it is really difficult on linux to get it to work. :(

qsniyg commented 3 years ago

@jarrard I haven't tested any later wine versions yet. It doesn't seem to me that it would have fixed it from a quick look at the source, but maybe it's fixed in a different place? I'll do a bit more testing later and try re-sending the patch with extra tests.

@smirgol

MO2 does not symlink the mods into the game that way

Do you mean that it fails to run the game? Or that it doesn't create symlinks on the drive? MO2 basically hooks file-related functions, creating a "virtual" filesystem, so it won't create symlinks, but it should in theory still work (at least it does on my side)...

That being said, there are some issues with the copy protection and running separate executables. Perhaps if you were to install a no-steam patch and run it in its own prefix with an updated wine version, it might work?

smirgol commented 3 years ago

I'm still trying to get my head around it, how it all works. It's difficult to get it up and running, as there is not much of information around the web on how to get it to work on linux. :|

What I do: I start MO2 in the terminal, setting the prefix for the games proton installation and using the proton wine binary. Then I install a mod and usually close down MO2 to start the game via steam - thanks to your comment I now realize that this is not going to work. So now I tried to start the game from within MO2. It will ask if it should run steam, I say "no" because its already running natively in the background. That seems to be okay, the game starts, but the mods are not there.

Also, when I switch the MO2 starter to "Explore Virtual Folder", it will show me the Data folder of Skyrim as is. No mods in there, where I think they should, as it is the "virtual" folder. sigh :)

I was thinking about using a proton-tkg runner with steam, so I would have a more recent wine version, but unfortunately they've compiled their recent versions against a new glibc version that I don't have. I'd need to compile it myself and I'm trying to get around that. :)

Edit: I should add that the "Skyrim Special Edition Support Plugin" does not work for me, the "installer_fomod_csharp.dll" crashes and is blacklisted to make MO2 work at all. Could that be the culprit of the virtual stuff not working?

qsniyg commented 3 years ago

That seems to be okay, the game starts, but the mods are not there

Huh weird... maybe try the nosteam method I suggested? I do it that way personally, just because it's way easier to test wine-related things with. Also, it should allow you to use a newer version of wine, perhaps that'll make a difference too?

Also, when I switch the MO2 starter to "Explore Virtual Folder", it will show me the Data folder of Skyrim as is. No mods in there, where I think they should, as it is the "virtual" folder. sigh :)

Yeah sorry, that one doesn't work due to the way wine works for the moment (it'll likely be remediated soon though, it - more or less - requires shell32.dll to be converted to PE)

smirgol commented 3 years ago

Okay, thanks for all your feedback! I've tried to avoid that, as usually proton is a much smoother experience game-wise these days. I really didn't miss compiling wine over and over again to add fixes that were required for my games and that took forever to get included into wine - if they ever did. But I guess I cannot avoid it any longer. :)

qsniyg commented 3 years ago

I really didn't miss compiling wine over and over again to add fixes that were required for my games and that took forever to get included into wine - if they ever did.

Agreed haha, and on that note I'm hoping the skse64 fix can get mainlined soon... (or a better version of it, if needed)

jarrard commented 3 years ago

I'm going to build proton-tkg with wine5.21 sometime soon, I've done it before and yes it can be annoying configuring all the dependencies but its worth doing it to get access to the latest fixes.

I mainly want the Fallout76 fix from 5.21 since using native windows DLLs to fix that game might be causing performance issues.

With Wine/Proton TKG, applying fixes is as easy as dropping them into a folder, however sometimes adjustments in patches is needed if something else has touched the code slightly.

smirgol commented 3 years ago

Ah sorry, while testing yesterday I accidentally used the script I've modified myself. There is a small error in the fix you have included: return re.sub(r"\)$", "", var) should be: return re.sub(r"\)$", "", newvar)

smirgol commented 3 years ago

I'm going to build proton-tkg with wine5.21 sometime soon, I've done it before and yes it can be annoying configuring all the dependencies but its worth doing it to get access to the latest fixes.

I mainly want the Fallout76 fix from 5.21 since using native windows DLLs to fix that game might be causing performance issues.

With Wine/Proton TKG, applying fixes is as easy as dropping them into a folder, however sometimes adjustments in patches is needed if something else has touched the code slightly.

I compiled it yesterday for the first time, and while it's a bit difficult to find out how to do it right and then install all the dependencies and do the configuration, I really like the streamlined build process. It's much less work than doing it all by hand. It didn't fix the issue for me though, that symlinks are just horribly slow in wine. :(

A heads-up: the current master of dxvk is horribly broken. I did include that frog repo, but dxvk isn't working for me with the tkg build atm.

qsniyg commented 3 years ago

Oops, fixed!

It didn't fix the issue for me though, that symlinks are just horribly slow in wine. :(

Sure, but the reason was more to just get the VFS thing running properly, without needing to use symlinks... does it still fail? Which game are you trying to run with MO2 btw?

smirgol commented 3 years ago

Skyrim Special Edition right now. I'm having a hard time to get the game to run without steam, so I'm looking into your script again.

Basically it does work fine, though I see some possible difficulties, like in which order the files are linked - not sure yet if it can find out in which order to link the files, have not looked into these parts yet. It's just that following the symlinks seems to be horrible slow in wine.

So, currently I'm playing around with hardlinks, which are super fast compared to symlinks, but I need to make some adjustments to the script so it can clean up the files when using --unvfs. It uses is_link to determine whether a file is a link or not, but that fails on hardlinks. But I see that it writes a log, maybe I can use that.

I cannot get MO2 to do the work for me at all, it just won't work for me, the files are not there when I launch the game using MO2, no matter if using default proton, GE or TKG.

qsniyg commented 3 years ago

I'm having a hard time to get the game to run without steam

Personally I'd recommend gamecopyworld, it's worked for most of the games I own.

smirgol commented 3 years ago

That still exists? Wow :D Thank you for the reminder!