Small code cleanup and partial merge with dev branch

This commit is contained in:
tomrus88 2009-03-21 19:07:38 +03:00
parent 3c7c5ba8d4
commit 28dc20c6e2
18 changed files with 371 additions and 468 deletions

View file

@ -635,6 +635,11 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );
}
data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4+4);
data << uint32(0);
data << uint32(0);
SendPacket(&data);
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
@ -754,7 +759,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
if(uint32 sourceNode = pCurrChar->m_taxi.GetTaxiSource())
{
sLog.outDebug( "WORLD: Restart character %u taxi flight", pCurrChar->GetGUIDLow() );
uint32 MountId = objmgr.GetTaxiMount(sourceNode, pCurrChar->GetTeam());
@ -1206,20 +1210,21 @@ void WorldSession::HandleRemoveGlyph( WorldPacket & recv_data )
uint32 slot;
recv_data >> slot;
if(slot > MAX_GLYPH_SLOT_INDEX)
if(slot < MAX_GLYPH_SLOT_INDEX)
{
sLog.outDebug("Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot);
if(uint32 glyph = _player->GetGlyph(slot))
{
if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph))
{
_player->RemoveAurasDueToSpell(gp->SpellId);
_player->SetGlyph(slot, 0);
}
}
return;
}
if(uint32 glyph = _player->GetGlyph(slot))
{
if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph))
{
_player->RemoveAurasDueToSpell(gp->SpellId);
_player->SetGlyph(slot, 0);
}
}
sLog.outDebug("Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot);
}
void WorldSession::HandleCharCustomize(WorldPacket& recv_data)

View file

@ -133,6 +133,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "arena", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugArenaCommand, "", NULL },
{ "bg", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugBattlegroundCommand, "", NULL },
{ "sendlargepacket",SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendLargePacketCommand, "", NULL },
{ "setitemflag", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemFlagCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};

View file

@ -452,6 +452,7 @@ class ChatHandler
bool HandleDebugSpawnVehicle(const char * args);
bool HandleDebugSendLargePacketCommand(const char * args);
bool HandleDebugSendSetPhaseShiftCommand(const char * args);
bool HandleDebugSetItemFlagCommand(const char * args);
Player* getSelectedPlayer();
Creature* getSelectedCreature();

View file

@ -105,6 +105,7 @@ enum ITEM_FLAGS
ITEM_FLAGS_CONJURED = 0x00000002,
ITEM_FLAGS_OPENABLE = 0x00000004,
ITEM_FLAGS_WRAPPED = 0x00000008,
ITEM_FLAGS_BROKEN = 0x00000010, // appears red icon (like when item durability==0)
ITEM_FLAGS_WRAPPER = 0x00000200, // used or not used wrapper
ITEM_FLAGS_PARTY_LOOT = 0x00000800, // determines if item is party loot or not
ITEM_FLAGS_CHARTER = 0x00002000, // arena/guild charter

View file

@ -902,7 +902,7 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
if(decompressedSize == 0) // erase
{
SetAccountData(type, timestamp, "");
SetAccountData(type, 0, "");
WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4);
data << uint32(type);
@ -1002,7 +1002,7 @@ void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data)
}
else if(type==ACTION_BUTTON_SPELL)
{
sLog.outDetail( "MISC: Added Action %u into button %u", action, button );
sLog.outDetail( "MISC: Added Spell %u into button %u", action, button );
GetPlayer()->addActionButton(button,action,type,misc);
}
else if(type==ACTION_BUTTON_ITEM)

View file

