Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Linux support #56

Open
jepotter1-archive opened this issue Jun 6, 2020 · 28 comments
Open

Linux support #56

jepotter1-archive opened this issue Jun 6, 2020 · 28 comments
Labels
Priority: Medium This issue may be useful, and needs some attention. Type: Enhancement New feature or request

Comments

@jepotter1-archive
Copy link

Please! People play TF2 on Linux too :)

@markdwhite
Copy link

markdwhite commented Jun 6, 2020

+1

Though already has an issue created by the maintainer at #47 for an x86 version.

@DaneBuson
Copy link

Yes please, a Linux version would be much appreciated.

@ldesgoui
Copy link

ldesgoui commented Jun 6, 2020

I don't see a Linux version being possible, it makes use of -hijack which is, as far as I'm aware, Windows-only and not reproducible.

@aggserp4
Copy link

aggserp4 commented Jun 6, 2020

I tried running TF2 with the -hijack command line argument on linux just like you would on Windows (./hl2-linux -game tf -hijack) and indeed, it doesn't appear to work. In fact I can't even launch the game from the command line at all. Maybe you need to run the hl2.sh script, but I've got no idea how that works.

After looking within the leaked TF2 source code, it does seem that the code responsible for the -hijack argument is within a #ifdef WIN32 block. So even if it is possible to start TF2 from the command line somehow, I don't think that this argument will work.

@PKPenguin321
Copy link

#58 eliminates the use of -hijack, which could resolve that roadblock to having Linux support.

@aggserp4
Copy link

aggserp4 commented Jun 7, 2020

The thing is, from what I can tell -hijack works internally by sending a message to the game window through the Win32 SendMessage function. The PR simply proposes that this is done directly from this program instead of by launching TF2 with the -hijack parameter. It still relies upon Windows API functions.

@lnx00 lnx00 mentioned this issue Jun 11, 2020
@Kirottu
Copy link

Kirottu commented Jun 11, 2020

Agreed, TF2 is pretty much the only game i play actively and I play it on Linux.

@ClusterConsultant ClusterConsultant added Priority: Medium This issue may be useful, and needs some attention. Type: Enhancement New feature or request labels Jul 2, 2020
@ClusterConsultant ClusterConsultant added this to the >=1.2 milestone Jul 2, 2020
@ClusterConsultant
Copy link
Collaborator

Hijack command is being removed and replaced with rcon which is platform agnostic. There is more to be done for linux support but that was the big dependency.

Repository owner deleted a comment Jul 2, 2020
@MatMercer
Copy link

Hijack command is being removed and replaced with rcon which is platform agnostic. There is more to be done for linux support but that was the big dependency.

Hey I looked through the project and I am currently studying how it works. So, I have a question abount RCON. Isn't it only for servers? https://wiki.vg/RCON

How can I communicate with my local hl2 with RCON? I've already downloaded rcon client but unfortunately I didn't had success.

Answering @aggserp4

Maybe you need to run the hl2.sh script, but I've got no idea how that works.

You can run in bash by:

cd ~/.local/share/Steam/steamapps/common/Team\ Fortress\ 2
export LD_LIBRARY_PATH="$(pwd)"/bin:$LD_LIBRARY_PATH
./hl2_linux -game tf -hijack test

I discovered that by taking a look at hl2.sh:

elif [ "$UNAME" == "Linux" ]; then
   # prepend our lib path to LD_LIBRARY_PATH
   export LD_LIBRARY_PATH="${GAMEROOT}"/bin:$LD_LIBRARY_PATH
fi

But guess what?

After looking within the leaked TF2 source code, it does seem that the code responsible for the -hijack argument is within a #ifdef WIN32 block.

This is 100% true, the command simply doesn't exists in Linux.

@PazerOP
Copy link
Owner

PazerOP commented Aug 1, 2020

@MatMercer you need to provide the -usercon argument on the command line. This is why you need to start TF2 through the tool in the latest version.

Also make sure you are listening on the correct ip (ip 0.0.0.0) and manually start up the networking if you want to issue commands before you are in a game (net_start).

@ClusterConsultant
Copy link
Collaborator

ClusterConsultant commented Aug 1, 2020

Rcon is designed for servers but is not exclusive to it. I'm not sure if this is the same for the linux client but the windows client does accept connections when launched with -usercon, you do need to set the rcon password or it will deny all requests

Note: ip 0.0.0.0 is a meta address that just listens on all available addresses. Can be a concern in some environments.

@PazerOP
Copy link
Owner

PazerOP commented Aug 1, 2020

@ClusterConsultant is correct about IP. While you should obviously have a firewall set up, TF2BD randomizes the rcon password and port every time tf2 is launched to provide an extra layer of security. If you are just using -usercon by itself, the rcon password defaults to an empty string and the port defaults to 27015.

I'm having trouble remembering, but am empty rcon password may mean that nobody can connect. Not sure.

@MatMercer
Copy link

MatMercer commented Aug 1, 2020

@PazerOP
@ClusterConsultant

It worked, thanks for the help, this are the steps for anyone interested:

