Core/DBLayer: Make database interaction after create character packet completely asynchronous. This is more performant and fixes a DoS loophole and possible data desynchronisation caused by spamming this packet.

Closes #584
Closes #2089
This commit is contained in:
Machiavelli
2011-06-22 14:22:08 +02:00
parent 5c85d43030
commit fe8cb75bf1
12 changed files with 379 additions and 228 deletions
+12 -12
View File
@@ -904,7 +904,7 @@ void Player::CleanupsBeforeDelete(bool finalCleanup)
itr->second.save->RemovePlayer(this);
}
bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 /*outfitId*/)
bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
{
//FIXME: outfitId not used in player creating
// TODO: need more checks against packet modifications
@@ -913,9 +913,9 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
Object::_Create(guidlow, 0, HIGHGUID_PLAYER);
m_name = name;
m_name = createInfo->Name;
PlayerInfo const* info = sObjectMgr->GetPlayerInfo(race, class_);
PlayerInfo const* info = sObjectMgr->GetPlayerInfo(createInfo->Race, createInfo->Class);
if (!info)
{
sLog->outError("Player have incorrect race/class pair. Can't be loaded.");
@@ -927,10 +927,10 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
Relocate(info->positionX, info->positionY, info->positionZ, info->orientation);
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(class_);
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(createInfo->Class);
if (!cEntry)
{
sLog->outError("Class %u not found in DBC (Wrong DBC files?)", class_);
sLog->outError("Class %u not found in DBC (Wrong DBC files?)", createInfo->Class);
return false;
}
@@ -941,15 +941,15 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
setFactionForRace(race);
setFactionForRace(createInfo->Race);
if (!IsValidGender(gender))
if (!IsValidGender(createInfo->Gender))
{
sLog->outError("Player has invalid gender (%hu), can't be loaded.", gender);
sLog->outError("Player has invalid gender (%hu), can't be loaded.", createInfo->Gender);
return false;
}
uint32 RaceClassGender = (race) | (class_ << 8) | (gender << 16);
uint32 RaceClassGender = (createInfo->Race) | (createInfo->Class << 8) | (createInfo->Gender << 16);
SetUInt32Value(UNIT_FIELD_BYTES_0, (RaceClassGender | (powertype << 24)));
InitDisplayIds();
@@ -965,9 +965,9 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
// -1 is default value
SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1));
SetUInt32Value(PLAYER_BYTES, (skin | (face << 8) | (hairStyle << 16) | (hairColor << 24)));
SetUInt32Value(PLAYER_BYTES_2, (facialHair | (0x00 << 8) | (0x00 << 16) | (0x02 << 24)));
SetByteValue(PLAYER_BYTES_3, 0, gender);
SetUInt32Value(PLAYER_BYTES, (createInfo->Skin | (createInfo->Face << 8) | (createInfo->HairStyle << 16) | (createInfo->HairColor << 24)));
SetUInt32Value(PLAYER_BYTES_2, (createInfo->FacialHair | (0x00 << 8) | (0x00 << 16) | (0x02 << 24)));
SetByteValue(PLAYER_BYTES_3, 0, createInfo->Gender);
SetByteValue(PLAYER_BYTES_3, 3, 0); // BattlefieldArenaFaction (0 or 1)
SetUInt32Value(PLAYER_GUILDID, 0);
+1 -1
View File
@@ -1064,7 +1064,7 @@ class Player : public Unit, public GridObject<Player>
}
void SummonIfPossible(bool agree);
bool Create(uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId);
bool Create(uint32 guidlow, CharacterCreateInfo* createInfo);
void Update(uint32 time);