Store properties in boiii_players as well

This commit is contained in:
Maurice Heumann 2023-05-18 10:27:14 +02:00
parent 6762da248b
commit 4f1d825b72
2 changed files with 18 additions and 2 deletions

View File

@ -147,7 +147,7 @@ namespace client_patches
} }
// TODO: Remove me after some time // TODO: Remove me after some time
void migrate_if_needed() extern "C" void migrate_if_needed()
{ {
std::error_code e; std::error_code e;

View File

@ -16,6 +16,8 @@ namespace utils::properties
{ {
namespace namespace
{ {
extern "C" void migrate_if_needed();
typedef rapidjson::EncodedOutputStream<rapidjson::UTF8<>, rapidjson::FileWriteStream> OutputStream; typedef rapidjson::EncodedOutputStream<rapidjson::UTF8<>, rapidjson::FileWriteStream> OutputStream;
typedef rapidjson::EncodedInputStream<rapidjson::UTF8<>, rapidjson::FileReadStream> InputStream; typedef rapidjson::EncodedInputStream<rapidjson::UTF8<>, rapidjson::FileReadStream> InputStream;
@ -27,7 +29,21 @@ namespace utils::properties
std::filesystem::path get_properties_file() std::filesystem::path get_properties_file()
{ {
static auto props = get_properties_folder() / "properties.json"; static auto props = []
{
auto path = std::filesystem::path("boiii_players/properties.json");
const auto legacy_path = get_properties_folder() / "properties.json";
migrate_if_needed();
if (io::file_exists(legacy_path) && !io::file_exists(path))
{
std::error_code e;
std::filesystem::copy(legacy_path, path, std::filesystem::copy_options::skip_existing, e);
}
return path;
}();
return props; return props;
} }