engine/actions/source/PickupAction.cpp
// Merge into the inventory, if possible.  If this is not possible,
// add the item to the inventory.
Merge into the inventory, if possible.  If this is not possible,
add the item to the inventory.
Merge into the inventory if possible . If this is not possible add the item to the inventory .
bool PickupAction::merge_or_add_into_inventory(CreaturePtr creature, ItemPtr item)
{
  if (creature)
  {
    IInventoryPtr creature_inv = creature->get_inventory();
    if (!creature_inv->merge(item))
    {
      creature_inv->add(item);
    }
    Game& game = Game::instance();
    CreaturePtr player = game.get_current_player();
    CurrentCreatureAbilities cca;
    bool player_blind = !cca.can_see(player);
    IMessageManager& manager = MM::instance(MessageTransmit::FOV, creature, creature && !player_blind && creature->get_is_player());
    string pick_up_message;
    if (!player_blind || (player_blind && creature->get_is_player()))
    {
      pick_up_message = TextMessages::get_item_pick_up_message(player_blind, creature, item);
    }
    if (!pick_up_message.empty())
    {
      manager.add_new_message(pick_up_message);
      manager.send();
    }
    return true;
  }
  return false;
}
bool PickupAction :: merge_or_add_into_inventory ( CreaturePtr creature , ItemPtr item ) { if ( creature ) { IInventoryPtr creature_inv = creature -> get_inventory ( ) ; if ( ! creature_inv -> merge ( item ) ) { creature_inv -> add ( item ) ; } Game & game = Game :: instance ( ) ; CreaturePtr player = game . get_current_player ( ) ; CurrentCreatureAbilities cca ; bool player_blind = ! cca . can_see ( player ) ; IMessageManager & manager = MM :: instance ( MessageTransmit :: FOV , creature , creature && ! player_blind && creature -> get_is_player ( ) ) ; string pick_up_message ; if ( ! player_blind || ( player_blind && creature -> get_is_player ( ) ) ) { pick_up_message = TextMessages :: get_item_pick_up_message ( player_blind , creature , item ) ; } if ( ! pick_up_message . empty ( ) ) { manager . add_new_message ( pick_up_message ) ; manager . send ( ) ; } return true ; } return false ; }
Merge into the inventory, if possible.
Merge into the inventory if possible .
// Add to the end of the inventory // Only broadcast if it's the player, or the monster's in range. // Display a message if necessary