cortex-command-community / Cortex-Command-Community-Project-Source

[ARCHIVED] Cortex Command - Open Source under GNU AGPL v3 (no game data included)
https://cortex-command-community.github.io/
GNU Affero General Public License v3.0
201 stars 41 forks source link

Linux support #89

Closed tuxayo closed 4 years ago

tuxayo commented 4 years ago

The old versions supported Linux until some time ago (I'm not sure when it stopped).

This issue is to gather info about how to bring back Linux support. And hopefully help someone motivated. As humble contribution, a bounty has been created Bountysource

MaximDude commented 4 years ago

See https://github.com/liberated-cortex for linux support.

tuxayo commented 4 years ago

Looking at the old forks, here are those that mention Linux in the README

https://github.com/liberated-cortex/CCOSS https://github.com/basxto/CCOSS

edit: @MaximDude you were fast ;)

garethyr commented 4 years ago

If anyone wants to try to do this and has questions feel free to ask here or join the discord channel and ask there. I can't promise I'll be able to help a ton, but I'm happy to do what I can. Definitely not gonna spearhead it though, too much other stuff to deal with.

HeliumAnt commented 4 years ago

I've started looking into this. From what I have been able to tell so far, most immediate issues for cross platform compatibility result from (newly added) MSVC and Visual Studio specific code and out of spec use of the standard library (most likely also compiler related). For now I'm trying to get everything into standard C++ code so it compiles and porting the project to a cross platform toolchain (currently using meson, not for any particular reason other than I understood the documentation)

garethyr commented 4 years ago

Hey Igg4373, thanks for taking a look at this. Please feel free to ask questions and we'll try to help if we're able. Also, you're welcome to join on discord and discuss things there, or stick with github comments if you'd prefer that. Good luck!

HeliumAnt commented 4 years ago

Things that work now:

not yet tested

Things that will work with light workaround

Things that might be able to work:

Things that will not work (on native allegro4) and will require a GLX backend for allegro:

  1. no media keys (so no volume control, play, pause) (annoying)

  2. no alt-tab (really really annoying)

  3. no alt-f4 to immediately close, although ctrl-alt-end (sortof) works

tuxayo commented 4 years ago

So I was able to go in the game, play almost an hour I think and get wrecked by the AI as expected for me ^o^

