Skip to content

Commit

Permalink
depot test
Browse files Browse the repository at this point in the history
  • Loading branch information
brightrim committed Jan 2, 2025
1 parent f0e3136 commit eff2c4c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ class Container {

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

[[nodiscard]] inline auto isDepot() const -> bool { return itemId == DEPOTITEM; }

[[nodiscard]] inline auto isDepot() const -> bool {

for (const auto& DEPOTITEM : DEPOTITEMS) {
if (itemId == DEPOTITEM) {
return true;
}
}
return false;
}

private:
static constexpr auto maximumRecursionDepth = 100;
Expand Down
18 changes: 14 additions & 4 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,26 @@ auto Player::lookIntoContainerOnField(direction dir) -> bool {
map::Field &field = World::get()->fieldAt(containerPosition);
Item item;

int isIdInDepotArray(int itemId) {
for (const auto& DEPOTITEM : DEPOTITEMS) {
if (itemId == DEPOTITEM) {
return true;
}
}
return false;
}


if (field.viewItemOnStack(item)) {
if (item.getId() != DEPOTITEM && item.isContainer()) {
if (isIdInDepotArray(item.getId()) && item.isContainer()) {
auto it = field.containers.find(item.getNumber());

if (it != field.containers.end()) {
openShowcase(it->second, static_cast<ScriptItem>(item), false);
return true;
}
} else {
if (item.getId() == DEPOTITEM) {
if (isIdInDepotArray(item.getId())) {
ScriptItem scriptItem(item);
scriptItem.type = ScriptItem::it_field;
scriptItem.pos = containerPosition;
Expand Down Expand Up @@ -1436,7 +1446,7 @@ auto Player::load() noexcept -> bool {

for (size_t i = 0; i < depotRows; ++i) {
if (depotid[i] != 0) {
depotContents[depotid[i]] = new Container(DEPOTITEM);
depotContents[depotid[i]] = new Container(321);
depots[depotid[i]] = depotContents[depotid[i]];
}
}
Expand Down Expand Up @@ -1919,7 +1929,7 @@ void Player::openDepot(const ScriptItem &item) {
openShowcase(depotContents[depotid], item, false);
}
} else {
depotContents[depotid] = new Container(DEPOTITEM);
depotContents[depotid] = new Container(item.getId());
openShowcase(depotContents[depotid], item, false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ constexpr auto WAITINGVALIDATION = 1;
constexpr auto BANNED = 30;
constexpr auto BANNEDFORTIME = 31;

constexpr auto DEPOTITEM = 321;
constexpr std::array<int, 2> DEPOTITEMS = {321, 4817};
constexpr auto DEPOTSIZE = 100;
constexpr auto BLOCKEDITEM = 228;

Expand Down

0 comments on commit eff2c4c

Please sign in to comment.