Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
nekiro committed Dec 19, 2024
1 parent 3b94ced commit cba1a45
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,22 +1196,24 @@ ReturnValue Game::internalMoveItem(Cylinder* fromCylinder, Cylinder* toCylinder,
}
}

Item* moveItem = nullptr;

// remove the item
Item* moveItem = item;
int32_t itemIndex = fromCylinder->getThingIndex(item);
Item* updateItem = nullptr;
fromCylinder->removeThing(item, moveCount);

// update item(s)
if (item->isStackable()) {
// lets find out how much we need to move
uint32_t allowedCount = 0;

if (item->equals(toItem)) {
allowedCount = std::min<uint32_t>(ITEM_STACK_SIZE - toItem->getItemCount(), moveCount);
// when item is moved onto another equal item
if (item->equals(toItem) && moveCount != MAX_ITEM_COUNT) {

Check failure on line 1209 in src/game.cpp

View workflow job for this annotation

GitHub Actions / test

‘MAX_ITEM_COUNT’ was not declared in this scope

Check failure on line 1209 in src/game.cpp

View workflow job for this annotation

GitHub Actions / macos-Debug-luajit=off

use of undeclared identifier 'MAX_ITEM_COUNT'
allowedCount =
std::min<uint32_t>(static_cast<uint16_t>(MAX_ITEM_COUNT) - toItem->getItemCount(), moveCount);

Check failure on line 1211 in src/game.cpp

View workflow job for this annotation

GitHub Actions / macos-Debug-luajit=off

use of undeclared identifier 'MAX_ITEM_COUNT'
if (allowedCount > 0) {
fromCylinder->removeThing(item, allowedCount);
toCylinder->updateThing(toItem, toItem->getID(), toItem->getItemCount() + allowedCount);
updateItem = toItem;
moveItem = nullptr;
}
}

Expand All @@ -1222,27 +1224,21 @@ ReturnValue Game::internalMoveItem(Cylinder* fromCylinder, Cylinder* toCylinder,
moveItem = item->clone();
moveItem->setItemCount(newCount);

// source item may get deleted if move count is actually the whole source count, so let's release it if
// needed
if (item->isRemoved()) {
ReleaseItem(item);
item->onRemoved();
}
} else {
// whole source item is moved
moveItem = item;
}
}
} else {
moveItem = item;
}

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

if (itemIndex != -1 && !item->hasParent()) {
fromCylinder->postRemoveNotification(item, toCylinder, itemIndex);
if (itemIndex != -1) {
fromCylinder->postRemoveNotification(item, toCylinder, itemIndex, LINK_OWNER, actorPlayer);

Check failure on line 1241 in src/game.cpp

View workflow job for this annotation

GitHub Actions / test

no matching function for call to ‘Cylinder::postRemoveNotification(Item*&, Cylinder*&, int32_t&, cylinderlink_t, Player*&)’

Check failure on line 1241 in src/game.cpp

View workflow job for this annotation

GitHub Actions / macos-Debug-luajit=off

too many arguments to function call, expected at most 4, have 5
}

if (moveItem) {
Expand Down

0 comments on commit cba1a45

Please sign in to comment.