comparison Player.cpp @ 1385:5644aecb5082

Player::AddItem and Player::AddItem2 fixed my bug
author Grumpy7
date Tue, 16 Jul 2013 23:35:40 +0200
parents b51332ab228f
children 72191abc8116
comparison
equal deleted inserted replaced
1384:b51332ab228f 1385:5644aecb5082
938 938
939 //----- (004927A8) -------------------------------------------------------- 939 //----- (004927A8) --------------------------------------------------------
940 int Player::AddItem(int index, unsigned int uItemID) 940 int Player::AddItem(int index, unsigned int uItemID)
941 { 941 {
942 int xStartValue = 0; 942 int xStartValue = 0;
943 int startOfInnerLoop = 0;
943 944
944 if ( index == -1 ) 945 if ( index == -1 )
945 { 946 {
946 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) 947 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++)
947 { 948 {
948 for (int xcoord = xStartValue; xcoord < INVETORYSLOTSWIDTH; xcoord++) 949 int innerLoopPos = startOfInnerLoop;
949 { 950 for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++)
950 if ( CanFitItem(xcoord, uItemID) ) 951 {
952 if ( CanFitItem(innerLoopPos, uItemID) )
951 { 953 {
952 return CreateItemInInventory(xcoord, uItemID); 954 return CreateItemInInventory(innerLoopPos, uItemID);
953 } 955 }
954 } 956 innerLoopPos++;
955 xStartValue += INVETORYSLOTSWIDTH; 957 }
958 startOfInnerLoop += INVETORYSLOTSWIDTH;
956 } 959 }
957 return 0; 960 return 0;
958 } 961 }
959 if ( !CanFitItem(index, uItemID) ) 962 if ( !CanFitItem(index, uItemID) )
960 { 963 {
967 //----- (00492826) -------------------------------------------------------- 970 //----- (00492826) --------------------------------------------------------
968 int Player::AddItem2(int index, ItemGen *Src) 971 int Player::AddItem2(int index, ItemGen *Src)
969 { 972 {
970 int xStartValue = 0; 973 int xStartValue = 0;
971 pItemsTable->SetSpecialBonus(Src); 974 pItemsTable->SetSpecialBonus(Src);
975 int startOfInnerLoop = 0;
972 976
973 if ( index == -1 ) 977 if ( index == -1 )
974 { 978 {
975 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) 979 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) //TODO: change pInventoryMatrix to 2 dimensional array.
976 { 980 {
977 for (int xcoord = xStartValue; xcoord < INVETORYSLOTSWIDTH; xcoord++) 981 int innerLoopPos = startOfInnerLoop;
978 { 982 for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++)
979 if ( CanFitItem(xcoord, Src->uItemID) ) 983 {
984 if ( CanFitItem(innerLoopPos, Src->uItemID) )
980 { 985 {
981 return CreateItemInInventory2(xcoord, Src); 986 return CreateItemInInventory2(innerLoopPos, Src);
982 } 987 }
983 } 988 innerLoopPos++;
984 xStartValue += INVETORYSLOTSWIDTH; 989 }
990 startOfInnerLoop += INVETORYSLOTSWIDTH;
985 } 991 }
986 return 0; 992 return 0;
987 } 993 }
988 if ( !CanFitItem(index, Src->uItemID) ) 994 if ( !CanFitItem(index, Src->uItemID) )
989 return 0; 995 return 0;
1015 return result; 1021 return result;
1016 } 1022 }
1017 // 506128: using guessed type int areWeLoadingTexture; 1023 // 506128: using guessed type int areWeLoadingTexture;
1018 1024
1019 //----- (0049298B) -------------------------------------------------------- 1025 //----- (0049298B) --------------------------------------------------------
1020 void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) 1026 void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) //originally accepted ItemGen* but needed only its uItemID
1021 { 1027 {
1022 Texture *item_texture; // esi@1 1028 Texture *item_texture; // esi@1
1023 int *pInvPos; // esi@4 1029 int *pInvPos; // esi@4
1024 unsigned int slot_width; // [sp+Ch] [bp-4h]@1 1030 unsigned int slot_width; // [sp+Ch] [bp-4h]@1
1025 unsigned int slot_height; // [sp+18h] [bp+8h]@1 1031 unsigned int slot_height; // [sp+18h] [bp+8h]@1