[Bug] FindBestZ selecting false zone floor as bestz - Results in roambox failures (#4504)

Added underworld checks per the EQMac project
This commit is contained in:
Fryguy 2024-10-13 16:53:09 -04:00 committed by GitHub
parent 7a1d69d0d4
commit 9ac306fe67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,12 +31,14 @@ Map::~Map() {
}
float Map::FindBestZ(glm::vec3 &start, glm::vec3 *result) const {
if (!imp)
if (!imp) {
return BEST_Z_INVALID;
}
glm::vec3 tmp;
if(!result)
if (!result) {
result = &tmp;
}
start.z += RuleI(Map, FindBestZHeightAdjust);
glm::vec3 from(start.x, start.y, start.z);
@ -45,16 +47,22 @@ float Map::FindBestZ(glm::vec3 &start, glm::vec3 *result) const {
bool hit = false;
hit = imp->rm->raycast((const RmReal*)&from, (const RmReal*)&to, (RmReal*)result, nullptr, &hit_distance);
if (hit && zone->newzone_data.underworld != 0.0f && result->z < zone->newzone_data.underworld) {
hit = false;
}
if (hit) {
return result->z;
}
// Find nearest Z above us
to.z = -BEST_Z_INVALID;
hit = imp->rm->raycast((const RmReal*)&from, (const RmReal*)&to, (RmReal*)result, nullptr, &hit_distance);
if (hit)
{
if (zone->newzone_data.max_z != 0.0f && result->z > zone->newzone_data.max_z) {
hit = false;
}
if (hit) {
return result->z;
}