Skip to content

Commit

Permalink
fix up bugs for unique items that incorrectly showed incorrect in som…
Browse files Browse the repository at this point in the history
…e cases, like the new 2.5 Charms
  • Loading branch information
WalterCouto committed Oct 3, 2022
1 parent bbe70ff commit 20c3406
Show file tree
Hide file tree
Showing 26 changed files with 8,040 additions and 45 deletions.
Binary file modified D2Editor.exe
Binary file not shown.
12 changes: 6 additions & 6 deletions D2EditorPadFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
</Company_Info>
<Program_Info>
<Program_Name>Diablo II Character Editor</Program_Name>
<Program_Version>2.1.6</Program_Version>
<Program_Release_Month>06</Program_Release_Month>
<Program_Release_Day>05</Program_Release_Day>
<Program_Version>2.1.9</Program_Version>
<Program_Release_Month>10</Program_Release_Month>
<Program_Release_Day>03</Program_Release_Day>
<Program_Release_Year>2022</Program_Release_Year>
<Program_Cost_Dollars>0</Program_Cost_Dollars>
<Program_Cost_Other_Code>CAD</Program_Cost_Other_Code>
Expand All @@ -51,9 +51,9 @@
<Program_Category_Class />
<Program_System_Requirements />
<File_Info>
<File_Size_Bytes>19513856</File_Size_Bytes>
<File_Size_K>19056</File_Size_K>
<File_Size_MB>18.6</File_Size_MB>
<File_Size_Bytes>19676672</File_Size_Bytes>
<File_Size_K>19215</File_Size_K>
<File_Size_MB>18.7</File_Size_MB>
</File_Info>
<Expire_Info>
<Has_Expire_Info>N</Has_Expire_Info>
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Check the following site for updates at https://github.com/WalterCouto/D2CE<br>
* [d2s Binary File Format](d2s_File_Format.md)<br>

### Revision History
**Version 2.19 (October 3, 2022)**
- Updated: fix up bugs for unique items that incorrectly showed incorrect in some cases, like the new 2.5 Charms<br>
<br>

**Version 2.18 (October 2, 2022)**
- Updated: allow poison and cold max attribute to be specified on it's own<br>
- Updated: Fix up tooltip display when min and max damage are both present<br>
Expand Down
4 changes: 4 additions & 0 deletions source/D2Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
Revision History
================
Version 2.19 (October 3, 2022)
- Updated: fix up bugs for unique items that incorrectly showed incorrect
in some cases, like the new 2.5 Charms
Version 2.18 (October 2, 2022)
- Updated: allow poison and cold max attribute to be specified on it's own
- Updated: Fix up tooltip display when min and max damage are both present
Expand Down
2 changes: 2 additions & 0 deletions source/d2ce/DataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,8 @@ namespace d2ce
virtual std::string getPotionDesc(EnumCharClass charClass) const;

virtual const std::string& getRuneLetter() const;
virtual const std::string& getTypeName() const; // return the parent type name, or if no parent it's name

};

struct RunewordType
Expand Down
12 changes: 6 additions & 6 deletions source/d2ce/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9409,18 +9409,18 @@ std::string d2ce::Item::getDisplayedItemName() const
ss << LocalizationHelpers::string_formatDiablo(strFormat, personalizedName, setAttrib.Name);
}

ss << '\n' << itemType.name;
ss << '\n' << itemType.getTypeName();
}
else
{
if (personalizedName.empty())
{
ss << itemType.name;
ss << itemType.getTypeName();
}
else
{
LocalizationHelpers::GetStringTxtValue("ChampionFormat", strFormat, "%0 %1");
ss << LocalizationHelpers::string_formatDiablo(strFormat, personalizedName, itemType.name);
ss << LocalizationHelpers::string_formatDiablo(strFormat, personalizedName, itemType.getTypeName());
}
}
break;
Expand Down Expand Up @@ -9517,7 +9517,7 @@ std::string d2ce::Item::getDisplayedItemName() const

