MCPcopy Create free account
hub / github.com/cuberite/cuberite / AddToBar

Method AddToBar

src/Inventory.cpp:471–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469
470#if 0
471bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ )
472{
473 // Fill already present stacks
474 if( a_Mode < 2 )
475 {
476 int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize();
477 for(int i = 0; i < a_Size; i++)
478 {
479 if( m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage )
480 {
481 int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount;
482 if( NumFree >= a_Item.m_ItemCount )
483 {
484
485 //printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree );
486 m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount;
487 a_Item.m_ItemCount = 0;
488 a_bChangedSlots[i + a_Offset] = true;
489 break;
490 }
491 else
492 {
493 //printf("2. Adding %i items\n", NumFree );
494 m_Slots[i + a_Offset].m_ItemCount += (char)NumFree;
495 a_Item.m_ItemCount -= (char)NumFree;
496 a_bChangedSlots[i + a_Offset] = true;
497 }
498 }
499 }
500 }
501
502 if( a_Mode > 0 )
503 {
504 // If we got more left, find first empty slot
505 for(int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++)
506 {
507 if( m_Slots[i + a_Offset].m_ItemType == -1 )
508 {
509 m_Slots[i + a_Offset] = a_Item;
510 a_Item.m_ItemCount = 0;
511 a_bChangedSlots[i + a_Offset] = true;
512 }
513 }
514 }
515
516 return true;
517}
518#endif
519
520

Callers

nothing calls this directly

Calls 1

GetMaxStackSizeMethod · 0.45

Tested by

no test coverage detected