@ -658,7 +658,6 @@ void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, Dec
void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data )
{
sLog.outDebug("WORLD: CMSG_PET_LEARN_TALENT");
recv_data.hexlike();
CHECK_PACKET_SIZE(recv_data, 8+4+4);
@ -666,117 +665,5 @@ void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data )
uint32 talent_id, requested_rank;
recv_data >> guid >> talent_id >> requested_rank;
Pet *pet = _player->GetPet();
if(!pet)
return;
if(guid != pet->GetGUID())
return;
uint32 CurTalentPoints = pet->GetFreeTalentPoints();
if(CurTalentPoints == 0)
return;
if (requested_rank > 4)
return;
TalentEntry const *talentInfo = sTalentStore.LookupEntry(talent_id);
if(!talentInfo)
return;
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
if(!talentTabInfo)
return;
CreatureInfo const *ci = pet->GetCreatureInfo();
if(!ci)
return;
CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
if(!pet_family)
return;
if(pet_family->petTalentType < 0) // not hunter pet
return;
// prevent learn talent for different family (cheating)
if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
return;
// prevent skip talent ranks (cheating)
if(requested_rank > 0 && !pet->HasSpell(talentInfo->RankID[requested_rank-1]))
return;
// Check if it requires another talent
if (talentInfo->DependsOn > 0)
{
if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
{
bool hasEnoughRank = false;
for (int i = talentInfo->DependsOnRank; i <= 4; i++)
{
if (depTalentInfo->RankID[i] != 0)
if (pet->HasSpell(depTalentInfo->RankID[i]))
hasEnoughRank = true;
}
if (!hasEnoughRank)
return;
}
}
// Find out how many points we have in this field
uint32 spentPoints = 0;
uint32 tTab = talentInfo->TalentTab;
if (talentInfo->Row > 0)
{
unsigned int numRows = sTalentStore.GetNumRows();
for (unsigned int i = 0; i < numRows; i++) // Loop through all talents.
{
// Someday, someone needs to revamp
const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i);
if (tmpTalent) // the way talents are tracked
{
if (tmpTalent->TalentTab == tTab)
{
for (int j = 0; j <= 4; j++)
{
if (tmpTalent->RankID[j] != 0)
{
if (pet->HasSpell(tmpTalent->RankID[j]))
{
spentPoints += j + 1;
}
}
}
}
}
}
}
// not have required min points spent in talent tree
if(spentPoints < (talentInfo->Row * 3))
return;
// spell not set in talent.dbc
uint32 spellid = talentInfo->RankID[requested_rank];
if( spellid == 0 )
{
sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talent_id, requested_rank);
return;
}
// already known
if(pet->HasSpell(spellid))
return;
// learn! (other talent ranks will unlearned at learning)
pet->learnSpell(spellid);
sLog.outDetail("TalentID: %u Rank: %u Spell: %u", talent_id, requested_rank, spellid);
_player->LearnPetTalent(guid, talent_id, requested_rank);
}

View file