mouse sensitivity (it's really weirdly slow, setting is ignored)

How where is the UI to change that? I found the place to remap the keys (I'm using an azerty keyboard) but no sign of mouse sensitivity there.

About fullscreen, can't enable:

Requested resolution multiplier will result in game window exceeding display bounds! No change will be made!

My screen is 1600x900

Without fullscreen, is there a way to have a higher resolution than 900xsomething. That make reading the text hard.

Found an issue: I let the game paused to write thing is now it's frozen:

Screenshot_2020-09-06_19-40-03

Nothing in the console logs.

tuxayo commented 4 years ago

False alarm, the freeze was due that I let the message in the background «Requested resolution multiplier will result in game window exceeding display bounds! No change will be made!»

HeliumAnt commented 4 years ago

mouse sensitivity (it's really weirdly slow, setting is ignored)

it's in Base.rte/Settings.ini but I'm not sure thats actually used

My screen is 1600x900

Not sure about fullscreen, but Windowed resolution should be able to be changed now, you can try Upscaled Fullscreen, that might work

MaximDude commented 4 years ago

@tuxayo Alt+Enter is used to quickly switch resolution multipliers to go between normal and upscaled modes, not to toggle fullscreen. If your game is running the default resolution, which is 960x540 using Alt+Enter will try to create a 1920x1080 window, which obviously will not fit your display and will just crash, thus the message. If you want fullscreen, set the resolution to your native resolution. If you want to run upscaled because everything is tiny, you must set your resolution to half of your native or lower and the resolution multiplier to 2. You'll need to go into Base.rte/Settings.ini and set

ResolutionX = 800
ResolutionY = 450
ResolutionMultiplier = 2

This will result in upscaled fullscreen. You can then use Alt+Enter to switch multipliers, going between 800x450x1 and 800x450x2 (1600x900).

The are buttons to toggle fullscreen/upscaled fullscreen in the ingame settings menu, so use those if you don't want to go in and manually set the resolution in the settings file, they should work (they don't for me but that's because the laptop i'm running linux on is 1366x768 and allegro doesn't support this garbage resolution, so I can never go into fullscreen on it).

As for mouse sensitivity, there's no ingame setting for it (yet). You will find it in Settings.ini on line 120.

tuxayo commented 4 years ago

Retried with 33856bc29adb81f9f62514cc1349135c9af28f39

you can try Upscaled Fullscreen, that might work

I confirm that alt tab and media volume keys don't work with fullscreen.

Not sure about fullscreen, but windowed resolution should be able to be changed now,

Indeed I can change the resolution :D

I got duplicates of the resolution though. Not a big deal. Screenshot_2020-09-06_19-40-03

Does the Windows version can only use the resolution that are in the list?

Here is the logic: Fullscreen comes with major regressions. So windowed mode with the highest possible resolution would make the above not an issue. But a user can't select the windowed resolution that matches the screen because that automatically switches to fullscreen. So they must select the resolution below. In my case 1600x900 => 1368x768 (1400x900 loose some part of bottom of the screen) Is there the same limitation in the Windows version for someone wanting to use windowed mode?

tuxayo commented 4 years ago

@MaximDude

If you want to run upscaled because everything is tiny, you must set your resolution to half of your native or lower and the resolution multiplier to 2. You'll need to go into Base.rte/Settings.ini and set

Same limitation as on Windows right?

The are buttons to toggle fullscreen/upscaled fullscreen in the ingame settings menu, so use those if you don't want to go in and manually set the resolution in the settings file, they should work (they don't for me but that's because the laptop i'm running linux on is 1366x768 and allegro doesn't support this garbage resolution, so I can never go into fullscreen on it).

Is this only for fullscreen ? I'm not sure to understand if there is a way to get windowed mode and multiplied resolution (to have bigger text) via the UI. (and then test if that has been lost in the current Linux port)

MaximDude commented 4 years ago

We removed native fullscreen from the Windows version entirely, because there's absolutely no benefit in it over borderless windowed and it performs worse overall. Since there is no borderless window driver for linux, you're stuck with native fullscreen mode with all the issues it has.

For the list of resolutions, we're getting it from the native fullscreen driver and it's populated only with resolutions your graphics card officially supports (some might be incompatible with your screen) minus some dumb ones, just because they make a sensible list of defaults and we don't need to populate the list manually.

Windowed mode, however, is not limited to that list so you can go into Settings.ini and set it to whatever you want as long as it makes sense, if it doesn't, you'll get a warning message. Just go in and manually set your resolution to 1596x796 or 798x396 with multiplier 2 for upscaled, these will give you maximum screen coverage while still being windowed.

tuxayo commented 4 years ago

@HeliumAnt BTW, how does one updates when you push new commits?

meson --reconfigure builddir and recompiling lead me to compile errors so I rm the buildir and start over from the instructions.

HeliumAnt commented 4 years ago

@HeliumAnt BTW, how does one updates when you push new commits?

meson --reconfigure builddir and recompiling lead me to compile errors so I rm the buildir and start over from the instructions.

Usually you should just have to meson compile if the build fails, that usually means I screwed up and forgot to test before committing. Then you'll have to wait until I push again. Though I changed some of the paths during the last few commits so a reconfigure is not a bad option

MaximDude commented 4 years ago

@HeliumAnt Regarding the alt+tabbing issue, you can try https://tronche.com/gui/x/xlib/window/stacking-order.html

So in UInputMan.cpp on line 869 you'll have something like

} else if (!FlagCtrlState() && FlagAltState()) {
#ifdef __unix__
    // Alt+Tab to fake window switching in linux native fullscreen mode
    if (KeyPressed(KEY_TAB)) {
        ...
        deal with things you normally don't need to
        ...
    }
#endif

You can probably figure out how to do this for other stuff as well, at least until you get a borderless window driver working.

tuxayo commented 4 years ago

Windowed mode, however, is not limited to that list so you can go into Settings.ini and set it to whatever you want as long as it makes sense, if it doesn't, you'll get a warning message. Just go in and manually set your resolution to 1596x796 or 798x396 with multiplier 2 for upscaled, these will give you maximum screen coverage while still being windowed.

Thanks it works. IIUC, this [1] is also a limitation of the Windows version so no regression here.

[1] having to edit the config file with screen specific values have a windowed game with a multiplier= 2 and a maximum screen surface

tuxayo commented 4 years ago

Is there anything specific to test?

HeliumAnt commented 4 years ago

I don't have anything Linux specific at the moment, apart from general playtesting.

tuxayo commented 4 years ago

Played a more than an hour long game with around 60 actors at least and at same point with no particular action from me or on my screen; freeze and crash with core being dumped.

/h/d/d/Cortex-Command-Community-Project-Data ❯❯❯ coredumpctl dump
           PID: 87569 (CCCP_debug.x86_)
           UID: 1000 (tuxayo)
           GID: 100 (users)
        Signal: 6 (ABRT)
     Timestamp: Tue 2020-09-08 00:32:59 CEST (4min 42s ago)
  Command Line: ./CCCP_debug.x86_64
    Executable: /home/datumoj/dev/Cortex-Command-Community-Project-Source/builddir/CCCP_debug.x86_64
 Control Group: /user.slice/user-1000.slice/session-1.scope
          Unit: session-1.scope
         Slice: user-1000.slice
       Session: 1
     Owner UID: 1000 (tuxayo)
       Boot ID: dd77d2c8b2744caf9eab13577112d0fd
    Machine ID: 2bcabf87c4874e7994dda0a192e1be2f
      Hostname: some-laptop
       Storage: /var/lib/systemd/coredump/core.CCCP_debug\x2ex86_.1000.dd77d2c8b2744caf9eab13577112d0fd.87569.1599517979000000.zst
       Message: Process 87569 (CCCP_debug.x86_) of user 1000 dumped core.

                Stack trace of thread 87569:
                #0  0x00007f6300566615 raise (libc.so.6 + 0x3d615)
                #1  0x00007f630054f862 abort (libc.so.6 + 0x26862)
                #2  0x00007f6300cf2fad n/a (liballeg.so.4.4 + 0xb7fad)
                #3  0x00007f63005666a0 __restore_rt (libc.so.6 + 0x3d6a0)
                #4  0x000055efd24a2f53 n/a (/home/datumoj/dev/Cortex-Command-Community-Project-Source/builddir/CCCP_debug.x86_64 + 0x1b3f53)

Here is the 160 MiB dump is case it's helpful (link valid 7 days). Maybe it's just a regular crash due to a long game with a number of actors that is getting high.

https://drop.infini.fr/r/n0b7WQRo2P#ZnC+e+063m/vIRXTO2lTV74IM5P6+aZ5NJ0Cotg1fx4=

tuxayo commented 4 years ago

Another one, not the same signal, stack trace and context.

/h/d/d/Cortex-Command-Community-Project-Data ❯❯❯ coredumpctl dump                                                                                                          ✘ 1 
           PID: 119645 (CCCP_debug.x86_)
           UID: 1000 (tuxayo)
           GID: 100 (users)
        Signal: 11 (SEGV)
     Timestamp: Tue 2020-09-08 01:01:37 CEST (41s ago)
  Command Line: ./CCCP_debug.x86_64
    Executable: /home/datumoj/dev/Cortex-Command-Community-Project-Source/builddir/CCCP_debug.x86_64
 Control Group: /user.slice/user-1000.slice/session-1.scope
          Unit: session-1.scope
         Slice: user-1000.slice
       Session: 1
     Owner UID: 1000 (tuxayo)
       Boot ID: dd77d2c8b2744caf9eab13577112d0fd
    Machine ID: 2bcabf87c4874e7994dda0a192e1be2f
      Hostname: some-laptop
       Storage: /var/lib/systemd/coredump/core.CCCP_debug\x2ex86_.1000.dd77d2c8b2744caf9eab13577112d0fd.119645.1599519697000000.zst
       Message: Process 119645 (CCCP_debug.x86_) of user 1000 dumped core.

                Stack trace of thread 119645:
                #0  0x00005645d26ba35c n/a (/home/datumoj/dev/Cortex-Command-Community-Project-Source/builddir/CCCP_debug.x86_64 + 0x21e35c)
                #1  0x00005645d25881dc n/a (/home/datumoj/dev/Cortex-Command-Community-Project-Source/builddir/CCCP_debug.x86_64 + 0xec1dc)
Refusing to dump core to tty (use shell redirection or specify --output).

link to the dump, valid 7 days

https://drop.infini.fr/r/bGm65srZU8#v+JFZhWr0EN4u31ui27Pf71/taBfU3+8lA/CHgGnFW8=

HeliumAnt commented 4 years ago

The first crash appears to have happened in a lua script while something was getting destroyed, so it's very hard to tell what caused this. these crashes happen occasionally on windows as well at least for me and always have. Ideally you'd also include the log files from CC (LogConsole.txt).

I can't reproduce the crab bomb crash, but the stacktrace is very very very weirdly long, with ~35000 identical entries, so it seems something very interesting is going on there, will investigate further

tuxayo commented 4 years ago

these crashes happen occasionally on windows as well at least for me and always have

Ok, might not be relevant here.

Ideally you'd also include the log files from CC (LogConsole.txt).

Cool, thank you, I didn't know that existed. (proposal to mention it in the bug report template: #185, feedback to complete it welcome)

I can't reproduce the crab bomb crash, but the stacktrace is very very very weirdly long, with ~35000 identical entries, so it seems something very interesting is going on there, will investigate further

Do you see the same in #184 ? if so, then I have a reliable test plan for this one.

garethyr commented 4 years ago

By the way, identical errors like that mean some recursive call or something screwed up, causing a stack overflow. Easiest way to really nail this down would be run it in debugger, but it seems like you figured out the cause anyway, so good stuff.

tuxayo commented 4 years ago

I popped the console with F1 that displays so help here.

And now I've found no way to close it. F1-F1, tab, escape, ctrl-D, typing exit, etc

MaximDude commented 4 years ago

Definitely a problem between the chair and keyboard. :facepalm: Since you pressed F1 anyway you might as well have read the help text and you'd know that you use the tilde key to open/close the console. Exactly like every game in the history of games that has a console.

Edit: Whoops, looks like I removed the ~ = this console line from the help text because I assumed everybody knows you tilde for console. Sorry I guess.

Edit edit: Why don't you join our discord so it's easier to communicate?

HeliumAnt commented 4 years ago

That might actually be a Linux issue, because on my keyboard the console opens with the ß/?/\ key (which would be the -/_ key on US layout) without having changed any settings. Though weirdly if I change the layout to US, that doesn't change

tuxayo commented 4 years ago

Definitely a problem between the chair and keyboard. facepalm

Turns out that was wrong :P It's just that not everyone has a keyboard with the tilde in the same place.

Exactly like every game in the history of games that has a console.

On an azerty keyboard[1], it's the "²" key that works in a lot of games. But here it doesn't. And the "~" (which is on another physical key) just inputs it to the console. I forgot to mention that I tried them both.

That looks like a bug related non qwerty layouts then. I would guess the other common layout that might have an issue is the Spanish/Latino American one since the tilde isn't in the same place.

[1] https://en.wikipedia.org/wiki/AZERTY#/media/File:KB_France.svg

After switching layout to the US qwerty one, it's applied in the console but the tilde doesn't apply it :(

Whoops, looks like I removed the ~ = this console line from the help text because I assumed everybody knows you tilde for console.

In case of someone not being used to in-game consoles (there are right?) An accidentally press might "trap them" there

MaximDude commented 4 years ago

Interesting, didn't know that. Does Alt Gr+é work?

tuxayo commented 4 years ago

Why don't you join our discord so it's easier to communicate?

I'm avoiding non-libre software especially for communication due to network effect (which makes it even harder to avoid). I noticed that Discord was the only current informal communication channel for the project and was wondering since few days what could I propose that could be acceptable for other people.

Unfortunately digital tools have ethical and political stakes which are a nuisance when on just wants to have fun. These stakes is why I'm using Linux and got interested again when Cortex Command became libre ^o^

I was also hopping that due to my minimal involvement I would not need to open the topic of having a parallel informal channel to discord. ^^" But now that the topic is on the table, here are the two things in mind:

HeliumAnt commented 4 years ago

From allegro/keyboard.h

/* The KEY_ macros are no longer #defined directly to avoid conflicting with
 * linux (which has its own KEY_ constants).  "__allegro_"-prefixed constants
 * are used by the Allegro-Linux keyboard driver, but everyone else should
 * continue to use the KEY_ constants.
 */

~I'll have to do some more work apparently.~ Actually that doesn't fix it either, so no clue whats going on here right now

tuxayo commented 4 years ago

Does Alt Gr+é work?

It writes the tilde in the console :D ^^"

garethyr commented 4 years ago

Regarding chat, fair enough about only wanting libre stuff. Github is planning to introduce github discussions at some point, so that'll let you better work around this once it's available. https://github.com/github/roadmap/projects/1 https://github.blog/2020-05-06-new-from-satellite-2020-github-codespaces-github-discussions-securing-code-in-private-repositories-and-more/#discussions

tuxayo commented 4 years ago

Opened #190 to move the discussion about the community discussion channels

tuxayo commented 4 years ago

@HeliumAnt

Though weirdly if I change the layout to US, that doesn't change

Indeed, changing the layout didn't help.

Found how to escape from the console :D

On an azerty keyboard, the key with )°] toggles the console.

on my keyboard the console opens with the ß/?/\ key (which would be the -/_ key on US layout)

ok that's consistent. When I switch to qwerty, the same physical key does -_ And it toggle the console.

So we have a regression as the most common common key, tilde (the key above tab for other layouts) isn't working. But at least the right next to the one with 0 is working.

tuxayo commented 4 years ago

Note for someone wanting to try it out: the branch 4zk-content on the data repository is still necessary for now.

tuxayo commented 4 years ago

Just to be sure, it there anything useful that could have been lost during the cleanups that removed Linux support? Here are the 3 commits that could find:

ca86c0898c3748ebc9795ea1c973295ff8304a4e Date: Sun Aug 2 17:34:35 2020 +0300 Remove a bunch of platform compatibility headers that we don't need

7f5aa5bafcba4091ba8fb3a06b98cb3cd52fdd48 Date: Sun Aug 2 16:58:34 2020 +0300 Remove linux lib

ec5a3fa9ce3a78bf77dbf41b07dcbffdcfaa43c2 Date: Tue Mar 3 14:50:38 2020 +0200 Remove all OSX related code and files - this may have worked at some point but probably doesn't anymore

HeliumAnt commented 4 years ago

I've seen those, and mostly just added them back in.