mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
Merge commit 'origin/master' into 320
This commit is contained in:
commit
87930a6d07
35 changed files with 719 additions and 467 deletions
|
|
@ -556,27 +556,12 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
|
||||
|
||||
switch(gender)
|
||||
{
|
||||
case GENDER_FEMALE:
|
||||
SetDisplayId(info->displayId_f );
|
||||
SetNativeDisplayId(info->displayId_f );
|
||||
break;
|
||||
case GENDER_MALE:
|
||||
SetDisplayId(info->displayId_m );
|
||||
SetNativeDisplayId(info->displayId_m );
|
||||
break;
|
||||
default:
|
||||
sLog.outError("Invalid gender %u for player",gender);
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
setFactionForRace(race);
|
||||
|
||||
uint32 RaceClassGender = ( race ) | ( class_ << 8 ) | ( gender << 16 );
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_0, ( RaceClassGender | ( powertype << 24 ) ) );
|
||||
InitDisplayIds();
|
||||
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP );
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE );
|
||||
SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
|
||||
|
|
@ -1412,7 +1397,7 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
|
|||
PlayerInfo const *info = objmgr.GetPlayerInfo(pRace, pClass);
|
||||
if(!info)
|
||||
{
|
||||
sLog.outError("Player %u have incorrect race/class pair. Don't build enum.", guid);
|
||||
sLog.outError("Player %u has incorrect race/class pair. Don't build enum.", guid);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -3354,6 +3339,22 @@ void Player::RemoveSpellCooldown( uint32 spell_id, bool update /* = false */ )
|
|||
SendClearCooldown(spell_id, this);
|
||||
}
|
||||
|
||||
void Player::RemoveSpellCategoryCooldown(uint32 cat, bool update /* = false */)
|
||||
{
|
||||
SpellCategoryStore::const_iterator ct = sSpellCategoryStore.find(cat);
|
||||
if (ct == sSpellCategoryStore.end())
|
||||
return;
|
||||
|
||||
const SpellCategorySet& ct_set = ct->second;
|
||||
for (SpellCooldowns::const_iterator i = m_spellCooldowns.begin(); i != m_spellCooldowns.end();)
|
||||
{
|
||||
if (ct_set.find(i->first) != ct_set.end())
|
||||
RemoveSpellCooldown((i++)->first, update);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void Player::RemoveArenaSpellCooldowns()
|
||||
{
|
||||
// remove cooldowns on spells that has < 15 min CD
|
||||
|
|
@ -3406,7 +3407,7 @@ void Player::_LoadSpellCooldowns(QueryResult *result)
|
|||
|
||||
if(!sSpellStore.LookupEntry(spell_id))
|
||||
{
|
||||
sLog.outError("Player %u have unknown spell %u in `character_spell_cooldown`, skipping.",GetGUIDLow(),spell_id);
|
||||
sLog.outError("Player %u has unknown spell %u in `character_spell_cooldown`, skipping.",GetGUIDLow(),spell_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -12524,7 +12525,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
|||
|
||||
for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i )
|
||||
{
|
||||
if ( pQuest->ReqItemId[i] )
|
||||
if (pQuest->ReqItemId[i])
|
||||
DestroyItemCount( pQuest->ReqItemId[i], pQuest->ReqItemCount[i], true);
|
||||
}
|
||||
|
||||
|
|
@ -12532,12 +12533,12 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
|||
// SetTimedQuest( 0 );
|
||||
m_timedquests.erase(pQuest->GetQuestId());
|
||||
|
||||
if ( pQuest->GetRewChoiceItemsCount() > 0 )
|
||||
if (pQuest->GetRewChoiceItemsCount() > 0)
|
||||
{
|
||||
if( pQuest->RewChoiceItemId[reward] )
|
||||
if (pQuest->RewChoiceItemId[reward])
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
if( CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] ) == EQUIP_ERR_OK )
|
||||
if (CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] ) == EQUIP_ERR_OK)
|
||||
{
|
||||
Item* item = StoreNewItem( dest, pQuest->RewChoiceItemId[reward], true);
|
||||
SendNewItem(item, pQuest->RewChoiceItemCount[reward], true, false);
|
||||
|
|
@ -12545,14 +12546,14 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
|||
}
|
||||
}
|
||||
|
||||
if ( pQuest->GetRewItemsCount() > 0 )
|
||||
if (pQuest->GetRewItemsCount() > 0)
|
||||
{
|
||||
for (uint32 i=0; i < pQuest->GetRewItemsCount(); ++i)
|
||||
{
|
||||
if( pQuest->RewItemId[i] )
|
||||
if (pQuest->RewItemId[i])
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
if( CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] ) == EQUIP_ERR_OK )
|
||||
if (CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] ) == EQUIP_ERR_OK)
|
||||
{
|
||||
Item* item = StoreNewItem( dest, pQuest->RewItemId[i], true);
|
||||
SendNewItem(item, pQuest->RewItemCount[i], true, false);
|
||||
|
|
@ -12563,13 +12564,8 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
|||
|
||||
RewardReputation( pQuest );
|
||||
|
||||
if( pQuest->GetRewSpellCast() > 0 )
|
||||
CastSpell( this, pQuest->GetRewSpellCast(), true);
|
||||
else if( pQuest->GetRewSpell() > 0)
|
||||
CastSpell( this, pQuest->GetRewSpell(), true);
|
||||
|
||||
uint16 log_slot = FindQuestSlot( quest_id );
|
||||
if( log_slot < MAX_QUEST_LOG_SIZE)
|
||||
if (log_slot < MAX_QUEST_LOG_SIZE)
|
||||
SetQuestSlot(log_slot,0);
|
||||
|
||||
QuestStatusData& q_status = mQuestStatus[quest_id];
|
||||
|
|
@ -12577,7 +12573,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
|||
// Not give XP in case already completed once repeatable quest
|
||||
uint32 XP = q_status.m_rewarded ? 0 : uint32(pQuest->XPValue( this )*sWorld.getRate(RATE_XP_QUEST));
|
||||
|
||||
if ( getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) )
|
||||
if (getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
GiveXP( XP , NULL );
|
||||
else
|
||||
{
|
||||
|
|
@ -12587,33 +12583,33 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
|||
}
|
||||
|
||||
// Give player extra money if GetRewOrReqMoney > 0 and get ReqMoney if negative
|
||||
if(pQuest->GetRewOrReqMoney())
|
||||
if (pQuest->GetRewOrReqMoney())
|
||||
{
|
||||
ModifyMoney( pQuest->GetRewOrReqMoney() );
|
||||
|
||||
if(pQuest->GetRewOrReqMoney() > 0)
|
||||
if (pQuest->GetRewOrReqMoney() > 0)
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD, pQuest->GetRewOrReqMoney());
|
||||
}
|
||||
|
||||
// honor reward
|
||||
if(pQuest->GetRewHonorableKills())
|
||||
if (pQuest->GetRewHonorableKills())
|
||||
RewardHonor(NULL, 0, MaNGOS::Honor::hk_honor_at_level(getLevel(), pQuest->GetRewHonorableKills()));
|
||||
|
||||
// title reward
|
||||
if(pQuest->GetCharTitleId())
|
||||
if (pQuest->GetCharTitleId())
|
||||
{
|
||||
if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId()))
|
||||
if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId()))
|
||||
SetTitle(titleEntry);
|
||||
}
|
||||
|
||||
if(pQuest->GetBonusTalents())
|
||||
if (pQuest->GetBonusTalents())
|
||||
{
|
||||
m_questRewardTalentCount+=pQuest->GetBonusTalents();
|
||||
InitTalentForLevel();
|
||||
}
|
||||
|
||||
// Send reward mail
|
||||
if(pQuest->GetRewMailTemplateId())
|
||||
if (pQuest->GetRewMailTemplateId())
|
||||
{
|
||||
MailMessageType mailType;
|
||||
uint32 senderGuidOrEntry;
|
||||
|
|
@ -12651,9 +12647,9 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
|||
uint32 max_slot = questMailLoot.GetMaxSlotInLootFor(this);
|
||||
for(uint32 i = 0; mi.size() < MAX_MAIL_ITEMS && i < max_slot; ++i)
|
||||
{
|
||||
if(LootItem* lootitem = questMailLoot.LootItemInSlot(i,this))
|
||||
if (LootItem* lootitem = questMailLoot.LootItemInSlot(i,this))
|
||||
{
|
||||
if(Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,this))
|
||||
if (Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,this))
|
||||
{
|
||||
item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
|
||||
mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item);
|
||||
|
|
@ -12664,23 +12660,30 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
|||
WorldSession::SendMailTo(this, mailType, MAIL_STATIONERY_NORMAL, senderGuidOrEntry, GetGUIDLow(), "", 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE,pQuest->GetRewMailDelaySecs(),pQuest->GetRewMailTemplateId());
|
||||
}
|
||||
|
||||
if(pQuest->IsDaily())
|
||||
if (pQuest->IsDaily())
|
||||
{
|
||||
SetDailyQuestStatus(quest_id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, 1);
|
||||
}
|
||||
|
||||
if ( !pQuest->IsRepeatable() )
|
||||
if (!pQuest->IsRepeatable())
|
||||
SetQuestStatus(quest_id, QUEST_STATUS_COMPLETE);
|
||||
else
|
||||
SetQuestStatus(quest_id, QUEST_STATUS_NONE);
|
||||
|
||||
q_status.m_rewarded = true;
|
||||
if (q_status.uState != QUEST_NEW)
|
||||
q_status.uState = QUEST_CHANGED;
|
||||
|
||||
if(announce)
|
||||
if (announce)
|
||||
SendQuestReward( pQuest, XP, questGiver );
|
||||
|
||||
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
||||
// cast spells after mark quest complete (some spells have quest completed state reqyurements in spell_area data)
|
||||
if (pQuest->GetRewSpellCast() > 0)
|
||||
CastSpell( this, pQuest->GetRewSpellCast(), true);
|
||||
else if ( pQuest->GetRewSpell() > 0)
|
||||
CastSpell( this, pQuest->GetRewSpell(), true);
|
||||
|
||||
if (pQuest->GetZoneOrSort() > 0)
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE, pQuest->GetZoneOrSort());
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT);
|
||||
|
|
@ -14028,7 +14031,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
m_name = fields[3].GetCppString();
|
||||
|
||||
// check name limitations
|
||||
if(!ObjectMgr::IsValidName(m_name) || (GetSession()->GetSecurity() == SEC_PLAYER && objmgr.IsReservedName(m_name)))
|
||||
if (ObjectMgr::CheckPlayerName(m_name) != CHAR_NAME_SUCCESS ||
|
||||
GetSession()->GetSecurity() == SEC_PLAYER && objmgr.IsReservedName(m_name))
|
||||
{
|
||||
delete result;
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'", uint32(AT_LOGIN_RENAME),guid);
|
||||
|
|
@ -14060,6 +14064,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
SetUInt32Value(PLAYER_BYTES_3, (GetUInt32Value(PLAYER_BYTES_3) & ~1) | fields[6].GetUInt8());
|
||||
SetUInt32Value(PLAYER_FLAGS, fields[12].GetUInt32());
|
||||
|
||||
InitDisplayIds();
|
||||
|
||||
// cleanup inventory related item value fields (its will be filled correctly in _LoadInventory)
|
||||
for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||
{
|
||||
|
|
@ -14921,7 +14927,7 @@ void Player::_LoadMailedItems(Mail *mail)
|
|||
|
||||
if(!proto)
|
||||
{
|
||||
sLog.outError( "Player %u have unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID);
|
||||
sLog.outError( "Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID);
|
||||
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
||||
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid_low);
|
||||
continue;
|
||||
|
|
@ -15514,7 +15520,6 @@ void Player::SaveToDB()
|
|||
SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND);
|
||||
SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
SetDisplayId(GetNativeDisplayId());
|
||||
|
||||
bool inworld = IsInWorld();
|
||||
|
||||
|
|
@ -15659,7 +15664,6 @@ void Player::SaveToDB()
|
|||
CharacterDatabase.CommitTransaction();
|
||||
|
||||
// restore state (before aura apply, if aura remove flag then aura must set it ack by self)
|
||||
SetDisplayId(tmp_displayid);
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_1, tmp_bytes);
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_2, tmp_bytes2);
|
||||
SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags);
|
||||
|
|
@ -16103,28 +16107,17 @@ void Player::SetFloatValueInDB(uint16 index, float value, uint64 guid)
|
|||
|
||||
void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair)
|
||||
{
|
||||
// 0 1 2 3 4
|
||||
QueryResult* result = CharacterDatabase.PQuery("SELECT data, race, class, playerBytes, playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
// 0
|
||||
QueryResult* result = CharacterDatabase.PQuery("SELECT playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
if(!result)
|
||||
return;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
Tokens tokens = StrSplit(fields[0].GetString(), " ");
|
||||
|
||||
PlayerInfo const* info = objmgr.GetPlayerInfo(fields[1].GetUInt8(), fields[2].GetUInt8());
|
||||
if(!info)
|
||||
return;
|
||||
|
||||
// TODO: do not access data field here
|
||||
SetUInt32ValueInArray(tokens, UNIT_FIELD_DISPLAYID, gender ? info->displayId_f : info->displayId_m);
|
||||
SetUInt32ValueInArray(tokens, UNIT_FIELD_NATIVEDISPLAYID, gender ? info->displayId_f : info->displayId_m);
|
||||
|
||||
uint32 player_bytes2 = fields[4].GetUInt32();
|
||||
uint32 player_bytes2 = fields[0].GetUInt32();
|
||||
player_bytes2 &= ~0xFF;
|
||||
player_bytes2 |= facialHair;
|
||||
|
||||
SaveValuesArrayInDB(tokens, guid);
|
||||
CharacterDatabase.PExecute("UPDATE characters SET gender = '%u', playerBytes = '%u', playerBytes2 = '%u' WHERE guid = '%u'", gender, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24), player_bytes2, GUID_LOPART(guid));
|
||||
|
||||
delete result;
|
||||
|
|
@ -16379,9 +16372,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
|
|||
|
||||
if(pet->isControlled())
|
||||
{
|
||||
WorldPacket data(SMSG_PET_SPELLS, 8);
|
||||
data << uint64(0);
|
||||
GetSession()->SendPacket(&data);
|
||||
RemovePetActionBar();
|
||||
|
||||
if(GetGroup())
|
||||
SetGroupUpdateFlag(GROUP_UPDATE_PET);
|
||||
|
|
@ -16643,6 +16634,13 @@ void Player::CharmSpellInitialize()
|
|||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void Player::RemovePetActionBar()
|
||||
{
|
||||
WorldPacket data(SMSG_PET_SPELLS, 8);
|
||||
data << uint64(0);
|
||||
SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
bool Player::IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell)
|
||||
{
|
||||
if (!mod || !spellInfo)
|
||||
|
|
@ -17156,17 +17154,43 @@ void Player::InitDataForForm(bool reapplyMods)
|
|||
UpdateAttackPowerAndDamage(true);
|
||||
}
|
||||
|
||||
void Player::InitDisplayIds()
|
||||
{
|
||||
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass());
|
||||
if(!info)
|
||||
{
|
||||
sLog.outError("Player %u has incorrect race/class pair. Can't init display ids.", GetGUIDLow());
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 gender = getGender();
|
||||
switch(gender)
|
||||
{
|
||||
case GENDER_FEMALE:
|
||||
SetDisplayId(info->displayId_f );
|
||||
SetNativeDisplayId(info->displayId_f );
|
||||
break;
|
||||
case GENDER_MALE:
|
||||
SetDisplayId(info->displayId_m );
|
||||
SetNativeDisplayId(info->displayId_m );
|
||||
break;
|
||||
default:
|
||||
sLog.outError("Invalid gender %u for player",gender);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Return true is the bought item has a max count to force refresh of window by caller
|
||||
bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot)
|
||||
bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot)
|
||||
{
|
||||
// cheating attempt
|
||||
if(count < 1) count = 1;
|
||||
if (count < 1) count = 1;
|
||||
|
||||
if(!isAlive())
|
||||
if (!isAlive())
|
||||
return false;
|
||||
|
||||
ItemPrototype const *pProto = objmgr.GetItemPrototype( item );
|
||||
if( !pProto )
|
||||
if (!pProto)
|
||||
{
|
||||
SendBuyError( BUY_ERR_CANT_FIND_ITEM, NULL, item, 0);
|
||||
return false;
|
||||
|
|
@ -17188,7 +17212,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
|||
}
|
||||
|
||||
size_t vendor_slot = vItems->FindItemSlot(item);
|
||||
if(vendor_slot >= vItems->GetItemCount())
|
||||
if (vendor_slot >= vItems->GetItemCount())
|
||||
{
|
||||
SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0);
|
||||
return false;
|
||||
|
|
@ -17197,39 +17221,39 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
|||
VendorItem const* crItem = vItems->m_items[vendor_slot];
|
||||
|
||||
// check current item amount if it limited
|
||||
if( crItem->maxcount != 0 )
|
||||
if (crItem->maxcount != 0)
|
||||
{
|
||||
if(pCreature->GetVendorItemCurrentCount(crItem) < pProto->BuyCount * count )
|
||||
if (pCreature->GetVendorItemCurrentCount(crItem) < pProto->BuyCount * count )
|
||||
{
|
||||
SendBuyError( BUY_ERR_ITEM_ALREADY_SOLD, pCreature, item, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if( uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank)
|
||||
if (uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank)
|
||||
{
|
||||
SendBuyError( BUY_ERR_REPUTATION_REQUIRE, pCreature, item, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(crItem->ExtendedCost)
|
||||
if (crItem->ExtendedCost)
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
if(!iece)
|
||||
if (!iece)
|
||||
{
|
||||
sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
|
||||
return false;
|
||||
}
|
||||
|
||||
// honor points price
|
||||
if(GetHonorPoints() < (iece->reqhonorpoints * count))
|
||||
if (GetHonorPoints() < (iece->reqhonorpoints * count))
|
||||
{
|
||||
SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// arena points price
|
||||
if(GetArenaPoints() < (iece->reqarenapoints * count))
|
||||
if (GetArenaPoints() < (iece->reqarenapoints * count))
|
||||
{
|
||||
SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL);
|
||||
return false;
|
||||
|
|
@ -17259,62 +17283,38 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
|||
// reputation discount
|
||||
price = uint32(floor(price * GetReputationPriceDiscount(pCreature)));
|
||||
|
||||
if( GetMoney() < price )
|
||||
if (GetMoney() < price)
|
||||
{
|
||||
SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, item, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8 bag = 0; // init for case invalid bagGUID
|
||||
|
||||
if (bagguid != NULL_BAG && slot != NULL_SLOT)
|
||||
{
|
||||
if( bagguid == GetGUID() )
|
||||
{
|
||||
bag = INVENTORY_SLOT_BAG_0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END;++i)
|
||||
{
|
||||
if( Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0,i) )
|
||||
{
|
||||
if( bagguid == pBag->GetGUID() )
|
||||
{
|
||||
bag = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( IsInventoryPos( bag, slot ) || (bagguid == NULL_BAG && slot == NULL_SLOT) )
|
||||
if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot))
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanStoreNewItem( bag, slot, dest, item, pProto->BuyCount * count );
|
||||
if( msg != EQUIP_ERR_OK )
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError( msg, NULL, NULL );
|
||||
return false;
|
||||
}
|
||||
|
||||
ModifyMoney( -(int32)price );
|
||||
if(crItem->ExtendedCost) // case for new honor system
|
||||
if (crItem->ExtendedCost) // case for new honor system
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
if(iece->reqhonorpoints)
|
||||
if (iece->reqhonorpoints)
|
||||
ModifyHonorPoints( - int32(iece->reqhonorpoints * count));
|
||||
if(iece->reqarenapoints)
|
||||
if (iece->reqarenapoints)
|
||||
ModifyArenaPoints( - int32(iece->reqarenapoints * count));
|
||||
for (uint8 i = 0; i < 5; ++i)
|
||||
{
|
||||
if(iece->reqitem[i])
|
||||
if (iece->reqitem[i])
|
||||
DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true);
|
||||
}
|
||||
}
|
||||
|
||||
if(Item *it = StoreNewItem( dest, item, true ))
|
||||
if (Item *it = StoreNewItem( dest, item, true ))
|
||||
{
|
||||
uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count);
|
||||
|
||||
|
|
@ -17328,9 +17328,9 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
|||
SendNewItem(it, pProto->BuyCount*count, true, false, false);
|
||||
}
|
||||
}
|
||||
else if( IsEquipmentPos( bag, slot ) )
|
||||
else if (IsEquipmentPos(bag, slot))
|
||||
{
|
||||
if(pProto->BuyCount * count != 1)
|
||||
if (pProto->BuyCount * count != 1)
|
||||
{
|
||||
SendEquipError( EQUIP_ERR_ITEM_CANT_BE_EQUIPPED, NULL, NULL );
|
||||
return false;
|
||||
|
|
@ -17338,19 +17338,19 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
|||
|
||||
uint16 dest;
|
||||
uint8 msg = CanEquipNewItem( slot, dest, item, false );
|
||||
if( msg != EQUIP_ERR_OK )
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
SendEquipError( msg, NULL, NULL );
|
||||
return false;
|
||||
}
|
||||
|
||||
ModifyMoney( -(int32)price );
|
||||
if(crItem->ExtendedCost) // case for new honor system
|
||||
if (crItem->ExtendedCost) // case for new honor system
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
if(iece->reqhonorpoints)
|
||||
if (iece->reqhonorpoints)
|
||||
ModifyHonorPoints( - int32(iece->reqhonorpoints));
|
||||
if(iece->reqarenapoints)
|
||||
if (iece->reqarenapoints)
|
||||
ModifyArenaPoints( - int32(iece->reqarenapoints));
|
||||
for (uint8 i = 0; i < 5; ++i)
|
||||
{
|
||||
|
|
@ -17359,7 +17359,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
|||
}
|
||||
}
|
||||
|
||||
if(Item *it = EquipNewItem( dest, item, true ))
|
||||
if (Item *it = EquipNewItem( dest, item, true ))
|
||||
{
|
||||
uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count);
|
||||
|
||||
|
|
@ -17381,7 +17381,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
|||
return false;
|
||||
}
|
||||
|
||||
return crItem->maxcount!=0;
|
||||
return crItem->maxcount != 0;
|
||||
}
|
||||
|
||||
uint32 Player::GetMaxPersonalArenaRatingRequirement()
|
||||
|
|
@ -19394,7 +19394,7 @@ void Player::EnterVehicle(Vehicle *vehicle)
|
|||
|
||||
vehicle->SetCharmerGUID(GetGUID());
|
||||
vehicle->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
|
||||
vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
|
||||
vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
vehicle->setFaction(getFaction());
|
||||
|
||||
SetCharm(vehicle); // charm
|
||||
|
|
@ -19446,7 +19446,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
|
|||
{
|
||||
vehicle->SetCharmerGUID(0);
|
||||
vehicle->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
|
||||
vehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
|
||||
vehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H);
|
||||
|
||||
SetCharm(NULL);
|
||||
|
|
@ -19468,9 +19468,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
|
|||
data << uint32(0); // fall time
|
||||
GetSession()->SendPacket(&data);
|
||||
|
||||
data.Initialize(SMSG_PET_SPELLS, 8);
|
||||
data << uint64(0);
|
||||
GetSession()->SendPacket(&data);
|
||||
RemovePetActionBar();
|
||||
|
||||
// maybe called at dummy aura remove?
|
||||
// CastSpell(this, 45472, true); // Parachute
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue