Skip to content

Commit 95ce558

Browse files
committedMar 16, 2018
ServerEnvironment::loadDefaultMeta: Loading default meta is only possible for ServerEnv itself
1 parent 858c956 commit 95ce558

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed
 

Diff for: ‎src/server.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,7 @@ Server::Server(
274274
// Register us to receive map edit events
275275
servermap->addEventReceiver(this);
276276

277-
// If file exists, load environment metadata
278-
if (fs::PathExists(m_path_world + DIR_DELIM "env_meta.txt")) {
279-
infostream << "Server: Loading environment metadata" << std::endl;
280-
m_env->loadMeta();
281-
} else {
282-
m_env->loadDefaultMeta();
283-
}
277+
m_env->loadMeta();
284278

285279
m_liquid_transform_every = g_settings->getFloat("liquid_update");
286280
m_max_chatmessage_length = g_settings->getU16("chat_message_max_size");

Diff for: ‎src/serverenvironment.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,16 @@ void ServerEnvironment::saveMeta()
614614

615615
void ServerEnvironment::loadMeta()
616616
{
617+
// If file doesn't exist, load default environment metadata
618+
if (!fs::PathExists(m_path_world + DIR_DELIM "env_meta.txt")) {
619+
infostream << "ServerEnvironment: Loading default environment metadata"
620+
<< std::endl;
621+
loadDefaultMeta();
622+
return;
623+
}
624+
625+
infostream << "ServerEnvironment: Loading environment metadata" << std::endl;
626+
617627
std::string path = m_path_world + DIR_DELIM "env_meta.txt";
618628

619629
// Open file and deserialize
@@ -664,6 +674,9 @@ void ServerEnvironment::loadMeta()
664674
args.getU64("day_count") : 0;
665675
}
666676

677+
/**
678+
* called if env_meta.txt doesn't exist (e.g. new world)
679+
*/
667680
void ServerEnvironment::loadDefaultMeta()
668681
{
669682
m_lbm_mgr.loadIntroductionTimes("", m_server, m_game_time);

Diff for: ‎src/serverenvironment.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,6 @@ class ServerEnvironment : public Environment
232232
*/
233233
void saveMeta();
234234
void loadMeta();
235-
// to be called instead of loadMeta if
236-
// env_meta.txt doesn't exist (e.g. new world)
237-
void loadDefaultMeta();
238235

239236
u32 addParticleSpawner(float exptime);
240237
u32 addParticleSpawner(float exptime, u16 attached_id);
@@ -371,6 +368,11 @@ class ServerEnvironment : public Environment
371368
const Settings &cmd_args);
372369
private:
373370

371+
/**
372+
* called if env_meta.txt doesn't exist (e.g. new world)
373+
*/
374+
void loadDefaultMeta();
375+
374376
static PlayerDatabase *openPlayerDatabase(const std::string &name,
375377
const std::string &savedir, const Settings &conf);
376378
/*

0 commit comments

Comments
 (0)
Please sign in to comment.