Skip to content

Commit

Permalink
Update game.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
nekiro committed Jun 30, 2024
1 parent a67e713 commit 3173d55
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,26 +1214,34 @@ ReturnValue Game::internalMoveItem(Cylinder* fromCylinder, Cylinder* toCylinder,
}

int32_t newCount = m - n;
if (newCount == item->getItemCount()) {
if (!updateItem && newCount == item->getItemCount()) {
// full item is moved (move count is the same as item count)
} else if (newCount > 0) {
moveItem = item->clone();
moveItem->setItemCount(newCount);
} else {
moveItem = nullptr;
}

if (item->isRemoved()) {
item->onRemoved();
}
}

// add item
toCylinder->addThing(index, moveItem);
if (moveItem) {
toCylinder->addThing(index, moveItem);
}

if (itemIndex != -1) {
fromCylinder->postRemoveNotification(item, toCylinder, itemIndex);
}

int32_t moveItemIndex = toCylinder->getThingIndex(moveItem);
if (moveItemIndex != -1) {
toCylinder->postAddNotification(moveItem, fromCylinder, moveItemIndex);
if (moveItem) {
int32_t moveItemIndex = toCylinder->getThingIndex(moveItem);
if (moveItemIndex != -1) {
toCylinder->postAddNotification(moveItem, fromCylinder, moveItemIndex);
}
}

if (updateItem) {
Expand Down

0 comments on commit 3173d55

Please sign in to comment.