diff --git a/D2Editor.exe b/D2Editor.exe index 845d0e89..878a0c27 100644 Binary files a/D2Editor.exe and b/D2Editor.exe differ diff --git a/readme.md b/readme.md index 5448c0b4..3a61b8dd 100644 --- a/readme.md +++ b/readme.md @@ -77,6 +77,7 @@ Check the following site for updates at https://github.com/WalterCouto/D2CE
**Version 2.14 (Mar 7, 2022)** - Updated: Updated jewel alternate images.
- Updated: Updated item context menus across forms showing items.
+- Updated: Fixed hiring of new mercenary to properly save items.

- Added: Shared Stash support. Users can now view and edit items in the shared stash if the file is present in the same location as their character.
diff --git a/source/D2Editor.cpp b/source/D2Editor.cpp index 857f09cb..38ecd828 100644 --- a/source/D2Editor.cpp +++ b/source/D2Editor.cpp @@ -18,10 +18,11 @@ Revision History ================ -Version 2.14 (Mar 7, 2022) +Version 2.14 (Mar 11, 2022) - Updated: Updated jewel alternate images. - Updated: Updated item context menus across forms showing items. + - Updated: Fixed hiring of new mercenary to properly save items. - Added: Shared Stash support. Users can now view and edit items in the shared stash if the file is present in the diff --git a/source/D2ItemToolTipCtrl.cpp b/source/D2ItemToolTipCtrl.cpp index 7b44f150..d3cb7a4e 100644 --- a/source/D2ItemToolTipCtrl.cpp +++ b/source/D2ItemToolTipCtrl.cpp @@ -91,29 +91,49 @@ CSize CD2ItemToolTipCtrl::OnDrawLabel(CDC* pDC, CRect rect, BOOL bCalcOnly) enum { WHITE = 0, BLUE, GREEN, RARE, UNIQUE, CRAFT, RED, GRAY }; // Get color of top text - COLORREF color = CurrItem->isIdentified() ? (CurrItem->isEthereal() ? colors[GRAY] : colors[WHITE]) : colors[RED]; - switch (CurrItem->getQuality()) + COLORREF color = colors[WHITE]; + if (CurrItem->isIdentified()) { - case d2ce::EnumItemQuality::MAGIC: - color = colors[BLUE]; - break; - - case d2ce::EnumItemQuality::SET: - color = colors[GREEN]; - break; - - case d2ce::EnumItemQuality::RARE: - color = colors[RARE]; - break; - - case d2ce::EnumItemQuality::UNIQUE: - color = colors[UNIQUE]; - break; + if (CurrItem->isEthereal()) + { + color = colors[GRAY]; + } + else if (CurrItem->isQuestItem()) + { + color = colors[UNIQUE]; + } + else if (CurrItem->isRune()) + { + color = colors[CRAFT]; + } - case d2ce::EnumItemQuality::CRAFT: - case d2ce::EnumItemQuality::TEMPERED: - color = colors[CRAFT]; - break; + switch (CurrItem->getQuality()) + { + case d2ce::EnumItemQuality::MAGIC: + color = colors[BLUE]; + break; + + case d2ce::EnumItemQuality::SET: + color = colors[GREEN]; + break; + + case d2ce::EnumItemQuality::RARE: + color = colors[RARE]; + break; + + case d2ce::EnumItemQuality::UNIQUE: + color = colors[UNIQUE]; + break; + + case d2ce::EnumItemQuality::CRAFT: + case d2ce::EnumItemQuality::TEMPERED: + color = colors[CRAFT]; + break; + } + } + else + { + color = colors[RED]; } pDC->SetTextColor(color); diff --git a/source/d2ce/Character.cpp b/source/d2ce/Character.cpp index 9e1ebeb5..efc54ea1 100644 --- a/source/d2ce/Character.cpp +++ b/source/d2ce/Character.cpp @@ -1727,7 +1727,7 @@ bool d2ce::Character::writeStats() //--------------------------------------------------------------------------- bool d2ce::Character::writeItems() { - return m_items.writeItems(m_charfile, isExpansionCharacter()); + return m_items.writeItems(m_charfile, isExpansionCharacter(), hasMercenary()); } //--------------------------------------------------------------------------- /* @@ -1758,7 +1758,7 @@ void d2ce::Character::writeTempFile() Cs.writeStats(tempfile); // Write Character, Corpse, Mercenary and Golem m_items - m_items.writeItems(tempfile, isExpansionCharacter()); + m_items.writeItems(tempfile, isExpansionCharacter(), hasMercenary()); std::fclose(tempfile); } //--------------------------------------------------------------------------- @@ -2098,6 +2098,11 @@ std::uint32_t d2ce::Character::getFileSize() const return FileSize; } //--------------------------------------------------------------------------- +bool d2ce::Character::hasMercenary() const +{ + return Merc.isHired(); +} +//--------------------------------------------------------------------------- d2ce::Mercenary& d2ce::Character::getMercenaryInfo() { return Merc; diff --git a/source/d2ce/Character.h b/source/d2ce/Character.h index aef6ffe4..735ded9f 100644 --- a/source/d2ce/Character.h +++ b/source/d2ce/Character.h @@ -151,6 +151,7 @@ namespace d2ce std::uint32_t getFileSize() const; // Mercenary Info + bool hasMercenary() const; Mercenary& getMercenaryInfo(); const std::list& getMercItems() const; diff --git a/source/d2ce/Item.cpp b/source/d2ce/Item.cpp index 723dfa87..bef65d1d 100644 --- a/source/d2ce/Item.cpp +++ b/source/d2ce/Item.cpp @@ -11862,7 +11862,7 @@ void d2ce::Items::readMercItems(std::FILE* charfile) } } - // lock ahead for no merc case + // look ahead for no merc case bool bHasMercId = true; if (!feof(charfile)) { @@ -11884,6 +11884,7 @@ void d2ce::Items::readMercItems(std::FILE* charfile) { return; } + isMercHired = true; } readGolemItem(charfile); @@ -11982,6 +11983,7 @@ void d2ce::Items::readMercItems(const Json::Value& root, bool bSerializedFormat, std::fwrite(ITEM_MARKER.data(), ITEM_MARKER.size(), 1, charfile); std::fwrite(&NumOfMercItems, sizeof(NumOfMercItems), 1, charfile); merc_location = std::ftell(charfile); + isMercHired = true; for (auto& item : MercItems) { if (!item.writeItem(charfile)) @@ -12179,11 +12181,11 @@ bool d2ce::Items::writeMercItems(std::FILE* charfile) std::fwrite(MERC_ITEM_MARKER.data(), MERC_ITEM_MARKER.size(), 1, charfile); NumOfMercItems = (std::uint16_t)MercItems.size(); - if (merc_location != 0) + if (NumOfMercItems > 0 || isMercHired) { + isMercHired = true; std::fwrite(ITEM_MARKER.data(), ITEM_MARKER.size(), 1, charfile); std::fwrite(&NumOfMercItems, sizeof(NumOfMercItems), 1, charfile); - merc_location = std::ftell(charfile); for (auto& item : MercItems) { if (!item.writeItem(charfile)) @@ -12215,6 +12217,7 @@ bool d2ce::Items::readItems(EnumCharVersion version, std::FILE* charfile, bool i Version = version; update_locations = items_location == 0 ? true : false; isFileExpansionCharacter = isExpansion; + isMercHired = false; GPSs.clear(); Stackables.clear(); Armor.clear(); @@ -12241,6 +12244,7 @@ bool d2ce::Items::readSharedStashPage(EnumCharVersion version, std::FILE* charfi Version = version; update_locations = items_location == 0 ? true : false; isFileExpansionCharacter = false; + isMercHired = false; GPSs.clear(); Stackables.clear(); Armor.clear(); @@ -12261,6 +12265,7 @@ bool d2ce::Items::readItems(const Json::Value& root, bool bSerializedFormat, Enu Version = version; update_locations = true; isFileExpansionCharacter = isExpansion; + isMercHired = false; if (!readItems(root, bSerializedFormat, charfile, items_location, NumOfItems, Inventory) || items_location == 0) { return false; @@ -12279,9 +12284,10 @@ bool d2ce::Items::readItems(const Json::Value& root, bool bSerializedFormat, Enu } //--------------------------------------------------------------------------- // write items in place at offset saved from reasding -bool d2ce::Items::writeItems(std::FILE* charfile, bool isExpansion) +bool d2ce::Items::writeItems(std::FILE* charfile, bool isExpansion, bool hasMercID) { isFileExpansionCharacter = isExpansion; + isMercHired = !MercItems.empty() | hasMercID; // Write Items std::fwrite(ITEM_MARKER.data(), ITEM_MARKER.size(), 1, charfile); @@ -12551,6 +12557,7 @@ d2ce::Items& d2ce::Items::operator=(const Items& other) update_locations = other.update_locations; isFileExpansionCharacter = other.isFileExpansionCharacter; + isMercHired = other.isMercHired; // refetch references to items GPSs.clear(); @@ -12605,6 +12612,7 @@ d2ce::Items& d2ce::Items::operator=(Items&& other) noexcept update_locations = std::exchange(other.update_locations, true); isFileExpansionCharacter = std::exchange(other.isFileExpansionCharacter, false); + isMercHired = std::exchange(other.isMercHired, false); return *this; } //--------------------------------------------------------------------------- diff --git a/source/d2ce/Item.h b/source/d2ce/Item.h index a8a04bf9..59255045 100644 --- a/source/d2ce/Item.h +++ b/source/d2ce/Item.h @@ -321,6 +321,7 @@ namespace d2ce bool update_locations = true; bool isFileExpansionCharacter = false; + bool isMercHired = false; private: void findItems(); @@ -348,7 +349,7 @@ namespace d2ce bool readItems(EnumCharVersion version, std::FILE* charfile, bool isExpansion = false); bool readSharedStashPage(EnumCharVersion version, std::FILE* charfile); bool readItems(const Json::Value& root, bool bSerializedFormat, EnumCharVersion version, std::FILE* charfile, bool isExpansion = false); - bool writeItems(std::FILE* charfile, bool isExpansion = false); + bool writeItems(std::FILE* charfile, bool isExpansion = false, bool hasMercID = false); bool writeSharedStashPage(std::FILE* charfile); void itemsAsJson(Json::Value& parent, std::uint32_t charLevel, bool bSerializedFormat = false) const; diff --git a/source/d2ce/helpers/ItemHelpers.cpp b/source/d2ce/helpers/ItemHelpers.cpp index e5eebaaa..d70d736f 100644 --- a/source/d2ce/helpers/ItemHelpers.cpp +++ b/source/d2ce/helpers/ItemHelpers.cpp @@ -1087,7 +1087,7 @@ namespace d2ce {"bbb", {"Lam Esen's Tome", {{ 0, 0 }, false, false, { 0, 0 }}, {0, 0}, {2, 2}, false, "invbbb", 0, {"Quest"}}}, {"mbr", {"Mephisto's Brain", {{ 0, 0 }, false, false, { 0, 0 }}, {0, 0}, {1, 1}, false, "invbrnz", 0, {"Quest"}}}, {"luv", {"Mephisto's Key", {{ 0, 0 }, false, false, { 0, 0 }}, {0, 0}, {1, 2}, false, "invmph", 0, {"Key", "Miscellaneous", "Quest"}}}, - {"mss", {"Mephisto's Soul Stone", {{ 0, 0 }, false, false, { 0, 0 }}, {0, 0}, {1, 1}, false, "invmss", 0, {"Quest"}}}, + {"mss", {"Mephisto's Soulstone", {{ 0, 0 }, false, false, { 0, 0 }}, {0, 0}, {1, 1}, false, "invmss", 0, {"Quest"}}}, {"ass", {"Book of Skill", {{ 0, 0 }, false, false, { 0, 0 }}, {0, 0}, {2, 2}, false, "invsbk", 0, {"Quest"}}}, {"rin", {"Ring", {{ 0, 0 }, false, false, { 0, 0 }}, {0, 0}, {1, 1}, false, "invrin", 0, {"Ring", "Miscellaneous"}}}, {"xyz", {"Potion of Life", {{ 0, 0 }, false, false, { 0, 0 }}, {0, 0}, {1, 1}, false, "invxyz", 0, {"Quest"}}}, diff --git a/source/examples/chars/97/MfBowzon.json b/source/examples/chars/97/MfBowzon.json index b1b3a587..5d0ea0b7 100644 --- a/source/examples/chars/97/MfBowzon.json +++ b/source/examples/chars/97/MfBowzon.json @@ -9657,7 +9657,7 @@ "type_id": 4, "quest_difficulty": 1, "nr_of_items_in_sockets": 0, - "type_name": "Mephisto's Soul Stone", + "type_name": "Mephisto's Soulstone", "inv_file": "invmss", "inv_height": 1, "inv_width": 1