public static AppraisalProfile read(BinaryReader binaryReader) { AppraisalProfile newObj = new AppraisalProfile(); newObj.header = binaryReader.ReadUInt32(); newObj.success_flag = binaryReader.ReadUInt32(); if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_IntStats) != 0) { newObj._intStatsTable = PackableHashTable <STypeInt, int> .read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_Int64Stats) != 0) { newObj._int64StatsTable = PackableHashTable <STypeInt64, long> .read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_BoolStats) != 0) { newObj._boolStatsTable = PackableHashTable <STypeBool, int> .read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_FloatStats) != 0) { newObj._floatStatsTable = PackableHashTable <STypeFloat, double> .read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_StringStats) != 0) { newObj._strStatsTable = PackableHashTable <STypeString, PStringChar> .read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_DataIDStats) != 0) { newObj._didStatsTable = PackableHashTable <STypeDID, uint> .read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_SpellList) != 0) { newObj._spellsTable = PList <SpellID> .read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_ArmorProfile) != 0) { newObj._armorProfileTable = ArmorProfile.read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_CreatureProfile) != 0) { newObj._creatureProfileTable = CreatureAppraisalProfile.read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_WeaponProfile) != 0) { newObj._weaponProfileTable = WeaponProfile.read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_HookProfile) != 0) { newObj._hookProfileTable = HookAppraisalProfile.read(binaryReader); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_ArmorEnchant) != 0) { newObj._armorEnchantment = binaryReader.ReadUInt32(); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_WeaponEnchant) != 0) { newObj._weaponEnchantment = binaryReader.ReadUInt32(); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_ResistEnchant) != 0) { newObj._resistEnchantment = binaryReader.ReadUInt32(); } if ((newObj.header & (uint)AppraisalProfilePackHeader.Packed_ArmorLevels) != 0) { newObj._armorLevelsTable = ArmorLevels.read(binaryReader); } return(newObj); }
public List <string> packedItems; // For display purposes public static PlayerModule read(BinaryReader binaryReader) { PlayerModule newObj = new PlayerModule(); newObj.packedItems = new List <string>(); newObj.header = binaryReader.ReadUInt32(); newObj.options_ = binaryReader.ReadUInt32(); if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_ShortCutManager) != 0) { newObj.shortcuts_ = ShortCutManager.read(binaryReader); newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_ShortCutManager.ToString()); } newObj.favorite_spells_[0] = PList <SpellID> .read(binaryReader); if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_MultiSpellLists) != 0) { for (int i = 1; i < 5; ++i) { newObj.favorite_spells_[i] = PList <SpellID> .read(binaryReader); } newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_MultiSpellLists.ToString()); } else if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_ExtendedMultiSpellLists) != 0) { for (int i = 1; i < 7; ++i) { newObj.favorite_spells_[i] = PList <SpellID> .read(binaryReader); } newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_ExtendedMultiSpellLists.ToString()); } else if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_8_SpellLists) != 0) { for (int i = 1; i < 8; ++i) { newObj.favorite_spells_[i] = PList <SpellID> .read(binaryReader); } newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_8_SpellLists.ToString()); } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_DesiredComps) != 0) { newObj.desired_comps_ = PackableHashTable <uint, int> .read(binaryReader); newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_DesiredComps.ToString()); } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_SpellbookFilters) != 0) { newObj.spell_filters_ = binaryReader.ReadUInt32(); newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_SpellbookFilters.ToString()); } else { newObj.spell_filters_ = 0x3FFF; } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_2ndCharacterOptions) != 0) { newObj.options2 = binaryReader.ReadUInt32(); newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_2ndCharacterOptions.ToString()); } else { newObj.options2 = 0x948700; } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_TimeStampFormat) != 0) { newObj.m_TimeStampFormat = PStringChar.read(binaryReader); newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_TimeStampFormat.ToString()); } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_GenericQualitiesData) != 0) { newObj.m_pPlayerOptionsData = GenericQualitiesData.read(binaryReader); newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_GenericQualitiesData.ToString()); } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_GameplayOptions) != 0) { newObj.m_colGameplayOptions = PackObjPropertyCollection.read(binaryReader); Util.readToAlign(binaryReader); // Align to dword boundary newObj.packedItems.Add(PlayerModulePackHeader.PM_Packed_GameplayOptions.ToString()); } return(newObj); }
public static PlayerModule read(BinaryReader binaryReader) { PlayerModule newObj = new PlayerModule(); newObj.header = binaryReader.ReadUInt32(); newObj.options_ = binaryReader.ReadUInt32(); if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_ShortCutManager) != 0) { newObj.shortcuts_ = ShortCutManager.read(binaryReader); } // TODO: This message often gets fragmented. Need to combine fragments to prevent the reader from creating an exception from trying to read beyond buffer. newObj.favorite_spells_[0] = PList <uint> .read(binaryReader); if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_MultiSpellLists) != 0) { for (int i = 1; i < 5; ++i) { newObj.favorite_spells_[i] = PList <uint> .read(binaryReader); } } else if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_ExtendedMultiSpellLists) != 0) { for (int i = 1; i < 7; ++i) { newObj.favorite_spells_[i] = PList <uint> .read(binaryReader); } } else if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_8_SpellLists) != 0) { for (int i = 1; i < 8; ++i) { newObj.favorite_spells_[i] = PList <uint> .read(binaryReader); } } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_DesiredComps) != 0) { newObj.desired_comps_ = PackableHashTable <uint, int> .read(binaryReader); } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_SpellbookFilters) != 0) { newObj.spell_filters_ = binaryReader.ReadUInt32(); } else { newObj.spell_filters_ = 0x3FFF; } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_2ndCharacterOptions) != 0) { newObj.options2 = binaryReader.ReadUInt32(); } else { newObj.options2 = 0x948700; } if ((newObj.header & (uint)PlayerModulePackHeader.PM_Packed_TimeStampFormat) != 0) { newObj.m_TimeStampFormat = PStringChar.read(binaryReader); } // TODO: Lots more to read here! return(newObj); }
private void WriteEventBody() { // refactor this -- it is kind of ridiculous for this to all be in 1 giant function. // this is a combination of CACQualities, BaseQualities, PlayerModule, and other structures var propertyFlags = DescriptionPropertyFlag.None; var propertyFlagsPos = Writer.BaseStream.Position; Writer.Write(0u); Writer.Write((uint)Session.Player.WeenieType); var _propertiesInt = Session.Player.GetAllPropertyInt().Where(x => SendOnLoginProperties.PropertiesInt.Contains((ushort)x.Key)).ToDictionary(i => i.Key, i => i.Value); if (_propertiesInt.Count != 0) { propertyFlags |= DescriptionPropertyFlag.PropertyInt32; PackableHashTable.WriteHeader(Writer, _propertiesInt.Count, PropertyIntComparer.NumBuckets); var propertiesInt = new SortedDictionary <PropertyInt, int>(_propertiesInt, PropertyIntComparer); foreach (var property in propertiesInt) { Writer.Write((uint)property.Key); Writer.Write(property.Value); } } var _propertiesInt64 = Session.Player.GetAllPropertyInt64().Where(x => ClientProperties.PropertiesInt64.Contains((ushort)x.Key)).ToDictionary(i => i.Key, i => i.Value); if (_propertiesInt64.Count != 0) { propertyFlags |= DescriptionPropertyFlag.PropertyInt64; PackableHashTable.WriteHeader(Writer, _propertiesInt64.Count, PropertyInt64Comparer.NumBuckets); var propertiesInt64 = new SortedDictionary <PropertyInt64, long>(_propertiesInt64, PropertyInt64Comparer); foreach (var property in propertiesInt64) { Writer.Write((uint)property.Key); Writer.Write(property.Value); } } var _propertiesBool = Session.Player.GetAllPropertyBools().Where(x => SendOnLoginProperties.PropertiesBool.Contains((ushort)x.Key)).ToDictionary(i => i.Key, i => i.Value); if (_propertiesBool.Count != 0) { propertyFlags |= DescriptionPropertyFlag.PropertyBool; PackableHashTable.WriteHeader(Writer, _propertiesBool.Count, PropertyBoolComparer.NumBuckets); var propertiesBool = new SortedDictionary <PropertyBool, bool>(_propertiesBool, PropertyBoolComparer); foreach (var property in propertiesBool) { Writer.Write((uint)property.Key); Writer.Write(Convert.ToUInt32(property.Value)); // just as fast as inlining } } var _propertiesDouble = Session.Player.GetAllPropertyFloat().Where(x => SendOnLoginProperties.PropertiesDouble.Contains((ushort)x.Key)).ToDictionary(i => i.Key, i => i.Value); if (_propertiesDouble.Count != 0) { propertyFlags |= DescriptionPropertyFlag.PropertyDouble; PackableHashTable.WriteHeader(Writer, _propertiesDouble.Count, PropertyDoubleComparer.NumBuckets); var propertiesDouble = new SortedDictionary <PropertyFloat, double>(_propertiesDouble, PropertyDoubleComparer); foreach (var property in propertiesDouble) { Writer.Write((uint)property.Key); Writer.Write(property.Value); } } var _propertiesString = Session.Player.GetAllPropertyString().Where(x => SendOnLoginProperties.PropertiesString.Contains((ushort)x.Key)).ToDictionary(i => i.Key, i => i.Value); if (_propertiesString.Count != 0) { propertyFlags |= DescriptionPropertyFlag.PropertyString; PackableHashTable.WriteHeader(Writer, _propertiesString.Count, PropertyStringComparer.NumBuckets); var propertiesString = new SortedDictionary <PropertyString, string>(_propertiesString, PropertyStringComparer); foreach (var property in propertiesString) { Writer.Write((uint)property.Key); if (property.Key == PropertyString.Name) { if (Session.Player.IsPlussed && Session.Player.CloakStatus < CloakStatus.Player) { Writer.WriteString16L("+" + property.Value); } else { Writer.WriteString16L(property.Value); } } else { Writer.WriteString16L(property.Value); } } } var _propertiesDid = Session.Player.GetAllPropertyDataId().Where(x => SendOnLoginProperties.PropertiesDataId.Contains((ushort)x.Key)).ToDictionary(i => i.Key, i => i.Value); if (_propertiesDid.Count != 0) { propertyFlags |= DescriptionPropertyFlag.PropertyDid; PackableHashTable.WriteHeader(Writer, _propertiesDid.Count, PropertyDataIdComparer.NumBuckets); var propertiesDid = new SortedDictionary <PropertyDataId, uint>(_propertiesDid, PropertyDataIdComparer); foreach (var property in propertiesDid) { Writer.Write((uint)property.Key); Writer.Write(property.Value); } } var _propertiesIid = Session.Player.GetAllPropertyInstanceId().Where(x => SendOnLoginProperties.PropertiesInstanceId.Contains((ushort)x.Key)).ToDictionary(i => i.Key, i => i.Value); if (_propertiesIid.Count != 0) { propertyFlags |= DescriptionPropertyFlag.PropertyIid; PackableHashTable.WriteHeader(Writer, _propertiesIid.Count, PropertyInstanceIdComparer.NumBuckets); var propertiesIid = new SortedDictionary <PropertyInstanceId, uint>(_propertiesIid, PropertyInstanceIdComparer); foreach (var property in propertiesIid) { Writer.Write((uint)property.Key); Writer.Write(property.Value); } } /*if ((propertyFlags & DescriptionPropertyFlag.Resource) != 0) * { * }*/ /*if ((propertyFlags & DescriptionPropertyFlag.Link) != 0) * { * }*/ var lastOutsideDeath = Session.Player.GetPosition(PositionType.LastOutsideDeath); if (lastOutsideDeath != null) { propertyFlags |= DescriptionPropertyFlag.Position; PackableHashTable.WriteHeader(Writer, 1, 16); Writer.Write((uint)PositionType.LastOutsideDeath); lastOutsideDeath.Serialize(Writer); } Writer.WritePosition((uint)propertyFlags, propertyFlagsPos); DescriptionVectorFlag vectorFlags = DescriptionVectorFlag.Attribute | DescriptionVectorFlag.Skill; var knownSpells = Session.Player.Biota.CloneSpells(Session.Player.BiotaDatabaseLock); if (knownSpells.Count > 0) { vectorFlags |= DescriptionVectorFlag.Spell; } if (Session.Player.EnchantmentManager.HasEnchantments) { vectorFlags |= DescriptionVectorFlag.Enchantment; } Writer.Write((uint)vectorFlags); Writer.Write(Convert.ToUInt32(Session.Player.Health != null)); if ((vectorFlags & DescriptionVectorFlag.Attribute) != 0) { var attributeFlags = AttributeCache.Full; Writer.Write((uint)attributeFlags); if ((attributeFlags & AttributeCache.Strength) != 0) { Writer.Write(Session.Player.Strength.Ranks); Writer.Write(Session.Player.Strength.StartingValue); Writer.Write(Session.Player.Strength.ExperienceSpent); } if ((attributeFlags & AttributeCache.Endurance) != 0) { Writer.Write(Session.Player.Endurance.Ranks); Writer.Write(Session.Player.Endurance.StartingValue); Writer.Write(Session.Player.Endurance.ExperienceSpent); } if ((attributeFlags & AttributeCache.Quickness) != 0) { Writer.Write(Session.Player.Quickness.Ranks); Writer.Write(Session.Player.Quickness.StartingValue); Writer.Write(Session.Player.Quickness.ExperienceSpent); } if ((attributeFlags & AttributeCache.Coordination) != 0) { Writer.Write(Session.Player.Coordination.Ranks); Writer.Write(Session.Player.Coordination.StartingValue); Writer.Write(Session.Player.Coordination.ExperienceSpent); } if ((attributeFlags & AttributeCache.Focus) != 0) { Writer.Write(Session.Player.Focus.Ranks); Writer.Write(Session.Player.Focus.StartingValue); Writer.Write(Session.Player.Focus.ExperienceSpent); } if ((attributeFlags & AttributeCache.Self) != 0) { Writer.Write(Session.Player.Self.Ranks); Writer.Write(Session.Player.Self.StartingValue); Writer.Write(Session.Player.Self.ExperienceSpent); } if ((attributeFlags & AttributeCache.Health) != 0) { Writer.Write(Session.Player.Health.Ranks); Writer.Write(Session.Player.Health.StartingValue); // init_level - always appears to be 0 Writer.Write(Session.Player.Health.ExperienceSpent); Writer.Write(Session.Player.Health.Current); } if ((attributeFlags & AttributeCache.Stamina) != 0) { Writer.Write(Session.Player.Stamina.Ranks); Writer.Write(Session.Player.Stamina.StartingValue); // init_level - always appears to be 0 Writer.Write(Session.Player.Stamina.ExperienceSpent); Writer.Write(Session.Player.Stamina.Current); } if ((attributeFlags & AttributeCache.Mana) != 0) { Writer.Write(Session.Player.Mana.Ranks); Writer.Write(Session.Player.Mana.StartingValue); // init_level - always appears to be 0 Writer.Write(Session.Player.Mana.ExperienceSpent); Writer.Write(Session.Player.Mana.Current); } } if ((vectorFlags & DescriptionVectorFlag.Skill) != 0) { PackableHashTable.WriteHeader(Writer, Session.Player.Skills.Count, SkillComparer.NumBuckets); var skills = new SortedDictionary <Skill, CreatureSkill>(Session.Player.Skills, SkillComparer); foreach (var kvp in skills) { // TODO: Network.Structure.Skill Writer.Write((uint)kvp.Key); // skill id Writer.Write(kvp.Value.Ranks); // points raised Writer.Write((ushort)1u); Writer.Write((uint)kvp.Value.AdvancementClass); // skill state Writer.Write(kvp.Value.ExperienceSpent); // xp spent on this skill Writer.Write(kvp.Value.InitLevel); // init_level, for training/specialized bonus from character creation Writer.Write(0u); // task difficulty, aka "resistance_of_last_check" Writer.Write(0d); // last_time_used } } if ((vectorFlags & DescriptionVectorFlag.Spell) != 0) { PackableHashTable.WriteHeader(Writer, knownSpells.Count, SpellComparer.NumBuckets); var spells = new SortedDictionary <int, float>(knownSpells, SpellComparer); foreach (var spell in spells) { Writer.Write(spell.Key); // This sets a flag to use new spell configuration always 2 Writer.Write(2f); } } if ((vectorFlags & DescriptionVectorFlag.Enchantment) != 0) { Session.Player.EnchantmentManager.SendRegistry(Writer); } // TODO: Refactor this to set all of these flags based on data. Og II var optionFlags = CharacterOptionDataFlag.CharacterOptions2; optionFlags |= CharacterOptionDataFlag.SpellLists8; var shortcuts = Session.Player.GetShortcuts(); if (shortcuts.Count > 0) { optionFlags |= CharacterOptionDataFlag.Shortcut; } if (Session.Player.Character.GameplayOptions != null && Session.Player.Character.GameplayOptions.Length > 0) { optionFlags |= CharacterOptionDataFlag.GameplayOptions; } var fillComps = Session.Player.Character.GetFillComponents(Session.Player.CharacterDatabaseLock); if (fillComps.Count > 0) { optionFlags |= CharacterOptionDataFlag.DesiredComps; } optionFlags |= CharacterOptionDataFlag.SpellbookFilters; Writer.Write((uint)optionFlags); Writer.Write(Session.Player.Character.CharacterOptions1); if (shortcuts.Count > 0) { Writer.Write(shortcuts); } if ((optionFlags & CharacterOptionDataFlag.SpellLists8) != 0) { for (int i = 0; i <= 7; i++) { var spells = Session.Player.GetSpellsInSpellBar(i); Writer.Write(spells.Count); foreach (var spell in spells) { Writer.Write(spell.SpellId); } } } else { Writer.Write(0u); } if ((optionFlags & CharacterOptionDataFlag.DesiredComps) != 0) { Writer.WriteOld(fillComps); // verify } //if ((optionFlags & CharacterOptionDataFlag.SpellbookFilters) != 0) Writer.Write(Session.Player.Character.SpellbookFilters); if ((optionFlags & CharacterOptionDataFlag.CharacterOptions2) != 0) { Writer.Write(Session.Player.Character.CharacterOptions2); } /*if ((optionFlags & DescriptionOptionFlag.Unk100) != 0) * { * }*/ if ((optionFlags & CharacterOptionDataFlag.GameplayOptions) != 0) { Writer.Write(Session.Player.Character.GameplayOptions); } /*if ((optionFlags & DescriptionOptionFlag.Unk400) != 0) * { * }*/ // Write total count. Writer.Write((uint)Session.Player.Inventory.Count); // write out all of the non-containers and foci foreach (var item in Session.Player.Inventory.Values.Where(i => !i.UseBackpackSlot).OrderBy(i => i.PlacementPosition)) { Writer.Write(item.Guid.Full); Writer.Write((uint)ContainerType.NonContainer); } // Containers and foci go in side slots, they come last with their own placement order. foreach (var item in Session.Player.Inventory.Values.Where(i => i.UseBackpackSlot).OrderBy(i => i.PlacementPosition)) { Writer.Write(item.Guid.Full); if (item.WeenieType == WeenieType.Container) { Writer.Write((uint)ContainerType.Container); } else { Writer.Write((uint)ContainerType.Foci); } } Writer.Write((uint)Session.Player.EquippedObjects.Values.Count); foreach (var item in Session.Player.EquippedObjects.Values) { Writer.Write(item.Guid.Full); Writer.Write((uint)(item.CurrentWieldedLocation ?? 0)); Writer.Write((uint)(item.ClothingPriority ?? 0)); } }