@ -3196,7 +3196,7 @@ void Player::RemoveArenaSpellCooldowns()
// notify player
WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8));
data << uint32(itr->first);
data << GetGUID();
data << uint64(GetGUID());
GetSession()->SendPacket(&data);
// remove cooldown
m_spellCooldowns.erase(itr);
@ -6026,12 +6026,9 @@ bool Player::SetOneFactionReputation(FactionEntry const* factionEntry, int32 sta
//Calculate total reputation percent player gain with quest/creature level
int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest)
{
// for grey creature kill received 20%, in other case 100.
int32 percent = (!for_quest && (creatureOrQuestLevel <= MaNGOS::XP::GetGrayLevel(getLevel()))) ? 20 : 100;
int32 repMod = GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN);
percent += rep > 0 ? repMod : -repMod;
int32 percent = rep > 0 ? repMod : -repMod;
if(percent <=0)
return 0;
@ -8332,10 +8329,10 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
slots[0] = EQUIPMENT_SLOT_RANGED;
break;
case INVTYPE_BAG:
slots[0] = INVENTORY_SLOT_BAG_1;
slots[1] = INVENTORY_SLOT_BAG_2;
slots[2] = INVENTORY_SLOT_BAG_3;
slots[3] = INVENTORY_SLOT_BAG_4;
slots[0] = INVENTORY_SLOT_BAG_START + 0;
slots[1] = INVENTORY_SLOT_BAG_START + 1;
slots[2] = INVENTORY_SLOT_BAG_START + 2;
slots[3] = INVENTORY_SLOT_BAG_START + 3;
break;
case INVTYPE_RELIC:
{
@ -9336,8 +9333,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
}
}
// Vanity pet case skipped as not used
/* until proper implementation
else if(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
{
@ -9360,28 +9355,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
}
}
*/
/* until proper implementation
else if(pProto->BagFamily & BAG_FAMILY_MASK_QUEST_ITEMS)
{
res = _CanStoreItem_InInventorySlots(QUESTBAG_SLOT_START,QUESTBAG_SLOT_END,dest,pProto,count,false,pItem,bag,slot);
if(res!=EQUIP_ERR_OK)
{
if(no_space_count)
*no_space_count = count + no_similar_count;
return res;
}
if(count==0)
{
if(no_similar_count==0)
return EQUIP_ERR_OK;
if(no_space_count)
*no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
}
*/
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot);
if(res!=EQUIP_ERR_OK)
@ -9530,8 +9503,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
}
}
// Vanity pet case skipped as not used
/* until proper implementation
else if(false pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
{
@ -9554,28 +9525,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
}
}
*/
/* until proper implementation
else if(false pProto->BagFamily & BAG_FAMILY_MASK_QUEST_ITEMS)
{
res = _CanStoreItem_InInventorySlots(QUESTBAG_SLOT_START,QUESTBAG_SLOT_END,dest,pProto,count,false,pItem,bag,slot);
if(res!=EQUIP_ERR_OK)
{
if(no_space_count)
*no_space_count = count + no_similar_count;
return res;
}
if(count==0)
{
if(no_similar_count==0)
return EQUIP_ERR_OK;
if(no_space_count)
*no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
}
*/
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
{
@ -9647,13 +9596,11 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
int inv_bags[INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START][MAX_BAG_SIZE];
int inv_keys[KEYRING_SLOT_END-KEYRING_SLOT_START];
int inv_tokens[CURRENCYTOKEN_SLOT_END-CURRENCYTOKEN_SLOT_START];
int inv_quests[QUESTBAG_SLOT_END-QUESTBAG_SLOT_START];
memset(inv_slot_items,0,sizeof(int)*(INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START));
memset(inv_bags,0,sizeof(int)*(INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START)*MAX_BAG_SIZE);
memset(inv_keys,0,sizeof(int)*(KEYRING_SLOT_END-KEYRING_SLOT_START));
memset(inv_tokens,0,sizeof(int)*(CURRENCYTOKEN_SLOT_END-CURRENCYTOKEN_SLOT_START));
memset(inv_quests,0,sizeof(int)*(QUESTBAG_SLOT_END-QUESTBAG_SLOT_START));
for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++)
{
@ -9675,8 +9622,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
}
}
// Vanity pet case skipped as not used
for(int i = CURRENCYTOKEN_SLOT_START; i < CURRENCYTOKEN_SLOT_END; i++)
{
pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
@ -9687,16 +9632,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
}
}
for(int i = QUESTBAG_SLOT_START; i < QUESTBAG_SLOT_END; i++)
{
pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
if (pItem2 && !pItem2->IsInTrade())
{
inv_quests[i-QUESTBAG_SLOT_START] = pItem2->GetCount();
}
}
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
{
if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
@ -9756,8 +9691,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
}
if (b_found) continue;
// Vanity pet case skipped as not used
for(int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; t++)
{
pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t );
@ -9770,18 +9703,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
}
if (b_found) continue;
for(int t = QUESTBAG_SLOT_START; t < QUESTBAG_SLOT_END; t++)
{
pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t );
if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_quests[t-QUESTBAG_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize())
{
inv_quests[t-QUESTBAG_SLOT_START] += pItem->GetCount();
b_found = true;
break;
}
}
if (b_found) continue;
for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++)
{
pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t );
@ -9834,8 +9755,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
if (b_found) continue;
// Vanity pet case skipped as not used
/* until proper implementation
if(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
{
@ -9850,22 +9769,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const
}
}
if (b_found) continue;
*/
/* until proper implementation
if(pProto->BagFamily & BAG_FAMILY_MASK_QUEST_ITEMS)
{
for(uint32 t = QUESTBAG_SLOT_START; t < QUESTBAG_SLOT_END; ++t)
{
if( inv_quests[t-QUESTBAG_SLOT_START] == 0 )
{
inv_quests[t-QUESTBAG_SLOT_START] = 1;
b_found = true;
break;
}
}
}
if (b_found) continue;
*/
@ -10983,6 +10886,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
}
}
}
for(int i = KEYRING_SLOT_START; i < QUESTBAG_SLOT_END; i++)
{
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
@ -14862,7 +14766,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
void Player::_LoadGlyphAuras()
{
for (uint8 i = 0; i <= MAX_GLYPH_SLOT_INDEX; ++i)
for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i)
{
if (uint32 glyph = GetGlyph(i))
{
@ -16646,7 +16550,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
if(pet->isControlled())
{
WorldPacket data(SMSG_PET_SPELLS, 8);
WorldPacket data(SMSG_PET_SPELLS, 8+4);
data << uint64(0);
data << uint32(0);
GetSession()->SendPacket(&data);
@ -16878,7 +16782,7 @@ void Player::PossessSpellInitialize()
data << uint64(charm->GetGUID());
data << uint32(0x00000000);
data << uint32(0);
data << uint8(0) << uint8(0) << uint16(0);
data << uint32(0);
for(uint32 i = 0; i < 10; i++) //40
{
@ -18360,10 +18264,6 @@ void Player::SendInitialPacketsBeforeAddToMap()
data << (float)0.01666667f; // game speed
GetSession()->SendPacket( &data );
data.Initialize(SMSG_TIME_SYNC_REQ, 4); // new 2.0.x, enable movement
data << uint32(0x00000000); // on blizz it increments periodically
GetSession()->SendPacket(&data);
// set fly flag if in fly form or taxi flight to prevent visually drop at ground in showup moment
if(HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || isInFlight())
AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
@ -20008,3 +19908,252 @@ void Player::UpdateAchievementCriteria( AchievementCriteriaTypes type, uint32 mi
{
GetAchievementMgr().UpdateAchievementCriteria(type, miscvalue1,miscvalue2,unit,time);
}
void Player::LearnTalent(uint32 talentId, uint32 talentRank)
{
uint32 CurTalentPoints = GetFreeTalentPoints();
if(CurTalentPoints == 0)
return;
if (talentRank > 4)
return;
TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentId );
if(!talentInfo)
return;
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab );
if(!talentTabInfo)
return;
// prevent learn talent for different class (cheating)
if( (getClassMask() & talentTabInfo->ClassMask) == 0 )
return;
// find current max talent rank
int32 curtalent_maxrank = 0;
for(int32 k = 4; k > -1; --k)
{
if(talentInfo->RankID[k] && HasSpell(talentInfo->RankID[k]))
{
curtalent_maxrank = k + 1;
break;
}
}
// we already have same or higher talent rank learned
if(curtalent_maxrank >= (talentRank + 1))
return;
// check if we have enough talent points
if(CurTalentPoints < (talentRank - curtalent_maxrank + 1))
return;
// Check if it requires another talent
if (talentInfo->DependsOn > 0)
{
if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
{
bool hasEnoughRank = false;
for (int i = talentInfo->DependsOnRank; i <= 4; i++)
{
if (depTalentInfo->RankID[i] != 0)
if (HasSpell(depTalentInfo->RankID[i]))
hasEnoughRank = true;
}
if (!hasEnoughRank)
return;
}
}
// Find out how many points we have in this field
uint32 spentPoints = 0;
uint32 tTab = talentInfo->TalentTab;
if (talentInfo->Row > 0)
{
unsigned int numRows = sTalentStore.GetNumRows();
for (unsigned int i = 0; i < numRows; i++) // Loop through all talents.
{
// Someday, someone needs to revamp
const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i);
if (tmpTalent) // the way talents are tracked
{
if (tmpTalent->TalentTab == tTab)
{
for (int j = 0; j <= 4; j++)
{
if (tmpTalent->RankID[j] != 0)
{
if (HasSpell(tmpTalent->RankID[j]))
{
spentPoints += j + 1;
}
}
}
}
}
}
}
// not have required min points spent in talent tree
if(spentPoints < (talentInfo->Row * 5))
return;
// spell not set in talent.dbc
uint32 spellid = talentInfo->RankID[talentRank];
if( spellid == 0 )
{
sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talentId, talentRank);
return;
}
// already known
if(HasSpell(spellid))
return;
// learn! (other talent ranks will unlearned at learning)
learnSpell(spellid, false);
sLog.outDetail("TalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid);
// update free talent points
SetFreeTalentPoints(CurTalentPoints - (talentRank - curtalent_maxrank + 1));
}
void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
{
Pet *pet = GetPet();
if(!pet)
return;
if(petGuid != pet->GetGUID())
return;
uint32 CurTalentPoints = pet->GetFreeTalentPoints();
if(CurTalentPoints == 0)
return;
if (talentRank > 2)
return;
TalentEntry const *talentInfo = sTalentStore.LookupEntry(talentId);
if(!talentInfo)
return;
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
if(!talentTabInfo)
return;
CreatureInfo const *ci = pet->GetCreatureInfo();
if(!ci)
return;
CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
if(!pet_family)
return;
if(pet_family->petTalentType < 0) // not hunter pet
return;
// prevent learn talent for different family (cheating)
if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
return;
// find current max talent rank
int32 curtalent_maxrank = 0;
for(int32 k = 4; k > -1; --k)
{
if(talentInfo->RankID[k] && pet->HasSpell(talentInfo->RankID[k]))
{
curtalent_maxrank = k + 1;
break;
}
}
// we already have same or higher talent rank learned
if(curtalent_maxrank >= (talentRank + 1))
return;
// check if we have enough talent points
if(CurTalentPoints < (talentRank - curtalent_maxrank + 1))
return;
// Check if it requires another talent
if (talentInfo->DependsOn > 0)
{
if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
{
bool hasEnoughRank = false;
for (int i = talentInfo->DependsOnRank; i <= 4; i++)
{
if (depTalentInfo->RankID[i] != 0)
if (pet->HasSpell(depTalentInfo->RankID[i]))
hasEnoughRank = true;
}
if (!hasEnoughRank)
return;
}
}
// Find out how many points we have in this field
uint32 spentPoints = 0;
uint32 tTab = talentInfo->TalentTab;
if (talentInfo->Row > 0)
{
unsigned int numRows = sTalentStore.GetNumRows();
for (unsigned int i = 0; i < numRows; ++i) // Loop through all talents.
{
// Someday, someone needs to revamp
const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i);
if (tmpTalent) // the way talents are tracked
{
if (tmpTalent->TalentTab == tTab)
{
for (int j = 0; j <= 4; j++)
{
if (tmpTalent->RankID[j] != 0)
{
if (pet->HasSpell(tmpTalent->RankID[j]))
{
spentPoints += j + 1;
}
}
}
}
}
}
}
// not have required min points spent in talent tree
if(spentPoints < (talentInfo->Row * 3))
return;
// spell not set in talent.dbc
uint32 spellid = talentInfo->RankID[talentRank];
if( spellid == 0 )
{
sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talentId, talentRank);
return;
}
// already known
if(pet->HasSpell(spellid))
return;
// learn! (other talent ranks will unlearned at learning)
pet->learnSpell(spellid);
sLog.outDetail("TalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid);
// update free talent points
pet->SetFreeTalentPoints(CurTalentPoints - (talentRank - curtalent_maxrank + 1));
}

View file

@ -562,7 +562,9 @@ enum PlayerSlots
PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START)
};
enum EquipmentSlots
#define INVENTORY_SLOT_BAG_0 255
enum EquipmentSlots // 19 slots
{
EQUIPMENT_SLOT_START = 0,
EQUIPMENT_SLOT_HEAD = 0,
@ -587,118 +589,56 @@ enum EquipmentSlots
EQUIPMENT_SLOT_END = 19
};
enum InventorySlots
enum InventorySlots // 4 slots
{
INVENTORY_SLOT_BAG_0 = 255,
INVENTORY_SLOT_BAG_START = 19,
INVENTORY_SLOT_BAG_1 = 19,
INVENTORY_SLOT_BAG_2 = 20,
INVENTORY_SLOT_BAG_3 = 21,
INVENTORY_SLOT_BAG_4 = 22,
INVENTORY_SLOT_BAG_END = 23,
INVENTORY_SLOT_BAG_END = 23
};
enum InventoryPackSlots // 16 slots
{
INVENTORY_SLOT_ITEM_START = 23,
INVENTORY_SLOT_ITEM_1 = 23,
INVENTORY_SLOT_ITEM_2 = 24,
INVENTORY_SLOT_ITEM_3 = 25,
INVENTORY_SLOT_ITEM_4 = 26,
INVENTORY_SLOT_ITEM_5 = 27,
INVENTORY_SLOT_ITEM_6 = 28,
INVENTORY_SLOT_ITEM_7 = 29,
INVENTORY_SLOT_ITEM_8 = 30,
INVENTORY_SLOT_ITEM_9 = 31,
INVENTORY_SLOT_ITEM_10 = 32,
INVENTORY_SLOT_ITEM_11 = 33,
INVENTORY_SLOT_ITEM_12 = 34,
INVENTORY_SLOT_ITEM_13 = 35,
INVENTORY_SLOT_ITEM_14 = 36,
INVENTORY_SLOT_ITEM_15 = 37,
INVENTORY_SLOT_ITEM_16 = 38,
INVENTORY_SLOT_ITEM_END = 39
};
enum BankSlots
enum BankItemSlots // 28 slots
{
BANK_SLOT_ITEM_START = 39,
BANK_SLOT_ITEM_1 = 39,
BANK_SLOT_ITEM_2 = 40,
BANK_SLOT_ITEM_3 = 41,
BANK_SLOT_ITEM_4 = 42,
BANK_SLOT_ITEM_5 = 43,
BANK_SLOT_ITEM_6 = 44,
BANK_SLOT_ITEM_7 = 45,
BANK_SLOT_ITEM_8 = 46,
BANK_SLOT_ITEM_9 = 47,
BANK_SLOT_ITEM_10 = 48,
BANK_SLOT_ITEM_11 = 49,
BANK_SLOT_ITEM_12 = 50,
BANK_SLOT_ITEM_13 = 51,
BANK_SLOT_ITEM_14 = 52,
BANK_SLOT_ITEM_15 = 53,
BANK_SLOT_ITEM_16 = 54,
BANK_SLOT_ITEM_17 = 55,
BANK_SLOT_ITEM_18 = 56,
BANK_SLOT_ITEM_19 = 57,
BANK_SLOT_ITEM_20 = 58,
BANK_SLOT_ITEM_21 = 59,
BANK_SLOT_ITEM_22 = 60,
BANK_SLOT_ITEM_23 = 61,
BANK_SLOT_ITEM_24 = 62,
BANK_SLOT_ITEM_25 = 63,
BANK_SLOT_ITEM_26 = 64,
BANK_SLOT_ITEM_27 = 65,
BANK_SLOT_ITEM_28 = 66,
BANK_SLOT_ITEM_END = 67,
BANK_SLOT_ITEM_END = 67
};
enum BankBagSlots // 7 slots
{
BANK_SLOT_BAG_START = 67,
BANK_SLOT_BAG_1 = 67,
BANK_SLOT_BAG_2 = 68,
BANK_SLOT_BAG_3 = 69,
BANK_SLOT_BAG_4 = 70,
BANK_SLOT_BAG_5 = 71,
BANK_SLOT_BAG_6 = 72,
BANK_SLOT_BAG_7 = 73,
BANK_SLOT_BAG_END = 74
};
enum BuyBackSlots
enum BuyBackSlots // 12 slots
{
// stored in m_buybackitems
BUYBACK_SLOT_START = 74,
BUYBACK_SLOT_1 = 74,
BUYBACK_SLOT_2 = 75,
BUYBACK_SLOT_3 = 76,
BUYBACK_SLOT_4 = 77,
BUYBACK_SLOT_5 = 78,
BUYBACK_SLOT_6 = 79,
BUYBACK_SLOT_7 = 80,
BUYBACK_SLOT_8 = 81,
BUYBACK_SLOT_9 = 82,
BUYBACK_SLOT_10 = 83,
BUYBACK_SLOT_11 = 84,
BUYBACK_SLOT_12 = 85,
BUYBACK_SLOT_END = 86
};
enum KeyRingSlots
enum KeyRingSlots // 32 slots
{
KEYRING_SLOT_START = 86,
KEYRING_SLOT_END = 118
};
enum VanityPetSlots
enum VanityPetSlots // 18 slots
{
VANITYPET_SLOT_START = 118, // not use, vanity pets stored as spells
VANITYPET_SLOT_END = 136 // not alloed any content in.
};
enum CurrencyTokenSlots
enum CurrencyTokenSlots // 32 slots
{
CURRENCYTOKEN_SLOT_START = 136,
CURRENCYTOKEN_SLOT_END = 168
};
enum QuestBagSlots
enum QuestBagSlots // 32 slots
{
QUESTBAG_SLOT_START = 168,
QUESTBAG_SLOT_END = 200
@ -770,11 +710,6 @@ struct MovementInfo
x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_unk = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f;
t_guid = 0;
}
void SetMovementFlags(uint32 _flags)
{
flags = _flags;
}
};
// flags that use in movement check for example at spell casting
@ -852,7 +787,6 @@ enum PlayerLoginQueryIndex
MAX_PLAYER_LOGIN_QUERY = 21
};
// Player summoning auto-decline time (in secs)
#define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
#define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
@ -1462,6 +1396,9 @@ class MANGOS_DLL_SPEC Player : public Unit
uint32 resetTalentsCost() const;
void InitTalentForLevel();
void LearnTalent(uint32 talentId, uint32 talentRank);
void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank);
uint32 CalculateTalentsPoints() const;
void InitGlyphsForLevel();

