mmtrt / cnctsun-snap

Unofficial C&C: Tiberian Sun soaked in WINE and Snapped for Linux
https://snapcraft.io/cnctsun
GNU Lesser General Public License v2.1
17 stars 1 forks source link

CnCNet snap #1

Closed FunkyFr3sh closed 5 years ago

FunkyFr3sh commented 5 years ago

I just tried this and I like it a lot!

I was wondering if it might be possible to make a CnCNet snap rather than making one for each game separately?

Installation would be looking like this:

wget http://downloads.cncnet.org/CnCNet.exe
wine CnCNet.exe /NOSHORTCUTS /SILENT

then create a shortcut for

.cncnet/drive_c/Games/CnCNet/CnCNetLauncher.exe

No need to install dotnet, CnCNet.exe will automatically install it into the wine prefix. It does also add the dll overrides (This file was made to be ran on WINE)

mmtrt commented 5 years ago

Also thought about creating single snap too and yes it is possible but for example like Red Alert is triggering ptrace on wineserver in snap strict confinement for some reason which hangs the game on starting from launcher for that reason I have created separate cncra snap which has devmode snap confinement so that it works with it but still it is testable snap so other games could might also trigger ptrace not tested all except TSun RA.

And I know the setup download and installs the dotnet which is some how broken so using the winetricks works fine and for dlloverrides the TSinstaller is not adding the dlloverrides which makes the game broken as compare to TiberianSun_Online_Installer which adds them when installing the game that I also discussed on CnCNet discord when I find out about the changes of installers.

FunkyFr3sh commented 5 years ago

Oh I see. I will have a look into Red Alert! I'm not experienced with snap, is there any way I can run your cncra snap without devmode or do I need to compile a new one? I actually tried to compile the cncts one but that didn't work out to well...

Red Alert is using DDE, I assume this might have something to do with the problem. It should be very easy to patch that out though. Tiberian Sun is not using DDE since it never had support for WWchat (The old official westwood online server). Even though you're playing the game offline the DDE code will still trigger to prevent multiple instances of the game.

Edit:

Managed to install it via:

snap install cncra --edge --jailmode

No luck though, game still doesn't start even with DDE removed. I will try some more, gonna keep you up to date!

mmtrt commented 5 years ago

You can edit the snap and test changes, so copy the snap file from

To a working dir then unpack it with command

Then edit file

Change

To

Save and then test the changes with the command which installs the unpacked snap

Note: When again making changes in squashfs-root make sure to run the command snap try squashfs-root again to test those changes.

FunkyFr3sh commented 5 years ago

Cool, thanks!

I've been testing for 4 hours, I got enough for today... I will try again tomorrow using your guide.

What I found out so far is that the game starts with when I remove the ddraw.dll from the game folder. It also starts when I rename the game executable (Which obviously also disables the ddraw.dll since there is no dll override for the renamed file).

The game is painfully slow without the ddraw proxy though, so that's not an option.

I tried a older version of cnc-ddraw and it worked! However if i recompiled it from the same commit then it didn't work anymore... Maybe something changed in GCC that triggers the bug? Or is something random going on here? I don't know... The visual studio build doesn't work at all.

mmtrt commented 5 years ago

Yeah there is something wrong indeed though I just have tested these cnc-ddraw releases the game does boot up fine from versions 1.1.6.0 to 1.1.2.0 in strict mode and I also made ddraw.dll to read-only so that config not replaces the copied version with the supplied one and also tried compiling the dll with mingw it failed on weird errors.

Also tested these ddraw version winelog where game hangs.

tsun ddraw 1.1.4.5
006c:err:seh:setup_exception_record stack overflow 1040 bytes in thread 006c eip 7bc457c6 esp 00730f20 stack 0x730000-0x731000-0x930000

cncnet ddraw 1.1.8.0
0057:err:seh:setup_exception_record stack overflow 1040 bytes in thread 0057 eip 7bc457c6 esp 00730f20 stack 0x730000-0x731000-0x930000

cncnet ddraw 1.1.6.4
0057:err:seh:setup_exception_record stack overflow 1040 bytes in thread 0057 eip 7bc457c6 esp 00730f20 stack 0x730000-0x731000-0x930000

EDIT: I can promote cncra snap to stable release using ddraw 1.1.6.0 with read-only permission though launcher will show errors no write access to dll when changing the video setting but still its workaround the current issue I'll just wait for proper fix.

FunkyFr3sh commented 5 years ago

Yeah, my logs look the same.

I got a working 1.1.8.1 here: http://downloads.cncnet.org/addons/ddraw10.7z No idea why it works, this is all too random...

I followed your guide and I could run some tests, thanks for that!

For now I don't really know what else we could try besides a different version of wine maybe? Have you tried any other wine versions already?

I guess the read-only ddraw trick would work yes, but it might be better to try some more and see if we can get it running without that.

mmtrt commented 5 years ago

Yeah I also tried wine-staging 3.13 still same issue.

FunkyFr3sh commented 5 years ago

I guess I got it working:

