Skip to content

Commit

Permalink
Fix Server triggering wrong errors if environment init fails
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed May 7, 2020
1 parent 4f9ccd8 commit 650168c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/serverenvironment.cpp
Expand Up @@ -624,6 +624,9 @@ PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,

void ServerEnvironment::saveMeta()
{
if (!m_meta_loaded)
return;

std::string path = m_path_world + DIR_DELIM "env_meta.txt";

// Open file and serialize
Expand All @@ -650,6 +653,9 @@ void ServerEnvironment::saveMeta()

void ServerEnvironment::loadMeta()
{
SANITY_CHECK(!m_meta_loaded);
m_meta_loaded = true;

// If file doesn't exist, load default environment metadata
if (!fs::PathExists(m_path_world + DIR_DELIM "env_meta.txt")) {
infostream << "ServerEnvironment: Loading default environment metadata"
Expand Down
2 changes: 2 additions & 0 deletions src/serverenvironment.h
Expand Up @@ -440,6 +440,8 @@ class ServerEnvironment : public Environment
IntervalLimiter m_active_blocks_management_interval;
IntervalLimiter m_active_block_modifier_interval;
IntervalLimiter m_active_blocks_nodemetadata_interval;
// Whether the variables below have been read from file yet
bool m_meta_loaded = false;
// Time from the beginning of the game in seconds.
// Incremented in step().
u32 m_game_time = 0;
Expand Down

0 comments on commit 650168c

Please sign in to comment.