Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Montandalar authored and SmallJoker committed Jan 11, 2020
1 parent 4c8af54 commit 8d75c11
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/client/client.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 8d75c11

Please sign in to comment.