uint32_t count = item->getItemCount();
if (count - 1 == 0)
{
uint32_t playerCount = player->getItemTypeCount(item->getID(), -1);
playerCount--;
if (playerCount > 0)
{
int32_t removeCount = std::max<int32_t>(1, std::min<int32_t>(100, playerCount));
bool test = player->removeItemOfType(item->getID(), removeCount, -1, true);
if (test)
{
g_game.transformItem(item, item->getID(), removeCount);
std::ostringstream ss;
ss << "Your " << item->getPluralName() << " were charged.";
player->sendTextMessage(MESSAGE_STATUS_SMALL, ss.str());
break;
}
}
}