Core/Pets: Save last summoned pet number in characters table

Port From (https://github.com/TrinityCore/TrinityCore/commit/8349444749227b3fd95196c7d74d9a3dde22dd6b)
This commit is contained in:
hondacrx
2022-03-10 10:35:54 -05:00
parent 5322ae75dd
commit cd29996170
5 changed files with 18 additions and 28 deletions
+8
View File
@@ -2599,6 +2599,7 @@ namespace Game.Entities
float trans_o = result.Read<float>(fieldIndex++);
ulong transguid = result.Read<ulong>(fieldIndex++);
PlayerExtraFlags extra_flags = (PlayerExtraFlags)result.Read<ushort>(fieldIndex++);
uint summonedPetNumber = result.Read<uint>(fieldIndex++);
ushort at_login = result.Read<ushort>(fieldIndex++);
ushort zone = result.Read<ushort>(fieldIndex++);
byte online = result.Read<byte>(fieldIndex++);
@@ -3080,6 +3081,7 @@ namespace Game.Entities
m_taxi.LoadTaxiMask(taximask); // must be before InitTaxiNodesForLevel
_LoadPetStable(holder.GetResult(PlayerLoginQueryLoad.PetSlots));
m_temporaryUnsummonedPetNumber = summonedPetNumber;
// Honor system
// Update Honor kills data
@@ -3446,6 +3448,7 @@ namespace Game.Entities
stmt.AddValue(index++, GetTalentResetTime());
stmt.AddValue(index++, GetPrimarySpecialization());
stmt.AddValue(index++, (ushort)m_ExtraFlags);
stmt.AddValue(index++, 0); // summonedPetNumber
stmt.AddValue(index++, (ushort)atLoginFlags);
stmt.AddValue(index++, m_deathExpireTime);
@@ -3585,6 +3588,11 @@ namespace Game.Entities
stmt.AddValue(index++, GetNumRespecs());
stmt.AddValue(index++, GetPrimarySpecialization());
stmt.AddValue(index++, (ushort)m_ExtraFlags);
PetStable petStable = GetPetStable();
if (petStable != null)
stmt.AddValue(index++, petStable.CurrentPet != null && petStable.CurrentPet.Health > 0 ? petStable.CurrentPet.PetNumber : 0); // summonedPetNumber
else
stmt.AddValue(index++, 0); // summonedPetNumber
stmt.AddValue(index++, (ushort)atLoginFlags);
stmt.AddValue(index++, GetZoneId());
stmt.AddValue(index++, m_deathExpireTime);
-10
View File
@@ -897,16 +897,6 @@ namespace Game.Entities
// last used pet number (for BG's)
public uint GetLastPetNumber() { return m_lastpetnumber; }
public void SetLastPetNumber(uint petnumber) { m_lastpetnumber = petnumber; }
public void LoadPet()
{
//fixme: the pet should still be loaded if the player is not in world
// just not added to the map
if (m_petStable != null && IsInWorld)
{
Pet pet = new(this);
pet.LoadPetFromDB(this, 0, 0, true);
}
}
public uint GetTemporaryUnsummonedPetNumber() { return m_temporaryUnsummonedPetNumber; }
public void SetTemporaryUnsummonedPetNumber(uint petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
public void UnsummonPetTemporaryIfAny()
+2 -3
View File
@@ -934,7 +934,7 @@ namespace Game
}
// Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned)
pCurrChar.LoadPet();
pCurrChar.ResummonPetTemporaryUnSummonedIfAny();
// Set FFA PvP for non GM in non-rest mode
if (Global.WorldMgr.IsFFAPvPRealm() && !pCurrChar.IsGameMaster() && !pCurrChar.HasPlayerFlag(PlayerFlags.Resting))
@@ -2867,8 +2867,7 @@ namespace Game
bool result = true;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(statements[isDeletedCharacters ? 1 : 0][withDeclinedNames ? 1 : 0]);
stmt.AddValue(0, (byte)PetSaveMode.AsCurrent);
stmt.AddValue(1, accountId);
stmt.AddValue(0, accountId);
SetQuery(EnumCharacterQueryLoad.Characters, stmt);
stmt = DB.Characters.GetPreparedStatement(statements[isDeletedCharacters ? 1 : 0][2]);