diff --git a/src/Engine/Objects/Chest.cpp b/src/Engine/Objects/Chest.cpp index 23faa09109e5..2577b40fdd68 100644 --- a/src/Engine/Objects/Chest.cpp +++ b/src/Engine/Objects/Chest.cpp @@ -593,7 +593,7 @@ void GenerateItemsInChest() { break; } currItem->SetIdentified(); - currItem->special_enchantment = (ItemEnchantment)goldAmount; + currItem->goldAmount = goldAmount; } else { pItemTable->generateItem(resultTreasureLevel, RANDOM_ITEM_ANY, currItem); } diff --git a/test/Bin/GameTest/CMakeLists.txt b/test/Bin/GameTest/CMakeLists.txt index efa63552ab75..04be3775b68d 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 00fd069134db2f7a85643a6c46de4733b0bfbd21 + GIT_TAG b11f684625eb68dde884b53525212073ae96d2dd 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 d5493aebb132..e9f86b392661 100644 --- a/test/Bin/GameTest/GameTests.cpp +++ b/test/Bin/GameTest/GameTests.cpp @@ -1707,6 +1707,7 @@ GAME_TEST(Issues, Issue1331) { } GAME_TEST(Issues, Issue1338) { + // Casting telepathy on an actor and then killing it results in the actor not dropping any gold. auto deadTape = actorTapes.indicesByState(AIState::Dead); auto statusTape = tapes.statusBar(); auto goldTape = tapes.gold(); @@ -1718,3 +1719,18 @@ GAME_TEST(Issues, Issue1338) { EXPECT_TRUE(statusTape.contains(fmt::format("{} gold", peasantGoldTape.max()))); // Telepathy status message. EXPECT_TRUE(statusTape.contains(fmt::format("You found {} gold!", peasantGoldTape.max()))); // Corpse pickup message. } + +GAME_TEST(Issues, Issue1340) { + // Gold piles in chests are generated with 0 gold. + auto goldTape = tapes.gold(); + auto mapTape = tapes.map(); + 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_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. + for (int gold : goldTape.adjacentDeltas()) + EXPECT_TRUE(statusTape.contains(fmt::format("You found {} gold!", gold))); +}