Core/Spells: Implement SPELL_EFFECT_TELEPORT_TO_RETURN_POINT
Port From (https://github.com/TrinityCore/TrinityCore/commit/1c852af7f2c820e429eaf8389822e8c910f961a1)
This commit is contained in:
@@ -1353,6 +1353,38 @@ namespace Game.Entities
|
||||
SetArenaTeamInfoField(slot, ArenaTeamInfoType.PersonalRating, personalRatingCache[slot]);
|
||||
}
|
||||
}
|
||||
void _LoadStoredAuraTeleportLocations(SQLResult result)
|
||||
{
|
||||
// 0 1 2 3 4 5
|
||||
//QueryResult* result = CharacterDatabase.PQuery("SELECT Spell, MapId, PositionX, PositionY, PositionZ, Orientation FROM character_spell_location WHERE Guid = ?", GetGUIDLow());
|
||||
|
||||
m_storedAuraTeleportLocations.Clear();
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
uint spellId = result.Read<uint>(0);
|
||||
|
||||
if (!Global.SpellMgr.HasSpellInfo(spellId, Difficulty.None))
|
||||
{
|
||||
Log.outError(LogFilter.Spells, $"Player._LoadStoredAuraTeleportLocations: Player {GetName()} ({GetGUID()}) spell (ID: {spellId}) does not exist");
|
||||
continue;
|
||||
}
|
||||
|
||||
WorldLocation location = new WorldLocation(result.Read<uint>(1), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4), result.Read<float>(5));
|
||||
if (!GridDefines.IsValidMapCoord(location))
|
||||
{
|
||||
Log.outError(LogFilter.Spells, $"Player._LoadStoredAuraTeleportLocations: Player {GetName()} ({GetGUID()}) spell (ID: {spellId}) has invalid position on map {location.GetMapId()}, {location}.");
|
||||
continue;
|
||||
}
|
||||
|
||||
StoredAuraTeleportLocation storedLocation = m_storedAuraTeleportLocations[spellId];
|
||||
storedLocation.Loc = location;
|
||||
storedLocation.CurrentState = StoredAuraTeleportLocation.State.Unchanged;
|
||||
}
|
||||
while (result.NextRow());
|
||||
}
|
||||
}
|
||||
void _LoadGroup(SQLResult result)
|
||||
{
|
||||
if (!result.IsEmpty())
|
||||
@@ -2188,6 +2220,38 @@ namespace Game.Entities
|
||||
|
||||
m_mailsUpdated = false;
|
||||
}
|
||||
void _SaveStoredAuraTeleportLocations(SQLTransaction trans)
|
||||
{
|
||||
foreach (var pair in m_storedAuraTeleportLocations.ToList())
|
||||
{
|
||||
var storedLocation = pair.Value;
|
||||
if (storedLocation.CurrentState == StoredAuraTeleportLocation.State.Deleted)
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHARACTER_AURA_STORED_LOCATION);
|
||||
stmt.AddValue(0, GetGUID().GetCounter());
|
||||
trans.Append(stmt);
|
||||
m_storedAuraTeleportLocations.Remove(pair.Key);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (storedLocation.CurrentState == StoredAuraTeleportLocation.State.Changed)
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHARACTER_AURA_STORED_LOCATION);
|
||||
stmt.AddValue(0, GetGUID().GetCounter());
|
||||
trans.Append(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_AURA_STORED_LOCATION);
|
||||
stmt.AddValue(0, GetGUID().GetCounter());
|
||||
stmt.AddValue(1, pair.Key);
|
||||
stmt.AddValue(2, storedLocation.Loc.GetMapId());
|
||||
stmt.AddValue(3, storedLocation.Loc.GetPositionX());
|
||||
stmt.AddValue(4, storedLocation.Loc.GetPositionY());
|
||||
stmt.AddValue(5, storedLocation.Loc.GetPositionZ());
|
||||
stmt.AddValue(6, storedLocation.Loc.GetOrientation());
|
||||
trans.Append(stmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
void _SaveStats(SQLTransaction trans)
|
||||
{
|
||||
// check if stat saving is enabled and if char level is high enough
|
||||
@@ -3036,6 +3100,9 @@ namespace Game.Entities
|
||||
if (HasPlayerFlag(PlayerFlags.Ghost))
|
||||
m_deathState = DeathState.Dead;
|
||||
|
||||
// Load spell locations - must be after loading auras
|
||||
_LoadStoredAuraTeleportLocations(holder.GetResult(PlayerLoginQueryLoad.AuraStoredLocations));
|
||||
|
||||
// after spell load, learn rewarded spell if need also
|
||||
_LoadQuestStatus(holder.GetResult(PlayerLoginQueryLoad.QuestStatus));
|
||||
_LoadQuestStatusObjectives(holder.GetResult(PlayerLoginQueryLoad.QuestStatusObjectives));
|
||||
@@ -3572,6 +3639,7 @@ namespace Game.Entities
|
||||
_SaveActions(characterTransaction);
|
||||
_SaveAuras(characterTransaction);
|
||||
_SaveSkills(characterTransaction);
|
||||
_SaveStoredAuraTeleportLocations(characterTransaction);
|
||||
m_achievementSys.SaveToDB(characterTransaction);
|
||||
reputationMgr.SaveToDB(characterTransaction);
|
||||
m_questObjectiveCriteriaMgr.SaveToDB(characterTransaction);
|
||||
@@ -4096,6 +4164,10 @@ namespace Game.Entities
|
||||
stmt.AddValue(0, guid);
|
||||
trans.Append(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHARACTER_AURA_STORED_LOCATIONS_BY_GUID);
|
||||
stmt.AddValue(0, guid);
|
||||
trans.Append(stmt);
|
||||
|
||||
Corpse.DeleteFromDB(playerGuid, trans);
|
||||
|
||||
Garrison.DeleteFromDB(guid, trans);
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace Game.Entities
|
||||
MultiMap<uint, uint> m_overrideSpells = new();
|
||||
public Spell m_spellModTakingSpell;
|
||||
uint m_oldpetspell;
|
||||
Dictionary<uint, StoredAuraTeleportLocation> m_storedAuraTeleportLocations = new();
|
||||
|
||||
//Mail
|
||||
List<Mail> m_mail = new();
|
||||
@@ -611,4 +612,17 @@ namespace Game.Entities
|
||||
public ObjectGuid GroupGuid;
|
||||
public int UpdateSequenceNumber;
|
||||
}
|
||||
|
||||
class StoredAuraTeleportLocation
|
||||
{
|
||||
public WorldLocation Loc;
|
||||
public State CurrentState;
|
||||
|
||||
public enum State
|
||||
{
|
||||
Unchanged,
|
||||
Changed,
|
||||
Deleted
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2288,6 +2288,31 @@ namespace Game.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddStoredAuraTeleportLocation(uint spellId)
|
||||
{
|
||||
StoredAuraTeleportLocation storedLocation = new();
|
||||
storedLocation.Loc = new WorldLocation(this);
|
||||
storedLocation.CurrentState = StoredAuraTeleportLocation.State.Changed;
|
||||
|
||||
m_storedAuraTeleportLocations[spellId] = storedLocation;
|
||||
}
|
||||
|
||||
public void RemoveStoredAuraTeleportLocation(uint spellId)
|
||||
{
|
||||
StoredAuraTeleportLocation storedLocation = m_storedAuraTeleportLocations.LookupByKey(spellId);
|
||||
if (storedLocation != null)
|
||||
storedLocation.CurrentState = StoredAuraTeleportLocation.State.Deleted;
|
||||
}
|
||||
|
||||
public WorldLocation GetStoredAuraTeleportLocation(uint spellId)
|
||||
{
|
||||
StoredAuraTeleportLocation auraLocation = m_storedAuraTeleportLocations.LookupByKey(spellId);
|
||||
if (auraLocation != null)
|
||||
return auraLocation.Loc;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
bool AddSpell(uint spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, uint fromSkill = 0)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
|
||||
|
||||
Reference in New Issue
Block a user