View file

@ -100,20 +100,20 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32
WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+4+4+4+10) );
data << MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER);
data << name;
data << (uint8)0;
data << (uint32)(field & 0xFF);
data << (uint32)((field >> 16) & 0xFF);
data << (uint32)((field >> 8) & 0xFF);
data << uint8(0);
data << uint32(field & 0xFF);
data << uint32((field >> 16) & 0xFF);
data << uint32((field >> 8) & 0xFF);
// if the first declined name field (3) is empty, the rest must be too
if(sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) && fields[3].GetCppString() != "")
{
data << (uint8)1; // is declined
data << uint8(1); // is declined
for(int i = 3; i < MAX_DECLINED_NAME_CASES+3; ++i)
data << fields[i].GetCppString();
}
else
data << (uint8)0; // is declined
data << uint8(0); // is declined
session->SendPacket( &data );
delete result;
@ -121,7 +121,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32
void WorldSession::HandleNameQueryOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
CHECK_PACKET_SIZE(recv_data, 8);
uint64 guid;
@ -174,23 +174,23 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
sLog.outDetail("WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name, entry);
// guess size
WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 100 );
data << (uint32)entry; // creature entry
data << uint32(entry); // creature entry
data << Name;
data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
data << SubName;
data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0
data << (uint32)ci->type_flags; // flags wdbFeild7=wad flags1
data << (uint32)ci->type;
data << (uint32)ci->family; // family wdbFeild9
data << (uint32)ci->rank; // rank wdbFeild10
data << (uint32)ci->PetSpellDataId; // Id from CreatureSpellData.dbc wdbField12
data << (uint32)ci->DisplayID_A; // modelid_male1
data << (uint32)ci->DisplayID_H; // modelid_female1 ?
data << (uint32)ci->DisplayID_A2; // modelid_male2 ?
data << (uint32)ci->DisplayID_H2; // modelid_femmale2 ?
data << (float)ci->unk16; // unk
data << (float)ci->unk17; // unk
data << (uint8)ci->RacialLeader;
data << uint32(ci->type_flags); // flags wdbFeild7=wad flags1
data << uint32(ci->type);
data << uint32(ci->family); // family wdbFeild9
data << uint32(ci->rank); // rank wdbFeild10
data << uint32(ci->PetSpellDataId); // Id from CreatureSpellData.dbc wdbField12
data << uint32(ci->DisplayID_A); // modelid_male1
data << uint32(ci->DisplayID_H); // modelid_female1 ?
data << uint32(ci->DisplayID_A2); // modelid_male2 ?
data << uint32(ci->DisplayID_H2); // modelid_femmale2 ?
data << float(ci->unk16); // unk
data << float(ci->unk17); // unk
data << uint8(ci->RacialLeader);
SendPacket( &data );
sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " );
}
@ -204,7 +204,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 4 );
data << uint32(entry | 0x80000000);
SendPacket( &data );
sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " );
sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " );
}
}
@ -240,15 +240,15 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data )
}
sLog.outDetail("WORLD: CMSG_GAMEOBJECT_QUERY '%s' - Entry: %u. ", info->name, entryID);
WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 150 );
data << entryID;
data << (uint32)info->type;
data << (uint32)info->displayId;
data << uint32(entryID);
data << uint32(info->type);
data << uint32(info->displayId);
data << Name;
data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4
data << uint8(0); // 2.0.3, string
data << CastBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting")
data << uint8(0); // 2.0.3, probably string
data.append(info->raw.data,24);
data << uint8(0); // 2.0.3, string
data.append(info->raw.data, 24);
data << float(info->size); // go size
SendPacket( &data );
sLog.outDebug( "WORLD: Sent CMSG_GAMEOBJECT_QUERY " );

