diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 3e3bb1291..c35ca70b3 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4725,7 +4725,7 @@ static bool HandleResetStatsOrLevelHelper(Player* player) player->setFactionForRace(player->getRace()); - player->SetUInt32Value(UNIT_FIELD_BYTES_0, ( ( player->getRace() ) | ( player->getClass() << 8 ) | ( player->getGender() << 16 ) | ( powertype << 24 ) ) ); + player->SetByteValue(UNIT_FIELD_BYTES_0, 3, powertype); // reset only if player not in some form; if(player->m_form==FORM_NONE) @@ -6691,7 +6691,7 @@ bool ChatHandler::HandleModifyGenderCommand(char *args) // Set gender player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); - player->SetByteValue(PLAYER_BYTES_3, 0, gender); + player->SetUInt16Value(PLAYER_BYTES_3, 0, uint16(gender) | (player->GetDrunkValue() & 0xFFFE)); // Change display ID player->InitDisplayIds(); diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 4e99b3524..11bca3158 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -197,12 +197,14 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool case SUMMON_PET: petlevel=owner->getLevel(); - SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); + SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_MAGE); SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); // this enables popup window (pet dismiss, cancel) break; case HUNTER_PET: - SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); + SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_WARRIOR); + SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_NONE); + SetByteValue(UNIT_FIELD_BYTES_0, 3, POWER_FOCUS); SetSheath(SHEATH_STATE_MELEE); SetByteFlag(UNIT_FIELD_BYTES_2, 2, fields[9].GetBool() ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); @@ -842,7 +844,9 @@ bool Pet::CreateBaseAtCreature(Creature* creature) if(cinfo->type == CREATURE_TYPE_BEAST) { - SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); + SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_WARRIOR); + SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_NONE); + SetByteValue(UNIT_FIELD_BYTES_0, 3, POWER_FOCUS); SetSheath(SHEATH_STATE_MELEE); SetByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); SetUInt32Value(UNIT_MOD_CAST_SPEED, creature->GetUInt32Value(UNIT_MOD_CAST_SPEED)); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0a7752499..e3047cd0c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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(); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 005076047..15f4c3c90 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4218,9 +4218,6 @@ void Spell::DoSummon(SpellEffectIndex eff_idx) spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); spawnCreature->setPowerType(POWER_MANA); spawnCreature->setFaction(m_caster->getFaction()); - spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS, 0); - spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); - spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); @@ -4679,8 +4676,6 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction) spawnCreature->setPowerType(POWER_MANA); spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, spawnCreature->GetCreatureInfo()->npcflag); spawnCreature->setFaction(forceFaction ? forceFaction : m_caster->getFaction()); - spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS, 0); - spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); spawnCreature->SetCreatorGuid(m_caster->GetObjectGuid()); spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); @@ -5112,8 +5107,6 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx) NewSummon->SetCreatorGuid(m_caster->GetObjectGuid()); NewSummon->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); NewSummon->setFaction(faction); - NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); - NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1859571cf..dc882f9d5 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10822" + #define REVISION_NR "10823" #endif // __REVISION_NR_H__