Core/Players: Save homebind location on creation instead of delaying it to first login

Port From (https://github.com/TrinityCore/TrinityCore/commit/696be301d304e92245c1d332c28ae61b0390e330)
This commit is contained in:
hondacrx
2021-10-02 21:01:21 -04:00
parent 4a97883559
commit b1152ac9fa
4 changed files with 42 additions and 8 deletions
+26 -6
View File
@@ -599,11 +599,8 @@ namespace Game.Entities
}
}
if (!ok)
void saveHomebindToDb()
{
homebind = new WorldLocation(info.MapId, info.PositionX, info.PositionY, info.PositionZ, info.Orientation);
homebindAreaId = info.ZoneId;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_PLAYER_HOMEBIND);
stmt.AddValue(0, GetGUID().GetCounter());
stmt.AddValue(1, homebind.GetMapId());
@@ -612,6 +609,29 @@ namespace Game.Entities
stmt.AddValue(4, homebind.posY);
stmt.AddValue(5, homebind.posZ);
DB.Characters.Execute(stmt);
};
if (!ok && HasAtLoginFlag(AtLoginFlags.FirstLogin))
{
homebind = new WorldLocation(info.MapId, info.PositionX, info.PositionY, info.PositionZ, info.Orientation);
homebindAreaId = info.ZoneId;
saveHomebindToDb();
ok = true;
}
if (!ok)
{
WorldSafeLocsEntry loc = Global.ObjectMgr.GetDefaultGraveYard(GetTeam());
if (loc == null && GetRace() == Race.PandarenNeutral)
loc = Global.ObjectMgr.GetWorldSafeLoc(3295); // The Wandering Isle, Starting Area GY
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);
homebindAreaId = Global.MapMgr.GetAreaId(PhasingHandler.EmptyPhaseShift, loc.Loc);
saveHomebindToDb();
}
Log.outDebug(LogFilter.Player, "Setting player home position - mapid: {0}, areaid: {1}, {2}",
@@ -2703,6 +2723,8 @@ namespace Game.Entities
SetPlayerFlagsEx(playerFlagsEx);
SetWatchedFactionIndex(watchedFaction);
atLoginFlags = (AtLoginFlags)at_login;
if (!GetSession().ValidateAppearance(GetRace(), GetClass(), gender, customizations))
{
Log.outError(LogFilter.Player, "Player {0} has wrong Appearance values (Hair/Skin/Color), can't be loaded.", guid.ToString());
@@ -3050,8 +3072,6 @@ namespace Game.Entities
m_stableSlots = 4;
}
atLoginFlags = (AtLoginFlags)at_login;
// Honor system
// Update Honor kills data
m_lastHonorUpdateTime = logoutTime;
+3
View File
@@ -197,6 +197,9 @@ namespace Game.Entities
m_createTime = GameTime.GetGameTime();
UpdatePositionData();
// set initial homebind position
SetHomebind(this, GetAreaId());
PowerType powertype = cEntry.DisplayPower;
SetObjectScale(1.0f);
+2 -1
View File
@@ -802,7 +802,7 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_worldSafeLocs.Count} world locations {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
}
WorldSafeLocsEntry GetDefaultGraveYard(Team team)
public WorldSafeLocsEntry GetDefaultGraveYard(Team team)
{
if (team == Team.Horde)
return GetWorldSafeLoc(10);
@@ -810,6 +810,7 @@ namespace Game
return GetWorldSafeLoc(4);
else return null;
}
public WorldSafeLocsEntry GetClosestGraveYard(WorldLocation location, Team team, WorldObject conditionObject)
{
float x, y, z;
+11 -1
View File
@@ -412,12 +412,22 @@ namespace Game.Entities
return i_maps.LookupByKey(mapId);
}
uint GetAreaId(PhaseShift phaseShift, uint mapid, float x, float y, float z)
public uint GetAreaId(PhaseShift phaseShift, uint mapid, float x, float y, float z)
{
Map m = CreateBaseMap(mapid);
return m.GetAreaId(phaseShift, x, y, z);
}
public uint GetAreaId(PhaseShift phaseShift, uint mapid, Position pos)
{
return GetAreaId(phaseShift, mapid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
}
public uint GetAreaId(PhaseShift phaseShift, WorldLocation loc)
{
return GetAreaId(phaseShift, loc.GetMapId(), loc);
}
public uint GetZoneId(PhaseShift phaseShift, uint mapid, float x, float y, float z)
{
Map m = CreateBaseMap(mapid);