Grasscutters / Cultivation

A custom launcher designed to make it as easy as possible to proxy anime game traffic to private servers.
Apache License 2.0
995 stars 166 forks source link

[Feature Request] Linux support #7

Closed RBNXI closed 1 year ago

RBNXI commented 2 years ago

Probably it's too soon to ask for a Linux port (although I think it should be easy, since the main problem would be launching the game on Linux but that's easy solvable launching the Lutris launcher.bat file of the game instead of the .exe), but could we get a quick guide on how to launch Cultivation with Wine?, it's currently impossible without some tinkering that I don't know (or maybe it's absolutely impossible to run it with Wine for some technical reason?).

SpikeHD commented 2 years ago

Linux/Mac builds are possible, they just have to specifically be built on Linux/Mac. I’ll probably setup GitHub actions at some point to create automated Linux builds

KingRainbow44 commented 2 years ago

at the moment, a few of cultivation's base logic (embedded in src-tauri) is platform specfiic and locked to windows. while it's in theory possible, it isn't well supported at the moment. (only a few methods have os checks)

it is worth noting that cross compatibility is planned (it's on our trello that we don't use)

Fanixtar commented 2 years ago

afaik linux require some client patching to make it work

RBNXI commented 2 years ago

afaik linux require some client patching to make it work

You mean to run Genshin on Linux? It doesn't need a patch, only a fix to some registry entries and a redirect to ip 0 for some calls. I mean, I can play Genshin in Linux, the problem is that Cultivation is not compatible with Linux.

ChazyTheBest commented 2 years ago

afaik linux require some client patching to make it work

You mean to run Genshin on Linux? It doesn't need a patch, only a fix to some registry entries and a redirect to ip 0 for some calls. I mean, I can play Genshin in Linux, the problem is that Cultivation is not compatible with Linux.

Don't they ban linux users? Don't tell me I could've had played all this time without my phone?

SpikeHD commented 2 years ago

Never heard of a linux user getting banned, I played linux myself for a while no problem

RBNXI commented 2 years ago

In general, for most games, even with the most aggressive patches that forces the game to run without anticheat, the worst problem could be that you get kicked of the game some times because the game thinks that your files are corrupted, but you won't get ban if you don't cheat. In genshin I've never have the tiniest problem, and of course I'm not banned either.

ChazyTheBest commented 2 years ago

Sorry, I was half sleep and couldn't have been more ambiguous.

I may really be gullible. I read last year about having to disable anti-cheat in order to run GI on linux and also read comments of people getting banned and honestly I freaked out, didn't want to loose my whale dolphin (ish) account. You mean to say online games (the ones using anti-cheat) don't ban linux users? I mean the ones that require tampering with the game files. I've read this for some online games, but who knows if it's really true or not. Which is one of last topics I read a while ago about fully supporting gaming on linux, games that require kernel-level access, how it affects linux and its users and solutions such as providing access to some dummy interface.

I also play different online games on linux and it really feels good not having to rely on windows. This could only get better by getting full wine-wayland support :)

Ugh, truth is I don't really have enough experience with rust or I would've opened a PR to replace the windows specific code. Tauri looks like a nice toolkit, I'll have to give it a try some day, my javascript is getting rusty (coding as a whole lol).

Birdulon commented 2 years ago

You mean to say online games (the ones using anti-cheat) don't ban linux users?

We don't have any firsthand accounts of it happening. This can change at any time and nobody here will be able to do anything for you if you do get banned. I would personally consider getting banned from this game to be a blessing, but I don't blame anyone for feeling differently about that.

It's against ToS, there's more than enough potential ways for them to detect it (normal operation for the Windows client expects remote code execution with admin access), and on the other hand they want paying customers to stay addicted and giving them some forced time off might wake them up to how pointless it all is.

Nobody here can guarantee anything will happen either way, and even if they claim they can, they'll disappear if you ever ask them to pay for a banned account ;)

RBNXI commented 2 years ago

You mean to say online games (the ones using anti-cheat) don't ban linux users?

