mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 08:09:46 +00:00
Handle character directories like save names
This commit is contained in:
parent
8f48a1f030
commit
c01ba41aa6
2 changed files with 9 additions and 5 deletions
|
@ -58,7 +58,7 @@ void MWState::Character::addSlot (const ESM::SavedGame& profile)
|
||||||
while(!description.eof())
|
while(!description.eof())
|
||||||
{
|
{
|
||||||
auto c = description.consume();
|
auto c = description.consume();
|
||||||
if(c > 0 && c <= 0x7F && std::isalnum(c)) // Ignore multibyte characters and non alphanumeric characters
|
if(c <= 0x7F && std::isalnum(c)) // Ignore multibyte characters and non alphanumeric characters
|
||||||
stream << static_cast<char>(c);
|
stream << static_cast<char>(c);
|
||||||
else
|
else
|
||||||
stream << '_';
|
stream << '_';
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include <components/misc/utf8stream.hpp>
|
||||||
|
|
||||||
MWState::CharacterManager::CharacterManager (const boost::filesystem::path& saves,
|
MWState::CharacterManager::CharacterManager (const boost::filesystem::path& saves,
|
||||||
const std::vector<std::string>& contentFiles)
|
const std::vector<std::string>& contentFiles)
|
||||||
: mPath (saves), mCurrent (nullptr), mGame (getFirstGameFile(contentFiles))
|
: mPath (saves), mCurrent (nullptr), mGame (getFirstGameFile(contentFiles))
|
||||||
|
@ -57,12 +59,14 @@ MWState::Character* MWState::CharacterManager::createCharacter(const std::string
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
||||||
// The character name is user-supplied, so we need to escape the path
|
// The character name is user-supplied, so we need to escape the path
|
||||||
for (std::string::const_iterator it = name.begin(); it != name.end(); ++it)
|
Utf8Stream nameStream(name);
|
||||||
|
while(!nameStream.eof())
|
||||||
{
|
{
|
||||||
if (std::isalnum(*it)) // Ignores multibyte characters and non alphanumeric characters
|
auto c = nameStream.consume();
|
||||||
stream << *it;
|
if(c <= 0x7F && std::isalnum(c)) // Ignore multibyte characters and non alphanumeric characters
|
||||||
|
stream << static_cast<char>(c);
|
||||||
else
|
else
|
||||||
stream << "_";
|
stream << '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path path = mPath / stream.str();
|
boost::filesystem::path path = mPath / stream.str();
|
||||||
|
|
Loading…
Reference in a new issue