View file

@ -123,7 +123,7 @@ enum __QuestFlags
//QUEST_FLAGS_NONE2 = 0x00000010, // Not used currently
QUEST_FLAGS_EPIC = 0x00000020, // Not used currently: Unsure of content
QUEST_FLAGS_RAID = 0x00000040, // Not used currently
QUEST_FLAGS_TBC = 0x00000080, // Not used currently: Available if TBC expension enabled only
QUEST_FLAGS_TBC = 0x00000080, // Not used currently: Available if TBC expansion enabled only
QUEST_FLAGS_UNK2 = 0x00000100, // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs
QUEST_FLAGS_HIDDEN_REWARDS = 0x00000200, // Items and money rewarded only sent in SMSG_QUESTGIVER_OFFER_REWARD (not in SMSG_QUESTGIVER_QUEST_DETAILS or in client quest log(SMSG_QUEST_QUERY_RESPONSE))
QUEST_FLAGS_AUTO_REWARDED = 0x00000400, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side.

View file

@ -440,7 +440,7 @@ enum ItemQualities
#define SPELL_ATTR_EX6_UNK30 0x40000000 // 30 not set in 3.0.3
#define SPELL_ATTR_EX6_UNK31 0x80000000 // 31 not set in 3.0.3
#define MAX_GLYPH_SLOT_INDEX 5
#define MAX_GLYPH_SLOT_INDEX 6
enum SheathTypes
{

View file

@ -33,103 +33,7 @@ void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data )
uint32 talent_id, requested_rank;
recv_data >> talent_id >> requested_rank;
uint32 CurTalentPoints = GetPlayer()->GetFreeTalentPoints();
if(CurTalentPoints == 0)
return;
if (requested_rank > 4)
return;
TalentEntry const *talentInfo = sTalentStore.LookupEntry( talent_id );
if(!talentInfo)
return;
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab );
if(!talentTabInfo)
return;
Player * player = GetPlayer();
// prevent learn talent for different class (cheating)
if( (player->getClassMask() & talentTabInfo->ClassMask) == 0 )
return;
// prevent skip talent ranks (cheating)
if(requested_rank > 0 && !player->HasSpell(talentInfo->RankID[requested_rank-1]))
return;
// Check if it requires another talent
if (talentInfo->DependsOn > 0)
{
if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
{
bool hasEnoughRank = false;
for (int i = talentInfo->DependsOnRank; i <= 4; i++)
{
if (depTalentInfo->RankID[i] != 0)
if (player->HasSpell(depTalentInfo->RankID[i]))
hasEnoughRank = true;
}
if (!hasEnoughRank)
return;
}
}
// Find out how many points we have in this field
uint32 spentPoints = 0;
uint32 tTab = talentInfo->TalentTab;
if (talentInfo->Row > 0)
{
unsigned int numRows = sTalentStore.GetNumRows();
for (unsigned int i = 0; i < numRows; i++) // Loop through all talents.
{
// Someday, someone needs to revamp
const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i);
if (tmpTalent) // the way talents are tracked
{
if (tmpTalent->TalentTab == tTab)
{
for (int j = 0; j <= 4; j++)
{
if (tmpTalent->RankID[j] != 0)
{
if (player->HasSpell(tmpTalent->RankID[j]))
{
spentPoints += j + 1;
}
}
}
}
}
}
}
// not have required min points spent in talent tree
if(spentPoints < (talentInfo->Row * 5))
return;
// spell not set in talent.dbc
uint32 spellid = talentInfo->RankID[requested_rank];
if( spellid == 0 )
{
sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talent_id, requested_rank);
return;
}
// already known
if(GetPlayer( )->HasSpell(spellid))
return;
// learn! (other talent ranks will unlearned at learning)
GetPlayer( )->learnSpell(spellid,false);
sLog.outDetail("TalentID: %u Rank: %u Spell: %u", talent_id, requested_rank, spellid);
// update free talent points
GetPlayer()->SetFreeTalentPoints(CurTalentPoints - 1);
_player->LearnTalent(talent_id, requested_rank);
}
void WorldSession::HandleTalentWipeOpcode( WorldPacket & recv_data )

