MCPcopy Create free account
hub / github.com/TurningWheel/Barony / quickStackItems

Function quickStackItems

src/interface/playerinventory.cpp:11904–11937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11902}
11903
11904void quickStackItems(int player)
11905{
11906 for ( node_t* node = stats[player]->inventory.first; node != NULL; node = node->next )
11907 {
11908 Item* itemToStack = (Item*)node->element;
11909 if ( itemToStack && itemToStack->shouldItemStack(player) )
11910 {
11911 for ( node_t* node = stats[player]->inventory.first; node != NULL; node = node->next )
11912 {
11913 Item* item2 = (Item*)node->element;
11914 // if items are the same, check to see if they should stack
11915 if ( item2 && item2 != itemToStack && !itemCompare(itemToStack, item2, false) )
11916 {
11917 itemToStack->count += item2->count;
11918 if ( multiplayer == CLIENT && itemIsEquipped(itemToStack, player) )
11919 {
11920 // if incrementing qty and holding item, then send "equip" for server to update their count of your held item.
11921 clientSendEquipUpdateToServer(EQUIP_ITEM_SLOT_WEAPON, EQUIP_ITEM_SUCCESS_UPDATE_QTY, player,
11922 itemToStack->type, itemToStack->status, itemToStack->beatitude, itemToStack->count, itemToStack->appearance, itemToStack->identified);
11923 }
11924 if ( item2->node )
11925 {
11926 list_RemoveNode(item2->node);
11927 }
11928 else
11929 {
11930 free(item2);
11931 item2 = nullptr;
11932 }
11933 }
11934 }
11935 }
11936 }
11937}
11938
11939void autosortInventory(int player, bool sortPaperDoll)
11940{

Callers

nothing calls this directly

Calls 5

itemCompareFunction · 0.85
itemIsEquippedFunction · 0.85
list_RemoveNodeFunction · 0.85
shouldItemStackMethod · 0.80

Tested by

no test coverage detected