aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2020-10-19 20:38:33 +0200
committerGitHub <noreply@github.com>2020-10-19 20:38:33 +0200
commit4f2303849e0f929524695a9e3719ec486b47ddd1 (patch)
tree66286a14f883a77e7d77bc0a6a20ae6470811fbb /src/server
parent660115c1abc76f3d4f6a6597ed0c4737465c6c55 (diff)
downloadminetest-4f2303849e0f929524695a9e3719ec486b47ddd1.tar.gz
minetest-4f2303849e0f929524695a9e3719ec486b47ddd1.tar.bz2
minetest-4f2303849e0f929524695a9e3719ec486b47ddd1.zip
Implement unloading of static_save=false objects according to existing docs (#10485)
Diffstat (limited to 'src/server')
-rw-r--r--src/server/luaentity_sao.h1
-rw-r--r--src/server/player_sao.h1
-rw-r--r--src/server/serveractiveobject.h9
3 files changed, 11 insertions, 0 deletions
diff --git a/src/server/luaentity_sao.h b/src/server/luaentity_sao.h
index 2520c8f5d..e060aa06d 100644
--- a/src/server/luaentity_sao.h
+++ b/src/server/luaentity_sao.h
@@ -42,6 +42,7 @@ public:
void step(float dtime, bool send_recommended);
std::string getClientInitializationData(u16 protocol_version);
bool isStaticAllowed() const { return m_prop.static_save; }
+ bool shouldUnload() const { return true; }
void getStaticData(std::string *result) const;
u16 punch(v3f dir, const ToolCapabilities *toolcap = nullptr,
ServerActiveObject *puncher = nullptr,
diff --git a/src/server/player_sao.h b/src/server/player_sao.h
index 8571bd4f9..3e178d4fc 100644
--- a/src/server/player_sao.h
+++ b/src/server/player_sao.h
@@ -83,6 +83,7 @@ public:
void addedToEnvironment(u32 dtime_s);
void removingFromEnvironment();
bool isStaticAllowed() const { return false; }
+ bool shouldUnload() const { return false; }
std::string getClientInitializationData(u16 protocol_version);
void getStaticData(std::string *result) const;
void step(float dtime, bool send_recommended);
diff --git a/src/server/serveractiveobject.h b/src/server/serveractiveobject.h
index 927009aef..2764d159e 100644
--- a/src/server/serveractiveobject.h
+++ b/src/server/serveractiveobject.h
@@ -125,6 +125,7 @@ public:
assert(isStaticAllowed());
*result = "";
}
+
/*
Return false in here to never save and instead remove object
on unload. getStaticData() will not be called in that case.
@@ -132,6 +133,14 @@ public:
virtual bool isStaticAllowed() const
{return true;}
+ /*
+ Return false here to never unload the object.
+ isStaticAllowed && shouldUnload -> unload when out of active block range
+ !isStaticAllowed && shouldUnload -> unload when block is unloaded
+ */
+ virtual bool shouldUnload() const
+ { return true; }
+
// Returns tool wear
virtual u16 punch(v3f dir,
const ToolCapabilities *toolcap = nullptr,