hondacrx
2024-02-02 21:49:02 -05:00
parent 75201f56ce
commit 4b669cfb5d
45 changed files with 1742 additions and 1273 deletions
+3 -2
View File
@@ -127,15 +127,16 @@ namespace Game.Entities
if (!Global.ConditionMgr.IsObjectMeetingNotGroupedConditions(ConditionSourceType.ConversationLine, line.Id, creator))
continue;
var convoLine = CliDB.ConversationLineStorage.LookupByKey(line.Id); // never null for conversationTemplate->Lines
ConversationLine lineField = new();
lineField.ConversationLineID = line.Id;
lineField.BroadcastTextID = convoLine.BroadcastTextID;
lineField.UiCameraID = line.UiCameraID;
lineField.ActorIndex = line.ActorIdx;
lineField.Flags = line.Flags;
lineField.ChatType = line.ChatType;
ConversationLineRecord convoLine = CliDB.ConversationLineStorage.LookupByKey(line.Id); // never null for conversationTemplate->Lines
for (Locale locale = Locale.enUS; locale < Locale.Total; locale = locale + 1)
{
if (locale == Locale.None)
@@ -126,6 +126,43 @@ namespace Game.Entities
public bool HasValue() { return _hasValue; }
}
public class UpdateFieldArrayString
{
public string[] _values;
public int FirstElementBit;
public int Bit;
public UpdateFieldArrayString(uint size, int bit, int firstElementBit)
{
_values = new string[size];
for (var i = 0; i < size; ++i)
_values[i] = "";
Bit = bit;
FirstElementBit = firstElementBit;
}
public string this[int index]
{
get
{
return _values[index];
}
set
{
_values[index] = value;
}
}
public int GetSize() { return _values.Length; }
public IEnumerator<string> GetEnumerator()
{
foreach (var obj in _values)
yield return obj;
}
}
public class UpdateFieldArray<T> where T : new()
{
public T[] _values;
@@ -404,6 +441,8 @@ namespace Game.Entities
}
}
public void ClearChangesMask(UpdateFieldArrayString updateField) { }
public void ClearChangesMask<U>(DynamicUpdateField<U> updateField) where U : new()
{
if (typeof(IHasChangesMask).IsAssignableFrom(typeof(U)))
@@ -421,24 +460,30 @@ namespace Game.Entities
return updateField;
}
public OptionalUpdateField<U> ModifyValue<U>(OptionalUpdateField<U> updateField) where U : new()
{
MarkChanged(updateField);
return updateField;
}
public UpdateFieldString ModifyValue(UpdateFieldString updateField)
{
MarkChanged(updateField);
return updateField;
}
public OptionalUpdateField<U> ModifyValue<U>(OptionalUpdateField<U> updateField) where U : new()
{
MarkChanged(updateField);
return updateField;
}
public ref U ModifyValue<U>(UpdateFieldArray<U> updateField, int index) where U : new()
{
MarkChanged(updateField, index);
return ref updateField._values[index];
}
public ref string ModifyValue(UpdateFieldArrayString updateField, int index)
{
MarkChanged(updateField, index);
return ref updateField._values[index];
}
public DynamicUpdateField<U> ModifyValue<U>(DynamicUpdateField<U> updateField) where U : new()
{
_changesMask.Set(updateField.BlockBit);
@@ -486,6 +531,12 @@ namespace Game.Entities
_changesMask.Set(updateField.FirstElementBit + index);
}
public void MarkChanged(UpdateFieldArrayString updateField, int index)
{
_changesMask.Set(updateField.Bit);
_changesMask.Set(updateField.FirstElementBit + index);
}
public void WriteCompleteDynamicFieldUpdateMask(int size, WorldPacket data, int bitsForSize = 32)
{
data.WriteBits(size, bitsForSize);
File diff suppressed because it is too large Load Diff
@@ -832,6 +832,15 @@ namespace Game.Entities
}
}
public void SetUpdateFieldValue(ref string value, string newValue)
{
if (!newValue.Equals(value))
{
value = newValue;
AddToObjectUpdateIfNeeded();
}
}
public void SetUpdateFieldValue<T>(DynamicUpdateField<T> updateField, int index, T newValue) where T : new()
{
if (!newValue.Equals(updateField[index]))
+17 -10
View File
@@ -465,7 +465,7 @@ namespace Game.Entities
do
{
var spell = m_spells.LookupByKey(favoritesResult.Read<uint>(0));
if (spell !=null)
if (spell != null)
spell.Favorite = true;
} while (favoritesResult.NextRow());
}
@@ -1388,9 +1388,9 @@ namespace Game.Entities
if (result.IsEmpty())
return;
_declinedname = new DeclinedName();
for (byte i = 0; i < SharedConst.MaxDeclinedNameCases; ++i)
_declinedname.name[i] = result.Read<string>(i);
DeclinedNames declinedNames = m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.DeclinedNames);
for (int i = 0; i < SharedConst.MaxDeclinedNameCases; ++i)
SetUpdateFieldValue(ref declinedNames.ModifyValue(declinedNames.Name, i), result.Read<string>(i));
}
void _LoadArenaTeamInfo(SQLResult result)
{
@@ -2047,7 +2047,7 @@ namespace Game.Entities
void _SaveActions(SQLTransaction trans)
{
int traitConfigId = 0;
TraitConfig traitConfig = GetTraitConfig((int)(uint)m_activePlayerData.ActiveCombatTraitConfigID);
if (traitConfig != null)
{
@@ -2430,7 +2430,7 @@ namespace Game.Entities
m_traitConfigStates.Clear();
}
public void _SaveMail(SQLTransaction trans)
{
PreparedStatement stmt;
@@ -2863,7 +2863,11 @@ namespace Game.Entities
PlayerRestState honorRestState = (PlayerRestState)result.Read<byte>(fieldIndex++);
float honorRestBonus = result.Read<float>(fieldIndex++);
byte numRespecs = result.Read<byte>(fieldIndex++);
int personalTabardEmblemStyle = result.Read<int>(fieldIndex++);
int personalTabardEmblemColor = result.Read<int>(fieldIndex++);
int personalTabardBorderStyle = result.Read<int>(fieldIndex++);
int personalTabardBorderColor = result.Read<int>(fieldIndex++);
int personalTabardBackgroundColor = result.Read<int>(fieldIndex++);
// check if the character's account in the db and the logged in account match.
// player should be able to load/delete character only with correct account!
@@ -2895,9 +2899,10 @@ namespace Game.Entities
return false;
}
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.Name), GetName());
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.WowAccount), GetSession().GetAccountGUID());
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BnetAccount), GetSession().GetBattlenetAccountGUID());
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.BnetAccount), GetSession().GetBattlenetAccountGUID());
if (gender >= Gender.None)
{
@@ -3099,7 +3104,7 @@ namespace Game.Entities
transport = transportOnMap;
}
}
if (transport != null)
{
float x = trans_x;
@@ -3217,7 +3222,7 @@ namespace Game.Entities
else if (map.IsDungeon()) // if map is dungeon...
{
TransferAbortParams denyReason = map.CannotEnter(this); // ... and can't enter map, then look for entry point.
if (denyReason != null)
if (denyReason != null)
{
SendTransferAborted(map.GetId(), denyReason.Reason, denyReason.Arg, denyReason.MapDifficultyXConditionId);
areaTrigger = Global.ObjectMgr.GetGoBackTrigger(mapId);
@@ -3460,6 +3465,8 @@ namespace Game.Entities
}
}
SetPersonalTabard(personalTabardEmblemStyle, personalTabardEmblemColor, personalTabardBorderStyle, personalTabardBorderColor, personalTabardBackgroundColor);
Log.outDebug(LogFilter.Player, "The value of player {0} after load item and aura is: ", GetName());
// GM state
@@ -237,7 +237,6 @@ namespace Game.Entities
TimeTracker m_groupUpdateTimer;
ulong m_GuildIdInvited;
DeclinedName _declinedname;
Runes m_runes = new();
uint m_hostileReferenceCheckTimer;
uint m_drunkTimer;
+27 -14
View File
@@ -138,7 +138,6 @@ namespace Game.Entities
PlayerTalkClass.ClearMenus();
ItemSetEff.Clear();
_declinedname = null;
m_runes = null;
m_achievementSys = null;
reputationMgr = null;
@@ -816,7 +815,7 @@ namespace Game.Entities
_session.SendPacket(data);
}
public DeclinedName GetDeclinedNames() { return _declinedname; }
public DeclinedNames GetDeclinedNames() { return m_playerData.DeclinedNames.HasValue() ? m_playerData.DeclinedNames.GetValue() : null; }
public void CreateGarrison(uint garrSiteId)
{
@@ -1040,7 +1039,7 @@ namespace Game.Entities
if (!m_activePlayerData.PetStable.HasValue())
return ObjectGuid.Empty;
return m_activePlayerData.PetStable.GetValue().StableMaster;
return m_activePlayerData.PetStable.GetValue().StableMaster;
}
public void SetStableMaster(ObjectGuid stableMaster)
@@ -1051,7 +1050,7 @@ namespace Game.Entities
StableInfo stableInfo = m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.PetStable);
SetUpdateFieldValue(stableInfo.ModifyValue(stableInfo.StableMaster), stableMaster);
}
// last used pet number (for BG's)
public uint GetLastPetNumber() { return m_lastpetnumber; }
public void SetLastPetNumber(uint petnumber) { m_lastpetnumber = petnumber; }
@@ -1059,7 +1058,7 @@ namespace Game.Entities
public void SetTemporaryUnsummonedPetNumber(uint petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
public ReactStates? GetTemporaryPetReactState() { return m_temporaryPetReactState; }
public void DisablePetControlsOnMount(ReactStates reactState, CommandStates commandState)
{
Pet pet = GetPet();
@@ -2667,11 +2666,12 @@ namespace Game.Entities
case GossipOptionNpc.Binder:
case GossipOptionNpc.Banker:
case GossipOptionNpc.PetitionVendor:
case GossipOptionNpc.TabardVendor:
case GossipOptionNpc.GuildTabardVendor:
case GossipOptionNpc.Auctioneer:
case GossipOptionNpc.Mailbox:
case GossipOptionNpc.Transmogrify:
case GossipOptionNpc.AzeriteRespec:
case GossipOptionNpc.PersonalTabardVendor:
break; // No checks
case GossipOptionNpc.CemeterySelect:
canTalk = false; // Deprecated
@@ -2887,7 +2887,7 @@ namespace Game.Entities
{
PlayerInteractionType.None, PlayerInteractionType.Vendor, PlayerInteractionType.TaxiNode,
PlayerInteractionType.Trainer, PlayerInteractionType.SpiritHealer, PlayerInteractionType.Binder,
PlayerInteractionType.Banker, PlayerInteractionType.PetitionVendor, PlayerInteractionType.TabardVendor,
PlayerInteractionType.Banker, PlayerInteractionType.PetitionVendor, PlayerInteractionType.GuildTabardVendor,
PlayerInteractionType.BattleMaster, PlayerInteractionType.Auctioneer, PlayerInteractionType.TalentMaster,
PlayerInteractionType.StableMaster, PlayerInteractionType.None, PlayerInteractionType.GuildBanker,
PlayerInteractionType.None, PlayerInteractionType.None, PlayerInteractionType.None,
@@ -2902,7 +2902,8 @@ namespace Game.Entities
PlayerInteractionType.LegendaryCrafting, PlayerInteractionType.NewPlayerGuide, PlayerInteractionType.LegendaryCrafting,
PlayerInteractionType.Renown, PlayerInteractionType.BlackMarketAuctioneer, PlayerInteractionType.PerksProgramVendor,
PlayerInteractionType.ProfessionsCraftingOrder, PlayerInteractionType.Professions, PlayerInteractionType.ProfessionsCustomerOrder,
PlayerInteractionType.TraitSystem, PlayerInteractionType.BarbersChoice, PlayerInteractionType.MajorFactionRenown
PlayerInteractionType.TraitSystem, PlayerInteractionType.BarbersChoice, PlayerInteractionType.MajorFactionRenown,
PlayerInteractionType.PersonalTabardVendor
};
PlayerInteractionType interactionType = GossipOptionNpcToInteractionType[(int)gossipOptionNpc];
@@ -4313,9 +4314,9 @@ namespace Game.Entities
}
ObjectGuid GetSpiritHealerGUID() { return _areaSpiritHealerGUID; }
public bool CanAcceptAreaSpiritHealFrom(Unit spiritHealer) { return spiritHealer.GetGUID() == _areaSpiritHealerGUID; }
public void SetAreaSpiritHealer(Creature creature)
{
if (creature == null)
@@ -4349,7 +4350,7 @@ namespace Game.Entities
areaSpiritHealerTime.TimeLeft = (uint)timeLeft;
SendPacket(areaSpiritHealerTime);
}
public void KillPlayer()
{
if (IsFlying() && GetTransport() == null)
@@ -5254,7 +5255,7 @@ namespace Game.Entities
if (guildId != 0)
{
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.GuildGUID), ObjectGuid.Create(HighGuid.Guild, guildId));
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.GuildClubMemberID), GetGUID().GetCounter());
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_playerData.GuildClubMemberID), GetGUID().GetCounter());
SetPlayerFlag(PlayerFlags.GuildLevelEnabled);
}
else
@@ -5376,6 +5377,8 @@ namespace Game.Entities
StartCriteria(CriteriaStartEvent.ReachLevel, level);
UpdateCriteria(CriteriaType.ReachLevel);
UpdateCriteria(CriteriaType.ActivelyReachLevel, level);
if (level > oldLevel)
UpdateCriteria(CriteriaType.GainLevels, level - oldLevel);
PushQuests();
@@ -7691,10 +7694,10 @@ namespace Game.Entities
public void RemoveAuraVision(PlayerFieldByte2Flags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.AuraVision), (byte)flags); }
public void SetTransportServerTime(int transportServerTime) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.TransportServerTime), transportServerTime); }
public void SetRequiredMountCapabilityFlag(byte flag) { SetUpdateFieldFlagValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.RequiredMountCapabilityFlags), flag); }
public void ReplaceAllRequiredMountCapabilityFlags(byte flags) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.RequiredMountCapabilityFlags), flags); }
public bool CanTameExoticPets() { return IsGameMaster() || HasAuraType(AuraType.AllowTamePetType); }
void SendAttackSwingCantAttack() { SendPacket(new AttackSwingError(AttackSwingErr.CantAttack)); }
@@ -7874,5 +7877,15 @@ namespace Game.Entities
//Clears the Menu
public void ClearGossipMenu() { PlayerTalkClass.ClearMenus(); }
public void SetPersonalTabard(int style, int color, int borderStyle, int borderColor, int backgroundColor)
{
CustomTabardInfo personalTabard = m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PersonalTabard);
SetUpdateFieldValue(personalTabard.ModifyValue(personalTabard.EmblemStyle), style);
SetUpdateFieldValue(personalTabard.ModifyValue(personalTabard.EmblemColor), color);
SetUpdateFieldValue(personalTabard.ModifyValue(personalTabard.BorderStyle), borderStyle);
SetUpdateFieldValue(personalTabard.ModifyValue(personalTabard.BorderColor), borderColor);
SetUpdateFieldValue(personalTabard.ModifyValue(personalTabard.BackgroundColor), backgroundColor);
}
}
}
+8 -1
View File
@@ -566,7 +566,14 @@ namespace Game.Entities
public class DeclinedName
{
public StringArray name = new(SharedConst.MaxDeclinedNameCases);
}
public DeclinedName() { }
public DeclinedName(DeclinedNames uf)
{
for (var i = 0; i < SharedConst.MaxDeclinedNameCases; ++i)
name[i] = uf.Name[i];
}
}
struct PositionUpdateInfo
{
+3 -19
View File
@@ -1495,27 +1495,11 @@ namespace Game.Entities
}
}
uint modelid = 0;
SpellShapeshiftFormRecord formEntry = CliDB.SpellShapeshiftFormStorage.LookupByKey(form);
if (formEntry != null && formEntry.CreatureDisplayID[0] != 0)
{
// Take the alliance modelid as default
if (GetTypeId() != TypeId.Player)
return formEntry.CreatureDisplayID[0];
else
{
if (Player.TeamForRace(GetRace()) == Team.Alliance)
modelid = formEntry.CreatureDisplayID[0];
else
modelid = formEntry.CreatureDisplayID[1];
if (formEntry != null && formEntry.CreatureDisplayID != 0)
return formEntry.CreatureDisplayID;
// If the player is horde but there are no values for the horde modelid - take the alliance modelid
if (modelid == 0 && Player.TeamForRace(GetRace()) == Team.Horde)
modelid = formEntry.CreatureDisplayID[0];
}
}
return modelid;
return 0;
}
public Totem ToTotem() { return IsTotem() ? (this as Totem) : null; }