From bd799ecd5b064300cc198d3a7aa982a82c34e175 Mon Sep 17 00:00:00 2001 From: Inifield Date: Mon, 26 Jun 2017 16:43:13 +0200 Subject: [PATCH] Core/Player: Correct gender by modelid and avoid saving character with wrong gender Closes #396 Author is MitchesD, Kittnz and Shauren --- src/game/Entities/Player/Player.cpp | 4 ++-- src/game/Entities/Unit/Unit.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/game/Entities/Player/Player.cpp b/src/game/Entities/Player/Player.cpp index 9c279d2eb..26f93c603 100644 --- a/src/game/Entities/Player/Player.cpp +++ b/src/game/Entities/Player/Player.cpp @@ -25861,7 +25861,7 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans) stmt->setString(index++, GetName()); stmt->setUInt8(index++, getRace(true)); stmt->setUInt8(index++, getClass()); - stmt->setUInt8(index++, getGender()); + stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, 0)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect stmt->setUInt8(index++, getLevel()); stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP)); stmt->setUInt32(index++, GetMoney()); @@ -25966,7 +25966,7 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans) stmt->setString(index++, GetName()); stmt->setUInt8(index++, getRace(true)); stmt->setUInt8(index++, getClass()); - stmt->setUInt8(index++, getGender()); + stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, 0)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect stmt->setUInt8(index++, getLevel()); stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP)); stmt->setUInt32(index++, GetMoney()); diff --git a/src/game/Entities/Unit/Unit.cpp b/src/game/Entities/Unit/Unit.cpp index d6063b3fa..7799ad675 100644 --- a/src/game/Entities/Unit/Unit.cpp +++ b/src/game/Entities/Unit/Unit.cpp @@ -15404,6 +15404,9 @@ bool Unit::IsPolymorphed() const void Unit::SetDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId); + // Set Gender by modelId + if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId)) + SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender); } void Unit::RestoreDisplayId()