if (!itemType.skipName)
{
ss << '\n' << itemType.name;
ss << '\n' << itemType.getTypeName();
}
}
else
Expand All @@ -9526,12 +9526,12 @@ std::string d2ce::Item::getDisplayedItemName() const
ss << itemType.name;
if (personalizedName.empty())
{
ss << itemType.name;
ss << itemType.getTypeName();
}
else
{
LocalizationHelpers::GetStringTxtValue("ChampionFormat", strFormat, "%0 %1");
ss << LocalizationHelpers::string_formatDiablo(strFormat, personalizedName, itemType.name);
ss << LocalizationHelpers::string_formatDiablo(strFormat, personalizedName, itemType.getTypeName());
}
}
break;
Expand Down
45 changes: 39 additions & 6 deletions source/d2ce/helpers/ItemHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace d2ce
#define read_uint32_bits(start,size) \
((*((std::uint32_t *) &data[(start) / 8]) >> ((start) & 7))& (((std::uint32_t)1 << (size)) - 1))

void ConvertPlaceHolders(std::string& descstr, size_t idxOffset = 0)
void ConvertPlaceHolders(std::string& descstr, size_t idxOffset = 0, bool negative = false)
{
static std::regex re{ "(%([+]?[id]|s))" };
static std::regex reAlt{ "(%[+]?[0-9])" };
Expand All @@ -119,7 +119,7 @@ namespace d2ce
while (strPos != descstr.npos)
{
std::stringstream ss2;
if (strFind.find("+") != strFind.npos)
if (strFind.find("+") != strFind.npos && !negative)
{
ss2 << "+";
}
Expand Down Expand Up @@ -156,9 +156,17 @@ namespace d2ce
void ConvertPlaceHolders(std::string& descstrpos, std::string& descstrneg, bool bGenerateNeg = false, size_t idxOffset = 0)
{
ConvertPlaceHolders(descstrpos, idxOffset);
if (!bGenerateNeg)
{
if (descstrpos.find("+{") != descstrpos.npos)
{
bGenerateNeg = true;
}
}

if (bGenerateNeg)
{
ConvertPlaceHolders(descstrneg, idxOffset);
ConvertPlaceHolders(descstrneg, idxOffset, true);
}
else
{
Expand Down Expand Up @@ -5171,6 +5179,8 @@ namespace d2ce

struct ItemUniqueType : public ItemType
{
std::string typeName; // name of the parent type

std::uint16_t id = 0; // index of the unique item

std::string index; // The ID pointer that is referenced by the game in TreasureClassEx.txt and CubeMain.txt, this also controls the string that will be used to display the item's name in-game.
Expand All @@ -5189,8 +5199,14 @@ namespace d2ce
return id;
}

const std::string& getTypeName() const override // return the parent type name
{
return typeName;
}

void CopyParentItem(const ItemType& parent)
{
typeName = parent.name;
compactsave = parent.compactsave;
ac = parent.ac;
dam = parent.dam;
Expand All @@ -5207,7 +5223,7 @@ namespace d2ce
inv_file = parent.inv_file;
nameable = parent.nameable;
beltable = parent.beltable;
skipName = parent.skipName;
skipName = typeName.empty() ? true : parent.skipName;
spellDesc = parent.spellDesc;
bodyLocations = parent.bodyLocations;
quiverCode = parent.quiverCode;
Expand Down Expand Up @@ -5415,7 +5431,11 @@ namespace d2ce
}
}

itemType.inv_file = doc.GetCellString(invfileColumnIdx, i);
strValue = doc.GetCellString(invfileColumnIdx, i);
if (!strValue.empty())
{
itemType.inv_file = strValue;
}
itemType.transform_color = doc.GetCellString(invtransformColumnIdx, i);

for (size_t idx = 0; idx < modParamSize; ++idx)
Expand Down Expand Up @@ -5768,6 +5788,8 @@ namespace d2ce

struct ItemSetItemType : public ItemType
{
std::string typeName; // name of the parent type

std::uint16_t id = 0; // index of the set item

std::string index; // string key to item's name
Expand Down Expand Up @@ -5893,8 +5915,14 @@ namespace d2ce
return std::uint16_t(bonusBits.to_ulong());
}

const std::string& getTypeName() const override // return the parent type name
{
return typeName;
}

void CopyParentItem(const ItemType& parent)
{
typeName = parent.name;
compactsave = parent.compactsave;
ac = parent.ac;
dam = parent.dam;
Expand All @@ -5911,7 +5939,7 @@ namespace d2ce
inv_file = parent.inv_file;
nameable = parent.nameable;
beltable = parent.beltable;
skipName = parent.skipName;
skipName = typeName.empty() ? true : parent.skipName;
spellDesc = parent.spellDesc;
bodyLocations = parent.bodyLocations;
quiverCode = parent.quiverCode;
Expand Down Expand Up @@ -8532,6 +8560,11 @@ const std::string& d2ce::ItemType::getRuneLetter() const
return iter->second.letter;
}
//---------------------------------------------------------------------------
const std::string& d2ce::ItemType::getTypeName() const
{
return name;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
void d2ce::ItemHelpers::setTxtReader(const d2ce::ITxtReader& txtReader)
Expand Down
32 changes: 32 additions & 0 deletions source/d2ceTests/D2EditorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,16 @@ namespace D2EditorTests
TestOpenBase("Spartacus.d2s", d2ce::EnumCharVersion::v140, true);
}

TEST_METHOD(TestOpen46)
{
TestOpenBase("Charming.d2s", d2ce::EnumCharVersion::v140, true);
}

TEST_METHOD(TestOpen47)
{
TestOpenBase("HCharming.d2s", d2ce::EnumCharVersion::v140, true);
}

TEST_METHOD(TestJsonExport01)
{
TestJsonExportBase("Merlina.d2s", d2ce::EnumCharVersion::v110, true);
Expand Down Expand Up @@ -902,6 +912,16 @@ namespace D2EditorTests
TestJsonExportBase("Spartacus.d2s", d2ce::EnumCharVersion::v140, true, false);
}

TEST_METHOD(TestJsonExport54)
{
TestJsonExportBase("Charming.d2s", d2ce::EnumCharVersion::v140, true, false);
}

TEST_METHOD(TestJsonExport55)
{
TestJsonExportBase("HCharming.d2s", d2ce::EnumCharVersion::v140, true, false);
}

TEST_METHOD(TestJsonOpen01)
{
d2ce::Character character;
Expand Down Expand Up @@ -1223,6 +1243,18 @@ namespace D2EditorTests
Assert::IsTrue(LoadCharFile("Spartacus.json", character, d2ce::EnumCharVersion::v140, true));
}

TEST_METHOD(TestJsonOpen56)
{
d2ce::Character character;
Assert::IsTrue(LoadCharFile("Charming.json", character, d2ce::EnumCharVersion::v140, true));
}

TEST_METHOD(TestJsonOpen57)
{
d2ce::Character character;
Assert::IsTrue(LoadCharFile("HCharming.json", character, d2ce::EnumCharVersion::v140, true));
}

TEST_METHOD(TestJsonTestComplexChange01)
{
d2ce::Character character;
Expand Down
60 changes: 60 additions & 0 deletions source/d2ceTests/D2EditorTests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,66 @@
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\examples\chars\99\Charming.d2s">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\examples\chars\99\Charming.json">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\examples\chars\99\HCharming.d2s">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\examples\chars\99\HCharming.json">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" "$(OutDir)examples\char\99\"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copy %(FullPath) To $(OutDir)examples\char\99\</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)examples\char\99\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
<None Include="d2ce\thirdparty\rapidcsv\LICENSE" />
<CustomBuild Include="..\examples\chars\96\WhirlWind_serialized.json">
<FileType>Document</FileType>
Expand Down
12 changes: 12 additions & 0 deletions source/d2ceTests/D2EditorTests.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,18 @@
<CustomBuild Include="..\examples\chars\99\Spartacus.json">
<Filter>examples\char\99</Filter>
</CustomBuild>
<CustomBuild Include="..\examples\chars\99\Charming.d2s">
<Filter>examples\char\99</Filter>
</CustomBuild>
<CustomBuild Include="..\examples\chars\99\Charming.json">
<Filter>examples\char\99</Filter>
</CustomBuild>
<CustomBuild Include="..\examples\chars\99\HCharming.d2s">
<Filter>examples\char\99</Filter>
</CustomBuild>
<CustomBuild Include="..\examples\chars\99\HCharming.json">
<Filter>examples\char\99</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<None Include="..\d2ce\thirdparty\jsoncpp\src\lib_json\json_valueiterator.inl">
Expand Down
4 changes: 2 additions & 2 deletions source/examples/chars/96/Blizzard.json
Original file line number Diff line number Diff line change
Expand Up @@ -8186,7 +8186,7 @@
-50
],
"name": "item_req_percent",
"description": "Requirements +-50%"
"description": "Requirements -50%"
}
],
"displayed_runeword_attributes": [],
Expand Down Expand Up @@ -8359,7 +8359,7 @@
-50
],
"name": "item_req_percent",
"description": "Requirements +-50%"
"description": "Requirements -50%"
}
]
},
Expand Down
Loading

0 comments on commit 20c3406

Please sign in to comment.