diff --git a/src/Engine/Graphics/Indoor.cpp b/src/Engine/Graphics/Indoor.cpp index a8945d456fed..5cd59f118753 100644 --- a/src/Engine/Graphics/Indoor.cpp +++ b/src/Engine/Graphics/Indoor.cpp @@ -2046,7 +2046,7 @@ void SpawnRandomTreasure(MapInfo *mapInfo, SpawnPoint *a2) { a1a.uType = pItemTable->pItems[a1a.containing_item.uItemID].uSpriteID; a1a.containing_item.SetIdentified(); a1a.uObjectDescID = pObjectList->ObjectIDByItemID(a1a.uType); - a1a.containing_item.special_enchantment = (ItemEnchantment)v34; + a1a.containing_item.goldAmount = v34; } else { if (!a1a.containing_item.GenerateArtifact()) return; diff --git a/test/Bin/GameTest/CMakeLists.txt b/test/Bin/GameTest/CMakeLists.txt index 87c02e2287b5..683afca4808c 100644 --- a/test/Bin/GameTest/CMakeLists.txt +++ b/test/Bin/GameTest/CMakeLists.txt @@ -19,7 +19,7 @@ if(OE_BUILD_TESTS) ExternalProject_Add(OpenEnroth_TestData PREFIX ${CMAKE_CURRENT_BINARY_DIR}/test_data_tmp GIT_REPOSITORY https://github.com/OpenEnroth/OpenEnroth_TestData.git - GIT_TAG a880c8bc91c4bfb16398c4064529cb4857a74dc6 + GIT_TAG 10ddfb20b6b1196158a3e8740c31e55d1830ee4c SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/test_data CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/test/Bin/GameTest/GameTests.cpp b/test/Bin/GameTest/GameTests.cpp index b752f8c7aa35..d9e99bc317fb 100644 --- a/test/Bin/GameTest/GameTests.cpp +++ b/test/Bin/GameTest/GameTests.cpp @@ -1727,7 +1727,8 @@ GAME_TEST(Issues, Issue1340) { auto statusTape = tapes.statusBar(); auto screenTape = tapes.screen(); test.playTraceFromTestData("issue_1340.mm7", "issue_1340.json"); - EXPECT_EQ(mapTape, tape("out01.odm", "d29.blv")); // Emerald Isle -> Castle Harmondale. + EXPECT_EQ(mapTape, tape("out01.odm", "d29.blv")); // Emerald Isle -> Castle Harmondale. Map change is important because + // we want to trigger map respawn on first visit. EXPECT_TRUE(screenTape.contains(SCREEN_CHEST)); EXPECT_GT(goldTape.delta(), 0); // Party should have picked some gold from the chest. EXPECT_FALSE(statusTape.contains("You found 0 gold!")); // No piles of 0 size. @@ -1748,3 +1749,19 @@ GAME_TEST(Issues, Issue1341) { EXPECT_TRUE(statusTape.contains(fmt::format("Roderick stole {} gold!", peasantGoldTape.max()))); // And succeeded. EXPECT_EQ(deadTape, tape(0)); // No one died in the process. } + +GAME_TEST(Issues, Issue1342) { + // Gold piles are generated with 0 gold. + auto goldTape = tapes.gold(); + auto pilesTape = tapes.mapItemCount(ITEM_GOLD_SMALL); + auto statusTape = tapes.statusBar(); + auto mapTape = tapes.map(); + test.playTraceFromTestData("issue_1342.mm7", "issue_1342.json"); + EXPECT_EQ(mapTape, tape("out01.odm", "d28.blv")); // Emerald Isle -> Dragon Cave. Map change is important here + // because we need to trigger map respawn on first visit. + EXPECT_GT(goldTape.delta(), 0); // We picked up some gold. + EXPECT_EQ(pilesTape, tape(0, 6, 5, 4)); // Minus two small gold piles. + EXPECT_FALSE(statusTape.contains("You found 0 gold!")); // No piles of 0 size. + for (int gold : goldTape.adjacentDeltas()) + EXPECT_TRUE(statusTape.contains(fmt::format("You found {} gold!", gold))); +} diff --git a/test/Testing/Game/CommonTapeRecorder.cpp b/test/Testing/Game/CommonTapeRecorder.cpp index 5d8e0f3d340c..58b65ac3c3e0 100644 --- a/test/Testing/Game/CommonTapeRecorder.cpp +++ b/test/Testing/Game/CommonTapeRecorder.cpp @@ -100,7 +100,7 @@ TestTape CommonTapeRecorder::turnBasedMode() { TestTape CommonTapeRecorder::mapItemCount() { return custom([] { return static_cast(std::ranges::count_if(pSpriteObjects, [] (const SpriteObject &object) { - return object.containing_item.uItemID != ITEM_NULL; + return object.uObjectDescID != 0 && object.containing_item.uItemID != ITEM_NULL; })); }); } @@ -108,7 +108,7 @@ TestTape CommonTapeRecorder::mapItemCount() { TestTape CommonTapeRecorder::mapItemCount(ItemId itemId) { return custom([itemId] { return static_cast(std::ranges::count_if(pSpriteObjects, [itemId] (const SpriteObject &object) { - return object.containing_item.uItemID == itemId; + return object.uObjectDescID != 0 && object.containing_item.uItemID == itemId; })); }); }