View file

@ -4987,7 +4987,7 @@ SpellCastResult Spell::CheckItems()
ItemPrototype const *proto = m_CastItem->GetProto();
if(!proto)
return SPELL_FAILED_ITEM_NOT_READY;
for(int s=0;s < MAX_ITEM_PROTO_SPELLS; ++s)
for(int s=0; s < MAX_ITEM_PROTO_SPELLS; ++s)
{
// CastItem will be used up and does not count as reagent
int32 charges = m_CastItem->GetSpellCharges(s);

View file

@ -3095,7 +3095,7 @@ void Aura::HandleModPossess(bool apply, bool Real)
if(caster->GetTypeId() == TYPEID_PLAYER)
{
WorldPacket data(SMSG_PET_SPELLS, 8);
WorldPacket data(SMSG_PET_SPELLS, 8+4);
data << uint64(0);
data << uint32(0);
((Player*)caster)->GetSession()->SendPacket(&data);
@ -3251,7 +3251,7 @@ void Aura::HandleModCharm(bool apply, bool Real)
if(caster->GetTypeId() == TYPEID_PLAYER)
{
WorldPacket data(SMSG_PET_SPELLS, 8);
WorldPacket data(SMSG_PET_SPELLS, 8+4);
data << uint64(0);
data << uint32(0);
((Player*)caster)->GetSession()->SendPacket(&data);

View file

@ -5390,16 +5390,6 @@ void Spell::EffectApplyGlyph(uint32 i)
Player *player = (Player*)m_caster;
// remove old glyph
if(uint32 oldglyph = player->GetGlyph(m_glyphIndex))
{
if(GlyphPropertiesEntry const *old_gp = sGlyphPropertiesStore.LookupEntry(oldglyph))
{
player->RemoveAurasDueToSpell(old_gp->SpellId);
player->SetGlyph(m_glyphIndex, 0);
}
}
// apply new one
if(uint32 glyph = m_spellInfo->EffectMiscValue[i])
{
@ -5410,7 +5400,17 @@ void Spell::EffectApplyGlyph(uint32 i)
if(gp->TypeFlags != gs->TypeFlags)
{
SendCastResult(SPELL_FAILED_INVALID_GLYPH);
return; // glyph slot missmatch
return; // glyph slot mismatch
}
}
// remove old glyph
if(uint32 oldglyph = player->GetGlyph(m_glyphIndex))
{
if(GlyphPropertiesEntry const *old_gp = sGlyphPropertiesStore.LookupEntry(oldglyph))
{
player->RemoveAurasDueToSpell(old_gp->SpellId);
player->SetGlyph(m_glyphIndex, 0);
}
}

View file

@ -35,7 +35,6 @@
#include "WorldPacket.h"
#include "SharedDefines.h"
#include "ByteBuffer.h"
#include "AddonHandler.h"
#include "Opcodes.h"
#include "Database/DatabaseEnv.h"
#include "Auth/Sha1.h"
@ -187,7 +186,7 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
}
ServerPktHeader header(pct.size()+2, pct.GetOpcode());
m_Crypt.EncryptSend ( header.header, header.getHeaderLength());
m_Crypt.EncryptSend ((uint8*)header.header, header.getHeaderLength());
if (m_OutBuffer->space () >= pct.size () + header.getHeaderLength() && msg_queue()->is_empty())
{
@ -480,7 +479,7 @@ int WorldSocket::handle_input_header (void)
ACE_ASSERT (m_Header.length () == sizeof (ClientPktHeader));
m_Crypt.DecryptRecv ((ACE_UINT8*) m_Header.rd_ptr (), sizeof (ClientPktHeader));
m_Crypt.DecryptRecv ((uint8*) m_Header.rd_ptr (), sizeof (ClientPktHeader));
ClientPktHeader& header = *((ClientPktHeader*) m_Header.rd_ptr ());
@ -993,10 +992,6 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
sWorld.AddSession (m_Session);
// Create and send the Addon packet
if (sAddOnHandler.BuildAddonPacket (&recvPacket, &SendAddonPacked))
SendPacket (SendAddonPacked);
return 0;
}

View file

@ -594,3 +594,27 @@ bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(const char* args)
m_session->SendSetPhaseShift(PhaseShift);
return true;
}
bool ChatHandler::HandleDebugSetItemFlagCommand(const char* args)
{
if(!args)
return false;
char* e = strtok((char*)args, " ");
char* f = strtok(NULL, " ");
if (!e || !f)
return false;
uint32 guid = (uint32)atoi(e);
uint32 flag = (uint32)atoi(f);
Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
if(!i)
return false;
i->SetUInt32Value(ITEM_FIELD_FLAGS, flag);
return true;
}

View file

@ -95,4 +95,3 @@ const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiii
const char WorldMapAreaEntryfmt[]="xinxffffix";
const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";
const char WorldMapOverlayEntryfmt[]="nxixxxxxxxxxxxxxx";