You need to install a command line RCON client. It is available in AUR if you use Arch Linux.

  1. Open the game with the method I said above:
cd ~/.local/share/Steam/steamapps/common/Team\ Fortress\ 2
export LD_LIBRARY_PATH="$(pwd)"/bin:$LD_LIBRARY_PATH
./hl2_linux -game tf -console -nologo -usercon
  1. Issue theses commands in the tf2 console.
ip 0.0.0.0
rcon_password pass
net_start
  1. Run the rcon command (should be installed as I said above)
rcon -H localhost -p 27015 -P pass plugin_print

It should output:

Loaded plugins:
---------------------
---------------------

@MatMercer
Copy link

MatMercer commented Aug 1, 2020

@PazerOP @ClusterConsultant

Now I have another question:

When using ping and status the output of these commands only appeared in the ingame console. But the command plugin_print I used as an example above outputted to the rcon stdout. That's why I used it as an example.

Is ping and status not outputting through rcon normal behavior?

@ClusterConsultant
Copy link
Collaborator

It is not. In our case the output is put in a log file and parsed by the application

@PazerOP
Copy link
Owner

PazerOP commented Aug 1, 2020

It is normal for those to not come back through rcon. Those commands need to be passed to the server in order to get a response, and the pseudocode for rcon looks something like this:

BeginCaptureConsoleOutput();
RunCommand();
EndCaptureConsoleOutput();
SendCapturedOutputToRCONClient();

The problem is that RunCommand() in this case just sends status or ping to the server. It doesn't wait for the reply, which takes some amount of time to come back.

plugin_print (and the commands the TF2BD uses, tf_lobby_debug/tf_party_debug) are implemented entirely on the client, and as such their responses are instant and are captured successfully and sent back over rcon.

@ClusterConsultant
Copy link
Collaborator

@MatMercer
Copy link

MatMercer commented Aug 1, 2020

@PazerOP
@ClusterConsultant

Thanks so much about the explanation! It makes sense, so a limitation is that we can only use commands that doesn't rely in the external server response. I was concerned that there would be differences on the Linux version that could make outputting game status to a external file impossible. But tf_lobby_debug and tf_party_debug do work.

Tomorrow I want to take a look about some strategies we would need to make to enable Linux compatibility. In my opinion, maybe create a command line MVP executable, without a gui, would be interesting and wouldn't require too much work. Since we already have a "common lib/api" that both Windows/Linux/Wathever versions could use. As said above, the rcon library is multi-platform. The code needs some refactors but not a lot. The logic is actually very separated from the GUI, and that's great.

Again, thanks for the fast responses.

@PazerOP
Copy link
Owner

PazerOP commented Aug 1, 2020

Theoretically it shouldn't be that much work to just have the whole GUI running on linux, since all of the platform specific stuff related to it should be handled by SDL2. The main blockers for linux right now are probably the missing implementations of these functions: https://github.com/PazerOP/tf2_bot_detector/blob/master/tf2_bot_detector/Platform/Platform.h. I just haven't had a chance to look into how to implement them, but they should be fairly straightforward. The only ones that I'm a bit dubious about are:

  • ExploreToAndSelect (not strictly necessary, only used for highlighting the generated debug_report.zip),
  • BrowseForFolderDialog (used for the "Browse..." buttons, not essential but quite desirable)
  • OpenURL (supposedly you can just use system() but I would hope there is a saner way)

@danhab99
Copy link

Checking in on any progress being made.

Also @PazerOP how do we build for Linux?

@ServerBBQ
Copy link

Checking in on any progress being made.

Also @PazerOP how do we build for Linux?

@danhab99
Answering your first question, theres definitely progress made but not sure if it works yet (https://github.com/PazerOP/tf2_bot_detector/tree/linux)

@ClusterConsultant
Copy link
Collaborator

No progress has been made since August 5th. Pazer has been busy with non TF2 things for a while. There will be a small announcement made with the release of 1.2 explaining future development priorities which should help explain when the linux version will be coming.

@incontestableness
Copy link

There will be a small announcement made with the release of 1.2 explaining future development priorities which should help explain when the linux version will be coming.

Hasn't 1.2 been released?
skelly

@ClusterConsultant
Copy link
Collaborator

Correct. See the "Release Themes" section for relevant information. https://github.com/PazerOP/tf2_bot_detector/releases/tag/1.2.0.798

@Nika03
Copy link

Nika03 commented Jan 26, 2021

I sure hope it will be worth the wait for the Linux update

@ClusterConsultant
Copy link
Collaborator

When work begins on this there will probably end up being a ton more issues generated since this is a big project. As they are made they will be added to the linux milestone.

@ChildishGiant
Copy link

I've been using this in the meantime https://github.com/Googe14/tf2-bot-kicker-gui

@DeWolfRobin
Copy link

I have made some adjustments to another bot detector, it's very hacky and ugly, but it works just fine :) feel free to contribute :)
https://github.com/DeWolfRobin/tf2-bot-kicker

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Priority: Medium This issue may be useful, and needs some attention. Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests