# HG changeset patch # User Grumpy7 # Date 1374010540 -7200 # Node ID 5644aecb5082c725e5899409b88587a04c6e90fc # Parent b51332ab228f4ac26972c8b78f27f951c2e3a0bf Player::AddItem and Player::AddItem2 fixed my bug diff -r b51332ab228f -r 5644aecb5082 Player.cpp --- a/Player.cpp Tue Jul 16 20:51:29 2013 +0200 +++ b/Player.cpp Tue Jul 16 23:35:40 2013 +0200 @@ -940,19 +940,22 @@ int Player::AddItem(int index, unsigned int uItemID) { int xStartValue = 0; + int startOfInnerLoop = 0; if ( index == -1 ) { for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) { - for (int xcoord = xStartValue; xcoord < INVETORYSLOTSWIDTH; xcoord++) - { - if ( CanFitItem(xcoord, uItemID) ) + int innerLoopPos = startOfInnerLoop; + for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) + { + if ( CanFitItem(innerLoopPos, uItemID) ) { - return CreateItemInInventory(xcoord, uItemID); + return CreateItemInInventory(innerLoopPos, uItemID); } - } - xStartValue += INVETORYSLOTSWIDTH; + innerLoopPos++; + } + startOfInnerLoop += INVETORYSLOTSWIDTH; } return 0; } @@ -969,19 +972,22 @@ { int xStartValue = 0; pItemsTable->SetSpecialBonus(Src); + int startOfInnerLoop = 0; if ( index == -1 ) { - for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) - { - for (int xcoord = xStartValue; xcoord < INVETORYSLOTSWIDTH; xcoord++) - { - if ( CanFitItem(xcoord, Src->uItemID) ) + for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) //TODO: change pInventoryMatrix to 2 dimensional array. + { + int innerLoopPos = startOfInnerLoop; + for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) + { + if ( CanFitItem(innerLoopPos, Src->uItemID) ) { - return CreateItemInInventory2(xcoord, Src); + return CreateItemInInventory2(innerLoopPos, Src); } - } - xStartValue += INVETORYSLOTSWIDTH; + innerLoopPos++; + } + startOfInnerLoop += INVETORYSLOTSWIDTH; } return 0; } @@ -1017,7 +1023,7 @@ // 506128: using guessed type int areWeLoadingTexture; //----- (0049298B) -------------------------------------------------------- -void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) +void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) //originally accepted ItemGen* but needed only its uItemID { Texture *item_texture; // esi@1 int *pInvPos; // esi@4