Skip to content

Commit

Permalink
Merge pull request OpenEnroth#1951 from captainurist/macos_fixes_633
Browse files Browse the repository at this point in the history
  • Loading branch information
captainurist authored Feb 23, 2025
2 parents b1d6c15 + 37b4240 commit 0daaa01
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Engine/Objects/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6119,7 +6119,7 @@ bool Character::hasUnderwaterSuitEquipped() {
return true;
}

bool Character::hasItem(ItemId uItemID, bool checkHeldItem) {
bool Character::hasItem(ItemId uItemID, bool checkHeldItem) const {
if (!checkHeldItem || pParty->pPickedItem.itemId != uItemID) {
for (unsigned i = 0; i < INVENTORY_SLOT_COUNT; ++i) {
if (this->pInventoryMatrix[i] > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Objects/Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class Character {
/**
* @offset 0x43EE15
*/
bool hasItem(ItemId uItemID, bool checkHeldItem);
bool hasItem(ItemId uItemID, bool checkHeldItem) const;
void OnInventoryLeftClick();

bool characterHitOrMiss(Actor *pActor, int distancemod, int skillmod);
Expand Down
2 changes: 1 addition & 1 deletion test/Bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
ExternalProject_Add(OpenEnroth_TestData
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/test_data_tmp
GIT_REPOSITORY https://github.com/OpenEnroth/OpenEnroth_TestData.git
GIT_TAG c0803c62f32eb13a5569957eb1f60a74f8872e0d
GIT_TAG edc30aa266c295aa2f6cb869a43a7e95a4e75ac9
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/test_data
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
11 changes: 11 additions & 0 deletions test/Bin/GameTest/GameTests_1500.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,17 @@ GAME_TEST(Issues, Issue1911) {
EXPECT_EQ(pParty->pCharacters[0].GetActualAttack(true), 14); // +10 from staff, +4 from unarmed.
}

GAME_TEST(Issues, Issue1912) {
// Trading a Red Potion for a Wealthy Hat doesn't remove the potion from the inventory.
auto potionTape = charTapes.hasItem(ITEM_POTION_CURE_WOUNDS);
auto hatTape = charTapes.hasItem(ITEM_QUEST_WEALTHY_HAT);
auto activeCharTape = tapes.activeCharacterIndex();
test.playTraceFromTestData("issue_1912.mm7", "issue_1912.json");
EXPECT_EQ(activeCharTape, tape(1)); // First char was talking.
EXPECT_EQ(potionTape, tape({false, true, false, false}, {false, false, false, false})); // But 2nd char had the potion.
EXPECT_EQ(hatTape, tape({false, false, false, false}, {true, false, false, false})); // We passed the hat to the 1st char.
}

GAME_TEST(Issues, Issue1925) {
// Test for wand behaviour.
for (bool wandsDisappear : {true, false}) {
Expand Down
8 changes: 8 additions & 0 deletions test/Testing/Game/CharacterTapeRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,11 @@ TestTape<SpellId> CharacterTapeRecorder::quickSpell(int characterIndex) {
TestMultiTape<SpellId> CharacterTapeRecorder::quickSpells() {
return custom(std::bind(&Character::uQuickSpell, _1));
}

TestTape<bool> CharacterTapeRecorder::hasItem(int characterIndex, ItemId itemId) {
return custom(characterIndex, std::bind(&Character::hasItem, _1, itemId, false));
}

TestMultiTape<bool> CharacterTapeRecorder::hasItem(ItemId itemId) {
return custom(std::bind(&Character::hasItem, _1, itemId, false));
}
3 changes: 3 additions & 0 deletions test/Testing/Game/CharacterTapeRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class CharacterTapeRecorder {
TestTape<SpellId> quickSpell(int characterIndex);
TestMultiTape<SpellId> quickSpells();

TestTape<bool> hasItem(int characterIndex, ItemId itemId);
TestMultiTape<bool> hasItem(ItemId itemId);

private:
static std::span<Character> characters();

Expand Down

0 comments on commit 0daaa01

Please sign in to comment.