thepeacockproject / Peacock

The Peacock Project is a HITMAN™ World of Assassination trilogy server replacement.
https://thepeacockproject.org
GNU Affero General Public License v3.0
367 stars 57 forks source link

Cross-platform patcher #388

Open LennardF1989 opened 7 months ago

LennardF1989 commented 7 months ago

I've updated the patcher to .NET 8, as-is. I touched as little code as possible, I could even (barely) hold myself back from applying proper C# name conventions shivers.

I then split the logic into 3 components: UI, CLI and Core. UI is pretty much Windows-only (but could run under Proton), CLI is cross-platform and spits out a native executable for either Windows or Linux.

Workflow has been adjusted to spit out 6 files:

CLI is pretty small when completely standalone (12MB-ish). UI is humongous when standalone (125MB, 50MB compressed). Not sure how I feel about that, but WinForms can't be stripped (yet). UI could potentially be replaced with a different solution.

This will bring the patcher into "modern era", as well as add support for Steam Deck (test pending).

CLI also has additional logic applied so it will respect settings from the config, as well as waiting for a HITMAN process before applying and exiting.

RDIL commented 7 months ago

This is incredible! 🤩 Never thought I would see the day!

RDIL commented 7 months ago

UI is humongous when standalone (125MB, 50MB compressed). Not sure how I feel about that, but WinForms can't be stripped (yet). UI could potentially be replaced with a different solution.

Probably controversial idea here - we might not even need a UI. If we have a script that starts the CLI in command prompt and then once the game is patched, it can just say something like "Done! You may now close this."

alex73630 commented 7 months ago

Thanks Lennard for this amazing work! If you need help testing Linux/Steam Deck support, I'll gladly help you out

alex73630 commented 7 months ago

Probably controversial idea here - we might not even need a UI. If we have a script that starts the CLI in command prompt and then once the game is patched, it can just say something like "Done! You may now close this."

I don't think it's a good idea to completely remove the UI option, knowing some of our users, this will create more problems than shipping a 50MB binary

LennardF1989 commented 7 months ago

I gave this same more thought, and I might be able to turn the Core-lib into a .netstandard1 package, which would technically allow the UI to be run as good-ol' .net 4.6, but the CLI as .NET 8, while still sharing the same logic AND having the space benefit.

LennardF1989 commented 7 months ago

Above works. However, using a native Unix process to perform patching causes all kinds of issues, since Linux doesn't have the functions Windows has to apply the patches.

I'll rethink this but I see a few options: get the CLI in top shape for proton, fire and forget.

Or, use a hook dll to perform the patches natively. Benefit of this is also that you could use something like ImGui as a replacement for the UI. To be continued.

LennardF1989 commented 7 months ago

BOOM! Also appears to work without sudo, which is great.

image
LennardF1989 commented 7 months ago

Build now outputs a Windows-only .NET Framework 4.6 version, exactly like the original, just through a different build system.

The .NET 8 version is cross-compiled for Windows and Linux and comes in self-contained and portable versions.

Should be ready for testing.

LennardF1989 commented 7 months ago

Setup files for Steam Deck: PeacockSteamDeck.zip

Installation

  1. Switch to Desktop Mode
  2. Open a terminal
  3. Create a directory anywhere using mkdir Peacock and cd Peacock into it
  4. Execute the following command (use the "Copy to clipboard"-button):
    wget https://github.com/thepeacockproject/Peacock/files/14323372/PeacockSteamDeck.zip && unzip PeacockSteamDeck.zip && chmod +x ./start.sh && rm PeacockSteamDeck.zip
  5. Run ./start.sh once to make sure everything is setup properly.
  6. Open a browser and go to http://localhost:3000 to confirm Peacock is running.
  7. Now open Steam, add a non-Steam game "Peacock" and choose the start.sh. Optionally assign the icon to be icon.png inside the Peacock-directory.

Running

  1. Switch back to Gaming Mode.
  2. Run the non-Steam game "Peacock". Leave it running like this, do not press B!
  3. Instead press the Steam-button on your Steam Deck to bring up your library. Either run Heroic and launch Hitman from there, or run the Steam version.

