Updated to 8.2.0.31429 (scripts disabled atm, they still need updated)

Code Port from TrinityCore https://github.com/TrinityCore/TrinityCore
Casc from WoW-Tools https://github.com/WoW-Tools/CASCExplorer
This commit is contained in:
hondacrx
2019-08-14 11:20:42 -04:00
parent e4d500f4b5
commit 125e3b3ac7
232 changed files with 12268 additions and 14670 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<Import Project="..\..\default.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<StartupObject>BNetServer.Server</StartupObject>
<ApplicationIcon>Red.ico</ApplicationIcon>
</PropertyGroup>
+9 -9
View File
@@ -212,13 +212,13 @@ namespace Framework.Constants
CommandDebugBg = 304,
CommandDebugEntervehicle = 305,
CommandDebugGetitemstate = 306,
CommandDebugGetitemvalue = 307,
CommandDebugGetvalue = 308,
CommandDebugGetitemvalue = 307, // DEPRECATED: DON'T REUSE
CommandDebugGetvalue = 308, // DEPRECATED: DON'T REUSE
CommandDebugHostil = 309,
CommandDebugItemexpire = 310,
CommandDebugLootrecipient = 311,
CommandDebugLos = 312,
CommandDebugMod32value = 313,
CommandDebugMod32value = 313, // DEPRECATED: DON'T REUSE
CommandDebugMoveflags = 314,
CommandDebugPlay = 315,
CommandDebugPlayCinematic = 316,
@@ -237,13 +237,13 @@ namespace Framework.Constants
CommandDebugSendSetphaseshift = 329,
CommandDebugSendSpellfail = 330,
CommandDebugSetaurastate = 331,
CommandDebugSetbit = 332,
CommandDebugSetitemvalue = 333,
CommandDebugSetvalue = 334,
CommandDebugSetbit = 332, // DEPRECATED: DON'T REUSE
CommandDebugSetitemvalue = 333, // DEPRECATED: DON'T REUSE
CommandDebugSetvalue = 334, // DEPRECATED: DON'T REUSE
CommandDebugSetvid = 335,
CommandDebugSpawnvehicle = 336,
CommandDebugThreat = 337,
CommandDebugUpdate = 338,
CommandDebugUpdate = 338, // DEPRECATED: DON'T REUSE
CommandDebugUws = 339,
CommandWpgps = 340,
CommandDeserter = 341,
@@ -451,7 +451,7 @@ namespace Framework.Constants
CommandDemorph = 543,
CommandModify = 544,
CommandModifyArenapoints = 545,
CommandModifyBit = 546,
CommandModifyBit = 546, // DEPRECATED: DON'T REUSE
CommandModifyDrunk = 547,
CommandModifyEnergy = 548,
CommandModifyFaction = 549,
@@ -558,7 +558,7 @@ namespace Framework.Constants
CommandReloadSupportSystem = 650,
CommandReloadGossipMenu = 651,
CommandReloadGossipMenuOption = 652,
CommandReloadItemEnchantmentTemplate = 653,
CommandReloadItemRandomBonusListTemplate = 653,
CommandReloadItemLootTemplate = 654,
CommandReloadItemSetNames = 655,
CommandReloadLfgDungeonRewards = 656,
@@ -411,7 +411,7 @@ namespace Framework.Constants
ReachAccountHonorLevel = 213,
HeartOfAzerothArtifactPowerEarned = 214,
HeartOfAzerothLevelReached = 215,
TotalTypes
TotalTypes = 217
}
public enum CriteriaDataType
+14 -9
View File
@@ -110,7 +110,7 @@ namespace Framework.Constants
Unk1 = 0x01,
}
public enum NPCFlags : ulong
public enum NPCFlags : uint
{
None = 0x00,
Gossip = 0x01, // 100%
@@ -145,14 +145,19 @@ namespace Framework.Constants
VaultKeeper = 0x20000000, // Void Storage
WildBattlePet = 0x40000000, // Pet That Player Can Fight (Battle Pet)
BlackMarket = 0x80000000, // Black Market
ItemUpgradeMaster = 0x100000000,
GarrisonArchitect = 0x200000000,
Steering = 0x400000000,
ShipmentCrafter = 0x1000000000,
GarrisonMissionNpc = 0x2000000000,
TradeskillNpc = 0x4000000000,
BlackMarketView = 0x8000000000,
ContributionCollector = 0x40000000000,
}
public enum NPCFlags2
{
None = 0x00,
ItemUpgradeMaster = 0x01,
GarrisonArchitect = 0x02,
Steering = 0x04,
ShipmentCrafter = 0x10,
GarrisonMissionNpc = 0x20,
TradeskillNpc = 0x40,
BlackMarketView = 0x80,
ContributionCollector = 0x400,
}
public enum CreatureTypeFlags : uint
-1
View File
@@ -29,7 +29,6 @@ namespace Framework.Constants
public const int MaxOutfitItems = 24;
public const int MaxItemExtCostItems = 5;
public const int MaxItemExtCostCurrencies = 5;
public const int MaxItemRandomProperties = 5;
public const int MaxItemEnchantmentEffects = 3;
public const int MaxProtoSpells = 5;
public const int MaxEquipmentSetIndex = 20;
@@ -21,8 +21,8 @@ namespace Framework.Constants
public enum SessionStatus
{
Authed = 0, // Player authenticated (_player == NULL, m_playerRecentlyLogout = false or will be reset before handler call, m_GUID have garbage)
Loggedin, // Player in game (_player != NULL, m_GUID == _player->GetGUID(), inWorld())
Transfer, // Player transferring to another map (_player != NULL, m_GUID == _player->GetGUID(), !inWorld())
Loggedin, // Player in game (_player != NULL, m_GUID == _player.GetGUID(), inWorld())
Transfer, // Player transferring to another map (_player != NULL, m_GUID == _player.GetGUID(), !inWorld())
LoggedinOrRecentlyLogout, // _player != NULL or _player == NULL && m_playerRecentlyLogout && m_playerLogout, m_GUID store last _player guid)
}
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -32,7 +32,8 @@ namespace Framework.Constants
Corpse = 10,
AreaTrigger = 11,
SceneObject = 12,
Conversation = 13
Conversation = 13,
Max = 14
}
public enum TypeMask
+4 -45
View File
@@ -30,14 +30,11 @@ namespace Framework.Constants
public const int MaxMasterySpells = 2;
public const int ReqPrimaryTreeTalents = 31;
public const int ExploredZonesSize = 320;
public const int ExploredZonesSize = 192;
public const ulong MaxMoneyAmount = 99999999999UL;
public const int MaxActionButtons = 132;
public const int MaxActionButtonActionValue = 0x00FFFFFF + 1;
public const uint KnowTitlesSize = 6;
public const uint MaxTitleIndex = KnowTitlesSize * 64;
public const int MaxDailyQuests = 25;
public const int QuestsCompletedBitsSize = 1750;
@@ -45,7 +42,7 @@ namespace Framework.Constants
public const uint infinityCooldownDelayCheck = Time.Month / 2;
public const int MaxPlayerSummonDelay = 2 * Time.Minute;
public const int TaxiMaskSize = 286;
public const int TaxiMaskSize = 311;
// corpse reclaim times
public const int DeathExpireStep = (5 * Time.Minute);
@@ -76,45 +73,6 @@ namespace Framework.Constants
public const int Gold = Silver * 100;
}
public struct PlayerFieldOffsets
{
public const byte BytesOffsetSkinId = 0;
public const byte BytesOffsetFaceId = 1;
public const byte BytesOffsetHairStyleId = 2;
public const byte BytesOffsetHairColorId = 3;
public const byte Bytes2OffsetCustomDisplayOption = 0; // 3 Bytes
public const byte Bytes2OffsetFacialStyle = 3;
public const byte Bytes3OffsetPartyType = 0;
public const byte Bytes3OffsetBankBagSlots = 1;
public const byte Bytes3OffsetGender = 2;
public const byte Bytes3OffsetInebriation = 3;
public const byte Bytes4OffsetPvpTitle = 0;
public const byte Bytes4OffsetArenaFaction = 1;
public const byte FieldBytesOffsetRafGrantableLevel = 0;
public const byte FieldBytesOffsetActionBarToggles = 1;
public const byte FieldBytesOffsetLifetimeMaxPvpRank = 2;
public const byte FieldBytesOffsetNumRespecs = 3;
public const byte FieldBytes2OffsetIgnorePowerRegenPredictionMask = 0;
public const byte FieldBytes2OffsetAuraVision = 1;
public const byte FieldBytes2OffsetNumBackpackSlots = 2;
public const byte FieldBytes3OffsetOverrideSpellsId = 2; // Uint16!
public const byte FieldBytes3OffsetOverrideSpellsIdUint16Offset = FieldBytes3OffsetOverrideSpellsId / 2;
public const byte FieldKillsOffsetTodayKills = 0;
public const byte FieldKillsOffsetYesterdayKills = 1;
public const byte RestStateXp = 0;
public const byte RestRestedXp = 1;
public const byte RestStateHonor = 2;
public const byte RestRestedHonor = 3;
}
public enum TradeSlots
{
Invalid = -1,
@@ -737,7 +695,8 @@ namespace Framework.Constants
None = 0x00,
BonusLevel90 = 0x01,
BonusLevel100 = 0x02,
BonusLevel110 = 0x04
BonusLevel110 = 0x04,
BonusLevel120 = 0x08
}
public enum HeirloomItemFlags
File diff suppressed because it is too large Load Diff
@@ -709,7 +709,8 @@ namespace Framework.Constants
WrongFaction = 292,
NotEnoughCurrency = 293,
BattleForAzerothRidingRequirement = 294,
Unknown = 295,
MountEquipmentError = 295,
Unknown = 296,
// Ok Cast Value - Here In Case A Future Version Removes Success And We Need To Use A Custom Value (Not Sent To Client Either Way)
SpellCastOk = Success
@@ -1711,7 +1712,7 @@ namespace Framework.Constants
Unk4 = 0x10, // 4
AbsorbEnvironmentalDamage = 0x20, // 5
Unk6 = 0x40, // 6
RankIgnoresCasterLevel = 0x80, // 7 Spell_C_GetSpellRank returns SpellLevels->MaxLevel * 5 instead of std::min(SpellLevels->MaxLevel, caster->Level) * 5
RankIgnoresCasterLevel = 0x80, // 7 Spell_C_GetSpellRank returns SpellLevels.MaxLevel * 5 instead of std::min(SpellLevels.MaxLevel, caster.Level) * 5
Unk8 = 0x100, // 8
Unk9 = 0x200, // 9
Unk10 = 0x400, // 10
@@ -2090,7 +2091,17 @@ namespace Framework.Constants
RespecAzeriteEmpoweredItem = 259,
SummonStabledPet = 260,
ScrapItem = 261,
TotalSpellEffects,
Unk262 = 262,
RepairItem = 263,
RemoveGem = 264,
LearnAzeriteEssencePower = 265,
Unk266 = 266,
Unk267 = 267,
ApplyMountEquipment = 268,
UpgradeItem = 269,
Unk270 = 270,
ApplyAreaAuraPartyNonrandom = 271,
TotalSpellEffects
}
public enum SpellEffectHandle
+7 -28
View File
@@ -242,7 +242,7 @@ namespace Framework.Constants
/// <summary>
/// UnitStandStateType
/// </summary>
public enum UnitStandStateType
public enum UnitStandStateType : byte
{
Stand = 0,
Sit = 1,
@@ -256,23 +256,7 @@ namespace Framework.Constants
Submerged = 9
}
public struct UnitBytes0Offsets
{
public const byte Race = 0;
public const byte Class = 1;
public const byte PlayerClass = 2;
public const byte Gender = 3;
}
public struct UnitBytes1Offsets
{
public const byte StandState = 0;
public const byte PetTalents = 1; // unused
public const byte VisFlag = 2;
public const byte AnimTier = 3;
}
public enum UnitStandFlags
public enum UnitVisFlags
{
Unk1 = 0x01,
Creep = 0x02,
@@ -284,22 +268,16 @@ namespace Framework.Constants
public enum UnitBytes1Flags
{
None = 0x00,
AlwaysStand = 0x01,
Hover = 0x02,
Unk3 = 0x04,
All = 0xFF
}
public struct UnitBytes2Offsets
{
public const byte SheathState = 0;
public const byte PvpFlag = 1;
public const byte PetFlags = 2;
public const byte ShapeshiftForm = 3;
}
public enum UnitBytes2Flags
public enum UnitPVPStateFlags
{
None = 0x00,
PvP = 0x01,
Unk1 = 0x02,
FFAPvp = 0x04,
@@ -310,8 +288,9 @@ namespace Framework.Constants
Unk7 = 0x80,
}
public enum UnitPetFlags
public enum UnitPetFlags : byte
{
None = 0x00,
CanBeRenamed = 0x01,
CanBeAbandoned = 0x02
}
File diff suppressed because it is too large Load Diff
@@ -1,455 +0,0 @@
/*
* Copyright (C) 2012-2019 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Framework.Constants
{
public enum ObjectFields
{
Guid = 0x000, // Size: 4, Flags: Public
Entry = 0x004, // Size: 1, Flags: Dynamic
DynamicFlags = 0x005, // Size: 1, Flags: Dynamic, Urgent
ScaleX = 0x006, // Size: 1, Flags: Public
End = 0x007,
}
public enum ItemFields
{
Owner = ObjectFields.End + 0x000, // Size: 4, Flags: Public
Contained = ObjectFields.End + 0x004, // Size: 4, Flags: Public
Creator = ObjectFields.End + 0x008, // Size: 4, Flags: Public
GiftCreator = ObjectFields.End + 0x00c, // Size: 4, Flags: Public
StackCount = ObjectFields.End + 0x010, // Size: 1, Flags: Owner
Duration = ObjectFields.End + 0x011, // Size: 1, Flags: Owner
SpellCharges = ObjectFields.End + 0x012, // Size: 5, Flags: Owner
Flags = ObjectFields.End + 0x017, // Size: 1, Flags: Public
Enchantment = ObjectFields.End + 0x018, // Size: 39, Flags: Public
PropertySeed = ObjectFields.End + 0x03f, // Size: 1, Flags: Public
RandomPropertiesId = ObjectFields.End + 0x040, // Size: 1, Flags: Public
Durability = ObjectFields.End + 0x041, // Size: 1, Flags: Owner
MaxDurability = ObjectFields.End + 0x042, // Size: 1, Flags: Owner
CreatePlayedTime = ObjectFields.End + 0x043, // Size: 1, Flags: Public
ModifiersMask = ObjectFields.End + 0x044, // Size: 1, Flags: Owner
Context = ObjectFields.End + 0x045, // Size: 1, Flags: Public
ArtifactXp = ObjectFields.End + 0x046, // Size: 2, Flags: OWNER
AppearanceModId = ObjectFields.End + 0x048, // Size: 1, Flags: OWNER
End = ObjectFields.End + 0x049
}
public enum ItemDynamicFields
{
Modifiers = 0x000, // Flags: Owner
BonusListIds = 0x001, // Flags: Owner, 0x100
ArtifactPowers = 0x002, // Flags: OWNER
Gems = 0x003, // Flags: OWNER
End = 0x004
}
public enum ContainerFields
{
Slot1 = ItemFields.End + 0x000, // Size: 144, Flags: Public
NumSlots = ItemFields.End + 0x090, // Size: 1, Flags: Public
End = ItemFields.End + 0x091
}
public enum AzeriteEmpoweredItemFields
{
Selections = ItemFields.End + 0x000, // Size: 4, Flags: PUBLIC
End = ItemFields.End + 0x004,
}
public enum AzeriteEmpoweredItemDynamicFields
{
End = ItemDynamicFields.End + 0x000,
}
public enum AzeriteItemFields
{
Xp = ItemFields.End + 0x000, // Size: 2, Flags: PUBLIC
Level = ItemFields.End + 0x002, // Size: 1, Flags: PUBLIC
AuraLevel = ItemFields.End + 0x003, // Size: 1, Flags: PUBLIC
KnowledgeLevel = ItemFields.End + 0x004, // Size: 1, Flags: OWNER
DebugKnowledgeWeek = ItemFields.End + 0x005, // Size: 1, Flags: OWNER
End = ItemFields.End + 0x006,
}
public enum AzeriteItemDynamicFields
{
End = ItemDynamicFields.End + 0x000,
}
public enum UnitFields
{
Charm = ObjectFields.End + 0x000, // Size: 4, Flags: Public
Summon = ObjectFields.End + 0x004, // Size: 4, Flags: Public
Critter = ObjectFields.End + 0x008, // Size: 4, Flags: Privaten
CharmedBy = ObjectFields.End + 0x00c, // Size: 4, Flags: Public
SummonedBy = ObjectFields.End + 0x010, // Size: 4, Flags: Public
CreatedBy = ObjectFields.End + 0x014, // Size: 4, Flags: Public
DemonCreator = ObjectFields.End + 0x018, // Size: 4, Flags: Public
LookAtControllerTarget = ObjectFields.End + 0x01c, // Size: 4, Flags: Public
Target = ObjectFields.End + 0x020, // Size: 4, Flags: Public
BattlePetCompanionGuid = ObjectFields.End + 0x024, // Size: 4, Flags: Public
BattlePetDbId = ObjectFields.End + 0x028, // Size: 2, Flags: Public
ChannelData = ObjectFields.End + 0x02a, // Size: 2, Flags: Public, Urgent
SummonedByHomeRealm = ObjectFields.End + 0x02c, // Size: 1, Flags: Public
Bytes0 = ObjectFields.End + 0x02d, // Size: 1, Flags: Public
DisplayPower = ObjectFields.End + 0x02e, // Size: 1, Flags: Public
OverrideDisplayPowerId = ObjectFields.End + 0x02f, // Size: 1, Flags: Public
Health = ObjectFields.End + 0x030, // Size: 2, Flags: Public
Power = ObjectFields.End + 0x032, // Size: 6, Flags: Public, UrgentSelfOnly
MaxHealth = ObjectFields.End + 0x038, // Size: 2, Flags: Public
MaxPower = ObjectFields.End + 0x03a, // Size: 6, Flags: Public
PowerRegenFlatModifier = ObjectFields.End + 0x040, // Size: 6, Flags: Private, Owner, UnitAll
PowerRegenInterruptedFlatModifier = ObjectFields.End + 0x046, // Size: 6, Flags: Private, Owner, UnitAll
Level = ObjectFields.End + 0x04c, // Size: 1, Flags: Public
EffectiveLevel = ObjectFields.End + 0x04d, // Size: 1, Flags: Public
ContentTuningId = ObjectFields.End + 0x04e, // Size: 1, Flags: Public
ScalingLevelMin = ObjectFields.End + 0x04f, // Size: 1, Flags: Public
ScalingLevelMax = ObjectFields.End + 0x050, // Size: 1, Flags: Public
ScalingLevelDelta = ObjectFields.End + 0x051, // Size: 1, Flags: Public
ScalingFactionGroup = ObjectFields.End + 0x052, // Size: 1, Flags: Public
ScalingHealthItemLevelCurveId = ObjectFields.End + 0x053, // Size: 1, Flags: Public
ScalingDamageItemLevelCurveId = ObjectFields.End + 0x054, // Size: 1, Flags: Public
FactionTemplate = ObjectFields.End + 0x055, // Size: 1, Flags: Public
VirtualItemSlotId = ObjectFields.End + 0x056, // Size: 6, Flags: Public
Flags = ObjectFields.End + 0x05c, // Size: 1, Flags: Public, Urgent
Flags2 = ObjectFields.End + 0x05d, // Size: 1, Flags: Public, Urgent
Flags3 = ObjectFields.End + 0x05e, // Size: 1, Flags: Public, UrgentScalingLevelDelta
AuraState = ObjectFields.End + 0x05f, // Size: 1, Flags: Public
BaseAttackTime = ObjectFields.End + 0x060, // Size: 2, Flags: Public
RangedAttackTime = ObjectFields.End + 0x062, // Size: 1, Flags: Private
BoundingRadius = ObjectFields.End + 0x063, // Size: 1, Flags: Public
CombatReach = ObjectFields.End + 0x064, // Size: 1, Flags: Public
DisplayId = ObjectFields.End + 0x065, // Size: 1, Flags: Dynamic, Urgent
DisplayScale = ObjectFields.End + 0x066, // Size: 1, Flags: Dynamic, Urgent
NativeDisplayId = ObjectFields.End + 0x067, // Size: 1, Flags: Public, Urgent
NativeXDisplayScale = ObjectFields.End + 0x068, // Size: 1, Flags: Public, Urgent
MountDisplayId = ObjectFields.End + 0x069, // Size: 1, Flags: Public, Urgent
MinDamage = ObjectFields.End + 0x06a, // Size: 1, Flags: Private, Owner, SpecialInfo
MaxDamage = ObjectFields.End + 0x06b, // Size: 1, Flags: Private, Owner, SpecialInfo
MinOffHandDamage = ObjectFields.End + 0x06c, // Size: 1, Flags: Private, Owner, SpecialInfo
MaxOffHandDamage = ObjectFields.End + 0x06d, // Size: 1, Flags: Private, Owner, SpecialInfo
Bytes1 = ObjectFields.End + 0x06e, // Size: 1, Flags: Public
PetNumber = ObjectFields.End + 0x06f, // Size: 1, Flags: Public
PetNameTimestamp = ObjectFields.End + 0x070, // Size: 1, Flags: Public
PetExperience = ObjectFields.End + 0x071, // Size: 1, Flags: Owner
PetNextLevelExp = ObjectFields.End + 0x072, // Size: 1, Flags: Owner
ModCastSpeed = ObjectFields.End + 0x073, // Size: 1, Flags: Public
ModCastHaste = ObjectFields.End + 0x074, // Size: 1, Flags: Public
ModHaste = ObjectFields.End + 0x075, // Size: 1, Flags: Public
ModRangedHaste = ObjectFields.End + 0x076, // Size: 1, Flags: Public
ModHasteRegen = ObjectFields.End + 0x077, // Size: 1, Flags: Public
ModTimeRate = ObjectFields.End + 0x078, // Size: 1, Flags: Public
CreatedBySpell = ObjectFields.End + 0x079, // Size: 1, Flags: Public
NpcFlags = ObjectFields.End + 0x07a, // Size: 2, Flags: Public, Dynamic
NpcEmotestate = ObjectFields.End + 0x07c, // Size: 1, Flags: Public
Stat = ObjectFields.End + 0x07d, // Size: 4, Flags: Private, Owner
PosStat = ObjectFields.End + 0x081, // Size: 4, Flags: Private, Owner
NegStat = ObjectFields.End + 0x085, // Size: 4, Flags: Private, Owner
Resistances = ObjectFields.End + 0x089, // Size: 7, Flags: Private, Owner, SpecialInfo
BonusResistanceMods = ObjectFields.End + 0x090, // Size: 7, Flags: Private, Owner
BaseMana = ObjectFields.End + 0x097, // Size: 1, Flags: Public
BaseHealth = ObjectFields.End + 0x098, // Size: 1, Flags: Private, Owner
Bytes2 = ObjectFields.End + 0x099, // Size: 1, Flags: Public
AttackPower = ObjectFields.End + 0x09a, // Size: 1, Flags: Private, Owner
AttackPowerModPos = ObjectFields.End + 0x09b, // Size: 1, Flags: Private, Owner
AttackPowerModNeg = ObjectFields.End + 0x09c, // Size: 1, Flags: Private, Owner
AttackPowerMultiplier = ObjectFields.End + 0x09d, // Size: 1, Flags: Private, Owner
RangedAttackPower = ObjectFields.End + 0x09e, // Size: 1, Flags: Private, Owner
RangedAttackPowerModPos = ObjectFields.End + 0x09f, // Size: 1, Flags: Private, Owner
RangedAttackPowerModNeg = ObjectFields.End + 0x0a0, // Size: 1, Flags: Private, Owner
RangedAttackPowerMultiplier = ObjectFields.End + 0x0a1, // Size: 1, Flags: Private, Owner
MainHandWeaponAttackPower = ObjectFields.End + 0x0a2, // Size: 1, Flags: Private, Owner
OffHandWeaponAttackPower = ObjectFields.End + 0x0a3, // Size: 1, Flags: Private, Owner
RangedHandWeaponAttackPower = ObjectFields.End + 0x0a4, // Size: 1, Flags: Private, Owner
AttackSpeedAura = ObjectFields.End + 0x0a5, // Size: 1, Flags: Private, Owner
Lifesteal = ObjectFields.End + 0x0a6, // Size: 1, Flags: Private, Owner
MinRangedDamage = ObjectFields.End + 0x0a7, // Size: 1, Flags: Private, Owner
MaxRangedDamage = ObjectFields.End + 0x0a8, // Size: 1, Flags: Private, Owner
PowerCostModifier = ObjectFields.End + 0x0a9, // Size: 7, Flags: Private, Owner
PowerCostMultiplier = ObjectFields.End + 0x0b0, // Size: 7, Flags: Private, Owner
MaxHealthModifier = ObjectFields.End + 0x0b7, // Size: 1, Flags: Private, Owner
HoverHeight = ObjectFields.End + 0x0b8, // Size: 1, Flags: Public
MinItemLevelCutoff = ObjectFields.End + 0x0b9, // Size: 1, Flags: Public
MinItemLevel = ObjectFields.End + 0x0ba, // Size: 1, Flags: Public
MaxItemlevel = ObjectFields.End + 0x0bb, // Size: 1, Flags: Public
WildBattlepetLevel = ObjectFields.End + 0x0bc, // Size: 1, Flags: Public
BattlepetCompanionNameTimestamp = ObjectFields.End + 0x0bd, // Size: 1, Flags: Public
InteractSpellid = ObjectFields.End + 0x0be, // Size: 1, Flags: Public
StateSpellVisualId = ObjectFields.End + 0x0bf, // Size: 1, Flags: Dynamic, Urgent
StateAnimId = ObjectFields.End + 0x0c0, // Size: 1, Flags: Dynamic, Urgent
StateAnimKitId = ObjectFields.End + 0x0c1, // Size: 1, Flags: Dynamic, Urgent
StateWorldEffectId = ObjectFields.End + 0x0c2, // Size: 4, Flags: Dynamic, Urgent
ScaleDuration = ObjectFields.End + 0x0c6, // Size: 1, Flags: Public
LooksLikeMountId = ObjectFields.End + 0x0c7, // Size: 1, Flags: Public
LooksLikeCreatureId = ObjectFields.End + 0x0c8, // Size: 1, Flags: Public
LookAtControllerId = ObjectFields.End + 0x0c9, // Size: 1, Flags: Public
GuildGuid = ObjectFields.End + 0x0ca, // Size: 4, Flags: Public
End = ObjectFields.End + 0x0ce
}
public enum UnitDynamicFields
{
PassiveSpells = 0x000, // Flags: Public, Urgent
WorldEffects = 0x001, // Flags: Public, Urgent
ChannelObjects = 0x002, // Flags: PUBLIC, URGENT
End = 0x003
}
public enum PlayerFields
{
DuelArbiter = UnitFields.End + 0x000, // Size: 4, Flags: Public
WowAccount = UnitFields.End + 0x004, // Size: 4, Flags: Public
LootTargetGuid = UnitFields.End + 0x008, // Size: 4, Flags: Public
Flags = UnitFields.End + 0x00c, // Size: 1, Flags: Public
FlagsEx = UnitFields.End + 0x00d, // Size: 1, Flags: Public
GuildRank = UnitFields.End + 0x00e, // Size: 1, Flags: Public
GuildDeleteDate = UnitFields.End + 0x00f, // Size: 1, Flags: Public
GuildLevel = UnitFields.End + 0x010, // Size: 1, Flags: Public
Bytes = UnitFields.End + 0x011, // Size: 1, Flags: Public
Bytes2 = UnitFields.End + 0x012, // Size: 1, Flags: Public
Bytes3 = UnitFields.End + 0x013, // Size: 1, Flags: Public
Bytes4 = UnitFields.End + 0x014, // Size: 1, Flags: Public
DuelTeam = UnitFields.End + 0x015, // Size: 1, Flags: Public
GuildTimestamp = UnitFields.End + 0x016, // Size: 1, Flags: Public
QuestLog = UnitFields.End + 0x017, // Size: 1600, Flags: PartyMember
VisibleItem = UnitFields.End + 0x657, // Size: 38, Flags: Public
ChosenTitle = UnitFields.End + 0x67d, // Size: 1, Flags: Public
FakeInebriation = UnitFields.End + 0x67e, // Size: 1, Flags: Public
VirtualRealm = UnitFields.End + 0x67f, // Size: 1, Flags: Public
CurrentSpecId = UnitFields.End + 0x680, // Size: 1, Flags: Public
TaxiMountAnimKitId = UnitFields.End + 0x681, // Size: 1, Flags: Public
AvgItemLevel = UnitFields.End + 0x682, // Size: 4, Flags: Public
CurrentBattlePetBreedQuality = UnitFields.End + 0x686, // Size: 1, Flags: Public
HonorLevel = UnitFields.End + 0x687, // Size: 1, Flags: Public
End = UnitFields.End + 0x688
}
public enum PlayerDynamicFields
{
ArenaCooldowns = UnitDynamicFields.End + 0x000, // Flags: Public
End = UnitDynamicFields.End + 0x001,
}
public enum ActivePlayerFields
{
InvSlotHead = PlayerFields.End + 0x000, // Size: 780, Flags: Public
Farsight = PlayerFields.End + 0x30c, // Size: 4, Flags: Public
SummonedBattlePetId = PlayerFields.End + 0x310, // Size: 4, Flags: Public
KnownTitles = PlayerFields.End + 0x314, // Size: 12, Flags: Public
Coinage = PlayerFields.End + 0x320, // Size: 2, Flags: Public
Xp = PlayerFields.End + 0x322, // Size: 1, Flags: Public
NextLevelXp = PlayerFields.End + 0x323, // Size: 1, Flags: Public
TrialXp = PlayerFields.End + 0x324, // Size: 1, Flags: Public
SkillLineId = PlayerFields.End + 0x325, // Size: 128, Flags: Public
SkillLineStep = PlayerFields.End + 0x3a5, // Size: 128, Flags: Public
SkillLineRank = PlayerFields.End + 0x425, // Size: 128, Flags: Public
SkillLineStartRank = PlayerFields.End + 0x4a5, // Size: 128, Flags: Public
SkillLineMaxRank = PlayerFields.End + 0x525, // Size: 128, Flags: Public
SkillLineTempBonus = PlayerFields.End + 0x5a5, // Size: 128, Flags: Public
SkillLinePermBonus = PlayerFields.End + 0x625, // Size: 128, Flags: Public
CharacterPoints = PlayerFields.End + 0x6a5, // Size: 1, Flags: Public
MaxTalentTiers = PlayerFields.End + 0x6a6, // Size: 1, Flags: Public
TrackCreatures = PlayerFields.End + 0x6a7, // Size: 1, Flags: Public
TrackResources = PlayerFields.End + 0x6a8, // Size: 2, Flags: Public
Expertise = PlayerFields.End + 0x6aa, // Size: 1, Flags: Public
OffhandExpertise = PlayerFields.End + 0x6ab, // Size: 1, Flags: Public
RangedExpertise = PlayerFields.End + 0x6ac, // Size: 1, Flags: Public
CombatRatingExpertise = PlayerFields.End + 0x6ad, // Size: 1, Flags: Public
BlockPercentage = PlayerFields.End + 0x6ae, // Size: 1, Flags: Public
DodgePercentage = PlayerFields.End + 0x6af, // Size: 1, Flags: Public
DodgePercentageFromAttribute = PlayerFields.End + 0x6b0, // Size: 1, Flags: Public
ParryPercentage = PlayerFields.End + 0x6b1, // Size: 1, Flags: Public
ParryPercentageFromAttribute = PlayerFields.End + 0x6b2, // Size: 1, Flags: Public
CritPercentage = PlayerFields.End + 0x6b3, // Size: 1, Flags: Public
RangedCritPercentage = PlayerFields.End + 0x6b4, // Size: 1, Flags: Public
OffhandCritPercentage = PlayerFields.End + 0x6b5, // Size: 1, Flags: Public
SpellCritPercentage1 = PlayerFields.End + 0x6b6, // Size: 1, Flags: Public
ShieldBlock = PlayerFields.End + 0x6b7, // Size: 1, Flags: Public
ShieldBlockCritPercentage = PlayerFields.End + 0x6b8, // Size: 1, Flags: Public
Mastery = PlayerFields.End + 0x6b9, // Size: 1, Flags: Public
Speed = PlayerFields.End + 0x6ba, // Size: 1, Flags: Public
Avoidance = PlayerFields.End + 0x6bb, // Size: 1, Flags: Public
Sturdiness = PlayerFields.End + 0x6bc, // Size: 1, Flags: Public
Versatility = PlayerFields.End + 0x6bd, // Size: 1, Flags: Public
VersatilityBonus = PlayerFields.End + 0x6be, // Size: 1, Flags: Public
PvpPowerDamage = PlayerFields.End + 0x6bf, // Size: 1, Flags: Public
PvpPowerHealing = PlayerFields.End + 0x6c0, // Size: 1, Flags: Public
ExploredZones = PlayerFields.End + 0x6c1, // Size: 320, Flags: Public
RestInfo = PlayerFields.End + 0x801, // Size: 4, Flags: Public
ModDamageDonePos = PlayerFields.End + 0x805, // Size: 7, Flags: Public
ModDamageDoneNeg = PlayerFields.End + 0x80c, // Size: 7, Flags: Public
ModDamageDonePct = PlayerFields.End + 0x813, // Size: 7, Flags: Public
ModHealingDonePos = PlayerFields.End + 0x81a, // Size: 1, Flags: Public
ModHealingPct = PlayerFields.End + 0x81b, // Size: 1, Flags: Public
ModHealingDonePct = PlayerFields.End + 0x81c, // Size: 1, Flags: Public
ModPeriodicHealingDonePercent = PlayerFields.End + 0x81d, // Size: 1, Flags: Public
WeaponDmgMultipliers = PlayerFields.End + 0x81e, // Size: 3, Flags: Public
WeaponAtkSpeedMultipliers = PlayerFields.End + 0x821, // Size: 3, Flags: Public
ModSpellPowerPct = PlayerFields.End + 0x824, // Size: 1, Flags: Public
ModResiliencePercent = PlayerFields.End + 0x825, // Size: 1, Flags: Public
OverrideSpellPowerByApPct = PlayerFields.End + 0x826, // Size: 1, Flags: Public
OverrideApBySpellPowerPercent = PlayerFields.End + 0x827, // Size: 1, Flags: Public
ModTargetResistance = PlayerFields.End + 0x828, // Size: 1, Flags: Public
ModTargetPhysicalResistance = PlayerFields.End + 0x829, // Size: 1, Flags: Public
LocalFlags = PlayerFields.End + 0x82a, // Size: 1, Flags: Public
Bytes = PlayerFields.End + 0x82b, // Size: 1, Flags: Public
PvpMedals = PlayerFields.End + 0x82c, // Size: 1, Flags: Public
BuyBackPrice = PlayerFields.End + 0x82d, // Size: 12, Flags: Public
BuyBackTimestamp = PlayerFields.End + 0x839, // Size: 12, Flags: Public
Kills = PlayerFields.End + 0x845, // Size: 1, Flags: Public
LifetimeHonorableKills = PlayerFields.End + 0x846, // Size: 1, Flags: Public
WatchedFactionIndex = PlayerFields.End + 0x847, // Size: 1, Flags: Public
CombatRating = PlayerFields.End + 0x848, // Size: 32, Flags: Public
ArenaTeamInfo = PlayerFields.End + 0x868, // Size: 54, Flags: Public
MaxLevel = PlayerFields.End + 0x89e, // Size: 1, Flags: Public
ScalingPlayerLevelDelta = PlayerFields.End + 0x89f, // Size: 1, Flags: Public
MaxCreatureScalingLevel = PlayerFields.End + 0x8a0, // Size: 1, Flags: Public
NoReagentCost = PlayerFields.End + 0x8a1, // Size: 4, Flags: Public
PetSpellPower = PlayerFields.End + 0x8a5, // Size: 1, Flags: Public
ProfessionSkillLine = PlayerFields.End + 0x8a6, // Size: 2, Flags: Public
UiHitModifier = PlayerFields.End + 0x8a8, // Size: 1, Flags: Public
UiSpellHitModifier = PlayerFields.End + 0x8a9, // Size: 1, Flags: Public
HomeRealmTimeOffset = PlayerFields.End + 0x8aa, // Size: 1, Flags: Public
ModPetHaste = PlayerFields.End + 0x8ab, // Size: 1, Flags: Public
Bytes2 = PlayerFields.End + 0x8ac, // Size: 1, Flags: Public
Bytes3 = PlayerFields.End + 0x8ad, // Size: 1, Flags: Public, UrgentSelfOnly
LfgBonusFactionId = PlayerFields.End + 0x8ae, // Size: 1, Flags: Public
LootSpecId = PlayerFields.End + 0x8af, // Size: 1, Flags: Public
OverrideZonePvpType = PlayerFields.End + 0x8b0, // Size: 1, Flags: Public, UrgentSelfOnly
BagSlotFlags = PlayerFields.End + 0x8b1, // Size: 4, Flags: Public
BankBagSlotFlags = PlayerFields.End + 0x8b5, // Size: 7, Flags: Public
InsertItemsLeftToRight = PlayerFields.End + 0x8bc, // Size: 1, Flags: Public
QuestCompleted = PlayerFields.End + 0x8bd, // Size: 1750, Flags: Public
Honor = PlayerFields.End + 0xf93, // Size: 1, Flags: Public
HonorNextLevel = PlayerFields.End + 0xf94, // Size: 1, Flags: Public
PvpTierMaxFromWins = PlayerFields.End + 0xf95, // Size: 1, Flags: Public
PvpLastWeeksTierMaxFromWins = PlayerFields.End + 0xf96, // Size: 1, Flags: Public
End = PlayerFields.End + 0xf97,
}
public enum ActivePlayerDynamicFields
{
ReserachSite = PlayerDynamicFields.End + 0x000, // Flags: Public
ResearchSiteProgress = PlayerDynamicFields.End + 0x001, // Flags: Public
DailyQuests = PlayerDynamicFields.End + 0x002, // Flags: Public
AvailableQuestLineXQuestId = PlayerDynamicFields.End + 0x003, // Flags: Public
Heirlooms = PlayerDynamicFields.End + 0x005, // Flags: Public
HeirloomFlags = PlayerDynamicFields.End + 0x006, // Flags: Public
Toys = PlayerDynamicFields.End + 0x007, // Flags: Public
Transmog = PlayerDynamicFields.End + 0x008, // Flags: Public
ConditionalTransmog = PlayerDynamicFields.End + 0x009, // Flags: Public
SelfResSpells = PlayerDynamicFields.End + 0x00a, // Flags: Public
CharacterRestrictions = PlayerDynamicFields.End + 0x00b, // Flags: Public
SpellPctModByLabel = PlayerDynamicFields.End + 0x00c, // Flags: Public
SpellFlatModByLabel = PlayerDynamicFields.End + 0x00d, // Flags: Public
Reserach = PlayerDynamicFields.End + 0x00e, // Flags: Public
End = PlayerDynamicFields.End + 0x00f,
}
public enum GameObjectFields
{
CreatedBy = ObjectFields.End + 0x000, // Size: 4, Flags: Public
GuildGuid = ObjectFields.End + 0x004, // Size: 4, Flags: Public
DisplayId = ObjectFields.End + 0x008, // Size: 1, Flags: Dynamic, Urgent
Flags = ObjectFields.End + 0x009, // Size: 1, Flags: Public, Urgent
ParentRotation = ObjectFields.End + 0x00a, // Size: 4, Flags: Public
Faction = ObjectFields.End + 0x00e, // Size: 1, Flags: Public
Level = ObjectFields.End + 0x00f, // Size: 1, Flags: Public
Bytes1 = ObjectFields.End + 0x010, // Size: 1, Flags: Public, Urgent
SpellVisualId = ObjectFields.End + 0x011, // Size: 1, Flags: Public, Dynamic, Urgent
StateSpellVisualId = ObjectFields.End + 0x012, // Size: 1, Flags: Dynamic, Urgent
StateAnimId = ObjectFields.End + 0x013, // Size: 1, Flags: Dynamic, Urgent
StateAnimKitId = ObjectFields.End + 0x014, // Size: 1, Flags: Dynamic, Urgent
StateWorldEffectId = ObjectFields.End + 0x015, // Size: 4, Flags: Dynamic, Urgent
CustomParam = ObjectFields.End + 0x019, // Size: 1, Flags: Public, Urgent
End = ObjectFields.End + 0x01a,
}
public enum GameObjectDynamicFields
{
EnableDoodadSets = 0x000, // Flags: PUBLIC
End = 0x001
}
public enum DynamicObjectFields
{
Caster = ObjectFields.End + 0x000, // Size: 4, Flags: Public
Type = ObjectFields.End + 0x004, // Size: 1, Flags: Public
SpellXSpellVisualId = ObjectFields.End + 0x005, // Size: 1, Flags: Public
SpellId = ObjectFields.End + 0x006, // Size: 1, Flags: Public
Radius = ObjectFields.End + 0x007, // Size: 1, Flags: Public
CastTime = ObjectFields.End + 0x008, // Size: 1, Flags: Public
End = ObjectFields.End + 0x009
}
public enum CorpseFields
{
Owner = ObjectFields.End + 0x000, // Size: 4, Flags: Public
Party = ObjectFields.End + 0x004, // Size: 4, Flags: Public
GuildGuid = ObjectFields.End + 0x008, // Size: 4, Flags: PUBLIC
DisplayId = ObjectFields.End + 0x00C, // Size: 1, Flags: Public
Item = ObjectFields.End + 0x00D, // Size: 19, Flags: Public
Bytes1 = ObjectFields.End + 0x020, // Size: 1, Flags: Public
Bytes2 = ObjectFields.End + 0x021, // Size: 1, Flags: Public
Flags = ObjectFields.End + 0x022, // Size: 1, Flags: Public
DynamicFlags = ObjectFields.End + 0x023, // Size: 1, Flags: Dynamic
FactionTemplate = ObjectFields.End + 0x024, // Size: 1, Flags: Public
CustomDisplayOption = ObjectFields.End + 0x025, // Size: 1, Flags: PUBLIC
End = ObjectFields.End + 0x026
}
public enum AreaTriggerFields
{
OverrideScaleCurve = ObjectFields.End + 0x000, // Size: 7, Flags: Public, Urgent
ExtraScaleCurve = ObjectFields.End + 0x007, // Size: 7, Flags: Public, Urgent
Caster = ObjectFields.End + 0x00e, // Size: 4, Flags: Public
Duration = ObjectFields.End + 0x012, // Size: 1, Flags: Public
TimeToTarget = ObjectFields.End + 0x013, // Size: 1, Flags: Public, Urgent
TimeToTargetScale = ObjectFields.End + 0x014, // Size: 1, Flags: Public, Urgent
TimeToTargetExtraScale = ObjectFields.End + 0x015, // Size: 1, Flags: Public, Urgent
SpellId = ObjectFields.End + 0x016, // Size: 1, Flags: Public
SpellForVisuals = ObjectFields.End + 0x017, // Size: 1, Flags: PUBLIC
SpellXSpellVisualId = ObjectFields.End + 0x018, // Size: 1, Flags: Dynamic
BoundsRadius2d = ObjectFields.End + 0x019, // Size: 1, Flags: Dynamic, Urgent
DecalPropertiesId = ObjectFields.End + 0x01A, // Size: 1, Flags: Public
CreatingEffectGuid = ObjectFields.End + 0x01B, // Size: 4, Flags: PUBLIC
End = ObjectFields.End + 0x01F
}
public enum SceneObjectFields
{
ScriptPackageId = ObjectFields.End + 0x000, // Size: 1, Flags: Public
RndSeedVal = ObjectFields.End + 0x001, // Size: 1, Flags: Public
Createdby = ObjectFields.End + 0x002, // Size: 4, Flags: Public
SceneType = ObjectFields.End + 0x006, // Size: 1, Flags: Public
End = ObjectFields.End + 0x007
}
public enum ConversationFields
{
LastLineEndTime = ObjectFields.End + 0x000, // Size: 1, Flags: DYNAMIC
End = ObjectFields.End + 0x001
}
public enum ConversationDynamicFields
{
Actors = 0x000, // Flags: Public
Lines = 0x001, // Flags: 0x100
End = 0x002
}
}
@@ -42,4 +42,13 @@ namespace Framework.Constants
//UPDATEFLAG_SCENEOBJECT = 0x10000,
//UPDATEFLAG_SCENE_PENDING_INSTANCE = 0x20000
}
public enum UpdateFieldFlag
{
None = 0,
Owner = 0x01,
PartyMember = 0x02,
UnitAll = 0x04,
Empath = 0x08
}
}
+37 -44
View File
@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Security.Cryptography;
using System;
using System.Security.Cryptography;
@@ -25,66 +26,54 @@ namespace Framework.Cryptography
static readonly byte[] ServerEncryptionKey = { 0x08, 0xF1, 0x95, 0x9F, 0x47, 0xE5, 0xD2, 0xDB, 0xA1, 0x3D, 0x77, 0x8F, 0x3F, 0x3E, 0xE7, 0x00 };
static readonly byte[] ServerDecryptionKey = { 0x40, 0xAA, 0xD3, 0x92, 0x26, 0x71, 0x43, 0x47, 0x3A, 0x31, 0x08, 0xA6, 0xE7, 0xDC, 0x98, 0x2A };
public void Initialize(byte[] sessionKey)
public void Initialize(byte[] key)
{
if (IsInitialized)
throw new InvalidOperationException("PacketCrypt already initialized!");
SARC4Encrypt = new SARC4();
SARC4Decrypt = new SARC4();
_clientDecrypt = new AuthenticatedAesCng();
_clientDecrypt.Key = key;
_clientDecrypt.CngMode = CngChainingMode.Gcm;
_clientDecrypt.TagSize = 96;
var encryptSHA1 = new HMACSHA1(ServerEncryptionKey);
var decryptSHA1 = new HMACSHA1(ServerDecryptionKey);
SARC4Encrypt.PrepareKey(encryptSHA1.ComputeHash(sessionKey));
SARC4Decrypt.PrepareKey(decryptSHA1.ComputeHash(sessionKey));
var PacketEncryptionDummy = new byte[0x400];
var PacketDecryptionDummy = new byte[0x400];
SARC4Encrypt.ProcessBuffer(PacketEncryptionDummy, PacketEncryptionDummy.Length);
SARC4Decrypt.ProcessBuffer(PacketDecryptionDummy, PacketDecryptionDummy.Length);
_serverEncrypt = new AuthenticatedAesCng();
_serverEncrypt.Key = key;
_serverEncrypt.CngMode = CngChainingMode.Gcm;
_serverEncrypt.TagSize = 96;
IsInitialized = true;
}
public void Initialize(byte[] sessionKey, byte[] serverSeed, byte[] clientSeed)
public bool Encrypt(ref byte[] data, int length, ref byte[] tag)
{
if (IsInitialized)
throw new InvalidOperationException("PacketCrypt already initialized!");
{
_serverEncrypt.IV = BitConverter.GetBytes(_serverCounter).Combine(BitConverter.GetBytes(0x52565253));
SARC4Encrypt = new SARC4();
SARC4Decrypt = new SARC4();
var encryptSHA1 = new HMACSHA1(serverSeed);
var decryptSHA1 = new HMACSHA1(clientSeed);
SARC4Encrypt.PrepareKey(encryptSHA1.ComputeHash(sessionKey));
SARC4Decrypt.PrepareKey(decryptSHA1.ComputeHash(sessionKey));
var PacketEncryptionDummy = new byte[0x400];
var PacketDecryptionDummy = new byte[0x400];
SARC4Encrypt.ProcessBuffer(PacketEncryptionDummy, PacketEncryptionDummy.Length);
SARC4Decrypt.ProcessBuffer(PacketDecryptionDummy, PacketDecryptionDummy.Length);
IsInitialized = true;
using (IAuthenticatedCryptoTransform encryptor = _serverEncrypt.CreateAuthenticatedEncryptor())
{
data = encryptor.TransformFinalBlock(data, 0, length);
tag = encryptor.GetTag();
}
}
public void Encrypt(byte[] data, int count)
{
if (!IsInitialized)
throw new InvalidOperationException("PacketCrypt not initialized!");
SARC4Encrypt.ProcessBuffer(data, count);
++_serverCounter;
return true;
}
public void Decrypt(byte[] data, int count)
public bool Decrypt(ref byte[] data, int length, byte[] tag)
{
if (!IsInitialized)
throw new InvalidOperationException("PacketCrypt not initialized!");
if (IsInitialized)
{
_clientDecrypt.IV = BitConverter.GetBytes(_clientCounter).Combine(BitConverter.GetBytes(0x544E4C43));
_clientDecrypt.Tag = tag;
SARC4Decrypt.ProcessBuffer(data, count);
using (ICryptoTransform decryptor = _clientDecrypt.CreateDecryptor())
data = decryptor.TransformFinalBlock(data, 0, length);
}
++_clientCounter;
return true;
}
public void Dispose()
@@ -93,7 +82,11 @@ namespace Framework.Cryptography
}
public bool IsInitialized { get; set; }
SARC4 SARC4Encrypt;
SARC4 SARC4Decrypt;
AuthenticatedAesCng _clientDecrypt;
AuthenticatedAesCng _serverEncrypt;
ulong _clientCounter;
ulong _serverCounter;
}
}
+17 -88
View File
@@ -15,103 +15,32 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Numerics;
using System.Security.Cryptography;
namespace Framework.Cryptography
{
public class RsaCrypt : IDisposable
public class RsaCrypt
{
public RsaCrypt()
public static RSACryptoServiceProvider RSA;
static RsaCrypt()
{
Dispose();
RSA = new RSACryptoServiceProvider(2048);
RSA.ImportParameters(RsaStore.RSAParameters);
}
public void InitializeEncryption<T>(T p, T q, T dp, T dq, T iq, bool isBigEndian = false)
{
_p = p.ToBigInteger(isBigEndian);
_q = q.ToBigInteger(isBigEndian);
_dp = dp.ToBigInteger(isBigEndian);
_dq = dq.ToBigInteger(isBigEndian);
_iq = iq.ToBigInteger(isBigEndian);
if (_p.IsZero && _q.IsZero)
throw new InvalidOperationException("'0' isn't allowed for p or q");
else
_isEncryptionInitialized = true;
}
public void InitializeDecryption<T>(T e, T n, bool reverseBytes = false)
{
_e = e.ToBigInteger(reverseBytes);
_n = n.ToBigInteger(reverseBytes);
_isDecryptionInitialized = true;
}
public byte[] Encrypt<T>(T data, bool isBigEndian = false)
{
if (!_isEncryptionInitialized)
throw new InvalidOperationException("Encryption not initialized");
var bData = data.ToBigInteger(isBigEndian);
var m1 = BigInteger.ModPow(bData % _p, _dp, _p);
var m2 = BigInteger.ModPow(bData % _q, _dq, _q);
var h = (_iq * (m1 - m2)) % _p;
// Be sure to use the positive remainder
if (h.Sign == -1)
h = _p + h;
var m = m2 + h * _q;
return m.ToByteArray();
}
public byte[] Decrypt<T>(T data, bool isBigEndian = false)
{
if (!_isDecryptionInitialized)
throw new InvalidOperationException("Encryption not initialized");
var c = data.ToBigInteger(isBigEndian);
return BigInteger.ModPow(c, _e, _n).ToByteArray();
}
public void Dispose()
{
_e = 0;
_n = 0;
_p = 0;
_q = 0;
_dp = 0;
_dq = 0;
_iq = 0;
_isEncryptionInitialized = false;
_isDecryptionInitialized = false;
}
BigInteger _e;
BigInteger _n;
BigInteger _p;
BigInteger _q;
BigInteger _dp;
BigInteger _dq;
BigInteger _iq;
bool _isEncryptionInitialized;
bool _isDecryptionInitialized;
}
public class RsaStore
{
public static byte[] DP = { 0xE1, 0xA6, 0x22, 0xAB, 0xFF, 0x57, 0x83, 0x45, 0x3F, 0x93, 0x76, 0xC8, 0xFA, 0xD9, 0x17, 0xE1, 0x49, 0x73, 0xC2, 0x13, 0x28, 0x0B, 0x1F, 0xE2, 0x9A, 0xF4, 0x7F, 0x7C, 0x37, 0x56, 0xA1, 0xDF, 0x51, 0x97, 0x2F, 0x15, 0x10, 0x97, 0xCD, 0x2A, 0x40, 0x09, 0xFC, 0x0A, 0xC3, 0x3F, 0x88, 0x86, 0xA9, 0x51, 0x13, 0xE1, 0x76, 0xCF, 0xA8, 0x37, 0x9A, 0x91, 0x3B, 0xD0, 0x70, 0xA1, 0xD7, 0x03, 0x71, 0x59, 0x6C, 0xB3, 0x41, 0xB8, 0x32, 0x68, 0x56, 0xC8, 0xB8, 0xD1, 0xF9, 0x1D, 0x04, 0xC5, 0x13, 0xB5, 0x8E, 0x57, 0x73, 0x02, 0x97, 0x7B, 0x33, 0x60, 0x68, 0xA9, 0xC2, 0x40, 0x96, 0x3C, 0x57, 0x4E, 0x4F, 0xC0, 0xAB, 0x21, 0x5C, 0xBA, 0x7D, 0x65, 0xAA, 0x1B, 0xD6, 0x43, 0x06, 0xCE, 0x3E, 0x0C, 0xB9, 0xB2, 0x82, 0xB0, 0xC9, 0x54, 0x59, 0x32, 0xC5, 0x88, 0x08, 0x9C, 0x9B, 0xBF };
public static byte[] DQ = { 0xE3, 0xB1, 0xED, 0x52, 0xEF, 0xE6, 0x88, 0x40, 0x50, 0x89, 0x4C, 0x99, 0xE5, 0xF7, 0xED, 0x03, 0x1C, 0x54, 0x11, 0x24, 0x2F, 0x9D, 0xE8, 0xE6, 0x39, 0xFA, 0x19, 0xF4, 0x06, 0x55, 0x0B, 0x8B, 0x95, 0xC8, 0xB1, 0xE2, 0x7C, 0x75, 0x3B, 0x2A, 0x40, 0xC3, 0xE7, 0xE0, 0x25, 0x18, 0xBF, 0xB5, 0x03, 0x1B, 0x5A, 0x57, 0x92, 0x3C, 0x85, 0x7D, 0x7F, 0x43, 0x56, 0x1F, 0x1E, 0x80, 0xC3, 0xBA, 0xF0, 0x53, 0xD7, 0x6A, 0xD0, 0xF2, 0xDD, 0x9C, 0xC6, 0x53, 0xE7, 0xB4, 0xD3, 0x9D, 0xAB, 0xBF, 0xE0, 0x97, 0x50, 0x92, 0x23, 0xB9, 0xB7, 0xDC, 0xAA, 0xC4, 0x20, 0x93, 0x5A, 0xF5, 0xDE, 0x76, 0x28, 0x93, 0x91, 0x44, 0x1E, 0x4C, 0x15, 0x2F, 0x7F, 0x45, 0x3C, 0x3B, 0x7D, 0x36, 0x3B, 0x24, 0xC7, 0x8C, 0x65, 0x43, 0xAE, 0x65, 0x84, 0xBC, 0xF9, 0x76, 0x4E, 0x3C, 0x44, 0x05, 0xBC, 0xFA };
public static byte[] InverseQ = { 0x63, 0xC1, 0x14, 0x2B, 0x57, 0x0B, 0x8A, 0x3C, 0x27, 0xDB, 0x96, 0x82, 0x27, 0xEB, 0xF6, 0x45, 0x6D, 0x07, 0x50, 0xE8, 0x4A, 0xD4, 0xB6, 0x7A, 0x3C, 0x8B, 0x4D, 0x65, 0xF0, 0x50, 0x70, 0x84, 0x71, 0x2B, 0xC6, 0x6D, 0x28, 0x2D, 0x76, 0x38, 0x73, 0x93, 0xDB, 0x44, 0xD7, 0xC0, 0x7F, 0xD9, 0x57, 0x18, 0x28, 0x57, 0xF1, 0x13, 0x38, 0xA4, 0x91, 0x67, 0x1E, 0x13, 0x73, 0x55, 0xFC, 0x7B, 0xAF, 0x50, 0xFA, 0xFD, 0x16, 0x12, 0x6F, 0xA4, 0x95, 0x15, 0x9C, 0x07, 0x18, 0xA6, 0x46, 0xFD, 0xB3, 0xCF, 0xA5, 0x0E, 0x05, 0x30, 0xEC, 0x2C, 0xCD, 0x62, 0xDD, 0x6F, 0xB1, 0xFE, 0x6C, 0x05, 0x2F, 0x11, 0xA6, 0xA0, 0x98, 0xAC, 0x9B, 0x15, 0xF0, 0x04, 0xC4, 0x7B, 0x79, 0xAA, 0x51, 0x25, 0x2A, 0x84, 0x73, 0xE6, 0x77, 0x47, 0xA3, 0xEB, 0xCF, 0x6D, 0xC8, 0x96, 0x3A, 0x1B, 0x02, 0x52 };
public static byte[] P = { 0x7D, 0xBD, 0xB9, 0xE1, 0x2D, 0xAE, 0x42, 0x56, 0x6E, 0x2B, 0xE2, 0x89, 0xD9, 0xBB, 0x0C, 0x1F, 0x67, 0x28, 0xC1, 0x4D, 0x91, 0x3C, 0xAD, 0x5F, 0xF0, 0x43, 0x86, 0x5C, 0x27, 0xDC, 0x58, 0xB3, 0x0E, 0x75, 0x77, 0x78, 0x49, 0x35, 0xE7, 0xE7, 0xDF, 0xFD, 0x74, 0xAB, 0x4E, 0xFE, 0xD3, 0xAB, 0x6B, 0x96, 0xF7, 0x89, 0xB2, 0x5A, 0x6A, 0x25, 0x03, 0x5A, 0x92, 0x1A, 0xF1, 0xFC, 0x05, 0x4E, 0xCE, 0xDD, 0x37, 0xA4, 0x02, 0x53, 0x76, 0xCB, 0xC2, 0xD9, 0x63, 0xCB, 0x51, 0x94, 0xEC, 0x5C, 0x39, 0xCC, 0xB2, 0x17, 0x0C, 0xA3, 0x43, 0x9A, 0xD0, 0x83, 0x27, 0x67, 0x52, 0x64, 0x37, 0x0E, 0x38, 0xB7, 0x9B, 0xF4, 0x2D, 0xB8, 0x0F, 0x30, 0x72, 0xD3, 0x15, 0xF3, 0x2C, 0x39, 0x55, 0x72, 0x2C, 0x55, 0x80, 0x63, 0xA0, 0xA1, 0x6F, 0x28, 0xF3, 0xF3, 0x5A, 0x6F, 0x68, 0x59, 0xB3, 0xF3 };
public static byte[] Q = { 0x0B, 0x1A, 0x13, 0x07, 0x12, 0xEF, 0xDD, 0x97, 0x01, 0x9A, 0x21, 0x7D, 0xFA, 0xA3, 0xB7, 0xE2, 0x39, 0x2E, 0x04, 0x92, 0x96, 0x45, 0x2A, 0xEB, 0x57, 0x03, 0xAC, 0xB1, 0x83, 0xCD, 0x25, 0x4F, 0x2C, 0xA9, 0xA1, 0x54, 0x26, 0x54, 0xCF, 0xE6, 0x1B, 0x53, 0x51, 0x3A, 0xC1, 0x15, 0xF4, 0x17, 0xBB, 0x17, 0x1F, 0x37, 0x66, 0x36, 0x1A, 0xD4, 0xB1, 0x5B, 0x49, 0xA8, 0xF1, 0x02, 0xB0, 0x42, 0xA9, 0x66, 0xA0, 0xE2, 0x52, 0x2C, 0x8C, 0x89, 0xA2, 0xDD, 0xA6, 0xF1, 0xA3, 0xDF, 0xB6, 0x80, 0x63, 0xB8, 0x10, 0xDA, 0xDE, 0x84, 0x56, 0xFA, 0xFB, 0x72, 0x65, 0x5E, 0xA3, 0x9C, 0x78, 0x65, 0xD0, 0x73, 0x07, 0x34, 0x1D, 0xE1, 0x4D, 0x77, 0xE8, 0x00, 0x0F, 0x80, 0x1C, 0x5A, 0x21, 0x55, 0x0A, 0x8C, 0xF4, 0x93, 0xF5, 0xF8, 0x40, 0xF2, 0x40, 0xEA, 0x52, 0x12, 0x40, 0xF0, 0xBF, 0xFA };
public static byte[] WherePacketHmac = { 0x2C, 0x1F, 0x1D, 0x80, 0xC3, 0x8C, 0x23, 0x64, 0xDA, 0x90, 0xCA, 0x8E, 0x2C, 0xFC, 0x0C, 0xCE, 0x09, 0xD3, 0x62, 0xF9, 0xF3, 0x8B, 0xBE, 0x9F, 0x19, 0xEF, 0x58, 0xA1, 0x1C, 0x34, 0x14, 0x41, 0x3F, 0x23, 0xFD, 0xD3, 0xE8, 0x14, 0xEC, 0x2A, 0xFD, 0x4F, 0x95, 0xBA, 0x30, 0x7E, 0x56, 0x5D, 0x83, 0x95, 0x81, 0x69, 0xB0, 0x5A, 0xB4, 0x9D, 0xA8, 0x55, 0xFF, 0xFC, 0xEE, 0x58, 0x0A, 0x2F };
public static RSAParameters RSAParameters = new RSAParameters()
{
Modulus = new byte[] { 0xee, 0xb3, 0xdc, 0xd4, 0xd3, 0xc3, 0xb4, 0x54, 0x51, 0xce, 0x66, 0x5b, 0xcb, 0x32, 0xb8, 0xf0, 0xf7, 0x92, 0x53, 0xc6, 0x19, 0xf2, 0x0c, 0x85, 0x2f, 0x8a, 0x26, 0xa9, 0x7a, 0x45, 0x9f, 0x60, 0xc4, 0xeb, 0xcd, 0xea, 0x7f, 0x8d, 0x59, 0xd8, 0x57, 0xb2, 0x60, 0x7b, 0x09, 0x4c, 0x9b, 0x68, 0xb8, 0xc7, 0xed, 0xef, 0x1e, 0x80, 0x0d, 0xe6, 0x6b, 0x37, 0x5b, 0x53, 0x90, 0xeb, 0x18, 0x13, 0x0d, 0x7f, 0x43, 0x64, 0x83, 0xda, 0x98, 0xe6, 0xac, 0xc2, 0x30, 0xa2, 0x82, 0xa5, 0xc6, 0xcb, 0xc7, 0xfb, 0x86, 0x9f, 0x9f, 0xa9, 0x02, 0x6a, 0x03, 0x49, 0xc5, 0x38, 0xfb, 0xc0, 0xc8, 0x55, 0xcc, 0xc0, 0xce, 0x25, 0x91, 0xbe, 0x85, 0xcf, 0xd1, 0xd1, 0x37, 0xce, 0xcc, 0x83, 0xd2, 0xea, 0x30, 0x80, 0x07, 0x7b, 0x80, 0x9f, 0x9d, 0x44, 0x54, 0x22, 0x29, 0xbe, 0x86, 0xda, 0xdb, 0x48, 0xc5, 0xa9, 0xf9, 0x13, 0x36, 0x95, 0x23, 0x76, 0xf1, 0x0e, 0xdc, 0x84, 0x0d, 0x94, 0x02, 0x12, 0xa8, 0x97, 0xf3, 0x3b, 0x14, 0xee, 0xaa, 0x6f, 0x98, 0x05, 0x27, 0x4e, 0x1f, 0xa3, 0x60, 0xa5, 0xa9, 0xda, 0xd8, 0x17, 0xdf, 0x33, 0xcb, 0xe2, 0x13, 0x54, 0x8b, 0x18, 0xb0, 0xca, 0xb9, 0xbb, 0x88, 0x64, 0x06, 0xdf, 0x75, 0xa6, 0xd7, 0x61, 0x00, 0xbb, 0xb0, 0x5a, 0x0e, 0x7a, 0xd4, 0x77, 0x08, 0x4d, 0x15, 0xe2, 0x10, 0x83, 0xb0, 0x04, 0xaa, 0x9e, 0x8b, 0x77, 0xa9, 0x06, 0x89, 0x5d, 0x08, 0x5d, 0x0f, 0xb8, 0x2e, 0x6b, 0xc1, 0xcb, 0x64, 0xcf, 0x6e, 0x5c, 0xdb, 0x4f, 0x58, 0x65, 0x08, 0x51, 0xfb, 0x0d, 0x48, 0x1a, 0x6f, 0xb6, 0x3d, 0x1f, 0x0b, 0xdd, 0xfe, 0x1b, 0x1d, 0xf0, 0xbf, 0xb0, 0x27, 0x6b, 0xf5, 0x8e, 0xbc, 0xc7, 0x40, 0x01, 0xff, 0xa7, 0x0b, 0x80, 0xd6, 0x5f },
Exponent = new byte[] { 0x01, 0x00, 0x01 },
P = new byte[] { 0xf3, 0xb3, 0x59, 0x68, 0x6f, 0x5a, 0xf3, 0xf3, 0x28, 0x6f, 0xa1, 0xa0, 0x63, 0x80, 0x55, 0x2c, 0x72, 0x55, 0x39, 0x2c, 0xf3, 0x15, 0xd3, 0x72, 0x30, 0x0f, 0xb8, 0x2d, 0xf4, 0x9b, 0xb7, 0x38, 0x0e, 0x37, 0x64, 0x52, 0x67, 0x27, 0x83, 0xd0, 0x9a, 0x43, 0xa3, 0x0c, 0x17, 0xb2, 0xcc, 0x39, 0x5c, 0xec, 0x94, 0x51, 0xcb, 0x63, 0xd9, 0xc2, 0xcb, 0x76, 0x53, 0x02, 0xa4, 0x37, 0xdd, 0xce, 0x4e, 0x05, 0xfc, 0xf1, 0x1a, 0x92, 0x5a, 0x03, 0x25, 0x6a, 0x5a, 0xb2, 0x89, 0xf7, 0x96, 0x6b, 0xab, 0xd3, 0xfe, 0x4e, 0xab, 0x74, 0xfd, 0xdf, 0xe7, 0xe7, 0x35, 0x49, 0x78, 0x77, 0x75, 0x0e, 0xb3, 0x58, 0xdc, 0x27, 0x5c, 0x86, 0x43, 0xf0, 0x5f, 0xad, 0x3c, 0x91, 0x4d, 0xc1, 0x28, 0x67, 0x1f, 0x0c, 0xbb, 0xd9, 0x89, 0xe2, 0x2b, 0x6e, 0x56, 0x42, 0xae, 0x2d, 0xe1, 0xb9, 0xbd, 0x7d },
Q = new byte[] { 0xfa, 0xbf, 0xf0, 0x40, 0x12, 0x52, 0xea, 0x40, 0xf2, 0x40, 0xf8, 0xf5, 0x93, 0xf4, 0x8c, 0x0a, 0x55, 0x21, 0x5a, 0x1c, 0x80, 0x0f, 0x00, 0xe8, 0x77, 0x4d, 0xe1, 0x1d, 0x34, 0x07, 0x73, 0xd0, 0x65, 0x78, 0x9c, 0xa3, 0x5e, 0x65, 0x72, 0xfb, 0xfa, 0x56, 0x84, 0xde, 0xda, 0x10, 0xb8, 0x63, 0x80, 0xb6, 0xdf, 0xa3, 0xf1, 0xa6, 0xdd, 0xa2, 0x89, 0x8c, 0x2c, 0x52, 0xe2, 0xa0, 0x66, 0xa9, 0x42, 0xb0, 0x02, 0xf1, 0xa8, 0x49, 0x5b, 0xb1, 0xd4, 0x1a, 0x36, 0x66, 0x37, 0x1f, 0x17, 0xbb, 0x17, 0xf4, 0x15, 0xc1, 0x3a, 0x51, 0x53, 0x1b, 0xe6, 0xcf, 0x54, 0x26, 0x54, 0xa1, 0xa9, 0x2c, 0x4f, 0x25, 0xcd, 0x83, 0xb1, 0xac, 0x03, 0x57, 0xeb, 0x2a, 0x45, 0x96, 0x92, 0x04, 0x2e, 0x39, 0xe2, 0xb7, 0xa3, 0xfa, 0x7d, 0x21, 0x9a, 0x01, 0x97, 0xdd, 0xef, 0x12, 0x07, 0x13, 0x1a, 0x0b },
DP = new byte[] { 0xbf, 0x9b, 0x9c, 0x08, 0x88, 0xc5, 0x32, 0x59, 0x54, 0xc9, 0xb0, 0x82, 0xb2, 0xb9, 0x0c, 0x3e, 0xce, 0x06, 0x43, 0xd6, 0x1b, 0xaa, 0x65, 0x7d, 0xba, 0x5c, 0x21, 0xab, 0xc0, 0x4f, 0x4e, 0x57, 0x3c, 0x96, 0x40, 0xc2, 0xa9, 0x68, 0x60, 0x33, 0x7b, 0x97, 0x02, 0x73, 0x57, 0x8e, 0xb5, 0x13, 0xc5, 0x04, 0x1d, 0xf9, 0xd1, 0xb8, 0xc8, 0x56, 0x68, 0x32, 0xb8, 0x41, 0xb3, 0x6c, 0x59, 0x71, 0x03, 0xd7, 0xa1, 0x70, 0xd0, 0x3b, 0x91, 0x9a, 0x37, 0xa8, 0xcf, 0x76, 0xe1, 0x13, 0x51, 0xa9, 0x86, 0x88, 0x3f, 0xc3, 0x0a, 0xfc, 0x09, 0x40, 0x2a, 0xcd, 0x97, 0x10, 0x15, 0x2f, 0x97, 0x51, 0xdf, 0xa1, 0x56, 0x37, 0x7c, 0x7f, 0xf4, 0x9a, 0xe2, 0x1f, 0x0b, 0x28, 0x13, 0xc2, 0x73, 0x49, 0xe1, 0x17, 0xd9, 0xfa, 0xc8, 0x76, 0x93, 0x3f, 0x45, 0x83, 0x57, 0xff, 0xab, 0x22, 0xa6, 0xe1 },
DQ = new byte[] { 0xfa, 0xbc, 0x05, 0x44, 0x3c, 0x4e, 0x76, 0xf9, 0xbc, 0x84, 0x65, 0xae, 0x43, 0x65, 0x8c, 0xc7, 0x24, 0x3b, 0x36, 0x7d, 0x3b, 0x3c, 0x45, 0x7f, 0x2f, 0x15, 0x4c, 0x1e, 0x44, 0x91, 0x93, 0x28, 0x76, 0xde, 0xf5, 0x5a, 0x93, 0x20, 0xc4, 0xaa, 0xdc, 0xb7, 0xb9, 0x23, 0x92, 0x50, 0x97, 0xe0, 0xbf, 0xab, 0x9d, 0xd3, 0xb4, 0xe7, 0x53, 0xc6, 0x9c, 0xdd, 0xf2, 0xd0, 0x6a, 0xd7, 0x53, 0xf0, 0xba, 0xc3, 0x80, 0x1e, 0x1f, 0x56, 0x43, 0x7f, 0x7d, 0x85, 0x3c, 0x92, 0x57, 0x5a, 0x1b, 0x03, 0xb5, 0xbf, 0x18, 0x25, 0xe0, 0xe7, 0xc3, 0x40, 0x2a, 0x3b, 0x75, 0x7c, 0xe2, 0xb1, 0xc8, 0x95, 0x8b, 0x0b, 0x55, 0x06, 0xf4, 0x19, 0xfa, 0x39, 0xe6, 0xe8, 0x9d, 0x2f, 0x24, 0x11, 0x54, 0x1c, 0x03, 0xed, 0xf7, 0xe5, 0x99, 0x4c, 0x89, 0x50, 0x40, 0x88, 0xe6, 0xef, 0x52, 0xed, 0xb1, 0xe3 },
InverseQ = new byte[] { 0x52, 0x02, 0x1b, 0x3a, 0x96, 0xc8, 0x6d, 0xcf, 0xeb, 0xa3, 0x47, 0x77, 0xe6, 0x73, 0x84, 0x2a, 0x25, 0x51, 0xaa, 0x79, 0x7b, 0xc4, 0x04, 0xf0, 0x15, 0x9b, 0xac, 0x98, 0xa0, 0xa6, 0x11, 0x2f, 0x05, 0x6c, 0xfe, 0xb1, 0x6f, 0xdd, 0x62, 0xcd, 0x2c, 0xec, 0x30, 0x05, 0x0e, 0xa5, 0xcf, 0xb3, 0xfd, 0x46, 0xa6, 0x18, 0x07, 0x9c, 0x15, 0x95, 0xa4, 0x6f, 0x12, 0x16, 0xfd, 0xfa, 0x50, 0xaf, 0x7b, 0xfc, 0x55, 0x73, 0x13, 0x1e, 0x67, 0x91, 0xa4, 0x38, 0x13, 0xf1, 0x57, 0x28, 0x18, 0x57, 0xd9, 0x7f, 0xc0, 0xd7, 0x44, 0xdb, 0x93, 0x73, 0x38, 0x76, 0x2d, 0x28, 0x6d, 0xc6, 0x2b, 0x71, 0x84, 0x70, 0x50, 0xf0, 0x65, 0x4d, 0x8b, 0x3c, 0x7a, 0xb6, 0xd4, 0x4a, 0xe8, 0x50, 0x07, 0x6d, 0x45, 0xf6, 0xeb, 0x27, 0x82, 0x96, 0xdb, 0x27, 0x3c, 0x8a, 0x0b, 0x57, 0x2b, 0x14, 0xc1, 0x63 },
D = new byte[] { 0x22, 0x9a, 0xe6, 0xaf, 0xe0, 0x07, 0x66, 0x34, 0x37, 0x2b, 0xe2, 0x00, 0xfa, 0xc3, 0x5e, 0xb6, 0x68, 0x5d, 0xc9, 0x51, 0x55, 0xdf, 0x96, 0x5b, 0x14, 0x9a, 0x45, 0xa2, 0x9a, 0x3c, 0x4f, 0xaf, 0xba, 0xbc, 0xa8, 0xbc, 0x8f, 0x43, 0x51, 0xbc, 0x20, 0x72, 0x96, 0xb4, 0x1f, 0x94, 0x00, 0x8f, 0xbd, 0x02, 0x17, 0x07, 0x6c, 0x77, 0x8a, 0x0c, 0x56, 0x8c, 0xce, 0xeb, 0x9d, 0x7d, 0xc7, 0x9e, 0xb3, 0x7d, 0x38, 0xaa, 0xf0, 0xc6, 0x97, 0x16, 0x12, 0x03, 0x91, 0x03, 0x6e, 0x47, 0x54, 0x3b, 0xa4, 0xc1, 0x5d, 0x31, 0xf4, 0xf6, 0x8e, 0x88, 0x09, 0xf3, 0xfe, 0xe8, 0x94, 0xee, 0xcc, 0xdc, 0x4b, 0x73, 0xc4, 0x2f, 0x04, 0x23, 0x07, 0xc9, 0x2a, 0x14, 0xd7, 0xaf, 0x5e, 0x4c, 0xda, 0x1d, 0xe3, 0x6c, 0x1c, 0x29, 0x96, 0x6b, 0x0d, 0x64, 0xa3, 0x81, 0xd4, 0x65, 0x6f, 0xad, 0x78, 0xce, 0x9b, 0x52, 0xad, 0x39, 0x9e, 0x02, 0x4d, 0x33, 0x34, 0x5a, 0xb3, 0xda, 0x2d, 0x50, 0xd3, 0xf5, 0xac, 0x7c, 0xa7, 0x29, 0x23, 0x98, 0x5c, 0x35, 0xea, 0xf1, 0x8f, 0x8f, 0xf4, 0x79, 0x0e, 0x4c, 0xbd, 0x56, 0x96, 0x9b, 0xb5, 0xf6, 0x4e, 0xbb, 0xf0, 0x04, 0x5b, 0x6e, 0x7d, 0x5c, 0x31, 0x22, 0x42, 0x04, 0xeb, 0x07, 0x81, 0x20, 0xf9, 0x2e, 0x06, 0x26, 0x31, 0xea, 0x03, 0x33, 0xd9, 0x06, 0x63, 0x32, 0xff, 0x18, 0x65, 0x0c, 0xae, 0x28, 0x31, 0x77, 0x9f, 0xa9, 0x74, 0x9c, 0x7c, 0x3e, 0x30, 0xd1, 0x1c, 0x6e, 0xb8, 0x21, 0x6b, 0xea, 0x5c, 0x4b, 0x3d, 0x9c, 0xf4, 0x4b, 0x7e, 0x41, 0x2b, 0x59, 0x08, 0x5a, 0x62, 0x24, 0xba, 0xff, 0xbd, 0x79, 0x0b, 0x88, 0xe0, 0x7a, 0xf5, 0x0b, 0x25, 0x70, 0x72, 0x1e, 0x1f, 0x91, 0xfb, 0xeb, 0xa7, 0xce, 0x31, 0xf2, 0xdb, 0xc0, 0x16, 0x79 },
};
}
}
@@ -21,7 +21,7 @@ namespace Framework.Database
{
public override void PreparedStatements()
{
const string SelectItemInstanceContent = "ii.guid, ii.itemEntry, ii.creatorGuid, ii.giftCreatorGuid, ii.count, ii.duration, ii.charges, ii.flags, ii.enchantments, ii.randomPropertyType, ii.randomPropertyId, " +
const string SelectItemInstanceContent = "ii.guid, ii.itemEntry, ii.creatorGuid, ii.giftCreatorGuid, ii.count, ii.duration, ii.charges, ii.flags, ii.enchantments, ii.randomBonusListId, " +
"ii.durability, ii.playedTime, ii.text, ii.upgradeId, ii.battlePetSpeciesId, ii.battlePetBreedData, ii.battlePetLevel, ii.battlePetDisplayId, ii.context, ii.bonusListIDs, " +
"iit.itemModifiedAppearanceAllSpecs, iit.itemModifiedAppearanceSpec1, iit.itemModifiedAppearanceSpec2, iit.itemModifiedAppearanceSpec3, iit.itemModifiedAppearanceSpec4, " +
"iit.spellItemEnchantmentAllSpecs, iit.spellItemEnchantmentSpec1, iit.spellItemEnchantmentSpec2, iit.spellItemEnchantmentSpec3, iit.spellItemEnchantmentSpec4, " +
@@ -168,8 +168,8 @@ namespace Framework.Database
PrepareStatement(CharStatements.DEL_ITEM_BOP_TRADE, "DELETE FROM item_soulbound_trade_data WHERE itemGuid = ? LIMIT 1");
PrepareStatement(CharStatements.INS_ITEM_BOP_TRADE, "INSERT INTO item_soulbound_trade_data VALUES (?, ?)");
PrepareStatement(CharStatements.REP_INVENTORY_ITEM, "REPLACE INTO character_inventory (guid, bag, slot, item) VALUES (?, ?, ?, ?)");
PrepareStatement(CharStatements.REP_ITEM_INSTANCE, "REPLACE INTO item_instance (itemEntry, owner_guid, creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, playedTime, text, upgradeId, battlePetSpeciesId, battlePetBreedData, battlePetLevel, battlePetDisplayId, context, bonusListIDs, guid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(CharStatements.UPD_ITEM_INSTANCE, "UPDATE item_instance SET itemEntry = ?, owner_guid = ?, creatorGuid = ?, giftCreatorGuid = ?, count = ?, duration = ?, charges = ?, flags = ?, enchantments = ?, randomPropertyType = ?, randomPropertyId = ?, durability = ?, playedTime = ?, text = ?, upgradeId = ?, battlePetSpeciesId = ?, battlePetBreedData = ?, battlePetLevel = ?, battlePetDisplayId = ?, context = ?, bonusListIDs = ? WHERE guid = ?");
PrepareStatement(CharStatements.REP_ITEM_INSTANCE, "REPLACE INTO item_instance (itemEntry, owner_guid, creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomBonusListId, durability, playedTime, text, upgradeId, battlePetSpeciesId, battlePetBreedData, battlePetLevel, battlePetDisplayId, context, bonusListIDs, guid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(CharStatements.UPD_ITEM_INSTANCE, "UPDATE item_instance SET itemEntry = ?, owner_guid = ?, creatorGuid = ?, giftCreatorGuid = ?, count = ?, duration = ?, charges = ?, flags = ?, enchantments = ?, randomBonusListId = ?, durability = ?, playedTime = ?, text = ?, upgradeId = ?, battlePetSpeciesId = ?, battlePetBreedData = ?, battlePetLevel = ?, battlePetDisplayId = ?, context = ?, bonusListIDs = ? WHERE guid = ?");
PrepareStatement(CharStatements.UPD_ITEM_INSTANCE_ON_LOAD, "UPDATE item_instance SET duration = ?, flags = ?, durability = ?, upgradeId = ? WHERE guid = ?");
PrepareStatement(CharStatements.DEL_ITEM_INSTANCE, "DELETE FROM item_instance WHERE guid = ?");
PrepareStatement(CharStatements.DEL_ITEM_INSTANCE_BY_OWNER, "DELETE FROM item_instance WHERE owner_guid = ?");
@@ -625,8 +625,8 @@ namespace Framework.Database
PrepareStatement(CharStatements.DEL_CHAR_FISHINGSTEPS, "DELETE FROM character_fishingsteps WHERE guid = ?");
// Void Storage
PrepareStatement(CharStatements.SEL_CHAR_VOID_STORAGE, "SELECT itemId, itemEntry, slot, creatorGuid, randomPropertyType, randomProperty, suffixFactor, upgradeId, fixedScalingLevel, artifactKnowledgeLevel, context, bonusListIDs FROM character_void_storage WHERE playerGuid = ?");
PrepareStatement(CharStatements.REP_CHAR_VOID_STORAGE_ITEM, "REPLACE INTO character_void_storage (itemId, playerGuid, itemEntry, slot, creatorGuid, randomPropertyType, randomProperty, suffixFactor, upgradeId, fixedScalingLevel, artifactKnowledgeLevel, context, bonusListIDs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(CharStatements.SEL_CHAR_VOID_STORAGE, "SELECT itemId, itemEntry, slot, creatorGuid, randomBonusListId, upgradeId, fixedScalingLevel, artifactKnowledgeLevel, context, bonusListIDs FROM character_void_storage WHERE playerGuid = ?");
PrepareStatement(CharStatements.REP_CHAR_VOID_STORAGE_ITEM, "REPLACE INTO character_void_storage (itemId, playerGuid, itemEntry, slot, creatorGuid, randomBonusListId, upgradeId, fixedScalingLevel, artifactKnowledgeLevel, context, bonusListIDs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(CharStatements.DEL_CHAR_VOID_STORAGE_ITEM_BY_CHAR_GUID, "DELETE FROM character_void_storage WHERE playerGuid = ?");
PrepareStatement(CharStatements.DEL_CHAR_VOID_STORAGE_ITEM_BY_SLOT, "DELETE FROM character_void_storage WHERE slot = ? AND playerGuid = ?");
@@ -643,10 +643,10 @@ namespace Framework.Database
PrepareStatement(CharStatements.DEL_GUILD_FINDER_GUILD_SETTINGS, "DELETE FROM guild_finder_guild_settings WHERE guildId = ?");
// Items that hold loot or money
PrepareStatement(CharStatements.SEL_ITEMCONTAINER_ITEMS, "SELECT item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_type, rnd_prop, rnd_suffix, context, bonus_list_ids FROM item_loot_items WHERE container_id = ?");
PrepareStatement(CharStatements.SEL_ITEMCONTAINER_ITEMS, "SELECT item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids FROM item_loot_items WHERE container_id = ?");
PrepareStatement(CharStatements.DEL_ITEMCONTAINER_ITEMS, "DELETE FROM item_loot_items WHERE container_id = ?");
PrepareStatement(CharStatements.DEL_ITEMCONTAINER_ITEM, "DELETE FROM item_loot_items WHERE container_id = ? AND item_id = ?");
PrepareStatement(CharStatements.INS_ITEMCONTAINER_ITEMS, "INSERT INTO item_loot_items (container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_type, rnd_prop, rnd_suffix, context, bonus_list_ids) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(CharStatements.INS_ITEMCONTAINER_ITEMS, "INSERT INTO item_loot_items (container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(CharStatements.SEL_ITEMCONTAINER_MONEY, "SELECT money FROM item_loot_money WHERE container_id = ?");
PrepareStatement(CharStatements.DEL_ITEMCONTAINER_MONEY, "DELETE FROM item_loot_money WHERE container_id = ?");
PrepareStatement(CharStatements.INS_ITEMCONTAINER_MONEY, "INSERT INTO item_loot_money (container_id, money) VALUES (?, ?)");
@@ -23,11 +23,11 @@ namespace Framework.Database
{
// Achievement.db2
PrepareStatement(HotfixStatements.SEL_ACHIEVEMENT, "SELECT Description, Title, Reward, ID, InstanceID, Faction, Supercedes, Category, MinimumCriteria, " +
"Points, Flags, UiOrder, IconFileID, CriteriaTree, SharesCriteria FROM achievement ORDER BY ID DESC");
"Points, Flags, UiOrder, IconFileID, RewardItemID, CriteriaTree, SharesCriteria FROM achievement ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_ACHIEVEMENT_LOCALE, "SELECT ID, Description_lang, Title_lang, Reward_lang FROM achievement_locale WHERE locale = ?");
// AnimationData.db2
PrepareStatement(HotfixStatements.SEL_ANIMATION_DATA, "SELECT ID, Fallback, BehaviorTier, BehaviorID, Flags1, Flags2 FROM animation_data ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_ANIMATION_DATA, "SELECT ID, BehaviorID, BehaviorTier, Fallback, Flags1, Flags2 FROM animation_data ORDER BY ID DESC");
// AnimKit.db2
PrepareStatement(HotfixStatements.SEL_ANIM_KIT, "SELECT ID, OneShotDuration, OneShotStopAnimKitID, LowDefAnimKitID FROM anim_kit ORDER BY ID DESC");
@@ -58,7 +58,7 @@ namespace Framework.Database
// ArtifactAppearance.db2
PrepareStatement(HotfixStatements.SEL_ARTIFACT_APPEARANCE, "SELECT Name, ID, ArtifactAppearanceSetID, DisplayIndex, UnlockPlayerConditionID, " +
"ItemAppearanceModifierID, UiSwatchColor, UiModelSaturation, UiModelOpacity, OverrideShapeshiftFormID, OverrideShapeshiftDisplayID, " +
"UiItemAppearanceID, UiAltItemAppearanceID, Flags, UiCameraID FROM artifact_appearance ORDER BY ID DESC");
"UiItemAppearanceID, UiAltItemAppearanceID, Flags, UiCameraID, UsablePlayerConditionID FROM artifact_appearance ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_ARTIFACT_APPEARANCE_LOCALE, "SELECT ID, Name_lang FROM artifact_appearance_locale WHERE locale = ?");
// ArtifactAppearanceSet.db2
@@ -170,8 +170,9 @@ namespace Framework.Database
// ChrClasses.db2
PrepareStatement(HotfixStatements.SEL_CHR_CLASSES, "SELECT Name, Filename, NameMale, NameFemale, PetNameToken, ID, CreateScreenFileDataID, " +
"SelectScreenFileDataID, IconFileDataID, LowResScreenFileDataID, StartingLevel, Flags, CinematicSequenceID, DefaultSpec, PrimaryStatPriority, " +
"DisplayPower, RangedAttackPowerPerAgility, AttackPowerPerAgility, AttackPowerPerStrength, SpellClassSet FROM chr_classes ORDER BY ID DESC");
"SelectScreenFileDataID, IconFileDataID, LowResScreenFileDataID, StartingLevel, SpellTextureBlobFileDataID, Flags, CinematicSequenceID, " +
"DefaultSpec, PrimaryStatPriority, DisplayPower, RangedAttackPowerPerAgility, AttackPowerPerAgility, AttackPowerPerStrength, SpellClassSet" +
" FROM chr_classes ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_CHR_CLASSES_LOCALE, "SELECT ID, Name_lang, NameMale_lang, NameFemale_lang FROM chr_classes_locale WHERE locale = ?");
// ChrClassesXPowerTypes.db2
@@ -206,7 +207,10 @@ namespace Framework.Database
" FROM cinematic_sequences ORDER BY ID DESC");
// ContentTuning.db2
PrepareStatement(HotfixStatements.SEL_CONTENT_TUNING, "SELECT ID, MinLevel, MaxLevel, Flags, ExpectedStatModID, DifficultyESMID FROM content_tuning" +
PrepareStatement(HotfixStatements.SEL_CONTENT_TUNING, "SELECT ID, MinLevel, MaxLevel, Flags, ExpansionID FROM content_tuning ORDER BY ID DESC");
// ContentTuningXExpected.db2
PrepareStatement(HotfixStatements.SEL_CONTENT_TUNING_X_EXPECTED, "SELECT ID, ExpectedStatModID, ContentTuningID FROM content_tuning_x_expected" +
" ORDER BY ID DESC");
// ConversationLine.db2
@@ -235,7 +239,8 @@ namespace Framework.Database
"FootprintTextureID, FootprintTextureLength, FootprintTextureWidth, FootprintParticleScale, FoleyMaterialID, FootstepCameraEffectID, " +
"DeathThudCameraEffectID, SoundID, SizeClass, CollisionWidth, CollisionHeight, WorldEffectScale, CreatureGeosetDataID, HoverHeight, " +
"AttachedEffectScale, ModelScale, MissileCollisionRadius, MissileCollisionPush, MissileCollisionRaise, MountHeight, OverrideLootEffectScale, " +
"OverrideNameScale, OverrideSelectionRadius, TamedPetBaseScale FROM creature_model_data ORDER BY ID DESC");
"OverrideNameScale, OverrideSelectionRadius, TamedPetBaseScale, Unknown820_1, Unknown820_2, Unknown820_31, Unknown820_32" +
" FROM creature_model_data ORDER BY ID DESC");
// CreatureType.db2
PrepareStatement(HotfixStatements.SEL_CREATURE_TYPE, "SELECT ID, Name, Flags FROM creature_type ORDER BY ID DESC");
@@ -252,7 +257,7 @@ namespace Framework.Database
// CurrencyTypes.db2
PrepareStatement(HotfixStatements.SEL_CURRENCY_TYPES, "SELECT ID, Name, Description, CategoryID, InventoryIconFileID, SpellWeight, SpellCategory, MaxQty, " +
"MaxEarnablePerWeek, Flags, Quality, FactionID FROM currency_types ORDER BY ID DESC");
"MaxEarnablePerWeek, Flags, Quality, FactionID, ItemGroupSoundsID FROM currency_types ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_CURRENCY_TYPES_LOCALE, "SELECT ID, Name_lang, Description_lang FROM currency_types_locale WHERE locale = ?");
// Curve.db2
@@ -275,8 +280,8 @@ namespace Framework.Database
PrepareStatement(HotfixStatements.SEL_DIFFICULTY_LOCALE, "SELECT ID, Name_lang FROM difficulty_locale WHERE locale = ?");
// DungeonEncounter.db2
PrepareStatement(HotfixStatements.SEL_DUNGEON_ENCOUNTER, "SELECT Name, ID, MapID, DifficultyID, OrderIndex, Bit, CreatureDisplayID, Flags, SpellIconFileID" +
" FROM dungeon_encounter ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_DUNGEON_ENCOUNTER, "SELECT Name, ID, MapID, DifficultyID, OrderIndex, CompleteWorldStateID, Bit, CreatureDisplayID, " +
"Flags, SpellIconFileID, Faction FROM dungeon_encounter ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_DUNGEON_ENCOUNTER_LOCALE, "SELECT ID, Name_lang FROM dungeon_encounter_locale WHERE locale = ?");
// DurabilityCosts.db2
@@ -392,7 +397,7 @@ namespace Framework.Database
PrepareStatement(HotfixStatements.SEL_GLYPH_BINDABLE_SPELL, "SELECT ID, SpellID, GlyphPropertiesID FROM glyph_bindable_spell ORDER BY ID DESC");
// GlyphProperties.db2
PrepareStatement(HotfixStatements.SEL_GLYPH_PROPERTIES, "SELECT ID, SpellID, SpellIconID, GlyphType, GlyphExclusiveCategoryID FROM glyph_properties" +
PrepareStatement(HotfixStatements.SEL_GLYPH_PROPERTIES, "SELECT ID, SpellID, GlyphType, GlyphExclusiveCategoryID, SpellIconFileDataID FROM glyph_properties" +
" ORDER BY ID DESC");
// GlyphRequiredSpec.db2
@@ -412,16 +417,17 @@ namespace Framework.Database
// Heirloom.db2
PrepareStatement(HotfixStatements.SEL_HEIRLOOM, "SELECT SourceText, ID, ItemID, LegacyUpgradedItemID, StaticUpgradedItemID, SourceTypeEnum, Flags, " +
"LegacyItemID, UpgradeItemID1, UpgradeItemID2, UpgradeItemID3, UpgradeItemBonusListID1, UpgradeItemBonusListID2, UpgradeItemBonusListID3" +
" FROM heirloom ORDER BY ID DESC");
"LegacyItemID, UpgradeItemID1, UpgradeItemID2, UpgradeItemID3, UpgradeItemID4, UpgradeItemBonusListID1, UpgradeItemBonusListID2, " +
"UpgradeItemBonusListID3, UpgradeItemBonusListID4 FROM heirloom ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_HEIRLOOM_LOCALE, "SELECT ID, SourceText_lang FROM heirloom_locale WHERE locale = ?");
// Holidays.db2
PrepareStatement(HotfixStatements.SEL_HOLIDAYS, "SELECT ID, Region, Looping, HolidayNameID, HolidayDescriptionID, Priority, CalendarFilterType, Flags, " +
"Duration1, Duration2, Duration3, Duration4, Duration5, Duration6, Duration7, Duration8, Duration9, Duration10, Date1, Date2, Date3, Date4, " +
"Date5, Date6, Date7, Date8, Date9, Date10, Date11, Date12, Date13, Date14, Date15, Date16, CalendarFlags1, CalendarFlags2, CalendarFlags3, " +
"CalendarFlags4, CalendarFlags5, CalendarFlags6, CalendarFlags7, CalendarFlags8, CalendarFlags9, CalendarFlags10, TextureFileDataID1, " +
"TextureFileDataID2, TextureFileDataID3 FROM holidays ORDER BY ID DESC");
"Date5, Date6, Date7, Date8, Date9, Date10, Date11, Date12, Date13, Date14, Date15, Date16, Date17, Date18, Date19, Date20, Date21, Date22, " +
"Date23, Date24, Date25, Date26, CalendarFlags1, CalendarFlags2, CalendarFlags3, CalendarFlags4, CalendarFlags5, CalendarFlags6, " +
"CalendarFlags7, CalendarFlags8, CalendarFlags9, CalendarFlags10, TextureFileDataID1, TextureFileDataID2, TextureFileDataID3 FROM holidays" +
" ORDER BY ID DESC");
// ImportPriceArmor.db2
PrepareStatement(HotfixStatements.SEL_IMPORT_PRICE_ARMOR, "SELECT ID, ClothModifier, LeatherModifier, ChainModifier, PlateModifier FROM import_price_armor" +
@@ -471,7 +477,7 @@ namespace Framework.Database
"ParentItemBonusTreeID FROM item_bonus_tree_node ORDER BY ID DESC");
// ItemChildEquipment.db2
PrepareStatement(HotfixStatements.SEL_ITEM_CHILD_EQUIPMENT, "SELECT ID, ChildItemID, ChildItemEquipSlot, ParentItemID FROM item_child_equipment" +
PrepareStatement(HotfixStatements.SEL_ITEM_CHILD_EQUIPMENT, "SELECT ID, ParentItemID, ChildItemID, ChildItemEquipSlot FROM item_child_equipment" +
" ORDER BY ID DESC");
// ItemClass.db2
@@ -516,7 +522,8 @@ namespace Framework.Database
" FROM item_extended_cost ORDER BY ID DESC");
// ItemLevelSelector.db2
PrepareStatement(HotfixStatements.SEL_ITEM_LEVEL_SELECTOR, "SELECT ID, MinItemLevel, ItemLevelSelectorQualitySetID FROM item_level_selector ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_ITEM_LEVEL_SELECTOR, "SELECT ID, MinItemLevel, ItemLevelSelectorQualitySetID, AzeriteUnlockMappingSet" +
" FROM item_level_selector ORDER BY ID DESC");
// ItemLevelSelectorQuality.db2
PrepareStatement(HotfixStatements.SEL_ITEM_LEVEL_SELECTOR_QUALITY, "SELECT ID, QualityItemBonusListID, Quality, ParentILSQualitySetID" +
@@ -540,16 +547,6 @@ namespace Framework.Database
// ItemPriceBase.db2
PrepareStatement(HotfixStatements.SEL_ITEM_PRICE_BASE, "SELECT ID, ItemLevel, Armor, Weapon FROM item_price_base ORDER BY ID DESC");
// ItemRandomProperties.db2
PrepareStatement(HotfixStatements.SEL_ITEM_RANDOM_PROPERTIES, "SELECT ID, Name, Enchantment1, Enchantment2, Enchantment3, Enchantment4, Enchantment5" +
" FROM item_random_properties ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_ITEM_RANDOM_PROPERTIES_LOCALE, "SELECT ID, Name_lang FROM item_random_properties_locale WHERE locale = ?");
// ItemRandomSuffix.db2
PrepareStatement(HotfixStatements.SEL_ITEM_RANDOM_SUFFIX, "SELECT ID, Name, Enchantment1, Enchantment2, Enchantment3, Enchantment4, Enchantment5, " +
"AllocationPct1, AllocationPct2, AllocationPct3, AllocationPct4, AllocationPct5 FROM item_random_suffix ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_ITEM_RANDOM_SUFFIX_LOCALE, "SELECT ID, Name_lang FROM item_random_suffix_locale WHERE locale = ?");
// ItemSearchName.db2
PrepareStatement(HotfixStatements.SEL_ITEM_SEARCH_NAME, "SELECT AllowableRace, Display, ID, OverallQualityID, ExpansionID, MinFactionID, MinReputation, " +
"AllowableClass, RequiredLevel, RequiredSkill, RequiredSkillRank, RequiredAbility, ItemLevel, Flags1, Flags2, Flags3, Flags4" +
@@ -573,12 +570,12 @@ namespace Framework.Database
"StatPercentEditor5, StatPercentEditor6, StatPercentEditor7, StatPercentEditor8, StatPercentEditor9, StatPercentEditor10, Stackable, " +
"MaxCount, RequiredAbility, SellPrice, BuyPrice, VendorStackCount, PriceVariance, PriceRandomValue, Flags1, Flags2, Flags3, Flags4, " +
"FactionRelated, ItemNameDescriptionID, RequiredTransmogHoliday, RequiredHoliday, LimitCategory, GemProperties, SocketMatchEnchantmentId, " +
"TotemCategoryID, InstanceBound, ZoneBound, ItemSet, ItemRandomSuffixGroupID, RandomSelect, LockID, StartQuestID, PageID, ItemDelay, " +
"ScalingStatDistributionID, MinFactionID, RequiredSkillRank, RequiredSkill, ItemLevel, AllowableClass, ExpansionID, ArtifactID, SpellWeight, " +
"SpellWeightCategory, SocketType1, SocketType2, SocketType3, SheatheType, Material, PageMaterialID, LanguageID, Bonding, DamageDamageType, " +
"StatModifierBonusStat1, StatModifierBonusStat2, StatModifierBonusStat3, StatModifierBonusStat4, StatModifierBonusStat5, " +
"StatModifierBonusStat6, StatModifierBonusStat7, StatModifierBonusStat8, StatModifierBonusStat9, StatModifierBonusStat10, ContainerSlots, " +
"MinReputation, RequiredPVPMedal, RequiredPVPRank, RequiredLevel, InventoryType, OverallQualityID FROM item_sparse ORDER BY ID DESC");
"TotemCategoryID, InstanceBound, ZoneBound, ItemSet, LockID, StartQuestID, PageID, ItemDelay, ScalingStatDistributionID, MinFactionID, " +
"RequiredSkillRank, RequiredSkill, ItemLevel, AllowableClass, ExpansionID, ArtifactID, SpellWeight, SpellWeightCategory, SocketType1, " +
"SocketType2, SocketType3, SheatheType, Material, PageMaterialID, LanguageID, Bonding, DamageDamageType, StatModifierBonusStat1, " +
"StatModifierBonusStat2, StatModifierBonusStat3, StatModifierBonusStat4, StatModifierBonusStat5, StatModifierBonusStat6, " +
"StatModifierBonusStat7, StatModifierBonusStat8, StatModifierBonusStat9, StatModifierBonusStat10, ContainerSlots, MinReputation, " +
"RequiredPVPMedal, RequiredPVPRank, RequiredLevel, InventoryType, OverallQualityID FROM item_sparse ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_ITEM_SPARSE_LOCALE, "SELECT ID, Description_lang, Display3_lang, Display2_lang, Display1_lang, Display_lang" +
" FROM item_sparse_locale WHERE locale = ?");
@@ -633,13 +630,13 @@ namespace Framework.Database
// Map.db2
PrepareStatement(HotfixStatements.SEL_MAP, "SELECT ID, Directory, MapName, MapDescription0, MapDescription1, PvpShortDescription, PvpLongDescription, " +
"CorpseX, CorpseY, MapType, InstanceType, ExpansionID, AreaTableID, LoadingScreenID, TimeOfDayOverride, ParentMapID, CosmeticParentMapID, " +
"TimeOffset, MinimapIconScale, CorpseMapID, MaxPlayers, WindSettingsID, ZmpFileDataID, Flags1, Flags2 FROM map ORDER BY ID DESC");
"TimeOffset, MinimapIconScale, CorpseMapID, MaxPlayers, WindSettingsID, ZmpFileDataID, WdtFileDataID, Flags1, Flags2 FROM map ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_MAP_LOCALE, "SELECT ID, MapName_lang, MapDescription0_lang, MapDescription1_lang, PvpShortDescription_lang, " +
"PvpLongDescription_lang FROM map_locale WHERE locale = ?");
// MapDifficulty.db2
PrepareStatement(HotfixStatements.SEL_MAP_DIFFICULTY, "SELECT ID, Message, ItemContextPickerID, ContentTuningID, DifficultyID, LockID, ResetInterval, " +
"MaxPlayers, ItemContext, Flags, MapID FROM map_difficulty ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_MAP_DIFFICULTY, "SELECT ID, Message, DifficultyID, LockID, ResetInterval, MaxPlayers, ItemContext, " +
"ItemContextPickerID, Flags, ContentTuningID, MapID FROM map_difficulty ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_MAP_DIFFICULTY_LOCALE, "SELECT ID, Message_lang FROM map_difficulty_locale WHERE locale = ?");
// ModifierTree.db2
@@ -653,7 +650,7 @@ namespace Framework.Database
// MountCapability.db2
PrepareStatement(HotfixStatements.SEL_MOUNT_CAPABILITY, "SELECT ID, Flags, ReqRidingSkill, ReqAreaID, ReqSpellAuraID, ReqSpellKnownID, ModSpellAuraID, " +
"ReqMapID FROM mount_capability ORDER BY ID DESC");
"ReqMapID, PlayerConditionID FROM mount_capability ORDER BY ID DESC");
// MountTypeXCapability.db2
PrepareStatement(HotfixStatements.SEL_MOUNT_TYPE_X_CAPABILITY, "SELECT ID, MountTypeID, MountCapabilityID, OrderIndex FROM mount_type_x_capability" +
@@ -764,8 +761,8 @@ namespace Framework.Database
"Difficulty8, Difficulty9, Difficulty10 FROM quest_xp ORDER BY ID DESC");
// RandPropPoints.db2
PrepareStatement(HotfixStatements.SEL_RAND_PROP_POINTS, "SELECT ID, DamageReplaceStat, Epic1, Epic2, Epic3, Epic4, Epic5, Superior1, Superior2, Superior3, " +
"Superior4, Superior5, Good1, Good2, Good3, Good4, Good5 FROM rand_prop_points ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_RAND_PROP_POINTS, "SELECT ID, DamageReplaceStat, DamageSecondary, Epic1, Epic2, Epic3, Epic4, Epic5, Superior1, " +
"Superior2, Superior3, Superior4, Superior5, Good1, Good2, Good3, Good4, Good5 FROM rand_prop_points ORDER BY ID DESC");
// RewardPack.db2
PrepareStatement(HotfixStatements.SEL_REWARD_PACK, "SELECT ID, CharTitleID, Money, ArtifactXPDifficulty, ArtifactXPMultiplier, ArtifactXPCategoryID, " +
@@ -889,7 +886,7 @@ namespace Framework.Database
// SpellItemEnchantment.db2
PrepareStatement(HotfixStatements.SEL_SPELL_ITEM_ENCHANTMENT, "SELECT ID, Name, HordeName, EffectArg1, EffectArg2, EffectArg3, EffectScalingPoints1, " +
"EffectScalingPoints2, EffectScalingPoints3, TransmogCost, IconFileDataID, TransmogPlayerConditionID, EffectPointsMin1, EffectPointsMin2, " +
"EffectScalingPoints2, EffectScalingPoints3, TransmogPlayerConditionID, TransmogCost, IconFileDataID, EffectPointsMin1, EffectPointsMin2, " +
"EffectPointsMin3, ItemVisual, Flags, RequiredSkillID, RequiredSkillRank, ItemLevel, Charges, Effect1, Effect2, Effect3, ScalingClass, " +
"ScalingClassRestricted, ConditionID, MinLevel, MaxLevel FROM spell_item_enchantment ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_SPELL_ITEM_ENCHANTMENT_LOCALE, "SELECT ID, Name_lang, HordeName_lang FROM spell_item_enchantment_locale WHERE locale = ?");
@@ -909,9 +906,9 @@ namespace Framework.Database
// SpellMisc.db2
PrepareStatement(HotfixStatements.SEL_SPELL_MISC, "SELECT ID, DifficultyID, CastingTimeIndex, DurationIndex, RangeIndex, SchoolMask, Speed, LaunchDelay, " +
"MinDuration, SpellIconFileDataID, ActiveIconFileDataID, Attributes1, Attributes2, Attributes3, Attributes4, Attributes5, Attributes6, " +
"Attributes7, Attributes8, Attributes9, Attributes10, Attributes11, Attributes12, Attributes13, Attributes14, SpellID FROM spell_misc" +
" ORDER BY ID DESC");
"MinDuration, SpellIconFileDataID, ActiveIconFileDataID, ContentTuningID, Attributes1, Attributes2, Attributes3, Attributes4, Attributes5, " +
"Attributes6, Attributes7, Attributes8, Attributes9, Attributes10, Attributes11, Attributes12, Attributes13, Attributes14, SpellID" +
" FROM spell_misc ORDER BY ID DESC");
// SpellName.db2
PrepareStatement(HotfixStatements.SEL_SPELL_NAME, "SELECT ID, Name FROM spell_name ORDER BY ID DESC");
@@ -985,8 +982,8 @@ namespace Framework.Database
// TaxiNodes.db2
PrepareStatement(HotfixStatements.SEL_TAXI_NODES, "SELECT Name, PosX, PosY, PosZ, MapOffsetX, MapOffsetY, FlightMapOffsetX, FlightMapOffsetY, ID, " +
"ContinentID, ConditionID, CharacterBitNumber, Flags, UiTextureKitID, Facing, SpecialIconConditionID, VisibilityConditionID, " +
"MountCreatureID1, MountCreatureID2 FROM taxi_nodes ORDER BY ID DESC");
"ContinentID, ConditionID, CharacterBitNumber, Flags, UiTextureKitID, MinimapAtlasMemberID, Facing, SpecialIconConditionID, " +
"VisibilityConditionID, MountCreatureID1, MountCreatureID2 FROM taxi_nodes ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_TAXI_NODES_LOCALE, "SELECT ID, Name_lang FROM taxi_nodes_locale WHERE locale = ?");
// TaxiPath.db2
@@ -1009,7 +1006,7 @@ namespace Framework.Database
// TransmogSet.db2
PrepareStatement(HotfixStatements.SEL_TRANSMOG_SET, "SELECT Name, ID, ClassMask, TrackingQuestID, Flags, TransmogSetGroupID, ItemNameDescriptionID, " +
"ParentTransmogSetID, ExpansionID, UiOrder FROM transmog_set ORDER BY ID DESC");
"ParentTransmogSetID, Unknown810, ExpansionID, PatchID, UiOrder FROM transmog_set ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_TRANSMOG_SET_LOCALE, "SELECT ID, Name_lang FROM transmog_set_locale WHERE locale = ?");
// TransmogSetGroup.db2
@@ -1037,8 +1034,8 @@ namespace Framework.Database
"Region2Z, ID, UiMapID, OrderIndex, MapID, AreaID, WmoDoodadPlacementID, WmoGroupID FROM ui_map_assignment ORDER BY ID DESC");
// UiMapLink.db2
PrepareStatement(HotfixStatements.SEL_UI_MAP_LINK, "SELECT UiMinX, UiMinY, UiMaxX, UiMaxY, ID, ParentUiMapID, OrderIndex, ChildUiMapID FROM ui_map_link" +
" ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_UI_MAP_LINK, "SELECT UiMinX, UiMinY, UiMaxX, UiMaxY, ID, ParentUiMapID, OrderIndex, ChildUiMapID, " +
"OverrideHighlightFileDataID, OverrideHighlightAtlasID FROM ui_map_link ORDER BY ID DESC");
// UiMapXMapArt.db2
PrepareStatement(HotfixStatements.SEL_UI_MAP_X_MAP_ART, "SELECT ID, PhaseID, UiMapArtID, UiMapID FROM ui_map_x_map_art ORDER BY ID DESC");
@@ -1189,6 +1186,8 @@ namespace Framework.Database
SEL_CONTENT_TUNING,
SEL_CONTENT_TUNING_X_EXPECTED,
SEL_CONVERSATION_LINE,
SEL_CREATURE_DISPLAY_INFO,
@@ -1359,12 +1358,6 @@ namespace Framework.Database
SEL_ITEM_PRICE_BASE,
SEL_ITEM_RANDOM_PROPERTIES,
SEL_ITEM_RANDOM_PROPERTIES_LOCALE,
SEL_ITEM_RANDOM_SUFFIX,
SEL_ITEM_RANDOM_SUFFIX_LOCALE,
SEL_ITEM_SEARCH_NAME,
SEL_ITEM_SEARCH_NAME_LOCALE,
@@ -27,8 +27,7 @@ namespace Framework.Database
PrepareStatement(LoginStatements.SEL_REALMLIST, "SELECT id, name, address, localAddress, localSubnetMask, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild, Region, Battlegroup FROM realmlist WHERE flag <> 3 ORDER BY name");
PrepareStatement(LoginStatements.DEL_EXPIRED_IP_BANS, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
PrepareStatement(LoginStatements.UPD_EXPIRED_ACCOUNT_BANS, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
PrepareStatement(LoginStatements.SEL_IP_INFO, "(SELECT unbandate > UNIX_TIMESTAMP() OR unbandate = bandate AS banned, NULL as country FROM ip_banned WHERE ip = ?) " +
"UNION (SELECT NULL AS banned, country FROM ip2nation WHERE INET_NTOA(ip) = ?)");
PrepareStatement(LoginStatements.SEL_IP_INFO, "SELECT unbandate > UNIX_TIMESTAMP() OR unbandate = bandate AS banned, NULL as country FROM ip_banned WHERE ip = ?");
PrepareStatement(LoginStatements.INS_IP_AUTO_BANNED, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Cypher Auth', 'Failed login autoban')");
PrepareStatement(LoginStatements.SEL_IP_BANNED_ALL, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) ORDER BY unbandate");
@@ -38,7 +37,6 @@ namespace Framework.Database
PrepareStatement(LoginStatements.DEL_ACCOUNT_BANNED, "DELETE FROM account_banned WHERE id = ?");
PrepareStatement(LoginStatements.UPD_ACCOUNT_INFO_CONTINUED_SESSION, "UPDATE account SET sessionkey = ? WHERE id = ?");
PrepareStatement(LoginStatements.SEL_ACCOUNT_INFO_CONTINUED_SESSION, "SELECT username, sessionkey FROM account WHERE id = ?");
PrepareStatement(LoginStatements.SEL_LOGON_COUNTRY, "SELECT country FROM ip2nation WHERE ip < ? ORDER BY ip DESC LIMIT 0,1");
PrepareStatement(LoginStatements.SEL_ACCOUNT_ID_BY_NAME, "SELECT id FROM account WHERE username = ?");
PrepareStatement(LoginStatements.SEL_ACCOUNT_LIST_BY_NAME, "SELECT id, username FROM account WHERE username = ?");
PrepareStatement(LoginStatements.SEL_ACCOUNT_INFO_BY_NAME, "SELECT a.id, a.sessionkey, ba.last_ip, ba.locked, ba.lock_country, a.expansion, a.mutetime, ba.locale, a.recruiter, a.os, ba.id, aa.gmLevel, " +
@@ -95,7 +93,6 @@ namespace Framework.Database
PrepareStatement(LoginStatements.SEL_LAST_IP, "SELECT last_ip FROM account WHERE id = ?");
PrepareStatement(LoginStatements.SEL_REALMLIST_SECURITY_LEVEL, "SELECT allowedSecurityLevel from realmlist WHERE id = ?");
PrepareStatement(LoginStatements.DEL_ACCOUNT, "DELETE FROM account WHERE id = ?");
PrepareStatement(LoginStatements.SEL_IP2NATION_COUNTRY, "SELECT c.country FROM ip2nationCountries c, ip2nation i WHERE i.ip < ? AND c.code = i.country ORDER BY i.ip DESC LIMIT 0,1");
PrepareStatement(LoginStatements.SEL_AUTOBROADCAST, "SELECT id, weight, text FROM autobroadcast WHERE realmid = ? OR realmid = -1");
PrepareStatement(LoginStatements.GET_EMAIL_BY_ID, "SELECT email FROM account WHERE id = ?");
// 0: uint32, 1: uint32, 2: uint8, 3: uint32, 4: string // Complete name: "Login_Insert_AccountLoginDeLete_IP_Logging"
@@ -191,7 +188,6 @@ namespace Framework.Database
UPD_ACCOUNT_INFO_CONTINUED_SESSION,
SEL_ACCOUNT_INFO_CONTINUED_SESSION,
UPD_VS,
SEL_LOGON_COUNTRY,
SEL_ACCOUNT_ID_BY_NAME,
SEL_ACCOUNT_LIST_BY_NAME,
SEL_ACCOUNT_INFO_BY_NAME,
+2 -1
View File
@@ -221,7 +221,7 @@ namespace Framework.Database
try
{
string query = File.ReadAllText(path);
if (query.Length > 1048576) //Default size limit of querys
if (Encoding.UTF8.GetByteCount(query) > 1048576) //Default size limit of querys
Apply("SET GLOBAL max_allowed_packet=1073741824;");
using (var connection = _connectionInfo.GetConnection())
@@ -229,6 +229,7 @@ namespace Framework.Database
connection.Open();
using (MySqlCommand cmd = connection.CreateCommand())
{
cmd.CommandTimeout = 120;
cmd.CommandText = query;
cmd.ExecuteNonQuery();
return true;
+2 -1
View File
@@ -12,7 +12,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="MySqlConnector" Version="0.48.2" />
<PackageReference Include="MySqlConnector" Version="0.56.0" />
<PackageReference Include="Security.Cryptography" Version="1.7.2" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" />
</ItemGroup>
+41 -36
View File
@@ -162,30 +162,30 @@ namespace Framework.IO
//BitPacking
public byte ReadBit()
{
if (BitPosition == 8)
if (_bitPosition == 8)
{
BitValue = ReadUInt8();
BitPosition = 0;
_bitPosition = 0;
}
int returnValue = BitValue;
BitValue = (byte)(2 * returnValue);
++BitPosition;
++_bitPosition;
return (byte)(returnValue >> 7);
}
public bool HasBit()
{
if (BitPosition == 8)
if (_bitPosition == 8)
{
BitValue = ReadUInt8();
BitPosition = 0;
_bitPosition = 0;
}
int returnValue = BitValue;
BitValue = (byte)(2 * returnValue);
++BitPosition;
++_bitPosition;
return Convert.ToBoolean(returnValue >> 7);
}
@@ -203,64 +203,64 @@ namespace Framework.IO
#endregion
#region Write Methods
public void WriteInt8<T>(T data)
public void WriteInt8(sbyte data)
{
FlushBits();
writeStream.Write(Convert.ToSByte(data));
writeStream.Write(data);
}
public void WriteInt16<T>(T data)
public void WriteInt16(short data)
{
FlushBits();
writeStream.Write(Convert.ToInt16(data));
writeStream.Write(data);
}
public void WriteInt32<T>(T data)
public void WriteInt32(int data)
{
FlushBits();
writeStream.Write(Convert.ToInt32(data));
writeStream.Write(data);
}
public void WriteInt64<T>(T data)
public void WriteInt64(long data)
{
FlushBits();
writeStream.Write(Convert.ToInt64(data));
writeStream.Write(data);
}
public void WriteUInt8<T>(T data)
public void WriteUInt8(byte data)
{
FlushBits();
writeStream.Write(Convert.ToByte(data));
writeStream.Write(data);
}
public void WriteUInt16<T>(T data)
public void WriteUInt16(ushort data)
{
FlushBits();
writeStream.Write(Convert.ToUInt16(data));
writeStream.Write(data);
}
public void WriteUInt32<T>(T data)
public void WriteUInt32(uint data)
{
FlushBits();
writeStream.Write(Convert.ToUInt32(data));
writeStream.Write(data);
}
public void WriteUInt64<T>(T data)
public void WriteUInt64(ulong data)
{
FlushBits();
writeStream.Write(Convert.ToUInt64(data));
writeStream.Write(data);
}
public void WriteFloat<T>(T data)
public void WriteFloat(float data)
{
FlushBits();
writeStream.Write(Convert.ToSingle(data));
writeStream.Write(data);
}
public void WriteDouble<T>(T data)
public void WriteDouble(double data)
{
FlushBits();
writeStream.Write(Convert.ToDouble(data));
writeStream.Write(data);
}
/// <summary>
@@ -329,16 +329,16 @@ namespace Framework.IO
public bool WriteBit(object bit)
{
--BitPosition;
--_bitPosition;
if (Convert.ToBoolean(bit))
BitValue |= (byte)(1 << BitPosition);
BitValue |= (byte)(1 << _bitPosition);
if (BitPosition == 0)
if (_bitPosition == 0)
{
writeStream.Write(BitValue);
BitPosition = 8;
_bitPosition = 8;
BitValue = 0;
}
return Convert.ToBoolean(bit);
@@ -363,22 +363,27 @@ namespace Framework.IO
}
#endregion
public bool HasUnfinishedBitPack()
{
return _bitPosition != 8;
}
public void FlushBits()
{
if (BitPosition == 8)
if (_bitPosition == 8)
return;
writeStream.Write(BitValue);
BitValue = 0;
BitPosition = 8;
_bitPosition = 8;
}
public void ResetBitPos()
{
if (BitPosition > 7)
if (_bitPosition > 7)
return;
BitPosition = 8;
_bitPosition = 8;
BitValue = 0;
}
@@ -412,12 +417,12 @@ namespace Framework.IO
public void Clear()
{
BitPosition = 8;
_bitPosition = 8;
BitValue = 0;
writeStream = new BinaryWriter(new MemoryStream());
}
byte BitPosition = 8;
byte _bitPosition = 8;
byte BitValue;
BinaryWriter writeStream;
BinaryReader readStream;
@@ -103,6 +103,11 @@ namespace System.Collections.Generic
int cur = list.Count;
if (size < cur)
list.RemoveRange((int)size, cur - (int)size);
else
{
for (var i = list.Count; i < size; ++i)
list.Add(default(T));
}
}
public static void RandomResize<T>(this IList<T> list, uint size)
+1 -1
View File
@@ -70,7 +70,7 @@ namespace Game.AI
return new VehicleAI(creature);
else if (creature.HasUnitTypeMask(UnitTypeMask.ControlableGuardian) && ((Guardian)creature).GetOwner().IsTypeId(TypeId.Player))
return new PetAI(creature);
else if (creature.HasFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick))
else if (creature.HasNpcFlag(NPCFlags.SpellClick))
return new NullCreatureAI(creature);
else if (creature.IsGuard())
return new GuardAI(creature);
+2 -2
View File
@@ -333,9 +333,9 @@ namespace Game.AI
if (point)
{
point.SetObjectScale(SharedConst.BoundaryVisualizeCreatureScale);
point.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.Stunned | UnitFlags.ImmuneToNpc);
point.AddUnitFlag(UnitFlags.ImmuneToPc | UnitFlags.Stunned | UnitFlags.ImmuneToNpc);
if (!hasOutOfBoundsNeighbor)
point.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable);
point.AddUnitFlag(UnitFlags.NotSelectable);
}
Q.Remove(front);
}
+2 -2
View File
@@ -65,14 +65,14 @@ namespace Game.AI
public override void JustDied(Unit unit)
{
// We died while possessed, disable our loot
me.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Lootable);
me.RemoveDynamicFlag(UnitDynFlags.Lootable);
}
public override void KilledUnit(Unit victim)
{
// We killed a creature, disable victim's loot
if (victim.IsTypeId(TypeId.Unit))
victim.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Lootable);
me.RemoveDynamicFlag(UnitDynFlags.Lootable);
}
public override void OnCharmed(bool apply)
+10 -10
View File
@@ -392,7 +392,7 @@ namespace Game.AI
public PlayerAI(Player player) : base(player)
{
me = player;
_selfSpec = player.GetUInt32Value(PlayerFields.CurrentSpecId);
_selfSpec = player.GetPrimarySpecialization();
_isSelfHealer = IsPlayerHealer(player);
_isSelfRangedAttacker = IsPlayerRangedAttacker(player);
}
@@ -414,15 +414,15 @@ namespace Game.AI
default:
return false;
case Class.Paladin:
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.PaladinHoly;
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.PaladinHoly;
case Class.Priest:
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.PriestDiscipline || who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.PriestHoly;
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestDiscipline || who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestHoly;
case Class.Shaman:
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.ShamanRestoration;
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.ShamanRestoration;
case Class.Monk:
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.MonkMistweaver;
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.MonkMistweaver;
case Class.Druid:
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.DruidRestoration;
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.DruidRestoration;
}
}
bool IsPlayerRangedAttacker(Player who)
@@ -454,11 +454,11 @@ namespace Game.AI
return false;
}
case Class.Priest:
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.PriestShadow;
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestShadow;
case Class.Shaman:
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.ShamanElemental;
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.ShamanElemental;
case Class.Druid:
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.DruidBalance;
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.DruidBalance;
}
}
@@ -659,7 +659,7 @@ namespace Game.AI
return (!who || who == me) ? _isSelfHealer : IsPlayerHealer(who);
}
public bool IsRangedAttacker(Player who = null) { return (!who || who == me) ? _isSelfRangedAttacker : IsPlayerRangedAttacker(who); }
uint GetSpec(Player who = null) { return (!who || who == me) ? _selfSpec : who.GetUInt32Value(PlayerFields.CurrentSpecId); }
uint GetSpec(Player who = null) { return (!who || who == me) ? _selfSpec : who.GetPrimarySpecialization(); }
void SetIsRangedAttacker(bool state) { _isSelfRangedAttacker = state; } // this allows overriding of the default ranged attacker detection
public virtual Unit SelectAttackTarget() { return me.GetCharmer() ? me.GetCharmer().GetVictim() : null; }
+1 -1
View File
@@ -125,7 +125,7 @@ namespace Game.AI
return null;
//Silenced so we can't cast
if (me.HasFlag(UnitFields.Flags, UnitFlags.Silenced))
if (me.HasUnitFlag(UnitFlags.Silenced))
return null;
//Using the extended script system we first create a list of viable spells
@@ -133,7 +133,7 @@ namespace Game.AI
//add a small delay before going to first waypoint, normal in near all cases
m_uiWPWaitTimer = 1000;
if (me.getFaction() != me.GetCreatureTemplate().Faction)
if (me.GetFaction() != me.GetCreatureTemplate().Faction)
me.RestoreFaction();
Reset();
@@ -162,7 +162,7 @@ namespace Game.AI
{
me.GetMotionMaster().MoveTargetedHome();
if (HasImmuneToNPCFlags)
me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc);
me.AddUnitFlag(UnitFlags.ImmuneToNpc);
Reset();
}
}
@@ -463,11 +463,12 @@ namespace Game.AI
}
//disable npcflags
me.SetUInt64Value(UnitFields.NpcFlags, (ulong)NPCFlags.None);
if (me.HasFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc))
me.SetNpcFlags(NPCFlags.None);
me.SetNpcFlags2(NPCFlags2.None);
if (me.HasUnitFlag(UnitFlags.ImmuneToNpc))
{
HasImmuneToNPCFlags = true;
me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc);
me.RemoveUnitFlag(UnitFlags.ImmuneToNpc);
}
Log.outDebug(LogFilter.Scripts, $"EscortAI started. ActiveAttacker = {m_bIsActiveAttacker}, Run = {m_bIsRunning}, PlayerGUID = {m_uiPlayerGUID.ToString()}");
@@ -168,7 +168,7 @@ namespace Game.AI
if (!IsCombatMovementAllowed())
SetCombatMovement(true);
if (me.getFaction() != me.GetCreatureTemplate().Faction)
if (me.GetFaction() != me.GetCreatureTemplate().Faction)
me.SetFaction(me.GetCreatureTemplate().Faction);
Reset();
@@ -318,7 +318,8 @@ namespace Game.AI
Log.outDebug(LogFilter.Scripts, "FollowerAI start with WAYPOINT_MOTION_TYPE, set to MoveIdle.");
}
me.SetUInt64Value(UnitFields.NpcFlags, (uint)NPCFlags.None);
me.SetNpcFlags(NPCFlags.None);
me.SetNpcFlags2(NPCFlags2.None);
AddFollowState(eFollowState.Inprogress);
+5 -5
View File
@@ -131,8 +131,8 @@ namespace Game.AI
if (invoker && invoker.GetTypeId() == TypeId.Player)
{
mEscortNPCFlags = me.GetUInt32Value(UnitFields.NpcFlags);
me.SetFlag(UnitFields.NpcFlags, 0);
mEscortNPCFlags = me.m_unitData.NpcFlags[0];
me.SetNpcFlags(NPCFlags.None);
}
GetScript().ProcessEventsFor(SmartEvents.WaypointStart, null, mCurrentWPID, GetScript().GetPathId());
@@ -227,7 +227,7 @@ namespace Game.AI
if (mEscortNPCFlags != 0)
{
me.SetFlag(UnitFields.NpcFlags, mEscortNPCFlags);
me.SetNpcFlags((NPCFlags)mEscortNPCFlags);
mEscortNPCFlags = 0;
}
@@ -591,7 +591,7 @@ namespace Game.AI
mDespawnState = 0;
mEscortState = SmartEscortState.None;
me.SetVisible(true);
if (me.getFaction() != me.GetCreatureTemplate().Faction)
if (me.GetFaction() != me.GetCreatureTemplate().Faction)
me.RestoreFaction();
mJustReset = true;
JustReachedHome();
@@ -646,7 +646,7 @@ namespace Game.AI
public override void AttackStart(Unit who)
{
// dont allow charmed npcs to act on their own
if (me.HasFlag(UnitFields.Flags, UnitFlags.PlayerControlled))
if (me.HasUnitFlag(UnitFlags.PlayerControlled))
{
if (who && mCanAutoAttack)
me.Attack(who, true);
@@ -1715,7 +1715,7 @@ namespace Game.AI
[FieldOffset(16)]
public Raw raw;
[FieldOffset(32)]
[FieldOffset(40)]
public string param_string;
#region Structs
+51 -17
View File
@@ -221,7 +221,7 @@ namespace Game.AI
CreatureTemplate ci = Global.ObjectMgr.GetCreatureTemplate(obj.ToCreature().GetEntry());
if (ci != null)
{
if (obj.ToCreature().getFaction() != ci.Faction)
if (obj.ToCreature().GetFaction() != ci.Faction)
{
obj.ToCreature().SetFaction(ci.Faction);
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_FACTION: Creature entry {0}, GuidLow {1} set faction to {2}",
@@ -647,7 +647,7 @@ namespace Game.AI
{
if (IsUnit(obj))
{
obj.ToUnit().SetUInt32Value(UnitFields.NpcEmotestate, e.Action.emote.emoteId);
obj.ToUnit().SetEmoteState((Emote)e.Action.emote.emoteId);
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_EMOTE_STATE. Unit {0} set emotestate to {1}",
obj.GetGUID().ToString(), e.Action.emote.emoteId);
}
@@ -668,13 +668,13 @@ namespace Game.AI
{
if (e.Action.unitFlag.type == 0)
{
obj.ToUnit().SetFlag(UnitFields.Flags, e.Action.unitFlag.flag);
obj.ToUnit().AddUnitFlag((UnitFlags)e.Action.unitFlag.flag);
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_UNIT_FLAG. Unit {0} added flag {1} to UNIT_FIELD_FLAGS",
obj.GetGUID().ToString(), e.Action.unitFlag.flag);
}
else
{
obj.ToUnit().SetFlag(UnitFields.Flags2, e.Action.unitFlag.flag);
obj.ToUnit().AddUnitFlag2((UnitFlags2)e.Action.unitFlag.flag);
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_UNIT_FLAG. Unit {0} added flag {1} to UNIT_FIELD_FLAGS_2",
obj.GetGUID().ToString(), e.Action.unitFlag.flag);
}
@@ -696,13 +696,13 @@ namespace Game.AI
{
if (e.Action.unitFlag.type == 0)
{
obj.ToUnit().RemoveFlag(UnitFields.Flags2, e.Action.unitFlag.flag);
obj.ToUnit().RemoveUnitFlag((UnitFlags)e.Action.unitFlag.flag);
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_REMOVE_UNIT_FLAG. Unit {0} removed flag {1} to UNIT_FIELD_FLAGS",
obj.GetGUID().ToString(), e.Action.unitFlag.flag);
}
else
{
obj.ToUnit().RemoveFlag(UnitFields.Flags2, e.Action.unitFlag.flag);
obj.ToUnit().RemoveUnitFlag2((UnitFlags2)e.Action.unitFlag.flag);
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_REMOVE_UNIT_FLAG. Unit {0} removed flag {1} to UNIT_FIELD_FLAGS_2",
obj.GetGUID().ToString(), e.Action.unitFlag.flag);
}
@@ -1756,7 +1756,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsUnit(obj))
obj.ToUnit().SetUInt64Value(UnitFields.NpcFlags, e.Action.unitFlag.flag);
obj.ToUnit().SetNpcFlags((NPCFlags)e.Action.unitFlag.flag);
break;
}
case SmartActions.AddNpcFlag:
@@ -1767,7 +1767,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsUnit(obj))
obj.ToUnit().SetFlag64(UnitFields.NpcFlags, e.Action.unitFlag.flag);
obj.ToUnit().AddNpcFlag((NPCFlags)e.Action.unitFlag.flag);
break;
}
case SmartActions.RemoveNpcFlag:
@@ -1778,7 +1778,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsUnit(obj))
obj.ToUnit().RemoveFlag64(UnitFields.NpcFlags, e.Action.unitFlag.flag);
obj.ToUnit().RemoveNpcFlag((NPCFlags)e.Action.unitFlag.flag);
break;
}
case SmartActions.CrossCast:
@@ -1937,7 +1937,25 @@ namespace Game.AI
break;
foreach (var obj in targets)
if (IsUnit(obj))
obj.ToUnit().SetByteFlag(UnitFields.Bytes1, (byte)e.Action.setunitByte.type, e.Action.setunitByte.byte1);
{
switch (e.Action.setunitByte.type)
{
case 0:
obj.ToUnit().SetStandState((UnitStandStateType)e.Action.setunitByte.byte1);
break;
case 1:
// pet talent points
break;
case 2:
obj.ToUnit().AddVisFlags((UnitVisFlags)e.Action.setunitByte.byte1);
break;
case 3:
// this is totally wrong to maintain compatibility with existing scripts
// TODO: fix with animtier overhaul
obj.ToUnit().SetAnimTier((UnitBytes1Flags)(obj.ToUnit().m_unitData.AnimTier | e.Action.setunitByte.byte1), false);
break;
}
}
break;
}
case SmartActions.RemoveUnitFieldBytes1:
@@ -1948,7 +1966,23 @@ namespace Game.AI
foreach (var obj in targets)
if (IsUnit(obj))
obj.ToUnit().RemoveByteFlag(UnitFields.Bytes1, (byte)e.Action.delunitByte.type, e.Action.delunitByte.byte1);
{
switch (e.Action.setunitByte.type)
{
case 0:
obj.ToUnit().SetStandState(UnitStandStateType.Stand);
break;
case 1:
// pet talent points
break;
case 2:
obj.ToUnit().RemoveVisFlags((UnitVisFlags)e.Action.setunitByte.byte1);
break;
case 3:
obj.ToUnit().SetAnimTier((UnitBytes1Flags)(obj.ToUnit().m_unitData.AnimTier & ~e.Action.setunitByte.byte1), false);
break;
}
}
break;
}
case SmartActions.InterruptSpell:
@@ -1981,7 +2015,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsUnit(obj))
obj.ToUnit().SetUInt32Value(ObjectFields.DynamicFlags, e.Action.unitFlag.flag);
obj.ToUnit().SetDynamicFlags((UnitDynFlags)e.Action.unitFlag.flag);
break;
}
case SmartActions.AddDynamicFlag:
@@ -1992,7 +2026,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsUnit(obj))
obj.ToUnit().SetFlag(ObjectFields.DynamicFlags, e.Action.unitFlag.flag);
obj.ToUnit().AddDynamicFlag((UnitDynFlags)e.Action.unitFlag.flag);
break;
}
case SmartActions.RemoveDynamicFlag:
@@ -2003,7 +2037,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsUnit(obj))
obj.ToUnit().RemoveFlag(ObjectFields.DynamicFlags, e.Action.unitFlag.flag);
obj.ToUnit().RemoveDynamicFlag((UnitDynFlags)e.Action.unitFlag.flag);
break;
}
case SmartActions.JumpToPos:
@@ -2163,7 +2197,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsGameObject(obj))
obj.ToGameObject().SetUInt32Value(GameObjectFields.Flags, e.Action.goFlag.flag);
obj.ToGameObject().SetFlags((GameObjectFlags)e.Action.goFlag.flag);
break;
}
case SmartActions.AddGoFlag:
@@ -2174,7 +2208,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsGameObject(obj))
obj.ToGameObject().SetFlag(GameObjectFields.Flags, e.Action.goFlag.flag);
obj.ToGameObject().AddFlag((GameObjectFlags)e.Action.goFlag.flag);
break;
}
case SmartActions.RemoveGoFlag:
@@ -2185,7 +2219,7 @@ namespace Game.AI
foreach (var obj in targets)
if (IsGameObject(obj))
obj.ToGameObject().RemoveFlag(GameObjectFields.Flags, e.Action.goFlag.flag);
obj.ToGameObject().RemoveFlag((GameObjectFlags)e.Action.goFlag.flag);
break;
}
case SmartActions.SummonCreatureGroup:
@@ -514,7 +514,7 @@ namespace Game.Achievements
//! Since no common attributes were found, (not even in titleRewardFlags field)
//! we explicitly check by ID. Maybe in the future we could move the achievement_reward
//! condition fields to the condition system.
uint titleId = reward.TitleId[achievement.Id == 1793 ? _owner.GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender) : (_owner.GetTeam() == Team.Alliance ? 0 : 1)];
uint titleId = reward.TitleId[achievement.Id == 1793 ? _owner.m_playerData.NativeSex : (_owner.GetTeam() == Team.Alliance ? 0 : 1)];
if (titleId != 0)
{
CharTitlesRecord titleEntry = CliDB.CharTitlesStorage.LookupByKey(titleId);
+4 -4
View File
@@ -284,7 +284,7 @@ namespace Game.Achievements
SetCriteriaProgress(criteria, referencePlayer.GetReputationMgr().GetVisibleFactionCount(), referencePlayer);
break;
case CriteriaTypes.EarnHonorableKill:
SetCriteriaProgress(criteria, referencePlayer.GetUInt32Value(ActivePlayerFields.LifetimeHonorableKills), referencePlayer);
SetCriteriaProgress(criteria, referencePlayer.m_activePlayerData.LifetimeHonorableKills, referencePlayer);
break;
case CriteriaTypes.HighestGoldValueOwned:
SetCriteriaProgress(criteria, referencePlayer.GetMoney(), referencePlayer, ProgressType.Highest);
@@ -1063,12 +1063,12 @@ namespace Game.Achievements
if (area.AreaBit < 0)
continue;
int playerIndexOffset = (int)((uint)area.AreaBit / 32);
int playerIndexOffset = (int)((uint)area.AreaBit / 64);
if (playerIndexOffset >= PlayerConst.ExploredZonesSize)
continue;
uint mask = 1u << (int)((uint)area.AreaBit % 32);
if (Convert.ToBoolean(referencePlayer.GetUInt32Value(ActivePlayerFields.ExploredZones + playerIndexOffset) & mask))
ulong mask = 1ul << (int)((uint)area.AreaBit % 64);
if (Convert.ToBoolean(referencePlayer.m_activePlayerData.ExploredZones[playerIndexOffset] & mask))
{
matchFound = true;
break;
+1 -1
View File
@@ -29,7 +29,7 @@ namespace Game.Arenas
TeamId = (int)(team == Team.Alliance ? BattlegroundTeamId.Alliance : BattlegroundTeamId.Horde);
}
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PlayerData playerData)
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PVPMatchPlayerStatistics playerData)
{
base.BuildPvPLogPlayerDataPacket(out playerData);
+1 -33
View File
@@ -555,38 +555,6 @@ namespace Game
string name = proto.GetName(player.GetSession().GetSessionDbcLocale());
if (string.IsNullOrEmpty(name))
continue;
// DO NOT use GetItemEnchantMod(proto.RandomProperty) as it may return a result
// that matches the search but it may not equal item.GetItemRandomPropertyId()
// used in BuildAuctionInfo() which then causes wrong items to be listed
int propRefID = item.GetItemRandomPropertyId();
if (propRefID != 0)
{
string suffix = null;
// Append the suffix to the name (ie: of the Monkey) if one exists
// These are found in ItemRandomProperties.dbc, not ItemRandomSuffix.dbc
// even though the DBC names seem misleading
if (propRefID < 0)
{
ItemRandomSuffixRecord itemRandSuffix = CliDB.ItemRandomSuffixStorage.LookupByKey(-propRefID);
if (itemRandSuffix != null)
suffix = itemRandSuffix.Name[player.GetSession().GetSessionDbcLocale()];
}
else
{
ItemRandomPropertiesRecord itemRandProp = CliDB.ItemRandomPropertiesStorage.LookupByKey(propRefID);
if (itemRandProp != null)
suffix = itemRandProp.Name[player.GetSession().GetSessionDbcLocale()];
}
// dbc local name
if (!string.IsNullOrEmpty(suffix))
{
// Append the suffix (ie: of the Monkey) to the name using localization
// or default enUS if localization is invalid
name += ' ' + suffix;
}
}
}
// Add the item if no search term or if entered search term was found
@@ -645,7 +613,7 @@ namespace Game
}
byte i = 0;
foreach (ItemDynamicFieldGems gemData in item.GetGems())
foreach (SocketedGem gemData in item.m_itemData.Gems)
{
if (gemData.ItemId != 0)
{
+3 -3
View File
@@ -501,7 +501,7 @@ namespace Game.BattleFields
{
creature.CombatStop();
creature.SetReactState(ReactStates.Passive);
creature.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable);
creature.AddUnitFlag(UnitFlags.NonAttackable | UnitFlags.NotSelectable);
creature.DisappearAndDie();
creature.SetVisible(false);
}
@@ -509,14 +509,14 @@ namespace Game.BattleFields
public void ShowNpc(Creature creature, bool aggressive)
{
creature.SetVisible(true);
creature.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable);
creature.RemoveUnitFlag(UnitFlags.NonAttackable | UnitFlags.NotSelectable);
if (!creature.IsAlive())
creature.Respawn(true);
if (aggressive)
creature.SetReactState(ReactStates.Aggressive);
else
{
creature.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable);
creature.AddUnitFlag(UnitFlags.NonAttackable);
creature.SetReactState(ReactStates.Passive);
}
}
@@ -187,7 +187,7 @@ namespace Game.BattleFields
// Update faction of relic, only attacker can click on
relic.SetFaction(WGConst.WintergraspFaction[GetAttackerTeam()]);
// Set in use (not allow to click on before last door is broken)
relic.SetFlag(GameObjectFields.Flags, GameObjectFlags.InUse | GameObjectFlags.NotSelectable);
relic.AddFlag(GameObjectFlags.InUse | GameObjectFlags.NotSelectable);
m_titansRelicGUID = relic.GetGUID();
}
else
@@ -1157,7 +1157,7 @@ namespace Game.BattleFields
}
_wg.SetRelicInteractible(true);
if (_wg.GetRelic())
_wg.GetRelic().RemoveFlag(GameObjectFields.Flags, GameObjectFlags.InUse | GameObjectFlags.NotSelectable);
_wg.GetRelic().RemoveFlag(GameObjectFlags.InUse | GameObjectFlags.NotSelectable);
else
Log.outError(LogFilter.Server, "BattlefieldWG: Titan Relic not found.");
break;
+7 -13
View File
@@ -426,7 +426,7 @@ namespace Game.BattleGrounds
player.SendPacket(battlefieldStatus);
// Correctly display EnemyUnitFrame
player.SetByteValue(PlayerFields.Bytes4, 3, (byte)player.GetBGTeam());
player.SetArenaFaction((byte)player.GetBGTeam());
player.RemoveAurasDueToSpell(BattlegroundConst.SpellArenaPreparation);
player.ResetAllPowers();
@@ -974,7 +974,7 @@ namespace Game.BattleGrounds
public virtual void AddPlayer(Player player)
{
// remove afk from player
if (player.HasFlag(PlayerFields.Flags, PlayerFlags.AFK))
if (player.isAFK())
player.ToggleAFK();
// score struct must be created in inherited class
@@ -985,7 +985,7 @@ namespace Game.BattleGrounds
BattlegroundPlayer bp = new BattlegroundPlayer();
bp.OfflineRemoveTime = 0;
bp.Team = team;
bp.ActiveSpec = player.GetInt32Value(PlayerFields.CurrentSpecId);
bp.ActiveSpec = (int)player.GetPrimarySpecialization();
// Add to list/maps
m_Players[guid] = bp;
@@ -1221,12 +1221,9 @@ namespace Game.BattleGrounds
{
pvpLogData = new PVPLogData();
if (GetStatus() == BattlegroundStatus.WaitLeave)
pvpLogData.Winner.Set((byte)GetWinner());
foreach (var score in PlayerScores)
{
PVPLogData.PlayerData playerData;
PVPLogData.PVPMatchPlayerStatistics playerData;
score.Value.BuildPvPLogPlayerDataPacket(out playerData);
@@ -1234,14 +1231,14 @@ namespace Game.BattleGrounds
if (player)
{
playerData.IsInWorld = true;
playerData.PrimaryTalentTree = (int)player.GetUInt32Value(PlayerFields.CurrentSpecId);
playerData.PrimaryTalentTree = (int)player.GetPrimarySpecialization();
playerData.Sex = (int)player.GetGender();
playerData.PlayerRace = player.GetRace();
playerData.PlayerClass = (int)player.GetClass();
playerData.HonorLevel = (int)player.GetHonorLevel();
}
pvpLogData.Players.Add(playerData);
pvpLogData.Statistics.Add(playerData);
}
pvpLogData.PlayerCount[(int)BattlegroundTeamId.Horde] = (sbyte)GetPlayersCountByTeam(Team.Horde);
@@ -1534,9 +1531,6 @@ namespace Game.BattleGrounds
// casting visual effect
creature.SetChannelSpellId(BattlegroundConst.SpellSpiritHealChannel);
creature.SetChannelSpellXSpellVisualId(BattlegroundConst.SpellSpiritHealChannelVisual);
// correct cast speed
creature.SetFloatValue(UnitFields.ModCastSpeed, 1.0f);
creature.SetFloatValue(UnitFields.ModCastHaste, 1.0f);
//creature.CastSpell(creature, SPELL_SPIRIT_HEAL_CHANNEL, true);
return true;
}
@@ -1649,7 +1643,7 @@ namespace Game.BattleGrounds
if (!isArena())
{
// To be able to remove insignia -- ONLY IN Battlegrounds
victim.SetFlag(UnitFields.Flags, UnitFlags.Skinnable);
victim.AddUnitFlag(UnitFlags.Skinnable);
RewardXPAtKill(killer, victim);
}
}
@@ -702,7 +702,7 @@ namespace Game.BattleGrounds
CreatureTemplate cInfo = Global.ObjectMgr.GetCreatureTemplate(entry);
if (cInfo != null)
{
if (!cInfo.Npcflag.HasAnyFlag(NPCFlags.BattleMaster))
if (!cInfo.Npcflag.HasAnyFlag((uint)NPCFlags.BattleMaster))
Log.outError(LogFilter.Sql, "Creature (Entry: {0}) listed in `battlemaster_entry` is not a battlemaster.", entry);
}
else
@@ -733,10 +733,10 @@ namespace Game.BattleGrounds
var templates = Global.ObjectMgr.GetCreatureTemplates();
foreach (var creature in templates)
{
if (creature.Value.Npcflag.HasAnyFlag(NPCFlags.BattleMaster) && !mBattleMastersMap.ContainsKey(creature.Value.Entry))
if (creature.Value.Npcflag.HasAnyFlag((uint)NPCFlags.BattleMaster) && !mBattleMastersMap.ContainsKey(creature.Value.Entry))
{
Log.outError(LogFilter.Sql, "CreatureTemplate (Entry: {0}) has UNIT_NPC_FLAG_BATTLEMASTER but no data in `battlemaster_entry` table. Removing flag!", creature.Value.Entry);
templates[creature.Key].Npcflag &= ~NPCFlags.BattleMaster;
templates[creature.Key].Npcflag &= ~(uint)NPCFlags.BattleMaster;
}
}
}
@@ -57,9 +57,9 @@ namespace Game.BattleGrounds
}
}
public virtual void BuildPvPLogPlayerDataPacket(out PVPLogData.PlayerData playerData)
public virtual void BuildPvPLogPlayerDataPacket(out PVPLogData.PVPMatchPlayerStatistics playerData)
{
playerData = new PVPLogData.PlayerData();
playerData = new PVPLogData.PVPMatchPlayerStatistics();
playerData.PlayerGUID = PlayerGuid;
playerData.Kills = KillingBlows;
playerData.Faction = (byte)TeamId;
@@ -833,7 +833,7 @@ namespace Game.BattleGrounds.Zones
}
}
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PlayerData playerData)
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PVPMatchPlayerStatistics playerData)
{
base.BuildPvPLogPlayerDataPacket(out playerData);
@@ -999,7 +999,7 @@ namespace Game.BattleGrounds.Zones
}
}
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PlayerData playerData)
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PVPMatchPlayerStatistics playerData)
{
base.BuildPvPLogPlayerDataPacket(out playerData);
@@ -689,9 +689,9 @@ namespace Game.BattleGrounds.Zones
if (dem)
{
if (start)
dem.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable);
dem.AddUnitFlag(UnitFlags.NonAttackable | UnitFlags.NotSelectable);
else
dem.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable);
dem.RemoveUnitFlag(UnitFlags.NonAttackable | UnitFlags.NotSelectable);
}
}
}
@@ -768,9 +768,9 @@ namespace Game.BattleGrounds.Zones
if (go)
{
if (CanInteractWithObject(objectId))
go.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable);
go.RemoveFlag(GameObjectFlags.NotSelectable);
else
go.SetFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable);
go.AddFlag(GameObjectFlags.NotSelectable);
}
}
@@ -1153,7 +1153,7 @@ namespace Game.BattleGrounds.Zones
}
}
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PlayerData playerData)
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PVPMatchPlayerStatistics playerData)
{
base.BuildPvPLogPlayerDataPacket(out playerData);
@@ -966,7 +966,7 @@ namespace Game.BattleGrounds.Zones
}
}
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PlayerData playerData)
public override void BuildPvPLogPlayerDataPacket(out PVPLogData.PVPMatchPlayerStatistics playerData)
{
base.BuildPvPLogPlayerDataPacket(out playerData);
+3 -3
View File
@@ -406,7 +406,7 @@ namespace Game.BattlePets
return;
// TODO: set proper CreatureID for spell DEFAULT_SUMMON_BATTLE_PET_SPELL (default EffectMiscValueA is 40721 - Murkimus the Gladiator)
_owner.GetPlayer().SetGuidValue(ActivePlayerFields.SummonedBattlePetId, guid);
_owner.GetPlayer().SetSummonedBattlePetGUID(guid);
_owner.GetPlayer().CastSpell(_owner.GetPlayer(), speciesEntry.SummonSpellID != 0 ? speciesEntry.SummonSpellID : SharedConst.DefaultSummonBattlePetSpell);
// TODO: set pet level, quality... update fields
@@ -416,10 +416,10 @@ namespace Game.BattlePets
{
Player ownerPlayer = _owner.GetPlayer();
Creature pet = ObjectAccessor.GetCreatureOrPetOrVehicle(ownerPlayer, ownerPlayer.GetCritterGUID());
if (pet && ownerPlayer.GetGuidValue(ActivePlayerFields.SummonedBattlePetId) == pet.GetGuidValue(UnitFields.BattlePetCompanionGuid))
if (pet && ownerPlayer.m_activePlayerData.SummonedBattlePetGUID == pet.GetBattlePetCompanionGUID())
{
pet.DespawnOrUnsummon();
ownerPlayer.SetGuidValue(ActivePlayerFields.SummonedBattlePetId, ObjectGuid.Empty);
ownerPlayer.SetSummonedBattlePetGUID(ObjectGuid.Empty);
}
}
+1 -1
View File
@@ -546,7 +546,7 @@ namespace Game
Player invitee = Global.ObjAccessor.FindPlayer(inviteeGuid);
uint inviteeLevel = invitee ? invitee.getLevel() : Player.GetLevelFromDB(inviteeGuid);
uint inviteeGuildId = invitee ? invitee.GetGuildId() : Player.GetGuildIdFromDB(inviteeGuid);
ulong inviteeGuildId = invitee ? invitee.GetGuildId() : Player.GetGuildIdFromDB(inviteeGuid);
CalendarEventInviteInfo inviteInfo = new CalendarEventInviteInfo();
inviteInfo.Guid = inviteeGuid;
@@ -65,9 +65,9 @@ namespace Game.Chat
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChannelNotifyJoined notify = new ChannelNotifyJoined();
//notify->ChannelWelcomeMsg = "";
//notify.ChannelWelcomeMsg = "";
notify.ChatChannelID = (int)_source.GetChannelId();
//notify->InstanceID = 0;
//notify.InstanceID = 0;
notify.ChannelFlags = _source.GetFlags();
notify.Channel = _source.GetName(localeIdx);
return notify;
+2 -2
View File
@@ -750,7 +750,7 @@ namespace Game.Chat
var ipBytes = System.Net.IPAddress.Parse(handler.GetSession().GetRemoteAddress()).GetAddressBytes();
Array.Reverse(ipBytes);
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_LOGON_COUNTRY);
/*PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_LOGON_COUNTRY);
stmt.AddValue(0, BitConverter.ToUInt32(ipBytes, 0));
SQLResult result = DB.Login.Query(stmt);
@@ -767,7 +767,7 @@ namespace Game.Chat
{
handler.SendSysMessage("[IP2NATION] Table empty");
Log.outDebug(LogFilter.Server, "[IP2NATION] Table empty");
}
}*/
}
else if (param == "off")
{
@@ -285,7 +285,8 @@ namespace Game.Chat.Commands
}
[CommandGroup("lock", RBACPermissions.CommandBnetAccount, true)]
class LockCommands {
class LockCommands
{
[Command("country", RBACPermissions.CommandBnetAccountLockCountry, true)]
static bool HandleLockCountryCommand(StringArguments args, CommandHandler handler)
{
@@ -300,7 +301,7 @@ namespace Game.Chat.Commands
{
if (param == "on")
{
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_LOGON_COUNTRY);
/*PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_LOGON_COUNTRY);
var ipBytes = System.Net.IPAddress.Parse(handler.GetSession().GetRemoteAddress()).GetAddressBytes();
Array.Reverse(ipBytes);
stmt.AddValue(0, BitConverter.ToUInt32(ipBytes, 0));
@@ -318,7 +319,7 @@ namespace Game.Chat.Commands
{
handler.SendSysMessage("[IP2NATION] Table empty");
Log.outDebug(LogFilter.Server, "[IP2NATION] Table empty");
}
}*/
}
else if (param == "off")
{
@@ -52,7 +52,7 @@ namespace Game.Chat
if (string.IsNullOrEmpty(name))
continue;
string activeStr = target.GetUInt32Value(PlayerFields.ChosenTitle) == titleInfo.MaskID
string activeStr = target.m_playerData.PlayerTitle == titleInfo.MaskID
? handler.GetCypherString(CypherStrings.Active) : "";
string titleNameStr = string.Format(name.ConvertFormatSyntax(), targetName);
@@ -600,7 +600,7 @@ namespace Game.Chat
if (!int.TryParse(daysStr, out keepDays) || keepDays < 0)
return false;
}
// config option value 0 -> disabled and can't be used
// config option value 0 . disabled and can't be used
else if (keepDays <= 0)
return false;
@@ -777,7 +777,7 @@ namespace Game.Chat
{
player.GiveLevel((uint)newLevel);
player.InitTalentForLevel();
player.SetUInt32Value(ActivePlayerFields.Xp, 0);
player.SetXP(0);
if (handler.needReportToTarget(player))
{
+2 -2
View File
@@ -245,9 +245,9 @@ namespace Game.Chat.Commands
for (ushort i = 0; i < PlayerConst.ExploredZonesSize; ++i)
{
if (flag != 0)
handler.GetSession().GetPlayer().SetFlag(ActivePlayerFields.ExploredZones + i, 0xFFFFFFFF);
handler.GetSession().GetPlayer().AddExploredZones(i, 0xFFFFFFFFFFFFFFFF);
else
handler.GetSession().GetPlayer().SetFlag(ActivePlayerFields.ExploredZones + i, 0);
handler.GetSession().GetPlayer().RemoveExploredZones(i, 0xFFFFFFFFFFFFFFFF);
}
return true;
-237
View File
@@ -435,78 +435,6 @@ namespace Game.Chat
return true;
}
[Command("getitemvalue", RBACPermissions.CommandDebugGetitemvalue)]
static bool HandleDebugGetItemValueCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
if (!ulong.TryParse(args.NextString(), out ulong guid))
return false;
if (!uint.TryParse(args.NextString(), out uint index))
return false;
Item item = handler.GetSession().GetPlayer().GetItemByGuid(ObjectGuid.Create(HighGuid.Item, guid));
if (!item)
return false;
if (index >= item.valuesCount)
return false;
uint value = item.GetUInt32Value(index);
handler.SendSysMessage("Item {0}: value at {1} is {2}", guid, index, value);
return true;
}
[Command("getvalue", RBACPermissions.CommandDebugGetvalue)]
static bool HandleDebugGetValueCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
string fieldStr = args.NextString();
string valueStr = args.NextString();
if (string.IsNullOrEmpty(fieldStr))
return false;
Unit target = handler.getSelectedUnit();
if (!target)
{
handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
return false;
}
if (!uint.TryParse(fieldStr, out uint field))
return false;
ObjectGuid guid = target.GetGUID();
if (field >= target.valuesCount)
{
handler.SendSysMessage(CypherStrings.TooBigIndex, field, guid.ToString(), target.valuesCount);
return false;
}
if (!bool.TryParse(valueStr, out bool isInt32))
isInt32 = true;
if (isInt32)
{
uint value = target.GetUInt32Value(field);
handler.SendSysMessage(CypherStrings.GetUintField, guid.ToString(), field, value);
}
else
{
float value = target.GetFloatValue(field);
handler.SendSysMessage(CypherStrings.GetFloatField, guid.ToString(), field, value);
}
return true;
}
[Command("hostil", RBACPermissions.CommandDebugHostil)]
static bool HandleDebugHostileRefListCommand(StringArguments args, CommandHandler handler)
{
@@ -570,31 +498,6 @@ namespace Game.Chat
return true;
}
[Command("Mod32Value", RBACPermissions.CommandDebugMod32value)]
static bool HandleDebugMod32ValueCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
uint field = args.NextUInt32();
int value = args.NextInt32();
if (field >= handler.GetSession().GetPlayer().valuesCount)
{
handler.SendSysMessage(CypherStrings.TooBigIndex, field, handler.GetSession().GetPlayer().GetGUID().ToString(), handler.GetSession().GetPlayer().valuesCount);
return false;
}
uint currentValue = handler.GetSession().GetPlayer().GetUInt32Value(field);
currentValue += (uint)value;
handler.GetSession().GetPlayer().SetUInt32Value(field, currentValue);
handler.SendSysMessage(CypherStrings.Change32bitField, field, currentValue);
return true;
}
[Command("moveflags", RBACPermissions.CommandDebugMoveflags)]
static bool HandleDebugMoveflagsCommand(StringArguments args, CommandHandler handler)
{
@@ -794,103 +697,6 @@ namespace Game.Chat
return true;
}
[Command("setbit", RBACPermissions.CommandDebugSetbit)]
static bool HandleDebugSet32BitCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
WorldObject target = handler.GetSelectedObject();
if (!target)
{
handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
return false;
}
uint field = args.NextUInt32();
uint val = args.NextUInt32();
if (val > 32) //uint = 32 bits
return false;
uint value = (uint)(val != 0 ? 1 << ((int)val - 1) : 0);
target.SetUInt32Value(field, value);
handler.SendSysMessage(CypherStrings.Set32bitField, field, value);
return true;
}
[Command("setitemvalue", RBACPermissions.CommandDebugSetitemvalue)]
static bool HandleDebugSetItemValueCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
if (!ulong.TryParse(args.NextString(), out ulong guid))
return false;
if (!uint.TryParse(args.NextString(), out uint index))
return false;
if (!uint.TryParse(args.NextString(), out uint value))
return false;
Item item = handler.GetSession().GetPlayer().GetItemByGuid(ObjectGuid.Create(HighGuid.Item, guid));
if (!item)
return false;
if (index >= item.valuesCount)
return false;
item.SetUInt32Value(index, value);
return true;
}
[Command("setvalue", RBACPermissions.CommandDebugSetvalue)]
static bool HandleDebugSetValueCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
WorldObject target = handler.GetSelectedObject();
if (!target)
{
handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
return false;
}
ObjectGuid guid = target.GetGUID();
uint field = args.NextUInt32();
if (field >= target.valuesCount)
{
handler.SendSysMessage(CypherStrings.TooBigIndex, field, guid.ToString(), target.valuesCount);
return false;
}
string valueStr = args.NextString();
if (!bool.TryParse(args.NextString(), out bool isInt32))
isInt32 = true;
if (isInt32)
{
if (!uint.TryParse(valueStr, out uint value))
return false;
target.SetUInt32Value(field, value);
handler.SendSysMessage(CypherStrings.SetUintField, guid.ToString(), field, value);
}
else
{
if (!float.TryParse(valueStr, out float value))
return false;
target.SetFloatValue(field, value);
handler.SendSysMessage(CypherStrings.SetFloatField, guid.ToString(), field, value);
}
return true;
}
[Command("setvid", RBACPermissions.CommandDebugSetvid)]
static bool HandleDebugSetVehicleIdCommand(StringArguments args, CommandHandler handler)
{
@@ -992,49 +798,6 @@ namespace Game.Chat
return true;
}
[Command("update", RBACPermissions.CommandDebugUpdate)]
static bool HandleDebugUpdateCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
Unit unit = handler.getSelectedUnit();
if (!unit)
{
handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
return false;
}
uint updateIndex = args.NextUInt32();
//check updateIndex
if (unit.IsTypeId(TypeId.Player))
{
if (updateIndex >= (int)PlayerFields.End)
return true;
}
else if (updateIndex >= (int)UnitFields.End)
return true;
uint value;
string valueStr = args.NextString();
if (string.IsNullOrEmpty(valueStr))
{
value = unit.GetUInt32Value(updateIndex);
handler.SendSysMessage(CypherStrings.Update, unit.GetGUID().ToString(), updateIndex, value);
return true;
}
if (!uint.TryParse(valueStr, out value))
return false;
handler.SendSysMessage(CypherStrings.UpdateChange, unit.GetGUID().ToString(), updateIndex, value);
unit.SetUInt32Value(updateIndex, value);
return true;
}
[Command("uws", RBACPermissions.CommandDebugUws)]
static bool HandleDebugUpdateWorldStateCommand(StringArguments args, CommandHandler handler)
{
@@ -625,19 +625,34 @@ namespace Game.Chat
if (string.IsNullOrEmpty(state))
return false;
if (!int.TryParse(state, out int objectState))
if (!uint.TryParse(state, out uint objectState))
return false;
if (objectType < 4)
obj.SetByteValue(GameObjectFields.Bytes1, (byte)objectType, (byte)objectState);
else if (objectType == 4)
obj.SendCustomAnim((uint)objectState);
else if (objectType == 5)
switch (objectType)
{
case 0:
obj.SetGoState((GameObjectState)objectState);
break;
case 1:
obj.SetGoType((GameObjectTypes)objectState);
break;
case 2:
obj.SetGoArtKit((byte)objectState);
break;
case 3:
obj.SetGoAnimProgress(objectState);
break;
case 4:
obj.SendCustomAnim(objectState);
break;
case 5:
if (objectState < 0 || objectState > (uint)GameObjectDestructibleState.Rebuilding)
return false;
obj.SetDestructibleState((GameObjectDestructibleState)objectState);
break;
default:
break;
}
handler.SendSysMessage("Set gobject type {0} state {1}", objectType, objectState);
+1 -1
View File
@@ -103,7 +103,7 @@ namespace Game.Chat
if (!handler.extractPlayerTarget(args, out target, out targetGuid))
return false;
uint guildId = target != null ? target.GetGuildId() : Player.GetGuildIdFromDB(targetGuid);
ulong guildId = target != null ? target.GetGuildId() : Player.GetGuildIdFromDB(targetGuid);
if (guildId == 0)
return false;
+1 -1
View File
@@ -834,7 +834,7 @@ namespace Game.Chat
string knownStr = target && target.HasTitle(titleInfo) ? handler.GetCypherString(CypherStrings.Known) : "";
string activeStr = target && target.GetUInt32Value(PlayerFields.ChosenTitle) == titleInfo.MaskID
string activeStr = target && target.m_playerData.PlayerTitle == titleInfo.MaskID
? handler.GetCypherString(CypherStrings.Active) : "";
string titleNameStr = string.Format(name.ConvertFormatSyntax(), targetName);
+13 -15
View File
@@ -345,7 +345,7 @@ namespace Game.Chat
return false;
}
Item item = playerTarget.StoreNewItem(dest, itemId, true, ItemEnchantment.GenerateItemRandomPropertyId(itemId), null, 0, bonusListIDs);
Item item = playerTarget.StoreNewItem(dest, itemId, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(itemId), null, 0, bonusListIDs);
// remove binding (let GM give it to another player later)
if (player == playerTarget)
@@ -420,7 +420,7 @@ namespace Game.Chat
InventoryResult msg = playerTarget.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, template.Value.GetId(), 1);
if (msg == InventoryResult.Ok)
{
Item item = playerTarget.StoreNewItem(dest, template.Value.GetId(), true, ItemRandomEnchantmentId.Empty, null, 0, bonusListIDs);
Item item = playerTarget.StoreNewItem(dest, template.Value.GetId(), true, 0, null, 0, bonusListIDs);
// remove binding (let GM give it to another player later)
if (player == playerTarget)
@@ -451,7 +451,7 @@ namespace Game.Chat
{
if (args.Empty())
{
if (handler.GetSession().GetPlayer().HasFlag(PlayerFields.Flags, PlayerFlags.Developer))
if (handler.GetSession().GetPlayer().HasPlayerFlag(PlayerFlags.Developer))
handler.GetSession().SendNotification(CypherStrings.DevOn);
else
handler.GetSession().SendNotification(CypherStrings.DevOff);
@@ -462,14 +462,14 @@ namespace Game.Chat
if (argstr == "on")
{
handler.GetSession().GetPlayer().SetFlag(PlayerFields.Flags, PlayerFlags.Developer);
handler.GetSession().GetPlayer().HasPlayerFlag(PlayerFlags.Developer);
handler.GetSession().SendNotification(CypherStrings.DevOn);
return true;
}
if (argstr == "off")
{
handler.GetSession().GetPlayer().RemoveFlag(PlayerFields.Flags, PlayerFlags.Developer);
handler.GetSession().GetPlayer().RemovePlayerFlag(PlayerFlags.Developer);
handler.GetSession().SendNotification(CypherStrings.DevOff);
return true;
}
@@ -1181,16 +1181,15 @@ namespace Game.Chat
return false;
}
int offset = area.AreaBit / 32;
uint offset = (uint)area.AreaBit / 64;
if (offset >= PlayerConst.ExploredZonesSize)
{
handler.SendSysMessage(CypherStrings.BadValue);
return false;
}
uint val = (1u << (area.AreaBit % 32));
uint currFields = playerTarget.GetUInt32Value(ActivePlayerFields.ExploredZones + offset);
playerTarget.SetUInt32Value(ActivePlayerFields.ExploredZones + offset, (currFields | val));
ulong val = 1ul << (area.AreaBit % 64);
playerTarget.AddExploredZones(offset, val);
handler.SendSysMessage(CypherStrings.ExploreArea);
return true;
@@ -1222,16 +1221,15 @@ namespace Game.Chat
return false;
}
int offset = area.AreaBit / 32;
uint offset = (uint)area.AreaBit / 64;
if (offset >= PlayerConst.ExploredZonesSize)
{
handler.SendSysMessage(CypherStrings.BadValue);
return false;
}
uint val = (1u << (area.AreaBit % 32));
uint currFields = playerTarget.GetUInt32Value(ActivePlayerFields.ExploredZones + offset);
playerTarget.SetUInt32Value(ActivePlayerFields.ExploredZones + offset, (currFields ^ val));
uint val = (1u << (area.AreaBit % 64));
playerTarget.RemoveExploredZones(offset, val);
handler.SendSysMessage(CypherStrings.UnexploreArea);
return true;
@@ -1404,7 +1402,7 @@ namespace Game.Chat
mapId = target.GetMapId();
areaId = target.GetAreaId();
alive = target.IsAlive() ? handler.GetCypherString(CypherStrings.Yes) : handler.GetCypherString(CypherStrings.No);
gender = (Gender)target.GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender);
gender = (Gender)(byte)target.m_playerData.NativeSex;
}
// get additional information from DB
else
@@ -1996,7 +1994,7 @@ namespace Game.Chat
}
go.ModifyHealth(-damage, player);
handler.SendSysMessage(CypherStrings.GameobjectDamaged, go.GetName(), guidLow, -damage, go.m_goValue.Building.Health);
handler.SendSysMessage(CypherStrings.GameobjectDamaged, go.GetName(), guidLow, -damage, go.GetGoValue().Building.Health);
}
return true;
+15 -59
View File
@@ -122,22 +122,22 @@ namespace Game.Chat
if (!uint.TryParse(pfactionid, out uint factionid))
{
uint _factionid = target.getFaction();
uint _flag = target.GetUInt32Value(UnitFields.Flags);
ulong _npcflag = target.GetUInt64Value(UnitFields.NpcFlags);
uint _dyflag = target.GetUInt32Value(ObjectFields.DynamicFlags);
uint _factionid = target.GetFaction();
uint _flag = target.m_unitData.Flags;
ulong _npcflag = (ulong)target.m_unitData.NpcFlags[0] << 32 | target.m_unitData.NpcFlags[1];
uint _dyflag = target.m_objectData.DynamicFlags;
handler.SendSysMessage(CypherStrings.CurrentFaction, target.GetGUID().ToString(), _factionid, _flag, _npcflag, _dyflag);
return true;
}
if (!uint.TryParse(args.NextString(), out uint flag))
flag = target.GetUInt32Value(UnitFields.Flags);
flag = target.m_unitData.Flags;
if (!ulong.TryParse(args.NextString(), out ulong npcflag))
npcflag = target.GetUInt64Value(UnitFields.NpcFlags);
npcflag = (ulong)target.m_unitData.NpcFlags[0] << 32 | target.m_unitData.NpcFlags[1];
if (!uint.TryParse(args.NextString(), out uint dyflag))
dyflag = target.GetUInt32Value(ObjectFields.DynamicFlags);
dyflag = target.m_objectData.DynamicFlags;
if (!CliDB.FactionTemplateStorage.ContainsKey(factionid))
{
@@ -148,9 +148,10 @@ namespace Game.Chat
handler.SendSysMessage(CypherStrings.YouChangeFaction, target.GetGUID().ToString(), factionid, flag, npcflag, dyflag);
target.SetFaction(factionid);
target.SetUInt32Value(UnitFields.Flags, flag);
target.SetUInt64Value(UnitFields.NpcFlags, npcflag);
target.SetUInt32Value(ObjectFields.DynamicFlags, dyflag);
target.SetUnitFlags((UnitFlags)flag);
target.SetNpcFlags((NPCFlags)(npcflag & 0xFFFFFFFF));
target.SetNpcFlags2((NPCFlags2)(npcflag >> 32));
target.SetDynamicFlags((UnitDynFlags)dyflag);
return true;
}
@@ -217,7 +218,7 @@ namespace Game.Chat
NotifyModification(handler, target, CypherStrings.YouChangeSize, CypherStrings.YoursSizeChanged, Scale);
Creature creatureTarget = target.ToCreature();
if (creatureTarget)
creatureTarget.SetFloatValue(UnitFields.DisplayScale, Scale);
creatureTarget.SetDisplayId(creatureTarget.GetDisplayId(), Scale);
else
target.SetObjectScale(Scale);
return true;
@@ -322,51 +323,6 @@ namespace Game.Chat
return true;
}
[Command("bit", RBACPermissions.CommandModifyBit)]
static bool HandleModifyBitCommand(StringArguments args, CommandHandler handler)
{
if (args.Empty())
return false;
Unit target = handler.getSelectedUnit();
if (!target)
{
handler.SendSysMessage(CypherStrings.NoCharSelected);
return false;
}
// check online security
if (target.IsTypeId(TypeId.Player) && handler.HasLowerSecurity(target.ToPlayer(), ObjectGuid.Empty))
return false;
ushort field = args.NextUInt16();
int bit = args.NextInt32();
if (field < (int)ObjectFields.End || field >= target.valuesCount)
{
handler.SendSysMessage(CypherStrings.BadValue);
return false;
}
if (bit < 1 || bit > 32)
{
handler.SendSysMessage(CypherStrings.BadValue);
return false;
}
if (target.HasFlag(field, (1 << (bit - 1))))
{
target.RemoveFlag(field, (1 << (bit - 1)));
handler.SendSysMessage(CypherStrings.RemoveBit, bit, field);
}
else
{
target.SetFlag(field, (1 << (bit - 1)));
handler.SendSysMessage(CypherStrings.SetBit, bit, field);
}
return true;
}
[Command("honor", RBACPermissions.CommandModifyHonor)]
static bool HandleModifyHonorCommand(StringArguments args, CommandHandler handler)
{
@@ -591,7 +547,7 @@ namespace Game.Chat
return false;
uint anim_id = args.NextUInt32();
handler.GetSession().GetPlayer().SetUInt32Value(UnitFields.NpcEmotestate, anim_id);
handler.GetSession().GetPlayer().SetEmoteState((Emote)anim_id);
return true;
}
@@ -637,8 +593,8 @@ namespace Game.Chat
}
// Set gender
target.SetByteValue(UnitFields.Bytes0, 3, (byte)gender);
target.SetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender, (byte)gender);
target.SetGender(gender);
target.SetNativeSex(gender);
// Change display ID
target.InitDisplayIds();
+17 -16
View File
@@ -44,8 +44,8 @@ namespace Game.Chat
CreatureTemplate cInfo = target.GetCreatureTemplate();
uint faction = target.getFaction();
ulong npcflags = target.GetUInt64Value(UnitFields.NpcFlags);
uint faction = target.GetFaction();
ulong npcflags = (ulong)target.m_unitData.NpcFlags[0] << 32 | target.m_unitData.NpcFlags[1];
uint mechanicImmuneMask = cInfo.MechanicImmuneMask;
uint displayid = target.GetDisplayId();
uint nativeid = target.GetNativeDisplayId();
@@ -63,22 +63,22 @@ namespace Game.Chat
handler.SendSysMessage(CypherStrings.NpcinfoHealth, target.GetCreateHealth(), target.GetMaxHealth(), target.GetHealth());
handler.SendSysMessage(CypherStrings.NpcinfoInhabitType, cInfo.InhabitType);
handler.SendSysMessage(CypherStrings.NpcinfoUnitFieldFlags, target.GetUInt32Value(UnitFields.Flags));
foreach (uint value in Enum.GetValues(typeof(UnitFlags)))
if (target.GetUInt32Value(UnitFields.Flags).HasAnyFlag(value))
handler.SendSysMessage(CypherStrings.NpcinfoUnitFieldFlags, target.m_unitData.Flags);
foreach (UnitFlags value in Enum.GetValues(typeof(UnitFlags)))
if (target.HasUnitFlag(value))
handler.SendSysMessage("{0} (0x{1:X})", (UnitFlags)value, value);
handler.SendSysMessage(CypherStrings.NpcinfoUnitFieldFlags2, target.GetUInt32Value(UnitFields.Flags2));
foreach (uint value in Enum.GetValues(typeof(UnitFlags2)))
if (target.GetUInt32Value(UnitFields.Flags2).HasAnyFlag(value))
handler.SendSysMessage(CypherStrings.NpcinfoUnitFieldFlags2, target.m_unitData.Flags2);
foreach (UnitFlags2 value in Enum.GetValues(typeof(UnitFlags2)))
if (target.HasUnitFlag2(value))
handler.SendSysMessage("{0} (0x{1:X})", (UnitFlags2)value, value);
handler.SendSysMessage(CypherStrings.NpcinfoUnitFieldFlags3, target.GetUInt32Value(UnitFields.Flags3));
foreach (uint value in Enum.GetValues(typeof(UnitFlags3)))
if (target.GetUInt32Value(UnitFields.Flags3).HasAnyFlag(value))
handler.SendSysMessage(CypherStrings.NpcinfoUnitFieldFlags3, target.m_unitData.Flags3);
foreach (UnitFlags3 value in Enum.GetValues(typeof(UnitFlags3)))
if (target.HasUnitFlag3(value))
handler.SendSysMessage("{0} (0x{1:X})", (UnitFlags3)value, value);
handler.SendSysMessage(CypherStrings.NpcinfoDynamicFlags, target.GetUInt32Value(ObjectFields.DynamicFlags));
handler.SendSysMessage(CypherStrings.NpcinfoDynamicFlags, target.GetDynamicFlags());
handler.SendSysMessage(CypherStrings.CommandRawpawntimes, defRespawnDelayStr, curRespawnDelayStr);
handler.SendSysMessage(CypherStrings.NpcinfoLoot, cInfo.LootId, cInfo.PickPocketId, cInfo.SkinLootId);
handler.SendSysMessage(CypherStrings.NpcinfoDungeonId, target.GetInstanceId());
@@ -243,7 +243,7 @@ namespace Game.Chat
return false;
}
target.SetUInt32Value(UnitFields.NpcEmotestate, emote);
target.SetEmoteState((Emote)emote);
return true;
}
@@ -402,13 +402,13 @@ namespace Game.Chat
uint level = (creatureTarget.getLevel() < (player.getLevel() - 5)) ? (player.getLevel() - 5) : creatureTarget.getLevel();
// prepare visual effect for levelup
pet.SetUInt32Value(UnitFields.Level, level - 1);
pet.SetLevel(level - 1);
// add to world
pet.GetMap().AddToMap(pet.ToCreature());
// visual effect for levelup
pet.SetUInt32Value(UnitFields.Level, level);
pet.SetLevel(level);
// caster have pet now
player.SetMinion(pet, true);
@@ -685,7 +685,8 @@ namespace Game.Chat
return false;
}
creature.SetUInt64Value(UnitFields.NpcFlags, npcFlags);
creature.SetNpcFlags((NPCFlags)(npcFlags & 0xFFFFFFFF));
creature.SetNpcFlags2((NPCFlags2)(npcFlags >> 32));
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_NPCFLAG);
stmt.AddValue(0, npcFlags);
+4 -4
View File
@@ -63,8 +63,8 @@ namespace Game.Chat
creatureTarget.RemoveCorpse();
creatureTarget.SetHealth(0); // just for nice GM-mode view
pet.SetGuidValue(UnitFields.CreatedBy, player.GetGUID());
pet.SetUInt32Value(UnitFields.FactionTemplate, player.getFaction());
pet.SetCreatorGUID(player.GetGUID());
pet.SetFaction(player.GetFaction());
if (!pet.InitStatsForLevel(creatureTarget.getLevel()))
{
@@ -74,7 +74,7 @@ namespace Game.Chat
}
// prepare visual effect for levelup
pet.SetUInt32Value(UnitFields.Level, creatureTarget.getLevel() - 1);
pet.SetLevel(creatureTarget.getLevel() - 1);
pet.GetCharmInfo().SetPetNumber(Global.ObjectMgr.GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
@@ -84,7 +84,7 @@ namespace Game.Chat
pet.GetMap().AddToMap(pet.ToCreature());
// visual effect for levelup
pet.SetUInt32Value(UnitFields.Level, creatureTarget.getLevel());
pet.SetLevel(creatureTarget.getLevel());
player.SetMinion(pet, true);
pet.SavePetToDB(PetSaveMode.AsCurrent);
+6 -6
View File
@@ -395,12 +395,12 @@ namespace Game.Chat
return true;
}
[Command("item_enchantment_template", RBACPermissions.CommandReloadItemEnchantmentTemplate, true)]
static bool HandleReloadItemEnchantementsCommand(StringArguments args, CommandHandler handler)
[Command("item_random_bonus_list_template", RBACPermissions.CommandReloadItemRandomBonusListTemplate, true)]
static bool HandleReloadItemRandomBonusListTemplatesCommand(StringArguments args, CommandHandler handler)
{
Log.outInfo(LogFilter.Server, "Re-Loading Item Random Enchantments Table...");
ItemEnchantment.LoadRandomEnchantmentsTable();
handler.SendGlobalGMSysMessage("DB table `item_enchantment_template` reloaded.");
Log.outInfo(LogFilter.Server, "Re-Loading Random item bonus list definitions...");
ItemEnchantmentManager.LoadItemRandomBonusListTemplates();
handler.SendGlobalGMSysMessage("DB table `item_random_bonus_list_template` reloaded.");
return true;
}
@@ -1015,7 +1015,7 @@ namespace Game.Chat
static bool HandleReloadAllItemCommand(StringArguments args, CommandHandler handler)
{
HandleReloadPageTextsCommand(null, handler);
HandleReloadItemEnchantementsCommand(null, handler);
HandleReloadItemRandomBonusListTemplatesCommand(null, handler);
return true;
}
+6 -7
View File
@@ -51,8 +51,7 @@ namespace Game.Chat
if (!handler.extractPlayerTarget(args, out target))
return false;
target.SetUInt32Value(ActivePlayerFields.Kills, 0);
target.SetUInt32Value(ActivePlayerFields.LifetimeHonorableKills, 0);
target.ResetHonorStats();
target.UpdateCriteria(CriteriaTypes.EarnHonorableKill);
return true;
@@ -74,18 +73,18 @@ namespace Game.Chat
player.SetShapeshiftForm(ShapeShiftForm.None);
player.setFactionForRace(player.GetRace());
player.SetUInt32Value(UnitFields.DisplayPower, (uint)powerType);
player.SetPowerType(powerType);
// reset only if player not in some form;
if (player.GetShapeshiftForm() == ShapeShiftForm.None)
player.InitDisplayIds();
player.SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, (byte)UnitBytes2Flags.PvP);
player.SetPvpFlags(UnitPVPStateFlags.PvP);
player.SetUInt32Value(UnitFields.Flags, (uint)UnitFlags.PvpAttackable);
player.SetUnitFlags(UnitFlags.PvpAttackable);
//-1 is default value
player.SetUInt32Value(ActivePlayerFields.WatchedFactionIndex, 0xFFFFFFFF);
player.SetWatchedFactionIndex(0xFFFFFFFF);
return true;
}
@@ -110,7 +109,7 @@ namespace Game.Chat
target.InitStatsForLevel(true);
target.InitTaxiNodesForLevel();
target.InitTalentForLevel();
target.SetUInt32Value(ActivePlayerFields.Xp, 0);
target.SetXP(0);
target._ApplyAllLevelScaleItemMods(true);
+6 -6
View File
@@ -62,7 +62,7 @@ namespace Game.Chat.Commands
string tNameLink = handler.GetNameLink(target);
target.SetTitle(titleInfo); // to be sure that title now known
target.SetUInt32Value(PlayerFields.ChosenTitle, titleInfo.MaskID);
target.SetChosenTitle(titleInfo.MaskID);
handler.SendSysMessage(CypherStrings.TitleCurrentRes, id, (target.GetGender() == Gender.Male ? titleInfo.Name : titleInfo.Name1)[handler.GetSessionDbcLocale()], tNameLink);
return true;
@@ -150,9 +150,9 @@ namespace Game.Chat.Commands
handler.SendSysMessage(CypherStrings.TitleRemoveRes, id, titleNameStr, tNameLink);
if (!target.HasTitle(target.GetUInt32Value(PlayerFields.ChosenTitle)))
if (!target.HasTitle(target.m_playerData.PlayerTitle))
{
target.SetUInt32Value(PlayerFields.ChosenTitle, 0);
target.SetChosenTitle(0);
handler.SendSysMessage(CypherStrings.CurrentTitleReset, tNameLink);
}
@@ -189,12 +189,12 @@ namespace Game.Chat.Commands
titles &= ~titles2; // remove not existed titles
target.SetUInt64Value(ActivePlayerFields.KnownTitles, titles);
target.SetKnownTitles(0, titles);
handler.SendSysMessage(CypherStrings.Done);
if (!target.HasTitle(target.GetUInt32Value(PlayerFields.ChosenTitle)))
if (!target.HasTitle(target.m_playerData.PlayerTitle))
{
target.SetUInt32Value(PlayerFields.ChosenTitle, 0);
target.SetChosenTitle(0);
handler.SendSysMessage(CypherStrings.CurrentTitleReset, handler.GetNameLink(target));
}
+10 -10
View File
@@ -1689,7 +1689,7 @@ namespace Game
if (condition.Gender >= 0 && (int)player.GetGender() != condition.Gender)
return false;
if (condition.NativeGender >= 0 && player.GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender) != condition.NativeGender)
if (condition.NativeGender >= 0 && player.m_playerData.NativeSex != condition.NativeGender)
return false;
if (condition.PowerType != -1 && condition.PowerTypeComp != 0)
@@ -1701,7 +1701,7 @@ namespace Game
if (condition.ChrSpecializationIndex >= 0 || condition.ChrSpecializationRole >= 0)
{
ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(player.GetUInt32Value(PlayerFields.CurrentSpecId));
ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(player.GetPrimarySpecialization());
if (spec != null)
{
if (condition.ChrSpecializationIndex >= 0 && spec.OrderIndex != condition.ChrSpecializationIndex)
@@ -1785,10 +1785,10 @@ namespace Game
}
}
if (condition.PvpMedal != 0 && !Convert.ToBoolean((1 << (condition.PvpMedal - 1)) & player.GetUInt32Value(ActivePlayerFields.PvpMedals)))
if (condition.PvpMedal != 0 && !Convert.ToBoolean((1 << (condition.PvpMedal - 1)) & player.m_activePlayerData.PvpMedals))
return false;
if (condition.LifetimeMaxPVPRank != 0 && player.GetByteValue(ActivePlayerFields.Bytes, PlayerFieldOffsets.FieldBytesOffsetLifetimeMaxPvpRank) != condition.LifetimeMaxPVPRank)
if (condition.LifetimeMaxPVPRank != 0 && player.m_activePlayerData.LifetimeMaxRank != condition.LifetimeMaxPVPRank)
return false;
if (condition.MovementFlags[0] != 0 && !Convert.ToBoolean((uint)player.GetUnitMovementFlags() & condition.MovementFlags[0]))
@@ -1841,7 +1841,7 @@ namespace Game
{
uint questBit = Global.DB2Mgr.GetQuestUniqueBitFlag(condition.PrevQuestID[i]);
if (questBit != 0)
results[i] = (player.GetUInt32Value(ActivePlayerFields.QuestCompleted + (int)((questBit - 1) >> 5)) & (1 << (int)((questBit - 1) & 31))) != 0;
results[i] = (player.m_activePlayerData.QuestCompleted[((int)questBit - 1) >> 6] & (1ul << (((int)questBit - 1) & 63))) != 0;
}
if (!PlayerConditionLogic(condition.PrevQuestLogic, results))
@@ -1920,7 +1920,7 @@ namespace Game
{
AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(condition.Explored[i]);
if (area != null)
if (area.AreaBit != -1 && !Convert.ToBoolean(player.GetUInt32Value(ActivePlayerFields.ExploredZones + area.AreaBit / 32) & (1 << (area.AreaBit % 32))))
if (area.AreaBit != -1 && !Convert.ToBoolean(player.m_activePlayerData.ExploredZones[area.AreaBit / 64] & (1ul << ((int)area.AreaBit % 64))))
return false;
}
}
@@ -2014,16 +2014,16 @@ namespace Game
}
}
if (condition.MinAvgItemLevel != 0 && Math.Floor(player.GetFloatValue(PlayerFields.AvgItemLevel)) < condition.MinAvgItemLevel)
if (condition.MinAvgItemLevel != 0 && Math.Floor(player.m_playerData.AvgItemLevel[0]) < condition.MinAvgItemLevel)
return false;
if (condition.MaxAvgItemLevel != 0 && Math.Floor(player.GetFloatValue(PlayerFields.AvgItemLevel)) > condition.MaxAvgItemLevel)
if (condition.MaxAvgItemLevel != 0 && Math.Floor(player.m_playerData.AvgItemLevel[0]) > condition.MaxAvgItemLevel)
return false;
if (condition.MinAvgEquippedItemLevel != 0 && Math.Floor(player.GetFloatValue(PlayerFields.AvgItemLevel + 1)) < condition.MinAvgEquippedItemLevel)
if (condition.MinAvgEquippedItemLevel != 0 && Math.Floor(player.m_playerData.AvgItemLevel[1]) < condition.MinAvgEquippedItemLevel)
return false;
if (condition.MaxAvgEquippedItemLevel != 0 && Math.Floor(player.GetFloatValue(PlayerFields.AvgItemLevel + 1)) > condition.MaxAvgEquippedItemLevel)
if (condition.MaxAvgEquippedItemLevel != 0 && Math.Floor(player.m_playerData.AvgItemLevel[1]) > condition.MaxAvgEquippedItemLevel)
return false;
if (condition.ModifierTreeID != 0 && !player.ModifierTreeSatisfied(condition.ModifierTreeID))
+11 -11
View File
@@ -76,6 +76,7 @@ namespace Game.DataStorage
CinematicCameraStorage = DBReader.Read<CinematicCameraRecord>("CinematicCamera.db2", HotfixStatements.SEL_CINEMATIC_CAMERA);
CinematicSequencesStorage = DBReader.Read<CinematicSequencesRecord>("CinematicSequences.db2", HotfixStatements.SEL_CINEMATIC_SEQUENCES);
ContentTuningStorage = DBReader.Read<ContentTuningRecord>("ContentTuning.db2", HotfixStatements.SEL_CONTENT_TUNING);
ContentTuningXExpectedStorage = DBReader.Read<ContentTuningXExpectedRecord>("ContentTuningXExpected.db2", HotfixStatements.SEL_CONTENT_TUNING_X_EXPECTED);
ConversationLineStorage = DBReader.Read<ConversationLineRecord>("ConversationLine.db2", HotfixStatements.SEL_CONVERSATION_LINE);
CreatureDisplayInfoStorage = DBReader.Read<CreatureDisplayInfoRecord>("CreatureDisplayInfo.db2", HotfixStatements.SEL_CREATURE_DISPLAY_INFO);
CreatureDisplayInfoExtraStorage = DBReader.Read<CreatureDisplayInfoExtraRecord>("CreatureDisplayInfoExtra.db2", HotfixStatements.SEL_CREATURE_DISPLAY_INFO_EXTRA);
@@ -153,8 +154,6 @@ namespace Game.DataStorage
ItemLimitCategoryConditionStorage = DBReader.Read<ItemLimitCategoryConditionRecord>("ItemLimitCategoryCondition.db2", HotfixStatements.SEL_ITEM_LIMIT_CATEGORY_CONDITION);
ItemModifiedAppearanceStorage = DBReader.Read<ItemModifiedAppearanceRecord>("ItemModifiedAppearance.db2", HotfixStatements.SEL_ITEM_MODIFIED_APPEARANCE);
ItemPriceBaseStorage = DBReader.Read<ItemPriceBaseRecord>("ItemPriceBase.db2", HotfixStatements.SEL_ITEM_PRICE_BASE);
ItemRandomPropertiesStorage = DBReader.Read<ItemRandomPropertiesRecord>("ItemRandomProperties.db2", HotfixStatements.SEL_ITEM_RANDOM_PROPERTIES, HotfixStatements.SEL_ITEM_RANDOM_PROPERTIES_LOCALE);
ItemRandomSuffixStorage = DBReader.Read<ItemRandomSuffixRecord>("ItemRandomSuffix.db2", HotfixStatements.SEL_ITEM_RANDOM_SUFFIX, HotfixStatements.SEL_ITEM_RANDOM_SUFFIX_LOCALE);
ItemSearchNameStorage = DBReader.Read<ItemSearchNameRecord>("ItemSearchName.db2", HotfixStatements.SEL_ITEM_SEARCH_NAME, HotfixStatements.SEL_ITEM_SEARCH_NAME_LOCALE);
ItemSetStorage = DBReader.Read<ItemSetRecord>("ItemSet.db2", HotfixStatements.SEL_ITEM_SET, HotfixStatements.SEL_ITEM_SET_LOCALE);
ItemSetSpellStorage = DBReader.Read<ItemSetSpellRecord>("ItemSetSpell.db2", HotfixStatements.SEL_ITEM_SET_SPELL);
@@ -324,13 +323,13 @@ namespace Game.DataStorage
}
// Check loaded DB2 files proper version
if (!AreaTableStorage.ContainsKey(10048) || // last area added in 8.0.1 (28153)
!CharTitlesStorage.ContainsKey(633) || // last char title added in 8.0.1 (28153)
!GemPropertiesStorage.ContainsKey(3745) || // last gem property added in 8.0.1 (28153)
!ItemStorage.ContainsKey(164760) || // last item added in 8.0.1 (28153)
!ItemExtendedCostStorage.ContainsKey(6448) || // last item extended cost added in 8.0.1 (28153)
!MapStorage.ContainsKey(2103) || // last map added in 8.0.1 (28153)
!SpellNameStorage.ContainsKey(281872)) // last spell added in 8.0.1 (28153)
if (!AreaTableStorage.ContainsKey(10521) || // last area added in 8.0.1 (28153)
!CharTitlesStorage.ContainsKey(649) || // last char title added in 8.0.1 (28153)
!GemPropertiesStorage.ContainsKey(3746) || // last gem property added in 8.0.1 (28153)
!ItemStorage.ContainsKey(168279) || // last item added in 8.0.1 (28153)
!ItemExtendedCostStorage.ContainsKey(6545) || // last item extended cost added in 8.0.1 (28153)
!MapStorage.ContainsKey(2178) || // last map added in 8.0.1 (28153)
!SpellNameStorage.ContainsKey(296952)) // last spell added in 8.0.1 (28153)
{
Log.outError(LogFilter.Misc, "You have _outdated_ DB2 files. Please extract correct versions from current using client.");
Global.WorldMgr.ShutdownServ(10, ShutdownMask.Force, ShutdownExitCode.Error);
@@ -420,6 +419,7 @@ namespace Game.DataStorage
public static DB6Storage<CinematicCameraRecord> CinematicCameraStorage;
public static DB6Storage<CinematicSequencesRecord> CinematicSequencesStorage;
public static DB6Storage<ContentTuningRecord> ContentTuningStorage;
public static DB6Storage<ContentTuningXExpectedRecord> ContentTuningXExpectedStorage;
public static DB6Storage<ConversationLineRecord> ConversationLineStorage;
public static DB6Storage<CreatureDisplayInfoRecord> CreatureDisplayInfoStorage;
public static DB6Storage<CreatureDisplayInfoExtraRecord> CreatureDisplayInfoExtraStorage;
@@ -497,8 +497,6 @@ namespace Game.DataStorage
public static DB6Storage<ItemLimitCategoryConditionRecord> ItemLimitCategoryConditionStorage;
public static DB6Storage<ItemModifiedAppearanceRecord> ItemModifiedAppearanceStorage;
public static DB6Storage<ItemPriceBaseRecord> ItemPriceBaseStorage;
public static DB6Storage<ItemRandomPropertiesRecord> ItemRandomPropertiesStorage;
public static DB6Storage<ItemRandomSuffixRecord> ItemRandomSuffixStorage;
public static DB6Storage<ItemSearchNameRecord> ItemSearchNameStorage;
public static DB6Storage<ItemSetRecord> ItemSetStorage;
public static DB6Storage<ItemSetSpellRecord> ItemSetSpellStorage;
@@ -725,6 +723,8 @@ namespace Game.DataStorage
return row.Health;
case -8:
return row.DamageReplaceStat;
case -9:
return row.DamageSecondary;
default:
break;
}
@@ -232,34 +232,34 @@ namespace Game.DataStorage
switch (Type.GetTypeCode(type))
{
case TypeCode.Boolean:
buffer.WriteUInt8(fieldInfo.GetValue(entry));
buffer.WriteUInt8((byte)((bool)fieldInfo.GetValue(entry) ? 1 : 0));
break;
case TypeCode.SByte:
buffer.WriteInt8(fieldInfo.GetValue(entry));
buffer.WriteInt8((sbyte)fieldInfo.GetValue(entry));
break;
case TypeCode.Byte:
buffer.WriteUInt8(fieldInfo.GetValue(entry));
buffer.WriteUInt8((byte)fieldInfo.GetValue(entry));
break;
case TypeCode.Int16:
buffer.WriteInt16(fieldInfo.GetValue(entry));
buffer.WriteInt16((short)fieldInfo.GetValue(entry));
break;
case TypeCode.UInt16:
buffer.WriteUInt16(fieldInfo.GetValue(entry));
buffer.WriteUInt16((ushort)fieldInfo.GetValue(entry));
break;
case TypeCode.Int32:
buffer.WriteInt32(fieldInfo.GetValue(entry));
buffer.WriteInt32((int)fieldInfo.GetValue(entry));
break;
case TypeCode.UInt32:
buffer.WriteUInt32(fieldInfo.GetValue(entry));
buffer.WriteUInt32((uint)fieldInfo.GetValue(entry));
break;
case TypeCode.Int64:
buffer.WriteInt64(fieldInfo.GetValue(entry));
buffer.WriteInt64((long)fieldInfo.GetValue(entry));
break;
case TypeCode.UInt64:
buffer.WriteUInt64(fieldInfo.GetValue(entry));
buffer.WriteUInt64((ulong)fieldInfo.GetValue(entry));
break;
case TypeCode.Single:
buffer.WriteFloat(fieldInfo.GetValue(entry));
buffer.WriteFloat((float)fieldInfo.GetValue(entry));
break;
case TypeCode.Object:
switch (type.Name)
@@ -294,34 +294,34 @@ namespace Game.DataStorage
switch (Type.GetTypeCode(type))
{
case TypeCode.Boolean:
buffer.WriteUInt8(array.GetValue(i));
buffer.WriteUInt8((byte)((bool)array.GetValue(i) ? 1 : 0));
break;
case TypeCode.SByte:
buffer.WriteInt8(array.GetValue(i));
buffer.WriteInt8((sbyte)array.GetValue(i));
break;
case TypeCode.Byte:
buffer.WriteUInt8(array.GetValue(i));
buffer.WriteUInt8((byte)array.GetValue(i));
break;
case TypeCode.Int16:
buffer.WriteInt16(array.GetValue(i));
buffer.WriteInt16((short)array.GetValue(i));
break;
case TypeCode.UInt16:
buffer.WriteUInt16(array.GetValue(i));
buffer.WriteUInt16((ushort)array.GetValue(i));
break;
case TypeCode.Int32:
buffer.WriteInt32(array.GetValue(i));
buffer.WriteInt32((int)array.GetValue(i));
break;
case TypeCode.UInt32:
buffer.WriteUInt32(array.GetValue(i));
buffer.WriteUInt32((uint)array.GetValue(i));
break;
case TypeCode.Int64:
buffer.WriteInt64(array.GetValue(i));
buffer.WriteInt64((long)array.GetValue(i));
break;
case TypeCode.UInt64:
buffer.WriteUInt64(array.GetValue(i));
buffer.WriteUInt64((ulong)array.GetValue(i));
break;
case TypeCode.Single:
buffer.WriteFloat(array.GetValue(i));
buffer.WriteFloat((float)array.GetValue(i));
break;
case TypeCode.String:
var str = (string)array.GetValue(i);
@@ -32,8 +32,8 @@ namespace Game.DataStorage
{
class DBReader
{
private const int HeaderSize = 72 + 1 * 36;
private const uint WDC2FmtSig = 0x32434457; // WDC2
private const int HeaderSize = 72;
private const uint WDC3FmtSig = 0x33434457; // WDC3
public static DB6Storage<T> Read<T>(string fileName, HotfixStatements preparedStatement, HotfixStatements preparedStatementLocale = 0) where T : new()
{
@@ -71,7 +71,7 @@ namespace Game.DataStorage
{
Header = new WDCHeader();
Header.Signature = reader.ReadUInt32();
if (Header.Signature != WDC2FmtSig)
if (Header.Signature != WDC3FmtSig)
return false;
Header.RecordCount = reader.ReadUInt32();
@@ -126,28 +126,41 @@ namespace Game.DataStorage
}
}
long previousStringTableSize = 0;
for (int sectionIndex = 0; sectionIndex < Header.SectionsCount; sectionIndex++)
{
if (sections[sectionIndex].TactKeyLookup != 0)// && !hasTactKeyFunc(sections[sectionIndex].TactKeyLookup))
{
previousStringTableSize += sections[sectionIndex].StringTableSize;
//Console.WriteLine("Detected db2 with encrypted section! HasKey {0}", CASC.HasKey(Sections[sectionIndex].TactKeyLookup));
continue;
}
reader.BaseStream.Position = sections[sectionIndex].FileOffset;
byte[] recordsData;
Dictionary<long, string> stringsTable = null;
List<Tuple<int, short>> offsetmap = null;
SparseEntry[] sparseEntries = null;
if (!Header.HasOffsetTable())
{
// records data
recordsData = reader.ReadBytes((int)(sections[sectionIndex].NumRecords * Header.RecordSize));
Array.Resize(ref recordsData, recordsData.Length + 8); // pad with extra zeros so we don't crash when reading
// string data
stringsTable = new Dictionary<long, string>();
long stringDataOffset = 0;
if (sectionIndex == 0)
stringDataOffset = (Header.RecordCount - sections[sectionIndex].NumRecords) * Header.RecordSize;
else
stringDataOffset = previousStringTableSize;
for (int i = 0; i < sections[sectionIndex].StringTableSize;)
{
long oldPos = reader.BaseStream.Position;
stringsTable[oldPos] = reader.ReadCString();
stringsTable[oldPos + stringDataOffset] = reader.ReadCString();
i += (int)(reader.BaseStream.Position - oldPos);
}
@@ -159,29 +172,23 @@ namespace Game.DataStorage
if (reader.BaseStream.Position != sections[sectionIndex].SparseTableOffset)
throw new Exception("reader.BaseStream.Position != sections[sectionIndex].SparseTableOffset");
offsetmap = new List<Tuple<int, short>>();
for (int i = 0; i < (Header.MaxId - Header.MinId + 1); i++)
{
int offset = reader.ReadInt32();
short length = reader.ReadInt16();
if (offset == 0 || length == 0)
continue;
offsetmap.Add(new Tuple<int, short>(offset, length));
}
}
Array.Resize(ref recordsData, recordsData.Length + 8); // pad with extra zeros so we don't crash when reading
// index data
int[] indexData = reader.ReadArray<int>((uint)(sections[sectionIndex].IndexDataSize / 4));
bool isIndexEmpty = Header.HasIndexTable() && indexData.Count(i => i == 0) == sections[sectionIndex].NumRecords;
// duplicate rows data
Dictionary<int, int> copyData = new Dictionary<int, int>();
for (int i = 0; i < sections[sectionIndex].CopyTableSize / 8; i++)
for (int i = 0; i < sections[sectionIndex].NumCopyRecords; i++)
copyData[reader.ReadInt32()] = reader.ReadInt32();
if (sections[sectionIndex].NumSparseRecords > 0)
sparseEntries = reader.ReadArray<SparseEntry>((uint)sections[sectionIndex].NumSparseRecords);
// reference data
ReferenceData refData = null;
@@ -208,23 +215,30 @@ namespace Game.DataStorage
};
}
if (sections[sectionIndex].NumSparseRecords > 0)
{
// TODO: use this shit
int[] sparseIndexData = reader.ReadArray<int>((uint)sections[sectionIndex].NumSparseRecords);
if (Header.HasIndexTable() && indexData.Length != sparseIndexData.Length)
throw new Exception("indexData.Length != sparseIndexData.Length");
//indexData = sparseIndexData;
}
BitReader bitReader = new BitReader(recordsData);
for (int i = 0; i < Header.RecordCount; ++i)
for (int i = 0; i < sections[sectionIndex].NumRecords; ++i)
{
bitReader.Position = 0;
if (offsetmap != null)
bitReader.Offset = offsetmap[i].Item1 - sections[sectionIndex].FileOffset;
if (Header.HasOffsetTable())
bitReader.Offset = sparseEntries[i].Offset - sections[sectionIndex].FileOffset;
else
bitReader.Offset = i * (int)Header.RecordSize;
bool hasRef = refData.Entries.TryGetValue(i, out int refId);
var rec = new WDC2Row(this, bitReader, sections[sectionIndex].FileOffset, sections[sectionIndex].IndexDataSize != 0 ? indexData[i] : -1, hasRef ? refId : -1, stringsTable);
if (sections[sectionIndex].IndexDataSize != 0)
_records.Add(indexData[i], rec);
else
var rec = new WDC3Row(this, bitReader, sections[sectionIndex].FileOffset, Header.HasIndexTable() ? (isIndexEmpty ? i : indexData[i]) : -1, hasRef ? refId : -1, stringsTable);
_records.Add(rec.Id, rec);
}
@@ -234,6 +248,8 @@ namespace Game.DataStorage
rec.Id = copyRow.Key;
_records.Add(copyRow.Key, rec);
}
previousStringTableSize += sections[sectionIndex].StringTableSize;
}
}
@@ -246,10 +262,10 @@ namespace Game.DataStorage
internal Value32[][] PalletData;
internal Dictionary<int, Value32>[] CommonData;
Dictionary<int, WDC2Row> _records = new Dictionary<int, WDC2Row>();
Dictionary<int, WDC3Row> _records = new Dictionary<int, WDC3Row>();
}
class WDC2Row
class WDC3Row
{
private BitReader _data;
private int _dataOffset;
@@ -265,7 +281,7 @@ namespace Game.DataStorage
private Dictionary<int, Value32>[] _commonData;
private Dictionary<long, string> _stringsTable;
public WDC2Row(DBReader reader, BitReader data, int recordsOffset, int id, int refId, Dictionary<long, string> stringsTable)
public WDC3Row(DBReader reader, BitReader data, int recordsOffset, int id, int refId, Dictionary<long, string> stringsTable)
{
_data = data;
_recordsOffset = recordsOffset;
@@ -553,9 +569,9 @@ namespace Game.DataStorage
return obj;
}
public WDC2Row Clone()
public WDC3Row Clone()
{
return (WDC2Row)MemberwiseClone();
return (WDC3Row)MemberwiseClone();
}
}
@@ -669,14 +685,15 @@ namespace Game.DataStorage
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct SectionHeader
{
public long TactKeyLookup;
public ulong TactKeyLookup;
public int FileOffset;
public int NumRecords;
public int StringTableSize;
public int CopyTableSize;
public int SparseTableOffset; // CatalogDataOffset, absolute value, {uint offset, ushort size}[MaxId - MinId + 1]
public int IndexDataSize; // int indexData[IndexDataSize / 4]
public int ParentLookupDataSize; // uint NumRecords, uint minId, uint maxId, {uint id, uint index}[NumRecords], questionable usefulness...
public int NumSparseRecords;
public int NumCopyRecords;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
+72 -20
View File
@@ -136,6 +136,13 @@ namespace Game.DataStorage
_defaultChrSpecializationsByClass[(uint)chrSpec.ClassID] = chrSpec;
}
foreach (ContentTuningXExpectedRecord contentTuningXExpectedStat in CliDB.ContentTuningXExpectedStorage.Values)
{
ExpectedStatModRecord expectedStatMod = CliDB.ExpectedStatModStorage.LookupByKey(contentTuningXExpectedStat.ExpectedStatModID);
if (expectedStatMod != null)
_expectedStatModsByContentTuning.Add(contentTuningXExpectedStat.ContentTuningID, expectedStatMod);
}
foreach (CurvePointRecord curvePoint in CliDB.CurvePointStorage.Values)
{
if (CliDB.CurveStorage.ContainsKey(curvePoint.CurveID))
@@ -396,6 +403,12 @@ namespace Game.DataStorage
CliDB.RulesetItemUpgradeStorage.Clear();
foreach (SkillLineRecord skill in CliDB.SkillLineStorage.Values)
{
if (skill.ParentSkillLineID != 0)
_skillLinesByParentSkillLine.Add(skill.ParentSkillLineID, skill);
}
foreach (SkillLineAbilityRecord skillLineAbility in CliDB.SkillLineAbilityStorage.Values)
_skillLineAbilitiesBySkillupSkill.Add(skillLineAbility.SkillupSkillLineID != 0 ? skillLineAbility.SkillupSkillLineID : skillLineAbility.SkillLine, skillLineAbility);
@@ -969,61 +982,93 @@ namespace Game.DataStorage
if (expectedStatRecord == null)
return 1.0f;
ExpectedStatModRecord[] mods = new ExpectedStatModRecord[3];
ContentTuningRecord contentTuning = CliDB.ContentTuningStorage.LookupByKey(contentTuningId);
if (contentTuning != null)
{
mods[0] = CliDB.ExpectedStatModStorage.LookupByKey(contentTuning.ExpectedStatModID);
mods[1] = CliDB.ExpectedStatModStorage.LookupByKey(contentTuning.DifficultyESMID);
}
ExpectedStatModRecord classMod = null;
switch (unitClass)
{
case Class.Warrior:
mods[2] = CliDB.ExpectedStatModStorage.LookupByKey(4);
classMod = CliDB.ExpectedStatModStorage.LookupByKey(4);
break;
case Class.Paladin:
mods[2] = CliDB.ExpectedStatModStorage.LookupByKey(2);
classMod = CliDB.ExpectedStatModStorage.LookupByKey(2);
break;
case Class.Rogue:
mods[2] = CliDB.ExpectedStatModStorage.LookupByKey(3);
classMod = CliDB.ExpectedStatModStorage.LookupByKey(3);
break;
case Class.Mage:
mods[2] = CliDB.ExpectedStatModStorage.LookupByKey(1);
classMod = CliDB.ExpectedStatModStorage.LookupByKey(1);
break;
default:
break;
}
List<ExpectedStatModRecord> contentTuningMods = _expectedStatModsByContentTuning.LookupByKey(contentTuningId);
float value = 0.0f;
switch (stat)
{
case ExpectedStatType.CreatureHealth:
value = mods.Sum(expectedStatMod => expectedStatRecord.CreatureHealth * (expectedStatMod != null ? expectedStatMod.CreatureHealthMod : 1.0f));
value = expectedStatRecord.CreatureHealth;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.CreatureHealthMod : 1.0f);
if (classMod != null)
value *= classMod.CreatureHealthMod;
break;
case ExpectedStatType.PlayerHealth:
value = mods.Sum(expectedStatMod => expectedStatRecord.PlayerHealth * (expectedStatMod != null ? expectedStatMod.PlayerHealthMod : 1.0f));
value = expectedStatRecord.PlayerHealth;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.PlayerHealthMod : 1.0f);
if (classMod != null)
value *= classMod.PlayerHealthMod;
break;
case ExpectedStatType.CreatureAutoAttackDps:
value = mods.Sum(expectedStatMod => expectedStatRecord.CreatureAutoAttackDps * (expectedStatMod != null ? expectedStatMod.CreatureAutoAttackDPSMod : 1.0f));
value = expectedStatRecord.CreatureAutoAttackDps;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.CreatureAutoAttackDPSMod : 1.0f);
if (classMod != null)
value *= classMod.CreatureAutoAttackDPSMod;
break;
case ExpectedStatType.CreatureArmor:
value = mods.Sum(expectedStatMod => expectedStatRecord.CreatureArmor * (expectedStatMod != null ? expectedStatMod.CreatureArmorMod : 1.0f));
value = expectedStatRecord.CreatureArmor;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.CreatureArmorMod : 1.0f);
if (classMod != null)
value *= classMod.CreatureArmorMod;
break;
case ExpectedStatType.PlayerMana:
value = mods.Sum(expectedStatMod => expectedStatRecord.PlayerMana * (expectedStatMod != null ? expectedStatMod.PlayerManaMod : 1.0f));
value = expectedStatRecord.PlayerMana;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.PlayerManaMod : 1.0f);
if (classMod != null)
value *= classMod.PlayerManaMod;
break;
case ExpectedStatType.PlayerPrimaryStat:
value = mods.Sum(expectedStatMod => expectedStatRecord.PlayerPrimaryStat * (expectedStatMod != null ? expectedStatMod.PlayerPrimaryStatMod : 1.0f));
value = expectedStatRecord.PlayerPrimaryStat;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.PlayerPrimaryStatMod : 1.0f);
if (classMod != null)
value *= classMod.PlayerPrimaryStatMod;
break;
case ExpectedStatType.PlayerSecondaryStat:
value = mods.Sum(expectedStatMod => expectedStatRecord.PlayerSecondaryStat * (expectedStatMod != null ? expectedStatMod.PlayerSecondaryStatMod : 1.0f));
value = expectedStatRecord.PlayerSecondaryStat;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.PlayerSecondaryStatMod : 1.0f);
if (classMod != null)
value *= classMod.PlayerSecondaryStatMod;
break;
case ExpectedStatType.ArmorConstant:
value = mods.Sum(expectedStatMod => expectedStatRecord.ArmorConstant * (expectedStatMod != null ? expectedStatMod.ArmorConstantMod : 1.0f));
value = expectedStatRecord.ArmorConstant;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.ArmorConstantMod : 1.0f);
if (classMod != null)
value *= classMod.ArmorConstantMod;
break;
case ExpectedStatType.None:
break;
case ExpectedStatType.CreatureSpellDamage:
value = mods.Sum(expectedStatMod => expectedStatRecord.CreatureSpellDamage * (expectedStatMod != null ? expectedStatMod.CreatureSpellDamageMod : 1.0f));
value = expectedStatRecord.CreatureSpellDamage;
if (contentTuningMods != null)
value *= contentTuningMods.Sum(expectedStatMod => expectedStatMod != null ? expectedStatMod.CreatureSpellDamageMod : 1.0f);
if (classMod != null)
value *= classMod.CreatureSpellDamageMod;
break;
default:
break;
@@ -1479,6 +1524,11 @@ namespace Game.DataStorage
return _rulesetItemUpgrade.LookupByKey(itemId);
}
public List<SkillLineRecord> GetSkillLinesForParentSkill(uint parentSkillId)
{
return _skillLinesByParentSkillLine.LookupByKey(parentSkillId);
}
public List<SkillLineAbilityRecord> GetSkillLineAbilitiesBySkill(uint skillId)
{
return _skillLineAbilitiesBySkillupSkill.LookupByKey(skillId);
@@ -1903,6 +1953,7 @@ namespace Game.DataStorage
MultiMap<uint, CurvePointRecord> _curvePoints = new MultiMap<uint, CurvePointRecord>();
Dictionary<Tuple<uint, byte, byte, byte>, EmotesTextSoundRecord> _emoteTextSounds = new Dictionary<Tuple<uint, byte, byte, byte>, EmotesTextSoundRecord>();
Dictionary<Tuple<uint, int>, ExpectedStatRecord> _expectedStatsByLevel = new Dictionary<Tuple<uint, int>, ExpectedStatRecord>();
MultiMap<uint, ExpectedStatModRecord> _expectedStatModsByContentTuning = new MultiMap<uint, ExpectedStatModRecord>();
MultiMap<uint, uint> _factionTeams = new MultiMap<uint, uint>();
Dictionary<uint, HeirloomRecord> _heirlooms = new Dictionary<uint, HeirloomRecord>();
MultiMap<uint, uint> _glyphBindableSpells = new MultiMap<uint, uint>();
@@ -1933,6 +1984,7 @@ namespace Game.DataStorage
MultiMap<uint, RewardPackXCurrencyTypeRecord> _rewardPackCurrencyTypes = new MultiMap<uint, RewardPackXCurrencyTypeRecord>();
MultiMap<uint, RewardPackXItemRecord> _rewardPackItems = new MultiMap<uint, RewardPackXItemRecord>();
Dictionary<uint, uint> _rulesetItemUpgrade = new Dictionary<uint, uint>();
MultiMap<uint, SkillLineRecord> _skillLinesByParentSkillLine = new MultiMap<uint, SkillLineRecord>();
MultiMap<uint, SkillLineAbilityRecord> _skillLineAbilitiesBySkillupSkill = new MultiMap<uint, SkillLineAbilityRecord>();
MultiMap<uint, SkillRaceClassInfoRecord> _skillRaceClassInfoBySkill = new MultiMap<uint, SkillRaceClassInfoRecord>();
MultiMap<uint, SpecializationSpellsRecord> _specializationSpellsBySpec = new MultiMap<uint, SpecializationSpellsRecord>();
+4 -2
View File
@@ -36,6 +36,7 @@ namespace Game.DataStorage
public AchievementFlags Flags;
public ushort UiOrder;
public uint IconFileID;
public int RewardItemID;
public uint CriteriaTree;
public ushort SharesCriteria;
}
@@ -43,9 +44,9 @@ namespace Game.DataStorage
public sealed class AnimationDataRecord
{
public uint Id;
public ushort Fallback;
public ushort BehaviorID;
public byte BehaviorTier;
public int BehaviorID;
public int Fallback;
public int[] Flags = new int[2];
}
@@ -161,6 +162,7 @@ namespace Game.DataStorage
public uint UiAltItemAppearanceID;
public byte Flags;
public ushort UiCameraID;
public uint UsablePlayerConditionID;
}
public sealed class ArtifactAppearanceSetRecord
+2 -2
View File
@@ -36,7 +36,7 @@ namespace Game.DataStorage
public string DisplayName;
public string Description;
public uint Id;
public byte Type; // value 0 -> hair, value 2 -> facialhair
public byte Type; // value 0 . hair, value 2 . facialhair
public float CostModifier;
public byte Race;
public byte Sex;
@@ -76,7 +76,7 @@ namespace Game.DataStorage
public sealed class BattlePetSpeciesStateRecord
{
public uint Id;
public byte BattlePetStateID;
public ushort BattlePetStateID;
public int Value;
public uint BattlePetSpeciesID;
}
+12 -1
View File
@@ -102,6 +102,7 @@ namespace Game.DataStorage
public uint IconFileDataID;
public uint LowResScreenFileDataID;
public int StartingLevel;
public uint SpellTextureBlobFileDataID;
public ushort Flags;
public ushort CinematicSequenceID;
public ushort DefaultSpec;
@@ -214,8 +215,14 @@ namespace Game.DataStorage
public int MinLevel;
public int MaxLevel;
public int Flags;
public int ExpansionID;
}
public sealed class ContentTuningXExpectedRecord
{
public uint Id;
public int ExpectedStatModID;
public int DifficultyESMID;
public uint ContentTuningID;
}
public sealed class ConversationLineRecord
@@ -322,6 +329,9 @@ namespace Game.DataStorage
public float OverrideNameScale;
public float OverrideSelectionRadius;
public float TamedPetBaseScale;
public sbyte Unknown820_1; // scale related
public float Unknown820_2; // scale related
public float[] Unknown820_3 = new float[2]; // scale related
}
public sealed class CreatureTypeRecord
@@ -373,6 +383,7 @@ namespace Game.DataStorage
public uint Flags;
public sbyte Quality;
public int FactionID;
public int ItemGroupSoundsID;
}
public sealed class CurveRecord
@@ -71,10 +71,12 @@ namespace Game.DataStorage
public short MapID;
public sbyte DifficultyID;
public int OrderIndex;
public int CompleteWorldStateID;
public sbyte Bit;
public int CreatureDisplayID;
public byte Flags;
public int SpellIconFileID;
public int Faction;
}
public sealed class DurabilityCostsRecord
+1 -1
View File
@@ -29,7 +29,7 @@ namespace Game.DataStorage
public short ReputationIndex;
public ushort ParentFactionID;
public byte Expansion;
public byte FriendshipRepID;
public uint FriendshipRepID;
public byte Flags;
public ushort ParagonFactionID;
public short[] ReputationClassMask = new short[4];
+3 -3
View File
@@ -131,8 +131,8 @@ namespace Game.DataStorage
public int AllianceCreatureID;
public byte HordeGarrFollRaceID;
public byte AllianceGarrFollRaceID;
public byte HordeGarrClassSpecID;
public byte AllianceGarrClassSpecID;
public uint HordeGarrClassSpecID;
public uint AllianceGarrClassSpecID;
public byte Quality;
public byte FollowerLevel;
public ushort ItemLevelWeapon;
@@ -232,9 +232,9 @@ namespace Game.DataStorage
{
public uint Id;
public uint SpellID;
public ushort SpellIconID;
public byte GlyphType;
public byte GlyphExclusiveCategoryID;
public uint SpellIconID;
}
public sealed class GlyphRequiredSpecRecord
@@ -166,6 +166,7 @@ namespace Game.DataStorage
public float Gem3;
public float Health;
public float DamageReplaceStat;
public float DamageSecondary;
}
public sealed class GtXpRecord
+2 -2
View File
@@ -29,8 +29,8 @@ namespace Game.DataStorage
public sbyte SourceTypeEnum;
public byte Flags;
public int LegacyItemID;
public int[] UpgradeItemID = new int[3];
public ushort[] UpgradeItemBonusListID = new ushort[3];
public int[] UpgradeItemID = new int[4];
public ushort[] UpgradeItemBonusListID = new ushort[4];
}
public sealed class HolidaysRecord
+20 -19
View File
@@ -102,16 +102,33 @@ namespace Game.DataStorage
public uint Id;
public int[] Value = new int[3];
public ushort ParentItemBonusListID;
public ItemBonusType Type;
public ItemBonusType BonusType;
public byte OrderIndex;
}
public sealed class ItemBonusListGroupEntryRecord
{
public uint Id;
public int ItemBonusListID;
public int ItemLevelSelectorID;
public int OrderIndex;
public int ItemExtendedCostID;
public int ItemBonusListGroupID;
}
public sealed class ItemBonusListLevelDeltaRecord
{
public short ItemLevelDelta;
public uint Id;
}
public sealed class ItemBonusSequenceSpellRecord
{
public uint Id;
public int SpellID;
public int ItemID;
}
public sealed class ItemBonusTreeNodeRecord
{
public uint Id;
@@ -125,9 +142,9 @@ namespace Game.DataStorage
public sealed class ItemChildEquipmentRecord
{
public uint Id;
public uint ParentItemID;
public uint ChildItemID;
public byte ChildItemEquipSlot;
public uint ParentItemID;
}
public sealed class ItemClassRecord
@@ -206,6 +223,7 @@ namespace Game.DataStorage
public uint Id;
public ushort MinItemLevel;
public ushort ItemLevelSelectorQualitySetID;
public ushort AzeriteUnlockMappingSet;
}
public sealed class ItemLevelSelectorQualityRecord
@@ -257,21 +275,6 @@ namespace Game.DataStorage
public float Weapon;
}
public sealed class ItemRandomPropertiesRecord
{
public uint Id;
public LocalizedString Name;
public ushort[] Enchantment = new ushort[ItemConst.MaxItemRandomProperties];
}
public sealed class ItemRandomSuffixRecord
{
public uint Id;
public LocalizedString Name;
public ushort[] Enchantment = new ushort[ItemConst.MaxItemRandomProperties];
public ushort[] AllocationPct = new ushort[ItemConst.MaxItemRandomProperties];
}
public sealed class ItemSearchNameRecord
{
public long AllowableRace;
@@ -345,8 +348,6 @@ namespace Game.DataStorage
public ushort InstanceBound;
public ushort ZoneBound;
public ushort ItemSet;
public ushort ItemRandomSuffixGroupID;
public ushort RandomSelect;
public ushort LockID;
public ushort StartQuestID;
public ushort PageID;
+10 -8
View File
@@ -50,6 +50,7 @@ namespace Game.DataStorage
public byte MaxPlayers;
public short WindSettingsID;
public int ZmpFileDataID;
public int WdtFileDataID;
public MapFlags[] Flags = new MapFlags[2];
// Helpers
@@ -95,14 +96,14 @@ namespace Game.DataStorage
{
public uint Id;
public LocalizedString Message; // m_message_lang (text showed when transfer to map failed)
public uint ItemContextPickerID;
public int ContentTuningID;
public byte DifficultyID;
public byte LockID;
public uint DifficultyID;
public int LockID;
public byte ResetInterval;
public byte MaxPlayers;
public byte ItemContext;
public byte Flags;
public uint MaxPlayers;
public int ItemContext;
public uint ItemContextPickerID;
public int Flags;
public int ContentTuningID;
public uint MapID;
public uint GetRaidDuration()
@@ -121,7 +122,7 @@ namespace Game.DataStorage
public uint Parent;
public sbyte Operator;
public sbyte Amount;
public byte Type;
public uint Type;
public uint Asset;
public int SecondaryAsset;
public sbyte TertiaryAsset;
@@ -154,6 +155,7 @@ namespace Game.DataStorage
public uint ReqSpellKnownID;
public uint ModSpellAuraID;
public short ReqMapID;
public int PlayerConditionID;
}
public sealed class MountTypeXCapabilityRecord
@@ -21,6 +21,7 @@ namespace Game.DataStorage
{
public uint Id;
public int DamageReplaceStat;
public int DamageSecondary;
public uint[] Epic = new uint[5];
public uint[] Superior = new uint[5];
public uint[] Good = new uint[5];
+3 -2
View File
@@ -139,7 +139,7 @@ namespace Game.DataStorage
public sealed class SoundKitRecord
{
public uint Id;
public byte SoundType;
public uint SoundType;
public float VolumeFloat;
public ushort Flags;
public float MinDistance;
@@ -331,9 +331,9 @@ namespace Game.DataStorage
public string HordeName;
public uint[] EffectArg = new uint[ItemConst.MaxItemEnchantmentEffects];
public float[] EffectScalingPoints = new float[ItemConst.MaxItemEnchantmentEffects];
public uint TransmogPlayerConditionID;
public uint TransmogCost;
public uint IconFileDataID;
public uint TransmogPlayerConditionID;
public ushort[] EffectPointsMin = new ushort[ItemConst.MaxItemEnchantmentEffects];
public ushort ItemVisual;
public EnchantmentSlotMask Flags;
@@ -392,6 +392,7 @@ namespace Game.DataStorage
public float MinDuration;
public uint SpellIconFileDataID;
public uint ActiveIconFileDataID;
public uint ContentTuningID;
public int[] Attributes = new int[14];
public uint SpellID;
}
+6 -3
View File
@@ -48,10 +48,11 @@ namespace Game.DataStorage
public Vector2 FlightMapOffset;
public uint Id;
public ushort ContinentID;
public ushort ConditionID;
public uint ConditionID;
public ushort CharacterBitNumber;
public TaxiNodeFlags Flags;
public int UiTextureKitID;
public int MinimapAtlasMemberID;
public float Facing;
public uint SpecialIconConditionID;
public uint VisibilityConditionID;
@@ -75,8 +76,8 @@ namespace Game.DataStorage
public ushort ContinentID;
public TaxiPathNodeFlags Flags;
public uint Delay;
public ushort ArrivalEventID;
public ushort DepartureEventID;
public uint ArrivalEventID;
public uint DepartureEventID;
}
public sealed class TotemCategoryRecord
@@ -112,7 +113,9 @@ namespace Game.DataStorage
public uint TransmogSetGroupID;
public int ItemNameDescriptionID;
public ushort ParentTransmogSetID;
public byte Unknown810;
public byte ExpansionID;
public int PatchID;
public short UiOrder;
}
@@ -58,6 +58,8 @@ namespace Game.DataStorage
public int ParentUiMapID;
public int OrderIndex;
public int ChildUiMapID;
public int OverrideHighlightFileDataID;
public int OverrideHighlightAtlasID;
}
public sealed class UiMapXMapArtRecord
+1 -1
View File
@@ -44,7 +44,7 @@ namespace Game.DataStorage
public uint Id;
public uint QuestFeedbackEffectID;
public byte WhenToDisplay;
public byte TargetType;
public int TargetType;
public int TargetAsset;
public uint PlayerConditionID;
public ushort CombatConditionID;
+78 -21
View File
@@ -26,6 +26,7 @@ using System;
using System.Collections.Generic;
using Game;
using Framework.Dynamic;
using Game.Network;
namespace Game.Entities
{
@@ -42,7 +43,7 @@ namespace Game.Entities
m_updateFlag.Stationary = true;
m_updateFlag.AreaTrigger = true;
valuesCount = (int)AreaTriggerFields.End;
m_areaTriggerData = new AreaTriggerFieldData();
_spline = new Spline();
}
@@ -114,19 +115,35 @@ namespace Game.Entities
SetObjectScale(1.0f);
SetGuidValue(AreaTriggerFields.Caster, caster.GetGUID());
SetGuidValue(AreaTriggerFields.CreatingEffectGuid, castId);
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.Caster), caster.GetGUID());
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.CreatingEffectGUID), castId);
SetUInt32Value(AreaTriggerFields.SpellId, spell.Id);
SetUInt32Value(AreaTriggerFields.SpellForVisuals, spell.Id);
SetUInt32Value(AreaTriggerFields.SpellXSpellVisualId, spellXSpellVisualId);
SetUInt32Value(AreaTriggerFields.TimeToTargetScale, GetMiscTemplate().TimeToTargetScale != 0 ? GetMiscTemplate().TimeToTargetScale : GetUInt32Value(AreaTriggerFields.Duration));
SetFloatValue(AreaTriggerFields.BoundsRadius2d, GetTemplate().MaxSearchRadius);
SetUInt32Value(AreaTriggerFields.DecalPropertiesId, GetMiscTemplate().DecalPropertiesId);
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.SpellID), spell.Id);
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.SpellForVisuals), spell.Id);
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.SpellXSpellVisualID), spellXSpellVisualId);
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.TimeToTargetScale), GetMiscTemplate().TimeToTargetScale != 0 ? GetMiscTemplate().TimeToTargetScale : m_areaTriggerData.Duration);
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.BoundsRadius2D), GetTemplate().MaxSearchRadius);
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.DecalPropertiesID), GetMiscTemplate().DecalPropertiesId);
ScaleCurve extraScaleCurve = m_areaTriggerData.ModifyValue(m_areaTriggerData.ExtraScaleCurve);
if (GetMiscTemplate().ExtraScale.Structured.StartTimeOffset != 0)
SetUpdateFieldValue(ref extraScaleCurve.StartTimeOffset, GetMiscTemplate().ExtraScale.Structured.StartTimeOffset);
if (GetMiscTemplate().ExtraScale.Structured.X != 0 || GetMiscTemplate().ExtraScale.Structured.Y != 0)
{
Vector2 point = new Vector2(GetMiscTemplate().ExtraScale.Structured.X, GetMiscTemplate().ExtraScale.Structured.Y);
SetUpdateFieldValue(ref extraScaleCurve.Points[0], point);
}
if (GetMiscTemplate().ExtraScale.Structured.Z != 0 || GetMiscTemplate().ExtraScale.Structured.W != 0)
{
Vector2 point = new Vector2(GetMiscTemplate().ExtraScale.Structured.Z, GetMiscTemplate().ExtraScale.Structured.W);
SetUpdateFieldValue(ref extraScaleCurve.Points[1], point);
}
if (GetMiscTemplate().ExtraScale.Raw.Data[5] != 0)
SetUpdateFieldValue(ref extraScaleCurve.ParameterCurve, GetMiscTemplate().ExtraScale.Raw.Data[5]);
if (GetMiscTemplate().ExtraScale.Structured.OverrideActive != 0)
SetUpdateFieldValue(ref extraScaleCurve.OverrideActive, GetMiscTemplate().ExtraScale.Structured.OverrideActive != 0 ? true : false);
for (byte scaleCurveIndex = 0; scaleCurveIndex < SharedConst.MaxAreatriggerScale; ++scaleCurveIndex)
if (GetMiscTemplate().ExtraScale.Raw.Data[scaleCurveIndex] != 0)
SetUInt32Value(AreaTriggerFields.ExtraScaleCurve + scaleCurveIndex, (uint)GetMiscTemplate().ExtraScale.Raw.Data[scaleCurveIndex]);
PhasingHandler.InheritPhaseShift(this, caster);
@@ -137,7 +154,7 @@ namespace Game.Entities
UpdateShape();
uint timeToTarget = GetMiscTemplate().TimeToTarget != 0 ? GetMiscTemplate().TimeToTarget : GetUInt32Value(AreaTriggerFields.Duration);
uint timeToTarget = GetMiscTemplate().TimeToTarget != 0 ? GetMiscTemplate().TimeToTarget : m_areaTriggerData.Duration;
if (GetTemplate().HasFlag(AreaTriggerFlags.HasCircularMovement))
{
@@ -234,7 +251,7 @@ namespace Game.Entities
_totalDuration = newDuration;
// negative duration (permanent areatrigger) sent as 0
SetUInt32Value(AreaTriggerFields.Duration, (uint)Math.Max(newDuration, 0));
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.Duration), (uint)Math.Max(newDuration, 0));
}
void _UpdateDuration(int newDuration)
@@ -242,7 +259,8 @@ namespace Game.Entities
_duration = newDuration;
// should be sent in object create packets only
updateValues[(int)AreaTriggerFields.Duration].SignedValue = _duration;
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.Duration), (uint)_duration);
m_areaTriggerData.ClearChanged(m_areaTriggerData.Duration);
}
float GetProgress()
@@ -619,7 +637,8 @@ namespace Game.Entities
_spline.initLengths();
// should be sent in object create packets only
updateValues[(int)AreaTriggerFields.TimeToTarget].UnsignedValue = timeToTarget;
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.TimeToTarget), timeToTarget);
m_areaTriggerData.ClearChanged(m_areaTriggerData.TimeToTarget);
if (IsInWorld)
{
@@ -648,7 +667,8 @@ namespace Game.Entities
Cypher.Assert(cmi.Center.HasValue || cmi.PathTarget.HasValue);
// should be sent in object create packets only
updateValues[(int)AreaTriggerFields.TimeToTarget].UnsignedValue = timeToTarget;
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.TimeToTarget), timeToTarget);
m_areaTriggerData.ClearChanged(m_areaTriggerData.TimeToTarget);
_circularMovementInfo.Set(cmi);
@@ -822,6 +842,41 @@ namespace Game.Entities
_ai = null;
}
public override void BuildValuesCreate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt8((byte)flags);
m_objectData.WriteCreate(buffer, flags, this, target);
m_areaTriggerData.WriteCreate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void BuildValuesUpdate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt32(m_values.GetChangedObjectTypeMask());
if (m_values.HasChanged(TypeId.Object))
m_objectData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.AreaTrigger))
m_areaTriggerData.WriteUpdate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void ClearUpdateMask(bool remove)
{
m_values.ClearChangesMask(m_areaTriggerData);
base.ClearUpdateMask(remove);
}
AreaTriggerAI GetAI() { return _ai; }
[System.Diagnostics.Conditional("DEBUG")]
@@ -838,11 +893,11 @@ namespace Game.Entities
}
public bool IsRemoved() { return _isRemoved; }
public uint GetSpellId() { return GetUInt32Value(AreaTriggerFields.SpellId); }
public uint GetSpellId() { return m_areaTriggerData.SpellID; }
public AuraEffect GetAuraEffect() { return _aurEff; }
public uint GetTimeSinceCreated() { return _timeSinceCreated; }
public uint GetTimeToTarget() { return GetUInt32Value(AreaTriggerFields.TimeToTarget); }
public uint GetTimeToTargetScale() { return GetUInt32Value(AreaTriggerFields.TimeToTargetScale); }
public uint GetTimeToTarget() { return m_areaTriggerData.TimeToTarget; }
public uint GetTimeToTargetScale() { return m_areaTriggerData.TimeToTargetScale; }
public int GetDuration() { return _duration; }
public int GetTotalDuration() { return _totalDuration; }
@@ -852,7 +907,7 @@ namespace Game.Entities
public AreaTriggerMiscTemplate GetMiscTemplate() { return _areaTriggerMiscTemplate; }
public ObjectGuid GetCasterGuid() { return GetGuidValue(AreaTriggerFields.Caster); }
public ObjectGuid GetCasterGuid() { return m_areaTriggerData.Caster; }
public Vector3 GetRollPitchYaw() { return _rollPitchYaw; }
public Vector3 GetTargetRollPitchYaw() { return _targetRollPitchYaw; }
@@ -863,6 +918,8 @@ namespace Game.Entities
public Optional<AreaTriggerCircularMovementInfo> GetCircularMovementInfo() { return _circularMovementInfo; }
AreaTriggerFieldData m_areaTriggerData;
ObjectGuid _targetGuid;
AuraEffect _aurEff;
@@ -104,10 +104,19 @@ namespace Game.Entities
public uint StartTimeOffset;
[FieldOffset(4)]
public float[] Points;
public float X;
[FieldOffset(8)]
public float Y;
[FieldOffset(12)]
public float Z;
[FieldOffset(16)]
public float W;
[FieldOffset(20)]
public curveparameters CurveParameters;
public uint CurveParameters;
[FieldOffset(24)]
public uint OverrideActive;
+65 -40
View File
@@ -20,6 +20,7 @@ using Game.DataStorage;
using Game.Maps;
using Game.Spells;
using System.Collections.Generic;
using Game.Network;
namespace Game.Entities
{
@@ -35,8 +36,7 @@ namespace Game.Entities
m_updateFlag.Stationary = true;
m_updateFlag.Conversation = true;
valuesCount = (int)ConversationFields.End;
_dynamicValuesCount = (int)ConversationDynamicFields.End;
m_conversationData = new ConversationData();
}
public override void AddToWorld()
@@ -117,7 +117,7 @@ namespace Game.Entities
SetEntry(conversationEntry);
SetObjectScale(1.0f);
SetUInt32Value(ConversationFields.LastLineEndTime, conversationTemplate.LastLineEndTime);
SetUpdateFieldValue(m_values.ModifyValue(m_conversationData).ModifyValue(m_conversationData.LastLineEndTime), conversationTemplate.LastLineEndTime);
_duration = conversationTemplate.LastLineEndTime;
_textureKitId = conversationTemplate.TextureKitId;
@@ -126,11 +126,12 @@ namespace Game.Entities
ConversationActorTemplate actor = conversationTemplate.Actors[actorIndex];
if (actor != null)
{
ConversationDynamicFieldActor actorField = new ConversationDynamicFieldActor();
actorField.ActorTemplate.CreatureId = actor.CreatureId;
actorField.ActorTemplate.CreatureModelId = actor.CreatureModelId;
actorField.Type = ConversationDynamicFieldActor.ActorType.CreatureActor;
SetDynamicStructuredValue(ConversationDynamicFields.Actors, actorIndex, actorField);
ConversationActor actorField = new ConversationActor();
actorField.CreatureID = actor.CreatureId;
actorField.CreatureDisplayInfoID = actor.CreatureModelId;
actorField.Type = ConversationActorType.CreatureActor;
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_conversationData).ModifyValue(m_conversationData.Actors), actorField);
}
}
@@ -150,17 +151,30 @@ namespace Game.Entities
Global.ScriptMgr.OnConversationCreate(this, creator);
List<ushort> actorIndices = new List<ushort>();
List<ConversationLine> lines = new List<ConversationLine>();
foreach (ConversationLineTemplate line in conversationTemplate.Lines)
{
actorIndices.Add(line.ActorIdx);
AddDynamicStructuredValue(ConversationDynamicFields.Lines, line);
ConversationLine lineField = new ConversationLine();
lineField.ConversationLineID = line.Id;
lineField.StartTime = line.StartTime;
lineField.UiCameraID = line.UiCameraID;
lineField.ActorIndex = line.ActorIdx;
lineField.Flags = line.Flags;
lines.Add(lineField);
}
SetUpdateFieldValue(m_values.ModifyValue(m_conversationData).ModifyValue(m_conversationData.Lines), lines);
Global.ScriptMgr.OnConversationCreate(this, creator);
// All actors need to be set
foreach (ushort actorIndex in actorIndices)
{
ConversationDynamicFieldActor actor = GetDynamicStructuredValue<ConversationDynamicFieldActor>(ConversationDynamicFields.Actors, actorIndex);
if (actor == null || actor.IsEmpty())
ConversationActor actor = actorIndex < m_conversationData.Actors.Size() ? m_conversationData.Actors[actorIndex] : null;
if (actor == null || (actor.CreatureID == 0 && actor.ActorGUID.IsEmpty()))
{
Log.outError(LogFilter.Conversation, $"Failed to create conversation (Id: {conversationEntry}) due to missing actor (Idx: {actorIndex}).");
return false;
@@ -175,10 +189,9 @@ namespace Game.Entities
void AddActor(ObjectGuid actorGuid, ushort actorIdx)
{
ConversationDynamicFieldActor actorField = new ConversationDynamicFieldActor();
actorField.ActorGuid = actorGuid;
actorField.Type = ConversationDynamicFieldActor.ActorType.WorldObjectActor;
SetDynamicStructuredValue(ConversationDynamicFields.Actors, actorIdx, actorField);
ConversationActor actorField = m_values.ModifyValue(m_conversationData).ModifyValue(m_conversationData.Actors, actorIdx);
SetUpdateFieldValue(ref actorField.ActorGUID, actorGuid);
SetUpdateFieldValue(ref actorField.Type, ConversationActorType.WorldObjectActor);
}
void AddParticipant(ObjectGuid participantGuid)
@@ -191,6 +204,41 @@ namespace Game.Entities
return Global.ConversationDataStorage.GetConversationTemplate(GetEntry()).ScriptId;
}
public override void BuildValuesCreate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
m_objectData.WriteCreate(buffer, flags, this, target);
m_conversationData.WriteCreate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteUInt8((byte)flags);
data.WriteBytes(buffer);
}
public override void BuildValuesUpdate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt32(m_values.GetChangedObjectTypeMask());
if (m_values.HasChanged(TypeId.Object))
m_objectData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.Conversation))
m_conversationData.WriteUpdate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void ClearUpdateMask(bool remove)
{
m_values.ClearChangesMask(m_conversationData);
base.ClearUpdateMask(remove);
}
uint GetDuration() { return _duration; }
public uint GetTextureKitId() { return _textureKitId; }
@@ -202,35 +250,12 @@ namespace Game.Entities
public override float GetStationaryO() { return _stationaryPosition.GetOrientation(); }
void RelocateStationaryPosition(Position pos) { _stationaryPosition.Relocate(pos); }
ConversationData m_conversationData;
Position _stationaryPosition = new Position();
ObjectGuid _creatorGuid;
uint _duration;
uint _textureKitId;
List<ObjectGuid> _participants = new List<ObjectGuid>();
}
class ConversationDynamicFieldActor
{
public enum ActorType
{
WorldObjectActor = 0,
CreatureActor = 1
}
public bool IsEmpty()
{
return ActorGuid.IsEmpty(); // this one is good enough
}
public ObjectGuid ActorGuid;
public ActorTemplateStruct ActorTemplate;
public struct ActorTemplateStruct
{
public uint CreatureId;
public uint CreatureModelId;
}
public ActorType Type;
}
}
+93 -19
View File
@@ -21,6 +21,9 @@ using Game.DataStorage;
using Game.Loots;
using Game.Maps;
using System.Collections.Generic;
using System.Text;
using Framework.Collections;
using Game.Network;
namespace Game.Entities
{
@@ -34,7 +37,7 @@ namespace Game.Entities
m_updateFlag.Stationary = true;
valuesCount = (int)CorpseFields.End;
m_corpseData = new CorpseData();
m_time = Time.UnixTime;
}
@@ -79,7 +82,7 @@ namespace Game.Entities
_Create(ObjectGuid.Create(HighGuid.Corpse, owner.GetMapId(), 0, guidlow));
SetObjectScale(1);
SetGuidValue(CorpseFields.Owner, owner.GetGUID());
SetOwnerGUID(owner.GetGUID());
_cellCoord = GridDefines.ComputeCellCoord(GetPositionX(), GetPositionY());
@@ -94,6 +97,14 @@ namespace Game.Entities
SQLTransaction trans = new SQLTransaction();
DeleteFromDB(trans);
StringBuilder items = new StringBuilder();
for (var i = 0; i < EquipmentSlot.End; ++i)
items.Append($"{m_corpseData.Items[i]} ");
uint bytes1 = ((uint)m_corpseData.RaceID << 8) | ((uint)m_corpseData.Sex << 16) | ((uint)m_corpseData.SkinID << 24);
uint bytes2 = ((uint)m_corpseData.FaceID) | ((uint)m_corpseData.HairStyleID << 8) | ((uint)m_corpseData.HairColorID << 16) | ((uint)m_corpseData.FacialHairStyleID << 24);
byte index = 0;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CORPSE);
stmt.AddValue(index++, GetOwnerGUID().GetCounter()); // guid
@@ -102,12 +113,12 @@ namespace Game.Entities
stmt.AddValue(index++, GetPositionZ()); // posZ
stmt.AddValue(index++, GetOrientation()); // orientation
stmt.AddValue(index++, GetMapId()); // mapId
stmt.AddValue(index++, GetUInt32Value(CorpseFields.DisplayId)); // displayId
stmt.AddValue(index++, _ConcatFields(CorpseFields.Item, EquipmentSlot.End)); // itemCache
stmt.AddValue(index++, GetUInt32Value(CorpseFields.Bytes1)); // bytes1
stmt.AddValue(index++, GetUInt32Value(CorpseFields.Bytes2)); // bytes2
stmt.AddValue(index++, GetUInt32Value(CorpseFields.Flags)); // flags
stmt.AddValue(index++, GetUInt32Value(CorpseFields.DynamicFlags)); // dynFlags
stmt.AddValue(index++, (uint)m_corpseData.DisplayID); // displayId
stmt.AddValue(index++, items.ToString()); // itemCache
stmt.AddValue(index++, bytes1); // bytes1
stmt.AddValue(index++, bytes2); // bytes2
stmt.AddValue(index++, (uint)m_corpseData.Flags); // flags
stmt.AddValue(index++, (uint)m_corpseData.DynamicFlags); // dynFlags
stmt.AddValue(index++, (uint)m_time); // time
stmt.AddValue(index++, (uint)GetCorpseType()); // corpseType
stmt.AddValue(index++, GetInstanceId()); // instanceId
@@ -153,16 +164,24 @@ namespace Game.Entities
_Create(ObjectGuid.Create(HighGuid.Corpse, mapId, 0, guid));
SetObjectScale(1.0f);
SetUInt32Value(CorpseFields.DisplayId, field.Read<uint>(5));
_LoadIntoDataField(field.Read<string>(6), (int)CorpseFields.Item, EquipmentSlot.End);
SetUInt32Value(CorpseFields.Bytes1, field.Read<uint>(7));
SetUInt32Value(CorpseFields.Bytes2, field.Read<uint>(8));
SetUInt32Value(CorpseFields.Flags, field.Read<byte>(9));
SetUInt32Value(CorpseFields.DynamicFlags, field.Read<byte>(10));
SetGuidValue(CorpseFields.Owner, ObjectGuid.Create(HighGuid.Player, field.Read<ulong>(14)));
CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(GetGuidValue(CorpseFields.Owner));
if (characterInfo != null)
SetUInt32Value(CorpseFields.FactionTemplate, CliDB.ChrRacesStorage.LookupByKey(characterInfo.RaceID).FactionID);
SetDisplayId(field.Read<uint>(5));
StringArray items = new StringArray(field.Read<string>(6), ' ');
for (uint index = 0; index < EquipmentSlot.End; ++index)
SetItem(index, uint.Parse(items[(int)index]));
uint bytes1 = field.Read<uint>(7);
uint bytes2 = field.Read<uint>(8);
SetRace((Race)((bytes1 >> 8) & 0xFF));
SetSex((Gender)((bytes1 >> 16) & 0xFF));
SetSkin((byte)((bytes1 >> 24) & 0xFF));
SetFace((byte)(bytes2 & 0xFF));
SetHairStyle((byte)((bytes2 >> 8) & 0xFF));
SetHairColor((byte)((bytes2 >> 16) & 0xFF));
SetFacialHairStyle((byte)((bytes2 >> 24) & 0xFF));
SetFlags((CorpseFlags)field.Read<byte>(9));
SetCorpseDynamicFlags((CorpseDynFlags)field.Read<byte>(10));
SetOwnerGUID(ObjectGuid.Create(HighGuid.Player, field.Read<ulong>(14)));
SetFactionTemplate(CliDB.ChrRacesStorage.LookupByKey(m_corpseData.RaceID).FactionID);
m_time = field.Read<uint>(11);
@@ -196,7 +215,60 @@ namespace Game.Entities
return m_time < t - 3 * Time.Day;
}
public ObjectGuid GetOwnerGUID() { return GetGuidValue(CorpseFields.Owner); }
public override void BuildValuesCreate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
m_objectData.WriteCreate(buffer, flags, this, target);
m_corpseData.WriteCreate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteUInt8((byte)flags);
data.WriteBytes(buffer);
}
public override void BuildValuesUpdate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt32(m_values.GetChangedObjectTypeMask());
if (m_values.HasChanged(TypeId.Object))
m_objectData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.Corpse))
m_corpseData.WriteUpdate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void ClearUpdateMask(bool remove)
{
m_values.ClearChangesMask(m_corpseData);
base.ClearUpdateMask(remove);
}
public void AddCorpseDynamicFlag(CorpseDynFlags dynamicFlags) { SetUpdateFieldFlagValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.DynamicFlags), (uint)dynamicFlags); }
public void RemoveCorpseDynamicFlag(CorpseDynFlags dynamicFlags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.DynamicFlags), (uint)dynamicFlags); }
public void SetCorpseDynamicFlags(CorpseDynFlags dynamicFlags) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.DynamicFlags), (uint)dynamicFlags); }
public ObjectGuid GetOwnerGUID() { return m_corpseData.Owner; }
public void SetOwnerGUID(ObjectGuid owner) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.Owner), owner); }
public void SetPartyGUID(ObjectGuid partyGuid) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.PartyGUID), partyGuid); }
public void SetGuildGUID(ObjectGuid guildGuid) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.GuildGUID), guildGuid); }
public void SetDisplayId(uint displayId) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.DisplayID), displayId); }
public void SetRace(Race race) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.RaceID), (byte)race); }
public void SetSex(Gender sex) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.Sex), (byte)sex); }
public void SetSkin(byte skin) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.SkinID), skin); }
public void SetFace(byte face) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.FaceID), face); }
public void SetHairStyle(byte hairStyle) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.HairStyleID), hairStyle); }
public void SetHairColor(byte hairColor) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.HairColorID), hairColor); }
public void SetFacialHairStyle(byte facialHairStyle) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.FacialHairStyleID), facialHairStyle); }
public void SetFlags(CorpseFlags flags) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.Flags), (uint)flags); }
public void SetFactionTemplate(int factionTemplate) { SetUpdateFieldValue(m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.FactionTemplate), factionTemplate); }
public void SetItem(uint slot, uint item) { SetUpdateFieldValue(ref m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.Items, (int)slot), item); }
public void SetCustomDisplayOption(uint slot, byte customDisplayOption) { SetUpdateFieldValue(ref m_values.ModifyValue(m_corpseData).ModifyValue(m_corpseData.CustomDisplayOption, (int)slot), customDisplayOption); }
public long GetGhostTime() { return m_time; }
public void ResetGhostTime() { m_time = Time.UnixTime; }
@@ -205,6 +277,8 @@ namespace Game.Entities
public CellCoord GetCellCoord() { return _cellCoord; }
public void SetCellCoord(CellCoord cellCoord) { _cellCoord = cellCoord; }
public CorpseData m_corpseData;
public Loot loot = new Loot();
public Player lootRecipient;
public bool lootForBody;
+84 -88
View File
@@ -46,8 +46,6 @@ namespace Game.Entities
m_meleeDamageSchoolMask = SpellSchoolMask.Normal;
m_regenTimer = SharedConst.CreatureRegenInterval;
valuesCount = (int)UnitFields.End;
_dynamicValuesCount = (int)UnitDynamicFields.End;
m_SightDistance = SharedConst.SightRangeUnit;
@@ -192,9 +190,8 @@ namespace Game.Entities
m_creatureInfo = cinfo; // map mode related always
// equal to player Race field, but creature does not have race
SetByteValue(UnitFields.Bytes0, 0, 0);
SetByteValue(UnitFields.Bytes0, 1, (byte)cinfo.UnitClass);
SetRace(0);
SetClass((Class)cinfo.UnitClass);
// Cancel load if no model defined
if (cinfo.GetFirstValidModel() == null)
@@ -213,7 +210,7 @@ namespace Game.Entities
SetDisplayId(model.CreatureDisplayID, model.DisplayScale);
SetNativeDisplayId(model.CreatureDisplayID, model.DisplayScale);
SetByteValue(UnitFields.Bytes0, 3, (byte)minfo.gender);
SetGender((Gender)minfo.gender);
// Load creature equipment
if (data == null || data.equipmentId == 0)
@@ -226,12 +223,12 @@ namespace Game.Entities
SetName(normalInfo.Name); // at normal entry always
SetFloatValue(UnitFields.ModCastSpeed, 1.0f);
SetFloatValue(UnitFields.ModCastHaste, 1.0f);
SetFloatValue(UnitFields.ModHaste, 1.0f);
SetFloatValue(UnitFields.ModRangedHaste, 1.0f);
SetFloatValue(UnitFields.ModHasteRegen, 1.0f);
SetFloatValue(UnitFields.ModTimeRate, 1.0f);
SetModCastingSpeed(1.0f);
SetModSpellHaste(1.0f);
SetModHaste(1.0f);
SetModRangedHaste(1.0f);
SetModHasteRegen(1.0f);
SetModTimeRate(1.0f);
SetSpeedRate(UnitMoveType.Walk, cinfo.SpeedWalk);
SetSpeedRate(UnitMoveType.Run, cinfo.SpeedRun);
@@ -240,7 +237,7 @@ namespace Game.Entities
SetObjectScale(cinfo.Scale);
SetFloatValue(UnitFields.HoverHeight, cinfo.HoverHeight);
SetHoverHeight(cinfo.HoverHeight);
// checked at loading
m_defaultMovementType = (MovementGeneratorType)cinfo.MovementType;
@@ -273,19 +270,20 @@ namespace Game.Entities
ObjectManager.ChooseCreatureFlags(cInfo, out npcFlags, out unitFlags, out unitFlags2, out unitFlags3, out dynamicFlags, data);
if (cInfo.FlagsExtra.HasAnyFlag(CreatureFlagsExtra.Worldevent))
SetUInt64Value(UnitFields.NpcFlags, npcFlags | Global.GameEventMgr.GetNPCFlag(this));
else
SetUInt64Value(UnitFields.NpcFlags, npcFlags);
npcFlags |= Global.GameEventMgr.GetNPCFlag(this);
SetUInt32Value(UnitFields.Flags, unitFlags);
SetUInt32Value(UnitFields.Flags2, unitFlags2);
SetUInt32Value(UnitFields.Flags3, unitFlags3);
SetNpcFlags((NPCFlags)(npcFlags & 0xFFFFFFFF));
SetNpcFlags2((NPCFlags2)(npcFlags >> 32));
SetUInt32Value(ObjectFields.DynamicFlags, dynamicFlags);
SetUnitFlags((UnitFlags)unitFlags);
SetUnitFlags2((UnitFlags2)unitFlags2);
SetUnitFlags3((UnitFlags3)unitFlags3);
SetUInt32Value(UnitFields.StateAnimId, (uint)CliDB.AnimationDataStorage.Count);
SetDynamicFlags((UnitDynFlags)dynamicFlags);
RemoveFlag(UnitFields.Flags, UnitFlags.InCombat);
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.StateAnimID), (uint)CliDB.AnimationDataStorage.Count);
RemoveUnitFlag(UnitFlags.InCombat);
SetBaseAttackTime(WeaponAttackType.BaseAttack, cInfo.BaseAttackTime);
SetBaseAttackTime(WeaponAttackType.OffAttack, cInfo.BaseAttackTime);
@@ -323,14 +321,14 @@ namespace Game.Entities
Player owner = GetCharmerOrOwnerPlayerOrPlayerItself();
if (owner != null) // this check comes in case we don't have a player
{
SetFaction(owner.getFaction()); // vehicles should have same as owner faction
SetFaction(owner.GetFaction()); // vehicles should have same as owner faction
owner.VehicleSpellInitialize();
}
}
// trigger creature is always not selectable and can not be attacked
if (IsTrigger())
SetFlag(UnitFields.Flags, UnitFlags.NotSelectable);
AddUnitFlag(UnitFlags.NotSelectable);
InitializeReactState();
@@ -411,7 +409,7 @@ namespace Game.Entities
else if (m_corpseRemoveTime <= Time.UnixTime)
{
RemoveCorpse(false);
Log.outDebug(LogFilter.Unit, "Removing corpse... {0} ", GetUInt32Value(ObjectFields.Entry));
Log.outDebug(LogFilter.Unit, "Removing corpse... {0} ", GetEntry());
}
break;
case DeathState.Alive:
@@ -519,7 +517,7 @@ namespace Game.Entities
if (!IsInEvadeMode() && (!bInCombat || IsPolymorphed() || CanNotReachTarget())) // regenerate health if not in combat or if polymorphed
RegenerateHealth();
if (HasFlag(UnitFields.Flags2, UnitFlags2.RegeneratePower))
if (HasUnitFlag2(UnitFlags2.RegeneratePower))
{
if (GetPowerType() == PowerType.Energy)
Regenerate(PowerType.Energy);
@@ -798,7 +796,7 @@ namespace Game.Entities
//! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there
if (HasUnitMovementFlag(MovementFlag.Hover))
{
z += GetFloatValue(UnitFields.HoverHeight);
z += m_unitData.HoverHeight;
//! Relocate again with updated Z coord
Relocate(x, y, z, ang);
@@ -810,7 +808,7 @@ namespace Game.Entities
{
SetDisplayId(display.CreatureDisplayID, display.DisplayScale);
SetNativeDisplayId(display.CreatureDisplayID, display.DisplayScale);
SetByteValue(UnitFields.Bytes0, 3, (byte)minfo.gender);
SetGender((Gender)minfo.gender);
}
LastUsedScriptID = GetScriptId();
@@ -956,7 +954,7 @@ namespace Game.Entities
{
m_lootRecipient.Clear();
m_lootRecipientGroup.Clear();
RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Lootable | UnitDynFlags.Tapped);
RemoveDynamicFlag(UnitDynFlags.Lootable | UnitDynFlags.Tapped);
return;
}
@@ -972,7 +970,7 @@ namespace Game.Entities
if (group)
m_lootRecipientGroup = group.GetGUID();
SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Tapped);
AddDynamicFlag(UnitDynFlags.Tapped);
}
public bool isTappedBy(Player player)
@@ -1011,11 +1009,11 @@ namespace Game.Entities
CreatureData data = Global.ObjectMgr.NewOrExistCreatureData(m_spawnId);
uint displayId = GetNativeDisplayId();
ulong npcflag = GetUInt64Value(UnitFields.NpcFlags);
uint unitFlags = GetUInt32Value(UnitFields.Flags);
uint unitFlags2 = GetUInt32Value(UnitFields.Flags2);
uint unitFlags3 = GetUInt32Value(UnitFields.Flags3);
uint dynamicflags = GetUInt32Value(ObjectFields.DynamicFlags);
ulong npcflag = ((ulong)m_unitData.NpcFlags[1] << 32) | m_unitData.NpcFlags[0];
uint unitFlags = m_unitData.Flags;
uint unitFlags2 = m_unitData.Flags2;
uint unitFlags3 = m_unitData.Flags3;
UnitDynFlags dynamicflags = (UnitDynFlags)(uint)m_objectData.DynamicFlags;
// check if it's a custom model and if not, use 0 for displayId
CreatureTemplate cinfo = GetCreatureTemplate();
@@ -1037,7 +1035,7 @@ namespace Game.Entities
if (unitFlags3 == cinfo.UnitFlags3)
unitFlags3 = 0;
if (dynamicflags == cinfo.DynamicFlags)
if (dynamicflags == (UnitDynFlags)cinfo.DynamicFlags)
dynamicflags = 0;
}
@@ -1064,7 +1062,7 @@ namespace Game.Entities
data.unit_flags = unitFlags;
data.unit_flags2 = unitFlags2;
data.unit_flags3 = unitFlags3;
data.dynamicflags = dynamicflags;
data.dynamicflags = (uint)dynamicflags;
data.phaseId = GetDBPhase() > 0 ? (uint)GetDBPhase() : data.phaseId;
data.phaseGroup = GetDBPhase() < 0 ? (uint)-GetDBPhase() : data.phaseGroup;
@@ -1119,14 +1117,14 @@ namespace Game.Entities
if (HasScalableLevels())
{
SetUInt32Value(UnitFields.ScalingLevelMin, cInfo.levelScaling.Value.MinLevel);
SetUInt32Value(UnitFields.ScalingLevelMax, cInfo.levelScaling.Value.MaxLevel);
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ScalingLevelMin), cInfo.levelScaling.Value.MinLevel);
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ScalingLevelMax), cInfo.levelScaling.Value.MaxLevel);
int mindelta = Math.Min(cInfo.levelScaling.Value.DeltaLevelMax, cInfo.levelScaling.Value.DeltaLevelMin);
int maxdelta = Math.Max(cInfo.levelScaling.Value.DeltaLevelMax, cInfo.levelScaling.Value.DeltaLevelMin);
int delta = mindelta == maxdelta ? mindelta : RandomHelper.IRand(mindelta, maxdelta);
SetInt32Value(UnitFields.ScalingLevelDelta, delta);
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ScalingLevelDelta), delta);
}
UpdateLevelDependantStats();
@@ -1434,9 +1432,9 @@ namespace Game.Entities
return false;
// This set of checks is should be done only for creatures
if ((HasFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc) && !who.IsTypeId(TypeId.Player)) // flag is valid only for non player characters
|| (HasFlag(UnitFields.Flags, UnitFlags.ImmuneToPc) && who.IsTypeId(TypeId.Player)) // immune to PC and target is a player, return false
|| (who.GetOwner() && who.GetOwner().IsTypeId(TypeId.Player) && HasFlag(UnitFields.Flags, UnitFlags.ImmuneToPc))) // player pets are immune to pc as well
if ((HasUnitFlag(UnitFlags.ImmuneToNpc) && !who.IsTypeId(TypeId.Player)) // flag is valid only for non player characters
|| (HasUnitFlag(UnitFlags.ImmuneToPc) && who.IsTypeId(TypeId.Player)) // immune to PC and target is a player, return false
|| (who.GetOwner() && who.GetOwner().IsTypeId(TypeId.Player) && HasUnitFlag(UnitFlags.ImmuneToPc))) // player pets are immune to pc as well
return false;
// Do not attack non-combat pets
@@ -1530,9 +1528,10 @@ namespace Game.Entities
DoNotReacquireTarget(); // cancel delayed re-target
SetTarget(ObjectGuid.Empty); // drop target - dead mobs shouldn't ever target things
SetUInt64Value(UnitFields.NpcFlags, (ulong)NPCFlags.None);
SetNpcFlags(NPCFlags.None);
SetNpcFlags2(NPCFlags2.None);
SetUInt32Value(UnitFields.MountDisplayId, 0); // if creature is mounted on a virtual mount, remove it at death
SetMountDisplayId(0); // if creature is mounted on a virtual mount, remove it at death
setActive(false);
@@ -1576,16 +1575,17 @@ namespace Game.Entities
ObjectManager.ChooseCreatureFlags(cInfo, out npcFlags, out unitFlags, out unitFlags2, out unitFlags3, out dynamicFlags, creatureData);
if (cInfo.FlagsExtra.HasAnyFlag(CreatureFlagsExtra.Worldevent))
SetUInt64Value(UnitFields.NpcFlags, npcFlags | Global.GameEventMgr.GetNPCFlag(this));
else
SetUInt64Value(UnitFields.NpcFlags, npcFlags);
npcFlags |= Global.GameEventMgr.GetNPCFlag(this);
SetUInt32Value(UnitFields.Flags, unitFlags);
SetUInt32Value(UnitFields.Flags2, unitFlags2);
SetUInt32Value(UnitFields.Flags3, unitFlags3);
SetUInt32Value(ObjectFields.DynamicFlags, dynamicFlags);
SetNpcFlags((NPCFlags)(npcFlags & 0xFFFFFFFF));
SetNpcFlags2((NPCFlags2)(npcFlags >> 32));
RemoveFlag(UnitFields.Flags, UnitFlags.InCombat);
SetUnitFlags((UnitFlags)unitFlags);
SetUnitFlags2((UnitFlags2)unitFlags2);
SetUnitFlags3((UnitFlags3)unitFlags3);
SetDynamicFlags((UnitDynFlags)dynamicFlags);
RemoveUnitFlag(UnitFlags.InCombat);
SetMeleeDamageSchool((SpellSchools)cInfo.DmgSchool);
}
@@ -1633,7 +1633,7 @@ namespace Game.Entities
{
SetDisplayId(display.CreatureDisplayID, display.DisplayScale);
SetNativeDisplayId(display.CreatureDisplayID, display.DisplayScale);
SetByteValue(UnitFields.Bytes0, 3, (byte)minfo.gender);
SetGender((Gender)minfo.gender);
}
GetMotionMaster().InitDefault();
@@ -1805,9 +1805,9 @@ namespace Game.Entities
float dist = GetDistance(victim);
if (dist > range || dist < minrange)
continue;
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && HasFlag(UnitFields.Flags, UnitFlags.Silenced))
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && HasUnitFlag(UnitFlags.Silenced))
continue;
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && HasFlag(UnitFields.Flags, UnitFlags.Pacified))
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && HasUnitFlag(UnitFlags.Pacified))
continue;
return spellInfo;
}
@@ -1854,9 +1854,9 @@ namespace Game.Entities
if (dist > range || dist < minrange)
continue;
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && HasFlag(UnitFields.Flags, UnitFlags.Silenced))
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && HasUnitFlag(UnitFlags.Silenced))
continue;
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && HasFlag(UnitFields.Flags, UnitFlags.Pacified))
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && HasUnitFlag(UnitFlags.Pacified))
continue;
return spellInfo;
}
@@ -1969,7 +1969,7 @@ namespace Game.Entities
if (IsCivilian())
return false;
if (HasFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.ImmuneToPc))
if (HasUnitFlag(UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.ImmuneToPc))
return false;
// skip fighting creature
@@ -1983,7 +1983,7 @@ namespace Game.Entities
// only from same creature faction
if (checkfaction)
{
if (getFaction() != u.getFaction())
if (GetFaction() != u.GetFaction())
return false;
}
else
@@ -2009,7 +2009,7 @@ namespace Game.Entities
if (target.HasUnitState(UnitState.Died))
{
// guards can detect fake death
if (IsGuard() && target.HasFlag(UnitFields.Flags2, UnitFlags2.FeignDeath))
if (IsGuard() && target.HasUnitFlag2(UnitFlags2.FeignDeath))
return true;
else
return false;
@@ -2099,18 +2099,16 @@ namespace Game.Entities
// 2 StandFlags
// 3 StandMiscFlags
SetByteValue(UnitFields.Bytes1, UnitBytes1Offsets.StandState, (byte)(cainfo.bytes1 & 0xFF));
//SetByteValue(UnitFields.Bytes1, UnitBytes1Offsets.PetTalent, (byte)((cainfo.bytes1 >> 8) & 0xFF));
SetByteValue(UnitFields.Bytes1, UnitBytes1Offsets.PetTalents, 0);
SetByteValue(UnitFields.Bytes1, UnitBytes1Offsets.VisFlag, (byte)((cainfo.bytes1 >> 16) & 0xFF));
SetByteValue(UnitFields.Bytes1, UnitBytes1Offsets.AnimTier, (byte)((cainfo.bytes1 >> 24) & 0xFF));
SetStandState((UnitStandStateType)(cainfo.bytes1 & 0xFF));
SetVisFlags((UnitVisFlags)((cainfo.bytes1 >> 16) & 0xFF));
SetAnimTier((UnitBytes1Flags)((cainfo.bytes1 >> 24) & 0xFF), false);
//! Suspected correlation between UNIT_FIELD_BYTES_1, offset 3, value 0x2:
//! If no inhabittype_fly (if no MovementFlag_DisableGravity or MovementFlag_CanFly flag found in sniffs)
//! Check using InhabitType as movement flags are assigned dynamically
//! basing on whether the creature is in air or not
//! Set MovementFlag_Hover. Otherwise do nothing.
if (Convert.ToBoolean(GetByteValue(UnitFields.Bytes1, UnitBytes1Offsets.AnimTier) & (byte)UnitBytes1Flags.Hover) && !Convert.ToBoolean(GetCreatureTemplate().InhabitType & InhabitType.Air))
if (Convert.ToBoolean(m_unitData.AnimTier & (byte)UnitBytes1Flags.Hover) && !Convert.ToBoolean(GetCreatureTemplate().InhabitType & InhabitType.Air))
AddUnitMovementFlag(MovementFlag.Hover);
}
@@ -2121,16 +2119,14 @@ namespace Game.Entities
// 2 PetFlags Pet only, so always 0 for default creature
// 3 ShapeshiftForm Must be determined/set by shapeshift spell/aura
SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.SheathState, (byte)(cainfo.bytes2 & 0xFF));
//SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, uint8((cainfo->bytes2 >> 8) & 0xFF));
//SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PetFlags, uint8((cainfo->bytes2 >> 16) & 0xFF));
SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PetFlags, 0);
//SetByteValue(UnitFields.Bytes2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM, uint8((cainfo->bytes2 >> 24) & 0xFF));
SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.ShapeshiftForm, 0);
SetSheath((SheathState)(cainfo.bytes2 & 0xFF));
SetPvpFlags(UnitPVPStateFlags.None);
SetPetFlags(UnitPetFlags.None);
SetShapeshiftForm(ShapeShiftForm.None);
}
if (cainfo.emote != 0)
SetUInt32Value(UnitFields.NpcEmotestate, cainfo.emote);
SetEmoteState((Emote)cainfo.emote);
SetAIAnimKitId(cainfo.aiAnimKit);
SetMovementAnimKitId(cainfo.movementAnimKit);
@@ -2289,7 +2285,7 @@ namespace Game.Entities
{
if (loot.loot_type != LootType.Skinning && !IsPet() && GetCreatureTemplate().SkinLootId != 0 && hasLootRecipient())
if (LootStorage.Skinning.HaveLootFor(GetCreatureTemplate().SkinLootId))
SetFlag(UnitFields.Flags, UnitFlags.Skinnable);
AddUnitFlag(UnitFlags.Skinnable);
long now = Time.UnixTime;
// Do not reset corpse remove time if corpse is already removed
@@ -2380,12 +2376,12 @@ namespace Game.Entities
// between UNIT_FIELD_SCALING_LEVEL_MIN and UNIT_FIELD_SCALING_LEVEL_MAX
if (HasScalableLevels())
{
int targetLevelWithDelta = ((int)unitTarget.getLevel() + GetInt32Value(UnitFields.ScalingLevelDelta));
int targetLevelWithDelta = (int)unitTarget.getLevel() + m_unitData.ScalingLevelDelta;
if (target.IsPlayer())
targetLevelWithDelta += target.GetInt32Value(ActivePlayerFields.ScalingPlayerLevelDelta);
targetLevelWithDelta += target.ToPlayer().m_activePlayerData.ScalingPlayerLevelDelta;
return (uint)MathFunctions.RoundToInterval(ref targetLevelWithDelta, GetInt32Value(UnitFields.ScalingLevelMin), GetInt32Value(UnitFields.ScalingLevelMax));
return (uint)MathFunctions.RoundToInterval(ref targetLevelWithDelta, m_unitData.ScalingLevelMin, m_unitData.ScalingLevelMax);
}
}
@@ -2409,7 +2405,7 @@ namespace Game.Entities
if (creatureData != null)
return creatureData.ScriptId;
return Global.ObjectMgr.GetCreatureTemplate(GetEntry()).ScriptID;
return Global.ObjectMgr.GetCreatureTemplate(GetEntry()) != null ? Global.ObjectMgr.GetCreatureTemplate(GetEntry()).ScriptID : 0;
}
public VendorItemData GetVendorItems()
@@ -2668,8 +2664,8 @@ namespace Game.Entities
CreatureModelInfo minfo = Global.ObjectMgr.GetCreatureModelInfo(GetDisplayId());
if (minfo != null)
{
SetFloatValue(UnitFields.BoundingRadius, (IsPet() ? 1.0f : minfo.BoundingRadius) * scale);
SetFloatValue(UnitFields.CombatReach, (IsPet() ? SharedConst.DefaultCombatReach : minfo.CombatReach) * scale);
SetBoundingRadius((IsPet() ? 1.0f : minfo.BoundingRadius) * scale);
SetCombatReach((IsPet() ? SharedConst.DefaultCombatReach : minfo.CombatReach) * scale);
}
}
@@ -2680,8 +2676,8 @@ namespace Game.Entities
CreatureModelInfo minfo = Global.ObjectMgr.GetCreatureModelInfo(modelId);
if (minfo != null)
{
SetFloatValue(UnitFields.BoundingRadius, (IsPet() ? 1.0f : minfo.BoundingRadius) * GetObjectScale());
SetFloatValue(UnitFields.CombatReach, (IsPet() ? SharedConst.DefaultCombatReach : minfo.CombatReach) * GetObjectScale());
SetBoundingRadius((IsPet() ? 1.0f : minfo.BoundingRadius) * GetObjectScale());
SetCombatReach((IsPet() ? SharedConst.DefaultCombatReach : minfo.CombatReach) * GetObjectScale());
}
}
@@ -2697,7 +2693,7 @@ namespace Game.Entities
if (IsFocusing(null, true))
m_suppressedTarget = guid;
else
SetGuidValue(UnitFields.Target, guid);
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Target), guid);
}
public void FocusTarget(Spell focusSpell, WorldObject target)
@@ -2716,7 +2712,7 @@ namespace Game.Entities
// store pre-cast values for target and orientation (used to later restore)
if (!IsFocusing(null, true))
{ // only overwrite these fields if we aren't transitioning from one spell focus to another
m_suppressedTarget = GetGuidValue(UnitFields.Target);
m_suppressedTarget = GetTarget();
m_suppressedOrientation = GetOrientation();
}
@@ -2724,9 +2720,9 @@ namespace Game.Entities
// set target, then force send update packet to players if it changed to provide appropriate facing
ObjectGuid newTarget = target ? target.GetGUID() : ObjectGuid.Empty;
if (GetGuidValue(UnitFields.Target) != newTarget)
if (GetTarget() != newTarget)
{
SetGuidValue(UnitFields.Target, newTarget);
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Target), newTarget);
// here we determine if the (relatively expensive) forced update is worth it, or whether we can afford to wait until the scheduled update tick
// only require instant update for spells that actually have a visual
@@ -2794,7 +2790,7 @@ namespace Game.Entities
if (IsPet())// player pets do not use delay system
{
SetGuidValue(UnitFields.Target, m_suppressedTarget);
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Target), m_suppressedTarget);
if (!m_suppressedTarget.IsEmpty())
{
WorldObject objTarget = Global.ObjAccessor.GetWorldObject(this, m_suppressedTarget);
@@ -42,7 +42,7 @@ namespace Game.Entities
public uint RequiredExpansion;
public uint VignetteID; // @todo Read Vignette.db2
public uint Faction;
public NPCFlags Npcflag;
public ulong Npcflag;
public float SpeedWalk;
public float SpeedRun;
public float Scale;
+48 -13
View File
@@ -17,6 +17,7 @@
using Framework.Constants;
using Game.Spells;
using Game.Network;
namespace Game.Entities
{
@@ -29,7 +30,7 @@ namespace Game.Entities
m_updateFlag.Stationary = true;
valuesCount = (int)DynamicObjectFields.End;
m_dynamicObjectData = new DynamicObjectData();
}
public override void Dispose()
@@ -77,7 +78,6 @@ namespace Game.Entities
public bool CreateDynamicObject(ulong guidlow, Unit caster, SpellInfo spell, Position pos, float radius, DynamicObjectType type, uint spellXSpellVisualId)
{
_spellXSpellVisualId = spellXSpellVisualId;
SetMap(caster.GetMap());
Relocate(pos);
if (!IsPositionValid())
@@ -91,13 +91,13 @@ namespace Game.Entities
SetEntry(spell.Id);
SetObjectScale(1f);
SetGuidValue(DynamicObjectFields.Caster, caster.GetGUID());
SetUInt32Value(DynamicObjectFields.Type, (uint)type);
SetUInt32Value(DynamicObjectFields.SpellXSpellVisualId, spellXSpellVisualId);
SetUInt32Value(DynamicObjectFields.SpellId, spell.Id);
SetFloatValue(DynamicObjectFields.Radius, radius);
SetUInt32Value(DynamicObjectFields.CastTime, Time.GetMSTime());
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.Caster), caster.GetGUID());
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.Type), (byte)type);
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.SpellXSpellVisualID), spellXSpellVisualId);
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.SpellID), spell.Id);
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.Radius), radius);
SetUpdateFieldValue(m_values.ModifyValue(m_dynamicObjectData).ModifyValue(m_dynamicObjectData.CastTime), Time.GetMSTime());
if (IsWorldObject())
setActive(true); //must before add to map to be put in world container
@@ -242,16 +242,51 @@ namespace Game.Entities
return Global.SpellMgr.GetSpellInfo(GetSpellId());
}
public Unit GetCaster() { return _caster; }
public uint GetSpellId() { return GetUInt32Value(DynamicObjectFields.SpellId); }
public ObjectGuid GetCasterGUID() { return GetGuidValue(DynamicObjectFields.Caster); }
public float GetRadius() { return GetFloatValue(DynamicObjectFields.Radius); }
public override void BuildValuesCreate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt8((byte)flags);
m_objectData.WriteCreate(buffer, flags, this, target);
m_dynamicObjectData.WriteCreate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void BuildValuesUpdate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt32(m_values.GetChangedObjectTypeMask());
if (m_values.HasChanged(TypeId.Object))
m_objectData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.DynamicObject))
m_dynamicObjectData.WriteUpdate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void ClearUpdateMask(bool remove)
{
m_values.ClearChangesMask(m_dynamicObjectData);
base.ClearUpdateMask(remove);
}
public Unit GetCaster() { return _caster; }
public uint GetSpellId() { return m_dynamicObjectData.SpellID; }
public ObjectGuid GetCasterGUID() { return m_dynamicObjectData.Caster; }
public float GetRadius() { return m_dynamicObjectData.Radius; }
DynamicObjectData m_dynamicObjectData;
Aura _aura;
Aura _removedAura;
Unit _caster;
int _duration; // for non-aura dynobjects
uint _spellXSpellVisualId;
bool _isViewpoint;
}
+105 -155
View File
@@ -31,6 +31,7 @@ using Game.Spells;
using System;
using System.Collections.Generic;
using System.Linq;
using Game.Network;
namespace Game.Entities
{
@@ -44,13 +45,14 @@ namespace Game.Entities
m_updateFlag.Stationary = true;
m_updateFlag.Rotation = true;
valuesCount = (int)GameObjectFields.End;
m_respawnDelayTime = 300;
m_lootState = LootState.NotReady;
m_spawnedByDefault = true;
ResetLootMode(); // restore default loot mode
m_stationaryPosition = new Position();
m_gameObjectData = new GameObjectFieldData();
}
public override void Dispose()
@@ -248,8 +250,8 @@ namespace Game.Entities
if (m_goTemplateAddon != null)
{
SetUInt32Value(GameObjectFields.Faction, m_goTemplateAddon.faction);
SetUInt32Value(GameObjectFields.Flags, m_goTemplateAddon.flags);
SetFaction(m_goTemplateAddon.faction);
SetFlags((GameObjectFlags)m_goTemplateAddon.flags);
if (m_goTemplateAddon.WorldEffectID != 0)
{
@@ -267,7 +269,7 @@ namespace Game.Entities
m_model = CreateModel();
if (m_model != null && m_model.isMapObject())
SetFlag(GameObjectFields.Flags, GameObjectFlags.MapObject);
AddFlag(GameObjectFlags.MapObject);
// GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
SetGoType(goInfo.type);
@@ -275,7 +277,7 @@ namespace Game.Entities
SetGoState(goState);
SetGoArtKit((byte)artKit);
SetUInt32Value(GameObjectFields.StateAnimId, (uint)CliDB.AnimationDataStorage.Count);
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.SpawnTrackingStateAnimID), (uint)CliDB.AnimationDataStorage.Count);
switch (goInfo.type)
{
@@ -287,7 +289,8 @@ namespace Game.Entities
m_goValue.Building.Health = 20000;//goinfo.DestructibleBuilding.intactNumHits + goinfo.DestructibleBuilding.damagedNumHits;
m_goValue.Building.MaxHealth = m_goValue.Building.Health;
SetGoAnimProgress(255);
SetUInt32Value(GameObjectFields.ParentRotation, goInfo.DestructibleBuilding.DestructibleModelRec);
// yes, even after the updatefield rewrite this garbage hack is still in client
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.ParentRotation), new Quaternion(goInfo.DestructibleBuilding.DestructibleModelRec, 0f, 0f, 0f));
break;
case GameObjectTypes.Transport:
m_goValue.Transport.AnimationInfo = Global.TransportMgr.GetTransportAnimInfo(goInfo.entry);
@@ -324,7 +327,7 @@ namespace Game.Entities
SetGoAnimProgress(animProgress);
break;
case GameObjectTypes.FishingNode:
SetUInt32Value(GameObjectFields.Level, 1);
SetLevel(1);
SetGoAnimProgress(255);
break;
case GameObjectTypes.Trap:
@@ -341,10 +344,11 @@ namespace Game.Entities
}
break;
case GameObjectTypes.PhaseableMo:
SetByteValue(GameObjectFields.Flags, 1, (byte)(m_goInfo.PhaseableMO.AreaNameSet & 0xF));
RemoveFlag((GameObjectFlags)0xF00);
AddFlag((GameObjectFlags)((m_goInfo.PhaseableMO.AreaNameSet & 0xF) << 8));
break;
case GameObjectTypes.CapturePoint:
SetUInt32Value(GameObjectFields.SpellVisualId, m_goInfo.CapturePoint.SpellVisual1);
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.SpellVisualID), m_goInfo.CapturePoint.SpellVisual1);
break;
default:
SetGoAnimProgress(animProgress);
@@ -438,15 +442,15 @@ namespace Game.Entities
m_goValue.Transport.PathProgress += diff;
/* TODO: Fix movement in unloaded grid - currently GO will just disappear
public uint timer = m_goValue.Transport.PathProgress % GetTransportPeriod();
TransportAnimationEntry const* node = m_goValue.Transport.AnimationInfo->GetAnimNode(timer);
if (node && m_goValue.Transport.CurrentSeg != node->TimeSeg)
TransportAnimationEntry const* node = m_goValue.Transport.AnimationInfo.GetAnimNode(timer);
if (node && m_goValue.Transport.CurrentSeg != node.TimeSeg)
{
m_goValue.Transport.CurrentSeg = node->TimeSeg;
m_goValue.Transport.CurrentSeg = node.TimeSeg;
G3D.Quat rotation = m_goValue.Transport.AnimationInfo->GetAnimRotation(timer);
G3D.Quat rotation = m_goValue.Transport.AnimationInfo.GetAnimRotation(timer);
G3D.Vector3 pos = rotation.toRotationMatrix()
G3D.Matrix3.fromEulerAnglesZYX(GetOrientation(), 0.0f, 0.0f)
G3D.Vector3(node->X, node->Y, node->Z);
G3D.Vector3(node.X, node.Y, node.Z);
pos += G3D.Vector3(GetStationaryX(), GetStationaryY(), GetStationaryZ());
@@ -454,7 +458,7 @@ namespace Game.Entities
TC_LOG_DEBUG("misc", "Src: {0} Dest: {1}", src.toString().c_str(), pos.toString().c_str());
GetMap()->GameObjectRelocation(this, pos.x, pos.y, pos.z, GetOrientation());
GetMap().GameObjectRelocation(this, pos.x, pos.y, pos.z, GetOrientation());
}
*/
if (!m_goValue.Transport.StopFrames.Empty())
@@ -464,8 +468,9 @@ namespace Game.Entities
uint visualStateAfter = (m_goValue.Transport.StateUpdateTimer / 20000) & 1;
if (visualStateBefore != visualStateAfter)
{
ForceValuesUpdateAtIndex(GameObjectFields.Level);
ForceValuesUpdateAtIndex(GameObjectFields.Bytes1);
m_gameObjectData.ModifyValue(m_gameObjectData.Level);
m_gameObjectData.ModifyValue(m_gameObjectData.State);
ForceUpdateFieldChange();
}
}
}
@@ -480,7 +485,7 @@ namespace Game.Entities
if (caster != null && caster.IsTypeId(TypeId.Player))
{
SetGoState(GameObjectState.Active);
SetUInt32Value(GameObjectFields.Flags, (uint)GameObjectFlags.NoDespawn);
SetFlags(GameObjectFlags.NoDespawn);
UpdateData udata = new UpdateData(caster.GetMapId());
UpdateObject packet;
@@ -650,7 +655,7 @@ namespace Game.Entities
case GameObjectTypes.Goober:
if (m_cooldownTime < Time.UnixTime)
{
RemoveFlag(GameObjectFields.Flags, GameObjectFlags.InUse);
RemoveFlag(GameObjectFlags.InUse);
SetLootState(LootState.JustDeactivated);
m_cooldownTime = 0;
@@ -770,7 +775,7 @@ namespace Game.Entities
//reset flags
GameObjectTemplateAddon addon = GetTemplateAddon();
if (addon != null)
SetUInt32Value(GameObjectFields.Flags, addon.flags);
SetFlags((GameObjectFlags)addon.flags);
}
if (m_respawnDelayTime == 0)
@@ -823,7 +828,7 @@ namespace Game.Entities
SetGoState(GameObjectState.Ready);
GameObjectTemplateAddon addon = GetTemplateAddon();
if (addon != null)
SetUInt32Value(GameObjectFields.Flags, addon.flags);
SetFlags((GameObjectFlags)addon.flags);
uint poolid = GetSpawnId() != 0 ? Global.PoolMgr.IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
if (poolid != 0)
@@ -918,7 +923,7 @@ namespace Game.Entities
data.animprogress = GetGoAnimProgress();
data.go_state = GetGoState();
data.spawnDifficulties = spawnDifficulties;
data.artKit = GetGoArtKit();
data.artKit = (byte)GetGoArtKit();
Global.ObjectMgr.NewGOData(m_spawnId, data);
data.phaseId = GetDBPhase() > 0 ? (uint)GetDBPhase() : data.phaseId;
@@ -980,7 +985,7 @@ namespace Game.Entities
if (!GetGoInfo().GetDespawnPossibility() && !GetGoInfo().IsDespawnAtAction())
{
SetFlag(GameObjectFields.Flags, GameObjectFlags.NoDespawn);
AddFlag(GameObjectFlags.NoDespawn);
m_respawnDelayTime = 0;
m_respawnTime = 0;
}
@@ -1104,7 +1109,7 @@ namespace Game.Entities
if (GetGoType() == GameObjectTypes.SpellFocus && GetGoInfo().SpellFocus.serverOnly == 1)
return true;
if (GetUInt32Value(GameObjectFields.DisplayId) == 0)
if (GetDisplayId() == 0)
return true;
return false;
@@ -1157,7 +1162,7 @@ namespace Game.Entities
}
}
bool ActivateToQuest(Player target)
public bool ActivateToQuest(Player target)
{
if (target.HasQuestForGO((int)GetEntry()))
return true;
@@ -1231,7 +1236,7 @@ namespace Game.Entities
if (m_lootState == LootState.Ready || m_lootState == LootState.JustDeactivated)
return;
RemoveFlag(GameObjectFields.Flags, GameObjectFlags.InUse);
RemoveFlag(GameObjectFlags.InUse);
SetGoState(m_prevGoState);
SetLootState(LootState.JustDeactivated);
@@ -1254,7 +1259,7 @@ namespace Game.Entities
public void SetGoArtKit(byte kit)
{
SetByteValue(GameObjectFields.Bytes1, 2, kit);
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.ArtKit), kit);
GameObjectData data = Global.ObjectMgr.GetGOData(m_spawnId);
if (data != null)
data.artKit = kit;
@@ -1278,9 +1283,9 @@ namespace Game.Entities
void SwitchDoorOrButton(bool activate, bool alternative = false)
{
if (activate)
SetFlag(GameObjectFields.Flags, GameObjectFlags.InUse);
AddFlag(GameObjectFlags.InUse);
else
RemoveFlag(GameObjectFields.Flags, GameObjectFlags.InUse);
RemoveFlag(GameObjectFlags.InUse);
if (GetGoState() == GameObjectState.Ready) //if closed . open
SetGoState(alternative ? GameObjectState.ActiveAlternative : GameObjectState.Active);
@@ -1423,7 +1428,7 @@ namespace Game.Entities
{
guid = player.GetGUID(); //this slot in now used by player
player.TeleportTo(GetMapId(), x_lowest, y_lowest, GetPositionZ(), GetOrientation(), (TeleportToOptions.NotLeaveTransport | TeleportToOptions.NotLeaveCombat | TeleportToOptions.NotUnSummonPet));
player.SetStandState(UnitStandStateType.SitLowChair + (int)info.Chair.chairheight);
player.SetStandState(UnitStandStateType.SitLowChair + (byte)info.Chair.chairheight);
return;
}
}
@@ -1487,7 +1492,7 @@ namespace Game.Entities
if (trapEntry != 0)
TriggeringLinkedGameObject(trapEntry, user);
SetFlag(GameObjectFields.Flags, GameObjectFlags.InUse);
AddFlag(GameObjectFlags.InUse);
SetLootState(LootState.Activated, user);
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
@@ -1864,7 +1869,7 @@ namespace Game.Entities
// fallback, will always work
player.TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), (TeleportToOptions.NotLeaveTransport | TeleportToOptions.NotLeaveCombat | TeleportToOptions.NotUnSummonPet));
player.SetStandState((UnitStandStateType)(UnitStandStateType.SitLowChair + (int)info.BarberChair.chairheight), info.BarberChair.SitAnimKit);
player.SetStandState((UnitStandStateType.SitLowChair + (byte)info.BarberChair.chairheight), info.BarberChair.SitAnimKit);
return;
}
case GameObjectTypes.ArtifactForge:
@@ -1972,16 +1977,16 @@ namespace Game.Entities
return;
// remove immunity flags, to allow spell to target anything
trigger.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc | UnitFlags.ImmuneToPc);
trigger.RemoveUnitFlag(UnitFlags.ImmuneToNpc | UnitFlags.ImmuneToPc);
Unit owner = GetOwner();
if (owner)
{
trigger.SetFaction(owner.getFaction());
if (owner.HasFlag(UnitFields.Flags, UnitFlags.PvpAttackable))
trigger.SetFlag(UnitFields.Flags, UnitFlags.PvpAttackable);
trigger.SetFaction(owner.GetFaction());
if (owner.HasUnitFlag(UnitFlags.PvpAttackable))
trigger.AddUnitFlag(UnitFlags.PvpAttackable);
// copy pvp state flags from owner
trigger.SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, owner.GetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag));
trigger.SetPvpFlags(owner.GetPvpFlags());
// needed for GO casts for proper target validation checks
trigger.SetOwnerGUID(owner.GetGUID());
trigger.CastSpell(target != null ? target : trigger, spellInfo, triggered, null, null, owner.GetGUID());
@@ -2097,10 +2102,7 @@ namespace Game.Entities
public void SetParentRotation(Quaternion rotation)
{
SetFloatValue(GameObjectFields.ParentRotation + 0, rotation.X);
SetFloatValue(GameObjectFields.ParentRotation + 1, rotation.Y);
SetFloatValue(GameObjectFields.ParentRotation + 2, rotation.Z);
SetFloatValue(GameObjectFields.ParentRotation + 3, rotation.W);
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.ParentRotation), rotation);
}
public void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot)
@@ -2165,7 +2167,7 @@ namespace Game.Entities
switch (state)
{
case GameObjectDestructibleState.Intact:
RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Damaged | GameObjectFlags.Destroyed);
RemoveFlag(GameObjectFlags.Damaged | GameObjectFlags.Destroyed);
SetDisplayId(m_goInfo.displayId);
if (setHealth)
{
@@ -2179,8 +2181,8 @@ namespace Game.Entities
EventInform(m_goInfo.DestructibleBuilding.DamagedEvent, eventInvoker);
Global.ScriptMgr.OnGameObjectDamaged(this, eventInvoker);
RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Destroyed);
SetFlag(GameObjectFields.Flags, GameObjectFlags.Damaged);
RemoveFlag(GameObjectFlags.Destroyed);
AddFlag(GameObjectFlags.Damaged);
uint modelId = m_goInfo.displayId;
DestructibleModelDataRecord modelData = CliDB.DestructibleModelDataStorage.LookupByKey(m_goInfo.DestructibleBuilding.DestructibleModelRec);
@@ -2211,8 +2213,8 @@ namespace Game.Entities
bg.DestroyGate(eventInvoker, this);
}
RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Damaged);
SetFlag(GameObjectFields.Flags, GameObjectFlags.Destroyed);
RemoveFlag(GameObjectFlags.Damaged);
AddFlag(GameObjectFlags.Destroyed);
uint modelId = m_goInfo.displayId;
DestructibleModelDataRecord modelData = CliDB.DestructibleModelDataStorage.LookupByKey(m_goInfo.DestructibleBuilding.DestructibleModelRec);
@@ -2232,7 +2234,7 @@ namespace Game.Entities
case GameObjectDestructibleState.Rebuilding:
{
EventInform(m_goInfo.DestructibleBuilding.RebuildingEvent, eventInvoker);
RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Damaged | GameObjectFlags.Destroyed);
RemoveFlag(GameObjectFlags.Damaged | GameObjectFlags.Destroyed);
uint modelId = m_goInfo.displayId;
DestructibleModelDataRecord modelData = CliDB.DestructibleModelDataStorage.LookupByKey(m_goInfo.DestructibleBuilding.DestructibleModelRec);
@@ -2277,7 +2279,7 @@ namespace Game.Entities
public void SetGoState(GameObjectState state)
{
SetByteValue(GameObjectFields.Bytes1, 0, (byte)state);
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.State), (sbyte)state);
Global.ScriptMgr.OnGameObjectStateChanged(this, state);
if (m_model != null && !IsTransport())
{
@@ -2327,7 +2329,7 @@ namespace Game.Entities
public void SetDisplayId(uint displayid)
{
SetUInt32Value(GameObjectFields.DisplayId, displayid);
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.DisplayID), displayid);
UpdateModel();
}
@@ -2357,7 +2359,8 @@ namespace Game.Entities
case GameObjectTypes.GarrisonBuilding:
case GameObjectTypes.GarrisonPlot:
case GameObjectTypes.PhaseableMo:
return (byte)(GetByteValue(GameObjectFields.Flags, 1) & 0xF);
var flags = (GameObjectFlags)(uint)m_gameObjectData.Flags;
return (byte)(((int)flags >> 8) & 0xF);
default:
break;
}
@@ -2386,7 +2389,10 @@ namespace Game.Entities
if (m_model != null)
GetMap().InsertGameObjectModel(m_model);
ApplyModFlag(GameObjectFields.Flags, GameObjectFlags.MapObject, m_model != null && m_model.isMapObject());
if (m_model != null && m_model.isMapObject())
AddFlag(GameObjectFlags.MapObject);
else
RemoveFlag(GameObjectFlags.MapObject);
}
Player GetLootRecipient()
@@ -2434,7 +2440,7 @@ namespace Game.Entities
m_lootRecipientGroup = unitGroup.GetGUID();
}
bool IsLootAllowedFor(Player player)
public bool IsLootAllowedFor(Player player)
{
if (m_lootRecipient.IsEmpty() && m_lootRecipientGroup.IsEmpty())
return true;
@@ -2455,103 +2461,39 @@ namespace Game.Entities
return ObjectAccessor.GetGameObject(this, m_linkedTrap);
}
public override void BuildValuesUpdate(UpdateType updateType, ByteBuffer data, Player target)
public override void BuildValuesCreate(WorldPacket data, Player target)
{
if (!target)
return;
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
bool isStoppableTransport = GetGoType() == GameObjectTypes.Transport && !m_goValue.Transport.StopFrames.Empty();
bool forcedFlags = GetGoType() == GameObjectTypes.Chest && GetGoInfo().Chest.usegrouplootrules != 0 && HasLootRecipient();
bool targetIsGM = target.IsGameMaster();
buffer.WriteUInt8((byte)flags);
m_objectData.WriteCreate(buffer, flags, this, target);
m_gameObjectData.WriteCreate(buffer, flags, this, target);
ByteBuffer fieldBuffer = new ByteBuffer();
UpdateMask updateMask = new UpdateMask(valuesCount);
uint[] flags = UpdateFieldFlags.GameObjectUpdateFieldFlags;
uint visibleFlag = UpdateFieldFlags.Public;
if (GetOwnerGUID() == target.GetGUID())
visibleFlag |= UpdateFieldFlags.Owner;
for (int index = 0; index < valuesCount; ++index)
{
if (_fieldNotifyFlags.HasAnyFlag(flags[index]) ||
((updateType == UpdateType.Values ? _changesMask.Get(index) : updateValues[index].UnsignedValue != 0) && flags[index].HasAnyFlag(visibleFlag)) ||
(index == (int)GameObjectFields.Flags && forcedFlags))
{
updateMask.SetBit(index);
if (index == (int)ObjectFields.DynamicFlags)
{
GameObjectDynamicLowFlags dynFlags = 0;
short pathProgress = -1;
switch (GetGoType())
{
case GameObjectTypes.QuestGiver:
if (ActivateToQuest(target))
dynFlags |= GameObjectDynamicLowFlags.Activate;
break;
case GameObjectTypes.Chest:
case GameObjectTypes.Goober:
if (ActivateToQuest(target) || targetIsGM)
dynFlags |= GameObjectDynamicLowFlags.Activate | GameObjectDynamicLowFlags.Sparkle;
break;
case GameObjectTypes.Generic:
if (ActivateToQuest(target))
dynFlags |= GameObjectDynamicLowFlags.Sparkle;
break;
case GameObjectTypes.Transport:
case GameObjectTypes.MapObjTransport:
uint transportPeriod = GetTransportPeriod();
if (transportPeriod != 0)
{
float timer = (float)m_goValue.Transport.PathProgress % transportPeriod;
pathProgress = (short)(timer / transportPeriod * 65535.0f);
}
break;
default:
break;
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
fieldBuffer.WriteUInt16(dynFlags);
fieldBuffer.WriteInt16(pathProgress);
}
else if (index == (int)GameObjectFields.Flags)
public override void BuildValuesUpdate(WorldPacket data, Player target)
{
GameObjectFlags _flags = (GameObjectFlags)GetUInt32Value(GameObjectFields.Flags);
if (GetGoType() == GameObjectTypes.Chest)
if (GetGoInfo().Chest.usegrouplootrules != 0 && !IsLootAllowedFor(target))
_flags |= GameObjectFlags.Locked | GameObjectFlags.NotSelectable;
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
fieldBuffer.WriteUInt32(_flags);
}
else if (index == (int)GameObjectFields.Level)
{
if (isStoppableTransport)
fieldBuffer.WriteUInt32(m_goValue.Transport.PathProgress);
else
fieldBuffer.WriteUInt32(updateValues[index].UnsignedValue);
}
else if (index == (int)GameObjectFields.Bytes1)
{
uint bytes1 = GetUInt32Value(index);
if (isStoppableTransport && GetGoState() == GameObjectState.TransportActive)
{
if (Convert.ToBoolean((m_goValue.Transport.StateUpdateTimer / 20000) & 1))
{
bytes1 &= 0xFFFFFF00;
bytes1 |= (int)GameObjectState.TransportStopped;
}
buffer.WriteUInt32(m_values.GetChangedObjectTypeMask());
if (m_values.HasChanged(TypeId.Object))
m_objectData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.GameObject))
m_gameObjectData.WriteUpdate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
fieldBuffer.WriteUInt32(bytes1);
}
else
fieldBuffer.WriteUInt32(updateValues[index].UnsignedValue);
}
}
updateMask.AppendToPacket(data);
data.WriteBytes(fieldBuffer);
public override void ClearUpdateMask(bool remove)
{
m_values.ClearChangesMask(m_gameObjectData);
base.ClearUpdateMask(remove);
}
public void GetRespawnPosition(out float x, out float y, out float z, out float ori)
@@ -2632,7 +2574,8 @@ namespace Game.Entities
public GameObjectTemplate GetGoInfo() { return m_goInfo; }
public GameObjectTemplateAddon GetTemplateAddon() { return m_goTemplateAddon; }
GameObjectData GetGoData() { return m_goData; }
public GameObjectData GetGoData() { return m_goData; }
public GameObjectValue GetGoValue() { return m_goValue; }
public ulong GetSpawnId() { return m_spawnId; }
@@ -2651,9 +2594,9 @@ namespace Game.Entities
Cypher.Assert(false);
}
m_spawnedByDefault = false; // all object with owner is despawned after delay
SetGuidValue(GameObjectFields.CreatedBy, owner);
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.CreatedBy), owner);
}
public ObjectGuid GetOwnerGUID() { return GetGuidValue(GameObjectFields.CreatedBy); }
public ObjectGuid GetOwnerGUID() { return m_gameObjectData.CreatedBy; }
public void SetSpellId(uint id)
{
@@ -2688,12 +2631,18 @@ namespace Game.Entities
public void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
public uint GetRespawnDelay() { return m_respawnDelayTime; }
public GameObjectTypes GetGoType() { return (GameObjectTypes)GetByteValue(GameObjectFields.Bytes1, 1); }
public void SetGoType(GameObjectTypes type) { SetByteValue(GameObjectFields.Bytes1, 1, (byte)type); }
public GameObjectState GetGoState() { return (GameObjectState)GetByteValue(GameObjectFields.Bytes1, 0); }
byte GetGoArtKit() { return GetByteValue(GameObjectFields.Bytes1, 2); }
byte GetGoAnimProgress() { return GetByteValue(GameObjectFields.Bytes1, 3); }
public void SetGoAnimProgress(uint animprogress) { SetByteValue(GameObjectFields.Bytes1, 3, (byte)animprogress); }
public bool HasFlag(GameObjectFlags flags) { return (m_gameObjectData.Flags & (uint)flags) != 0; }
public void AddFlag(GameObjectFlags flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.Flags), (uint)flags); }
public void RemoveFlag(GameObjectFlags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.Flags), (uint)flags); }
public void SetFlags(GameObjectFlags flags) { SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.Flags), (uint)flags); }
public void SetLevel(uint level) { SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.Level), level); }
public GameObjectTypes GetGoType() { return (GameObjectTypes)(sbyte)m_gameObjectData.TypeID; }
public void SetGoType(GameObjectTypes type) { SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.TypeID), (sbyte)type); }
public GameObjectState GetGoState() { return (GameObjectState)(sbyte)m_gameObjectData.State; }
uint GetGoArtKit() { return m_gameObjectData.ArtKit; }
byte GetGoAnimProgress() { return m_gameObjectData.PercentHealth; }
public void SetGoAnimProgress(uint animprogress) { SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.PercentHealth), (byte)animprogress); }
public LootState getLootState() { return m_lootState; }
public LootModes GetLootMode() { return m_LootMode; }
@@ -2732,19 +2681,19 @@ namespace Game.Entities
GameObjectDestructibleState GetDestructibleState()
{
if (HasFlag(GameObjectFields.Flags, GameObjectFlags.Destroyed))
if ((m_gameObjectData.Flags & (uint)GameObjectFlags.Destroyed) != 0)
return GameObjectDestructibleState.Destroyed;
if (HasFlag(GameObjectFields.Flags, GameObjectFlags.Damaged))
if ((m_gameObjectData.Flags & (uint)GameObjectFlags.Damaged) != 0)
return GameObjectDestructibleState.Damaged;
return GameObjectDestructibleState.Intact;
}
public GameObjectAI GetAI() { return m_AI; }
public uint GetDisplayId() { return GetUInt32Value(GameObjectFields.DisplayId); }
public uint GetDisplayId() { return m_gameObjectData.DisplayID; }
uint GetFaction() { return GetUInt32Value(GameObjectFields.Faction); }
public void SetFaction(uint faction) { SetUInt32Value(GameObjectFields.Faction, faction); }
public uint GetFaction() { return m_gameObjectData.FactionTemplate; }
public void SetFaction(uint faction) { SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.FactionTemplate), faction); }
public override float GetStationaryX() { return m_stationaryPosition.GetPositionX(); }
public override float GetStationaryY() { return m_stationaryPosition.GetPositionY(); }
@@ -2766,7 +2715,8 @@ namespace Game.Entities
}
#region Fields
public GameObjectValue m_goValue;
protected GameObjectFieldData m_gameObjectData;
protected GameObjectValue m_goValue;
protected GameObjectTemplate m_goInfo;
protected GameObjectTemplateAddon m_goTemplateAddon;
GameObjectData m_goData;
+59 -16
View File
@@ -17,6 +17,7 @@
using Framework.Constants;
using Framework.Database;
using Game.Network;
namespace Game.Entities
{
@@ -27,8 +28,7 @@ namespace Game.Entities
objectTypeMask |= TypeMask.Container;
objectTypeId = TypeId.Container;
valuesCount = (int)ContainerFields.End;
_dynamicValuesCount = (int)ItemDynamicFields.End;
m_containerData = new ContainerData();
}
public override void Dispose()
@@ -86,20 +86,20 @@ namespace Game.Entities
if (owner)
{
SetGuidValue(ItemFields.Owner, owner.GetGUID());
SetGuidValue(ItemFields.Contained, owner.GetGUID());
SetOwnerGUID(owner.GetGUID());
SetContainedIn(owner.GetGUID());
}
SetUInt32Value(ItemFields.MaxDurability, itemProto.MaxDurability);
SetUInt32Value(ItemFields.Durability, itemProto.MaxDurability);
SetUInt32Value(ItemFields.StackCount, 1);
SetUpdateFieldValue(m_values.ModifyValue(m_itemData).ModifyValue(m_itemData.MaxDurability), itemProto.MaxDurability);
SetDurability(itemProto.MaxDurability);
SetCount(1);
// Setting the number of Slots the Container has
SetUInt32Value(ContainerFields.NumSlots, itemProto.GetContainerSlots());
SetBagSize(itemProto.GetContainerSlots());
// Cleaning 20 slots
for (byte i = 0; i < ItemConst.MaxBagSize; ++i)
SetGuidValue(ContainerFields.Slot1 + (i * 4), ObjectGuid.Empty);
SetSlot(i, ObjectGuid.Empty);
m_bagslot = new Item[ItemConst.MaxBagSize];
return true;
@@ -111,11 +111,11 @@ namespace Game.Entities
return false;
ItemTemplate itemProto = GetTemplate(); // checked in Item.LoadFromDB
SetUInt32Value(ContainerFields.NumSlots, itemProto.GetContainerSlots());
SetBagSize(itemProto.GetContainerSlots());
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
for (byte i = 0; i < ItemConst.MaxBagSize; ++i)
{
SetGuidValue(ContainerFields.Slot1 + (i * 4), ObjectGuid.Empty);
SetSlot(i, ObjectGuid.Empty);
m_bagslot[i] = null;
}
return true;
@@ -146,7 +146,7 @@ namespace Game.Entities
m_bagslot[slot].SetContainer(null);
m_bagslot[slot] = null;
SetGuidValue(ContainerFields.Slot1 + (slot * 4), ObjectGuid.Empty);
SetSlot(slot, ObjectGuid.Empty);
}
public void StoreItem(byte slot, Item pItem, bool update)
@@ -154,9 +154,9 @@ namespace Game.Entities
if (pItem != null && pItem.GetGUID() != GetGUID())
{
m_bagslot[slot] = pItem;
SetGuidValue(ContainerFields.Slot1 + (slot * 4), pItem.GetGUID());
pItem.SetGuidValue(ItemFields.Contained, GetGUID());
pItem.SetGuidValue(ItemFields.Owner, GetOwnerGUID());
SetSlot(slot, pItem.GetGUID());
pItem.SetContainedIn(GetGUID());
pItem.SetOwnerGUID(GetOwnerGUID());
pItem.SetContainer(this);
pItem.SetSlot(slot);
}
@@ -171,6 +171,45 @@ namespace Game.Entities
m_bagslot[i].BuildCreateUpdateBlockForPlayer(data, target);
}
public override void BuildValuesCreate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt8((byte)flags);
m_objectData.WriteCreate(buffer, flags, this, target);
m_itemData.WriteCreate(buffer, flags, this, target);
m_containerData.WriteCreate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void BuildValuesUpdate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt32(m_values.GetChangedObjectTypeMask());
if (m_values.HasChanged(TypeId.Object))
m_objectData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.Item))
m_itemData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.Container))
m_containerData.WriteUpdate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void ClearUpdateMask(bool remove)
{
m_values.ClearChangesMask(m_containerData);
base.ClearUpdateMask(remove);
}
public bool IsEmpty()
{
for (var i = 0; i < GetBagSize(); ++i)
@@ -243,13 +282,17 @@ namespace Game.Entities
return null;
}
public uint GetBagSize() { return GetUInt32Value(ContainerFields.NumSlots); }
public uint GetBagSize() { return m_containerData.NumSlots; }
void SetBagSize(uint numSlots) { SetUpdateFieldValue(m_values.ModifyValue(m_containerData).ModifyValue(m_containerData.NumSlots), numSlots); }
void SetSlot(int slot, ObjectGuid guid) { SetUpdateFieldValue(ref m_values.ModifyValue(m_containerData).ModifyValue(m_containerData.Slots, slot), guid); }
public static Item NewItemOrBag(ItemTemplate proto)
{
return (proto.GetInventoryType() == InventoryType.Bag) ? new Bag() : new Item();
}
ContainerData m_containerData;
Item[] m_bagslot = new Item[36];
}
}
File diff suppressed because it is too large Load Diff
+38 -160
View File
@@ -22,148 +22,79 @@ using System.Collections.Generic;
namespace Game.Entities
{
public class ItemEnchantment
public class ItemEnchantmentManager
{
static ItemEnchantment()
public static void LoadItemRandomBonusListTemplates()
{
RandomItemEnch = new EnchantmentStore();
}
uint oldMSTime = Time.GetMSTime();
public static void LoadRandomEnchantmentsTable()
{
// for reload case
RandomItemEnch[ItemRandomEnchantmentType.Property].Clear();
RandomItemEnch[ItemRandomEnchantmentType.Suffix].Clear();
_storage.Clear();
// 0 1 2 3
SQLResult result = DB.World.Query("SELECT entry, type, ench, chance FROM item_enchantment_template");
// 0 1 2
SQLResult result = DB.World.Query("SELECT Id, BonusListID, Chance FROM item_random_bonus_list_template");
if (result.IsEmpty())
{
Log.outError(LogFilter.Player, "Loaded 0 Item Enchantment definitions. DB table `item_enchantment_template` is empty.");
return;
}
uint count = 0;
do
{
uint entry = result.Read<uint>(0);
ItemRandomEnchantmentType type = (ItemRandomEnchantmentType)result.Read<byte>(1);
uint ench = result.Read<uint>(2);
float chance = result.Read<float>(3);
uint id = result.Read<uint>(0);
uint bonusListId = result.Read<uint>(1);
float chance = result.Read<float>(2);
switch (type)
if (Global.DB2Mgr.GetItemBonusList(bonusListId) == null)
{
case ItemRandomEnchantmentType.Property:
if (!CliDB.ItemRandomPropertiesStorage.ContainsKey(ench))
{
Log.outError(LogFilter.Sql, "Property {0} used in `item_enchantment_template` by entry {1} doesn't have exist in ItemRandomProperties.db2", ench, entry);
Log.outError(LogFilter.Sql, $"Bonus list {bonusListId} used in `item_random_bonus_list_template` by id {id} doesn't have exist in ItemBonus.db2");
continue;
}
break;
case ItemRandomEnchantmentType.Suffix:
if (!CliDB.ItemRandomSuffixStorage.ContainsKey(ench))
{
Log.outError(LogFilter.Sql, "Suffix {0} used in `item_enchantment_template` by entry {1} doesn't have exist in ItemRandomSuffix.db2", ench, entry);
continue;
}
break;
case ItemRandomEnchantmentType.BonusList:
if (Global.DB2Mgr.GetItemBonusList(ench) == null)
{
Log.outError(LogFilter.Sql, "Bonus list {0} used in `item_enchantment_template` by entry {1} doesn't have exist in ItemBonus.db2", ench, entry);
continue;
}
break;
default:
Log.outError(LogFilter.Sql, "Invalid random enchantment type specified in `item_enchantment_template` table for `entry` {0} `ench` {1}", entry, ench);
break;
}
if (chance < 0.000001f || chance > 100.0f)
{
Log.outError(LogFilter.Sql, "Random item enchantment for entry {0} type {1} ench {2} has invalid chance {3}", entry, type, ench, chance);
Log.outError(LogFilter.Sql, $"Bonus list {bonusListId} used in `item_random_bonus_list_template` by id {id} has invalid chance {chance}");
continue;
}
switch (type)
{
case ItemRandomEnchantmentType.Property:
RandomItemEnch[ItemRandomEnchantmentType.Property].Add(entry, new EnchStoreItem(type, ench, chance));
break;
case ItemRandomEnchantmentType.Suffix:
case ItemRandomEnchantmentType.BonusList: // random bonus lists use RandomSuffix field in Item-sparse.db2
RandomItemEnch[ItemRandomEnchantmentType.Suffix].Add(entry, new EnchStoreItem(type, ench, chance));
break;
default:
break;
}
if (!_storage.ContainsKey(id))
_storage[id] = new RandomBonusListIds();
RandomBonusListIds ids = _storage[id];
ids.BonusListIDs.Add(bonusListId);
ids.Chances.Add(chance);
++count;
} while (result.NextRow());
Log.outInfo(LogFilter.Player, "Loaded {0} Item Enchantment definitions", count);
Log.outInfo(LogFilter.Player, $"Loaded {count} Random item bonus list definitions in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
}
public static ItemRandomEnchantmentId GetItemEnchantMod(int entry, ItemRandomEnchantmentType type)
{
if (entry == 0)
return ItemRandomEnchantmentId.Empty;
if (entry == -1)
return ItemRandomEnchantmentId.Empty;
var tab = RandomItemEnch[type].LookupByKey(entry);
if (tab == null)
{
Log.outError(LogFilter.Player, "Item RandomProperty / RandomSuffix id #{0} used in `item_template` but it does not have records in `item_enchantment_template` table.", entry);
return ItemRandomEnchantmentId.Empty;
}
var selectedItem = tab.SelectRandomElementByWeight(enchant => enchant.chance);
return new ItemRandomEnchantmentId(selectedItem.type, selectedItem.ench);
}
public static ItemRandomEnchantmentId GenerateItemRandomPropertyId(uint item_id)
public static uint GenerateItemRandomBonusListId(uint item_id)
{
ItemTemplate itemProto = Global.ObjectMgr.GetItemTemplate(item_id);
if (itemProto == null)
return ItemRandomEnchantmentId.Empty;
return 0;
// item must have one from this field values not null if it can have random enchantments
if (itemProto.GetRandomProperty() == 0 && itemProto.GetRandomSuffix() == 0)
return ItemRandomEnchantmentId.Empty;
// item can have not null only one from field values
if (itemProto.GetRandomProperty() != 0 && itemProto.GetRandomSuffix() != 0)
{
Log.outError(LogFilter.Sql, "Item template {0} have RandomProperty == {1} and RandomSuffix == {2}, but must have one from field =0", itemProto.GetId(), itemProto.GetRandomProperty(), itemProto.GetRandomSuffix());
return ItemRandomEnchantmentId.Empty;
}
// RandomProperty case
if (itemProto.GetRandomProperty() != 0)
return GetItemEnchantMod((int)itemProto.GetRandomProperty(), ItemRandomEnchantmentType.Property);
// RandomSuffix case
else
return GetItemEnchantMod((int)itemProto.GetRandomSuffix(), ItemRandomEnchantmentType.Suffix);
}
public static uint GenerateEnchSuffixFactor(uint item_id)
{
ItemTemplate itemProto = Global.ObjectMgr.GetItemTemplate(item_id);
if (itemProto == null)
return 0;
if (itemProto.GetRandomSuffix() == 0)
if (itemProto.RandomBonusListTemplateId == 0)
return 0;
return GetRandomPropertyPoints(itemProto.GetBaseItemLevel(), itemProto.GetQuality(), itemProto.GetInventoryType(), itemProto.GetSubClass());
var tab = _storage.LookupByKey(itemProto.RandomBonusListTemplateId);
if (tab == null)
{
Log.outError(LogFilter.Sql, $"Item RandomBonusListTemplateId id {itemProto.RandomBonusListTemplateId} used in `item_template_addon` but it does not have records in `item_random_bonus_list_template` table.");
return 0;
}
//todo fix me this is ulgy
return tab.BonusListIDs.SelectRandomElementByWeight(x => (float)tab.Chances[tab.BonusListIDs.IndexOf(x)]);
}
public static uint GetRandomPropertyPoints(uint itemLevel, ItemQuality quality, InventoryType inventoryType, uint subClass)
{
uint propIndex;
switch (inventoryType)
{
case InventoryType.Head:
@@ -208,11 +139,11 @@ namespace Game.Entities
default:
return 0;
}
RandPropPointsRecord randPropPointsEntry = CliDB.RandPropPointsStorage.LookupByKey(itemLevel);
if (randPropPointsEntry == null)
return 0;
// Select rare/epic modifier
switch (quality)
{
case ItemQuality.Uncommon:
@@ -225,69 +156,16 @@ namespace Game.Entities
case ItemQuality.Artifact:
return randPropPointsEntry.Epic[propIndex];
}
return 0;
}
static EnchantmentStore RandomItemEnch;
public class EnchStoreItem
{
public EnchStoreItem()
{
ench = 0;
chance = 0;
}
public EnchStoreItem(ItemRandomEnchantmentType _type, uint _ench, float _chance)
{
type = _type;
ench = _ench;
chance = _chance;
static Dictionary<uint, RandomBonusListIds> _storage = new Dictionary<uint, RandomBonusListIds>();
}
public ItemRandomEnchantmentType type;
public uint ench;
public float chance;
}
class EnchantmentStore
public class RandomBonusListIds
{
public EnchantmentStore()
{
_data[(byte)ItemRandomEnchantmentType.Property] = new MultiMap<uint, EnchStoreItem>();
_data[(byte)ItemRandomEnchantmentType.Suffix] = new MultiMap<uint, EnchStoreItem>();
}
public MultiMap<uint, EnchStoreItem> this[ItemRandomEnchantmentType type]
{
get
{
//(type != ItemRandomEnchantmentType.BonusList, "Random bonus lists do not have their own storage, use Suffix for them");
return _data[(byte)type];
}
}
MultiMap<uint, EnchStoreItem>[] _data = new MultiMap<uint, EnchStoreItem>[2];
}
}
public struct ItemRandomEnchantmentId
{
public static ItemRandomEnchantmentId Empty = default(ItemRandomEnchantmentId);
public ItemRandomEnchantmentId(ItemRandomEnchantmentType type, uint id)
{
Type = type;
Id = id;
}
public ItemRandomEnchantmentType Type;
public uint Id;
}
public enum ItemRandomEnchantmentType
{
Property = 0,
Suffix = 1,
BonusList = 2
public List<uint> BonusListIDs = new List<uint>();
public List<double> Chances = new List<double>();
}
}
+3 -4
View File
@@ -223,9 +223,9 @@ namespace Game.Entities
if (GetFlags().HasAnyFlag(ItemFlags.IsBoundToAccount) && alwaysAllowBoundToAccount)
return true;
uint spec = player.GetUInt32Value(ActivePlayerFields.LootSpecId);
uint spec = player.GetLootSpecId();
if (spec == 0)
spec = player.GetUInt32Value(PlayerFields.CurrentSpecId);
spec = player.GetPrimarySpecialization();
if (spec == 0)
spec = player.GetDefaultSpecId();
@@ -295,8 +295,6 @@ namespace Game.Entities
public uint GetPageText() { return ExtendedData.PageID; }
public uint GetStartQuest() { return ExtendedData.StartQuestID; }
public uint GetLockID() { return ExtendedData.LockID; }
public uint GetRandomProperty() { return ExtendedData.RandomSelect; }
public uint GetRandomSuffix() { return ExtendedData.ItemRandomSuffixGroupID; }
public uint GetItemSet() { return ExtendedData.ItemSet; }
public uint GetArea() { return ExtendedData.ZoneBound; }
public uint GetMap() { return ExtendedData.InstanceBound; }
@@ -345,6 +343,7 @@ namespace Game.Entities
public uint MaxMoneyLoot;
public ItemFlagsCustom FlagsCu;
public float SpellPPMRate;
public uint RandomBonusListTemplateId;
public BitArray[] Specializations = new BitArray[3];
public uint ItemSpecClassMask;
@@ -56,13 +56,13 @@ namespace Game.Entities
if (buffer.WriteBit(!outOfRangeGUIDs.Empty()))
{
buffer.WriteUInt16(0); // object limit to instantly destroy - objects before this index on m_outOfRangeGUIDs list get "smoothly phased out"
buffer.WriteUInt32(outOfRangeGUIDs.Count);
buffer.WriteInt32(outOfRangeGUIDs.Count);
foreach (var guid in outOfRangeGUIDs)
buffer.WritePackedGuid(guid);
}
var bytes = data.GetData();
buffer.WriteUInt32(bytes.Length);
buffer.WriteInt32(bytes.Length);
buffer.WriteBytes(bytes);
packet.Data = buffer.GetData();
@@ -0,0 +1,453 @@
/*
* Copyright (C) 2012-2019 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Constants;
using Game.Network;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace Game.Entities
{
public class UpdateFieldHolder
{
public UpdateFieldHolder(WorldObject owner) { _owner = owner; }
public BaseUpdateData<T> ModifyValue<T>(BaseUpdateData<T> updateData)
{
_changesMask.Set(updateData.Bit);
return updateData;
}
public void ClearChangesMask<T>(BaseUpdateData<T> updateData)
{
_changesMask.Reset(updateData.Bit);
}
public void ClearChangesMask<T, U>(BaseUpdateData<T> updateData, ref UpdateField<U> updateField) where T : new() where U : new()
{
_changesMask.Reset(updateData.Bit);
IHasChangesMask hasChangesMask = (IHasChangesMask)updateField._value;
if (hasChangesMask != null)
hasChangesMask.ClearChangesMask();
}
public uint GetChangedObjectTypeMask()
{
return _changesMask.GetBlock(0);
}
public bool HasChanged(TypeId index)
{
return _changesMask[(int)index];
}
UpdateMask _changesMask = new UpdateMask((int)TypeId.Max);
WorldObject _owner;
}
public interface IUpdateField<T>
{
void SetValue(T value);
T GetValue();
}
public class UpdateField<T> : IUpdateField<T> where T : new()
{
public T _value;
public int BlockBit;
public int Bit;
public UpdateField(int blockBit, int bit)
{
BlockBit = blockBit;
Bit = bit;
_value = new T();
}
public static implicit operator T(UpdateField<T> updateField)
{
return updateField._value;
}
public void SetValue(T value) { _value = value; }
public T GetValue() { return _value; }
}
public class UpdateFieldArray<T> where T : new()
{
public T[] _values;
public int FirstElementBit;
public int Bit;
public UpdateFieldArray(uint size, int bit, int firstElementBit)
{
_values = new T[size];
for (var i = 0; i < size; ++i)
_values[i] = new T();
Bit = bit;
FirstElementBit = firstElementBit;
}
public T this[int index]
{
get
{
return _values[index];
}
set
{
_values[index] = value;
}
}
public int GetSize() { return _values.Length; }
public IEnumerator<T> GetEnumerator()
{
foreach (var obj in _values)
yield return obj;
}
}
public class DynamicUpdateField<T> where T : new()
{
public List<T> _values;
public List<uint> _updateMask;
public int BlockBit;
public int Bit;
public DynamicUpdateField()
{
_values = new List<T>();
_updateMask = new List<uint>();
BlockBit = -1;
Bit = -1;
}
public DynamicUpdateField(int blockBit, int bit)
{
_values = new List<T>();
_updateMask = new List<uint>();
BlockBit = blockBit;
Bit = bit;
}
public int FindIndex(T value)
{
return _values.IndexOf(value);
}
public bool HasChanged(int index)
{
return (_updateMask[index / 32] & (1 << (index % 32))) != 0;
}
public void WriteUpdateMask(WorldPacket data)
{
data.WriteBits(_values.Count, 32);
if (_values.Count > 32)
{
if (data.HasUnfinishedBitPack())
for (int block = 0; block < _values.Count / 32; ++block)
data.WriteBits(_updateMask[block], 32);
else
for (int block = 0; block < _values.Count / 32; ++block)
data.WriteUInt32(_updateMask[block]);
}
if ((_values.Count % 32) != 0)
data.WriteBits(_updateMask.Last(), _values.Count % 32);
}
public void ClearChangesMask()
{
for (var i = 0; i < _updateMask.Count; ++i)
_updateMask[i] = 0;
}
public void AddValue(T value)
{
MarkChanged(_values.Count);
if (value is IHasChangesMask)
{
IHasChangesMask hasChanges = (IHasChangesMask)value;
if (hasChanges != null)
hasChanges.GetUpdateMask().SetAll();
}
_values.Add(value);
}
public void InsertValue(int index, T value)
{
_values.Insert(index, value);
for (int i = index; i < _values.Count; ++i)
{
MarkChanged(i);
// also mark all fields of value as changed
IHasChangesMask hasChangesMask = (IHasChangesMask)_values[i];
if (hasChangesMask != null)
hasChangesMask.GetUpdateMask().SetAll();
}
}
public void RemoveValue(int index)
{
// remove by shifting entire container - client might rely on values being sorted for certain fields
_values.RemoveAt(index);
for (int i = index; i < _values.Count; ++i)
{
MarkChanged(i);
// also mark all fields of value as changed
IHasChangesMask hasChanges = (IHasChangesMask)_values[i];
if (hasChanges != null)
hasChanges.GetUpdateMask().SetAll();
}
if ((_values.Count % 32) != 0)
_updateMask[UpdateMask.GetBlockIndex(_values.Count)] &= (uint)~UpdateMask.GetBlockFlag(_values.Count);
else
_updateMask.RemoveAt(_updateMask.Count - 1);
}
public void Clear()
{
_values.Clear();
_updateMask.Clear();
}
public void MarkChanged(int index)
{
int block = UpdateMask.GetBlockIndex(index);
if (block >= _updateMask.Count)
_updateMask.Add(0);
_updateMask[block] |= (uint)UpdateMask.GetBlockFlag(index);
}
public void ClearChanged(int index)
{
int block = UpdateMask.GetBlockIndex(index);
if (block >= _updateMask.Count)
_updateMask.Add(0);
_updateMask[block] &= ~(uint)UpdateMask.GetBlockFlag(index);
}
public int Size()
{
return _values.Count;
}
public T this[int index]
{
get
{
if (_values.Count <= index)
_values.Add(new T());
return _values[index];
}
set
{
_values[index] = value;
}
}
public static implicit operator List<T>(DynamicUpdateField<T> updateField)
{
return updateField._values;
}
public IEnumerator<T> GetEnumerator()
{
foreach (var obj in _values)
yield return obj;
}
}
public interface IHasChangesMask
{
void ClearChangesMask();
UpdateMask GetUpdateMask();
}
public abstract class BaseUpdateData<T> : IHasChangesMask
{
public UpdateMask _changesMask;
public int _blockBit;
public int Bit;
public BaseUpdateData(int blockBit, TypeId bit, int changeMask)
{
_blockBit = blockBit;
Bit = (int)bit;
_changesMask = new UpdateMask(changeMask);
}
public BaseUpdateData(int changeMask)
{
_changesMask = new UpdateMask(changeMask);
}
public abstract void WriteCreate(WorldPacket data, UpdateFieldFlag fieldVisibilityFlags, T owner, Player receiver);
public abstract void WriteUpdate(WorldPacket data, UpdateFieldFlag fieldVisibilityFlags, T owner, Player receiver);
public abstract void ClearChangesMask();
public UpdateMask GetUpdateMask()
{
return _changesMask;
}
public void ClearChanged<U>(UpdateField<U> updateField) where U : new()
{
_changesMask.Reset(updateField.Bit);
}
public void ClearChanged<U>(UpdateFieldArray<U> updateField, int index) where U : new()
{
_changesMask.Reset(updateField.Bit);
_changesMask.Reset(updateField.FirstElementBit + index);
}
public void ClearChanged<U>(DynamicUpdateField<U> updateField, int index) where U : new()
{
_changesMask.Reset(Bit);
updateField.ClearChanged(index);
}
public void ClearChangesMask<U>(UpdateField<U> updateField) where U : new()
{
if (typeof(U).BaseType == typeof(IHasChangesMask))
((IHasChangesMask)updateField._value).ClearChangesMask();
}
public void ClearChangesMask<U>(UpdateFieldArray<U> updateField) where U : new()
{
if (typeof(U).BaseType == typeof(IHasChangesMask))
{
for (int i = 0; i < updateField.GetSize(); ++i)
((IHasChangesMask)updateField[i]).ClearChangesMask();
}
}
public void ClearChangesMask<U>(DynamicUpdateField<U> updateField) where U : new()
{
if (typeof(U).BaseType == typeof(IHasChangesMask))
{
for (int i = 0; i < updateField.Size(); ++i)
((IHasChangesMask)updateField[i]).ClearChangesMask();
updateField.ClearChangesMask();
}
}
public UpdateField<UU> ModifyValue<U, UU>(Expression<Func<U, UpdateField<UU>>> expression) where UU : new()
{
var fieldInfo = ((MemberExpression)expression.Body).Member as FieldInfo;
if (fieldInfo == null)
throw new ArgumentException("The lambda expression 'property' should point to a valid Property");
var updateField = (UpdateField<UU>)fieldInfo.GetValue(this);
_changesMask.Set(updateField.BlockBit);
_changesMask.Set(updateField.Bit);
return updateField;
}
public ref UU ModifyValue<U, UU>(Expression<Func<U, UpdateFieldArray<UU>>> expression, int index) where UU : new()
{
var fieldInfo = ((MemberExpression)expression.Body).Member as FieldInfo;
if (fieldInfo == null)
throw new ArgumentException("The lambda expression 'property' should point to a valid Property");
var updateFieldArray = (UpdateFieldArray<UU>)fieldInfo.GetValue(this);
_changesMask.Set(updateFieldArray.Bit);
_changesMask.Set(updateFieldArray.FirstElementBit + index);
return ref updateFieldArray._values[index];
}
public UpdateField<U> ModifyValue<U>(UpdateField<U> updateField) where U : new()
{
_changesMask.Set(updateField.BlockBit);
_changesMask.Set(updateField.Bit);
return updateField;
}
public ref U ModifyValue<U>(UpdateFieldArray<U> updateField, int index) where U : new()
{
_changesMask.Set(updateField.Bit);
_changesMask.Set(updateField.FirstElementBit + index);
return ref updateField._values[index];
}
public DynamicUpdateField<U> ModifyValue<U>(DynamicUpdateField<U> updateField) where U : new()
{
_changesMask.Set(updateField.BlockBit);
_changesMask.Set(updateField.Bit);
return updateField;
}
public DynamicUpdateFieldSetter<U> ModifyValue<U>(DynamicUpdateField<U> updateField, int index) where U : new()
{
if (index >= updateField._values.Count)
{
// fill with zeros until reaching desired slot
updateField._values.Resize((uint)index + 1);
updateField._updateMask.Resize((uint)(updateField._values.Count + 31) / 32);
}
_changesMask.Set(updateField.BlockBit);
_changesMask.Set(updateField.Bit);
updateField.MarkChanged(index);
return new DynamicUpdateFieldSetter<U>(updateField, index);
}
}
public class DynamicUpdateFieldSetter<T> : IUpdateField<T> where T : new()
{
public DynamicUpdateFieldSetter(DynamicUpdateField<T> dynamicUpdateField, int index)
{
_dynamicUpdateField = dynamicUpdateField;
_index = index;
}
public void SetValue(T value)
{
_dynamicUpdateField[_index] = value;
}
public T GetValue() { return _dynamicUpdateField[_index]; }
public static implicit operator T(DynamicUpdateFieldSetter<T> dynamicUpdateFieldSetter)
{
return dynamicUpdateFieldSetter.GetValue();
}
DynamicUpdateField<T> _dynamicUpdateField;
int _index;
}
}
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More