aboutsummaryrefslogtreecommitdiff
path: root/src/serverenvironment.cpp
diff options
context:
space:
mode:
authorsavilli <78875209+savilli@users.noreply.github.com>2022-09-27 22:22:11 +0200
committerGitHub <noreply@github.com>2022-09-27 16:22:11 -0400
commit907dcdcf7bb513ecfeb1c988f071f497dcfbf765 (patch)
tree5ef19550e97f876f9a1d5eadbedc4c4de879d8a8 /src/serverenvironment.cpp
parent3f801bc096077a91094087fab4a4557198429851 (diff)
downloadminetest-907dcdcf7bb513ecfeb1c988f071f497dcfbf765.tar.xz
Add unittests for item movement code (#11885)
Diffstat (limited to 'src/serverenvironment.cpp')
-rw-r--r--src/serverenvironment.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp
index 8989fb05f..0e408f378 100644
--- a/src/serverenvironment.cpp
+++ b/src/serverenvironment.cpp
@@ -389,17 +389,29 @@ void ActiveBlockList::update(std::vector<PlayerSAO*> &active_players,
static std::random_device seed;
ServerEnvironment::ServerEnvironment(ServerMap *map,
- ServerScripting *scriptIface, Server *server,
+ ServerScripting *script_iface, Server *server,
const std::string &path_world, MetricsBackend *mb):
Environment(server),
m_map(map),
- m_script(scriptIface),
+ m_script(script_iface),
m_server(server),
m_path_world(path_world),
m_rgen(seed())
{
+ m_step_time_counter = mb->addCounter(
+ "minetest_env_step_time", "Time spent in environment step (in microseconds)");
+
+ m_active_block_gauge = mb->addGauge(
+ "minetest_env_active_blocks", "Number of active blocks");
+
+ m_active_object_gauge = mb->addGauge(
+ "minetest_env_active_objects", "Number of active objects");
+}
+
+void ServerEnvironment::init()
+{
// Determine which database backend to use
- std::string conf_path = path_world + DIR_DELIM + "world.mt";
+ std::string conf_path = m_path_world + DIR_DELIM + "world.mt";
Settings conf;
std::string player_backend_name = "sqlite3";
@@ -455,17 +467,8 @@ ServerEnvironment::ServerEnvironment(ServerMap *map,
<< "please read http://wiki.minetest.net/Database_backends." << std::endl;
}
- m_player_database = openPlayerDatabase(player_backend_name, path_world, conf);
- m_auth_database = openAuthDatabase(auth_backend_name, path_world, conf);
-
- m_step_time_counter = mb->addCounter(
- "minetest_env_step_time", "Time spent in environment step (in microseconds)");
-
- m_active_block_gauge = mb->addGauge(
- "minetest_env_active_blocks", "Number of active blocks");
-
- m_active_object_gauge = mb->addGauge(
- "minetest_env_active_objects", "Number of active objects");
+ m_player_database = openPlayerDatabase(player_backend_name, m_path_world, conf);
+ m_auth_database = openAuthDatabase(auth_backend_name, m_path_world, conf);
}
ServerEnvironment::~ServerEnvironment()
@@ -478,7 +481,8 @@ ServerEnvironment::~ServerEnvironment()
deactivateFarObjects(true);
// Drop/delete map
- m_map->drop();
+ if (m_map)
+ m_map->drop();
// Delete ActiveBlockModifiers
for (ABMWithState &m_abm : m_abms) {