Fix load configs

This commit is contained in:
Jiga228
2025-10-18 13:03:26 +07:00
parent 137522cefa
commit bed233e56c
5 changed files with 62 additions and 5 deletions
+2
View File
@@ -37,6 +37,8 @@ SaveMap::SaveMap(const std::string& json_data)
{
size_t key_begin = i = json_data_blank.find_first_of('\"', i) + 1;
size_t key_end = i = json_data_blank.find_first_of('\"', i);
if (0 == key_begin)
return;
std::string name = json_data_blank.substr(key_begin, key_end - key_begin);
+5 -1
View File
@@ -25,8 +25,12 @@ struct WorldFactory
std::ifstream config_file("./Worlds/" #WorldName ".world");\
if (config_file.fail())\
throw std::runtime_error("Can't open world file");\
config_file.seekg(0, std::ios::end);\
size_t file_size = config_file.tellg();\
config_file.seekg(0, std::ios::beg);\
std::string data;\
std::getline(config_file, data);\
data.resize(file_size);\
config_file.read(data.data(), file_size);\
world->load(std::make_shared<SaveMap>(data));\
return world;\
}},