aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/MiscHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/MiscHandler.cpp')
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp54
1 files changed, 4 insertions, 50 deletions
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 2f6a6dcc70b..683b77e7aa0 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -823,59 +823,13 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
return;
}
- if (player->GetMapId() != atEntry->mapid)
+ if (!player->IsInAreaTriggerRadius(atEntry))
{
- TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u",
- player->GetName().c_str(), atEntry->mapid, player->GetMapId(), player->GetGUIDLow(), triggerId);
+ TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far, ignore Area Trigger ID: %u",
+ player->GetName().c_str(), player->GetGUIDLow(), triggerId);
return;
}
- // delta is safe radius
- const float delta = 5.0f;
-
- if (atEntry->radius > 0)
- {
- // if we have radius check it
- float dist = player->GetDistance(atEntry->x, atEntry->y, atEntry->z);
- if (dist > atEntry->radius + delta)
- {
- TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u",
- player->GetName().c_str(), player->GetGUIDLow(), atEntry->radius, dist, triggerId);
- return;
- }
- }
- else
- {
- // we have only extent
-
- // rotate the players position instead of rotating the whole cube, that way we can make a simplified
- // is-in-cube check and we have to calculate only one point instead of 4
-
- // 2PI = 360°, keep in mind that ingame orientation is counter-clockwise
- double rotation = 2 * M_PI - atEntry->box_orientation;
- double sinVal = std::sin(rotation);
- double cosVal = std::cos(rotation);
-
- float playerBoxDistX = player->GetPositionX() - atEntry->x;
- float playerBoxDistY = player->GetPositionY() - atEntry->y;
-
- float rotPlayerX = float(atEntry->x + playerBoxDistX * cosVal - playerBoxDistY*sinVal);
- float rotPlayerY = float(atEntry->y + playerBoxDistY * cosVal + playerBoxDistX*sinVal);
-
- // box edges are parallel to coordiante axis, so we can treat every dimension independently :D
- float dz = player->GetPositionZ() - atEntry->z;
- float dx = rotPlayerX - atEntry->x;
- float dy = rotPlayerY - atEntry->y;
- if ((std::fabs(dx) > atEntry->box_x / 2 + delta) ||
- (std::fabs(dy) > atEntry->box_y / 2 + delta) ||
- (std::fabs(dz) > atEntry->box_z / 2 + delta))
- {
- TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u",
- player->GetName().c_str(), player->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotPlayerX, rotPlayerY, dz, triggerId);
- return;
- }
- }
-
if (player->isDebugAreaTriggers)
ChatHandler(player->GetSession()).PSendSysMessage(LANG_DEBUG_AREATRIGGER_REACHED, triggerId);
@@ -891,7 +845,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
{
// set resting flag we are in the inn
player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
- player->InnEnter(time(NULL), atEntry->mapid, atEntry->x, atEntry->y, atEntry->z);
+ player->InnEnter(time(nullptr), atEntry->id);
player->SetRestType(REST_TYPE_IN_TAVERN);
if (sWorld->IsFFAPvPRealm())