For MOST games, that's the case. And if the game is playable without any tinkering, it's probably just running the anticheat with Wine, so it should be legal and you shouldn't get banned. But if the game needs a patch that disables the anticheat, either you get automatically banned (if the anticheat is VERY aggressive, and I've never have this problem personally) or the game let's you play as long as you don't cheat. For genshin... I haven't heard anyone getting banned because of playing in Linux, and you have a Linux patch in the Lutris website, so there are a lot of people using it and no one has reported a ban yet. BUT, in the case of Grasscutter, even when no one should be banned for using it, it's recommended not to use the same genshin installation for playing in the official servers and Grascutter, just in case.

games that require kernel-level access

Like Valorant, right? I don't know if that would be possible in Wine, probably yes, at some point, but if that requires some kernel level patch FOR LINUX... I wouldn't play it.

I also play different online games on linux and it really feels good not having to rely on windows

Same :D

I would've opened a PR to replace the windows specific code

If you do so, you have my gratitude :D

RBNXI commented 2 years ago

Has this progressed since then?

SpikeHD commented 2 years ago

Nope

hetake2 commented 2 years ago

Ok, I compiled the launcher and it works (Arch Linux).

My next step would be patching the game once I download it from official launcher.

And final step would be trying to launch the game from Cultivation.

But of course there's no built-in Wine/Proton to launch this game for Linux, so, I might need some hints about which source file should I modify to add the ability to execute Wine/Proton by pressing "Launch" button.

If somebody is interested in cooperation to launch the game in Linux, feel free to DM me in discord: Алладин#8211

I hope soon I'll be able to send PR.

4Benj commented 2 years ago

My next step would be patching the game once I download it from official launcher.

From my discoveries while working on #83, client patching seems to be completely broken currently. So I don't think you'd have much luck with that unless you fix it yourself.

I might need some hints about which source file should I modify to add the ability to execute Wine/Proton by pressing "Launch" button.

I'm not sure myself what files you'd need to modify, but it might be a good idea for when Linux supported is implemented to automatically patch the game for Linux support. If you need help with developing the patcher, feel free to contact me and I'll see what I can do when I get time.

SpikeHD commented 2 years ago

This is still actively being worked on, and I already have ideas on how I will handle it. The best way to get linux support is to just wait for me to finish it :P

ArjixWasTaken commented 2 years ago

Sent a message to subscribe to this issue :floppy_disk:

Edit: oof, looks like i can subscribe w/o doing that, sry :pray:

TropicLegend commented 2 years ago

I'm so hyped for Linux Support, finally no VM needed

TropicLegend commented 2 years ago

If y'all need some base to work with, I can PM you some an anime game launcher

ChazyTheBest commented 2 years ago

But of course there's no built-in Wine/Proton to launch this game for Linux, so, I might need some hints about which source file should I modify to add the ability to execute Wine/Proton by pressing "Launch" button.

No need to reinvent the wheel, there are other projects that do exactly the same, launch a windows game using a wine prefix with dxvk, for example: https://github.com/goatcorp/FFXIVQuickLauncher

@SpikeHD If you need more ideas or just are curious, the ffxiv launcher does exactly this (except the patching).

Mar0xy commented 2 years ago

If you need specific examples for this game you can look at https://github.com/an-anime-team/an-anime-game-launcher or the GTK alternative written in rust https://github.com/an-anime-team/an-anime-game-launcher-gtk

TropicLegend commented 2 years ago

If you need specific examples for this game you can look at https://github.com/an-anime-team/an-anime-game-launcher or the GTK alternative written in rust https://github.com/an-anime-team/an-anime-game-launcher-gtk

It's specifically said that you should not send links to their project publicly. Please delete them.

Mar0xy commented 2 years ago

If you need specific examples for this game you can look at https://github.com/an-anime-team/an-anime-game-launcher or the GTK alternative written in rust https://github.com/an-anime-team/an-anime-game-launcher-gtk

It's specifically said that you should not send links to their project publicly. Please delete them.

I am one of the devs and admins so no I won't.

TropicLegend commented 2 years ago

Didn’t know about that. Thanks for making it.

paletteOvO commented 2 years ago

Besides a fully supported game launcher for Linux, is it possible to port Grasscutter patcher only and release it individually?

GarnetSunset commented 2 years ago

Would it be possible to pack cultivation into flatpak? :O For steam deck! :)

TropicLegend commented 2 years ago

