mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 15:07:28 +00:00
chore: make predefined name unique when the name files are not provided (#1453)
Multiple characters would not be allowed to be made since they would both have tha name INVALID, that is no longer the case
This commit is contained in:
parent
29666a1ff7
commit
ecaaea3175
@ -301,6 +301,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
|||||||
|
|
||||||
const auto name = LUWStringName.GetAsString();
|
const auto name = LUWStringName.GetAsString();
|
||||||
std::string predefinedName = GetPredefinedName(firstNameIndex, middleNameIndex, lastNameIndex);
|
std::string predefinedName = GetPredefinedName(firstNameIndex, middleNameIndex, lastNameIndex);
|
||||||
|
|
||||||
LOT shirtLOT = FindCharShirtID(shirtColor, shirtStyle);
|
LOT shirtLOT = FindCharShirtID(shirtColor, shirtStyle);
|
||||||
LOT pantsLOT = FindCharPantsID(pantsColor);
|
LOT pantsLOT = FindCharPantsID(pantsColor);
|
||||||
|
|
||||||
@ -323,7 +324,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Now that the name is ok, we can get an objectID from Master:
|
//Now that the name is ok, we can get an objectID from Master:
|
||||||
ObjectIDManager::RequestPersistentID([=, this](uint32_t objectID) {
|
ObjectIDManager::RequestPersistentID([=, this](uint32_t objectID) mutable {
|
||||||
if (Database::Get()->GetCharacterInfo(objectID)) {
|
if (Database::Get()->GetCharacterInfo(objectID)) {
|
||||||
LOG("Character object id unavailable, check object_id_tracker!");
|
LOG("Character object id unavailable, check object_id_tracker!");
|
||||||
WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::OBJECT_ID_UNAVAILABLE);
|
WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::OBJECT_ID_UNAVAILABLE);
|
||||||
@ -366,6 +367,14 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
|||||||
bool nameOk = IsNamePreapproved(name);
|
bool nameOk = IsNamePreapproved(name);
|
||||||
if (!nameOk && u->GetMaxGMLevel() > eGameMasterLevel::FORUM_MODERATOR) nameOk = true;
|
if (!nameOk && u->GetMaxGMLevel() > eGameMasterLevel::FORUM_MODERATOR) nameOk = true;
|
||||||
|
|
||||||
|
// If predefined name is invalid, change it to be their object id
|
||||||
|
// that way more than one player can create characters if the predefined name files are not provided
|
||||||
|
if (predefinedName == "INVALID") {
|
||||||
|
std::stringstream nameObjID;
|
||||||
|
nameObjID << "minifig" << objectID;
|
||||||
|
predefinedName = nameObjID.str();
|
||||||
|
}
|
||||||
|
|
||||||
std::string_view nameToAssign = !name.empty() && nameOk ? name : predefinedName;
|
std::string_view nameToAssign = !name.empty() && nameOk ? name : predefinedName;
|
||||||
std::string pendingName = !name.empty() && !nameOk ? name : "";
|
std::string pendingName = !name.empty() && !nameOk ? name : "";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user