[Cleanup] Cleanup zone/zoning.cpp (#3289)

# Notes
- Duplicate outcome cases in `Client::Handle_OP_ZoneChange`.
- Use `.length()` over `strlen` in array defintition.
- Remove unnecessary `else if` in `Client::ZonePC`
This commit is contained in:
Alex King 2023-04-14 19:40:01 -04:00 committed by GitHub
parent 1b272cba50
commit de8ae7afa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,19 +72,14 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
target_zone_id = zone->GetZoneID(); target_zone_id = zone->GetZoneID();
break; break;
case GMSummon: case GMSummon:
case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going.
target_zone_id = zonesummon_id; target_zone_id = zonesummon_id;
break; break;
case GateToBindPoint: case GateToBindPoint:
target_zone_id = m_pp.binds[0].zone_id;
target_instance_id = m_pp.binds[0].instance_id;
break;
case ZoneToBindPoint: case ZoneToBindPoint:
target_zone_id = m_pp.binds[0].zone_id; target_zone_id = m_pp.binds[0].zone_id;
target_instance_id = m_pp.binds[0].instance_id; target_instance_id = m_pp.binds[0].instance_id;
break; break;
case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going.
target_zone_id = zonesummon_id;
break;
case ZoneUnsolicited: //client came up with this on its own. case ZoneUnsolicited: //client came up with this on its own.
zone_point = zone->GetClosestZonePointWithoutZone(GetX(), GetY(), GetZ(), this, ZONEPOINT_NOZONE_RANGE); zone_point = zone->GetClosestZonePointWithoutZone(GetX(), GetY(), GetZ(), this, ZONEPOINT_NOZONE_RANGE);
if (zone_point) { if (zone_point) {
@ -645,7 +640,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
auto zd = GetZoneVersionWithFallback(zoneID, zone->GetInstanceVersion()); auto zd = GetZoneVersionWithFallback(zoneID, zone->GetInstanceVersion());
if (zd) { if (zd) {
pZoneName = strcpy(new char[strlen(zd->long_name.c_str()) + 1], zd->long_name.c_str()); pZoneName = strcpy(new char[zd->long_name.length() + 1], zd->long_name.c_str());
} }
LogInfo( LogInfo(
@ -791,8 +786,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
FastQueuePacket(&outapp); FastQueuePacket(&outapp);
} }
else if(zm == EvacToSafeCoords) { else if(zm == EvacToSafeCoords) {
auto outapp = auto outapp = new EQApplicationPacket(OP_RequestClientZoneChange, sizeof(RequestClientZoneChange_Struct));
new EQApplicationPacket(OP_RequestClientZoneChange, sizeof(RequestClientZoneChange_Struct));
RequestClientZoneChange_Struct* gmg = (RequestClientZoneChange_Struct*) outapp->pBuffer; RequestClientZoneChange_Struct* gmg = (RequestClientZoneChange_Struct*) outapp->pBuffer;
// if we are in the same zone we want to evac to, client will not send OP_ZoneChange back to do an actual // if we are in the same zone we want to evac to, client will not send OP_ZoneChange back to do an actual
@ -803,12 +797,11 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
// 76 is orignial Plane of Hate // 76 is orignial Plane of Hate
// WildcardX 27 January 2008. Tested this for 6.2 and Titanium clients. // WildcardX 27 January 2008. Tested this for 6.2 and Titanium clients.
if(GetZoneID() == 1) if (GetZoneID() == 1) {
gmg->zone_id = 2; gmg->zone_id = 2;
else if(GetZoneID() == 2) } else {
gmg->zone_id = 1;
else
gmg->zone_id = 1; gmg->zone_id = 1;
}
gmg->x = x; gmg->x = x;
gmg->y = y; gmg->y = y;