Skip to content

Commit

Permalink
Eliminate saving of GUId generator state to disk. Use system time ins…
Browse files Browse the repository at this point in the history
…tead.
  • Loading branch information
sfence committed Jan 4, 2024
1 parent 24d1120 commit 5665585
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/guid.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ class GUIdGenerator {
* Set ServerEnvironment,
* @param env ServerEnvironment.
*/
void setServerEnvironment(ServerEnvironment *env) { m_env = env; };
void setServerEnvironment(ServerEnvironment *env, u64 state) { m_env = env; m_next = state; };
/**
* Set state to defined/known state,
* @param next New state value.
*/
void setState(u32 state) { m_next = state; };
void setState(u64 state) { m_next = state; };
/**
* Get state,
* @return Return aactual state value.
*/
u32 getState() const { return m_next; };
u64 getState() const { return m_next; };

private:
ServerEnvironment *m_env;
u32 m_next;
u64 m_next;

friend class ServerEnvironment;
};
7 changes: 1 addition & 6 deletions src/serverenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ ServerEnvironment::ServerEnvironment(ServerMap *map,
m_active_object_gauge = mb->addGauge(
"minetest_env_active_objects", "Number of active objects");

m_guid_generator.setServerEnvironment(this);
m_guid_generator.setServerEnvironment(this, porting::getTimeS());
}

void ServerEnvironment::init()
Expand Down Expand Up @@ -720,7 +720,6 @@ void ServerEnvironment::saveMeta()
args.set("lbm_introduction_times",
m_lbm_mgr.createIntroductionTimesString());
args.setU64("day_count", m_day_count);
args.setU64("guid_state", m_guid_generator.getState());
args.writeLines(ss);

if(!fs::safeWriteToFile(path, ss.str()))
Expand Down Expand Up @@ -794,10 +793,6 @@ void ServerEnvironment::loadMeta()

m_day_count = args.exists("day_count") ?
args.getU64("day_count") : 0;

u32 guid_state = args.exists("guid_state") ?
args.getU64("guid_state") : 0;
m_guid_generator.setState(guid_state);
}

/**
Expand Down

0 comments on commit 5665585

Please sign in to comment.