From 5ce6fcc59bb988bda9a1bb9725a2fbcf2270b3c2 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sun, 7 Nov 2021 01:42:13 +0100 Subject: use fallback world name Apparently, the default world of minetest-server does not have a name set (which is kind of okay because it is the only existing world anyway). But ModderBaas needs to deal with this situation properly. In this case, we simply take the directory name, similar to games. --- src/world.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/world.rs') diff --git a/src/world.rs b/src/world.rs index 42a41a4..79ba3f9 100644 --- a/src/world.rs +++ b/src/world.rs @@ -37,8 +37,14 @@ impl World { /// Returns the name of the world. pub fn world_name(&self) -> Result { + let fallback = self.path + .file_name() + .map(|s| s.to_str().expect("Non-UTF8 directory encountered")); + let conf = self.conf()?; conf.get("world_name") + .map(String::as_str) + .or(fallback) .ok_or_else(|| Error::InvalidWorldDir(self.path.clone())) .map(Into::into) } -- cgit v1.2.3