Merge pull request #38 from yuwui/patch/strip_cr

This commit is contained in:
Wincent Holm 2021-12-06 07:46:14 +01:00 committed by GitHub
commit 34f1d4002b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
#include <fstream>
#include <future>
#include <sstream>
#include <algorithm>
#include "Database.h"
#include "Game.h"
@ -25,6 +26,10 @@ UserManager * UserManager::m_Address = nullptr;
uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle);
uint32_t FindCharPantsID(uint32_t pantsColor);
inline void StripCR(std::string& str) {
str.erase(std::remove(str.begin(), str.end(), '\r'), str.end());
}
void UserManager::Initialize() {
std::string firstNamePath = "./res/names/minifigname_first.txt";
std::string middleNamePath = "./res/names/minifigname_middle.txt";
@ -37,16 +42,19 @@ void UserManager::Initialize() {
while (std::getline(fnFile, line, '\n')) {
std::string name = line;
StripCR(name);
m_FirstNames.push_back(name);
}
while (std::getline(mnFile, line, '\n')) {
std::string name = line;
StripCR(name);
m_MiddleNames.push_back(name);
}
while (std::getline(lnFile, line, '\n')) {
std::string name = line;
StripCR(name);
m_LastNames.push_back(name);
}
@ -57,6 +65,7 @@ void UserManager::Initialize() {
//Load our pre-approved names:
std::fstream chatList("./res/chatplus_en_us.txt", std::ios::in);
while (std::getline(chatList, line, '\n')) {
StripCR(line);
m_PreapprovedNames.push_back(line);
}