diff --git a/common/Item.cpp b/common/Item.cpp index 2e43a6d75..c9f5b3f32 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -392,6 +392,35 @@ void ItemInst::PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id) } } +bool ItemInst::HasOrnamentation() const +{ + const ItemInst *item; + for (int i = 0; i < MAX_AUGMENT_SLOTS; ++i) + { + uint32 id = 0; + if ((item = GetItem(i)) != nullptr) + { + if (item->GetItem()->AugType == 524288)return true; + } + } + return false; +} + +ItemInst* ItemInst::GetOrnamentation() const +{ + if (m_item->ItemClass == ItemClassCommon) + { + ItemInst *item; + for (int i = 0; i < MAX_AUGMENT_SLOTS; ++i) + { + + uint32 id = 0; + if ((item = GetItem(i)) != nullptr && item->GetItem()->AugType == 524288) return item; + } + } + return nullptr; +} + // Retrieve item inside container ItemInst* ItemInst::GetItem(uint8 index) const { diff --git a/common/Item.h b/common/Item.h index 33f0ff12f..6ce50e359 100644 --- a/common/Item.h +++ b/common/Item.h @@ -303,7 +303,8 @@ public: bool AvailableWearSlot(uint32 aug_wear_slots) const; int8 AvailableAugmentSlot(int32 augtype) const; inline int32 GetAugmentType() const { return m_item->AugType; } - + bool HasOrnamentation() const; + ItemInst* GetOrnamentation() const; inline bool IsExpendable() const { return ((m_item->Click.Type == ET_Expendable ) || (m_item->ItemType == ItemTypePotion)); } // diff --git a/common/patches/RoF.cpp b/common/patches/RoF.cpp index 07cea6dfb..08d4f1d45 100644 --- a/common/patches/RoF.cpp +++ b/common/patches/RoF.cpp @@ -4926,13 +4926,27 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint ss.write((const char*)&null_term, sizeof(uint8)); } - if(strlen(item->IDFile) > 0) + // Moofta: if the item has an aug of type 20 (ornamentation) then we use the ID file of that when serializing. + // the only thing we should probably worry about is generating a wear change packet to all cl;ients in zone if someone adds a type 20 aug. + if (inst && inst->HasOrnamentation()) //instance is not null and does have an ornament aug (slot 20) { - ss.write(item->IDFile, strlen(item->IDFile)); + ItemInst* ornamentation = inst->GetOrnamentation(); + if (ornamentation) //paranoid! + { + ss.write(ornamentation->GetItem()->IDFile, strlen(ornamentation->GetItem()->IDFile)); + } + else if (strlen(item->IDFile) > 0) + { + ss.write(item->IDFile, strlen(item->IDFile)); + } ss.write((const char*)&null_term, sizeof(uint8)); } - else + else //original code although I shortened it { + if (strlen(item->IDFile) > 0) + { + ss.write(item->IDFile, strlen(item->IDFile)); + } ss.write((const char*)&null_term, sizeof(uint8)); } diff --git a/common/patches/SoD.cpp b/common/patches/SoD.cpp index 08a3401ad..c93155c64 100644 --- a/common/patches/SoD.cpp +++ b/common/patches/SoD.cpp @@ -3119,13 +3119,27 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint ss.write((const char*)&null_term, sizeof(uint8)); } - if(strlen(item->IDFile) > 0) + // Moofta: if the item has an aug of type 20 (ornamentation) then we use the ID file of that when serializing. + // the only thing we should probably worry about is generating a wear change packet to all cl;ients in zone if someone adds a type 20 aug. + if (inst && inst->HasOrnamentation()) //instance is not null and does have an ornament aug (slot 20) { - ss.write(item->IDFile, strlen(item->IDFile)); + ItemInst* ornamentation = inst->GetOrnamentation(); + if (ornamentation) //paranoid! + { + ss.write(ornamentation->GetItem()->IDFile, strlen(ornamentation->GetItem()->IDFile)); + } + else if (strlen(item->IDFile) > 0) + { + ss.write(item->IDFile, strlen(item->IDFile)); + } ss.write((const char*)&null_term, sizeof(uint8)); } - else + else //original code although I shortened it { + if (strlen(item->IDFile) > 0) + { + ss.write(item->IDFile, strlen(item->IDFile)); + } ss.write((const char*)&null_term, sizeof(uint8)); } diff --git a/common/patches/SoF.cpp b/common/patches/SoF.cpp index 96b1f223e..c020ddb9b 100644 --- a/common/patches/SoF.cpp +++ b/common/patches/SoF.cpp @@ -2437,13 +2437,27 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint ss.write((const char*)&null_term, sizeof(uint8)); } - if(strlen(item->IDFile) > 0) + // Moofta: if the item has an aug of type 20/524288 (ornamentation) then we use the ID file of that when serializing. + // the only thing we should probably worry about is generating a wear change packet to all cl;ients in zone if someone adds a type 20 aug. + if (inst && inst->HasOrnamentation()) //instance is not null and does have an ornament aug (slot 20) { - ss.write(item->IDFile, strlen(item->IDFile)); + ItemInst* ornamentation = inst->GetOrnamentation(); + if (ornamentation) //paranoid! + { + ss.write(ornamentation->GetItem()->IDFile, strlen(ornamentation->GetItem()->IDFile)); + } + else if (strlen(item->IDFile) > 0) + { + ss.write(item->IDFile, strlen(item->IDFile)); + } ss.write((const char*)&null_term, sizeof(uint8)); } - else + else //original code although I shortened it { + if (strlen(item->IDFile) > 0) + { + ss.write(item->IDFile, strlen(item->IDFile)); + } ss.write((const char*)&null_term, sizeof(uint8)); } diff --git a/common/patches/Underfoot.cpp b/common/patches/Underfoot.cpp index f15a94bde..cb33a5b9c 100644 --- a/common/patches/Underfoot.cpp +++ b/common/patches/Underfoot.cpp @@ -3530,13 +3530,27 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint ss.write((const char*)&null_term, sizeof(uint8)); } - if(strlen(item->IDFile) > 0) + // Moofta: if the item has an aug of type 20 (ornamentation) then we use the ID file of that when serializing. + // the only thing we should probably worry about is generating a wear change packet to all cl;ients in zone if someone adds a type 20 aug. + if (inst && inst->HasOrnamentation()) //instance is not null and does have an ornament aug (slot 20) { - ss.write(item->IDFile, strlen(item->IDFile)); + ItemInst* ornamentation = inst->GetOrnamentation(); + if (ornamentation) //paranoid! + { + ss.write(ornamentation->GetItem()->IDFile, strlen(ornamentation->GetItem()->IDFile)); + } + else if (strlen(item->IDFile) > 0) + { + ss.write(item->IDFile, strlen(item->IDFile)); + } ss.write((const char*)&null_term, sizeof(uint8)); } - else + else //original code although I shortened it { + if (strlen(item->IDFile) > 0) + { + ss.write(item->IDFile, strlen(item->IDFile)); + } ss.write((const char*)&null_term, sizeof(uint8)); } diff --git a/world/worlddb.cpp b/world/worlddb.cpp index ab8f6099a..cd3e93cd6 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -197,14 +197,26 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct* cs->cs_colors[char_num][material].color = color; // the weapons are kept elsewhere - if ((material==MaterialPrimary) || (material==MaterialSecondary)) + if ((material == MaterialPrimary) || (material == MaterialSecondary)) { - if(strlen(item->GetItem()->IDFile) > 2) { - uint32 idfile=atoi(&item->GetItem()->IDFile[2]); - if (material==MaterialPrimary) - cs->primary[char_num]=idfile; + if (strlen(item->GetItem()->IDFile) > 2) { + uint32 idfile = 0; + if (item->HasOrnamentation()) + { + ItemInst* ornament = item->GetOrnamentation(); + if (strlen(ornament->GetItem()->IDFile) > 2) + { + idfile = atoi(&ornament->GetItem()->IDFile[2]); + } + } else - cs->secondary[char_num]=idfile; + { + idfile = atoi(&item->GetItem()->IDFile[2]); + } + if (material == MaterialPrimary) + cs->primary[char_num] = idfile; + else + cs->secondary[char_num] = idfile; } } }