summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorMontandalar <jbis1337@hotmail.com>2020-01-12 06:47:34 +1100
committerSmallJoker <SmallJoker@users.noreply.github.com>2020-01-11 20:47:34 +0100
commit8d75c118d99b3ccf383ceb3b7bbc9b84a1d837b2 (patch)
tree23100b322c3b7f73c748647e7f03a433b882047b /src/client
parent4c8af5492ba9c3b9671f5213e81d28a7b856e134 (diff)
downloadminetest-8d75c118d99b3ccf383ceb3b7bbc9b84a1d837b2.tar.gz
minetest-8d75c118d99b3ccf383ceb3b7bbc9b84a1d837b2.tar.bz2
minetest-8d75c118d99b3ccf383ceb3b7bbc9b84a1d837b2.zip
Map download: Escape ':' to '_' (#9235)
This is necessary under Windows systems, and direct IPv6 connections. Windows universally disallows ':' from occuring in filenames. Other disallowed characters on Windows: \ / * ? " < > | are not relevant to hostnames, IPv4 or IPv6 addresses. Anyone who has got an existing server map saved on Linux with ':' in the world save will want to keep that save.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp
index 315fcd410..94b483802 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -782,11 +782,20 @@ void Client::initLocalMapSaving(const Address &address,
return;
}
- const std::string world_path = porting::path_user
- + DIR_DELIM + "worlds"
- + DIR_DELIM + "server_"
+ std::string world_path;
+#define set_world_path(hostname) \
+ world_path = porting::path_user \
+ + DIR_DELIM + "worlds" \
+ + DIR_DELIM + "server_" \
+ hostname + "_" + std::to_string(address.getPort());
+ set_world_path(hostname);
+ if (!fs::IsDir(world_path)) {
+ std::string hostname_escaped = hostname;
+ str_replace(hostname_escaped, ':', '_');
+ set_world_path(hostname_escaped);
+ }
+#undef set_world_path
fs::CreateAllDirs(world_path);
m_localdb = new MapDatabaseSQLite3(world_path);