Fix three-part names coming across as INVALID with custom client path

This commit is contained in:
Jonathan Romano 2022-11-26 05:29:53 -05:00 committed by GitHub
parent afb97a81b5
commit 4569f62100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@
#include "Entity.h" #include "Entity.h"
#include "EntityManager.h" #include "EntityManager.h"
#include "SkillComponent.h" #include "SkillComponent.h"
#include "AssetManager.h"
UserManager* UserManager::m_Address = nullptr; UserManager* UserManager::m_Address = nullptr;
@ -32,43 +33,59 @@ inline void StripCR(std::string& str) {
} }
void UserManager::Initialize() { void UserManager::Initialize() {
std::string firstNamePath = "./res/names/minifigname_first.txt";
std::string middleNamePath = "./res/names/minifigname_middle.txt";
std::string lastNamePath = "./res/names/minifigname_last.txt";
std::string line; std::string line;
std::fstream fnFile(firstNamePath, std::ios::in); AssetMemoryBuffer fnBuff = Game::assetManager->GetFileAsBuffer("names/minifigname_first.txt");
std::fstream mnFile(middleNamePath, std::ios::in); if (!fnBuff.m_Success) {
std::fstream lnFile(lastNamePath, std::ios::in); Game::logger->Log("UserManager", "Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_first.txt").string().c_str());
throw std::runtime_error("Aborting initialization due to missing minifigure name file.");
while (std::getline(fnFile, line, '\n')) { }
std::istream fnStream = std::istream(&fnBuff);
while (std::getline(fnStream, line, '\n')) {
std::string name = line; std::string name = line;
StripCR(name); StripCR(name);
m_FirstNames.push_back(name); m_FirstNames.push_back(name);
} }
fnBuff.close();
while (std::getline(mnFile, line, '\n')) { AssetMemoryBuffer mnBuff = Game::assetManager->GetFileAsBuffer("names/minifigname_middle.txt");
if (!mnBuff.m_Success) {
Game::logger->Log("UserManager", "Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_middle.txt").string().c_str());
throw std::runtime_error("Aborting initialization due to missing minifigure name file.");
}
std::istream mnStream = std::istream(&mnBuff);
while (std::getline(mnStream, line, '\n')) {
std::string name = line; std::string name = line;
StripCR(name); StripCR(name);
m_MiddleNames.push_back(name); m_MiddleNames.push_back(name);
} }
mnBuff.close();
while (std::getline(lnFile, line, '\n')) { AssetMemoryBuffer lnBuff = Game::assetManager->GetFileAsBuffer("names/minifigname_last.txt");
if (!lnBuff.m_Success) {
Game::logger->Log("UserManager", "Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_last.txt").string().c_str());
throw std::runtime_error("Aborting initialization due to missing minifigure name file.");
}
std::istream lnStream = std::istream(&lnBuff);
while (std::getline(lnStream, line, '\n')) {
std::string name = line; std::string name = line;
StripCR(name); StripCR(name);
m_LastNames.push_back(name); m_LastNames.push_back(name);
} }
lnBuff.close();
fnFile.close();
mnFile.close();
lnFile.close();
//Load our pre-approved names: //Load our pre-approved names:
std::fstream chatList("./res/chatplus_en_us.txt", std::ios::in); AssetMemoryBuffer chatListBuff = Game::assetManager->GetFileAsBuffer("chatplus_en_us.txt");
while (std::getline(chatList, line, '\n')) { if (!chatListBuff.m_Success) {
Game::logger->Log("UserManager", "Failed to load %s", (Game::assetManager->GetResPath() / "names/chatplus_en_us.txt").string().c_str());
throw std::runtime_error("Aborting initialization due to missing chat whitelist file.");
}
std::istream chatListStream = std::istream(&chatListBuff);
while (std::getline(chatListStream, line, '\n')) {
StripCR(line); StripCR(line);
m_PreapprovedNames.push_back(line); m_PreapprovedNames.push_back(line);
} }
chatListBuff.close();
} }
UserManager::~UserManager() { UserManager::~UserManager() {