bool ChatHandler::HandleAuraUpdateRemove( const char *args, WorldSession *m_session ) { if(!args) return false; char * pArgs = strtok((char*)args, " "); if(!pArgs) return false; uint8 VisualSlot = (uint8)atoi(pArgs); Player * Pl = m_session->GetPlayer(); Aura * AuraPtr = Pl->FindAura(Pl->m_auravisuals[VisualSlot]); if(!AuraPtr) { SystemMessage(m_session, "No auraid found in slot %u", VisualSlot); return true; } WorldPacket data(SMSG_AURA_UPDATE, 20); FastGUIDPack(data, Pl->GetGUID()); data << (uint8)VisualSlot; data << (uint32)0; m_session->SendPacket(&data); SystemMessage(m_session, "SMSG_AURA_UPDATE (remove): VisualSlot %u - SpellID 0", VisualSlot); AuraPtr->Remove(); return true; }
void AchievementInterface::SendCriteriaUpdate(AchievementData * ad, uint32 idx) { ad->m_isDirty = true; ad->date = (uint32)time(NULL); WorldPacket data(SMSG_CRITERIA_UPDATE, 50); AchievementEntry * ae = dbcAchievement.LookupEntry(ad->id); data << uint32(ae->AssociatedCriteria[idx]); FastGUIDPack( data, (uint64)ad->counter[idx] ); data << m_player->GetNewGUID(); data << uint32(0); data << uint32(unixTimeToTimeBitfields(time(NULL))); data << uint32(0); data << uint32(0); if( !m_player->IsInWorld() ) m_player->CopyAndSendDelayedPacket(&data); else m_player->GetSession()->SendPacket(&data); if( m_achievementInspectPacket ) { delete m_achievementInspectPacket; m_achievementInspectPacket = NULL; } }
WorldPacket* AchievementInterface::BuildAchievementData(bool forInspect) { if(forInspect && m_achievementInspectPacket) return m_achievementInspectPacket; WorldPacket * data = new WorldPacket(forInspect ? SMSG_RESPOND_INSPECT_ACHIEVEMENTS : SMSG_ALL_ACHIEVEMENT_DATA, 400); if(forInspect) *data << m_player->GetNewGUID(); std::map<uint32,AchievementData*>::iterator itr = m_achivementDataMap.begin(); for(; itr != m_achivementDataMap.end(); ++itr) { if( itr->second->completed ) { *data << uint32(itr->first); *data << uint32( unixTimeToTimeBitfields(itr->second->date) ); } } *data << int32(-1); itr = m_achivementDataMap.begin(); // Re-loop, luls for(; itr != m_achivementDataMap.end(); ++itr) { if( !itr->second->completed ) { AchievementEntry * ae = dbcAchievement.LookupEntry( itr->second->id ); // Loop over the associated criteria for(uint32 i = 0; i < ae->AssociatedCriteriaCount; ++i) { *data << uint32( ae->AssociatedCriteria[i] ); uint32 counterVar = itr->second->counter[i]; FastGUIDPack( *data, counterVar ); *data << m_player->GetNewGUID(); *data << uint32(0); *data << uint32( unixTimeToTimeBitfields( time(NULL) ) ); *data << uint32(0); *data << uint32(0); } } } *data << int32(-1); if(forInspect) m_achievementInspectPacket = data; return data; }
bool AuraInterface::BuildAuraUpdateAllPacket(WorldPacket* data) { if(!m_auras.size()) return false; bool res = false; Aura* aur = NULL; for (uint32 i=0; i<MAX_AURAS; i++) { if(m_auras.find(i) != m_auras.end()) { res = true; aur = m_auras.at(i); aur->BuildAuraUpdate(); uint8 flags = aur->GetAuraFlags(); *data << uint8(aur->m_auraSlot); int32 stack = aur->stackSize; if(aur->procCharges > stack && stack != 0) stack = aur->procCharges; if(stack < 0) { *data << uint32(0); continue; } *data << uint32(aur->GetSpellId()); *data << uint8(flags); *data << uint8(aur->GetUnitCaster() ? aur->GetUnitCaster()->getLevel() : 0); *data << uint8(stack); if(!(flags & AFLAG_NOT_GUID)) FastGUIDPack(*data, aur->GetCasterGUID()); if(flags & AFLAG_HAS_DURATION) { *data << aur->GetDuration(); *data << aur->GetTimeLeft(); } } } return res; }
bool ChatHandler::HandleAuraUpdateAdd( const char *args, WorldSession *m_session ) { if(!args) return false; uint32 SpellID = 0; int Flags = 0; int StackCount = 0; if(sscanf(args, "%u 0x%X %i", &SpellID, &Flags, &StackCount) != 3 && sscanf(args, "%u %u %i", &SpellID, &Flags, &StackCount) != 3) return false; Player * Pl = m_session->GetPlayer(); if(Aura * AuraPtr = Pl->FindAura(SpellID)) { uint8 VisualSlot = AuraPtr->m_visualSlot; WorldPacket data(SMSG_AURA_UPDATE, 20); FastGUIDPack(data, Pl->GetGUID()); data << (uint8)VisualSlot; data << (uint32)SpellID; data << (uint8)Flags; data << (uint8)Pl->getLevel(); data << (uint8)StackCount; if( !(Flags & AFLAG_NOT_CASTER) ) data << WoWGuid(Pl->GetSelection()); if(Flags & AFLAG_DURATION) { data << (uint32)AuraPtr->GetDuration(); data << (uint32)AuraPtr->GetTimeLeft(); } m_session->SendPacket(&data); SystemMessage(m_session, "SMSG_AURA_UPDATE (update): VisualSlot %u - SpellID %u - Flags %i (0x%04X) - StackCount %i", VisualSlot, SpellID, Flags, Flags, StackCount); } else { SpellEntry * Sp = dbcSpell.LookupEntryForced(SpellID); if(!Sp) { SystemMessage(m_session, "SpellID %u is invalid.", SpellID); return true; } Spell * SpellPtr = new Spell(Pl, Sp, false, NULL); AuraPtr = new Aura(Sp, SpellPtr->GetDuration(), Pl, Pl); Pl->AddAura(AuraPtr); // Serves purpose to just add the aura to our auraslots uint8 VisualSlot = Pl->FindVisualSlot(SpellID, AuraPtr->IsPositive()); WorldPacket data(SMSG_AURA_UPDATE, 20); FastGUIDPack(data, Pl->GetGUID()); data << (uint8)VisualSlot; data << (uint32)SpellID; data << (uint8)Flags; data << (uint8)Pl->getLevel(); data << (uint8)StackCount; if( !(Flags & AFLAG_NOT_CASTER) ) data << (uint8)0; // caster guid if(Flags & AFLAG_DURATION) { data << (uint32)SpellPtr->GetDuration(); data << (uint32)SpellPtr->GetDuration(); } m_session->SendPacket(&data); SystemMessage(m_session, "SMSG_AURA_UPDATE (add): VisualSlot %u - SpellID %u - Flags %i (0x%04X) - StackCount %i", VisualSlot, SpellID, Flags, Flags, StackCount); delete SpellPtr; } return true; }
void LfgMgr::SendLfgList(Player* plr, uint32 Dungeon) { if (plr == NULL) return; if (Dungeon >= MAX_DUNGEONS) return; LfgPlayerList::iterator itr; GroupMembersSet::iterator it2; uint32 count = 0; Player * pl; uint32 i; uint64 tguid; SubGroup * sgrp; m_lock.Acquire(); WorldPacket data(MSG_LOOKING_FOR_GROUP, ((m_lookingForGroup[Dungeon].size() + m_lookingForMore[Dungeon].size()) * 20) + 20); data << LfgDungeonTypes[Dungeon]; data << Dungeon; data << uint32(m_lookingForGroup[Dungeon].size()); data << uint32(m_lookingForGroup[Dungeon].size()); for (itr = m_lookingForGroup[Dungeon].begin(); itr != m_lookingForGroup[Dungeon].end(); ++itr) { pl = *itr; if (pl->GetTeam() != plr->GetTeam() || pl == plr) continue; ++count; data << pl->GetNewGUID(); data << pl->getLevel(); data << pl->GetZoneId(); data << uint8(0); // 1=LFG? for (i = 0; i < MAX_LFG_QUEUE_ID; ++i) data << pl->LfgDungeonId[i] << uint8(0) << pl->LfgType[i]; data << pl->Lfgcomment; // LFG members are never in parties. data << uint32(0); } for (itr = m_lookingForMore[Dungeon].begin(); itr != m_lookingForMore[Dungeon].end(); ++itr) { pl = *itr; if (pl->GetTeam() != plr->GetTeam() || pl == plr) continue; ++count; data << pl->GetNewGUID(); data << pl->getLevel(); data << pl->GetZoneId(); data << uint8(1); // 1=LFM? for (i = 0; i < MAX_LFG_QUEUE_ID; ++i) data << pl->LfgDungeonId[i] << uint8(0) << pl->LfgType[i]; data << pl->Lfgcomment; if (pl->GetGroup() && pl->GetGroup()->GetGroupType() == GROUP_TYPE_PARTY) { pl->GetGroup()->Lock(); sgrp = pl->GetGroup()->GetSubGroup(0); data << uint32(sgrp->GetMemberCount() - 1); for (it2 = sgrp->GetGroupMembersBegin(); it2 != sgrp->GetGroupMembersEnd(); ++it2) { if ((*it2)->m_loggedInPlayer) data << (*it2)->m_loggedInPlayer->GetNewGUID(); else { tguid = (*it2)->guid; FastGUIDPack(data, tguid); } } pl->GetGroup()->Unlock(); } else data << uint32(0); } m_lock.Release(); //*(uint32*)(data.contents()[8]) = count; //*(uint32*)(data.contents()[12]) = count; data.put(8, count); data.put(12, count); plr->GetSession()->SendPacket(&data); }