summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2024-09-08 18:43:05 +0000
committerFedja Beader <fedja@protonmail.ch>2024-09-08 18:43:05 +0000
commit08c37fd2f0d7508d9d3016382747a9722fe0564d (patch)
tree2da8fd5ae19e4892eb8dc26e1001118c7d73fa87 /src
parentdb452921bafb2dd322b52c1e5d03e5e713849dd0 (diff)
downloadplus-08c37fd2f0d7508d9d3016382747a9722fe0564d.tar.gz
plus-08c37fd2f0d7508d9d3016382747a9722fe0564d.tar.bz2
plus-08c37fd2f0d7508d9d3016382747a9722fe0564d.tar.xz
plus-08c37fd2f0d7508d9d3016382747a9722fe0564d.zip
Refactor outfit saving logic
Shaves some bytes from exe, too **** mana/plus!102
Diffstat (limited to 'src')
-rw-r--r--src/gui/windows/outfitwindow.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index cd015a114..390f31525 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -181,31 +181,41 @@ void OutfitWindow::save() const
std::string outfitColorsStr;
for (unsigned o = 0; o < OUTFITS_COUNT; o++)
{
- bool good = false;
+ bool isEmpty = true;
for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
{
const int val = mItems[o][i];
- const int res = val != 0 ? val : -1;
- if (res != -1)
- good = true;
+ // Not sure why, but "empty" is stored as -1 instead of 0.
+ int res;
+ if (val == 0)
+ res = -1;
+ else
+ {
+ isEmpty = false;
+ res = val;
+ }
+
outfitStr.append(toString(res));
+ outfitColorsStr.append(toString(CAST_S32(mItemColors[o][i])));
+
if (i < OUTFIT_ITEM_COUNT - 1)
+ {
outfitStr.append(" ");
- outfitColorsStr.append(toString(CAST_S32(
- toInt(mItemColors[o][i], int))));
- if (i < OUTFIT_ITEM_COUNT - 1)
outfitColorsStr.append(" ");
+ }
}
- if (good)
+
+ if (isEmpty)
{
- serverConfig.setValue("Outfit" + toString(o), outfitStr);
- serverConfig.setValue("OutfitColor" + toString(o),
- outfitColorsStr);
+ serverConfig.deleteKey("Outfit" + toString(o));
+ serverConfig.deleteKey("OutfitColor" + toString(o));
}
else
{
- serverConfig.deleteKey("Outfit" + toString(o));
- serverConfig.deleteKey("OutfitColor" + toString(o));
+ serverConfig.setValue("Outfit" + toString(o),
+ outfitStr);
+ serverConfig.setValue("OutfitColor" + toString(o),
+ outfitColorsStr);
}
if (mItemsUnequip[o])