Added demo system code changes to existing code. #15

Open
anomaly wants to merge 13 commits from anomaly/iw6-mod:changed_code_for_demo_system into master
Showing only changes of commit 2516a48fc1 - Show all commits

View File

@ -4,6 +4,7 @@
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "utils/command_line.hpp"
#include <utils/flags.hpp>
#include <utils/io.hpp>
#include <utils/string.hpp>
@ -165,11 +166,26 @@ FARPROC load_binary(const launcher::mode mode)
}
std::string data;
if (!utils::io::read_file(binary, &data))
{
// 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
return loader.load_library(binary);