Skip to content

Commit eff2c4c

Browse files
committed
depot test
1 parent f0e3136 commit eff2c4c

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/Container.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,16 @@ class Container {
8585

8686
[[nodiscard]] auto getFirstFreeSlot() const -> TYPE_OF_CONTAINERSLOTS;
8787

88-
[[nodiscard]] inline auto isDepot() const -> bool { return itemId == DEPOTITEM; }
88+
89+
[[nodiscard]] inline auto isDepot() const -> bool {
90+
91+
for (const auto& DEPOTITEM : DEPOTITEMS) {
92+
if (itemId == DEPOTITEM) {
93+
return true;
94+
}
95+
}
96+
return false;
97+
}
8998

9099
private:
91100
static constexpr auto maximumRecursionDepth = 100;

src/Player.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,26 @@ auto Player::lookIntoContainerOnField(direction dir) -> bool {
409409
map::Field &field = World::get()->fieldAt(containerPosition);
410410
Item item;
411411

412+
int isIdInDepotArray(int itemId) {
413+
for (const auto& DEPOTITEM : DEPOTITEMS) {
414+
if (itemId == DEPOTITEM) {
415+
return true;
416+
}
417+
}
418+
return false;
419+
}
420+
421+
412422
if (field.viewItemOnStack(item)) {
413-
if (item.getId() != DEPOTITEM && item.isContainer()) {
423+
if (isIdInDepotArray(item.getId()) && item.isContainer()) {
414424
auto it = field.containers.find(item.getNumber());
415425

416426
if (it != field.containers.end()) {
417427
openShowcase(it->second, static_cast<ScriptItem>(item), false);
418428
return true;
419429
}
420430
} else {
421-
if (item.getId() == DEPOTITEM) {
431+
if (isIdInDepotArray(item.getId())) {
422432
ScriptItem scriptItem(item);
423433
scriptItem.type = ScriptItem::it_field;
424434
scriptItem.pos = containerPosition;
@@ -1436,7 +1446,7 @@ auto Player::load() noexcept -> bool {
14361446

14371447
for (size_t i = 0; i < depotRows; ++i) {
14381448
if (depotid[i] != 0) {
1439-
depotContents[depotid[i]] = new Container(DEPOTITEM);
1449+
depotContents[depotid[i]] = new Container(321);
14401450
depots[depotid[i]] = depotContents[depotid[i]];
14411451
}
14421452
}
@@ -1919,7 +1929,7 @@ void Player::openDepot(const ScriptItem &item) {
19191929
openShowcase(depotContents[depotid], item, false);
19201930
}
19211931
} else {
1922-
depotContents[depotid] = new Container(DEPOTITEM);
1932+
depotContents[depotid] = new Container(item.getId());
19231933
openShowcase(depotContents[depotid], item, false);
19241934
}
19251935
}

src/constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ constexpr auto WAITINGVALIDATION = 1;
5757
constexpr auto BANNED = 30;
5858
constexpr auto BANNEDFORTIME = 31;
5959

60-
constexpr auto DEPOTITEM = 321;
60+
constexpr std::array<int, 2> DEPOTITEMS = {321, 4817};
6161
constexpr auto DEPOTSIZE = 100;
6262
constexpr auto BLOCKEDITEM = 228;
6363

0 commit comments

Comments
 (0)