Core/Characters: Made homebind location a WorldLocation (this implicitly adds orientation)

Port From (https://github.com/TrinityCore/TrinityCore/commit/68c2fc8ff58d9ad272e8e17391a6bb6c3743923b)
This commit is contained in:
hondacrx
2021-10-16 17:59:01 -04:00
parent 86cc00ff57
commit 2d976d7421
11 changed files with 41 additions and 37 deletions
+15 -16
View File
@@ -577,18 +577,13 @@ namespace Game.Entities
bool ok = false;
if (!result.IsEmpty())
{
homebind = new WorldLocation();
homebind.SetMapId(result.Read<uint>(0));
homebind.WorldRelocate(result.Read<uint>(0), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4), result.Read<float>(5));
homebindAreaId = result.Read<uint>(1);
homebind.posX = result.Read<float>(2);
homebind.posY = result.Read<float>(3);
homebind.posZ = result.Read<float>(4);
var map = CliDB.MapStorage.LookupByKey(homebind.GetMapId());
// accept saved data only for valid position (and non instanceable), and accessable
if (GridDefines.IsValidMapCoord(homebind.GetMapId(), homebind.posX, homebind.posY, homebind.posZ) &&
if (GridDefines.IsValidMapCoord(homebind) &&
!map.Instanceable() && GetSession().GetExpansion() >= map.Expansion())
ok = true;
else
@@ -605,9 +600,10 @@ namespace Game.Entities
stmt.AddValue(0, GetGUID().GetCounter());
stmt.AddValue(1, homebind.GetMapId());
stmt.AddValue(2, homebindAreaId);
stmt.AddValue(3, homebind.posX);
stmt.AddValue(4, homebind.posY);
stmt.AddValue(5, homebind.posZ);
stmt.AddValue(3, homebind.GetPositionX());
stmt.AddValue(4, homebind.GetPositionY());
stmt.AddValue(5, homebind.GetPositionZ());
stmt.AddValue(6, homebind.GetOrientation());
DB.Characters.Execute(stmt);
};
@@ -615,12 +611,16 @@ namespace Game.Entities
{
var createPosition = m_createMode == PlayerCreateMode.NPE && info.createPositionNPE.HasValue ? info.createPositionNPE.Value : info.createPosition;
homebind = new WorldLocation(createPosition.Loc.GetMapId(), createPosition.Loc);
homebind.WorldRelocate(createPosition.Loc);
if (createPosition.TransportGuid.HasValue)
{
Transport transport = Global.ObjAccessor.FindTransport(ObjectGuid.Create(HighGuid.Transport, createPosition.TransportGuid.Value));
if (transport != null)
transport.CalculatePassengerPosition(ref homebind.posX, ref homebind.posY, ref homebind.posZ, ref homebind.Orientation);
{
float orientation = homebind.GetOrientation();
transport.CalculatePassengerPosition(ref homebind.posX, ref homebind.posY, ref homebind.posZ, ref orientation);
homebind.SetOrientation(orientation);
}
}
homebindAreaId = Global.MapMgr.GetAreaId(PhasingHandler.EmptyPhaseShift, homebind);
@@ -637,14 +637,13 @@ namespace Game.Entities
Cypher.Assert(loc != null, "Missing fallback graveyard location for faction {GetTeamId()}");
homebind = new WorldLocation(loc.Loc.GetMapId(), loc.Loc.posX, loc.Loc.posY, loc.Loc.posZ);
homebind.WorldRelocate(loc.Loc);
homebindAreaId = Global.MapMgr.GetAreaId(PhasingHandler.EmptyPhaseShift, loc.Loc);
saveHomebindToDb();
}
Log.outDebug(LogFilter.Player, "Setting player home position - mapid: {0}, areaid: {1}, {2}",
homebind.GetMapId(), homebindAreaId, homebind);
Log.outDebug(LogFilter.Player, $"Setting player home position - mapid: {homebind.GetMapId()}, areaid: {homebindAreaId}, {homebind}");
return true;
}
@@ -2774,7 +2773,7 @@ namespace Game.Entities
SetRaidDifficultyID(CheckLoadedRaidDifficultyID(raidDifficulty));
SetLegacyRaidDifficultyID(CheckLoadedLegacyRaidDifficultyID(legacyRaidDifficulty));
var RelocateToHomebind = new Action(() => { mapId = (ushort)homebind.GetMapId(); instance_id = 0; Relocate(homebind); });
var RelocateToHomebind = new Action(() => { instance_id = 0; Relocate(homebind); });
_LoadGroup(holder.GetResult(PlayerLoginQueryLoad.Group));
+1 -1
View File
@@ -233,7 +233,7 @@ namespace Game.Entities
// Recall position
WorldLocation m_recall_location;
WorldLocation homebind;
WorldLocation homebind = new();
uint homebindAreaId;
uint m_HomebindTimer;
+7 -8
View File
@@ -2808,17 +2808,18 @@ namespace Game.Entities
}
public void SetHomebind(WorldLocation loc, uint areaId)
{
homebind = loc;
homebind.WorldRelocate(loc);
homebindAreaId = areaId;
// update sql homebind
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_PLAYER_HOMEBIND);
stmt.AddValue(0, homebind.GetMapId());
stmt.AddValue(1, homebindAreaId);
stmt.AddValue(2, homebind.posX);
stmt.AddValue(3, homebind.posY);
stmt.AddValue(4, homebind.posZ);
stmt.AddValue(5, GetGUID().GetCounter());
stmt.AddValue(2, homebind.GetPositionX());
stmt.AddValue(3, homebind.GetPositionY());
stmt.AddValue(4, homebind.GetPositionZ());
stmt.AddValue(5, homebind.GetOrientation());
stmt.AddValue(6, GetGUID().GetCounter());
DB.Characters.Execute(stmt);
}
public void SetBindPoint(ObjectGuid guid)
@@ -2829,9 +2830,7 @@ namespace Game.Entities
public void SendBindPointUpdate()
{
BindPointUpdate packet = new();
packet.BindPosition.X = homebind.GetPositionX();
packet.BindPosition.Y = homebind.GetPositionY();
packet.BindPosition.Z = homebind.GetPositionZ();
packet.BindPosition = new (homebind.GetPositionX(), homebind.GetPositionY(), homebind.GetPositionZ());
packet.BindMapID = homebind.GetMapId();
packet.BindAreaID = homebindAreaId;
SendPacket(packet);