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:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user