mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[10823] Clear way access/set UNIT_FIELD_BYTES_*/PLAYER_BYTES* byte fields.
Fix some bugs when all uint32 field modified instead byte parts. In some cases added byte way set/get but code line itself need additinal reserch/fix for use correctness in line pos.
This commit is contained in:
parent
9e071e4483
commit
b967848e42
5 changed files with 63 additions and 50 deletions
|
|
@ -653,12 +653,6 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i)
|
||||
m_items[i] = NULL;
|
||||
|
||||
SetLocationMapId(info->mapId);
|
||||
Relocate(info->positionX,info->positionY,info->positionZ, info->orientation);
|
||||
|
||||
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(class_);
|
||||
if(!cEntry)
|
||||
{
|
||||
|
|
@ -666,15 +660,29 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
return false;
|
||||
}
|
||||
|
||||
// player store gender in single bit
|
||||
if (gender != uint8(GENDER_MALE) && gender != uint8(GENDER_FEMALE))
|
||||
{
|
||||
sLog.outError("Invalid gender %u at player creating", uint32(gender));
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i)
|
||||
m_items[i] = NULL;
|
||||
|
||||
SetLocationMapId(info->mapId);
|
||||
Relocate(info->positionX,info->positionY,info->positionZ, info->orientation);
|
||||
|
||||
SetMap(sMapMgr.CreateMap(info->mapId, this));
|
||||
|
||||
uint8 powertype = cEntry->powerType;
|
||||
|
||||
setFactionForRace(race);
|
||||
|
||||
uint32 RaceClassGender = ( race ) | ( class_ << 8 ) | ( gender << 16 );
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_0, ( RaceClassGender | ( powertype << 24 ) ) );
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 0, race);
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 1, class_);
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 2, gender);
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 3, powertype);
|
||||
|
||||
InitDisplayIds(); // model, scale and model data
|
||||
|
||||
|
|
@ -686,9 +694,15 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
|
||||
SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, -1); // -1 is default value
|
||||
|
||||
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);
|
||||
SetByteValue(PLAYER_BYTES, 0, skin);
|
||||
SetByteValue(PLAYER_BYTES, 1, face);
|
||||
SetByteValue(PLAYER_BYTES, 2, hairStyle);
|
||||
SetByteValue(PLAYER_BYTES, 2, hairColor);
|
||||
|
||||
SetByteValue(PLAYER_BYTES_2, 0, facialHair);
|
||||
SetByteValue(PLAYER_BYTES_2, 3, 0x02); // rest state = normal
|
||||
|
||||
SetUInt16Value(PLAYER_BYTES_3, 0, gender); // only GENDER_MALE/GENDER_FEMALE (1 bit) allowed, drunk state = 0
|
||||
SetByteValue(PLAYER_BYTES_3, 3, 0); // BattlefieldArenaFaction (0 or 1)
|
||||
|
||||
SetUInt32Value( PLAYER_GUILDID, 0 );
|
||||
|
|
@ -760,12 +774,14 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
addActionButton(0, action_itr->button,action_itr->action,action_itr->type);
|
||||
|
||||
// original items
|
||||
uint32 raceClassGender = GetUInt32Value(UNIT_FIELD_BYTES_0) & 0x00FFFFFF;
|
||||
|
||||
CharStartOutfitEntry const* oEntry = NULL;
|
||||
for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i)
|
||||
{
|
||||
if(CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i))
|
||||
{
|
||||
if(entry->RaceClassGender == RaceClassGender)
|
||||
if(entry->RaceClassGender == raceClassGender)
|
||||
{
|
||||
oEntry = entry;
|
||||
break;
|
||||
|
|
@ -1151,7 +1167,7 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId)
|
|||
uint32 oldDrunkenState = Player::GetDrunkenstateByValue(m_drunk);
|
||||
|
||||
m_drunk = newDrunkenValue;
|
||||
SetUInt32Value(PLAYER_BYTES_3,(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFF0001) | (m_drunk & 0xFFFE));
|
||||
SetUInt16Value(PLAYER_BYTES_3, 0, uint16(getGender()) | (m_drunk & 0xFFFE));
|
||||
|
||||
uint32 newDrunkenState = Player::GetDrunkenstateByValue(m_drunk);
|
||||
|
||||
|
|
@ -4544,8 +4560,6 @@ Corpse* Player::CreateCorpse()
|
|||
// prevent existence 2 corpse for player
|
||||
SpawnCorpseBones();
|
||||
|
||||
uint32 _uf, _pb, _pb2, _cfb1, _cfb2;
|
||||
|
||||
Corpse *corpse = new Corpse( (m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE );
|
||||
SetPvPDeath(false);
|
||||
|
||||
|
|
@ -4555,22 +4569,20 @@ Corpse* Player::CreateCorpse()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
_uf = GetUInt32Value(UNIT_FIELD_BYTES_0);
|
||||
_pb = GetUInt32Value(PLAYER_BYTES);
|
||||
_pb2 = GetUInt32Value(PLAYER_BYTES_2);
|
||||
uint8 skin = GetByteValue(PLAYER_BYTES, 0);
|
||||
uint8 face = GetByteValue(PLAYER_BYTES, 1);
|
||||
uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2);
|
||||
uint8 haircolor = GetByteValue(PLAYER_BYTES, 3);
|
||||
uint8 facialhair = GetByteValue(PLAYER_BYTES_2, 0);
|
||||
|
||||
uint8 race = (uint8)(_uf);
|
||||
uint8 skin = (uint8)(_pb);
|
||||
uint8 face = (uint8)(_pb >> 8);
|
||||
uint8 hairstyle = (uint8)(_pb >> 16);
|
||||
uint8 haircolor = (uint8)(_pb >> 24);
|
||||
uint8 facialhair = (uint8)(_pb2);
|
||||
corpse->SetByteValue(CORPSE_FIELD_BYTES_1, 1, getRace());
|
||||
corpse->SetByteValue(CORPSE_FIELD_BYTES_1, 2, getGender());
|
||||
corpse->SetByteValue(CORPSE_FIELD_BYTES_1, 3, skin);
|
||||
|
||||
_cfb1 = ((0x00) | (race << 8) | (getGender() << 16) | (skin << 24));
|
||||
_cfb2 = ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24));
|
||||
|
||||
corpse->SetUInt32Value( CORPSE_FIELD_BYTES_1, _cfb1 );
|
||||
corpse->SetUInt32Value( CORPSE_FIELD_BYTES_2, _cfb2 );
|
||||
corpse->SetByteValue(CORPSE_FIELD_BYTES_2, 0, face);
|
||||
corpse->SetByteValue(CORPSE_FIELD_BYTES_2, 1, hairstyle);
|
||||
corpse->SetByteValue(CORPSE_FIELD_BYTES_2, 2, haircolor);
|
||||
corpse->SetByteValue(CORPSE_FIELD_BYTES_2, 3, facialhair);
|
||||
|
||||
uint32 flags = CORPSE_FLAG_UNK2;
|
||||
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM))
|
||||
|
|
@ -15124,11 +15136,11 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
|||
SetGuidValue(OBJECT_FIELD_GUID, guid);
|
||||
|
||||
// overwrite some data fields
|
||||
uint32 bytes0 = 0;
|
||||
bytes0 |= fields[3].GetUInt8(); // race
|
||||
bytes0 |= fields[4].GetUInt8() << 8; // class
|
||||
bytes0 |= fields[5].GetUInt8() << 16; // gender
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_0, bytes0);
|
||||
SetByteValue(UNIT_FIELD_BYTES_0,0,fields[3].GetUInt8());// race
|
||||
SetByteValue(UNIT_FIELD_BYTES_0,1,fields[4].GetUInt8());// class
|
||||
|
||||
uint8 gender = fields[5].GetUInt8() & 0x01; // allowed only 1 bit values male/female cases (for fit drunk gender part)
|
||||
SetByteValue(UNIT_FIELD_BYTES_0,2,gender); // gender
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_LEVEL, fields[6].GetUInt8());
|
||||
SetUInt32Value(PLAYER_XP, fields[7].GetUInt32());
|
||||
|
|
@ -15147,7 +15159,11 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
|||
|
||||
SetUInt32Value(PLAYER_BYTES, fields[9].GetUInt32());
|
||||
SetUInt32Value(PLAYER_BYTES_2, fields[10].GetUInt32());
|
||||
SetUInt32Value(PLAYER_BYTES_3, (fields[49].GetUInt16() & 0xFFFE) | fields[5].GetUInt8());
|
||||
|
||||
m_drunk = fields[49].GetUInt16();
|
||||
|
||||
SetUInt16Value(PLAYER_BYTES_3, 0, (m_drunk & 0xFFFE) | gender);
|
||||
|
||||
SetUInt32Value(PLAYER_FLAGS, fields[11].GetUInt32());
|
||||
SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[48].GetInt32());
|
||||
|
||||
|
|
@ -15392,7 +15408,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
|||
soberFactor = 0;
|
||||
else
|
||||
soberFactor = 1-time_diff/(15.0f*MINUTE);
|
||||
uint16 newDrunkenValue = uint16(soberFactor*(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE));
|
||||
uint16 newDrunkenValue = uint16(soberFactor* m_drunk);
|
||||
SetDrunkValue(newDrunkenValue);
|
||||
|
||||
m_cinematic = fields[18].GetUInt32();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue