Mercurial > mm7
changeset 2285:4fd03103be62
sub_4BE571 changed to sub_4BE571_AddItemToSet + cleaned up, dword_F8B1DC changed to dword_F8B1DC_currentShopOption + moved out of mm7_data
author | Grumpy7 |
---|---|
date | Sat, 15 Mar 2014 12:24:20 +0100 |
parents | 40c4065234f8 |
children | 288e0b29a493 |
files | Items.cpp mm7_data.cpp mm7_data.h |
diffstat | 3 files changed, 20 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/Items.cpp Sat Mar 15 01:32:56 2014 +0100 +++ b/Items.cpp Sat Mar 15 12:24:20 2014 +0100 @@ -138,7 +138,8 @@ { 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6}, { 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}}}; -int sub_4BE571(int a1, int *a2, int a3, int a4); +int sub_4BE571_AddItemToSet(int valueToAdd, int *outPutSet, int elemsAlreadyPresent, int elemsNeeded); +int dword_F8B1DC_currentShopOption; // weak ItemGen *ptr_50C9A4_ItemToEnchant; @@ -2098,7 +2099,7 @@ int v37=0; // [sp+24h] [bp-4h]@1* int i=0; - dword_F8B1DC = 0; + dword_F8B1DC_currentShopOption = 0; switch (_this) { @@ -2124,7 +2125,7 @@ default: continue; } - v37 = sub_4BE571(v34, v35, v37, 5); + v37 = sub_4BE571_AddItemToSet(v34, v35, v37, 5); } } break; @@ -2149,7 +2150,7 @@ default: continue; } - v37 = sub_4BE571(v33, v35, v37, 5); + v37 = sub_4BE571_AddItemToSet(v33, v35, v37, 5); } } } @@ -2213,8 +2214,8 @@ default: v30 = pGlobalTXT_LocalizationStrings[127]; //"No Text!" } - pShopOptions[dword_F8B1DC] = const_cast<char *>(v30); - ++dword_F8B1DC; + pShopOptions[dword_F8B1DC_currentShopOption] = const_cast<char *>(v30); + ++dword_F8B1DC_currentShopOption; CreateButtonInColumn(i+1, v29); } pDialogueWindow->_41D08F_set_keyboard_control_group(i, 1, 0, 2); @@ -2222,31 +2223,22 @@ } //----- (004BE571) -------------------------------------------------------- -int sub_4BE571(int a1, int *a2, int a3, int a4) - { - int result; // eax@1 +int sub_4BE571_AddItemToSet(int valueToAdd, int *outPutSet, int elemsAlreadyPresent, int elemsNeeded) +{ int i; // esi@3 - result = a3; - if ( a3 < a4 ) - { - for ( i = 0; i < a3; ++i ) - { - if ( a1 == a2[i] ) - break; - } - if ( i == a3 ) - { - a2[a3] = a1; - result = a3 + 1; - } - return result; - } - else - { - return a4; - } + if ( elemsAlreadyPresent < elemsNeeded ) + { + for ( i = 0; i < elemsAlreadyPresent; ++i ) + { + if ( valueToAdd == outPutSet[i] ) + return elemsAlreadyPresent; + } + outPutSet[elemsAlreadyPresent] = valueToAdd; + return elemsAlreadyPresent + 1; } + return elemsNeeded; +} //----- (0043C91D) -------------------------------------------------------- int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder) {
--- a/mm7_data.cpp Sat Mar 15 01:32:56 2014 +0100 +++ b/mm7_data.cpp Sat Mar 15 12:24:20 2014 +0100 @@ -1119,7 +1119,6 @@ int gold_transaction_amount; // F8B1B4 std::array<char *, 4> pShopOptions; int dword_F8B1D8; // weak -int dword_F8B1DC; // weak int dword_F8B1E0; // weak int dword_F8B1E4; // weak const char *current_npc_text; // idb
--- a/mm7_data.h Sat Mar 15 01:32:56 2014 +0100 +++ b/mm7_data.h Sat Mar 15 12:24:20 2014 +0100 @@ -767,7 +767,6 @@ extern int gold_transaction_amount; // F8B1B4 extern std::array<char *, 4> pShopOptions; extern int dword_F8B1D8; // weak -extern int dword_F8B1DC; // weak extern int dword_F8B1E0; // weak extern int dword_F8B1E4; // weak extern const char *current_npc_text; // 0xF8B1E8