Small fix + cleanup
This commit is contained in:
parent
0938e5450d
commit
b1c69e74b7
@ -9,16 +9,18 @@
|
||||
#include "filesystem.hpp"
|
||||
#include "materials.hpp"
|
||||
#include "fonts.hpp"
|
||||
#include "mods.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/io.hpp>
|
||||
|
||||
namespace mods
|
||||
{
|
||||
std::string mod_path{};
|
||||
|
||||
namespace
|
||||
{
|
||||
utils::hook::detour db_release_xassets_hook;
|
||||
|
||||
bool release_assets = false;
|
||||
|
||||
void db_release_xassets_stub()
|
||||
@ -71,22 +73,22 @@ namespace mods
|
||||
}
|
||||
|
||||
const auto path = params.get(1);
|
||||
game_console::print(game_console::con_type_info, "Loading mod %s\n", path);
|
||||
|
||||
if (!utils::io::directory_exists(path))
|
||||
{
|
||||
game_console::print(game_console::con_type_error, "Mod %s not found!\n", path);
|
||||
return;
|
||||
}
|
||||
|
||||
game_console::print(game_console::con_type_info, "Loading mod %s\n", path);
|
||||
filesystem::get_search_paths().erase(mod_path);
|
||||
filesystem::get_search_paths().insert(path);
|
||||
game::mod_folder = path;
|
||||
mod_path = path;
|
||||
restart();
|
||||
});
|
||||
|
||||
command::add("unloadmod", [](const command::params& params)
|
||||
{
|
||||
if (game::mod_folder.empty())
|
||||
if (mod_path.empty())
|
||||
{
|
||||
game_console::print(game_console::con_type_info, "No mod loaded\n");
|
||||
return;
|
||||
@ -99,9 +101,9 @@ namespace mods
|
||||
return;
|
||||
}
|
||||
|
||||
game_console::print(game_console::con_type_info, "Unloading mod %s\n", game::mod_folder.data());
|
||||
filesystem::get_search_paths().erase(game::mod_folder);
|
||||
game::mod_folder.clear();
|
||||
game_console::print(game_console::con_type_info, "Unloading mod %s\n", mod_path.data());
|
||||
filesystem::get_search_paths().erase(mod_path);
|
||||
mod_path.clear();
|
||||
restart();
|
||||
});
|
||||
}
|
||||
|
6
src/client/component/mods.hpp
Normal file
6
src/client/component/mods.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace mods
|
||||
{
|
||||
extern std::string mod_path;
|
||||
}
|
@ -3,8 +3,6 @@
|
||||
|
||||
namespace game
|
||||
{
|
||||
std::string mod_folder{};
|
||||
|
||||
namespace environment
|
||||
{
|
||||
launcher::mode mode = launcher::mode::none;
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
namespace game
|
||||
{
|
||||
extern std::string mod_folder;
|
||||
|
||||
namespace environment
|
||||
{
|
||||
launcher::mode get_mode();
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "../../../component/fastfiles.hpp"
|
||||
#include "../../../component/updater.hpp"
|
||||
#include "../../../component/localized_strings.hpp"
|
||||
#include "../../../component/mods.hpp"
|
||||
|
||||
#include "component/game_console.hpp"
|
||||
#include "component/scheduler.hpp"
|
||||
@ -434,7 +435,7 @@ namespace ui_scripting::lua
|
||||
|
||||
game_type["getloadedmod"] = [](const game&)
|
||||
{
|
||||
return ::game::mod_folder;
|
||||
return mods::mod_path;
|
||||
};
|
||||
|
||||
game_type["addlocalizedstring"] = [](const game&, const std::string& string,
|
||||
|
Loading…
Reference in New Issue
Block a user