Skip to content

Commit

Permalink
Merge branch 'custom' into new-tables
Browse files Browse the repository at this point in the history
  • Loading branch information
surepy authored Aug 4, 2024
2 parents b0f7d84 + d4a33de commit 029ebbe
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
4 changes: 2 additions & 2 deletions tf2_bot_detector/Config/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ std::string GeneralSettings::GetBinaryName() const
switch (m_TFBinaryMode) {
case TFBinaryMode::x64:
case TFBinaryMode::x86: // ignored in linux
return "tf_linux64";
return "tf.sh";
case TFBinaryMode::x86_legacy:
return "hl2_linux";
};

// it might be probably better to error out?
return "tf_linux64";
return "tf.sh";
}
#endif

Expand Down
4 changes: 1 addition & 3 deletions tf2_bot_detector/Platform/Linux/Processes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ void tf2_bot_detector::Processes::Launch(const std::filesystem::path& executable
std::string execute_command;

// TODO: implement elevated?

execute_command = fmt::format("{} {}", executable, args);
// we need to change cwd apparently
// we need to change cwd apparently?
execute_command = fmt::format("cd {} && {} &", executable.parent_path(), execute_command);
Log(execute_command);


system(execute_command.c_str());
}

Expand Down
50 changes: 33 additions & 17 deletions tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ static std::string FindUserLaunchOptions(const Settings& settings)
/// <param name="rconPort"></param>
static void OpenTF2(const Settings& settings, const std::string_view& rconPassword, uint16_t rconPort)
{
const std::filesystem::path hl2Path = settings.GetTFDir() / ".." / settings.GetBinaryName();
const std::filesystem::path gameEXE = settings.GetTFDir() / ".." / settings.GetBinaryName();

if (!std::filesystem::exists(hl2Path)) {
LogError("Can't open this file! (empty() returned true) path={}", hl2Path);
if (!std::filesystem::exists(gameEXE)) {
LogError("Can't open this file! (empty() returned true) path={}", gameEXE);
return;
}

Expand Down Expand Up @@ -280,24 +280,40 @@ static void OpenTF2(const Settings& settings, const std::string_view& rconPasswo
if (args.length() > 512) {
// the game will not launch, but let's try anyway.
LogWarning("args length is >512! (={}) the game might (will) not launch!", args.length());
// TODO: fail more dramatically, warn the user.
}

// bad fix
char* library_path = getenv("LD_LIBRARY_PATH");
const std::filesystem::path libPath32 = settings.GetTFDir() / ".." / "bin";
const std::filesystem::path libPath64 = settings.GetTFDir() / ".." / "bin" / "linux64";
// we have to run w/ sniper runtime lib apparently.
// "TF2 requires the sniper container runtime" - tf.sh
const std::filesystem::path runtime_sniper = settings.GetSteamDir()/"steamapps"/"common"/"SteamLinuxRuntime_sniper"/"run";

std::string new_library_path = fmt::format("{}:{}:$LD_LIBRARY_PATH", libPath32.string(), libPath64.string());
Log("[Linux] new LD_LIBRARY_PATH = {}", new_library_path);
setenv("LD_LIBRARY_PATH", new_library_path.c_str(), true);
// run the game with sniper w/ args.
// we now use tf.sh to handle libraries instead of calling tf_linux64 directly and handling libraries ourselves.
std::string sniper_args = fmt::format("--steam-app-id=440 --systemd-scope --keep-game-overlay \"{}\" -- {}", gameEXE.string(), args);
// probably do not need
setenv("SteamEnv", "1", true);
// TODO: manually set SDL_DYNAMIC_API (see #37)
#endif
Processes::Launch(hl2Path, args);
#ifdef __linux__
if (library_path) {
setenv("LD_LIBRARY_PATH", library_path, true);
}
/*
setenv("PRESSURE_VESSEL_PREFIX", "1", true);
setenv("PRESSURE_VESSEL_VARIABLE_DIR", "1", true);
// TODO: disable game overlay if the user wants it disabled
setenv("LD_PRELOAD", "1", true);
setenv("STEAM_RUNTIME", "1", true);
// copied from "steam-runtime-launch-options -- %command% -novid"
// https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/slr-for-game-developers.md#using-steam-runtime-launch-options
std::string tf2_cmd = fmt::format("{} {}", gameEXE, args);
const std::string sniper_entrypoint = fmt::format("{}/steamapps/common/SteamLinuxRuntime_sniper/_v2-entry-point --verb=waitforexitandrun -- {}", settings.GetSteamDir(), tf2_cmd);
const std::string steam_launch_wrapper = fmt::format("{}/ubuntu12_32/steam-launch-wrapper -- {}", settings.GetSteamDir(), sniper_entrypoint);
// steam reaper
const std::string final_cmd = fmt::format("{}/ubuntu12_32/reaper SteamLaunch AppId=440 -- {}", settings.GetSteamDir(), steam_launch_wrapper);
*/
// getenv("TF2BD_TF2_LD_PRELOAD")
Processes::Launch(runtime_sniper, sniper_args);
#else
// if not linux we don't have to do all of that and just launch the game.
Processes::Launch(gameEXE, args);
#endif
}

Expand Down

0 comments on commit 029ebbe

Please sign in to comment.