Fix flight paths for KoS, DoF clients. Working around by sending the single flight path due to indexing issues with the client.

This commit is contained in:
Emagi 2025-06-18 17:04:13 -04:00
parent 0f5cfddf89
commit 712b5ebf3f
3 changed files with 31 additions and 7 deletions

View File

@ -11827,9 +11827,8 @@ void Client::AttemptStartAutoMount() {
packet->setDataByName("speed", GetCurrentZone()->GetFlightPathSpeed(GetPendingFlightPath()));
QueuePacket(packet->serialize());
safe_delete(packet);
on_auto_mount = true;
}
on_auto_mount = true;
}
else {
LogWrite(CCLIENT__ERROR, 0, "Client", "OP_ReadyForTakeOffMsg recieved but unable to get an index for path (%u) in zone (%u)", GetPendingFlightPath(), GetCurrentZone()->GetZoneID());
@ -11837,7 +11836,7 @@ void Client::AttemptStartAutoMount() {
EndAutoMount();
}
SetPendingFlightPath(0);
//SetPendingFlightPath(0);
}
else
@ -11888,6 +11887,7 @@ void Client::EndAutoMount() {
player->SetMountColor(&mount_color);
player->SetMountSaddleColor(&saddle_color);
player->SetTempMount(0);
SetPendingFlightPath(0);
}
bool Client::EntityCommandPrecheck(Spawn* spawn, const char* command) {
@ -12466,6 +12466,10 @@ void Client::SendFlightAutoMount(int32 path_id, int16 mount_id, int8 mount_red_c
((Player*)player)->SetTempMountColor(((Entity*)player)->GetMountColor());
((Player*)player)->SetTempMountSaddleColor(((Entity*)player)->GetMountSaddleColor());
int32 index = GetCurrentZone()->GetFlightPathIndex(GetPendingFlightPath());
if(GetVersion() <= 561) {
GetCurrentZone()->SendFlightPathsPackets(this, index);
}
PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", GetVersion());
if (packet) {
QueuePacket(packet->serialize());
@ -12475,14 +12479,14 @@ void Client::SendFlightAutoMount(int32 path_id, int16 mount_id, int8 mount_red_c
if (mount_id)
((Entity*)GetPlayer())->SetMount(mount_id, mount_red_color, mount_green_color, mount_blue_color);
if(GetVersion() <= 561) {
PacketStruct* packet = configReader.getStruct("WS_CreateBoatTransportMsg", GetVersion());
if (!packet) {
LogWrite(CCLIENT__ERROR, 0, "Client", "WS_CreateBoatTransportMsg missing for version %u", GetVersion());
return;
}
int8 index = (int8)GetCurrentZone()->GetFlightPathIndex(GetPendingFlightPath());
packet->setDataByName("path_id", index);
packet->setDataByName("path_id", 1); // workaround we send the SendFlightPathsPackets based on the index since the structure seems to only honor the first index as every index+1
// packet->PrintPacket();
QueuePacket(packet->serialize());
safe_delete(packet);

View File

@ -8830,19 +8830,37 @@ void ZoneServer::DeleteFlightPaths() {
m_flightPaths.clear();
}
void ZoneServer::SendFlightPathsPackets(Client* client) {
void ZoneServer::SendFlightPathsPackets(Client* client, int32 index) {
if(client->GetVersion() <= 561 && index == 0xFFFFFFFF)
return;
// Only send a packet if there are flight paths
if (m_flightPathRoutes.size() > 0) {
PacketStruct* packet = configReader.getStruct("WS_FlightPathsMsg", client->GetVersion());
if (packet) {
int32 num_routes = m_flightPaths.size();
if(index != 0xFFFFFFFF) {
num_routes = 1;
}
packet->setArrayLengthByName("number_of_routes", num_routes);
packet->setArrayLengthByName("number_of_routes2", num_routes);
packet->setArrayLengthByName("number_of_routes3", num_routes);
packet->setArrayLengthByName("number_of_routes4", num_routes);
map<int32, FlightPathInfo*>::iterator itr;
int32 i = 0;
bool breakout = false;
for (itr = m_flightPaths.begin(); itr != m_flightPaths.end(); itr++, i++) {
if(index != 0xFFFFFFFF) {
if(i != index) {
continue;
}
else {
i = 0;
breakout = true;
}
}
packet->setArrayDataByName("route_length", m_flightPathRoutes[itr->first].size(), i);
packet->setArrayDataByName("ground_mount", itr->second->flying ? 0 : 1, i);
packet->setArrayDataByName("allow_dismount", itr->second->dismount ? 1 : 0, i);
@ -8854,6 +8872,8 @@ void ZoneServer::SendFlightPathsPackets(Client* client) {
packet->setSubArrayDataByName("y", (*itr2)->Y, i, j);
packet->setSubArrayDataByName("z", (*itr2)->Z, i, j);
}
if(breakout)
break;
}
client->QueuePacket(packet->serialize());
safe_delete(packet);

View File

@ -679,7 +679,7 @@ public:
void AddFlightPath(int32 id, FlightPathInfo* info);
void AddFlightPathLocation(int32 id, FlightPathLocation* location);
void DeleteFlightPaths();
void SendFlightPathsPackets(Client* client);
void SendFlightPathsPackets(Client* client, int32 index = 0xFFFFFFFF);
int32 GetFlightPathIndex(int32 id);
float GetFlightPathSpeed(int32 id);