Skip to content

Commit bafe7eb

Browse files
committed
fix: more const ref
1 parent bf79813 commit bafe7eb

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/items/containers/container.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ uint32_t Container::getContainerHoldingCount() {
386386
bool Container::isHoldingItem(const std::shared_ptr<Item> &item) {
387387
for (ContainerIterator it = iterator(); it.hasNext(); it.advance()) {
388388
const auto &compareItem = *it;
389-
if (!compareItem) {
389+
if (!compareItem || !item) {
390390
continue;
391391
}
392392

src/items/containers/mailbox/mailbox.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ bool Mailbox::sendItem(const std::shared_ptr<Item> &item) const {
9999
}
100100
if (player && item) {
101101
const auto &playerInbox = player->getInbox();
102-
if (g_game().internalMoveItem(item->getParent(), playerInbox, INDEX_WHEREEVER, item, item->getItemCount(), nullptr, FLAG_NOLIMIT) == RETURNVALUE_NOERROR) {
102+
const auto &itemParent = item->getParent();
103+
if (g_game().internalMoveItem(itemParent, playerInbox, INDEX_WHEREEVER, item, item->getItemCount(), nullptr, FLAG_NOLIMIT) == RETURNVALUE_NOERROR) {
103104
const auto &newItem = g_game().transformItem(item, item->getID() + 1);
104105
if (newItem && newItem->getID() == ITEM_LETTER_STAMPED && !writer.empty()) {
105106
newItem->setAttribute(ItemAttribute_t::WRITER, writer);

src/map/house/house.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ void Houses::payHouses(RentPeriod_t rentPeriod) const {
849849
if (house->getPayRentWarnings() < 7) {
850850
const int32_t daysLeft = 7 - house->getPayRentWarnings();
851851

852-
std::shared_ptr<Item> letter = Item::CreateItem(ITEM_LETTER_STAMPED);
852+
const std::shared_ptr<Item> &letter = Item::CreateItem(ITEM_LETTER_STAMPED);
853853
std::string period;
854854

855855
switch (rentPeriod) {

0 commit comments

Comments
 (0)