The game will be patched accordingly and connect to your own Peacock server.

Closing

Just close the game, switch back to Peacock and exit the application. This will take down both the server and the patcher.*

crazytelli commented 6 months ago

@LennardF1989 I was able to run the server and confirm in my browser that localhost:3000 is indeed running peacock.

I had to make a slight change in start.sh as follows:

FOLDER_NAME="Peacock-${LATEST_RELEASE}-linux" as the download file for linux is no longer named lite.

The one problem I'm running now is the Patcher is failing when launching hitman.

Here are some screenshots:

peacock-server-running

patcher-failed

RDIL commented 6 months ago

@crazytelli thanks for the heads up, I changed it from lite -> linux in the linux setup repo. Will check on the error later.

LennardF1989 commented 6 months ago

Which version are you running @crazytelli? Steam, Epic? And if so, which version is reported in the main menu?

crazytelli commented 6 months ago

Which version are you running @crazytelli? Steam, Epic? And if so, which version is reported in the main menu?

I`m running the Steam version of Hitman III.

The game version (if I'm understanding what you're asking correctly) - in game -> Options:

LennardF1989 commented 6 months ago

And is it consistently failing to patch, or occasionally?

crazytelli commented 6 months ago

Consistently, never actually managed to launch peacock successfully with this method.

-------- Mensagem original -------- Em 06/04/2024 08:44, Lennard Fonteijn escreveu:

And is it consistently failing to patch, or occasionally?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

LennardF1989 commented 3 months ago

Consistently, never actually managed to launch peacock successfully with this method. -------- Mensagem original -------- Em 06/04/2024 08:44, Lennard Fonteijn escreveu: And is it consistently failing to patch, or occasionally? — Reply to this email directly, [view it on GitHub](#388 (comment)), or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

I've tested this on both the Steam and Epic version, with both the CLI and GUI version, with both the .NET 8 version and legacy version and I cannot reproduce this issue on Windows at least.

I will deploy the latest version to my Steam Deck and perform the same tests again to confirm everything still works there, too.

EDIT:

LennardF1989 commented 3 months ago

Found and fixed the issue on the Steam Deck. Was an absolute pain to get my local development environment running there, but I'll make a write up about it soon.

Instructions of https://github.com/thepeacockproject/Peacock/pull/388#issuecomment-1951378211 still apply, however: I made a new version of the zip:

This one supports updating either Peacock or Node when it's outdated. Peacock will only ever overwrite files, not delete them, so your profile data should be safe. Node is installed based on the .nvm file that comes with Peacock.

New command to install:

wget https://github.com/user-attachments/files/16045984/PeacockSteamDeck.zip && unzip PeacockSteamDeck.zip && chmod +x ./start.sh && chmod +x ./kill.sh && rm PeacockSteamDeck.zip

@crazytelli Can you give it a spin?

refrogerator commented 1 month ago

cli sounds like an awesome idea! i'm currently trying to use the patcher on my steam deck and the gui is a pain because i have to reenter the port every time

RDIL commented 1 month ago

@refrogerator it’s available in the current stable builds already.

LennardF1989 commented 1 month ago

While the bundled version with the latest stable does include a CLI option, it does not have the Linux specific logic to make it work on the Steam Deck.

RDIL commented 1 month ago

I think it would be best to switch to something lighter weight than winforms before merging would be best. Either that, or we’ll need to rethink our approach of committing the latest patcher binary for convenience.

LennardF1989 commented 1 month ago

I'd say include the self-contained Linux CLI version (12MB) and the .NET Framework* based CLI and UI exe (200kb total). The UI has no use on Unix in any shape or form because you will have to run it through Wine in the same context as the game (which I couldn't even get working), and for Windows the .NET Framework one "just works".

Alternatively, we can just have the Unix installer script in a separate repository that grabs the CLI binary version whenever it's needed and keeps itself updated. Much like how installing [insert a package manager name] works on Unix.

* Only thing I want to adjust in that is making WinForms for .NET Framework DPI aware, so it's no longer blurry on high DPI monitors.