void Client::SendPathPacket(const std::vector<FindPerson_Point> &points) { EQ::BackgroundTask task([](EQEmu::Any &data) { auto &points = EQEmu::any_cast<std::vector<FindPerson_Point>&>(data); CullPoints(points); }, [this](EQEmu::Any &data) { auto &points = EQEmu::any_cast<std::vector<FindPerson_Point>&>(data); if (points.size() < 2) { if (Admin() > 10) { Message(MT_System, "Too few points"); } EQApplicationPacket outapp(OP_FindPersonReply, 0); QueuePacket(&outapp); return; } if (points.size() > 36) { if (Admin() > 10) { Message(MT_System, "Too many points %u", points.size()); } EQApplicationPacket outapp(OP_FindPersonReply, 0); QueuePacket(&outapp); return; } if (Admin() > 10) { Message(MT_System, "Total points %u", points.size()); } int len = sizeof(FindPersonResult_Struct) + (points.size() + 1) * sizeof(FindPerson_Point); auto outapp = new EQApplicationPacket(OP_FindPersonReply, len); FindPersonResult_Struct* fpr = (FindPersonResult_Struct*)outapp->pBuffer; std::vector<FindPerson_Point>::iterator cur, end; cur = points.begin(); end = points.end(); unsigned int r; for (r = 0; cur != end; ++cur, r++) { fpr->path[r] = *cur; } //put the last element into the destination field --cur; fpr->path[r] = *cur; fpr->dest = *cur; FastQueuePacket(&outapp); }, points); }
void Client::SendTributes() { std::map<uint32, TributeData>::iterator cur,end; cur = tribute_list.begin(); end = tribute_list.end(); for(; cur != end; ++cur) { if(cur->second.is_guild) continue; //skip guild tributes here int len = cur->second.name.length(); EQApplicationPacket outapp(OP_TributeInfo, sizeof(TributeAbility_Struct) + len + 1); TributeAbility_Struct* tas = (TributeAbility_Struct*)outapp.pBuffer; tas->tribute_id = htonl(cur->first); tas->tier_count = htonl(cur->second.unknown); //gotta copy over the data from tiers, and flip all the //byte orders, no idea why its flipped here uint32 r, c; c = cur->second.tier_count; TributeLevel_Struct *dest = tas->tiers; TributeLevel_Struct *src = cur->second.tiers; for(r = 0; r < c; r++, dest++, src++) { dest->cost = htonl(src->cost); dest->level = htonl(src->level); dest->tribute_item_id = htonl(src->tribute_item_id); } memcpy(tas->name, cur->second.name.c_str(), len); tas->name[len] = '\0'; QueuePacket(&outapp); } }
void Raid::SendHPPacketsFrom(Mob *m) { if(!m) return; uint32 gid = 0; if(m->IsClient()) gid = this->GetGroup(m->CastToClient()); EQApplicationPacket hpapp; EQApplicationPacket outapp(OP_MobManaUpdate, sizeof(MobManaUpdate_Struct)); m->CreateHPPacket(&hpapp); for(int x = 0; x < MAX_RAID_MEMBERS; x++) { if(members[x].member) { if(!m->IsClient() || ((members[x].member != m->CastToClient()) && (members[x].GroupNumber == gid))) { members[x].member->QueuePacket(&hpapp, false); if(members[x].member->GetClientVersion() >= EQClientSoD) { outapp.SetOpcode(OP_MobManaUpdate); MobManaUpdate_Struct *mmus = (MobManaUpdate_Struct *)outapp.pBuffer; mmus->spawn_id = m->GetID(); mmus->mana = m->GetManaPercent(); members[x].member->QueuePacket(&outapp, false); outapp.SetOpcode(OP_MobEnduranceUpdate); MobEnduranceUpdate_Struct *meus = (MobEnduranceUpdate_Struct *)outapp.pBuffer; meus->endurance = m->GetEndurancePercent(); members[x].member->QueuePacket(&outapp, false); } } } } }
void Mob::RemoveAllAuras() { if (IsClient()) { database.SaveAuras(CastToClient()); EQApplicationPacket outapp(OP_UpdateAura, 4); outapp.WriteUInt32(2); CastToClient()->QueuePacket(&outapp); } // this is sent on camp/zone, so it just despawns? if (aura_mgr.count) { for (auto &e : aura_mgr.auras) { if (e.aura) e.aura->Depop(); } } aura_mgr.count = 0; if (trap_mgr.count) { for (auto &e : trap_mgr.auras) { if (e.aura) e.aura->Depop(); } } trap_mgr.count = 0; return; }
void Client::AddTributePoints(int32 ammount) { EQApplicationPacket outapp(OP_TributePointUpdate, sizeof(TributePoint_Struct)); TributePoint_Struct *t = (TributePoint_Struct *) outapp.pBuffer; //change the point values. m_pp.tribute_points += ammount; //career only tracks points earned, not spent. if(ammount > 0) m_pp.career_tribute_points += ammount; //fill in the packet. t->career_tribute_points = m_pp.career_tribute_points; t->tribute_points = m_pp.tribute_points; QueuePacket(&outapp); }
void Client::SendTributeDetails(uint32 client_id, uint32 tribute_id) { if(tribute_list.count(tribute_id) != 1) { Log.Out(Logs::General, Logs::Error, "Details request for invalid tribute %lu", (unsigned long)tribute_id); return; } TributeData &td = tribute_list[tribute_id]; int len = td.description.length(); EQApplicationPacket outapp(OP_SelectTribute, sizeof(SelectTributeReply_Struct)+len+1); SelectTributeReply_Struct *t = (SelectTributeReply_Struct *) outapp.pBuffer; t->client_id = client_id; t->tribute_id = tribute_id; memcpy(t->desc, td.description.c_str(), len); t->desc[len] = '\0'; QueuePacket(&outapp); }
void MobMovementManager::SendCommandToClients(Mob *m, float dx, float dy, float dz, float dh, int anim, ClientRange range) { if (range == ClientRangeNone) { return; } EQApplicationPacket outapp(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); PlayerPositionUpdateServer_Struct *spu = (PlayerPositionUpdateServer_Struct*)outapp.pBuffer; FillCommandStruct(spu, m, dx, dy, dz, dh, anim); if (range == ClientRangeAny) { for (auto &c : _impl->Clients) { _impl->Stats.TotalSent++; if (anim != 0) { _impl->Stats.TotalSentMovement++; } else if (dh != 0) { _impl->Stats.TotalSentHeading++; } else { _impl->Stats.TotalSentPosition++; } c->QueuePacket(&outapp, false); } } else { for (auto &c : _impl->Clients) { float dist = c->CalculateDistance(m->GetX(), m->GetY(), m->GetZ()); bool match = false; if (range & ClientRangeClose) { if (dist < 250.0f) { match = true; } } if (!match && range & ClientRangeMedium) { if (dist >= 250.0f && dist < 1500.0f) { match = true; } } if (!match && range & ClientRangeLong) { if (dist >= 1500.0f) { match = true; } } if (match) { _impl->Stats.TotalSent++; if (anim != 0) { _impl->Stats.TotalSentMovement++; } else if (dh != 0) { _impl->Stats.TotalSentHeading++; } else { _impl->Stats.TotalSentPosition++; } c->QueuePacket(&outapp, false); } } } }
void Client::DoTributeUpdate() { EQApplicationPacket outapp(OP_TributeUpdate, sizeof(TributeInfo_Struct)); TributeInfo_Struct *tis = (TributeInfo_Struct *) outapp.pBuffer; tis->active = m_pp.tribute_active ? 1 : 0; tis->tribute_master_id = tribute_master_id; //Dont know what this is for int r; for (r = 0; r < EQEmu::legacy::TRIBUTE_SIZE; r++) { if(m_pp.tributes[r].tribute != TRIBUTE_NONE) { tis->tributes[r] = m_pp.tributes[r].tribute; tis->tiers[r] = m_pp.tributes[r].tier; } else { tis->tributes[r] = TRIBUTE_NONE; tis->tiers[r] = 0; } } QueuePacket(&outapp); SendTributeTimer(); if(m_pp.tribute_active) { //send and equip tribute items... for (r = 0; r < EQEmu::legacy::TRIBUTE_SIZE; r++) { uint32 tid = m_pp.tributes[r].tribute; if(tid == TRIBUTE_NONE) { if (m_inv[EQEmu::legacy::TRIBUTE_BEGIN + r]) DeleteItemInInventory(EQEmu::legacy::TRIBUTE_BEGIN + r, 0, false); continue; } if(tribute_list.count(tid) != 1) { if (m_inv[EQEmu::legacy::TRIBUTE_BEGIN + r]) DeleteItemInInventory(EQEmu::legacy::TRIBUTE_BEGIN + r, 0, false); continue; } //sanity check if(m_pp.tributes[r].tier >= MAX_TRIBUTE_TIERS) { if (m_inv[EQEmu::legacy::TRIBUTE_BEGIN + r]) DeleteItemInInventory(EQEmu::legacy::TRIBUTE_BEGIN + r, 0, false); m_pp.tributes[r].tier = 0; continue; } TributeData &d = tribute_list[tid]; TributeLevel_Struct &tier = d.tiers[m_pp.tributes[r].tier]; uint32 item_id = tier.tribute_item_id; //summon the item for them const ItemInst* inst = database.CreateItem(item_id, 1); if(inst == nullptr) continue; PutItemInInventory(EQEmu::legacy::TRIBUTE_BEGIN + r, *inst, false); SendItemPacket(EQEmu::legacy::TRIBUTE_BEGIN + r, inst, ItemPacketTributeItem); safe_delete(inst); } } else { //unequip tribute items... for (r = 0; r < EQEmu::legacy::TRIBUTE_SIZE; r++) { if (m_inv[EQEmu::legacy::TRIBUTE_BEGIN + r]) DeleteItemInInventory(EQEmu::legacy::TRIBUTE_BEGIN + r, 0, false); } } CalcBonuses(); }