From cea6a01de7943bb000ec2d69e009ae7afa6de757 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Thu, 8 Dec 2022 09:06:32 +0000 Subject: [PATCH] More item packing fix on big-endian Refs #5573 --- Source/pack.cpp | 6 +++--- test/pack_test.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/pack.cpp b/Source/pack.cpp index 41418a79b..1f9e69356 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -50,15 +50,15 @@ void PackItem(ItemPack &packedItem, const Item &item, bool isHellfire) } packedItem.idx = SDL_SwapLE16(idx); if (item.IDidx == IDI_EAR) { - packedItem.iCreateInfo = item._iIName[1] | (item._iIName[0] << 8); - packedItem.iSeed = LoadBE32(&item._iIName[2]); + packedItem.iCreateInfo = SDL_SwapLE16(item._iIName[1] | (item._iIName[0] << 8)); + packedItem.iSeed = SDL_SwapLE32(LoadBE32(&item._iIName[2])); packedItem.bId = item._iIName[6]; packedItem.bDur = item._iIName[7]; packedItem.bMDur = item._iIName[8]; packedItem.bCh = item._iIName[9]; packedItem.bMCh = item._iIName[10]; packedItem.wValue = SDL_SwapLE16(item._ivalue | (item._iIName[11] << 8) | ((item._iCurs - ICURS_EAR_SORCERER) << 6)); - packedItem.dwBuff = LoadBE32(&item._iIName[12]); + packedItem.dwBuff = SDL_SwapLE32(LoadBE32(&item._iIName[12])); } else { packedItem.iSeed = SDL_SwapLE32(item._iSeed); packedItem.iCreateInfo = SDL_SwapLE16(item._iCreateInfo); diff --git a/test/pack_test.cpp b/test/pack_test.cpp index bd24b19c5..8d05d7c81 100644 --- a/test/pack_test.cpp +++ b/test/pack_test.cpp @@ -761,7 +761,7 @@ static void compareGold(const ItemPack &is, int iCurs) ASSERT_EQ(id._iCurs, iCurs); ASSERT_EQ(id.IDidx, IDI_GOLD); // Copy the value out before comparing to avoid loading a misaligned address. - const auto wvalue = is.wValue; + const auto wvalue = SDL_SwapLE16(is.wValue); ASSERT_EQ(id._ivalue, wvalue); ASSERT_EQ(id._itype, ItemType::Gold); ASSERT_EQ(id._iClass, ICLASS_GOLD);