Reset environment metadata if it is unreadable

master
numzero 2022-04-07 22:38:18 +03:00 committed by Maksim
parent 11abe53d2b
commit 745b858bae
2 changed files with 8 additions and 2 deletions

View File

@ -482,7 +482,13 @@ void Server::init()
// Register us to receive map edit events
servermap->addEventReceiver(this);
m_env->loadMeta();
try {
m_env->loadMeta();
} catch (SerializationError &e) {
warningstream << "Environment metadata is corrupted: " << e.what() << std::endl;
warningstream << "Loading the default instead" << std::endl;
m_env->loadDefaultMeta();
}
// Those settings can be overwritten in world.mt, they are
// intended to be cached after environment loading.

View File

@ -368,13 +368,13 @@ public:
const bool isCompatPlayerModel(const std::string &model_name);
inline bool getCompatSendOriginalModel() { return m_compat_send_original_model; }
private:
/**
* called if env_meta.txt doesn't exist (e.g. new world)
*/
void loadDefaultMeta();
private:
static PlayerDatabase *openPlayerDatabase(const std::string &name,
const std::string &savedir, const Settings &conf);
static AuthDatabase *openAuthDatabase(const std::string &name,