Core/Players: Greatly simplifiy fdb2b90685

This commit is contained in:
Shauren
2018-04-11 00:05:59 +02:00
committed by Aokromes
parent 1c83dcac98
commit 3c066b1ed3
4 changed files with 8 additions and 26 deletions

View File

@@ -427,14 +427,6 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
}
}
// Reserve the name for the duration of callback chain
createInfo->NameToken = sCharacterCache->TryCreateCharacterWithName(createInfo->Name);
if (!createInfo->NameToken)
{
SendCharCreate(CHAR_CREATE_NAME_IN_USE);
return;
}
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
stmt->setString(0, createInfo->Name);
@@ -586,6 +578,13 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
return;
}
// Check name uniqueness in the same step as saving to database
if (sCharacterCache->GetCharacterCacheByName(createInfo->Name))
{
SendCharCreate(CHAR_CREATE_NAME_IN_USE);
return;
}
Player newChar(this);
newChar.GetMotionMaster()->Initialize();
if (!newChar.Create(sObjectMgr->GetGenerator<HighGuid::Player>().Generate(), createInfo.get()))