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