From 102abf5fff122ec736b49c978fcfba0177f9edc2 Mon Sep 17 00:00:00 2001 From: XTZGZoReX Date: Fri, 29 Jan 2010 22:01:16 +0100 Subject: [PATCH] [9266] Implement CMSG_CORPSE_MAP_POSITION_QUERY opcode. * Send coordinates of corpse on world map, if outside instance. * Send coordinates of instance entrance, if inside instance. Thanks to Ceris and Lightguard for helping with research/code. --- src/game/QueryHandler.cpp | 74 +++++++++++++++++++++++++++++++++++---- src/shared/revision_nr.h | 2 +- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 27fff2d8489..6bc0bafc0ee 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -314,7 +314,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/) data << float(y); data << float(z); data << int32(corpsemapid); - data << uint32(0); // unknown + data << uint32(corpse->GetGUIDLow()); SendPacket(&data); } @@ -455,14 +455,74 @@ void WorldSession::HandleCorpseMapPositionQuery( WorldPacket & recv_data ) { sLog.outDebug( "WORLD: Recv CMSG_CORPSE_MAP_POSITION_QUERY" ); - uint32 unk; - recv_data >> unk; + uint32 lowGuid; + recv_data >> lowGuid; // not needed + + Player* player = _player; + Corpse* corpse = player->GetCorpse(); + if (!corpse) + return; WorldPacket data(CMSG_CORPSE_MAP_POSITION_QUERY_RESPONSE, 4+4+4+4); - data << float(0); - data << float(0); - data << float(0); - data << float(0); + + Map* map = corpse->GetMap(); + + float cx, cy, cz; + + if (map->IsDungeon()) + { + int32 mapId; + float mx, my; + map->GetEntrancePos(mapId, mx, my); + + const Map* newMap = sMapMgr.CreateBaseMap(mapId); + uint32 zoneId = newMap->GetZoneId(mx, my, 0); + + float _mx = mx; + float _my = my; + Map2ZoneCoordinates(mx, my, zoneId); + + float x = corpse->GetPositionX(); + float y = corpse->GetPositionY(); + Map2ZoneCoordinates(x, y, zoneId); + + cx = x - mx; + cy = y - my; + cz = corpse->GetPositionZ() - map->GetHeight(_mx, _my, MAX_HEIGHT); + } + else + { + WorldSafeLocsEntry const *ClosestGrave = NULL; + + // Special handle for battleground maps + if (BattleGround *bg = player->GetBattleGround()) + ClosestGrave = bg->GetClosestGraveYard(player); + else + ClosestGrave = sObjectMgr.GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam()); + + if (!ClosestGrave) + return; + + uint32 zoneId = corpse->GetZoneId(); + + float gx = ClosestGrave->x; + float gy = ClosestGrave->y; + Map2ZoneCoordinates(gx, gy, zoneId); + + float x = corpse->GetPositionX(); + float y = corpse->GetPositionY(); + Map2ZoneCoordinates(x, y, zoneId); + + cx = x - gx; + cy = y - gy; + cz = corpse->GetPositionZ() - ClosestGrave->z; + } + + data << float(cx); + data << float(cy); + data << float(cz); + data << float(0); // unknown + SendPacket(&data); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3b235ead289..979ee234a65 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9265" + #define REVISION_NR "9266" #endif // __REVISION_NR_H__