/** * Combine items in the pack, confirming no blank objects or gold */ void combine_pack(void) { struct object *obj1, *obj2, *prev; bool display_message = false; /* Combine the pack (backwards) */ obj1 = gear_last_item(); while (obj1) { assert(obj1->kind); assert(!tval_is_money(obj1)); prev = obj1->prev; /* Scan the items above that item */ for (obj2 = player->gear; obj2 && obj2 != obj1; obj2 = obj2->next) { assert(obj2->kind); /* Can we drop "obj1" onto "obj2"? */ if (object_similar(obj2, obj1, OSTACK_PACK)) { display_message = true; object_absorb(obj2->known, obj1->known); obj1->known = NULL; object_absorb(obj2, obj1); break; } else if (inven_can_stack_partial(obj2, obj1, OSTACK_PACK)) { /* Setting this to true spams the combine message. */ display_message = false; object_absorb_partial(obj2->known, obj1->known); object_absorb_partial(obj2, obj1); break; } } obj1 = prev; } calc_inventory(player->upkeep, player->gear, player->body); /* Redraw gear */ event_signal(EVENT_INVENTORY); event_signal(EVENT_EQUIPMENT); /* Message */ if (display_message) { msg("You combine some items in your pack."); /* Stop "repeat last command" from working. */ cmd_disable_repeat(); } }
/** * Combine items in the pack, confirming no blank objects or gold */ void combine_pack(void) { struct object *obj1, *obj2; bool display_message = FALSE; bool redraw = FALSE; /* Combine the pack (backwards) */ for (obj1 = gear_last_item(); obj1; obj1 = obj1->prev) { assert(obj1->kind); assert(!tval_is_money(obj1)); /* Scan the items above that item */ for (obj2 = player->gear; obj2 && obj2 != obj1; obj2 = obj2->next) { assert(obj2->kind); /* Can we drop "obj1" onto "obj2"? */ if (object_similar(obj2, obj1, OSTACK_PACK)) { display_message = TRUE; redraw = TRUE; object_absorb(obj2, obj1); } else if (inven_can_stack_partial(obj2, obj1, OSTACK_PACK)) { /* Setting this to TRUE spams the combine message. */ display_message = FALSE; redraw = TRUE; object_absorb_partial(obj2, obj1); break; } } } calc_inventory(player->upkeep, player->gear, player->body); /* Redraw stuff */ if (redraw) { player->upkeep->redraw |= (PR_INVEN | PR_EQUIP); player->upkeep->update |= (PU_INVEN); } /* Message */ if (display_message) { msg("You combine some items in your pack."); /* Stop "repeat last command" from working. */ cmd_disable_repeat(); } }