Yeah, that'd be awesome. Is there any update on Linux support for Cultivation?

ArjixWasTaken commented 1 year ago

I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.

There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!

That's like saying an apple is not an apple, but it is the combination of an apple and a pear...

ArjixWasTaken commented 1 year ago

That's a very bad analogy. Linux is a kernel. However, it would be more accurate to say that Linux is not the OS, but the several other free components are what make up the OS, and that they are all equally important, but that including them all in the name would make it a mouthful.

Still

Kernel = kernel + software

Is what this copypasta says

And then we have alpine Linux.

tamilpp25 commented 1 year ago

I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.

There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!

Did you seriously revive a 6 months old issue just for saying Linux != GNU/Linux wtf

GarnetSunset commented 1 year ago

Can we please shut up about this, I don't want emails about this shit. @SpikeHD can you limit conversation on this please.

GarnetSunset commented 1 year ago

I want to get emails about the actual development of this thread, not your inane ramblings. Please. Make a new issue if you want to complain about that. Thanks.

GarnetSunset commented 1 year ago

Yes, please reserve this thread for discussions on the topic, I will not write any more as not to add to the pile.

SpikeHD commented 1 year ago

Yeah, that'd be awesome. Is there any update on Linux support for Cultivation?

Not really, it still can exist and some theorycrafting has been done but no real progress has been made recently.

SpikeHD commented 1 year ago

No.

SpikeHD commented 1 year ago

Electron is a bloated memory hog, since it bundles an entirely separate Chromium engine AND a NodeJS runtime with it. This, and Linux support is just as easy with Tauri, as it uses WebkitGTK.

If you'd like to discuss switching backends further to stop clogging this poor issue, please make a new issue so I can close it as "not planned" :P

PackmanDude commented 1 year ago

LMAO this thread ended up on r/copypasta: https://www.reddit.com/r/copypasta/comments/124s9ea/github_comments_are_a_work_of_art/

Collei mains are genius mfs that this community does not deserve to have.

ArjixWasTaken commented 1 year ago

Electron is a bloated memory hog, since it bundles an entirely separate Chromium engine AND a NodeJS runtime with it. This, and Linux support is just as easy with Tauri, as it uses WebkitGTK.

If you'd like to discuss switching backends further to stop clogging this poor issue, please make a new issue so I can close it as "not planned" :P

weirdly enough, tauri (on windows) uses more RAM than electron I don't know why, might have been because I ran it in dev mode and not production mode, but it was using way more RAM, almost double

tauri on windows uses the webview2 runtime (ms edge)

(I literally just made an empty tauri project and had it visit discord.com and compared it with the electron client for discord)

SpikeHD commented 1 year ago

Running in debug mode typically uses around double the amount of RAM. You can also take a look at this web to desktop comparison (though I do not know how dated it is) to compare them all.

Tauri typically comes out on top - or close to it - in each benchmark.

tauri on windows uses the webview2 runtime (ms edge)

Haha yes I know, that was another reason for choosing it, as all newer installs of Win10 (and EVERY install of Win11) has it preinstalled already, making for beautifully small file sizes :)

I also wouldn’t be surprised if Discord uses an optimized bundle or a fork of Electron with modifications for their desktop app tbh but that is purely speculation

SpikeHD commented 1 year ago

Feel free to fork but, again, I am not changing the framework we use. I would also disagree that an increase of disk and RAM usage isn't an issue, as I've seen many people running PS related software on machines that frankly need every MB of RAM and HDD space they can get 😄.

Given that reinstalling WebView2 (and/or using compat mode) is a known solution to a problem that isn't our fault (blame Microsoft for having it break on Win11, I guess), I'll put it in the README.

Now please keep this issue related to Linux support. Just @ me in the Discord if you care to talk about unrelated stuff further :)

fnr1r commented 1 year ago

