Mercurial > mm7
comparison Player.cpp @ 1382:132a6a0d5cef
Player::AddItem2, Player::CreateItemInInventory2 cleanup
author | Grumpy7 |
---|---|
date | Tue, 16 Jul 2013 00:20:17 +0200 |
parents | 2e5c994f0833 |
children | 0a4254e80036 |
comparison
equal
deleted
inserted
replaced
1375:270134611caf | 1382:132a6a0d5cef |
---|---|
936 return 0; | 936 return 0; |
937 } | 937 } |
938 } | 938 } |
939 | 939 |
940 //----- (00492745) -------------------------------------------------------- | 940 //----- (00492745) -------------------------------------------------------- |
941 int Player::WearItem(unsigned int uItemID) | 941 void Player::WearItem( unsigned int uItemID ) |
942 { | 942 { |
943 int item_body_anch; // edi@6 | 943 int item_body_anch; // edi@6 |
944 int item_indx; | 944 int item_indx; |
945 item_indx = FindFreeInventorySlot(); | 945 item_indx = FindFreeInventorySlot(); |
946 | 946 |
949 pInventoryItems[item_indx].uItemID = uItemID; | 949 pInventoryItems[item_indx].uItemID = uItemID; |
950 item_body_anch = pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; | 950 item_body_anch = pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; |
951 pEquipment.pIndices[item_body_anch] = item_indx + 1; | 951 pEquipment.pIndices[item_body_anch] = item_indx + 1; |
952 pInventoryItems[item_indx].uBodyAnchor = item_body_anch + 1; | 952 pInventoryItems[item_indx].uBodyAnchor = item_body_anch + 1; |
953 } | 953 } |
954 return 0; | |
955 } | 954 } |
956 | 955 |
957 //----- (004927A8) -------------------------------------------------------- | 956 //----- (004927A8) -------------------------------------------------------- |
958 int Player::AddItem(int uSlot, unsigned int uItemID) | 957 int Player::AddItem(int uSlot, unsigned int uItemID) |
959 { | 958 { |
983 } | 982 } |
984 | 983 |
985 //----- (00492826) -------------------------------------------------------- | 984 //----- (00492826) -------------------------------------------------------- |
986 int Player::AddItem2(int uSlot, ItemGen *Src) | 985 int Player::AddItem2(int uSlot, ItemGen *Src) |
987 { | 986 { |
988 unsigned int v3; // ebx@1 | 987 int xStartValue = 0; |
989 unsigned int v4; // esi@3 | |
990 signed int v5; // edi@3 | |
991 unsigned int v7; // [sp-8h] [bp-18h]@9 | |
992 ItemGen *v8; // [sp-4h] [bp-14h]@9 | |
993 Player *thisa; // [sp+Ch] [bp-4h]@1 | |
994 signed int uSlota; // [sp+18h] [bp+8h]@2 | |
995 | |
996 thisa = this; | |
997 v3 = Src->uItemID; | |
998 pItemsTable->SetSpecialBonus(Src); | 988 pItemsTable->SetSpecialBonus(Src); |
989 | |
999 if ( uSlot == -1 ) | 990 if ( uSlot == -1 ) |
1000 { | 991 { |
1001 uSlota = 0; | 992 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) |
1002 while ( true ) | 993 { |
1003 { | 994 for (int xcoord = xStartValue; xcoord < INVETORYSLOTSWIDTH; xcoord++) |
1004 v4 = uSlota; | 995 { |
1005 v5 = 0; | 996 if ( CanFitItem(xcoord, Src->uItemID) ) |
1006 do | |
1007 { | |
1008 if ( CanFitItem(v4, v3) ) | |
1009 { | 997 { |
1010 v8 = Src; | 998 return CreateItemInInventory2(xcoord, Src); |
1011 v7 = v4; | |
1012 return CreateItemInInventory2(v7, v8); | |
1013 } | 999 } |
1014 ++v5; | 1000 } |
1015 v4 += 14; | 1001 xStartValue += INVETORYSLOTSWIDTH; |
1016 } | |
1017 while ( v5 < 14 ); | |
1018 ++uSlota; | |
1019 if ( uSlota < 9 ) | |
1020 continue; | |
1021 break; | |
1022 } | 1002 } |
1023 return 0; | 1003 return 0; |
1024 } | 1004 } |
1025 if ( !CanFitItem(uSlot, v3) ) | 1005 if ( !CanFitItem(uSlot, Src->uItemID) ) |
1026 return 0; | 1006 return 0; |
1027 v8 = Src; | 1007 return CreateItemInInventory2(uSlot, Src); |
1028 v7 = uSlot; | |
1029 return CreateItemInInventory2(v7, v8); | |
1030 } | 1008 } |
1031 | 1009 |
1032 //----- (0049289C) -------------------------------------------------------- | 1010 //----- (0049289C) -------------------------------------------------------- |
1033 int Player::CreateItemInInventory2(unsigned int uSlot, ItemGen *Src) | 1011 int Player::CreateItemInInventory2(unsigned int uSlot, ItemGen *Src) |
1034 { | 1012 { |
1035 signed int v3; // ebx@1 | 1013 signed int freeSlot; // ebx@1 |
1036 ItemGen *v4; // eax@1 | |
1037 int result; // eax@6 | 1014 int result; // eax@6 |
1038 //unsigned int v6; // eax@7 | |
1039 Texture *item_texture; // esi@7 | 1015 Texture *item_texture; // esi@7 |
1040 unsigned int v8; // edx@9 | |
1041 int *pInvPos; // esi@10 | 1016 int *pInvPos; // esi@10 |
1042 unsigned int slot_width; // [sp+4h] [bp-Ch]@7 | 1017 unsigned int slot_width; // [sp+4h] [bp-Ch]@7 |
1043 unsigned int slot_height; // [sp+8h] [bp-8h]@7 | 1018 unsigned int slot_height; // [sp+8h] [bp-8h]@7 |
1044 Player *v12; // [sp+Ch] [bp-4h]@1 | 1019 |
1045 | 1020 |
1046 | 1021 freeSlot = FindFreeInventorySlot(); |
1047 v12 = this; | 1022 if ( freeSlot == -1 ) |
1048 v3 = 0; | |
1049 v4 = this->pInventoryItems; | |
1050 while ( v4->uItemID ) | |
1051 { | |
1052 ++v3; | |
1053 ++v4; | |
1054 if ( v3 >= 126 ) | |
1055 { | |
1056 v3 = -1; | |
1057 break; | |
1058 } | |
1059 } | |
1060 if ( v3 == -1 ) | |
1061 { | 1023 { |
1062 result = 0; | 1024 result = 0; |
1063 } | 1025 } |
1064 else | 1026 else |
1065 { | 1027 { |
1069 if ( !areWeLoadingTexture ) | 1031 if ( !areWeLoadingTexture ) |
1070 { | 1032 { |
1071 item_texture->Release(); | 1033 item_texture->Release(); |
1072 pIcons_LOD->SyncLoadedFilesCount(); | 1034 pIcons_LOD->SyncLoadedFilesCount(); |
1073 } | 1035 } |
1074 if ( slot_height > 0 ) | 1036 |
1037 if ( slot_width > 0 ) | |
1075 { | 1038 { |
1076 pInvPos = &pInventoryIndices[uSlot]; | 1039 pInvPos = &pInventoryIndices[uSlot]; |
1077 do | 1040 for (unsigned int i = 0; i < slot_height; i++) |
1078 { | 1041 { |
1079 if ( slot_width > 0 ) | 1042 memset32(pInvPos, -1 - uSlot, slot_width); |
1080 memset32(pInvPos, -1 - uSlot, slot_width); | 1043 pInvPos += INVETORYSLOTSWIDTH; |
1081 pInvPos +=14; | 1044 } |
1082 --slot_height; | 1045 } |
1083 } | 1046 pInventoryIndices[uSlot] = freeSlot + 1; |
1084 while ( slot_height ); | 1047 memcpy(&pInventoryItems[freeSlot], Src, sizeof(ItemGen)); |
1085 } | 1048 result = freeSlot + 1; |
1086 pInventoryIndices[uSlot] = v3 + 1; | |
1087 memcpy(&pInventoryItems[v3], Src, sizeof(ItemGen)); | |
1088 result = v3 + 1; | |
1089 } | 1049 } |
1090 return result; | 1050 return result; |
1091 } | 1051 } |
1092 // 506128: using guessed type int areWeLoadingTexture; | 1052 // 506128: using guessed type int areWeLoadingTexture; |
1093 | 1053 |