diff --git a/src/client/main.cpp b/src/client/main.cpp index e50f1cc..0581a00 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -4,6 +4,7 @@ #include "loader/component_loader.hpp" #include "game/game.hpp" +#include "utils/command_line.hpp" #include #include #include @@ -167,8 +168,23 @@ FARPROC load_binary(const launcher::mode mode) std::string data; if (!utils::io::read_file(binary, &data)) { - throw std::runtime_error( - "Failed to read game binary! Please select the correct path in the launcher settings."); + // Check the first argument to see if the current directory needs to changed + // Required when the game is used to open a file (like a demo file) + const auto& args = utils::command_line::get_args(); + if (!args.empty()) + { + const auto& binary_dir = args.front(); + if (binary_dir.filename().string().ends_with("iw6-mod.exe")) + { + std::filesystem::current_path(binary_dir.parent_path()); + } + } + + if (!utils::io::read_file(binary, &data)) + { + throw std::runtime_error( + "Failed to read game binary! Please select the correct path in the launcher settings."); + } } #ifdef INJECT_HOST_AS_LIB