I have ported some of the logic of Cultivation to Linux with anime-launcher-sdk, although I have a few issues:

  1. The usage of slashes in paths is inconsistent, which I fixed in the slashes branch of my clone (which is safe to pull, it also fixes a bug and changes what one function prints).
  2. The game has to be installed (and probably patched) with the other launcher.
  3. I'm not sure if proxying should be a part of anime-launcher-sdk, therefore I implemented it with environment variables. Maybe it should, but before adding it I'd ask @an-anime-team for some kind of consensus on implementing proxy support into that library, since implementing it could make anime-launcher-sdk problematic in the company's eyes.
  4. My clone Cultivation does not run as root, since it's unsafe and causes problems with storing the app's data. This causes some parts of this app to not work properly (like copying CA certs, which only works correctly on Debian-based distros anyway) (or binding port 443 on GC fails, bc it requires root or certain capabilities)
  5. Patching does not work. version.dll is copied but is not loaded. The patch itself does work if it's copied as mhypbase.dll

Feedback is highly appreciated.

SpikeHD commented 1 year ago
  1. Feel free to PR that one! I have been fixing them sometimes as I see them but I have clearly not fixed them all
  2. Does the launcher do anything extravagant that users cannot do themselves? Just curious as to whether some of it can also be done via Culti
  3. Does the usage of env variables actually work? I know some programs listen to it and some ignore it entirely so I just want to make sure.
  4. That's totally fine, I would rather have mostly-working Debian support than no Linux support at all. Other distros can be figured out in the future.
  5. We can just have Culti specifically rename it to mhypbase.dll when it knows it's running on Linux, that's probably fine
SpikeHD commented 1 year ago

@fnr1r Meant to ping you in the original comment, sorry ^

fnr1r commented 1 year ago

@SpikeHD

  1. PR sent. (#186)
  2. From what I've gathered, the only thing we have to care about is Linux-specific patches (called "dawn") and renaming mhypbase.dll (which is its own option). In the case of Linux-specific patches, I'll error out if the game is not patched. Installing the game and changing settings (like upscaling, managing wine version or changing the /etc/hosts file to block telemetry) can be handled by the other launcher.
  3. Yep. Wine respects http_proxy and https_proxy environment variables. I tested it on a clean install of Ubuntu.

As for 5, today I finished implementing patching in a way that respects the other launcher's settings, so I think that's dealt with.

SpikeHD commented 1 year ago

Alright that makes sense. Been about (if not more than) a year since I've played on Linux so I'm glad the patch is the same as when I did it. I think it's reasonable to expect that someone running the game on Linux will have already patched the game to work on it (either with Dawn manually or with the other launcher).

How is setting the game path handled on the Linux side? Is the DirInput now able to accept a command as it's input (eg. wine cmd /c launcher.bat as opposed to the standard C:/Path/To/Game.exe that Windows users currently do)? What other problems does the branch have atm?

(you are welcome to open a PR and just slap WIP: in front of it so we don't accidentally merge it! Makes it easy for people to see the diff)

SpikeHD commented 1 year ago

@fnr1r forgot to ping again oops

fnr1r commented 1 year ago

@SpikeHD I use the same element as on Windows. Since the game_command option was not fully implemented, I removed it (although it's still in translation files). My clone also ignores the un_elevated toggle, but I have not hidden it on Linux yet.

As for other problems, I noticed some code is duplicated across Rust and TS. While it is a bit annoying, I kept most of it as-is. The one thing I moved to Rust is RSA patching. Installing CA files is disabled since it crashed the launcher upon failing. I'll enable it once I find a way to do it across distros. I'm not sure if anything swag-related works. Some operations, like unpatching or stopping MongoDB, run two times, which causes some problems. In the case of unpatching, it shows a popup telling the user that unpatching failed, despite everything working. And in the case of MongoDB, one of the commands fail and prints an error message in the console. That's about it.

CurrentSubset68 commented 1 year ago

@SpikeHD putting cultivation on flatpak/flathub could be a way to get around supporting all distros. it's sandboxed tho so there might be a few issues with it to fix. (personally waiting for an arch release tho somone will probably make an unofficial aur package at some point)

SpikeHD commented 1 year ago

I don't have the time or energy to put it there and debug any weirdness that comes from the sandboxing right now, so you'll just have to settle with Github releases and/or whenever someone decides to maintain an AUR package

My1 commented 1 year ago

is an appimage maybe less "sandboxy"? because appimages also run on deck

or maybe even a zip with a runnable bin or whatever

SpikeHD commented 1 year ago

Culti currently is erroring when attempting to bundle an AppImage. Might just be my WSL, so if someone else is able to do it lemme know