[Expeditions] Store description and leader name on dz (#1294)

* Rename dynamic zone source files

* Store description and leader name on dz

Removes the DynamicZoneInfo struct used for switch list window. This
data can be stored on DynamicZone and kept updated by its owning system

* Separate create compass packet method

Cleanup MarkSingleCompassLoc
This commit is contained in:
hg
2021-03-16 01:00:55 -04:00
committed by GitHub
parent b3fbe1b015
commit 0d12bf0b1f
11 changed files with 91 additions and 87 deletions
+47 -45
View File
@@ -6161,17 +6161,10 @@ void Client::CheckEmoteHail(Mob *target, const char* message)
void Client::MarkSingleCompassLoc(float in_x, float in_y, float in_z, uint8 count)
{
if (count == 0)
{
m_has_quest_compass = false;
}
else
{
m_has_quest_compass = true;
m_quest_compass.x = in_x;
m_quest_compass.y = in_y;
m_quest_compass.z = in_z;
}
m_has_quest_compass = (count != 0);
m_quest_compass.x = in_x;
m_quest_compass.y = in_y;
m_quest_compass.z = in_z;
SendDzCompassUpdate();
}
@@ -9862,13 +9855,13 @@ void Client::SendDzCompassUpdate()
for (const auto& client_dz : GetDynamicZones())
{
auto compass = client_dz.dynamic_zone.GetCompassLocation();
if (zone && zone->GetZoneID() == compass.zone_id && zone->GetInstanceID() == 0)
auto compass = client_dz->GetCompassLocation();
if (zone && zone->IsZone(compass.zone_id, 0))
{
DynamicZoneCompassEntry_Struct entry;
entry.dz_zone_id = static_cast<uint16_t>(client_dz.dynamic_zone.GetZoneID());
entry.dz_instance_id = static_cast<uint16_t>(client_dz.dynamic_zone.GetInstanceID());
entry.dz_type = static_cast<uint32_t>(client_dz.dynamic_zone.GetType());
entry.dz_zone_id = client_dz->GetZoneID();
entry.dz_instance_id = client_dz->GetInstanceID();
entry.dz_type = static_cast<uint32_t>(client_dz->GetType());
entry.x = compass.x;
entry.y = compass.y;
entry.z = compass.z;
@@ -9891,6 +9884,12 @@ void Client::SendDzCompassUpdate()
compass_entries.emplace_back(entry);
}
QueuePacket(CreateCompassPacket(compass_entries).get());
}
std::unique_ptr<EQApplicationPacket> Client::CreateCompassPacket(
const std::vector<DynamicZoneCompassEntry_Struct>& compass_entries)
{
uint32 count = static_cast<uint32_t>(compass_entries.size());
uint32 entries_size = sizeof(DynamicZoneCompassEntry_Struct) * count;
uint32 outsize = sizeof(DynamicZoneCompass_Struct) + entries_size;
@@ -9899,7 +9898,7 @@ void Client::SendDzCompassUpdate()
outbuf->count = count;
memcpy(outbuf->entries, compass_entries.data(), entries_size);
QueuePacket(outapp.get());
return outapp;
}
void Client::GoToDzSafeReturnOrBind(const DynamicZone& dynamic_zone)
@@ -9919,9 +9918,9 @@ void Client::GoToDzSafeReturnOrBind(const DynamicZone& dynamic_zone)
}
}
std::vector<DynamicZoneInfo> Client::GetDynamicZones(uint32_t zone_id, int zone_version)
std::vector<DynamicZone*> Client::GetDynamicZones(uint32_t zone_id, int zone_version)
{
std::vector<DynamicZoneInfo> client_dzs;
std::vector<DynamicZone*> client_dzs;
// check client systems for any associated dynamic zones optionally filtered by zone
Expedition* expedition = GetExpedition();
@@ -9929,7 +9928,7 @@ std::vector<DynamicZoneInfo> Client::GetDynamicZones(uint32_t zone_id, int zone_
(zone_id == 0 || expedition->GetDynamicZone().GetZoneID() == zone_id) &&
(zone_version < 0 || expedition->GetDynamicZone().GetZoneVersion() == zone_version))
{
client_dzs.emplace_back(expedition->GetName(), expedition->GetLeaderName(), expedition->GetDynamicZone());
client_dzs.emplace_back(&expedition->GetDynamicZone());
}
// todo: tasks, missions (shared tasks), and quests with an associated dz to zone_id
@@ -9955,38 +9954,41 @@ void Client::MovePCDynamicZone(uint32 zone_id, int zone_version, bool msg_if_inv
}
else if (client_dzs.size() == 1)
{
const DynamicZone& dz = client_dzs[0].dynamic_zone;
DynamicZoneLocation zonein = dz.GetZoneInLocation();
ZoneMode zone_mode = dz.HasZoneInLocation() ? ZoneMode::ZoneSolicited : ZoneMode::ZoneToSafeCoords;
MovePC(zone_id, dz.GetInstanceID(), zonein.x, zonein.y, zonein.z, zonein.heading, 0, zone_mode);
auto dz = client_dzs.front();
DynamicZoneLocation zonein = dz->GetZoneInLocation();
ZoneMode zone_mode = dz->HasZoneInLocation() ? ZoneMode::ZoneSolicited : ZoneMode::ZoneToSafeCoords;
MovePC(zone_id, dz->GetInstanceID(), zonein.x, zonein.y, zonein.z, zonein.heading, 0, zone_mode);
}
else
{
LogDynamicZonesDetail(
"Sending DzSwitchListWnd to character [{}] associated with [{}] dynamic zone(s)",
CharacterID(), client_dzs.size());
LogDynamicZonesDetail("Sending DzSwitchListWnd to [{}] for zone [{}] with [{}] dynamic zone(s)",
CharacterID(), zone_id, client_dzs.size());
// more than one dynamic zone to this zone, send out the switchlist window
// note that this will most likely crash clients if they've reloaded the ui
// this occurs on live as well so it may just be a long lasting client bug
uint32 count = static_cast<uint32_t>(client_dzs.size());
uint32 entries_size = sizeof(DynamicZoneChooseZoneEntry_Struct) * count;
uint32 outsize = sizeof(DynamicZoneChooseZone_Struct) + entries_size;
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzChooseZone, outsize);
auto outbuf = reinterpret_cast<DynamicZoneChooseZone_Struct*>(outapp->pBuffer);
outbuf->count = count;
for (int i = 0; i < client_dzs.size(); ++i)
{
outbuf->choices[i].dz_zone_id = client_dzs[i].dynamic_zone.GetZoneID();
outbuf->choices[i].dz_instance_id = client_dzs[i].dynamic_zone.GetInstanceID();
outbuf->choices[i].dz_type = static_cast<uint32_t>(client_dzs[i].dynamic_zone.GetType());
strn0cpy(outbuf->choices[i].description, client_dzs[i].description.c_str(), sizeof(outbuf->choices[i].description));
strn0cpy(outbuf->choices[i].leader_name, client_dzs[i].leader_name.c_str(), sizeof(outbuf->choices[i].leader_name));
}
QueuePacket(outapp.get());
// client has more than one dz for this zone, send out the switchlist window
QueuePacket(CreateDzSwitchListPacket(client_dzs).get());
}
}
std::unique_ptr<EQApplicationPacket> Client::CreateDzSwitchListPacket(
const std::vector<DynamicZone*>& client_dzs)
{
uint32 count = static_cast<uint32_t>(client_dzs.size());
uint32 entries_size = sizeof(DynamicZoneChooseZoneEntry_Struct) * count;
uint32 outsize = sizeof(DynamicZoneChooseZone_Struct) + entries_size;
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzChooseZone, outsize);
auto outbuf = reinterpret_cast<DynamicZoneChooseZone_Struct*>(outapp->pBuffer);
outbuf->count = count;
for (int i = 0; i < client_dzs.size(); ++i)
{
outbuf->choices[i].dz_zone_id = client_dzs[i]->GetZoneID();
outbuf->choices[i].dz_instance_id = client_dzs[i]->GetInstanceID();
outbuf->choices[i].dz_type = static_cast<uint32_t>(client_dzs[i]->GetType());
strn0cpy(outbuf->choices[i].description, client_dzs[i]->GetName().c_str(), sizeof(outbuf->choices[i].description));
strn0cpy(outbuf->choices[i].leader_name, client_dzs[i]->GetLeaderName().c_str(), sizeof(outbuf->choices[i].leader_name));
}
return outapp;
}
void Client::MovePCDynamicZone(const std::string& zone_name, int zone_version, bool msg_if_invalid)
{
auto zone_id = ZoneID(zone_name.c_str());