https://github.com/CnCNet/cnc-ddraw/commit/b8ee01684f88d0b1bcab8a0dd60dc1090b03fdf0

I updated all installers, it should now work without the need to do any updates to the snap.

The installers are cached (cloudflare) so it might take a moment until the new versions will be available.

mmtrt commented 5 years ago

great so it was a build flag that created this issue all along anyways I'll rebuild snap with strict confinment after 4hrs going to work.

FunkyFr3sh commented 5 years ago

Cool, I'm gonna give it a try tomorrow!

I played a bit around and noticed when I play in windowed mode my cursor doesn't work properly, it seems to not sync with the real cursor, you you have that problem too? I'm using a ubuntu virtual machine to test so it could be that this might be the reason for the bug, just wanting to make sure :) Fullscreen works fine.

mmtrt commented 5 years ago

I'm still having same issue even with new 1.1.8.2 though I had same cursor issue when I was testing older releases of ddraw.

PS: 1.1.8.1 you posted works fine which have size of 166k as compare to 1.1.8.2 which is 170k.

FunkyFr3sh commented 5 years ago

Really?! That's sad... Running out of ideas...

I don't really know what else we could try then. This is a snap only bug, never happened outside, so maybe it's impossible for us to fix.

Could just use the 1.1.8.1 then I guess or keep the snap in dev mode :(

Edit: Here's a updated config tool with the 1.1.8.1, if you feel like putting something together then use this one

https://drive.google.com/open?id=1zwB6-_rQuMbJIqixTldvCtXKaBF4E97v

I also removed the windowed mode and advanced settings button to prevent failures.

I'm off now, will have a look again tomorrow. cya!

mmtrt commented 5 years ago

Thanks for working on this, so I've pushed updated config tool & ddraw to the repo with some adjustments in snap & now snap is published as strict on stable channel.

FunkyFr3sh commented 5 years ago

I justed tested the multiplayer install and it worked fine, then reset the VM and installed the snap again, this time using the full game install... it didn't work :(

Skirmish also didn't work in the full game install, it's too random... All files are the same but yet it sometimes works and sometimes not.

Edit: Someone suggested to try taskset to run the games on a single cpu core. Apparently that might be possible:

https://github.com/snapcore/snapd/pull/5006

mmtrt commented 5 years ago

Yeah I did not test the full game b/c slow internet anyways I have posted call for test the snap on snapcraft forum to get users feedback it might work out on real hardware if not workout I'll checkout that taskset.

mmtrt commented 5 years ago

full game has same issue hangs however I have found that when ever I use full config then in video options check use cnc-ddraw hit ok then start game works fine both full multi.

full game is now disabled from stable till its fixed.

FunkyFr3sh commented 5 years ago

The one in the full config is the one from yesterday, I had to do a new build since a found a bug (Not related to snap).

If you wanna give that one a try, here it is: https://drive.google.com/open?id=1e_g7YcFRnNoWUjTYAZg5TLvxgUyYk5hr

It works for me too in multiplayer, I also ran the RA1installer in the snap to install the full game and it worked there too.

Also, do you know about a way for the installer to detect that it's running in a snap? Detecting wine is easy, but don't know a good way to know if it's a snap or not. If there is no good way to detect it, could you place a file on drive_c named "snap-mmtrt.txt" maybe? This file would need to be placed in drive_c before the installer was started though. This way the installer would be able to look for that file and know it's running in a snap and then adjust the settings to work better in a snap (e.g. don't enable windowed mode)

mmtrt commented 5 years ago

yeah now it is working in both games and for check whether its running in snap, calling env | grep SNAP_NAME=cncra in snap's shell works so don't how setup will detect this from wine. Another thing on wine system.reg file outside drive_c folder has this font entry maybe detect this Z:\\snap\\cncra.

"Tahoma (TrueType)"="Z:\\snap\\cncra\\6\\bin\\..\\share\\wine\\fonts\\tahoma.ttf"

FunkyFr3sh commented 5 years ago

Good idea, I just added it today. Works fine

mmtrt commented 5 years ago

great job all is good now but I have just have little annoyance in multiplayer install default display mode is set to full-screen when game is launched user will have to use alt+enter for goto full-screen in ubuntu 16.04 so it should be set to stretched as it is on full game by default which shows game full screen on launch.

FunkyFr3sh commented 5 years ago

Haha, I actually saw your comment

Make sure you select your Resolution [ Your Display’s Current ] from Settings & leave the Renderer as [ Automatic ].

And I already enabled stretching for both installs now by default, so you can remove that now!

I'm also going to play a online game to see how it works.

FunkyFr3sh commented 5 years ago

Online seems to work fine.

You removed the custom config/ddraw I saw, I guess you want me to add them back to the installer?

Edit:

I added it now. Both multiplayer and full game are working, just to confirm again. I guess we are done for now :)

If there are still issues you can find me on the cncnet forums.

Thanks for creating this snap!

mmtrt commented 5 years ago

game was working without depending on them thats why I removed them so anyways its working fine and thanks fixing this issue.