Misc changes. #13
| @@ -4,6 +4,7 @@ | |||||||
| #include "loader/component_loader.hpp" | #include "loader/component_loader.hpp" | ||||||
| #include "game/game.hpp" | #include "game/game.hpp" | ||||||
|  |  | ||||||
|  | #include "utils/command_line.hpp" | ||||||
| #include <utils/flags.hpp> | #include <utils/flags.hpp> | ||||||
| #include <utils/io.hpp> | #include <utils/io.hpp> | ||||||
| #include <utils/string.hpp> | #include <utils/string.hpp> | ||||||
| @@ -167,8 +168,23 @@ FARPROC load_binary(const launcher::mode mode) | |||||||
| 	std::string data; | 	std::string data; | ||||||
| 	if (!utils::io::read_file(binary, &data)) | 	if (!utils::io::read_file(binary, &data)) | ||||||
| 	{ | 	{ | ||||||
| 		throw std::runtime_error( | 		// Check the first argument to see if the current directory needs to changed | ||||||
| 			"Failed to read game binary! Please select the correct path in the launcher settings."); | 		// 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 | #ifdef INJECT_HOST_AS_LIB | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user