diff --git a/common/item_instance.cpp b/common/item_instance.cpp index 3c7294e62..897512a1d 100644 --- a/common/item_instance.cpp +++ b/common/item_instance.cpp @@ -17,6 +17,7 @@ */ #include "inventory_profile.h" +#include "../common/data_verification.h" //#include "classes.h" //#include "global_define.h" //#include "item_instance.h" @@ -527,78 +528,99 @@ EQ::ItemInstance* EQ::ItemInstance::GetAugment(uint8 augment_index) const return nullptr; } -EQ::ItemInstance* EQ::ItemInstance::GetOrnamentationAug(int32 ornamentationAugtype) const +bool EQ::ItemInstance::IsOrnamentationAugment(EQ::ItemInstance* augment) const { - if (!m_item || !m_item->IsClassCommon()) { return nullptr; } - if (ornamentationAugtype == 0) { return nullptr; } + if (!m_item || !m_item->IsClassCommon() || !augment) { + return false; + } - for (int i = invaug::SOCKET_BEGIN; i <= invaug::SOCKET_END; i++) - { - if (GetAugment(i) && m_item->AugSlotType[i] == ornamentationAugtype) - { - const char *item_IDFile = GetAugment(i)->GetItem()->IDFile; - if ( - (strncmp(item_IDFile, "IT64", strlen(item_IDFile)) == 0 - || strncmp(item_IDFile, "IT63", strlen(item_IDFile)) == 0) - && GetAugment(i)->GetItem()->HerosForgeModel == 0 - ) - { - continue; - } - return GetAugment(i); + const auto augment_item = augment->GetItem(); + if (!augment_item) { + return false; + } + + const std::string& idfile = augment_item->IDFile; + + if ( + EQ::ValueWithin( + augment->GetAugmentType(), + OrnamentationAugmentTypes::StandardOrnamentation, + OrnamentationAugmentTypes::SpecialOrnamentation + ) || + ( + idfile != "IT63" && + idfile != "IT64" + ) || + augment_item->HerosForgeModel + ) { + return true; + } + + return false; +} + +EQ::ItemInstance* EQ::ItemInstance::GetOrnamentationAugment() const +{ + if (!m_item || !m_item->IsClassCommon()) { + return nullptr; + } + + for (int i = invaug::SOCKET_BEGIN; i <= invaug::SOCKET_END; i++) { + const auto augment = GetAugment(i); + if (augment && IsOrnamentationAugment(augment)) { + return augment; } } return nullptr; } -uint32 EQ::ItemInstance::GetOrnamentHeroModel(int32 material_slot) const { +uint32 EQ::ItemInstance::GetOrnamentHeroModel(int32 material_slot) const +{ // Not a Hero Forge item. - if (m_ornament_hero_model == 0 || material_slot < 0) + if (m_ornament_hero_model == 0 || material_slot < 0) { return 0; + } // Item is using an explicit Hero Forge ID - if (m_ornament_hero_model >= 1000) + if (m_ornament_hero_model >= 1000) { return m_ornament_hero_model; + } // Item is using a shorthand ID return (m_ornament_hero_model * 100) + material_slot; } -bool EQ::ItemInstance::UpdateOrnamentationInfo() { - if (!m_item || !m_item->IsClassCommon()) +bool EQ::ItemInstance::UpdateOrnamentationInfo() +{ + if (!m_item || !m_item->IsClassCommon()) { return false; + } - bool ornamentSet = false; + const auto augment = GetOrnamentationAugment(); - int32 ornamentationAugtype = RuleI(Character, OrnamentationAugmentType); - if (GetOrnamentationAug(ornamentationAugtype)) - { - const ItemData* ornamentItem; - ornamentItem = GetOrnamentationAug(ornamentationAugtype)->GetItem(); - if (ornamentItem != nullptr) - { - SetOrnamentIcon(ornamentItem->Icon); - SetOrnamentHeroModel(ornamentItem->HerosForgeModel); - if (strlen(ornamentItem->IDFile) > 2) - { - SetOrnamentationIDFile(Strings::ToUnsignedInt(&ornamentItem->IDFile[2])); - } - else - { + if (augment) { + const auto augment_item = GetOrnamentationAugment()->GetItem(); + + if (augment_item) { + SetOrnamentIcon(augment_item->Icon); + SetOrnamentHeroModel(augment_item->HerosForgeModel); + + if (strlen(augment_item->IDFile) > 2) { + SetOrnamentationIDFile(Strings::ToUnsignedInt(&augment_item->IDFile[2])); + } else { SetOrnamentationIDFile(0); } - ornamentSet = true; + + return true; } } - else - { - SetOrnamentIcon(0); - SetOrnamentHeroModel(0); - SetOrnamentationIDFile(0); - } - return ornamentSet; + SetOrnamentIcon(0); + SetOrnamentHeroModel(0); + SetOrnamentationIDFile(0); + + return false; } bool EQ::ItemInstance::CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll) { diff --git a/common/item_instance.h b/common/item_instance.h index a0d1d4a19..1b1d4043e 100644 --- a/common/item_instance.h +++ b/common/item_instance.h @@ -51,6 +51,11 @@ typedef enum { byFlagNotSet //apply action if the flag is NOT set } byFlagSetting; +enum OrnamentationAugmentTypes { + StandardOrnamentation = 20, + SpecialOrnamentation = 21 +}; + class SharedDatabase; // ######################################## @@ -136,7 +141,8 @@ namespace EQ bool IsAugmented(); bool ContainsAugmentByID(uint32 item_id); int CountAugmentByID(uint32 item_id); - ItemInstance* GetOrnamentationAug(int32 ornamentationAugtype) const; + bool IsOrnamentationAugment(EQ::ItemInstance* augment) const; + ItemInstance* GetOrnamentationAugment() const; bool UpdateOrnamentationInfo(); static bool CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll = false); diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index d6e0e2a17..318c50f62 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -5218,7 +5218,6 @@ namespace RoF /** * Ornamentation */ - int ornamentation_augment_type = RuleI(Character, OrnamentationAugmentType); uint32 ornamentation_icon = (inst->GetOrnamentationIcon() ? inst->GetOrnamentationIcon() : 0); uint32 hero_model = 0; diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index 3c34cd011..30b6ad70a 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -5477,7 +5477,6 @@ namespace RoF2 /** * Ornamentation */ - int ornamentation_augment_type = RuleI(Character, OrnamentationAugmentType); uint32 ornamentation_icon = (inst->GetOrnamentationIcon() ? inst->GetOrnamentationIcon() : 0); uint32 hero_model = 0; diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index b632cb7e3..b9c1d888a 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -3851,17 +3851,17 @@ namespace UF ob.write((const char*)&evotop, sizeof(UF::structs::EvolvingItem)); } - //ORNAMENT IDFILE / ICON - - int ornamentationAugtype = RuleI(Character, OrnamentationAugmentType); - uint16 ornaIcon = 0; - if (inst->GetOrnamentationAug(ornamentationAugtype)) { - const EQ::ItemData *aug_weap = inst->GetOrnamentationAug(ornamentationAugtype)->GetItem(); - ornaIcon = aug_weap->Icon; + uint16 ornament_icon = 0; + const auto augment = inst->GetOrnamentationAugment(); - ob.write(aug_weap->IDFile, strlen(aug_weap->IDFile)); + if (augment) { + const auto augment_item = augment->GetItem(); + ornament_icon = augment_item->Icon; + + ob.write(augment_item->IDFile, strlen(augment_item->IDFile)); } else if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) { - ornaIcon = inst->GetOrnamentationIcon(); + ornament_icon = inst->GetOrnamentationIcon(); char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile()); ob.write(tmp, strlen(tmp)); @@ -3870,7 +3870,7 @@ namespace UF UF::structs::ItemSerializationHeaderFinish hdrf; - hdrf.ornamentIcon = ornaIcon; + hdrf.ornamentIcon = ornament_icon; hdrf.unknown060 = 0; //This is Always 0.. or it breaks shit.. hdrf.unknown061 = 0; //possibly ornament / special ornament hdrf.isCopied = 0; //Flag for item to be 'Copied' diff --git a/common/ruletypes.h b/common/ruletypes.h index f7b9f4288..d8972c94a 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -136,7 +136,6 @@ RULE_BOOL(Character, EnableFoodRequirement, true, "If disabled, food is no longe RULE_INT(Character, BaseInstrumentSoftCap, 36, "Softcap for instrument mods, 36 commonly referred to as 3.6 as well") RULE_BOOL(Character, UseSpellFileSongCap, true, "When they removed the AA that increased the cap they removed the above and just use the spell field") RULE_INT(Character, BaseRunSpeedCap, 158, "Base Run Speed Cap, on live it's 158% which will give you a runspeed of 1.580 hard capped to 225") -RULE_INT(Character, OrnamentationAugmentType, 20, "Ornamentation Augment Type") RULE_REAL(Character, EnvironmentDamageMulipliter, 1, "Multiplier for environmental damage like fall damage.") RULE_BOOL(Character, UnmemSpellsOnDeath, true, "Setting whether at death all memorized Spells are forgotten") RULE_REAL(Character, TradeskillUpAlchemy, 2.0, "Alchemy skillup rate adjustment. Lower is faster") diff --git a/zone/client.cpp b/zone/client.cpp index 770b281fb..e51bc56ec 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -5619,7 +5619,6 @@ void Client::ProcessInspectRequest(Client *requestee, Client *requester) const EQ::ItemData *item = nullptr; const EQ::ItemInstance *inst = nullptr; - int ornamentation_augment_type = RuleI(Character, OrnamentationAugmentType); for (int16 L = EQ::invslot::EQUIPMENT_BEGIN; L <= EQ::invslot::EQUIPMENT_END; L++) { inst = requestee->GetInv().GetItem(L); @@ -5629,13 +5628,15 @@ void Client::ProcessInspectRequest(Client *requestee, Client *requester) if (item) { strcpy(insr->itemnames[L], item->Name); - const EQ::ItemData *aug_item = nullptr; - if (inst->GetOrnamentationAug(ornamentation_augment_type)) { - aug_item = inst->GetOrnamentationAug(ornamentation_augment_type)->GetItem(); + const EQ::ItemData *augment_item = nullptr; + const auto augment = inst->GetOrnamentationAugment(); + + if (augment) { + augment_item = augment->GetItem(); } - if (aug_item) { - insr->itemicons[L] = aug_item->Icon; + if (augment_item) { + insr->itemicons[L] = augment_item->Icon; } else if (inst->GetOrnamentationIcon()) { insr->itemicons[L] = inst->GetOrnamentationIcon(); } else { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index bebbc60cd..6c5ce062c 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -8613,47 +8613,51 @@ void Client::Handle_OP_Illusion(const EQApplicationPacket *app) void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) { - if (app->size != sizeof(InspectResponse_Struct)) { LogError("Wrong size: OP_InspectAnswer, size=[{}], expected [{}]", app->size, sizeof(InspectResponse_Struct)); return; } //Fills the app sent from client. - EQApplicationPacket* outapp = app->Copy(); - InspectResponse_Struct* insr = (InspectResponse_Struct*)outapp->pBuffer; - Mob* tmp = entity_list.GetMob(insr->TargetID); - const EQ::ItemData* item = nullptr; + auto outapp = app->Copy(); + auto insr = (InspectResponse_Struct *) outapp->pBuffer; + auto tmp = entity_list.GetMob(insr->TargetID); + const EQ::ItemData *item = nullptr; - int ornamentationAugtype = RuleI(Character, OrnamentationAugmentType); - for (int16 L = EQ::invslot::EQUIPMENT_BEGIN; L <= EQ::invslot::EQUIPMENT_END; L++) { - const EQ::ItemInstance* inst = GetInv().GetItem(L); + for (int16 L = EQ::invslot::EQUIPMENT_BEGIN; L <= EQ::invslot::EQUIPMENT_END; L++) { + const auto inst = GetInv().GetItem(L); item = inst ? inst->GetItem() : nullptr; if (item) { strcpy(insr->itemnames[L], item->Name); - if (inst && inst->GetOrnamentationAug(ornamentationAugtype)) { - const EQ::ItemData *aug_item = inst->GetOrnamentationAug(ornamentationAugtype)->GetItem(); - insr->itemicons[L] = aug_item->Icon; - } - else if (inst->GetOrnamentationIcon()) { - insr->itemicons[L] = inst->GetOrnamentationIcon(); - } - else { + if (inst) { + const auto augment = inst->GetOrnamentationAugment(); + + if (augment) { + insr->itemicons[L] = augment->GetItem()->Icon; + } else if (inst->GetOrnamentationIcon()) { + insr->itemicons[L] = inst->GetOrnamentationIcon(); + } + } else { insr->itemicons[L] = item->Icon; } + } else { + insr->itemicons[L] = 0xFFFFFFFF; } - else { insr->itemicons[L] = 0xFFFFFFFF; } } - InspectMessage_Struct* newmessage = (InspectMessage_Struct*)insr->text; - InspectMessage_Struct& playermessage = GetInspectMessage(); - memcpy(&playermessage, newmessage, sizeof(InspectMessage_Struct)); - database.SaveCharacterInspectMessage(CharacterID(), &playermessage); + auto message = (InspectMessage_Struct *) insr->text; + auto inspect_message = GetInspectMessage(); - if (tmp != 0 && tmp->IsClient()) { tmp->CastToClient()->QueuePacket(outapp); } // Send answer to requester + memcpy(&inspect_message, message, sizeof(InspectMessage_Struct)); + database.SaveCharacterInspectMessage(CharacterID(), &inspect_message); - return; + if ( + tmp && + tmp->IsClient() + ) { + tmp->CastToClient()->QueuePacket(outapp); + } // Send answer to requester } void Client::Handle_OP_InspectMessageUpdate(const EQApplicationPacket *app) diff --git a/zone/mob_appearance.cpp b/zone/mob_appearance.cpp index 574c4ae0f..8608ee9da 100644 --- a/zone/mob_appearance.cpp +++ b/zone/mob_appearance.cpp @@ -204,13 +204,11 @@ int32 Mob::GetTextureProfileHeroForgeModel(uint8 material_slot) const */ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const { - uint32 equipment_material = 0; - int32 ornamentation_augment_type = RuleI(Character, OrnamentationAugmentType); + uint32 equipment_material = 0; + int32 texture_profile_material = GetTextureProfileMaterial(material_slot); - int32 texture_profile_material = GetTextureProfileMaterial(material_slot); - - Log(Logs::Detail, Logs::MobAppearance, - "[%s] material_slot: %u texture_profile_material: %i", + LogMobAppearance( + "[{}] material_slot: {} texture_profile_material: {}", clean_name, material_slot, texture_profile_material @@ -233,9 +231,12 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const } const auto* inst = CastToClient()->m_inv[inventory_slot]; + if (inst) { - if (inst->GetOrnamentationAug(ornamentation_augment_type)) { - item = inst->GetOrnamentationAug(ornamentation_augment_type)->GetItem(); + const auto augment = inst->GetOrnamentationAugment(); + + if (augment) { + item = augment->GetItem(); if (item && strlen(item->IDFile) > 2 && Strings::IsNumber(&item->IDFile[2])) { equipment_material = Strings::ToInt(&item->IDFile[2]); } @@ -310,21 +311,20 @@ uint32 Mob::GetEquipmentColor(uint8 material_slot) const int32 Mob::GetHerosForgeModel(uint8 material_slot) const { uint32 hero_model = 0; - if (material_slot >= 0 && material_slot < EQ::textures::weaponPrimary) { - uint32 ornamentation_aug_type = RuleI(Character, OrnamentationAugmentType); - + if (EQ::ValueWithin(material_slot, 0, EQ::textures::weaponPrimary)) { const EQ::ItemData *item = database.GetItem(GetEquippedItemFromTextureSlot(material_slot)); - int16 invslot = EQ::InventoryProfile::CalcSlotFromMaterial(material_slot); + const auto slot = EQ::InventoryProfile::CalcSlotFromMaterial(material_slot); - if (item != nullptr && invslot != INVALID_INDEX) { + if (item && slot != INVALID_INDEX) { if (IsClient()) { - const EQ::ItemInstance *inst = CastToClient()->m_inv[invslot]; + const auto inst = CastToClient()->m_inv[slot]; if (inst) { - if (inst->GetOrnamentationAug(ornamentation_aug_type)) { - item = inst->GetOrnamentationAug(ornamentation_aug_type)->GetItem(); + const auto augment = inst->GetOrnamentationAugment(); + + if (augment) { + item = augment->GetItem(); hero_model = item->HerosForgeModel; - } - else if (inst->GetOrnamentHeroModel()) { + } else if (inst->GetOrnamentHeroModel()) { hero_model = inst->GetOrnamentHeroModel(); } } @@ -341,8 +341,13 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const /** * Robes require full model number, and should only be sent to chest, arms, wrists, and legs slots */ - if (hero_model > 1000 && material_slot != 1 && material_slot != 2 && material_slot != 3 && - material_slot != 5) { + if ( + hero_model > 1000 && + material_slot != EQ::textures::armorChest && + material_slot != EQ::textures::armorArms && + material_slot != EQ::textures::armorWrist && + material_slot != EQ::textures::armorLegs + ) { hero_model = 0; } } @@ -354,7 +359,7 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const * Otherwise, use the exact Model if model is > 999 * Robes for example are 11607 to 12107 in RoF */ - if (hero_model > 0 && hero_model < 1000) { + if (EQ::ValueWithin(hero_model, 1, 999)) { hero_model *= 100; hero_model += material_slot; }